浏览代码

KeyframeTrack: Make validated/optimized flags private.

Don McCurdy 7 年之前
父节点
当前提交
a78faf6ba6
共有 2 个文件被更改,包括 23 次插入21 次删除
  1. 2 15
      docs/api/animation/KeyframeTrack.html
  2. 21 6
      src/animation/KeyframeTrack.js

+ 2 - 15
docs/api/animation/KeyframeTrack.html

@@ -91,16 +91,6 @@
 		<h2>Properties</h2>
 		<h2>Properties</h2>
 
 
 
 
-		<h3>[property:Boolean isOptimized]</h3>
-		<p>
-			Whether the track has been optimized with .optimize().
-		</p>
-
-		<h3>[property:Boolean isValidated]</h3>
-		<p>
-			Whether the track has been successfully validated with .validate().
-		</p>
-
 		<h3>[property:String name]</h3>
 		<h3>[property:String name]</h3>
 		<p>
 		<p>
 			The track's name can refer to [page:Geometry.morphTargets morph targets] or
 			The track's name can refer to [page:Geometry.morphTargets morph targets] or
@@ -214,8 +204,7 @@
 
 
 		<h3>[method:null optimize]()</h3>
 		<h3>[method:null optimize]()</h3>
 		<p>
 		<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.
 		</p>
 		</p>
 
 
 		<h3>[method:null scale]()</h3>
 		<h3>[method:null scale]()</h3>
@@ -246,9 +235,7 @@
 
 
 		<h3>[method:null validate]()</h3>
 		<h3>[method:null validate]()</h3>
 		<p>
 		<p>
-			Performs minimal validation on the tracks.  Calling this method will set
-			[page:.isValidated isValidated] to true if validation succeeds, and additional calls will do
-			nothing.
+			Performs minimal validation on the tracks.
 		</p>
 		</p>
 
 
 		<p>
 		<p>

+ 21 - 6
src/animation/KeyframeTrack.js

@@ -34,8 +34,11 @@ function KeyframeTrack( name, times, values, interpolation ) {
 	this.times = AnimationUtils.convertArray( times, this.TimeBufferType );
 	this.times = AnimationUtils.convertArray( times, this.TimeBufferType );
 	this.values = AnimationUtils.convertArray( values, this.ValueBufferType );
 	this.values = AnimationUtils.convertArray( values, this.ValueBufferType );
 
 
-	this.isValidated = false;
-	this.isOptimized = false;
+	// TODO: These flags are used to warn users of duplicate validate/optimize
+	// calls when multiple actions are created from a single clip, starting with
+	// r95. We will eventually remove these flags and the transitional warnings.
+	this._needsValidate = true;
+	this._needsOptimize = true;
 
 
 	this.setInterpolation( interpolation || this.DefaultInterpolation );
 	this.setInterpolation( interpolation || this.DefaultInterpolation );
 
 
@@ -353,7 +356,13 @@ Object.assign( KeyframeTrack.prototype, {
 	// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
 	// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
 	validate: function () {
 	validate: function () {
 
 
-		if ( this.isValidated ) return true;
+		if ( ! this._needsValidate ) {
+
+			console.warn( 'THREE.KeyframeTrack: Track has already been validated. '
+				+ 'Disable "needsValidateAndOptimize" argument to mixer.clipAction() '
+				+ 'to avoid redundant validation.' );
+
+		}
 
 
 		var valid = true;
 		var valid = true;
 
 
@@ -425,7 +434,7 @@ Object.assign( KeyframeTrack.prototype, {
 
 
 		}
 		}
 
 
-		this.isValidated = valid;
+		this._needsValidate = !valid;
 
 
 		return valid;
 		return valid;
 
 
@@ -435,7 +444,13 @@ Object.assign( KeyframeTrack.prototype, {
 	// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
 	// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
 	optimize: function () {
 	optimize: function () {
 
 
-		if ( this.isOptimized ) return this;
+		if ( ! this._needsOptimize ) {
+
+			console.warn( 'THREE.KeyframeTrack: Track has already been optimized. '
+				+ 'Disable "needsValidateAndOptimize" argument to mixer.clipAction() '
+				+ 'to avoid redundant optimization.' );
+
+		}
 
 
 		var times = this.times,
 		var times = this.times,
 			values = this.values,
 			values = this.values,
@@ -535,7 +550,7 @@ Object.assign( KeyframeTrack.prototype, {
 
 
 		}
 		}
 
 
-		this.isOptimized = true;
+		this._needsOptimize = false;
 
 
 		return this;
 		return this;