Gestures & WebcamPremium

Palm Figurines

An animated 3D figurine lands in your palm on the webcam, follows your hand and turns with it. Close your fist: the next one in the collection. Without a camera, it follows the cursor.

WebcamMediaPipeThree.jsHand tracking

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

Hold the figurine in your hand before buying it — product page of a collectible figurine shop — Palm Figurines example 1

① Hold the figurine in your hand before buying it — product page of a collectible figurine shop

WhenThe customer is torn between the three models of the series. A click on "Astronaut" changes the figurine in the block on the right, and the name, description and price follow. With the camera on and an open hand, the figurine lands on it, at the scale of the palm.
WhyA photo does not tell the size of a 12 cm object; seeing it stand in your own hand does. And the page stays right whichever way the figurine is changed: chip, button, click or fist.
Settings264 × 248 px block to the right of the product details, short button label (.pfg-short), pointer-events: none on the scene so the figurine stays on the right-hand hand. The chips call effect.select(i) (the effect object is read from scene.pfgBase); the page reads effect.cur ten times a second and updates the details. The shipped CSS also holds a ready-made variant, .pfg-shop, with the text laid over the scene.
Figurine won at the end of the level — victory screen of a mental arithmetic game for 9-year-olds — Palm Figurines example 2

② Figurine won at the end of the level — victory screen of a mental arithmetic game for 9-year-olds

WhenThe pupil finishes the times tables with 18 out of 20. A figurine arrives waving; they move it around with the mouse, tap the screen to discover the other two, and the dots in the top right corner fill up.
WhyThe reward is an object to hold and move, not a static medal: the child plays with it for a few seconds before the next level. The character's greeting does the congratulating.
SettingsFull-screen scene, cursor active. The headline, the score and the name sit inside the scene right after the video tag: they go under both canvases and the figurine passes in front of them. The click on the scene is the shipped code's own; the page only reads effect.cur and effect.names.
Welcome companion in a corner of the screen — first launch of a learn-to-code app for ages 8 to 12 — Palm Figurines example 3

③ Welcome companion in a corner of the screen — first launch of a learn-to-code app for ages 8 to 12

WhenThe child opens the app for the first time. In a frame on the left, a character waves; the bubble next to it introduces it. A few seconds later, another companion takes over with its own line.
WhyAn animated character saying hello gives the app a face with no video or illustration to produce, and no camera is needed: the code's own demonstration is playing.
SettingsCamera-free use: no control bar and no status pill in the HTML. The scene measures 340 × 300 px and its 204 × 210 px container, with overflow: hidden, only shows the part where the figurine stands. The bubble changes text when effect.cur changes, every 5.5 s.

How it works

The open hand is the display stand. A figurine stands on a small base at the bottom of the palm, one and a half times as tall as the palm is long: its head reaches the fingertips. It moves with the hand, leans when the hand leans and spins when the palm turns sideways. A wireframe display case with eight glowing corners surrounds it, and a label gives its name and rank, "ROBOT BOLT · 1/3".

These are real animated 3D models, rendered by Three.js with studio lighting, reflections and a contact shadow under the base: a robot, an astronaut and a golem, each with an idle animation and a greeting played on arrival. The three glTF files, under a CC0 licence, are included in the script: nothing to host. They weigh 324 KB out of the 376 KB of JavaScript.

There are four ways to move to the next figurine: close a fist (either hand, for 0.12 s), click or tap the scene, press the "Next figurine" button, or call next() or select(i) from your page. The figurine shrinks in 0.2 s and the next one pops in with a slight bounce. With two hands, the one that stays open holds the figurine while the other flips through the collection.

Without a camera, two drawn hands hold the scene: the figurine goes to the one following the cursor, otherwise to the right-hand one, and it changes by itself every 5.5 s. Every capture on this page was taken that way, using the code you buy. The webcam opens from its button; frames are analysed in the browser by MediaPipe and never leave it. What does go out is a technical log that MediaPipe sends to Google (odml.pa.googleapis.com) after one minute, then for every minute of camera use, with no image at all, carrying the detector's version and its processing times. Your privacy policy can mention it.

Accessibility

  • Keyboard: two buttons follow each other in the tab order, the camera then "Next figurine". The whole collection can be browsed with Enter or Space, with no mouse and no gesture.
  • Reduced motion: the figurine stands in a fixed pose, with no greeting, no swaying and no automatic change: the display case stays still until someone interacts with it. A click or the button still changes the figurine, at once, with no shrinking and no bounce.
  • Figurine name: the label is drawn in the canvas, so a screen reader cannot see it. If the name matters on your page, show it as text too, as the three examples do from effect.names and effect.cur.
  • Touch: a short tap (under 0.4 s, without dragging) moves to the next figurine. A finger sliding sideways carries the figurine along; up or down, the page scrolls. The tap was tried on a simulated touch screen in Chromium, Firefox and WebKit.
  • Light: nothing blinks. Changes are scale animations of 0.2 to 0.4 s confined to the figurine, and the wave that marks a fist is a thin ring around the hand.

Browser compatibility

Three.js 0.186 (WebGL 2) and its glTF loader are fetched from cdn.jsdelivr.net as soon as the scene initialises, before any click: three files, 176 KB transferred. Three.js sets a __THREE__ variable on window. Two display cases on one page (Chromium 149, Firefox 151, WebKit 26.5) share a single Three.js download, and a click on one flips through its own collection only. The camera, tried in Chromium and Firefox with a simulated webcam, adds the hand detector (about 10.7 MB) and the MediaPipe log to Google, one request per minute. Simulated hand landmarks passed to the shipped code in Chromium confirmed the fist (one figurine per closing, no repeat while it stays closed), the rotation when the palm pivots and the sharing of roles between two hands. A WebKit quirk: the CDN announces Three.js as a preload (Link: rel=modulepreload) with a relative address, which WebKit resolves against your own domain; that request to /npm/three@0.186.0/+esm ends in a 404 with no visible effect, and the figurine still shows. Real Safari and phones: not verified.

Chrome 99+✓ Full (measured)
Firefox 112+✓ Full (measured)
Safari 16+✓ Demo measured · camera not verified
Edge 99+✓ Not verified
iOS Safari 16+✓ Not verified
Android Chrome 99+✓ Not verified

If cdn.jsdelivr.net is blocked (CSP, offline) or WebGL 2 is missing, the figurine does not show: the display case, its corners and the label remain, follow the hand and change name from the button. Verified by cutting the CDN. The minimum versions come from roundRect, which draws the label. Camera refused: a message, and the demo carries on.

The code

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

index.html — structure
<div class="fx-0850-root">
  <div class="pfg-scene" data-pfg-lang="en" role="region" aria-label="Figurine on your palm — a 3D collectible stands in your hand. Cursor demo, camera on request (processed on your device only)">
    <video class="pfg-video" playsinline muted autoplay aria-hidden="true" tabindex="-1"></video>
    <canvas class="pfg-canvas" aria-hidden="true"></canvas>
    <div class="pfg-bar">
      <button class="pfg-btn pfg-cam-btn" type="button" aria-pressed="false">
        <span class="pfg-btn-ico" aria-hidden="true"></span><span class="pfg-btn-txt">Turn camera on</span>
      </button>
      <button class="pfg-btn pfg-next-btn" type="button">
        <span class="pfg-btn-txt"><span class="pfg-long">Next figurine</span><span class="pfg-short">Next</span></span><span class="pfg-btn-arrow" aria-hidden="true">›</span>
      </button>
      <p class="pfg-privacy">No image ever leaves your device.</p>
    </div>
    <p class="pfg-status" role="status" aria-live="polite"></p>
    <canvas class="pfg-gl" aria-hidden="true"></canvas>
    <div class="pfg-label" aria-hidden="true">
      <span>Figurine on your palm</span>
      <span class="pfg-hint">move the cursor · click: next figurine · 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
Your own models (JS — FIG_MODELS, FIG_NAMES) robot, astronaut, golem Each entry is a GLB file encoded in base64, with the name of its idle animation (idle) and of its greeting (hello). Replace one or extend the list: the counter on the label adapts.
Figurine height (JS — FIG_H) 1.55 × the palm Ratio between the figurine and the length of the palm. In demo, since the drawn hands are small, it is enlarged a further 1.5 to 1.7 times.
Automatic change in demo (JS — AUTO_MS) 5,500 ms Interval between two figurines while the camera is off. A very large value amounts to switching it off; it never runs under reduced motion or on camera.
Delay between two fists (JS — COOL_MS) 900 ms Minimum time between two fist-triggered changes. Clicks and the button are not limited.
Display case (JS — CASE) 0.92 wide, 1.15 high Size of the wireframe, for a figurine of height 1. Widen it if your model holds its arms out.
Three.js version (JS — THREE_VERSION) 0.186.0 Version fetched from the CDN. To host it yourself, change the three addresses that follow; the glTF loader must import the same copy of Three.js.
Shop variant (HTML — .pfg-shop, data-pfg-start) to add to the HTML The shipped CSS already includes it: name, price and two buttons laid over the left of the scene; the main button starts the camera.

FAQ

Export your model as GLB with at least an idle animation, encode the file in base64 and replace one entry of FIG_MODELS, giving the names of its animations; add its name to FIG_NAMES. The code brings it to the right height and centres it on the base by itself. Keep the files light: the three provided models are 35 to 109 KB, compressed with meshopt.
Yes. They are three models by Quaternius, published on Poly Pizza under a CC0 licence: free commercial use and modification, no credit required. The script keeps the original address of each model in a comment.
Because the figurine also shows in the demo. Three.js and its model loader are therefore fetched when the scene loads: 176 KB transferred, three requests to cdn.jsdelivr.net. If your CSP does not allow that domain in script-src, the display case stays empty. The hand detector, for its part, is only downloaded on a click on the camera button.