提交 dd15cd2e 编写于 作者: M Mr.doob

Completing .reflect() change. Thanks @WestLangley.

上级 faa20918
...@@ -330,12 +330,12 @@ ...@@ -330,12 +330,12 @@
Sets this vector's x, y, and z equal to the column of the matrix specified by the index. Sets this vector's x, y, and z equal to the column of the matrix specified by the index.
</div> </div>
<h3>.reflect([page:Vector3 vector]) [page:Vector3 this]</h3> <h3>.reflect([page:Vector3 normal]) [page:Vector3 this]</h3>
<div> <div>
vector -- [page:Vector3] the vector to reflect about normal -- [page:Vector3] the normal to the reflecting plane
</div> </div>
<div> <div>
Reflects this vector about a vector. Reflect incident vector off of plane orthogonal to normal. normal is assumed to have unit length.
</div> </div>
<h3>.fromArray([page:Array array]) [page:Vector3 this]</h3> <h3>.fromArray([page:Array array]) [page:Vector3 this]</h3>
......
...@@ -276,18 +276,19 @@ test( "projectOnPlane", function() { ...@@ -276,18 +276,19 @@ test( "projectOnPlane", function() {
}); });
test( "reflect", function() { test( "reflect", function() {
var a = new THREE.Vector3( 1, 0, 0 ); var a = new THREE.Vector3();
var normal = new THREE.Vector3( 1, 0, 0 ); var normal = new THREE.Vector3( 0, 1, 0 );
var b = new THREE.Vector3( 0, 0, 0 ); var b = new THREE.Vector3();
ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( 1, 0, 0 ) ), "Passed!" ); a.set( 0, -1, 0 );
ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
a.set( 1, -1, 0 ); a.set( 1, -1, 0 );
ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" ); ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
a.set( 1, -1, 0 ); a.set( 1, -1, 0 );
normal.set( 0, -1, 0 ); normal.set( 0, -1, 0 );
ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( -1, -1, 0 ) ), "Passed!" ); ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" );
}); });
test( "angleTo", function() { test( "angleTo", function() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册