Forráskód Böngészése

Animation: Clean up chaining methods and docs.

Don McCurdy 7 éve
szülő
commit
5566ecfad1

+ 6 - 6
docs/api/animation/AnimationClip.html

@@ -66,27 +66,27 @@
 		<h2>Methods</h2>
 
 
-		<h3>[method:AnimationClip optimize]()</h3>
+		<h3>[method:this optimize]()</h3>
 		<p>
 			Optimizes each track by removing equivalent sequential keys (which are common in morph target
-			sequences). Called automatically by [page:AnimationMixer]'s clipAction() method.
+			sequences). Called automatically by [page:AnimationMixer.clipAction mixer.clipAction]().
 		</p>
 
-		<h3>[method:null resetDuration]()</h3>
+		<h3>[method:this resetDuration]()</h3>
 		<p>
 			Sets the [page:.duration duration] of the clip to the duration of its longest
 			[page:KeyframeTrack].
 		</p>
 
-		<h3>[method:AnimationClip trim]()</h3>
+		<h3>[method:this trim]()</h3>
 		<p>
 			Trims all tracks to the clip's duration.
 		</p>
 
-		<h3>[method:AnimationClip validate]()</h3>
+		<h3>[method:Boolean validate]()</h3>
 		<p>
 			Performs minimal validation on each track in the clip. Called automatically by
-			[page:AnimationMixer]'s clipAction() method.
+			[page:AnimationMixer.clipAction mixer.clipAction](). Returns true if all tracks are valid.
 		</p>
 
 

+ 9 - 7
docs/api/animation/KeyframeTrack.html

@@ -202,12 +202,13 @@
 			created automatically.
 		</p>
 
-		<h3>[method:null optimize]()</h3>
+		<h3>[method:this optimize]()</h3>
 		<p>
 			Removes equivalent sequential keys, which are common in morph target sequences.
+			Called automatically by [page:AnimationMixer.clipAction mixer.clipAction]().
 		</p>
 
-		<h3>[method:null scale]()</h3>
+		<h3>[method:this scale]()</h3>
 		<p>
 			Scales all keyframe times by a factor.<br /><br />
 
@@ -216,26 +217,27 @@
 			[page:AnimationClip.CreateFromMorphTargetSequence animationClip.CreateFromMorphTargetSequence]).
 		</p>
 
-		<h3>[method:null setInterpolation]( [param:Constant interpolationType] )</h3>
+		<h3>[method:this setInterpolation]( [param:Constant interpolationType] )</h3>
 		<p>
 			Sets the interpolation type. See [page:Animation Animation Constants] for choices.
 		</p>
 
-		<h3>[method:null shift]( [param:Number timeOffsetInSeconds] )</h3>
+		<h3>[method:this shift]( [param:Number timeOffsetInSeconds] )</h3>
 		<p>
 			Moves all keyframes either forward or backward in time.
 		</p>
 
 
-		<h3>[method:null trim]( [param:Number startTimeInSeconds], [param:Number endTimeInSeconds] )</h3>
+		<h3>[method:this trim]( [param:Number startTimeInSeconds], [param:Number endTimeInSeconds] )</h3>
 		<p>
 			Removes keyframes before *startTime* and after *endTime*,
 			without changing any values within the range [*startTime*, *endTime*].
 		</p>
 
-		<h3>[method:null validate]()</h3>
+		<h3>[method:Boolean validate]()</h3>
 		<p>
-			Performs minimal validation on the tracks.
+			Performs minimal validation on the tracks. Called automatically by
+			[page:AnimationMixer.clipAction mixer.clipAction](). Returns true if valid.
 		</p>
 
 		<p>

+ 6 - 2
src/animation/AnimationClip.js

@@ -325,6 +325,8 @@ Object.assign( AnimationClip.prototype, {
 
 		this.duration = duration;
 
+		return this;
+
 	},
 
 	trim: function () {
@@ -341,13 +343,15 @@ Object.assign( AnimationClip.prototype, {
 
 	validate: function () {
 
+		var valid = true;
+
 		for ( var i = 0; i < this.tracks.length; i ++ ) {
 
-			this.tracks[ i ].validate();
+			valid = valid && this.tracks[ i ].validate();
 
 		}
 
-		return this;
+		return valid;
 
 	},
 

+ 1 - 2
src/animation/AnimationMixer.js

@@ -557,8 +557,7 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy
 
 		if ( needsValidateAndOptimize !== false ) {
 
-			clipObject.validate();
-			clipObject.optimize();
+			if ( clipObject.validate() ) clipObject.optimize();
 
 		}
 

+ 3 - 1
src/animation/KeyframeTrack.js

@@ -243,12 +243,14 @@ Object.assign( KeyframeTrack.prototype, {
 			}
 
 			console.warn( 'THREE.KeyframeTrack:', message );
-			return;
+			return this;
 
 		}
 
 		this.createInterpolant = factoryMethod;
 
+		return this;
+
 	},
 
 	getInterpolation: function () {