Преглед изворни кода

Completing .reflect() change. Thanks @WestLangley.

Mr.doob пре 11 година
родитељ
комит
dd15cd2ed6
2 измењених фајлова са 9 додато и 8 уклоњено
  1. 3 3
      docs/api/math/Vector3.html
  2. 6 5
      test/unit/math/Vector3.js

+ 3 - 3
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.
 		</div>
 
-		<h3>.reflect([page:Vector3 vector]) [page:Vector3 this]</h3>
+		<h3>.reflect([page:Vector3 normal]) [page:Vector3 this]</h3>
 		<div>
-		vector -- [page:Vector3] the vector to reflect about
+		normal -- [page:Vector3] the normal to the reflecting plane
 		</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>
 
 		<h3>.fromArray([page:Array array]) [page:Vector3 this]</h3>

+ 6 - 5
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() {