提交 ace4d4b3 编写于 作者: B Ben Houston

Vector3: project->projectOn, ortho->orthoTo per @WestLangley

上级 d2ebe85c
......@@ -521,20 +521,20 @@ THREE.extend( THREE.Vector3.prototype, {
},
project: function( normal ) {
projectOn: function( normal ) {
var d = this.dot( normal );
return this.copy( normal ).multiplyScalar( d );
},
ortho: function () {
orthoTo: function () {
var v1 = new THREE.Vector3();
return function( normal ) {
v1.copy( this ).project( normal );
v1.copy( this ).projectOn( normal );
return this.sub( v1 );
......@@ -548,7 +548,7 @@ THREE.extend( THREE.Vector3.prototype, {
return function ( normal ) {
v1.copy( this ).project( normal ).multiplyScalar( 2 );
v1.copy( this ).projectOn( normal ).multiplyScalar( 2 );
return this.subVectors( v1, this );
......
......@@ -239,39 +239,39 @@ test( "setLength", function() {
});
test( "project", function() {
test( "projectOn", function() {
var a = new THREE.Vector3( 1, 0, 0 );
var b = new THREE.Vector3();
var normal = new THREE.Vector3( 1, 0, 0 );
ok( b.copy( a ).project( normal ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" );
ok( b.copy( a ).projectOn( normal ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" );
a.set( 0, 1, 0 );
ok( b.copy( a ).project( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.copy( a ).projectOn( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a.set( 0, 0, -1 );
ok( b.copy( a ).project( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.copy( a ).projectOn( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a.set( -1, 0, 0 );
ok( b.copy( a ).project( normal ).equals( new THREE.Vector3( -1, 0, 0 ) ), "Passed!" );
ok( b.copy( a ).projectOn( normal ).equals( new THREE.Vector3( -1, 0, 0 ) ), "Passed!" );
});
test( "ortho", function() {
test( "orthoTo", function() {
var a = new THREE.Vector3( 1, 0, 0 );
var b = new THREE.Vector3();
var normal = new THREE.Vector3( 1, 0, 0 );
ok( b.copy( a ).ortho( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a.set( 0, 1, 0 );
ok( b.copy( a ).ortho( normal ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
a.set( 0, 0, -1 );
ok( b.copy( a ).ortho( normal ).equals( new THREE.Vector3( 0, 0, -1 ) ), "Passed!" );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, -1 ) ), "Passed!" );
a.set( -1, 0, 0 );
ok( b.copy( a ).ortho( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册