Interactive Vision From Zero · Episode 21
Hands Meet Splats
Hands Meet Splats is Episode 21 of Interactive Vision From Zero, a MasterAllArts free interactive lesson for artists learning creative 3D on the web.
Part of the MasterAllArts Creative 3D Roadmap .
For twenty episodes your hand has pushed pixels, bones, and shaders around a flat screen. Today it reaches into a radiance field. The glowing cloud below is a Gaussian splat scene — the same soft, additive blobs that the Gaussian Splatting From Zero series builds from scratch — and you are about to grab it with your bare hand. Push it. Scoop a fistful of light. Stir it and watch it settle back into shape.
This is the crossover: the vision series shakes hands with the splatting series. A synthetic hand is already sculpting the cloud on first paint — no camera, no install. Click use my camera and it's your hand, in 3D, plunged into a field of light. By the end you'll know how to map a 2D landmark into a 3D scene, apply a soft radial force to thousands of points, and spring them home so the shape never dissolves.
What you're looking at
Every speck of light is one splat: a position, a color, and a soft round alpha that fades to nothing at its rim. Drawn with additive blending, overlapping splats sum their light, so dense regions glow white-hot and sparse ones drift to a dim haze. That single primitive — a soft Gaussian sprite — is the atom of the splatting series, and we reuse it here verbatim. The difference is that this cloud is squishy: each splat remembers a home position, carries a velocity, and is shoved around by a 3D cursor driven by your hand.
The six stages below are six states of one machine. Step through them with the
stage selector; each maps 1:1 to a section of this article.
Stage 1 — A procedural splat cloud
We start with the scene at rest: a few thousand soft sprites swept into a spiral
galaxy with a warm core and cool arms. No interaction yet — just the radiance field
breathing. This is the look we're protecting: every later stage deforms this
shape, and every later stage has to let it return. Drag the splats slider
and watch the cloud thicken; the count is capped so even a modest GPU holds 120fps.
Stage 2 — A 3D hand cursor
Now a glowing orb appears and tracks the hand. The synthetic hand puppets it on
autoplay; your mouse takes over the moment you move it; your camera takes over when you
enable it. The trick is turning a flat landmark — {x, y} in
[0,1] image space — into a point in the 3D scene. We un-project it
onto a fixed depth plane, exactly the recipe from the series brief. The cursor is the
business end of every force that follows.
Stage 3 — Push
Bring the cursor near the cloud and the splats flee. Each splat within the force
radius feels a push away from the hand, strongest at the center and smoothly
fading to zero at the rim — a falloff, never a hard cliff. Sweep the hand through the
galaxy and you carve a glowing wake. Crank force radius to clear a wider
crater. Nothing returns home yet, so the damage accumulates — that's deliberate, so you
can see the force before we add the spring.
Stage 4 — Pinch to scoop
Flip the force around. When you pinch — thumb tip to index tip — the sign of the force inverts inside the radius: splats are pulled toward the hand instead of away. Close your fingers and you gather a fistful of light; open them and the next stage's spring lets it pour back. On autoplay the synthetic hand pinches rhythmically so you can watch the cloud inhale and exhale. The pinch is read with hysteresis — separate on/off thresholds — so it doesn't flicker at the edge.
Stage 5 — Spring back
Here's the stabilizer. Every splat is pulled toward its home position by a spring, and its velocity is damped each frame. Push the cloud and it deforms; let go and it eases back into the galaxy — overshooting a touch, wobbling, settling. This is the one rule that keeps the scene from being a one-way demolition. Without it the cloud dissolves into a uniform fog after a few seconds of poking.
Stage 6 — Sculpt
Everything on at once: the pretty scene, the push, the pinch-scoop, and the spring-back, with a richer palette. This is the playground. Stir the field, scoop a handful and fling it, carve a tunnel and watch it heal. It feels like kneading light — and it's running the same soft-splat primitive you'd build from scratch in the splatting series, just with a velocity and a home tacked onto every point.
How the code works
Four ideas carry the whole demo: a soft additive splat, a landmark un-projected to 3D, a radius-limited force, and a spring home. Here's each, close to the real thing.
(a) The procedural splat cloud — soft round additive sprites
We render every splat with THREE.Points and a tiny
ShaderMaterial. The fragment shader is where a square GL point becomes a
soft Gaussian: measure the distance from the sprite center and apply an
exp() falloff for alpha. That exp(-d²) bell is the exact
falloff the splatting
series teaches in Episode 02 — here we lean on additive blending so the blobs sum
into a glow instead of compositing back-to-front.
// Geometry: position + color + a per-splat home (we deform position, keep home fixed)
const N = 12000;
const pos = new Float32Array(N * 3); // live, deformed positions
const home = new Float32Array(N * 3); // rest positions (the galaxy)
const col = new Float32Array(N * 3);
const vel = new Float32Array(N * 3); // velocity, integrated each frame
// ... fill home[] as a spiral galaxy, copy into pos[], tint col[] by radius ...
const geo = new THREE.BufferGeometry();
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
const material = new THREE.ShaderMaterial({
uniforms: { uSize: { value: 9 }, uDpr: { value: renderer.getPixelRatio() } },
transparent: true, depthWrite: false,
blending: THREE.AdditiveBlending, // light sums → glow
vertexShader: `
uniform float uSize, uDpr; attribute vec3 color; varying vec3 vColor;
void main() {
vColor = color;
vec4 mv = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = uSize * uDpr * 8.0 / -mv.z; // perspective sizing
gl_Position = projectionMatrix * mv;
}`,
fragmentShader: `
varying vec3 vColor;
void main() {
float d = length(gl_PointCoord - 0.5) * 2.0; // 0 center → 1 rim
float a = exp(-d * d * 4.0); // Gaussian falloff (Ep02)
if (a < 0.01) discard;
gl_FragColor = vec4(vColor * a, a); // premultiplied, additive
}`,
});
scene.add(new THREE.Points(geo, material));
(b) Normalized landmark → 3D hand position
The landmark arrives as {x, y} in [0,1]. We mirror X (selfie
view), convert to NDC in [-1,1], then un-project onto a
fixed z-plane so the cursor lives at a stable depth inside the cloud. Fixing z
is the key simplification — a single landmark has no reliable absolute depth, so we
choose one. This is precisely the mapping the Season 3 brief prescribes for 3D
episodes.
// hand = the 21-landmark array (synthetic OR MediaPipe — same shape).
const _v = new THREE.Vector3();
function landmarkTo3D(lm) {
const ndcX = (1.0 - lm.x) * 2.0 - 1.0; // mirror X, then → [-1,1]
const ndcY = 1.0 - lm.y * 2.0; // flip Y (image y is down)
_v.set(ndcX, ndcY, 0.5).unproject(camera); // ray through that pixel
const dir = _v.sub(camera.position).normalize();
const t = (HAND_Z - camera.position.z) / dir.z; // hit the fixed z-plane
return camera.position.clone().add(dir.multiplyScalar(t));
}
// palm = midpoint of wrist(0) and middle-MCP(9); pinch = dist(thumb tip 4, index tip 8)
(c) The per-splat force — repel within radius, pinch to attract
For each splat we take the vector from the hand to the splat, and if it's inside the force radius we add an impulse to that splat's velocity. The strength is a smooth falloff (1 at the center, 0 at the rim) so there's no popping. Pinching flips the sign, turning the push into a scoop. We push velocity, not position, so the motion has momentum and reads as physical.
// hp = hand position (Vector3), pinching = bool, R = force radius, dt = seconds
function applyForce(hp, pinching, R, dt) {
const R2 = R * R;
const sign = pinching ? -1.0 : 1.0; // pinch = attract, else repel
const strength = (pinching ? 9.0 : 14.0) * dt;
for (let i = 0; i < N; i++) {
const dx = pos[i*3] - hp.x;
const dy = pos[i*3+1] - hp.y;
const dz = pos[i*3+2] - hp.z;
const d2 = dx*dx + dy*dy + dz*dz;
if (d2 > R2 || d2 < 1e-6) continue; // radius-limited
const d = Math.sqrt(d2);
const fall = 1.0 - d / R; // smooth 1 → 0 at the rim
const f = sign * strength * fall * fall / d; // normalize direction
vel[i*3] += dx * f;
vel[i*3+1] += dy * f;
vel[i*3+2] += dz * f;
}
}
(d) Spring back to home + integrate
The stabilizer that makes it a toy instead of a wrecking ball. Each frame, every
splat is pulled toward its home with a spring (Hooke: force proportional to
displacement), its velocity is damped, and then position integrates from velocity. Tune
k (stiffness) and damp for anything from honey to a taut
trampoline.
function integrate(dt) {
const k = 6.0; // spring stiffness → pull home
const damp = Math.pow(0.0025, dt); // frame-rate-independent damping
for (let i = 0; i < N; i++) {
for (let a = 0; a < 3; a++) {
const j = i*3 + a;
vel[j] += (home[j] - pos[j]) * k * dt; // Hooke toward home
vel[j] *= damp; // bleed energy
pos[j] += vel[j] * dt; // move
}
}
geo.attributes.position.needsUpdate = true; // re-upload to GPU once
}
That's the entire interaction loop: read a hand, map it to 3D, apply the force to
velocities, then spring-and-integrate. The synthetic hand and the camera feed both arrive
at the same onLandmarks(hand) entry point, so there is exactly one code path
to reason about.
The camera swap — same hand, real input
The demo is fully alive with zero network calls: a procedurally-animated synthetic
hand emits the identical 21-landmark structure MediaPipe produces, so all the math above
runs unchanged. The use my camera button lazily imports
MediaPipe's HandLandmarker only on click, starts the webcam, and feeds the
very same onLandmarks. Everything is wrapped in try/catch: no
webcam, denied permission, or an insecure file:// context all fall straight
back to the synthetic hand with a short status line — the page never throws.
🔒 The camera path runs entirely on-device. Landmarks are computed in your browser; no video and no data ever leave your machine. That privacy line lives right under the button in the demo.
Mirror. This is a selfie view, so we flip the X axis when mapping a
landmark to the scene: ndcX = (1 - x) * 2 - 1. Move your hand right, the
cursor goes right. The same flip is applied to the synthetic hand so both modes agree —
mismatched mirroring is the number-one source of "why is it backwards" confusion.
Common pitfalls
- Splat count vs. performance. Each splat is a fragment-heavy
overlapping sprite, and we touch every one on the CPU each frame. Cap the count
(this demo maxes at 24k) and use
THREE.Pointsor instancing — never one mesh per splat. If frames drop, lower the slider before anything else. - Additive blow-out. Additive blending sums light, so a dense pinch can clip to pure white and wash out the color. Keep per-splat brightness modest, let density do the work, and consider tone-mapping. Pretty depends on restraint.
- Hand → 3D mapping needs a fixed z. One landmark has no trustworthy
absolute depth. Un-project onto a chosen z-plane (
HAND_Z); if you instead believe the raw landmarkz, the cursor jitters in and out of the cloud. - Force falloff must be smooth and radius-limited. A hard cutoff at
the radius makes splats pop as they cross it. Use a
1 - d/R(or squared) falloff and skip everything outside the radius entirely — both for looks and for speed. - Splats must return home. Force-only with no spring turns the gorgeous galaxy into uniform fog within seconds. The spring-to-home + damping is not optional polish; it's what makes the cloud a reusable toy.
- Mirror. Forget the
1 - xflip and your hand pushes the cloud the wrong way. Flip both the synthetic and camera paths identically. - Lost tracking returns nothing. When no hand is in frame MediaPipe
yields an empty result. Guard for
nulland simply skip the force that frame — the spring quietly heals the cloud while you're out of view.
This is the same splat primitive taught from scratch — soft sprite, Gaussian falloff, additive glow — in the Gaussian Splatting From Zero course. If the rendering side intrigues you, that's where the covariance projection, depth sort, and spherical-harmonic color get built properly.
Exercises
- Color by displacement. Add a per-splat attribute that grows with
length(pos - home)and feed it to the fragment shader to shift hue (cool at rest → hot when shoved). Now the deformation paints itself, and you can see exactly where your hand has been. - Two-hand pull-apart. Call
syntheticHandtwice with different palm positions and runonLandmarks([handA, handB])(camera path:numHands: 2). Apply two attract forces and pull the galaxy into a dumbbell, then release and watch it snap back into one. - Freeze / reset. Add a key (or button) that zeroes every velocity
to freeze the sculpture in place, and another that snaps
posback tohomefor an instant reset. Great for capturing a pose you like before stirring again.
What's next
Episode 22 — Multiplayer Body. We stop sculpting alone. Instead of pixels, we stream the landmarks themselves — tiny and private, never video — over a channel so two bodies can share one space. Synthetic bot bodies keep it alive solo, and it cross-links the streaming series. Your hand learned to touch a radiance field; next it learns to touch someone else's.