Energy Crystal
A faceted crystal floats between your hands on the webcam: an open palm charges it, a fist shatters it, a pinch re-forms it and sets its size. Without a camera, one click does it.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Gestures & Webcam has 11 effects, all premium. Explore the category →
3 usage examples



How it works
The crystal is a 12-facet bipyramid, computed in WebGL in a 512 px buffer and then copied onto the scene canvas. It sits halfway between two hands, or next to a single hand, spins on its axis and is surrounded by 150 orbiting particles. Each facet shows what lies behind it, with a different refraction index for red, green and blue: on the webcam, your own picture bends inside the crystal.
Three gestures make a cycle. Open palm: a beam leaves the palm, the crystal's charge rises by 50% per second per hand, it spins faster and glows more; with no palm it drops by 16% per second. Fist: the crystal vanishes and its particles are thrown outwards, with a glow and a ring that stay around it. Pinch (thumb against index, other fingers straight): the particles spiral back and the crystal re-forms; the gap between thumb and index then sets its size, from 0.7 to 1.6 times the starting size.
A small panel in the top right corner shows the number of hands, the recognised gesture and the state of the crystal. The script only writes two attributes on the scene, data-ecx-gesture and data-ecx-crystal; the CSS picks the label. Your page can read both attributes to react, as the first two examples do.
Without a camera, the palm of a drawn hand follows the cursor, a click or a tap counts as a fist, and the second hand comes in 1.2 s later to pinch the crystal back together. If nobody touches anything, the two hands run through the three gestures on their own over 13 s. The captures on this page are made this way, with the code you buy. The webcam only opens from its button: the MediaPipe hand detector is then downloaded and runs inside the page, and no image leaves the device. Only one thing goes out: about a minute after the detector loads, then every minute while the camera is filming, Google's library sends a technical report of about a hundred bytes (its version, processing times) to odml.pa.googleapis.com on its own, with no image. Mention it in your site's privacy policy.
Accessibility
- Keyboard: a single tab stop, the camera button (Enter or Space). Shattering the crystal takes a click, a tap or a real fist: there is no key for it. With no pointer, the automatic demonstration still shows all three states.
- Reduced motion: rotation, orbits and automatic hands stop: with no pointer, the crystal stays still, down to the pixel. A click still shatters the crystal, but the particles are placed straight at their end position, with no flight and no glow, and then it reappears.
- State for screen readers: the gesture panel is
aria-hidden, like the canvas. Only the camera messages (loading, camera on, no hand, refusal) are announced, through arole="status"pill. If a gesture triggers something on your page, announce it yourself. - Touch: a tap shatters, a horizontal swipe moves the hand, a vertical swipe scrolls the page. The tap was checked in touch emulation in all three engines, the swipes in Chromium only; nothing on a real phone.
- Light: the shatter is a glow and a ring around the crystal, gone in half a second, never a full-screen flash, and the code allows one every 0.7 s at most. The
.ecx-solidclass on the scene dims the effect by 45% and makes the panels opaque.
Browser compatibility
WebGL 1 for the crystal, Canvas 2D for everything else, 63 KB of unminified JavaScript, no library in demo mode. Our tests (Chromium 149, Firefox 151, WebKit 26.5): with two crystals on the same page, clicking the second breaks only that one; in demo, not a single network request; off screen, drawing stops. On the camera side, tried in Chromium and Firefox with their simulated webcam: four files to download (10.7 MB transferred, around twenty once unpacked), then the MediaPipe report of about 100 bytes every minute. A CSP whose connect-src does not allow odml.pa.googleapis.com blocks that report without affecting the crystal (tried in Chromium). For the three gestures, simulated hand landmarks were passed to the shipped code in Chromium, and a trial video showed that a real hand is recognised. Camera never tried in Safari.
No WebGL, or context lost: the crystal is drawn in Canvas 2D, with flat blue facets and light edges, without refraction; particles, beams and gestures are unchanged. Camera refused or missing: a 10 s message, and the demonstration resumes. On camera, a shattered crystal re-forms by itself when no hand has been seen for 3 s.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0848-root">
<div class="ecx-scene" data-ecx-lang="en" role="region" aria-label="Energy Crystal — a faceted crystal floats between your hands: open palm to charge it, fist to shatter it, pinch to re-form it. Cursor demo, camera on request (processed on your device only)">
<video class="ecx-video" playsinline muted autoplay aria-hidden="true" tabindex="-1"></video>
<canvas class="ecx-canvas" aria-hidden="true"></canvas>
<div class="ecx-bar">
<button class="ecx-btn ecx-cam-btn" type="button" aria-pressed="false">
<span class="ecx-btn-ico" aria-hidden="true"></span><span class="ecx-btn-txt">Turn camera on</span>
</button>
<p class="ecx-privacy">No image ever leaves your device.</p>
</div>
<p class="ecx-status" role="status" aria-live="polite"></p>
<div class="ecx-label" aria-hidden="true">
<span>Energy Crystal</span>
<span class="ecx-hint">move the cursor · click to shatter · or turn the camera on</span>
</div>
<div class="ecx-hud" aria-hidden="true">
<span class="ecx-hud-k">Hands</span><span class="ecx-hud-v ecx-hud-hands">0</span>
<span class="ecx-hud-k">Gesture</span><span class="ecx-hud-v"><i data-g="none">none</i><i data-g="palm">palm · beam</i><i data-g="fist">fist · shatter</i><i data-g="pinch">pinch · size</i></span>
<span class="ecx-hud-k">Crystal</span><span class="ecx-hud-v"><i data-c="stable">stable</i><i data-c="charge">charged</i><i data-c="burst">shattered · pinch</i><i data-c="form">forming</i> <b class="ecx-hud-scale">1.0×</b></span>
</div>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Size set by the pinch (JS — SIZE_MIN, SIZE_MAX) |
0.7 and 1.6 | Bounds of the crystal's size, as multiples of its base size (18.5% of the scene's short side, between 40 and 160 px in radius). Use two equal values for a fixed size. |
Delay between two shatters (JS — BLAST_GAP) |
0.7 s | Minimum time between two bursts. Do not go below 0.34 s: past three bursts per second, you leave the limit the code set itself for photosensitive people. |
Gesture hold (JS — GEST_HOLD) |
0.1 s | How long a hand shape must stay stable before it counts as a gesture. 0.25 s avoids accidental shatters when a hand crosses the frame. |
Charge speed (JS — 0.5 * feed : -0.16 in render) |
+50% per second per palm, −16% otherwise | The first number sets the rise, the second the fall. The panel reads "charged" above 75%. |
Particles (JS — DUST_N, FLUX_MAX) |
150 and 260 | Number of orbiting particles, and cap on those travelling up the beams. Halve both on a slow device. |
Crystal sharpness (JS — GL_SIZE) |
512 px | Side of the WebGL buffer. 256 is enough for a crystal under 120 px on screen; 1024 for a full-screen kiosk. |
Refracted backdrop in demo (JS — c0, c1, c2 in FS) |
the scene's night-blue gradient | Without a camera, the crystal refracts a gradient written in the shader, not your page. If you change the scene background in CSS, copy the same colours there. |
Hero variant (HTML — .ecx-kiosk, data-ecx-start) |
to add to the HTML | A dark veil on the left holds your headline, your text and the call-to-action button. The gesture panel only shows once the camera is on. |
Gesture panel (HTML — .ecx-hud) |
present | Remove the block from the HTML: the script does without it and keeps writing the two attributes on the scene. |
FAQ
data-ecx-gesture is none, palm, fist or pinch, and data-ecx-crystal is stable, charge, burst or form. An attribute selector is enough to change a style; to run code, watch them with a MutationObserver. The charge (0.12 to 1) and the size can be read from scene.ecxBase.effect.charge and .sizeF.