Prompt specification
Build or customize the Three.js 3D scene "Print workshop connecting carving and drying" 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: Print workshop connecting carving and drying
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/print-workshop-connecting-carving-and-drying-x2343
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing Edo-period Japanese woodblock printing. Build a referenced Japanese print workshop with design table, carving area, printing bench, and drying rack. Follow one original print through the stages without copying a protected artwork. Low-poly.
Working Three.js Starter (print-workshop-connecting-carving-and-drying-x2343):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Koi at Dusk — An Edo-Inspired Woodblock Workshop</title>
<style>
:root {
--ink: #201b19;
--paper: #f2e8cf;
--paper-dark: #d8c7a3;
--red: #b84b36;
--indigo: #254b61;
--gold: #c49b4a;
--panel: rgba(32, 27, 25, 0.86);
--line: rgba(242, 232, 207, 0.22);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #cdbb9a;
color: var(--paper);
font-family: Georgia, "Times New Roman", serif;
}
#viewport {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
#hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.panel {
background: var(--panel);
border: 1px solid var(--line);
box-shadow: 0 14px 45px rgba(24, 17, 12, 0.22);
backdrop-filter: blur(10px);
}
#title-card {
position: absolute;
top: 20px;
left: 20px;
width: min(410px, calc(100vw - 40px));
padding: 17px 19px 15px;
border-left: 4px solid var(--red);
}
.eyebrow {
margin: 0 0 7px;
color: #d9bd7b;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(25px, 3vw, 38px);
font-weight: 500;
line-height: 1;
letter-spacing: 0.02em;
}
.subtitle {
margin: 9px 0 0;
color: #d9cfba;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 1.5;
}
#stage-card {
position: absolute;
top: 20px;
right: 20px;
width: min(330px, calc(100vw - 40px));
padding: 16px 18px;
}
#stage-number {
color: var(--gold);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.2em;
text-transform: uppercase;
}
#stage-title {
margin: 5px 0 7px;
font-size: 24px;
font-weight: 500;
}
#stage-description {
min-height: 50px;
margin: 0;
color: #d9cfba;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
line-height: 1.55;
}
#controls {
position: absolute;
top: 170px;
right: 20px;
display: flex;
gap: 7px;
pointer-events: auto;
}
button {
border: 1px solid rgba(242, 232, 207, 0.26);
border-radius: 0;
background: rgba(32, 27, 25, 0.88);
color: var(--paper);
padding: 9px 12px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
letter-spacing: 0.04em;
cursor: pointer;
transition:
background 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover {
background: #493a31;
border-color: rgba(242, 232, 207, 0.62);
}
button:active {
transform: translateY(1px);
}
button.active {
border-color: var(--gold);
color: #f5d998;
}
#timeline-panel {
position: absolute;
right: 20px;
bottom: 20px;
left: 20px;
padding: 13px 15px 14px;
pointer-events: auto;
}
.timeline-top {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 11px;
}
#play {
min-width: 86px;
border-color: var(--gold);
color: #f5d998;
}
#scrubber {
width: 100%;
height: 5px;
margin: 0;
appearance: none;
border-radius: 0;
outline: none;
background:
linear-gradient(
to right,
var(--gold) 0%,
var(--gold) var(--progress, 0%),
rgba(242, 232, 207, 0.18) var(--progress, 0%),
rgba(242, 232, 207, 0.18) 100%
);
cursor: pointer;
}
#scrubber::-webkit-slider-thumb {
width: 13px;
height: 13px;
appearance: none;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--red);
box-shadow: 0 0 0 3px rgba(242, 232, 207, 0.12);
}
#scrubber::-moz-range-thumb {
width: 11px;
height: 11px;
border: 2px solid var(--paper);
border-radius: 50%;
background: var(--red);
}
#time-label {
min-width: 76px;
color: #d9cfba;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-align: right;
}
#stage-nav {
display: grid;
grid-template-columns: repeat(5, minmax(125px, 1fr));
gap: 7px;
}
.stage-button {
position: relative;
display: flex;
min-height: 48px;
align-items: center;
gap: 10px;
overflow: hidden;
padding: 8px 10px;
text-align: left;
}
.stage-button::before {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 3px;
background: transparent;
content: "";
}
.stage-button.active {
background: rgba(184, 75, 54, 0.2);
}
.stage-button.active::before {
background: var(--red);
}
.stage-index {
color: var(--gold);
font-family: Georgia, serif;
font-size: 19px;
}
.stage-name {
display: block;
font-size: 11px;
font-weight: 700;
}
.stage-duration {
display: block;
margin-top: 3px;
color: #a99f91;
font-size: 9px;
}
#hint {
position: absolute;
bottom: 147px;
left: 22px;
padding: 7px 10px;
color: rgba(32, 27, 25, 0.76);
background: rgba(242, 232, 207, 0.78);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
letter-spacing: 0.04em;
pointer-events: none;
}
#loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #cdbb9a;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
.loading-inner {
width: min(430px, calc(100vw - 40px));
padding: 28px;
border: 1px solid rgba(32, 27, 25, 0.25);
background: rgba(242, 232, 207, 0.62);
text-align: center;
}
.loading-mark {
margin-bottom: 13px;
color: var(--red);
font-size: 45px;
}
.loading-copy {
color: var(--ink);
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
line-height: 1.7;
letter-spacing: 0.08em;
}
@media (max-width: 760px) {
#title-card {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
}
#stage-card {
top: 138px;
right: 12px;
width: calc(100vw - 24px);
padding: 12px 14px;
}
#stage-description {
min-height: 0;
}
#controls {
top: 246px;
right: 12px;
flex-wrap: wrap;
justify-content: flex-end;
}
#timeline-panel {
right: 12px;
bottom: 12px;
left: 12px;
overflow-x: auto;
}
#stage-nav {
width: 650px;
}
#hint {
display: none;
}
.timeline-top {
min-width: 610px;
}
}
</style>
</head>
<body>
<div id="viewport"></div>
<div id="hud">
<section id="title-card" class="panel">
<p class="eyebrow">Edo-inspired moku-hanga workshop · c. 1850</p>
<h1>Koi at Dusk</h1>
<p class="subtitle">
Follow one entirely original print from a first brush drawing to a
finished sheet on the drying rack.
</p>
</section>
<section id="stage-card" class="panel">
<div id="stage-number">Stage 01 / 05</div>
<h2 id="stage-title">Designing the composition</h2>
<p id="stage-description"></p>
</section>
<nav id="controls" aria-label="Scene controls">
<button id="overview" type="button">Overview</button>
<button id="follow" class="active" type="button">Follow print</button>
</nav>
<div id="hint">Drag to orbit · Wheel to zoom · Shift-drag to pan</div>
<section id="timeline-panel" class="panel">
<div class="timeline-top">
<button id="play" type="button">Pause</button>
<input
id="scrubber"
type="range"
min="0"
max="40"
step="0.05"
value="0"
aria-label="Workshop timeline"
/>
<span id="time-label">00:00 / 00:40</span>
</div>
<div id="stage-nav">
<button class="stage-button active" type="button" data-start="0">
<span class="stage-index">01</span>
<span>
<span class="stage-name">Design</span>
<span class="stage-duration">Brush the original drawing</span>
</span>
</button>
<button class="stage-button" type="button" data-start="7">
<span class="stage-index">02</span>
<span>
<span class="stage-name">Key block</span>
<span class="stage-duration">Carve the master lines</span>
</span>
</button>
<button class="stage-button" type="button" data-start="14">
<span class="stage-index">03</span>
<span>
<span class="stage-name">Color blocks</span>
<span class="stage-duration">Cut and register colors</span>
</span>
</button>
<button class="stage-button" type="button" data-start="23">
<span class="stage-index">04</span>
<span>
<span class="stage-name">Printing</span>
<span class="stage-duration">Press each layer onto washi</span>
</span>
</button>
<button class="stage-button" type="button" data-start="32">
<span class="stage-index">05</span>
<span>
<span class="stage-name">Drying</span>
<span class="stage-duration">Hang the completed print</span>
</span>
</button>
</div>
</section>
</div>
<div id="loading">
<div class="loading-inner">
<div class="loading-mark">魚</div>
<div class="loading-copy">
PREPARING THE WORKSHOP<br />
Carving blocks, mixing pigments, and printing an original composition
</div>
</div>
</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 viewport = document.getElementById("viewport");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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.12;
viewport.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd2c09e);
scene.fog = new THREE.Fog(0xd2c09e, 23, 43);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 1.1, -0.5);
camera.position.set(14, 11.5, 16.5);
camera.lookAt(cameraTarget);
const hemisphere = new THREE.HemisphereLight(0xf6e4bd, 0x59483d, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe2ac, 3.25);
sun.position.set(-8, 15, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -16;
sun.shadow.camera.right = 16;
sun.shadow.camera.top = 14;
sun.shadow.camera.bottom = -14;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00035;
scene.add(sun);
const warmFill = new THREE.PointLight(0xe89959, 18, 13, 2);
warmFill.position.set(5, 4.6, -3.8);
scene.add(warmFill);
// ------------------------------------------------------------
// Procedural textures
// ------------------------------------------------------------
function makeCanvasTexture(width, height, draw) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
draw(context, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const floorTexture = makeCanvasTexture(512, 512, (ctx, w, h) => {
ctx.fillStyle = "#9a7049";
ctx.fillRect(0, 0, w, h);
const plankHeight = 64;
for (let row = 0; row < h / plankHeight; row++) {
const offset = row % 2 === 0 ? 0 : 90;
for (let x = -180; x < w + 180; x += 180) {
const tone = 112 + ((row * 17 + x * 3) % 24);
ctx.fillStyle = `rgb(${tone + 35},${tone - 15},${tone - 54})`;
ctx.fillRect(x + offset, row * plankHeight, 178, plankHeight - 3);
ctx.fillStyle = "rgba(52,31,19,.20)";
ctx.fillRect(x + offset, row * plankHeight + 58, 178, 2);
}
}
for (let i = 0; i < 100; i++) {
const x = (i * 97) % w;
const y = (i * 53) % h;
ctx.strokeStyle = "rgba(50,30,20,.07)";
ctx.beginPath();
ctx.moveTo(x, y);
ctx.bezierCurveTo(x + 20, y - 3, x + 45, y + 3, x + 80, y);
ctx.stroke();
}
});
floorTexture.wrapS = floorTexture.wrapT = THREE.RepeatWrapping;
floorTexture.repeat.set(5, 3);
// The featured composition is procedural and original.
const artworkCanvas = document.createElement("canvas");
artworkCanvas.width = 512;
artworkCanvas.height = 704;
const artworkContext = artworkCanvas.getContext("2d");
const artworkTexture = new THREE.CanvasTexture(artworkCanvas);
artworkTexture.colorSpace = THREE.SRGBColorSpace;
artworkTexture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
function drawKoiPath(ctx) {
ctx.beginPath();
ctx.moveTo(359, 350);
ctx.bezierCurveTo(350, 300, 291, 278, 235, 307);
ctx.bezierCurveTo(184, 333, 177, 390, 219, 426);
ctx.bezierCurveTo(269, 469, 344, 439, 359, 388);
ctx.closePath();
}
function drawTail(ctx) {
ctx.beginPath();
ctx.moveTo(216, 351);
ctx.bezierCurveTo(183, 316, 143, 302, 108, 295);
ctx.bezierCurveTo(123, 330, 128, 359, 111, 397);
ctx.bezierCurveTo(151, 391, 186, 376, 216, 361);
ctx.closePath();
}
function drawPlant(ctx, includeColor, progress) {
const greenVisible = includeColor && progress > 0.46;
const flowerVisible = includeColor && progress > 0.66;
ctx.strokeStyle = greenVisible ? "#466b55" : "#211b19";
ctx.fillStyle = greenVisible ? "#6f8c65" : "transparent";
ctx.lineWidth = 9;
ctx.lineCap = "round";
ctx.beginPath();
ctx.moveTo(379, 618);
ctx.bezierCurveTo(363, 513, 386, 414, 356, 274);
ctx.moveTo(373, 487);
ctx.bezierCurveTo(323, 431, 305, 370, 300, 312);
ctx.stroke();
const leaves = [
[374, 535, 316, 501, 284, 538],
[371, 470, 425, 429, 452, 465],
[365, 410, 309, 380, 286, 414],
[360, 348, 408, 314, 432, 348]
];
for (const [x1, y1, cx, cy, x2, y2] of leaves) {
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.quadraticCurveTo(cx, cy, x2, y2);
ctx.quadraticCurveTo(cx, cy + 20, x1, y1);
if (greenVisible) ctx.fill();
ctx.stroke();
}
function bellflower(x, y, radius, color) {
ctx.beginPath();
ctx.moveTo(x, y - 15);
ctx.bezierCurveTo(
x - radius,
y - 2,
x - radius + 5,
y + radius,
x,
y + radius + 6
);
ctx.bezierCurveTo(
x + radius - 5,
y + radius,
x + radius,
y - 2,
x,
y - 15
);
if (flowerVisible) {
ctx.fillStyle = color;
ctx.fill();
}
ctx.strokeStyle = "#211b19";
ctx.lineWidth = 5;
ctx.stroke();
}
bellflower(352, 224, 34, "#765176");
bellflower(294, 277, 29, "#b75a62");
bellflower(405, 304, 25, "#77527d");
}
function drawArtwork(mode, progress) {
const ctx = artworkContext;
const w = artworkCanvas.width;
const h = artworkCanvas.height;
ctx.clearRect(0, 0, w, h);
ctx.save();
ctx.lineJoin = "round";
ctx.lineCap = "round";
const isPaper = mode !== "block";
if (isPaper) {
ctx.fillStyle = "#f1e6c9";
ctx.fillRect(0, 0, w, h);
// Deterministic washi flecks.
for (let i = 0; i < 210; i++) {
const x = (i * 83 + 19) % w;
const y = (i * 47 + 11) % h;
ctx.fillStyle = i % 3 === 0
? "rgba(112,91,57,.045)"
: "rgba(255,255,255,.07)";
ctx.fillRect(x, y, 1 + (i % 2), 1);
}
}
const printMode = mode === "print";
// Moon.
if (printMode && progress > 0.13) {
ctx.fillStyle = "#d9bd69";
ctx.beginPath();
ctx.arc(105, 132, 67, 0, Math.PI * 2);
ctx.fill();
}
ctx.strokeStyle = mode === "block" ? "#171311" : "#28211e";
ctx.lineWidth = mode === "block" ? 7 : 5;
ctx.beginPath();
ctx.arc(105, 132, 67, 0, Math.PI * 2);
ctx.stroke();
// Water bands.
if (printMode && progress > 0.25) {
ctx.strokeStyle = "#31566b";
ctx.lineWidth = 13;
for (let band = 0; band < 4; band++) {
const y = 468 + band * 51;
ctx.beginPath();
ctx.moveTo(-25, y);
ctx.bezierCurveTo(70, y - 24, 140, y + 25, 238, y);
ctx.bezierCurveTo(337, y - 25, 405, y + 23, 540, y - 4);
ctx.stroke();
}
}
drawPlant(ctx, printMode, progress);
// Koi body.
if (printMode && progress > 0.76) {
ctx.fillStyle = "#c65d43";
drawKoiPath(ctx);
ctx.fill();
ctx.fillStyle = "#eee2c4";
ctx.beginPath();
ctx.ellipse(278, 337, 23, 17, -0.35, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.ellipse(307, 395, 15, 11, 0.4, 0, Math.PI * 2);
ctx.fill();
}
ctx.strokeStyle = mode === "block" ? "#14110f" : "#211a18";
ctx.lineWidth = mode === "block" ? 8 : 5;
drawKoiPath(ctx);
ctx.stroke();
ctx.fillStyle = printMode && progress > 0.76 ? "#c65d43" : "transparent";
drawTail(ctx);
ctx.fill();
ctx.stroke();
// Fins.
ctx.beginPath();
ctx.moveTo(259, 308);
ctx.quadraticCurveTo(257, 263, 294, 276);
ctx.quadraticCurveTo(281, 294, 259, 308);
ctx.closePath();
if (printMode && progress > 0.76) {
ctx.fillStyle = "#c65d43";
ctx.fill();
}
ctx.stroke();
// Eye and gill.
ctx.fillStyle = "#211a18";
ctx.beginPath();
ctx.arc(333, 342, 6, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(315, 346, 20, 0.45, 1.75);
ctx.stroke();
// Fine water accents.
ctx.strokeStyle = printMode && progress > 0.25 ? "#31566b" : "#29211e";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.moveTo(62, 570);
ctx.bezierCurveTo(100, 548, 135, 591, 174, 566);
ctx.moveTo(164, 618);
ctx.bezierCurveTo(200, 598, 229, 633, 270, 608);
ctx.stroke();
// A restrained printed border.
ctx.strokeStyle = "rgba(32,25,22,.38)";
ctx.lineWidth = 3;
ctx.strokeRect(22, 22, w - 44, h - 44);
ctx.restore();
artworkTexture.needsUpdate = true;
}
function makeMiniPrintTexture(index) {
return makeCanvasTexture(256, 352, (ctx, w, h) => {
const palettes = [
["#e8d9b6", "#c45740", "#31576b"],
["#e9dcba", "#5d785f", "#b58a3f"],
["#eee4ca", "#745477", "#31566b"]
];
const p = palettes[index % palettes.length];
ctx.fillStyle = p[0];
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = p[1];
ctx.beginPath();
ctx.arc(w * 0.65, h * 0.28, 35, 0, Math.PI * 2);
ctx.fill();
ctx.fillStyle = p[2];
for (let i = 0; i < 5; i++) {
const y = h * 0.55 + i * 28;
ctx.beginPath();
ctx.moveTo(-10, y);
ctx.bezierCurveTo(55, y - 24, 90, y + 20, 145, y);
ctx.bezierCurveTo(190, y - 18, 225, y + 18, 270, y - 2);
ctx.lineTo(270, y + 10);
ctx.lineTo(-10, y + 10);
ctx.closePath();
ctx.fill();
}
ctx.strokeStyle = "rgba(30,24,20,.55)";
ctx.lineWidth = 4;
ctx.strokeRect(13, 13, w - 26, h - 26);
});
}
// ------------------------------------------------------------
// Materials and geometry helpers
// ------------------------------------------------------------
function stdMaterial(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0,
flatShading: true,
...options
});
}
const materials = {
darkWood: stdMaterial(0x4c3326),
wood: stdMaterial(0x8d5a38),
lightWood: stdMaterial(0xb57e4e),
cherry: stdMaterial(0xc28b5b),
plaster: stdMaterial(0xd8c6a3),
darkPlaster: stdMaterial(0xb9a484),
paper: stdMaterial(0xefe3c4),
black: stdMaterial(0x24211e),
iron: stdMaterial(0x3d4140, { metalness: 0.42, roughness: 0.55 }),
indigo: stdMaterial(0x294b61),
red: stdMaterial(0xba503b),
green: stdMaterial(0x59735a),
purple: stdMaterial(0x735675),
gold: stdMaterial(0xc39b4b),
shoji: stdMaterial(0xe7d7b0, {
emissive: 0x7e6743,
emissiveIntensity: 0.13
})
};
function addBox(parent, w, h, d, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
topRadius,
bottomRadius,
height,
segments,
material,
x = 0,
y = 0,
z = 0
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinderBetween(parent, a, b, radius, material, segments = 6) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const mesh = addCylinder(
parent,
radius,
radius,
direction.length(),
segments,
material
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return mesh;
}
function addTable(parent, x, z, width, depth, height = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
parent.add(group);
addBox(
group,
width,
0.16,
depth,
materials.lightWood,
0,
height,
0
);
const legInsetX = width * 0.37;
const legInsetZ = depth * 0.31;
for (const sx of [-1, 1]) {
for (const sz of [-1, 1]) {
addBox(
group,
0.18,
height,
0.18,
materials.darkWood,
sx * legInsetX,
height * 0.5,
sz * legInsetZ
);
}
}
addBox(
group,
width * 0.82,
0.12,
0.12,
materials.darkWood,
0,
height * 0.3,
-depth * 0.31
);
return group;
}
function addBowl(parent, x, y, z, color, radius = 0.23) {
const bowl = addCylinder(
parent,
radius,
radius * 0.76,
0.11,
12,
stdMaterial(color),
x,
y,
z
);
const pigment = addCylinder(
parent,
radius * 0.78,
radius * 0.78,
0.015,
12,
stdMaterial(color, { roughness: 0.35 }),
x,
y + 0.061,
z
);
return { bowl, pigment };
}
function makeLabel(text, accent = "#b84b36") {
const texture = makeCanvasTexture(512, 112, (ctx, w, h) => {
ctx.fillStyle = "rgba(30,25,22,.88)";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 10, h);
ctx.strokeStyle = "rgba(242,232,207,.32)";
ctx.lineWidth = 3;
ctx.strokeRect(2, 2, w - 4, h - 4);
ctx.fillStyle = "#f2e8cf";
ctx.font = "600 34px Arial, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, w / 2 + 4, h / 2 + 2);
});
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(2.65, 0.58, 1);
sprite.renderOrder = 8;
return sprite;
}
// ------------------------------------------------------------
// Workshop architecture
// ------------------------------------------------------------
const floorMaterial = new THREE.MeshStandardMaterial({
map: floorTexture,
roughness: 0.9,
flatShading: true
});
addBox(scene, 20.4, 0.38, 12.4, floorMaterial, 0, -0.22, 0);
addBox(scene, 21.2, 0.18, 13.2, materials.darkWood, 0, -0.48, 0);
// Back wall: plaster above and timber below.
addBox(scene, 20, 3.6, 0.22, materials.plaster, 0, 3.05, -5.65);
addBox(scene, 20, 1.6, 0.25, materials.darkWood, 0, 0.85, -5.55);
// Left return wall.
addBox(scene, 0.25, 4.9, 8.2, materials.plaster, -9.85, 2.45, -1.55);
addBox(scene, 0.28, 1.5, 8.2, materials.darkWood, -9.72, 0.78, -1.55);
// Structural posts and beams.
for (const x of [-9.5, -3.2, 3.2, 9.5]) {
addBox(scene, 0.34, 5.4, 0.36, materials.darkWood, x, 2.7, -5.25);
addBox(scene, 0.22, 4.8, 0.24, materials.darkWood, x, 2.4, 5.25);
}
addBox(scene, 20, 0.32, 0.38, materials.darkWood, 0, 5.3, -5.22);
addBox(scene, 20, 0.3, 0.34, materials.darkWood, 0, 5.08, 5.22);
addBox(scene, 19.5, 0.26, 0.3, materials.darkWood, 0, 4.95, 0);
// Exposed rafters.
for (const x of [-7.5, -4.5, -1.5, 1.5, 4.5, 7.5]) {
const rafter = addBox(
scene,
0.17,
0.18,
10.5,
materials.darkWood,
x,
4.95,
0
);
rafter.rotation.y = x * 0.003;
}
// Shoji-style panels on the rear wall.
for (let i = 0; i < 6; i++) {
const x = -7.9 + i * 3.15;
addBox(scene, 2.75, 3.35, 0.08, materials.shoji, x, 3.35, -5.49);
addBox(scene, 0.09, 3.42, 0.13, materials.darkWood, x - 1.38, 3.35, -5.41);
addBox(scene, 0.09, 3.42, 0.13, materials.darkWood, x + 1.38, 3.35, -5.41);
for (let j = 0; j < 4; j++) {
addBox(
scene,
2.72,
0.045,
0.1,
materials.wood,
x,
2.05 + j * 0.86,
-5.39
);
}
for (let j = 0; j < 3; j++) {
addBox(
scene,
0.045,
3.28,
0.1,
materials.wood,
x - 0.9 + j * 0.9,
3.35,
-5.39
);
}
}
// Workshop sign.
const signTexture = makeCanvasTexture(768, 200, (ctx, w, h) => {
ctx.fillStyle = "#3d2b22";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "#c5a15d";
ctx.lineWidth = 8;
ctx.strokeRect(14, 14, w - 28, h - 28);
ctx.fillStyle = "#ead9ad";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = "72px serif";
ctx.fillText("江戸 摺絵工房", w / 2, h / 2 - 8);
ctx.font = "22px Arial";
ctx.fillText("EDO · COLORED WOODBLOCK STUDIO", w / 2, h - 43);
});
const sign = new THREE.Mesh(
new THREE.PlaneGeometry(5.1, 1.33),
new THREE.MeshStandardMaterial({ map: signTexture, roughness: 0.9 })
);
sign.position.set(0.2, 4.55, -5.17);
scene.add(sign);
// Lanterns.
function addLantern(x, z) {
cylinderBetween(
scene,
[x, 5.0, z],
[x, 4.3, z],
0.025,
materials.black,
6
);
const shade = addCylinder(
scene,
0.27,
0.32,
0.55,
8,
stdMaterial(0xe5c783, {
emissive: 0xd69748,
emissiveIntensity: 0.55
}),
x,
3.94,
z
);
addCylinder(scene, 0.33, 0.33, 0.06, 8, materials.darkWood, x, 4.24, z);
addCylinder(scene, 0.33, 0.33, 0.06, 8, materials.darkWood, x, 3.64, z);
return shade;
}
addLantern(-4.2, -3.9);
addLantern(5.5, -3.9);
// ------------------------------------------------------------
// Design area
// ------------------------------------------------------------
const designTable = addTable(scene, -5.7, 0.15, 3.3, 1.75, 0.96);
addBowl(designTable, -1.08, 1.08, 0.42, 0x283f4f, 0.25);
addBowl(designTable, -1.08, 1.08, -0.02, 0xb84b36, 0.22);
addBowl(designTable, -0.61, 1.08, 0.48, 0x6e805d, 0.19);
addBowl(designTable, -0.64, 1.08, 0.05, 0xc7a258, 0.18);
// Brush pot and brushes.
addCylinder(
designTable,
0.18,
0.15,
0.48,
8,
materials.indigo,
-1.24,
1.3,
-0.48
);
for (let i = 0; i < 5; i++) {
const brush = cylinderBetween(
designTable,
[-1.24 + (i - 2) * 0.035, 1.43, -0.48],
[-1.3 + i * 0.055, 1.91 + (i % 2) * 0.12, -0.46],
0.018,
i % 2 ? materials.darkWood : materials.lightWood,
5
);
brush.castShadow = true;
}
// Paper stack and ruler.
for (let i = 0; i < 6; i++) {
addBox(
designTable,
0.78,
0.018,
0.98,
materials.paper,
1.04,
1.057 + i * 0.018,
-0.02
);
}
addBox(
designTable,
1.42,
0.035,
0.08,
materials.gold,
0.74,
1.067,
0.59
);
const designLabel = makeLabel("01 · DESIGN", "#b84b36");
designLabel.position.set(-5.7, 2.33, 0.2);
scene.add(designLabel);
// ------------------------------------------------------------
// Carving area
// ------------------------------------------------------------
const carvingTable = addTable(scene, -1.15, -0.65, 4.05, 2.35, 0.98);
// Carving knife and mallet.
const carvingKnife = new THREE.Group();
carvingKnife.position.set(1.05, 1.12, 0.18);
carvingKnife.rotation.y = -0.55;
carvingTable.add(carvingKnife);
addBox(carvingKnife, 0.65, 0.07, 0.08, materials.lightWood, 0, 0, 0);
addBox(carvingKnife, 0.28, 0.045, 0.12, materials.iron, 0.42, 0, 0);
cylinderBetween(
carvingKnife,
[0.12, 0, 0],
[0.12, 0.3, 0],
0.018,
materials.iron,
5
);
const malletPivot = new THREE.Group();
malletPivot.position.set(0.62, 1.18, -0.63);
carvingTable.add(malletPivot);
cylinderBetween(
malletPivot,
[0, 0, 0],
[0, 0.47, 0],
0.055,
materials.lightWood,
7
);
addBox(
malletPivot,
0.43,
0.22,
0.23,
materials.wood,
0,
0.48,
0
);
// Wood shavings.
for (let i = 0; i < 14; i++) {
const shaving = addBox(
carvingTable,
0.28,
0.025,
0.07,
materials.cherry,
-1.55 + (i % 7) * 0.09,
1.095,
0.72 + Math.floor(i / 7) * 0.14
);
shaving.rotation.y = i * 0.71;
shaving.rotation.z = (i % 3 - 1) * 0.1;
}
const carvingLabel = makeLabel("02 · CARVING", "#b88743");
carvingLabel.position.set(-1.1, 2.35, -0.8);
scene.add(carvingLabel);
// Color-block side stand.
const colorStand = new THREE.Group();
colorStand.position.set(0.45, 0, -2.3);
scene.add(colorStand);
addBox(colorStand, 3.15, 0.16, 1.2, materials.darkWood, 0, 0.83, 0);
for (const x of [-1.25, 1.25]) {
addBox(colorStand, 0.16, 0.83, 0.16, materials.darkWood, x, 0.42, 0);
}
const colorBlockGroups = [];
const blockColors = [materials.green, materials.indigo, materials.red];
for (let i = 0; i < 3; i++) {
const group = new THREE.Group();
group.position.set(-0.98 + i * 0.98, 0.98, -0.03 + (i % 2) * 0.08);
group.scale.setScalar(0.001);
colorStand.add(group);
addBox(group, 0.78, 0.13, 0.94, blockColors[i], 0, 0, 0);
// A small raised shape suggests a separately carved color area.
const shape = addBox(
group,
0.28,
0.025,
0.45,
stdMaterial(blockColors[i].color, {
roughness: 0.45
}),
0,
0.075,
0
);
shape.rotation.y = i * 0.4;
colorBlockGroups.push(group);
}
const colorLabel = makeLabel("03 · COLOR BLOCKS", "#55745a");
colorLabel.position.set(0.45, 2.12, -2.3);
scene.add(colorLabel);
// ------------------------------------------------------------
// Printing bench
// ------------------------------------------------------------
const printingTable = addTable(scene, 4.25, 0.85, 5.1, 2.45, 0.98);
// Pigment bowls.
addBowl(printingTable, -1.75, 1.08, -0.52, 0x263f4e, 0.26);
addBowl(printingTable, -1.75, 1.08, 0.04, 0xb84b36, 0.23);
addBowl(printingTable, -1.17, 1.08, -0.42, 0xc5a054, 0.2);
// Stack of fresh paper.
for (let i = 0; i < 8; i++) {
addBox(
printingTable,
1.18,
0.017,
1.46,
materials.paper,
1.68,
1.059 + i * 0.017,
0
);
}
// Baren-like rubbing pad.
const baren = new THREE.Group();
printingTable.add(baren);
addCylinder(baren, 0.19, 0.23, 0.11, 10, materials.paper, 0, 0, 0);
addCylinder(baren, 0.1, 0.16, 0.17, 8, materials.darkWood, 0, 0.12, 0);
// Roller press with a wooden axle.
const roller = new THREE.Group();
roller.position.set(4.25, 1.45, -0.05);
scene.add(roller);
const rollerBody = addCylinder(
roller,
0.24,
0.24,
1.75,
12,
materials.paper,
0,
0,
0
);
rollerBody.rotation.z = Math.PI / 2;
const axle = addCylinder(
roller,
0.055,
0.055,
2.62,
8,
materials.darkWood,
0,
0,
0
);
axle.rotation.z = Math.PI / 2;
for (const x of [-1.22, 1.22]) {
addBox(roller, 0.12, 0.13, 0.14, materials.red, x, 0, 0);
}
const printingLabel = makeLabel("04 · PRINTING", "#31566b");
printingLabel.position.set(4.25, 2.34, 0.9);
scene.add(printingLabel);
// ------------------------------------------------------------
// Drying rack
// ------------------------------------------------------------
const rack = new THREE.Group();
rack.position.set(7.65, 0, -4.25);
scene.add(rack);
for (const x of [-1.65, 1.65]) {
addBox(rack, 0.16, 4.55, 0.18, materials.darkWood, x, 2.28, 0);
addBox(rack, 0.18, 0.18, 1.4, materials.darkWood, x, 0.12, 0.35);
}
addBox(rack, 3.45, 0.13, 0.16, materials.darkWood, 0, 4.32, 0);
addBox(rack, 3.45, 0.12, 0.16, materials.darkWood, 0, 1.15, 0);
// Fine drying cord.
const cordPoints = [
new THREE.Vector3(-1.65, 4.28, 0.04),
new THREE.Vector3(0, 4.18, 0.04),
new THREE.Vector3(1.65, 4.28, 0.04)
];
const cord = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(cordPoints),
new THREE.LineBasicMaterial({ color: 0x5d4b39 })
);
rack.add(cord);
// Decorative completed prints on either side of the hero sheet.
const miniPrints = [];
for (let i = 0; i < 2; i++) {
const printGroup = new THREE.Group();
printGroup.position.set(i === 0 ? -1.15 : 1.13, 2.62, 0.06);
rack.add(printGroup);
const print = new THREE.Mesh(
new THREE.PlaneGeometry(0.78, 1.12),
new THREE.MeshStandardMaterial({
map: makeMiniPrintTexture(i + 1),
side: THREE.DoubleSide,
roughness: 0.95
})
);
print.castShadow = true;
printGroup.add(print);
cylinderBetween(
printGroup,
[0, 0.56, 0],
[0, 0.77, 0],
0.012,
materials.darkWood,
5
);
miniPrints.push(printGroup);
}
const dryingLabel = makeLabel("05 · DRYING", "#765477");
dryingLabel.position.set(7.65, 4.88, -4.15);
scene.add(dryingLabel);
// ------------------------------------------------------------
// Low-poly artisans
// ------------------------------------------------------------
function addWorker(x, z, robeColor, apronColor, turned = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = turned;
scene.add(group);
const robe = stdMaterial(robeColor);
const apron = stdMaterial(apronColor);
const skin = stdMaterial(0xc99369);
// Seated lower body.
addCylinder(group, 0.31, 0.43, 0.62, 7, robe, 0, 0.45, 0);
addBox(group, 0.56, 0.18, 0.55, robe, 0, 0.13, 0.12);
// Torso.
addCylinder(group, 0.28, 0.34, 0.65, 7, robe, 0, 0.91, 0);
addBox(group, 0.43, 0.48, 0.08, apron, 0, 0.78, 0.28);
// Head, hair, and simple facial wedge.
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.22, 1),
skin
);
head.position.set(0, 1.42, 0.015);
head.castShadow = true;
group.add(head);
const hair = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.225, 1),
materials.black
);
hair.scale.set(1.02, 0.68, 1.03);
hair.position.set(0, 1.54, -0.025);
group.add(hair);
const nose = addBox(
group,
0.07,
0.065,
0.08,
skin,
0,
1.41,
0.22
);
nose.rotation.x = -0.15;
// Arms reaching toward the work.
cylinderBetween(
group,
[-0.25, 1.08, 0.02],
[-0.38, 0.78, 0.47],
0.09,
robe,
6
);
cylinderBetween(
group,
[0.25, 1.08, 0.02],
[0.39, 0.79, 0.46],
0.09,
robe,
6
);
addBox(group, 0.14, 0.08, 0.14, skin, -0.39, 0.78, 0.49);
addBox(group, 0.14, 0.08, 0.14, skin, 0.4, 0.79, 0.48);
return group;
}
const designer = addWorker(-5.75, -1.08, 0x354a58, 0x9c6b43);
const carver = addWorker(-0.95, -2.38, 0x765849, 0x3d4b50);
const printer = addWorker(5.48, -0.73, 0x4b5158, 0x9a4e3f);
// Extra shelving and workshop storage.
const shelf = new THREE.Group();
shelf.position.set(-6.8, 0, -4.85);
scene.add(shelf);
for (const y of [1.15, 2.05, 2.95]) {
addBox(shelf, 3.75, 0.12, 0.72, materials.darkWood, 0, y, 0);
}
for (const x of [-1.7, 1.7]) {
addBox(shelf, 0.13, 3.25, 0.13, materials.darkWood, x, 1.62, -0.23);
}
// Stored blocks.
for (let row = 0; row < 2; row++) {
for (let i = 0; i < 5; i++) {
addBox(
shelf,
0.52,
0.18,
0.55,
i % 2 ? materials.lightWood : materials.cherry,
-1.4 + i * 0.68,
1.28 + row * 0.9,
0
);
}
}
// Pigment jars.
const jarColors = [0x2a4353, 0xb44d39, 0x55705b, 0x745574, 0xc39b4b];
for (let i = 0; i < 7; i++) {
addCylinder(
shelf,
0.14,
0.16,
0.32,
8,
stdMaterial(jarColors[i % jarColors.length]),
-1.35 + i * 0.45,
3.18,
0
);
}
// Water bucket and floor stones.
addCylinder(scene, 0.42, 0.34, 0.62, 10, materials.darkWood, 6.5, 0.31, 2.95);
addCylinder(scene, 0.36, 0.36, 0.025, 10, materials.indigo, 6.5, 0.63, 2.95);
for (let i = 0; i < 9; i++) {
const stone = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.16 + (i % 3) * 0.04, 0),
stdMaterial(i % 2 ? 0x8b8b78 : 0x777b70)
);
stone.position.set(-8.6 + i * 0.32, 0.08, 4.35 + (i % 2) * 0.13);
stone.scale.y = 0.45;
stone.castShadow = true;
scene.add(stone);
}
// ------------------------------------------------------------
// Hero print: one object moving through the complete workflow
// ------------------------------------------------------------
const heroRoot = new THREE.Group();
scene.add(heroRoot);
const heroBase = addBox(
heroRoot,
1.58,
0.12,
2.12,
materials.paper,
0,
0,
0
);
const heroImage = new THREE.Mesh(
new THREE.PlaneGeometry(1.52, 2.04),
new THREE.MeshStandardMaterial({
map: artworkTexture,
transparent: true,
side: THREE.DoubleSide,
roughness: 0.96
})
);
heroImage.rotation.x = -Math.PI / 2;
heroImage.position.y = 0.067;
heroImage.renderOrder = 2;
heroRoot.add(heroImage);
const designPosition = new THREE.Vector3(-5.7, 1.145, 0.18);
const carvingPosition = new THREE.Vector3(-1.22, 1.145, -0.48);
const colorPosition = new THREE.Vector3(-1.22, 1.145, -0.93);
const printingPosition = new THREE.Vector3(4.25, 1.145, 0.78);
const dryingPosition = new THREE.Vector3(7.65, 2.72, -4.16);
const positions = {
design: designPosition,
carving: carvingPosition,
color: colorPosition,
printing: printingPosition,
drying: dryingPosition
};
function smooth01(value) {
const x = THREE.MathUtils.clamp(value, 0, 1);
return x * x * (3 - 2 * x);
}
function rangeProgress(time, start, end) {
return smooth01((time - start) / (end - start));
}
function interpolatePosition(out, a, b, amount) {
out.lerpVectors(a, b, amount);
return out;
}
// ------------------------------------------------------------
// Timeline and stage data
// ------------------------------------------------------------
const stages = [
{
start: 0,
title: "Designing the composition",
description:
"A brush drawing establishes the original koi, moon, water, and bellflowers. The master design is copied onto a prepared cherry block."
},
{
start: 7,
title: "Carving the key block",
description:
"The design is transferred to cherry wood. The printer cuts away the background, leaving the raised key-block lines and shapes."
},
{
start: 14,
title: "Cutting the color blocks",
description:
"Separate blocks are carved for green foliage, indigo water, and vermilion koi. Each area is registered to the key image."
},
{
start: 23,
title: "Printing the layers",
description:
"Water is brushed onto a block, thin washi is placed above it, and a roller or baren transfers pigment in carefully aligned passes."
},
{
start: 32,
title: "Drying the finished print",
description:
"The completed sheet is lifted from the bench and hung on the rack. Its original composition settles into its final muted colors."
}
];
const totalDuration = 40;
let elapsed = 0;
let playing = true;
let followMode = true;
let cameraMode = "follow";
let lastStageIndex = -1;
let artworkSignature = "";
const clock = new THREE.Clock();
const playButton = document.getElementById("play");
const scrubber = document.getElementById("scrubber");
const timeLabel = document.getElementById("time-label");
const stageNumber = document.getElementById("stage-number");
const stageTitle = document.getElementById("stage-title");
const stageDescription = document.getElementById("stage-description");
const followButton = document.getElementById("follow");
const overviewButton = document.getElementById("overview");
const stageButtons = [...document.querySelectorAll(".stage-button")];
function getStageIndex(time) {
let index = 0;
for (let i = 0; i < stages.length; i++) {
if (time >= stages[i].start) index = i;
}
return index;
}
function updateInterface(index) {
if (index === lastStageIndex) return;
lastStageIndex = index;
const stage = stages[index];
stageNumber.textContent =
`Stage ${String(index + 1).padStart(2, "0")} / 05`;
stageTitle.textContent = stage.title;
stageDescription.textContent = stage.description;
stageButtons.forEach((button, i) => {
button.classList.toggle("active", i === index);
});
}
playButton.addEventListener("click", () => {
if (elapsed >= totalDuration) elapsed = 0;
playing = !playing;
playButton.textContent = playing ? "Pause" : "Play";
});
scrubber.addEventListener("input", () => {
elapsed = Number(scrubber.value);
playing = false;
playButton.textContent = "Play";
});
stageButtons.forEach((button) => {
button.addEventListener("click", () => {
elapsed = Number(button.dataset.start) + 0.05;
playing = true;
playButton.textContent = "Pause";
followMode = true;
cameraMode = "follow";
followButton.classList.add("active");
overviewButton.classList.remove("active");
});
});
followButton.addEventListener("click", () => {
followMode = true;
cameraMode = "follow";
followButton.classList.add("active");
overviewButton.classList.remove("active");
});
overviewButton.addEventListener("click", () => {
followMode = false;
cameraMode = "overview";
followButton.classList.remove("active");
overviewButton.classList.add("active");
});
// ------------------------------------------------------------
// Custom orbit, pan, and zoom controls — no external addons
// ------------------------------------------------------------
let dragging = false;
let dragMode = "orbit";
let pointerX = 0;
let pointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
dragMode = event.shiftKey || event.button === 2 ? "pan" : "orbit";
pointerX = event.clientX;
pointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
if (followMode || cameraMode === "overview") {
followMode = false;
cameraMode = "manual";
followButton.classList.remove("active");
overviewButton.classList.remove("active");
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
if (dragMode === "orbit") {
const offset = camera.position.clone().sub(cameraTarget);
const spherical = new THREE.Spherical().setFromVector3(offset);
spherical.theta -= dx * 0.006;
spherical.phi = THREE.MathUtils.clamp(
spherical.phi - dy * 0.005,
0.18,
1.48
);
offset.setFromSpherical(spherical);
camera.position.copy(cameraTarget).add(offset);
} else {
const scale = camera.position.distanceTo(cameraTarget) * 0.0012;
const right = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
0
);
const up = new THREE.Vector3().setFromMatrixColumn(
camera.matrix,
1
);
const movement = right
.multiplyScalar(-dx * scale)
.add(up.multiplyScalar(dy * scale));
camera.position.add(movement);
cameraTarget.add(movement);
}
camera.lookAt(cameraTarget);
});
function endDrag(event) {
dragging = false;
if (event.pointerId !== undefined &&
renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
if (followMode || cameraMode === "overview") {
followMode = false;
cameraMode = "manual";
followButton.classList.remove("active");
overviewButton.classList.remove("active");
}
const offset = camera.position.clone().sub(cameraTarget);
const radius = THREE.MathUtils.clamp(
offset.length() * Math.exp(event.deltaY * 0.001),
3.3,
29
);
offset.setLength(radius);
camera.position.copy(cameraTarget).add(offset);
camera.lookAt(cameraTarget);
}, { passive: false });
// ------------------------------------------------------------
// Camera framing for each workshop stage
// ------------------------------------------------------------
const cameraViews = [
{
target: new THREE.Vector3(-5.65, 1.0, 0.1),
position: new THREE.Vector3(-1.85, 5.35, 6.65)
},
{
target: new THREE.Vector3(-1.05, 1.05, -0.75),
position: new THREE.Vector3(1.45, 4.65, 5.55)
},
{
target: new THREE.Vector3(-0.15, 1.25, -1.55),
position: new THREE.Vector3(1.25, 5.25, 4.8)
},
{
target: new THREE.Vector3(4.25, 1.05, 0.8),
position: new THREE.Vector3(8.15, 4.75, 6.75)
},
{
target: new THREE.Vector3(7.55, 2.65, -4.05),
position: new THREE.Vector3(11.15, 5.5, 1.65)
}
];
const overviewView = {
target: new THREE.Vector3(0, 1.15, -0.65),
position: new THREE.Vector3(14.0, 11.3, 16.4)
};
const desiredTarget = new THREE.Vector3();
const desiredPosition = new THREE.Vector3();
function updateDesiredCamera(time) {
if (cameraMode === "overview") {
desiredTarget.copy(overviewView.target);
desiredPosition.copy(overviewView.position);
return;
}
if (cameraMode !== "follow") return;
const index = getStageIndex(time);
const current = cameraViews[index];
const previous = cameraViews[Math.max(0, index - 1)];
let blend = 1;
if (index > 0) {
blend = rangeProgress(time, stages[index].start, stages[index].start + 1.4);
}
desiredTarget.lerpVectors(previous.target, current.target, blend);
desiredPosition.lerpVectors(previous.position, current.position, blend);
}
// ------------------------------------------------------------
// Animation updates
// ------------------------------------------------------------
function updateHero(time) {
let blockAmount = 0;
let mode = "design";
let progress = 0;
if (time >= 7 && time < 23.35) {
blockAmount = 1;
mode = "block";
progress = THREE.MathUtils.clamp((time - 7) / 5.6, 0, 1);
} else if (time >= 23.35) {
mode = "print";
progress = THREE.MathUtils.clamp((time - 23.35) / 6.6, 0, 1);
}
heroBase.material = blockAmount > 0.5
? materials.cherry
: materials.paper;
heroBase.scale.y = blockAmount > 0.5 ? 1 : 0.18;
heroImage.position.y = blockAmount > 0.5 ? 0.067 : 0.019;
const signature = `${mode}|${Math.round(progress * 100)}`;
if (signature !== artworkSignature) {
artworkSignature = signature;
drawArtwork(mode, progress);
}
const heroPosition = new THREE.Vector3();
if (time < 6) {
heroPosition.copy(designPosition);
} else if (time < 7.4) {
const u = rangeProgress(time, 6, 7.4);
interpolatePosition(
heroPosition,
designPosition,
carvingPosition,
u
);
} else if (time < 13) {
heroPosition.copy(carvingPosition);
} else if (time < 14.4) {
const u = rangeProgress(time, 13, 14.4);
interpolatePosition(
heroPosition,
carvingPosition,
colorPosition,
u
);
} else if (time < 22) {
heroPosition.copy(colorPosition);
} else if (time < 23.4) {
const u = rangeProgress(time, 22, 23.4);
interpolatePosition(
heroPosition,
colorPosition,
printingPosition,
u
);
} else if (time < 31) {
heroPosition.copy(printingPosition);
} else if (time < 33.3) {
const u = rangeProgress(time, 31, 33.3);
interpolatePosition(
heroPosition,
printingPosition,
dryingPosition,
u
);
heroPosition.y += Math.sin(u * Math.PI) * 1.35;
heroPosition.z += Math.sin(u * Math.PI) * 0.42;
} else {
heroPosition.copy(dryingPosition);
}
heroRoot.position.copy(heroPosition);
let verticalRotation = 0;
if (time >= 31 && time < 33.3) {
verticalRotation =
rangeProgress(time, 31, 33.3) * Math.PI * 0.5;
} else if (time >= 33.3) {
verticalRotation = Math.PI * 0.5;
}
heroRoot.rotation.x = verticalRotation;
heroRoot.rotation.z =
time >= 33.3
? Math.sin((time - 33.3) * 1.45) * 0.012
: 0;
}
function updateWorkshopActivity(time, dt) {
const stageIndex = getStageIndex(time);
// The designer's brush makes small rhythmic motions.
designer.rotation.z =
stageIndex === 0
? Math.sin(time * 3.1) * 0.025
: 0;
// The carving mallet rises and falls during the key-block stage.
if (stageIndex === 1) {
const local = time - stages[1].start;
const strike = Math.max(0, Math.sin(local * 4.8));
malletPivot.rotation.x = -0.15 - strike * 0.82;
carver.rotation.x = -0.08 + strike * 0.045;
} else {
malletPivot.rotation.x = THREE.MathUtils.lerp(
malletPivot.rotation.x,
-0.08,
Math.min(1, dt * 4)
);
}
// The color blocks appear one by one.
for (let i = 0; i < colorBlockGroups.length; i++) {
const reveal = rangeProgress(
time,
stages[2].start + i * 0.72,
stages[2].start + i * 0.72 + 0.9
);
const scale = Math.max(0.001, reveal);
colorBlockGroups[i].scale.setScalar(scale);
colorBlockGroups[i].visible = time >= stages[2].start;
}
// The roller moves across the sheet during the printing stage.
if (stageIndex === 3) {
const printProgress = THREE.MathUtils.clamp(
(time - stages[3].start) / 6.8,
0,
1
);
const cycle = (printProgress * 3.0) % 1;
const eased = smooth01(cycle);
roller.position.z = THREE.MathUtils.lerp(-0.22, 1.92, eased);
roller.position.y = 1.42 + Math.sin(eased * Math.PI) * 0.045;
roller.visible = true;
baren.position.set(
4.25,
1.13,
THREE.MathUtils.lerp(-0.15, 1.9, eased)
);
} else {
roller.visible = stageIndex >= 3;
baren.position.set(4.25, 1.13, 0.7);
}
// Completed side prints move gently in the drying room.
for (let i = 0; i < miniPrints.length; i++) {
miniPrints[i].rotation.z =
Math.sin(time * 1.1 + i * 1.8) * 0.014;
}
// Small life in the room without distracting from the hero print.
lanternLightPulse(time);
}
function lanternLightPulse(time) {
warmFill.intensity = 17.5 + Math.sin(time * 1.7) * 0.65;
}
function updateTimelineUI() {
const percentage = (elapsed / totalDuration) * 100;
scrubber.value = elapsed.toFixed(2);
scrubber.style.setProperty("--progress", `${percentage}%`);
const seconds = Math.floor(elapsed);
timeLabel.textContent =
`00:${String(seconds).padStart(2, "0")} / 00:40`;
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
// ------------------------------------------------------------
// Main loop
// ------------------------------------------------------------
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
if (playing) {
elapsed += dt;
if (elapsed >= totalDuration) {
elapsed = totalDuration;
playing = false;
playButton.textContent = "Replay";
}
}
const stageIndex = getStageIndex(elapsed);
updateInterface(stageIndex);
updateHero(elapsed);
updateWorkshopActivity(elapsed, dt);
updateTimelineUI();
updateDesiredCamera(elapsed);
if (cameraMode === "follow" || cameraMode === "overview") {
const easing = 1 - Math.exp(-dt * 2.7);
cameraTarget.lerp(desiredTarget, easing);
camera.position.lerp(desiredPosition, easing);
camera.lookAt(cameraTarget);
}
renderer.render(scene, camera);
}
drawArtwork("design", 0);
updateInterface(0);
updateTimelineUI();
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
setTimeout(() => {
document.getElementById("loading").remove();
}, 550);
});
</script>
</body>
</html>
```