提交 5b39846a 编写于 作者: M Mr.doob

Matrix*: Dumber copy()

上级 8b31096b
...@@ -66,7 +66,9 @@ Object.assign( Matrix3.prototype, { ...@@ -66,7 +66,9 @@ Object.assign( Matrix3.prototype, {
var te = this.elements; var te = this.elements;
var me = m.elements; var me = m.elements;
for ( var i = 0; i < 9; i ++ ) te[ i ] = me[ i ]; te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];
te[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];
te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];
return this; return this;
......
...@@ -75,7 +75,10 @@ Object.assign( Matrix4.prototype, { ...@@ -75,7 +75,10 @@ Object.assign( Matrix4.prototype, {
var te = this.elements; var te = this.elements;
var me = m.elements; var me = m.elements;
for ( var i = 0; i < 16; i ++ ) te[ i ] = me[ i ]; te[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];
te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];
te[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];
te[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];
return this; return this;
...@@ -764,18 +767,14 @@ Object.assign( Matrix4.prototype, { ...@@ -764,18 +767,14 @@ Object.assign( Matrix4.prototype, {
// if determine is negative, we need to invert one scale // if determine is negative, we need to invert one scale
var det = this.determinant(); var det = this.determinant();
if ( det < 0 ) { if ( det < 0 ) sx = - sx;
sx = - sx;
}
position.x = te[ 12 ]; position.x = te[ 12 ];
position.y = te[ 13 ]; position.y = te[ 13 ];
position.z = te[ 14 ]; position.z = te[ 14 ];
// scale the rotation part // scale the rotation part
for ( var i = 0; i < 16; i ++ ) matrix.elements[ i ] = this.elements[ i ]; // at this point matrix is incomplete so we can't use .copy() matrix.copy( this );
var invSX = 1 / sx; var invSX = 1 / sx;
var invSY = 1 / sy; var invSY = 1 / sy;
...@@ -870,7 +869,7 @@ Object.assign( Matrix4.prototype, { ...@@ -870,7 +869,7 @@ Object.assign( Matrix4.prototype, {
if ( offset === undefined ) offset = 0; if ( offset === undefined ) offset = 0;
for( var i = 0; i < 16; i ++ ) { for ( var i = 0; i < 16; i ++ ) {
this.elements[ i ] = array[ i + offset ]; this.elements[ i ] = array[ i + offset ];
...@@ -897,8 +896,8 @@ Object.assign( Matrix4.prototype, { ...@@ -897,8 +896,8 @@ Object.assign( Matrix4.prototype, {
array[ offset + 6 ] = te[ 6 ]; array[ offset + 6 ] = te[ 6 ];
array[ offset + 7 ] = te[ 7 ]; array[ offset + 7 ] = te[ 7 ];
array[ offset + 8 ] = te[ 8 ]; array[ offset + 8 ] = te[ 8 ];
array[ offset + 9 ] = te[ 9 ]; array[ offset + 9 ] = te[ 9 ];
array[ offset + 10 ] = te[ 10 ]; array[ offset + 10 ] = te[ 10 ];
array[ offset + 11 ] = te[ 11 ]; array[ offset + 11 ] = te[ 11 ];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册