Prompt specification
Build or customize the Three.js 3D scene "Two-color print alignment table" 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: Two-color print alignment table
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/two-color-print-alignment-table-x2342
Scene Description Prompt:
Make a voxel Three.js scene in a self-contained HTML file using cdnjs: Two-color print alignment table. Create an Edo-inspired printing station with two blocks and one sheet. Animate successive impressions using a clearly original geometric design and show registration alignment.
Working Three.js Starter (two-color-print-alignment-table-x2342):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Two-Color Registration — Voxel Printing Station</title>
<style>
:root {
--paper: #efe5cf;
--ink: #302820;
--muted: #756a59;
--vermilion: #d64b3e;
--indigo: #244f69;
--line: rgba(73, 58, 42, 0.22);
--panel: rgba(239, 229, 207, 0.88);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d7cbb3;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 0 14px 40px rgba(49, 35, 22, 0.12);
backdrop-filter: blur(10px);
}
#title-panel {
top: 24px;
left: 24px;
width: min(390px, calc(100vw - 48px));
padding: 18px 20px 16px;
}
.eyebrow {
margin-bottom: 7px;
color: var(--muted);
font: 700 10px/1.2 Arial, sans-serif;
letter-spacing: 0.24em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 36px);
font-weight: 500;
line-height: 1.04;
letter-spacing: -0.025em;
}
.subtitle {
margin: 10px 0 0;
color: var(--muted);
font: 12px/1.5 Arial, sans-serif;
letter-spacing: 0.055em;
}
.red-rule {
width: 58px;
height: 4px;
margin-top: 14px;
background: linear-gradient(
90deg,
var(--vermilion) 0 50%,
var(--indigo) 50% 100%
);
}
#registration-panel {
top: 24px;
right: 24px;
width: 226px;
padding: 16px;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.16em;
text-transform: uppercase;
}
#lock-state {
color: var(--indigo);
font-size: 9px;
}
.registration-wrap {
position: relative;
display: grid;
place-items: center;
padding: 13px;
border: 1px solid var(--line);
background:
linear-gradient(rgba(48, 40, 32, 0.035) 1px, transparent 1px),
linear-gradient(90deg, rgba(48, 40, 32, 0.035) 1px, transparent 1px),
rgba(255, 255, 255, 0.23);
background-size: 17px 17px;
}
#mini-grid {
position: relative;
display: grid;
grid-template-columns: repeat(17, 7px);
grid-template-rows: repeat(17, 7px);
gap: 0;
background: #eee4cd;
box-shadow: 0 0 0 1px rgba(48, 40, 32, 0.14);
}
#mini-grid::before,
#mini-grid::after {
content: "";
position: absolute;
z-index: 2;
pointer-events: none;
background: rgba(214, 75, 62, 0.34);
}
#mini-grid::before {
left: 50%;
top: 0;
width: 1px;
height: 100%;
transform: translateX(-50%);
}
#mini-grid::after {
top: 50%;
left: 0;
height: 1px;
width: 100%;
transform: translateY(-50%);
}
.mini-cell {
width: 7px;
height: 7px;
position: relative;
z-index: 1;
}
.mini-cell.ghost-r { background: rgba(214, 75, 62, 0.13); }
.mini-cell.ghost-b { background: rgba(36, 79, 105, 0.13); }
.mini-cell.print-r { background: var(--vermilion); }
.mini-cell.print-b { background: var(--indigo); }
.legend {
display: flex;
justify-content: space-between;
gap: 12px;
margin-top: 11px;
font: 10px/1.3 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend span {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 9px;
height: 9px;
display: inline-block;
}
.swatch.red { background: var(--vermilion); }
.swatch.blue { background: var(--indigo); }
#status-panel {
left: 24px;
bottom: 104px;
width: 280px;
padding: 14px 16px;
}
#phase {
margin-bottom: 7px;
font: 700 11px/1.3 Arial, sans-serif;
letter-spacing: 0.13em;
text-transform: uppercase;
}
#phase-detail {
color: var(--muted);
font: 11px/1.4 Arial, sans-serif;
}
.progress-track {
height: 3px;
margin-top: 12px;
overflow: hidden;
background: rgba(48, 40, 32, 0.13);
}
#progress {
width: 0%;
height: 100%;
background: linear-gradient(90deg, var(--vermilion), var(--indigo));
}
#controls {
position: fixed;
z-index: 20;
left: 50%;
bottom: 22px;
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 8px;
width: max-content;
max-width: calc(100vw - 32px);
padding: 10px;
background: rgba(239, 229, 207, 0.93);
border: 1px solid var(--line);
box-shadow: 0 15px 45px rgba(48, 35, 22, 0.18);
backdrop-filter: blur(12px);
}
button {
border: 1px solid rgba(48, 40, 32, 0.32);
background: rgba(255, 255, 255, 0.22);
color: var(--ink);
padding: 9px 12px;
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.1em;
text-transform: uppercase;
cursor: pointer;
transition: background 150ms, color 150ms, transform 100ms;
}
button:hover {
background: var(--ink);
color: var(--paper);
}
button:active { transform: translateY(1px); }
#pause {
min-width: 82px;
background: var(--ink);
color: var(--paper);
}
.control-divider {
width: 1px;
height: 28px;
margin: 0 3px;
background: var(--line);
}
.range-control {
display: flex;
align-items: center;
gap: 8px;
padding: 0 7px;
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
}
input[type="range"] {
width: 78px;
accent-color: var(--indigo);
}
.check-control {
display: flex;
align-items: center;
gap: 7px;
padding: 0 7px;
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
}
.check-control input {
accent-color: var(--indigo);
}
#hint {
position: fixed;
z-index: 8;
right: 24px;
bottom: 25px;
color: rgba(48, 40, 32, 0.7);
font: 10px/1.4 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: #d7cbb3;
color: var(--ink);
font: 700 11px/1 Arial, sans-serif;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 400ms;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 900px) {
#registration-panel { display: none; }
#hint { display: none; }
}
@media (max-width: 620px) {
#title-panel {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 13px 15px;
}
.subtitle { display: none; }
.red-rule { margin-top: 10px; }
#status-panel {
left: 12px;
bottom: 112px;
width: calc(100vw - 24px);
}
#controls {
bottom: 12px;
flex-wrap: wrap;
justify-content: center;
width: calc(100vw - 24px);
}
.control-divider { display: none; }
button { padding: 9px 10px; }
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive voxel printing station"></canvas>
<section id="title-panel" class="panel">
<div class="eyebrow">Edo-inspired registration studio · Plate sequence 01</div>
<h1>Two Blocks,<br>One Exact Impression</h1>
<p class="subtitle">
A vermilion and indigo relief-print demonstration with a shared
17 × 17 registration grid.
</p>
<div class="red-rule"></div>
</section>
<aside id="registration-panel" class="panel">
<div class="panel-heading">
<span>Registration map</span>
<span id="lock-state">Ready</span>
</div>
<div class="registration-wrap">
<div id="mini-grid" aria-label="Two-color geometric print registration map"></div>
</div>
<div class="legend">
<span><i class="swatch red"></i> Plate I</span>
<span><i class="swatch blue"></i> Plate II</span>
</div>
</aside>
<section id="status-panel" class="panel">
<div id="phase">Preparing plate I</div>
<div id="phase-detail">Vermilion block moving into register.</div>
<div class="progress-track"><div id="progress"></div></div>
</section>
<nav id="controls" aria-label="Animation controls">
<button id="replay" type="button">Replay</button>
<button id="pause" type="button">Pause</button>
<div class="control-divider"></div>
<label class="range-control">
Speed
<input id="speed" type="range" min="0.5" max="1.75" step="0.25" value="1">
<span id="speed-value">1×</span>
</label>
<label class="check-control">
<input id="guides" type="checkbox" checked>
Guides
</label>
<button id="reset-camera" type="button">Reset view</button>
</nav>
<div id="hint">Drag to orbit · Wheel to zoom · Right-drag to pan</div>
<div id="loading">Preparing the printing studio…</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ------------------------------------------------------------
// Renderer, camera, and custom orbit controls
// ------------------------------------------------------------
const canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
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.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd7cbb3);
scene.fog = new THREE.Fog(0xd7cbb3, 14, 30);
const camera = new THREE.OrthographicCamera(-6, 6, 5, -5, 0.1, 80);
const controls = {
target: new THREE.Vector3(0, 1.45, -0.15),
azimuth: 0.64,
polar: 1.02,
radius: 12,
defaultAzimuth: 0.64,
defaultPolar: 1.02,
defaultRadius: 12,
dragging: false,
panning: false,
lastX: 0,
lastY: 0
};
function updateCamera() {
const sinPolar = Math.sin(controls.polar);
const cosPolar = Math.cos(controls.polar);
camera.position.set(
controls.target.x + controls.radius * sinPolar * Math.sin(controls.azimuth),
controls.target.y + controls.radius * cosPolar,
controls.target.z + controls.radius * sinPolar * Math.cos(controls.azimuth)
);
camera.lookAt(controls.target);
camera.zoom = 12 / controls.radius;
camera.updateProjectionMatrix();
}
function resetCamera() {
controls.azimuth = controls.defaultAzimuth;
controls.polar = controls.defaultPolar;
controls.radius = controls.defaultRadius;
controls.target.set(0, 1.45, -0.15);
updateCamera();
}
canvas.addEventListener("contextmenu", event => event.preventDefault());
canvas.addEventListener("pointerdown", event => {
controls.dragging = true;
controls.panning = event.button === 2 || event.shiftKey;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
if (controls.panning) {
const right = new THREE.Vector3(
Math.cos(controls.azimuth),
0,
-Math.sin(controls.azimuth)
);
const scale = controls.radius * 0.0012;
controls.target.addScaledVector(right, -dx * scale);
controls.target.z += dy * scale * 0.65;
} else {
controls.azimuth -= dx * 0.005;
controls.polar = THREE.MathUtils.clamp(
controls.polar - dy * 0.004,
0.43,
1.36
);
}
updateCamera();
});
function stopDragging(event) {
controls.dragging = false;
controls.panning = false;
if (event && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener("wheel", event => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
7,
18
);
updateCamera();
}, { passive: false });
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = Math.max(8.2, 11.5 / aspect);
camera.left = -viewHeight * aspect / 2;
camera.right = viewHeight * aspect / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
updateCamera();
}
window.addEventListener("resize", resize);
// ------------------------------------------------------------
// Materials and lighting
// ------------------------------------------------------------
const material = (color, roughness = 0.8, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness,
flatShading: true,
...extra
});
const mats = {
floor: material(0x77765c),
floorStripe: material(0x85846a),
woodDark: material(0x3f291e),
wood: material(0x68402a),
woodLight: material(0x8a5d39),
woodEdge: material(0x2d211b),
brass: material(0xb18a47, 0.48, { metalness: 0.48 }),
washi: material(0xe8dcc1, 0.95, {
emissive: 0x4b3827,
emissiveIntensity: 0.06
}),
paper: material(0xf4ead2, 0.96),
red: material(0xd64b3e, 0.62, {
emissive: 0x52130e,
emissiveIntensity: 0.08
}),
blue: material(0x244f69, 0.62, {
emissive: 0x081f30,
emissiveIntensity: 0.08
}),
lantern: material(0xe8aa56, 0.55, {
emissive: 0xff8d31,
emissiveIntensity: 1.25
}),
fabric: material(0x29495e),
charcoal: material(0x26231f)
};
const hemi = new THREE.HemisphereLight(0xfff1cf, 0x584735, 2.2);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xffe3ae, 3.1);
sun.position.set(5.5, 10, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -11;
sun.shadow.camera.right = 11;
sun.shadow.camera.top = 11;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9fc5d7, 0.7);
fill.position.set(-7, 5, -3);
scene.add(fill);
function box(parent, size, position, mat, cast = true, receive = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = cast;
mesh.receiveShadow = receive;
parent.add(mesh);
return mesh;
}
// ------------------------------------------------------------
// Room and Edo-inspired station
// ------------------------------------------------------------
box(scene, [30, 0.18, 28], [0, -0.13, 0], mats.floor, false, true);
for (let i = -7; i <= 7; i++) {
box(
scene,
[29, 0.012, 0.035],
[0, -0.032, i * 1.65],
mats.floorStripe,
false,
true
);
}
// Shoji screen.
const screen = new THREE.Group();
scene.add(screen);
for (const x of [-3, 0, 3]) {
box(screen, [2.76, 4.45, 0.08], [x, 2.55, -4.55], mats.washi, false, true);
}
for (const x of [-4.55, -1.5, 1.5, 4.55]) {
box(screen, [0.14, 5.0, 0.18], [x, 2.52, -4.43], mats.woodDark);
}
for (const y of [0.35, 1.45, 2.55, 3.65, 4.78]) {
box(screen, [9.2, 0.12, 0.18], [0, y, -4.42], mats.woodDark);
}
for (const x of [-3, 0, 3]) {
box(screen, [0.07, 4.4, 0.13], [x, 2.55, -4.39], mats.wood);
}
box(screen, [10.4, 0.28, 0.65], [0, 5.02, -4.25], mats.woodEdge);
box(screen, [10.8, 0.13, 0.42], [0, 5.25, -4.42], mats.woodDark);
// Hanging lantern.
box(scene, [0.035, 1.1, 0.035], [-4.72, 4.22, -4.0], mats.charcoal);
box(scene, [0.78, 0.12, 0.78], [-4.72, 3.69, -4.0], mats.woodDark);
box(scene, [0.62, 0.78, 0.62], [-4.72, 3.19, -4.0], mats.lantern, false, false);
box(scene, [0.80, 0.12, 0.80], [-4.72, 2.72, -4.0], mats.woodDark);
for (const z of [-4.34, -3.66]) {
box(scene, [0.82, 0.10, 0.10], [-4.72, 3.19, z], mats.woodDark);
}
const lanternLight = new THREE.PointLight(0xff9a42, 7, 7, 2);
lanternLight.position.set(-4.72, 3.15, -3.7);
scene.add(lanternLight);
// Main work table.
const table = new THREE.Group();
scene.add(table);
for (let i = 0; i < 9; i++) {
const z = -2.4 + i * 0.6;
box(table, [8.8, 0.22, 0.55], [0, 0.88, z], i % 2 ? mats.wood : mats.woodLight);
}
box(table, [9.1, 0.28, 0.25], [0, 0.68, 2.5], mats.woodEdge);
box(table, [9.1, 0.28, 0.25], [0, 0.68, -2.5], mats.woodEdge);
box(table, [0.25, 0.28, 5.0], [-4.25, 0.68, 0], mats.woodEdge);
box(table, [0.25, 0.28, 5.0], [4.25, 0.68, 0], mats.woodEdge);
for (const x of [-3.85, 3.85]) {
for (const z of [-2.05, 2.05]) {
box(table, [0.38, 0.78, 0.38], [x, 0.39, z], mats.woodDark);
box(table, [0.48, 0.13, 0.48], [x, 0.06, z], mats.charcoal);
}
}
// Front measuring rail.
box(table, [6.7, 0.06, 0.22], [0, 1.01, 2.13], mats.brass);
for (let i = -16; i <= 16; i++) {
const major = i % 4 === 0;
box(
table,
[0.025, major ? 0.018 : 0.012, major ? 0.15 : 0.08],
[i * 0.19, 1.045, 2.13],
mats.charcoal,
false,
false
);
}
// Small pigment trays at the front corners.
box(table, [0.68, 0.07, 0.48], [-4.0, 1.055, 1.55], mats.woodDark);
box(table, [0.57, 0.025, 0.37], [-4.0, 1.10, 1.55], mats.red);
box(table, [0.68, 0.07, 0.48], [4.0, 1.055, 1.55], mats.woodDark);
box(table, [0.57, 0.025, 0.37], [4.0, 1.10, 1.55], mats.blue);
// ------------------------------------------------------------
// Original geometric artwork: "Split Sun / Folded Tide"
// ------------------------------------------------------------
const GRID = 17;
const CELL = 0.105;
const FOOTPRINT = 2.18;
const PAPER_Z = 0.10;
const PAPER_TOP = 1.065;
const PRESS_Y = PAPER_TOP + 0.16;
const PARK_Y = 1.42;
const HOVER_Y = 2.30;
const redCells = new Set();
const blueCells = new Set();
const cellKey = (column, row) => `${column},${row}`;
// A circular vermilion form with a deliberate rectangular bite.
for (let row = 0; row < GRID; row++) {
for (let column = 0; column < GRID; column++) {
const dx = column - 8;
const dy = row - 4.15;
const insideCircle = dx * dx + dy * dy <= 12.1;
const removedNotch =
column >= 8 &&
column <= 10 &&
row >= 4 &&
row <= 7;
if (insideCircle && !removedNotch) {
redCells.add(cellKey(column, row));
}
}
}
function drawPixelLine(points, destination) {
const addCell = (x, y) => {
if (x >= 0 && x < GRID && y >= 0 && y < GRID) {
destination.add(cellKey(x, y));
}
};
for (let i = 0; i < points.length - 1; i++) {
let [x0, y0] = points[i];
const [x1, y1] = points[i + 1];
const dx = Math.abs(x1 - x0);
const sx = x0 < x1 ? 1 : -1;
const dy = -Math.abs(y1 - y0);
const sy = y0 < y1 ? 1 : -1;
let error = dx + dy;
while (true) {
addCell(x0, y0);
if (x0 === x1 && y0 === y1) break;
const twiceError = 2 * error;
if (twiceError >= dy) {
error += dy;
x0 += sx;
}
if (twiceError <= dx) {
error += dx;
y0 += sy;
}
}
}
}
// Two angular indigo tides fold beneath the split sun.
drawPixelLine([
[1, 16], [3, 15], [5, 14], [7, 13], [8, 12],
[9, 13], [11, 14], [13, 15], [15, 16]
], blueCells);
drawPixelLine([
[1, 12], [3, 11], [5, 10], [7, 9], [8, 8],
[9, 9], [11, 10], [13, 11], [15, 12]
], blueCells);
// Short terminal rays distinguish the design from a plain chevron.
drawPixelLine([[3, 16], [5, 15], [7, 14]], blueCells);
drawPixelLine([[13, 16], [11, 15], [9, 14]], blueCells);
function cellsToCoordinates(cellSet) {
return [...cellSet].map(key => {
const [column, row] = key.split(",").map(Number);
return {
column,
row,
x: (column - (GRID - 1) / 2) * CELL,
z: (row - (GRID - 1) / 2) * CELL
};
});
}
const redCoordinates = cellsToCoordinates(redCells);
const blueCoordinates = cellsToCoordinates(blueCells);
// ------------------------------------------------------------
// The single sheet and its animated two-color impression
// ------------------------------------------------------------
const paper = box(
scene,
[4.35, 0.06, 4.35],
[0, PAPER_TOP - 0.03, PAPER_Z],
mats.paper,
false,
true
);
// A slightly lifted lower corner gives the otherwise flat sheet depth.
box(
scene,
[0.24, 0.025, 0.38],
[1.93, PAPER_TOP - 0.006, 2.05],
mats.paper,
false,
true
);
const printEntries = [];
function createPrintCells(coordinates, color) {
coordinates.forEach(coordinate => {
const printMaterial = new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
transparent: true,
opacity: 0,
depthWrite: false
});
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(CELL * 0.88, 0.014, CELL * 0.88),
printMaterial
);
mesh.position.set(
coordinate.x,
PAPER_TOP + 0.012,
PAPER_Z + coordinate.z
);
mesh.visible = false;
mesh.scale.y = 0.05;
scene.add(mesh);
printEntries.push({
mesh,
row: coordinate.row,
delay: (coordinate.row / (GRID - 1)) * 0.22
});
});
}
createPrintCells(redCoordinates, 0xd64b3e);
createPrintCells(blueCoordinates, 0x244f69);
// ------------------------------------------------------------
// Registration guides: shared grid, center axes, corner keys
// ------------------------------------------------------------
const guideGroup = new THREE.Group();
guideGroup.position.set(0, PAPER_TOP + 0.026, PAPER_Z);
scene.add(guideGroup);
const guideMaterials = [];
function guideMaterial(color, opacity) {
const mat = new THREE.MeshBasicMaterial({
color,
transparent: true,
opacity,
depthWrite: false
});
guideMaterials.push({ mat, base: opacity });
return mat;
}
const gridMat = guideMaterial(0x315f65, 0.18);
const redGuideMat = guideMaterial(0xd64b3e, 0.88);
const blueGuideMat = guideMaterial(0x244f69, 0.88);
const brassGuideMat = guideMaterial(0x9b793d, 0.76);
const patternSpan = GRID * CELL;
for (let i = 0; i <= GRID; i++) {
const p = -patternSpan / 2 + i * CELL;
box(
guideGroup,
[0.009, 0.008, patternSpan],
[p, 0, 0],
gridMat,
false,
false
);
box(
guideGroup,
[patternSpan, 0.008, 0.009],
[0, 0, p],
gridMat,
false,
false
);
}
// Central crosshair.
box(guideGroup, [2.38, 0.011, 0.018], [0, 0.003, 0], brassGuideMat, false, false);
box(guideGroup, [0.018, 0.011, 2.38], [0, 0.004, 0], brassGuideMat, false, false);
// Alternating vermilion and indigo corner brackets.
const corners = [
[-1.17, -1.17, redGuideMat, 1, 1],
[ 1.17, -1.17, blueGuideMat, -1, 1],
[ 1.17, 1.17, redGuideMat, -1, -1],
[-1.17, 1.17, blueGuideMat, 1, -1]
];
for (const [x, z, mat, xDirection, zDirection] of corners) {
box(guideGroup, [0.30, 0.012, 0.026], [x + xDirection * 0.13, 0.009, z], mat, false, false);
box(guideGroup, [0.026, 0.012, 0.30], [x, 0.010, z + zDirection * 0.13], mat, false, false);
}
// Registration keys on the corners of both printing blocks.
function makeBlock(coordinates, pigmentMaterial, accentColor, parkX, parkYaw) {
const group = new THREE.Group();
scene.add(group);
box(group, [FOOTPRINT, 0.32, FOOTPRINT], [0, 0, 0], mats.woodDark);
box(group, [FOOTPRINT - 0.13, 0.035, FOOTPRINT - 0.13], [0, 0.178, 0], mats.woodLight);
// Color-coded side key.
box(
group,
[FOOTPRINT - 0.18, 0.065, 0.035],
[0, 0.025, FOOTPRINT / 2 + 0.006],
pigmentMaterial
);
for (const x of [-0.96, 0.96]) {
for (const z of [-0.96, 0.96]) {
box(group, [0.075, 0.075, 0.075], [x, 0.22, z], mats.brass);
}
}
for (const coordinate of coordinates) {
box(
group,
[CELL * 0.84, 0.11, CELL * 0.84],
[coordinate.x, 0.247, coordinate.z],
pigmentMaterial
);
}
// Small block handle on the outer edge.
box(group, [0.14, 0.16, 0.72], [-FOOTPRINT / 2 - 0.07, 0.04, 0], mats.wood);
box(group, [0.23, 0.12, 0.84], [-FOOTPRINT / 2 - 0.14, 0.12, 0], mats.woodDark);
group.position.set(parkX, PARK_Y, PAPER_Z);
group.rotation.y = parkYaw;
return {
group,
pigmentMaterial,
parkX,
parkYaw
};
}
const redBlock = makeBlock(redCoordinates, mats.red, 0xd64b3e, -3.38, -0.10);
const blueBlock = makeBlock(blueCoordinates, mats.blue, 0x244f69, 3.38, 0.10);
// Parking cradles.
for (const x of [-3.38, 3.38]) {
for (const dx of [-0.67, 0.67]) {
box(
scene,
[0.16, 0.25, 1.90],
[x + dx, 1.135, PAPER_Z],
mats.woodDark
);
}
}
// ------------------------------------------------------------
// Miniature registration map in the HTML overlay
// ------------------------------------------------------------
const miniGrid = document.querySelector("#mini-grid");
const miniCells = new Map();
for (let row = 0; row < GRID; row++) {
for (let column = 0; column < GRID; column++) {
const element = document.createElement("div");
element.className = "mini-cell";
miniGrid.appendChild(element);
const key = cellKey(column, row);
if (redCells.has(key)) {
element.classList.add("ghost-r");
miniCells.set(key, { element, type: "r" });
} else if (blueCells.has(key)) {
element.classList.add("ghost-b");
miniCells.set(key, { element, type: "b" });
}
}
}
function resetPrint() {
for (const entry of printEntries) {
entry.mesh.visible = false;
entry.mesh.material.opacity = 0;
entry.mesh.scale.y = 0.05;
}
for (const { element } of miniCells.values()) {
element.classList.remove("print-r", "print-b");
}
}
// ------------------------------------------------------------
// Animation timeline
// ------------------------------------------------------------
const RED_START = 0.15;
const BLUE_START = 4.65;
const SEQUENCE_DURATION = 9.35;
const TOTAL_DURATION = 10.7;
let timeline = 0;
let playing = true;
let speed = 1;
const easeInOut = value => {
const t = THREE.MathUtils.clamp(value, 0, 1);
return t * t * (3 - 2 * t);
};
function samplePlate(block, localTime) {
const t = localTime;
if (t <= 0 || t >= 3.75) {
block.group.position.set(block.parkX, PARK_Y, PAPER_Z);
block.group.rotation.y = block.parkYaw;
block.pigmentMaterial.emissiveIntensity = 0.08;
return;
}
let x = block.parkX;
let y = PARK_Y;
let yaw = block.parkYaw;
if (t < 1.0) {
const p = easeInOut(t / 1.0);
x = THREE.MathUtils.lerp(block.parkX, 0, p);
y = THREE.MathUtils.lerp(PARK_Y, HOVER_Y, p);
yaw = THREE.MathUtils.lerp(block.parkYaw, 0, p);
} else if (t < 1.65) {
const p = easeInOut((t - 1.0) / 0.65);
x = 0;
y = THREE.MathUtils.lerp(HOVER_Y, PRESS_Y, p);
yaw = 0;
} else if (t < 2.10) {
x = 0;
y = PRESS_Y;
yaw = 0;
block.pigmentMaterial.emissiveIntensity = 0.38;
} else if (t < 2.75) {
const p = easeInOut((t - 2.10) / 0.65);
x = 0;
y = THREE.MathUtils.lerp(PRESS_Y, HOVER_Y, p);
yaw = 0;
} else {
const p = easeInOut((t - 2.75) / 1.0);
x = THREE.MathUtils.lerp(0, block.parkX, p);
y = THREE.MathUtils.lerp(HOVER_Y, PARK_Y, p);
yaw = THREE.MathUtils.lerp(0, block.parkYaw, p);
}
block.group.position.set(x, y, PAPER_Z);
block.group.rotation.y = yaw;
if (t < 1.65 || t >= 2.10) {
block.pigmentMaterial.emissiveIntensity = 0.08;
}
}
function revealPrint(revealTime) {
const elapsed = timeline - revealTime;
for (const entry of printEntries) {
const p = THREE.MathUtils.clamp(
(elapsed - entry.delay) / 0.17,
0,
1
);
entry.mesh.visible = p > 0;
entry.mesh.material.opacity = p * 0.96;
entry.mesh.scale.y = Math.max(0.05, p);
}
}
const phaseElement = document.querySelector("#phase");
const phaseDetailElement = document.querySelector("#phase-detail");
const progressElement = document.querySelector("#progress");
const lockStateElement = document.querySelector("#lock-state");
function updateStatus() {
const redLocal = timeline - RED_START;
const blueLocal = timeline - BLUE_START;
if (timeline < RED_START) {
phaseElement.textContent = "Preparing plate I";
phaseDetailElement.textContent = "Vermilion block moving into register.";
lockStateElement.textContent = "Ready";
} else if (redLocal < 3.75) {
phaseElement.textContent = "Plate I · Vermilion";
if (redLocal < 1.65) {
phaseDetailElement.textContent = "Aligning the relief face to the shared grid.";
lockStateElement.textContent = "Aligning";
} else if (redLocal < 2.1) {
phaseDetailElement.textContent = "Registration keys locked. First impression in progress.";
lockStateElement.textContent = "Locked";
} else {
phaseDetailElement.textContent = "Raising plate I and revealing the vermilion impression.";
lockStateElement.textContent = "Printed";
}
} else if (blueLocal < 0) {
phaseElement.textContent = "Changing plates";
phaseDetailElement.textContent = "The first color is set. Preparing the indigo block.";
lockStateElement.textContent = "Ready";
} else if (blueLocal < 3.75) {
phaseElement.textContent = "Plate II · Indigo";
if (blueLocal < 1.65) {
phaseDetailElement.textContent = "Aligning the second relief face to the same origin.";
lockStateElement.textContent = "Aligning";
} else if (blueLocal < 2.1) {
phaseDetailElement.textContent = "Registration keys locked. Second impression in progress.";
lockStateElement.textContent = "Locked";
} else {
phaseDetailElement.textContent = "Raising plate II and completing the two-color image.";
lockStateElement.textContent = "Printed";
}
} else {
phaseElement.textContent = "Impression complete";
phaseDetailElement.textContent = "Both relief blocks share one verified registration grid.";
lockStateElement.textContent = "Verified";
}
progressElement.style.width = `${Math.min(timeline / TOTAL_DURATION, 1) * 100}%`;
}
function updateTimeline(delta) {
if (playing) {
timeline += delta * speed;
}
if (timeline >= TOTAL_DURATION) {
timeline = 0;
resetPrint();
}
samplePlate(redBlock, timeline - RED_START);
samplePlate(blueBlock, timeline - BLUE_START);
const redReveal = RED_START + 1.77;
const blueReveal = BLUE_START + 1.77;
revealPrint(redReveal);
if (timeline >= blueReveal) {
revealPrint(blueReveal);
}
// Update the HTML registration map as each color transfers.
for (const [key, entry] of miniCells.entries()) {
const coordinate = key.split(",").map(Number);
const row = coordinate[1];
const delay = (row / (GRID - 1)) * 0.22;
const reveal =
entry.type === "r" ? redReveal : blueReveal;
const printed = timeline - reveal - delay > 0.07;
if (printed) {
entry.element.classList.add(entry.type === "r" ? "print-r" : "print-b");
} else {
entry.element.classList.remove(entry.type === "r" ? "print-r" : "print-b");
}
}
updateStatus();
}
// ------------------------------------------------------------
// UI controls
// ------------------------------------------------------------
const replayButton = document.querySelector("#replay");
const pauseButton = document.querySelector("#pause");
const speedInput = document.querySelector("#speed");
const speedValue = document.querySelector("#speed-value");
const guidesInput = document.querySelector("#guides");
const resetCameraButton = document.querySelector("#reset-camera");
replayButton.addEventListener("click", () => {
timeline = 0;
resetPrint();
playing = true;
pauseButton.textContent = "Pause";
});
pauseButton.addEventListener("click", () => {
playing = !playing;
pauseButton.textContent = playing ? "Pause" : "Play";
});
speedInput.addEventListener("input", () => {
speed = Number(speedInput.value);
speedValue.textContent = `${speed}×`;
});
guidesInput.addEventListener("change", () => {
guideGroup.visible = guidesInput.checked;
});
resetCameraButton.addEventListener("click", resetCamera);
window.addEventListener("keydown", event => {
if (event.target instanceof HTMLInputElement) return;
if (event.code === "Space") {
event.preventDefault();
pauseButton.click();
} else if (event.key.toLowerCase() === "r") {
replayButton.click();
} else if (event.key.toLowerCase() === "g") {
guidesInput.checked = !guidesInput.checked;
guideGroup.visible = guidesInput.checked;
} else if (event.key.toLowerCase() === "c") {
resetCamera();
}
});
// ------------------------------------------------------------
// Render loop
// ------------------------------------------------------------
resetPrint();
resetCamera();
resize();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
updateTimeline(delta);
// The guide grid breathes gently to emphasize exact registration.
const pulse = 0.5 + 0.5 * Math.sin(performance.now() * 0.0025);
for (const item of guideMaterials) {
item.mat.opacity = item.base * (0.88 + pulse * 0.12);
}
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
document.querySelector("#loading").classList.add("hidden");
});
</script>
</body>
</html>
```