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(entity, world, instanceDataBufferArray, offset): void

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

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

Parameters

entity

number

The entity to bind data for.

world

EcsWorld

The world the entity belongs to.

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:47

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