Skip to main content

Class: Material<TModuleProps, TBindings>

Defined in: modules/engine/src/material/material.ts:84

Material owns bind group 3 resources and uniforms for one material instance.

setProps() mutates uniform values in place. Structural resource changes are expressed through clone({...}), which creates a new material identity.

Type Parameters​

TModuleProps​

TModuleProps extends MaterialModuleProps = MaterialModuleProps

TBindings​

TBindings extends MaterialBindings = MaterialBindings

Constructors​

Constructor​

new Material<TModuleProps, TBindings>(device, props?): Material<TModuleProps, TBindings>

Defined in: modules/engine/src/material/material.ts:103

Parameters​

device​

Device

props?​

MaterialProps<TModuleProps, TBindings> = {}

Returns​

Material<TModuleProps, TBindings>

Properties​

bindings​

readonly bindings: Record<string, MaterialBinding> = {}

Defined in: modules/engine/src/material/material.ts:97

Internal binding store including uniform buffers and resource bindings.


device​

readonly device: Device

Defined in: modules/engine/src/material/material.ts:91

Device that owns the material resources.


factory​

readonly factory: MaterialFactory<TModuleProps, TBindings>

Defined in: modules/engine/src/material/material.ts:93

Factory that defines the material schema.


id​

readonly id: string

Defined in: modules/engine/src/material/material.ts:89

Application-provided identifier.


shaderInputs​

readonly shaderInputs: ShaderInputs<TModuleProps>

Defined in: modules/engine/src/material/material.ts:95

Shader inputs for the material-owned modules.

Methods​

clone()​

clone(props?): Material<TModuleProps, TBindings>

Defined in: modules/engine/src/material/material.ts:141

Creates a new material variant with optional structural and uniform overrides.

Parameters​

props?​

MaterialCloneProps<TModuleProps, TBindings> = {}

Returns​

Material<TModuleProps, TBindings>


destroy()​

destroy(): void

Defined in: modules/engine/src/material/material.ts:136

Destroys managed uniform-buffer resources owned by this material.

Returns​

void


getBindGroupCacheKey()​

getBindGroupCacheKey(group): object | null

Defined in: modules/engine/src/material/material.ts:248

Returns the stable bind-group cache token for the requested bind group.

Parameters​

group​

number

Returns​

object | null


getBindings()​

getBindings(shaderLayout?): Partial<{ [K in string | number | symbol]: Binding }> & Record<string, Binding>

Defined in: modules/engine/src/material/material.ts:209

Returns resolved bindings, including internal uniform buffers and ready texture sources.

Parameters​

shaderLayout?​

AnyShaderLayout = ...

Reflected bindings used to select copied or external texture resolution.

Returns​

Partial<{ [K in string | number | symbol]: Binding }> & Record<string, Binding>


getBindingsByGroup()​

getBindingsByGroup(shaderLayout?): BindingsByGroup

Defined in: modules/engine/src/material/material.ts:243

Packages resolved material bindings into logical bind group 3.

Parameters​

shaderLayout?​

AnyShaderLayout = ...

Reflected bindings used to select copied or external texture resolution.

Returns​

BindingsByGroup


getBindingsUpdateTimestamp()​

getBindingsUpdateTimestamp(): number

Defined in: modules/engine/src/material/material.ts:254

Returns the latest update timestamp across material-owned resources.

Returns​

number


getResourceBindings()​

getResourceBindings(): Partial<TBindings>

Defined in: modules/engine/src/material/material.ts:193

Returns the material-owned resource bindings without internal uniform buffers.

Returns​

Partial<TBindings>


ownsBinding()​

ownsBinding(bindingName): boolean

Defined in: modules/engine/src/material/material.ts:164

Returns true if this material owns the supplied binding name.

Parameters​

bindingName​

string

Returns​

boolean


ownsModule()​

ownsModule(moduleName): boolean

Defined in: modules/engine/src/material/material.ts:169

Returns true if this material owns the supplied shader module.

Parameters​

moduleName​

string

Returns​

boolean


setProps()​

setProps(props): void

Defined in: modules/engine/src/material/material.ts:174

Updates material uniform/module props in place without changing material identity.

Parameters​

props​

MaterialPropsUpdate<TModuleProps>

Returns​

void


updateShaderInputs()​

updateShaderInputs(commandEncoder?): void

Defined in: modules/engine/src/material/material.ts:184

Updates managed uniform buffers and shader-input-owned bindings.

Parameters​

commandEncoder?​

CommandEncoder

Optional encoder used to order material uniform uploads with subsequent draw commands.

Returns​

void