Prompt specification
Build or customize the Three.js 3D scene "Stone workshop material selection scene" 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: Stone workshop material selection scene
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/stone-workshop-material-selection-scene-x1163
Scene Description Prompt:
Make one HTML file using Three.js from cdnjs for this voxel scene: Build a sculptor's bench with polishing, carving, and abrasion stations; show different material responses schematically and keep hardness, toughness, and surface finish labels separate.
Working Three.js Starter (stone-workshop-material-selection-scene-x1163):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Sculptor's Bench</title>
<style>
:root {
--bg: #111b1e;
--panel: rgba(19, 30, 33, 0.92);
--panel-light: rgba(35, 49, 51, 0.9);
--border: rgba(221, 236, 227, 0.16);
--text: #edf1e9;
--muted: #9baaa3;
--accent: #55d6c3;
--carving: #e5a862;
--polishing: #74c9ec;
--abrasion: #d47c70;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#viewport {
position: fixed;
inset: 0;
}
#viewport canvas {
display: block;
width: 100%;
height: 100%;
outline: none;
cursor: grab;
touch-action: none;
}
#viewport canvas.dragging {
cursor: grabbing;
}
.interface {
position: fixed;
inset: 0;
pointer-events: none;
}
.topbar {
position: absolute;
top: 22px;
left: 24px;
right: 24px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
}
.title-block {
max-width: 510px;
padding: 15px 17px;
border: 1px solid var(--border);
border-radius: 14px;
background: var(--panel);
box-shadow: 0 14px 50px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(21px, 2.6vw, 34px);
font-weight: 760;
letter-spacing: -0.035em;
line-height: 1.05;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.actions {
display: flex;
gap: 8px;
pointer-events: auto;
}
.control-button {
min-height: 38px;
padding: 0 13px;
border: 1px solid var(--border);
border-radius: 9px;
color: var(--text);
background: var(--panel);
cursor: pointer;
backdrop-filter: blur(12px);
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.control-button:hover {
border-color: rgba(85, 214, 195, 0.65);
background: var(--panel-light);
transform: translateY(-1px);
}
.control-button:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
#pins {
position: absolute;
inset: 0;
pointer-events: none;
}
.world-pin {
position: absolute;
left: 0;
top: 0;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px 7px 7px;
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
background: rgba(14, 23, 25, 0.88);
box-shadow: 0 7px 20px rgba(0, 0, 0, 0.24);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
white-space: nowrap;
pointer-events: auto;
cursor: pointer;
transform: translate(-50%, -100%);
transition:
border-color 160ms ease,
background 160ms ease;
}
.world-pin::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 19px;
background: linear-gradient(var(--pin-color), transparent);
}
.world-pin:hover,
.world-pin.active {
border-color: var(--pin-color);
background: rgba(29, 43, 44, 0.96);
}
.pin-number {
display: grid;
width: 24px;
height: 24px;
place-items: center;
border-radius: 5px;
color: #102022;
background: var(--pin-color);
font-size: 10px;
}
#cards {
position: absolute;
left: 24px;
right: 24px;
bottom: 24px;
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
pointer-events: auto;
}
.station-card {
position: relative;
overflow: hidden;
padding: 14px 15px 13px;
border: 1px solid var(--border);
border-radius: 13px;
background: var(--panel);
box-shadow: 0 15px 45px rgba(0, 0, 0, 0.25);
backdrop-filter: blur(13px);
cursor: pointer;
outline: none;
transition:
border-color 160ms ease,
transform 160ms ease,
background 160ms ease;
}
.station-card::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 3px;
background: var(--station-color);
opacity: 0.35;
}
.station-card:hover {
transform: translateY(-2px);
border-color: rgba(255, 255, 255, 0.28);
}
.station-card.active {
border-color: var(--station-color);
background: rgba(27, 40, 42, 0.96);
}
.station-card.active::before {
opacity: 1;
}
.station-card:focus-visible {
outline: 2px solid var(--station-color);
outline-offset: 3px;
}
.station-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 12px;
}
.station-name {
display: flex;
align-items: center;
gap: 9px;
}
.station-dot {
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--station-color);
box-shadow: 0 0 15px color-mix(in srgb, var(--station-color), transparent 45%);
}
.station-title {
font-size: 13px;
font-weight: 780;
letter-spacing: 0.02em;
}
.material-name {
color: var(--muted);
font-size: 10px;
}
.station-index {
color: var(--muted);
font-size: 10px;
font-variant-numeric: tabular-nums;
letter-spacing: 0.12em;
}
.metric {
display: grid;
grid-template-columns: 94px minmax(60px, 1fr) auto;
align-items: center;
gap: 10px;
min-height: 26px;
border-top: 1px solid rgba(255, 255, 255, 0.055);
}
.metric-label {
color: #b7c2bc;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.meter {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 3px;
}
.meter i {
height: 4px;
border-radius: 2px;
background: rgba(255, 255, 255, 0.09);
}
.meter i.on {
background: var(--station-color);
}
.metric-value {
min-width: 31px;
color: var(--text);
font-size: 10px;
font-weight: 700;
text-align: right;
font-variant-numeric: tabular-nums;
}
.finish-chip {
justify-self: end;
padding: 4px 7px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 5px;
color: var(--station-color);
background: rgba(255, 255, 255, 0.035);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend {
position: absolute;
left: 25px;
bottom: 244px;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 1px solid var(--border);
border-radius: 7px;
color: var(--muted);
background: rgba(15, 24, 26, 0.78);
font-size: 9px;
letter-spacing: 0.04em;
backdrop-filter: blur(9px);
}
.legend-mark {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--accent);
}
.controls-hint {
position: absolute;
top: 122px;
right: 25px;
padding: 7px 10px;
border: 1px solid var(--border);
border-radius: 7px;
color: var(--muted);
background: rgba(15, 24, 26, 0.72);
font-size: 9px;
letter-spacing: 0.04em;
backdrop-filter: blur(9px);
}
@media (max-width: 780px) {
.topbar {
top: 12px;
left: 12px;
right: 12px;
}
.title-block {
max-width: calc(100vw - 125px);
padding: 12px;
}
.subtitle {
display: none;
}
.actions {
flex-direction: column;
}
.control-button {
min-height: 32px;
padding: 0 9px;
font-size: 10px;
}
#cards {
left: 12px;
right: 12px;
bottom: 12px;
display: flex;
gap: 8px;
overflow-x: auto;
padding-bottom: 2px;
scroll-snap-type: x mandatory;
}
.station-card {
min-width: 275px;
scroll-snap-align: start;
}
.legend {
left: 13px;
bottom: 229px;
}
.controls-hint {
display: none;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div class="interface">
<header class="topbar">
<div class="title-block">
<div class="eyebrow">Material Response Study</div>
<h1>The Sculptor's Bench</h1>
<p class="subtitle">
Three voxel stations compare cutting, polishing, and abrasion.
Select a station to inspect its schematic material response.
</p>
</div>
<div class="actions">
<button class="control-button" id="orbitButton" type="button">
Pause orbit
</button>
<button class="control-button" id="resetButton" type="button">
Reset view
</button>
</div>
</header>
<div id="pins">
<button class="world-pin" data-station="carving" type="button">
<span class="pin-number">01</span>
Carving
</button>
<button class="world-pin" data-station="polishing" type="button">
<span class="pin-number">02</span>
Polishing
</button>
<button class="world-pin" data-station="abrasion" type="button">
<span class="pin-number">03</span>
Abrasion
</button>
</div>
<div class="controls-hint">
DRAG TO ORBIT · SCROLL TO ZOOM · CLICK A STATION
</div>
<div class="legend">
<span class="legend-mark"></span>
Schematic values, not measured engineering data
</div>
<section id="cards" aria-label="Material response comparisons">
<article
class="station-card active"
data-station="carving"
tabindex="0"
role="button"
aria-pressed="true"
style="--station-color: var(--carving)"
>
<div class="station-heading">
<div class="station-name">
<span class="station-dot"></span>
<div>
<div class="station-title">Carving</div>
<div class="material-name">Soft soapstone</div>
</div>
</div>
<span class="station-index">01</span>
</div>
<div class="metric">
<span class="metric-label">Hardness</span>
<span class="meter" aria-label="Hardness 2 out of 5">
<i class="on"></i><i class="on"></i><i></i><i></i><i></i>
</span>
<span class="metric-value">2 / 5</span>
</div>
<div class="metric">
<span class="metric-label">Toughness</span>
<span class="meter" aria-label="Toughness 3 out of 5">
<i class="on"></i><i class="on"></i><i class="on"></i><i></i><i></i>
</span>
<span class="metric-value">3 / 5</span>
</div>
<div class="metric">
<span class="metric-label">Surface finish</span>
<span></span>
<span class="finish-chip">Rough cut</span>
</div>
</article>
<article
class="station-card"
data-station="polishing"
tabindex="0"
role="button"
aria-pressed="false"
style="--station-color: var(--polishing)"
>
<div class="station-heading">
<div class="station-name">
<span class="station-dot"></span>
<div>
<div class="station-title">Polishing</div>
<div class="material-name">Fine marble</div>
</div>
</div>
<span class="station-index">02</span>
</div>
<div class="metric">
<span class="metric-label">Hardness</span>
<span class="meter" aria-label="Hardness 4 out of 5">
<i class="on"></i><i class="on"></i><i class="on"></i><i class="on"></i><i></i>
</span>
<span class="metric-value">4 / 5</span>
</div>
<div class="metric">
<span class="metric-label">Toughness</span>
<span class="meter" aria-label="Toughness 2 out of 5">
<i class="on"></i><i class="on"></i><i></i><i></i><i></i>
</span>
<span class="metric-value">2 / 5</span>
</div>
<div class="metric">
<span class="metric-label">Surface finish</span>
<span></span>
<span class="finish-chip">Polished</span>
</div>
</article>
<article
class="station-card"
data-station="abrasion"
tabindex="0"
role="button"
aria-pressed="false"
style="--station-color: var(--abrasion)"
>
<div class="station-heading">
<div class="station-name">
<span class="station-dot"></span>
<div>
<div class="station-title">Abrasion</div>
<div class="material-name">Dense basalt</div>
</div>
</div>
<span class="station-index">03</span>
</div>
<div class="metric">
<span class="metric-label">Hardness</span>
<span class="meter" aria-label="Hardness 5 out of 5">
<i class="on"></i><i class="on"></i><i class="on"></i><i class="on"></i><i class="on"></i>
</span>
<span class="metric-value">5 / 5</span>
</div>
<div class="metric">
<span class="metric-label">Toughness</span>
<span class="meter" aria-label="Toughness 4 out of 5">
<i class="on"></i><i class="on"></i><i class="on"></i><i class="on"></i><i></i>
</span>
<span class="metric-value">4 / 5</span>
</div>
<div class="metric">
<span class="metric-label">Surface finish</span>
<span></span>
<span class="finish-chip">Satin</span>
</div>
</article>
</section>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const viewport = document.getElementById("viewport");
const cards = [...document.querySelectorAll(".station-card")];
const pins = [...document.querySelectorAll(".world-pin")];
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x111b1e);
scene.fog = new THREE.Fog(0x111b1e, 18, 36);
const camera = new THREE.PerspectiveCamera(
40,
innerWidth / innerHeight,
0.1,
70
);
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.12;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute(
"aria-label",
"Interactive voxel sculptor's bench. Drag to orbit and scroll to zoom."
);
viewport.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xd8efff, 0x4b3021, 1.65);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff0d5, 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 = 9;
keyLight.shadow.camera.bottom = -6;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x77d9e8, 1.25);
rimLight.position.set(8, 6, -6);
scene.add(rimLight);
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0x1d2a2c,
roughness: 0.94,
metalness: 0.02
}),
floorInset: new THREE.MeshStandardMaterial({
color: 0x263638,
roughness: 0.92
}),
wall: new THREE.MeshStandardMaterial({
color: 0x243538,
roughness: 0.88
}),
wallDark: new THREE.MeshStandardMaterial({
color: 0x10191b,
roughness: 0.95
}),
wood: new THREE.MeshStandardMaterial({
color: 0x9a5a35,
roughness: 0.82,
flatShading: true
}),
woodLight: new THREE.MeshStandardMaterial({
color: 0xc17b49,
roughness: 0.78,
flatShading: true
}),
woodDark: new THREE.MeshStandardMaterial({
color: 0x603923,
roughness: 0.88,
flatShading: true
}),
stone: new THREE.MeshStandardMaterial({
color: 0x97a28f,
roughness: 0.98,
flatShading: true
}),
stoneLight: new THREE.MeshStandardMaterial({
color: 0xb0b7a4,
roughness: 0.94,
flatShading: true
}),
marble: new THREE.MeshStandardMaterial({
color: 0xf2eee4,
roughness: 0.12,
metalness: 0.08,
flatShading: true
}),
marbleShade: new THREE.MeshStandardMaterial({
color: 0xc9d1cd,
roughness: 0.19,
metalness: 0.05,
flatShading: true
}),
basalt: new THREE.MeshStandardMaterial({
color: 0x68716f,
roughness: 0.78,
flatShading: true
}),
basaltLight: new THREE.MeshStandardMaterial({
color: 0x89918c,
roughness: 0.72,
flatShading: true
}),
metal: new THREE.MeshStandardMaterial({
color: 0x53656a,
roughness: 0.34,
metalness: 0.72,
flatShading: true
}),
steel: new THREE.MeshStandardMaterial({
color: 0xaeb8b4,
roughness: 0.26,
metalness: 0.82,
flatShading: true
}),
darkMetal: new THREE.MeshStandardMaterial({
color: 0x263438,
roughness: 0.48,
metalness: 0.58,
flatShading: true
}),
rubber: new THREE.MeshStandardMaterial({
color: 0x202729,
roughness: 0.93
}),
brass: new THREE.MeshStandardMaterial({
color: 0xd6a45a,
roughness: 0.31,
metalness: 0.7,
flatShading: true
}),
buff: new THREE.MeshStandardMaterial({
color: 0xd8c58d,
roughness: 0.86,
flatShading: true
}),
teal: new THREE.MeshStandardMaterial({
color: 0x3fc9b6,
emissive: 0x12473e,
emissiveIntensity: 0.4,
roughness: 0.55,
flatShading: true
}),
lamp: new THREE.MeshStandardMaterial({
color: 0xffe0a0,
emissive: 0xffb94f,
emissiveIntensity: 2.1,
roughness: 0.4
})
};
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x172124,
transparent: true,
opacity: 0.46
});
function addBox(parent, size, position, material, outline = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
if (outline) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry),
edgeMaterial
);
mesh.add(edges);
}
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radius,
height,
position,
material,
radialSegments = 12
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, height, radialSegments),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addXCylinder(
parent,
radius,
length,
position,
material,
radialSegments = 12
) {
const pivot = new THREE.Group();
pivot.position.set(position[0], position[1], position[2]);
pivot.rotation.z = Math.PI / 2;
parent.add(pivot);
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, radialSegments),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
pivot.add(mesh);
return { pivot, mesh };
}
// Voxel diorama base.
addBox(scene, [15.5, 0.5, 8.3], [0, -0.42, 0], materials.floor);
addBox(scene, [15.05, 0.18, 7.85], [0, -0.1, 0], materials.floorInset);
for (let x = -7; x <= 7; x += 1) {
addBox(
scene,
[0.018, 0.012, 7.5],
[x, 0.002, 0],
materials.wallDark,
false
);
}
for (let z = -3; z <= 3; z += 1) {
addBox(
scene,
[14.8, 0.012, 0.018],
[0, 0.002, z],
materials.wallDark,
false
);
}
// Workshop back wall and pegboard.
addBox(scene, [14.8, 5.7, 0.28], [0, 2.45, -3.7], materials.wall);
addBox(scene, [12.8, 4.3, 0.12], [0, 2.55, -3.5], materials.woodDark);
for (let row = 0; row < 7; row++) {
for (let col = 0; col < 15; col++) {
addBox(
scene,
[0.09, 0.09, 0.045],
[-5.6 + col * 0.8, 0.95 + row * 0.5, -3.415],
materials.wallDark,
false
);
}
}
// Shelf.
addBox(scene, [11.6, 0.22, 0.72], [0, 4.43, -3.12], materials.wood);
addBox(scene, [11.4, 0.12, 0.58], [0, 4.28, -3.12], materials.woodDark);
// Hanging workshop tools.
addBox(scene, [0.16, 1.45, 0.12], [-4.8, 3.32, -3.25], materials.woodLight);
addBox(scene, [0.65, 0.2, 0.2], [-4.8, 4.02, -3.25], materials.woodLight);
addBox(scene, [1.1, 0.12, 0.1], [-3.25, 3.55, -3.25], materials.steel);
addBox(scene, [0.28, 0.42, 0.18], [-3.72, 3.55, -3.25], materials.wood);
addBox(scene, [0.16, 1.1, 0.12], [3.9, 3.25, -3.25], materials.steel);
addBox(scene, [0.56, 0.25, 0.18], [3.9, 3.8, -3.25], materials.rubber);
// Main workbench.
const bench = new THREE.Group();
scene.add(bench);
addBox(bench, [11.5, 0.46, 2.7], [0, 1.72, 0], materials.wood);
addBox(bench, [11.65, 0.12, 2.84], [0, 1.43, 0], materials.woodDark);
addBox(bench, [11.2, 0.1, 2.45], [0, 1.985, 0], materials.woodLight);
for (const x of [-4.85, -2.45, 0, 2.45, 4.85]) {
addBox(bench, [0.38, 1.55, 0.42], [x, 0.62, 0], materials.woodDark);
addBox(bench, [0.62, 0.14, 0.62], [x, -0.08, 0], materials.wallDark);
}
addBox(bench, [9.9, 0.22, 0.25], [0, 0.42, -0.9], materials.woodDark);
addBox(bench, [9.9, 0.22, 0.25], [0, 0.42, 0.9], materials.woodDark);
for (const x of [-3.65, 0, 3.65]) {
addBox(bench, [2.7, 0.64, 0.12], [x, 1.03, 1.37], materials.woodDark);
addBox(bench, [0.62, 0.09, 0.13], [x, 1.04, 1.48], materials.brass);
}
// Three overhead block lamps.
for (const x of [-3.45, 0, 3.45]) {
addBox(scene, [0.045, 1.3, 0.045], [x, 5.2, 0.45], materials.darkMetal, false);
addBox(scene, [0.9, 0.22, 0.72], [x, 4.55, 0.45], materials.darkMetal);
addBox(scene, [0.67, 0.055, 0.5], [x, 4.42, 0.45], materials.lamp);
const light = new THREE.PointLight(0xffd19a, 10, 7, 2);
light.position.set(x, 4.2, 0.45);
scene.add(light);
}
const stations = {};
function createStation(id, x, anchorHeight, color) {
const group = new THREE.Group();
group.position.x = x;
group.userData.stationId = id;
group.userData.anchorLocal = new THREE.Vector3(0, anchorHeight, 0);
scene.add(group);
const padMaterial = materials.teal.clone();
padMaterial.color.setHex(color);
padMaterial.emissive.setHex(color);
padMaterial.emissiveIntensity = 0.06;
const pad = addBox(
group,
[3.08, 0.045, 2.28],
[0, 2.055, 0],
padMaterial,
false
);
pad.userData.baseColor = color;
stations[id] = { group, pad };
return group;
}
// 01 — Carving station.
const carving = createStation("carving", -3.45, 4.05, 0xe5a862);
addBox(carving, [1.35, 0.17, 1.2], [-0.48, 2.16, 0.08], materials.woodDark);
const roughSculpture = new THREE.Group();
roughSculpture.position.set(-0.48, 2.23, 0.08);
carving.add(roughSculpture);
addBox(roughSculpture, [0.82, 0.64, 0.74], [0, 0.34, 0], materials.stone);
addBox(roughSculpture, [0.61, 0.27, 0.57], [-0.03, 0.78, -0.01], materials.stoneLight);
addBox(roughSculpture, [0.29, 0.25, 0.46], [0.29, 0.46, 0.04], materials.stoneLight);
addBox(roughSculpture, [0.19, 0.19, 0.15], [0.28, 0.56, 0.32], materials.stone);
// Chisel.
const chisel = new THREE.Group();
chisel.position.set(-1.1, 2.32, 0.55);
chisel.rotation.set(0.12, -0.35, 0.2);
carving.add(chisel);
addBox(chisel, [0.22, 0.22, 0.78], [0, 0, 0.38], materials.woodLight);
addBox(chisel, [0.12, 0.12, 1.12], [0, 0, -0.58], materials.steel);
addBox(chisel, [0.16, 0.1, 0.3], [0, 0, -1.18], materials.steel);
// Mallet.
const mallet = new THREE.Group();
mallet.position.set(1.02, 2.25, 0.5);
mallet.rotation.y = -0.4;
carving.add(mallet);
addBox(mallet, [1.18, 0.19, 0.2], [0, 0, 0], materials.woodLight);
addBox(mallet, [0.48, 0.55, 0.55], [0.62, 0.05, 0], materials.woodDark);
// Visible chips illustrate a softer carving response.
const chipPositions = [
[-1.1, 2.13, 0.85, 0.2],
[-0.15, 2.13, 0.93, 0.15],
[0.45, 2.13, -0.55, 0.18],
[-0.9, 2.13, -0.74, 0.13]
];
for (const [x, y, z, s] of chipPositions) {
const chip = addBox(
carving,
[s, s * 0.45, s * 0.8],
[x, y, z],
materials.stoneLight
);
chip.rotation.y = x * 2.7;
}
// 02 — Polishing station.
const polishing = createStation("polishing", 0, 4.38, 0x74c9ec);
const turntable = addCylinder(
polishing,
0.77,
0.19,
[-0.48, 2.16, 0.02],
materials.darkMetal,
16
);
const sculpture = new THREE.Group();
sculpture.position.set(-0.48, 2.25, 0.02);
polishing.add(sculpture);
addBox(sculpture, [0.72, 0.32, 0.7], [0, 0.16, 0], materials.marble);
addBox(sculpture, [0.58, 0.72, 0.52], [0, 0.66, 0], materials.marble);
addBox(sculpture, [0.52, 0.52, 0.5], [0, 1.25, 0], materials.marbleShade);
addBox(sculpture, [0.16, 0.17, 0.17], [0, 1.23, 0.31], materials.marble);
addBox(sculpture, [0.2, 0.63, 0.21], [-0.4, 0.66, 0], materials.marble);
addBox(sculpture, [0.2, 0.63, 0.21], [0.4, 0.66, 0], materials.marble);
// Polisher support and motor.
addBox(polishing, [0.26, 0.8, 0.3], [1.04, 2.5, -0.46], materials.darkMetal);
addBox(polishing, [0.78, 0.55, 0.68], [1.18, 2.57, -0.12], materials.metal);
addBox(polishing, [0.35, 0.25, 0.5], [1.13, 3.0, -0.12], materials.rubber);
const buffWheel = addXCylinder(
polishing,
0.48,
0.25,
[0.75, 2.64, 0.34],
materials.buff,
12
);
const buffHub = new THREE.Mesh(
new THREE.CylinderGeometry(0.14, 0.14, 0.29, 12),
materials.brass
);
buffWheel.mesh.add(buffHub);
// Moving glints make the polished response visually distinct.
const glintMaterial = new THREE.MeshBasicMaterial({
color: 0xd9ffff,
transparent: true,
opacity: 0.9
});
const glints = [];
for (let i = 0; i < 12; i++) {
const glint = new THREE.Mesh(
new THREE.BoxGeometry(0.055, 0.055, 0.055),
glintMaterial
);
polishing.add(glint);
glints.push({
mesh: glint,
phase: (i / 12) * Math.PI * 2,
radius: 0.51 + (i % 3) * 0.035
});
}
// 03 — Abrasion station.
const abrasion = createStation("abrasion", 3.45, 4.08, 0xd47c70);
addBox(abrasion, [1.2, 0.17, 1.12], [-0.72, 2.16, 0], materials.woodDark);
const abradedBlock = new THREE.Group();
abradedBlock.position.set(-0.72, 2.23, 0);
abrasion.add(abradedBlock);
addBox(abradedBlock, [0.95, 0.68, 0.9], [0, 0.35, 0], materials.basalt);
addBox(abradedBlock, [0.76, 0.2, 0.7], [0.02, 0.77, -0.02], materials.basaltLight);
// Fine incised lines schematically indicate a worked surface.
for (let i = 0; i < 5; i++) {
addBox(
abradedBlock,
[0.72 - i * 0.045, 0.018, 0.018],
[-0.04, 0.19 + i * 0.12, 0.456],
materials.wallDark,
false
);
}
for (let i = 0; i < 4; i++) {
addBox(
abradedBlock,
[0.018, 0.4, 0.018],
[-0.25 + i * 0.17, 0.41, 0.458],
materials.wallDark,
false
);
}
// Belt sander.
addBox(abrasion, [0.83, 0.35, 0.72], [0.93, 2.31, -0.05], materials.metal);
addBox(abrasion, [0.31, 0.7, 0.36], [1.27, 2.75, -0.05], materials.darkMetal);
addBox(abrasion, [0.28, 0.3, 0.84], [1.27, 3.22, -0.05], materials.rubber);
const beltWheels = [
addXCylinder(abrasion, 0.3, 0.28, [0.77, 2.78, 0.43], materials.metal),
addXCylinder(abrasion, 0.3, 0.28, [0.77, 2.78, -0.43], materials.metal)
];
addBox(abrasion, [0.3, 0.055, 1.13], [0.77, 3.08, 0], materials.rubber);
addBox(abrasion, [0.3, 0.055, 1.13], [0.77, 2.48, 0], materials.rubber);
// Small dust voxels around the abrasive station.
const dust = [];
const dustMaterial = new THREE.MeshBasicMaterial({
color: 0xd2b28b,
transparent: true,
opacity: 0.42
});
for (let i = 0; i < 14; i++) {
const particle = new THREE.Mesh(
new THREE.BoxGeometry(0.045, 0.045, 0.045),
dustMaterial
);
abrasion.add(particle);
dust.push({
mesh: particle,
phase: i * 1.73,
radius: 0.25 + (i % 5) * 0.11,
height: 2.45 + (i % 4) * 0.13
});
}
// Decorative storage blocks under the bench.
addBox(scene, [1.15, 0.62, 0.82], [-3.65, 0.48, 0.1], materials.woodDark);
addBox(scene, [0.83, 0.4, 0.66], [-3.65, 0.93, 0.1], materials.stone);
addBox(scene, [1.3, 0.48, 0.82], [0, 0.42, -0.16], materials.woodDark);
addBox(scene, [1.06, 0.5, 0.74], [3.65, 0.44, 0.04], materials.woodDark);
// Custom camera controls.
const cameraState = {
azimuth: 0.72,
polar: 1.08,
radius: 15.2,
target: new THREE.Vector3(0, 1.9, 0),
autoOrbit: true
};
const defaultCamera = {
azimuth: 0.72,
polar: 1.08,
radius: 15.2
};
function updateCamera() {
const sinPolar = Math.sin(cameraState.polar);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPolar * Math.sin(cameraState.azimuth),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.polar),
cameraState.target.z +
cameraState.radius * sinPolar * Math.cos(cameraState.azimuth)
);
camera.lookAt(cameraState.target);
}
updateCamera();
const pointers = new Map();
let pinchDistance = 0;
let pointerTravel = 0;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
pointerTravel = 0;
canvas.classList.add("dragging");
if (pointers.size === 2) {
const points = [...pointers.values()];
pinchDistance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
}
});
canvas.addEventListener("pointermove", (event) => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
pointerTravel += Math.abs(dx) + Math.abs(dy);
if (pointers.size === 1) {
cameraState.azimuth -= dx * 0.006;
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar - dy * 0.005,
0.38,
1.38
);
} else if (pointers.size === 2) {
const points = [...pointers.values()];
const distance = Math.hypot(
points[0].x - points[1].x,
points[0].y - points[1].y
);
if (pinchDistance > 0) {
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius * (pinchDistance / Math.max(distance, 1)),
8.5,
23
);
}
pinchDistance = distance;
}
});
function releasePointer(event) {
pointers.delete(event.pointerId);
pinchDistance = 0;
if (pointers.size === 0) canvas.classList.remove("dragging");
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
8.5,
23
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener("keydown", (event) => {
const step = 0.08;
if (event.key === "ArrowLeft") cameraState.azimuth += step;
else if (event.key === "ArrowRight") cameraState.azimuth -= step;
else if (event.key === "ArrowUp") {
cameraState.polar = Math.max(0.38, cameraState.polar - step);
} else if (event.key === "ArrowDown") {
cameraState.polar = Math.min(1.38, cameraState.polar + step);
} else if (event.key === "+" || event.key === "=") {
cameraState.radius = Math.max(8.5, cameraState.radius - 0.5);
} else if (event.key === "-" || event.key === "_") {
cameraState.radius = Math.min(23, cameraState.radius + 0.5);
} else if (event.key.toLowerCase() === "r") {
resetCamera();
} else {
return;
}
event.preventDefault();
});
function resetCamera() {
cameraState.azimuth = defaultCamera.azimuth;
cameraState.polar = defaultCamera.polar;
cameraState.radius = defaultCamera.radius;
cameraState.target.set(0, 1.9, 0);
}
document.getElementById("resetButton").addEventListener("click", resetCamera);
const orbitButton = document.getElementById("orbitButton");
orbitButton.addEventListener("click", () => {
cameraState.autoOrbit = !cameraState.autoOrbit;
orbitButton.textContent = cameraState.autoOrbit
? "Pause orbit"
: "Auto orbit";
});
// Station selection.
let selectedStation = "carving";
function selectStation(id) {
if (!stations[id]) return;
selectedStation = id;
for (const card of cards) {
const active = card.dataset.station === id;
card.classList.toggle("active", active);
card.setAttribute("aria-pressed", String(active));
}
for (const pin of pins) {
pin.classList.toggle("active", pin.dataset.station === id);
}
for (const [stationId, station] of Object.entries(stations)) {
const active = stationId === id;
station.pad.material.emissiveIntensity = active ? 0.52 : 0.06;
station.pad.material.color.setHex(
active ? station.pad.userData.baseColor : 0x2b3b3c
);
}
}
for (const card of cards) {
card.addEventListener("click", () => selectStation(card.dataset.station));
card.addEventListener("keydown", (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
selectStation(card.dataset.station);
}
});
}
for (const pin of pins) {
pin.addEventListener("click", () => selectStation(pin.dataset.station));
}
// Raycast station geometry.
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let downPoint = null;
canvas.addEventListener("pointerdown", (event) => {
downPoint = { x: event.clientX, y: event.clientY };
});
canvas.addEventListener("pointerup", (event) => {
if (!downPoint) return;
const moved = Math.hypot(
event.clientX - downPoint.x,
event.clientY - downPoint.y
);
downPoint = null;
if (moved > 6) return;
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(scene.children, true);
for (const hit of intersections) {
let object = hit.object;
while (object) {
if (object.userData.stationId) {
selectStation(object.userData.stationId);
break;
}
object = object.parent;
}
if (object) break;
}
});
selectStation(selectedStation);
// Project station labels into screen space without external renderers.
const projected = new THREE.Vector3();
function updatePins() {
for (const pin of pins) {
const id = pin.dataset.station;
const station = stations[id];
projected
.copy(station.group.userData.anchorLocal)
.add(station.group.position)
.project(camera);
const visible = projected.z > -1 && projected.z < 1;
pin.style.display = visible ? "flex" : "none";
if (visible) {
const x = (projected.x * 0.5 + 0.5) * innerWidth;
const y = (-projected.y * 0.5 + 0.5) * innerHeight;
pin.style.left = `${x}px`;
pin.style.top = `${y}px`;
}
}
}
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (cameraState.autoOrbit) {
cameraState.azimuth += delta * 0.075;
}
updateCamera();
turntable.rotation.y += delta * 0.28;
sculpture.rotation.y = Math.sin(elapsed * 0.32) * 0.08;
buffWheel.mesh.rotation.y += delta * 5.6;
for (const wheel of beltWheels) {
wheel.mesh.rotation.y -= delta * 4.2;
}
for (const glint of glints) {
const angle = elapsed * 2.5 + glint.phase;
glint.mesh.position.set(
0.77 + Math.sin(elapsed + glint.phase) * 0.05,
2.64 + Math.sin(angle) * glint.radius,
0.34 + Math.cos(angle) * glint.radius
);
glint.mesh.rotation.set(angle, angle * 0.5, 0);
glint.mesh.material.opacity = 0.9;
}
for (const particle of dust) {
const angle = elapsed * 0.8 + particle.phase;
particle.mesh.position.set(
0.22 + Math.cos(angle) * particle.radius,
particle.height + Math.sin(elapsed * 1.3 + particle.phase) * 0.08,
0.45 + Math.sin(angle) * particle.radius
);
particle.mesh.rotation.set(angle, angle * 0.7, 0);
}
updatePins();
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```