Browse Source

Removed remaining Matrix4 .translate() and .rotateByAxis() dependencies. Fixes #3185.

Mr.doob 12 years ago
parent
commit
45076157fe

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

@@ -206,31 +206,6 @@
 		Copies the rotation component of the supplied matrix *m* into this matrix rotation component.
 		</div>
 
-		<h3>.rotateByAxis( [page:Vector3 axis], [page:Float angle] ) [page:Matrix4]</h3>
-		<div>
-		Rotates this matrix around the supplied *axis* by *angle*.
-		</div>
-
-		<h3>.rotateX( [page:Float angle] ) [page:Matrix4]</h3>
-		<div>
-		Rotates this matrix around the *x* axis by *angle*.
-		</div>
-
-		<h3>.rotateY( [page:Float angle] ) [page:Matrix4]</h3>
-		<div>
-		Rotates this matrix around the *y* axis by *angle*.
-		</div>
-
-		<h3>.rotateZ( [page:Float angle] ) [page:Matrix4]</h3>
-		<div>
-		Rotates this matrix around the *z* axis by *angle*.
-		</div>
-
-		<h3>.translate( [page:Vector3 v] ) [page:Matrix4]</h3>
-		<div>
-		Translates this matrix by vector *v*.
-		</div>
-
 		<h3>.makeTranslation( [page:Float x], [page:Float y], [page:Float z] ) [page:Matrix4]</h3>
 		<div>
 		Sets this matrix as translation transform.

+ 6 - 7
examples/js/effects/OculusRiftEffect.js

@@ -19,7 +19,6 @@ THREE.OculusRiftEffect = function ( renderer ) {
 
 	var _pCamera = new THREE.PerspectiveCamera();
 	_pCamera.matrixAutoUpdate = false;
-	_pCamera.target = new THREE.Vector3();
 
 	var _scene = new THREE.Scene();
 
@@ -27,6 +26,8 @@ THREE.OculusRiftEffect = function ( renderer ) {
 	_oCamera.position.z = 1;
 	_scene.add( _oCamera );
 
+	var _offset = new THREE.Matrix4();
+
 	// pre-render hooks
 	this.preLeftRender = function() {};
 	this.preRightRender = function() {};
@@ -99,9 +100,8 @@ THREE.OculusRiftEffect = function ( renderer ) {
 		// Render left
 		this.preLeftRender();
 
-		var offset = new THREE.Vector3(-this.separation,0,0);
-		_pCamera.matrix.copy(camera.matrix);
-		_pCamera.matrix.translate(offset);
+		_offset.elements[12] = -this.separation; // set x offset
+		_pCamera.matrix.copy(camera.matrix).multiply(_offset);
 		_pCamera.matrixWorldNeedsUpdate = true;
 
 		renderer.setViewport( 0, 0, _width, _height );
@@ -111,9 +111,8 @@ THREE.OculusRiftEffect = function ( renderer ) {
 		// Render right
 		this.preRightRender();
 
-		offset.set(this.separation,0,0);
-		_pCamera.matrix.copy(camera.matrix);
-		_pCamera.matrix.translate(offset);
+		_offset.elements[12] = this.separation; // set x offset
+		_pCamera.matrix.copy(camera.matrix).multiply(_offset);
 		_pCamera.matrixWorldNeedsUpdate = true;
 
 		renderer.setViewport( _width, 0, _width, _height );

+ 22 - 16
examples/js/loaders/ColladaLoader.js

@@ -1945,37 +1945,43 @@ THREE.ColladaLoader = function () {
 
 	};
 
-	Transform.prototype.apply = function ( matrix ) {
+	Transform.prototype.apply = function () {
 
-		switch ( this.type ) {
+		var m1 = new THREE.Matrix4();
 
-			case 'matrix':
+		return function ( matrix ) {
 
-				matrix.multiply( this.obj );
+			switch ( this.type ) {
 
-				break;
+				case 'matrix':
 
-			case 'translate':
+					matrix.multiply( this.obj );
 
-				matrix.translate( this.obj );
+					break;
 
-				break;
+				case 'translate':
 
-			case 'rotate':
+					matrix.multiply( m1.makeTranslation( this.obj.x, this.obj.y, this.obj.z ) );
 
-				matrix.rotateByAxis( this.obj, this.angle );
+					break;
 
-				break;
+				case 'rotate':
 
-			case 'scale':
+					matrix.multiply( m1.makeRotationAxis( this.obj, this.angle ) );
 
-				matrix.scale( this.obj );
+					break;
 
-				break;
+				case 'scale':
 
-		}
+					matrix.scale( this.obj );
 
-	};
+					break;
+
+			}
+
+		};
+
+	}();
 
 	Transform.prototype.update = function ( data, member ) {
 

+ 1 - 1
src/math/Matrix4.js

@@ -597,7 +597,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	extractRotation: function() {
+	extractRotation: function () {
 
 		var v1 = new THREE.Vector3();