Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fish-eye #182

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default defineConfig({
text: 'Pmndrs',
items: [
{ text: 'Barrel blur', link: '/guide/pmndrs/barrel-blur' },
{ text: 'Fish Eye', link: '/guide/pmndrs/fish-eye' },
{ text: 'Bloom', link: '/guide/pmndrs/bloom' },
{ text: 'Chromatic Aberration', link: '/guide/pmndrs/chromatic-aberration' },
{ text: 'Linocut', link: '/guide/pmndrs/linocut' },
Expand Down
3 changes: 1 addition & 2 deletions docs/.vitepress/theme/components/DocsDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<template>
<ClientOnly>
<div
class="relative"
style="aspect-ratio: 16/9; height: auto; margin: 2rem 0; border-radius: 8px; overflow:hidden;"
class="relative aspect-16/9 my-8 rounded-lg overflow-hidden shadow-lg"
>
<Suspense>
<slot></slot>
Expand Down
14 changes: 14 additions & 0 deletions docs/.vitepress/theme/components/DocsDemoGUI.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
</script>

<template>
<ClientOnly>
<div
class="relative my-8 flex flex-col rounded-lg overflow-hidden shadow-lg"
>
<Suspense>
<slot></slot>
</Suspense>
</div>
</ClientOnly>
</template>
57 changes: 29 additions & 28 deletions docs/.vitepress/theme/components/pmdrs/BarrelBlurDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,36 @@ const { amount, offsetX, offsetY, blendFunction } = useControls({
</script>

<template>
<TresLeches style="left: initial;right:10px; top:10px;" />

<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls auto-rotate />
<div class="aspect-16/9">
<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls auto-rotate />

<Suspense>
<Environment preset="shangai" />
</Suspense>
<Suspense>
<Environment preset="shangai" />
</Suspense>

<RoundedBox :args="[2, 2, 2, 2, 0.25]">
<TresMeshPhysicalMaterial
color="white"
:metalness=".9"
:roughness=".5"
:clearcoat="1.0"
:clearcoatRoughness="0.1"
/>
</RoundedBox>
<RoundedBox :args="[2, 2, 2, 2, 0.25]">
<TresMeshPhysicalMaterial
color="white"
:metalness=".9"
:roughness=".5"
:clearcoat="1.0"
:clearcoatRoughness="0.1"
/>
</RoundedBox>

<Suspense>
<EffectComposerPmndrs>
<BarrelBlurPmndrs :amount="amount.value" :offset="[offsetX.value, offsetY.value]" :blendFunction="Number(blendFunction.value)" />
</EffectComposerPmndrs>
</Suspense>
</TresCanvas>
<Suspense>
<EffectComposerPmndrs>
<BarrelBlurPmndrs :amount="amount" :offset="[offsetX, offsetY]" :blendFunction="Number(blendFunction)" />
</EffectComposerPmndrs>
</Suspense>
</TresCanvas>
</div>
<TresLeches :float="false" />
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { ChromaticAberrationPmndrs, EffectComposerPmndrs } from '@tresjs/post-pr

import '@tresjs/leches/styles'

// TODO: Adapt watchEffect to useControls for visibility of modulationOffset

const gl = {
clearColor: '#ffffff',
toneMapping: NoToneMapping,
Expand All @@ -24,57 +26,58 @@ const { offsetX, offsetY, radialModulation, modulationOffset } = useControls({
})

watchEffect(() => {
modulationOffset.value.visible = radialModulation.value.value
// modulationOffset.value.visible = radialModulation.value.value
})
</script>

<template>
<TresLeches style="left: initial;right:10px; top:10px;" />

<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls auto-rotate />

<template
v-for="i in 4"
:key="i"
<div class="aspect-16/9">
<TresCanvas
v-bind="gl"
>
<TresMesh
:position="[((i - 1) - (4 - 1) / 2) * 1.5, 0, 0]"
<TresPerspectiveCamera
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls auto-rotate />

<template
v-for="i in 4"
:key="i"
>
<TresBoxGeometry
:width="4"
:height="4"
:depth="4"
/>
<TresMeshStandardMaterial color="#1C1C1E" />
</TresMesh>
</template>
<TresMesh
:position="[((i - 1) - (4 - 1) / 2) * 1.5, 0, 0]"
>
<TresBoxGeometry
:width="4"
:height="4"
:depth="4"
/>
<TresMeshStandardMaterial color="#1C1C1E" />
</TresMesh>
</template>

<TresAmbientLight color="#ffffff" />
<TresAmbientLight color="#ffffff" />

<TresDirectionalLight />
<TresDirectionalLight />

<ContactShadows
:opacity="1"
:position-y="-.5"
:scale="20"
:blur=".85"
/>
<ContactShadows
:opacity="1"
:position-y="-.5"
:scale="20"
:blur=".85"
/>

<Suspense>
<EffectComposerPmndrs>
<ChromaticAberrationPmndrs ref="chromaticAberrationRef" :offset="new Vector2(offsetX.value, offsetY.value)" :radial-modulation="radialModulation.value" :modulation-offset="modulationOffset.value" />
</EffectComposerPmndrs>
</Suspense>
<Suspense>
<EffectComposerPmndrs>
<ChromaticAberrationPmndrs ref="chromaticAberrationRef" :offset="new Vector2(offsetX, offsetY)" :radial-modulation="radialModulation" :modulation-offset="modulationOffset" />
</EffectComposerPmndrs>
</Suspense>

<Suspense>
<Environment :intensity="2" :blur="0" preset="snow" />
</Suspense>
</TresCanvas>
<Suspense>
<Environment :intensity="2" :blur="0" preset="snow" />
</Suspense>
</TresCanvas>
</div>
<TresLeches :float="false" />
</template>
49 changes: 25 additions & 24 deletions docs/.vitepress/theme/components/pmdrs/ColorAverageDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const { blendFunction, opacity } = useControls({

function onUpdateTimeline(e) {
const progress = 1 - e.progress()
opacity.value.value = progress
opacity.value = progress
}

watch(meshRef, () => {
Expand All @@ -63,30 +63,31 @@ onUnmounted(() => {
</script>

<template>
<TresLeches style="left: initial;right:10px; top:10px;" />
<div class="aspect-16/9">
<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[5, 2, 15]"
:look-at="[0, 0, 0]"
/>
<OrbitControls auto-rotate />

<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[5, 2, 15]"
:look-at="[0, 0, 0]"
/>
<OrbitControls auto-rotate />
<TresMesh ref="meshRef" :position="[0, 3.5, 0]">
<TresBoxGeometry :args="[2, 2, 2]" />
<TresMeshPhysicalMaterial color="#8B0000" :roughness=".25" />
</TresMesh>

<TresMesh ref="meshRef" :position="[0, 3.5, 0]">
<TresBoxGeometry :args="[2, 2, 2]" />
<TresMeshPhysicalMaterial color="#8B0000" :roughness=".25" />
</TresMesh>
<Suspense>
<Environment background preset="shangai" />
</Suspense>

<Suspense>
<Environment background preset="shangai" />
</Suspense>

<Suspense>
<EffectComposerPmndrs>
<ColorAveragePmndrs :blendFunction="Number(blendFunction.value)" :opacity="opacity.value" />
</EffectComposerPmndrs>
</Suspense>
</TresCanvas>
<Suspense>
<EffectComposerPmndrs>
<ColorAveragePmndrs :blendFunction="Number(blendFunction)" :opacity="opacity" />
</EffectComposerPmndrs>
</Suspense>
</TresCanvas>
</div>
<TresLeches :float="false" />
</template>
58 changes: 30 additions & 28 deletions docs/.vitepress/theme/components/pmdrs/DotScreenDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,34 @@ const { scene } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets
</script>

<template>
<TresLeches style="left: initial;right:10px; top:10px;" />

<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[0, 1, 7.5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls />

<primitive :scale="2" :rotation-x="Math.PI / -5" :rotation-y="Math.PI" :position-y=".25" :position-z="0.5" :object="scene" />

<ContactShadows
:opacity="1"
:position-y="-1.5"
/>

<Suspense>
<Environment preset="modern" />
</Suspense>

<Suspense>
<EffectComposerPmndrs>
<DotScreenPmndrs :blendFunction="Number(blendFunction.value)" :angle="angle.value" :scale="scale.value" />
</EffectComposerPmndrs>
</Suspense>
</TresCanvas>
<div class="aspect-16/9">
<TresCanvas
v-bind="gl"
>
<TresPerspectiveCamera
:position="[0, 1, 7.5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls />

<primitive :scale="2" :rotation-x="Math.PI / -5" :rotation-y="Math.PI" :position-y=".25" :position-z="0.5" :object="scene" />

<ContactShadows
:opacity="1"
:position-y="-1.5"
/>

<Suspense>
<Environment preset="modern" />
</Suspense>

<Suspense>
<EffectComposerPmndrs>
<DotScreenPmndrs :blendFunction="Number(blendFunction)" :angle="angle" :scale="scale" />
</EffectComposerPmndrs>
</Suspense>
</TresCanvas>
</div>

<TresLeches :float="false" />
</template>
Loading
Loading