What you will build
A glowing 3D sculpture in the browser that turns, twists and ripples as you move your hand. Buttons switch the base shape (knot, sphere, spiral), the colour palette, and release a burst of particles. Screenshots can be saved as PNG.
How it works
The XBOT Motion Controller firmware from Project 11 streams pitch, roll and yaw rate. The browser maps them to sculpting parameters instead of flight controls:
| Input | Sculpt parameter |
|---|---|
| Roll | Rotation around the vertical axis |
| Pitch | Ripple strength (how much the surface waves) |
Yaw rate (gz) |
Twist along the shape |
| Button 1 (GPIO 25) | Next shape |
| Button 2 (GPIO 27) | Next colour palette |
| Button 3 (GPIO 32) | Particle burst |
| Button 4 (GPIO 33) | Reset view |
The shape is a Three.js mesh whose vertices are moved every frame by a small displacement function, so the sculpture changes smoothly rather than jumping.
Parts
| Part | Qty | Purpose | Required |
|---|---|---|---|
| XBOT Motion Controller (from Project 11) | 1 | Input | Yes |
| Laptop with Chrome or Edge | 1 | Renders the sculpture | Yes |
If building fresh: ESP32-DevKitC V4, MPU6050, 4 buttons, breadboard, USB data cable (~£32).
Build steps
- Build and flash the XBOT Motion Controller (Project 11, steps 1–4).
- Open
/projects/3d-gesture-sculptor/play. Click Connect Controller, then Calibrate with the controller level. - Roll your wrist slowly: the sculpture turns. Tilt forward: ripples grow.
- Press each button and check the action.
- Adjust Sensitivity and Smoothing sliders until movement feels controlled.
- Click Save image to download a PNG of your sculpture.
Try it in the browser
The browser scene is the project. Virtual Controller mode uses mouse drag (rotate), scroll (ripple) and keys 1–4 for the buttons, so it works on any device. The badge reads Live Controller only while fresh serial data is arriving.
Code
Shared motion controller firmware and Web Serial example
Firmware: the XBOT Motion Controller sketch from Project 11, unchanged. Browser:
// sculptor.js — XBOTNOW. Uses three (r160+) and xbot-serial.js from Project 11.
import * as THREE from 'three';
import { readInput } from './xbot-serial.js';
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 100);
camera.position.z = 6;
const renderer = new THREE.WebGLRenderer({ antialias: true, preserveDrawingBuffer: true });
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
scene.add(new THREE.AmbientLight(0xffffff, 0.4));
const light = new THREE.PointLight(0xffffff, 60); light.position.set(3, 4, 5); scene.add(light);
const shapes = [
() => new THREE.TorusKnotGeometry(1.2, 0.4, 256, 48),
() => new THREE.IcosahedronGeometry(1.6, 24),
() => new THREE.TorusGeometry(1.4, 0.35, 64, 200)
];
const palettes = [[0x7b5cff, 0x00d4ff], [0xff5c8a, 0xffc15c], [0x2ee6a6, 0x2b6cff]];
let shapeIdx = 0, palIdx = 0, prevButtons = 0, calib = { p: 0, r: 0 };
const material = new THREE.MeshStandardMaterial({ color: palettes[0][0], emissive: palettes[0][1],
emissiveIntensity: 0.25, metalness: 0.3, roughness: 0.35 });
let mesh, base;
function setShape(i) {
if (mesh) { scene.remove(mesh); mesh.geometry.dispose(); }
mesh = new THREE.Mesh(shapes[i](), material);
base = mesh.geometry.attributes.position.array.slice(); // rest positions
scene.add(mesh);
}
setShape(0);
let ripple = 0, twist = 0;
function animate(t) {
const inp = readInput(calib); // falls back to neutral if stale
const pressed = inp.buttons & ~prevButtons; // rising edges
prevButtons = inp.buttons;
if (pressed & 1) setShape(shapeIdx = (shapeIdx + 1) % shapes.length);
if (pressed & 2) { palIdx = (palIdx + 1) % palettes.length;
material.color.setHex(palettes[palIdx][0]); material.emissive.setHex(palettes[palIdx][1]); }
if (pressed & 8) { mesh.rotation.set(0, 0, 0); ripple = twist = 0; }
mesh.rotation.y += (inp.roll / 45) * 0.04;
ripple += ((Math.min(Math.abs(inp.pitch), 40) / 40) * 0.35 - ripple) * 0.08;
twist += ((inp.fresh ? inp.gz : 0) * 0.3 - twist) * 0.05;
const pos = mesh.geometry.attributes.position;
for (let i = 0; i < pos.count; i++) {
const x = base[i * 3], y = base[i * 3 + 1], z = base[i * 3 + 2];
const a = twist * y, c = Math.cos(a), s = Math.sin(a);
const k = 1 + ripple * Math.sin(4 * y + t * 0.003) * Math.cos(4 * x);
pos.setXYZ(i, (x * c - z * s) * k, y * k, (x * s + z * c) * k);
}
pos.needsUpdate = true;
mesh.geometry.computeVertexNormals();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
// Particle burst (button 3, bit value 4), Save image and reduced-motion are left to the page build.
Troubleshooting
| Symptom | Likely cause | Check |
|---|---|---|
| Sculpture spins constantly | Not calibrated | Hold level, click Calibrate |
| Jerky movement | Low frame rate on a slow laptop | Pick the lower-detail setting (fewer vertices) |
| No connect option | Unsupported browser | Use Virtual Controller mode |
Safety and limitations
Provide a reduced-motion toggle and avoid rapid flashing colours. Keep the USB cable clear of your hands and drinks.
Checklist
Next project
Motion-Controlled Music Instrument: turn the same movement into sound.

