Gestures & WebcamPremium

Particle Sphere

A 4,200-point sphere settles on your palm: the number of raised fingers picks its colour, the gap between two hands its size, a wide-open hand makes it burst.

WebcamMediaPipeHand trackingWebGL

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

A celestial body in your palm — station in the hall of planets of an observatory — Particle Sphere example 1

① A celestial body in your palm — station in the hall of planets of an observatory

WhenThe visitor raises two, three, four or five fingers: the sphere changes colour and the sheet on the right goes from the Orion Nebula to Mars, the Moon or the Sun. Two hands: Uranus, which grows as they move apart.
WhySix colours for six finger counts: a menu you browse without touching anything, readable from a distance, and a dotted sphere easily passes for a planet.
SettingsThe page reads scene.psxBase.effect.s.count and s.mode every 80 ms to show the sheet. In this example, pointer-events: none on .psx-scene (a station with no mouse) and the script keeps the demo scenario on its “one hand” part: the fingers in the capture belong to the ghost hand.
Setting the volume without touching the screen — console of a media library listening room — Particle Sphere example 2

② Setting the volume without touching the screen — console of a media library listening room

WhenThe listener spreads their hands: the sphere grows and the volume gauge rises; bringing them closer lowers it. With the cursor, the distance between the pointer and the opposite hand plays that part.
WhyThe sphere's radius is a continuous measurement, already smoothed by the effect: the page only has to copy it into a gauge. The sphere is the visual feedback; you see the setting before reading the number.
SettingsEvery 80 ms the page reads s.R (radius in pixels) when s.mode is 2 and maps it to 0–100% (here from 42 to 112 px). A click in the scene bursts the sphere without changing the volume: that is how the effect behaves.
Confirming a vote by opening your hand wide — participatory budget station in a town hall — Particle Sphere example 3

③ Confirming a vote by opening your hand wide — participatory budget station in a town hall

WhenThe resident has picked a project. They tap “Confirm my vote”, or open a hand wide in front of the camera: the sphere in the medallion bursts, the button turns to “Vote recorded”, then the sphere re-forms.
WhyThe burst lasts 2.45 s and cannot repeat within 2.4 s: a hesitant gesture does not confirm twice. The button stays for anyone who will not, or cannot, use the camera.
Settings166 px medallion (50% rounded corners on the container, camera button shrunk to 9 px). The button calls scene.psxBase.effect.burst(); the page watches s.exp, non-null during the explosion, to record the vote whatever triggered it.

How it works

The sphere is a globe of dots laid out on 48 parallels, drawn with WebGL in an off-screen canvas and then copied onto the scene's canvas. The number of dots shown follows the radius: 500 for a small sphere, 4,200 above 100 px. It spins slowly on itself, and faster when the hand moves; dots on the far side are darker, which gives it depth.

The effect reads two values from the hand. With a single hand it counts raised fingers: zero to five, six colours (violet, mauve, pink, orange, warm white, gold), confirmed after 0.16 s so they do not flicker; the fingertips that count light up. With two hands the sphere turns cyan, sits between the palms, and its radius is 38% of the gap between them.

Hand wide open, fingers spread, for 0.08 s: the sphere bursts, its dots drift and curve back, all within 2.45 s and at most once every 2.4 s. A click or a tap in the scene triggers the same burst; on the webcam, bringing both hands together does too.

None of this needs a camera to begin with. The scene starts as a demo: with the cursor, two ghost hands frame the sphere, whose size follows the distance between the pointer and the opposite hand; without a cursor, a 14 s script goes through two hands, one hand with 2, 3 and 4 fingers, then the burst. The three examples on this page run that way. The webcam only switches on when its button is clicked; hands are then located by MediaPipe inside the browser, and the video stream is passed to no server (the FAQ details the one technical report that does go out).

Accessibility

  • Keyboard: only the camera button can be operated from the keyboard (Tab, then Enter or Space). Bursting on click has no keyboard equivalent in the delivered code; if your page relies on it, add a button that calls burst(), as the third example does.
  • Reduced motion: the sphere no longer spins, breathes or bursts (click and gesture are ignored), and the automatic script is replaced by a still two-hand pose. It still follows the cursor. Measured: two captures 0.8 s apart are pixel-identical.
  • Touch: a tap bursts the sphere; a horizontal drag moves the hand, a vertical drag scrolls the page. Measured with touch emulation, not on a phone.
  • Screen readers: colour and size are not stated anywhere as text. If they carry information (a choice, a setting), write it in your page, as the fact sheet and the gauge in the examples do. Camera messages are announced through the role="status" pill.
  • Light: a scattered sphere is darker than at rest, never brighter, and the 2.4 s delay between two bursts rules out any flicker.

Browser compatibility

WebGL 1 for the dots, 2D canvas for the halo and the hands; 46 KB of unminified JavaScript. Demo tried with software rendering under Chromium 149, Firefox 151, WebKit 26.5: two independent spheres on one page, a click on one does not reach the other, zero requests. Camera measured with a fake stream in Chromium and Firefox; finger reading was checked by injecting hand landmarks into the code, not with a real filmed hand. Safari: camera not verified.

Chrome 88+✓ Full (measured)
Firefox 89+✓ Full (measured)
Safari 15+✓ Demo measured · camera not verified
Edge 88+✓ Not verified
iOS Safari 15+✓ Not verified
Android Chrome 88+✓ Not verified

Without WebGL the dots are drawn on a 2D canvas: 200 to 900 small squares, same rotation, simplified burst. If the WebGL context is lost it is recreated up to three times before that fallback. Webcam refused or not found: the pill explains it and the sphere stays cursor-driven. The browser asks for permission on the first click, and only on an https page; the webcam switches itself off as soon as the sphere leaves the screen or the tab goes to the background.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0845-root">
  <div class="psx-scene" data-psx-lang="en" role="region" aria-label="Particle Sphere — a sphere of light settles on your hand and follows your gestures. Cursor demo, camera on request (processed on your device only)">
    <video class="psx-video" playsinline muted autoplay aria-hidden="true" tabindex="-1"></video>
    <canvas class="psx-canvas" aria-hidden="true"></canvas>
    <div class="psx-bar">
      <button class="psx-btn psx-cam-btn" type="button" aria-pressed="false">
        <span class="psx-btn-ico" aria-hidden="true"></span><span class="psx-btn-txt">Turn camera on</span>
      </button>
      <p class="psx-privacy">No image ever leaves your device.</p>
    </div>
    <p class="psx-status" role="status" aria-live="polite"></p>
    <div class="psx-label" aria-hidden="true">
      <span>Particle Sphere</span>
      <span class="psx-hint">move the cursor · click to burst it · or turn the camera on</span>
    </div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Finger colours (JS — PALETTE) 6 RGB colours, 0 to 5 fingers One row per finger count. Two neighbouring counts that are too close (0 and 1 by default: violet and mauve) are hard to tell apart: spread the hues if the choice matters.
Two-hand colour (JS — CYAN) [95, 230, 255] Tint of the large sphere between the palms. The halo behind the sphere takes the same colour.
Number of dots (JS — N_POINTS) 4,200 Cap on dots drawn. 2,000 lightens rendering on a small device; the sphere stays readable since small spheres already show only 500.
Delay between two bursts (JS — BURST_COOLDOWN) 2.4 s Do not go below the 2.45 s of EXPLODE_END without shortening the shader animation too: a burst cannot start during the previous one.
“Wide-open hand” threshold (JS — WIDE_RATIO) 1.6 Ratio between the spread of the fingertips and that of their bases. Lower, the sphere bursts as soon as the hand opens; higher, fingers really have to be spread.
Spin speed (JS — s.ay += dt * (0.35 + …)) 0.35 radian per second, one turn in 18 s Base rotation, to which the hand's speed is added. At 0 the sphere only turns while being moved.
Scene background (CSS — background of .psx-scene) night-violet radial gradient Dots add their light to the background: keep it dark. On a light background the sphere fades until it disappears.
Kiosk variant (HTML — .psx-kiosk, data-psx-start) not included in the delivered HTML The CSS contains a welcome screen ready to fill in: .psx-scrim veil, .psx-kiosk-content block, .psx-cta button. The button starts the camera if it carries data-psx-start.

FAQ

The effect fires no event, but its state can be read on the scene element: scene.psxBase.effect.s gives count (raised fingers), mode (1 or 2 hands), R (radius) and exp (non-null during an explosion). Read it at regular intervals, as the three examples do. effect.burst() triggers the burst from your code.
Because the cursor demo shows two hands, and two hands give the large cyan sphere. Per-finger colours only appear with a single hand: on the webcam, or in the automatic script that resumes 2.5 s after the last cursor movement.
Four files, read-only: the MediaPipe module and its WebAssembly engine from cdn.jsdelivr.net, the hand model from storage.googleapis.com, about 20 MB in total, then kept in cache. After that, only one request still goes out, measured in Chromium and Firefox: every minute while detection runs, MediaPipe sends Google (odml.pa.googleapis.com) a usage report — library version, start-up and processing times — with no webcam image and no hand landmark. Your privacy policy can mention it.