From 7f05ba167c522d1b9bac01677c2249b0f1b8c834 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sun, 8 Apr 2012 14:07:38 +0200 Subject: [PATCH] Renamed Matrix4's setTranslation, setRotationX, setRotationY, setRotationZ, setRotationAxis and setScale to makeTranslation, makeRotationX, makeRotationY, makeRotationZ, makeRotationAxis and makeScale. Fixes #1615. --- examples/js/postprocessing/EffectComposer.js | 2 +- examples/webgl_geometry_subdivison.html | 8 ++-- .../webgl_interactive_draggablecubes.html | 2 +- examples/webgl_shader.html | 4 +- examples/webgl_terrain_dynamic.html | 2 +- src/core/Matrix4.js | 42 +++++++++---------- src/extras/GeometryUtils.js | 2 +- src/extras/geometries/LatheGeometry.js | 2 +- src/extras/geometries/TubeGeometry.js | 4 +- src/extras/helpers/ArrowHelper.js | 2 +- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/js/postprocessing/EffectComposer.js b/examples/js/postprocessing/EffectComposer.js index 909992d253d9c..d597c02f5034c 100644 --- a/examples/js/postprocessing/EffectComposer.js +++ b/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; diff --git a/examples/webgl_geometry_subdivison.html b/examples/webgl_geometry_subdivison.html index 62d6ef0971c61..46c4ecd320587 100644 --- a/examples/webgl_geometry_subdivison.html +++ b/examples/webgl_geometry_subdivison.html @@ -185,10 +185,10 @@ info.innerHTML = 'Drag to spin THREE.' + params.type + - '

Subdivisions: ' + subdivisions + + '

Subdivisions: ' + subdivisions + ' more/less' + '
Geometry: ' + dropdown + ' next' + - '

Vertices count: before ' + geometry.vertices.length + ' after ' + smooth.vertices.length + + '

Vertices count: before ' + geometry.vertices.length + ' after ' + smooth.vertices.length + '
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 ); diff --git a/examples/webgl_interactive_draggablecubes.html b/examples/webgl_interactive_draggablecubes.html index 12443953fae8e..068d7a42511ad 100644 --- a/examples/webgl_interactive_draggablecubes.html +++ b/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 ); diff --git a/examples/webgl_shader.html b/examples/webgl_shader.html index 5edbc97a058a6..5cbca7f8e1b7d 100644 --- a/examples/webgl_shader.html +++ b/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(); diff --git a/examples/webgl_terrain_dynamic.html b/examples/webgl_terrain_dynamic.html index ea3d0a594c956..1316679c62fa3 100644 --- a/examples/webgl_terrain_dynamic.html +++ b/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(); diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index b29bd6ddadfea..7bbd5dc9fc414 100644 --- a/src/core/Matrix4.js +++ b/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 ); diff --git a/src/extras/GeometryUtils.js b/src/extras/GeometryUtils.js index 45f14e14b2052..784253b770459 100644 --- a/src/extras/GeometryUtils.js +++ b/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; diff --git a/src/extras/geometries/LatheGeometry.js b/src/extras/geometries/LatheGeometry.js index 1461583b045bc..f66d19b5e7022 100644 --- a/src/extras/geometries/LatheGeometry.js +++ b/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 ++ ) { diff --git a/src/extras/geometries/TubeGeometry.js b/src/extras/geometries/TubeGeometry.js index 35824f6bd3624..ce01056e4f66e 100644 --- a/src/extras/geometries/TubeGeometry.js +++ b/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 ] ); } diff --git a/src/extras/helpers/ArrowHelper.js b/src/extras/helpers/ArrowHelper.js index 9dc955b856b48..84d50c21fd5d3 100644 --- a/src/extras/helpers/ArrowHelper.js +++ b/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 );