diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 7a51ab2b..5ef16e7e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -37,6 +37,7 @@ export default defineConfig({ { text: 'useAnimations', link: '/guide/abstractions/use-animations' }, { text: 'MouseParallax', link: '/guide/abstractions/mouse-parallax' }, { text: 'Lensflare', link: '/guide/abstractions/lensflare' }, + { text: 'Reflector', link: '/guide/abstractions/reflector' }, { text: 'GlobalAudio', link: '/guide/abstractions/global-audio' }, { text: 'Fbo', link: '/guide/abstractions/fbo' }, { text: 'useFBO', link: '/guide/abstractions/use-fbo' }, diff --git a/docs/.vitepress/theme/components/ReflectorDemo.vue b/docs/.vitepress/theme/components/ReflectorDemo.vue new file mode 100644 index 00000000..8d4a1d9d --- /dev/null +++ b/docs/.vitepress/theme/components/ReflectorDemo.vue @@ -0,0 +1,36 @@ + + + diff --git a/docs/guide/abstractions/reflector.md b/docs/guide/abstractions/reflector.md new file mode 100644 index 00000000..84636cff --- /dev/null +++ b/docs/guide/abstractions/reflector.md @@ -0,0 +1,123 @@ +# Reflector + + + + + +The `cientos` package provides an abstraction of the [Reflector class](https://github.com/mrdoob/three.js/blob/dev/examples/jsm/objects/Reflector.js), which creates a Mesh showing a real-time reflection of your scene. This Mesh extends from `Mesh` so all the default props can be passed as well: + +## Usage + +<<< @/.vitepress/theme/components/ReflectorDemo.vue{6,26-32} + +## Props + +| Prop | Description | Default | +| :---------------- | :--------------------------------------------------- | ------------------------- | +| **color** | The base color that's combine with the mirror effect | '#333' | +| **textureWidth** | the width of the texture to render on the mirror | 512 | +| **textureHeight** | the height of the texture to render on the mirror | 512 | +| **clipBias** | to use the clipBias property | 0 | +| **multisample** | how many samplers will be render | 4 | +| **shader** | The texture of the smoke. | Reflector.ReflectorShader | + +::: warning +All the props except the `color`, are not reactive +::: + +## Custom mirror effect + +For more complex effect you can provide your own shaders, you could do this creating an object and pass the uniforms, vertexShaders or fragmentShaders: + +```vue{2,4-6,15} + + + diff --git a/playground/src/router/routes/abstractions.ts b/playground/src/router/routes/abstractions.ts index 5783ab10..c4822614 100644 --- a/playground/src/router/routes/abstractions.ts +++ b/playground/src/router/routes/abstractions.ts @@ -19,6 +19,11 @@ export const abstractionsRoutes = [ name: 'Lensflare', component: () => import('../../pages/abstractions/LensflareDemo.vue'), }, + { + path: '/abstractions/reflector-mesh', + name: 'ReflectorMeshDemo', + component: () => import('../../pages/abstractions/ReflectorMeshDemo.vue'), + }, { path: '/abstractions/global-audio', name: 'GlobalAudio', diff --git a/src/core/abstractions/Reflector.vue b/src/core/abstractions/Reflector.vue new file mode 100644 index 00000000..8a1c05b6 --- /dev/null +++ b/src/core/abstractions/Reflector.vue @@ -0,0 +1,97 @@ + + + diff --git a/src/core/abstractions/index.ts b/src/core/abstractions/index.ts index a00d958b..2cc2f435 100644 --- a/src/core/abstractions/index.ts +++ b/src/core/abstractions/index.ts @@ -1,6 +1,7 @@ import Text3D from './Text3D.vue' import { useAnimations } from './useAnimations' import Levioso from './Levioso.vue' +import Reflector from './Reflector.vue' import MouseParallax from './MouseParallax.vue' import { GlobalAudio } from './GlobalAudio' import Lensflare from './Lensflare/component.vue' @@ -13,6 +14,7 @@ export { useAnimations, MouseParallax, Levioso, + Reflector, Lensflare, GlobalAudio, Fbo,