fix animation bug

This commit is contained in:
Leslie
2019-01-29 11:25:14 +08:00
parent 9fd96b3ff7
commit aa3c2e8931
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -198,7 +198,7 @@ export class AnimationSampler {
const getState = (channel: IAnimationChannel) => {
const iNode = this._animationTarget.get(channel.target);
if (!iNode) {
if (iNode === undefined) {
return null;
}
return this._nodeSamplingStates[iNode];
@@ -299,6 +299,9 @@ class NodeSamplingState {
* https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
*/
public blendRotation (rotation: Quat, weight: number) {
if (weight === 0) {
return;
}
const t = weight / (this._sumRotWeight + weight);
quat.slerp(tmpquat, this._target.getRotation(), rotation, t);
this._target.setRotation(tmpquat);
@@ -306,6 +309,12 @@ class NodeSamplingState {
}
public apply () {
if (CC_DEV) {
if (this._sumPosWeight > 1.0 || this._sumRotWeight > 1.0 || this._sumScaleWeight > 1.0) {
throw new Error(`Unexpected.`);
}
}
if (this._sumPosWeight < 1.0) {
this.blendPosition(this._defaultPosition, 1.0 - this._sumPosWeight);
}
+1 -1
View File
@@ -216,7 +216,7 @@ class AnimationCtrl {
}
// handle playing
if (this._current) {
else if (this._current) {
const t0 = this._getTime(this._current);
this._animationSampler.sample(this._current.clip, t0, 1.0);
this._current.time += deltaTime;