提交 5c377546 编写于 作者: B Ben Houston

Vector3.projectOn/reflect: normal arg to unitNormal. Removed Vector3.orthoTo

上级 ace4d4b3
......@@ -520,35 +520,20 @@ THREE.extend( THREE.Vector3.prototype, {
},
projectOn: function( unitNormal ) {
projectOn: function( normal ) {
var d = this.dot( normal );
return this.copy( normal ).multiplyScalar( d );
var d = this.dot( unitNormal );
return this.copy( unitNormal ).multiplyScalar( d );
},
orthoTo: function () {
var v1 = new THREE.Vector3();
return function( normal ) {
v1.copy( this ).projectOn( normal );
return this.sub( v1 );
}
}(),
reflect: function () {
var v1 = new THREE.Vector3();
return function ( normal ) {
return function ( unitNormal ) {
v1.copy( this ).projectOn( normal ).multiplyScalar( 2 );
v1.copy( this ).projectOn( unitNormal ).multiplyScalar( 2 );
return this.subVectors( v1, this );
......
......@@ -257,24 +257,6 @@ test( "projectOn", 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 ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a.set( 0, 1, 0 );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
a.set( 0, 0, -1 );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, -1 ) ), "Passed!" );
a.set( -1, 0, 0 );
ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
});
test( "reflect", function() {
var a = new THREE.Vector3( 1, 0, 0 );
var normal = new THREE.Vector3( 1, 0, 0 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册