提交 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 @@
<script src="../build/three.js"></script>
<script src="js/libs/stats.min.js"></script>
<script src="js/AnimationClipCreator.js"></script>
<script>
......
......@@ -36,7 +36,6 @@
<script src="../build/three.js"></script>
<script src="js/controls/TrackballControls.js"></script>
<script src="js/AnimationClipCreator.js"></script>
<script src="js/Detector.js"></script>
<script src="js/libs/stats.min.js"></script>
......
......@@ -731,22 +731,19 @@ THREE.AnimationMixer._Action.prototype = {
var duration = this._clip.duration,
loop = this.loop,
loopCount = this._loopCount,
loopCount = this._loopCount;
pingPong = false;
if ( loop === THREE.LoopOnce ) {
switch ( loop ) {
if ( loopCount === -1 ) {
// just started
case THREE.LoopOnce:
this.loopCount = 0;
this._setEndings( true, true, false );
if ( loopCount === -1 ) {
// just started
this.loopCount = 0;
this._setEndings( true, true, false );
}
}
handle_stop: {
if ( time >= duration ) {
......@@ -756,9 +753,7 @@ THREE.AnimationMixer._Action.prototype = {
time = 0;
} else break;
// reached the end
} else break handle_stop;
if ( this.clampWhenFinished ) this.pause = true;
else this.enabled = false;
......@@ -768,68 +763,63 @@ THREE.AnimationMixer._Action.prototype = {
direction: deltaTime < 0 ? -1 : 1
} );
break;
case THREE.LoopPingPong:
pingPong = true;
}
case THREE.LoopRepeat:
} else { // repetitive Repeat or PingPong
if ( loopCount === -1 ) {
var pingPong = ( loop === THREE.LoopPingPong );
// just started
if ( loopCount === -1 ) {
// just started
if ( deltaTime > 0 ) {
if ( deltaTime >= 0 ) {
loopCount = 0;
loopCount = 0;
this._setEndings(
true, this.repetitions === 0, pingPong );
this._setEndings(
true, this.repetitions === 0, pingPong );
} else {
} else {
// when looping in reverse direction, the initial
// transition through zero counts as a repetition,
// so leave loopCount at -1
// when looping in reverse direction, the initial
// transition through zero counts as a repetition,
// so leave loopCount at -1
this._setEndings(
this.repetitions === 0, true, pingPong );
}
this._setEndings(
this.repetitions === 0, true, pingPong );
}
if ( time >= duration || time < 0 ) {
// wrap around
var loopDelta = Math.floor( time / duration ); // signed
time -= duration * loopDelta;
}
loopCount += Math.abs( loopDelta );
if ( time >= duration || time < 0 ) {
// wrap around
var pending = this.repetitions - loopCount;
var loopDelta = Math.floor( time / duration ); // signed
time -= duration * loopDelta;
if ( pending < 0 ) {
loopCount += Math.abs( loopDelta );
// stop (switch state, clamp time, fire event)
var pending = this.repetitions - loopCount;
if ( this.clampWhenFinished ) this.paused = true;
else this.enabled = false;
if ( pending < 0 ) {
// have to stop (switch state, clamp time, fire event)
time = deltaTime > 0 ? duration : 0;
if ( this.clampWhenFinished ) this.paused = true;
else this.enabled = false;
this._mixer.dispatchEvent( {
type: 'finished', action: this,
direction: deltaTime > 0 ? 1 : -1
} );
time = deltaTime > 0 ? duration : 0;
break;
this._mixer.dispatchEvent( {
type: 'finished', action: this,
direction: deltaTime > 0 ? 1 : -1
} );
} else if ( pending === 0 ) {
} else {
// keep running
// transition to last round
if ( pending === 0 ) {
// entering the last round
var atStart = deltaTime < 0;
this._setEndings( atStart, ! atStart, pingPong );
......@@ -848,22 +838,19 @@ THREE.AnimationMixer._Action.prototype = {
}
if ( loop === THREE.LoopPingPong && ( loopCount & 1 ) === 1 ) {
// invert time for the "pong round"
this.time = time;
}
return duration - time;
if ( pingPong && ( loopCount & 1 ) === 1 ) {
// invert time for the "pong round"
}
this.time = time;
return duration - time;
break;
}
}
this.time = time;
return time;
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册