How to make camera follow GLTF object?

Hello,
I got a question about camera, how to make it follow the GLTF object, that is moving through TWEEN addon?

		var loader = new THREE.GLTFLoader();
		loader.load('Car/car1.gltf', function (gltf) {
		car1_object = gltf.scene;
		scene.add(car1_object);
		car_animation(); //HERE IS WHOLE TWEEN CODE
		});

and then I have something like this:

function animate(time)
{
requestAnimationFrame(animate);
TWEEN.update(time);

if(car1_object)
{
camera.lookAt(car1_object);
}
}

I got no error in console, but my whole screen is black, how can it be repaired? :blush:

If you look at the docs, the .lookAt() method takes either a Vector3 or three separate x, y, z parameters. Instead, you’re trying to pass car1_object, which seems to be the scene from the .gltf file.

Try camera.lookAt(car1_object.position);

1 Like

Thanks Man!