Prompt specification
Build or customize the Three.js 3D scene "Different Characters Reach a Shared Table" 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: Different Characters Reach a Shared Table
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/different-characters-reach-a-shared-table-x3682
Scene Description Prompt:
Several stylized characters use different poses and supports to place objects on a shared table. Create one HTML file using Three.js from cdnjs.
Working Three.js Starter (different-characters-reach-a-shared-table-x3682):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shared Table</title>
<style>
:root {
color-scheme: light;
--ink: #263b3a;
--cream: #f7f1e7;
--muted: #6d7772;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 22% 16%, #fffaf1 0%, transparent 38%),
radial-gradient(circle at 82% 20%, #e7f1ec 0%, transparent 36%),
linear-gradient(145deg, #f8f0e4 0%, #e8eee8 100%);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
top: 28px;
left: 28px;
width: min(390px, calc(100vw - 56px));
pointer-events: none;
}
.eyebrow {
display: inline-flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
color: #52766e;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 22px;
height: 3px;
border-radius: 999px;
background: #df9f43;
content: "";
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(38px, 5vw, 66px);
font-weight: 500;
line-height: 0.94;
letter-spacing: -0.045em;
}
.subtitle {
max-width: 340px;
margin: 15px 0 18px;
color: var(--muted);
font-size: 14px;
line-height: 1.55;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 7px 10px;
border: 1px solid rgba(38, 59, 58, 0.09);
border-radius: 999px;
background: rgba(255, 255, 255, 0.57);
box-shadow: 0 8px 24px rgba(57, 67, 59, 0.06);
backdrop-filter: blur(10px);
color: #4f625e;
font-size: 11px;
font-weight: 650;
}
.legend i {
width: 8px;
height: 8px;
border-radius: 50%;
}
#reset {
position: fixed;
z-index: 20;
top: 28px;
right: 28px;
padding: 10px 14px;
border: 1px solid rgba(38, 59, 58, 0.12);
border-radius: 999px;
background: rgba(255, 255, 255, 0.72);
box-shadow: 0 8px 30px rgba(44, 58, 50, 0.08);
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 700;
cursor: pointer;
backdrop-filter: blur(12px);
transition: transform 160ms ease, background 160ms ease;
}
#reset:hover {
transform: translateY(-2px);
background: rgba(255, 255, 255, 0.94);
}
.hint {
position: fixed;
z-index: 10;
right: 28px;
bottom: 24px;
padding: 9px 13px;
border: 1px solid rgba(38, 59, 58, 0.08);
border-radius: 999px;
background: rgba(255, 255, 255, 0.55);
color: #61716d;
font-size: 11px;
font-weight: 650;
pointer-events: none;
backdrop-filter: blur(10px);
}
@media (max-width: 650px) {
.panel {
top: 20px;
left: 20px;
width: calc(100vw - 40px);
}
h1 {
font-size: 42px;
}
.subtitle {
max-width: 270px;
margin-top: 10px;
}
.legend {
display: none;
}
#reset {
top: auto;
right: 20px;
bottom: 64px;
}
.hint {
right: 20px;
bottom: 20px;
}
}
</style>
</head>
<body>
<div id="app"></div>
<section class="panel">
<div class="eyebrow">Collaborative workshop</div>
<h1>One table,<br>many hands.</h1>
<p class="subtitle">
Four stylized helpers bring their own posture, tools, and support while
placing objects onto a shared worktable.
</p>
<div class="legend" aria-label="Character supports">
<span><i style="background:#e2a43d"></i>Standing carrier</span>
<span><i style="background:#dd715c"></i>Cane support</span>
<span><i style="background:#8178aa"></i>Step platform</span>
<span><i style="background:#3e9c93"></i>Stool seat</span>
</div>
</section>
<button id="reset" type="button">Reset view</button>
<div class="hint">Drag to orbit · Scroll to zoom</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer, scene, camera
// -------------------------------------------------------------------------
const app = document.getElementById("app");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0x000000, 0);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
app.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xeeeade, 16, 31);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const controls = {
theta: 0.64,
phi: 0.96,
radius: 12.8,
targetTheta: 0.64,
targetPhi: 0.96,
targetRadius: 12.8,
target: new THREE.Vector3(0, 1.55, 0)
};
function updateCamera(dt) {
const damping = 1 - Math.exp(-8 * dt);
controls.theta +=
(controls.targetTheta - controls.theta) * damping;
controls.phi +=
(controls.targetPhi - controls.phi) * damping;
controls.radius +=
(controls.targetRadius - controls.radius) * damping;
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x +
controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y +
controls.radius * Math.cos(controls.phi),
controls.target.z +
controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xfff8eb, 0x82968e, 2.25));
const keyLight = new THREE.DirectionalLight(0xfff0d9, 3.8);
keyLight.position.set(-5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -10;
keyLight.shadow.camera.right = 10;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xb8d9e6, 1.4);
fillLight.position.set(7, 5, -6);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0xffc77d, 24, 16, 2);
rimLight.position.set(-5, 5, -5);
scene.add(rimLight);
// -------------------------------------------------------------------------
// Geometry and material helpers
// -------------------------------------------------------------------------
const material = (color, roughness = 0.78, metalness = 0) =>
new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
const MAT = {
ground: material(0xe9e3d7),
rug: material(0x78a59f),
rugEdge: material(0x668d88),
wood: material(0xc8834e),
woodLight: material(0xdca06a),
woodDark: material(0x825638),
apron: material(0xf0dfbd),
dark: material(0x263837),
cream: material(0xfff2d8)
};
function addMesh(
parent,
geometry,
mat,
position = [0, 0, 0],
scale = [1, 1, 1]
) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(...position);
mesh.scale.set(...scale);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function box(parent, size, position, mat) {
return addMesh(
parent,
new THREE.BoxGeometry(...size),
mat,
position
);
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
position,
mat,
segments = 16
) {
return addMesh(
parent,
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
mat,
position
);
}
function ball(parent, radius, position, mat, scale = [1, 1, 1]) {
return addMesh(
parent,
new THREE.SphereGeometry(radius, 22, 16),
mat,
position,
scale
);
}
function cylinderBetween(parent, a, b, radius, mat) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const mesh = addMesh(
parent,
new THREE.CylinderGeometry(radius, radius, length, 14),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
// -------------------------------------------------------------------------
// Ground, rug, plants, and the shared table
// -------------------------------------------------------------------------
const ground = addMesh(
scene,
new THREE.PlaneGeometry(50, 50),
MAT.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.015;
ground.castShadow = false;
const rug = addMesh(
scene,
new THREE.CircleGeometry(7.1, 96),
MAT.rug
);
rug.rotation.x = -Math.PI / 2;
rug.position.y = 0.006;
rug.castShadow = false;
const rugRing = addMesh(
scene,
new THREE.RingGeometry(5.95, 6.05, 96),
MAT.rugEdge
);
rugRing.rotation.x = -Math.PI / 2;
rugRing.position.y = 0.012;
rugRing.castShadow = false;
function makePlant(x, z, scale = 1) {
const plant = new THREE.Group();
plant.position.set(x, 0, z);
plant.scale.setScalar(scale);
scene.add(plant);
const potMat = material(0xc87958);
const stemMat = material(0x557a52);
const leafMat = material(0x6f9567);
cylinder(plant, 0.42, 0.3, 0.55, [0, 0.275, 0], potMat);
cylinder(plant, 0.46, 0.46, 0.08, [0, 0.55, 0], potMat);
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2;
const end = [
Math.cos(angle) * 0.42,
1.25 + (i % 2) * 0.25,
Math.sin(angle) * 0.42
];
cylinderBetween(
plant,
[0, 0.55, 0],
end,
0.035,
stemMat
);
const leaf = ball(
plant,
0.32,
end,
leafMat,
[0.72, 1.35, 0.32]
);
leaf.rotation.z = Math.cos(angle) * 0.45;
leaf.rotation.x = Math.sin(angle) * 0.45;
}
}
makePlant(-6.4, -4.7, 1.08);
makePlant(6.2, -4.2, 0.92);
const table = new THREE.Group();
scene.add(table);
const plankDepth = 0.96;
for (let i = -1; i <= 1; i++) {
box(
table,
[6.8, 0.24, plankDepth],
[0, 1.74, i * 1.0],
i === 0 ? MAT.woodLight : MAT.wood
);
}
for (const x of [-2.85, 2.85]) {
for (const z of [-1.03, 1.03]) {
cylinder(
table,
0.17,
0.23,
1.64,
[x, 0.82, z],
MAT.woodDark
);
}
}
box(table, [5.9, 0.17, 0.16], [0, 1.4, -1.02], MAT.woodDark);
box(table, [5.9, 0.17, 0.16], [0, 1.4, 1.02], MAT.woodDark);
box(table, [0.16, 0.17, 2.0], [-2.85, 1.4, 0], MAT.woodDark);
box(table, [0.16, 0.17, 2.0], [2.85, 1.4, 0], MAT.woodDark);
const tableSurfaceY = 1.86;
function stationDisc(x, z, color) {
const disc = addMesh(
scene,
new THREE.CircleGeometry(0.72, 48),
new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity: 0.24,
depthWrite: false
}),
[x, 0.025, z]
);
disc.rotation.x = -Math.PI / 2;
disc.castShadow = false;
disc.receiveShadow = false;
}
stationDisc(-4.05, -0.1, 0xe2a43d);
stationDisc(4.05, 0.1, 0xdd715c);
stationDisc(0.35, -2.9, 0x8178aa);
stationDisc(-0.6, 2.85, 0x3e9c93);
// -------------------------------------------------------------------------
// Character construction
// -------------------------------------------------------------------------
const animatedArms = [];
function createHead(parent, headY, skinMat, hairMat, style) {
const head = new THREE.Group();
head.position.y = headY;
parent.add(head);
ball(head, 0.42, [0, 0, 0], skinMat, [1, 1.04, 0.96]);
const hairCap = addMesh(
head,
new THREE.SphereGeometry(
0.435,
24,
12,
0,
Math.PI * 2,
0,
Math.PI * 0.52
),
hairMat,
[0, 0.025, -0.025]
);
hairCap.scale.set(1.03, 0.92, 1.03);
if (style === "curly") {
for (let i = 0; i < 6; i++) {
const angle = (i / 6) * Math.PI * 2;
ball(
head,
0.15,
[
Math.cos(angle) * 0.27,
0.31 + Math.sin(i * 2) * 0.04,
Math.sin(angle) * 0.25
],
hairMat
);
}
} else if (style === "bun") {
ball(head, 0.2, [0, 0.36, -0.36], hairMat);
ball(head, 0.13, [0.19, 0.34, -0.3], hairMat);
} else if (style === "pony") {
const tail = ball(
head,
0.18,
[0.31, 0.12, -0.32],
hairMat,
[0.85, 1.35, 0.85]
);
tail.rotation.z = -0.4;
} else if (style === "cap") {
const cap = addMesh(
head,
new THREE.SphereGeometry(
0.44,
24,
10,
0,
Math.PI * 2,
0,
Math.PI * 0.5
),
hairMat,
[0, 0.055, 0]
);
cap.scale.set(1.02, 0.72, 1.03);
box(head, [0.48, 0.06, 0.28], [0, 0.22, 0.34], hairMat);
}
const eyeMat = material(0x24302e, 0.5);
ball(head, 0.038, [-0.13, 0.035, 0.388], eyeMat);
ball(head, 0.038, [0.13, 0.035, 0.388], eyeMat);
ball(head, 0.065, [0, -0.045, 0.41], skinMat, [0.8, 1, 0.8]);
box(head, [0.13, 0.025, 0.025], [0, -0.17, 0.385], MAT.dark);
ball(head, 0.09, [-0.42, -0.01, 0], skinMat, [0.65, 1, 0.8]);
ball(head, 0.09, [0.42, -0.01, 0], skinMat, [0.65, 1, 0.8]);
return head;
}
function createArm(
root,
side,
shoulderY,
sleeveMat,
skinMat,
shoulderRotation,
elbowRotation,
isReaching
) {
const shoulder = new THREE.Group();
shoulder.position.set(side * 0.53, shoulderY, 0);
shoulder.rotation.x = shoulderRotation;
root.add(shoulder);
cylinder(
shoulder,
0.135,
0.145,
0.62,
[0, -0.31, 0],
sleeveMat,
14
);
const elbow = new THREE.Group();
elbow.position.y = -0.62;
elbow.rotation.x = elbowRotation;
shoulder.add(elbow);
cylinder(
elbow,
0.105,
0.115,
0.58,
[0, -0.29, 0],
skinMat,
14
);
const hand = ball(
elbow,
0.14,
[0, -0.63, 0],
skinMat,
[0.9, 1, 0.9]
);
if (isReaching) {
animatedArms.push({
shoulder,
base: shoulderRotation,
phase: animatedArms.length * 1.7
});
}
return { shoulder, elbow, hand };
}
function createCharacter(options) {
const {
x,
z,
yaw,
baseY = 0,
pose = "stand",
skin,
hair,
shirt,
pants,
hairStyle,
apron = false
} = options;
const root = new THREE.Group();
root.position.set(x, baseY, z);
root.rotation.y = yaw;
scene.add(root);
const skinMat = material(skin);
const hairMat = material(hair);
const shirtMat = material(shirt);
const pantsMat = material(pants);
const shoeMat = material(0x3c4541);
const seated = pose === "seat";
const torsoY = seated ? 1.62 : 1.94;
const pelvisY = seated ? 1.08 : 1.38;
const headY = seated ? 2.64 : 3.03;
const shoulderY = seated ? 2.22 : 2.36;
const torso = ball(
root,
1,
[0, torsoY, 0],
shirtMat,
[0.49, seated ? 0.67 : 0.72, 0.36]
);
torso.castShadow = true;
ball(
root,
1,
[0, pelvisY, 0],
pantsMat,
[0.48, 0.3, 0.34]
);
cylinder(
root,
0.14,
0.15,
seated ? 0.2 : 0.23,
[0, headY - 0.43, 0],
skinMat,
12
);
createHead(root, headY, skinMat, hairMat, hairStyle);
if (apron) {
box(
root,
[0.58, 0.73, 0.055],
[0, torsoY - 0.02, 0.355],
MAT.apron
);
box(
root,
[0.12, 0.67, 0.045],
[-0.22, torsoY - 0.01, 0.38],
MAT.apron
);
box(
root,
[0.12, 0.67, 0.045],
[0.22, torsoY - 0.01, 0.38],
MAT.apron
);
}
if (!seated) {
for (const side of [-1, 1]) {
const hipX = side * 0.23;
cylinderBetween(
root,
[hipX, 1.38, 0],
[hipX, 0.76, 0.01],
0.165,
pantsMat
);
ball(root, 0.17, [hipX, 0.75, 0.01], pantsMat);
cylinderBetween(
root,
[hipX, 0.74, 0.01],
[hipX, 0.17, 0.02],
0.135,
pantsMat
);
box(
root,
[0.32, 0.18, 0.48],
[hipX, 0.1, 0.1],
shoeMat
);
}
} else {
for (const side of [-1, 1]) {
const hipX = side * 0.23;
cylinderBetween(
root,
[hipX, 1.08, 0.02],
[hipX, 0.78, 0.66],
0.17,
pantsMat
);
ball(root, 0.18, [hipX, 0.77, 0.66], pantsMat);
cylinderBetween(
root,
[hipX, 0.76, 0.67],
[hipX, 0.18, 0.76],
0.135,
pantsMat
);
box(
root,
[0.31, 0.17, 0.47],
[hipX, 0.1, 0.84],
shoeMat
);
}
}
const reachA = createArm(
root,
1,
shoulderY,
shirtMat,
skinMat,
-1.02,
-0.42,
true
);
createArm(
root,
-1,
shoulderY,
shirtMat,
skinMat,
seated ? -1.0 : 0.14,
seated ? -0.42 : 0.12,
seated
);
root.userData.reachArm = reachA;
return root;
}
// -------------------------------------------------------------------------
// Four distinct poses and support systems
// -------------------------------------------------------------------------
// A: standing carrier with a small wooden crate.
const carrier = createCharacter({
x: -4.05,
z: -0.1,
yaw: Math.atan2(4.05, 0.1),
skin: 0x9a6247,
hair: 0x352b28,
shirt: 0xe1a13c,
pants: 0x3d6674,
hairStyle: "curly",
apron: true
});
const carrierCrate = new THREE.Group();
carrierCrate.position.set(-0.68, 0.82, 0.14);
carrierCrate.rotation.z = -0.08;
carrier.add(carrierCrate);
box(carrierCrate, [0.62, 0.48, 0.42], [0, 0, 0], MAT.woodDark);
for (let i = -1; i <= 1; i++) {
box(
carrierCrate,
[0.62, 0.1, 0.46],
[0, i * 0.16, 0.01],
MAT.woodLight
);
}
// B: standing helper leaning on a cane.
const caneHelper = createCharacter({
x: 4.05,
z: 0.1,
yaw: Math.atan2(-4.05, -0.1),
skin: 0xe0aa82,
hair: 0x8a4c32,
shirt: 0xdc705c,
pants: 0x435b72,
hairStyle: "cap"
});
cylinderBetween(
caneHelper,
[0.62, 0.05, 0.04],
[0.62, 1.23, 0.04],
0.045,
MAT.woodDark
);
ball(
caneHelper,
0.105,
[0.62, 1.23, 0.04],
MAT.woodLight
);
// C: helper standing on a crate-like platform with a rear handrail.
const platformHelper = createCharacter({
x: 0.35,
z: -2.9,
yaw: Math.atan2(-0.35, 2.9),
baseY: 0.65,
skin: 0x744b3a,
hair: 0x252629,
shirt: 0x8178aa,
pants: 0x353e4b,
hairStyle: "bun"
});
const platform = new THREE.Group();
platform.position.set(0.35, 0, -2.9);
scene.add(platform);
box(platform, [1.55, 0.62, 1.3], [0, 0.31, 0], MAT.woodDark);
for (let i = -2; i <= 2; i++) {
box(
platform,
[0.09, 0.68, 1.34],
[i * 0.31, 0.31, 0],
MAT.woodLight
);
}
cylinderBetween(
platformHelper,
[0.58, 0, -0.72],
[0.58, 2.18, -0.72],
0.045,
MAT.woodDark
);
cylinderBetween(
platformHelper,
[0.58, 1.52, -0.72],
[0.58, 1.52, -0.48],
0.06,
MAT.woodLight
);
// D: seated helper using a tall stool.
const seatedHelper = createCharacter({
x: -0.6,
z: 2.85,
yaw: Math.atan2(0.6, -2.85),
pose: "seat",
skin: 0xb87555,
hair: 0x4b302b,
shirt: 0x3e9c93,
pants: 0x655775,
hairStyle: "pony"
});
const stool = new THREE.Group();
stool.position.set(-0.6, 0, 2.85);
scene.add(stool);
cylinder(stool, 0.62, 0.62, 0.16, [0, 0.84, 0], MAT.woodLight);
for (const x of [-0.35, 0.35]) {
for (const z of [-0.3, 0.3]) {
cylinderBetween(
stool,
[x * 1.12, 0.02, z * 1.12],
[x, 0.78, z],
0.07,
MAT.woodDark
);
}
}
cylinderBetween(
stool,
[-0.35, 0.35, 0],
[0.35, 0.35, 0],
0.055,
MAT.woodDark
);
// -------------------------------------------------------------------------
// Objects placed onto the shared table
// -------------------------------------------------------------------------
function createBooks() {
const group = new THREE.Group();
const colors = [0x4e7b79, 0xe4a044, 0x9b6c9d];
for (let i = 0; i < 3; i++) {
const book = box(
group,
[0.94 - i * 0.05, 0.12, 0.66 - i * 0.03],
[i * 0.035, 0.06 + i * 0.12, i * 0.025],
material(colors[i])
);
book.rotation.y = (i - 1) * 0.09;
}
box(
group,
[0.2, 0.04, 0.68],
[-0.34, 0.32, 0.02],
MAT.cream
);
return group;
}
function createVase() {
const group = new THREE.Group();
const vaseMat = material(0xcf765a, 0.55);
const profile = [
new THREE.Vector2(0.22, 0),
new THREE.Vector2(0.31, 0.07),
new THREE.Vector2(0.37, 0.25),
new THREE.Vector2(0.27, 0.43),
new THREE.Vector2(0.17, 0.62),
new THREE.Vector2(0.21, 0.73)
];
addMesh(
group,
new THREE.LatheGeometry(profile, 28),
vaseMat
);
cylinderBetween(
group,
[0, 0.66, 0],
[0.04, 1.12, 0.01],
0.025,
material(0x5c8058)
);
ball(group, 0.16, [0.04, 1.16, 0.01], material(0xe8b657));
ball(group, 0.12, [0.16, 1.1, 0.02], material(0xd76f6f));
ball(group, 0.11, [-0.1, 1.08, 0.03], material(0xf3e2ba));
return group;
}
function createBowl() {
const group = new THREE.Group();
const bowlMat = material(0xe7a34d, 0.48);
addMesh(
group,
new THREE.SphereGeometry(
0.42,
28,
16,
0,
Math.PI * 2,
Math.PI * 0.5,
Math.PI * 0.5
),
bowlMat
);
const rim = addMesh(
group,
new THREE.TorusGeometry(0.405, 0.045, 10, 36),
material(0xf3c77e, 0.45)
);
rim.rotation.x = Math.PI / 2;
ball(group, 0.12, [-0.12, 0.04, 0.04], material(0xcf665b));
ball(group, 0.13, [0.1, 0.05, 0.07], material(0x779a65));
ball(group, 0.115, [0, 0.08, -0.14], material(0xe7cc69));
return group;
}
function createBall() {
const group = new THREE.Group();
ball(group, 0.36, [0, 0, 0], material(0x5d91b5, 0.4));
const stripe = addMesh(
group,
new THREE.TorusGeometry(0.355, 0.035, 10, 36),
material(0xe5eef0, 0.42)
);
stripe.rotation.x = Math.PI / 2;
return group;
}
const placements = [];
function addPlacement(group, start, end, delay, arc, rotation = 0) {
const ring = addMesh(
scene,
new THREE.RingGeometry(0.2, 0.29, 48),
new THREE.MeshBasicMaterial({
color: 0xffd68a,
transparent: true,
opacity: 0,
side: THREE.DoubleSide,
depthWrite: false
}),
[end[0], tableSurfaceY + 0.012, end[2]]
);
ring.rotation.x = -Math.PI / 2;
ring.castShadow = false;
ring.receiveShadow = false;
group.position.set(...start);
group.rotation.y = rotation;
scene.add(group);
placements.push({
group,
start: new THREE.Vector3(...start),
end: new THREE.Vector3(...end),
delay,
duration: 1.25,
arc,
ring,
rotation
});
}
addPlacement(
createBooks(),
[-3.05, 2.05, -0.2],
[1.92, tableSurfaceY, -0.58],
0.15,
0.48,
-0.18
);
addPlacement(
createBall(),
[3.05, 2.14, 0.2],
[1.2, tableSurfaceY + 0.36, 0.43],
0.75,
0.6,
0.5
);
addPlacement(
createVase(),
[0.24, 2.65, -1.78],
[-0.72, tableSurfaceY, -0.55],
1.35,
0.34,
-0.3
);
addPlacement(
createBowl(),
[-0.8, 2.08, 1.78],
[-1.46, tableSurfaceY + 0.42, 0.45],
1.95,
0.52,
0.25
);
// -------------------------------------------------------------------------
// Custom camera interaction — no external controls module
// -------------------------------------------------------------------------
let dragging = false;
let previousX = 0;
let previousY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
controls.targetTheta -= dx * 0.006;
controls.targetPhi = THREE.MathUtils.clamp(
controls.targetPhi - dy * 0.005,
0.58,
1.32
);
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.targetRadius = THREE.MathUtils.clamp(
controls.targetRadius + event.deltaY * 0.012,
8,
18
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetView);
renderer.domElement.addEventListener(
"contextmenu",
(event) => event.preventDefault()
);
function resetView() {
controls.targetTheta = 0.64;
controls.targetPhi = 0.96;
controls.targetRadius = 12.8;
}
document.getElementById("reset").addEventListener("click", resetView);
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
elapsed += dt;
for (const arm of animatedArms) {
arm.shoulder.rotation.x =
arm.base + Math.sin(elapsed * 1.15 + arm.phase) * 0.018;
}
for (const placement of placements) {
const raw = THREE.MathUtils.clamp(
(elapsed - placement.delay) / placement.duration,
0,
1
);
const eased = raw * raw * (3 - 2 * raw);
placement.group.position.lerpVectors(
placement.start,
placement.end,
eased
);
placement.group.position.y +=
Math.sin(Math.PI * eased) * placement.arc;
placement.group.rotation.y =
placement.rotation + eased * Math.PI * 0.55;
const scale = 0.82 + eased * 0.18;
placement.group.scale.setScalar(scale);
if (raw < 1) {
placement.ring.visible = true;
placement.ring.material.opacity = 0.55 * (1 - raw);
placement.ring.scale.setScalar(1 + raw * 1.8);
} else {
placement.ring.visible = false;
}
}
updateCamera(dt);
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
</script>
</body>
</html>
```