Skip to content

createScene#lights

Summary

createScene#lights returns all light instances currently attached to the scene, including disabled lights. Use this collection for inspection, UI listing, or bulk parameter edits.

Syntax

Scene.lights: readonly Light[]
const lights = scene.lights;

Parameters

This property does not take parameters.

Returns

readonly Light[] - Ordered list of scene lights.

Type Details

LightType

type LightType = "ambient" | "directional" | "point" | "spot";

Example

const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);

const scene = wgpu.createScene();
scene.addLight(wgpu.createLight.ambient({ intensity: 0.2 }));
scene.addLight(wgpu.createLight.point({ position: [1, 2, 1], range: 10 }));
scene.addLight(wgpu.createLight.spot({ position: [-1, 2, 0], direction: [0, -1, 0], range: 14 }));
console.log(scene.lights.length, scene.lights.map(l => l.type));

See Also