API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classMaterial
Describes the look of a renderable - shader, uniforms, textures, blend mode, and sampling state - independent of its geometry. A `Material` can be shared across many drawables; renderers cache compiled programs/pipelines keyed on pipelineKey and reuse bindings keyed on bindKey. Subclasses fix the target drawable class. Call destroy when the material is no longer needed to release the GPU resources cached on every backend it was used on. Both keys are derived live from the current material state, so they stay stable across repeated reads and change exactly when the relevant state changes - even when uniforms, textures, blendMode, or sampler are mutated in place. # Typed and raw uniforms A shader source that declares a uniform schema gives its materials typed accessors: `material.uniforms.time.set(seconds)` for the implicit block, or `material.uniformBlocks.camera.uniforms.projection.set(matrix)` for named blocks. Writes go into the material's own std140 buffer and are uploaded only when a value changed, and setUniform is not available. A source without a schema keeps the untyped record: `material.uniforms` is a live map of the names declared at construction, and both languages' uniform declarations are the author's responsibility. Write a function that takes materials of either kind against AnyMaterial rather than the bare class, whose defaults describe the raw path.
import { Material } from '@codexo/exojs'Describes the look of a renderable - shader, uniforms, textures, blend mode, and sampling state - independent of its geometry.
A `Material` can be shared across many drawables; renderers cache compiled programs/pipelines keyed on pipelineKey and reuse bindings keyed on bindKey. Subclasses fix the target drawable class. Call destroy when the material is no longer needed to release the GPU resources cached on every backend it was used on.
Both keys are derived live from the current material state, so they stay stable across repeated reads and change exactly when the relevant state changes - even when uniforms, textures, blendMode, or sampler are mutated in place.
# Typed and raw uniforms
A shader source that declares a uniform schema gives its materials typed accessors: `material.uniforms.time.set(seconds)` for the implicit block, or `material.uniformBlocks.camera.uniforms.projection.set(matrix)` for named blocks. Writes go into the material's own std140 buffer and are uploaded only when a value changed, and setUniform is not available.
A source without a schema keeps the untyped record: `material.uniforms` is a live map of the names declared at construction, and both languages' uniform declarations are the author's responsibility.
Write a function that takes materials of either kind against AnyMaterial rather than the bare class, whose defaults describe the raw path.
destroy(): voidonDispose(callback: () => void): voidsetTexture(name: string, texture: RenderTextureAn off-screen render target that can also be sampled as a texture. Combines RenderTarget (framebuffer attachment) with the sampler parameters of a Texture (sca… | TextureA static GPU texture sourced from an image, canvas, or video element. Holds the pixel source, its sampling state (ScaleModes, WrapModes) and its upload state (…): thissetUniform(name: MaterialRawUniformNameA uniform name the raw path accepts; `never` once a schema is declared.<F, B>, value: UniformValueValue accepted by a material uniform on a shader source that declares no uniform schema. Scalars and small tuples auto-marshal to the appropriate `Float32Array…): thistarget: "mesh" | "particle" | "sprite"bindKey: numberpipelineKey: numbertextures: Record<string, RenderTextureAn off-screen render target that can also be sampled as a texture. Combines RenderTarget (framebuffer attachment) with the sampler parameters of a Texture (sca… | TextureA static GPU texture sourced from an image, canvas, or video element. Holds the pixel source, its sampling state (ScaleModes, WrapModes) and its upload state (…>