Просмотр исходного кода

Merge pull request #15224 from yomotsu/feature/cleanup-animations

Animations: clean up
Mr.doob 6 лет назад
Родитель
Сommit
a5c81d2f0c

+ 19 - 17
src/animation/AnimationAction.js

@@ -36,13 +36,13 @@ function AnimationAction( mixer, clip, localRoot ) {
 
 
 	this._interpolantSettings = interpolantSettings;
 	this._interpolantSettings = interpolantSettings;
 
 
-	this._interpolants = interpolants;	// bound by the mixer
+	this._interpolants = interpolants; // bound by the mixer
 
 
 	// inside: PropertyMixer (managed by the mixer)
 	// inside: PropertyMixer (managed by the mixer)
 	this._propertyBindings = new Array( nTracks );
 	this._propertyBindings = new Array( nTracks );
 
 
-	this._cacheIndex = null;			// for the memory manager
-	this._byClipCacheIndex = null;		// for the memory manager
+	this._cacheIndex = null; // for the memory manager
+	this._byClipCacheIndex = null; // for the memory manager
 
 
 	this._timeScaleInterpolant = null;
 	this._timeScaleInterpolant = null;
 	this._weightInterpolant = null;
 	this._weightInterpolant = null;
@@ -64,15 +64,15 @@ function AnimationAction( mixer, clip, localRoot ) {
 	this.weight = 1;
 	this.weight = 1;
 	this._effectiveWeight = 1;
 	this._effectiveWeight = 1;
 
 
-	this.repetitions = Infinity; 		// no. of repetitions when looping
+	this.repetitions = Infinity; // no. of repetitions when looping
 
 
-	this.paused = false;				// true -> zero effective time scale
-	this.enabled = true;				// false -> zero effective weight
+	this.paused = false; // true -> zero effective time scale
+	this.enabled = true; // false -> zero effective weight
 
 
-	this.clampWhenFinished 	= false;	// keep feeding the last frame?
+	this.clampWhenFinished = false;// keep feeding the last frame?
 
 
-	this.zeroSlopeAtStart 	= true;		// for smooth interpolation w/o separate
-	this.zeroSlopeAtEnd		= true;		// clips for start, loop and end
+	this.zeroSlopeAtStart = true;// for smooth interpolation w/o separate
+	this.zeroSlopeAtEnd = true;// clips for start, loop and end
 
 
 }
 }
 
 
@@ -101,9 +101,9 @@ Object.assign( AnimationAction.prototype, {
 		this.paused = false;
 		this.paused = false;
 		this.enabled = true;
 		this.enabled = true;
 
 
-		this.time = 0;			// restart clip
-		this._loopCount = - 1;	// forget previous loops
-		this._startTime = null;	// forget scheduling
+		this.time = 0; // restart clip
+		this._loopCount = - 1;// forget previous loops
+		this._startTime = null;// forget scheduling
 
 
 		return this.stopFading().stopWarping();
 		return this.stopFading().stopWarping();
 
 
@@ -112,7 +112,7 @@ Object.assign( AnimationAction.prototype, {
 	isRunning: function () {
 	isRunning: function () {
 
 
 		return this.enabled && ! this.paused && this.timeScale !== 0 &&
 		return this.enabled && ! this.paused && this.timeScale !== 0 &&
-				this._startTime === null && this._mixer._isActiveAction( this );
+			this._startTime === null && this._mixer._isActiveAction( this );
 
 
 	},
 	},
 
 
@@ -613,8 +613,8 @@ Object.assign( AnimationAction.prototype, {
 
 
 		if ( pingPong ) {
 		if ( pingPong ) {
 
 
-			settings.endingStart 	= ZeroSlopeEnding;
-			settings.endingEnd		= ZeroSlopeEnding;
+			settings.endingStart = ZeroSlopeEnding;
+			settings.endingEnd = ZeroSlopeEnding;
 
 
 		} else {
 		} else {
 
 
@@ -659,8 +659,10 @@ Object.assign( AnimationAction.prototype, {
 		var times = interpolant.parameterPositions,
 		var times = interpolant.parameterPositions,
 			values = interpolant.sampleValues;
 			values = interpolant.sampleValues;
 
 
-		times[ 0 ] = now; 				values[ 0 ] = weightNow;
-		times[ 1 ] = now + duration;	values[ 1 ] = weightThen;
+		times[ 0 ] = now;
+		values[ 0 ] = weightNow;
+		times[ 1 ] = now + duration;
+		values[ 1 ] = weightThen;
 
 
 		return this;
 		return this;
 
 

+ 2 - 2
src/animation/AnimationMixer.js

@@ -176,8 +176,8 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy
 		this._actionsByClip = {};
 		this._actionsByClip = {};
 		// inside:
 		// inside:
 		// {
 		// {
-		// 		knownActions: Array< AnimationAction >	- used as prototypes
-		// 		actionByRoot: AnimationAction			- lookup
+		// 	knownActions: Array< AnimationAction > - used as prototypes
+		// 	actionByRoot: AnimationAction - lookup
 		// }
 		// }
 
 
 
 

+ 19 - 19
src/animation/AnimationObjectGroup.js

@@ -7,27 +7,27 @@ import { _Math } from '../math/Math.js';
  *
  *
  * Usage:
  * Usage:
  *
  *
- * 	-	Add objects you would otherwise pass as 'root' to the
- * 		constructor or the .clipAction method of AnimationMixer.
+ *  - Add objects you would otherwise pass as 'root' to the
+ *    constructor or the .clipAction method of AnimationMixer.
  *
  *
- * 	-	Instead pass this object as 'root'.
+ *  - Instead pass this object as 'root'.
  *
  *
- * 	-	You can also add and remove objects later when the mixer
- * 		is running.
+ *  - You can also add and remove objects later when the mixer
+ *    is running.
  *
  *
  * Note:
  * Note:
  *
  *
- *  	Objects of this class appear as one object to the mixer,
- *  	so cache control of the individual objects must be done
- *  	on the group.
+ *    Objects of this class appear as one object to the mixer,
+ *    so cache control of the individual objects must be done
+ *    on the group.
  *
  *
  * Limitation:
  * Limitation:
  *
  *
- * 	- 	The animated properties must be compatible among the
- * 		all objects in the group.
+ *  - The animated properties must be compatible among the
+ *    all objects in the group.
  *
  *
- *  -	A single property can either be controlled through a
- *  	target group or directly, but not both.
+ *  - A single property can either be controlled through a
+ *    target group or directly, but not both.
  *
  *
  * @author tschw
  * @author tschw
  */
  */
@@ -39,11 +39,11 @@ function AnimationObjectGroup() {
 	// cached objects followed by the active ones
 	// cached objects followed by the active ones
 	this._objects = Array.prototype.slice.call( arguments );
 	this._objects = Array.prototype.slice.call( arguments );
 
 
-	this.nCachedObjects_ = 0;			// threshold
+	this.nCachedObjects_ = 0; // threshold
 	// note: read by PropertyBinding.Composite
 	// note: read by PropertyBinding.Composite
 
 
 	var indices = {};
 	var indices = {};
-	this._indicesByUUID = indices;		// for bookkeeping
+	this._indicesByUUID = indices; // for bookkeeping
 
 
 	for ( var i = 0, n = arguments.length; i !== n; ++ i ) {
 	for ( var i = 0, n = arguments.length; i !== n; ++ i ) {
 
 
@@ -51,10 +51,10 @@ function AnimationObjectGroup() {
 
 
 	}
 	}
 
 
-	this._paths = [];					// inside: string
-	this._parsedPaths = [];				// inside: { we don't care, here }
-	this._bindings = []; 				// inside: Array< PropertyBinding >
-	this._bindingsIndicesByPath = {}; 	// inside: indices in these arrays
+	this._paths = []; // inside: string
+	this._parsedPaths = []; // inside: { we don't care, here }
+	this._bindings = []; // inside: Array< PropertyBinding >
+	this._bindingsIndicesByPath = {}; // inside: indices in these arrays
 
 
 	var scope = this;
 	var scope = this;
 
 
@@ -162,7 +162,7 @@ Object.assign( AnimationObjectGroup.prototype, {
 			} else if ( objects[ index ] !== knownObject ) {
 			} else if ( objects[ index ] !== knownObject ) {
 
 
 				console.error( 'THREE.AnimationObjectGroup: Different objects with the same UUID ' +
 				console.error( 'THREE.AnimationObjectGroup: Different objects with the same UUID ' +
-						'detected. Clean the caches or recreate your infrastructure when reloading scenes.' );
+					'detected. Clean the caches or recreate your infrastructure when reloading scenes.' );
 
 
 			} // else the object is already where we want it to be
 			} // else the object is already where we want it to be
 
 

+ 2 - 2
src/animation/AnimationUtils.js

@@ -25,7 +25,7 @@ var AnimationUtils = {
 	convertArray: function ( array, type, forceClone ) {
 	convertArray: function ( array, type, forceClone ) {
 
 
 		if ( ! array || // let 'undefined' and 'null' pass
 		if ( ! array || // let 'undefined' and 'null' pass
-				! forceClone && array.constructor === type ) return array;
+			! forceClone && array.constructor === type ) return array;
 
 
 		if ( typeof type.BYTES_PER_ELEMENT === 'number' ) {
 		if ( typeof type.BYTES_PER_ELEMENT === 'number' ) {
 
 
@@ -40,7 +40,7 @@ var AnimationUtils = {
 	isTypedArray: function ( object ) {
 	isTypedArray: function ( object ) {
 
 
 		return ArrayBuffer.isView( object ) &&
 		return ArrayBuffer.isView( object ) &&
-				! ( object instanceof DataView );
+			! ( object instanceof DataView );
 
 
 	},
 	},
 
 

+ 3 - 6
src/animation/PropertyBinding.js

@@ -38,8 +38,7 @@ Object.assign( Composite.prototype, {
 
 
 		var bindings = this._bindings;
 		var bindings = this._bindings;
 
 
-		for ( var i = this._targetGroup.nCachedObjects_,
-				  n = bindings.length; i !== n; ++ i ) {
+		for ( var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) {
 
 
 			bindings[ i ].setValue( array, offset );
 			bindings[ i ].setValue( array, offset );
 
 
@@ -51,8 +50,7 @@ Object.assign( Composite.prototype, {
 
 
 		var bindings = this._bindings;
 		var bindings = this._bindings;
 
 
-		for ( var i = this._targetGroup.nCachedObjects_,
-				  n = bindings.length; i !== n; ++ i ) {
+		for ( var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) {
 
 
 			bindings[ i ].bind();
 			bindings[ i ].bind();
 
 
@@ -64,8 +62,7 @@ Object.assign( Composite.prototype, {
 
 
 		var bindings = this._bindings;
 		var bindings = this._bindings;
 
 
-		for ( var i = this._targetGroup.nCachedObjects_,
-				  n = bindings.length; i !== n; ++ i ) {
+		for ( var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) {
 
 
 			bindings[ i ].unbind();
 			bindings[ i ].unbind();