tween.js - Tween camera position while rotation with slerp -- THREE.js -


I want to add the camera position during rotation.

This is my function:

  Function steps andlookup (camera, DSTOPO, DSSILAT, options) {options || (Option = {duration: 300}); Var origpos = new THREE.Vector3 (). Copy (camera. Search); // Original position var origotot = new three.Euler (). Copy (camera.rotation); // Original rotation camera.position.set (dstpos.x, dstpos.y, dstpos.z); Camera.lookAt (dstlookat); Var dstrot = new three.Euler (). Copy (camera.rotation) // Reset original position and rotation camera.position.set (origpos.x, origpos.y, origpos.z); Camera.rotation.set (origotot.x, origotot.y, origotot.z); // // Tiving // // status new TWEEN.Tween (camera.position) .to ({x: dstpos.x, y: dstpos.y, z: dstpos.z}, options.duration). Start () ;; // rotation (using slrap) (function () {var qa = camera.quaternion; // source quaternion var qb = new three quarters.) SetFromEuler (dstrot); // dst quaternion var qm = new three Quarteran (); Var O = {T:} New TWEEN.Tween (O) .to ({T: 1}, options.duration) UpUpdate (function () {THREE.Quaternion.slerp (qa, qb, Qm, ot); camera.quarean.set (qm.x, qm.y, qm.z, qm.w);}). Start ();}). Call (this); }  

It works great:


The only problem is for rotation does not seem linear ...

Thank you

In your code

  // rotation (using slerp) (function () {var qa = camera.quaternion; // Src quaternion  

to change it

 qa = new three.Quaternion () .copy (camera.quaternion); // src quaternion  

The way you do this, Qi is similar to the camera Quaternion, And this slurp comes back to Calcus. This is a steady variable Should Ona.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -