arrayOf()
함수, 레이아웃 분류
Declare a fixed-length array field inside a uniformStruct field map.
import { arrayOf } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function arrayOf<H extends StructHandle>(element: H, count: number): HandleArray<H>;function arrayOf<T extends ShaderType>(element: T, count: number): TypeArray<T>;매개변수
elementH extends StructHandlethe element: a struct handle, or a shader type.
countnumberthe array length.
반환값
HandleArray<H>
a HandleArray for a struct handle, a TypeArray for a shader type.
설명
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.
예제
예제
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>'>함께 보기
소스
src/core/sot.ts, 647행, 커밋 c66579bf 기준