EdgePath
Defined in: packages/sigma/src/rendering/edges/types.ts:29
EdgePath - defines the geometry of an edge via GLSL functions.
Minimal Interface: Only the position function is required. All other
functions (length, distance, t_at_distance, closest_t, tangent, normal)
are auto-generated from position if not provided.
This makes creating new path types trivial - just define how the edge curves from source to target, and the system handles the rest.
For better performance, paths can optionally override the auto-generated functions with analytical or optimized implementations.
Properties
analyticalTangentGlsl?
optionalanalyticalTangentGlsl?:string
Defined in: packages/sigma/src/rendering/edges/types.ts:147
Optional GLSL code for analytical tangent computation. When provided, this is used instead of auto-generated numerical tangent (which uses finite differences on the position function).
Should define: vec2 path_{name}_tangent(float t, vec2 source, vec2 target)
Useful for paths with discontinuities (corners) where numerical differentiation produces incorrect results due to averaging across perpendicular directions.
attributes
attributes:
AttributeSpecification[]
Defined in: packages/sigma/src/rendering/edges/types.ts:85
Additional per-edge attributes required by this path.
cornerSkipGlsl?
optionalcornerSkipGlsl?:string
Defined in: packages/sigma/src/rendering/edges/types.ts:185
GLSL code for handling corner skipping in above/below label positioning.
Required when hasSharpCorners is true. Should define functions for:
- Detecting which corners are concave relative to the label position
- Computing skip distances to create gaps at inner corners
The skip distance prevents characters from bunching up at concave corners where the inner arc length approaches zero.
generateConstantData?
optionalgenerateConstantData?: () =>object
Defined in: packages/sigma/src/rendering/edges/types.ts:119
Optional custom constant data generator for advanced tessellation. If provided, overrides the default triangle strip generation.
This is useful for paths with sharp corners (like taxi with cornerRadius=0) where the default smooth parametric approach doesn’t work well.
The returned data should contain vertex attributes that the shader will use to compute final positions. Standard attributes are [t, side] but custom attributes can be added for special geometry (e.g., miter joins).
Returns
attributes
attributes:
object[]
Attribute specifications for the vertex data
data
data:
number[][]
Vertex data as array of attribute values per vertex
verticesPerEdge
verticesPerEdge:
number
Number of vertices per edge instance
glsl
glsl:
string
Defined in: packages/sigma/src/rendering/edges/types.ts:75
GLSL code defining the path computation functions.
REQUIRED function (replace {name} with the path name):
- vec2 path_{name}_position(float t, vec2 source, vec2 target) Position at parameter t ∈ [0, 1]
OPTIONAL functions (auto-generated if not provided):
- float path_{name}_length(vec2 source, vec2 target) Total arc length. Default: samples position 16 times.
- float path_{name}_distance(vec2 p, vec2 source, vec2 target) Signed distance from point p. Default: uses closest_t + normal.
- float path_{name}_t_at_distance(float d, vec2 source, vec2 target) Parameter t for arc distance d. Default: binary search.
- float path_{name}_closest_t(vec2 p, vec2 source, vec2 target) Closest t for point p. Default: coarse sample + ternary search.
AUTO-GENERATED functions (from position via numerical differentiation):
- vec2 path_{name}_tangent(float t, vec2 source, vec2 target) Unit tangent vector at t (computed via finite differences)
- vec2 path_{name}_normal(float t, vec2 source, vec2 target) Unit normal vector at t (perpendicular to tangent)
Path functions can access per-edge attributes directly (e.g., a_curvature).
Example
vec2 path_myPath_position(float t, vec2 source, vec2 target) { return mix(source, target, t * t); // Ease-in curve}hasSharpCorners?
optionalhasSharpCorners?:boolean
Defined in: packages/sigma/src/rendering/edges/types.ts:173
Whether this path has sharp corners that need special handling for above/below label positioning.
When true, the label shader will use cornerSkipGlsl to skip inner
corners, preventing character overlap at concave bends.
innerCornerSkipFactor?
optionalinnerCornerSkipFactor?:number
Defined in: packages/sigma/src/rendering/edges/types.ts:194
Skip factor for inner corners when labels are positioned above/below. The gap at inner corners = innerCornerSkipFactor * fontSize (in screen pixels).
Only used when hasSharpCorners is true.
Default: 1.0
linearParameterization?
optionallinearParameterization?:boolean
Defined in: packages/sigma/src/rendering/edges/types.ts:164
Whether the path parameter t maps linearly to arc distance.
-
true: For straight and piecewise-linear paths where arcDistance = t * totalLength. The generator will use direct linear formula: distance = t * visibleLength
-
false: For curved paths where speed varies along the curve. The generator will use numerical integration for accurate arc distances.
Default: false (numerical integration is safer for unknown paths)
Note: When generateConstantData is provided, the generator automatically uses
position-based t computation via path_*_closest_t(fragmentPosition) to ensure
accurate distances at custom geometry (e.g., miter corners in taxi paths).
minBodyLengthRatio?
optionalminBodyLengthRatio?:number
Defined in: packages/sigma/src/rendering/edges/types.ts:134
Minimum body length as a ratio of edge thickness. Ensures the body zone has at least this length even when extremities are large. Useful for paths with corners (taxi) to ensure corners stay in body zone. Default: 0 (no minimum)
name
name:
string
Defined in: packages/sigma/src/rendering/edges/types.ts:34
Unique identifier for this path type (e.g., “straight”, “quadratic”). Used to generate GLSL function names: path_{name}_position, etc.
segments
segments:
number
Defined in: packages/sigma/src/rendering/edges/types.ts:41
Number of segments for vertex tessellation.
- 1 for straight edges (simple quad with 4 vertices)
- 8-16 for curved edges (triangle strip along curve)
spread?
optionalspread?:object
Defined in: packages/sigma/src/rendering/edges/types.ts:101
Optional spread definition for parallel edge separation. Defines which variable to set and how to compute its value from the edge’s position in a parallel group.
compute
compute: (
index,count,factor) =>number
Computes the variable value from parallel edge position
Parameters
index
number
count
number
factor
number
Returns
number
variable
variable:
string
The variable to set (e.g., “curvature”)
uniforms
uniforms:
UniformSpecification[]
Defined in: packages/sigma/src/rendering/edges/types.ts:80
Additional uniforms required by this path (e.g., curvature for Bezier).
variables?
optionalvariables?:Record<string, {default:string|number;type:"number"|"color"; }>
Defined in: packages/sigma/src/rendering/edges/types.ts:94
Optional variable declarations for path attributes that need to flow through the display data pipeline (graph attributes → GPU).
When a path has per-edge attributes (e.g., loopRadius, loopAngle), declaring them here lets them be read from graph edge data automatically.