Note that there are some explanatory texts on larger screens.

plurals
  1. POThree.js tweened value doesn't arrive at target, instead completes but stays at initial value
    text
    copied!<p>I'm trying to use Tween in my WebGL project ( <a href="http://eyesonmars.com/" rel="nofollow">http://eyesonmars.com/</a> ) to move the to a new position smoothly. However, I haven't yet been able to get Tween to work for me.</p> <p>Instead of Tweening the value of the camera.position.x from -3 to -10 over a period of 3 seconds it simply sends the camera's position to x=-3 and does not continue. I have also confirmed that the Tween object believes it has completed it's task by having Tween's .onComplete() pop up an alert (I have since removed that alert so it is not in the current code).</p> <p>Here is the code I'm using and it can be found at <a href="http://eyesonmars.com/libs/EOM_Utils.js" rel="nofollow">http://eyesonmars.com/libs/EOM_Utils.js</a> </p> <pre><code>function zoomOutCamera() { var position, target; // app.camera.position.z = 10; position = -3.0; target = -10.0; myTween = new TWEEN.Tween(position).to(target, 3000); myTween.onUpdate(function(){ // alert(position); app.camera.position.x = position; }); // myTween.onComplete(bananaphone(position)); myTween.start(); } function myAnimate() { if(!myTween.onComplete()) { requestAnimationFrame( myAnimate); } myTween.update(); } </code></pre> <p>Below I've summarized how I am testing the code and what should've been happening according to what I think I know.</p> <p>What IS happening: Typed into browsers JavaScript console:</p> <pre><code>input: camera.position.x output: 0.5 input: myAnimate() output: undefined input: camera.position.x output: -3 </code></pre> <p>What SHOULD happen (according to me): Typed into browsers JavaScript console:</p> <pre><code>input: camera.position.x output: 0.5 input: myAnimate() output: undefined input: camera.position.x output: -10 </code></pre> <p>I have tried different variations of the tween and also researched solutions online and my O'Reilly book. I'm glad to hear any suggestions for how I can post my question more accurately.</p> <p>Thank you in advance for any help you can provide.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload