提交 3b7ff814 编写于 作者: T tschw 提交者: Mr.doob

Minor Animation Cleanup

* Removed leftover inclusion of AnimationClipCreator.

- See #8677
  https://github.com/mrdoob/three.js/issues/8677#issuecomment-213629279

* Clarified AnimationMixer loop mode handling.

- See #8719
上级 e7e032ce
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
<script src="../build/three.js"></script> <script src="../build/three.js"></script>
<script src="js/libs/stats.min.js"></script> <script src="js/libs/stats.min.js"></script>
<script src="js/AnimationClipCreator.js"></script>
<script> <script>
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
<script src="../build/three.js"></script> <script src="../build/three.js"></script>
<script src="js/controls/TrackballControls.js"></script> <script src="js/controls/TrackballControls.js"></script>
<script src="js/AnimationClipCreator.js"></script>
<script src="js/Detector.js"></script> <script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script> <script src="js/libs/stats.min.js"></script>
......
...@@ -731,16 +731,11 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -731,16 +731,11 @@ THREE.AnimationMixer._Action.prototype = {
var duration = this._clip.duration, var duration = this._clip.duration,
loop = this.loop, loop = this.loop,
loopCount = this._loopCount, loopCount = this._loopCount;
pingPong = false; if ( loop === THREE.LoopOnce ) {
switch ( loop ) {
case THREE.LoopOnce:
if ( loopCount === -1 ) { if ( loopCount === -1 ) {
// just started // just started
this.loopCount = 0; this.loopCount = 0;
...@@ -748,6 +743,8 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -748,6 +743,8 @@ THREE.AnimationMixer._Action.prototype = {
} }
handle_stop: {
if ( time >= duration ) { if ( time >= duration ) {
time = duration; time = duration;
...@@ -756,9 +753,7 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -756,9 +753,7 @@ THREE.AnimationMixer._Action.prototype = {
time = 0; time = 0;
} else break; } else break handle_stop;
// reached the end
if ( this.clampWhenFinished ) this.pause = true; if ( this.clampWhenFinished ) this.pause = true;
else this.enabled = false; else this.enabled = false;
...@@ -768,19 +763,16 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -768,19 +763,16 @@ THREE.AnimationMixer._Action.prototype = {
direction: deltaTime < 0 ? -1 : 1 direction: deltaTime < 0 ? -1 : 1
} ); } );
break; }
case THREE.LoopPingPong:
pingPong = true; } else { // repetitive Repeat or PingPong
case THREE.LoopRepeat: var pingPong = ( loop === THREE.LoopPingPong );
if ( loopCount === -1 ) { if ( loopCount === -1 ) {
// just started // just started
if ( deltaTime > 0 ) { if ( deltaTime >= 0 ) {
loopCount = 0; loopCount = 0;
...@@ -801,7 +793,6 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -801,7 +793,6 @@ THREE.AnimationMixer._Action.prototype = {
} }
if ( time >= duration || time < 0 ) { if ( time >= duration || time < 0 ) {
// wrap around // wrap around
var loopDelta = Math.floor( time / duration ); // signed var loopDelta = Math.floor( time / duration ); // signed
...@@ -812,8 +803,7 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -812,8 +803,7 @@ THREE.AnimationMixer._Action.prototype = {
var pending = this.repetitions - loopCount; var pending = this.repetitions - loopCount;
if ( pending < 0 ) { if ( pending < 0 ) {
// have to stop (switch state, clamp time, fire event)
// stop (switch state, clamp time, fire event)
if ( this.clampWhenFinished ) this.paused = true; if ( this.clampWhenFinished ) this.paused = true;
else this.enabled = false; else this.enabled = false;
...@@ -825,11 +815,11 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -825,11 +815,11 @@ THREE.AnimationMixer._Action.prototype = {
direction: deltaTime > 0 ? 1 : -1 direction: deltaTime > 0 ? 1 : -1
} ); } );
break; } else {
// keep running
} else if ( pending === 0 ) {
// transition to last round if ( pending === 0 ) {
// entering the last round
var atStart = deltaTime < 0; var atStart = deltaTime < 0;
this._setEndings( atStart, ! atStart, pingPong ); this._setEndings( atStart, ! atStart, pingPong );
...@@ -848,22 +838,19 @@ THREE.AnimationMixer._Action.prototype = { ...@@ -848,22 +838,19 @@ THREE.AnimationMixer._Action.prototype = {
} }
if ( loop === THREE.LoopPingPong && ( loopCount & 1 ) === 1 ) { }
if ( pingPong && ( loopCount & 1 ) === 1 ) {
// invert time for the "pong round" // invert time for the "pong round"
this.time = time; this.time = time;
return duration - time; return duration - time;
} }
break;
} }
this.time = time; this.time = time;
return time; return time;
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册