How to use tween - 10 common examples

To help you get started, we’ve selected a few tween examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github borismus / copresence-vr / src / main.js View on Github external
//console.log('Sent state to peer %s.', pc.remotePeerId);
      pc.send(JSON.stringify(state));
    }

    // Set the pose of the observer in the audio renderer.
    var ar = audioRenderers[pc.remotePeerId]
    var pr = peerRenderers[pc.remotePeerId];
    if (ar && pr) {
      ar.setPose(pose);

      // Reflect your peer's audio level in the peer renderer.
      pr.setPeerAudioLevel(ar.getLevel());
    }
  }

  TWEEN.update();

  rafID = requestAnimationFrame(render);
}
github vlandham / vis / src / grid.js View on Github external
Pic.prototype.startGrid = function() {
  var target = {x: 10, y: 20, z: 0};
  // this.tween = new TWEEN.Tween(this.position).to(target, 2000);
  // this.tween.start();
  new TWEEN.Tween(this.position).to(target, 2000)
    .start();
  new TWEEN.Tween(this.rotation).to({x:0,y:0,z:0}, 2000)
    .start();
};
github vlandham / vis / src / grid.js View on Github external
Pic.prototype.startGrid = function() {
  var target = {x: 10, y: 20, z: 0};
  // this.tween = new TWEEN.Tween(this.position).to(target, 2000);
  // this.tween.start();
  new TWEEN.Tween(this.position).to(target, 2000)
    .start();
  new TWEEN.Tween(this.rotation).to({x:0,y:0,z:0}, 2000)
    .start();
};
github shinseed / BIMServer-NodeJs / BIMServerSrc / components / threeView / util.js View on Github external
render() {
        if (!this.renderer.autoClear) this.renderer.clear();

        this.controls.update();

        // this.CameraHelper.update();
        TWEEN.update();

        this.pinObj3D.children.forEach((item) => {
            item.lookAt(this.controls.object.position);
        })

        this.octree.update();

        this.renderer.render(this.scene, this.camera);
    }
}
github anvaka / allnpmviz3d / src / scripts / scene / autoPilot.js View on Github external
// Move camera from its current position to target:
    new TWEEN.Tween(from).to(cameraEndPos, 400)
      .easing(TWEEN.Easing.Linear.None)
      .onUpdate(moveCamera)
      .onComplete(function() {
        if (typeof done === 'function') done();
      })
      .start();

    // Also rotate camera while it flies to an object:
    var startRotation = new THREE.Quaternion().copy(camera.quaternion);
    camera.lookAt(new THREE.Vector3(to.x, to.y, to.z));
    var endRotation = new THREE.Quaternion().copy(camera.quaternion);
    camera.quaternion.copy(startRotation); // revert to original rotation

    new TWEEN.Tween({
      x: startRotation.x,
      y: startRotation.y,
      z: startRotation.z,
      w: startRotation.w
    }).to({
      x: endRotation.x,
      y: endRotation.y,
      z: endRotation.z,
      w: endRotation.w
    }, 300).onUpdate(rotateCamera).start();
  }
github anvaka / unrender / lib / auto-pilot.js View on Github external
// Move camera from its current position to target:
    new TWEEN.Tween(from).to(cameraEndPos, 400)
      .easing(TWEEN.Easing.Linear.None)
      .onUpdate(moveCamera)
      .onComplete(function() {
        if (typeof done === 'function') done();
      })
      .start();

    // Also rotate camera while it flies to an object:
    var startRotation = new THREE.Quaternion().copy(camera.quaternion);
    camera.lookAt(new THREE.Vector3(to.x, to.y, to.z));
    var endRotation = new THREE.Quaternion().copy(camera.quaternion);
    camera.quaternion.copy(startRotation); // revert to original rotation

    new TWEEN.Tween({
      x: startRotation.x,
      y: startRotation.y,
      z: startRotation.z,
      w: startRotation.w
    }).to({
      x: endRotation.x,
      y: endRotation.y,
      z: endRotation.z,
      w: endRotation.w
    }, 300).onUpdate(rotateCamera).start();
  }
github anvaka / allnpmviz3d / src / scripts / scene / autoPilot.js View on Github external
cameraOffset = done;
      done = undefined;
    }
    cameraOffset = typeof cameraOffset === 'number' ? cameraOffset : 100;
    // copy camera's current position - we will be animating this value
    var from = {
      x: camera.position.x,
      y: camera.position.y,
      z: camera.position.z,
    };

    // Camera needs to stop at given distance from target's center
    var cameraEndPos = intersect(from, to, cameraOffset);

    // Move camera from its current position to target:
    new TWEEN.Tween(from).to(cameraEndPos, 400)
      .easing(TWEEN.Easing.Linear.None)
      .onUpdate(moveCamera)
      .onComplete(function() {
        if (typeof done === 'function') done();
      })
      .start();

    // Also rotate camera while it flies to an object:
    var startRotation = new THREE.Quaternion().copy(camera.quaternion);
    camera.lookAt(new THREE.Vector3(to.x, to.y, to.z));
    var endRotation = new THREE.Quaternion().copy(camera.quaternion);
    camera.quaternion.copy(startRotation); // revert to original rotation

    new TWEEN.Tween({
      x: startRotation.x,
      y: startRotation.y,
github getlackey / lackey-cms / modules / cms / client / js / manager / dummy.js View on Github external
function animate(time) {
      requestAnimationFrame(animate);
      TWEEN.update(time);
}
github nervoussystem / bookshelf / gui.js View on Github external
function animate(time) {
	requestAnimationFrame(animate);
	TWEEN.update(time);
}
github PixelsCommander / HTML-GL / src / gl-element / transition-manager / index.js View on Github external
function animate(time) {
    requestAnimationFrame(animate);
    TWEEN.update(time);
}

tween

Super simple, fast and easy to use tweening engine which incorporates optimised Robert Penner's equations.

Unrecognized
Latest version published 11 years ago

Package Health Score

56 / 100
Full package analysis

Popular tween functions