API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classLitMaterial

@codexo/exojs-lighting / lighting / stable

Makes a sprite respond to the lights of a Lighting system. ```ts crate.material = new LitMaterial({ lighting }); hero.material = new LitMaterial({ lighting, normals: new NormalMap(heroNormalMap) }); ``` The shaded result is `albedo * (ambient + sum over lights)`, each light falling off quadratically to nothing at its radius and, for a cone light, fading across its edge. # One normal source per material Normals are a material binding, not a per-sprite one, so every sprite drawn with a given material shares them - in practice one material per atlas. Sprites from a second atlas need a second material, which breaks the batch at the material boundary. Both shade against the same system. # Ownership The material owns neither the lighting system nor the textures. `destroy()` releases only the GPU resources cached against this material.

12
props
6
methods
0
events
Import
import { LitMaterial } from '@codexo/exojs-lighting'

Makes a sprite respond to the lights of a Lighting system.

```ts crate.material = new LitMaterial({ lighting }); hero.material = new LitMaterial({ lighting, normals: new NormalMap(heroNormalMap) }); ```

The shaded result is `albedo * (ambient + sum over lights)`, each light falling off quadratically to nothing at its radius and, for a cone light, fading across its edge.

# One normal source per material

Normals are a material binding, not a per-sprite one, so every sprite drawn with a given material shares them - in practice one material per atlas. Sprites from a second atlas need a second material, which breaks the batch at the material boundary. Both shade against the same system.

# Ownership

The material owns neither the lighting system nor the textures. `destroy()` releases only the GPU resources cached against this material.

Constructors1
Methods6
destroy(): void
Release GPU resources cached against this material on every backend that has compiled it. Safe to call multiple times. After destroy, the material can still be re-used - renderers recompile on next draw - but typical usage is to drop the reference.
onDispose(callback: () => void): void
Hook for renderers to register a per-material-instance cleanup callback (release compiled program, pipeline, or bind groups). The callback fires on destroy; renderers MUST also tolerate the material being garbage-collected without destroy ever being called. Part of the renderer SDK contract for extension renderers.
Replace a declared uniform value, returning this for chaining. Unknown names and scalar↔texture kind changes are rejected. Only available on a material whose shader source declares no uniform schema; a typed material writes through uniforms instead.
Properties12
target: "sprite"
Which drawable class this material can serve; renderers check compatibility.
bindKey: number
Stable bind key: identical ⇒ same bindings (textures unchanged). Derived from this material's identity, base-texture sampler override, and the identities of its bound textures. Changes when a texture is swapped or sampler state changes; drives bind-group/slot reuse.
emissive: number
How much light the surface emits of its own. See LitMaterialOptions.emissive.
The bound normal source. Assigning a replacement takes effect on the next draw and carries its own channel convention with it.
pipelineKey: number
Stable pipeline key: identical ⇒ same GPU pipeline/program can be used. Derived from shader identity and blend mode, and is independent of the owning material instance so identically configured materials share a pipeline. Drives grouping and the pipeline cache.
The declared named uniform blocks, each owning its own values.
The typed accessors of the declared uniform block, or - on a source without a schema - the live user uniform values, where construction declares the fixed set of names and each name's scalar/texture kind: material.uniforms.u_time = performance.now() / 1000; material.uniforms.u_color = [1, 0.5, 0, 1];
Source