Modules / Rendering & look

lights3dplugin

Point lights in the 3D scene, grouped into clusters so a scene can hold many of them.

Putting it in a scene

Add it anywhere in plugins with a render3d. Every PointLight in the scene then goes through it.

"plugins": ["loader", "scenemanager", "player", "render3d", "lights3d"],
"world": {
  "lights3d": { "grid": [16, 9], "slices": 24 }
}

Properties

Read from world.lights3d. Both are required.

.grid : [across, up]

How many cells the frame is cut into across and up. Whole numbers above 0.

.slices : number

How many cells the view is cut into in depth, from the camera's near to its far. Each is the same ratio deeper than the one before, so the cells near the eye are shallow. A whole number above 0.

Which lights it takes

It takes every visible PointLight that casts no shadow, and each pixel is lit only by the lights whose reach includes its cell. A light's distance sets its reach in metres. A light with no distance reaches every cell, which takes away the saving.

A point light that casts a shadow is drawn by three.js as usual. Standard, physical, Lambert, Phong and toon materials are lit; basic materials are not. The overlay scene is lit only by its own lights.

Properties of the plugin

Through plugins.lights3d.

count : number

The lights it handled the last time the scene was drawn.

entries : number

How many lights were put in a cell, counting a light once for every cell it reaches.

cells : number

The number of cells, grid across × up × slices.

In the guide