Prompt specification
Build or customize the Three.js 3D scene "Paper workshop and writing courtyard" 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: Paper workshop and writing courtyard
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/paper-workshop-and-writing-courtyard-x2275
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a compact low-poly paper workshop connected to a sheltered writing courtyard. Arrange a fiber collection area, a shallow vat, a forming frame, a pressing station, and a drying rack in a readable work sequence. Follow one marked sheet as fibers are gathered into the frame, pressed into a thin layer, dried, and finally carried to a writing surface. Use timber, pale fibers, stone weights, and simple cloth-like mats with distinct shapes. Choose historically referenced details for the setting, while presenting the sequence as a representative process without naming a single inventor or suggesting one recipe applied everywhere.
Working Three.js Starter (paper-workshop-and-writing-courtyard-x2275):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fiber to Folio — A Paper Workshop Diorama</title>
<style>
:root {
--ink: #352b24;
--muted: #6f6256;
--paper: #f4ead6;
--paper-strong: #fff8e9;
--timber: #8e5937;
--ochre: #c4772d;
--ochre-dark: #8f4f20;
--sage: #728672;
--line: rgba(73, 55, 42, 0.24);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8deca;
color: var(--ink);
font-family: Georgia, "Times New Roman", serif;
}
body {
overscroll-behavior: none;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
button {
font: inherit;
}
#ui {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-card {
position: absolute;
top: 24px;
left: 26px;
width: min(390px, calc(100vw - 52px));
pointer-events: none;
}
.eyebrow {
margin-bottom: 7px;
color: var(--ochre-dark);
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(31px, 4vw, 56px);
font-weight: 500;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
max-width: 340px;
margin: 10px 0 0;
color: var(--muted);
font-size: 15px;
line-height: 1.45;
}
.controls {
position: absolute;
top: 24px;
right: 24px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 8px;
max-width: 360px;
pointer-events: auto;
}
.control-button {
min-height: 38px;
padding: 8px 13px;
border: 1px solid rgba(69, 49, 35, 0.26);
border-radius: 999px;
background: rgba(255, 248, 233, 0.9);
color: var(--ink);
box-shadow: 0 4px 15px rgba(63, 43, 28, 0.08);
cursor: pointer;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: 700;
backdrop-filter: blur(8px);
}
.control-button:hover,
.control-button:focus-visible {
border-color: var(--ochre);
background: #fffaf0;
outline: none;
}
.control-button.primary {
border-color: var(--ochre);
background: var(--ochre);
color: #fffaf0;
}
#labels {
position: absolute;
inset: 0;
overflow: hidden;
pointer-events: none;
}
.station-label {
position: absolute;
min-width: 124px;
max-width: 190px;
padding: 7px 9px 7px 10px;
border-left: 3px solid var(--ochre);
border-radius: 2px 7px 7px 2px;
background: rgba(255, 248, 233, 0.88);
box-shadow: 0 5px 18px rgba(62, 43, 29, 0.11);
transform: translate(-50%, -100%);
backdrop-filter: blur(7px);
}
.station-label strong {
display: block;
font-size: 13px;
font-weight: 700;
line-height: 1.1;
}
.station-label small {
display: block;
margin-top: 3px;
color: var(--muted);
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: 600;
letter-spacing: 0.025em;
line-height: 1.25;
}
#tracked-label {
min-width: auto;
padding: 5px 8px;
border-left-color: #9b4f28;
color: #743b21;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.03em;
white-space: nowrap;
}
.story-card {
position: absolute;
left: 26px;
bottom: 105px;
width: min(350px, calc(100vw - 52px));
padding: 14px 16px;
border: 1px solid var(--line);
border-radius: 10px;
background: rgba(255, 248, 233, 0.86);
box-shadow: 0 8px 28px rgba(66, 45, 29, 0.09);
backdrop-filter: blur(9px);
}
.story-card h2 {
margin: 0 0 6px;
font-size: 15px;
font-weight: 700;
}
.story-card p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.story-card .caveat {
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--line);
color: #76523a;
font-style: italic;
}
.legend {
display: flex;
align-items: center;
gap: 8px;
margin-top: 9px;
color: var(--ink);
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: 700;
}
.legend-mark {
width: 15px;
height: 10px;
border: 1px solid #c8b58d;
background: #f3ead5;
box-shadow: inset -5px -4px 0 #9b4f28;
}
#sequence-wrap {
position: absolute;
right: 24px;
bottom: 22px;
left: 24px;
pointer-events: auto;
}
#sequence {
display: flex;
width: max-content;
max-width: 100%;
margin: 0 auto;
overflow-x: auto;
padding: 7px;
border: 1px solid rgba(69, 49, 35, 0.22);
border-radius: 12px;
background: rgba(255, 248, 233, 0.92);
box-shadow: 0 10px 30px rgba(66, 45, 29, 0.12);
scrollbar-width: none;
backdrop-filter: blur(10px);
}
#sequence::-webkit-scrollbar {
display: none;
}
.stage {
position: relative;
min-width: 112px;
padding: 9px 13px 9px 29px;
border: 0;
border-radius: 8px;
background: transparent;
color: var(--muted);
cursor: pointer;
text-align: left;
}
.stage + .stage::before {
position: absolute;
top: 50%;
left: -1px;
width: 1px;
height: 23px;
background: var(--line);
content: "";
transform: translateY(-50%);
}
.stage:hover,
.stage:focus-visible {
background: rgba(196, 119, 45, 0.09);
outline: none;
}
.stage.active {
background: rgba(196, 119, 45, 0.15);
color: var(--ink);
}
.stage-number {
position: absolute;
top: 50%;
left: 9px;
width: 16px;
height: 16px;
border: 1px solid #b79573;
border-radius: 50%;
color: var(--ochre-dark);
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
font-weight: 800;
line-height: 14px;
text-align: center;
transform: translateY(-50%);
}
.stage.active .stage-number {
border-color: var(--ochre);
background: var(--ochre);
color: white;
}
.stage strong {
display: block;
font-size: 12px;
line-height: 1.1;
}
.stage small {
display: block;
margin-top: 3px;
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
line-height: 1.2;
}
#loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #e8deca;
color: var(--muted);
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@media (max-width: 900px) {
.story-card {
display: none;
}
.title-card {
top: 16px;
left: 17px;
}
.subtitle {
max-width: 250px;
font-size: 13px;
}
.controls {
top: 16px;
right: 16px;
max-width: 180px;
}
.control-button {
padding: 7px 10px;
font-size: 10px;
}
#sequence-wrap {
right: 10px;
bottom: 10px;
left: 10px;
}
#sequence {
justify-content: flex-start;
}
.stage {
min-width: 103px;
padding-right: 9px;
}
.station-label {
min-width: auto;
padding: 5px 7px;
}
.station-label small {
display: none;
}
}
@media (max-width: 560px) {
.title-card {
width: 230px;
}
h1 {
font-size: 30px;
}
.subtitle {
display: none;
}
.eyebrow {
font-size: 9px;
}
.controls {
max-width: 150px;
}
#reset-view {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly paper workshop and writing courtyard"></canvas>
<div id="ui">
<header class="title-card">
<div class="eyebrow">An interpretive workshop diorama</div>
<h1>Fiber to Folio</h1>
<p class="subtitle">
Follow one ochre-cornered sheet through a compact paper workshop
and into a sheltered writing court.
</p>
</header>
<div class="controls">
<button class="control-button primary" id="play" type="button">Pause</button>
<button class="control-button" id="replay" type="button">Replay</button>
<button class="control-button" id="reset-view" type="button">Reset view</button>
</div>
<div id="labels">
<div class="station-label" id="label-fiber">
<strong>Fiber collection</strong>
<small>Sorted cloth and plant fibers</small>
</div>
<div class="station-label" id="label-vat">
<strong>Shallow vat</strong>
<small>Soften and mix the fibers</small>
</div>
<div class="station-label" id="label-frame">
<strong>Forming frame</strong>
<small>Deckle, mesh and a thin sheet</small>
</div>
<div class="station-label" id="label-press">
<strong>Pressing station</strong>
<small>Timber screw, felt mats, stone weights</small>
</div>
<div class="station-label" id="label-rack">
<strong>Drying rack</strong>
<small>Sheets hung to dry</small>
</div>
<div class="station-label" id="label-court">
<strong>Writing court</strong>
<small>Desk beneath a timber shelter</small>
</div>
<div class="station-label" id="tracked-label">Ochre corner = the same sheet</div>
</div>
<aside class="story-card">
<h2>One representative working sequence</h2>
<p>
Cloth or other plant fibers are collected and softened in water.
A framed screen forms a thin layer, which is transferred with felt,
pressed, dried on a rack, and finally carried to a writing surface.
</p>
<div class="legend">
<span class="legend-mark"></span>
The ochre corner identifies the tracked sheet.
</div>
<p class="caveat">
A composite of historically referenced practices, not a reconstruction
of one site. Fibers, recipes, tools, and sequence varied by place,
workshop, material, and period.
</p>
</aside>
<div id="sequence-wrap">
<nav id="sequence" aria-label="Paper-making sequence">
<button class="stage active" type="button" data-time="0">
<span class="stage-number">1</span>
<strong>Gather</strong>
<small>Collect fibers</small>
</button>
<button class="stage" type="button" data-time="0.16">
<span class="stage-number">2</span>
<strong>Soak</strong>
<small>Shallow vat</small>
</button>
<button class="stage" type="button" data-time="0.32">
<span class="stage-number">3</span>
<strong>Form</strong>
<small>Framed layer</small>
</button>
<button class="stage" type="button" data-time="0.50">
<span class="stage-number">4</span>
<strong>Press</strong>
<small>Remove water</small>
</button>
<button class="stage" type="button" data-time="0.68">
<span class="stage-number">5</span>
<strong>Dry</strong>
<small>Drying rack</small>
</button>
<button class="stage" type="button" data-time="1">
<span class="stage-number">6</span>
<strong>Write</strong>
<small>Writing court</small>
</button>
</nav>
</div>
</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, camera, and directly implemented controls
// -------------------------------------------------------------------------
const canvas = document.getElementById("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.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e8deca");
scene.fog = new THREE.Fog("#e8deca", 28, 48);
const camera = new THREE.OrthographicCamera(-10, 10, 6, -6, 0.1, 100);
const cameraTarget = new THREE.Vector3(0, 0.65, 0);
let cameraYaw = 0.18;
let cameraPitch = 0.72;
let cameraRadius = 24;
let cameraZoom = 1;
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraRadius;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraRadius,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
camera.zoom = cameraZoom;
camera.updateProjectionMatrix();
}
function resetCamera() {
cameraYaw = 0.18;
cameraPitch = 0.72;
cameraRadius = 24;
cameraZoom = 1;
updateCamera();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
// Keep the full diorama visible on wide screens while allowing the
// orthographic view to expand vertically on narrow screens.
const viewHeight = aspect < 1.25
? 15.5 / aspect
: 10.4;
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);
resize();
let pointerDown = false;
let pointerX = 0;
let pointerY = 0;
canvas.addEventListener("pointerdown", (event) => {
pointerDown = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!pointerDown) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
cameraYaw -= dx * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + dy * 0.004,
0.38,
1.18
);
pointerX = event.clientX;
pointerY = event.clientY;
updateCamera();
});
function endPointer(event) {
pointerDown = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("dblclick", resetCamera);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraZoom = THREE.MathUtils.clamp(
cameraZoom * Math.exp(-event.deltaY * 0.001),
0.68,
1.72
);
updateCamera();
},
{ passive: false }
);
// -------------------------------------------------------------------------
// Lighting and reusable low-poly construction helpers
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight("#fff8df", "#88725f", 2.1);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0cc", 3.2);
sun.position.set(-7, 13, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 11;
sun.shadow.camera.bottom = -11;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight("#d7e1dc", 0.75);
fill.position.set(9, 7, -8);
scene.add(fill);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.84,
metalness: 0,
flatShading: true,
...options
});
}
const M = {
ground: material("#d5c5a7"),
groundEdge: material("#b9a686"),
floor: material("#b88757"),
floorDark: material("#9c6a43"),
timber: material("#8e5937"),
timberLight: material("#ad7449"),
timberDark: material("#553923"),
beam: material("#6d432b"),
plaster: material("#d8ccb2"),
plasterDark: material("#b8a98d"),
fiber: material("#eee2bd"),
fiberLight: material("#fff3cf"),
fiberShade: material("#cdbb8e"),
mesh: material("#8e967f", { side: THREE.DoubleSide }),
water: material("#839f91", {
roughness: 0.28,
transparent: true,
opacity: 0.84,
side: THREE.DoubleSide
}),
stone: material("#73756d"),
stoneLight: material("#98998d"),
stoneDark: material("#555a54"),
sage: material("#778a74", { side: THREE.DoubleSide }),
sageDark: material("#5c705f", { side: THREE.DoubleSide }),
ochreCloth: material("#b88a52", { side: THREE.DoubleSide }),
paper: material("#f3ead4"),
paperEdge: material("#d8c9a9"),
mark: material("#9b4f28"),
courtyard: material("#bfb9a7"),
tileA: material("#c8c0ad"),
tileB: material("#b8b19f"),
ink: material("#373535"),
skin: material("#bd815f"),
robe: material("#536d70"),
robeDark: material("#3e5558"),
straw: material("#b89a5c")
};
function box(w, h, d, mat, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
topRadius,
bottomRadius,
height,
segments,
mat,
x,
y,
z,
parent = scene
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
topRadius,
bottomRadius,
height,
segments
),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(a, b, thickness, mat, parent = scene) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(thickness, length, thickness),
mat
);
mesh.position.copy(start).add(end).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cloth(w, d, mat, x, y, z, parent = scene) {
const geometry = new THREE.PlaneGeometry(w, d, 5, 4);
geometry.rotateX(-Math.PI / 2);
const positions = geometry.attributes.position;
for (let i = 0; i < positions.count; i++) {
const px = positions.getX(i);
const pz = positions.getZ(i);
const ripple =
Math.sin(px * 3.1 + pz * 1.7) * 0.035 +
Math.cos(pz * 4.2 - px) * 0.018;
positions.setY(i, positions.getY(i) + ripple);
}
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function tuft(parent, x, y, z, scale = 1, mat = M.fiber) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.scale.setScalar(scale);
for (let i = 0; i < 5; i++) {
const cone = new THREE.Mesh(
new THREE.ConeGeometry(0.055, 0.45 + Math.random() * 0.25, 5),
i % 3 === 0 ? M.fiberLight : mat
);
cone.position.set(
(Math.random() - 0.5) * 0.34,
0.12 + Math.random() * 0.12,
(Math.random() - 0.5) * 0.34
);
cone.rotation.z = (Math.random() - 0.5) * 1.3;
cone.rotation.x = (Math.random() - 0.5) * 0.9;
cone.castShadow = true;
group.add(cone);
}
parent.add(group);
return group;
}
// -------------------------------------------------------------------------
// Ground, workshop shell, and sheltered writing courtyard
// -------------------------------------------------------------------------
box(15.5, 0.3, 8.2, M.groundEdge, 0.45, -0.18, 0);
box(15.1, 0.12, 7.9, M.ground, 0.45, -0.01, 0);
// Workshop floor.
box(8.25, 0.24, 5.65, M.floor, -2.08, 0.12, 0.03);
// A few floorboards.
for (let i = 0; i < 8; i++) {
box(0.045, 0.018, 5.35, M.floorDark, -5.75 + i, 0.252, 0.02);
}
// Back and left walls.
box(8.0, 2.45, 0.16, M.plaster, -2.12, 1.445, -2.77);
box(0.16, 2.1, 5.4, M.plasterDark, -6.05, 1.28, -0.05);
// Exposed timber frame: open-front workshop.
const postPositions = [
[-6.0, -2.66],
[1.78, -2.66],
[-6.0, 2.62],
[1.78, 2.62]
];
postPositions.forEach(([x, z]) => {
box(0.2, 2.9, 0.2, M.timberDark, x, 1.68, z);
});
box(8.05, 0.22, 0.22, M.timberDark, -2.11, 3.08, -2.66);
box(0.22, 0.22, 5.5, M.timberDark, -6.0, 3.08, -0.02);
box(0.22, 0.22, 5.5, M.timberDark, 1.78, 3.08, -0.02);
box(8.05, 0.18, 0.18, M.timber, -2.11, 3.04, 2.62);
// Short rafters indicate a cutaway roof without hiding the work.
[-4.9, -2.7, -0.5, 1.1].forEach((x) => {
beam([x, 3.11, -2.66], [x, 3.02, -0.6], 0.105, M.timberLight);
});
// Rolled-back shade cloth.
const rolledCanvas = cylinder(
0.16,
0.16,
7.8,
10,
M.ochreCloth,
-2.1,
2.88,
-2.53
);
rolledCanvas.rotation.z = Math.PI / 2;
// Courtyard paving.
box(4.5, 0.15, 5.55, M.courtyard, 5.2, 0.075, 0);
for (let ix = 0; ix < 5; ix++) {
for (let iz = 0; iz < 6; iz++) {
const mat = (ix + iz) % 2 === 0 ? M.tileA : M.tileB;
box(
0.82,
0.035,
0.83,
mat,
3.22 + ix * 0.9,
0.168,
-2.25 + iz * 0.9
);
}
}
// Writing-court shelter.
const courtPosts = [
[3.32, -2.42],
[7.08, -2.42],
[3.32, 2.42],
[7.08, 2.42]
];
courtPosts.forEach(([x, z]) => {
box(0.18, 2.85, 0.18, M.timberDark, x, 1.58, z);
});
box(3.95, 0.2, 0.2, M.timberDark, 5.2, 2.95, -2.42);
box(3.95, 0.2, 0.2, M.timberDark, 5.2, 2.95, 2.42);
box(0.2, 0.2, 5.0, M.timberDark, 3.32, 2.95, 0);
box(0.2, 0.2, 5.0, M.timberDark, 7.08, 2.95, 0);
// Open roof slats preserve visibility of the desk.
[-1.9, -1.15, -0.4, 0.35, 1.1, 1.85].forEach((z) => {
box(3.82, 0.08, 0.11, M.timberLight, 5.2, 3.02, z);
});
// Rear canvas shade.
cloth(3.75, 1.65, M.ochreCloth, 5.2, 3.02, -1.52);
// Low courtyard wall and a simple stone threshold.
box(4.35, 0.62, 0.18, M.plasterDark, 5.2, 0.43, -2.74);
box(1.1, 0.12, 2.5, M.stoneLight, 2.65, 0.07, -0.05);
// Stepping stones between workshop and court.
for (let i = 0; i < 4; i++) {
const stone = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.43, 0),
i % 2 === 0 ? M.stone : M.stoneLight
);
stone.position.set(2.55 + i * 0.58, 0.12, -0.78 + i * 0.27);
stone.scale.set(1.2, 0.28, 0.8);
stone.rotation.y = i * 0.53;
stone.castShadow = true;
stone.receiveShadow = true;
scene.add(stone);
}
// -------------------------------------------------------------------------
// Stage 1: fiber collection
// -------------------------------------------------------------------------
function basket(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0.26, z);
group.scale.setScalar(scale);
cylinder(0.58, 0.46, 0.42, 9, M.timberLight, 0, 0.21, 0, group);
cylinder(0.49, 0.49, 0.035, 9, M.timberDark, 0, 0.42, 0, group);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.54, 0.045, 5, 10),
M.timberDark
);
rim.rotation.x = Math.PI / 2;
rim.position.y = 0.43;
rim.castShadow = true;
group.add(rim);
scene.add(group);
return group;
}
const fiberBasket = basket(-4.92, -1.42, 1);
const smallerBasket = basket(-4.0, -1.94, 0.82);
tuft(scene, -4.95, 0.68, -1.42, 1.1);
tuft(scene, -4.69, 0.64, -1.57, 0.85);
tuft(scene, -4.98, 0.68, -1.18, 0.8);
tuft(scene, -4.02, 0.57, -1.94, 0.9);
tuft(scene, -3.84, 0.53, -2.03, 0.72);
// Folded textile offcuts in the baskets.
cloth(0.62, 0.43, M.sage, -4.94, 0.76, -1.39);
cloth(0.47, 0.35, M.ochreCloth, -4.0, 0.65, -1.93);
// A low bundle of raw fibers.
box(0.95, 0.3, 0.72, M.fiberShade, -5.22, 0.42, -2.1);
for (let i = 0; i < 5; i++) {
tuft(
scene,
-5.55 + i * 0.17,
0.58,
-2.08 + (i % 2) * 0.15,
0.52,
M.fiberLight
);
}
// Small sorting board and mallet.
box(1.05, 0.11, 0.62, M.timberLight, -5.2, 0.93, -0.5);
box(0.4, 0.18, 0.18, M.timberDark, -5.38, 1.08, -0.52);
beam([-5.35, 1.08, -0.52], [-4.91, 1.08, -0.46], 0.07, M.timber);
// -------------------------------------------------------------------------
// Stage 2: shallow vat
// -------------------------------------------------------------------------
const vatX = -3.5;
const vatZ = 0.28;
box(1.85, 0.18, 1.24, M.timberDark, vatX, 0.31, vatZ);
box(1.85, 0.57, 0.13, M.timber, vatX, 0.57, vatZ - 0.555);
box(1.85, 0.57, 0.13, M.timber, vatX, 0.57, vatZ + 0.555);
box(0.13, 0.57, 1.0, M.timber, vatX - 0.86, 0.57, vatZ);
box(0.13, 0.57, 1.0, M.timber, vatX + 0.86, 0.57, vatZ);
const vatWater = new THREE.Mesh(
new THREE.PlaneGeometry(1.58, 0.94, 4, 3),
M.water
);
vatWater.rotation.x = -Math.PI / 2;
vatWater.position.set(vatX, 0.81, vatZ);
vatWater.receiveShadow = true;
scene.add(vatWater);
// A dipping screen resting against the vat.
const dippingFrame = new THREE.Group();
dippingFrame.position.set(-3.95, 0.94, -0.17);
dippingFrame.rotation.x = -0.38;
box(1.0, 0.07, 0.07, M.timberLight, 0, 0, 0, dippingFrame);
box(1.0, 0.07, 0.07, M.timberLight, 0, 0, 0.7, dippingFrame);
box(0.07, 0.07, 0.7, M.timberLight, -0.47, 0, 0.35, dippingFrame);
box(0.07, 0.07, 0.7, M.timberLight, 0.47, 0, 0.35, dippingFrame);
box(0.87, 0.015, 0.56, M.mesh, 0, 0.01, 0.35, dippingFrame);
scene.add(dippingFrame);
// Stirring paddle.
beam([-3.1, 0.72, 0.53], [-2.78, 1.48, 0.35], 0.055, M.timberLight);
box(0.31, 0.08, 0.2, M.timberDark, -3.08, 0.74, 0.53);
// -------------------------------------------------------------------------
// Stage 3: forming frame on a low working table
// -------------------------------------------------------------------------
const frameX = -1.62;
const frameZ = 0.32;
box(1.72, 0.14, 1.2, M.timberLight, frameX, 0.76, frameZ);
box(0.13, 0.58, 0.13, M.timberDark, frameX - 0.68, 0.42, frameZ - 0.43);
box(0.13, 0.58, 0.13, M.timberDark, frameX + 0.68, 0.42, frameZ - 0.43);
box(0.13, 0.58, 0.13, M.timberDark, frameX - 0.68, 0.42, frameZ + 0.43);
box(0.13, 0.58, 0.13, M.timberDark, frameX + 0.68, 0.42, frameZ + 0.43);
// Rectangular deckle around a fine screen.
box(1.43, 0.08, 0.08, M.timberDark, frameX, 0.89, frameZ - 0.49);
box(1.43, 0.08, 0.08, M.timberDark, frameX, 0.89, frameZ + 0.49);
box(0.08, 0.08, 0.98, M.timberDark, frameX - 0.675, 0.89, frameZ);
box(0.08, 0.08, 0.98, M.timberDark, frameX + 0.675, 0.89, frameZ);
box(1.24, 0.018, 0.86, M.mesh, frameX, 0.875, frameZ);
// A folded felt mat beside the forming frame.
cloth(0.75, 0.58, M.sageDark, -1.55, 0.855, 1.18);
// -------------------------------------------------------------------------
// Stage 4: pressing station with a timber screw press and stone weights
// -------------------------------------------------------------------------
const pressX = 0.02;
const pressZ = 1.35;
box(1.95, 0.16, 1.35, M.timberDark, pressX, 0.31, pressZ);
box(0.22, 2.3, 0.28, M.timberDark, pressX - 0.72, 1.45, pressZ);
box(0.22, 2.3, 0.28, M.timberDark, pressX + 0.72, 1.45, pressZ);
box(1.82, 0.24, 0.35, M.timber, pressX, 2.66, pressZ);
// Press bed and felt layers.
box(1.25, 0.12, 0.95, M.timberLight, pressX, 0.92, pressZ);
cloth(1.12, 0.83, M.sage, pressX, 1.0, pressZ);
cloth(1.02, 0.73, M.sageDark, pressX, 1.025, pressZ);
const platen = box(
1.38,
0.14,
1.05,
M.timberLight,
pressX,
1.53,
pressZ
);
// Central screw.
cylinder(0.085, 0.085, 1.13, 10, M.stoneDark, pressX, 2.12, pressZ);
for (let i = 0; i < 7; i++) {
const thread = new THREE.Mesh(
new THREE.TorusGeometry(0.11, 0.023, 5, 10),
M.stoneLight
);
thread.rotation.x = Math.PI / 2;
thread.position.set(pressX, 1.76 + i * 0.12, pressZ);
thread.castShadow = true;
scene.add(thread);
}
// Cross handle.
beam(
[pressX - 0.42, 2.55, pressZ],
[pressX + 0.42, 2.55, pressZ],
0.065,
M.timber
);
// Distinctive stone weights beside the press.
const weightA = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.35, 0),
M.stone
);
weightA.position.set(1.25, 0.53, 1.73);
weightA.scale.set(1.05, 0.7, 0.86);
weightA.rotation.y = 0.35;
weightA.castShadow = true;
scene.add(weightA);
const weightB = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.3, 0),
M.stoneLight
);
weightB.position.set(1.2, 0.82, 1.63);
weightB.scale.set(1.1, 0.72, 0.88);
weightB.rotation.y = -0.4;
weightB.castShadow = true;
scene.add(weightB);
box(0.62, 0.17, 0.48, M.stoneDark, 1.38, 0.33, 0.83);
// -------------------------------------------------------------------------
// Stage 5: drying rack
// -------------------------------------------------------------------------
const rackX = 0.62;
const rackZ = -1.55;
box(0.16, 2.75, 0.16, M.timberDark, rackX - 1.15, 1.62, rackZ);
box(0.16, 2.75, 0.16, M.timberDark, rackX + 1.15, 1.62, rackZ);
box(2.48, 0.13, 0.15, M.timber, rackX, 2.91, rackZ);
box(2.48, 0.11, 0.13, M.timberLight, rackX, 1.02, rackZ);
beam(
[rackX - 1.15, 2.95, rackZ],
[rackX + 1.15, 1.05, rackZ],
0.08,
M.timberLight
);
function hangingSheet(x, y, z, w, h, tilt = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.z = tilt;
box(w, h, 0.026, M.paper, 0, 0, 0, group);
box(w, h, 0.029, M.paperEdge, 0, 0, -0.005, group);
scene.add(group);
return group;
}
hangingSheet(rackX - 0.76, 1.85, rackZ + 0.05, 0.62, 1.45, 0.04);
hangingSheet(rackX - 0.08, 1.82, rackZ + 0.02, 0.58, 1.38, -0.025);
hangingSheet(rackX + 0.72, 1.86, rackZ + 0.04, 0.62, 1.47, 0.035);
hangingSheet(rackX + 1.08, 1.84, rackZ + 0.11, 0.42, 1.4, -0.03);
// -------------------------------------------------------------------------
// Stage 6: writing surface in the sheltered court
// -------------------------------------------------------------------------
const deskX = 5.15;
const deskZ = 0.18;
box(2.45, 0.15, 1.15, M.timberLight, deskX, 1.12, deskZ);
box(0.16, 0.92, 0.16, M.timberDark, deskX - 0.95, 0.58, deskZ - 0.38);
box(0.16, 0.92, 0.16, M.timberDark, deskX + 0.95, 0.58, deskZ - 0.38);
box(0.16, 0.92, 0.16, M.timberDark, deskX - 0.95, 0.58, deskZ + 0.38);
box(0.16, 0.92, 0.16, M.timberDark, deskX + 0.95, 0.58, deskZ + 0.38);
box(1.92, 0.09, 0.12, M.timberDark, deskX, 0.55, deskZ + 0.38);
// Book stack.
box(0.65, 0.09, 0.46, M.robeDark, 5.68, 1.24, 0.17);
box(0.61, 0.055, 0.43, M.paper, 5.68, 1.31, 0.17);
box(0.65, 0.035, 0.46, M.robeDark, 5.68, 1.35, 0.17);
// Inkpot.
cylinder(0.12, 0.16, 0.19, 8, M.ink, 4.48, 1.29, 0.2);
// Quill.
beam([4.43, 1.2, 0.2], [4.28, 1.78, 0.1], 0.022, M.straw);
const feather = new THREE.Mesh(
new THREE.ConeGeometry(0.095, 0.47, 4),
M.paper
);
feather.position.set(4.29, 1.77, 0.1);
feather.rotation.z = -0.28;
feather.castShadow = true;
scene.add(feather);
// Stool.
box(0.68, 0.12, 0.56, M.timber, 5.15, 0.62, 1.18);
box(0.12, 0.49, 0.12, M.timberDark, 4.91, 0.36, 1.38);
box(0.12, 0.49, 0.12, M.timberDark, 5.39, 0.36, 1.38);
box(0.12, 0.49, 0.12, M.timberDark, 4.91, 0.36, 0.98);
box(0.12, 0.49, 0.12, M.timberDark, 5.39, 0.36, 0.98);
// -------------------------------------------------------------------------
// The tracked sheet and animated loose fibers
// -------------------------------------------------------------------------
const trackedSheet = new THREE.Group();
box(0.78, 0.53, 0.025, M.paper, 0, 0, 0, trackedSheet);
box(0.78, 0.015, 0.028, M.paperEdge, 0, -0.257, 0, trackedSheet);
box(0.15, 0.09, 0.016, M.mark, 0.28, 0.19, 0.021, trackedSheet);
const sheetEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(new THREE.BoxGeometry(0.78, 0.53, 0.025)),
new THREE.LineBasicMaterial({
color: "#bca980",
transparent: true,
opacity: 0.75
})
);
trackedSheet.add(sheetEdges);
scene.add(trackedSheet);
// Small moving tufts show the gathering of fibers into the frame.
const movingFibers = [];
for (let i = 0; i < 12; i++) {
movingFibers.push(
tuft(scene, -4.9, 0.85, -1.4, 0.22, i % 2 ? M.fiber : M.fiberLight)
);
}
// -------------------------------------------------------------------------
// A simple low-poly carrier for the final walk to the writing court
// -------------------------------------------------------------------------
const carrier = new THREE.Group();
cylinder(0.25, 0.32, 0.72, 7, M.robe, 0, 1.04, 0, carrier);
cylinder(0.34, 0.37, 0.35, 7, M.robeDark, 0, 0.7, 0, carrier);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.19, 8, 6),
M.skin
);
head.position.set(0, 1.62, 0);
head.castShadow = true;
carrier.add(head);
const cap = new THREE.Mesh(
new THREE.CylinderGeometry(0.19, 0.22, 0.15, 7),
M.straw
);
cap.position.set(0, 1.77, 0);
cap.castShadow = true;
carrier.add(cap);
beam([-0.12, 0.63, 0], [-0.15, 0.16, 0.02], 0.11, M.robeDark, carrier);
beam([0.12, 0.63, 0], [0.16, 0.16, 0.02], 0.11, M.robeDark, carrier);
beam([-0.19, 1.27, 0], [-0.3, 0.99, 0.48], 0.09, M.robe, carrier);
beam([0.19, 1.27, 0], [0.3, 0.99, 0.48], 0.09, M.robe, carrier);
const leftHand = new THREE.Mesh(
new THREE.SphereGeometry(0.075, 6, 5),
M.skin
);
leftHand.position.set(-0.3, 0.99, 0.48);
carrier.add(leftHand);
const rightHand = leftHand.clone();
rightHand.position.set(0.3, 0.99, 0.48);
carrier.add(rightHand);
scene.add(carrier);
carrier.visible = false;
// -------------------------------------------------------------------------
// Animation state and interpolation
// -------------------------------------------------------------------------
const keyTimes = [0, 0.16, 0.32, 0.50, 0.68, 1.0];
const keyPositions = [
new THREE.Vector3(-4.86, 0.98, -1.43), // collection
new THREE.Vector3(-3.50, 0.84, 0.28), // vat
new THREE.Vector3(-1.62, 0.94, 0.32), // forming frame
new THREE.Vector3(0.02, 1.07, 1.35), // press
new THREE.Vector3(0.54, 1.58, -1.48), // drying rack
new THREE.Vector3(5.08, 1.23, 0.16) // writing desk
];
const horizontalRotation = new THREE.Quaternion().setFromEuler(
new THREE.Euler(-Math.PI / 2, 0, 0)
);
const verticalRotation = new THREE.Quaternion().setFromEuler(
new THREE.Euler(0, 0, -0.035)
);
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let progress = 0;
let playing = !reducedMotion;
let activeStage = -1;
const duration = 23;
const playButton = document.getElementById("play");
const stageButtons = [...document.querySelectorAll(".stage")];
function clamp01(value) {
return THREE.MathUtils.clamp(value, 0, 1);
}
function smoothstep(value) {
const t = clamp01(value);
return t * t * (3 - 2 * t);
}
function quadraticBezier(a, b, c, t) {
const inverse = 1 - t;
return new THREE.Vector3()
.addScaledVector(a, inverse * inverse)
.addScaledVector(b, 2 * inverse * t)
.addScaledVector(c, t * t);
}
function carryPosition(t) {
const a = keyPositions[4];
const c = keyPositions[5];
const control = new THREE.Vector3(3.0, 1.9, -0.9);
return quadraticBezier(a, control, c, smoothstep(t));
}
function getTrackedPosition(p) {
if (p >= keyTimes[4]) {
const t = (p - keyTimes[4]) / (keyTimes[5] - keyTimes[4]);
return carryPosition(t);
}
for (let i = 0; i < keyTimes.length - 1; i++) {
if (p >= keyTimes[i] && p <= keyTimes[i + 1]) {
const t =
(p - keyTimes[i]) / (keyTimes[i + 1] - keyTimes[i]);
return keyPositions[i].clone().lerp(
keyPositions[i + 1],
smoothstep(t)
);
}
}
return keyPositions[0].clone();
}
function updateTrackedSheet(p) {
const position = getTrackedPosition(p);
trackedSheet.position.copy(position);
if (p < keyTimes[4]) {
trackedSheet.quaternion.copy(horizontalRotation);
} else {
const t = (p - keyTimes[4]) / (keyTimes[5] - keyTimes[4]);
const rotationT = smoothstep((t - 0.42) / 0.58);
trackedSheet.quaternion.slerpQuaternions(
verticalRotation,
horizontalRotation,
rotationT
);
}
const sheetScale = 0.66 + smoothstep(p / 0.35) * 0.28;
trackedSheet.scale.setScalar(sheetScale);
// The carrier appears as the sheet leaves the rack.
carrier.visible = p >= 0.675;
if (carrier.visible) {
const t = clamp01((p - 0.675) / (1 - 0.675));
const before = carryPosition(Math.max(0, t - 0.015));
const after = carryPosition(Math.min(1, t + 0.015));
const direction = after.sub(before);
direction.y = 0;
if (direction.lengthSq() > 0.0001) {
direction.normalize();
carrier.position.set(
position.x - direction.x * 0.72,
0.17,
position.z - direction.z * 0.72
);
carrier.rotation.y = Math.atan2(direction.x, direction.z);
}
}
// Loose fibers move from collection to vat, then into the frame.
movingFibers.forEach((fiber, index) => {
const t = clamp01(p * 3.2 - index * 0.047);
fiber.visible = p < 0.34;
if (t < 0.55) {
fiber.position.lerpVectors(
keyPositions[0],
keyPositions[1],
smoothstep(t / 0.55)
);
} else {
fiber.position.lerpVectors(
keyPositions[1],
keyPositions[2],
smoothstep((t - 0.55) / 0.45)
);
}
fiber.position.y += 0.12 + Math.sin(t * Math.PI) * 0.22;
fiber.rotation.y = t * Math.PI * 4 + index;
});
// The press platen lowers around the tracked sheet.
const pressCycle = clamp01((p - 0.39) / 0.19);
platen.position.y = 1.53 - Math.sin(pressCycle * Math.PI) * 0.32;
}
function getActiveStage(p) {
if (p < 0.12) return 0;
if (p < 0.27) return 1;
if (p < 0.42) return 2;
if (p < 0.58) return 3;
if (p < 0.72) return 4;
return 5;
}
function updateInterface() {
const nextStage = getActiveStage(progress);
if (nextStage !== activeStage) {
activeStage = nextStage;
stageButtons.forEach((button, index) => {
button.classList.toggle("active", index === activeStage);
if (index === activeStage) {
button.setAttribute("aria-current", "step");
} else {
button.removeAttribute("aria-current");
}
});
}
playButton.textContent = playing
? "Pause"
: progress >= 1
? "Replay"
: "Play";
}
playButton.addEventListener("click", () => {
if (progress >= 1) {
progress = 0;
playing = true;
} else {
playing = !playing;
}
updateInterface();
});
document.getElementById("replay").addEventListener("click", () => {
progress = 0;
playing = true;
updateInterface();
});
document.getElementById("reset-view").addEventListener("click", resetCamera);
stageButtons.forEach((button) => {
button.addEventListener("click", () => {
progress = Number(button.dataset.time);
playing = false;
updateInterface();
});
});
window.addEventListener("keydown", (event) => {
if (event.code === "Space") {
event.preventDefault();
playButton.click();
}
if (event.key.toLowerCase() === "r") {
resetCamera();
}
});
// -------------------------------------------------------------------------
// Screen-space labels projected from world anchors
// -------------------------------------------------------------------------
const labelDefinitions = [
{
element: document.getElementById("label-fiber"),
anchor: new THREE.Vector3(-4.92, 1.2, -1.45),
dx: -18,
dy: 8
},
{
element: document.getElementById("label-vat"),
anchor: new THREE.Vector3(-3.5, 0.86, 0.28),
dx: -8,
dy: 10
},
{
element: document.getElementById("label-frame"),
anchor: new THREE.Vector3(-1.62, 1.02, 0.32),
dx: 0,
dy: 17
},
{
element: document.getElementById("label-press"),
anchor: new THREE.Vector3(0.02, 2.75, 1.35),
dx: 34,
dy: 0
},
{
element: document.getElementById("label-rack"),
anchor: new THREE.Vector3(0.62, 2.48, -1.55),
dx: -12,
dy: 8
},
{
element: document.getElementById("label-court"),
anchor: new THREE.Vector3(5.2, 1.45, 0.18),
dx: 28,
dy: 8
}
];
const trackedLabel = document.getElementById("tracked-label");
function positionLabel(element, worldPosition, dx = 0, dy = 0) {
const projected = worldPosition.clone().project(camera);
if (
projected.z < -1 ||
projected.z > 1 ||
projected.x < -1.2 ||
projected.x > 1.2 ||
projected.y < -1.2 ||
projected.y > 1.2
) {
element.style.display = "none";
return;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.display = "block";
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.style.transform =
`translate(-50%, -100%) translate(${dx}px, ${dy}px)`;
}
function updateLabels() {
labelDefinitions.forEach((definition) => {
positionLabel(
definition.element,
definition.anchor,
definition.dx,
definition.dy
);
});
positionLabel(
trackedLabel,
trackedSheet.position.clone().add(new THREE.Vector3(0, 0.35, 0)),
10,
-3
);
}
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
let previousTime = performance.now();
function animate(now) {
const delta = Math.min((now - previousTime) / 1000, 0.05);
previousTime = now;
if (playing) {
progress += delta / duration;
if (progress >= 1) {
progress = 1;
playing = false;
}
}
updateTrackedSheet(progress);
updateInterface();
updateLabels();
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
updateTrackedSheet(progress);
updateInterface();
updateLabels();
document.getElementById("loading").remove();
requestAnimationFrame(animate);
</script>
</body>
</html>
```