2
0
Эх сурвалжийг харах

Renamed Matrix4's .extractPosition() and .extractRotation() to .copyPosition() and .copyRotation().

Mr.doob 12 жил өмнө
parent
commit
8d7d0f17e0

+ 10 - 10
docs/api/math/Matrix4.html

@@ -63,6 +63,16 @@
 		Copies a matrix *m* into this matrix.
 		</div>
 
+		<h3>.copyPosition( [page:Matrix4 m] ) [page:Matrix4]</h3>
+		<div>
+		Copies the translation component of the supplied matrix *m* into this matrix translation component.
+		</div>
+
+		<h3>.copyRotation( [page:Matrix4 m] ) [page:Matrix4]</h3>
+		<div>
+		Copies the rotation component of the supplied matrix *m* into this matrix rotation component.
+		</div>
+
 		<h3>.lookAt( [page:Vector3 eye], [page:Vector3 center], [page:Vector3 up], ) [page:Matrix4]</h3>
 		<div>
 		Constructs a rotation matrix, looking from *eye* towards *center* with defined *up* vector.
@@ -196,16 +206,6 @@
 		If parameters are not passed, new instances will be created.
 		</div>
 
-		<h3>.extractPosition( [page:Matrix4 m] ) [page:Matrix4]</h3>
-		<div>
-		Copies the translation component of the supplied matrix *m* into this matrix translation component.
-		</div>
-
-		<h3>.extractRotation( [page:Matrix4 m] ) [page:Matrix4]</h3>
-		<div>
-		Copies the rotation component of the supplied matrix *m* into this matrix rotation component.
-		</div>
-
 		<h3>.makeTranslation( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]</h3>
 		<div>
 		Sets this matrix as translation transform.

+ 1 - 1
examples/js/renderers/CSS3DRenderer.js

@@ -169,7 +169,7 @@ THREE.CSS3DRenderer = function () {
 
 					_tmpMatrix.copy( camera.matrixWorldInverse );
 					_tmpMatrix.transpose();
-					_tmpMatrix.extractPosition( object.matrixWorld );
+					_tmpMatrix.copyPosition( object.matrixWorld );
 					_tmpMatrix.scale( object.scale );
 
 					_tmpMatrix.elements[ 3 ] = 0;

+ 1 - 1
src/core/Object3D.js

@@ -63,7 +63,7 @@ THREE.Object3D.prototype = {
 
 			this.scale.getScaleFromMatrix( this.matrix );
 
-			m1.extractRotation( this.matrix );
+			m1.copyRotation( this.matrix );
 
 			if ( this.useQuaternion === true )  {
 

+ 1 - 1
src/core/Raycaster.js

@@ -84,7 +84,7 @@
 			var a, b, c, d;
 			var precision = raycaster.precision;
 
-			object.matrixRotationWorld.extractRotation( object.matrixWorld );
+			object.matrixRotationWorld.copyRotation( object.matrixWorld );
 
 			inverseMatrix.getInverse( object.matrixWorld );
 

+ 50 - 36
src/math/Matrix4.js

@@ -75,6 +75,50 @@ THREE.Matrix4.prototype = {
 
 	},
 
+	copyPosition: function ( m ) {
+
+		var te = this.elements;
+		var me = m.elements;
+
+		te[12] = me[12];
+		te[13] = me[13];
+		te[14] = me[14];
+
+		return this;
+
+	},
+
+	copyRotation: function () {
+
+		var v1 = new THREE.Vector3();
+
+		return function ( m ) {
+
+			var te = this.elements;
+			var me = m.elements;
+
+			var scaleX = 1 / v1.set( me[0], me[1], me[2] ).length();
+			var scaleY = 1 / v1.set( me[4], me[5], me[6] ).length();
+			var scaleZ = 1 / v1.set( me[8], me[9], me[10] ).length();
+
+			te[0] = me[0] * scaleX;
+			te[1] = me[1] * scaleX;
+			te[2] = me[2] * scaleX;
+
+			te[4] = me[4] * scaleY;
+			te[5] = me[5] * scaleY;
+			te[6] = me[6] * scaleY;
+
+			te[8] = me[8] * scaleZ;
+			te[9] = me[9] * scaleZ;
+			te[10] = me[10] * scaleZ;
+
+			return this;
+
+		};
+
+	}(),
+
 	setRotationFromEuler: function ( v, order ) {
 
 		var te = this.elements;
@@ -586,47 +630,17 @@ THREE.Matrix4.prototype = {
 
 	extractPosition: function ( m ) {
 
-		var te = this.elements;
-		var me = m.elements;
-
-		te[12] = me[12];
-		te[13] = me[13];
-		te[14] = me[14];
-
-		return this;
+		console.warn( 'DEPRECATED: Matrix4\'s .extractPosition() has been renamed to .copyPosition().' );
+		return this.copyPosition( m );
 
 	},
 
-	extractRotation: function () {
-
-		var v1 = new THREE.Vector3();
-
-		return function ( m ) {
+	extractRotation: function ( m ) {
 
-			var te = this.elements;
-			var me = m.elements;
+		console.warn( 'DEPRECATED: Matrix4\'s .extractRotation() has been renamed to .copyRotation().' );
+		return this.copyRotation( m );
 
-			var scaleX = 1 / v1.set( me[0], me[1], me[2] ).length();
-			var scaleY = 1 / v1.set( me[4], me[5], me[6] ).length();
-			var scaleZ = 1 / v1.set( me[8], me[9], me[10] ).length();
-
-			te[0] = me[0] * scaleX;
-			te[1] = me[1] * scaleX;
-			te[2] = me[2] * scaleX;
-
-			te[4] = me[4] * scaleY;
-			te[5] = me[5] * scaleY;
-			te[6] = me[6] * scaleY;
-
-			te[8] = me[8] * scaleZ;
-			te[9] = me[9] * scaleZ;
-			te[10] = me[10] * scaleZ;
-
-			return this;
-
-		};
-
-	}(),
+	},
 
 	translate: function ( v ) {