Camera.rotation can't update after animation


I have a camera animation group, including position animation and rotation animation.

After the animations, I can’t update the camera.rotation using euler(x,y,z) anymore. The rotation animation is using Quaternion.

Hello!
Don’t know whether this helps, but I have this setup when animating arc cameras:

Before you animate the camera:

scene.onBeforeRenderObservable.add(forceRebuild)
export const forceRebuild = function(eventData: Scene) {
  const camera = eventData.activeCamera
  if (camera instanceof ArcRotateCamera) {
    camera.rebuildAnglesAndRadius()
  }
}

One the animations finishes, just remove the callback.

  if (allFinished) {
    if (callback) callback()
    scene.onBeforeRenderObservable.removeCallback(forceRebuild)
  }

Also pay atention that you might want to animate a cloned position and/or target.

Hope it helps!
R.

Once you define a quaternion rotation, Euler angles stop working. You will need to continue using quaternions from this moment on.

So my quickie was off topic :stuck_out_tongue:

Thank you, guys.

There is a warning in the end!

1 Like