提交 1f4f7e1a 编写于 作者: B Ben Houston

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

上级 dca460bf
......@@ -88,7 +88,7 @@
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 ++ ) {
......
......@@ -271,7 +271,7 @@ THREE.extend( THREE.Box3.prototype, {
},
transform: function() {
applyMatrix4: function() {
var points = [
new THREE.Vector3(),
......
......@@ -100,7 +100,7 @@ THREE.extend( THREE.Line3.prototype, {
},
transform: function ( matrix ) {
applyMatrix4: function ( matrix ) {
this.start.applyMatrix4( matrix );
this.end.applyMatrix4( matrix );
......
......@@ -174,7 +174,7 @@ THREE.extend( THREE.Plane.prototype, {
},
transform: function() {
applyMatrix4: function() {
var v1 = new THREE.Vector3();
var v2 = new THREE.Vector3();
......
......@@ -140,7 +140,7 @@ THREE.extend( THREE.Ray.prototype, {
},
transform: function ( matrix4 ) {
applyMatrix4: function ( matrix4 ) {
this.direction.add( this.origin ).applyMatrix4( matrix4 );
this.origin.applyMatrix4( matrix4 );
......
......@@ -102,7 +102,7 @@ THREE.extend( THREE.Sphere.prototype, {
},
transform: function ( matrix ) {
applyMatrix4: function ( matrix ) {
this.center.applyMatrix4( matrix );
this.radius = this.radius * matrix.getMaxScaleOnAxis();
......
......@@ -248,7 +248,7 @@ var compareBox = function ( a, b, threshold ) {
a.max.distanceTo( b.max ) < threshold );
};
test( "transform", function() {
test( "applyMatrix4", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var b = new THREE.Box3( zero3.clone(), 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 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() {
......
......@@ -153,7 +153,6 @@ test( "isInterestionLine/intersectLine", function() {
});
test( "projectPoint", function() {
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!" );
});
test( "transform/translate", function() {
test( "applyMatrix4/translate", function() {
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
var m = new THREE.Matrix4();
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 );
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 );
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!" );
});
......@@ -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 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 ) );
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 );
var b = a.clone();
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.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
a.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.direction.distanceTo( b.direction ) < 0.0001, "Passed!" );
});
......
......@@ -85,12 +85,12 @@ test( "getBoundingBox", function() {
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 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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册