Renderer · function

packInstances

Interleave count instances into out, matrix, tint and opacity, at INSTANCE_FLOATS apart.

Explained in Hello world.

function packInstances(instances: MeshInstances, out: Float32Array): void
import { packInstances } from '@driftengine/core';

Parameters

ParameterTypeDescription
instancesMeshInstances
outFloat32Array

In depth

Interleaved rather than two buffers so a batch's upload is one writeBuffer and an instance's colour sits beside the matrix that places it. Shared by both backends, because which floats go where is a decision and not a binding — the rule this repository draws around resolveAtmosphere and resolvePointLights.

Writes nothing beyond count, and allocates nothing: out is the caller's staging array.