UniformStruct
인터페이스, 레이아웃 분류
The handle uniformStruct returns: a struct and its binding declared together.
import type { UniformStruct } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
interface UniformStruct<F extends Record<string, UniformFieldSpec>> { readonly struct: StructDecl; readonly decl: StructDecl; readonly type: ShaderType; readonly binding: BindingDecl; readonly node: Node; readonly field: { readonly [K in keyof F]: UniformFieldNode<F[K]> };}설명
.struct (also spelled .decl) is for module({ structs }), .binding for
module({ bindings }), and .field gives typed, read-only field access; uniforms are
read-only in WGSL, so .field.x.assign(...) is a tsc error. F may include a fixed-size
arrayOf field (a struct-element array or a plain-type array), the one field shape
PlainStruct cannot express.
The type is exported so that other code can accept it as a generic constraint and build on
the struct’s shape F without re-declaring it: a host can derive a CPU-side std140 buffer
writer from u.struct, and a helper can return
UniformStruct<{ time: ...; resolution: ... } & F> to compose a base uniform layout with a
caller’s extra fields under one type-checked struct.
인스턴스 속성
struct읽기 전용StructDeclThe struct declaration, for
module({ structs }).decl읽기 전용StructDeclThe same declaration as
struct, under the name every other handle in this module uses, sostructs: [U.decl, VsOut.decl]reads uniformly.type읽기 전용ShaderTypeThe struct’s
ShaderType.binding읽기 전용BindingDeclThe binding declaration, for
module({ bindings }).node읽기 전용NodeThe raw binding access node, for a hand-built
member(...)read.field읽기 전용{ readonly [K in keyof F]: UniformFieldNode<F[K]> }Typed, read-only field access. A field declared with
arrayOfexposes.at(i).
함께 보기
소스
src/core/sot.ts, 690행, 커밋 c66579bf 기준