@@ -474,12 +474,10 @@ THREE.SEA3D.Animator.prototype.update = function( dt ) {
474
474
475
475
this . mixer . update ( dt ) ;
476
476
477
- if ( ! this . currentAnimationAction . enabled && ! this . currentAnimationData . completed ) {
477
+ if ( this . currentAnimationAction . paused ) {
478
478
479
479
this . pause ( ) ;
480
480
481
- this . currentAnimationData . completed = true ;
482
-
483
481
if ( this . currentAnimationData . onComplete ) this . currentAnimationData . onComplete ( this ) ;
484
482
485
483
}
@@ -581,41 +579,43 @@ THREE.SEA3D.Animator.prototype.play = function( name, crossfade, offset, weight
581
579
582
580
if ( animation == this . currentAnimation ) {
583
581
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 ;
586
585
587
- return this ;
586
+ return this . resume ( ) ;
588
587
589
- }
588
+ } else {
590
589
591
- if ( ! animation ) throw new Error ( 'Animation "' + name + '" not found.' ) ;
590
+ if ( ! animation ) throw new Error ( 'Animation "' + name + '" not found.' ) ;
592
591
593
- this . previousAnimation = this . currentAnimation ;
594
- this . currentAnimation = animation ;
592
+ this . previousAnimation = this . currentAnimation ;
593
+ this . currentAnimation = animation ;
595
594
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 ;
599
599
600
- this . previousAnimationData = this . currentAnimationData ;
601
- this . currentAnimationData = this . animationsData [ name ] ;
600
+ this . previousAnimationData = this . currentAnimationData ;
601
+ this . currentAnimationData = this . animationsData [ name ] ;
602
602
603
- this . currentAnimationData . completed = false ;
603
+ this . updateTimeScale ( ) ;
604
604
605
- this . updateTimeScale ( ) ;
605
+ if ( offset !== undefined || ! animation . loop ) this . currentAnimationAction . time = offset !== undefined ? offset : 0 ;
606
+ this . currentAnimationAction . setEffectiveWeight ( weight !== undefined ? weight : 1 ) ;
606
607
607
- this . currentAnimationAction . play ( ) ;
608
+ this . currentAnimationAction . play ( ) ;
608
609
609
- if ( offset !== undefined ) this . currentAnimationAction . time = offset ;
610
- if ( weight !== undefined ) this . currentAnimationAction . setEffectiveWeight ( weight ) ;
610
+ if ( ! this . playing ) this . mixer . update ( 0 ) ;
611
611
612
- if ( ! this . playing ) this . mixer . update ( 0 ) ;
612
+ this . playing = true ;
613
613
614
- this . playing = true ;
614
+ if ( this . previousAnimation ) this . previousAnimationAction . crossFadeTo ( this . currentAnimationAction , crossfade || 0 , true ) ;
615
615
616
- if ( this . previousAnimation ) this . previousAnimationAction . crossFadeTo ( this . currentAnimationAction , crossfade || 0 , true ) ;
616
+ THREE . SEA3D . AnimationHandler . addAnimator ( this ) ;
617
617
618
- THREE . SEA3D . AnimationHandler . addAnimator ( this ) ;
618
+ }
619
619
620
620
return this ;
621
621
0 commit comments