Serialise PerspectiveCamera in three.js

I already use
Serialise PerspectiveCamera in three.js, together with Orbit Controls. However, this does not always work. Sometimes, the restored camera state is completely different from what it was before. I assume this happens due to Maths and rotation matrices -> quaternion not being unique…

Any ideas on this?
I’ve already tried to restore the matrix additionally, but this does not work.

It’s hard to know what’s going on without seeing your code, please share what you’re doing here. Also, you may need to call controls.update() for any new position to get applied.

Just like in the link:


  public saveCameraState() {
    return this._camera.matrix;


  public restoreCameraState(state: THREE.Matrix4) {
    // Taken from:
    this._camera.matrix.decompose(this._camera.position, this._camera.quaternion, this._camera.scale);

The problem is not, that the changes are not applied - the resulting view is just plain wrong, sometimes.
Note that all “resulting perspectives” are always restored correctly.