0
votes

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.

1

1 Answers

0
votes

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

camera.position.set( 0, 200, -500 );
spaceship1.add( camera );