提交 141ad4f8 编写于 作者: M Mr.doob

Simplified Matrix* constructors. See #5202.

上级 c5acf1a7
......@@ -4,15 +4,21 @@
* @author bhouston / http://exocortex.com
*/
THREE.Matrix3 = function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {
THREE.Matrix3 = function () {
this.elements = new Float32Array( 9 );
this.elements = new Float32Array( [
var te = this.elements;
1, 0, 0,
0, 1, 0,
0, 0, 1
te[ 0 ] = ( n11 !== undefined ) ? n11 : 1; te[ 3 ] = n12 || 0; te[ 6 ] = n13 || 0;
te[ 1 ] = n21 || 0; te[ 4 ] = ( n22 !== undefined ) ? n22 : 1; te[ 7 ] = n23 || 0;
te[ 2 ] = n31 || 0; te[ 5 ] = n32 || 0; te[ 8 ] = ( n33 !== undefined ) ? n33 : 1;
] );
if ( arguments.length > 0 ) {
console.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );
}
};
......@@ -259,15 +265,7 @@ THREE.Matrix3.prototype = {
clone: function () {
var te = this.elements;
return new THREE.Matrix3(
te[ 0 ], te[ 3 ], te[ 6 ],
te[ 1 ], te[ 4 ], te[ 7 ],
te[ 2 ], te[ 5 ], te[ 8 ]
);
return new THREE.Matrix3().fromArray( this.elements );
}
......
......@@ -11,20 +11,22 @@
* @author WestLangley / http://github.com/WestLangley
*/
THREE.Matrix4 = function () {
THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
this.elements = new Float32Array( [
this.elements = new Float32Array( 16 );
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
// TODO: if n11 is undefined, then just set to identity, otherwise copy all other values into matrix
// we should not support semi specification of Matrix4, it is just weird.
] );
var te = this.elements;
if ( arguments.length > 0 ) {
te[ 0 ] = ( n11 !== undefined ) ? n11 : 1; te[ 4 ] = n12 || 0; te[ 8 ] = n13 || 0; te[ 12 ] = n14 || 0;
te[ 1 ] = n21 || 0; te[ 5 ] = ( n22 !== undefined ) ? n22 : 1; te[ 9 ] = n23 || 0; te[ 13 ] = n24 || 0;
te[ 2 ] = n31 || 0; te[ 6 ] = n32 || 0; te[ 10 ] = ( n33 !== undefined ) ? n33 : 1; te[ 14 ] = n34 || 0;
te[ 3 ] = n41 || 0; te[ 7 ] = n42 || 0; te[ 11 ] = n43 || 0; te[ 15 ] = ( n44 !== undefined ) ? n44 : 1;
console.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );
}
};
......@@ -70,7 +72,7 @@ THREE.Matrix4.prototype = {
extractPosition: function ( m ) {
console.warn( 'THREEMatrix4: .extractPosition() has been renamed to .copyPosition().' );
console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' );
return this.copyPosition( m );
},
......@@ -954,16 +956,7 @@ THREE.Matrix4.prototype = {
clone: function () {
var te = this.elements;
return new THREE.Matrix4(
te[ 0 ], te[ 4 ], te[ 8 ], te[ 12 ],
te[ 1 ], te[ 5 ], te[ 9 ], te[ 13 ],
te[ 2 ], te[ 6 ], te[ 10 ], te[ 14 ],
te[ 3 ], te[ 7 ], te[ 11 ], te[ 15 ]
);
return new THREE.Matrix4().fromArray( this.elements );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册