Browse Source

(Box3|Line3|Plane|Ray|Sphere).transform() -> applyMatrix4() for consistency.

Ben Houston 12 years ago
parent
commit
1f4f7e1a79

+ 1 - 1
src/core/Raycaster.js

@@ -88,7 +88,7 @@
 
 
 			inverseMatrix.getInverse( object.matrixWorld );
 			inverseMatrix.getInverse( object.matrixWorld );
 
 
-			localRay.copy( raycaster.ray ).transform( inverseMatrix );
+			localRay.copy( raycaster.ray ).applyMatrix4( inverseMatrix );
 
 
 			for ( var f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
 			for ( var f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
 
 

+ 1 - 1
src/math/Box3.js

@@ -271,7 +271,7 @@ THREE.extend( THREE.Box3.prototype, {
 
 
 	},
 	},
 
 
-	transform: function() {
+	applyMatrix4: function() {
 
 
 		var points = [
 		var points = [
 			new THREE.Vector3(),
 			new THREE.Vector3(),

+ 1 - 1
src/math/Line3.js

@@ -100,7 +100,7 @@ THREE.extend( THREE.Line3.prototype, {
 
 
 	},
 	},
 
 
-	transform: function ( matrix ) {
+	applyMatrix4: function ( matrix ) {
 
 
 		this.start.applyMatrix4( matrix );
 		this.start.applyMatrix4( matrix );
 		this.end.applyMatrix4( matrix );
 		this.end.applyMatrix4( matrix );

+ 1 - 1
src/math/Plane.js

@@ -174,7 +174,7 @@ THREE.extend( THREE.Plane.prototype, {
 
 
 	},
 	},
 
 
-	transform: function() {
+	applyMatrix4: function() {
 
 
 		var v1 = new THREE.Vector3();
 		var v1 = new THREE.Vector3();
 		var v2 = new THREE.Vector3();
 		var v2 = new THREE.Vector3();

+ 1 - 1
src/math/Ray.js

@@ -140,7 +140,7 @@ THREE.extend( THREE.Ray.prototype, {
 
 
 	},
 	},
 
 
-	transform: function ( matrix4 ) {
+	applyMatrix4: function ( matrix4 ) {
 
 
 		this.direction.add( this.origin ).applyMatrix4( matrix4 );
 		this.direction.add( this.origin ).applyMatrix4( matrix4 );
 		this.origin.applyMatrix4( matrix4 );
 		this.origin.applyMatrix4( matrix4 );

+ 1 - 1
src/math/Sphere.js

@@ -102,7 +102,7 @@ THREE.extend( THREE.Sphere.prototype, {
 
 
 	},
 	},
 
 
-	transform: function ( matrix ) {
+	applyMatrix4: function ( matrix ) {
 
 
 		this.center.applyMatrix4( matrix );
 		this.center.applyMatrix4( matrix );
 		this.radius = this.radius * matrix.getMaxScaleOnAxis();
 		this.radius = this.radius * matrix.getMaxScaleOnAxis();

+ 5 - 5
test/unit/math/Box3.js

@@ -248,7 +248,7 @@ var compareBox = function ( a, b, threshold ) {
 	a.max.distanceTo( b.max ) < threshold );
 	a.max.distanceTo( b.max ) < threshold );
 };
 };
 
 
-test( "transform", function() {
+test( "applyMatrix4", function() {
 	var a = new THREE.Box3( zero3.clone(), zero3.clone() );
 	var a = new THREE.Box3( zero3.clone(), zero3.clone() );
 	var b = new THREE.Box3( zero3.clone(), one3.clone() );
 	var b = new THREE.Box3( zero3.clone(), one3.clone() );
 	var c = new THREE.Box3( one3.clone().negate(), one3.clone() );
 	var c = new THREE.Box3( one3.clone().negate(), one3.clone() );
@@ -257,10 +257,10 @@ test( "transform", function() {
 	var m = new THREE.Matrix4().makeTranslation( 1, -2, 1 );
 	var m = new THREE.Matrix4().makeTranslation( 1, -2, 1 );
 	var t1 = new THREE.Vector3( 1, -2, 1 );
 	var t1 = new THREE.Vector3( 1, -2, 1 );
 
 
-	ok( compareBox( a.clone().transform( m ), a.clone().translate( t1 ) ), "Passed!" );
-	ok( compareBox( b.clone().transform( m ), b.clone().translate( t1 ) ), "Passed!" );
-	ok( compareBox( c.clone().transform( m ), c.clone().translate( t1 ) ), "Passed!" );
-	ok( compareBox( d.clone().transform( m ), d.clone().translate( t1 ) ), "Passed!" );
+	ok( compareBox( a.clone().applyMatrix4( m ), a.clone().translate( t1 ) ), "Passed!" );
+	ok( compareBox( b.clone().applyMatrix4( m ), b.clone().translate( t1 ) ), "Passed!" );
+	ok( compareBox( c.clone().applyMatrix4( m ), c.clone().translate( t1 ) ), "Passed!" );
+	ok( compareBox( d.clone().applyMatrix4( m ), d.clone().translate( t1 ) ), "Passed!" );
 });
 });
 
 
 test( "translate", function() {
 test( "translate", function() {

+ 4 - 5
test/unit/math/Plane.js

@@ -153,7 +153,6 @@ test( "isInterestionLine/intersectLine", function() {
 
 
 });
 });
 
 
-
 test( "projectPoint", function() {
 test( "projectPoint", function() {
 	var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
 	var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
 
 
@@ -181,18 +180,18 @@ test( "coplanarPoint", function() {
 	ok( a.distanceToPoint( a.coplanarPoint() ) === 0, "Passed!" );
 	ok( a.distanceToPoint( a.coplanarPoint() ) === 0, "Passed!" );
 });
 });
 
 
-test( "transform/translate", function() {
+test( "applyMatrix4/translate", function() {
 
 
 	var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
 	var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
 
 
 	var m = new THREE.Matrix4();
 	var m = new THREE.Matrix4();
 	m.makeRotationZ( Math.PI * 0.5 );
 	m.makeRotationZ( Math.PI * 0.5 );
 
 
-	ok( comparePlane( a.clone().transform( m ), new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), 0 ) ), "Passed!" );
+	ok( comparePlane( a.clone().applyMatrix4( m ), new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), 0 ) ), "Passed!" );
 
 
 	a = new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), -1 );
 	a = new THREE.Plane( new THREE.Vector3( 0, 1, 0 ), -1 );
-	ok( comparePlane( a.clone().transform( m ), new THREE.Plane( new THREE.Vector3( -1, 0, 0 ), -1 ) ), "Passed!" );
+	ok( comparePlane( a.clone().applyMatrix4( m ), new THREE.Plane( new THREE.Vector3( -1, 0, 0 ), -1 ) ), "Passed!" );
 
 
 	m.makeTranslation( 1, 1, 1 );
 	m.makeTranslation( 1, 1, 1 );
-	ok( comparePlane( a.clone().transform( m ), a.clone().translate( new THREE.Vector3( 1, 1, 1 ) ) ), "Passed!" );
+	ok( comparePlane( a.clone().applyMatrix4( m ), a.clone().translate( new THREE.Vector3( 1, 1, 1 ) ) ), "Passed!" );
 });
 });

+ 5 - 5
test/unit/math/Ray.js

@@ -149,26 +149,26 @@ test( "intersectPlane", function() {
 });
 });
 
 
 
 
-test( "transform", function() {
+test( "applyMatrix4", function() {
 	var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
 	var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
 	var m = new THREE.Matrix4().identity();
 	var m = new THREE.Matrix4().identity();
 
 
-	ok( a.clone().transform( m ).equals( a ), "Passed!" );
+	ok( a.clone().applyMatrix4( m ).equals( a ), "Passed!" );
 
 
 	a = new THREE.Ray( zero3.clone(), new THREE.Vector3( 0, 0, 1 ) );
 	a = new THREE.Ray( zero3.clone(), new THREE.Vector3( 0, 0, 1 ) );
 	m.rotateByAxis( new THREE.Vector3( 0, 0, 1 ), Math.PI );
 	m.rotateByAxis( new THREE.Vector3( 0, 0, 1 ), Math.PI );
-	ok( a.clone().transform( m ).equals( a ), "Passed!" );
+	ok( a.clone().applyMatrix4( m ).equals( a ), "Passed!" );
 
 
 	m.identity().rotateX( Math.PI );
 	m.identity().rotateX( Math.PI );
 	var b = a.clone();
 	var b = a.clone();
 	b.direction.negate();
 	b.direction.negate();
-	var a2 = a.clone().transform( m );
+	var a2 = a.clone().applyMatrix4( m );
 	ok( a2.origin.distanceTo( b.origin ) < 0.0001, "Passed!" );
 	ok( a2.origin.distanceTo( b.origin ) < 0.0001, "Passed!" );
 	ok( a2.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
 	ok( a2.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
 
 
 	a.origin = new THREE.Vector3( 0, 0, 1 );
 	a.origin = new THREE.Vector3( 0, 0, 1 );
 	b.origin = new THREE.Vector3( 0, 0, -1 );
 	b.origin = new THREE.Vector3( 0, 0, -1 );
-	var a2 = a.clone().transform( m );
+	var a2 = a.clone().applyMatrix4( m );
 	ok( a2.origin.distanceTo( b.origin ) < 0.0001, "Passed!" );
 	ok( a2.origin.distanceTo( b.origin ) < 0.0001, "Passed!" );
 	ok( a2.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
 	ok( a2.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
 });
 });

+ 2 - 2
test/unit/math/Sphere.js

@@ -85,12 +85,12 @@ test( "getBoundingBox", function() {
 	ok( a.getBoundingBox().equals( new THREE.Box3( zero3, zero3 ) ), "Passed!" );
 	ok( a.getBoundingBox().equals( new THREE.Box3( zero3, zero3 ) ), "Passed!" );
 });
 });
 
 
-test( "transform", function() {
+test( "applyMatrix4", function() {
 	var a = new THREE.Sphere( one3.clone(), 1 );
 	var a = new THREE.Sphere( one3.clone(), 1 );
 
 
 	var m = new THREE.Matrix4().makeTranslation( 1, -2, 1 );
 	var m = new THREE.Matrix4().makeTranslation( 1, -2, 1 );
 
 
-	ok( a.clone().transform( m ).getBoundingBox().equals( a.getBoundingBox().transform( m ) ), "Passed!" );
+	ok( a.clone().applyMatrix4( m ).getBoundingBox().equals( a.getBoundingBox().applyMatrix4( m ) ), "Passed!" );
 });
 });
 
 
 test( "translate", function() {
 test( "translate", function() {