Skip to content

Commit ad6fd49

Browse files
authored
update the anim controller update function to fix certain transition states (playcanvas#2434)
1 parent 3b9983c commit ad6fd49

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/framework/components/anim/controller.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,9 @@ Object.assign(AnimController.prototype, {
485485
var interpolatedTime = this._currTransitionTime / this._totalTransitionTime;
486486
for (i = 0; i < this._transitionPreviousStates.length; i++) {
487487
// interpolate the weights of the most recent previous state and all other previous states based on the progress through the previous transition
488-
if (i !== this._transitionPreviousStates.length - 1) {
488+
if (!this._isTransitioning) {
489+
this._transitionPreviousStates[i].weight = 1.0;
490+
} else if (i !== this._transitionPreviousStates.length - 1) {
489491
this._transitionPreviousStates[i].weight *= (1.0 - interpolatedTime);
490492
} else {
491493
this._transitionPreviousStates[i].weight = interpolatedTime;
@@ -501,9 +503,9 @@ Object.assign(AnimController.prototype, {
501503
clip.name = animation.name + '.previous.' + i;
502504
}
503505
// // pause previous animation clips to reduce their impact on performance
504-
// if (i !== this._transitionPreviousStates.length - 1) {
505-
clip.pause();
506-
// }
506+
if (i !== this._transitionPreviousStates.length - 1) {
507+
clip.pause();
508+
}
507509
}
508510
}
509511
}
@@ -652,7 +654,8 @@ Object.assign(AnimController.prototype, {
652654
this._updateStateFromTransition(transition);
653655

654656
if (this._isTransitioning) {
655-
if (this._currTransitionTime < this._totalTransitionTime) {
657+
this._currTransitionTime += dt;
658+
if (this._currTransitionTime <= this._totalTransitionTime) {
656659
var interpolatedTime = this._currTransitionTime / this._totalTransitionTime;
657660
// while transitioning, set all previous state animations to be weighted by (1.0 - interpolationTime).
658661
for (i = 0; i < this._transitionPreviousStates.length; i++) {
@@ -691,7 +694,6 @@ Object.assign(AnimController.prototype, {
691694
}
692695
}
693696
}
694-
this._currTransitionTime += dt;
695697
}
696698
this._animEvaluator.update(dt);
697699
},

0 commit comments

Comments
 (0)