Cannot use animation on camera.position

setting camera.position manually works fine, but it cannot be animated out-of-the-box

on the other side, other camera properties such as (and others) can be animated without problems

playground reproduction:

The arc rotate camera has 3 parameters that can be used to change the camera’s position - alpha, beta and radius. If you want to change position and get the values updated you need to call the update function to update those values. This example is rather unoptimized, but i hope it explains the situation:

animating camera position | Babylon.js Playground (

Thanks, that makes sense - but then question is why those properties get updated automatically sometimes - e.g., i can set camera.position = new BABYLON.Vector3(0, 5, -10); and that does update alpha and beta. but updating same position via animation does not?

i don’t want to have global camera.rebuildAnglesAndRadius(); that executes on each frame forever since camera animation runs for 1sec and its done.

And that’s exactly why it is not running on every frame :slight_smile:

The reason setting a new position is that position is actually a getter/setter . when you ask for position you are actually getting camera._position. Which is a vector that changes when you change the position, but is not being inspected for changes. When you set a new position ( i.e. camera.position = …` you call the setter, which updates the camera’s properties.

This is what I meant when I said it is not optimized. Instead of animation (which “gets” and then sets), you can run the animation yourself using observables, which would be a solution. You can also check if an animation is running, and update only when it is running.

It’s not optimal, I agree, but this is by design

i’d expect that position.x would also be a setter that triggers recalc - and internally its position._x

the fact that its not is inconsistent behavior (yes, its by design so perhaps this should be a new “feature” instead of a “bug”)

you can run the animation yourself using observables

i already do something similar, just wished to have all animations to use same code

anyhow, thanks