Light
A light source node. The SDK's 3D lighting model is deliberately small: every Scene
gets image-based ambient light (IBL) by default — tune it with the scene's
environmentIntensity option — and Light.sun() adds the one direct light: a directional sun
that also casts shadows. There are no point or spot light factories.
Light extends Node; add it to a scene like any node.
At a glance
const scene = new Scene()
scene.add(Light.sun({ direction: [1, -2, -1], intensity: 80000, shadowsQuality: 2 }))
scene.add(Mesh.box({ material: Material.lit({ color: '#e33' }), position: [0, 0.5, 0] }))
scene.open()Light.sun()
Light.sun(options?: {
direction?: Vec3Like // where the light TRAVELS; default [0.548, -0.474, -0.689] (key-light angle)
intensity?: number // luminous intensity; default 100000
color?: ColorInput // default white (0xffffff)
shadowsQuality?: 0 | 1 | 2 | 3 // default 1 — see table
}): LightshadowsQuality |
Result |
|---|---|
0 |
no shadows |
1 |
standard — 1024 shadow map, hard PCF edges |
2 |
high — 2048, stable, soft contact-hardening edges |
3 |
best — 4096, stable, PCSS soft shadows |
Higher quality costs more GPU and memory.
direction, intensity, color and shadow quality are creation-time options — Light
exposes no setters for them. To change the sun, destroy() it and create a new one.
only meshes flagged castShadows throw shadows, and only receiveShadows surfaces
show them — see Mesh. A Material.shadow() plane makes a
transparent shadow-catcher (the AR staple).
IBL vs sun
- IBL (scene option) — soft omnidirectional ambient; on by default, strength
environmentIntensity(default 20000), disable withibl: false. No shadows. Light.sun()— directional key light; gives surfaces shading direction and casts shadows.
A typical lit scene uses both. With ibl: false and no sun, Material.lit() surfaces render
black — use Material.unlit() if you want no lighting at all.