From dd15cd2ed6873d53b44d0c068c47aab1f37cf985 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 31 Jan 2014 15:35:23 +0100 Subject: [PATCH] Completing .reflect() change. Thanks @WestLangley. --- docs/api/math/Vector3.html | 6 +++--- test/unit/math/Vector3.js | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/api/math/Vector3.html b/docs/api/math/Vector3.html index e420439425..0caed2bc0a 100644 --- a/docs/api/math/Vector3.html +++ b/docs/api/math/Vector3.html @@ -330,12 +330,12 @@ Sets this vector's x, y, and z equal to the column of the matrix specified by the index. -

.reflect([page:Vector3 vector]) [page:Vector3 this]

+

.reflect([page:Vector3 normal]) [page:Vector3 this]

- vector -- [page:Vector3] the vector to reflect about + normal -- [page:Vector3] the normal to the reflecting plane
- Reflects this vector about a vector. + Reflect incident vector off of plane orthogonal to normal. normal is assumed to have unit length.

.fromArray([page:Array array]) [page:Vector3 this]

diff --git a/test/unit/math/Vector3.js b/test/unit/math/Vector3.js index 2aa2370edd..b6157d50c3 100644 --- a/test/unit/math/Vector3.js +++ b/test/unit/math/Vector3.js @@ -276,18 +276,19 @@ test( "projectOnPlane", function() { }); test( "reflect", function() { - var a = new THREE.Vector3( 1, 0, 0 ); - var normal = new THREE.Vector3( 1, 0, 0 ); - var b = new THREE.Vector3( 0, 0, 0 ); + var a = new THREE.Vector3(); + var normal = new THREE.Vector3( 0, 1, 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 ); ok( b.copy( a ).reflect( normal ).equals( new THREE.Vector3( 1, 1, 0 ) ), "Passed!" ); a.set( 1, -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() { -- GitLab