Explorar o código

add clarifying comment

Garrett Johnson %!s(int64=5) %!d(string=hai) anos
pai
achega
eca2412e0e
Modificáronse 2 ficheiros con 10 adicións e 2 borrados
  1. 5 1
      examples/js/lines/LineSegments2.js
  2. 5 1
      examples/jsm/lines/LineSegments2.js

+ 5 - 1
examples/js/lines/LineSegments2.js

@@ -85,8 +85,12 @@ THREE.LineSegments2.prototype = Object.assign( Object.create( THREE.Mesh.prototy
 			var instanceStart = geometry.attributes.instanceStart;
 			var instanceEnd = geometry.attributes.instanceEnd;
 
-			// ndc space [ - 1.0, 1.0 ]
+			// pick a point 1 unit out along the ray to avoid the ray origin
+			// sitting at the camera origin which will cause "w" to be 0 when
+			// applying the projection matrix.
 			ray.at( 1, ssOrigin );
+
+			// ndc space [ - 1.0, 1.0 ]
 			ssOrigin.w = 1;
 			ssOrigin.applyMatrix4( camera.matrixWorldInverse );
 			ssOrigin.applyMatrix4( projectionMatrix );

+ 5 - 1
examples/jsm/lines/LineSegments2.js

@@ -98,8 +98,12 @@ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), {
 			var instanceStart = geometry.attributes.instanceStart;
 			var instanceEnd = geometry.attributes.instanceEnd;
 
-			// ndc space [ - 1.0, 1.0 ]
+			// pick a point 1 unit out along the ray to avoid the ray origin
+			// sitting at the camera origin which will cause "w" to be 0 when
+			// applying the projection matrix.
 			ray.at( 1, ssOrigin );
+
+			// ndc space [ - 1.0, 1.0 ]
 			ssOrigin.w = 1;
 			ssOrigin.applyMatrix4( camera.matrixWorldInverse );
 			ssOrigin.applyMatrix4( projectionMatrix );