bx-865-apps #1
|
@ -1,9 +1,9 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { CameraControls, FBXModel, PositionalAudio, useGLTF, useProgress } from '@tresjs/cientos'
|
import { CameraControls, FBXModel, PositionalAudio, useGLTF, useProgress } from '@tresjs/cientos'
|
||||||
import { TresCanvas } from '@tresjs/core';
|
import { TresCanvas, useRenderLoop } from '@tresjs/core';
|
||||||
import { Vector3 } from 'three';
|
import { Vector3 } from 'three';
|
||||||
import { onMounted, onUnmounted, reactive } from 'vue';
|
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
||||||
|
|
||||||
import modelUrl from '../../assets/promo/models/sea_fbx/source/Stronghold.fbx'
|
import modelUrl from '../../assets/promo/models/sea_fbx/source/Stronghold.fbx'
|
||||||
import duckUrl from '../../assets/promo/models/rubber_duck (1)/scene.gltf'
|
import duckUrl from '../../assets/promo/models/rubber_duck (1)/scene.gltf'
|
||||||
|
@ -43,10 +43,22 @@ onUnmounted(() => {
|
||||||
positionalAudioRef?.value?.dispose()
|
positionalAudioRef?.value?.dispose()
|
||||||
})
|
})
|
||||||
const ducks: any[] = []
|
const ducks: any[] = []
|
||||||
|
const ducksRef: any[] = []
|
||||||
for (let index = 0; index < 4; index++) {
|
for (let index = 0; index < 4; index++) {
|
||||||
const { scene } = await useGLTF(duckUrl)
|
const { scene } = await useGLTF(duckUrl)
|
||||||
ducks.push(scene)
|
ducks.push(scene)
|
||||||
|
ducksRef.push(ref())
|
||||||
}
|
}
|
||||||
|
const { onLoop } = useRenderLoop()
|
||||||
|
|
||||||
|
onLoop(() => {
|
||||||
|
for (let index = 0; index < ducksRef.length; index++) {
|
||||||
|
const element = ducksRef[index];
|
||||||
|
if (element.value) {
|
||||||
|
element.value[0].rotation.y += 0.01
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div :class="[{ 'invisible': !!hasFinishLoading }, 'loader']">
|
<div :class="[{ 'invisible': !!hasFinishLoading }, 'loader']">
|
||||||
|
@ -68,10 +80,12 @@ for (let index = 0; index < 4; index++) {
|
||||||
<TresMeshBasicMaterial color="red" />
|
<TresMeshBasicMaterial color="red" />
|
||||||
</TresMesh>
|
</TresMesh>
|
||||||
<template v-for="i in 4">
|
<template v-for="i in 4">
|
||||||
<TresMesh :position-x="[1, 3].includes(i) ? -300 : 300" :position-z="100 * i"
|
<Suspense>
|
||||||
@click="() => console.log('click on duck')">
|
<TresMesh :position-x="[1, 3].includes(i) ? -300 : 300" :position-z="100 * i"
|
||||||
<primitive :object="ducks[i - 1]" :scale="40"></primitive>
|
@click="() => console.log('click on duck')" :ref="ducksRef[i]" cast-shadow>
|
||||||
</TresMesh>
|
<primitive :object="ducks[i - 1]" :scale="40"></primitive>
|
||||||
|
</TresMesh>
|
||||||
|
</Suspense>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<TresDirectionalLight :position="lightPosition" :intensity="15" cast-shadow />
|
<TresDirectionalLight :position="lightPosition" :intensity="15" cast-shadow />
|
||||||
|
|
Loading…
Reference in New Issue