【发布时间】:2021-04-15 04:43:48
【问题描述】:
我的游戏中有一架直升机,我希望摄像机始终注视直升机的后部,但我做不到。当直升机旋转时,我无法让相机随直升机旋转。这是直升机和相机旋转的图像。This is what I want even the helicopter rotates. But this is what happened\\
相机初始化:const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
function cameraUpdate(camera) {
camera.position.x = movingObject.x + 20
camera.position.y = movingObject.y + 20;
camera.position.z = movingObject.z;
camera.lookAt(movingObject.position);}
这个函数在我的渲染循环中调用。 MovingObject 是我的直升机。直升机的旋转代码在我的 inputController 函数中,该函数在渲染循环中调用。旋转sn-p如下。
if (input.rotClk === true) {
moveableObj.rotatation.y += -0.05;
}
我尝试 camera.rotation.y += -0.05 并没有成功。
【问题讨论】:
标签: javascript three.js