Explorar o código

SphericalHarmonics3: Added fromArray() and toArray()

Mr.doob %!s(int64=6) %!d(string=hai) anos
pai
achega
21e3eab971
Modificáronse 1 ficheiros con 29 adicións e 0 borrados
  1. 29 0
      src/math/SphericalHarmonics3.js

+ 29 - 0
src/math/SphericalHarmonics3.js

@@ -175,6 +175,35 @@ Object.assign( SphericalHarmonics3.prototype, {
 
 		return new this.constructor().copy( this );
 
+	},
+
+	fromArray: function ( array ) {
+
+		var coefficients = this.coefficients;
+
+		for ( var i = 0; i < 9; i ++ ) {
+
+			coefficients[ i ].fromArray( array, i * 3 );
+
+		}
+
+		return this;
+
+	},
+
+	toArray: function () {
+
+		var array = [];
+		var coefficients = this.coefficients;
+
+		for ( var i = 0; i < 9; i ++ ) {
+
+			coefficients[ i ].toArray( array, i * 3 );
+
+		}
+
+		return array;
+
 	}
 
 } );