forked from mns/mini-skamja
37 lines
1.0 KiB
Vue
37 lines
1.0 KiB
Vue
<script setup lang="ts">
|
|
import { Vector3 } from 'three';
|
|
const props = defineProps(['model', 'position', 'target'])
|
|
|
|
const scene = props.model
|
|
scene.receiveShadow = true
|
|
scene.castShadow = true
|
|
|
|
const target = ref(props.target ? new Vector3(...props.target) : null)
|
|
|
|
const model = ref()
|
|
const { onLoop } = useRenderLoop()
|
|
|
|
let stepbase = 0.005
|
|
const axis = [
|
|
{ axis: 'x', func: 'translateX', },
|
|
{ axis: 'y', func: 'translateY', },
|
|
{ axis: 'z', func: 'translateZ', },
|
|
]
|
|
type vectorType = 'x' | 'y' | 'z';
|
|
|
|
watch(props, () => {
|
|
if (props.target) {
|
|
target.value = new Vector3(...props.target)
|
|
}
|
|
}, { deep: true })
|
|
</script>
|
|
<template>
|
|
<TresGroup ref="model" :position="(props.position || [0, 0, 0])">
|
|
<template v-if="scene.children[0].type == 'Group'">
|
|
<TresObject3D v-for="item in scene.children[0].children" v-bind="item" />
|
|
</template>
|
|
<template v-else>
|
|
<TresObject3D v-for="item in (scene.children)" v-bind="item" />
|
|
</template>
|
|
</TresGroup>
|
|
</template> |