Problem picking up with interactive camera and orbitcontrols after amination camera moves "camera view"

28 Views Asked by At

I have a viewer that reads/displays glTF using Three JS. Using orthographicCamera/OrbitControls the user can pan around the 3d scene. When I play an animation that contains a camera movement I want to position my interactive orthographicCamera/OrbitControls where the amination leaves off. But I am missing something.

Moved my code to a jsFiddle.

https://jsfiddle.net/MarkTheMule/ah5dts0g/15/

              var p = curntCamera.position.clone();
              var q = curntCamera.quaternion.clone();
              var m = curntCamera.matrix.clone();
              var s = curntCamera.scale.clone(); ///x
              var z = curntCamera.zoom; ///x
              var a = new THREE.Vector3(0,0,0);
              curntCamera.getWorldDirection( a );
              a.x = p.x + a.x;
              a.y = p.y + a.y;
              a.z = p.z + a.z;

              if (isAnime == false) {
                camInfo('animeCamera', curntCamera);
                cube.material.color.r = 0;
                cube.material.color.g = 1;
                cube.material.color.b = 0;
                curntCamera = actnCamera;
              } else {
                camInfo('actnCamera', curntCamera);
                cube.material.color.r = 1;
                cube.material.color.g = 0;
                cube.material.color.b = 0;
                curntCamera = animeCamera;
              }
        
              curntCamera.position.copy(p);
              curntCamera.quaternion.copy(q);
              //curntCamera.matrix.copy(m);
              curntCamera.scale.copy(s); ///x
              curntCamera.zoom = z; ///x
              curntCamera.lookAt(a);
        
              curntCamera.updateProjectionMatrix();
        
              oControls.object = curntCamera;
              oControls.update();
              render();

Clicking runs the animation. When it finishes, I want the actnCamera to become the curntCamera and pick up where the animeCamera left off. But for some reason the quaternion changes. Any help is appreciated.

0

There are 0 best solutions below