arrayOf()
Function in Layout
Declare a fixed-length array field inside a uniformStruct field map.
import { arrayOf } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
function arrayOf<H extends StructHandle>(element: H, count: number): HandleArray<H>;function arrayOf<T extends ShaderType>(element: T, count: number): TypeArray<T>;Parameters
elementH extends StructHandlethe element: a struct handle, or a shader type.
countnumberthe array length.
Return value
HandleArray<H>
a HandleArray for a struct handle, a TypeArray for a shader type.
Description
The array is
always array<T, N> with a declared count. A runtime-length array<T> is a top-level
storageBuffer binding, which takes no count. Which overload applies is decided by
the shape of element: a struct handle (from structDecl or ioStruct,
recognised by its .of method) returns a HandleArray whose field .at(i) gives the
typed field proxy; a bare ShaderType returns a TypeArray whose field .at(i)
gives the element read directly.
Examples
Example
import { uniformStruct, arrayOf, vec4fT } from 'typeshade'
const U = uniformStruct('Uniforms', { group: 0, binding: 0, as: 'u' }, { dash_array: arrayOf(vec4fT, 2),})const d0 = U.field.dash_array.at(0) // ReadonlyNode<'vec4<f32>'>See also
Source
src/core/sot.ts, line 647, at commit 26de7be8