Prompt specification
Build or customize the Three.js 3D scene "Printer arranging a small news sheet" 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: Printer arranging a small news sheet
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/printer-arranging-a-small-news-sheet-x2338
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring early printed news sheets and their distribution. Create a historically referenced early modern printing vignette with type, ink tools, and paper stack. Print an original fictional notice clearly identified as illustrative. Voxel style.
Working Three.js Starter (printer-arranging-a-small-news-sheet-x2338):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Common Press — An Early Modern Printing Vignette</title>
<style>
:root {
color-scheme: dark;
--ink: #201710;
--parchment: #ead9b4;
--gold: #d9b66e;
--cream: #f3e6c8;
--muted: #c5b99e;
--panel: rgba(25, 19, 14, 0.88);
--line: rgba(233, 211, 165, 0.22);
--red: #a63d2c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #1d1712;
font-family: Georgia, "Times New Roman", serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
z-index: 5;
pointer-events: none;
}
#title-card {
top: 24px;
left: 24px;
max-width: 440px;
padding: 20px 22px;
border: 1px solid var(--line);
border-left: 4px solid var(--gold);
background:
linear-gradient(135deg, rgba(49, 36, 24, 0.94), rgba(22, 17, 13, 0.88));
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
backdrop-filter: blur(8px);
}
.eyebrow {
margin: 0 0 8px;
color: var(--gold);
font: 700 11px/1.2 Arial, sans-serif;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
color: var(--cream);
font-size: clamp(28px, 4vw, 44px);
font-weight: 500;
line-height: 0.98;
}
#title-card .subtitle {
margin: 11px 0 0;
color: var(--muted);
font: 13px/1.5 Arial, sans-serif;
}
#period {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 14px;
padding: 7px 9px;
border: 1px solid rgba(217, 182, 110, 0.3);
color: #e3c98f;
background: rgba(217, 182, 110, 0.07);
font: 700 10px/1 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#period::before {
width: 7px;
height: 7px;
content: "";
background: var(--gold);
box-shadow: 0 0 12px rgba(217, 182, 110, 0.65);
}
#about {
right: 24px;
top: 24px;
width: min(330px, calc(100vw - 48px));
padding: 16px 18px;
border: 1px solid var(--line);
background: var(--panel);
color: var(--muted);
font: 12px/1.55 Arial, sans-serif;
box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(8px);
}
#about strong {
display: block;
margin-bottom: 6px;
color: var(--cream);
font-size: 12px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#controls {
bottom: 22px;
left: 50%;
display: flex;
max-width: calc(100vw - 30px);
padding: 8px;
transform: translateX(-50%);
border: 1px solid var(--line);
background: rgba(24, 18, 13, 0.9);
box-shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
pointer-events: auto;
backdrop-filter: blur(10px);
flex-wrap: wrap;
justify-content: center;
}
.control-button {
min-height: 40px;
margin: 2px;
padding: 10px 14px;
border: 1px solid transparent;
color: #d7c9ac;
background: transparent;
cursor: pointer;
font: 700 11px/1 Arial, sans-serif;
letter-spacing: 0.06em;
text-transform: uppercase;
transition:
color 150ms ease,
border-color 150ms ease,
background 150ms ease;
}
.control-button:hover,
.control-button:focus-visible {
border-color: rgba(217, 182, 110, 0.4);
color: #fff0cc;
background: rgba(217, 182, 110, 0.08);
outline: none;
}
.control-button[aria-pressed="true"] {
border-color: rgba(217, 182, 110, 0.6);
color: var(--gold);
background: rgba(217, 182, 110, 0.12);
}
.control-button.read {
border-color: rgba(166, 61, 44, 0.65);
color: #efb19f;
}
.hint {
bottom: 91px;
left: 50%;
padding: 7px 11px;
transform: translateX(-50%);
color: rgba(242, 226, 194, 0.62);
background: rgba(20, 15, 11, 0.65);
font: 10px/1.2 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
white-space: nowrap;
}
#loading {
position: fixed;
z-index: 20;
inset: 0;
display: grid;
place-items: center;
color: var(--gold);
background: #1d1712;
font: 700 12px/1 Arial, sans-serif;
letter-spacing: 0.2em;
text-transform: uppercase;
transition: opacity 500ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
#notice-modal {
position: fixed;
z-index: 30;
inset: 0;
display: grid;
place-items: center;
padding: 24px;
background: rgba(10, 7, 5, 0.78);
opacity: 0;
visibility: hidden;
transition: opacity 180ms ease;
backdrop-filter: blur(5px);
}
#notice-modal.open {
opacity: 1;
visibility: visible;
}
.notice-paper {
position: relative;
width: min(720px, 100%);
max-height: calc(100vh - 48px);
overflow: auto;
padding: 42px 50px 48px;
border: 1px solid #a78c61;
color: #2a2118;
background:
radial-gradient(circle at 15% 10%, rgba(116, 76, 37, 0.12), transparent 23%),
radial-gradient(circle at 85% 72%, rgba(116, 76, 37, 0.1), transparent 28%),
#e7d5ad;
box-shadow:
0 28px 90px rgba(0, 0, 0, 0.55),
inset 0 0 55px rgba(85, 54, 26, 0.13);
transform: rotate(-0.35deg) translateY(10px);
transition: transform 220ms ease;
}
#notice-modal.open .notice-paper {
transform: rotate(-0.35deg) translateY(0);
}
.fiction-banner {
margin: -12px -16px 22px;
padding: 10px 12px;
border: 2px solid #8f3328;
color: #7f2d23;
text-align: center;
font: 900 12px/1.35 Arial, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.notice-paper header {
text-align: center;
}
.notice-paper h2 {
margin: 0;
font-size: clamp(34px, 7vw, 58px);
font-weight: 500;
letter-spacing: 0.05em;
}
.notice-paper .issue {
margin: 7px 0 17px;
color: #6b5037;
font: italic 14px/1.4 Georgia, serif;
}
.notice-paper h3 {
margin: 17px 0 12px;
padding: 10px 5px;
border-top: 3px double #423225;
border-bottom: 3px double #423225;
text-align: center;
font-size: clamp(22px, 4vw, 34px);
font-weight: 500;
line-height: 1.08;
}
.notice-columns {
column-count: 2;
column-gap: 28px;
column-rule: 1px solid rgba(66, 50, 37, 0.35);
font: 15px/1.48 Georgia, serif;
}
.notice-columns p {
margin: 0 0 10px;
}
.notice-columns p:first-child::first-letter {
float: left;
margin: 4px 6px 0 0;
color: #7f2d23;
font-size: 45px;
line-height: 0.75;
}
.notice-signature {
margin-top: 20px;
text-align: center;
font-style: italic;
}
.fiction-note {
margin-top: 22px;
padding-top: 13px;
border-top: 1px solid rgba(66, 50, 37, 0.4);
color: #6c5138;
text-align: center;
font: 12px/1.5 Arial, sans-serif;
}
#close-notice {
position: absolute;
top: 10px;
right: 12px;
width: 34px;
height: 34px;
border: 1px solid rgba(66, 50, 37, 0.4);
color: #3d2c1e;
background: rgba(255, 246, 222, 0.35);
cursor: pointer;
font: 700 20px/1 Arial, sans-serif;
}
#close-notice:hover,
#close-notice:focus-visible {
background: rgba(127, 45, 35, 0.12);
outline: none;
}
@media (max-width: 760px) {
#title-card {
top: 12px;
left: 12px;
max-width: calc(100vw - 24px);
padding: 14px 16px;
}
#title-card .subtitle {
display: none;
}
#about {
display: none;
}
#controls {
bottom: 12px;
width: calc(100vw - 24px);
}
.control-button {
padding: 9px 10px;
font-size: 9px;
}
.hint {
bottom: 82px;
}
.notice-paper {
padding: 36px 26px 38px;
}
.notice-columns {
column-count: 1;
}
}
</style>
</head>
<body>
<div id="scene" aria-label="Interactive voxel-style early modern printing workshop"></div>
<section id="title-card" class="hud">
<p class="eyebrow">A procedural Three.js diorama</p>
<h1>The Common Press</h1>
<p class="subtitle">
An imagined early modern printing house where sheets are composed, inked,
printed, bundled, carried, and posted.
</p>
<div id="period">c. 1650–1700 · interpretive vignette</div>
</section>
<aside id="about" class="hud">
<strong>Historical reference</strong>
Stylized after European hand-printing workshops: a wooden common press,
composing stick, type case, leather ink balls, single-sheet news, a carrier,
and a public posting board. This is an interpretive scene rather than a
reconstruction of one documented shop. The visible newspaper is original
fiction and is labeled as illustrative.
</aside>
<div id="hint" class="hud">Drag to orbit · wheel to zoom · click the marked sheet</div>
<nav id="controls" class="hud" aria-label="Scene controls">
<button class="control-button" data-focus="overview" aria-pressed="true">Overview</button>
<button class="control-button" data-focus="press" aria-pressed="false">Hand press</button>
<button class="control-button" data-focus="type" aria-pressed="false">Type & ink</button>
<button class="control-button" data-focus="distribution" aria-pressed="false">Distribution</button>
<button id="read-notice" class="control-button read">Read fictional notice</button>
<button id="motion-toggle" class="control-button" aria-pressed="true">Pause motion</button>
</nav>
<div id="loading">Setting type and ink…</div>
<div id="notice-modal" role="dialog" aria-modal="true" aria-labelledby="notice-title">
<article class="notice-paper">
<button id="close-notice" aria-label="Close notice">×</button>
<div class="fiction-banner">
Illustrative fiction — not an authentic historical document
</div>
<header>
<h2 id="notice-title">The River Post</h2>
<p class="issue">Imagined issue no. 47 · 12 June 1683</p>
</header>
<h3>The Bridge at Lowford Will Be Mended</h3>
<div class="notice-columns">
<p>
Whereas the stone bridge over the Lower Water at Lowford is lately
found weaken in its middle arch, the inhabitants of the said village
are hereby informed that workmen shall begin the repair upon the
first fair day following the feast of Saint John.
</p>
<p>
During the mending, carts and market wains are commanded to pass by
the Old Ferry Road. The ferryman shall attend from sunrise until dusk,
and no person shall demand passage beyond the mill at Hollow Beck
until the bridge-keeper gives leave.
</p>
<p>
All householders are requested to bring timber, straw, and common
lime to the common yard before the bell at four. Master Edmund
Winter, appointed overseer, will give direction to the workmen, and
complaints shall be made to the constable of the south ward.
</p>
<p>
This notice concerns no real bridge, place, person, office, or
newspaper. It was written for this interactive historical vignette.
</p>
</div>
<p class="notice-signature">
By order of the imaginary River Post Office,<br>
at the imagined town of Lowford
</p>
<div class="fiction-note">
Original fictional notice created for this scene. It is included to
demonstrate the appearance and circulation of early modern printed
news, not to reproduce an archival source.
</div>
</article>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const sceneHost = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
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;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x211913);
scene.fog = new THREE.Fog(0x211913, 24, 43);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemi = new THREE.HemisphereLight(0xffedc5, 0x3b2d24, 2.15);
scene.add(hemi);
const key = new THREE.DirectionalLight(0xffe2a3, 4.3);
key.position.set(8, 13, 10);
key.castShadow = true;
key.shadow.mapSize.set(2048, 2048);
key.shadow.camera.left = -14;
key.shadow.camera.right = 14;
key.shadow.camera.top = 13;
key.shadow.camera.bottom = -10;
key.shadow.camera.near = 1;
key.shadow.camera.far = 38;
key.shadow.bias = -0.0005;
scene.add(key);
const warmFill = new THREE.PointLight(0xff9d52, 26, 15, 2);
warmFill.position.set(-5, 5, 1.5);
scene.add(warmFill);
const coolFill = new THREE.PointLight(0x8aa6c7, 12, 14, 2);
coolFill.position.set(6, 4.5, -2);
scene.add(coolFill);
// -------------------------------------------------------------------------
// Palette and geometry helpers
// -------------------------------------------------------------------------
const M = {
darkWood: new THREE.MeshStandardMaterial({
color: 0x3c2417,
roughness: 0.93
}),
wood: new THREE.MeshStandardMaterial({
color: 0x694027,
roughness: 0.9
}),
lightWood: new THREE.MeshStandardMaterial({
color: 0x9a6a39,
roughness: 0.88
}),
paleWood: new THREE.MeshStandardMaterial({
color: 0xb8874d,
roughness: 0.86
}),
plaster: new THREE.MeshStandardMaterial({
color: 0x97816a,
roughness: 1
}),
stone: new THREE.MeshStandardMaterial({
color: 0x625d54,
roughness: 1
}),
stoneLight: new THREE.MeshStandardMaterial({
color: 0x81786a,
roughness: 1
}),
metal: new THREE.MeshStandardMaterial({
color: 0x303033,
roughness: 0.62,
metalness: 0.55
}),
iron: new THREE.MeshStandardMaterial({
color: 0x202225,
roughness: 0.52,
metalness: 0.75
}),
brass: new THREE.MeshStandardMaterial({
color: 0xa47b35,
roughness: 0.48,
metalness: 0.65
}),
ink: new THREE.MeshStandardMaterial({
color: 0x111013,
roughness: 0.72
}),
paper: new THREE.MeshStandardMaterial({
color: 0xd8c394,
roughness: 0.98
}),
paperEdge: new THREE.MeshStandardMaterial({
color: 0xbba777,
roughness: 1
}),
red: new THREE.MeshStandardMaterial({
color: 0x8e3024,
roughness: 0.85
}),
blue: new THREE.MeshStandardMaterial({
color: 0x3d5965,
roughness: 0.9
}),
green: new THREE.MeshStandardMaterial({
color: 0x40513c,
roughness: 0.95
}),
coat: new THREE.MeshStandardMaterial({
color: 0x4b3529,
roughness: 0.96
}),
skin: new THREE.MeshStandardMaterial({
color: 0xc99167,
roughness: 0.95
}),
window: new THREE.MeshStandardMaterial({
color: 0x9ab6c0,
emissive: 0x496b7b,
emissiveIntensity: 0.34,
roughness: 0.85
})
};
function cuboid(w, h, d, x, y, z, material, parent = scene) {
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 group(x = 0, y = 0, z = 0, parent = scene) {
const g = new THREE.Group();
g.position.set(x, y, z);
parent.add(g);
return g;
}
let randomSeed = 1683;
function random() {
randomSeed =
(randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
// -------------------------------------------------------------------------
// Procedural canvas textures
// -------------------------------------------------------------------------
function makeTexture(width, height, draw) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
draw(ctx, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
const noticeTexture = makeTexture(768, 1024, (ctx, w, h) => {
ctx.fillStyle = "#e5d2a8";
ctx.fillRect(0, 0, w, h);
for (let i = 0; i < 90; i++) {
const x = random() * w;
const y = random() * h;
const r = 4 + random() * 28;
ctx.fillStyle = `rgba(104, 69, 35, ${0.012 + random() * 0.035})`;
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI * 2);
ctx.fill();
}
ctx.strokeStyle = "#3f3021";
ctx.lineWidth = 3;
ctx.strokeRect(25, 25, w - 50, h - 50);
ctx.lineWidth = 1;
ctx.strokeRect(35, 35, w - 70, h - 70);
ctx.fillStyle = "#7f2d23";
ctx.fillRect(48, 48, w - 96, 53);
ctx.fillStyle = "#f0dfb9";
ctx.font = "900 20px Arial";
ctx.textAlign = "center";
ctx.fillText(
"ILLUSTRATIVE FICTION • NOT AN AUTHENTIC DOCUMENT",
w / 2,
81
);
ctx.fillStyle = "#282018";
ctx.font = "bold 66px Georgia";
ctx.fillText("THE RIVER POST", w / 2, 166);
ctx.font = "italic 24px Georgia";
ctx.fillText("Imagined weekly news of the lower water", w / 2, 202);
ctx.strokeStyle = "#493624";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.moveTo(62, 225);
ctx.lineTo(w - 62, 225);
ctx.stroke();
ctx.font = "bold 45px Georgia";
const headline = "THE BRIDGE AT LOWFORD";
ctx.fillText(headline, w / 2, 287);
ctx.fillText("WILL BE MENDED", w / 2, 340);
ctx.font = "18px Georgia";
ctx.fillText("Issue No. 47 • 12 June 1683", w / 2, 381);
ctx.strokeStyle = "#493624";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(63, 408);
ctx.lineTo(w - 63, 408);
ctx.stroke();
const bodyLeft = 63;
const bodyRight = w - 63;
const columnGap = 28;
const columnWidth = (bodyRight - bodyLeft - columnGap) / 2;
const paragraphs = [
"Whereas the stone bridge over the Lower Water is lately found to weaken in its middle arch, the inhabitants are informed that workmen shall begin the repair on the first fair day after the feast of Saint John.",
"During the mending, carts and market wains are commanded to pass by the Old Ferry Road. The ferryman shall attend from sunrise until dusk.",
"All householders are requested to bring timber, straw, and common lime to the common yard before the bell at four. Master Winter, appointed overseer, shall direct the workmen.",
"This notice is entirely invented for an educational vignette. It concerns no real bridge, place, person, office, or newspaper."
];
let textY = 448;
for (let column = 0; column < 2; column++) {
ctx.fillStyle = "#33281d";
ctx.font = "19px Georgia";
ctx.textAlign = "left";
for (let p = 0; p < 2; p++) {
const index = column * 2 + p;
const words = paragraphs[index].split(" ");
let line = "";
let lineY = textY;
for (const word of words) {
const test = line ? `${line} ${word}` : word;
if (ctx.measureText(test).width > columnWidth) {
ctx.fillText(line, bodyLeft + column * (columnWidth + columnGap), lineY);
line = word;
lineY += 26;
} else {
line = test;
}
}
ctx.fillText(line, bodyLeft + column * (columnWidth + columnGap), lineY);
lineY += 46;
}
}
ctx.textAlign = "center";
ctx.fillStyle = "#6e2f25";
ctx.font = "italic 21px Georgia";
ctx.fillText("By order of the imaginary River Post Office", w / 2, 842);
ctx.fillText("at the imagined town of Lowford", w / 2, 873);
ctx.strokeStyle = "#7f2d23";
ctx.lineWidth = 4;
ctx.strokeRect(254, 895, 260, 72);
ctx.fillStyle = "#7f2d23";
ctx.font = "bold 17px Arial";
ctx.fillText("FICTIONAL", w / 2, 925);
ctx.fillText("EXEMPLAR", w / 2, 951);
});
const newsTexture = makeTexture(640, 800, (ctx, w, h) => {
ctx.fillStyle = "#ddca9d";
ctx.fillRect(0, 0, w, h);
for (let i = 0; i < 55; i++) {
ctx.fillStyle = `rgba(100, 66, 31, ${0.01 + random() * 0.035})`;
ctx.beginPath();
ctx.arc(random() * w, random() * h, 3 + random() * 18, 0, Math.PI * 2);
ctx.fill();
}
ctx.strokeStyle = "#473321";
ctx.lineWidth = 3;
ctx.strokeRect(24, 24, w - 48, h - 48);
ctx.fillStyle = "#30231a";
ctx.textAlign = "center";
ctx.font = "bold 54px Georgia";
ctx.fillText("THE RIVER POST", w / 2, 112);
ctx.font = "italic 19px Georgia";
ctx.fillText("An imagined weekly news sheet", w / 2, 145);
ctx.fillStyle = "#843328";
ctx.fillRect(48, 168, w - 96, 38);
ctx.fillStyle = "#f0dfb8";
ctx.font = "bold 15px Arial";
ctx.fillText("ILLUSTRATIVE FICTION", w / 2, 194);
ctx.strokeStyle = "#493624";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.moveTo(52, 231);
ctx.lineTo(w - 52, 231);
ctx.stroke();
ctx.fillStyle = "#34281d";
ctx.font = "bold 35px Georgia";
ctx.fillText("NEWS FROM THE LOWER", w / 2, 282);
ctx.fillText("MARKET AND RIVER", w / 2, 325);
ctx.font = "18px Georgia";
ctx.textAlign = "left";
for (let column = 0; column < 2; column++) {
const x = 55 + column * 278;
for (let line = 0; line < 21; line++) {
const length = 135 + random() * 125;
ctx.fillStyle = "rgba(51, 40, 29, 0.83)";
ctx.fillRect(x, 370 + line * 17, length, 3);
}
}
ctx.textAlign = "center";
ctx.font = "italic 17px Georgia";
ctx.fillText("A created teaching example — not an archival source", w / 2, 758);
});
const pressSignTexture = makeTexture(900, 150, (ctx, w, h) => {
ctx.fillStyle = "#2b1e15";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "#c3a268";
ctx.lineWidth = 4;
ctx.strokeRect(12, 12, w - 24, h - 24);
ctx.textAlign = "center";
ctx.fillStyle = "#dfc487";
ctx.font = "bold 42px Georgia";
ctx.fillText("THE COMMON PRESS", w / 2, 65);
ctx.font = "22px Georgia";
ctx.fillText("An interpretive workshop of about 1650–1700", w / 2, 108);
});
const distributionSignTexture = makeTexture(700, 180, (ctx, w, h) => {
ctx.fillStyle = "#d4bc8a";
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = "#5a3824";
ctx.lineWidth = 8;
ctx.strokeRect(10, 10, w - 20, h - 20);
ctx.textAlign = "center";
ctx.fillStyle = "#4b2d1f";
ctx.font = "bold 54px Georgia";
ctx.fillText("NEWS TO BE CARRIED", w / 2, 80);
ctx.font = "bold 24px Arial";
ctx.fillText("ILLUSTRATIVE SINGLE-SHEET CIRCULATION", w / 2, 126);
});
const typeTextures = new Map();
const typeLetters = "ETAOINSRHLDCUMWFGYPBVKJXQZ";
function typeTexture(letter) {
if (typeTextures.has(letter)) return typeTextures.get(letter);
const texture = makeTexture(96, 96, (ctx) => {
ctx.fillStyle = "#b9a17a";
ctx.fillRect(0, 0, 96, 96);
ctx.fillStyle = "#24201c";
ctx.font = "bold 68px Georgia";
ctx.textAlign = "center";
ctx.fillText(letter, 48, 69);
});
typeTextures.set(letter, texture);
return texture;
}
// -------------------------------------------------------------------------
// Interactive paper objects
// -------------------------------------------------------------------------
const interactiveSheets = [];
function makeSheet(
width,
height,
x,
y,
z,
texture,
parent = scene,
vertical = false,
isNotice = false
) {
const face = new THREE.MeshStandardMaterial({
map: texture,
roughness: 0.98,
metalness: 0
});
const edge = M.paperEdge;
const materials = vertical
? [edge, edge, edge, edge, face, edge]
: [edge, edge, face, edge, edge, edge];
const dimensions = vertical
? [width, height, 0.026]
: [width, 0.026, height];
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(...dimensions),
materials
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (isNotice) {
mesh.userData.isNotice = true;
interactiveSheets.push(mesh);
}
return mesh;
}
function makePanel(width, height, x, y, z, texture, parent = scene) {
const face = new THREE.MeshStandardMaterial({
map: texture,
roughness: 0.92
});
const edge = M.darkWood;
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, 0.08),
[edge, edge, edge, edge, face, edge]
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
// -------------------------------------------------------------------------
// Floor, walls, window, and street
// -------------------------------------------------------------------------
cuboid(18.2, 0.55, 13.2, 0, -0.32, 0, M.darkWood);
for (let row = 0; row < 11; row++) {
const woodMaterial = row % 3 === 0 ? M.wood : M.darkWood;
cuboid(
18,
0.08,
1.14,
0,
0,
-5.85 + row * 1.18,
woodMaterial
);
}
// Uneven stone blocks on the public side of the diorama.
for (let row = 0; row < 3; row++) {
for (let col = 0; col < 9; col++) {
const material = (row + col) % 3 === 0 ? M.stoneLight : M.stone;
cuboid(
1.75 + random() * 0.2,
0.22 + random() * 0.08,
1.05,
-7.4 + col * 1.86,
0.12 + row * 0.23,
4.25 + (row % 2) * 0.09,
material
);
}
}
cuboid(18.2, 6.4, 0.45, 0, 3.1, -6.45, M.plaster);
cuboid(0.45, 6.4, 12.8, -9, 3.1, 0, M.plaster);
// Timber framing on the rear wall.
for (const x of [-8.55, -5.8, -2.9, 0, 2.9, 5.8, 8.55]) {
cuboid(0.25, 6.1, 0.3, x, 3.05, -6.15, M.darkWood);
}
cuboid(18, 0.28, 0.34, 0, 6.08, -6.13, M.darkWood);
cuboid(18, 0.25, 0.34, 0, 0.35, -6.13, M.darkWood);
// Irregular plaster patches, assembled as voxels.
for (let i = 0; i < 30; i++) {
cuboid(
0.35 + random() * 0.65,
0.25 + random() * 0.45,
0.035,
-8.4 + random() * 16.8,
0.55 + random() * 5.25,
-6.205,
(i % 2) ? M.stoneLight : M.stone
);
}
// Window.
const windowGroup = group(1.25, 4.25, -6.08);
cuboid(2.35, 2.05, 0.08, 0, 0, 0, M.window, windowGroup);
cuboid(2.65, 0.18, 0.2, 0, 1.05, 0.06, M.darkWood, windowGroup);
cuboid(2.65, 0.18, 0.2, 0, -1.05, 0.06, M.darkWood, windowGroup);
cuboid(0.18, 2.25, 0.2, -1.25, 0, 0.06, M.darkWood, windowGroup);
cuboid(0.18, 2.25, 0.2, 1.25, 0, 0.06, M.darkWood, windowGroup);
cuboid(0.13, 2.05, 0.2, 0, 0, 0.07, M.darkWood, windowGroup);
cuboid(2.35, 0.13, 0.2, 0, 0, 0.07, M.darkWood, windowGroup);
makePanel(
4.2,
0.7,
-4.55,
5.72,
-6.03,
pressSignTexture
);
// -------------------------------------------------------------------------
// The wooden common hand press
// -------------------------------------------------------------------------
const press = group(-4.55, 0, -3.55);
cuboid(1.15, 0.38, 1.25, -1.85, 0.18, -0.35, M.darkWood, press);
cuboid(1.15, 0.38, 1.25, 1.85, 0.18, -0.35, M.darkWood, press);
cuboid(0.48, 5.15, 0.68, -1.85, 2.75, -0.35, M.darkWood, press);
cuboid(0.48, 5.15, 0.68, 1.85, 2.75, -0.35, M.darkWood, press);
cuboid(4.85, 0.72, 0.82, 0, 5.18, -0.35, M.wood, press);
// Cross braces.
cuboid(0.32, 4.45, 0.42, -1.15, 2.65, -0.36, M.wood, press);
cuboid(0.32, 4.45, 0.42, 1.15, 2.65, -0.36, M.wood, press);
// Press bed and lower platform.
cuboid(3.65, 0.34, 2.85, 0, 1.12, 0.35, M.darkWood, press);
cuboid(3.95, 0.22, 3.15, 0, 0.87, 0.35, M.wood, press);
cuboid(2.85, 0.13, 2.15, 0, 1.35, 0.38, M.iron, press);
// Tympan/frame resting above the bed.
cuboid(2.55, 0.12, 1.9, 0, 1.49, 0.38, M.lightWood, press);
cuboid(2.2, 0.08, 1.55, 0, 1.58, 0.38, M.paper, press);
// Screw and spindle, deliberately square/voxel-like.
cuboid(0.34, 1.62, 0.34, 0, 4.25, -0.35, M.iron, press);
for (let i = 0; i < 8; i++) {
cuboid(
0.64 - i * 0.025,
0.12,
0.64 - i * 0.025,
0,
3.55 + i * 0.16,
-0.35,
M.metal,
press
);
}
// Platen moves subtly during the printing cycle.
const platen = group(0, 3.12, 0.35, press);
cuboid(2.55, 0.34, 2.05, 0, 0, 0, M.iron, platen);
cuboid(2.85, 0.16, 2.25, 0, 0.25, 0, M.darkWood, platen);
cuboid(0.42, 0.66, 0.42, 0, 0.55, 0, M.metal, platen);
// Long operating lever.
const lever = cuboid(4.65, 0.25, 0.3, 1.85, 2.45, -0.35, M.wood, press);
lever.rotation.z = -0.19;
const leverHandle = cuboid(
1.05,
0.28,
0.32,
3.86,
2.02,
-0.35,
M.darkWood,
press
);
leverHandle.rotation.z = -0.19;
// A printed sheet lies on the bed.
makeSheet(
1.35,
1.72,
0,
1.67,
0.4,
newsTexture,
press
);
// -------------------------------------------------------------------------
// Type table, composing stick, type case, ink balls, and ink pot
// -------------------------------------------------------------------------
const typeTable = group(-4.25, 0, 0.75);
cuboid(4.35, 0.25, 2.45, 0, 1.58, 0, M.wood, typeTable);
for (const x of [-1.83, 1.83]) {
for (const z of [-0.92, 0.92]) {
cuboid(0.28, 1.45, 0.28, x, 0.76, z, M.darkWood, typeTable);
}
}
cuboid(3.8, 0.16, 0.18, 0, 0.55, 0, M.darkWood, typeTable);
// Type case.
cuboid(1.8, 0.13, 1.22, -0.98, 1.76, -0.42, M.darkWood, typeTable);
cuboid(1.65, 0.08, 1.08, -0.98, 1.85, -0.42, M.iron, typeTable);
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 12; col++) {
const letter = typeLetters[(row * 12 + col) % typeLetters.length];
const topMaterial = new THREE.MeshStandardMaterial({
map: typeTexture(letter),
roughness: 0.78
});
const sort = new THREE.Mesh(
new THREE.BoxGeometry(0.115, 0.35, 0.115),
[
M.metal,
M.metal,
topMaterial,
M.metal,
M.metal,
M.metal
]
);
sort.position.set(
-1.7 + col * 0.13,
2.0,
-0.88 + row * 0.21
);
sort.castShadow = true;
typeTable.add(sort);
}
}
// Composing stick.
const composingStick = group(0.94, 1.73, 0.62, typeTable);
cuboid(1.35, 0.08, 0.4, 0, 0, 0, M.metal, composingStick);
cuboid(1.35, 0.28, 0.08, 0, 0.12, -0.18, M.iron, composingStick);
cuboid(0.08, 0.28, 0.4, 0.67, 0.12, 0, M.iron, composingStick);
for (let i = 0; i < 7; i++) {
const letter = typeLetters[(i * 5) % typeLetters.length];
const topMaterial = new THREE.MeshStandardMaterial({
map: typeTexture(letter),
roughness: 0.78
});
const sort = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.38, 0.13),
[M.metal, M.metal, topMaterial, M.metal, M.metal, M.metal]
);
sort.position.set(-0.52 + i * 0.17, 0.2, 0);
sort.castShadow = true;
composingStick.add(sort);
}
// Ink pot.
cuboid(0.58, 0.36, 0.58, 1.43, 1.88, -0.68, M.iron, typeTable);
cuboid(0.48, 0.06, 0.48, 1.43, 2.08, -0.68, M.ink, typeTable);
cuboid(0.24, 0.18, 0.24, 1.7, 2.15, -0.75, M.brass, typeTable);
function makeInkBall(x, y, z, parent) {
const ball = group(x, y, z, parent);
cuboid(0.55, 0.42, 0.5, 0, 0.2, 0, M.darkWood, ball);
cuboid(0.4, 0.54, 0.38, -0.2, 0.16, 0, M.wood, ball);
cuboid(0.4, 0.54, 0.38, 0.2, 0.16, 0, M.wood, ball);
cuboid(0.42, 0.38, 0.46, 0, 0.16, -0.19, M.wood, ball);
cuboid(0.42, 0.38, 0.46, 0, 0.16, 0.19, M.wood, ball);
cuboid(0.38, 0.3, 0.34, 0, 0.47, 0, M.ink, ball);
cuboid(0.19, 0.55, 0.19, 0, 0.78, 0, M.lightWood, ball);
cuboid(0.33, 0.12, 0.3, 0, 1.05, 0, M.darkWood, ball);
}
makeInkBall(0.12, 1.72, -0.64, typeTable);
makeInkBall(0.55, 1.72, -0.74, typeTable);
// -------------------------------------------------------------------------
// Paper table and stack
// -------------------------------------------------------------------------
const paperTable = group(0.35, 0, 0.65);
cuboid(3.15, 0.25, 2.35, 0, 1.56, 0, M.lightWood, paperTable);
for (const x of [-1.22, 1.22]) {
for (const z of [-0.87, 0.87]) {
cuboid(0.27, 1.42, 0.27, x, 0.75, z, M.darkWood, paperTable);
}
}
cuboid(2.7, 0.15, 0.18, 0, 0.54, 0, M.darkWood, paperTable);
for (let i = 0; i < 12; i++) {
const sheet = cuboid(
1.22,
0.026,
1.66,
(random() - 0.5) * 0.08,
1.705 + i * 0.028,
(random() - 0.5) * 0.07,
i % 3 === 0 ? M.paperEdge : M.paper,
paperTable
);
sheet.rotation.y = (random() - 0.5) * 0.025;
}
const topNotice = makeSheet(
1.22,
1.66,
0,
2.07,
0,
noticeTexture,
paperTable,
false,
true
);
topNotice.rotation.y = -0.025;
// -------------------------------------------------------------------------
// Distribution counter, bundles, carrier, and posting board
// -------------------------------------------------------------------------
const counter = group(4.35, 0, 0.85);
cuboid(2.85, 0.24, 1.7, 0, 1.35, 0, M.wood, counter);
for (const x of [-1.15, 1.15]) {
for (const z of [-0.58, 0.58]) {
cuboid(0.26, 1.25, 0.26, x, 0.65, z, M.darkWood, counter);
}
}
cuboid(2.55, 0.16, 0.18, 0, 0.45, 0, M.darkWood, counter);
makePanel(
2.4,
0.62,
0,
0.92,
0.89,
distributionSignTexture,
counter
);
// Bundled sheets on the distribution counter.
for (let i = 0; i < 8; i++) {
const sheet = cuboid(
0.92,
0.025,
1.16,
0.38 + (random() - 0.5) * 0.05,
1.49 + i * 0.028,
-0.08 + (random() - 0.5) * 0.05,
i === 7 ? M.paper : M.paperEdge,
counter
);
sheet.rotation.y = (random() - 0.5) * 0.045;
}
// A twine-like voxel band around the counter bundle.
cuboid(0.95, 0.055, 0.06, 0.38, 1.69, 0.24, M.paperEdge, counter);
cuboid(0.06, 0.055, 1.15, 0.38, 1.69, -0.08, M.paperEdge, counter);
// News carrier / courier.
const carrier = group(6.25, 0, -1.35);
carrier.rotation.y = -0.17;
cuboid(0.29, 0.72, 0.3, -0.19, 0.39, 0, M.darkWood, carrier);
cuboid(0.29, 0.72, 0.3, 0.19, 0.39, 0, M.darkWood, carrier);
cuboid(0.37, 0.18, 0.5, -0.19, 0.09, 0.06, M.iron, carrier);
cuboid(0.37, 0.18, 0.5, 0.19, 0.09, 0.06, M.iron, carrier);
cuboid(0.92, 1.02, 0.55, 0, 1.2, 0, M.coat, carrier);
cuboid(0.28, 0.95, 0.28, -0.62, 1.24, 0.02, M.coat, carrier);
cuboid(0.28, 0.95, 0.28, 0.62, 1.24, 0.02, M.coat, carrier);
cuboid(0.28, 0.3, 0.28, -0.62, 0.83, 0.04, M.skin, carrier);
cuboid(0.28, 0.3, 0.28, 0.62, 0.83, 0.04, M.skin, carrier);
cuboid(0.61, 0.62, 0.57, 0, 2.02, 0, M.skin, carrier);
cuboid(0.73, 0.13, 0.68, 0, 2.38, 0, M.darkWood, carrier);
cuboid(0.53, 0.35, 0.48, 0, 2.57, 0, M.darkWood, carrier);
// Eyes are tiny cubes on the front of the head.
cuboid(0.075, 0.075, 0.03, -0.13, 2.08, 0.294, M.ink, carrier);
cuboid(0.075, 0.075, 0.03, 0.13, 2.08, 0.294, M.ink, carrier);
// Satchel.
cuboid(0.58, 0.62, 0.3, -0.64, 1.06, -0.1, M.wood, carrier);
cuboid(0.61, 0.16, 0.33, -0.64, 1.28, -0.1, M.darkWood, carrier);
cuboid(0.08, 0.9, 0.08, -0.36, 1.53, -0.1, M.paperEdge, carrier);
// Papers carried under the right arm.
const carriedBundle = group(0.82, 1.18, 0.18, carrier);
carriedBundle.rotation.z = -0.12;
for (let i = 0; i < 5; i++) {
cuboid(
0.78,
0.026,
1.02,
(random() - 0.5) * 0.035,
i * 0.028,
(random() - 0.5) * 0.035,
i === 4 ? M.paper : M.paperEdge,
carriedBundle
);
}
cuboid(0.8, 0.045, 0.06, 0, 0.13, 0.3, M.paperEdge, carriedBundle);
cuboid(0.06, 0.045, 1.02, 0, 0.13, 0, M.paperEdge, carriedBundle);
// Public posting board.
const board = group(7.05, 0, -5.84);
cuboid(0.27, 4.45, 0.3, -1.08, 2.25, 0, M.darkWood, board);
cuboid(0.27, 4.45, 0.3, 1.08, 2.25, 0, M.darkWood, board);
cuboid(2.75, 2.35, 0.22, 0, 3.05, 0, M.darkWood, board);
cuboid(2.48, 2.08, 0.09, 0, 3.05, 0.15, M.wood, board);
const postedNotice = makeSheet(
1.45,
1.92,
-0.5,
3.12,
0.215,
noticeTexture,
board,
true,
true
);
postedNotice.rotation.y = -0.015;
makeSheet(
0.82,
1.08,
0.68,
3.36,
0.225,
newsTexture,
board,
true
);
// Red sealing wax cubes used as pins.
for (const x of [-1.06, 0.05, 1.08]) {
for (const y of [4.02, 2.05]) {
cuboid(0.13, 0.13, 0.13, x, y, 0.25, M.red, board);
}
}
// A stool and a tied bundle beside the counter.
cuboid(0.85, 0.18, 0.72, 3.25, 0.72, 2.55, M.wood);
for (const x of [-0.3, 0.3]) {
for (const z of [-0.25, 0.25]) {
cuboid(0.16, 0.62, 0.16, 3.25 + x, 0.35, 2.55 + z, M.darkWood);
}
}
// -------------------------------------------------------------------------
// Additional workshop props
// -------------------------------------------------------------------------
// Shelf with folded sheets and bound folios.
cuboid(3.15, 0.17, 0.72, -0.9, 3.55, -5.82, M.wood);
for (let i = 0; i < 6; i++) {
cuboid(
0.33 + random() * 0.08,
0.65 + random() * 0.15,
0.52,
-2.15 + i * 0.48,
3.93,
-5.78,
i % 3 === 0 ? M.red : M.green
);
}
// Barrel-like storage built from square timber bands.
cuboid(1.1, 1.35, 1.1, 2.95, 0.7, -4.95, M.wood);
for (const y of [0.25, 0.72, 1.2]) {
cuboid(1.18, 0.09, 1.18, 2.95, y, -4.95, M.darkWood);
}
cuboid(1.22, 0.13, 1.22, 2.95, 1.42, -4.95, M.lightWood);
// Ink-stained work block and wiping cloths.
cuboid(0.78, 0.12, 0.62, -2.25, 1.78, 1.2, M.ink);
cuboid(0.62, 0.06, 0.42, -1.63, 1.76, 1.3, M.paperEdge);
cuboid(0.48, 0.05, 0.35, -1.55, 1.81, 1.28, M.paper);
// -------------------------------------------------------------------------
// Camera controls: custom orbit, zoom, and animated focus views
// -------------------------------------------------------------------------
const focusViews = {
overview: {
position: new THREE.Vector3(12.8, 9.2, 15.4),
target: new THREE.Vector3(-0.1, 1.7, -0.55)
},
press: {
position: new THREE.Vector3(1.8, 6.2, 2.8),
target: new THREE.Vector3(-4.55, 2.35, -3.25)
},
type: {
position: new THREE.Vector3(0.8, 4.3, 5.25),
target: new THREE.Vector3(-4.15, 1.55, 0.7)
},
distribution: {
position: new THREE.Vector3(11.3, 5.7, 6.7),
target: new THREE.Vector3(5.3, 1.55, -0.7)
}
};
const orbit = {
current: {
theta: 0,
phi: 0,
radius: 20,
target: focusViews.overview.target.clone()
},
desired: {
theta: 0,
phi: 0,
radius: 20,
target: focusViews.overview.target.clone()
}
};
const offset = new THREE.Vector3();
function setFocus(name, immediate = false) {
const view = focusViews[name];
if (!view) return;
orbit.desired.target.copy(view.target);
offset.copy(view.position).sub(view.target);
orbit.desired.radius = offset.length();
orbit.desired.phi = Math.acos(
THREE.MathUtils.clamp(offset.y / orbit.desired.radius, -1, 1)
);
orbit.desired.theta = Math.atan2(offset.x, offset.z);
if (immediate) {
orbit.current.theta = orbit.desired.theta;
orbit.current.phi = orbit.desired.phi;
orbit.current.radius = orbit.desired.radius;
orbit.current.target.copy(orbit.desired.target);
}
document.querySelectorAll("[data-focus]").forEach((button) => {
button.setAttribute(
"aria-pressed",
String(button.dataset.focus === name)
);
});
}
setFocus("overview", true);
let dragging = false;
let pointerMoved = false;
let previousX = 0;
let previousY = 0;
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
pointerMoved = false;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (dragging) {
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
if (Math.abs(dx) + Math.abs(dy) > 2) {
pointerMoved = true;
}
orbit.desired.theta -= dx * 0.006;
orbit.desired.phi = THREE.MathUtils.clamp(
orbit.desired.phi - dy * 0.005,
0.42,
1.39
);
previousX = event.clientX;
previousY = event.clientY;
} else {
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveSheets, false);
renderer.domElement.style.cursor = hits.length ? "pointer" : "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (!pointerMoved) {
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(interactiveSheets, false);
if (hits.length) {
openNotice();
}
}
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.desired.radius = THREE.MathUtils.clamp(
orbit.desired.radius * Math.exp(event.deltaY * 0.001),
7.2,
28
);
},
{ passive: false }
);
document.querySelectorAll("[data-focus]").forEach((button) => {
button.addEventListener("click", () => {
setFocus(button.dataset.focus);
});
});
// -------------------------------------------------------------------------
// Notice dialog
// -------------------------------------------------------------------------
const modal = document.querySelector("#notice-modal");
const readButton = document.querySelector("#read-notice");
const closeButton = document.querySelector("#close-notice");
function openNotice() {
modal.classList.add("open");
closeButton.focus();
}
function closeNotice() {
modal.classList.remove("open");
readButton.focus();
}
readButton.addEventListener("click", openNotice);
closeButton.addEventListener("click", closeNotice);
modal.addEventListener("click", (event) => {
if (event.target === modal) closeNotice();
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape" && modal.classList.contains("open")) {
closeNotice();
}
});
// -------------------------------------------------------------------------
// Ambient press motion
// -------------------------------------------------------------------------
const reducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let motionEnabled = !reducedMotion;
const motionButton = document.querySelector("#motion-toggle");
function updateMotionButton() {
motionButton.textContent = motionEnabled ? "Pause motion" : "Resume motion";
motionButton.setAttribute("aria-pressed", String(motionEnabled));
}
motionButton.addEventListener("click", () => {
motionEnabled = !motionEnabled;
updateMotionButton();
});
updateMotionButton();
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const smoothing = 1 - Math.exp(-delta * 5.5);
orbit.current.theta +=
(orbit.desired.theta - orbit.current.theta) * smoothing;
orbit.current.phi +=
(orbit.desired.phi - orbit.current.phi) * smoothing;
orbit.current.radius +=
(orbit.desired.radius - orbit.current.radius) * smoothing;
orbit.current.target.lerp(
orbit.desired.target,
smoothing
);
const sinPhi = Math.sin(orbit.current.phi);
camera.position.set(
orbit.current.target.x +
orbit.current.radius * sinPhi * Math.sin(orbit.current.theta),
orbit.current.target.y +
orbit.current.radius * Math.cos(orbit.current.phi),
orbit.current.target.z +
orbit.current.radius * sinPhi * Math.cos(orbit.current.theta)
);
camera.lookAt(orbit.current.target);
if (motionEnabled) {
const cycle = (elapsed % 5.2) / 5.2;
let pressAmount = 0;
if (cycle < 0.3) {
const p = cycle / 0.3;
pressAmount = p * p * (3 - 2 * p);
}
platen.position.y = 3.12 - pressAmount * 1.25;
} else {
platen.position.y = 3.12;
}
renderer.render(scene, camera);
}
animate();
requestAnimationFrame(() => {
loading.classList.add("hidden");
window.setTimeout(() => loading.remove(), 600);
});
</script>
</body>
</html>
```