Browse Source

SphericalHarmonics3: Added fromArray() and toArray()

Mr.doob 6 years ago
parent
commit
21e3eab971
1 changed files with 29 additions and 0 deletions
  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;
+
 	}
 
 } );