Browse Source

Protect Interpolant against the closure circular reference bug

Tristan VALCKE 8 years ago
parent
commit
f63ca88909
1 changed files with 14 additions and 19 deletions
  1. 14 19
      src/math/Interpolant.js

+ 14 - 19
src/math/Interpolant.js

@@ -20,8 +20,7 @@
  * @author tschw
  */
 
-function Interpolant(
-		parameterPositions, sampleValues, sampleSize, resultBuffer ) {
+function Interpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
 
 	this.parameterPositions = parameterPositions;
 	this._cachedIndex = 0;
@@ -33,10 +32,16 @@ function Interpolant(
 
 }
 
-Interpolant.prototype = {
+Object.assign( Interpolant.prototype, {
 
 	constructor: Interpolant,
 
+	beforeStart_: //( 0, t, t0 ), returns this.resultBuffer
+		Interpolant.prototype.copySampleValue_,
+
+	afterEnd_: //( N-1, tN-1, t ), returns this.resultBuffer
+		Interpolant.prototype.copySampleValue_,
+
 	evaluate: function( t ) {
 
 		var pp = this.parameterPositions,
@@ -52,10 +57,10 @@ Interpolant.prototype = {
 				var right;
 
 				linear_scan: {
-//- See http://jsperf.com/comparison-to-undefined/3
-//- slower code:
-//-
-//- 				if ( t >= t1 || t1 === undefined ) {
+					//- See http://jsperf.com/comparison-to-undefined/3
+					//- slower code:
+					//-
+					//- 				if ( t >= t1 || t1 === undefined ) {
 					forward_scan: if ( ! ( t < t1 ) ) {
 
 						for ( var giveUpAt = i1 + 2; ;) {
@@ -92,8 +97,8 @@ Interpolant.prototype = {
 
 					}
 
-//- slower code:
-//-					if ( t < t0 || t0 === undefined ) {
+					//- slower code:
+					//-					if ( t < t0 || t0 === undefined ) {
 					if ( ! ( t >= t0 ) ) {
 
 						// looping?
@@ -244,16 +249,6 @@ Interpolant.prototype = {
 
 	}
 
-};
-
-Object.assign( Interpolant.prototype, {
-
-	beforeStart_: //( 0, t, t0 ), returns this.resultBuffer
-		Interpolant.prototype.copySampleValue_,
-
-	afterEnd_: //( N-1, tN-1, t ), returns this.resultBuffer
-		Interpolant.prototype.copySampleValue_
-
 } );