Skip to content

feat: adapt code and playgrounds to latest changes on ecosystem #207

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

Merged
merged 7 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 10 additions & 9 deletions docs/.vitepress/theme/components/BlenderCube.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<script setup lang="ts">
import { useGLTF } from '@tresjs/cientos'
import type { TresObject } from '@tresjs/core'
import { computed, shallowRef } from 'vue'

const { nodes }
= await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb', { draco: true })
const model = nodes.Cube
const { nodes } = useGLTF(
'https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb',
{ draco: true },
)

model.traverse((child) => {
if (child.isMesh) {
child.castShadow = true
}
})
const modelRef = shallowRef<TresObject | null>(null)

const model = computed(() => nodes.value?.BlenderCube)
</script>

<template>
<primitive :object="model" />
<primitive v-if="model" ref="modelRef" :object="model" />
</template>
16 changes: 13 additions & 3 deletions docs/.vitepress/theme/components/Ducky.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<script setup lang="ts">
import { useGLTF } from '@tresjs/cientos'
import { Mesh } from 'three'
import { watch } from 'vue'

const { scene: model }
= await useGLTF('https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/duck/model.gltf', { draco: true })
const { state }
= useGLTF('https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/duck/model.gltf', { draco: true })

watch(state, (model) => {
model.scene.traverse((child) => {
if (child instanceof Mesh) {
child.castShadow = true
}
})
})
</script>

<template>
<primitive :object="model" />
<primitive v-if="state" :object="state.scene" />
</template>
8 changes: 2 additions & 6 deletions docs/.vitepress/theme/components/pmdrs/DepthOfFieldDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ const effectParams = ref({
:position="[-5, 0.5, -10]"
:scale="0.5"
>
<Suspense>
<Ducky />
</Suspense>
<Ducky />
</TresGroup>
<TresGroup
:position="[0, 0.5, 0]"
:scale="0.5"
>
<Suspense>
<BlenderCube />
</Suspense>
<BlenderCube />
</TresGroup>
<TresAmbientLight />
<TresDirectionalLight
Expand Down
12 changes: 10 additions & 2 deletions docs/.vitepress/theme/components/pmdrs/DotScreenDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { angle, scale, blendFunction } = useControls({
},
})

const { scene } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/suzanne/suzanne.glb', { draco: true })
const { state } = useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/suzanne/suzanne.glb', { draco: true })
</script>

<template>
Expand All @@ -44,7 +44,15 @@ const { scene } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets
/>
<OrbitControls />

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

<ContactShadows
:opacity="1"
Expand Down
19 changes: 15 additions & 4 deletions docs/.vitepress/theme/components/pmdrs/KuwaharaDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const glComposer = {
multisampling: 4,
}

const { scene: scenePlantJar } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/kuwahara-effect/plant-jar/plant-jar.glb', { draco: true })
const { scene: sceneWatermelon } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/kuwahara-effect/watermelon/watermelon_fruit.glb', { draco: true })
const { state: scenePlantJar } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/kuwahara-effect/plant-jar/plant-jar.glb', { draco: true })
const { state: sceneWatermelon } = await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/kuwahara-effect/watermelon/watermelon_fruit.glb', { draco: true })

const effectProps = reactive({
blendFunction: BlendFunction.NORMAL,
Expand Down Expand Up @@ -51,8 +51,19 @@ watch(enabled, () => {

<TresDirectionalLight />

<primitive :position-x="-3" :position-y="-3.5" :scale="5" :object="scenePlantJar" />
<primitive :position-x="4" :scale="20" :object="sceneWatermelon" />
<primitive
v-if="scenePlantJar"
:position-x="-3"
:position-y="-3.5"
:scale="5"
:object="scenePlantJar.scene"
/>
<primitive
v-if="sceneWatermelon"
:position-x="4"
:scale="20"
:object="sceneWatermelon.scene"
/>

<ContactShadows
:opacity=".25"
Expand Down
4 changes: 1 addition & 3 deletions docs/.vitepress/theme/components/pmdrs/VignetteDemo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const { effectComposer } = useRouteDisposal()
<TresCanvas v-bind="gl">
<TresPerspectiveCamera :position="[3, 3, 3]" />
<OrbitControls />
<Suspense>
<BlenderCube />
</Suspense>
<BlenderCube />
<EffectComposerPmndrs ref="effectComposer">
<DepthOfFieldPmndrs :focus-distance="0" :focal-length="0.02" :bokeh-scale="2" />
<VignettePmndrs :darkness="0.9" :offset="0.3" />
Expand Down
1 change: 1 addition & 0 deletions docs/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
// biome-ignore lint: disable
export {}

/* prettier-ignore */
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"preview": "vitepress preview"
},
"dependencies": {
"@tresjs/cientos": "^4.1.0",
"@tresjs/core": "^4.3.2",
"@tresjs/cientos": "5.0.0-next.2",
"@tresjs/core": "5.0.0-next.3",
"@tresjs/post-processing": "workspace:^",
"gsap": "^3.12.7"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"docs:preview": "vitepress preview"
},
"peerDependencies": {
"@tresjs/core": ">=4.0",
"@tresjs/core": ">=5.0",
"three": ">=0.169",
"vue": ">=3.4"
},
Expand Down
23 changes: 0 additions & 23 deletions playground/public/nuxt-stones/package.json

This file was deleted.

19 changes: 10 additions & 9 deletions playground/src/components/BlenderCube.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<script setup lang="ts">
import { useGLTF } from '@tresjs/cientos'
import type { TresObject } from '@tresjs/core'
import { computed, shallowRef } from 'vue'

const { nodes }
= await useGLTF('https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb', { draco: true })
const model = nodes.Cube
const { nodes } = useGLTF(
'https://raw.githubusercontent.com/Tresjs/assets/main/models/gltf/blender-cube.glb',
{ draco: true },
)

model.traverse((child) => {
if (child.isMesh) {
child.castShadow = true
}
})
const modelRef = shallowRef<TresObject | null>(null)

const model = computed(() => nodes.value?.BlenderCube)
</script>

<template>
<primitive :object="model" />
<primitive v-if="model" ref="modelRef" :object="model" />
</template>
18 changes: 11 additions & 7 deletions playground/src/components/Ducky.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<script setup lang="ts">
import { useGLTF } from '@tresjs/cientos'
import { Mesh } from 'three'
import { watch } from 'vue'

const { scene: model }
= await useGLTF('https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/duck/model.gltf', { draco: true })
const { state }
= useGLTF('https://vazxmixjsiawhamofees.supabase.co/storage/v1/object/public/models/duck/model.gltf', { draco: true })

model.traverse((child) => {
if (child.isMesh) {
child.castShadow = true
}
watch(state, (model) => {
model.scene.traverse((child) => {
if (child instanceof Mesh) {
child.castShadow = true
}
})
})
</script>

<template>
<primitive :object="model" />
<primitive v-if="state" :object="state.scene" />
</template>
6 changes: 1 addition & 5 deletions playground/src/pages/postprocessing/on-demand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ function onRender() {
}

const canvas = ref<InstanceType<typeof TresCanvas>>()

function onControlChange() {
canvas.value?.context?.invalidate()
}
</script>

<template>
Expand All @@ -30,7 +26,7 @@ function onControlChange() {
:position="[5, 5, 5]"
:look-at="[0, 0, 0]"
/>
<OrbitControls @change="onControlChange" />
<OrbitControls />
<TresMesh
:position="[-3.5, 1, 0]"
>
Expand Down
25 changes: 13 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/core/pmndrs/DepthOfFieldPmndrs.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import type { BlendFunction } from 'postprocessing'
import { useTresContext } from '@tresjs/core'
import { useTres } from '@tresjs/core'
import { DepthOfFieldEffect } from 'postprocessing'
import { makePropWatchers } from '../../util/prop'
import { useEffectPmndrs } from './composables/useEffectPmndrs'
Expand Down Expand Up @@ -44,7 +44,7 @@ export interface DepthOfFieldPmndrsProps {

<script lang="ts" setup>
const props = defineProps<DepthOfFieldPmndrsProps>()
const { camera } = useTresContext()
const { camera } = useTres()

const { pass, effect } = useEffectPmndrs(() => new DepthOfFieldEffect(camera.value, props), props)
defineExpose({ pass, effect })
Expand Down
Loading