Animate Camera Target

#1

I was looking around and cant find if its possible to animate the cameras target?

currently I am doing

var animation = new BABYLON.Animation("cameraSwoop",	"position", 30,
				BABYLON.Animation.ANIMATIONTYPE_VECTOR3)
var keyFrames = []
keyFrames.push({
					frame: 0,
					value: camera.position.clone()
				})
for(var i=1; i<=path.length; i++){
				var ap = path[i-1]
				keyFrames.push({
					frame: step*i,
					value: ap
				})
			}
animation.setKeys(keyFrames)
camera.animations = [animation]
animation = scene.beginAnimation(camera, 0, step*path.length, false, 1)

and use a secondary observer to set the target, only problem is it makes a nasty jump on the initial set target where the camera does not smoothly pan to the target.

I found the old thread where I do it manually on the old forum… but I don’t wanna do that again.

#2

UPDATE

Oooooo I know, Ill make a hidden camera target node and animate that to the target at the same rate that the camera position animation is running. Then just set the target to the node.

UPDATE of UPDATE

This worked like a charm!

3 Likes