2
0
Эх сурвалжийг харах

Merge pull request #14383 from mrdoob/revert-14345-animation-optimize-optout

Revert "AnimationMixer: Move validate/optimization call, allow opt-out."
Mr.doob 7 жил өмнө
parent
commit
1476110de2

+ 1 - 19
docs/api/animation/AnimationClip.html

@@ -46,16 +46,6 @@
 			array via [page:.resetDuration resetDuration].
 		</p>
 
-		<h3>[property:Boolean isOptimized]</h3>
-		<p>
-			Whether the clip has been optimized with .optimize().
-		</p>
-
-		<h3>[property:Boolean isValidated]</h3>
-		<p>
-			Whether the clip has been validated with .validate().
-		</p>
-
 		<h3>[property:String name]</h3>
 		<p>
 			A name for this clip. A certain clip can be searched via [page:.findByName findByName].
@@ -79,8 +69,7 @@
 		<h3>[method:AnimationClip 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. Calling this
-			method will set [page:.isValidated isValidated] to true, and additional calls will do nothing.
+			sequences).
 		</p>
 
 		<h3>[method:null resetDuration]()</h3>
@@ -94,13 +83,6 @@
 			Trims all tracks to the clip's duration.
 		</p>
 
-		<h3>[method:AnimationClip validate]()</h3>
-		<p>
-			Performs minimal validation on each track in the clip. Called automatically by
-			[page:AnimationMixer]'s clipAction() method. Calling this method will set
-			[page:.isValidated isValidated] to true, and additional calls will do nothing.
-		</p>
-
 
 		<h2>Static Methods</h2>
 

+ 0 - 2
docs/api/animation/AnimationMixer.html

@@ -55,8 +55,6 @@
 			from the mixer's default root. The first parameter can be either an [page:AnimationClip] object
 			or the name of an AnimationClip.<br /><br />
 
-			Automatically calls .validate() and .optimize() on the clip.<br /><br />
-
 			If an action fitting these parameters doesn't yet exist, it will be created by this method.<br /><br />
 
 			Note: Calling this method several times with the same parameters returns always the same clip

+ 3 - 3
docs/api/animation/KeyframeTrack.html

@@ -204,8 +204,8 @@
 
 		<h3>[method:null optimize]()</h3>
 		<p>
-			Removes equivalent sequential keys, which are common in morph target sequences. Calling this
-			method will set [page:.isOptimized isOptimized] to true, and additional calls will do nothing.
+			Removes equivalent sequential keys, which are common in morph target sequences. Called
+			automatically by the constructor.
 		</p>
 
 		<h3>[method:null scale]()</h3>
@@ -236,7 +236,7 @@
 
 		<h3>[method:null validate]()</h3>
 		<p>
-			Performs minimal validation on the tracks.<br /><br />
+			Performs minimal validation on the tracks. Called automatically by the constructor.<br /><br />
 			This method logs errors to the console, if a track is empty, if the [page:.valueSize value size] is not valid, if an item
 			in the [page:.times times] or [page:.values values] array is not a valid number or if the items in the *times* array are out of order.
 		</p>

+ 2 - 23
src/animation/AnimationClip.js

@@ -19,9 +19,6 @@ function AnimationClip( name, duration, tracks ) {
 	this.tracks = tracks;
 	this.duration = ( duration !== undefined ) ? duration : - 1;
 
-	this.isValidated = false;
-	this.isOptimized = false;
-
 	this.uuid = _Math.generateUUID();
 
 	// this means it should figure out its duration by scanning the tracks
@@ -31,6 +28,8 @@ function AnimationClip( name, duration, tracks ) {
 
 	}
 
+	this.optimize();
+
 }
 
 Object.assign( AnimationClip, {
@@ -342,34 +341,14 @@ Object.assign( AnimationClip.prototype, {
 
 	},
 
-	validate: function () {
-
-		if ( this.isValidated ) return this;
-
-		for ( var i = 0; i < this.tracks.length; i ++ ) {
-
-			this.tracks[ i ].validate();
-
-		}
-
-		this.isValidated = true;
-
-		return this;
-
-	},
-
 	optimize: function () {
 
-		if ( this.isOptimized ) return this;
-
 		for ( var i = 0; i < this.tracks.length; i ++ ) {
 
 			this.tracks[ i ].optimize();
 
 		}
 
-		this.isOptimized = true;
-
 		return this;
 
 	}

+ 0 - 3
src/animation/AnimationMixer.js

@@ -555,9 +555,6 @@ AnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototy
 		// clip must be known when specified via string
 		if ( clipObject === null ) return null;
 
-		clipObject.validate();
-		clipObject.optimize();
-
 		// allocate all resources required to run it
 		var newAction = new AnimationAction( this, clipObject, optionalRoot );
 

+ 3 - 0
src/animation/KeyframeTrack.js

@@ -36,6 +36,9 @@ function KeyframeTrack( name, times, values, interpolation ) {
 
 	this.setInterpolation( interpolation || this.DefaultInterpolation );
 
+	this.validate();
+	this.optimize();
+
 }
 
 // Static methods:

+ 2 - 32
test/unit/src/animation/AnimationClip.tests.js

@@ -4,7 +4,6 @@
 /* global QUnit */
 
 import { AnimationClip } from '../../../../src/animation/AnimationClip';
-import { NumberKeyframeTrack } from '../../../../src/animation/tracks/NumberKeyframeTrack';
 
 export default QUnit.module( 'Animation', () => {
 
@@ -67,38 +66,9 @@ export default QUnit.module( 'Animation', () => {
 
 		} );
 
-		QUnit.test( 'optimize', ( assert ) => {
+		QUnit.todo( "optimize", ( assert ) => {
 
-			var track = new NumberKeyframeTrack( '.material.opacity', [ 0, 1, 2, 3, 4 ], [ 0, 0, 0, 0, 1 ] );
-			var clip = new AnimationClip( 'fadeIn', 4, [ track ] );
-
-			assert.equal( clip.tracks[0].values.length, 5 );
-
-			clip.isOptimized = true;
-			clip.optimize();
-
-			assert.equal( clip.tracks[0].values.length, 5 );
-
-			clip.isOptimized = false;
-			clip.optimize();
-
-			assert.equal( clip.tracks[0].values.length, 3 );
-
-		} );
-
-		QUnit.test( 'validate', ( assert ) => {
-
-			var track = new NumberKeyframeTrack( '.material.opacity', [ 0, 1 ], [ 0, NaN ] );
-			var clip = new AnimationClip( 'fadeIn', 1, [ track ] );
-
-			track.validate = () => { throw new Error('Validation should not be called.') };
-			clip.isValidated = true;
-			clip.validate();
-
-			delete track.validate;
-			clip.isValidated = false;
-			clip.validate();
-			assert.ok( clip.isValidated );
+			assert.ok( false, "everything's gonna be alright" );
 
 		} );