瀏覽代碼

Replaced the remaining Matrix4.rotateAxis.

Mr.doob 12 年之前
父節點
當前提交
245376f6dd
共有 4 個文件被更改,包括 14 次插入19 次删除
  1. 0 5
      docs/api/math/Matrix4.html
  2. 2 4
      examples/js/AudioObject.js
  3. 8 8
      examples/js/renderers/WebGLDeferredRenderer.js
  4. 4 2
      src/core/Object3D.js

+ 0 - 5
docs/api/math/Matrix4.html

@@ -99,11 +99,6 @@
 		Applies this matrix to *v*.
 		</div>
 
-		<h3>.rotateAxis( [page:Vector3 v] ) [page:Vector3]</h3>
-		<div>
-		Applies rotation submatrix of this matrix to vector *v* and then normalizes it.
-		</div>
-
 		<h3>.crossVector( [page:Vector4 a] ) [page:Vector4]</h3>
 		<div>
 		Computes the cross product between this matrix and the [page:Vector4] parameter *a*.

+ 2 - 4
examples/js/AudioObject.js

@@ -119,8 +119,7 @@ THREE.AudioObject = function ( url, volume, playbackRate, loop ) {
 		cameraUp.copy( camera.up );
 
 		cameraFront.set( 0, 0, -1 );
-		camera.matrixWorld.rotateAxis( cameraFront );
-		cameraFront.normalize();
+		cameraFront.transformDirection( camera.matrixWorld );
 
 		this.listener.setPosition( cameraPosition.x, cameraPosition.y, cameraPosition.z );
 		this.listener.setVelocity( cameraDelta.x, cameraDelta.y, cameraDelta.z );
@@ -132,8 +131,7 @@ THREE.AudioObject = function ( url, volume, playbackRate, loop ) {
 		if ( this.directionalSource ) {
 
 			soundFront.set( 0, 0, -1 );
-			this.matrixWorld.rotateAxis( soundFront );
-			soundFront.normalize();
+			soundFront.transformDirection( this.matrixWorld );
 
 			soundUp.copy( this.up );
 			this.panner.setOrientation( soundFront.x, soundFront.y, soundFront.z, soundUp.x, soundUp.y, soundUp.z );

+ 8 - 8
examples/js/renderers/WebGLDeferredRenderer.js

@@ -430,7 +430,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		tempVS.getPositionFromMatrix( light.target.matrixWorld );
 		directionVS.sub( tempVS );
 		directionVS.normalize();
-		viewMatrix.rotateAxis( directionVS );
+		directionVS.transformDirection( viewMatrix );
 
 		uniforms[ "lightPositionVS" ].value.copy( positionVS );
 		uniforms[ "lightDirectionVS" ].value.copy( directionVS );
@@ -501,7 +501,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		tempVS.getPositionFromMatrix( light.target.matrixWorld );
 		directionVS.sub( tempVS );
 		directionVS.normalize();
-		camera.matrixWorldInverse.rotateAxis( directionVS );
+		directionVS.transformDirection( camera.matrixWorldInverse );
 
 		uniforms[ "lightDirectionVS" ].value.copy( directionVS );
 
@@ -566,7 +566,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 
 		directionVS.getPositionFromMatrix( light.matrixWorld );
 		directionVS.normalize();
-		camera.matrixWorldInverse.rotateAxis( directionVS );
+		directionVS.transformDirection( camera.matrixWorldInverse );
 
 		uniforms[ "lightDirectionVS" ].value.copy( directionVS );
 
@@ -639,12 +639,12 @@ THREE.WebGLDeferredRenderer = function ( parameters ) {
 		uniforms[ "lightPositionVS" ].value.copy( positionVS );
 
 		rightVS.copy( light.right );
-		normalVS.copy( light.normal );
-		modelMatrix.rotateAxis( rightVS );
-		modelMatrix.rotateAxis( normalVS );
+		rightVS.transformDirection( modelMatrix );
+		rightVS.transformDirection( viewMatrix );
 
-		viewMatrix.rotateAxis( rightVS );
-		viewMatrix.rotateAxis( normalVS );
+		normalVS.copy( light.normal );
+		normalVS.transformDirection( modelMatrix );
+		normalVS.transformDirection( viewMatrix );
 
 		upVS.crossVectors( rightVS, normalVS );
 		upVS.normalize();

+ 4 - 2
src/core/Object3D.js

@@ -82,8 +82,10 @@ THREE.Object3D.prototype = {
 
 	translate: function ( distance, axis ) {
 
-		this.matrix.rotateAxis( axis );
-		this.position.add( axis.multiplyScalar( distance ) );
+		axis.transformDirection( this.matrix );
+		axis.multiplyScalar( distance );
+
+		this.position.add( axis );
 
 	},