文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
控制相机垂直 / 水平旋转
Only enable horizontal Only enable vertical set horizontal rotation value range set vertical rotation value range
<template>
<div class="controls">
<div class="buttons">
<!-- 开启水平旋转 -->
<button @click="setHorizontal()">
Only {{ horizontalCtrl ? "disable" : "enable" }} horizontal
</button>
<!-- 开启垂直旋转 -->
<button @click="setVertical()">
Only {{ verticalCtrl ? "disable" : "enable" }} vertical
</button>
<!-- 设置水平旋转最大/小角度 -->
<button @click="setHorizontal('range')">
set horizontal rotation value range
</button>
<!-- 设置垂直旋转最大/小角度 -->
<button @click="setVertical('range')">
set vertical rotation value range
</button>
</div>
<vue3dLoader
v-if="!refersh"
filePath="/models/collada/stormtrooper/stormtrooper.dae"
:scale="{ x: 0.1, y: 0.1, z: 0.1 }"
:verticalCtrl="verticalCtrl"
:horizontalCtrl="horizontalCtrl"
/>
</div>
</template>
<script lang="ts" setup>
import { nextTick, ref } from "vue";
const verticalCtrl: any = ref(false);
const horizontalCtrl: any = ref(false);
const refersh = ref(false);
function setVertical(type?: string) {
horizontalCtrl.value = false;
if (type === "range") {
// set vertical angle range
verticalCtrl.value = { min: 0, max: 1 };
} else {
verticalCtrl.value = true;
// horizontalCtrl.value = { min: 0, max: Math.PI };
}
refersh3d();
}
function setHorizontal(type?: string) {
verticalCtrl.value = false;
if (type === "range") {
// set horizontal angle range
horizontalCtrl.value = { min: 1, max: 2 };
} else {
horizontalCtrl.value = true;
// verticalCtrl.value = { min: -Math.PI, max: Math.PI };
}
refersh3d();
}
function refersh3d() {
refersh.value = true;
nextTick(() => {
refersh.value = false;
});
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论