我想制作一个360度的特定产品查看器,这样我就有了一个3d对象,我想在适当的方向上以每次点击45度的角度围绕对象旋转我的相机,但我遇到了问题。
相机:
this.camera.rotation.y = 15 / 180 * Math.PI;
this.camera.position.x = 0;
this.camera.position.y = 500;
this.camera.position.z = 1200;
this.camera.lookAt(0, 0, 0);
按钮点击方法:
onRightClicked() {
const newCamPosition = (this.camera.position.x + degToRad(45)) * 10;
this.camera.position.x = newCamPosition;
this.camera.position.y = 500;
this.camera.position.z = 1200;
}
onLeftClicked() {
const newCamPosition = (this.camera.position.x - 150);
this.camera.position.x = newCamPosition;
this.camera.position.y = 500;
this.camera.position.z = 1200;
}
一切都正常,但我的相机不会每次点击45度。我认为问题出在相机上。旋转。但是我是一个初学者,我不知道发生了什么。
.applyAxisAngle()
:可能会出现类似情况
var axis = new THREE.Vector3(0, 1, 0);
var step = Math.PI * 0.25;
onRightClicked() {
this.camera.position.applyAxisAngle(axis, step);
}
onLeftClicked() {
this.camera.position.applyAxisAngle(axis, -step);
}