Prompt specification
Build or customize the Three.js 3D scene "Hand Proxy Grasping a Cup Handle" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Hand Proxy Grasping a Cup Handle
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/hand-proxy-grasping-a-cup-handle-x3729
Scene Description Prompt:
Hand proxy grasping a cup handle. Model a simplified hand around a cup handle with visible clearance. Keep the fingers outside the cup wall and show a plausible contact arrangement. Please build this with Three.js from cdnjs in one self-contained HTML file, using stylized solid shapes.
Working Three.js Starter (hand-proxy-grasping-a-cup-handle-x3729):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Three.js Cup Handle Grip Study</title>
<style>
:root {
color-scheme: dark;
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #0b1020;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas.dragging {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(12, 18, 34, 0.78);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
backdrop-filter: blur(14px);
-webkit-backdrop-filter: blur(14px);
}
#title {
top: 22px;
left: 22px;
max-width: 360px;
padding: 15px 17px;
border-radius: 14px;
}
.eyebrow {
margin-bottom: 6px;
color: #73e4d9;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: #f8fbff;
font-size: clamp(18px, 2vw, 25px);
font-weight: 700;
letter-spacing: -0.03em;
}
#title p {
margin: 7px 0 0;
color: #aeb9ce;
font-size: 12px;
line-height: 1.5;
}
#controls {
top: 22px;
right: 22px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
padding: 9px;
border-radius: 14px;
}
button {
appearance: none;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 9px;
padding: 9px 12px;
color: #dce6f7;
background: rgba(255, 255, 255, 0.055);
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover {
background: rgba(255, 255, 255, 0.12);
border-color: rgba(255, 255, 255, 0.25);
}
button:active {
transform: translateY(1px);
}
button.active {
color: #062421;
border-color: #73e4d9;
background: #73e4d9;
}
#instructions {
bottom: 20px;
left: 22px;
padding: 10px 13px;
border-radius: 11px;
color: #aeb9ce;
font-size: 11px;
}
#legend {
right: 22px;
bottom: 20px;
display: grid;
gap: 8px;
min-width: 210px;
padding: 12px 14px;
border-radius: 12px;
color: #b7c2d5;
font-size: 11px;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
}
.swatch {
width: 10px;
height: 10px;
flex: 0 0 auto;
border-radius: 50%;
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}
#clearance-label {
position: fixed;
z-index: 8;
display: none;
pointer-events: none;
padding: 6px 9px;
border: 1px solid rgba(115, 228, 217, 0.65);
border-radius: 7px;
color: #bafaf2;
background: rgba(9, 35, 39, 0.9);
box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.09em;
white-space: nowrap;
transform: translate(-50%, -145%);
}
@media (max-width: 720px) {
#title {
top: 12px;
left: 12px;
max-width: calc(100vw - 24px);
}
#title p {
display: none;
}
#controls {
top: 105px;
right: 12px;
}
#instructions {
bottom: 12px;
left: 12px;
}
#legend {
display: none;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<section id="title" class="panel">
<div class="eyebrow">Three.js / Proxy Grip Study</div>
<h1>Cup Handle Grasp</h1>
<p>
Four wrapped fingers contact the outside of the handle while the
opposing thumb supports the inner side. All finger geometry remains
outside the cup wall.
</p>
</section>
<section id="controls" class="panel">
<button id="clearance-toggle" class="active" type="button">
Clearance guide
</button>
<button id="contact-toggle" class="active" type="button">
Contact points
</button>
<button id="reset-view" type="button">Reset view</button>
</section>
<div id="instructions" class="panel">
Drag to orbit · Scroll to zoom · Double-click to reset
</div>
<div id="legend" class="panel">
<div class="legend-row">
<span class="swatch" style="background:#73e4d9"></span>
<span>Visible wall-clearance measurement</span>
</div>
<div class="legend-row">
<span class="swatch" style="background:#ffc857"></span>
<span>Finger-pad and thumb contact points</span>
</div>
</div>
<div id="clearance-label">FINGERS CLEAR OF CUP WALL</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.querySelector("#stage");
const clearanceToggle = document.querySelector("#clearance-toggle");
const contactToggle = document.querySelector("#contact-toggle");
const resetViewButton = document.querySelector("#reset-view");
const clearanceLabel = document.querySelector("#clearance-label");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x0b1020);
scene.fog = new THREE.Fog(0x0b1020, 9, 18);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.05,
50
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
stage.appendChild(renderer.domElement);
// ------------------------------------------------------------
// Lighting
// ------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xbcd9ff, 0x20202a, 1.9);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff1dd, 3.3);
keyLight.position.set(3.5, 7, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 6;
keyLight.shadow.camera.top = 6;
keyLight.shadow.camera.bottom = -3;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 16;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x77d9ff, 1.4);
fillLight.position.set(-4, 3, 4);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xff8f70, 1.8);
rimLight.position.set(4, 3, -5);
scene.add(rimLight);
// ------------------------------------------------------------
// Materials
// ------------------------------------------------------------
const ceramicMaterial = new THREE.MeshStandardMaterial({
color: 0xf0eadf,
roughness: 0.38,
metalness: 0.02
});
const handleMaterial = new THREE.MeshStandardMaterial({
color: 0x35b9ad,
roughness: 0.42,
metalness: 0.02
});
const skinMaterial = new THREE.MeshStandardMaterial({
color: 0xe99a76,
roughness: 0.67,
metalness: 0
});
const skinShadowMaterial = new THREE.MeshStandardMaterial({
color: 0xd87e60,
roughness: 0.72,
metalness: 0
});
const coffeeMaterial = new THREE.MeshStandardMaterial({
color: 0x512719,
roughness: 0.24,
metalness: 0.05
});
const cuffMaterial = new THREE.MeshStandardMaterial({
color: 0x273448,
roughness: 0.8,
metalness: 0.05
});
const contactMaterial = new THREE.MeshStandardMaterial({
color: 0xffc857,
emissive: 0x9a5300,
emissiveIntensity: 0.75,
roughness: 0.35
});
// ------------------------------------------------------------
// Helpers
// ------------------------------------------------------------
const UP = new THREE.Vector3(0, 1, 0);
function addSegment(parent, a, b, radius, material, taper = 0.9) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(
radius * taper,
radius,
length,
16,
1,
false
);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
UP,
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addJoint(parent, position, radius, material) {
const mesh = new THREE.Mesh(
new THREE.SphereGeometry(radius, 18, 12),
material
);
mesh.position.copy(position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeJointedDigit(points, radius, material) {
const digit = new THREE.Group();
points.forEach((point, index) => {
const jointRadius = index === points.length - 1
? radius * 1.04
: radius * 1.08;
addJoint(digit, point, jointRadius, material);
});
for (let i = 0; i < points.length - 1; i++) {
addSegment(
digit,
points[i],
points[i + 1],
radius,
material,
i === points.length - 2 ? 0.88 : 0.96
);
}
scene.add(digit);
return digit;
}
// ------------------------------------------------------------
// Cup body: lathed solid with a hollow interior
// ------------------------------------------------------------
const cupCenterX = -0.75;
const cupProfile = [
new THREE.Vector2(0.00, 0.08),
new THREE.Vector2(0.70, 0.08),
new THREE.Vector2(0.90, 0.12),
new THREE.Vector2(1.01, 0.30),
new THREE.Vector2(1.07, 1.18),
new THREE.Vector2(1.10, 2.18),
new THREE.Vector2(1.08, 2.32),
new THREE.Vector2(0.98, 2.32),
new THREE.Vector2(0.92, 2.18),
new THREE.Vector2(0.88, 1.18),
new THREE.Vector2(0.80, 0.34),
new THREE.Vector2(0.00, 0.34)
];
const cupBody = new THREE.Mesh(
new THREE.LatheGeometry(cupProfile, 96),
ceramicMaterial
);
cupBody.position.x = cupCenterX;
cupBody.castShadow = true;
cupBody.receiveShadow = true;
scene.add(cupBody);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(1.025, 0.045, 14, 96),
ceramicMaterial
);
rim.position.set(cupCenterX, 2.315, 0);
rim.rotation.x = Math.PI / 2;
rim.castShadow = true;
scene.add(rim);
const coffee = new THREE.Mesh(
new THREE.CylinderGeometry(0.89, 0.89, 0.025, 72),
coffeeMaterial
);
coffee.position.set(cupCenterX, 1.91, 0);
coffee.receiveShadow = true;
scene.add(coffee);
// ------------------------------------------------------------
// Handle: smooth C-shaped tube with a mostly vertical grip area
// ------------------------------------------------------------
const handleCurve = new THREE.CatmullRomCurve3(
[
new THREE.Vector3(0.25, 1.98, 0),
new THREE.Vector3(0.76, 2.08, 0),
new THREE.Vector3(1.17, 1.95, 0),
new THREE.Vector3(1.38, 1.72, 0),
new THREE.Vector3(1.42, 1.50, 0),
new THREE.Vector3(1.37, 1.27, 0),
new THREE.Vector3(1.13, 1.10, 0),
new THREE.Vector3(0.76, 1.00, 0),
new THREE.Vector3(0.25, 1.08, 0)
],
false,
"catmullrom",
0.45
);
const handle = new THREE.Mesh(
new THREE.TubeGeometry(handleCurve, 112, 0.14, 18, false),
handleMaterial
);
handle.castShadow = true;
handle.receiveShadow = true;
scene.add(handle);
// ------------------------------------------------------------
// Stylized hand proxy
// ------------------------------------------------------------
const hand = new THREE.Group();
scene.add(hand);
// Palm sits behind the handle so the wrapped fingers remain visible.
const palm = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 20),
skinMaterial
);
palm.position.set(1.93, 1.43, -0.16);
palm.scale.set(0.35, 0.63, 0.245);
palm.rotation.z = -0.07;
palm.castShadow = true;
palm.receiveShadow = true;
hand.add(palm);
// Wrist and dark cuff.
addSegment(
hand,
new THREE.Vector3(2.13, 1.39, -0.16),
new THREE.Vector3(2.72, 1.34, -0.17),
0.235,
skinMaterial,
0.95
);
addSegment(
hand,
new THREE.Vector3(2.62, 1.345, -0.168),
new THREE.Vector3(2.78, 1.327, -0.172),
0.255,
cuffMaterial,
1
);
// Finger contact points are placed against the handle tube.
// Their centers wrap around the tube rather than passing through it.
const fingerDefinitions = [
{
name: "index",
y: 1.72,
handleX: 1.36,
radius: 0.097
},
{
name: "middle",
y: 1.50,
handleX: 1.42,
radius: 0.100
},
{
name: "ring",
y: 1.29,
handleX: 1.40,
radius: 0.095
},
{
name: "little",
y: 1.10,
handleX: 1.28,
radius: 0.085
}
];
const contactGroup = new THREE.Group();
scene.add(contactGroup);
for (const finger of fingerDefinitions) {
const hx = finger.handleX;
const y = finger.y;
const points = [
// Knuckle / palm connection.
new THREE.Vector3(1.76, y + 0.07, -0.08),
// Outer side of handle.
new THREE.Vector3(hx + 0.26, y + 0.02, 0.03),
// Front wrap.
new THREE.Vector3(hx + 0.15, y - 0.03, 0.17),
new THREE.Vector3(hx, y - 0.07, 0.22),
// Inner-side contact and curled tip.
new THREE.Vector3(hx - 0.17, y - 0.10, 0.15),
new THREE.Vector3(hx - 0.24, y - 0.13, 0.01)
];
makeJointedDigit(points, finger.radius, skinMaterial);
// Amber marker indicates the intended finger-pad contact.
const contact = new THREE.Mesh(
new THREE.SphereGeometry(0.037, 16, 10),
contactMaterial
);
contact.position.set(hx, y - 0.035, 0.145);
contact.castShadow = true;
contactGroup.add(contact);
}
// Opposing thumb: its tip meets the lower-inner side of the handle.
const thumbPoints = [
new THREE.Vector3(2.02, 1.02, -0.12),
new THREE.Vector3(1.82, 1.05, -0.02),
new THREE.Vector3(1.60, 1.11, 0.10),
new THREE.Vector3(1.39, 1.17, 0.16),
new THREE.Vector3(1.18, 1.25, 0.10),
new THREE.Vector3(1.16, 1.31, 0.01)
];
makeJointedDigit(thumbPoints, 0.102, skinShadowMaterial);
const thumbContact = new THREE.Mesh(
new THREE.SphereGeometry(0.038, 16, 10),
contactMaterial
);
thumbContact.position.set(1.40, 1.27, 0.145);
contactGroup.add(thumbContact);
// ------------------------------------------------------------
// Clearance guide
// ------------------------------------------------------------
const clearanceGroup = new THREE.Group();
scene.add(clearanceGroup);
// At this z position the cup's right wall is around x = 0.25.
// The nearest finger surface is around x = 0.95, leaving a
// deliberate and visible gap between the hand and the cup.
const clearanceStart = new THREE.Vector3(0.28, 0.94, 0.36);
const clearanceEnd = new THREE.Vector3(0.92, 0.94, 0.36);
const clearanceMaterial = new THREE.LineDashedMaterial({
color: 0x73e4d9,
dashSize: 0.07,
gapSize: 0.045,
transparent: true,
opacity: 0.95,
depthTest: false
});
const clearanceLine = new THREE.Line(
new THREE.BufferGeometry().setFromPoints([
clearanceStart,
clearanceEnd
]),
clearanceMaterial
);
clearanceLine.computeLineDistances();
clearanceLine.renderOrder = 20;
clearanceGroup.add(clearanceLine);
const tickGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(0.28, 0.87, 0.36),
new THREE.Vector3(0.28, 1.01, 0.36),
new THREE.Vector3(0.92, 0.87, 0.36),
new THREE.Vector3(0.92, 1.01, 0.36)
]);
const clearanceTicks = new THREE.LineSegments(
tickGeometry,
clearanceMaterial
);
clearanceTicks.renderOrder = 20;
clearanceGroup.add(clearanceTicks);
const clearanceAnchor = new THREE.Vector3(0.60, 0.94, 0.36);
// ------------------------------------------------------------
// Ground plane
// ------------------------------------------------------------
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0x111827,
roughness: 0.92,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = 0;
floor.receiveShadow = true;
scene.add(floor);
// ------------------------------------------------------------
// Custom camera controls — no addons
// ------------------------------------------------------------
const cameraTarget = new THREE.Vector3(0.50, 1.23, 0);
const initialTheta = 0.58;
const initialPhi = 1.17;
const initialRadius = innerWidth / innerHeight < 1 ? 7.8 : 6.35;
let goalTheta = initialTheta;
let goalPhi = initialPhi;
let goalRadius = initialRadius;
let currentTheta = goalTheta;
let currentPhi = goalPhi;
let currentRadius = goalRadius;
let dragging = false;
let lastPointerX = 0;
let lastPointerY = 0;
const spherical = new THREE.Spherical();
function applyCamera() {
spherical.set(currentRadius, currentPhi, currentTheta);
camera.position.setFromSpherical(spherical).add(cameraTarget);
camera.lookAt(cameraTarget);
}
function resetCamera() {
goalTheta = initialTheta;
goalPhi = initialPhi;
goalRadius = innerWidth / innerHeight < 1 ? 7.8 : 6.35;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
renderer.domElement.classList.add("dragging");
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastPointerX;
const dy = event.clientY - lastPointerY;
lastPointerX = event.clientX;
lastPointerY = event.clientY;
goalTheta -= dx * 0.006;
goalPhi = THREE.MathUtils.clamp(
goalPhi - dy * 0.006,
0.28,
Math.PI - 0.28
);
});
function stopDragging(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (
event &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
goalRadius = THREE.MathUtils.clamp(
goalRadius * Math.exp(event.deltaY * 0.001),
3.8,
10.5
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
resetViewButton.addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") resetCamera();
});
// ------------------------------------------------------------
// UI toggles
// ------------------------------------------------------------
let clearanceVisible = true;
let contactsVisible = true;
clearanceToggle.addEventListener("click", () => {
clearanceVisible = !clearanceVisible;
clearanceGroup.visible = clearanceVisible;
clearanceLabel.style.display = clearanceVisible ? "block" : "none";
clearanceToggle.classList.toggle("active", clearanceVisible);
});
contactToggle.addEventListener("click", () => {
contactsVisible = !contactsVisible;
contactGroup.visible = contactsVisible;
contactToggle.classList.toggle("active", contactsVisible);
});
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
}
window.addEventListener("resize", resize);
const projected = new THREE.Vector3();
function updateClearanceLabel() {
if (!clearanceVisible) return;
projected.copy(clearanceAnchor).project(camera);
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
clearanceLabel.style.left = `${x}px`;
clearanceLabel.style.top = `${y}px`;
}
function animate() {
requestAnimationFrame(animate);
currentTheta += (goalTheta - currentTheta) * 0.12;
currentPhi += (goalPhi - currentPhi) * 0.12;
currentRadius += (goalRadius - currentRadius) * 0.12;
applyCamera();
renderer.render(scene, camera);
updateClearanceLabel();
}
applyCamera();
animate();
</script>
</body>
</html>
```