Prompt specification
Build or customize the Three.js 3D scene "Traveling filled-dough exhibition" 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: Traveling filled-dough exhibition
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/traveling-filled-dough-exhibition-x0100
Scene Description Prompt:
Create a standalone low-poly scene in one HTML file using Three.js from cdnjs. Build three museum tables comparing differently shaped filled dough parcels; use generic preparation diagrams and labeled cultural references to show shared enclosure ideas without claiming identical recipes.
Working Three.js Starter (traveling-filled-dough-exhibition-x0100):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Enclosure Table — A Museum of Filled Dough Parcels</title>
<style>
:root {
--paper: #f5f0e6;
--ink: #263029;
--muted: #6e746d;
--line: rgba(38, 48, 41, 0.17);
--accent: #a76749;
--shadow: 0 18px 50px rgba(40, 42, 35, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e7e1d5;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#stage,
#canvas {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
}
#canvas {
display: block;
outline: none;
touch-action: none;
cursor: grab;
}
#canvas.dragging {
cursor: grabbing;
}
.hero {
position: fixed;
z-index: 5;
top: 26px;
left: 30px;
width: min(490px, calc(100vw - 60px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 9px;
color: #59625a;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
width: 26px;
height: 2px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(37px, 4.6vw, 66px);
font-weight: 500;
line-height: 0.93;
letter-spacing: -0.045em;
}
.hero p {
max-width: 430px;
margin: 15px 0 0;
color: #596159;
font-size: 14px;
line-height: 1.55;
}
.hero .theme-line {
display: inline-block;
margin-top: 14px;
padding: 7px 10px 6px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(245, 240, 230, 0.68);
color: #475149;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
backdrop-filter: blur(8px);
}
.controls {
position: fixed;
z-index: 10;
top: 25px;
right: 27px;
display: flex;
gap: 8px;
}
.control-button {
min-height: 38px;
padding: 0 14px;
border: 1px solid rgba(38, 48, 41, 0.19);
border-radius: 999px;
background: rgba(246, 241, 231, 0.88);
box-shadow: 0 5px 20px rgba(48, 47, 39, 0.07);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.04em;
transition: background 160ms ease, transform 160ms ease;
backdrop-filter: blur(10px);
}
.control-button:hover,
.control-button:focus-visible {
background: #fffaf0;
transform: translateY(-1px);
outline: none;
}
.control-button[aria-pressed="false"] {
opacity: 0.56;
}
#markers {
position: fixed;
z-index: 4;
inset: 0;
overflow: hidden;
pointer-events: none;
transition: opacity 180ms ease;
}
body.no-markers #markers {
opacity: 0;
}
.marker {
position: absolute;
display: grid;
grid-template-columns: 29px 1fr;
grid-template-rows: auto auto;
column-gap: 9px;
min-width: 172px;
padding: 9px 12px 9px 9px;
border: 1px solid rgba(38, 48, 41, 0.17);
border-radius: 11px;
background: rgba(250, 246, 237, 0.91);
box-shadow: 0 10px 30px rgba(46, 44, 35, 0.13);
opacity: 0;
text-align: left;
transform: translate(-50%, -100%);
transition: opacity 140ms ease, background 140ms ease, box-shadow 140ms ease;
pointer-events: auto;
cursor: pointer;
backdrop-filter: blur(9px);
}
.marker.visible {
opacity: 1;
}
.marker:hover,
.marker:focus-visible,
.marker.active {
background: #fffaf1;
box-shadow: 0 14px 36px rgba(46, 44, 35, 0.19);
outline: none;
}
.marker-index {
grid-row: 1 / 3;
display: grid;
place-items: center;
width: 29px;
height: 29px;
border-radius: 50%;
background: var(--marker-accent);
color: #fffaf2;
font-family: Georgia, serif;
font-size: 13px;
}
.marker strong {
align-self: end;
font-family: Georgia, "Times New Roman", serif;
font-size: 14px;
font-weight: 600;
line-height: 1.1;
}
.marker small {
margin-top: 2px;
color: #777c75;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#compare {
position: fixed;
z-index: 8;
bottom: 24px;
left: 50%;
display: flex;
align-items: center;
gap: 4px;
padding: 5px;
border: 1px solid rgba(38, 48, 41, 0.17);
border-radius: 999px;
background: rgba(247, 242, 232, 0.88);
box-shadow: var(--shadow);
transform: translateX(-50%);
backdrop-filter: blur(12px);
}
.compare-label {
padding: 0 10px;
color: #777c75;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.compare-button {
display: flex;
align-items: center;
gap: 7px;
padding: 8px 11px;
border: 0;
border-radius: 999px;
background: transparent;
color: #424a43;
cursor: pointer;
font-size: 10px;
font-weight: 750;
transition: background 150ms ease, color 150ms ease;
}
.compare-button:hover,
.compare-button:focus-visible,
.compare-button.active {
background: #fffdf6;
color: #1f2721;
outline: none;
}
.compare-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--dot);
}
#hint {
position: fixed;
z-index: 5;
right: 27px;
bottom: 26px;
color: rgba(47, 55, 48, 0.65);
font-size: 10px;
letter-spacing: 0.025em;
pointer-events: none;
}
#panel {
position: fixed;
z-index: 20;
top: 84px;
right: 24px;
bottom: 24px;
width: min(380px, calc(100vw - 48px));
padding: 25px 24px 22px;
overflow-y: auto;
border: 1px solid rgba(38, 48, 41, 0.17);
border-radius: 18px;
background: rgba(249, 245, 236, 0.96);
box-shadow: 0 28px 80px rgba(40, 42, 35, 0.2);
transform: translateX(calc(100% + 45px));
opacity: 0;
transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
opacity 180ms ease;
backdrop-filter: blur(18px);
}
#panel.open {
transform: translateX(0);
opacity: 1;
}
.panel-close {
position: absolute;
top: 16px;
right: 16px;
width: 31px;
height: 31px;
border: 1px solid var(--line);
border-radius: 50%;
background: transparent;
color: #596159;
cursor: pointer;
font-size: 18px;
line-height: 1;
}
.panel-close:hover,
.panel-close:focus-visible {
background: #fffdf7;
outline: none;
}
.panel-kicker {
margin-bottom: 8px;
color: var(--panel-accent);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
#panel h2 {
max-width: 280px;
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 35px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.035em;
}
#panel-description {
margin: 13px 0 22px;
color: #626961;
font-size: 13px;
line-height: 1.6;
}
.section-heading {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 10px;
margin-bottom: 9px;
padding-top: 17px;
border-top: 1px solid var(--line);
color: #394139;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.section-heading span {
color: #969991;
font-size: 8px;
font-weight: 750;
letter-spacing: 0.08em;
text-align: right;
}
.process-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 5px;
}
.process-step {
min-width: 0;
padding: 7px 3px 6px;
border: 1px solid rgba(38, 48, 41, 0.11);
border-radius: 9px;
background: #fffdf7;
text-align: center;
}
.process-step svg {
display: block;
width: 100%;
height: 54px;
margin-bottom: 3px;
}
.process-step span {
display: block;
color: #6c726b;
font-size: 8px;
font-weight: 750;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.diagram-dough {
fill: #e1b36f;
stroke: #9f7643;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.diagram-line {
fill: none;
stroke: #647067;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
}
.diagram-fill {
fill: #b96545;
stroke: none;
}
.diagram-arrow {
fill: #a0a49d;
}
.cultural-card {
margin-top: 10px;
padding: 15px;
border-left: 3px solid var(--panel-accent);
border-radius: 0 10px 10px 0;
background: rgba(229, 224, 211, 0.43);
}
.cultural-card .label {
margin-bottom: 6px;
color: #777c74;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.cultural-card h3 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 17px;
font-weight: 600;
line-height: 1.25;
}
.cultural-card p {
margin: 8px 0 0;
color: #626861;
font-size: 11px;
line-height: 1.55;
}
.caution {
margin-top: 11px;
padding: 13px 14px;
border: 1px solid rgba(149, 102, 67, 0.22);
border-radius: 10px;
background: rgba(207, 167, 112, 0.1);
color: #6f6253;
font-size: 10px;
line-height: 1.55;
}
.caution strong {
color: #4e473e;
}
.view-all {
width: 100%;
margin-top: 17px;
padding: 11px 14px;
border: 0;
border-radius: 10px;
background: #334038;
color: #fffaf0;
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: background 150ms ease, transform 150ms ease;
}
.view-all:hover,
.view-all:focus-visible {
background: #243029;
transform: translateY(-1px);
outline: none;
}
#loading {
position: fixed;
z-index: 100;
inset: 0;
display: grid;
place-items: center;
background: #e7e1d5;
color: #4e5a51;
font-family: Georgia, serif;
font-size: 19px;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.done {
visibility: hidden;
opacity: 0;
}
@media (max-width: 900px) {
.hero {
top: 20px;
left: 20px;
}
.hero p {
max-width: 330px;
font-size: 12px;
}
.controls {
top: 18px;
right: 18px;
}
#hint {
display: none;
}
#compare {
bottom: 15px;
}
}
@media (max-width: 680px) {
.hero {
width: calc(100vw - 38px);
}
.hero p {
display: none;
}
.hero .theme-line {
margin-top: 10px;
padding: 5px 8px;
font-size: 8px;
}
h1 {
max-width: 260px;
font-size: 39px;
}
.controls {
top: auto;
right: 14px;
bottom: 76px;
flex-direction: column;
}
.control-button {
min-height: 32px;
padding: 0 10px;
font-size: 9px;
}
#compare {
right: 12px;
bottom: 12px;
left: 12px;
justify-content: center;
transform: none;
}
.compare-label {
display: none;
}
.compare-button {
padding: 8px 9px;
font-size: 9px;
}
.marker {
min-width: 145px;
grid-template-columns: 24px 1fr;
padding: 7px 9px 7px 7px;
}
.marker-index {
width: 24px;
height: 24px;
font-size: 11px;
}
.marker strong {
font-size: 12px;
}
.marker small {
display: none;
}
#panel {
top: auto;
right: 0;
bottom: 0;
left: 0;
width: 100%;
max-height: 76vh;
border-right: 0;
border-bottom: 0;
border-left: 0;
border-radius: 20px 20px 0 0;
transform: translateY(105%);
}
#panel.open {
transform: translateY(0);
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<div id="stage">
<canvas id="canvas" aria-label="Interactive low-poly museum gallery with three tables displaying filled dough parcels"></canvas>
</div>
<header class="hero">
<div class="eyebrow">A museum of everyday choices</div>
<h1>The enclosure table</h1>
<p>
Three filled-dough forms, compared as geometry—not as interchangeable recipes.
The shared move is simple: wrap, fill, close, and mark.
</p>
<div class="theme-line">Shape study · 03 forms</div>
</header>
<div class="controls">
<button class="control-button" id="reset-view" type="button">Reset view</button>
<button class="control-button" id="toggle-labels" type="button" aria-pressed="true">Labels</button>
</div>
<div id="markers" aria-label="Exhibit labels"></div>
<nav id="compare" aria-label="Compare the three parcel shapes">
<span class="compare-label">Compare forms</span>
<button class="compare-button" type="button" data-index="0" style="--dot:#a76749">
<span class="compare-dot"></span>Round
</button>
<button class="compare-button" type="button" data-index="1" style="--dot:#647a6a">
<span class="compare-dot"></span>Crescent
</button>
<button class="compare-button" type="button" data-index="2" style="--dot:#617b8b">
<span class="compare-dot"></span>Pouch
</button>
</nav>
<div id="hint">Drag to orbit · right-drag to pan · scroll to zoom</div>
<aside id="panel" role="dialog" aria-label="Exhibit details">
<button class="panel-close" id="close-panel" type="button" aria-label="Close exhibit details">×</button>
<div class="panel-kicker" id="panel-kicker"></div>
<h2 id="panel-title"></h2>
<p id="panel-description"></p>
<div class="section-heading">
Generic preparation diagram
<span>Shape logic, not a recipe</span>
</div>
<div class="process-grid" id="process-grid"></div>
<div class="section-heading">Cultural reference</div>
<div class="cultural-card">
<div class="label">Reference anchor</div>
<h3 id="panel-reference"></h3>
<p id="panel-reference-text"></p>
</div>
<div class="caution">
<strong>Not the same food.</strong>
These are independent cultural references, not evidence of a shared origin,
direct transmission, or interchangeable recipes. Ingredients, fillings,
doughs, cooking methods, names, and social meanings remain community-specific.
</div>
<button class="view-all" id="view-all" type="button">Return to the full table</button>
</aside>
<div id="loading">Preparing the gallery…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const canvas = document.querySelector("#canvas");
const loading = document.querySelector("#loading");
const markersLayer = document.querySelector("#markers");
const panel = document.querySelector("#panel");
const processGrid = document.querySelector("#process-grid");
const compareButtons = [...document.querySelectorAll(".compare-button")];
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const exhibits = [
{
id: "round",
title: "Gathered round",
subtitle: "Radial pinch",
form: "round",
accent: "#a76749",
x: -5,
description:
"A broad, domed wrapper is gathered toward a small crown. The radiating pinch gives the parcel a centered, compact silhouette.",
steps: ["Portion", "Fill", "Gather", "Pinch"],
reference: "Chinese baozi traditions · filled steamed buns",
referenceText:
"Chinese baozi are pleated filled buns with many regional variations. This model borrows only the broad gathered geometry, not a particular filling, dough, fold pattern, or steaming method."
},
{
id: "crescent",
title: "Crescent parcel",
subtitle: "Curved edge",
form: "crescent",
accent: "#647a6a",
x: 0,
description:
"A folded wrapper forms a long curved body. Small repeated marks along the outer edge make the closure visible as a rhythm of impressions.",
steps: ["Portion", "Fill", "Fold", "Crimp"],
reference: "Empanada form families · Iberia and Latin America",
referenceText:
"Empanadas take many forms across Iberia and Latin America. The crescent is one visible branch of that larger family; names, fillings, doughs, folds, and cooking methods vary by place and tradition."
},
{
id: "pouch",
title: "Pleated pouch",
subtitle: "Pinched neck",
form: "pouch",
accent: "#617b8b",
x: 5,
description:
"The wrapper rises around a central filling and narrows into a pinched neck. Pleats gather above the body and make the final closure legible.",
steps: ["Portion", "Fill", "Cup", "Gather"],
reference: "Momo form families · Himalayan and South Asian communities",
referenceText:
"Momos and related filled dumplings use pleated or pouch-like wrappers in Himalayan and South Asian cuisines. Their proportions, fillings, sizes, cooking methods, and cultural roles are not uniform."
}
];
let renderer;
try {
renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
} catch (error) {
loading.textContent = "This gallery requires WebGL to be enabled.";
throw error;
}
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color("#e7e1d5");
scene.fog = new THREE.Fog("#e7e1d5", 18, 34);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
80
);
const cameraState = {
target: new THREE.Vector3(0, 1.2, -0.8),
goalTarget: new THREE.Vector3(0, 1.2, -0.8),
radius: 15.4,
goalRadius: 15.4,
theta: 0,
goalTheta: 0,
phi: 1.16,
goalPhi: 1.16
};
const hemi = new THREE.HemisphereLight("#fff8e8", "#857c6c", 2.25);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff2d5", 3.1);
sun.position.set(-7, 11, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fillLight = new THREE.DirectionalLight("#dce8e5", 0.75);
fillLight.position.set(8, 5, -3);
scene.add(fillLight);
const materials = {
floor: new THREE.MeshStandardMaterial({
color: "#cfc7b7",
roughness: 0.98,
metalness: 0
}),
wall: new THREE.MeshStandardMaterial({
color: "#e5ded1",
roughness: 1
}),
frame: new THREE.MeshStandardMaterial({
color: "#9c9588",
roughness: 0.92
}),
wood: new THREE.MeshStandardMaterial({
color: "#9a6d4e",
roughness: 0.82
}),
woodDark: new THREE.MeshStandardMaterial({
color: "#74503b",
roughness: 0.9
}),
dough: new THREE.MeshStandardMaterial({
color: "#d9aa64",
roughness: 0.9,
flatShading: true
}),
doughLight: new THREE.MeshStandardMaterial({
color: "#e4b875",
roughness: 0.92,
flatShading: true
}),
doughDark: new THREE.MeshStandardMaterial({
color: "#b98548",
roughness: 0.94,
flatShading: true
}),
ceramic: new THREE.MeshStandardMaterial({
color: "#b87559",
roughness: 0.72,
flatShading: true
}),
filling: new THREE.MeshStandardMaterial({
color: "#687453",
roughness: 1,
flatShading: true
})
};
const clickableMeshes = [];
const markerEntries = [];
function addBox(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
radialSegments,
position,
material
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
radialSegments
),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function createGallery() {
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(42, 30),
materials.floor
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.015;
floor.receiveShadow = true;
scene.add(floor);
const backWall = new THREE.Mesh(
new THREE.PlaneGeometry(30, 9),
materials.wall
);
backWall.position.set(0, 4.45, -7.45);
backWall.receiveShadow = true;
scene.add(backWall);
addBox(
scene,
[30, 0.24, 0.14],
[0, 0.13, -7.28],
materials.frame,
false
);
const panelColors = ["#ddd3c3", "#d8ddd3", "#d9cfc7"];
const accentColors = ["#b77c5d", "#7c9180", "#71899a"];
exhibits.forEach((exhibit, index) => {
const panelMaterial = new THREE.MeshStandardMaterial({
color: panelColors[index],
roughness: 1
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: accentColors[index],
roughness: 0.9
});
addBox(
scene,
[4.15, 5.35, 0.08],
[exhibit.x, 3.08, -7.32],
panelMaterial,
false
);
addBox(
scene,
[4.28, 0.045, 0.05],
[exhibit.x, 5.76, -7.24],
accentMaterial,
false
);
addBox(
scene,
[0.035, 5.2, 0.05],
[exhibit.x - 2.08, 3.08, -7.23],
materials.frame,
false
);
addBox(
scene,
[0.035, 5.2, 0.05],
[exhibit.x + 2.08, 3.08, -7.23],
materials.frame,
false
);
const inlay = new THREE.Mesh(
new THREE.CircleGeometry(2.35, 48),
new THREE.MeshStandardMaterial({
color: index === 1 ? "#c9c6b7" : "#c8bda9",
roughness: 1
})
);
inlay.rotation.x = -Math.PI / 2;
inlay.position.set(exhibit.x, 0.002, -0.78);
inlay.receiveShadow = true;
scene.add(inlay);
const ring = new THREE.Mesh(
new THREE.RingGeometry(2.28, 2.31, 48),
new THREE.MeshStandardMaterial({
color: accentColors[index],
roughness: 0.9,
side: THREE.DoubleSide
})
);
ring.rotation.x = -Math.PI / 2;
ring.position.set(exhibit.x, 0.008, -0.78);
scene.add(ring);
});
createWallTitle();
}
function createWallTitle() {
const titleCanvas = document.createElement("canvas");
titleCanvas.width = 1600;
titleCanvas.height = 280;
const ctx = titleCanvas.getContext("2d");
ctx.clearRect(0, 0, 1600, 280);
ctx.fillStyle = "rgba(38, 48, 41, 0.9)";
ctx.textAlign = "center";
ctx.font = "500 76px Georgia";
ctx.fillText("THE ENCLOSURE TABLE", 800, 115);
ctx.fillStyle = "rgba(80, 89, 80, 0.72)";
ctx.font = "700 22px sans-serif";
ctx.fillText("THREE FORM STUDIES / GEOMETRY, NOT LINEAGE", 800, 175);
const texture = new THREE.CanvasTexture(titleCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const title = new THREE.Mesh(
new THREE.PlaneGeometry(8.8, 1.54),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
title.position.set(0, 6.25, -7.18);
scene.add(title);
}
function createParcel(exhibit) {
const group = new THREE.Group();
if (exhibit.form === "round") {
const profile = [
new THREE.Vector2(0, 0),
new THREE.Vector2(0.38, 0),
new THREE.Vector2(0.72, 0.08),
new THREE.Vector2(0.98, 0.28),
new THREE.Vector2(1.02, 0.52),
new THREE.Vector2(0.88, 0.76),
new THREE.Vector2(0.58, 0.96),
new THREE.Vector2(0.22, 1.04),
new THREE.Vector2(0, 1.05)
];
const body = new THREE.Mesh(
new THREE.LatheGeometry(profile, 16),
materials.dough
);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const seam = new THREE.Mesh(
new THREE.TorusGeometry(0.69, 0.045, 5, 24),
materials.doughDark
);
seam.rotation.x = Math.PI / 2;
seam.position.y = 0.72;
seam.castShadow = true;
group.add(seam);
const pleatGeometry = new THREE.ConeGeometry(0.095, 0.38, 5);
const up = new THREE.Vector3(0, 1, 0);
for (let i = 0; i < 12; i++) {
const angle = (i / 12) * Math.PI * 2;
const outer = new THREE.Vector3(
Math.cos(angle) * 0.68,
0.76,
Math.sin(angle) * 0.68
);
const inner = new THREE.Vector3(
Math.cos(angle) * 0.14,
1.08,
Math.sin(angle) * 0.14
);
const direction = inner.clone().sub(outer).normalize();
const pleat = new THREE.Mesh(pleatGeometry, materials.doughLight);
pleat.position.copy(outer).add(inner).multiplyScalar(0.5);
pleat.quaternion.setFromUnitVectors(up, direction);
pleat.castShadow = true;
group.add(pleat);
}
}
if (exhibit.form === "crescent") {
const shape = new THREE.Shape();
shape.moveTo(-1.15, 0);
shape.quadraticCurveTo(0, 1.85, 1.15, 0);
shape.quadraticCurveTo(0, 0.48, -1.15, 0);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: 0.24,
bevelEnabled: true,
bevelSegments: 1,
steps: 1,
bevelSize: 0.045,
bevelThickness: 0.04,
curveSegments: 10
});
const oriented = new THREE.Group();
oriented.rotation.x = -Math.PI / 2;
const body = new THREE.Mesh(geometry, materials.dough);
body.castShadow = true;
body.receiveShadow = true;
oriented.add(body);
const outerCurve = new THREE.QuadraticBezierCurve3(
new THREE.Vector3(-1.15, 0, 0),
new THREE.Vector3(0, 1.85, 0),
new THREE.Vector3(1.15, 0, 0)
);
const beadGeometry = new THREE.SphereGeometry(1, 8, 5);
for (let i = 0; i < 13; i++) {
const point = outerCurve.getPoint(i / 12);
const bead = new THREE.Mesh(beadGeometry, materials.doughLight);
bead.position.set(point.x, point.y, 0.29);
bead.scale.set(0.105, 0.16, 0.09);
bead.castShadow = true;
oriented.add(bead);
}
const innerCurve = new THREE.QuadraticBezierCurve3(
new THREE.Vector3(1.15, 0, 0),
new THREE.Vector3(0, 0.48, 0),
new THREE.Vector3(-1.15, 0, 0)
);
for (let i = 1; i < 8; i++) {
const point = innerCurve.getPoint(i / 8);
const bead = new THREE.Mesh(beadGeometry, materials.doughDark);
bead.position.set(point.x, point.y, 0.285);
bead.scale.set(0.085, 0.11, 0.065);
bead.castShadow = true;
oriented.add(bead);
}
group.add(oriented);
}
if (exhibit.form === "pouch") {
const profile = [
new THREE.Vector2(0, 0),
new THREE.Vector2(0.38, 0),
new THREE.Vector2(0.72, 0.12),
new THREE.Vector2(0.87, 0.42),
new THREE.Vector2(0.8, 0.78),
new THREE.Vector2(0.62, 1.05),
new THREE.Vector2(0.35, 1.28),
new THREE.Vector2(0.18, 1.38),
new THREE.Vector2(0, 1.4)
];
const body = new THREE.Mesh(
new THREE.LatheGeometry(profile, 14),
materials.dough
);
body.castShadow = true;
body.receiveShadow = true;
group.add(body);
const neck = new THREE.Mesh(
new THREE.TorusGeometry(0.29, 0.055, 5, 18),
materials.doughDark
);
neck.rotation.x = Math.PI / 2;
neck.position.y = 1.28;
neck.castShadow = true;
group.add(neck);
const pleatGeometry = new THREE.ConeGeometry(0.085, 0.34, 5);
const up = new THREE.Vector3(0, 1, 0);
for (let i = 0; i < 9; i++) {
const angle = (i / 9) * Math.PI * 2;
const outer = new THREE.Vector3(
Math.cos(angle) * 0.31,
1.28,
Math.sin(angle) * 0.31
);
const inner = new THREE.Vector3(
Math.cos(angle) * 0.06,
1.53,
Math.sin(angle) * 0.06
);
const direction = inner.clone().sub(outer).normalize();
const pleat = new THREE.Mesh(pleatGeometry, materials.doughLight);
pleat.position.copy(outer).add(inner).multiplyScalar(0.5);
pleat.quaternion.setFromUnitVectors(up, direction);
pleat.castShadow = true;
group.add(pleat);
}
}
return group;
}
function drawMiniShape(ctx, form, x, y, radius, color) {
ctx.save();
ctx.translate(x, y);
ctx.strokeStyle = color;
ctx.fillStyle = "rgba(215, 173, 105, 0.72)";
ctx.lineWidth = 4;
ctx.lineCap = "round";
ctx.lineJoin = "round";
if (form === "round") {
ctx.beginPath();
ctx.arc(0, 0, radius, 0, Math.PI * 2);
ctx.fill();
ctx.stroke();
for (let i = 0; i < 8; i++) {
const angle = (i / 8) * Math.PI * 2;
ctx.beginPath();
ctx.moveTo(Math.cos(angle) * radius * 0.78, Math.sin(angle) * radius * 0.78);
ctx.lineTo(Math.cos(angle) * radius * 0.18, Math.sin(angle) * radius * 0.18);
ctx.stroke();
}
} else if (form === "crescent") {
ctx.beginPath();
ctx.moveTo(-radius, radius * 0.35);
ctx.quadraticCurveTo(0, -radius * 1.45, radius, radius * 0.35);
ctx.quadraticCurveTo(0, -radius * 0.2, -radius, radius * 0.35);
ctx.closePath();
ctx.fill();
ctx.stroke();
} else {
ctx.beginPath();
ctx.moveTo(-radius * 0.65, radius);
ctx.quadraticCurveTo(-radius, -radius * 0.5, -radius * 0.34, -radius);
ctx.lineTo(radius * 0.34, -radius);
ctx.quadraticCurveTo(radius, -radius * 0.5, radius * 0.65, radius);
ctx.closePath();
ctx.fill();
ctx.stroke();
for (let i = -2; i <= 2; i++) {
ctx.beginPath();
ctx.moveTo(i * radius * 0.12, -radius * 0.85);
ctx.lineTo(i * radius * 0.07, -radius * 1.18);
ctx.stroke();
}
}
ctx.restore();
}
function createTableSign(exhibit, index) {
const signCanvas = document.createElement("canvas");
signCanvas.width = 1400;
signCanvas.height = 360;
const ctx = signCanvas.getContext("2d");
ctx.fillStyle = "#f4eee2";
ctx.fillRect(0, 0, 1400, 360);
ctx.strokeStyle = "#b8afa0";
ctx.lineWidth = 5;
ctx.strokeRect(9, 9, 1382, 342);
ctx.fillStyle = exhibit.accent;
ctx.fillRect(0, 0, 22, 360);
ctx.fillStyle = "#313a32";
ctx.textAlign = "left";
ctx.font = "700 23px sans-serif";
ctx.fillText(
`${String(index + 1).padStart(2, "0")} / ${exhibit.title.toUpperCase()}`,
60,
72
);
ctx.fillStyle = "#747b73";
ctx.font = "600 20px sans-serif";
ctx.fillText(exhibit.subtitle.toUpperCase() + " · SCHEMATIC FORM", 60, 110);
ctx.strokeStyle = "#c8bfb1";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(60, 142);
ctx.lineTo(880, 142);
ctx.stroke();
ctx.fillStyle = "#626b62";
ctx.font = "500 26px Georgia";
ctx.fillText(exhibit.reference.split("·")[0].trim(), 60, 197);
ctx.fillStyle = "#858a83";
ctx.font = "700 16px sans-serif";
ctx.fillText("SHAPE REFERENCE ONLY · NOT A RECIPE", 60, 247);
ctx.fillStyle = "#8b8f87";
ctx.font = "500 18px sans-serif";
ctx.fillText("wrapper → filling → enclosure → visible mark", 60, 293);
drawMiniShape(ctx, exhibit.form, 1120, 175, 115, exhibit.accent);
const texture = new THREE.CanvasTexture(signCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return new THREE.Mesh(
new THREE.PlaneGeometry(3.66, 0.94),
new THREE.MeshBasicMaterial({ map: texture })
);
}
function createTable(exhibit, index) {
const group = new THREE.Group();
group.position.set(exhibit.x, 0, -1);
addBox(group, [4.15, 0.18, 2.8], [0, 1.34, 0], materials.wood);
addBox(group, [4.25, 0.08, 2.9], [0, 1.22, 0], materials.woodDark);
const legPositions = [
[-1.7, 0.61, -1.02],
[1.7, 0.61, -1.02],
[-1.7, 0.61, 1.02],
[1.7, 0.61, 1.02]
];
legPositions.forEach((position) => {
addBox(group, [0.22, 1.22, 0.22], position, materials.woodDark);
});
const matMaterial = new THREE.MeshStandardMaterial({
color:
index === 0
? "#b88467"
: index === 1
? "#718273"
: "#718696",
roughness: 0.96
});
addBox(group, [2.78, 0.035, 1.85], [0, 1.455, -0.12], matMaterial);
addBox(group, [2.48, 0.045, 1.5], [0, 1.485, -0.15], materials.woodDark);
const parcel = createParcel(exhibit);
parcel.position.set(0, 1.515, -0.18);
parcel.traverse((child) => {
if (child.isMesh) {
child.userData.exhibitIndex = index;
clickableMeshes.push(child);
}
});
group.add(parcel);
const bowlMaterial = materials.ceramic.clone();
bowlMaterial.color.set(index === 0 ? "#b87657" : index === 1 ? "#6f8271" : "#647c8c");
addCylinder(group, 0.25, 0.18, 0.17, 10, [1.33, 1.58, -0.58], bowlMaterial);
const fillingTop = new THREE.Mesh(
new THREE.CylinderGeometry(0.215, 0.215, 0.025, 10),
materials.filling
);
fillingTop.position.set(1.33, 1.675, -0.58);
fillingTop.castShadow = true;
group.add(fillingTop);
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2;
const bit = new THREE.Mesh(
new THREE.BoxGeometry(0.07, 0.05, 0.06),
materials.filling
);
bit.position.set(
1.33 + Math.cos(angle) * 0.09,
1.71,
-0.58 + Math.sin(angle) * 0.09
);
bit.rotation.y = angle;
bit.castShadow = true;
group.add(bit);
}
const signBacking = addBox(
group,
[3.86, 1.05, 0.07],
[0, 0.88, 1.42],
materials.woodDark
);
signBacking.rotation.x = -0.12;
const sign = createTableSign(exhibit, index);
sign.position.set(0, 0.88, 1.465);
sign.rotation.x = -0.12;
group.add(sign);
scene.add(group);
const anchorHeight =
exhibit.form === "pouch" ? 3.45 : exhibit.form === "round" ? 3.22 : 2.82;
markerEntries.push({
exhibit,
index,
element: null,
anchor: new THREE.Vector3(exhibit.x, anchorHeight, -1)
});
}
function svgIcon(type) {
const commonArrow = `
<path class="diagram-arrow" d="M20 27h7l-2.5-2.5 1.4-1.4 5.1 5.1-5.1 5.1-1.4-1.4 2.5-2.5h-7z"/>
`;
if (type === "portion") {
return `
<svg viewBox="0 0 48 54" aria-hidden="true">
<ellipse class="diagram-dough" cx="17" cy="28" rx="12" ry="8"/>
<path class="diagram-line" d="M7 42h20M7 39v6M27 39v6"/>
</svg>`;
}
if (type === "fill") {
return `
<svg viewBox="0 0 48 54" aria-hidden="true">
<path class="diagram-line" d="M10 14c-2 17 5 25 14 25s16-8 14-25"/>
<circle class="diagram-fill" cx="24" cy="25" r="5"/>
<path class="diagram-line" d="M18 11l6-7 6 7"/>
</svg>`;
}
if (type === "enclose") {
return `
<svg viewBox="0 0 48 54" aria-hidden="true">
<path class="diagram-line" d="M7 37c2-17 9-25 17-25s15 8 17 25"/>
<path class="diagram-line" d="M11 35c7-9 19-9 26 0M17 25c5-4 9-4 14 0"/>
<circle class="diagram-fill" cx="24" cy="24" r="4"/>
</svg>`;
}
const finalShape = {
round: `
<circle class="diagram-dough" cx="24" cy="27" r="14"/>
<path class="diagram-line" d="M24 13v5M24 36v5M10 27h5M33 27h5M14 17l4 4M30 33l4 4M34 17l-4 4M18 33l-4 4"/>
`,
crescent: `
<path class="diagram-dough" d="M7 31C12 9 30 6 41 25 30 17 20 21 7 31z"/>
<path class="diagram-line" d="M10 29l3 2M15 23l3 2M21 18l2 3M28 16l1 3M35 18v3"/>
`,
pouch: `
<path class="diagram-dough" d="M10 41C8 26 14 17 19 13h10c5 4 11 13 9 28-5 5-13 5-18 0 5 0 10 0 10 0z"/>
<path class="diagram-line" d="M19 13l-2-6M24 13v-8M29 13l2-6M12 27h24"/>
`
}[type];
return `
<svg viewBox="0 0 48 54" aria-hidden="true">
${finalShape}
</svg>`;
}
function createDiagram(exhibit) {
const icons = ["portion", "fill", "enclose", exhibit.form];
processGrid.innerHTML = icons
.map(
(icon, index) => `
<div class="process-step">
${svgIcon(icon)}
<span>${index + 1} · ${exhibit.steps[index]}</span>
</div>
`
)
.join("");
}
createGallery();
exhibits.forEach(createTable);
function createMarker(entry) {
const button = document.createElement("button");
button.className = "marker";
button.type = "button";
button.style.setProperty("--marker-accent", entry.exhibit.accent);
button.setAttribute(
"aria-label",
`Open exhibit ${entry.index + 1}: ${entry.exhibit.title}`
);
button.innerHTML = `
<span class="marker-index">${String(entry.index + 1).padStart(2, "0")}</span>
<strong>${entry.exhibit.title}</strong>
<small>${entry.exhibit.subtitle}</small>
`;
button.addEventListener("click", () => openExhibit(entry.index));
markersLayer.appendChild(button);
entry.element = button;
}
markerEntries.forEach(createMarker);
let activeExhibit = -1;
function openExhibit(index) {
const exhibit = exhibits[index];
activeExhibit = index;
panel.style.setProperty("--panel-accent", exhibit.accent);
document.querySelector("#panel-kicker").textContent =
`Form study ${String(index + 1).padStart(2, "0")} · ${exhibit.subtitle}`;
document.querySelector("#panel-title").textContent = exhibit.title;
document.querySelector("#panel-description").textContent = exhibit.description;
document.querySelector("#panel-reference").textContent = exhibit.reference;
document.querySelector("#panel-reference-text").textContent =
exhibit.referenceText;
createDiagram(exhibit);
panel.classList.add("open");
panel.scrollTop = 0;
compareButtons.forEach((button, buttonIndex) => {
button.classList.toggle("active", buttonIndex === index);
});
markerEntries.forEach((entry) => {
entry.element.classList.toggle("active", entry.index === index);
});
focusExhibit(index);
}
function focusExhibit(index) {
const exhibit = exhibits[index];
cameraState.goalTarget.set(exhibit.x, 1.45, -1.0);
cameraState.goalRadius = 8.9;
cameraState.goalTheta = 0;
cameraState.goalPhi = 1.14;
}
function resetView() {
activeExhibit = -1;
cameraState.goalTarget.set(0, 1.2, -0.8);
cameraState.goalRadius = 15.4;
cameraState.goalTheta = 0;
cameraState.goalPhi = 1.16;
compareButtons.forEach((button) => button.classList.remove("active"));
markerEntries.forEach((entry) => entry.element.classList.remove("active"));
}
compareButtons.forEach((button) => {
button.addEventListener("click", () => {
openExhibit(Number(button.dataset.index));
});
});
document.querySelector("#reset-view").addEventListener("click", () => {
resetView();
panel.classList.remove("open");
});
document.querySelector("#close-panel").addEventListener("click", () => {
panel.classList.remove("open");
});
document.querySelector("#view-all").addEventListener("click", () => {
resetView();
panel.classList.remove("open");
});
document.querySelector("#toggle-labels").addEventListener("click", (event) => {
const button = event.currentTarget;
const enabled = button.getAttribute("aria-pressed") === "true";
button.setAttribute("aria-pressed", String(!enabled));
document.body.classList.toggle("no-markers", enabled);
});
/* Direct camera controls: no external controls module. */
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const pointers = new Map();
let interactionMode = null;
let pinchDistance = 0;
function updatePointerCoordinates(event) {
const rect = canvas.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function panCamera(deltaX, deltaY) {
camera.updateMatrixWorld();
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 0)
.setY(0)
.normalize();
const up = new THREE.Vector3()
.setFromMatrixColumn(camera.matrixWorld, 1)
.normalize();
const distance = cameraState.radius * 0.00125;
cameraState.goalTarget.addScaledVector(right, -deltaX * distance);
cameraState.goalTarget.addScaledVector(up, deltaY * distance);
cameraState.goalTarget.x = THREE.MathUtils.clamp(
cameraState.goalTarget.x,
-9,
9
);
cameraState.goalTarget.y = THREE.MathUtils.clamp(
cameraState.goalTarget.y,
0.2,
3.8
);
cameraState.goalTarget.z = THREE.MathUtils.clamp(
cameraState.goalTarget.z,
-4,
3
);
}
function currentPinchDistance() {
const values = [...pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
moved: 0
});
if (pointers.size === 1) {
interactionMode = event.button === 2 ? "pan" : "orbit";
} else if (pointers.size === 2) {
interactionMode = "pinch";
pinchDistance = currentPinchDistance();
}
canvas.classList.add("dragging");
});
canvas.addEventListener("pointermove", (event) => {
const tracked = pointers.get(event.pointerId);
if (!tracked) return;
const deltaX = event.clientX - tracked.x;
const deltaY = event.clientY - tracked.y;
tracked.x = event.clientX;
tracked.y = event.clientY;
tracked.moved += Math.abs(deltaX) + Math.abs(deltaY);
if (pointers.size === 1 && interactionMode === "orbit") {
cameraState.goalTheta -= deltaX * 0.006;
cameraState.goalPhi = THREE.MathUtils.clamp(
cameraState.goalPhi - deltaY * 0.005,
0.62,
1.46
);
} else if (pointers.size === 1 && interactionMode === "pan") {
panCamera(deltaX, deltaY);
} else if (pointers.size === 2 && interactionMode === "pinch") {
const distance = currentPinchDistance();
if (distance > 0 && pinchDistance > 0) {
cameraState.goalRadius = THREE.MathUtils.clamp(
cameraState.goalRadius * (pinchDistance / distance),
6.2,
23
);
}
pinchDistance = distance;
}
});
function finishPointer(event) {
const tracked = pointers.get(event.pointerId);
const shouldClick =
tracked &&
tracked.moved < 6 &&
pointers.size === 1 &&
interactionMode === "orbit";
pointers.delete(event.pointerId);
if (pointers.size === 0) {
interactionMode = null;
canvas.classList.remove("dragging");
} else if (pointers.size === 1) {
interactionMode = "orbit";
}
if (shouldClick) {
updatePointerCoordinates(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(clickableMeshes, false);
if (hits.length) {
const index = hits[0].object.userData.exhibitIndex;
openExhibit(index);
}
}
}
canvas.addEventListener("pointerup", finishPointer);
canvas.addEventListener("pointercancel", finishPointer);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.goalRadius = THREE.MathUtils.clamp(
cameraState.goalRadius + event.deltaY * 0.012,
6.2,
23
);
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
if (event.target instanceof HTMLButtonElement) return;
if (event.key === "ArrowLeft") {
cameraState.goalTheta -= 0.1;
} else if (event.key === "ArrowRight") {
cameraState.goalTheta += 0.1;
} else if (event.key === "ArrowUp") {
cameraState.goalPhi = THREE.MathUtils.clamp(
cameraState.goalPhi - 0.07,
0.62,
1.46
);
} else if (event.key === "ArrowDown") {
cameraState.goalPhi = THREE.MathUtils.clamp(
cameraState.goalPhi + 0.07,
0.62,
1.46
);
} else if (event.key === "+" || event.key === "=") {
cameraState.goalRadius = Math.max(6.2, cameraState.goalRadius - 0.8);
} else if (event.key === "-" || event.key === "_") {
cameraState.goalRadius = Math.min(23, cameraState.goalRadius + 0.8);
} else if (event.key.toLowerCase() === "r") {
resetView();
} else if (["1", "2", "3"].includes(event.key)) {
openExhibit(Number(event.key) - 1);
}
});
function shortestAngleDifference(from, to) {
return Math.atan2(Math.sin(from - to), Math.cos(from - to));
}
function updateCamera() {
const smoothing = reducedMotion ? 1 : 0.09;
cameraState.target.lerp(cameraState.goalTarget, smoothing);
cameraState.radius +=
(cameraState.goalRadius - cameraState.radius) * smoothing;
cameraState.theta +=
shortestAngleDifference(cameraState.goalTheta, cameraState.theta) *
smoothing;
cameraState.phi +=
(cameraState.goalPhi - cameraState.phi) * smoothing;
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x +
cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z +
cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
}
const projected = new THREE.Vector3();
function updateMarkers() {
markerEntries.forEach((entry) => {
projected.copy(entry.anchor).project(camera);
const onScreen =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.12 &&
projected.x < 1.12 &&
projected.y > -1.12 &&
projected.y < 1.12;
entry.element.classList.toggle("visible", onScreen);
if (onScreen) {
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
entry.element.style.left = `${x}px`;
entry.element.style.top = `${y}px`;
}
});
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
function animate() {
requestAnimationFrame(animate);
updateCamera();
updateMarkers();
renderer.render(scene, camera);
}
updateCamera();
animate();
requestAnimationFrame(() => {
loading.classList.add("done");
});
</script>
</body>
</html>
```