memoryLayoutOf
memoryLayoutOf<
T>(schema,accessor?):PrimitiveOffsetInfo
A function that retrieves offset and information for a specific primitive within a data schema. Example usage:
const Boid = d.struct({ position: d.vec3f, velocity: d.vec3f,});const memLayout = d.memoryLayoutOf(Boid, (b) => b.velocity.y);console.log(memLayout.offset); // Byte offset of velocity.y within Boid (here 20 bytes)console.log(memLayout.contiguous); // Contiguous bytes available from that offset (here 8 bytes)Type Parameters
Section titled “Type Parameters”• T extends BaseData
Parameters
Section titled “Parameters”schema
Section titled “schema”T
The data schema to analyze.
accessor?
Section titled “accessor?”(proxy) => number
Optional function that accesses a specific primitive within the schema. If omitted, uses the root offset (0).
Returns
Section titled “Returns”PrimitiveOffsetInfo
An object containing the offset and contiguous byte information.