glTF Line Primitives for Wireframe Rendering
This article provides an overview of the line primitive topologies
supported by the glTF 2.0 specification for rendering wireframes and
outlines. It details the three native line primitive
modes—LINES, LINE_STRIP, and
LINE_LOOP—explaining their structure, indexation, and
practical application when constructing wireframe representations in
real-time 3D graphics engines.
In the glTF specification, the topology of a mesh primitive is
defined by the integer value assigned to the mode property
within the mesh.primitive object. When rendering wireframe
structures directly using native line geometry, glTF supports three
distinct line primitive modes derived from standard OpenGL
primitives:
1. LINES (Mode 1)
The LINES topology interprets vertices as individual,
disconnected line segments. For every two consecutive vertices (or
indices, if an index accessor is provided), a distinct line segment is
drawn between them:
- Segment pairs: \((v_0, v_1), (v_2, v_3), (v_4, v_5), \dots\)
- Use case: This is the most common and versatile
mode for wireframe models. Because complex 3D meshes feature branching
edges that share vertices across multiple polygonal faces, the
LINESmode allows any arbitrary edge graph to be constructed without enforcing a continuous path.
2. LINE_LOOP (Mode 2)
The LINE_LOOP topology creates a continuous path through
a sequence of vertices and automatically closes the loop by connecting
the final vertex back to the first:
- Segment sequence: \((v_0, v_1), (v_1, v_2), \dots, (v_{n-1}, v_n), (v_n, v_0)\)
- Use case:
LINE_LOOPis ideal for rendering isolated polygon boundaries, planar contours, or closed geometric cross-sections. However, because modern graphics APIs like Direct3D 12 and Vulkan do not have native hardware support for line loops, runtimes often convert this topology toLINESorLINE_STRIPon the fly.
3. LINE_STRIP (Mode 3)
The LINE_STRIP topology connects a sequence of vertices
into a continuous, unbroken chain of line segments without closing the
final gap:
- Segment sequence: \((v_0, v_1), (v_1, v_2), (v_2, v_3), \dots, (v_{n-1}, v_n)\)
- Use case: This mode is optimal for linear,
non-branching wire elements such as paths, trajectories, or
single-stroke profile outlines, offering lower memory overhead compared
to
LINESby sharing intermediate vertices.
Indexing and Attribute Constraints
All three line topologies support both indexed and non-indexed geometry in glTF:
- Indexed primitives: An
indicesproperty points to an accessor containing vertex buffer indices, which reduces buffer size by reusing shared endpoints. - Non-indexed primitives: Vertices are consumed
sequentially from the accessor arrays defining attributes like
POSITION. - Attributes: Line primitives require at least the
POSITIONattribute. While materials can be applied to line primitives, attributes such asNORMALandTANGENTare typically ignored by standard physically-based rendering (PBR) pipelines when evaluating line topologies.