Prompt specification
Build or customize the Three.js 3D scene "Delicate object holding puzzle" 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: Delicate object holding puzzle
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/delicate-object-holding-puzzle-x0256
Scene Description Prompt:
Choose padded clamp jaws for low-poly restoration objects, securing each without covering its marked working area. Create standalone HTML using Three.js from cdnjs.
Working Three.js Starter (delicate-object-holding-puzzle-x0256):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Padded Clamp Fit — Conservation Lab</title>
<style>
:root {
--ink: #23302e;
--muted: #6f7a76;
--paper: #f5f3ed;
--line: #d9ddd6;
--teal: #4f9387;
--teal-dark: #27675f;
--amber: #d99532;
--amber-soft: #f5dfb9;
--panel: #fbfaf6;
--shadow: 0 18px 50px rgba(45, 56, 52, 0.11);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
color: var(--ink);
background: #e8e7df;
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
select,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
display: grid;
grid-template-rows: 68px minmax(0, 1fr);
height: 100dvh;
}
.topbar {
z-index: 10;
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 0 24px;
border-bottom: 1px solid rgba(64, 78, 73, 0.13);
background: rgba(250, 249, 244, 0.94);
backdrop-filter: blur(18px);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-mark {
position: relative;
width: 34px;
height: 34px;
flex: 0 0 auto;
border: 2px solid var(--teal-dark);
border-radius: 10px;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
top: 7px;
width: 7px;
height: 16px;
border-radius: 4px;
background: var(--teal);
}
.brand-mark::before {
left: 6px;
}
.brand-mark::after {
right: 6px;
}
.eyebrow {
margin: 0 0 2px;
color: var(--teal-dark);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 18px;
font-weight: 680;
letter-spacing: -0.02em;
}
.top-status {
display: flex;
align-items: center;
gap: 9px;
padding: 9px 13px;
border: 1px solid #ccd9d2;
border-radius: 999px;
color: #365b51;
background: #eef5f0;
font-size: 12px;
font-weight: 700;
white-space: nowrap;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #58a16e;
box-shadow: 0 0 0 4px rgba(88, 161, 110, 0.13);
}
.workspace {
display: grid;
grid-template-columns: minmax(0, 1fr) 348px;
min-height: 0;
}
.viewport {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background:
radial-gradient(circle at 50% 35%, #f4f2ea 0, #e7e6df 72%);
}
.viewport canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.view-header {
position: absolute;
z-index: 3;
top: 22px;
left: 24px;
pointer-events: none;
}
.view-title {
margin: 0 0 7px;
font-size: 13px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.view-subtitle {
margin: 0;
color: var(--muted);
font-size: 12px;
}
.legend {
position: absolute;
z-index: 3;
left: 24px;
bottom: 23px;
display: flex;
flex-wrap: wrap;
gap: 8px 15px;
max-width: calc(100% - 170px);
padding: 10px 13px;
border: 1px solid rgba(76, 88, 83, 0.13);
border-radius: 12px;
background: rgba(250, 249, 245, 0.83);
backdrop-filter: blur(12px);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
color: #5d6965;
font-size: 11px;
font-weight: 650;
}
.legend-swatch {
width: 10px;
height: 10px;
border-radius: 3px;
}
.legend-swatch.work {
border: 2px solid var(--amber);
background: rgba(217, 149, 50, 0.18);
}
.legend-swatch.pad {
background: var(--teal);
}
.legend-swatch.frame {
background: #424a48;
}
.view-tools {
position: absolute;
z-index: 4;
right: 20px;
bottom: 20px;
display: flex;
gap: 7px;
}
.icon-button {
display: grid;
width: 38px;
height: 38px;
place-items: center;
padding: 0;
border: 1px solid rgba(76, 88, 83, 0.18);
border-radius: 11px;
background: rgba(251, 250, 246, 0.9);
box-shadow: 0 6px 18px rgba(50, 60, 57, 0.08);
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease;
}
.icon-button:hover {
transform: translateY(-2px);
background: #fff;
}
.icon-button svg {
width: 17px;
height: 17px;
fill: none;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.8;
}
.labels {
position: absolute;
z-index: 2;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.world-label {
position: absolute;
display: flex;
align-items: center;
gap: 8px;
padding: 7px 10px;
border: 1px solid rgba(75, 89, 84, 0.16);
border-radius: 10px;
background: rgba(250, 249, 245, 0.9);
box-shadow: 0 8px 22px rgba(50, 61, 57, 0.08);
transform: translate(-50%, -50%);
pointer-events: auto;
cursor: pointer;
transition:
border-color 160ms ease,
background 160ms ease;
}
.world-label.active {
border-color: rgba(39, 103, 95, 0.58);
background: #f8fbf8;
}
.world-label .number {
display: grid;
width: 23px;
height: 23px;
place-items: center;
border-radius: 7px;
color: #fff;
background: #68736f;
font-size: 10px;
font-weight: 800;
}
.world-label.active .number {
background: var(--teal-dark);
}
.world-label strong {
display: block;
font-size: 11px;
line-height: 1.15;
white-space: nowrap;
}
.world-label small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
white-space: nowrap;
}
.zone-label {
position: absolute;
display: flex;
align-items: center;
gap: 5px;
padding: 4px 7px;
border: 1px solid rgba(190, 127, 31, 0.28);
border-radius: 7px;
color: #8a5d1c;
background: rgba(255, 247, 226, 0.9);
font-size: 8px;
font-weight: 850;
letter-spacing: 0.12em;
transform: translate(10px, -50%);
pointer-events: none;
}
.zone-label::before {
content: "";
width: 5px;
height: 5px;
border-radius: 50%;
background: var(--amber);
}
.panel {
z-index: 5;
min-height: 0;
overflow-y: auto;
padding: 23px 22px 28px;
border-left: 1px solid rgba(64, 78, 73, 0.13);
background: var(--panel);
box-shadow: -14px 0 40px rgba(56, 64, 61, 0.04);
}
.panel h2 {
margin: 0;
font-size: 21px;
font-weight: 720;
letter-spacing: -0.035em;
}
.panel-intro {
margin: 7px 0 22px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.section {
padding: 18px 0;
border-top: 1px solid var(--line);
}
.section:first-of-type {
border-top: 0;
}
.section-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 11px;
}
.section-heading h3 {
margin: 0;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.section-heading span {
color: var(--muted);
font-size: 10px;
}
.object-list {
display: grid;
gap: 7px;
}
.object-option {
display: grid;
grid-template-columns: 30px minmax(0, 1fr) 18px;
align-items: center;
gap: 10px;
width: 100%;
padding: 10px;
border: 1px solid transparent;
border-radius: 11px;
background: #f1f1eb;
text-align: left;
cursor: pointer;
transition:
border-color 150ms ease,
background 150ms ease,
transform 150ms ease;
}
.object-option:hover {
transform: translateX(2px);
background: #eeeee7;
}
.object-option.active {
border-color: #a9c9c0;
background: #edf5f1;
}
.object-index {
display: grid;
width: 29px;
height: 29px;
place-items: center;
border-radius: 9px;
color: #fff;
background: #697370;
font-size: 10px;
font-weight: 850;
}
.object-option.active .object-index {
background: var(--teal-dark);
}
.object-copy {
min-width: 0;
}
.object-copy strong {
display: block;
overflow: hidden;
font-size: 12px;
font-weight: 750;
text-overflow: ellipsis;
white-space: nowrap;
}
.object-copy small {
display: block;
margin-top: 3px;
overflow: hidden;
color: var(--muted);
font-size: 9px;
text-overflow: ellipsis;
white-space: nowrap;
}
.check {
color: var(--teal-dark);
font-size: 15px;
opacity: 0;
}
.object-option.active .check {
opacity: 1;
}
.profile-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.profile-button {
min-width: 0;
padding: 11px 5px 9px;
border: 1px solid var(--line);
border-radius: 10px;
background: #fff;
cursor: pointer;
transition:
border-color 150ms ease,
background 150ms ease,
transform 150ms ease;
}
.profile-button:hover {
transform: translateY(-1px);
border-color: #aab9b3;
}
.profile-button.active {
border-color: var(--teal);
background: #eaf4f0;
box-shadow: inset 0 0 0 1px rgba(79, 147, 135, 0.15);
}
.profile-icon {
position: relative;
display: block;
width: 31px;
height: 17px;
margin: 0 auto 7px;
}
.profile-icon::before,
.profile-icon::after {
content: "";
position: absolute;
top: 1px;
width: 11px;
height: 15px;
border-radius: 5px;
background: #63706c;
}
.profile-icon::before {
left: 1px;
}
.profile-icon::after {
right: 1px;
}
.profile-button:nth-child(1) .profile-icon::before,
.profile-button:nth-child(1) .profile-icon::after {
width: 8px;
}
.profile-button:nth-child(3) .profile-icon::before,
.profile-button:nth-child(3) .profile-icon::after {
width: 14px;
}
.profile-button.active .profile-icon::before,
.profile-button.active .profile-icon::after {
background: var(--teal-dark);
}
.profile-button strong {
display: block;
font-size: 10px;
font-weight: 800;
}
.profile-button small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 8px;
}
.field {
display: grid;
gap: 7px;
margin-top: 14px;
}
.field label {
color: var(--muted);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
}
select {
width: 100%;
height: 40px;
padding: 0 34px 0 11px;
border: 1px solid var(--line);
border-radius: 10px;
color: var(--ink);
background: #fff;
cursor: pointer;
}
.metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.metric {
padding: 11px;
border: 1px solid var(--line);
border-radius: 11px;
background: #fff;
}
.metric span {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.metric strong {
font-size: 15px;
font-weight: 760;
}
.metric strong.safe {
color: var(--teal-dark);
}
.metric strong.work {
color: #a66a16;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 12px;
color: #4e5a56;
font-size: 11px;
font-weight: 650;
}
.switch {
position: relative;
width: 38px;
height: 22px;
flex: 0 0 auto;
}
.switch input {
position: absolute;
opacity: 0;
}
.switch-track {
position: absolute;
inset: 0;
border-radius: 999px;
background: #c9ceca;
cursor: pointer;
transition: background 160ms ease;
}
.switch-track::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 16px;
height: 16px;
border-radius: 50%;
background: #fff;
box-shadow: 0 2px 5px rgba(35, 48, 46, 0.18);
transition: transform 160ms ease;
}
.switch input:checked + .switch-track {
background: var(--teal);
}
.switch input:checked + .switch-track::after {
transform: translateX(16px);
}
.primary-button {
width: 100%;
min-height: 43px;
margin-top: 15px;
border: 0;
border-radius: 11px;
color: #fff;
background: var(--teal-dark);
box-shadow: 0 9px 20px rgba(39, 103, 95, 0.18);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.025em;
cursor: pointer;
transition:
transform 150ms ease,
background 150ms ease;
}
.primary-button:hover {
transform: translateY(-2px);
background: #205b54;
}
.primary-button:active {
transform: translateY(0);
}
.safe-note {
display: flex;
align-items: flex-start;
gap: 9px;
margin-top: 15px;
padding: 11px;
border: 1px solid #d5e4dc;
border-radius: 11px;
color: #4b655b;
background: #f0f7f3;
font-size: 10px;
line-height: 1.45;
}
.safe-note svg {
width: 15px;
height: 15px;
flex: 0 0 auto;
fill: none;
stroke: #4c866b;
stroke-width: 2;
}
@media (max-width: 860px) {
html,
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100dvh;
}
.workspace {
grid-template-columns: 1fr;
grid-template-rows: minmax(500px, 64dvh) auto;
}
.panel {
overflow: visible;
border-top: 1px solid var(--line);
border-left: 0;
}
.topbar {
padding: 0 16px;
}
.top-status {
padding: 8px 10px;
}
.top-status span:last-child {
display: none;
}
.view-header {
top: 16px;
left: 17px;
}
.legend {
left: 14px;
bottom: 14px;
max-width: calc(100% - 120px);
}
.view-tools {
right: 13px;
bottom: 13px;
}
}
@media (max-width: 480px) {
.brand .eyebrow {
display: none;
}
h1 {
font-size: 15px;
}
.legend-item:nth-child(3) {
display: none;
}
.world-label small {
display: none;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true"></div>
<div>
<p class="eyebrow">Conservation Lab</p>
<h1>Padded Clamp Fit</h1>
</div>
</div>
<div class="top-status">
<i class="status-dot"></i>
<span>3 objects secured</span>
</div>
</header>
<main class="workspace">
<section class="viewport" id="viewport" aria-label="Interactive 3D clamp fitting view">
<div class="view-header">
<p class="view-title">Restoration Bench</p>
<p class="view-subtitle">Low-poly objects · protected work zones visible</p>
</div>
<div class="labels" id="labels"></div>
<div class="legend" aria-hidden="true">
<div class="legend-item">
<i class="legend-swatch work"></i>
Marked working area
</div>
<div class="legend-item">
<i class="legend-swatch pad"></i>
Padded jaw
</div>
<div class="legend-item">
<i class="legend-swatch frame"></i>
Clamp frame
</div>
</div>
<div class="view-tools">
<button class="icon-button" id="zoomIn" title="Zoom in" aria-label="Zoom in">
<svg viewBox="0 0 24 24"><path d="M12 5v14M5 12h14" /></svg>
</button>
<button class="icon-button" id="zoomOut" title="Zoom out" aria-label="Zoom out">
<svg viewBox="0 0 24 24"><path d="M5 12h14" /></svg>
</button>
<button class="icon-button" id="topView" title="Top view" aria-label="Top view">
<svg viewBox="0 0 24 24"><path d="m12 3 9 5-9 5-9-5 9-5Z" /><path d="m3 12 9 5 9-5M3 16l9 5 9-5" /></svg>
</button>
<button class="icon-button" id="resetView" title="Reset view" aria-label="Reset view">
<svg viewBox="0 0 24 24"><path d="M4 4v6h6" /><path d="M5.5 15a8 8 0 1 0 .5-7.5L4 10" /></svg>
</button>
</div>
</section>
<aside class="panel">
<h2>Jaw selection</h2>
<p class="panel-intro">
Choose a padded profile and fit each clamp around the object without
obscuring its marked conservation area.
</p>
<section class="section">
<div class="section-heading">
<h3>Restoration object</h3>
<span id="selectedName">Portrait study</span>
</div>
<div class="object-list">
<button class="object-option" data-object="0">
<span class="object-index">01</span>
<span class="object-copy">
<strong>Ceramic amphora</strong>
<small>Faceted earthenware · 28 cm</small>
</span>
<span class="check">✓</span>
</button>
<button class="object-option active" data-object="1">
<span class="object-index">02</span>
<span class="object-copy">
<strong>Portrait study</strong>
<small>Cast plaster · 31 cm</small>
</span>
<span class="check">✓</span>
</button>
<button class="object-option" data-object="2">
<span class="object-index">03</span>
<span class="object-copy">
<strong>Geometric flask</strong>
<small>Patinated ceramic · 26 cm</small>
</span>
<span class="check">✓</span>
</button>
</div>
</section>
<section class="section">
<div class="section-heading">
<h3>Jaw profile</h3>
<span>Applied to selected</span>
</div>
<div class="profile-grid">
<button class="profile-button" data-profile="precision">
<span class="profile-icon" aria-hidden="true"></span>
<strong>Precision</strong>
<small>Narrow</small>
</button>
<button class="profile-button active" data-profile="balanced">
<span class="profile-icon" aria-hidden="true"></span>
<strong>Balanced</strong>
<small>Standard</small>
</button>
<button class="profile-button" data-profile="contour">
<span class="profile-icon" aria-hidden="true"></span>
<strong>Contour</strong>
<small>Wide</small>
</button>
</div>
<div class="field">
<label for="paddingSelect">Contact padding</label>
<select id="paddingSelect">
<option value="silicone">Soft silicone · mint</option>
<option value="foam">Micro-cell foam · graphite</option>
<option value="gel">Gel comfort pad · blue</option>
</select>
</div>
</section>
<section class="section">
<div class="section-heading">
<h3>Fit verification</h3>
<span>Live measurement</span>
</div>
<div class="metrics">
<div class="metric">
<span>Work coverage</span>
<strong class="safe" id="coverageMetric">0%</strong>
</div>
<div class="metric">
<span>Minimum clearance</span>
<strong id="clearanceMetric">18 mm</strong>
</div>
<div class="metric">
<span>Protected zone</span>
<strong class="work" id="areaMetric">12.4 cm²</strong>
</div>
<div class="metric">
<span>Jaw status</span>
<strong class="safe">Clear</strong>
</div>
</div>
<div class="toggle-row">
<span>Show protected work zones</span>
<label class="switch">
<input id="showZones" type="checkbox" checked />
<span class="switch-track"></span>
</label>
</div>
<button class="primary-button" id="reseatButton">
Re-seat selected clamps
</button>
<div class="safe-note">
<svg viewBox="0 0 24 24">
<path d="m5 12 4 4L19 6" />
</svg>
<span>
Jaws contact the protected perimeter only. The amber restoration
area remains fully visible and accessible.
</span>
</div>
</section>
</aside>
</main>
</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 labelsContainer = document.getElementById("labels");
const objectButtons = [...document.querySelectorAll("[data-object]")];
const profileButtons = [...document.querySelectorAll("[data-profile]")];
const paddingSelect = document.getElementById("paddingSelect");
const selectedName = document.getElementById("selectedName");
const coverageMetric = document.getElementById("coverageMetric");
const clearanceMetric = document.getElementById("clearanceMetric");
const areaMetric = document.getElementById("areaMetric");
const showZones = document.getElementById("showZones");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e7df);
scene.fog = new THREE.Fog(0xe8e7df, 20, 38);
const camera = new THREE.PerspectiveCamera(42, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.style.position = "absolute";
renderer.domElement.style.inset = "0";
viewport.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xfffdf4, 0x8c928d, 2.15);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff4df, 3.4);
keyLight.position.set(-7, 11, 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 = -8;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.00035;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xc8dddf, 1.15);
fillLight.position.set(8, 5, -7);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffdfae, 0.8);
rimLight.position.set(0, 5, 9);
scene.add(rimLight);
const benchMaterial = new THREE.MeshStandardMaterial({
color: 0xd4d0c5,
roughness: 0.88,
metalness: 0.02
});
const bench = new THREE.Mesh(
new THREE.BoxGeometry(16.2, 0.36, 6.6),
benchMaterial
);
bench.position.set(0, -0.25, 0);
bench.receiveShadow = true;
scene.add(bench);
const benchEdge = new THREE.Mesh(
new THREE.BoxGeometry(16.2, 0.14, 0.12),
new THREE.MeshStandardMaterial({
color: 0xaaa79e,
roughness: 0.82
})
);
benchEdge.position.set(0, -0.08, 3.28);
scene.add(benchEdge);
const grid = new THREE.GridHelper(30, 30, 0xb2b5ad, 0xc8cac2);
grid.position.y = -0.435;
grid.material.transparent = true;
grid.material.opacity = 0.22;
scene.add(grid);
const profileFactors = {
precision: 0.82,
balanced: 1,
contour: 1.16
};
const profileClearance = {
precision: 26,
balanced: 22,
contour: 18
};
const paddingOptions = {
silicone: {
color: 0x4f9387,
roughness: 0.52,
label: "Soft silicone"
},
foam: {
color: 0x3f4a4d,
roughness: 0.94,
label: "Micro-cell foam"
},
gel: {
color: 0x657eb2,
roughness: 0.38,
label: "Gel comfort pad"
}
};
const artifacts = [];
const pickables = [];
let selectedIndex = 1;
function tagPickable(mesh, index) {
mesh.userData.artifactIndex = index;
pickables.push(mesh);
}
function addArtifactMesh(group, index, geometry, material, position, rotation, scale) {
const mesh = new THREE.Mesh(geometry, material);
if (position) mesh.position.set(...position);
if (rotation) mesh.rotation.set(...rotation);
if (scale) mesh.scale.set(...scale);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
tagPickable(mesh, index);
return mesh;
}
function createWorkZone(artifact, position, radius) {
const zone = new THREE.Group();
zone.position.set(...position);
const fillMaterial = new THREE.MeshBasicMaterial({
color: 0xe3a33d,
transparent: true,
opacity: 0.18,
side: THREE.DoubleSide,
depthWrite: false,
polygonOffset: true,
polygonOffsetFactor: -2
});
const ringMaterial = new THREE.MeshBasicMaterial({
color: 0xd38d27,
transparent: true,
opacity: 0.96,
side: THREE.DoubleSide,
depthWrite: false,
polygonOffset: true,
polygonOffsetFactor: -3
});
const fill = new THREE.Mesh(
new THREE.CircleGeometry(radius * 0.72, 32),
fillMaterial
);
fill.position.z = -0.002;
fill.renderOrder = 5;
zone.add(fill);
const ring = new THREE.Mesh(
new THREE.RingGeometry(radius * 0.72, radius, 36),
ringMaterial
);
ring.renderOrder = 6;
zone.add(ring);
const linePoints = [];
for (let i = -1; i <= 1; i++) {
linePoints.push(
new THREE.Vector3(-radius * 0.25, i * radius * 0.16, 0.012),
new THREE.Vector3(radius * 0.25, i * radius * 0.16, 0.012)
);
}
const lineGeometry = new THREE.BufferGeometry().setFromPoints(linePoints);
const lines = new THREE.LineSegments(
lineGeometry,
new THREE.LineBasicMaterial({
color: 0xa96713,
transparent: true,
opacity: 0.65
})
);
lines.renderOrder = 7;
zone.add(lines);
artifact.group.add(zone);
artifact.workZone = zone;
artifact.workFill = fill;
artifact.workRing = ring;
artifact.workLines = lines;
}
function createClamp(artifact, jawY, contactRadius) {
const frameMaterial = artifact.frameMaterial;
const padMaterial = artifact.padMaterial;
for (const side of [-1, 1]) {
const postX = side * 1.67;
const post = new THREE.Mesh(
new THREE.CylinderGeometry(0.075, 0.09, 1.9, 8),
frameMaterial
);
post.position.set(postX, 1.1, 0.18);
post.castShadow = true;
artifact.group.add(post);
tagPickable(post, artifact.index);
const foot = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.23, 0.1, 12),
frameMaterial
);
foot.position.set(postX, 0.18, 0.18);
foot.castShadow = true;
foot.receiveShadow = true;
artifact.group.add(foot);
tagPickable(foot, artifact.index);
const arm = new THREE.Mesh(
new THREE.BoxGeometry(1, 0.17, 0.2),
frameMaterial
);
arm.position.set(side * 1.2, jawY + 0.04, 0.18);
arm.castShadow = true;
artifact.group.add(arm);
tagPickable(arm, artifact.index);
const padGroup = new THREE.Group();
padGroup.position.set(
side * (contactRadius + 0.23 - 0.02),
jawY,
0.18
);
artifact.group.add(padGroup);
const pad = new THREE.Mesh(
new THREE.CapsuleGeometry(0.23, 0.64, 4, 10),
padMaterial
);
pad.castShadow = true;
pad.receiveShadow = true;
padGroup.add(pad);
tagPickable(pad, artifact.index);
const spine = new THREE.Mesh(
new THREE.BoxGeometry(0.13, 0.83, 0.34),
frameMaterial
);
spine.position.x = side * 0.2;
spine.castShadow = true;
padGroup.add(spine);
tagPickable(spine, artifact.index);
for (const y of [-0.22, 0, 0.22]) {
const seam = new THREE.Mesh(
new THREE.BoxGeometry(0.31, 0.035, 0.05),
artifact.seamMaterial
);
seam.position.set(0, y, 0.218);
padGroup.add(seam);
}
artifact.jaws.push({
side,
arm,
padGroup,
jawY,
contactRadius,
postX
});
}
}
function applyJawGeometry(artifact, factor) {
for (const jaw of artifact.jaws) {
const padX =
jaw.side * (jaw.contactRadius + 0.23 * factor - 0.02);
jaw.padGroup.scale.x = factor;
jaw.padGroup.position.x = padX;
jaw.arm.position.x = (jaw.postX + padX) * 0.5;
jaw.arm.scale.x = Math.abs(jaw.postX - padX);
}
}
function makePlaque(index, title) {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 150;
const context = canvas.getContext("2d");
context.fillStyle = "#343d3a";
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "#d7e2dc";
context.font = "700 30px sans-serif";
context.fillText(
`${String(index + 1).padStart(2, "0")} ${title}`,
30,
62
);
context.fillStyle = "#8ca49b";
context.font = "500 20px sans-serif";
context.fillText("RESTORATION OBJECT", 31, 108);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
4,
renderer.capabilities.getMaxAnisotropy()
);
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(2.4, 0.56),
new THREE.MeshBasicMaterial({ map: texture })
);
plaque.rotation.x = -Math.PI / 2;
plaque.position.set(artifacts[index].x, -0.055, 2.48);
scene.add(plaque);
}
function createArtifact(config) {
const root = new THREE.Group();
root.position.x = config.x;
root.position.y = 0.12;
scene.add(root);
const artifact = {
index: artifacts.length,
title: config.title,
subtitle: config.subtitle,
group: root,
x: config.x,
jawY: config.jawY,
contactRadius: config.contactRadius,
area: config.area,
profile: config.profile,
recommended: config.recommended,
padding: config.padding,
currentFactor: profileFactors[config.profile],
targetFactor: profileFactors[config.profile],
jaws: [],
padMaterial: new THREE.MeshStandardMaterial({
color: paddingOptions[config.padding].color,
roughness: paddingOptions[config.padding].roughness,
metalness: 0.02,
flatShading: true,
emissive: 0x000000
}),
frameMaterial: new THREE.MeshStandardMaterial({
color: 0x3c4542,
roughness: 0.42,
metalness: 0.62,
emissive: 0x000000
}),
seamMaterial: new THREE.MeshStandardMaterial({
color: 0x2f6f66,
roughness: 0.88,
metalness: 0
})
};
config.build(root, artifact.index);
createWorkZone(artifact, config.workPosition, config.workRadius);
createClamp(artifact, config.jawY, config.contactRadius);
applyJawGeometry(artifact, artifact.currentFactor);
const pedestal = new THREE.Mesh(
new THREE.CylinderGeometry(1.82, 1.9, 0.18, 32),
new THREE.MeshStandardMaterial({
color: 0xbfc4bc,
roughness: 0.78,
metalness: 0.08
})
);
pedestal.position.set(config.x, 0.02, 0);
pedestal.receiveShadow = true;
scene.add(pedestal);
const selectionRing = new THREE.Mesh(
new THREE.TorusGeometry(1.72, 0.025, 5, 64),
new THREE.MeshBasicMaterial({
color: 0x4f9387,
transparent: true,
opacity: 0.18
})
);
selectionRing.rotation.x = Math.PI / 2;
selectionRing.position.set(config.x, 0.125, 0);
scene.add(selectionRing);
artifact.selectionRing = selectionRing;
artifacts.push(artifact);
makePlaque(artifact.index, config.title);
createWorldLabel(artifact);
return artifact;
}
createArtifact({
title: "Ceramic amphora",
subtitle: "Faceted earthenware · 28 cm",
x: -4.45,
area: "9.8 cm²",
profile: "precision",
recommended: "precision",
padding: "silicone",
jawY: 1.08,
contactRadius: 0.88,
workPosition: [0, 1.66, 0.82],
workRadius: 0.26,
build(root, index) {
const clay = new THREE.MeshStandardMaterial({
color: 0xb86d50,
roughness: 0.88,
metalness: 0.02,
flatShading: true
});
const clayDark = new THREE.MeshStandardMaterial({
color: 0x96523e,
roughness: 0.9,
metalness: 0.01,
flatShading: true
});
addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.98, 0.68, 2.15, 7, 1),
clay,
[0, 1.42, 0]
);
addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.61, 0.98, 0.58, 7),
clay,
[0, 2.79, 0]
);
addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.49, 0.61, 0.52, 7),
clayDark,
[0, 3.34, 0]
);
addArtifactMesh(
root,
index,
new THREE.TorusGeometry(0.54, 0.075, 4, 12),
clayDark,
[0, 3.62, 0],
[Math.PI / 2, 0, 0]
);
for (const side of [-1, 1]) {
addArtifactMesh(
root,
index,
new THREE.TorusGeometry(0.37, 0.085, 4, 10, Math.PI),
clayDark,
[side * 0.74, 2.42, 0],
[0, 0, side < 0 ? Math.PI : 0]
);
}
}
});
createArtifact({
title: "Portrait study",
subtitle: "Cast plaster · 31 cm",
x: 0,
area: "12.4 cm²",
profile: "balanced",
recommended: "contour",
padding: "silicone",
jawY: 1.02,
contactRadius: 1.12,
workPosition: [0, 1.27, 1.015],
workRadius: 0.3,
build(root, index) {
const plaster = new THREE.MeshStandardMaterial({
color: 0xc9bea9,
roughness: 0.94,
metalness: 0,
flatShading: true
});
const shadowClay = new THREE.MeshStandardMaterial({
color: 0x9c8c76,
roughness: 0.92,
flatShading: true
});
addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.82, 1.34, 0.98, 7),
plaster,
[0, 0.96, 0]
);
addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.33, 0.4, 0.62, 7),
plaster,
[0, 1.73, 0]
);
addArtifactMesh(
root,
index,
new THREE.IcosahedronGeometry(0.88, 1),
plaster,
[0, 2.63, 0],
[0, 0, 0],
[1, 1.08, 0.88]
);
addArtifactMesh(
root,
index,
new THREE.ConeGeometry(0.13, 0.3, 4),
shadowClay,
[0, 2.59, 0.73],
[Math.PI / 2, 0, 0]
);
for (const side of [-1, 1]) {
const eye = addArtifactMesh(
root,
index,
new THREE.BoxGeometry(0.17, 0.035, 0.035),
shadowClay,
[side * 0.24, 2.78, 0.68],
[0, 0, side * 0.08]
);
eye.castShadow = false;
}
}
});
createArtifact({
title: "Geometric flask",
subtitle: "Patinated ceramic · 26 cm",
x: 4.45,
area: "10.6 cm²",
profile: "contour",
recommended: "balanced",
padding: "foam",
jawY: 1.05,
contactRadius: 1.02,
workPosition: [0.16, 1.67, 1.075],
workRadius: 0.27,
build(root, index) {
const ceramic = new THREE.MeshStandardMaterial({
color: 0x7f9693,
roughness: 0.78,
metalness: 0.07,
flatShading: true
});
const ceramicDark = new THREE.MeshStandardMaterial({
color: 0x526c69,
roughness: 0.84,
metalness: 0.05,
flatShading: true
});
addArtifactMesh(
root,
index,
new THREE.DodecahedronGeometry(1.13, 0),
ceramic,
[0, 1.58, 0],
[0, 0.08, 0],
[1, 1.2, 0.96]
);
addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.43, 0.55, 0.62, 7),
ceramicDark,
[0, 2.83, 0]
);
addArtifactMesh(
root,
index,
new THREE.TorusGeometry(0.48, 0.075, 4, 12),
ceramicDark,
[0, 3.15, 0],
[Math.PI / 2, 0, 0]
);
const foot = addArtifactMesh(
root,
index,
new THREE.CylinderGeometry(0.58, 0.7, 0.18, 7),
ceramicDark,
[0, 0.17, 0]
);
foot.castShadow = true;
}
});
function createWorldLabel(artifact) {
const label = document.createElement("button");
label.className = "world-label";
label.innerHTML = `
<span class="number">${String(artifact.index + 1).padStart(2, "0")}</span>
<span>
<strong>${artifact.title}</strong>
<small>Protected · clamp seated</small>
</span>
`;
label.addEventListener("click", () => selectArtifact(artifact.index));
labelsContainer.appendChild(label);
artifact.worldLabel = label;
const zoneLabel = document.createElement("div");
zoneLabel.className = "zone-label";
zoneLabel.textContent = "WORK";
labelsContainer.appendChild(zoneLabel);
artifact.zoneLabel = zoneLabel;
}
function updateSelectionVisuals() {
for (const artifact of artifacts) {
const selected = artifact.index === selectedIndex;
artifact.worldLabel.classList.toggle("active", selected);
artifact.selectionRing.material.opacity = selected ? 0.85 : 0.16;
artifact.selectionRing.material.color.setHex(
selected ? 0x4f9387 : 0xa9b4ae
);
artifact.padMaterial.emissive.setHex(selected ? 0x183f39 : 0x000000);
artifact.padMaterial.emissiveIntensity = selected ? 0.25 : 0;
artifact.frameMaterial.emissive.setHex(selected ? 0x172b27 : 0x000000);
artifact.frameMaterial.emissiveIntensity = selected ? 0.18 : 0;
artifact.workRing.material.opacity = selected ? 1 : 0.72;
artifact.workFill.material.opacity = selected ? 0.22 : 0.14;
}
}
function selectArtifact(index) {
selectedIndex = index;
const artifact = artifacts[index];
objectButtons.forEach((button) => {
button.classList.toggle("active", Number(button.dataset.object) === index);
});
profileButtons.forEach((button) => {
button.classList.toggle(
"active",
button.dataset.profile === artifact.profile
);
});
paddingSelect.value = artifact.padding;
selectedName.textContent = artifact.title;
coverageMetric.textContent = "0%";
clearanceMetric.textContent = `${profileClearance[artifact.profile]} mm`;
areaMetric.textContent = artifact.area;
updateSelectionVisuals();
}
function setProfile(profile, animate = true) {
const artifact = artifacts[selectedIndex];
artifact.profile = profile;
artifact.targetFactor = profileFactors[profile];
if (!animate) {
artifact.currentFactor = artifact.targetFactor;
applyJawGeometry(artifact, artifact.currentFactor);
}
profileButtons.forEach((button) => {
button.classList.toggle(
"active",
button.dataset.profile === profile
);
});
clearanceMetric.textContent = `${profileClearance[profile]} mm`;
}
function setPadding(type) {
const artifact = artifacts[selectedIndex];
artifact.padding = type;
artifact.padMaterial.color.setHex(paddingOptions[type].color);
artifact.padMaterial.roughness = paddingOptions[type].roughness;
artifact.padMaterial.needsUpdate = true;
}
objectButtons.forEach((button) => {
button.addEventListener("click", () => {
selectArtifact(Number(button.dataset.object));
});
});
profileButtons.forEach((button) => {
button.addEventListener("click", () => {
setProfile(button.dataset.profile);
});
});
paddingSelect.addEventListener("change", () => {
setPadding(paddingSelect.value);
});
document.getElementById("reseatButton").addEventListener("click", () => {
const artifact = artifacts[selectedIndex];
setProfile(artifact.recommended);
setPadding(artifact.padding);
});
showZones.addEventListener("change", () => {
for (const artifact of artifacts) {
artifact.workZone.visible = showZones.checked;
artifact.zoneLabel.style.display = showZones.checked ? "flex" : "none";
}
});
const cameraState = {
theta: 0.1,
phi: 1.08,
radius: 15.8,
desiredTheta: 0.1,
desiredPhi: 1.08,
desiredRadius: 15.8,
target: new THREE.Vector3(0, 1.42, 0),
desiredTarget: new THREE.Vector3(0, 1.42, 0)
};
function updateCamera() {
cameraState.theta = THREE.MathUtils.lerp(
cameraState.theta,
cameraState.desiredTheta,
0.11
);
cameraState.phi = THREE.MathUtils.lerp(
cameraState.phi,
cameraState.desiredPhi,
0.11
);
cameraState.radius = THREE.MathUtils.lerp(
cameraState.radius,
cameraState.desiredRadius,
0.11
);
cameraState.target.lerp(cameraState.desiredTarget, 0.11);
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
function resetCamera(top = false) {
cameraState.desiredTheta = 0.1;
cameraState.desiredPhi = top ? 0.16 : 1.08;
cameraState.desiredRadius = 15.8;
cameraState.desiredTarget.set(0, 1.42, 0);
}
document.getElementById("resetView").addEventListener("click", () => {
resetCamera(false);
});
document.getElementById("topView").addEventListener("click", () => {
resetCamera(true);
});
document.getElementById("zoomIn").addEventListener("click", () => {
cameraState.desiredRadius = Math.max(
8,
cameraState.desiredRadius - 1.5
);
});
document.getElementById("zoomOut").addEventListener("click", () => {
cameraState.desiredRadius = Math.min(
25,
cameraState.desiredRadius + 1.5
);
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let drag = 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 pickArtifact(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(pickables, false);
if (intersections.length) {
selectArtifact(intersections[0].object.userData.artifactIndex);
}
}
renderer.domElement.addEventListener("pointerdown", (event) => {
if (event.button !== 0 && event.button !== 2) return;
drag = {
id: event.pointerId,
x: event.clientX,
y: event.clientY,
startX: event.clientX,
startY: event.clientY,
moved: false,
pan: event.shiftKey || event.button === 2
};
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (drag && drag.id === event.pointerId) {
const dx = event.clientX - drag.x;
const dy = event.clientY - drag.y;
if (
Math.abs(event.clientX - drag.startX) +
Math.abs(event.clientY - drag.startY) >
4
) {
drag.moved = true;
}
if (drag.pan || event.shiftKey) {
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
1
);
const panScale = cameraState.radius * 0.0012;
cameraState.desiredTarget.addScaledVector(
right,
-dx * panScale
);
cameraState.desiredTarget.addScaledVector(up, dy * panScale);
} else {
cameraState.desiredTheta -= dx * 0.006;
cameraState.desiredPhi = THREE.MathUtils.clamp(
cameraState.desiredPhi - dy * 0.005,
0.16,
1.43
);
}
drag.x = event.clientX;
drag.y = event.clientY;
renderer.domElement.style.cursor = "grabbing";
} else {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
renderer.domElement.style.cursor =
raycaster.intersectObjects(pickables, false).length
? "pointer"
: "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (drag && drag.id === event.pointerId) {
if (!drag.moved) pickArtifact(event);
drag = null;
renderer.domElement.style.cursor = "grab";
}
});
renderer.domElement.addEventListener("pointercancel", () => {
drag = null;
renderer.domElement.style.cursor = "grab";
});
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.desiredRadius = THREE.MathUtils.clamp(
cameraState.desiredRadius + event.deltaY * 0.008,
8,
25
);
},
{ passive: false }
);
function resize() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
camera.aspect = width / Math.max(height, 1);
camera.fov = width < 800 ? 58 : 42;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
resize();
const projected = new THREE.Vector3();
const zonePosition = new THREE.Vector3();
function updateLabels() {
const width = viewport.clientWidth;
const height = viewport.clientHeight;
for (const artifact of artifacts) {
artifact.group.getWorldPosition(projected);
projected.y += artifact.title === "Ceramic amphora" ? 3.95 : 3.62;
projected.project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible = projected.z > -1 && projected.z < 1;
artifact.worldLabel.style.left = `${x}px`;
artifact.worldLabel.style.top = `${y}px`;
artifact.worldLabel.style.display = visible ? "flex" : "none";
artifact.workZone.getWorldPosition(zonePosition);
zonePosition.project(camera);
const zx = (zonePosition.x * 0.5 + 0.5) * width;
const zy = (-zonePosition.y * 0.5 + 0.5) * height;
artifact.zoneLabel.style.left = `${zx}px`;
artifact.zoneLabel.style.top = `${zy}px`;
artifact.zoneLabel.style.visibility =
zonePosition.z > -1 && zonePosition.z < 1 ? "visible" : "hidden";
}
}
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
updateCamera();
for (const artifact of artifacts) {
if (
Math.abs(artifact.currentFactor - artifact.targetFactor) >
0.0001
) {
artifact.currentFactor = THREE.MathUtils.lerp(
artifact.currentFactor,
artifact.targetFactor,
0.12
);
applyJawGeometry(artifact, artifact.currentFactor);
}
if (artifact.index === selectedIndex) {
const pulse = 1 + Math.sin(elapsed * 2.6) * 0.035;
artifact.workRing.scale.setScalar(pulse);
artifact.selectionRing.material.opacity =
0.72 + Math.sin(elapsed * 2.6) * 0.12;
} else {
artifact.workRing.scale.setScalar(1);
}
}
updateLabels();
renderer.render(scene, camera);
}
selectArtifact(selectedIndex);
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```