gapSize
Provides a float value representing the size of a gap, primarily used in `LineDashedNodeMaterial` to define the length of the empty space in a dashed line.
Core Advantages
Offers an extremely intuitive `material.gapSize = value` API, abstracting away underlying Uniform management and providing a standardized parameter for controlling gap-based effects like dashed lines.
Common Uses
Defining the length of the empty space in dashed lines with `LineDashedNodeMaterial`.
Controlling the spacing in procedural grid or dot patterns.
Setting the height of transparent bands in stripe or shutter effects.
Adjusting the thickness of the black gaps in a CRT scanline effect.
How to adjust
Directly modify the `material.gapSize` property (a number) in JavaScript. For a dashed line, increasing this value makes the gaps longer and the line sparser. Setting it to 0 will cause the dashes to connect, forming a solid line.
Code Examples
1// In a dashed line shader, vLineDistance is the distance along the line.
2// Discard the fragment if it's in the gap part of the pattern.
3if ( mod( vLineDistance, dashSize.add( gapSize ) ).greaterThan( dashSize ) ) {
4
5 discard;
6
7}