title: Get the Camera position and restore it in Forge Viewer for a virtual visit
body: <p>I'm trying to put the camera correctly on <code>dbId</code> defines.</p>
  
  <p>For this, I run in the javascript console this command after put the view like I want : </p>
  
  <p><code>JSON.stringify(v.navigation.getCamera());</code></p>
  
  <p>But if I make a test and try to load the result directly, I have an error : </p>
  
  <p><code>v.navigation.setCamera(JSON.parse("{\"metadata\":{\"version\":4.3,\"type\":\"Object\",\"generator\":\"Ob...."))</code></p>
  
  <p><em>Error :</em>
  <code>camera.up is undefined</code></p>
  
  <p>In other words, how can I save the camera position manually and restore it? </p>
  
  <h2>EDIT</h2>
  
  <p>I try to do this with <code>setViewFromArray</code> : </p>
  
  <p><code>
  viewerApp.myCurrentViewer.setViewFromArray([
      454.76857106060265,
      96.01886808305997,
      212.6431659314611,
      287.11932000223214,
      167.19053946002487,
      97.17925996096139,
      -0.49285695792051964,
      0.20923119682030047,
      0.8445793777416518,
      2.7467811158798283,
      45.00000125223908,
      1,
      1
  ]);
  </code></p>
  
  <p>But it zoom to much IN the object and beyond...</p>
  
  <h2>EDIT 2</h2>
  
  <p>I've found a solution with <code>restoreState()</code> and <code>getState()</code> but it moving to fast and these methods do not seem to be queued.</p>
  
  <p>I would like to make a virtual visit of my building... </p>
  
  <h2>Edit 3</h2>
  
  <p>I've try to use your function. So I've migrate it to use it in a Javascript file : </p>
  
  <pre><code>    var animate = false;
  
      function tweenCameraTo(viewer, state) {
  
          var targetTweenEasing = {
              id: TWEEN.Easing.Linear.None,
              name: 'Linear' 
            };
          var posTweenEasing = {
              id: TWEEN.Easing.Linear.None,
              name: 'Linear'
            };
          var  upTweenEasing =  {
              id: TWEEN.Easing.Linear.None,
              name: 'Linear'
          };
  
          const targetEnd = new THREE.Vector3(
            state.viewport.target[0],
            state.viewport.target[1],
            state.viewport.target[2])
  
          const posEnd = new THREE.Vector3(
            state.viewport.eye[0],
            state.viewport.eye[1],
            state.viewport.eye[2])
  
          const upEnd = new THREE.Vector3(
            state.viewport.up[0],
            state.viewport.up[1],
            state.viewport.up[2])
  
          const nav = viewer.navigation
  
          const target = new THREE.Vector3().copy(
            nav.getTarget())
  
          const pos = new THREE.Vector3().copy(
            nav.getPosition())
  
          const up = new THREE.Vector3().copy(
            nav.getCameraUpVector())
  
          //nav.setView (posEnd, targetEnd);
  
          //nav.setCameraUpVector(upEnd);
  
  
          var targetTween = createTween({
            easing: targetTweenEasing.id,
            onUpdate: (v) =&gt; {
              nav.setTarget(v)
            },
            duration: 25000, //targetTweenDuration,
            object: target,
            to: targetEnd
          }).then((r) =&gt; {console.log("targetTween");});
  
          var posTween = createTween({
            easing: posTweenEasing.id,
            onUpdate: (v) =&gt; {
              nav.setPosition(v)
            },
            duration: 25000,//posTweenDuration,
            object: pos,
            to: posEnd
          }).then((r) =&gt; {console.log("posTween");});
  
          var upTween = createTween({
            easing: upTweenEasing.id,
            onUpdate: (v) =&gt; {
              nav.setCameraUpVector(v)
            },
            duration: 25000, //upTweenDuration,
            object: up,
            to: upEnd
          }).then((r) =&gt; {console.log("upTween");});
  
          Promise.all([
            targetTween,
            posTween,
            upTween]).then(() =&gt; {
            console.log("Fin animation");
              animate = false;
          })
  
          runAnimation(true);
    }
  
   // var animId = null;
  
    var runAnimation = function runAnimation (start) {        
          if(start || animate){
            requestAnimationFrame(runAnimation);
            TWEEN.update()
          }
    }
  
  
    function createTween (params) {
  
      return new Promise((resolve) =&gt; {
          console.log("params.to", params.to);
        new TWEEN.Tween(params.object)
          .to(params.to, params.duration)
          .onComplete(() =&gt; {resolve();})
          .onUpdate(params.onUpdate)
          .easing(params.easing)
          .start()
      })
    }
  </code></pre>
  
  <p>But When I try to use it, it drive me in a big zoom, not in front of my building for example. I've miss something but I do not see what. </p>
  
  <pre><code>tweenCameraTo(viewer, {"viewport":{"name":"","eye":[888.5217895507812,-257.4985656738281,576.9136962890625],"target":[262.7552795410156,81.58747863769531,73.64283752441406],"up":[0,0,1],"worldUpVector":[0,0,1],"pivotPoint":[262.7552795410156,81.58747863769531,73.64283752441406],"distanceToOrbit":871.6906720725796,"aspectRatio":2.7507163323782233,"projection":"perspective","isOrthographic":false,"fieldOfView":45.00000125223908}}); 
  
  tweenCameraTo(viewer, {"viewport":{"name":"","eye":[243.36675374870242,423.8180714045694,167.78380714288494],"target":[303.9841786300087,-347.23884414908446,-234.26269334678466],"up":[0.03614822612815841,-0.4598073869962326,0.8872826340076113],"worldUpVector":[0,0,1],"pivotPoint":[262.7552795410156,81.58747863769531,73.64283752441406],"distanceToOrbit":347.4897746012467,"aspectRatio":2.7507163323782233,"projection":"perspective","isOrthographic":false,"fieldOfView":45.00000125223908}}); 
  </code></pre>