Browse Source

Renamed Matrix4's setTranslation, setRotationX, setRotationY, setRotationZ, setRotationAxis and setScale to makeTranslation, makeRotationX, makeRotationY, makeRotationZ, makeRotationAxis and makeScale. Fixes #1615.

Mr.doob 13 năm trước cách đây
mục cha
commit
7f05ba167c

+ 1 - 1
examples/js/postprocessing/EffectComposer.js

@@ -126,7 +126,7 @@ THREE.EffectComposer.camera = new THREE.OrthographicCamera( window.innerWidth /
 // shared fullscreen quad scene
 
 THREE.EffectComposer.geometry = new THREE.PlaneGeometry( 1, 1 );
-THREE.EffectComposer.geometry.applyMatrix( new THREE.Matrix4().setRotationX( Math.PI / 2 ) );
+THREE.EffectComposer.geometry.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2 ) );
 
 THREE.EffectComposer.quad = new THREE.Mesh( THREE.EffectComposer.geometry, null );
 THREE.EffectComposer.quad.position.z = -100;

+ 4 - 4
examples/webgl_geometry_subdivison.html

@@ -185,10 +185,10 @@
 
 				info.innerHTML = 'Drag to spin THREE.' + params.type +
 
-				 	'<br/><br/>Subdivisions: '  + subdivisions +
+				 	'<br><br>Subdivisions: '  + subdivisions +
 					' <a href="#" onclick="nextSubdivision(1); return false;">more</a>/<a href="#" onclick="nextSubdivision(-1); return false;">less</a>' +
 					'<br>Geometry: ' + dropdown + ' <a href="#" onclick="nextGeometry();return false;">next</a>' +
-					'<br/><br>Vertices count: before ' + geometry.vertices.length + ' after ' + smooth.vertices.length +
+					'<br><br>Vertices count: before ' + geometry.vertices.length + ' after ' + smooth.vertices.length +
 					'<br>Face count: before ' + geometry.faces.length + ' after ' + smooth.faces.length
 				; //+ params.args;
 			}
@@ -214,7 +214,7 @@
 
 				if ( params.scale ) {
 
-					geometry.applyMatrix( new THREE.Matrix4().setScale( params.scale, params.scale, params.scale ) );
+					geometry.applyMatrix( new THREE.Matrix4().makeScale( params.scale, params.scale, params.scale ) );
 
 				}
 
@@ -362,7 +362,7 @@
 
 				addStuff();
 
-				renderer = new THREE.WebGLRenderer( { antialias: true, clearColor: 0xf0f0f0 } ); // WebGLRenderer CanvasRenderer
+				renderer = new THREE.WebGLRenderer( { antialias: true } ); // WebGLRenderer CanvasRenderer
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 				container.appendChild( renderer.domElement );

+ 1 - 1
examples/webgl_interactive_draggablecubes.html

@@ -91,7 +91,7 @@
 				}
 
 				plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.25, transparent: true, wireframe: true } ) );
-				plane.geometry.applyMatrix( new THREE.Matrix4().setRotationX( Math.PI / 2 ) );
+				plane.geometry.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2 ) );
 				plane.lookAt( camera.position );
 				plane.visible = false;
 				scene.add( plane );

+ 2 - 2
examples/webgl_shader.html

@@ -126,10 +126,10 @@
 					vertexShader: document.getElementById( 'vertexShader' ).textContent,
 					fragmentShader: document.getElementById( 'fragmentShader' ).textContent
 
-					} );
+				} );
 
 				mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), material );
-				mesh.geometry.applyMatrix( new THREE.Matrix4().setRotationX( Math.PI / 2 ) );
+				mesh.geometry.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2 ) );
 				scene.add( mesh );
 
 				renderer = new THREE.WebGLRenderer();

+ 1 - 1
examples/webgl_terrain_dynamic.html

@@ -425,7 +425,7 @@
 				// TERRAIN MESH
 
 				var geometryTerrain = new THREE.PlaneGeometry( 6000, 6000, 256, 256 );
-				geometryTerrain.applyMatrix( new THREE.Matrix4().setRotationX( Math.PI / 2 ) );
+				geometryTerrain.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2 ) );
 
 				geometryTerrain.computeFaceNormals();
 				geometryTerrain.computeVertexNormals();

+ 21 - 21
src/core/Matrix4.js

@@ -317,7 +317,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setTranslation: function( x, y, z ) {
+	makeTranslation: function ( x, y, z ) {
 
 		this.set(
 
@@ -332,22 +332,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setScale: function ( x, y, z ) {
-
-		this.set(
-
-			x, 0, 0, 0,
-			0, y, 0, 0,
-			0, 0, z, 0,
-			0, 0, 0, 1
-
-		);
-
-		return this;
-
-	},
-
-	setRotationX: function ( theta ) {
+	makeRotationX: function ( theta ) {
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
@@ -364,7 +349,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotationY: function( theta ) {
+	makeRotationY: function ( theta ) {
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
@@ -381,7 +366,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotationZ: function( theta ) {
+	makeRotationZ: function ( theta ) {
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
@@ -398,7 +383,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotationAxis: function( axis, angle ) {
+	makeRotationAxis: function ( axis, angle ) {
 
 		// Based on http://www.gamedev.net/reference/articles/article1199.asp
 
@@ -421,6 +406,21 @@ THREE.Matrix4.prototype = {
 
 	},
 
+	makeScale: function ( x, y, z ) {
+
+		this.set(
+
+			x, 0, 0, 0,
+			0, y, 0, 0,
+			0, 0, z, 0,
+			0, 0, 0, 1
+
+		);
+
+		return this;
+
+	},
+
 	setPosition: function ( v ) {
 
 		this.n14 = v.x;
@@ -649,7 +649,7 @@ THREE.Matrix4.prototype = {
 		mRotation.identity();
 		mRotation.setRotationFromQuaternion( rotation );
 
-		mScale.setScale( scale.x, scale.y, scale.z );
+		mScale.makeScale( scale.x, scale.y, scale.z );
 
 		this.multiply( mRotation, mScale );
 

+ 1 - 1
src/extras/GeometryUtils.js

@@ -453,7 +453,7 @@ THREE.GeometryUtils = {
 		offset.add( bb.min, bb.max );
 		offset.multiplyScalar( -0.5 );
 
-		geometry.applyMatrix( new THREE.Matrix4().setTranslation( offset.x, offset.y, offset.z ) );
+		geometry.applyMatrix( new THREE.Matrix4().makeTranslation( offset.x, offset.y, offset.z ) );
 		geometry.computeBoundingBox();
 
 		return offset;

+ 1 - 1
src/extras/geometries/LatheGeometry.js

@@ -11,7 +11,7 @@ THREE.LatheGeometry = function ( points, steps, angle ) {
 
 	var stepSize = this.angle / this.steps,
 	newV = [], oldInds = [], newInds = [], startInds = [],
-	matrix = new THREE.Matrix4().setRotationZ( stepSize );
+	matrix = new THREE.Matrix4().makeRotationZ( stepSize );
 
 	for ( var j = 0; j < points.length; j ++ ) {
 

+ 2 - 2
src/extras/geometries/TubeGeometry.js

@@ -146,7 +146,7 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
 
 			theta = Math.acos( tangents[ i-1 ].dot( tangents[ i ] ) );
 
-			mat.setRotationAxis( vec, theta ).multiplyVector3( normals[ i ] );
+			mat.makeRotationAxis( vec, theta ).multiplyVector3( normals[ i ] );
 
 		}
 
@@ -171,7 +171,7 @@ THREE.TubeGeometry = function( path, segments, radius, segmentsRadius, closed, d
 		for ( i = 1; i < numpoints; i++ ) {
 
 			// twist a little...
-			mat.setRotationAxis( tangents[ i ], theta * i ).multiplyVector3( normals[ i ] );
+			mat.makeRotationAxis( tangents[ i ], theta * i ).multiplyVector3( normals[ i ] );
 			binormals[ i ].cross( tangents[ i ], normals[ i ] );
 
 		}

+ 1 - 1
src/extras/helpers/ArrowHelper.js

@@ -51,7 +51,7 @@ THREE.ArrowHelper.prototype.setDirection = function( dir ) {
 
     var radians = Math.acos( new THREE.Vector3( 0, 1, 0 ).dot( dir.clone().normalize() ) );
 
-    this.matrix = new THREE.Matrix4().setRotationAxis( axis.normalize(), radians );
+    this.matrix = new THREE.Matrix4().makeRotationAxis( axis.normalize(), radians );
 
     this.rotation.getRotationFromMatrix( this.matrix, this.scale );