Optionaloptions: DebugDrawBufferOptionsSegments the current backing store holds. Doubles on overflow and never shrinks — including across DebugDrawBuffer.clear — so a steady-state overlay stops allocating.
Floats DebugDrawBuffer.writeColors will write:
lineCount * DEBUG_COLOR_FLOATS_PER_SEGMENT.
The whole capacity-sized backing store, by reference — the zero-alloc read path, to be used together with DebugDrawBuffer.floatLength. The reference changes when the buffer grows, so re-read it rather than caching it across frames.
Live floats: lineCount * DEBUG_SEGMENT_FLOATS. Everything in
DebugDrawBuffer.data beyond this is stale and must not be read.
Segments written since the last DebugDrawBuffer.clear.
Floats DebugDrawBuffer.writePositions will write:
lineCount * DEBUG_POSITION_FLOATS_PER_SEGMENT.
Appends an axis-aligned cross centred on center, arm half-length size:
three segments, appended in X, Y, Z order — (±size, 0, 0),
(0, ±size, 0), (0, 0, ±size).
In a 2D scene (§7a: Y-up, everything at z = 0) the Z arm is a single pixel
seen down the camera axis. It is drawn anyway rather than branching on a
dimension this package cannot see; it costs one segment and it is what makes
the same cross usable in 3D.
Appends one segment from from to to.
Coordinates are stored verbatim, including non-finite ones — see the module header.
Appends one segment from raw components — the form the providers use, since it lets them offset an endpoint without a scratch vector.
Draws a point as a cross — an alias of DebugDrawBuffer.addCross, spelled the way a caller thinks of it.
A line list has no point primitive (GL.POINTS is not in
GeometryDrawMode, which is "triangles" | "lines"), so every point in
§113's list — a contact, a body origin — is three segments of 2 * size
length. size is a world-space half-extent, not a pixel radius: this
package cannot see a camera, so a screen-constant size is not expressible
here and is the caller's to choose per scale.
Appends origin → origin + vector * scale as one segment — the shape
§113's "velocity and force vectors" take.
No arrowhead. A head is three more segments and a screen-space size to pick, and the direction is already readable from the segment's endpoints; the tip is the second vertex. Heads can be added later without a layout change.
Drops every segment. Keeps the backing store (see DebugDrawBuffer.capacity) and does not zero it: stale floats past DebugDrawBuffer.floatLength are unreachable through every accessor here.
A view of exactly the live floats.
Convenience for tests and one-shot inspection: subarray copies no data but
does allocate a view object, so a per-frame path should use
DebugDrawBuffer.data with DebugDrawBuffer.floatLength
instead.
Copies the live segments' colours into out — 8 floats per segment
(straight RGBA per vertex, two vertices), the layout
BufferGeometry.colors wants alongside the positions
DebugDrawBuffer.writePositions produces.
This is the other half of the split: the buffer interleaves position and colour per vertex (module header), a GL vertex attribute wants each stream contiguous, and these two methods are the de-interleave. No expansion happens — the colour is already stored per vertex, so a future gradient segment (two different endpoint colours) comes out correct without a change here.
Allocates nothing. Returns the number of floats written, which is
DebugDrawBuffer.colorFloatLength. Floats in out past that are
left untouched, exactly as DebugDrawBuffer.writePositions leaves
them.
Optionaloffset: numberCopies the live segments into out as positions only — 6 floats per
segment, the layout BufferGeometry's positions wants with
mode: "lines".
Allocates nothing. Returns the number of floats written, which is
DebugDrawBuffer.positionFloatLength. Floats in out past that are
left untouched — a geometry sized for the worst case keeps its stale tail,
so either size out exactly per frame or accept that the extra segments
still draw. (Collapsing the tail to a degenerate point is a caller policy,
not a buffer one.)
Optionaloffset: numberDebugDrawBuffer.writePositions restricted to the segments whose
first vertex carries exactly color — how one mixed buffer feeds several
single-colour UnlitMaterial draws while the render path has no
vertex-colour attribute (module header).
The comparison is exact float equality on all four components, which is the right test precisely because colours here are constants copied out of a literal or DEBUG_DRAW_DEFAULT_COLORS — nothing computes a colour, so nothing needs a tolerance.
Allocates nothing. Returns the number of floats written.
Optionaloffset: number
A growable world-space line list with a colour per vertex — the transport every provider in this module writes into, and the only drawing primitive §113's visualizations need (a point is drawn as a cross of lines; see DebugDrawBuffer.addPoint).
See the module header for the float layout, the growth policy, and why non-finite coordinates are stored rather than rejected.