Browse Source

Fix raytracing of LineSegments2 when the mesh has a transformation applied. (#24405)

Co-authored-by: mloeppky <[email protected]>
Mitchell Loeppky 2 years ago
parent
commit
fbace95ba7
1 changed files with 4 additions and 0 deletions
  1. 4 0
      examples/jsm/lines/LineSegments2.js

+ 4 - 0
examples/jsm/lines/LineSegments2.js

@@ -51,11 +51,15 @@ function getWorldSpaceHalfWidth( camera, distance, resolution ) {
 
 function raycastWorldUnits( lineSegments, intersects ) {
 
+	const matrixWorld = lineSegments.matrixWorld;
+
 	for ( let i = 0, l = _instanceStart.count; i < l; i ++ ) {
 
 		_line.start.fromBufferAttribute( _instanceStart, i );
 		_line.end.fromBufferAttribute( _instanceEnd, i );
 
+		_line.applyMatrix4( matrixWorld );
+
 		const pointOnLine = new Vector3();
 		const point = new Vector3();