浏览代码

SphericalHarmonics3: Added fromArray() and toArray()

Mr.doob 6 年之前
父节点
当前提交
21e3eab971
共有 1 个文件被更改,包括 29 次插入0 次删除
  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 );
 		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;
+
 	}
 	}
 
 
 } );
 } );