GizmoBuffer

View source

Collects positions and colors for immediate-mode drawing.

A Gizmo2D or Gizmo3D resource uses this buffer to submit its drawing data. The generic type is the owning resource’s position type. Use Vector2 in 2D gizmos and Vector3 in 3D gizmos.

Positions are stored in GizmoBuffer#positions, and matching colors are stored in GizmoBuffer#colors. The renderer reads these arrays in pairs. Strip positions and colors are stored in GizmoBuffer#polylinePositions and GizmoBuffer#polylineColors; a polyline is ended by the NaN sentinel that the gizmo helpers append. Filled triangle-strip positions and colors are stored in GizmoBuffer#fillPositions and GizmoBuffer#fillColors; a strip is ended by the same NaN sentinel convention. Text, text transforms, and text colors are stored in GizmoBuffer#texts, GizmoBuffer#textAffines, and GizmoBuffer#textColors, and GizmoBuffer#textAlignments; text sizes are stored in GizmoBuffer#textSizes; filled text uses the corresponding GizmoBuffer#fillTexts, GizmoBuffer#fillTextAffines, GizmoBuffer#fillTextColors, GizmoBuffer#fillTextAlignments, and GizmoBuffer#fillTextSizes arrays.

A gizmo resource owns its buffer, so application code normally adds drawing through methods such as Gizmo2D#line or Gizmo2D#polyline rather than pushing directly. Call GizmoBuffer#clear to discard the current drawing data. It sets the length of all twelve arrays to 0, preserving the array instances and returning undefined.

Examples

const buffer = gizmo.buffer
buffer.positions.push(start, end)
buffer.colors.push(Color.WHITE, Color.WHITE)
buffer.clear() // empties all six arrays

Constructor


constructor<T>()

Type Parameters

T

Properties


fillPositions: T[]

View source

Vertex positions for filled triangle strips.

Default: []

texts: string[]

View source

Text strings rendered with the canvas stroke-text operation.

Default: []

fillTexts: string[]

View source

Text strings rendered with the canvas fill-text operation.

Default: []

Methods