Prompt specification
Build or customize the Three.js 3D scene "Small Soap-Shaping Workshop" 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: Small Soap-Shaping Workshop
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/small-soap-shaping-workshop-x2051
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: small soap-shaping workshop. Build a fictional workshop using original two-part molds and drying racks. Explain cavity, parting, and release geometrically without prescribing a chemical manufacturing recipe. Return one self-contained HTML file.
Working Three.js Starter (small-soap-shaping-workshop-x2051):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Form Room — Two-Part Mold Workshop</title>
<style>
:root {
--ink: #25313a;
--muted: #637078;
--paper: #f7f1e5;
--glass: rgba(248, 243, 232, 0.91);
--line: rgba(37, 49, 58, 0.17);
--violet: #7357a7;
--cyan: #35a9bd;
--amber: #d98b42;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7decc;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid var(--line);
background: var(--glass);
box-shadow: 0 16px 50px rgba(41, 42, 39, 0.13);
backdrop-filter: blur(13px);
-webkit-backdrop-filter: blur(13px);
}
header {
top: 18px;
left: 18px;
width: min(430px, calc(100vw - 36px));
padding: 18px 20px 17px;
border-radius: 16px;
}
.eyebrow {
margin: 0 0 7px;
color: var(--violet);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 38px);
line-height: 0.98;
letter-spacing: -0.045em;
}
.subtitle {
margin: 9px 0 0;
max-width: 360px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.tabs {
right: 18px;
top: 18px;
display: flex;
gap: 5px;
padding: 6px;
border-radius: 13px;
}
button {
appearance: none;
border: 0;
border-radius: 9px;
padding: 10px 13px;
background: transparent;
color: var(--ink);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}
button:hover { background: rgba(37, 49, 58, 0.07); }
button:active { transform: translateY(1px); }
button.active {
background: var(--ink);
color: #fffaf0;
}
.detail {
left: 18px;
bottom: 18px;
width: min(430px, calc(100vw - 36px));
padding: 17px 19px 18px;
border-radius: 16px;
}
.detail-top {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 9px;
}
.swatch {
width: 11px;
height: 11px;
flex: 0 0 auto;
border-radius: 3px;
background: var(--violet);
box-shadow: 0 0 0 4px rgba(115, 87, 167, 0.12);
}
#detail-kicker {
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
#detail-title {
margin: 0 0 6px;
font-size: 18px;
letter-spacing: -0.025em;
}
#detail-body {
margin: 0;
color: #4f5b62;
font-size: 13px;
line-height: 1.52;
}
.legend {
right: 18px;
bottom: 18px;
padding: 13px 15px;
border-radius: 13px;
color: var(--muted);
font-size: 11px;
line-height: 1.7;
}
.legend-row {
display: flex;
align-items: center;
gap: 8px;
}
.dot {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--cyan);
}
.dot.amber { background: var(--amber); }
.dot.violet { background: var(--violet); }
.controls {
position: fixed;
z-index: 8;
left: 50%;
bottom: 18px;
transform: translateX(-50%);
padding: 9px 13px;
border-radius: 999px;
background: rgba(37, 49, 58, 0.79);
color: rgba(255,255,255,0.86);
font-size: 11px;
letter-spacing: 0.02em;
pointer-events: none;
white-space: nowrap;
}
#callouts {
position: fixed;
inset: 0;
z-index: 6;
pointer-events: none;
}
.callout {
position: absolute;
transform: translate(-50%, -100%);
padding: 6px 9px;
border: 1px solid rgba(37, 49, 58, 0.18);
border-radius: 6px;
background: rgba(250, 246, 237, 0.91);
box-shadow: 0 6px 18px rgba(37, 49, 58, 0.12);
color: #36434a;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.075em;
text-transform: uppercase;
white-space: nowrap;
}
.callout::after {
content: "";
position: absolute;
left: 50%;
top: 100%;
width: 1px;
height: 15px;
background: rgba(37, 49, 58, 0.42);
}
.callout.cyan { border-left: 4px solid var(--cyan); }
.callout.violet { border-left: 4px solid var(--violet); }
.callout.amber { border-left: 4px solid var(--amber); }
#loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
background: #e7decc;
color: #435058;
font-size: 12px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
#loading.done {
opacity: 0;
pointer-events: none;
}
@media (max-width: 760px) {
header {
top: 10px;
left: 10px;
width: calc(100vw - 20px);
padding: 13px 15px;
}
.subtitle { display: none; }
.tabs {
top: auto;
right: 10px;
bottom: 118px;
flex-direction: column;
}
button { padding: 8px 10px; font-size: 11px; }
.detail {
left: 10px;
bottom: 10px;
width: calc(100vw - 20px);
padding: 13px 15px;
}
.legend { display: none; }
.controls {
bottom: 121px;
font-size: 9px;
}
.callout { font-size: 8px; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel soap-shaping workshop"></canvas>
<header class="panel">
<p class="eyebrow">Fictional prototype workshop · 02</p>
<h1>FORM ROOM</h1>
<p class="subtitle">
Two original rigid mold families, drying racks, and a cutaway study of
cavity, parting, and geometric release.
</p>
</header>
<nav class="panel tabs" aria-label="Geometric study mode">
<button class="active" data-mode="all">Overview</button>
<button data-mode="cavity">Cavity</button>
<button data-mode="parting">Parting</button>
<button data-mode="release">Release</button>
</nav>
<section class="panel detail" aria-live="polite">
<div class="detail-top">
<span class="swatch"></span>
<span id="detail-kicker">Two fictional mold families</span>
</div>
<h2 id="detail-title">Shape is carried by negative space.</h2>
<p id="detail-body">
ASTER-6 uses a faceted six-lobed cavity. CROWN-STEP uses a stepped,
orthogonal cavity. The cyan blocks identify occupied form volume in the
cutaway half; the empty space in a closed mold is the negative cavity.
</p>
</section>
<aside class="panel legend" aria-label="Scene legend">
<div class="legend-row"><span class="dot"></span> Negative cavity / form volume</div>
<div class="legend-row"><span class="dot violet"></span> Rigid mold half</div>
<div class="legend-row"><span class="dot amber"></span> Parting and release axes</div>
</aside>
<div class="controls">Drag to orbit · Shift/right-drag to pan · Wheel to zoom · Click a colored part</div>
<div id="callouts"></div>
<div id="loading">Building the workshop…</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const canvas = document.querySelector('#scene');
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.13;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe7decc);
scene.fog = new THREE.Fog(0xe7decc, 25, 48);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const controls = {
target: new THREE.Vector3(0, 1.65, 0),
radius: 18.7,
theta: 0.62,
phi: 0.98
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
camera.updateMatrixWorld();
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xfff6df, 0x81786f, 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffedcf, 3.35);
sun.position.set(7, 13, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xbadce8, 0.7);
fill.position.set(-7, 6, 4);
scene.add(fill);
const warmFill = new THREE.PointLight(0xffc982, 18, 12, 2);
warmFill.position.set(-4, 4.5, -2.5);
scene.add(warmFill);
// -------------------------------------------------------------------------
// Materials and reusable geometry helpers
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
function standard(color, roughness = 0.8, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
}
const materials = {
wall: standard(0xd9cfbb),
wallTrim: standard(0xb9aa91),
darkTrim: standard(0x41484a),
wood: standard(0xa9784c),
woodLight: standard(0xc49767),
woodDark: standard(0x77513b),
metal: standard(0x596568, 0.42, 0.62),
blackMetal: standard(0x30383c, 0.38, 0.52),
cream: standard(0xf1e5cb),
sky: standard(0x9bcbd2, 0.9),
cyan: new THREE.MeshBasicMaterial({
color: 0x42bdd0,
transparent: true,
opacity: 0.32,
depthWrite: false
}),
violet: [
standard(0x7458a7),
standard(0x8061b4),
standard(0x684d99),
standard(0x8b6abd)
],
amber: [
standard(0xc77b43),
standard(0xd58a4b),
standard(0xb76c3b),
standard(0xde9657)
]
};
function addBox(parent, size, position, material, cast = true, receive = true) {
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(size[0], size[1], size[2]);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
parent.add(mesh);
return mesh;
}
function addLineLoop(parent, width, depth, y, color, opacity = 1) {
const points = [
new THREE.Vector3(-width / 2, y, -depth / 2),
new THREE.Vector3(width / 2, y, -depth / 2),
new THREE.Vector3(width / 2, y, depth / 2),
new THREE.Vector3(-width / 2, y, depth / 2)
];
const line = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(points),
new THREE.LineBasicMaterial({
color,
transparent: opacity < 1,
opacity
})
);
parent.add(line);
return line;
}
function makeTextTexture(title, subtitle, background = '#26343b') {
const c = document.createElement('canvas');
c.width = 1024;
c.height = 256;
const ctx = c.getContext('2d');
ctx.fillStyle = background;
ctx.fillRect(0, 0, c.width, c.height);
ctx.fillStyle = '#f6ead2';
ctx.font = '800 88px system-ui, sans-serif';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(title, 512, 100);
ctx.fillStyle = '#a8c7c9';
ctx.font = '700 31px system-ui, sans-serif';
ctx.letterSpacing = '6px';
ctx.fillText(subtitle, 512, 186);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function addWallSign(title, subtitle, width, height, position) {
const texture = makeTextTexture(title, subtitle);
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({ map: texture })
);
mesh.position.set(...position);
scene.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Room shell and voxel floor
// -------------------------------------------------------------------------
addBox(scene, [16.6, 0.45, 12.6], [0, -0.34, 0], standard(0x8b7966));
addBox(scene, [16.35, 7.1, 0.36], [0, 3.45, -6.05], materials.wall);
addBox(scene, [0.36, 7.1, 12.1], [-8.05, 3.45, 0], materials.wall);
const floorColors = [
0xb8895c, 0xc09466, 0xad7d54, 0xc59a6f,
0xb98b5d, 0xa9784f, 0xc49768, 0xb18156,
0xc5996a, 0xb08055, 0xc29565, 0xac7c52
];
floorColors.forEach((color, i) => {
addBox(
scene,
[1.29, 0.16, 12.15],
[-7.27 + i * 1.32, -0.075, 0],
standard(color)
);
});
// Wall trim and panel battens.
addBox(scene, [16.2, 0.16, 0.16], [0, 0.08, -5.81], materials.wallTrim);
addBox(scene, [0.16, 0.16, 12], [-7.81, 0.08, 0], materials.wallTrim);
addBox(scene, [16.2, 0.15, 0.16], [0, 6.96, -5.81], materials.wallTrim);
for (let x = -7.4; x <= 7.5; x += 1.85) {
addBox(scene, [0.07, 6.7, 0.05], [x, 3.4, -5.84], standard(0xc9bea9));
}
// Window.
addBox(scene, [3.65, 2.75, 0.08], [4.55, 4.35, -5.82], materials.sky, false, false);
addBox(scene, [3.9, 0.16, 0.18], [4.55, 5.77, -5.68], materials.cream);
addBox(scene, [3.9, 0.16, 0.18], [4.55, 2.93, -5.68], materials.cream);
addBox(scene, [0.16, 2.95, 0.18], [2.57, 4.35, -5.68], materials.cream);
addBox(scene, [0.16, 2.95, 0.18], [6.53, 4.35, -5.68], materials.cream);
addBox(scene, [0.12, 2.72, 0.16], [4.55, 4.35, -5.58], materials.cream);
addBox(scene, [3.72, 0.12, 0.16], [4.55, 4.35, -5.58], materials.cream);
addBox(scene, [4.05, 0.14, 0.65], [4.55, 2.86, -5.48], materials.woodLight);
// The window shows a few abstract distant blocks.
addBox(scene, [0.75, 0.75, 0.04], [3.5, 3.58, -5.75], standard(0x84aeb3), false, false);
addBox(scene, [0.58, 1.1, 0.04], [5.45, 3.6, -5.75], standard(0x9db7a5), false, false);
addBox(scene, [2.6, 0.16, 0.04], [4.6, 3.05, -5.73], standard(0xc8d2b6), false, false);
addWallSign(
'FORM ROOM',
'TWO-PART GEOMETRY STUDY',
4.8,
1.2,
[-3.25, 6.12, -5.77]
);
// -------------------------------------------------------------------------
// Mold geometry: grid cells, negative cavity, rigid halves, seam plane
// -------------------------------------------------------------------------
const GRID_X = 11;
const GRID_Z = 9;
const CELL = 0.22;
const HALF_LAYERS = 4;
const HALF_HEIGHT = CELL * HALF_LAYERS;
const MOLD_WIDTH = GRID_X * CELL;
const MOLD_DEPTH = GRID_Z * CELL;
function createAsterMask() {
const mask = new Set();
for (let gx = 0; gx < GRID_X; gx++) {
for (let gz = 0; gz < GRID_Z; gz++) {
const x = gx - (GRID_X - 1) / 2;
const z = gz - (GRID_Z - 1) / 2;
const angle = Math.atan2(z, x);
const radius = Math.sqrt((x / 3.65) ** 2 + (z / 3.45) ** 2);
const sixLobeBoundary = 0.79 + 0.17 * Math.cos(6 * angle);
if (radius < sixLobeBoundary) mask.add(`${gx},${gz}`);
}
}
return mask;
}
function createCrownMask() {
const mask = new Set();
for (let gx = 0; gx < GRID_X; gx++) {
for (let gz = 0; gz < GRID_Z; gz++) {
const x = Math.abs(gx - (GRID_X - 1) / 2);
const z = Math.abs(gz - (GRID_Z - 1) / 2);
const horizontalBar = x <= 3.2 && z <= 2.1;
const verticalBar = x <= 2.1 && z <= 3.1;
if (horizontalBar || verticalBar) mask.add(`${gx},${gz}`);
}
}
return mask;
}
const asterMask = createAsterMask();
const crownMask = createCrownMask();
function gridPosition(gx, gz) {
return [
(gx - (GRID_X - 1) / 2) * CELL,
(gz - (GRID_Z - 1) / 2) * CELL
];
}
function buildMoldHalf(mask, kind, palette, cutaway = false) {
const group = new THREE.Group();
const buckets = [[], [], [], []];
for (let gx = 0; gx < GRID_X; gx++) {
for (let gz = 0; gz < GRID_Z; gz++) {
const inCavity = mask.has(`${gx},${gz}`);
// A cutaway removes the camera-facing quarter of the upper shell.
if (cutaway && kind === 'upper' && gx > 0 && gz > 0) continue;
for (let layer = 0; layer < HALF_LAYERS; layer++) {
let include;
if (!inCavity) {
include = true;
} else if (kind === 'lower') {
// Lower half retains a solid floor beneath its open cavity.
include = layer < HALF_LAYERS / 2;
} else {
// Upper half is an inverted tray with a downward-facing cavity.
include = layer >= HALF_LAYERS / 2;
}
if (include) {
const bucket = (gx * 7 + gz * 11 + layer * 3 + kind.length) % palette.length;
buckets[bucket].push({ gx, gz, layer });
}
}
}
}
const dummy = new THREE.Object3D();
buckets.forEach((cells, bucketIndex) => {
if (!cells.length) return;
const mesh = new THREE.InstancedMesh(
unitBox,
palette[bucketIndex],
cells.length
);
cells.forEach((cell, index) => {
const [x, z] = gridPosition(cell.gx, cell.gz);
dummy.position.set(x, (cell.layer + 0.5) * CELL, z);
dummy.scale.set(CELL * 0.93, CELL * 0.93, CELL * 0.93);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
});
return group;
}
function createCavityVolume(mask, layerStart, layerCount) {
const positions = [];
for (let gx = 0; gx < GRID_X; gx++) {
for (let gz = 0; gz < GRID_Z; gz++) {
if (!mask.has(`${gx},${gz}`)) continue;
for (let layer = 0; layer < layerCount; layer++) {
positions.push({
gx,
gz,
layer: layerStart + layer
});
}
}
}
const mesh = new THREE.InstancedMesh(unitBox, materials.cyan, positions.length);
const dummy = new THREE.Object3D();
positions.forEach((cell, index) => {
const [x, z] = gridPosition(cell.gx, cell.gz);
dummy.position.set(x, (cell.layer + 0.5) * CELL, z);
dummy.scale.set(CELL * 0.89, CELL * 0.89, CELL * 0.89);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.renderOrder = 3;
return mesh;
}
function createAssembledMold(mask, palette, scale = 1) {
const group = new THREE.Group();
const lower = buildMoldHalf(mask, 'lower', palette);
const upper = buildMoldHalf(mask, 'upper', palette);
lower.position.y = 0;
upper.position.y = HALF_HEIGHT;
group.add(lower, upper);
group.scale.setScalar(scale);
addLineLoop(group, MOLD_WIDTH * scale, MOLD_DEPTH * scale, HALF_HEIGHT * scale, 0x343c40, 0.75);
return group;
}
function makeVoxelSoap(mask, cellSize = 0.115, layers = 3, color = 0xe9a66f) {
const group = new THREE.Group();
const cells = [];
mask.forEach(key => {
const [gx, gz] = key.split(',').map(Number);
for (let layer = 0; layer < layers; layer++) cells.push({ gx, gz, layer });
});
const soapMaterial = standard(color, 0.58);
const mesh = new THREE.InstancedMesh(unitBox, soapMaterial, cells.length);
const dummy = new THREE.Object3D();
cells.forEach((cell, index) => {
const [x, z] = gridPosition(cell.gx, cell.gz);
dummy.position.set(x, (cell.layer + 0.5) * cellSize, z);
dummy.scale.set(cellSize * 0.95, cellSize * 0.95, cellSize * 0.95);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
return group;
}
// -------------------------------------------------------------------------
// Workbenches
// -------------------------------------------------------------------------
function createWorkbench(x, z, width, depth, topY) {
const group = new THREE.Group();
group.position.set(x, 0, z);
addBox(group, [width, 0.32, depth], [0, topY, 0], materials.woodLight);
addBox(group, [width + 0.08, 0.12, depth + 0.08], [0, topY - 0.2, 0], materials.woodDark);
const legX = width / 2 - 0.35;
const legZ = depth / 2 - 0.28;
for (const lx of [-legX, legX]) {
for (const lz of [-legZ, legZ]) {
addBox(group, [0.32, topY - 0.25, 0.32], [lx, (topY - 0.25) / 2, lz], materials.woodDark);
}
}
addBox(group, [width - 0.65, 0.72, 0.16], [0, topY - 0.63, depth / 2 - 0.12], materials.wood);
addBox(group, [0.65, 0.1, 0.12], [0, topY - 0.58, depth / 2 - 0.02], materials.blackMetal);
scene.add(group);
return group;
}
const backBench = createWorkbench(-3.55, -3.65, 8.5, 2.15, 2.25);
const frontBench = createWorkbench(-4.45, 1.65, 5.5, 2.25, 1.6);
// CROWN-STEP, closed on the rear workbench.
const crownMold = createAssembledMold(crownMask, materials.amber, 0.78);
crownMold.position.set(-5.35, 2.43, -3.65);
scene.add(crownMold);
// A small Aster prototype and its matching sample form.
const smallAster = createAssembledMold(asterMask, materials.violet, 0.62);
smallAster.position.set(-1.95, 2.43, -3.75);
scene.add(smallAster);
const asterSample = makeVoxelSoap(asterMask, 0.12, 3, 0x67bdc8);
asterSample.position.set(-3.95, 2.43, -3.4);
scene.add(asterSample);
// Bench tools: blade, handle, ruler, and a sample block.
addBox(backBench, [0.68, 0.035, 0.12], [1.4, 2.43, -0.45], materials.metal);
addBox(backBench, [0.3, 0.09, 0.17], [1.86, 2.45, -0.45], materials.woodDark);
addBox(backBench, [1.35, 0.045, 0.16], [2.7, 2.45, 0.42], standard(0xd4c69e));
for (let i = 0; i < 9; i++) {
addBox(backBench, [0.025, 0.012, 0.12], [2.15 + i * 0.14, 2.477, 0.42], materials.darkTrim, false, false);
}
addBox(backBench, [0.66, 0.22, 0.48], [-0.2, 2.54, 0.28], standard(0xe7bb77));
// Foreground table objects.
const crownSample = makeVoxelSoap(crownMask, 0.11, 3, 0xe6a764);
crownSample.position.set(-5.55, 1.78, 1.45);
scene.add(crownSample);
addBox(frontBench, [1.55, 0.055, 0.19], [-3.3, 1.82, 1.15], standard(0xdfd1ac));
addBox(frontBench, [0.22, 0.12, 0.52], [-2.45, 1.84, 1.3], materials.woodDark);
addBox(frontBench, [0.72, 0.12, 0.18], [-2.85, 1.85, 1.3], materials.metal);
// -------------------------------------------------------------------------
// Hero cutaway: separated Aster-6 mold and geometric annotations
// -------------------------------------------------------------------------
const heroX = 0.55;
const heroZ = 1.72;
const lowerBase = 0.27;
const upperBase = 2.13;
const lowerSeamY = lowerBase + HALF_HEIGHT;
addBox(scene, [3.55, 0.27, 3.15], [heroX, 0.13, heroZ], materials.darkTrim);
addBox(scene, [3.42, 0.08, 3.02], [heroX, 0.295, heroZ], standard(0xd4c6ad));
const heroLower = buildMoldHalf(asterMask, 'lower', materials.violet);
heroLower.position.set(heroX, lowerBase, heroZ);
scene.add(heroLower);
const heroUpper = buildMoldHalf(asterMask, 'upper', materials.violet, true);
heroUpper.position.set(heroX, upperBase, heroZ);
scene.add(heroUpper);
const cavityVolume = createCavityVolume(asterMask, 2, 2);
cavityVolume.position.set(heroX, lowerBase, heroZ);
scene.add(cavityVolume);
const partingPlane = new THREE.Mesh(
new THREE.PlaneGeometry(MOLD_WIDTH, MOLD_DEPTH),
new THREE.MeshBasicMaterial({
color: 0xe29b47,
transparent: true,
opacity: 0.12,
side: THREE.DoubleSide,
depthWrite: false
})
);
partingPlane.rotation.x = -Math.PI / 2;
partingPlane.position.set(heroX, lowerSeamY, heroZ);
partingPlane.renderOrder = 2;
scene.add(partingPlane);
const partingOutline = addLineLoop(
scene,
MOLD_WIDTH,
MOLD_DEPTH,
lowerSeamY + 0.012,
0xe29b47,
0.95
);
// Dashed translation guides connect the two mating seam planes.
const guideGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(heroX - MOLD_WIDTH / 2, lowerSeamY, heroZ - MOLD_DEPTH / 2),
new THREE.Vector3(heroX - MOLD_WIDTH / 2, upperBase, heroZ - MOLD_DEPTH / 2),
new THREE.Vector3(heroX + MOLD_WIDTH / 2, lowerSeamY, heroZ - MOLD_DEPTH / 2),
new THREE.Vector3(heroX + MOLD_WIDTH / 2, upperBase, heroZ - MOLD_DEPTH / 2),
new THREE.Vector3(heroX - MOLD_WIDTH / 2, lowerSeamY, heroZ + MOLD_DEPTH / 2),
new THREE.Vector3(heroX - MOLD_WIDTH / 2, upperBase, heroZ + MOLD_DEPTH / 2),
new THREE.Vector3(heroX + MOLD_WIDTH / 2, lowerSeamY, heroZ + MOLD_DEPTH / 2),
new THREE.Vector3(heroX + MOLD_WIDTH / 2, upperBase, heroZ + MOLD_DEPTH / 2)
]);
const guideMaterial = new THREE.LineDashedMaterial({
color: 0xb87634,
dashSize: 0.09,
gapSize: 0.065,
transparent: true,
opacity: 0.65
});
const guideLines = new THREE.LineSegments(guideGeometry, guideMaterial);
guideLines.computeLineDistances();
scene.add(guideLines);
const releaseGroup = new THREE.Group();
scene.add(releaseGroup);
const downArrow = new THREE.ArrowHelper(
new THREE.Vector3(0, -1, 0),
new THREE.Vector3(),
0.82,
0xd36a46,
0.2,
0.13
);
downArrow.position.set(heroX + 1.72, 2.05, heroZ);
releaseGroup.add(downArrow);
const upArrow = new THREE.ArrowHelper(
new THREE.Vector3(0, 1, 0),
new THREE.Vector3(),
0.82,
0x35a9bd,
0.2,
0.13
);
upArrow.position.set(heroX + 1.72, 2.63, heroZ);
releaseGroup.add(upArrow);
// Small physical plaque.
addBox(scene, [1.95, 0.48, 0.1], [heroX, 0.48, heroZ + 1.63], materials.cream);
const heroSignTexture = makeTextTexture('ASTER–6', 'TWO-PART / CUTAWAY', '#4b3a67');
const heroSign = new THREE.Mesh(
new THREE.PlaneGeometry(1.78, 0.36),
new THREE.MeshBasicMaterial({ map: heroSignTexture })
);
heroSign.position.set(heroX, 0.49, heroZ + 1.69);
scene.add(heroSign);
// -------------------------------------------------------------------------
// Drying racks and soap forms
// -------------------------------------------------------------------------
function makeBarSoap(color, scale = 1) {
const group = new THREE.Group();
addBox(group, [0.7 * scale, 0.2 * scale, 0.44 * scale], [0, 0.1 * scale, 0], standard(color, 0.58));
addBox(group, [0.58 * scale, 0.055 * scale, 0.34 * scale], [0, 0.225 * scale, 0], standard(color, 0.52));
return group;
}
function createDryingRack(x, z, width, height, levels, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
const postX = width / 2;
const depth = 1.22;
for (const px of [-postX, postX]) {
addBox(group, [0.16, height, 0.16], [px, height / 2, -depth / 2], materials.blackMetal);
addBox(group, [0.16, height, 0.16], [px, height / 2, depth / 2], materials.blackMetal);
addBox(group, [0.22, 0.12, depth + 0.35], [px, 0.12, 0], materials.blackMetal);
}
const soapColors = [0xe6a56e, 0x7cc0bd, 0xc899c8, 0xe3cf84, 0x8eb4cf];
levels.forEach((level, rowIndex) => {
const y = level;
addBox(group, [width + 0.15, 0.11, 0.11], [0, y, -depth / 2], materials.metal);
addBox(group, [width + 0.15, 0.11, 0.11], [0, y, depth / 2], materials.metal);
for (let slat = -2; slat <= 2; slat++) {
addBox(group, [0.09, 0.08, depth], [slat * width / 5, y, 0], materials.metal);
}
const count = rowIndex % 2 === 0 ? 4 : 3;
for (let i = 0; i < count; i++) {
const soap = makeBarSoap(
soapColors[(rowIndex * 2 + i) % soapColors.length],
0.9
);
soap.position.set(
-width * 0.34 + i * (width * 0.68 / Math.max(1, count - 1)),
y + 0.05,
(rowIndex % 2 === 0 ? -1 : 1) * 0.18
);
soap.rotation.y = (i % 2 ? 1 : -1) * 0.12;
group.add(soap);
}
});
addBox(group, [width + 0.15, 0.12, 0.16], [0, height, -depth / 2], materials.blackMetal);
addBox(group, [width + 0.15, 0.12, 0.16], [0, height, depth / 2], materials.blackMetal);
scene.add(group);
return group;
}
createDryingRack(5.1, -2.75, 3.65, 4.65, [0.78, 1.9, 3.02, 4.14]);
createDryingRack(5.95, 1.0, 2.65, 3.55, [0.72, 1.67, 2.62], -0.12);
// -------------------------------------------------------------------------
// Wall shelving, pegboard, and generic workshop containers
// -------------------------------------------------------------------------
const shelf = new THREE.Group();
shelf.position.set(-3.55, 0, -5.42);
[3.65, 5.1].forEach((y, shelfIndex) => {
addBox(shelf, [7.3, 0.16, 0.64], [0, y, 0], materials.woodLight);
for (const x of [-2.9, 0, 2.9]) {
addBox(shelf, [0.14, 1.05, 0.14], [x, y - 0.56, -0.12], materials.woodDark);
}
const colors = [0xb5c7b2, 0xd5b77f, 0x9eb7c2, 0xc6a2b5];
for (let i = 0; i < 8; i++) {
const h = 0.42 + ((i + shelfIndex) % 3) * 0.1;
const x = -2.85 + i * 0.8;
addBox(shelf, [0.43, h, 0.36], [x, y + 0.08 + h / 2, 0.05], standard(colors[(i + shelfIndex) % colors.length]));
addBox(shelf, [0.29, 0.08, 0.27], [x, y + 0.12 + h, 0.05], materials.cream);
}
});
scene.add(shelf);
// Pegboard on the left wall.
addBox(scene, [0.12, 2.45, 3.4], [-7.82, 3.65, -1.4], standard(0xa88764));
for (let z = -2.85; z <= 0.1; z += 0.38) {
for (let y = 2.65; y <= 4.65; y += 0.38) {
addBox(scene, [0.03, 0.07, 0.07], [-7.74, y, z], materials.darkTrim, false, false);
}
}
// Hanging geometric tools.
addBox(scene, [0.12, 1.15, 0.16], [-7.56, 3.9, -2.3], materials.metal);
addBox(scene, [0.12, 0.8, 0.23], [-7.56, 3.28, -1.75], materials.woodDark);
addBox(scene, [0.12, 0.55, 0.4], [-7.56, 3.98, -1.18], materials.metal);
addBox(scene, [0.13, 0.78, 0.13], [-7.56, 3.65, -0.45], materials.woodDark);
// -------------------------------------------------------------------------
// Interaction modes and clickable scene parts
// -------------------------------------------------------------------------
const details = {
all: {
color: '#7357a7',
kicker: 'Two fictional mold families',
title: 'Shape is carried by negative space.',
body:
'ASTER-6 uses a faceted six-lobed cavity. CROWN-STEP uses a stepped, orthogonal cavity. ' +
'The cyan blocks identify occupied form volume in the cutaway half; the empty space in a closed mold is the negative cavity.'
},
cavity: {
color: '#35a9bd',
kicker: '01 · Negative volume',
title: 'The cavity determines the finished silhouette.',
body:
'Each solid grid cell is tool material. Omitted cells form the void occupied by the casting. ' +
'ASTER-6 combines a circular core with six stepped lobes, producing an original voxelized outline.'
},
parting: {
color: '#d98b42',
kicker: '02 · Rigid interface',
title: 'A flat seam separates the tool into two bodies.',
body:
'The amber plane is the parting interface. Each half has a matching flat seam and complementary cavity surfaces. ' +
'The exploded upper half is cut away only for inspection; the CROWN-STEP example shows the closed seam.'
},
release: {
color: '#d36a46',
kicker: '03 · Geometric separation',
title: 'The halves move apart along the seam normal.',
body:
'Once the casting has set, the two rigid halves translate in opposite directions perpendicular to the parting plane. ' +
'Stepped cavity walls bias the form toward separation. This describes geometry only, not a chemical manufacturing recipe.'
}
};
let activeMode = 'all';
const detailKicker = document.querySelector('#detail-kicker');
const detailTitle = document.querySelector('#detail-title');
const detailBody = document.querySelector('#detail-body');
const swatch = document.querySelector('.swatch');
const modeButtons = [...document.querySelectorAll('[data-mode]')];
function setMode(mode) {
if (!details[mode]) return;
activeMode = mode;
modeButtons.forEach(button => {
button.classList.toggle('active', button.dataset.mode === mode);
});
detailKicker.textContent = details[mode].kicker;
detailTitle.textContent = details[mode].title;
detailBody.textContent = details[mode].body;
swatch.style.background = details[mode].color;
cavityVolume.visible = mode === 'all' || mode === 'cavity';
materials.cyan.opacity = mode === 'cavity' ? 0.56 : 0.32;
partingPlane.visible = mode !== 'cavity';
partingOutline.visible = mode !== 'cavity';
partingPlane.material.opacity = mode === 'parting' ? 0.28 : 0.09;
guideLines.visible = mode === 'all' || mode === 'release';
releaseGroup.visible = mode === 'all' || mode === 'release';
}
modeButtons.forEach(button => {
button.addEventListener('click', () => setMode(button.dataset.mode));
});
const interactive = [];
function markInteractive(object, mode) {
object.traverse(child => {
if (child.isMesh || child.isLine || child.isLineSegments) {
child.userData.mode = mode;
interactive.push(child);
}
});
}
markInteractive(cavityVolume, 'cavity');
markInteractive(partingPlane, 'parting');
markInteractive(partingOutline, 'parting');
markInteractive(releaseGroup, 'release');
markInteractive(crownMold, 'parting');
markInteractive(smallAster, 'cavity');
// -------------------------------------------------------------------------
// DOM callouts projected from 3D anchors without extra renderer modules
// -------------------------------------------------------------------------
const calloutAnchors = [];
function addCallout(text, className, anchor) {
const element = document.createElement('div');
element.className = `callout ${className}`;
element.textContent = text;
document.querySelector('#callouts').appendChild(element);
calloutAnchors.push({ element, anchor });
}
addCallout('ASTER–6 / CUTAWAY', 'violet', new THREE.Vector3(heroX, 3.16, heroZ));
addCallout('01 · NEGATIVE CAVITY', 'cyan', new THREE.Vector3(heroX - 0.42, lowerBase + 0.56, heroZ + 0.3));
addCallout('02 · PARTING PLANE', 'amber', new THREE.Vector3(heroX + 0.96, lowerSeamY + 0.08, heroZ + 0.12));
addCallout('03 · RELEASE AXIS', 'amber', new THREE.Vector3(heroX + 1.72, 3.03, heroZ));
addCallout('DRYING RACK / 18 FORMS', 'violet', new THREE.Vector3(5.1, 4.75, -2.75));
const projected = new THREE.Vector3();
function updateCallouts() {
const width = window.innerWidth;
const height = window.innerHeight;
calloutAnchors.forEach(({ element, anchor }) => {
projected.copy(anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? 'block' : 'none';
if (visible) {
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
});
}
// -------------------------------------------------------------------------
// Direct camera controls: orbit, pan, wheel zoom, and touch pinch
// -------------------------------------------------------------------------
const pointers = new Map();
let dragButton = 0;
let movedDistance = 0;
let previousPinchDistance = 0;
function pointerDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
}
canvas.addEventListener('contextmenu', event => event.preventDefault());
canvas.addEventListener('pointerdown', event => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
dragButton = event.button;
movedDistance = 0;
if (pointers.size === 2) previousPinchDistance = pointerDistance();
});
canvas.addEventListener('pointermove', event => {
if (!pointers.has(event.pointerId)) return;
const previous = pointers.get(event.pointerId);
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
movedDistance += Math.hypot(dx, dy);
if (pointers.size === 1) {
const wantsPan = event.shiftKey || dragButton === 2 || dragButton === 1;
if (wantsPan) {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
const up = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 1);
const panScale = controls.radius * 0.00125;
controls.target.addScaledVector(right, -dx * panScale);
controls.target.addScaledVector(up, dy * panScale);
} else {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(controls.phi - dy * 0.006, 0.25, 1.43);
}
} else if (pointers.size === 2) {
const distance = pointerDistance();
if (previousPinchDistance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (previousPinchDistance / Math.max(distance, 1)),
8.5,
31
);
}
previousPinchDistance = distance;
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) previousPinchDistance = 0;
}
canvas.addEventListener('pointerup', event => {
releasePointer(event);
if (movedDistance < 6) {
const rect = canvas.getBoundingClientRect();
const mouse = new THREE.Vector2(
((event.clientX - rect.left) / rect.width) * 2 - 1,
-((event.clientY - rect.top) / rect.height) * 2 + 1
);
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera(mouse, camera);
const hits = raycaster.intersectObjects(interactive, false);
if (hits.length) {
const mode = hits[0].object.userData.mode;
if (mode) setMode(mode);
}
}
});
canvas.addEventListener('pointercancel', releasePointer);
canvas.addEventListener('wheel', event => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
8.5,
31
);
updateCamera();
}, { passive: false });
window.addEventListener('keydown', event => {
const step = 0.09;
if (event.key === 'ArrowLeft') controls.theta += step;
if (event.key === 'ArrowRight') controls.theta -= step;
if (event.key === 'ArrowUp') controls.phi = Math.max(0.25, controls.phi - step);
if (event.key === 'ArrowDown') controls.phi = Math.min(1.43, controls.phi + step);
if (event.key === '+' || event.key === '=') controls.radius = Math.max(8.5, controls.radius - 0.7);
if (event.key === '-' || event.key === '_') controls.radius = Math.min(31, controls.radius + 0.7);
updateCamera();
});
// -------------------------------------------------------------------------
// 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);
}
window.addEventListener('resize', resize);
setMode('all');
renderer.setAnimationLoop(() => {
updateCallouts();
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
document.querySelector('#loading').classList.add('done');
});
</script>
</body>
</html>
```