Skip to content

Commit 8d7d0f1

Browse files
committed
Renamed Matrix4's .extractPosition() and .extractRotation() to .copyPosition() and .copyRotation().
1 parent 4507615 commit 8d7d0f1

5 files changed

Lines changed: 63 additions & 49 deletions

File tree

docs/api/math/Matrix4.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ <h3>.copy( [page:Matrix4 m] ) [page:Matrix4]</h3>
6363
Copies a matrix *m* into this matrix.
6464
</div>
6565

66+
<h3>.copyPosition( [page:Matrix4 m] ) [page:Matrix4]</h3>
67+
<div>
68+
Copies the translation component of the supplied matrix *m* into this matrix translation component.
69+
</div>
70+
71+
<h3>.copyRotation( [page:Matrix4 m] ) [page:Matrix4]</h3>
72+
<div>
73+
Copies the rotation component of the supplied matrix *m* into this matrix rotation component.
74+
</div>
75+
6676
<h3>.lookAt( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4]</h3>
6777
<div>
6878
Constructs a rotation matrix, looking from *eye* towards *center* with defined *up* vector.
@@ -196,16 +206,6 @@ <h3>.decompose( [page:Vector3 translation], [page:Quaternion rotation], [page:Ve
196206
If parameters are not passed, new instances will be created.
197207
</div>
198208

199-
<h3>.extractPosition( [page:Matrix4 m] ) [page:Matrix4]</h3>
200-
<div>
201-
Copies the translation component of the supplied matrix *m* into this matrix translation component.
202-
</div>
203-
204-
<h3>.extractRotation( [page:Matrix4 m] ) [page:Matrix4]</h3>
205-
<div>
206-
Copies the rotation component of the supplied matrix *m* into this matrix rotation component.
207-
</div>
208-
209209
<h3>.makeTranslation( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]</h3>
210210
<div>
211211
Sets this matrix as translation transform.

examples/js/renderers/CSS3DRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ THREE.CSS3DRenderer = function () {
169169

170170
_tmpMatrix.copy( camera.matrixWorldInverse );
171171
_tmpMatrix.transpose();
172-
_tmpMatrix.extractPosition( object.matrixWorld );
172+
_tmpMatrix.copyPosition( object.matrixWorld );
173173
_tmpMatrix.scale( object.scale );
174174

175175
_tmpMatrix.elements[ 3 ] = 0;

src/core/Object3D.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ THREE.Object3D.prototype = {
6363

6464
this.scale.getScaleFromMatrix( this.matrix );
6565

66-
m1.extractRotation( this.matrix );
66+
m1.copyRotation( this.matrix );
6767

6868
if ( this.useQuaternion === true ) {
6969

src/core/Raycaster.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
var a, b, c, d;
8585
var precision = raycaster.precision;
8686

87-
object.matrixRotationWorld.extractRotation( object.matrixWorld );
87+
object.matrixRotationWorld.copyRotation( object.matrixWorld );
8888

8989
inverseMatrix.getInverse( object.matrixWorld );
9090

src/math/Matrix4.js

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,50 @@ THREE.Matrix4.prototype = {
7575

7676
},
7777

78+
copyPosition: function ( m ) {
79+
80+
var te = this.elements;
81+
var me = m.elements;
82+
83+
te[12] = me[12];
84+
te[13] = me[13];
85+
te[14] = me[14];
86+
87+
return this;
88+
89+
},
90+
91+
copyRotation: function () {
92+
93+
var v1 = new THREE.Vector3();
94+
95+
return function ( m ) {
96+
97+
var te = this.elements;
98+
var me = m.elements;
99+
100+
var scaleX = 1 / v1.set( me[0], me[1], me[2] ).length();
101+
var scaleY = 1 / v1.set( me[4], me[5], me[6] ).length();
102+
var scaleZ = 1 / v1.set( me[8], me[9], me[10] ).length();
103+
104+
te[0] = me[0] * scaleX;
105+
te[1] = me[1] * scaleX;
106+
te[2] = me[2] * scaleX;
107+
108+
te[4] = me[4] * scaleY;
109+
te[5] = me[5] * scaleY;
110+
te[6] = me[6] * scaleY;
111+
112+
te[8] = me[8] * scaleZ;
113+
te[9] = me[9] * scaleZ;
114+
te[10] = me[10] * scaleZ;
115+
116+
return this;
117+
118+
};
119+
120+
}(),
121+
78122
setRotationFromEuler: function ( v, order ) {
79123

80124
var te = this.elements;
@@ -586,47 +630,17 @@ THREE.Matrix4.prototype = {
586630

587631
extractPosition: function ( m ) {
588632

589-
var te = this.elements;
590-
var me = m.elements;
591-
592-
te[12] = me[12];
593-
te[13] = me[13];
594-
te[14] = me[14];
595-
596-
return this;
633+
console.warn( 'DEPRECATED: Matrix4\'s .extractPosition() has been renamed to .copyPosition().' );
634+
return this.copyPosition( m );
597635

598636
},
599637

600-
extractRotation: function () {
601-
602-
var v1 = new THREE.Vector3();
603-
604-
return function ( m ) {
638+
extractRotation: function ( m ) {
605639

606-
var te = this.elements;
607-
var me = m.elements;
640+
console.warn( 'DEPRECATED: Matrix4\'s .extractRotation() has been renamed to .copyRotation().' );
641+
return this.copyRotation( m );
608642

609-
var scaleX = 1 / v1.set( me[0], me[1], me[2] ).length();
610-
var scaleY = 1 / v1.set( me[4], me[5], me[6] ).length();
611-
var scaleZ = 1 / v1.set( me[8], me[9], me[10] ).length();
612-
613-
te[0] = me[0] * scaleX;
614-
te[1] = me[1] * scaleX;
615-
te[2] = me[2] * scaleX;
616-
617-
te[4] = me[4] * scaleY;
618-
te[5] = me[5] * scaleY;
619-
te[6] = me[6] * scaleY;
620-
621-
te[8] = me[8] * scaleZ;
622-
te[9] = me[9] * scaleZ;
623-
te[10] = me[10] * scaleZ;
624-
625-
return this;
626-
627-
};
628-
629-
}(),
643+
},
630644

631645
translate: function ( v ) {
632646

0 commit comments

Comments
 (0)