FatLine: Add Arrow Rendering Support to webgl and webgpu #30141
Closed
+407
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR extends the functionality of
LineSegmentGeometry
andLineMaterial
in Three.js to support arrow rendering directly on fat lines. By adding customizable options toLineMaterial
, users can now configure arrow properties for lines without needing additional geometries or meshes.New Options in
LineMaterial
arrow
(boolean): Enables or disables arrow rendering on lines. Default:false
.arrowSize
(number): Defines the size of the arrows. Default:1
.arrowStep
(number): Sets the interval between arrows along the line. Default:1
.arrowReverse
(boolean): Reverses the direction of the arrows. Default:false
.The arrows are positioned between consecutive vertices along the line and are rendered using the existing line geometry and material properties.
Motivation
Rendering arrows for large datasets using
InstancedMesh
or separate arrow geometries often leads to performance and memory issues. By integrating arrow rendering intoLineSegmentGeometry
andLineMaterial
, we solve the following problems:Arrow Rendering Demonstration on Fat Lines
Example Usage
world units
Since I am not very experienced with vertex shaders, I utilized a simple approach to implement arrows in world units. The arrow size is scaled by a factor of
20
to achieve consistent visual proportions.