문제

Actually, I am new to THREE.js. I was trying to make a game in which I am using a spaceship as a mesh, I created a chase camera for my model but I want to shift in position about which it is looking at. I am using following code :

var relativeCameraOffset = new THREE.Vector3(0,200,-500);

var cameraOffset = relativeCameraOffset.applyMatrix4( spaceship1.matrixWorld );

camera.position.x = cameraOffset.x;
camera.position.y = cameraOffset.y;
camera.position.z = cameraOffset.z;
camera.lookAt(spaceship1.position);

I want to place my camera in front of spaceship and it must look forward when I move, it should not look at spaceship.

도움이 되었습니까?

해결책

You can just add the camera as child of the spaceship.

camera.position.set( 0, 200, -500 );
spaceship1.add( camera );
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top