Skip to content

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.

ComponentTypeWhat it does
Bloom Effectcomp-bloom-effectMakes bright parts of the image glow.
Shock Wave Effectcomp-shock-wave-effectA ring that ripples the image outward from a world point, like a blast, set off by a script.
Lens Drops Effectcomp-lens-drops-effectRaindrops on the camera lens that land, slide down and dry off.

BloomEffectComponent makes bright parts of the image glow.

Prop Type Default Description
intensity number 0.6 Strength of the glow, 0 to 5.
luminanceThreshold number 0.85 Brightness, 0 to 10, above which a pixel glows.
luminanceSmoothing number 0.025 Softness of the threshold’s edge, 0 to 1.
mipmapBlur boolean true A wider, smoother glow.

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.

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.

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.

BarrelBlast.jx
#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);
});
}
  • 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, and play(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.

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.

StormLens.jx
#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));
}
  • clear(0) in startup dries the lens at once while the effect stays enabled and compiled.
  • duration: 0 keeps drops landing until the rain is stopped. advance: 3 starts 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.