Prompt specification
Build or customize the Three.js 3D scene "Reveal how mold geometry shapes a vessel" 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: Reveal how mold geometry shapes a vessel
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/reveal-how-mold-geometry-shapes-a-vessel-x2320
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Shang-era bronze casting with piece molds. Let users remove mold sections from a completed virtual casting. Compare core size and wall thickness geometrically while keeping the reconstruction's historical uncertainty visible. Low-poly.
Working Three.js Starter (reveal-how-mold-geometry-shapes-a-vessel-x2320):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shang Piece-Mold Casting — Interactive Reconstruction</title>
<style>
:root {
--ink: #25241f;
--muted: #6e685d;
--paper: #f3eee4;
--paper-solid: #eee6d8;
--line: rgba(49, 43, 34, 0.18);
--bronze: #496657;
--bronze-dark: #30463d;
--clay: #9b673f;
--uncertainty: #c37a2c;
--shadow: 0 14px 45px rgba(50, 40, 27, 0.14);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7dfd0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button, input { font: inherit; }
#stage {
position: relative;
width: 100%;
height: 100%;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.brand {
position: absolute;
top: 24px;
left: 28px;
z-index: 5;
max-width: 430px;
pointer-events: none;
text-shadow: 0 1px 18px rgba(255,255,255,.7);
}
.eyebrow {
margin-bottom: 8px;
color: var(--clay);
font-size: 11px;
font-weight: 800;
letter-spacing: .19em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 3.3vw, 48px);
font-weight: 500;
letter-spacing: -.035em;
line-height: .98;
}
.brand p {
margin: 10px 0 0;
color: #5d574c;
font-size: 13px;
line-height: 1.5;
}
.panel {
position: absolute;
z-index: 6;
border: 1px solid rgba(67, 56, 40, .16);
border-radius: 15px;
background: rgba(246, 241, 232, .91);
box-shadow: var(--shadow);
backdrop-filter: blur(15px) saturate(.9);
-webkit-backdrop-filter: blur(15px) saturate(.9);
}
#controls {
top: 24px;
right: 24px;
width: 338px;
max-height: calc(100vh - 48px);
overflow: auto;
padding: 18px;
}
.panel-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 13px;
}
.panel-title h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 19px;
font-weight: 500;
letter-spacing: -.015em;
}
.panel-title small {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .12em;
text-transform: uppercase;
}
.section {
padding: 15px 0;
border-top: 1px solid var(--line);
}
.section:first-of-type { border-top: 0; padding-top: 0; }
.section-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-bottom: 11px;
}
.section-heading h3 {
margin: 0;
font-size: 11px;
font-weight: 850;
letter-spacing: .13em;
text-transform: uppercase;
}
.section-heading span {
color: var(--muted);
font-size: 11px;
}
.mold-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 7px;
}
.piece-button {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
min-height: 38px;
padding: 8px 9px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255,255,255,.47);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 700;
text-align: left;
transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.piece-button:hover {
border-color: rgba(80, 58, 33, .4);
background: rgba(255,255,255,.8);
transform: translateY(-1px);
}
.piece-button.removed {
background: rgba(75, 91, 81, .11);
color: #667269;
border-style: dashed;
}
.piece-button .state {
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
}
.button-row {
display: flex;
gap: 7px;
margin-top: 9px;
}
.button {
flex: 1;
min-height: 36px;
padding: 8px 10px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(255,255,255,.55);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 750;
transition: background .16s ease, transform .16s ease;
}
.button:hover {
background: rgba(255,255,255,.9);
transform: translateY(-1px);
}
.button.primary {
border-color: var(--bronze-dark);
background: var(--bronze-dark);
color: #f4efe3;
}
.button.primary:hover { background: #3d594c; }
.control-row { margin-top: 13px; }
.control-label {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 7px;
font-size: 12px;
font-weight: 700;
}
output {
color: var(--clay);
font-variant-numeric: tabular-nums;
font-size: 11px;
font-weight: 850;
}
input[type="range"] {
width: 100%;
height: 4px;
margin: 6px 0;
border-radius: 999px;
accent-color: var(--bronze-dark);
cursor: pointer;
}
.metric-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 10px;
}
.metric {
padding: 10px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255,255,255,.35);
}
.metric span {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: .09em;
text-transform: uppercase;
}
.metric strong {
display: block;
margin-top: 4px;
font-family: Georgia, "Times New Roman", serif;
font-size: 20px;
font-weight: 500;
}
.toggle-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 10px;
font-size: 12px;
font-weight: 700;
}
.toggle {
position: relative;
width: 37px;
height: 21px;
flex: 0 0 auto;
}
.toggle input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.toggle-track {
position: absolute;
inset: 0;
border-radius: 999px;
background: #c8bfb0;
cursor: pointer;
transition: background .18s ease;
}
.toggle-track::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 15px;
height: 15px;
border-radius: 50%;
background: #fffaf0;
box-shadow: 0 1px 4px rgba(0,0,0,.2);
transition: transform .18s ease;
}
.toggle input:checked + .toggle-track {
background: var(--uncertainty);
}
.toggle input:checked + .toggle-track::after {
transform: translateX(16px);
}
.uncertainty-note {
margin: 10px 0 0;
padding: 10px 11px;
border-left: 3px solid var(--uncertainty);
border-radius: 0 8px 8px 0;
background: rgba(195, 122, 44, .09);
color: #68513a;
font-size: 11px;
line-height: 1.48;
}
#method {
left: 28px;
bottom: 25px;
width: 345px;
padding: 16px 17px;
}
.steps {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
margin-bottom: 12px;
}
.step {
position: relative;
padding-top: 8px;
border-top: 2px solid rgba(77, 94, 84, .28);
color: var(--muted);
font-size: 9px;
font-weight: 750;
line-height: 1.25;
}
.step.active {
border-color: var(--bronze-dark);
color: var(--bronze-dark);
}
.step b {
display: block;
margin-bottom: 2px;
font-size: 10px;
}
#method p {
margin: 0;
color: #645d52;
font-size: 11px;
line-height: 1.5;
}
#method strong { color: #3e3a32; }
.status {
position: absolute;
top: 25px;
left: 50%;
z-index: 7;
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
border: 1px solid rgba(65, 54, 39, .15);
border-radius: 999px;
background: rgba(246, 241, 232, .84);
box-shadow: 0 6px 24px rgba(50, 40, 27, .09);
color: #5b554b;
font-size: 10px;
font-weight: 800;
letter-spacing: .08em;
text-transform: uppercase;
transform: translateX(-50%);
pointer-events: none;
}
.status-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--clay);
box-shadow: 0 0 0 3px rgba(155, 103, 63, .13);
}
.measure-label {
position: absolute;
z-index: 4;
display: none;
padding: 5px 8px;
border: 1px solid rgba(255,255,255,.3);
border-radius: 6px;
background: rgba(35, 48, 42, .88);
box-shadow: 0 5px 16px rgba(0,0,0,.14);
color: #f6f0e2;
font-size: 10px;
font-weight: 850;
letter-spacing: .055em;
white-space: nowrap;
pointer-events: none;
transform: translate(-50%, -50%);
}
.measure-label.amber {
background: rgba(145, 83, 24, .91);
}
#hint {
position: absolute;
right: 27px;
bottom: 24px;
z-index: 5;
max-width: 320px;
padding: 8px 11px;
border-radius: 8px;
background: rgba(242, 236, 224, .7);
color: #696256;
font-size: 10px;
font-weight: 650;
text-align: right;
pointer-events: none;
}
.legend {
position: absolute;
left: 50%;
bottom: 24px;
z-index: 5;
display: flex;
gap: 14px;
align-items: center;
padding: 8px 12px;
border-radius: 999px;
background: rgba(246, 241, 232, .75);
color: #625c51;
font-size: 10px;
font-weight: 700;
transform: translateX(-50%);
pointer-events: none;
}
.legend-item {
display: flex;
align-items: center;
gap: 5px;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 50%;
}
.swatch.bronze { background: #496657; }
.swatch.core { background: #a86d49; }
.swatch.range {
border: 1px dashed #c37a2c;
background: transparent;
}
@media (max-width: 980px) {
#method { display: none; }
.legend { left: 25px; transform: none; }
#hint { display: none; }
.brand { max-width: 360px; }
}
@media (max-width: 680px) {
.brand {
top: 16px;
left: 16px;
max-width: calc(100vw - 32px);
}
.brand h1 { font-size: 29px; }
.brand p { display: none; }
.status { top: 91px; }
#controls {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 48vh;
padding: 14px;
}
.legend { display: none; }
}
</style>
</head>
<body>
<div id="stage">
<canvas id="scene" tabindex="0"
aria-label="Interactive low-poly reconstruction of a Shang bronze vessel surrounded by removable clay mold sections"></canvas>
<header class="brand">
<div class="eyebrow">Shang casting laboratory · interpretive model</div>
<h1>Piece-mold bronze</h1>
<p>A completed ritual wine vessel, still enclosed in its sectioned clay mold.</p>
</header>
<div class="status" aria-live="polite">
<span class="status-dot"></span>
<span id="statusText">0 of 6 mold sections removed</span>
</div>
<aside class="panel" id="controls">
<div class="panel-title">
<h2>Explore the casting</h2>
<small>Virtual jack</small>
</div>
<section class="section">
<div class="section-heading">
<h3>Outer mold sections</h3>
<span>Click a piece or button</span>
</div>
<div class="mold-grid" id="moldGrid"></div>
<div class="button-row">
<button class="button" id="removeAll" type="button">Remove all</button>
<button class="button" id="restoreAll" type="button">Restore all</button>
</div>
</section>
<section class="section">
<div class="section-heading">
<h3>Geometry hypothesis</h3>
<span>Working values</span>
</div>
<div class="control-row">
<label class="control-label" for="coreScale">
<span>Core-size cap</span>
<output id="coreScaleValue">96%</output>
</label>
<input id="coreScale" type="range" min="78" max="104" step="1" value="96">
</div>
<div class="control-row">
<label class="control-label" for="wallThickness">
<span>Nominal wall target</span>
<output id="wallValue">2.4 mm</output>
</label>
<input id="wallThickness" type="range" min="1.0" max="4.5" step="0.1" value="2.4">
</div>
<div class="metric-grid">
<div class="metric">
<span>Core diameter</span>
<strong id="coreMetric">—</strong>
</div>
<div class="metric">
<span>Measured wall</span>
<strong id="wallMetric">—</strong>
</div>
</div>
<div class="button-row">
<button class="button primary" id="compare" type="button" aria-pressed="false">
Compare cutaway
</button>
</div>
<div class="button-row">
<button class="button" id="frontView" type="button">Front</button>
<button class="button" id="topView" type="button">Top</button>
<button class="button" id="resetView" type="button">Reset view</button>
</div>
</section>
<section class="section">
<div class="toggle-row">
<label for="uncertainty">Show historical uncertainty</label>
<span class="toggle">
<input id="uncertainty" type="checkbox" checked>
<span class="toggle-track"></span>
</span>
</div>
<p class="uncertainty-note">
<strong>Not an excavated measurement.</strong><br>
Plausible working ranges: core Ø 14–24 cm and wall 1.2–4.5 mm.
Amber dashed geometry marks uncertainty rather than a single exact reconstruction.
</p>
</section>
</aside>
<aside class="panel" id="method">
<div class="steps">
<div class="step"><b>01</b>Clay core</div>
<div class="step"><b>02</b>Piece molds</div>
<div class="step"><b>03</b>Pour bronze</div>
<div class="step active"><b>04</b>Strip mold</div>
</div>
<p>
<strong>A clay core establishes the hollow.</strong> Sectioned outer molds are assembled
around it, leaving a cavity for bronze. After cooling, each mold section can be
removed. This vessel, its section count, and its dimensions are a research exercise—not
a scan of a single excavated object.
</p>
</aside>
<div class="legend" aria-hidden="true">
<span class="legend-item"><i class="swatch bronze"></i>Bronze</span>
<span class="legend-item"><i class="swatch core"></i>Clay core</span>
<span class="legend-item"><i class="swatch range"></i>Possible range</span>
</div>
<div class="measure-label" id="coreLabel">CORE Ø —</div>
<div class="measure-label amber" id="wallLabel">WALL —</div>
<div id="hint">Drag to orbit · Scroll to zoom · Click a clay section to remove it</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
/* ------------------------------------------------------------------
Core scene
------------------------------------------------------------------ */
const canvas = document.querySelector("#scene");
const stage = document.querySelector("#stage");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.localClippingEnabled = true;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7dfd0);
scene.fog = new THREE.Fog(0xe7dfd0, 13, 24);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraState = {
theta: 0.68,
phi: 1.17,
radius: 10.1
};
const cameraGoal = { ...cameraState };
const cameraTarget = new THREE.Vector3(0, 2.45, 0);
let viewAnimating = true;
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraTarget.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraTarget.y + cameraState.radius * Math.cos(cameraState.phi),
cameraTarget.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraTarget);
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xfff6e7, 0x766b59, 2.15);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xfff1d2, 3.2);
key.position.set(-5, 9, 7);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -7;
key.shadow.camera.right = 7;
key.shadow.camera.top = 8;
key.shadow.camera.bottom = -3;
key.shadow.bias = -0.0004;
scene.add(key);
const fill = new THREE.DirectionalLight(0xbfd5c7, 1.0);
fill.position.set(6, 3, -5);
scene.add(fill);
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0xe1d8c8,
roughness: 1,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.09;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(16, 32, 0x8b806e, 0x9f9380);
grid.position.y = -0.082;
grid.material.transparent = true;
grid.material.opacity = 0.14;
scene.add(grid);
const bed = new THREE.Mesh(
new THREE.CylinderGeometry(1.64, 1.75, 0.18, 12),
new THREE.MeshStandardMaterial({
color: 0x79563b,
roughness: 0.98,
flatShading: true
})
);
bed.position.y = 0;
bed.receiveShadow = true;
bed.castShadow = true;
scene.add(bed);
/* ------------------------------------------------------------------
Materials and shared geometry helpers
------------------------------------------------------------------ */
const bronzeMaterial = new THREE.MeshStandardMaterial({
color: 0x547363,
metalness: 0.68,
roughness: 0.57,
flatShading: true,
side: THREE.DoubleSide
});
const innerBronzeMaterial = new THREE.MeshStandardMaterial({
color: 0x30473d,
metalness: 0.57,
roughness: 0.73,
flatShading: true,
side: THREE.DoubleSide
});
const bandMaterial = new THREE.MeshStandardMaterial({
color: 0x354f43,
metalness: 0.74,
roughness: 0.48,
flatShading: true,
side: THREE.DoubleSide
});
const coreMaterial = new THREE.MeshStandardMaterial({
color: 0xa76e4c,
roughness: 0.96,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide
});
const sectionMaterial = new THREE.MeshStandardMaterial({
color: 0xd18a3f,
roughness: 0.87,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide
});
const bronzeMaterials = [
bronzeMaterial,
innerBronzeMaterial,
bandMaterial
];
const outerProfile = [
[0.48, 0.15],
[0.72, 0.25],
[0.78, 0.48],
[0.68, 0.72],
[0.53, 0.98],
[0.45, 1.32],
[0.43, 2.05],
[0.48, 2.72],
[0.63, 3.42],
[0.87, 4.08],
[1.12, 4.58],
[1.18, 4.80]
];
const gaugeY = 2.72;
const CM_PER_UNIT = 10;
const NOMINAL_CORE_WALL = 0.024;
let innerProfile = [];
let coreScale = 0.96;
let wallMillimeters = 2.4;
let compareMode = false;
let showUncertainty = true;
function radiusAt(profile, y) {
if (y <= profile[0][1]) return profile[0][0];
for (let i = 1; i < profile.length; i++) {
const [r0, y0] = profile[i - 1];
const [r1, y1] = profile[i];
if (y <= y1) {
const t = (y - y0) / Math.max(0.0001, y1 - y0);
return THREE.MathUtils.lerp(r0, r1, t);
}
}
return profile[profile.length - 1][0];
}
function computeInnerProfile() {
const wallWorld = wallMillimeters / 100;
const result = [
[0.12, 0.88]
];
for (const [outerRadius, y] of outerProfile) {
if (y < 0.9) continue;
const nominalCoreRadius = Math.max(0.055, outerRadius - NOMINAL_CORE_WALL);
const scaledCoreRadius = nominalCoreRadius * coreScale;
const wallLimitedRadius = Math.max(0.035, outerRadius - wallWorld);
result.push([
Math.min(wallLimitedRadius, scaledCoreRadius),
y
]);
}
return result;
}
function disposeGroupGeometry(group) {
for (const child of [...group.children]) {
child.traverse(object => {
if (object.geometry) object.geometry.dispose();
});
group.remove(child);
}
}
function makeLine(points, color, dashed = false, opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map(p => new THREE.Vector3(...p))
);
const material = dashed
? new THREE.LineDashedMaterial({
color,
dashSize: 0.09,
gapSize: 0.055,
transparent: true,
opacity,
depthWrite: false
})
: new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity,
depthWrite: false
});
const line = new THREE.Line(geometry, material);
if (dashed) line.computeLineDistances();
return line;
}
function makeLineSegments(points, color, dashed = false, opacity = 1) {
const geometry = new THREE.BufferGeometry().setFromPoints(
points.map(p => new THREE.Vector3(...p))
);
const material = dashed
? new THREE.LineDashedMaterial({
color,
dashSize: 0.085,
gapSize: 0.055,
transparent: true,
opacity,
depthWrite: false
})
: new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity,
depthWrite: false
});
const line = new THREE.LineSegments(geometry, material);
if (dashed) line.computeLineDistances();
return line;
}
function makeCircleLine(radius, y, color, dashed = true, opacity = 0.7) {
const points = [];
const segments = 24;
for (let i = 0; i <= segments; i++) {
const angle = i / segments * Math.PI * 2;
points.push([Math.cos(angle) * radius, y, Math.sin(angle) * radius]);
}
return makeLine(points, color, dashed, opacity);
}
function makeProfileWire(profile, radialFactor, color, opacity) {
const points = [];
const segments = 12;
for (let row = 0; row < profile.length; row++) {
const [radius, y] = profile[row];
if (radius < 0.002) continue;
for (let i = 0; i < segments; i++) {
const a = i / segments * Math.PI * 2;
const b = (i + 1) / segments * Math.PI * 2;
points.push([
Math.cos(a) * radius * radialFactor,
y,
Math.sin(a) * radius * radialFactor
]);
points.push([
Math.cos(b) * radius * radialFactor,
y,
Math.sin(b) * radius * radialFactor
]);
}
if (row > 0) {
const previous = profile[row - 1];
if (previous[0] > 0.002) {
for (let i = 0; i < segments; i++) {
const angle = i / segments * Math.PI * 2;
points.push([
Math.cos(angle) * previous[0] * radialFactor,
previous[1],
Math.sin(angle) * previous[0] * radialFactor
]);
points.push([
Math.cos(angle) * radius * radialFactor,
y,
Math.sin(angle) * radius * radialFactor
]);
}
}
}
}
return makeLineSegments(points, color, true, opacity);
}
/* ------------------------------------------------------------------
Low-poly bronze vessel
------------------------------------------------------------------ */
const bronzeGroup = new THREE.Group();
const coreGroup = new THREE.Group();
const compareGroup = new THREE.Group();
const uncertaintyGroup = new THREE.Group();
scene.add(bronzeGroup, coreGroup, compareGroup);
compareGroup.add(uncertaintyGroup);
const clipPlane = new THREE.Plane(
new THREE.Vector3(0, 0, -1),
0
);
function addBronzeBand(group, y, radius) {
const band = new THREE.Mesh(
new THREE.TorusGeometry(radius + 0.018, 0.025, 4, 12),
bandMaterial
);
band.rotation.x = Math.PI / 2;
band.position.y = y;
band.castShadow = true;
band.receiveShadow = true;
group.add(band);
}
function buildBronze() {
disposeGroupGeometry(bronzeGroup);
const outer = new THREE.Mesh(
new THREE.LatheGeometry(
outerProfile.map(([r, y]) => new THREE.Vector2(r, y)),
12
),
bronzeMaterial
);
outer.castShadow = true;
outer.receiveShadow = true;
bronzeGroup.add(outer);
const inner = new THREE.Mesh(
new THREE.LatheGeometry(
innerProfile.map(([r, y]) => new THREE.Vector2(r, y)),
12
),
innerBronzeMaterial
);
inner.castShadow = true;
inner.receiveShadow = true;
bronzeGroup.add(inner);
const floorRadius = innerProfile[0][0];
const floor = new THREE.Mesh(
new THREE.CircleGeometry(floorRadius, 12),
innerBronzeMaterial
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = 0.88;
floor.receiveShadow = true;
bronzeGroup.add(floor);
const topOuter = outerProfile[outerProfile.length - 1][0];
const topInner = innerProfile[innerProfile.length - 1][0];
const rim = new THREE.Mesh(
new THREE.RingGeometry(topInner, topOuter, 12),
bandMaterial
);
rim.rotation.x = -Math.PI / 2;
rim.position.y = 4.8;
rim.castShadow = true;
bronzeGroup.add(rim);
const bandHeights = [0.74, 1.03, 2.72, 3.43, 4.53];
for (const y of bandHeights) {
addBronzeBand(bronzeGroup, y, radiusAt(outerProfile, y));
}
// Small low-poly relief bosses around the shoulder.
const bossHeight = 3.63;
const bossRadius = radiusAt(outerProfile, bossHeight) + 0.025;
for (let i = 0; i < 10; i++) {
const angle = i / 10 * Math.PI * 2;
const boss = new THREE.Mesh(
new THREE.ConeGeometry(0.035, 0.11, 4),
bandMaterial
);
boss.position.set(
Math.cos(angle) * bossRadius,
bossHeight,
Math.sin(angle) * bossRadius
);
boss.castShadow = true;
bronzeGroup.add(boss);
}
}
function buildCore() {
disposeGroupGeometry(coreGroup);
const solidProfile = [[0, 0.86], ...innerProfile];
const core = new THREE.Mesh(
new THREE.LatheGeometry(
solidProfile.map(([r, y]) => new THREE.Vector2(r, y)),
12
),
coreMaterial
);
core.castShadow = true;
core.receiveShadow = true;
coreGroup.add(core);
const topRadius = innerProfile[innerProfile.length - 1][0];
const cap = new THREE.Mesh(
new THREE.CircleGeometry(topRadius, 12),
coreMaterial
);
cap.rotation.x = -Math.PI / 2;
cap.position.y = 4.8;
coreGroup.add(cap);
}
function buildWallSection() {
const positions = [];
const indices = [];
const steps = 28;
function appendSide(sign) {
const base = positions.length / 3;
for (let i = 0; i <= steps; i++) {
const y = THREE.MathUtils.lerp(0.91, 4.8, i / steps);
const outerRadius = radiusAt(outerProfile, y);
const innerRadius = radiusAt(innerProfile, y);
positions.push(sign * outerRadius, y, 0);
positions.push(sign * innerRadius, y, 0);
}
for (let i = 0; i < steps; i++) {
const a = base + i * 2;
const b = a + 1;
const c = a + 2;
const d = a + 3;
indices.push(a, b, c, b, d, c);
}
}
appendSide(1);
appendSide(-1);
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const section = new THREE.Mesh(geometry, sectionMaterial);
section.renderOrder = 3;
return section;
}
function buildMeasurements() {
const measurements = new THREE.Group();
const coreRadius = Math.max(...innerProfile.map(p => p[0]));
const dimensionY = 5.03;
const corePoints = [
[-coreRadius, dimensionY, 0],
[coreRadius, dimensionY, 0],
[-coreRadius, dimensionY - 0.09, 0],
[-coreRadius, dimensionY + 0.09, 0],
[coreRadius, dimensionY - 0.09, 0],
[coreRadius, dimensionY + 0.09, 0]
];
measurements.add(makeLineSegments(corePoints, 0xf1dfbd));
const outerRadius = radiusAt(outerProfile, gaugeY);
const innerRadius = radiusAt(innerProfile, gaugeY);
const wallPoints = [
[innerRadius, gaugeY, 0],
[outerRadius, gaugeY, 0],
[innerRadius, gaugeY - 0.07, 0],
[innerRadius, gaugeY + 0.07, 0],
[outerRadius, gaugeY - 0.07, 0],
[outerRadius, gaugeY + 0.07, 0]
];
measurements.add(makeLineSegments(wallPoints, 0xe7a54b));
return measurements;
}
function buildCompareVisuals() {
disposeGroupGeometry(compareGroup);
const wallSection = buildWallSection();
compareGroup.add(wallSection);
const measurements = buildMeasurements();
compareGroup.add(measurements);
const minCore = makeProfileWire(innerProfile, 0.92, 0xc37a2c, 0.48);
const maxCore = makeProfileWire(innerProfile, 1.08, 0xc37a2c, 0.48);
uncertaintyGroup.add(minCore, maxCore);
const outerRadius = radiusAt(outerProfile, gaugeY);
const innerRadius = radiusAt(innerProfile, gaugeY);
uncertaintyGroup.add(
makeCircleLine(outerRadius + 0.015, gaugeY, 0xc37a2c, true, 0.65),
makeCircleLine(Math.max(0.01, innerRadius - 0.015), gaugeY, 0xc37a2c, true, 0.65)
);
}
function setClipping() {
for (const material of bronzeMaterials) {
material.clippingPlanes = compareMode ? [clipPlane] : [];
material.clipShadows = true;
material.needsUpdate = true;
}
}
function updateMetrics() {
const coreRadius = Math.max(...innerProfile.map(p => p[0]));
const coreDiameterCM = coreRadius * 2 * CM_PER_UNIT;
const outerRadius = radiusAt(outerProfile, gaugeY);
const innerRadius = radiusAt(innerProfile, gaugeY);
const actualWallMM = (outerRadius - innerRadius) * 100;
document.querySelector("#coreMetric").textContent =
`${coreDiameterCM.toFixed(1)} cm`;
document.querySelector("#wallMetric").textContent =
`${actualWallMM.toFixed(1)} mm`;
document.querySelector("#coreLabel").textContent =
`CORE Ø ${coreDiameterCM.toFixed(1)} CM · HYPOTHESIS`;
document.querySelector("#wallLabel").textContent =
`WALL ${actualWallMM.toFixed(1)} MM · GAUGE`;
return { coreDiameterCM, actualWallMM };
}
function rebuildGeometry() {
innerProfile = computeInnerProfile();
buildBronze();
buildCore();
buildCompareVisuals();
updateMetrics();
setClipping();
updateVisibility();
}
/* ------------------------------------------------------------------
Sectioned clay mold
------------------------------------------------------------------ */
const moldGroup = new THREE.Group();
scene.add(moldGroup);
const moldSections = [];
const moldButtons = [];
const pieceNames = [
"Front",
"Front right",
"Back right",
"Back",
"Back left",
"Front left"
];
const sectionCenters = [
Math.PI / 2,
Math.PI / 6,
-Math.PI / 6,
-Math.PI / 2,
-5 * Math.PI / 6,
5 * Math.PI / 6
];
function moldRows() {
const rows = [];
rows.push([radiusAt(outerProfile, 0.10), 0.10]);
for (const [r, y] of outerProfile) rows.push([r, y]);
rows.push([radiusAt(outerProfile, 4.95), 4.95]);
return rows;
}
function createMoldGeometry(startAngle, endAngle) {
const rows = moldRows();
const arcSegments = 6;
const rowCount = rows.length;
const colCount = arcSegments + 1;
const innerOffset = rowCount * colCount;
const positions = [];
const colors = [];
const indices = [];
const gap = 0.055;
const thickness = 0.33;
function addVertex(x, y, z, layer, row, col) {
const variation =
Math.sin(row * 12.73 + col * 4.17 + layer * 1.9) * 0.045;
const color = new THREE.Color();
color.setHSL(
0.072 + Math.sin(row * 2.1 + col) * 0.006,
0.39,
0.39 + variation - layer * 0.025
);
positions.push(x, y, z);
colors.push(color.r, color.g, color.b);
}
for (let layer = 0; layer < 2; layer++) {
for (let row = 0; row < rowCount; row++) {
const [radius, y] = rows[row];
const r = radius + gap + (layer === 0 ? thickness : 0);
for (let col = 0; col < colCount; col++) {
const t = col / arcSegments;
const angle = THREE.MathUtils.lerp(startAngle, endAngle, t);
addVertex(
Math.cos(angle) * r,
y,
Math.sin(angle) * r,
layer,
row,
col
);
}
}
}
const outerIndex = (row, col) => row * colCount + col;
const innerIndex = (row, col) => innerOffset + row * colCount + col;
for (let row = 0; row < rowCount - 1; row++) {
for (let col = 0; col < arcSegments; col++) {
const a = outerIndex(row, col);
const b = outerIndex(row, col + 1);
const c = outerIndex(row + 1, col);
const d = outerIndex(row + 1, col + 1);
indices.push(a, c, b, b, c, d);
const ia = innerIndex(row, col);
const ib = innerIndex(row, col + 1);
const ic = innerIndex(row + 1, col);
const id = innerIndex(row + 1, col + 1);
indices.push(ia, ib, ic, ib, id, ic);
}
}
// Start and end faces of each removable clay section.
for (let row = 0; row < rowCount - 1; row++) {
const o0 = outerIndex(row, 0);
const o1 = outerIndex(row + 1, 0);
const i0 = innerIndex(row, 0);
const i1 = innerIndex(row + 1, 0);
indices.push(o0, i0, o1, i0, i1, o1);
const oe0 = outerIndex(row, arcSegments);
const oe1 = outerIndex(row + 1, arcSegments);
const ie0 = innerIndex(row, arcSegments);
const ie1 = innerIndex(row + 1, arcSegments);
indices.push(oe0, oe1, ie0, ie0, oe1, ie1);
}
// Top and bottom caps.
for (let col = 0; col < arcSegments; col++) {
const ot0 = outerIndex(0, col);
const ot1 = outerIndex(0, col + 1);
const it0 = innerIndex(0, col);
const it1 = innerIndex(0, col + 1);
indices.push(ot0, ot1, it0, it1, ot0, it1);
const ob0 = outerIndex(rowCount - 1, col);
const ob1 = outerIndex(rowCount - 1, col + 1);
const ib0 = innerIndex(rowCount - 1, col);
const ib1 = innerIndex(rowCount - 1, col + 1);
indices.push(ob0, ib0, ob1, ib1, ob0, ob1);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(colors, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
function addRunnerToSection(group, direction, index) {
if (index !== 0 && index !== 3) return;
const radius = radiusAt(outerProfile, 3.65) + 0.30;
const runner = new THREE.Mesh(
new THREE.CylinderGeometry(0.075, 0.10, 0.92, 6),
new THREE.MeshStandardMaterial({
color: 0x8d6040,
roughness: 0.96,
flatShading: true
})
);
runner.position.set(
direction.x * radius,
3.68,
direction.z * radius
);
runner.castShadow = true;
group.add(runner);
}
function buildMolds() {
const sectionAngle = Math.PI * 2 / 6;
const gapAngle = 0.055;
for (let i = 0; i < 6; i++) {
const center = sectionCenters[i];
const start = center - sectionAngle / 2 + gapAngle;
const end = center + sectionAngle / 2 - gapAngle;
const geometry = createMoldGeometry(start, end);
const material = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.97,
metalness: 0,
flatShading: true,
side: THREE.DoubleSide,
transparent: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.userData.sectionIndex = i;
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x4b3425,
transparent: true,
opacity: 0.62
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 18),
edgeMaterial
);
const group = new THREE.Group();
group.add(mesh, edges);
const direction = new THREE.Vector3(
Math.cos(center),
0,
Math.sin(center)
);
addRunnerToSection(group, direction, i);
moldGroup.add(group);
moldSections.push({
group,
mesh,
material,
edgeMaterial,
direction,
removed: false,
removalAmount: 0
});
}
}
function updateMoldButtons() {
moldSections.forEach((section, index) => {
const button = moldButtons[index];
button.classList.toggle("removed", section.removed);
button.setAttribute("aria-pressed", String(section.removed));
button.querySelector(".state").textContent =
section.removed ? "removed" : "remove";
});
const count = moldSections.filter(section => section.removed).length;
document.querySelector("#statusText").textContent = compareMode
? "Half-section view · historical range visible"
: count === 0
? "0 of 6 mold sections removed"
: count === 6
? "Casting fully revealed"
: `${count} of 6 mold sections removed`;
}
function toggleMold(index) {
moldSections[index].removed = !moldSections[index].removed;
updateMoldButtons();
}
function setAllMolds(removed) {
for (const section of moldSections) section.removed = removed;
updateMoldButtons();
}
const moldGrid = document.querySelector("#moldGrid");
pieceNames.forEach((name, index) => {
const button = document.createElement("button");
button.type = "button";
button.className = "piece-button";
button.setAttribute("aria-pressed", "false");
button.innerHTML = `
<span>${name}</span>
<span class="state">remove</span>
`;
button.addEventListener("click", () => toggleMold(index));
moldGrid.appendChild(button);
moldButtons.push(button);
});
/* ------------------------------------------------------------------
Interaction, comparison mode, and controls
------------------------------------------------------------------ */
function updateVisibility() {
coreGroup.visible = compareMode;
compareGroup.visible = compareMode;
uncertaintyGroup.visible = compareMode && showUncertainty;
document.querySelector("#coreLabel").style.display =
compareMode ? "block" : "none";
document.querySelector("#wallLabel").style.display =
compareMode ? "block" : "none";
const compareButton = document.querySelector("#compare");
compareButton.setAttribute("aria-pressed", String(compareMode));
compareButton.textContent = compareMode
? "Return to casting"
: "Compare cutaway";
updateMoldButtons();
}
document.querySelector("#coreScale").addEventListener("input", event => {
coreScale = Number(event.target.value) / 100;
document.querySelector("#coreScaleValue").textContent =
`${event.target.value}%`;
rebuildGeometry();
});
document.querySelector("#wallThickness").addEventListener("input", event => {
wallMillimeters = Number(event.target.value);
document.querySelector("#wallValue").textContent =
`${wallMillimeters.toFixed(1)} mm`;
rebuildGeometry();
});
document.querySelector("#uncertainty").addEventListener("change", event => {
showUncertainty = event.target.checked;
uncertaintyGroup.visible = compareMode && showUncertainty;
});
document.querySelector("#compare").addEventListener("click", () => {
compareMode = !compareMode;
setClipping();
updateVisibility();
if (compareMode) {
setView({ theta: 0.76, phi: 1.18, radius: 9.6 });
}
});
document.querySelector("#removeAll").addEventListener("click", () => {
setAllMolds(true);
});
document.querySelector("#restoreAll").addEventListener("click", () => {
setAllMolds(false);
});
function setView(values) {
Object.assign(cameraGoal, values);
viewAnimating = true;
}
document.querySelector("#frontView").addEventListener("click", () => {
setView({ theta: 0.02, phi: 1.25, radius: 10.2 });
});
document.querySelector("#topView").addEventListener("click", () => {
setView({ theta: 0.02, phi: 0.16, radius: 9.7 });
});
document.querySelector("#resetView").addEventListener("click", () => {
setView({ theta: 0.68, phi: 1.17, radius: 10.1 });
});
/* ------------------------------------------------------------------
Custom camera controls — no addons
------------------------------------------------------------------ */
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let pointerDown = false;
let pointerMoved = false;
let previousX = 0;
let previousY = 0;
let hoveredSection = null;
function updatePointer(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function findHoveredSection(event) {
if (compareMode) return null;
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(
moldSections.map(section => section.mesh),
false
);
if (!intersections.length) return null;
return moldSections[intersections[0].object.userData.sectionIndex];
}
function setHoveredSection(section) {
if (hoveredSection === section) return;
if (hoveredSection) {
hoveredSection.material.emissive.setHex(0x000000);
hoveredSection.material.emissiveIntensity = 0;
}
hoveredSection = section;
if (hoveredSection) {
hoveredSection.material.emissive.setHex(0x4a2813);
hoveredSection.material.emissiveIntensity = 0.28;
canvas.style.cursor = "pointer";
document.querySelector("#hint").textContent =
`Click to remove the ${pieceNames[hoveredSection.group.userData.index || 0]} clay section`;
} else {
canvas.style.cursor = "grab";
document.querySelector("#hint").textContent =
"Drag to orbit · Scroll to zoom · Click a clay section to remove it";
}
}
canvas.addEventListener("pointerdown", event => {
pointerDown = true;
pointerMoved = false;
previousX = event.clientX;
previousY = event.clientY;
viewAnimating = false;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", event => {
if (pointerDown) {
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
if (Math.abs(dx) + Math.abs(dy) > 2) pointerMoved = true;
cameraState.theta -= dx * 0.007;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.006,
0.12,
1.48
);
previousX = event.clientX;
previousY = event.clientY;
} else {
setHoveredSection(findHoveredSection(event));
}
});
canvas.addEventListener("pointerup", event => {
pointerDown = false;
if (!pointerMoved) {
const section = findHoveredSection(event);
if (section) toggleMold(section.group.userData.index);
}
canvas.style.cursor = hoveredSection ? "pointer" : "grab";
});
canvas.addEventListener("pointercancel", () => {
pointerDown = false;
canvas.style.cursor = "grab";
});
canvas.addEventListener("pointerleave", () => {
if (!pointerDown) setHoveredSection(null);
});
canvas.addEventListener("wheel", event => {
event.preventDefault();
viewAnimating = false;
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
6.2,
15
);
}, { passive: false });
/* ------------------------------------------------------------------
Projected measurement labels
------------------------------------------------------------------ */
const coreLabelElement = document.querySelector("#coreLabel");
const wallLabelElement = document.querySelector("#wallLabel");
function positionLabel(element, worldPoint) {
const projected = worldPoint.clone().project(camera);
const visible = projected.z > -1 && projected.z < 1;
if (!visible) {
element.style.display = "none";
return;
}
element.style.display = "block";
element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
/* ------------------------------------------------------------------
Resize and animation
------------------------------------------------------------------ */
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
function animate() {
requestAnimationFrame(animate);
if (viewAnimating) {
cameraState.theta = THREE.MathUtils.lerp(cameraState.theta, cameraGoal.theta, 0.10);
cameraState.phi = THREE.MathUtils.lerp(cameraState.phi, cameraGoal.phi, 0.10);
cameraState.radius = THREE.MathUtils.lerp(cameraState.radius, cameraGoal.radius, 0.10);
if (
Math.abs(cameraState.theta - cameraGoal.theta) < 0.001 &&
Math.abs(cameraState.phi - cameraGoal.phi) < 0.001 &&
Math.abs(cameraState.radius - cameraGoal.radius) < 0.001
) {
viewAnimating = false;
}
}
updateCamera();
for (const section of moldSections) {
const target = compareMode || section.removed ? 1 : 0;
section.removalAmount = THREE.MathUtils.lerp(
section.removalAmount,
target,
0.105
);
const amount = section.removalAmount;
section.group.position.copy(section.direction).multiplyScalar(amount * 2.35);
section.group.position.y = amount * 0.16;
section.material.opacity = 1 - amount * 0.96;
section.material.depthWrite = amount < 0.04;
section.edgeMaterial.opacity = 0.62 * (1 - amount);
section.group.visible = amount < 0.995;
}
if (compareMode) {
const coreRadius = Math.max(...innerProfile.map(p => p[0]));
positionLabel(
coreLabelElement,
new THREE.Vector3(0, 5.30, 0)
);
positionLabel(
wallLabelElement,
new THREE.Vector3(
radiusAt(outerProfile, gaugeY) + 0.44,
gaugeY + 0.16,
0
)
);
}
renderer.render(scene, camera);
}
/* ------------------------------------------------------------------
Initialize
------------------------------------------------------------------ */
buildMolds();
moldSections.forEach((section, index) => {
section.group.userData.index = index;
});
rebuildGeometry();
updateMoldButtons();
canvas.style.cursor = "grab";
animate();
</script>
</body>
</html>
```