struct

Declare a record type.

struct(name: string, fields: Record<string, StructFieldType>): StructType

Import struct from shaders/std.

The engine writes the WGSL struct for you and sizes buffers from it, so it is type-checked in TypeScript and identical in every pass that uses it.

Parameters

NameTypeNotes
namestring
fieldsRecord<string, StructFieldType>

Example

const Star = struct('Star', {pos: 'vec3f', vel: 'vec3f', heat: 'f32'})

See also

  • buffer — A storage buffer of count records of a struct type, zero-filled.
  • kernel — Your own compute pass.