Light and lens effects
Updated
Light and lens effects act like light and glass: Bloom makes bright parts glow, a Shock Wave ripples out from a point, and Lens Drops run down the lens like rain. Shock Wave and Lens Drops are one-shot effects that scripts fire when something happens.
| Component | Type | What it does |
|---|---|---|
| Bloom Effect | comp-bloom-effect | Makes bright parts of the image glow. |
| Shock Wave Effect | comp-shock-wave-effect | A ring that ripples the image outward from a world point, like a blast, set off by a script. |
| Lens Drops Effect | comp-lens-drops-effect | Raindrops on the camera lens that land, slide down and dry off. |
The effects
Section titled “The effects”BloomEffectComponent makes bright parts of the image glow.
| Prop | Type | Default | Description |
|---|---|---|---|
intensity |
number |
0.6 |
Strength of the glow, 0 to 5. |
luminance |
number |
0.85 |
Brightness, 0 to 10, above which a pixel glows. |
luminance |
number |
0.025 |
Softness of the threshold’s edge, 0 to 1. |
mipmapBlur |
boolean |
true |
A wider, smoother glow. |
Shock Wave
Section titled “Shock Wave”ShockWaveEffectComponent sends a ring rippling outward across the image from a world point, like a blast.
| Prop | Type | Default | Description |
|---|---|---|---|
position |
[number, number, number] |
[0, 0, 0] |
World point the wave starts from when play() is given none. |
speed |
number |
2 |
How fast the ring grows, 0 to 10. |
maxRadius |
number |
1 |
How far the ring travels before it fades, as a share of the screen, 0 to 10. |
waveSize |
number |
0.2 |
Width of the ring, as a share of the screen, 0.001 to 2. |
amplitude |
number |
0.05 |
How strongly the ring bends the image, -0.25 to 0.25. |
| Method | What it does |
|---|---|
play(at?) |
Sets off a wave at the world point at ({ x, y, z }, for example a THREE.Vector3), or at position when none is given. |
It is a one-shot effect: leave it enabled, it draws nothing while idle, and play sets it off. Nothing happens while the effect is not drawn: disabled, not on the rendering camera, or in the editor outside Preview.
Lens Drops
Section titled “Lens Drops”LensDropsEffectComponent puts raindrops on the camera lens that land, slide down and dry off.
| Prop | Type | Default | Description |
|---|---|---|---|
duration |
number |
10 |
Seconds new drops keep landing, 0 to 60. 0 for no end. |
rate |
number |
20 |
New drops per second, 0 to 100: how hard it rains. |
count |
number |
40 |
Drops already on the lens when it starts, a whole number from 0 to 1000. |
size |
number |
0.03 |
Average drop size, as a share of the screen’s height, 0.005 to 0.2. |
evaporation |
number |
6 |
Seconds a drop takes to dry, 0.1 to 30. |
gravity |
number |
1 |
How fast big drops slide down, 0 to 10. 1 is natural, 0 makes them cling. |
cling |
number |
1 |
Most seconds a big drop waits before it slides, 0 to 5. |
advance |
number |
0 |
Seconds the drops are moved ahead when they start, 0 to 60, so it looks as if it has been raining a while. |
| Method | What it does |
|---|---|
play() |
Start the rain over: count drops at once, then rate per second for duration seconds. |
stop() |
End the rain early: no new drop lands, and those on the lens dry off. |
clear(fade?) |
Wipe the lens until the next play(). Drops fade out over fade seconds, 0.25 by default; clear(0) wipes at once. |
Enabling the component also starts the rain; disabling it removes the drops at once. Once the last drop has dried, the effect costs next to nothing while it stays enabled. Drops slide toward the world’s down as the camera sees it: roll the camera and they slide across the view.
Examples
Section titled “Examples”1. Set off a shock wave where something explodes
Section titled “1. Set off a shock wave where something explodes”Click a barrel to blow it up: a shock wave ripples out from its position. The barrel has a Selectable and a Signal Emitter with the signal barrel/click. The camera has a Shock Wave effect, enabled and idle.
#pragma lifecycle(startup)
const where = new THREE.Vector3();
function startup() { const wave = findEntity('Main Camera').getComponent(ShockWaveEffectComponent); wave.setProps({ speed: 2.5, maxRadius: 0.8, amplitude: 0.08 });
on('barrel/click', (event) => { if (event.eventType !== EventType.Selectable.Select) return; findEntity(event.entityId)?.getComponent(SelectableComponent)?.setSelected(false); // so the next click selects it again const barrel = findEntity(event.entityId); if (!barrel) return;
barrel.getWorldPosition(where); wave.play(where); destroy(barrel); });}Click a barrel and it disappears in a shock wave that ripples across the screen from where it stood: a Shock Wave effect on the camera, played by a Behavior script from Selectable clicks.
Click the barrels one by one. Reload to bring them back. Drag to orbit the camera, scroll to zoom.
wave.setProps(...)tunes the ring once at startup: a little faster, a little shorter, a little stronger than the default.- The Signal Emitter event carries
entityId, the entity that sent it, so one script can handle any number of barrels that share the same signal. getWorldPosition(where)reads the barrel’s world position into a vector made once, andplay(where)starts the ring there.- The wave is placed from where the camera is in the world, so it works on a moving camera and in a headset.
destroy(barrel)removes the barrel after the wave has its position.
2. Rain on the lens during a storm
Section titled “2. Rain on the lens during a storm”A storm wets the lens, and it clears when the storm ends. The effect is kept enabled from the start and wiped at once, so the first drops show without delay.
#pragma lifecycle(startup)
function startup() { const drops = findEntity('Main Camera').getComponent(LensDropsEffectComponent); drops.clear(0);
on('storm/start', (data) => { const heavy = data?.heavy === true; drops.setProps({ duration: 0, rate: heavy ? 60 : 20, gravity: heavy ? 1.5 : 1, advance: 3, }); drops.play(); });
on('storm/end', () => drops.stop()); on('player/wipe-visor', () => drops.clear(0.5));}A storm wets the camera lens and its end lets the drops dry: a Lens Drops effect kept enabled and wiped at start, driven by Storm, End storm and Wipe buttons.
Press Storm to start the rain on the lens, Wipe to clear it at once, End storm to let it dry. Drag to orbit the camera, scroll to zoom.
clear(0)instartupdries the lens at once while the effect stays enabled and compiled.duration: 0keeps drops landing until the rain is stopped.advance: 3starts as if it had been raining for three seconds, with trails already on the lens.play()starts the rain with the new settings;stop()lets the drops on the lens dry naturally;clear(0.5)wipes them over half a second, as a visor wipe would.