diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 49afa85a..bd03f28e 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -145,7 +145,7 @@ export default defineConfig({ { text: 'Sky', link: '/guide/staging/sky' }, { text: 'Stars', link: '/guide/staging/stars' }, { text: 'Smoke', link: '/guide/staging/smoke' }, - { text: 'Contact Shadows', link: '/guide/staging/contact-shadows' }, + { text: 'ContactShadows', link: '/guide/staging/contact-shadows' }, { text: 'Precipitation', link: '/guide/staging/precipitation' }, { text: 'Sparkles', link: '/guide/staging/sparkles' }, { text: 'Ocean', link: '/guide/staging/ocean' }, diff --git a/docs/.vitepress/theme/components/ContactShadowDemo.vue b/docs/.vitepress/theme/components/ContactShadowDemo.vue deleted file mode 100644 index 94812173..00000000 --- a/docs/.vitepress/theme/components/ContactShadowDemo.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/docs/.vitepress/theme/components/ContactShadowsDemo.vue b/docs/.vitepress/theme/components/ContactShadowsDemo.vue new file mode 100644 index 00000000..840f6655 --- /dev/null +++ b/docs/.vitepress/theme/components/ContactShadowsDemo.vue @@ -0,0 +1,15 @@ + + + diff --git a/docs/component-list/components.ts b/docs/component-list/components.ts index b989fd42..ebc3cc8b 100644 --- a/docs/component-list/components.ts +++ b/docs/component-list/components.ts @@ -93,7 +93,7 @@ export default [ { text: 'Sky', link: '/guide/staging/sky' }, { text: 'Stars', link: '/guide/staging/stars' }, { text: 'Smoke', link: '/guide/staging/smoke' }, - { text: 'Contact Shadows', link: '/guide/staging/contact-shadows' }, + { text: 'ContactShadows', link: '/guide/staging/contact-shadows' }, { text: 'Precipitation', link: '/guide/staging/precipitation' }, { text: 'Sparkles', link: '/guide/staging/sparkles' }, { text: 'Ocean', link: '/guide/staging/ocean' }, diff --git a/docs/guide/staging/contact-shadows.md b/docs/guide/staging/contact-shadows.md index 97ccdb35..d6b7e506 100644 --- a/docs/guide/staging/contact-shadows.md +++ b/docs/guide/staging/contact-shadows.md @@ -1,45 +1,28 @@ -# Contact Shadows +# ContactShadows - + -A contact shadow implementation is a technique used in 3D graphics to create shadows that appear where objects meet or "contact" each other. This is different from traditional shadowing techniques, which often only create shadows based on the position of a light source relative to an object. - -This component is used to create and manage contact shadows in a 3D scene. It is based on the original code by [@mrdoob](https://twitter.com/mrdoob) and the implementation in [pmndrs drei](https://github.com/pmndrs/drei/blob/master/src/core/ContactShadows.tsx#L113) but adapted for Vue Composition API. +`` is a "fake", non-lighting-based shadow component. It displays shadows on a single plane. The component is based on the [THREE.js contact shadows example](https://threejs.org/examples/webgl_shadow_contact.html) by [@mrdoob](https://twitter.com/mrdoob). ## Usage -```vue{11} - -``` +<<< @/.vitepress/theme/components/ContactShadowsDemo.vue + +## Props -| Prop | Description | Default | -| ------------ | ------------------------------------------------------------------------------ | --------- | -| `opacity` | The opacity of the shadows. | 1 | -| `width` | The width of the shadows. | 1 | -| `height` | The height of the shadows. | 1 | -| `blur` | The blur of the shadows. | 1 | -| `far` | How far the OrthographicCamera should be to capture the shadows. | 10 | -| `smooth` | Whether the shadows should be smooth or not. | true | -| `resolution` | The resolution of the shadows. | 512 | -| `frames` | The number of frames to render the shadows. | Infinity | -| `scale` | The scale of the shadows. Can be a number or an array of two numbers `[x, y]`. | 10 | -| `color` | The color of the shadows. | '#000000' | -| `depthWrite` | Whether the shadows should write to the depth buffer or not. | false | +| Prop | Description | Default | +| ------------ | ------------------------------------------------------------------------------ | ----------- | +| `opacity` | The opacity of the shadows. | `1` | +| `blur` | The blur of the shadows. | `1` | +| `color` | The color of the shadows. | `'#000000'` | +| `tint` | If provided, the color of the "core" of the shadows. "Added" to `color`. | `undefined` | +| `scale` | The scale of the shadows/shadow plane. Can be a number or an array of two numbers `[x, y]`. | 10 | +| `width` | The width of the shadow plane. | `1` | +| `height` | The height of the shadow plane. | `1` | +| `far` | The distance of the orthographic shadow camera extends above the shadow plane. | `10` | +| `smooth` | Whether the shadows should be smoothed to reduce artifacts. | `true` | +| `resolution` | The resolution of the shadow textures. | `512` | +| `frames` | For performance, optionally stop updating shadows after `frames` frames. | `Math.POSITIVE_INFINITY` | +| `depthWrite` | Whether the shadows should write to the depth buffer or not. | `false` | diff --git a/package.json b/package.json index 7c33243a..cff8f689 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "prepare": "node .husky/install.mjs" }, "peerDependencies": { - "@tresjs/core": ">=3.2", + "@tresjs/core": ">=4.2.1", "three": ">=0.133", "vue": ">=3.3" }, diff --git a/playground/src/pages/staging/ContactShadowsDemo.vue b/playground/src/pages/staging/ContactShadowsDemo.vue index d8278770..f55c9466 100644 --- a/playground/src/pages/staging/ContactShadowsDemo.vue +++ b/playground/src/pages/staging/ContactShadowsDemo.vue @@ -1,13 +1,13 @@ diff --git a/src/core/staging/ContactShadows.vue b/src/core/staging/ContactShadows.vue index 7b4495e1..6dc71ea4 100644 --- a/src/core/staging/ContactShadows.vue +++ b/src/core/staging/ContactShadows.vue @@ -1,32 +1,33 @@