Skip to content

Commit 37ab904

Browse files
committed
chore: tests
1 parent 3490c4a commit 37ab904

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

playground/src/pages/primitives.vue

+37-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
Group,
1313
SphereGeometry,
1414
} from 'three'
15-
import { TresCanvas } from '@tresjs/core'
15+
import { TresCanvas, useRenderLoop } from '@tresjs/core'
1616
import { OrbitControls } from '@tresjs/cientos'
1717
import { TresLeches, useControls } from '@tresjs/leches'
1818
import '@tresjs/leches/styles'
@@ -29,7 +29,7 @@ const canvas = ref()
2929
const meshRef = ref()
3030
3131
const { knot } = useControls({
32-
knot: false,
32+
knot: true,
3333
})
3434
3535
const { isVisible } = useControls({
@@ -71,6 +71,28 @@ firstGroup.add(torusKnot)
7171
7272
const secondGroup = new Group()
7373
secondGroup.add(sphere)
74+
75+
const primitiveRef = ref()
76+
77+
useRenderLoop().onLoop(() => {
78+
if (primitiveRef.value) {
79+
primitiveRef.value.rotation.x += 0.01
80+
primitiveRef.value.rotation.y += 0.01
81+
}
82+
})
83+
84+
watchEffect(() => {
85+
console.log('primitiveRef.value', primitiveRef.value)
86+
})
87+
88+
const reactivePrimitiveRef = ref(new Mesh(
89+
new TorusKnotGeometry(1, 0.5, 100, 16),
90+
new MeshToonMaterial({
91+
color: 'orange',
92+
}),
93+
))
94+
95+
const modelArray = ref([torus, torusKnot, sphere])
7496
</script>
7597

7698
<template>
@@ -86,13 +108,23 @@ secondGroup.add(sphere)
86108
:position="[7, 7, 7]"
87109
/>
88110
<OrbitControls />
111+
<!-- <primitive
112+
:object="reactivePrimitiveRef"
113+
/> -->
114+
<!-- <primitive
115+
v-for="(model, index) of modelArray"
116+
:key="index"
117+
:object="model"
118+
:position="[index * 2, index * 2, 0]"
119+
/> -->
89120
<primitive
90121
v-if="isVisible"
91-
:object="knot ? firstGroup : sphere"
122+
ref="primitiveRef"
123+
:object="knot ? torusKnot : torus"
92124
/>
93-
<Suspense>
125+
<!-- <Suspense>
94126
<DynamicModel />
95-
</Suspense>
127+
</Suspense> -->
96128
<TresAxesHelper :args="[1]" />
97129
<TresDirectionalLight
98130
:position="[0, 2, 4]"

0 commit comments

Comments
 (0)