Prompt specification
Build or customize the Three.js 3D scene "Piece-mold assembly around a core" 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: Piece-mold assembly around a core
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/piece-mold-assembly-around-a-core-x2318
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Shang-era bronze casting with piece molds. Animate labeled mold sections closing around a central core with a visible gap. Keep the casting cavity continuous and avoid unsupported details of a specific archaeological object. Low-poly.
Working Three.js Starter (piece-mold-assembly-around-a-core-x2318):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shang-Era Bronze Casting with Piece Molds</title>
<style>
:root {
color-scheme: dark;
--panel: rgba(25, 23, 19, 0.88);
--line: rgba(224, 190, 126, 0.22);
--text: #eee4d1;
--muted: #b9ad97;
--bronze: #d89448;
--clay: #b47a48;
--mold: #aaa08d;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #171612;
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--panel);
box-shadow: 0 12px 38px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
}
#intro {
top: 20px;
left: 20px;
width: min(390px, calc(100vw - 40px));
padding: 17px 18px 15px;
border-radius: 14px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--bronze);
font-size: 11px;
font-weight: 750;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(22px, 3vw, 30px);
font-weight: 500;
line-height: 1.08;
}
#intro p {
margin: 10px 0 13px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
button {
appearance: none;
border: 1px solid rgba(225, 190, 129, 0.3);
border-radius: 8px;
padding: 8px 11px;
background: rgba(215, 151, 73, 0.1);
color: var(--text);
font: inherit;
font-size: 12px;
cursor: pointer;
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover {
border-color: rgba(225, 190, 129, 0.65);
background: rgba(215, 151, 73, 0.2);
}
button:active {
transform: translateY(1px);
}
button.primary {
border-color: rgba(216, 148, 72, 0.62);
background: rgba(216, 148, 72, 0.2);
}
#timeline {
position: relative;
height: 3px;
margin-top: 14px;
overflow: hidden;
border-radius: 999px;
background: rgba(255, 255, 255, 0.09);
}
#timeline-fill {
width: 0;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #805027, #e0a052);
transition: width 80ms linear;
}
#status {
min-height: 18px;
margin-top: 9px;
color: #d5c8b2;
font-size: 11px;
}
#legend {
left: 20px;
bottom: 20px;
padding: 12px 14px;
border-radius: 12px;
font-size: 11px;
line-height: 1.7;
}
.legend-row {
display: flex;
align-items: center;
gap: 8px;
color: var(--muted);
}
.swatch {
width: 12px;
height: 12px;
flex: 0 0 auto;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 3px;
}
.swatch.core {
background: var(--clay);
}
.swatch.mold {
background: var(--mold);
}
.swatch.bronze {
background: var(--bronze);
}
.note {
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--line);
color: #9f9482;
font-size: 10px;
line-height: 1.45;
}
#help {
right: 20px;
bottom: 20px;
padding: 9px 12px;
border-radius: 9px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.02em;
}
#labels,
#leaders {
position: fixed;
inset: 0;
z-index: 5;
width: 100%;
height: 100%;
pointer-events: none;
}
#leaders {
z-index: 4;
overflow: visible;
}
.world-label {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, -50%);
padding: 5px 8px;
border: 1px solid rgba(235, 207, 158, 0.32);
border-radius: 6px;
background: rgba(25, 22, 18, 0.82);
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
color: #f0e5d1;
font-size: 10px;
font-weight: 650;
letter-spacing: 0.035em;
white-space: nowrap;
backdrop-filter: blur(5px);
}
.world-label.core {
border-color: rgba(180, 122, 72, 0.72);
color: #e2aa78;
}
.world-label.bronze {
border-color: rgba(216, 148, 72, 0.8);
color: #f1b866;
}
.world-label.mold {
border-color: rgba(188, 180, 159, 0.58);
color: #ddd5c4;
}
.leader {
stroke: rgba(226, 198, 149, 0.55);
stroke-width: 1;
stroke-dasharray: 3 3;
}
@media (max-width: 680px) {
#intro {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 14px;
}
#intro p {
display: none;
}
#legend {
left: 10px;
bottom: 10px;
}
#help {
right: 10px;
bottom: 10px;
}
.world-label {
font-size: 9px;
}
}
</style>
</head>
<body>
<main id="scene" aria-label="Interactive low-poly diagram of Shang-era bronze casting"></main>
<div id="labels"></div>
<svg id="leaders" aria-hidden="true"></svg>
<section id="intro" class="panel">
<div class="eyebrow">Process reconstruction</div>
<h1>Shang-era bronze casting</h1>
<p>
Four low-poly clay mold sections close around a central core.
A continuous annular cavity remains between the core and the molds.
</p>
<div class="controls">
<button id="replay" class="primary" type="button">Replay assembly</button>
<button id="pause" type="button">Pause</button>
<button id="camera-reset" type="button">Reset camera</button>
</div>
<div id="timeline" aria-hidden="true">
<div id="timeline-fill"></div>
</div>
<div id="status" role="status" aria-live="polite">
Preparing the piece molds…
</div>
</section>
<section id="legend" class="panel" aria-label="Diagram legend">
<div class="legend-row">
<span class="swatch core"></span>
<span>Central clay core</span>
</div>
<div class="legend-row">
<span class="swatch mold"></span>
<span>Separate clay mold pieces</span>
</div>
<div class="legend-row">
<span class="swatch bronze"></span>
<span>Continuous bronze cavity</span>
</div>
<div class="note">
Generic process diagram; it does not reproduce the details of a
specific excavated object.
</div>
</section>
<div id="help" class="panel">
Drag to orbit · Scroll to zoom · Space to pause
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, scene, and camera
// ------------------------------------------------------------
const container = document.querySelector("#scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x171612);
scene.fog = new THREE.Fog(0x171612, 12, 24);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
container.appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(
0xd8c29e,
0x30271e,
1.65
);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffe3b8, 3.0);
keyLight.position.set(5.5, 8.5, 5.0);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -7;
keyLight.shadow.camera.right = 7;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 25;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x7894a6, 0.8);
fillLight.position.set(-5, 4, -4);
scene.add(fillLight);
const bronzeLight = new THREE.PointLight(0xff8d32, 0, 8, 2);
bronzeLight.position.set(1.7, 3.0, 1.7);
scene.add(bronzeLight);
// Neutral work area: intentionally free of object-specific decoration.
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
new THREE.MeshStandardMaterial({
color: 0x24211c,
roughness: 1
})
);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
const workSurface = new THREE.Mesh(
new THREE.BoxGeometry(7.8, 0.24, 6.2),
new THREE.MeshStandardMaterial({
color: 0x493a29,
roughness: 0.94,
flatShading: true
})
);
workSurface.position.y = 0.12;
workSurface.receiveShadow = true;
workSurface.castShadow = true;
scene.add(workSurface);
// A few restrained plank divisions provide scale without implying
// a specific archaeological object.
const plankMaterial = new THREE.MeshStandardMaterial({
color: 0x2e261d,
roughness: 1
});
for (const z of [-1.85, -0.62, 0.62, 1.85]) {
const seam = new THREE.Mesh(
new THREE.BoxGeometry(7.45, 0.012, 0.025),
plankMaterial
);
seam.position.set(0, 0.247, z);
scene.add(seam);
}
const castingBed = new THREE.Mesh(
new THREE.CylinderGeometry(2.55, 2.72, 0.18, 16),
new THREE.MeshStandardMaterial({
color: 0x655643,
roughness: 0.95,
flatShading: true
})
);
castingBed.position.y = 0.33;
castingBed.receiveShadow = true;
castingBed.castShadow = true;
scene.add(castingBed);
// ------------------------------------------------------------
// Assembly dimensions
// ------------------------------------------------------------
const MOLD_HEIGHT = 1.75;
const MOLD_CENTER_Y = 1.30;
const MOLD_INNER_RADIUS = 1.24;
const MOLD_OUTER_RADIUS = 1.91;
const CORE_HEIGHT = 1.78;
const CORE_CENTER_Y = 1.31;
const CAVITY_BOTTOM = 0.43;
const CAVITY_HEIGHT = 1.70;
const CAVITY_INNER_RADIUS = 1.015;
const CAVITY_OUTER_RADIUS = 1.225;
// ------------------------------------------------------------
// Central low-poly clay core
// ------------------------------------------------------------
const core = new THREE.Mesh(
new THREE.CylinderGeometry(
0.78,
0.94,
CORE_HEIGHT,
10,
1,
false
),
new THREE.MeshStandardMaterial({
color: 0xa86e40,
roughness: 0.96,
flatShading: true
})
);
core.position.y = CORE_CENTER_Y;
core.castShadow = true;
core.receiveShadow = true;
scene.add(core);
const coreEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(core.geometry, 18),
new THREE.LineBasicMaterial({
color: 0x6d4227,
transparent: true,
opacity: 0.36
})
);
coreEdges.position.copy(core.position);
scene.add(coreEdges);
// ------------------------------------------------------------
// Four separate annular-sector mold pieces
// ------------------------------------------------------------
function makeMoldPieceGeometry(
startAngle,
endAngle,
innerRadius,
outerRadius,
height
) {
const shape = new THREE.Shape();
shape.moveTo(
innerRadius * Math.cos(startAngle),
innerRadius * Math.sin(startAngle)
);
shape.lineTo(
outerRadius * Math.cos(startAngle),
outerRadius * Math.sin(startAngle)
);
shape.absarc(
0,
0,
outerRadius,
startAngle,
endAngle,
false
);
shape.lineTo(
innerRadius * Math.cos(endAngle),
innerRadius * Math.sin(endAngle)
);
shape.absarc(
0,
0,
innerRadius,
endAngle,
startAngle,
true
);
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: height,
bevelEnabled: false,
steps: 1,
curveSegments: 4
});
// Shape XY becomes XZ; extrusion becomes vertical.
geometry.rotateX(Math.PI / 2);
geometry.translate(0, height / 2, 0);
geometry.computeVertexNormals();
return geometry;
}
const moldColors = [
0x8f8676,
0x9b8d78,
0x827a6d,
0x9a927f
];
const moldPieces = [];
const pieceLabels = [];
const sectorGap = 0.018;
for (let i = 0; i < 4; i++) {
const start = i * Math.PI / 2 + sectorGap;
const end = (i + 1) * Math.PI / 2 - sectorGap;
const middle = (start + end) / 2;
const group = new THREE.Group();
group.position.y = MOLD_CENTER_Y;
group.userData.middle = middle;
group.userData.delay = 0.10 + i * 0.40;
group.userData.direction = new THREE.Vector3(
Math.cos(middle),
0,
Math.sin(middle)
);
group.userData.twist = i % 2 === 0 ? 1 : -1;
const geometry = makeMoldPieceGeometry(
start,
end,
MOLD_INNER_RADIUS,
MOLD_OUTER_RADIUS,
MOLD_HEIGHT
);
const material = new THREE.MeshStandardMaterial({
color: moldColors[i],
roughness: 0.97,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
const edgeMaterial = new THREE.LineBasicMaterial({
color: 0x443f35,
transparent: true,
opacity: 0.58
});
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 22),
edgeMaterial
);
group.add(edges);
scene.add(group);
moldPieces.push(group);
}
// ------------------------------------------------------------
// One uninterrupted annular casting volume
// ------------------------------------------------------------
function makeAnnularVolumeGeometry(
innerRadius,
outerRadius,
height,
segments = 24
) {
const positions = [];
const indices = [];
for (let i = 0; i <= segments; i++) {
const angle = (i / segments) * Math.PI * 2;
const c = Math.cos(angle);
const s = Math.sin(angle);
positions.push(
innerRadius * c, 0, innerRadius * s,
outerRadius * c, 0, outerRadius * s,
innerRadius * c, height, innerRadius * s,
outerRadius * c, height, outerRadius * s
);
}
for (let i = 0; i < segments; i++) {
const a = i * 4;
const b = (i + 1) * 4;
const innerBottom = a;
const outerBottom = a + 1;
const innerTop = a + 2;
const outerTop = a + 3;
const nextInnerBottom = b;
const nextOuterBottom = b + 1;
const nextInnerTop = b + 2;
const nextOuterTop = b + 3;
// Top annulus
indices.push(
innerTop, outerTop, nextOuterTop,
innerTop, nextOuterTop, nextInnerTop
);
// Bottom annulus
indices.push(
innerBottom, nextInnerBottom, nextOuterBottom,
innerBottom, nextOuterBottom, outerBottom
);
// Outer wall
indices.push(
outerBottom, nextOuterBottom, nextOuterTop,
outerBottom, nextOuterTop, outerTop
);
// Inner wall
indices.push(
innerBottom, innerTop, nextInnerTop,
innerBottom, nextInnerTop, nextInnerBottom
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
const cavityMaterial = new THREE.MeshStandardMaterial({
color: 0x7b451f,
emissive: 0x2b1004,
emissiveIntensity: 0.08,
metalness: 0.72,
roughness: 0.38,
transparent: true,
opacity: 0.13,
side: THREE.DoubleSide,
flatShading: true
});
const cavityGroup = new THREE.Group();
cavityGroup.position.y = CAVITY_BOTTOM;
const cavityMesh = new THREE.Mesh(
makeAnnularVolumeGeometry(
CAVITY_INNER_RADIUS,
CAVITY_OUTER_RADIUS,
CAVITY_HEIGHT,
24
),
cavityMaterial
);
cavityMesh.castShadow = true;
cavityMesh.receiveShadow = true;
cavityGroup.add(cavityMesh);
// A single, unbroken annular form visually confirms that the
// casting space continues behind all four mold seams.
scene.add(cavityGroup);
// ------------------------------------------------------------
// Projected HTML labels
// ------------------------------------------------------------
const labelLayer = document.querySelector("#labels");
const leaderSvg = document.querySelector("#leaders");
const labels = [];
function createWorldLabel(text, className, anchorFunction, offset) {
const element = document.createElement("div");
element.className = `world-label ${className}`;
element.textContent = text;
labelLayer.appendChild(element);
const line = document.createElementNS(
"http://www.w3.org/2000/svg",
"line"
);
line.setAttribute("class", "leader");
leaderSvg.appendChild(line);
labels.push({
element,
line,
anchorFunction,
offset
});
}
createWorldLabel(
"Central clay core",
"core",
() => new THREE.Vector3(0, 2.28, 0),
{ x: -95, y: -62 }
);
createWorldLabel(
"Continuous casting cavity",
"bronze",
() => cavityGroup.localToWorld(
new THREE.Vector3(1.12, CAVITY_HEIGHT, 0)
),
{ x: 94, y: -55 }
);
const moldNames = [
"Piece mold A",
"Piece mold B",
"Piece mold C",
"Piece mold D"
];
const moldOffsets = [
{ x: 58, y: -65 },
{ x: 102, y: 4 },
{ x: 54, y: 72 },
{ x: -94, y: 18 }
];
moldPieces.forEach((piece, index) => {
createWorldLabel(
moldNames[index],
"mold",
() => {
const middle = piece.userData.middle;
return piece.localToWorld(
new THREE.Vector3(
Math.cos(middle) * 1.58,
MOLD_HEIGHT / 2 + 0.10,
Math.sin(middle) * 1.58
)
);
},
moldOffsets[index]
);
});
function updateLabels() {
const width = window.innerWidth;
const height = window.innerHeight;
for (const label of labels) {
const world = label.anchorFunction();
const projected = world.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.35 &&
projected.x < 1.35 &&
projected.y > -1.35 &&
projected.y < 1.35;
if (!visible) {
label.element.style.display = "none";
label.line.style.display = "none";
continue;
}
label.element.style.display = "block";
label.line.style.display = "block";
const anchorX = (projected.x * 0.5 + 0.5) * width;
const anchorY = (-projected.y * 0.5 + 0.5) * height;
const labelX = anchorX + label.offset.x;
const labelY = anchorY + label.offset.y;
label.element.style.left = `${labelX}px`;
label.element.style.top = `${labelY}px`;
label.line.setAttribute("x1", anchorX);
label.line.setAttribute("y1", anchorY);
label.line.setAttribute("x2", labelX);
label.line.setAttribute("y2", labelY);
}
}
// ------------------------------------------------------------
// Direct camera controls: no addons are imported
// ------------------------------------------------------------
const cameraState = {
target: new THREE.Vector3(0, 1.2, 0),
radius: 8.25,
theta: 0.83,
phi: 1.03
};
const defaultCamera = {
radius: 8.25,
theta: 0.83,
phi: 1.03
};
let dragging = false;
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - pointerX;
const deltaY = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
cameraState.theta -= deltaX * 0.006;
cameraState.phi -= deltaY * 0.005;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi,
0.42,
1.42
);
});
function endDrag(event) {
dragging = false;
if (
renderer.domElement.hasPointerCapture &&
renderer.domElement.hasPointerCapture(event.pointerId)
) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.007,
5.2,
13.5
);
}, { passive: false });
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
const cosPhi = Math.cos(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.cos(cameraState.theta),
cameraState.target.y +
cameraState.radius * cosPhi,
cameraState.target.z +
cameraState.radius * sinPhi * Math.sin(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
document.querySelector("#camera-reset").addEventListener("click", () => {
cameraState.radius = defaultCamera.radius;
cameraState.theta = defaultCamera.theta;
cameraState.phi = defaultCamera.phi;
});
// ------------------------------------------------------------
// Assembly animation
// ------------------------------------------------------------
const replayButton = document.querySelector("#replay");
const pauseButton = document.querySelector("#pause");
const statusElement = document.querySelector("#status");
const timelineFill = document.querySelector("#timeline-fill");
const ANIMATION_DURATION = 6.0;
let simulationTime = 0;
let paused = false;
let previousTime = performance.now();
function smoothstep(edge0, edge1, value) {
const x = THREE.MathUtils.clamp(
(value - edge0) / (edge1 - edge0),
0,
1
);
return x * x * (3 - 2 * x);
}
function resetAnimation() {
simulationTime = 0;
paused = false;
pauseButton.textContent = "Pause";
previousTime = performance.now();
}
replayButton.addEventListener("click", resetAnimation);
pauseButton.addEventListener("click", () => {
paused = !paused;
pauseButton.textContent = paused ? "Resume" : "Pause";
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
}
if (event.key.toLowerCase() === "r") {
resetAnimation();
}
});
const bronzeStartColor = new THREE.Color(0x7b451f);
const bronzeEndColor = new THREE.Color(0xc8873d);
const bronzeEmissiveStart = new THREE.Color(0x2b1004);
const bronzeEmissiveEnd = new THREE.Color(0x7c2d08);
function updateAssembly(time) {
// Each mold moves inward independently, producing a staged
// closing sequence while all four remain visible.
for (const piece of moldPieces) {
const start = piece.userData.delay;
const duration = 2.35;
const progress = THREE.MathUtils.clamp(
(time - start) / duration,
0,
1
);
const eased = progress * progress * (3 - 2 * progress);
const remaining = 1 - eased;
const radialOffset = 1.70 * remaining;
const direction = piece.userData.direction;
piece.position.x = direction.x * radialOffset;
piece.position.z = direction.z * radialOffset;
piece.position.y = MOLD_CENTER_Y;
piece.rotation.y =
piece.userData.twist *
0.115 *
Math.sin(Math.PI * progress) *
(1 - progress);
}
// After closure, bronze rises through one continuous annular
// volume. It is never split into four disconnected sections.
const fill = smoothstep(3.65, 5.05, time);
cavityGroup.scale.y = THREE.MathUtils.lerp(0.035, 1, fill);
cavityMaterial.opacity = THREE.MathUtils.lerp(0.13, 1, fill);
cavityMaterial.color.copy(bronzeStartColor).lerp(
bronzeEndColor,
fill
);
cavityMaterial.emissive.copy(bronzeEmissiveStart).lerp(
bronzeEmissiveEnd,
fill
);
cavityMaterial.emissiveIntensity = THREE.MathUtils.lerp(
0.08,
0.34,
fill
);
bronzeLight.intensity = fill * 3.2;
const progressPercent = Math.min(
100,
(time / ANIMATION_DURATION) * 100
);
timelineFill.style.width = `${progressPercent}%`;
if (time < 0.9) {
statusElement.textContent =
"Preparing the four separate clay mold sections…";
} else if (time < 3.7) {
statusElement.textContent =
"Piece molds closing around the central clay core…";
} else if (time < 5.05) {
statusElement.textContent =
"Molds closed; bronze fills the continuous casting gap…";
} else {
statusElement.textContent =
"Assembly complete: a continuous cavity remains visible around the core.";
}
}
// ------------------------------------------------------------
// Resize and render loop
// ------------------------------------------------------------
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
leaderSvg.setAttribute(
"viewBox",
`0 0 ${window.innerWidth} ${window.innerHeight}`
);
}
window.addEventListener("resize", resize);
resize();
function animate(now) {
requestAnimationFrame(animate);
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (!paused) {
simulationTime = Math.min(
simulationTime + delta,
ANIMATION_DURATION
);
}
updateAssembly(simulationTime);
updateCamera();
scene.updateMatrixWorld(true);
updateLabels();
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```