Prompt specification
Build or customize the Three.js 3D scene "One Character Three Tool Sets" 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: One Character Three Tool Sets
Category: Games & Play · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/one-character-three-tool-sets-x3745
Scene Description Prompt:
I'd like to see this as a low-poly Three.js scene: one character three tool sets. Display one original neutral character beside gardening, repair, and music tools. Distinguish activity cues without changing body shape or implying professions belong to particular identities. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (one-character-three-tool-sets-x3745):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>One Character, Three Activities</title>
<style>
:root {
--ink: #26312f;
--muted: #64706c;
--paper: rgba(250, 251, 246, 0.9);
--garden: #4e8b63;
--repair: #d97945;
--music: #7765a8;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9eee7;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene:active { cursor: grabbing; }
.panel {
position: fixed;
z-index: 5;
background: var(--paper);
border: 1px solid rgba(38, 49, 47, 0.1);
box-shadow: 0 14px 40px rgba(47, 61, 55, 0.1);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#intro {
top: 22px;
left: 22px;
width: min(360px, calc(100vw - 44px));
padding: 18px 20px 17px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 7px;
color: #6a7671;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(22px, 3vw, 31px);
line-height: 0.98;
letter-spacing: -0.045em;
font-weight: 850;
}
h1 span {
color: #55766b;
font-weight: 650;
}
#intro p {
margin: 12px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 13px;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 8px;
border-radius: 999px;
background: rgba(38, 49, 47, 0.045);
color: #45524e;
font-size: 10px;
font-weight: 700;
}
.legend i {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--color);
}
#controls {
top: 22px;
right: 22px;
display: flex;
gap: 6px;
padding: 7px;
border-radius: 14px;
}
#controls button {
width: 36px;
height: 36px;
border: 0;
border-radius: 10px;
background: #eef1eb;
color: #42504c;
font: inherit;
font-size: 17px;
font-weight: 750;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
#controls button:hover {
background: #e1e8df;
transform: translateY(-1px);
}
#controls button:focus-visible {
outline: 3px solid rgba(78, 139, 99, 0.35);
outline-offset: 2px;
}
#help {
left: 50%;
bottom: 18px;
transform: translateX(-50%);
max-width: calc(100vw - 32px);
padding: 9px 13px;
border-radius: 999px;
color: #66726e;
font-size: 10px;
font-weight: 650;
letter-spacing: 0.02em;
text-align: center;
white-space: nowrap;
pointer-events: none;
}
@media (max-width: 700px) {
#intro {
top: 12px;
left: 12px;
width: min(285px, calc(100vw - 82px));
padding: 13px 14px;
border-radius: 15px;
}
.eyebrow { display: none; }
h1 { font-size: 20px; }
#intro p { margin-top: 8px; font-size: 10px; }
.legend { gap: 4px; margin-top: 8px; }
.legend span { padding: 4px 6px; font-size: 9px; }
#controls {
top: 12px;
right: 12px;
padding: 5px;
}
#controls button {
width: 31px;
height: 31px;
border-radius: 8px;
}
#help {
bottom: 10px;
padding: 8px 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<canvas
id="scene"
aria-label="A low-poly neutral character standing between gardening, repair, and music tool sets"
></canvas>
<section id="intro" class="panel" aria-labelledby="title">
<p class="eyebrow">Low-poly activity study</p>
<h1 id="title">ONE CHARACTER<br /><span>THREE ACTIVITIES</span></h1>
<p>
The same faceted figure appears beside three equal tool islands.
Color and motion communicate activities—not occupations or identity.
</p>
<div class="legend" aria-label="Activity color legend">
<span><i style="--color: var(--garden)"></i>Gardening</span>
<span><i style="--color: var(--repair)"></i>Repair</span>
<span><i style="--color: var(--music)"></i>Music</span>
</div>
</section>
<nav id="controls" class="panel" aria-label="Camera controls">
<button id="zoom-in" type="button" aria-label="Zoom in">+</button>
<button id="zoom-out" type="button" aria-label="Zoom out">−</button>
<button id="reset" type="button" aria-label="Reset camera" title="Reset view">↺</button>
</nav>
<div id="help" class="panel">
Drag to orbit · Scroll or use + / − to zoom · Arrow keys also orbit
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#scene");
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9eee7);
scene.fog = new THREE.Fog(0xe9eee7, 21, 39);
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraState = {
theta: 0.28,
phi: 1.16,
radius: 17.2,
target: new THREE.Vector3(0, 1.55, 0)
};
function updateCamera() {
const { theta, phi, radius, target } = cameraState;
const horizontal = radius * Math.sin(phi);
camera.position.set(
target.x + horizontal * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + horizontal * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xffffff, 0x7d8d7c, 2.0);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff5df, 3.1);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc9dcf4, 0.75);
fill.position.set(8, 6, -8);
scene.add(fill);
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.76,
metalness: options.metalness ?? 0.0,
flatShading: true,
transparent: options.transparent ?? false,
opacity: options.opacity ?? 1
});
const M = {
ground: material(0xe5e9df),
groundSide: material(0xd5ddd2),
platform: material(0xcbd5cd),
characterBase: material(0xd5ddd8),
sweater: material(0x56877d),
sweaterLight: material(0x6e9b91),
pants: material(0x465454),
shoes: material(0x2f3939),
skin: material(0xc8a789),
face: material(0x263231),
gardenBase: material(0xdce7d8),
garden: material(0x4e8b63),
leaf: material(0x77ad70),
leafDark: material(0x3f7653),
terracotta: material(0xbd7255),
soil: material(0x5f4938),
can: material(0x667f82),
repairBase: material(0xeee0d5),
repair: material(0xd97945),
orangeDark: material(0xa85332),
steel: material(0xaeb8b6, { metalness: 0.58, roughness: 0.42 }),
darkSteel: material(0x596363, { metalness: 0.48, roughness: 0.5 }),
musicBase: material(0xe3dfed),
music: material(0x7765a8),
musicLight: material(0x9a89c7),
speaker: material(0x394342),
speakerCone: material(0x222a29),
white: material(0xf4f0e6),
black: material(0x303333),
drum: material(0x8772ae),
drumSkin: material(0xe9dfc9)
};
function mesh(parent, geometry, mat, x = 0, y = 0, z = 0) {
const object = new THREE.Mesh(geometry, mat);
object.position.set(x, y, z);
object.castShadow = true;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(parent, size, mat, x = 0, y = 0, z = 0) {
return mesh(
parent,
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat,
x, y, z
);
}
function cylinder(parent, top, bottom, height, sides, mat, x = 0, y = 0, z = 0) {
return mesh(
parent,
new THREE.CylinderGeometry(top, bottom, height, sides),
mat,
x, y, z
);
}
function torus(parent, radius, tube, mat, x = 0, y = 0, z = 0, arc = Math.PI * 2) {
return mesh(
parent,
new THREE.TorusGeometry(radius, tube, 6, 14, arc),
mat,
x, y, z
);
}
const up = new THREE.Vector3(0, 1, 0);
function cylinderBetween(parent, a, b, radius, mat, sides = 7) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const object = cylinder(parent, radius, radius, length, sides, mat);
object.position.copy(start).add(end).multiplyScalar(0.5);
object.quaternion.setFromUnitVectors(up, direction.normalize());
return object;
}
// Ground and low-poly plaza.
const ground = cylinder(scene, 12.8, 13.1, 0.3, 48, M.ground, 0, -0.16, 0);
ground.receiveShadow = true;
const groundSide = cylinder(scene, 13.15, 13.15, 0.08, 48, M.groundSide, 0, -0.34, 0);
groundSide.receiveShadow = true;
// The central character platform.
const characterBase = cylinder(scene, 1.46, 1.56, 0.22, 10, M.characterBase, 0, 0.09, 0);
characterBase.receiveShadow = true;
const characterRing = torus(scene, 1.32, 0.035, M.sweaterLight, 0, 0.215, 0);
characterRing.rotation.x = Math.PI / 2;
// Original, deliberately neutral low-poly character.
const character = new THREE.Group();
character.position.y = 0.21;
scene.add(character);
const leftShoe = box(character, [0.5, 0.25, 0.72], M.shoes, -0.27, 0.17, 0.12);
const rightShoe = box(character, [0.5, 0.25, 0.72], M.shoes, 0.27, 0.17, 0.12);
leftShoe.rotation.y = -0.035;
rightShoe.rotation.y = 0.035;
const leftLeg = cylinder(character, 0.26, 0.3, 1.22, 6, M.pants, -0.27, 0.86, 0);
const rightLeg = cylinder(character, 0.26, 0.3, 1.22, 6, M.pants, 0.27, 0.86, 0);
leftLeg.rotation.z = -0.018;
rightLeg.rotation.z = 0.018;
const torso = cylinder(character, 0.53, 0.63, 1.25, 7, M.sweater, 0, 1.92, 0);
torso.scale.z = 0.78;
const collar = cylinder(character, 0.34, 0.34, 0.11, 8, M.sweaterLight, 0, 2.56, 0);
collar.scale.z = 0.8;
const neck = cylinder(character, 0.17, 0.18, 0.25, 7, M.skin, 0, 2.67, 0);
const head = mesh(character, new THREE.DodecahedronGeometry(0.48, 0), M.skin, 0, 3.03, 0);
head.scale.set(1, 1.06, 0.96);
const leftEar = mesh(character, new THREE.DodecahedronGeometry(0.105, 0), M.skin, -0.46, 3.01, 0);
const rightEar = mesh(character, new THREE.DodecahedronGeometry(0.105, 0), M.skin, 0.46, 3.01, 0);
leftEar.scale.set(0.75, 1, 0.8);
rightEar.scale.set(0.75, 1, 0.8);
mesh(character, new THREE.SphereGeometry(0.034, 6, 4), M.face, -0.14, 3.06, 0.435);
mesh(character, new THREE.SphereGeometry(0.034, 6, 4), M.face, 0.14, 3.06, 0.435);
const mouth = box(character, [0.12, 0.022, 0.025], M.face, 0, 2.89, 0.447);
mouth.rotation.z = 0.01;
cylinderBetween(character, [-0.48, 2.34, 0], [-0.63, 1.88, 0.015], 0.17, M.sweater);
cylinderBetween(character, [-0.63, 1.88, 0.015], [-0.69, 1.52, 0.04], 0.145, M.sweater);
cylinderBetween(character, [0.48, 2.34, 0], [0.63, 1.88, 0.015], 0.17, M.sweater);
cylinderBetween(character, [0.63, 1.88, 0.015], [0.69, 1.52, 0.04], 0.145, M.sweater);
mesh(character, new THREE.DodecahedronGeometry(0.16, 0), M.skin, -0.69, 1.42, 0.04);
mesh(character, new THREE.DodecahedronGeometry(0.16, 0), M.skin, 0.69, 1.42, 0.04);
// Small, character-neutral color accents.
const leftBadge = mesh(character, new THREE.CylinderGeometry(0.09, 0.09, 0.025, 8), M.sweaterLight, -0.28, 2.19, 0.405);
leftBadge.rotation.x = Math.PI / 2;
const rightBadge = leftBadge.clone();
rightBadge.position.x = 0.28;
character.add(rightBadge);
// Activity cue label sprites.
function roundedRect(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.arcTo(x + w, y, x + w, y + h, r);
ctx.arcTo(x + w, y + h, x, y + h, r);
ctx.arcTo(x, y + h, x, y, r);
ctx.arcTo(x, y, x + w, y, r);
ctx.closePath();
}
function makeLabel(kind, title, accent) {
const c = document.createElement("canvas");
c.width = 640;
c.height = 190;
const ctx = c.getContext("2d");
ctx.clearRect(0, 0, c.width, c.height);
ctx.shadowColor = "rgba(40, 52, 48, 0.18)";
ctx.shadowBlur = 18;
ctx.shadowOffsetY = 7;
roundedRect(ctx, 12, 18, 616, 142, 48);
ctx.fillStyle = "rgba(250, 251, 246, 0.96)";
ctx.fill();
ctx.shadowColor = "transparent";
ctx.fillStyle = accent;
ctx.beginPath();
ctx.arc(88, 89, 51, 0, Math.PI * 2);
ctx.fill();
ctx.strokeStyle = "#ffffff";
ctx.fillStyle = "#ffffff";
ctx.lineWidth = 9;
ctx.lineCap = "round";
ctx.lineJoin = "round";
if (kind === "garden") {
ctx.beginPath();
ctx.moveTo(88, 118);
ctx.lineTo(88, 67);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(88, 94);
ctx.bezierCurveTo(68, 94, 61, 80, 66, 72);
ctx.bezierCurveTo(82, 71, 89, 81, 88, 94);
ctx.fill();
ctx.beginPath();
ctx.moveTo(88, 82);
ctx.bezierCurveTo(106, 82, 114, 69, 110, 61);
ctx.bezierCurveTo(95, 59, 87, 69, 88, 82);
ctx.fill();
} else if (kind === "repair") {
ctx.beginPath();
ctx.arc(79, 78, 12, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(88, 88);
ctx.lineTo(113, 113);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(105, 104);
ctx.lineTo(115, 94);
ctx.stroke();
} else {
ctx.beginPath();
ctx.ellipse(77, 111, 14, 11, -0.25, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.moveTo(88, 109);
ctx.lineTo(88, 61);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(88, 62);
ctx.bezierCurveTo(99, 56, 108, 64, 109, 73);
ctx.stroke();
}
ctx.fillStyle = "#34403d";
ctx.font = "700 48px system-ui, sans-serif";
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillText(title, 158, 86);
ctx.fillStyle = "#7a8581";
ctx.font = "600 20px system-ui, sans-serif";
ctx.fillText("ACTIVITY", 160, 124);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
fog: false
}));
sprite.scale.set(2.65, 0.79, 1);
sprite.renderOrder = 20;
return sprite;
}
const animatedCues = [];
const labels = [];
function addFloatingCue(parent, type, colorMat, center, count = 3) {
for (let i = 0; i < count; i++) {
const cue = new THREE.Group();
parent.add(cue);
if (type === "leaf") {
const leaf = mesh(cue, new THREE.DodecahedronGeometry(0.13, 0), colorMat);
leaf.scale.set(1.35, 0.35, 0.65);
leaf.rotation.z = i * 0.8;
} else if (type === "spark") {
mesh(cue, new THREE.OctahedronGeometry(0.075, 0), colorMat);
} else {
const noteHead = mesh(cue, new THREE.SphereGeometry(0.085, 6, 4), colorMat, 0, 0, 0);
noteHead.scale.set(1.25, 0.72, 0.55);
box(cue, [0.025, 0.27, 0.025], colorMat, 0.045, 0.13, 0);
}
const angle = (i / count) * Math.PI * 2 + 0.5;
cue.position.set(
center[0] + Math.cos(angle) * 0.47,
center[1] + i * 0.17,
center[2] + Math.sin(angle) * 0.47
);
animatedCues.push({
object: cue,
baseY: cue.position.y,
phase: i * 1.8,
speed: 0.9 + i * 0.12
});
}
}
function makeStation(position, baseMaterial, accentMaterial, kind, title, accentHex) {
const root = new THREE.Group();
root.position.set(position[0], 0, position[1]);
scene.add(root);
const platform = cylinder(root, 1.58, 1.7, 0.22, 6, baseMaterial, 0, 0.08, 0);
platform.receiveShadow = true;
const ring = torus(root, 1.38, 0.045, accentMaterial, 0, 0.215, 0);
ring.rotation.x = Math.PI / 2;
const tools = new THREE.Group();
tools.position.y = 0.21;
root.add(tools);
const label = makeLabel(kind, title, accentHex);
label.position.set(0, 3.18, 0);
root.add(label);
labels.push({ sprite: label, baseY: 3.18, phase: labels.length * 1.7 });
return { root, tools, label };
}
// Garden tool set.
const garden = makeStation(
[-4.65, 0.65],
M.gardenBase,
M.garden,
"garden",
"GARDEN",
"#4e8b63"
);
const plantPot = cylinder(garden.tools, 0.39, 0.29, 0.52, 8, M.terracotta, -0.52, 0.29, 0.14);
const potRim = torus(garden.tools, 0.38, 0.055, M.terracotta, -0.52, 0.55, 0.14);
potRim.rotation.x = Math.PI / 2;
cylinder(garden.tools, 0.33, 0.33, 0.07, 8, M.soil, -0.52, 0.57, 0.14);
cylinderBetween(garden.tools, [-0.52, 0.6, 0.14], [-0.57, 1.18, 0.12], 0.025, M.leafDark);
cylinderBetween(garden.tools, [-0.52, 0.6, 0.14], [-0.27, 1.04, 0.16], 0.022, M.leafDark);
cylinderBetween(garden.tools, [-0.52, 0.6, 0.14], [-0.77, 0.95, 0.1], 0.022, M.leafDark);
const leafA = mesh(garden.tools, new THREE.DodecahedronGeometry(0.2, 0), M.leaf, -0.72, 1.0, 0.1);
leafA.scale.set(1.35, 0.3, 0.8);
leafA.rotation.z = 0.55;
const leafB = mesh(garden.tools, new THREE.DodecahedronGeometry(0.22, 0), M.leaf, -0.25, 1.08, 0.16);
leafB.scale.set(1.35, 0.3, 0.8);
leafB.rotation.z = -0.62;
const leafC = mesh(garden.tools, new THREE.DodecahedronGeometry(0.18, 0), M.leafDark, -0.57, 1.23, 0.1);
leafC.scale.set(0.75, 1.25, 0.5);
const canBody = cylinder(garden.tools, 0.31, 0.36, 0.56, 8, M.can, 0.67, 0.31, -0.32);
canBody.rotation.y = 0.18;
const canRim = torus(garden.tools, 0.31, 0.035, M.darkSteel, 0.67, 0.59, -0.32);
canRim.rotation.x = Math.PI / 2;
const canHandle = torus(garden.tools, 0.23, 0.045, M.darkSteel, 0.96, 0.35, -0.32);
canHandle.rotation.y = Math.PI / 2;
cylinderBetween(garden.tools, [0.42, 0.29, -0.32], [0.07, 0.61, -0.52], 0.06, M.darkSteel);
const rose = mesh(garden.tools, new THREE.ConeGeometry(0.13, 0.18, 6), M.steel, 0.05, 0.64, -0.54);
rose.rotation.z = -0.95;
cylinderBetween(garden.tools, [1.02, 0.18, 0.54], [1.18, 0.84, 0.54], 0.065, M.repair);
const trowelBlade = mesh(garden.tools, new THREE.ConeGeometry(0.17, 0.38, 4), M.steel, 1.2, 0.99, 0.54);
trowelBlade.rotation.z = -0.08;
addFloatingCue(garden.tools, "leaf", M.leaf, [-0.5, 1.12, 0.15]);
// Repair tool set.
const repair = makeStation(
[4.65, 0.65],
M.repairBase,
M.repair,
"repair",
"REPAIR",
"#d97945"
);
const toolbox = box(repair.tools, [1.03, 0.56, 0.66], M.repair, 0.43, 0.3, -0.3);
toolbox.rotation.y = -0.07;
box(repair.tools, [1.08, 0.09, 0.7], M.orangeDark, 0.43, 0.61, -0.3);
const toolboxHandle = torus(repair.tools, 0.23, 0.045, M.darkSteel, 0.43, 0.72, -0.3);
toolboxHandle.scale.y = 0.8;
box(repair.tools, [0.12, 0.15, 0.04], M.steel, 0.16, 0.51, 0.045);
box(repair.tools, [0.12, 0.15, 0.04], M.steel, 0.7, 0.51, 0.045);
cylinderBetween(repair.tools, [-0.6, 0.2, 0.3], [-0.82, 1.13, 0.3], 0.075, M.steel);
const wrenchJaw = torus(repair.tools, 0.145, 0.045, M.steel, -0.84, 1.17, 0.3, Math.PI * 1.62);
wrenchJaw.rotation.z = -0.38;
cylinderBetween(repair.tools, [0.95, 0.18, 0.55], [1.18, 0.91, 0.55], 0.06, M.repair);
const hammerHead = box(repair.tools, [0.58, 0.19, 0.22], M.darkSteel, 1.18, 1.0, 0.55);
hammerHead.rotation.z = -0.08;
const gear = new THREE.Group();
gear.position.set(-0.82, 0.24, -0.7);
gear.rotation.x = 0.08;
repair.tools.add(gear);
cylinder(gear, 0.23, 0.23, 0.11, 10, M.steel, 0, 0, 0);
cylinder(gear, 0.09, 0.09, 0.13, 8, M.darkSteel, 0, 0.015, 0);
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
const tooth = box(gear, [0.15, 0.11, 0.12], M.steel, Math.cos(angle) * 0.25, 0, Math.sin(angle) * 0.25);
tooth.rotation.y = -angle;
}
addFloatingCue(repair.tools, "spark", M.repair, [0.42, 0.95, -0.3]);
// Music tool set.
const music = makeStation(
[0, -4.65],
M.musicBase,
M.music,
"music",
"MUSIC",
"#7765a8"
);
const speaker = new THREE.Group();
speaker.position.set(-0.62, 0, -0.2);
music.tools.add(speaker);
box(speaker, [0.72, 1.22, 0.58], M.speaker, 0, 0.63, 0);
box(speaker, [0.82, 0.1, 0.65], M.darkSteel, 0, 1.28, 0);
const upperSpeaker = cylinder(speaker, 0.19, 0.19, 0.07, 12, M.speakerCone, 0, 0.88, 0.3);
upperSpeaker.rotation.x = Math.PI / 2;
const upperRing = torus(speaker, 0.19, 0.035, M.music, 0, 0.88, 0.34);
const lowerSpeaker = cylinder(speaker, 0.28, 0.28, 0.08, 12, M.speakerCone, 0, 0.42, 0.3);
lowerSpeaker.rotation.x = Math.PI / 2;
const lowerRing = torus(speaker, 0.28, 0.035, M.music, 0, 0.42, 0.34);
const keyboard = new THREE.Group();
keyboard.position.set(0.55, 0, 0.31);
keyboard.rotation.y = -0.18;
music.tools.add(keyboard);
box(keyboard, [1.15, 0.13, 0.43], M.music, 0, 0.83, 0);
for (let i = 0; i < 8; i++) {
const x = -0.49 + i * 0.14;
box(keyboard, [0.115, 0.055, 0.32], M.white, x, 0.92, 0.02);
if (i !== 2 && i !== 6) {
box(keyboard, [0.065, 0.065, 0.19], M.black, x + 0.07, 0.97, -0.08);
}
}
cylinderBetween(keyboard, [-0.4, 0.12, 0], [-0.32, 0.78, 0], 0.025, M.darkSteel);
cylinderBetween(keyboard, [0.4, 0.12, 0], [0.32, 0.78, 0], 0.025, M.darkSteel);
const drum = cylinder(music.tools, 0.34, 0.34, 0.48, 10, M.drum, 1.02, 0.37, -0.67);
cylinder(music.tools, 0.35, 0.35, 0.055, 12, M.drumSkin, 1.02, 0.63, -0.67);
cylinder(music.tools, 0.35, 0.35, 0.05, 12, M.darkSteel, 1.02, 0.12, -0.67);
addFloatingCue(music.tools, "note", M.musicLight, [0.45, 1.1, -0.25]);
// Colored stepping cues connect the single character to each activity island.
const stationData = [
{ x: -4.65, z: 0.65, mat: M.garden },
{ x: 4.65, z: 0.65, mat: M.repair },
{ x: 0, z: -4.65, mat: M.music }
];
for (const station of stationData) {
const dx = station.x;
const dz = station.z;
const length = Math.hypot(dx, dz);
for (let i = 0; i < 3; i++) {
const distance = 2.0 + i * 0.55;
const chip = cylinder(
scene,
0.12,
0.14,
0.035,
8,
station.mat,
dx / length * distance,
0.025,
dz / length * distance
);
chip.castShadow = false;
}
}
// Custom camera controls implemented without addons.
const pointers = new Map();
let lastPointer = null;
let previousPinchDistance = 0;
function clamp(value, min, max) {
return Math.max(min, Math.min(max, value));
}
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
canvas.addEventListener("pointerdown", event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
lastPointer = { x: event.clientX, y: event.clientY };
if (pointers.size === 2) previousPinchDistance = pointerDistance();
});
canvas.addEventListener("pointermove", event => {
if (!pointers.has(event.pointerId)) return;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0) {
cameraState.radius = clamp(
cameraState.radius + (previousPinchDistance - distance) * 0.025,
10.5,
27
);
}
previousPinchDistance = distance;
} else if (lastPointer) {
const dx = event.clientX - lastPointer.x;
const dy = event.clientY - lastPointer.y;
cameraState.theta -= dx * 0.006;
cameraState.phi = clamp(cameraState.phi + dy * 0.005, 0.55, 1.43);
}
lastPointer = { x: event.clientX, y: event.clientY };
});
function releasePointer(event) {
pointers.delete(event.pointerId);
lastPointer = pointers.size
? { ...pointers.values()[pointers.size - 1] }
: null;
previousPinchDistance = pointers.size === 2 ? pointerDistance() : 0;
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("lostpointercapture", releasePointer);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
cameraState.radius = clamp(
cameraState.radius + event.deltaY * 0.012,
10.5,
27
);
},
{ passive: false }
);
function resetCamera() {
cameraState.theta = 0.28;
cameraState.phi = 1.16;
cameraState.radius = window.innerWidth / window.innerHeight < 0.9 ? 20.4 : 17.2;
cameraState.target.set(0, 1.55, 0);
updateCamera();
}
document.querySelector("#reset").addEventListener("click", resetCamera);
document.querySelector("#zoom-in").addEventListener("click", () => {
cameraState.radius = clamp(cameraState.radius - 1.25, 10.5, 27);
});
document.querySelector("#zoom-out").addEventListener("click", () => {
cameraState.radius = clamp(cameraState.radius + 1.25, 10.5, 27);
});
window.addEventListener("keydown", event => {
let handled = true;
switch (event.key) {
case "ArrowLeft": cameraState.theta += 0.08; break;
case "ArrowRight": cameraState.theta -= 0.08; break;
case "ArrowUp": cameraState.phi = clamp(cameraState.phi - 0.06, 0.55, 1.43); break;
case "ArrowDown": cameraState.phi = clamp(cameraState.phi + 0.06, 0.55, 1.43); break;
case "+":
case "=": cameraState.radius = clamp(cameraState.radius - 1, 10.5, 27); break;
case "-": cameraState.radius = clamp(cameraState.radius + 1, 10.5, 27); break;
case "r":
case "R": resetCamera(); break;
default: handled = false;
}
if (handled) event.preventDefault();
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
if (window.innerWidth / window.innerHeight < 0.9) {
cameraState.radius = 20.4;
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const time = clock.getElapsedTime();
if (!reducedMotion) {
for (const cue of animatedCues) {
cue.object.position.y = cue.baseY + Math.sin(time * cue.speed + cue.phase) * 0.1;
cue.object.rotation.y = time * 0.38 + cue.phase;
}
for (const label of labels) {
label.sprite.position.y = label.baseY + Math.sin(time * 0.85 + label.phase) * 0.065;
}
}
updateCamera();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```