Prompt specification
Build or customize the Three.js 3D scene "Cleanup kit and material categories" 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: Cleanup kit and material categories
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/cleanup-kit-and-material-categories-x3885
Scene Description Prompt:
I'd like to see this as a stylized Three.js scene: cleanup kit and material categories. Arrange gloves, grabber, bags, and three symbolic litter types beside matching collection signs; keep the objects distinct enough for shape-based classification. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (cleanup-kit-and-material-categories-x3885):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cleanup Kit & Material Categories</title>
<style>
:root {
--ink: #173c35;
--paper: #f8f7ef;
--glass: rgba(248, 247, 239, 0.86);
--line: rgba(23, 60, 53, 0.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7ede5;
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;
outline: none;
}
canvas.dragging { cursor: grabbing; }
.panel {
position: fixed;
z-index: 10;
background: var(--glass);
border: 1px solid rgba(255, 255, 255, 0.72);
box-shadow: 0 12px 35px rgba(35, 61, 52, 0.12);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#intro {
top: 22px;
left: 22px;
max-width: 390px;
padding: 17px 20px 16px;
border-radius: 18px;
pointer-events: none;
}
.eyebrow {
margin-bottom: 5px;
color: #6d8078;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
#intro h1 {
margin: 0;
font-size: clamp(22px, 2.5vw, 34px);
line-height: 1.02;
letter-spacing: -0.045em;
}
#intro p {
margin: 8px 0 0;
color: #536b63;
font-size: 13px;
line-height: 1.45;
}
#tools {
top: 22px;
right: 22px;
display: flex;
gap: 8px;
padding: 8px;
border-radius: 15px;
}
button {
appearance: none;
border: 0;
border-radius: 10px;
padding: 10px 13px;
background: #edf2eb;
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition: transform 150ms ease, background 150ms ease;
}
button:hover {
transform: translateY(-1px);
background: #fff;
}
button:active { transform: translateY(0); }
#status {
left: 22px;
bottom: 22px;
min-width: 225px;
padding: 13px 16px;
border-radius: 14px;
pointer-events: none;
}
#status .eyebrow { margin-bottom: 4px; }
#statusText {
font-size: 14px;
font-weight: 750;
}
#hint {
right: 22px;
bottom: 22px;
padding: 11px 15px;
border-radius: 12px;
color: #61766e;
font-size: 11px;
font-weight: 650;
pointer-events: none;
}
#tooltip {
position: fixed;
z-index: 20;
display: none;
max-width: 240px;
padding: 8px 11px;
border-radius: 10px;
background: rgba(19, 51, 44, 0.93);
color: #fff;
box-shadow: 0 8px 24px rgba(20, 45, 39, 0.2);
font-size: 11px;
font-weight: 700;
line-height: 1.35;
pointer-events: none;
transform: translate(12px, 12px);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #e7ede5;
color: var(--ink);
font-size: 13px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 700px) {
#intro {
top: 12px;
left: 12px;
right: 12px;
max-width: none;
padding: 13px 15px;
}
#intro p { display: none; }
#tools {
top: 103px;
right: 12px;
}
#status {
left: 12px;
bottom: 12px;
min-width: 0;
}
#hint { display: none; }
}
</style>
</head>
<body>
<div id="app"></div>
<section id="intro" class="panel">
<div class="eyebrow">Shape-first sorting station</div>
<h1>Cleanup kit &<br />material categories</h1>
<p>Six clearly separated silhouettes, each paired with a matching collection sign.</p>
</section>
<nav id="tools" class="panel" aria-label="Camera controls">
<button id="resetView" type="button">Reset view</button>
<button id="topView" type="button">Top view</button>
</nav>
<div id="status" class="panel" aria-live="polite">
<div class="eyebrow">Classification</div>
<div id="statusText">Select an object to identify its category</div>
</div>
<div id="hint" class="panel">Drag to orbit · Scroll to zoom · Click an item</div>
<div id="tooltip"></div>
<div id="loading">Building the sorting station…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
const tooltip = document.getElementById("tooltip");
const statusText = document.getElementById("statusText");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7ede5);
scene.fog = new THREE.Fog(0xe7ede5, 24, 46);
const camera = new THREE.PerspectiveCamera(
42,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
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.05;
renderer.domElement.setAttribute("aria-label", "Interactive 3D cleanup and recycling category scene");
app.appendChild(renderer.domElement);
const hemi = new THREE.HemisphereLight(0xf8fcff, 0x718276, 2.25);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xfff8e9, 3.1);
keyLight.position.set(-6, 12, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xcce8ff, 1.15);
fillLight.position.set(9, 6, -3);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffd8b8, 0.8);
rimLight.position.set(-10, 4, -8);
scene.add(rimLight);
const target = new THREE.Vector3(0, 0.75, 0.05);
const desired = { theta: 0.08, phi: 1.02, radius: 15 };
const current = { ...desired };
let userZoomed = false;
function fitRadius() {
const aspect = innerWidth / innerHeight;
const horizontalFov = 2 * Math.tan(THREE.MathUtils.degToRad(camera.fov * 0.5)) * aspect;
return Math.min(40, Math.max(14.8, 18.2 / horizontalFov));
}
desired.radius = fitRadius();
current.radius = desired.radius;
function standard(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.72,
metalness: 0.0,
...options
});
}
function addMesh(geometry, material, parent, cast = true, receive = true) {
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
if (parent) parent.add(mesh);
return mesh;
}
function cylinderBetween(a, b, radius, material, parent, radiusTop = radius) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.CylinderGeometry(radiusTop, radius, length, 16);
const mesh = addMesh(geometry, material, parent);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function roundedRectPath(ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
function canvasTexture(canvas) {
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function makeSignTexture(index, title, subtitle, accent) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 384;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#faf9f2";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, canvas.width, 20);
roundedRectPath(ctx, 28, 61, 116, 116, 24);
ctx.fillStyle = accent;
ctx.fill();
ctx.fillStyle = "#ffffff";
ctx.font = "800 58px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(index, 86, 119);
ctx.textAlign = "left";
ctx.fillStyle = "#173c35";
ctx.font = "800 66px Arial, sans-serif";
ctx.fillText(title, 173, 112, 550);
ctx.fillStyle = "#71827b";
ctx.font = "700 25px Arial, sans-serif";
ctx.fillText(subtitle.toUpperCase(), 176, 168, 545);
ctx.fillStyle = accent;
ctx.beginPath();
ctx.moveTo(676, 270);
ctx.lineTo(718, 270);
ctx.lineTo(697, 311);
ctx.closePath();
ctx.fill();
ctx.fillStyle = "#d8dfd8";
ctx.fillRect(174, 206, 500, 3);
return canvasTexture(canvas);
}
function makeHeaderTexture(title, subtitle, accent) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = accent;
ctx.font = "800 27px Arial, sans-serif";
ctx.fillText(subtitle.toUpperCase(), 512, 46);
ctx.fillStyle = "#173c35";
ctx.font = "900 82px Arial, sans-serif";
ctx.fillText(title, 512, 130);
ctx.strokeStyle = accent;
ctx.lineWidth = 8;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(340, 202);
ctx.lineTo(684, 202);
ctx.stroke();
return canvasTexture(canvas);
}
function createRoundedShape(width, height, radius) {
const shape = new THREE.Shape();
const x = -width / 2;
const y = -height / 2;
shape.moveTo(x + radius, y);
shape.lineTo(x + width - radius, y);
shape.quadraticCurveTo(x + width, y, x + width, y + radius);
shape.lineTo(x + width, y + height - radius);
shape.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
shape.lineTo(x + radius, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - radius);
shape.lineTo(x, y + radius);
shape.quadraticCurveTo(x, y, x + radius, y);
return shape;
}
// Exhibit architecture
const ground = addMesh(
new THREE.PlaneGeometry(50, 50),
standard(0xe3e9e0, { roughness: 1 }),
scene,
false,
true
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.13;
const wall = addMesh(
new THREE.BoxGeometry(20, 6.8, 0.28),
standard(0xdce6dc, { roughness: 0.95 }),
scene,
false,
true
);
wall.position.set(0, 2.75, -3.55);
const lowerWall = addMesh(
new THREE.BoxGeometry(20, 0.12, 0.31),
standard(0xacc2b4, { roughness: 0.9 }),
scene,
false,
true
);
lowerWall.position.set(0, 0.06, -3.53);
const slabGeometry = new THREE.ExtrudeGeometry(
createRoundedShape(17.5, 3.75, 0.48),
{ depth: 0.16, bevelEnabled: false, curveSegments: 10 }
);
slabGeometry.rotateX(-Math.PI / 2);
const slab = addMesh(
slabGeometry,
standard(0xf3f0e6, { roughness: 0.88 }),
scene,
true,
true
);
slab.position.set(0, -0.04, 0.2);
const frontTrim = addMesh(
new THREE.BoxGeometry(16.5, 0.045, 0.055),
standard(0x4c7c6d, { roughness: 0.7 }),
scene,
false,
true
);
frontTrim.position.set(0, 0.015, 2.065);
const headerLeft = addMesh(
new THREE.PlaneGeometry(4.7, 1.18),
new THREE.MeshBasicMaterial({
map: makeHeaderTexture("CLEANUP KIT", "Tools & supplies", "#55c3a8"),
transparent: true,
depthWrite: false,
toneMapped: false
}),
scene,
false,
false
);
headerLeft.position.set(-3.65, 3.75, -3.395);
const headerRight = addMesh(
new THREE.PlaneGeometry(5.1, 1.18),
new THREE.MeshBasicMaterial({
map: makeHeaderTexture("LITTER CATEGORIES", "Sort by material", "#ee9567"),
transparent: true,
depthWrite: false,
toneMapped: false
}),
scene,
false,
false
);
headerRight.position.set(4.2, 3.75, -3.39);
// Distinct category objects
function createGloves() {
const group = new THREE.Group();
const gloveShape = new THREE.Shape();
gloveShape.moveTo(-0.22, -0.44);
gloveShape.lineTo(0.22, -0.44);
gloveShape.lineTo(0.25, -0.27);
gloveShape.quadraticCurveTo(0.32, -0.15, 0.31, -0.02);
gloveShape.lineTo(0.47, 0.12);
gloveShape.quadraticCurveTo(0.57, 0.24, 0.50, 0.29);
gloveShape.quadraticCurveTo(0.45, 0.33, 0.39, 0.27);
gloveShape.lineTo(0.30, 0.18);
gloveShape.lineTo(0.26, 0.02);
gloveShape.lineTo(0.23, 0.42);
gloveShape.quadraticCurveTo(0.22, 0.51, 0.16, 0.52);
gloveShape.quadraticCurveTo(0.10, 0.52, 0.10, 0.44);
gloveShape.lineTo(0.08, 0.09);
gloveShape.lineTo(0.04, 0.57);
gloveShape.quadraticCurveTo(0.03, 0.66, -0.03, 0.66);
gloveShape.quadraticCurveTo(-0.09, 0.66, -0.09, 0.58);
gloveShape.lineTo(-0.10, 0.08);
gloveShape.lineTo(-0.16, 0.46);
gloveShape.quadraticCurveTo(-0.17, 0.54, -0.23, 0.54);
gloveShape.quadraticCurveTo(-0.29, 0.54, -0.28, 0.46);
gloveShape.lineTo(-0.27, 0.04);
gloveShape.lineTo(-0.33, 0.31);
gloveShape.quadraticCurveTo(-0.34, 0.39, -0.40, 0.38);
gloveShape.quadraticCurveTo(-0.45, 0.37, -0.43, 0.30);
gloveShape.lineTo(-0.34, -0.02);
gloveShape.quadraticCurveTo(-0.34, -0.18, -0.28, -0.27);
gloveShape.lineTo(-0.26, -0.44);
gloveShape.closePath();
const geometry = new THREE.ExtrudeGeometry(gloveShape, {
depth: 0.085,
bevelEnabled: true,
bevelSegments: 3,
bevelSize: 0.025,
bevelThickness: 0.025,
curveSegments: 10
});
geometry.rotateX(-Math.PI / 2);
const mint = standard(0x58cbb3, { roughness: 0.8 });
const mintDark = standard(0x239b87, { roughness: 0.78 });
const left = addMesh(geometry, mint, group);
left.position.set(-0.25, 0.035, 0.02);
left.rotation.y = -0.13;
const right = addMesh(geometry, mintDark, group);
right.position.set(0.27, 0.04, 0.22);
right.rotation.y = 0.13;
const cuffMaterial = standard(0xe8fff8, { roughness: 0.9 });
const cuffA = addMesh(new THREE.BoxGeometry(0.48, 0.08, 0.22), cuffMaterial, group);
cuffA.position.set(-0.25, 0.095, 0.40);
cuffA.rotation.y = -0.13;
const cuffB = addMesh(new THREE.BoxGeometry(0.48, 0.08, 0.22), cuffMaterial, group);
cuffB.position.set(0.27, 0.10, 0.60);
cuffB.rotation.y = 0.13;
return group;
}
function createGrabber() {
const group = new THREE.Group();
const coral = standard(0xf07d5e, { roughness: 0.52 });
const dark = standard(0x334c50, { roughness: 0.72 });
const tip = standard(0xffd39c, { roughness: 0.46 });
cylinderBetween(
new THREE.Vector3(0, 0.08, 0),
new THREE.Vector3(0, 1.22, 0),
0.075,
coral,
group
);
cylinderBetween(
new THREE.Vector3(0, 0.08, 0),
new THREE.Vector3(0, 0.48, 0),
0.105,
dark,
group
);
for (let i = 0; i < 4; i++) {
const rib = addMesh(new THREE.TorusGeometry(0.106, 0.012, 8, 24), coral, group);
rib.rotation.x = Math.PI / 2;
rib.position.y = 0.18 + i * 0.09;
}
const hub = addMesh(new THREE.SphereGeometry(0.13, 20, 14), dark, group);
hub.position.set(0, 1.23, 0);
cylinderBetween(
new THREE.Vector3(0, 1.23, 0),
new THREE.Vector3(-0.22, 1.53, 0),
0.055,
coral,
group
);
cylinderBetween(
new THREE.Vector3(0, 1.23, 0),
new THREE.Vector3(0.22, 1.53, 0),
0.055,
coral,
group
);
cylinderBetween(
new THREE.Vector3(-0.22, 1.53, 0),
new THREE.Vector3(-0.34, 1.70, 0),
0.042,
tip,
group,
0.025
);
cylinderBetween(
new THREE.Vector3(0.22, 1.53, 0),
new THREE.Vector3(0.34, 1.70, 0),
0.042,
tip,
group,
0.025
);
cylinderBetween(
new THREE.Vector3(-0.23, 1.54, 0.01),
new THREE.Vector3(-0.13, 1.68, 0.02),
0.034,
tip,
group,
0.02
);
cylinderBetween(
new THREE.Vector3(0.23, 1.54, 0.01),
new THREE.Vector3(0.13, 1.68, 0.02),
0.034,
tip,
group,
0.02
);
return group;
}
function createBags() {
const group = new THREE.Group();
const navy = standard(0x50627c, { roughness: 0.85 });
const navyLight = standard(0x667a95, { roughness: 0.86 });
const tie = standard(0xe7be65, { roughness: 0.66 });
const makeBag = (x, z, sx, sy, sz, material) => {
const bag = new THREE.Group();
const body = addMesh(new THREE.SphereGeometry(0.44, 24, 18), material, bag);
body.scale.set(sx, sy, sz);
body.position.y = 0.43;
const neck = addMesh(new THREE.CylinderGeometry(0.09, 0.12, 0.16, 16), material, bag);
neck.position.y = 0.88;
const knot = addMesh(new THREE.ConeGeometry(0.13, 0.19, 16), material, bag);
knot.position.y = 1.02;
const ring = addMesh(new THREE.TorusGeometry(0.105, 0.025, 8, 20), tie, bag);
ring.rotation.x = Math.PI / 2;
ring.position.y = 0.89;
bag.position.set(x, 0, z);
group.add(bag);
};
makeBag(-0.37, 0.08, 0.76, 1.0, 0.68, navy);
makeBag(0.30, 0.18, 0.82, 1.12, 0.73, navyLight);
makeBag(-0.02, 0.48, 0.70, 0.86, 0.64, navy);
return group;
}
function createBottle() {
const group = new THREE.Group();
const blue = standard(0x4c9de3, { roughness: 0.25, metalness: 0.02 });
const blueDark = standard(0x2f75b6, { roughness: 0.32 });
const white = standard(0xf7faf3, { roughness: 0.58 });
const cap = standard(0x2b68aa, { roughness: 0.45 });
addMesh(new THREE.CylinderGeometry(0.235, 0.265, 0.62, 28), blue, group).position.y = 0.36;
addMesh(new THREE.CylinderGeometry(0.105, 0.235, 0.20, 28), blue, group).position.y = 0.77;
addMesh(new THREE.CylinderGeometry(0.09, 0.09, 0.15, 24), blueDark, group).position.y = 0.945;
addMesh(new THREE.CylinderGeometry(0.115, 0.115, 0.12, 24), cap, group).position.y = 1.075;
const label = addMesh(new THREE.CylinderGeometry(0.267, 0.267, 0.23, 28, 1, true), white, group);
label.position.y = 0.39;
const stripe = addMesh(new THREE.CylinderGeometry(0.269, 0.269, 0.07, 28, 1, true), blueDark, group);
stripe.position.y = 0.39;
const baseRing = addMesh(new THREE.TorusGeometry(0.24, 0.022, 8, 30), blueDark, group);
baseRing.rotation.x = Math.PI / 2;
baseRing.position.y = 0.055;
return group;
}
function createCan() {
const group = new THREE.Group();
const metal = standard(0xc9d2d3, {
roughness: 0.23,
metalness: 0.72
});
const orange = standard(0xef8d61, { roughness: 0.42, metalness: 0.12 });
const dark = standard(0x66777a, { roughness: 0.35, metalness: 0.55 });
addMesh(new THREE.CylinderGeometry(0.285, 0.285, 0.74, 32), metal, group).position.y = 0.38;
const band = addMesh(
new THREE.CylinderGeometry(0.289, 0.289, 0.27, 32, 1, true),
orange,
group
);
band.position.y = 0.39;
const bottomRing = addMesh(new THREE.TorusGeometry(0.265, 0.022, 8, 36), dark, group);
bottomRing.rotation.x = Math.PI / 2;
bottomRing.position.y = 0.02;
const topRing = addMesh(new THREE.TorusGeometry(0.265, 0.022, 8, 36), dark, group);
topRing.rotation.x = Math.PI / 2;
topRing.position.y = 0.75;
const lid = addMesh(new THREE.CylinderGeometry(0.25, 0.25, 0.018, 32), metal, group);
lid.position.y = 0.755;
const tab = addMesh(new THREE.TorusGeometry(0.075, 0.018, 8, 24), dark, group);
tab.rotation.x = Math.PI / 2;
tab.position.set(0.05, 0.775, 0);
return group;
}
function createPaperCup() {
const group = new THREE.Group();
const paper = standard(0xf3ead6, {
roughness: 0.92,
side: THREE.DoubleSide
});
const inside = standard(0xbfae91, { roughness: 1 });
const gold = standard(0xe4b65c, { roughness: 0.78 });
addMesh(
new THREE.CylinderGeometry(0.34, 0.22, 0.70, 32, 1, true),
paper,
group
).position.y = 0.36;
const opening = addMesh(new THREE.CircleGeometry(0.335, 32), inside, group);
opening.rotation.x = -Math.PI / 2;
opening.position.y = 0.705;
const rim = addMesh(new THREE.TorusGeometry(0.338, 0.024, 8, 40), paper, group);
rim.rotation.x = Math.PI / 2;
rim.position.y = 0.71;
const sleeve = addMesh(
new THREE.CylinderGeometry(0.286, 0.259, 0.27, 32, 1, true),
gold,
group
);
sleeve.position.y = 0.38;
const sleeveBand = addMesh(
new THREE.CylinderGeometry(0.288, 0.288, 0.035, 32, 1, true),
standard(0xf6df9e, { roughness: 0.8 }),
group
);
sleeveBand.position.y = 0.39;
return group;
}
const stationSpecs = [
{
key: "gloves",
index: "01",
title: "GLOVES",
subtitle: "Hand protection",
objectTitle: "Protective gloves",
accent: "#54c3a8",
x: -6.15,
create: createGloves
},
{
key: "grabber",
index: "02",
title: "GRABBER",
subtitle: "Reaching tool",
objectTitle: "Long-handled grabber",
accent: "#ef7b59",
x: -3.87,
create: createGrabber
},
{
key: "bags",
index: "03",
title: "BAGS",
subtitle: "Collection bags",
objectTitle: "Tied collection bags",
accent: "#536985",
x: -1.58,
create: createBags
},
{
key: "plastic",
index: "04",
title: "PLASTIC",
subtitle: "Plastic bottles",
objectTitle: "Plastic bottle",
accent: "#4b9be1",
x: 1.62,
create: createBottle
},
{
key: "metal",
index: "05",
title: "METAL",
subtitle: "Metal cans",
objectTitle: "Metal can",
accent: "#e88760",
x: 4.02,
create: createCan
},
{
key: "paper",
index: "06",
title: "PAPER",
subtitle: "Paper cups",
objectTitle: "Paper cup",
accent: "#e1b154",
x: 6.42,
create: createPaperCup
}
];
const itemRoots = [];
const signs = new Map();
const pedestalTopMaterial = standard(0xfaf8ef, { roughness: 0.9 });
for (const spec of stationSpecs) {
const pedestal = addMesh(
new THREE.CylinderGeometry(0.82, 0.87, 0.18, 48),
pedestalTopMaterial,
scene
);
pedestal.position.set(spec.x, 0.21, 0.38);
const accentMaterial = standard(spec.accent, { roughness: 0.67 });
const ring = addMesh(
new THREE.TorusGeometry(0.835, 0.035, 10, 64),
accentMaterial,
scene
);
ring.rotation.x = Math.PI / 2;
ring.position.set(spec.x, 0.305, 0.38);
const item = spec.create();
item.position.set(spec.x, 0.31, 0.42);
item.userData.category = spec.title;
item.userData.description = spec.objectTitle;
item.userData.key = spec.key;
scene.add(item);
itemRoots.push(item);
const sign = new THREE.Group();
sign.position.set(spec.x - 0.79, 0, -0.76);
const poleMaterial = standard(0x31594f, { roughness: 0.7 });
const pole = addMesh(
new THREE.CylinderGeometry(0.038, 0.048, 0.78, 14),
poleMaterial,
sign
);
pole.position.y = 0.63;
const foot = addMesh(
new THREE.CylinderGeometry(0.14, 0.16, 0.055, 24),
poleMaterial,
sign
);
foot.position.y = 0.16;
const backingMaterial = standard(0x173c35, { roughness: 0.64 });
const backing = addMesh(
new THREE.BoxGeometry(1.42, 0.73, 0.11),
backingMaterial,
sign
);
backing.position.y = 1.27;
const face = addMesh(
new THREE.PlaneGeometry(1.35, 0.67),
new THREE.MeshBasicMaterial({
map: makeSignTexture(
spec.index,
spec.title,
spec.subtitle,
spec.accent
),
toneMapped: false
}),
sign,
false,
false
);
face.position.set(0, 1.27, 0.061);
scene.add(sign);
signs.set(spec.key, { group: sign, backing });
}
// Direct camera controls, implemented without Three.js addons.
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let dragging = false;
let moved = false;
let lastX = 0;
let lastY = 0;
let activeKey = null;
function categoryFromObject(object) {
let currentObject = object;
while (currentObject) {
if (currentObject.userData.category) return currentObject;
currentObject = currentObject.parent;
}
return null;
}
function setPointer(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function pick(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(itemRoots, true);
for (const hit of hits) {
const category = categoryFromObject(hit.object);
if (category) return category;
}
return null;
}
function highlightCategory(key) {
activeKey = key;
for (const [signKey, sign] of signs) {
const accent = stationSpecs.find(s => s.key === signKey).accent;
sign.backing.material.emissive.set(accent);
sign.backing.material.emissiveIntensity = signKey === key ? 0.42 : 0;
}
}
renderer.domElement.addEventListener("pointerdown", event => {
dragging = true;
moved = false;
lastX = event.clientX;
lastY = event.clientY;
renderer.domElement.classList.add("dragging");
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", event => {
if (dragging) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(event.clientX - lastX) + Math.abs(event.clientY - lastY) > 1) {
moved = true;
}
lastX = event.clientX;
lastY = event.clientY;
desired.theta = THREE.MathUtils.clamp(
desired.theta - dx * 0.005,
-0.68,
0.68
);
desired.phi = THREE.MathUtils.clamp(
desired.phi - dy * 0.004,
0.12,
1.34
);
tooltip.style.display = "none";
return;
}
const category = pick(event);
if (category) {
tooltip.textContent = `${category.userData.description} · ${category.userData.category}`;
tooltip.style.left = `${event.clientX}px`;
tooltip.style.top = `${event.clientY}px`;
tooltip.style.display = "block";
renderer.domElement.style.cursor = "pointer";
} else {
tooltip.style.display = "none";
renderer.domElement.style.cursor = "grab";
}
});
function endPointer(event) {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (!moved) {
const category = pick(event);
if (category) {
highlightCategory(category.userData.key);
statusText.textContent =
`${category.userData.description} → ${category.userData.category}`;
}
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener("pointerleave", () => {
if (!dragging) tooltip.style.display = "none";
});
renderer.domElement.addEventListener(
"wheel",
event => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius + event.deltaY * 0.012,
8.5,
40
);
userZoomed = true;
},
{ passive: false }
);
document.getElementById("resetView").addEventListener("click", () => {
desired.theta = 0.08;
desired.phi = 1.02;
desired.radius = fitRadius();
userZoomed = false;
});
document.getElementById("topView").addEventListener("click", () => {
desired.theta = 0;
desired.phi = 0.10;
desired.radius = fitRadius();
userZoomed = false;
});
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
if (!userZoomed) {
desired.radius = fitRadius();
}
}
addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const smoothing = 1 - Math.exp(-dt * 8);
current.theta = THREE.MathUtils.lerp(current.theta, desired.theta, smoothing);
current.phi = THREE.MathUtils.lerp(current.phi, desired.phi, smoothing);
current.radius = THREE.MathUtils.lerp(current.radius, desired.radius, smoothing);
const sinPhi = Math.sin(current.phi);
camera.position.set(
target.x + current.radius * sinPhi * Math.sin(current.theta),
target.y + current.radius * Math.cos(current.phi),
target.z + current.radius * sinPhi * Math.cos(current.theta)
);
camera.lookAt(target);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
renderer.render(scene, camera);
document.getElementById("loading").style.display = "none";
animate();
</script>
</body>
</html>
```