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

Updated builds.

上级 58f5fb54
......@@ -14919,26 +14919,10 @@ THREE.Bone = function ( belongsToSkin ) {
this.skin = belongsToSkin;
this.accumulatedRotWeight = 0;
this.accumulatedPosWeight = 0;
this.accumulatedSclWeight = 0;
};
THREE.Bone.prototype = Object.create( THREE.Object3D.prototype );
THREE.Bone.prototype.updateMatrixWorld = function ( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
// Reset weights to be re-accumulated in the next frame
this.accumulatedRotWeight = 0;
this.accumulatedPosWeight = 0;
this.accumulatedSclWeight = 0;
};
// File:src/objects/Skeleton.js
......@@ -28910,6 +28894,12 @@ THREE.AnimationHandler = {
update: function ( deltaTimeMS ) {
for ( var i = 0; i < this.animations.length; i ++ ) {
this.animations[ i ].resetBlendWeights( );
}
for ( var i = 0; i < this.animations.length; i ++ ) {
this.animations[ i ].update( deltaTimeMS );
......@@ -28981,20 +28971,26 @@ THREE.Animation.prototype.reset = function () {
if ( object.animationCache === undefined ) {
object.animationCache = {};
object.animationCache = {
animations: {},
blending: {
positionWeight: 0.0,
quaternionWeight: 0.0,
scaleWeight: 0.0
}
};
}
if ( object.animationCache[this.data.name] === undefined ) {
if ( object.animationCache.animations[this.data.name] === undefined ) {
object.animationCache[this.data.name] = {};
object.animationCache[this.data.name].prevKey = { pos: 0, rot: 0, scl: 0 };
object.animationCache[this.data.name].nextKey = { pos: 0, rot: 0, scl: 0 };
object.animationCache[this.data.name].originalMatrix = object.matrix;
object.animationCache.animations[this.data.name] = {};
object.animationCache.animations[this.data.name].prevKey = { pos: 0, rot: 0, scl: 0 };
object.animationCache.animations[this.data.name].nextKey = { pos: 0, rot: 0, scl: 0 };
object.animationCache.animations[this.data.name].originalMatrix = object.matrix;
}
var animationCache = object.animationCache[this.data.name];
var animationCache = object.animationCache.animations[this.data.name];
// Get keys to match our current time
......@@ -29021,6 +29017,23 @@ THREE.Animation.prototype.reset = function () {
};
THREE.Animation.prototype.resetBlendWeights = function () {
for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) {
var object = this.hierarchy[ h ];
if ( object.animationCache !== undefined ) {
object.animationCache.blending.positionWeight = 0.0;
object.animationCache.blending.quaternionWeight = 0.0;
object.animationCache.blending.scaleWeight = 0.0;
}
}
};
THREE.Animation.prototype.update = (function(){
......@@ -29099,7 +29112,8 @@ THREE.Animation.prototype.update = (function(){
for ( var h = 0, hl = this.hierarchy.length; h < hl; h ++ ) {
var object = this.hierarchy[ h ];
var animationCache = object.animationCache[this.data.name];
var animationCache = object.animationCache.animations[this.data.name];
var blending = object.animationCache.blending;
// loop through pos/rot/scl
......@@ -29150,17 +29164,9 @@ THREE.Animation.prototype.update = (function(){
newVector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale;
// blend
if ( object instanceof THREE.Bone ) {
var proportionalWeight = this.weight / ( this.weight + object.accumulatedPosWeight );
object.position.lerp( newVector, proportionalWeight );
object.accumulatedPosWeight += this.weight;
} else {
object.position.copy( newVector );
}
var proportionalWeight = this.weight / ( this.weight + blending.positionWeight );
object.position.lerp( newVector, proportionalWeight );
blending.positionWeight += this.weight;
} else if ( this.interpolationType === THREE.AnimationHandler.CATMULLROM ||
this.interpolationType === THREE.AnimationHandler.CATMULLROM_FORWARD ) {
......@@ -29173,14 +29179,8 @@ THREE.Animation.prototype.update = (function(){
scale = scale * 0.33 + 0.33;
var currentPoint = interpolateCatmullRom( points, scale );
var proportionalWeight = 1;
if ( object instanceof THREE.Bone ) {
proportionalWeight = this.weight / ( this.weight + object.accumulatedPosWeight );
object.accumulatedPosWeight += this.weight;
}
var proportionalWeight = this.weight / ( this.weight + blending.positionWeight );
blending.positionWeight += this.weight;
// blend
......@@ -29211,20 +29211,16 @@ THREE.Animation.prototype.update = (function(){
THREE.Quaternion.slerp( prevXYZ, nextXYZ, newQuat, scale );
// Avoid paying the cost of an additional slerp if we don't have to
if ( ! ( object instanceof THREE.Bone ) ) {
object.quaternion.copy(newQuat);
} else if ( object.accumulatedRotWeight === 0 ) {
if ( blending.quaternionWeight === 0 ) {
object.quaternion.copy(newQuat);
object.accumulatedRotWeight = this.weight;
blending.quaternionWeight = this.weight;
} else {
var proportionalWeight = this.weight / ( this.weight + object.accumulatedRotWeight );
var proportionalWeight = this.weight / ( this.weight + blending.quaternionWeight );
THREE.Quaternion.slerp( object.quaternion, newQuat, object.quaternion, proportionalWeight );
object.accumulatedRotWeight += this.weight;
blending.quaternionWeight += this.weight;
}
......@@ -29234,17 +29230,9 @@ THREE.Animation.prototype.update = (function(){
newVector.y = prevXYZ[ 1 ] + ( nextXYZ[ 1 ] - prevXYZ[ 1 ] ) * scale;
newVector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale;
if ( object instanceof THREE.Bone ) {
var proportionalWeight = this.weight / ( this.weight + object.accumulatedSclWeight);
object.scale.lerp( newVector, proportionalWeight );
object.accumulatedSclWeight += this.weight;
} else {
object.scale.copy( newVector );
}
var proportionalWeight = this.weight / ( this.weight + blending.scaleWeight );
object.scale.lerp( newVector, proportionalWeight );
blending.scaleWeight += this.weight;
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册