Skip to content

Instantly share code, notes, and snippets.

@cubicleDowns
Last active December 31, 2015 16:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cubicleDowns/8015934 to your computer and use it in GitHub Desktop.
Save cubicleDowns/8015934 to your computer and use it in GitHub Desktop.
Object4D animation and tweening. You can read more on my blog, http://blog.tempt3d.com/
var Demo = Demo || {};
// This object manages all of the 4D objects.
// Between renders, it'll take the difference between the last render and the current time.
// This Time Delta is passed to each Object4D object.
// Each Object4D object will then move a distance based upon their individually set speed,
Demo.Manager = function () {
this.clock = new Demo.Clock();
// an array container all of the Object4D guys.
this._objectManager = [];
this.init();
};
Demo.Manager.prototype = {
init: function () {
// this.listeners();
},
update: function () {
var timeDelta = this.clock.getTimeDelta();
this.updateMovers( timeDelta );
},
// Take the time delta, and pass it to each Object4D object.
updateMovers: function ( timeDelta ) {
for(var i = 0; i < this._objectManager.length; i++){
this._objectManager[i].update( timeDelta );
}
},
// Set random X,Y,Z locations for each managed object
setRandomTargets: function () {
for(var i = 0; i < this._objectManager.length; i++){
this._objectManager[i].randomTarget();
}
},
// Add a random object to the mover.
add4DObject: function ( mover ) {
this._objectManager.push( mover );
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment