Skip to content

arrayOf

arrayOf<TElement>(elementType, elementCount): WgslArray<TElement>

Defined in: packages/typegpu/src/data/array.ts:26

Creates an array schema that can be used to construct gpu buffers. Describes arrays with fixed-size length, storing elements of the same type.

TElement extends AnyWgslData

TElement

The type of elements in the array.

number

The number of elements in the array.

WgslArray<TElement>

const LENGTH = 3;
const array = d.arrayOf(d.u32, LENGTH);
If `elementCount` is not specified, a partially applied function is returned.
const array = d.arrayOf(d.vec3f);
// ^? (n: number) => WgslArray<d.Vec3f>

arrayOf<TElement>(elementType, elementCount?): (elementCount) => WgslArray<TElement>

Defined in: packages/typegpu/src/data/array.ts:31

Creates an array schema that can be used to construct gpu buffers. Describes arrays with fixed-size length, storing elements of the same type.

TElement extends AnyWgslData

TElement

The type of elements in the array.

undefined

The number of elements in the array.

Function

number

WgslArray<TElement>

const LENGTH = 3;
const array = d.arrayOf(d.u32, LENGTH);
If `elementCount` is not specified, a partially applied function is returned.
const array = d.arrayOf(d.vec3f);
// ^? (n: number) => WgslArray<d.Vec3f>