API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classLitMaterial
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.
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.
new(options: LitMaterialOptionsConstruction options for LitMaterial.): LitMaterialdestroy(): 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 (…): thisfrom(source: ShaderImmutable shader source pair shared by Material instances. `Shader` owns only the GLSL/WGSL text and its stable identity; it carries no uniform/texture state (…<F, B>, options?: Omit<MaterialOptionsConstruction options shared by every Material. Only `shader` is required. What `uniforms` means follows from the shader source: on a source that declares a uni…<F, B>, "shader">): SpriteMaterialMaterial specialization for Sprite drawables. The base texture stays on the sprite and is sampled through the engine's `sampleBase(slot, uv)` helper, which pre…<F, B>from(glslVertex: string, glslFragment: string, options?: { blendMode?: BlendModesCompositing blend modes applied when drawing a Drawable over the current render target. Modes 0-4 are implemented as fixed-function GPU blend equations (no tex…; sampler?: SamplerOptionsGPU sampling state: how a texture is filtered and how UV coordinates outside `[0, 1]` are resolved. Sampling state is independent of a texture's pixel content,… | null; uniforms?: Record<string, 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…>; wgsl?: string }): SpriteMaterialMaterial specialization for Sprite drawables. The base texture stays on the sprite and is sampled through the engine's `sampleBase(slot, uv)` helper, which pre…shader: ShaderImmutable shader source pair shared by Material instances. `Shader` owns only the GLSL/WGSL text and its stable identity; it carries no uniform/texture state (…<Readonly<{ emissive: Float; normalY: Float }>, undefined>target: "sprite"bindKey: numberemissive: 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 (…>