API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classLighting
What a lighting system does with lights, materials and occluders, whichever renderer turns them into pixels. ```ts const lighting = new LightmapLighting(app, { ambient: new Color(11, 16, 32) }); scene.systems.add(lighting); lighting.add(player.addChild(new PointLight({ radius: 260 }))); lighting.occludeFrom(new PhysicsOccluder(world)); ``` Construct one of ForwardLighting, LightmapLighting or RadianceLighting. They are alternatives rather than layers, and a frame is shaded by exactly one of them. This class is what they share: the registries, the collection of occluders, and the update and destroy contracts. It links no renderer of its own, which is what keeps a project using one of them from carrying the others. # What it owns The renderer and its GPU resources. Lights are scene nodes owned by the tree they hang in - registering one does not transfer ownership, and destroying a registered light unregisters it. Occluder sources, filters passed as `post`, and the host are the caller's too. # Ordering Register it with the registry that ticks AFTER the code moving the lights, so the frame it shades is the frame that was drawn. `app.systems` runs its update phase before the active scene's, so a system registered there sees lights the scene has not moved yet; `scene.systems` is usually what you want.
import { Lighting } from '@codexo/exojs-lighting'What a lighting system does with lights, materials and occluders, whichever renderer turns them into pixels.
```ts const lighting = new LightmapLighting(app, { ambient: new Color(11, 16, 32) });
scene.systems.add(lighting); lighting.add(player.addChild(new PointLight({ radius: 260 }))); lighting.occludeFrom(new PhysicsOccluder(world)); ```
Construct one of ForwardLighting, LightmapLighting or RadianceLighting. They are alternatives rather than layers, and a frame is shaded by exactly one of them. This class is what they share: the registries, the collection of occluders, and the update and destroy contracts. It links no renderer of its own, which is what keeps a project using one of them from carrying the others.
# What it owns
The renderer and its GPU resources. Lights are scene nodes owned by the tree they hang in - registering one does not transfer ownership, and destroying a registered light unregisters it. Occluder sources, filters passed as `post`, and the host are the caller's too.
# Ordering
Register it with the registry that ticks AFTER the code moving the lights, so the frame it shades is the frame that was drawn. `app.systems` runs its update phase before the active scene's, so a system registered there sees lights the scene has not moved yet; `scene.systems` is usually what you want.
new(backend: LightingBackend, host: LightingHostWhat a lighting system needs of the application whose frame it lights. A renderer that composes the frame reads the drawn frame, installs its passes in the fra… | null, options: LightingOptionsWhat every lighting system takes, whichever renderer it is.): Lightingadd(light: T): Tclear(): thisclearOccluders(): thisclearSurfaces(): thisdestroy(): voidoccludeFrom(source: T): Tupdate(): voidactiveLightCount: numberactiveSurfaceCount: numberdebugExposure: numberhdr: booleansurfaces: readonly NormalSurfaceA registered drawable and the normals it contributes.[]