How to use the tween.js.Tween function in tween

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 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 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 googlearchive / vrview / src / embed / world-renderer.js View on Github external
WorldRenderer.prototype.autopan = function(duration) {
  var targetY = this.camera.parent.rotation.y - AUTOPAN_ANGLE;
  var tween = new TWEEN.Tween(this.camera.parent.rotation)
      .to({y: targetY}, AUTOPAN_DURATION)
      .easing(TWEEN.Easing.Quadratic.Out)
      .start();
};
github borismus / copresence-vr / src / peer-renderer.js View on Github external
PeerRenderer.prototype.stopWalking_ = function() {
  var leftBack = new TWEEN.Tween(this.leftLeg.rotation);
  leftBack.to({x: 0}, WALKING_RATE/2).start();

  var rightBack = new TWEEN.Tween(this.rightLeg.rotation);
  rightBack.to({x: 0}, WALKING_RATE/2).start();

  this.startIdleAnimation_();
};
github Holograf / Holograf / public / js / three / methods / View.js View on Github external
var placeSelection = function (theatre) {
  var nodePosition = theatre.selectedNode.position;
  var selection = theatre.selection;

  selection.material.opacity = 0;
  selection.position.x = nodePosition.x;
  selection.position.y = nodePosition.y - 250;
  selection.position.z = nodePosition.z;
  new TWEEN.Tween(selection.position).to( {y: nodePosition.y - 100}, 300 ).start();
  new TWEEN.Tween(selection.material).to( {opacity:1}, 300 ).start();
}
github sole / howa / client / js / Threedes.js View on Github external
function tweenObject(object, destination, duration) {
	var tween = object.__internalTween;
	if(tween) {
		tween.stop();
	}

	tween = new TWEEN.Tween(object);
	tween.easing(TWEEN.Easing.Exponential.Out);
	tween.to(destination, duration);

	object.__internalTween = tween;
	return tween;
}
github edwinwebb / three-seed / app / displayobjects / Bunny / Bunny.js View on Github external
constructor() {
    const texture = PIXI.Texture.fromImage(BUNNY);

    super(texture);

    this.tween = new Tween(this);

    this.anchor.x = .5;
    this.anchor.y = 1;

    this.pivot.x = .5;
    this.pivot.y = .5;

    this.interactive = true;
  }

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