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

fix: reimplement ContactShadows for v4 #449

Merged
merged 47 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d7eb9fe
chore(deps): update deps to latest
alvarosabu Jun 6, 2024
37e6948
chore: on demand invalidation composable with prop change detection
alvarosabu Jun 6, 2024
e9f23e1
feat: on-demand orbit-controls
alvarosabu Jun 6, 2024
c17a7ab
feat: on-demand camera controls
alvarosabu Jun 6, 2024
f7ce6ff
feat: invalidate also on autoRotate
alvarosabu Jun 6, 2024
ff4e850
feat: on-demand map controls and refactor
alvarosabu Jun 6, 2024
385c1a1
feat: on-demand transform controls
alvarosabu Jun 6, 2024
928db6b
feat: on-demand keyboard controls
alvarosabu Jun 6, 2024
2c02b8b
feat: on-demand keybaord controls
alvarosabu Jun 6, 2024
e4c817e
chore: added demo suffix to control pages to avoid confusions
alvarosabu Jun 6, 2024
e6125ac
feat: on-demand pointer lock controls
alvarosabu Jun 6, 2024
543a29a
feat: on-demand scroll controls
alvarosabu Jun 6, 2024
c159dc2
feat: on-demand levioso
alvarosabu Jun 6, 2024
83503c5
feat: correct orbit controls auto rotate invalidation
alvarosabu Jun 6, 2024
232b869
feat: on-demand text3d
alvarosabu Jun 15, 2024
4369e3c
feat: on-demand mouse-parallax
alvarosabu Jun 15, 2024
75d563a
feat: on-demand fbo and size watcher refactor
alvarosabu Jun 15, 2024
7ddfdc3
chore(playground): refactor to use useLoop and sub components
alvarosabu Jun 15, 2024
aef0bf4
chore: remove unused import for lint fix
alvarosabu Jun 15, 2024
3bb4625
chore(playground): refactor lensflare demo to use useLoop
alvarosabu Jun 15, 2024
19db54b
feat: on-demand sampler
alvarosabu Jun 15, 2024
eb8b3a4
feat: on-demand invaldiation on reflector prop change
alvarosabu Jun 15, 2024
593f4a0
chore: added render activity graph and try to make on-demand work on …
alvarosabu Jun 17, 2024
a3d7f47
chore: renamed positional audio demo
alvarosabu Jun 17, 2024
fb4bddb
chore: on-demand smoke
alvarosabu Jun 17, 2024
fb665eb
feat: on-demand precipitation
alvarosabu Jun 17, 2024
74ee39f
feat: on-dermand stars
alvarosabu Jun 17, 2024
adc0ea8
feat: on-demand Environment
alvarosabu Jun 17, 2024
5f0fe94
feat: on-demand sky
alvarosabu Jun 17, 2024
806587c
feat: on-demand Ocean component
alvarosabu Jun 17, 2024
ee5f40d
chore: testing on-demand on fit
alvarosabu Jun 17, 2024
14b3bc3
feat: on-demand Wobble Material
alvarosabu Jun 17, 2024
4b2ce7c
feat: on-demand invalidation holographic material
alvarosabu Jun 21, 2024
0895163
feat: on-demand reflection material
alvarosabu Jun 21, 2024
262e0aa
feat: on-demand custom shader material
alvarosabu Jun 21, 2024
008897c
chore: rename bakeshadows demo
alvarosabu Jun 21, 2024
775addb
Merge branch 'v4' into feature/423-enable-on-demand-render-mode-usage
alvarosabu Jun 21, 2024
605d5f9
chore: misc route
alvarosabu Jun 29, 2024
c4998d9
Merge branch 'v4' into feature/423-enable-on-demand-render-mode-usage
alvarosabu Jul 14, 2024
91289e5
Merge branch 'v4' into feature/423-enable-on-demand-render-mode-usage
alvarosabu Jul 14, 2024
5e441bc
chore: ci, update action setup
alvarosabu Jul 14, 2024
8e0b18f
Merge branch 'v4' into feature/423-enable-on-demand-render-mode-usage
alvarosabu Jul 14, 2024
c414cfb
chore: update Tres core
andretchen0 Jul 17, 2024
f12ec26
fix: reimplement ContactShadows for v4 core
andretchen0 Jul 15, 2024
85218b5
Merge branch 'v4' into fix/contact-shadows
andretchen0 Jul 17, 2024
2f92ddd
docs: change link name
andretchen0 Jul 19, 2024
3f4b873
fix(ContactShadows): add invalidate to updates
andretchen0 Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
75 changes: 0 additions & 75 deletions docs/.vitepress/theme/components/ContactShadowDemo.vue

This file was deleted.

15 changes: 15 additions & 0 deletions docs/.vitepress/theme/components/ContactShadowsDemo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { ContactShadows, Levioso, TorusKnot } from '@tresjs/cientos'
</script>

<template>
<TresCanvas clear-color="white">
<Levioso :speed="2" :range="[0, 0.7]" :rotation-factor="9">
<TorusKnot :scale="0.45">
<TresMeshNormalMaterial />
</TorusKnot>
</Levioso>
<ContactShadows :position-y="-1" color="#335" :scale="20" />
</TresCanvas>
</template>
2 changes: 1 addition & 1 deletion docs/component-list/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
57 changes: 20 additions & 37 deletions docs/guide/staging/contact-shadows.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
# Contact Shadows
# ContactShadows

<DocsDemo>
<ContactShadowDemo />
<ContactShadowsDemo />
</DocsDemo>

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.
`<ContactShadows />` 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}
<template>
<TresCanvas v-bind="gl">
<TresPerspectiveCamera :position="[11, 11, 11]" />
<OrbitControls />
<Box ref="boxRef" :args="[0.4, 0.4, 0.4]" :position="[0, 1, 0]">
<TresMeshNormalMaterial />
</Box>
<Icosahedron ref="icoRef" :args="[0.3]" :position="[1, 1, 1]">
<TresMeshNormalMaterial />
</Icosahedron>
<ContactShadows :blur="0.5" :resolution="512" :opacity="0.2" />
<Plane :args="[10, 10, 10]" :position="[0, -0.02, 0]">
<TresMeshBasicMaterial :color="'#ffffff'" />
</Plane>
<TresAmbientLight :intensity="1" />
</TresCanvas>
</template>
```
<<< @/.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` |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Loading