|
@@ -1,9 +1,9 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { sRGBEncoding, BasicShadowMap, NoToneMapping, Vector3 } from 'three'
|
|
|
+import { sRGBEncoding, BasicShadowMap, NoToneMapping, Vector3 } from 'three'
|
|
|
import { reactive, ref } from 'vue'
|
|
|
import { TresCanvas } from '/@/components/TresCanvas'
|
|
|
-import { OrbitControls, TransformControls } from '@tresjs/cientos'
|
|
|
-import { useRenderLoop } from '/@/'
|
|
|
+import { OrbitControls, TransformControls } from '@tresjs/cientos'
|
|
|
+import { useRenderLoop, useTexture } from '/@/'
|
|
|
/* import { OrbitControls, GLTFModel } from '@tresjs/cientos' */
|
|
|
|
|
|
const state = reactive({
|
|
@@ -16,18 +16,25 @@ const state = reactive({
|
|
|
toneMapping: NoToneMapping,
|
|
|
})
|
|
|
|
|
|
+const { alphaMap } = await useTexture({
|
|
|
+ alphaMap: 'https://assets.codepen.io/4698468/2k_earth_clouds.jpg',
|
|
|
+})
|
|
|
+
|
|
|
const sphereRef = ref()
|
|
|
+const cloudRef = ref()
|
|
|
|
|
|
const { onLoop } = useRenderLoop()
|
|
|
|
|
|
onLoop(({ elapsed }) => {
|
|
|
if (!sphereRef.value) return
|
|
|
sphereRef.value.position.y += Math.sin(elapsed) * 0.01
|
|
|
+ cloudRef.value.position.y += Math.sin(elapsed) * 0.01
|
|
|
})
|
|
|
</script>
|
|
|
<template>
|
|
|
<TresCanvas v-bind="state">
|
|
|
- <TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000" :look-at="[0,0,0]" />
|
|
|
+ <TresPerspectiveCamera :position="[5, 5, 5]" :fov="45" :near="0.1" :far="1000"
|
|
|
+ :look-at="[0,0,0]" />
|
|
|
<OrbitControls />
|
|
|
<TresAmbientLight :intensity="0.5" />
|
|
|
|
|
@@ -36,6 +43,11 @@ onLoop(({ elapsed }) => {
|
|
|
<TresMeshToonMaterial color="cyan" />
|
|
|
<!-- <TresMeshToonMaterial color="#FBB03B" /> -->
|
|
|
</TresMesh>
|
|
|
+ <TresMesh ref="cloudRef" :position="[0, 4, 0]" cast-shadow>
|
|
|
+ <TresSphereGeometry :args="[2.01,32,32]"/>
|
|
|
+ <TresMeshStandardMaterial :transparent="true" :alpha-map="alphaMap" />
|
|
|
+ </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]" />
|