Procházet zdrojové kódy

LineSegment2: Don't raycast without a valid resolution. (#33872)

Michael Herzog před 1 týdnem
rodič
revize
202a495686

+ 1 - 1
examples/jsm/lines/LineMaterial.js

@@ -10,7 +10,7 @@ UniformsLib.line = {
 
 	worldUnits: { value: 1 },
 	linewidth: { value: 1 },
-	resolution: { value: new Vector2( 1, 1 ) },
+	resolution: { value: new Vector2() },
 	dashOffset: { value: 0 },
 	dashScale: { value: 1 },
 	dashSize: { value: 1 },

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

@@ -326,6 +326,14 @@ class LineSegments2 extends Mesh {
 
 		}
 
+		// early out if no resolution has been set (line was not rendered yet)
+
+		if ( worldUnits === false && ( this.material.resolution.x === 0 || this.material.resolution.y === 0 ) ) {
+
+			return;
+
+		}
+
 		const threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
 
 		_ray = raycaster.ray;

+ 8 - 0
examples/jsm/lines/webgpu/LineSegments2.js

@@ -324,6 +324,14 @@ class LineSegments2 extends Mesh {
 
 		}
 
+		// early out if no resolution has been set (line was not rendered yet)
+
+		if ( worldUnits === false && ( this._resolution.x === 0 || this._resolution.y === 0 ) ) {
+
+			return;
+
+		}
+
 		const threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
 
 		_ray = raycaster.ray;

粤ICP备19079148号