title: Reverse the effects of a Tween.js animation
body: <p>I'm trying to animate a three.js block in such a way that it returns to its original position when the animation ends, using tween.js.</p>
  
  <p>Is there a way to achieve this with tween.js <strong>only using one tween</strong>?</p>
  
  <p>I have got this working as shown below:</p>
  
  <pre><code>var position = {x: -200, y: 150, width: 1, height: 1, depth: 1, rotx: -0.5, roty: 0.7, rotz: 0.9};
  var target = {x: 200, y: -100, width: 0.4, height: 3, depth: 8, rotx: 0.3, roty: -0.4, rotz: -0.6};
  var position2 = {x: -200, y: 150, width: 1, height: 1, depth: 1, rotx: -0.5, roty: 0.7, rotz: 0.9};
  
  var mesh = new THREE.Mesh(
    new THREE.CubeGeometry(190, 45, 30),
    new THREE.MeshBasicMaterial({color: 0x444444}),
    0
  );
  mesh.position.set(position.x, position.y, 0);
  mesh.rotation.set(position.rotx, position.roty, position.rotz);
  scene.add(mesh);
  
  var t1 = new TWEEN.Tween(position).to(target, 2000);
  t1.onUpdate(function() {
    mesh.position.set(position.x, position.y, 0);
    mesh.scale.set(position.width, position.height, position.depth);
    mesh.rotation.set(position.rotx, position.roty, position.rotz);
  });
  t1.easing(TWEEN.Easing.Quadratic.Out);
  t1.onComplete(function() {t2.start();});
  
  var t2 = new TWEEN.Tween(target).to(position2, 2000);
  t2.onUpdate(function() {
    mesh.position.set(target.x, target.y, 0);
    mesh.scale.set(target.width, target.height, target.depth);
    mesh.rotation.set(target.rotx, target.roty, target.rotz);
  });
  t2.easing(TWEEN.Easing.Quadratic.In);
  
  t1.start();
  </code></pre>
  
  <p>And I have the tweens updating in my animation function:</p>
  
  <pre><code>function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
    mesh.__dirtyPosition = true;
    mesh.__dirtyRotation = true;
    TWEEN.update();
  }
  animate();
  </code></pre>
  
  <p>This is working as I expect it to, but it is clearly very inefficient, and difficult to work around.</p>
  
  <p>Any and all help will be appreciated.</p>