UniformStruct
Interface in Layout
The handle uniformStruct returns: a struct and its binding declared together.
import type { UniformStruct } from 'typeshade'
The signature, the description and the examples come from the compiler's own source at commit 26de7be8.
Syntax
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]> };}Description
.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.
Instance properties
structread onlyStructDeclThe struct declaration, for
module({ structs }).declread onlyStructDeclThe same declaration as
struct, under the name every other handle in this module uses, sostructs: [U.decl, VsOut.decl]reads uniformly.typeread onlyShaderTypeThe struct’s
ShaderType.bindingread onlyBindingDeclThe binding declaration, for
module({ bindings }).noderead onlyNodeThe raw binding access node, for a hand-built
member(...)read.fieldread only{ readonly [K in keyof F]: UniformFieldNode<F[K]> }Typed, read-only field access. A field declared with
arrayOfexposes.at(i).
See also
Source
src/core/sot.ts, line 690, at commit 26de7be8