我的游戏中有一架直升机,我想让摄像机总是看着直升机的后部,但我做不到。当直升机旋转的时候,我不能让相机和直升机一起旋转。这是直升机和相机旋转的图像。This is what I want even the helicopter rotates. But this is what happened\
摄像机初始化:常量摄像机=新的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函数中,该函数在渲染循环中调用。旋转代码片段如下所示。
if (input.rotClk === true) {
moveableObj.rotatation.y += -0.05;
}我尝试使用camera.rotation.y += -0.05,但它不起作用。
发布于 2021-01-10 04:33:45
你可以让你的直升机成为相机的子级,然后让你的输入控制器控制相机,它看起来就像是相机在跟随着直升机(实际上直升机正在跟随着相机,只是向前和向下平移),所以,在你的初始化函数中:
camera.add(movingObject);
movingObject.position.set(0,-10,-100);
scene.add(camera)此答案可能包含更多信息How to put an object in front of camera in THREE.JS?
https://stackoverflow.com/questions/65646553
复制相似问题