Class
GizmoBuffer
View sourceCollects 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 arraysConstructor
Properties
positions: T[]
View sourceDefault: []
colors: Color[]
View sourceDefault: []
polylinePositions: T[]
View sourceDefault: []
polylineColors: Color[]
View sourceDefault: []
fillPositions: T[]
View sourceVertex positions for filled triangle strips.
Default: []
fillColors: Color[]
View sourceColors corresponding to GizmoBuffer#fillPositions.
Default: []
texts: string[]
View sourceText strings rendered with the canvas stroke-text operation.
Default: []
textAffines: Affine2[]
View sourceAffine transforms corresponding to GizmoBuffer#texts.
Default: []
textColors: Color[]
View sourceColors corresponding to GizmoBuffer#texts.
Default: []
textAlignments: number[]
View sourceHorizontal alignments corresponding to GizmoBuffer#texts.
Default: []
textSizes: number[]
View sourceFont sizes corresponding to GizmoBuffer#texts.
Default: []
fillTexts: string[]
View sourceText strings rendered with the canvas fill-text operation.
Default: []
fillTextAffines: Affine2[]
View sourceAffine transforms corresponding to GizmoBuffer#fillTexts.
Default: []
fillTextColors: Color[]
View sourceColors corresponding to GizmoBuffer#fillTexts.
Default: []
fillTextAlignments: number[]
View sourceHorizontal alignments corresponding to GizmoBuffer#fillTexts.
Default: []
fillTextSizes: number[]
View sourceFont sizes corresponding to GizmoBuffer#fillTexts.
Default: []
Methods
clear(): void
View sourceRemoves all submitted drawing data from the buffer.
This sets the length of GizmoBuffer#positions,
GizmoBuffer#colors, GizmoBuffer#polylinePositions,
GizmoBuffer#polylineColors, GizmoBuffer#fillPositions,
GizmoBuffer#fillColors, GizmoBuffer#texts,
GizmoBuffer#textAffines, GizmoBuffer#textColors,
GizmoBuffer#textAlignments, GizmoBuffer#fillTexts,
GizmoBuffer#fillTextAffines, GizmoBuffer#fillTextColors, and
GizmoBuffer#fillTextAlignments, GizmoBuffer#textSizes, and
GizmoBuffer#fillTextSizes to 0. The sixteen array
instances keep their identity and remain usable after the call.
