提交 b02db06c 编写于 作者: M Mr.doob

Animation: Removed JITCompile stuff.

上级 e3f0f1e9
......@@ -4,7 +4,7 @@
* @author alteredq / http://alteredqualia.com/
*/
THREE.Animation = function( root, name, interpolationType, JITCompile ) {
THREE.Animation = function ( root, name, interpolationType ) {
this.root = root;
this.data = THREE.AnimationHandler.get( name );
......@@ -18,16 +18,15 @@ THREE.Animation = function( root, name, interpolationType, JITCompile ) {
this.loop = true;
this.interpolationType = interpolationType !== undefined ? interpolationType : THREE.AnimationHandler.LINEAR;
this.JITCompile = JITCompile !== undefined ? JITCompile : true;
this.points = [];
this.target = new THREE.Vector3();
};
THREE.Animation.prototype.play = function( loop, startTimeMS ) {
THREE.Animation.prototype.play = function ( loop, startTimeMS ) {
if ( !this.isPlaying ) {
if ( this.isPlaying === false ) {
this.isPlaying = true;
this.loop = loop !== undefined ? loop : true;
......@@ -85,7 +84,7 @@ THREE.Animation.prototype.play = function( loop, startTimeMS ) {
THREE.Animation.prototype.pause = function() {
if( this.isPaused ) {
if ( this.isPaused === true ) {
THREE.AnimationHandler.addToUpdate( this );
......@@ -106,37 +105,14 @@ THREE.Animation.prototype.stop = function() {
this.isPaused = false;
THREE.AnimationHandler.removeFromUpdate( this );
// reset JIT matrix and remove cache
for ( var h = 0; h < this.hierarchy.length; h ++ ) {
if ( this.hierarchy[ h ].animationCache !== undefined ) {
if( this.hierarchy[ h ] instanceof THREE.Bone ) {
this.hierarchy[ h ].skinMatrix = this.hierarchy[ h ].animationCache.originalMatrix;
} else {
this.hierarchy[ h ].matrix = this.hierarchy[ h ].animationCache.originalMatrix;
}
delete this.hierarchy[ h ].animationCache;
}
}
};
THREE.Animation.prototype.update = function( deltaTimeMS ) {
THREE.Animation.prototype.update = function ( deltaTimeMS ) {
// early out
if ( !this.isPlaying ) return;
if ( this.isPlaying === false ) return;
// vars
......@@ -155,8 +131,6 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
var currentPoint, forwardPoint, angle;
// update
this.currentTime += deltaTimeMS * this.timeScale;
unloopedCurrentTime = this.currentTime;
......@@ -164,54 +138,11 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
frame = parseInt( Math.min( currentTime * this.data.fps, this.data.length * this.data.fps ), 10 );
// update
for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) {
object = this.hierarchy[ h ];
animationCache = object.animationCache;
// use JIT?
if ( this.JITCompile && JIThierarchy[ h ][ frame ] !== undefined ) {
if( object instanceof THREE.Bone ) {
object.skinMatrix = JIThierarchy[ h ][ frame ];
object.matrixAutoUpdate = false;
object.matrixWorldNeedsUpdate = false;
} else {
object.matrix = JIThierarchy[ h ][ frame ];
object.matrixAutoUpdate = false;
object.matrixWorldNeedsUpdate = true;
}
// use interpolation
} else {
// make sure so original matrix and not JIT matrix is set
if ( this.JITCompile ) {
if ( object instanceof THREE.Bone ) {
object.skinMatrix = object.animationCache.originalMatrix;
} else {
object.matrix = object.animationCache.originalMatrix;
}
}
// loop through pos/rot/scl
for ( var t = 0; t < 3; t ++ ) {
......@@ -289,7 +220,7 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
vector = object.position;
if( this.interpolationType === THREE.AnimationHandler.LINEAR ) {
if ( this.interpolationType === THREE.AnimationHandler.LINEAR ) {
vector.x = prevXYZ[ 0 ] + ( nextXYZ[ 0 ] - prevXYZ[ 0 ] ) * scale;
vector.y = prevXYZ[ 1 ] + ( nextXYZ[ 1 ] - prevXYZ[ 1 ] ) * scale;
......@@ -311,7 +242,7 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
vector.y = currentPoint[ 1 ];
vector.z = currentPoint[ 2 ];
if( this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) {
if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) {
forwardPoint = this.interpolateCatmullRom( this.points, scale * 1.01 );
......@@ -331,7 +262,7 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
THREE.Quaternion.slerp( prevXYZ, nextXYZ, object.quaternion, scale );
} else if( type === "scl" ) {
} else if ( type === "scl" ) {
vector = object.scale;
......@@ -345,34 +276,6 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
}
}
// update JIT?
if ( this.JITCompile ) {
if ( JIThierarchy[ 0 ][ frame ] === undefined ) {
this.hierarchy[ 0 ].updateMatrixWorld( true );
for ( var h = 0; h < this.hierarchy.length; h ++ ) {
if ( this.hierarchy[ h ] instanceof THREE.Bone ) {
JIThierarchy[ h ][ frame ] = this.hierarchy[ h ].skinMatrix.clone();
} else {
JIThierarchy[ h ][ frame ] = this.hierarchy[ h ].matrix.clone();
}
}
}
}
};
// Catmull-Rom spline
......@@ -408,7 +311,7 @@ THREE.Animation.prototype.interpolateCatmullRom = function ( points, scale ) {
};
THREE.Animation.prototype.interpolate = function( p0, p1, p2, p3, t, t2, t3 ) {
THREE.Animation.prototype.interpolate = function ( p0, p1, p2, p3, t, t2, t3 ) {
var v0 = ( p2 - p0 ) * 0.5,
v1 = ( p3 - p1 ) * 0.5;
......@@ -421,7 +324,7 @@ THREE.Animation.prototype.interpolate = function( p0, p1, p2, p3, t, t2, t3 ) {
// Get next key with
THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) {
THREE.Animation.prototype.getNextKeyWith = function ( type, h, key ) {
var keys = this.data.hierarchy[ h ].keys;
......@@ -452,7 +355,7 @@ THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) {
// Get previous key with
THREE.Animation.prototype.getPrevKeyWith = function( type, h, key ) {
THREE.Animation.prototype.getPrevKeyWith = function ( type, h, key ) {
var keys = this.data.hierarchy[ h ].keys;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册