The live demo starts when it’s in view.Drag to orbit · W A S D move · Q E turn · G glide · L rings the lamps with real lights
Hundreds of lamps lit for the price of eight lights.
What it costs a frame
GPU
0.94 ms
CPU
0.27 ms
02468101216.7 ms
GPU
0.94 ms
CPU, median
0.27 ms
CPU, 95th pct
0.41 ms
Draw calls
16
Weight
Moderate
Measured 11 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept. What ran: Measured gliding by itself round its loop (down a street, rising over each open crossing, along the boulevard and through the square), the real lights handed between lamps as it goes, rings on. 236 lamps (posts, wall lamps, bollards, floods), 4 point and 4 spot lights, about 840 windows; every lamp a glow, every post a pool and a beam near the camera. Phones: tiers are being measured next.
apple · Apple A19 Proin a browser tab · 16 November 2026
3.15
0.40
0.60
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
6.42
0.95
1.36
Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.
What it needs
Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages
What it’s for
Street lamps, wall lamps and bollards across a town or a game level at night
A building or a city with thousands of lit windows
Floodlights and searchlights washing walls and landing on the ground
Architectural and product walk-throughs after dark
Keeping the light count fixed so shaders never rebuild mid-game
Dusk falling across a scene, lamps coming on one by one
Stadiums, car parks, harbours and yards lit by rows of masts
Pitfalls, in brief
Make the real lights once and never add or remove one. three bakes the number of lights into every lit shader, so a light coming or going rebuilds every lit material in the scene on the next frame: a stall of a few hundred milliseconds or more.
Each light in the pool costs in every lit pixel, even at intensity 0: eight pooled lights took the source game from 2.7 to 3.0 ms of GPU.
Not three r187’s DynamicLighting (three/addons/lighting/DynamicLighting.js): it batches lights into uniform arrays so their count can change without a rebuild, but each kind adds uniform buffers of its own.
Call compile() once the object is in the scene, before the first frame: an instanced mesh with a count of 0 is skipped by compileAsync, so the glow, beams, pools and rings would otherwise be built on the frame they first show.
Choose by what matters, not by the camera alone: the player, or the view’s centre in an orbit view.
7 more in brief
Keep the hold margin (hysteresis) above 0 when lamps stand in rows: two posts at the same distance otherwise trade a light every choice, and the ground flickers between them.
A hand-over fades out, then in, so the fade sets how fast the light follows a fast camera: 0.35 s with a choice every 0.25 s follows walking and a slow glide.
Match the faked pool to the real light by eye (poolAlone against the light’s intensity, with the rings on): where they differ, the crossfade shows as a slow brightening.
The glow, beams and pools are added on top (additive blending), so the scene’s fog would add its colour to them: pass the fog’s density as air, and they fade with distance instead.
Instance colours are set from the start (all black).
Beams are drawn for spots within beamNear of the camera, re-listed at each choice and faded to nothing at the edge, so one enters dark.
The window attribute travels with its instance: if your app moves instances between slots (removing one by swapping in the last), move the attribute’s value too, or a lit window goes dark and another lights.
12 pitfalls in full, the hook-up guide, the module source and its tests come with the part.
Where it comes from
From HaTac. Fully custom code.
MurmurHash3 finaliser (Austin Appleby, public domain): the integer hash behind the flicker and the lit windows, in place of the sine hash
lightslight poolpoint lightspot lightstreet lampsnightinstancinginstance attributeglowlight beamlight pool on the groundlit windowslevel of detailhysteresiscrossfadeduskshader compilelight countWebGPU limitsthree.jsTSLno dependencies
GLB models ready for a stage: gated before loading (header, size and count budgets, allowed extensions, nothing outside the file, each refusal with a plain…