Skip to main content

Interface: InstanceDataSegment

Defined in: rendering/utilities/instance-data-segment.ts:20

A reusable, self-contained chunk of per-instance data.

Segments describe how to bind a fixed number of floats into the instance data buffer and how to wire those floats up to vertex attributes, relative to an offset within the instance. Combine segments with combineInstanceDataSegments to build the instance data layout for a Renderable, allowing binding logic for a vertex shader's instance attributes (e.g. the standard sprite layout) to be shared between sprites with different fragment shaders, and extended with additional per-instance attributes.

Properties​

floatsPerInstance​

readonly floatsPerInstance: number

Defined in: rendering/utilities/instance-data-segment.ts:24

The number of floats this segment occupies in the per-instance buffer.

Methods​

bindInstanceData()​

bindInstanceData(components, instanceDataBufferArray, offset): void

Defined in: rendering/utilities/instance-data-segment.ts:33

Writes this segment's data for an entity into instanceDataBufferArray, starting at offset floats from the start of the instance.

Parameters​

components​

InstanceComponents

The entity's components, resolved once per entity by the render system.

instanceDataBufferArray​

Float32Array

The buffer to write into.

offset​

number

The offset, in floats, of this segment within the instance.

Returns​

void


setupInstanceAttributes()​

setupInstanceAttributes(gl, renderable, offset): void

Defined in: rendering/utilities/instance-data-segment.ts:45

Configures the WebGL vertex attributes for this segment's data.

Parameters​

gl​

WebGL2RenderingContext

The WebGL2 rendering context.

renderable​

Renderable

The renderable being configured.

offset​

number

The offset, in floats, of this segment within the instance.

Returns​

void