文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
加载多个模型并单独设置模型位置
<template>
<div class="check-box">
<input type="checkbox" @change="change($event, 'position')" checked /> Set
position
<input type="checkbox" @change="change($event, 'rotation')" checked /> Set
rotation
<input type="checkbox" @change="change($event, 'scale')" checked /> Set
scale
</div>
<vue3dLoader
:filePath="filePath"
:position="position"
:rotation="rotation"
:scale="scale"
:cameraPosition="{ x: -0, y: 0, z: -500 }"
:height="350"
/>
</template>
<script setup lang="ts">
import { vue3dLoader } from "vue-3d-loader";
import { ref } from "vue";
const filePath = ref();
filePath.value = [
"/models/fbx/Samba Dancing.fbx",
"/models/collada/pump/pump.dae",
];
const position = ref();
position.value = [
{ x: 0, y: 0, z: 0 },
{ x: 100, y: 100, z: 100 },
];
const rotation = ref();
rotation.value = [
{ x: 0, y: 0, z: 0 },
{ x: 10, y: 1, z: 1 },
];
const scale = ref();
scale.value = [
{ x: 0.4, y: 0.4, z: 0.4 },
{ x: 0.8, y: 0.8, z: 0.8 },
];
function change(event: any, type: string) {
const value = event.target.checked;
switch (type) {
case "position":
value
? (position.value = [
{ x: 0, y: 0, z: 0 },
{ x: 100, y: 100, z: 100 },
])
: (position.value = []);
break;
case "rotation":
value
? (rotation.value = [
{ x: 0, y: 0, z: 0 },
{ x: 10, y: 1, z: 1 },
])
: (rotation.value = []);
break;
case "scale":
value
? (scale.value = [
{ x: 0.4, y: 0.4, z: 0.4 },
{ x: 0.8, y: 0.8, z: 0.8 },
])
: (scale.value = []);
break;
}
}
</script>
<style>
.check-box {
position: absolute;
top: 5px;
left: 5px;
background-color: rgb(13, 6, 103);
padding: 2px 4px;
z-index: 100;
font-size: 12px;
border-radius: 4px;
color: #fff;
}
</style>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论