Skip to content

Commit bfec4ef

Browse files
sunagmrdoob
authored andcommitted
fix sea3d onComplete animation & AnimationAction wrong reference (mrdoob#8941)
* onComplete animation fix * wrong variable reference * remove check action.enabled is no longer necessary * remove animationData.completed is no longer necessary
1 parent ea09112 commit bfec4ef

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

examples/js/loaders/sea3d/SEA3DLoader.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,10 @@ THREE.SEA3D.Animator.prototype.update = function( dt ) {
474474

475475
this.mixer.update( dt );
476476

477-
if ( ! this.currentAnimationAction.enabled && ! this.currentAnimationData.completed ) {
477+
if ( this.currentAnimationAction.paused ) {
478478

479479
this.pause();
480480

481-
this.currentAnimationData.completed = true;
482-
483481
if ( this.currentAnimationData.onComplete ) this.currentAnimationData.onComplete( this );
484482

485483
}
@@ -581,41 +579,43 @@ THREE.SEA3D.Animator.prototype.play = function( name, crossfade, offset, weight
581579

582580
if ( animation == this.currentAnimation ) {
583581

584-
if ( offset !== undefined ) this.currentAnimationAction.time = offset;
585-
if ( weight !== undefined ) this.currentAnimationAction.setEffectiveWeight( weight );
582+
if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : 0;
583+
this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 );
584+
this.currentAnimationAction.paused = false;
586585

587-
return this;
586+
return this.resume();
588587

589-
}
588+
} else {
590589

591-
if ( ! animation ) throw new Error( 'Animation "' + name + '" not found.' );
590+
if ( ! animation ) throw new Error( 'Animation "' + name + '" not found.' );
592591

593-
this.previousAnimation = this.currentAnimation;
594-
this.currentAnimation = animation;
592+
this.previousAnimation = this.currentAnimation;
593+
this.currentAnimation = animation;
595594

596-
this.previousAnimationAction = this.currentAnimationAction;
597-
this.currentAnimationAction = this.mixer.clipAction( animation ).setLoop( animation.loop ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset();
598-
this.currentAnimationAction.clampWhenFinished = true;
595+
this.previousAnimationAction = this.currentAnimationAction;
596+
this.currentAnimationAction = this.mixer.clipAction( animation ).setLoop( animation.loop ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset();
597+
this.currentAnimationAction.clampWhenFinished = true;
598+
this.currentAnimationAction.paused = false;
599599

600-
this.previousAnimationData = this.currentAnimationData;
601-
this.currentAnimationData = this.animationsData[ name ];
600+
this.previousAnimationData = this.currentAnimationData;
601+
this.currentAnimationData = this.animationsData[ name ];
602602

603-
this.currentAnimationData.completed = false;
603+
this.updateTimeScale();
604604

605-
this.updateTimeScale();
605+
if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : 0;
606+
this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 );
606607

607-
this.currentAnimationAction.play();
608+
this.currentAnimationAction.play();
608609

609-
if ( offset !== undefined ) this.currentAnimationAction.time = offset;
610-
if ( weight !== undefined ) this.currentAnimationAction.setEffectiveWeight( weight );
610+
if ( ! this.playing ) this.mixer.update( 0 );
611611

612-
if ( ! this.playing ) this.mixer.update( 0 );
612+
this.playing = true;
613613

614-
this.playing = true;
614+
if ( this.previousAnimation ) this.previousAnimationAction.crossFadeTo( this.currentAnimationAction, crossfade || 0, true );
615615

616-
if ( this.previousAnimation ) this.previousAnimationAction.crossFadeTo( this.currentAnimationAction, crossfade || 0, true );
616+
THREE.SEA3D.AnimationHandler.addAnimator( this );
617617

618-
THREE.SEA3D.AnimationHandler.addAnimator( this );
618+
}
619619

620620
return this;
621621

src/animation/AnimationAction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ THREE.AnimationAction._new.prototype = {
447447
if ( timeScale === 0 ) {
448448

449449
// motion has halted, pause
450-
this.pause = true;
450+
this.paused = true;
451451

452452
} else {
453453

@@ -500,7 +500,7 @@ THREE.AnimationAction._new.prototype = {
500500

501501
} else break handle_stop;
502502

503-
if ( this.clampWhenFinished ) this.pause = true;
503+
if ( this.clampWhenFinished ) this.paused = true;
504504
else this.enabled = false;
505505

506506
this._mixer.dispatchEvent( {

0 commit comments

Comments
 (0)