|
@@ -1,9 +1,9 @@
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { sRGBEncoding, BasicShadowMap, NoToneMapping } from 'three'
|
|
import { sRGBEncoding, BasicShadowMap, NoToneMapping } from 'three'
|
|
import { reactive, ref } from 'vue'
|
|
import { reactive, ref } from 'vue'
|
|
-
|
|
|
|
-import { OrbitControls, TransformControls } from '@tresjs/cientos'
|
|
|
|
-import { useRenderLoop } from '..'
|
|
|
|
|
|
+import { TresCanvas } from '/@/components/TresCanvas'
|
|
|
|
+import { OrbitControls } from '@tresjs/cientos'
|
|
|
|
+import { useRenderLoop } from '../composables/useRenderLoop'
|
|
/* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */
|
|
/* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */
|
|
|
|
|
|
const state = reactive({
|
|
const state = reactive({
|
|
@@ -21,28 +21,26 @@ const sphereRef = ref()
|
|
const { onLoop } = useRenderLoop()
|
|
const { onLoop } = useRenderLoop()
|
|
|
|
|
|
onLoop(({ elapsed }) => {
|
|
onLoop(({ elapsed }) => {
|
|
- sphereRef.value.position.y += Math.sin(elapsed * 0.01) * 0.1
|
|
|
|
|
|
+ if (!sphereRef.value) return
|
|
|
|
+ sphereRef.value.position.y += Math.sin(elapsed) * 0.01
|
|
})
|
|
})
|
|
</script>
|
|
</script>
|
|
<template>
|
|
<template>
|
|
<TresCanvas v-bind="state">
|
|
<TresCanvas v-bind="state">
|
|
<TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[-8, 3, -3]" />
|
|
<TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[-8, 3, -3]" />
|
|
<OrbitControls make-default />
|
|
<OrbitControls make-default />
|
|
- <TresScene>
|
|
|
|
- <TresAmbientLight :intensity="0.5" />
|
|
|
|
- <TransformControls mode="scale" :object="sphereRef" />
|
|
|
|
|
|
+ <TresAmbientLight :intensity="0.5" />
|
|
|
|
|
|
- <TresMesh ref="sphereRef" :position="[0, 4, 0]" cast-shadow>
|
|
|
|
- <TresSphereGeometry />
|
|
|
|
- <TresMeshToonMaterial color="#FBB03B" />
|
|
|
|
- <!-- <TresMeshToonMaterial color="#FBB03B" /> -->
|
|
|
|
- </TresMesh>
|
|
|
|
- <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
|
|
|
|
- <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>
|
|
|
|
- <TresPlaneGeometry :args="[10, 10, 10, 10]" />
|
|
|
|
- <TresMeshToonMaterial />
|
|
|
|
- </TresMesh>
|
|
|
|
- <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow />
|
|
|
|
- </TresScene>
|
|
|
|
|
|
+ <TresMesh ref="sphereRef" :position="[0, 4, 0]" cast-shadow>
|
|
|
|
+ <TresSphereGeometry />
|
|
|
|
+ <TresMeshToonMaterial color="cyan" />
|
|
|
|
+ <!-- <TresMeshToonMaterial color="#FBB03B" /> -->
|
|
|
|
+ </TresMesh>
|
|
|
|
+ <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
|
|
|
|
+ <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>
|
|
|
|
+ <TresPlaneGeometry :args="[10, 10, 10, 10]" />
|
|
|
|
+ <TresMeshToonMaterial />
|
|
|
|
+ </TresMesh>
|
|
|
|
+ <TresDirectionalLight :position="[0, 2, 4]" :intensity="1" cast-shadow />
|
|
</TresCanvas>
|
|
</TresCanvas>
|
|
</template>
|
|
</template>
|