Prompt specification
Build or customize the Three.js 3D scene "Two Accounts of One Festival" inside the active workspace.
Engineering Constraints:
1. Runtime & Orbit: Use Three.js r160 with OrbitControls (damping enabled) and ACESFilmicToneMapping.
2. Frame Timing: Drive all motion strictly with clock.getDelta() so animation speed is FPS-independent.
3. Viewport Hygiene: Handle window resize cleanly, cap DPR at Math.min(window.devicePixelRatio, 2), and dispose geometries/materials/renderer on unmount.
Scene Metadata:
Scene: Two Accounts of One Festival
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/two-accounts-of-one-festival-x3210
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows community memory from partial and differing accounts. Create two small recollection displays focusing on different aspects of a fictional festival. Link shared facts while keeping personal viewpoints and unverified details explicitly separate. Voxel style.
Working Three.js Starter (two-accounts-of-one-festival-x3210):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Willow Lanterns — Community Memory</title>
<style>
:root {
--ink: #19342f;
--paper: #f5f0df;
--paper-strong: #fffaf0;
--green: #b9d3b0;
--green-dark: #477565;
--blue: #8bb7bd;
--orange: #d9855b;
--peach: #f3d7c4;
--muted: #60736e;
--shadow: rgba(25, 52, 47, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
min-height: 100%;
background: #dce6df;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
color: inherit;
}
button:focus-visible,
[tabindex]:focus-visible {
outline: 3px solid var(--orange);
outline-offset: 3px;
}
#app {
position: relative;
min-height: 100svh;
isolation: isolate;
}
#stage {
position: fixed;
inset: 0;
z-index: 0;
overflow: hidden;
background:
linear-gradient(rgba(255, 255, 255, 0.13) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.13) 1px, transparent 1px),
#dce6df;
background-size: 32px 32px;
}
#scene {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene:active {
cursor: grabbing;
}
.masthead {
position: fixed;
top: 24px;
left: 24px;
z-index: 6;
width: 340px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 10px;
color: var(--green-dark);
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(2.55rem, 4.5vw, 4.2rem);
font-weight: 500;
line-height: 0.86;
letter-spacing: -0.055em;
}
.lede {
max-width: 305px;
margin: 16px 0 0;
color: #405b55;
font-size: 0.94rem;
line-height: 1.45;
}
.case-meta {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 15px;
}
.case-meta span {
padding: 5px 7px;
border: 1px solid rgba(25, 52, 47, 0.35);
background: rgba(245, 240, 223, 0.62);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.63rem;
font-weight: 800;
letter-spacing: 0.08em;
}
.controls {
position: fixed;
top: 24px;
right: 24px;
z-index: 8;
display: flex;
gap: 8px;
}
.control-button {
min-height: 40px;
padding: 0 12px;
border: 2px solid var(--ink);
border-radius: 0;
background: rgba(245, 240, 223, 0.9);
box-shadow: 4px 4px 0 var(--ink);
cursor: pointer;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.67rem;
font-weight: 800;
letter-spacing: 0.05em;
text-transform: uppercase;
transition: transform 120ms ease, box-shadow 120ms ease;
}
.control-button:hover {
transform: translate(2px, 2px);
box-shadow: 2px 2px 0 var(--ink);
}
#shared-tray {
position: fixed;
top: 24px;
left: 50%;
z-index: 7;
display: flex;
align-items: stretch;
transform: translateX(-50%);
border: 2px solid var(--ink);
background: rgba(245, 240, 223, 0.94);
box-shadow: 6px 6px 0 var(--ink);
}
.tray-title {
display: flex;
align-items: center;
padding: 0 13px;
border-right: 2px solid var(--ink);
background: var(--green);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.66rem;
font-weight: 900;
letter-spacing: 0.1em;
white-space: nowrap;
}
.fact-button {
position: relative;
min-width: 108px;
padding: 12px 13px 11px;
border: 0;
border-right: 1px solid rgba(25, 52, 47, 0.22);
background: transparent;
cursor: pointer;
font-size: 0.72rem;
font-weight: 750;
line-height: 1.15;
text-align: left;
}
.fact-button:last-child {
border-right: 0;
}
.fact-button span {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.6rem;
letter-spacing: 0.1em;
}
.fact-button:hover {
background: rgba(185, 211, 176, 0.35);
}
.fact-button[aria-pressed="true"] {
background: var(--ink);
color: var(--paper-strong);
}
.fact-button[aria-pressed="true"] span {
color: var(--green);
}
#shared-detail {
position: fixed;
top: 102px;
left: 50%;
z-index: 6;
width: min(570px, calc(100vw - 32px));
transform: translateX(-50%);
padding: 13px 16px 14px;
border-left: 5px solid var(--green-dark);
background: rgba(255, 250, 240, 0.93);
box-shadow: 0 8px 24px var(--shadow);
pointer-events: none;
}
.detail-topline {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 5px;
color: var(--green-dark);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.62rem;
font-weight: 900;
letter-spacing: 0.1em;
text-transform: uppercase;
}
#shared-title {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 1.25rem;
font-weight: 600;
line-height: 1.15;
}
#shared-description {
margin: 6px 0 0;
color: #3e5650;
font-size: 0.79rem;
line-height: 1.4;
}
#shared-evidence {
margin-top: 7px;
color: var(--green-dark);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.62rem;
font-weight: 800;
letter-spacing: 0.03em;
}
#cards {
position: fixed;
right: 24px;
bottom: 24px;
left: 24px;
z-index: 7;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 28px;
pointer-events: none;
}
.memory-card {
position: relative;
width: min(350px, 29vw);
padding: 16px;
border: 2px solid var(--ink);
background: rgba(255, 250, 240, 0.95);
box-shadow: 7px 7px 0 var(--ink);
cursor: pointer;
pointer-events: auto;
transition:
transform 180ms ease,
box-shadow 180ms ease,
background 180ms ease;
}
.memory-card::before {
position: absolute;
top: -2px;
right: -2px;
left: -2px;
height: 6px;
background: var(--card-accent);
content: "";
}
.memory-card:hover {
transform: translate(-2px, -3px);
box-shadow: 10px 11px 0 var(--ink);
}
.memory-card.active {
transform: translate(-3px, -4px);
background: #fffdf5;
box-shadow: 11px 12px 0 var(--card-accent);
}
.card-mara {
--card-accent: var(--green-dark);
}
.card-toma {
--card-accent: var(--orange);
}
.card-kicker {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin: 2px 0 7px;
color: var(--card-accent);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.62rem;
font-weight: 900;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.memory-card h2 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: 1.55rem;
font-weight: 600;
line-height: 1.05;
}
.focus-line {
margin: 6px 0 13px;
color: var(--muted);
font-size: 0.73rem;
line-height: 1.35;
}
.memory-block {
margin-top: 9px;
padding: 10px 11px;
}
.shared-block {
border: 1px solid #a9c4aa;
border-left: 4px solid var(--green-dark);
background: #e9f0df;
}
.personal-block {
border: 1px dashed #b66d4b;
background: #f8e6d8;
}
.block-label {
display: block;
margin-bottom: 5px;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.58rem;
font-weight: 900;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.shared-block .block-label {
color: var(--green-dark);
}
.personal-block .block-label {
color: #a14f30;
}
.memory-block p {
margin: 0;
color: #354d47;
font-size: 0.76rem;
line-height: 1.43;
}
.memory-block p + p {
margin-top: 7px;
}
.card-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-top: 11px;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.56rem;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
}
#orbit-hint {
position: fixed;
bottom: 13px;
left: 50%;
z-index: 5;
transform: translateX(-50%);
color: rgba(25, 52, 47, 0.65);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.58rem;
font-weight: 800;
letter-spacing: 0.06em;
text-align: center;
text-transform: uppercase;
pointer-events: none;
white-space: nowrap;
}
#labels {
position: absolute;
inset: 0;
z-index: 2;
overflow: hidden;
pointer-events: none;
}
.scene-label {
position: absolute;
top: 0;
left: 0;
display: flex;
align-items: center;
gap: 7px;
padding: 6px 8px;
border: 1px solid var(--ink);
background: rgba(255, 250, 240, 0.9);
box-shadow: 3px 3px 0 rgba(25, 52, 47, 0.8);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.57rem;
font-weight: 900;
letter-spacing: 0.07em;
white-space: nowrap;
pointer-events: auto;
}
button.scene-label {
cursor: pointer;
}
button.scene-label:hover {
background: var(--ink);
color: white;
}
.scene-label span {
display: grid;
width: 19px;
height: 19px;
place-items: center;
background: var(--green-dark);
color: white;
font-size: 0.55rem;
}
.label-toma span {
background: var(--orange);
}
#shared-scene-label {
pointer-events: none;
}
#shared-scene-label span {
background: #b88832;
}
.loading {
position: fixed;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
background: #dce6df;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.72rem;
font-weight: 900;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 350ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 1250px) {
#shared-tray {
top: 132px;
}
#shared-detail {
top: 210px;
}
}
@media (max-width: 800px) {
body {
overflow-y: auto;
}
#app {
min-height: 1500px;
}
#stage {
height: 70svh;
min-height: 500px;
bottom: auto;
}
.masthead {
top: 16px;
left: 16px;
width: calc(100vw - 32px);
}
h1 {
font-size: 2.7rem;
}
.lede {
max-width: 255px;
font-size: 0.82rem;
}
.case-meta {
display: none;
}
.controls {
top: 112px;
right: 16px;
}
.control-button {
min-height: 34px;
padding: 0 9px;
font-size: 0.58rem;
}
#shared-tray {
top: 162px;
left: 16px;
width: calc(100vw - 32px);
transform: none;
overflow-x: auto;
}
.tray-title {
position: sticky;
left: 0;
z-index: 2;
padding: 0 10px;
}
.fact-button {
min-width: 96px;
padding: 10px;
}
#shared-detail {
top: 249px;
width: calc(100vw - 32px);
padding: 11px 13px;
}
#shared-title {
font-size: 1.08rem;
}
#shared-description {
font-size: 0.72rem;
}
#cards {
position: relative;
right: auto;
bottom: auto;
left: auto;
display: grid;
grid-template-columns: 1fr;
gap: 18px;
margin: calc(70svh - 5px) 16px 35px;
}
.memory-card {
width: 100%;
}
#orbit-hint {
display: none;
}
}
@media (max-width: 460px) {
h1 {
font-size: 2.35rem;
}
.lede {
max-width: 220px;
}
.controls {
top: 105px;
}
#shared-tray {
top: 151px;
}
#shared-detail {
top: 237px;
}
.scene-label {
font-size: 0.5rem;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<div id="app">
<div id="stage">
<canvas
id="scene"
role="img"
aria-label="Interactive voxel diorama of two festival memory displays connected by shared facts."
></canvas>
<div id="labels">
<button class="scene-label label-mara" data-view="mara" type="button">
<span>01</span> SOUND / ARRIVAL
</button>
<button class="scene-label label-toma" data-view="toma" type="button">
<span>02</span> FOOD / FELLOWSHIP
</button>
<div id="shared-scene-label" class="scene-label">
<span>◆</span>
<b id="scene-fact-short">DUSK</b>
</div>
</div>
</div>
<header class="masthead">
<p class="eyebrow">Community memory / case 07</p>
<h1>Willow<br>Lanterns</h1>
<p class="lede">
One evening. Four shared facts. Two very different memories.
Select a fact to see what it links—and what it does not.
</p>
<div class="case-meta" aria-label="Fictional case metadata">
<span>REDBANK COMMONS</span>
<span>14 AUG 2024</span>
</div>
</header>
<nav class="controls" aria-label="Scene controls">
<button id="reset-view" class="control-button" type="button">Reset view</button>
<button id="motion-toggle" class="control-button" type="button">Motion: full</button>
</nav>
<section id="shared-tray" aria-label="Shared facts">
<div class="tray-title">SHARED<br>GROUND</div>
<button class="fact-button" data-fact="dusk" aria-pressed="true" type="button">
<span>01 / CROSS-CHECK</span>
Dusk opening
</button>
<button class="fact-button" data-fact="lanterns" aria-pressed="false" type="button">
<span>02 / PHOTO</span>
17 lanterns
</button>
<button class="fact-button" data-fact="table" aria-pressed="false" type="button">
<span>03 / SITE + RECEIPT</span>
Willow table
</button>
<button class="fact-button" data-fact="bell" aria-pressed="false" type="button">
<span>04 / RELEASE LOG</span>
Final bell
</button>
</section>
<section id="shared-detail" aria-live="polite">
<div class="detail-topline">
<span id="shared-kind">Shared fact 01</span>
<span id="shared-anchor">Two accounts agree</span>
</div>
<h2 id="shared-title">The festival opened as daylight faded.</h2>
<p id="shared-description">
Both recollections place the beginning at dusk, but they do not agree on what happened first.
</p>
<div id="shared-evidence">ANCHOR: CROSS-ACCOUNT AGREEMENT</div>
</section>
<main id="cards" aria-label="Personal recollection displays">
<article
id="card-mara"
class="memory-card card-mara"
data-memory="mara"
tabindex="0"
aria-label="Mara's recollection display. Activate to focus its voxel scene."
>
<div class="card-kicker">
<span>Memory display 01</span>
<span>Mara K.</span>
</div>
<h2>The sound of waiting</h2>
<p class="focus-line">Focus: arrival, music, and the order of events.</p>
<div class="memory-block shared-block">
<span class="block-label">Linked shared fact</span>
<p id="mara-shared"></p>
</div>
<div class="memory-block personal-block">
<span class="block-label">Personal view • Unverified</span>
<p id="mara-personal"></p>
</div>
<div class="card-foot">
<span>Not treated as common fact</span>
<span>Select to focus ↗</span>
</div>
</article>
<article
id="card-toma"
class="memory-card card-toma"
data-memory="toma"
tabindex="0"
aria-label="Toma's recollection display. Activate to focus its voxel scene."
>
<div class="card-kicker">
<span>Memory display 02</span>
<span>Toma R.</span>
</div>
<h2>The table between us</h2>
<p class="focus-line">Focus: food, company, and the shape of the place.</p>
<div class="memory-block shared-block">
<span class="block-label">Linked shared fact</span>
<p id="toma-shared"></p>
</div>
<div class="memory-block personal-block">
<span class="block-label">Personal view • Unverified</span>
<p id="toma-personal"></p>
</div>
<div class="card-foot">
<span>Not treated as common fact</span>
<span>Select to focus ↗</span>
</div>
</article>
</main>
<div id="orbit-hint">Drag to orbit · Scroll to zoom · Select a display</div>
<div id="loading" class="loading">Building the memory map…</div>
</div>
<noscript>This experience requires JavaScript and WebGL.</noscript>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const $ = (id) => document.getElementById(id);
const facts = {
dusk: {
number: "01",
label: "Dusk opening",
short: "DUSK",
shared: "The festival opened as daylight faded.",
description:
"Both recollections place the beginning at dusk, but they do not agree on what happened first.",
anchor: "Two accounts agree",
evidence: "ANCHOR: CROSS-ACCOUNT AGREEMENT",
mara:
"Mara heard a drum before the first lantern. She is unsure whether the opening bell came before it.",
toma:
"Toma says the lanterns rose before there was music. He does not remember an opening bell."
},
lanterns: {
number: "02",
label: "17 lanterns released",
short: "17 LANTERNS",
shared: "Seventeen paper lanterns left the east bank.",
description:
"A group photograph confirms the number of lanterns, but not the exact rhythm of their release.",
anchor: "Group photograph",
evidence: "ANCHOR: 17 LANTERNS VISIBLE IN THE GROUP PHOTO",
mara:
"Mara saw them rise in one bright cluster and thinks the drummer paused to watch.",
toma:
"Toma counted seventeen from the river, but cannot say whether they all rose at the same moment."
},
table: {
number: "03",
label: "Soup beneath the willow",
short: "WILLOW TABLE",
shared: "The communal soup table stood beneath the willow tree.",
description:
"A site photograph and the caterer's receipt place the soup table beneath the willow.",
anchor: "Site photo + receipt",
evidence: "ANCHOR: SITE PHOTOGRAPH AND CATERER'S RECEIPT",
mara:
"Mara remembers the table pushed toward the river, away from the musicians.",
toma:
"Toma remembers it running east–west, with bowls passed hand to hand."
},
bell: {
number: "04",
label: "Final bell, then release",
short: "FINAL BELL",
shared: "The release log places the final bell immediately before the lanterns.",
description:
"The documented sequence is clear. The extra sound that one person remembers is not.",
anchor: "Release log",
evidence: "ANCHOR: RELEASE LOG TIMESTAMP",
mara:
"Mara believes she heard two extra taps and says they were a 'good luck' signal.",
toma:
"Toma heard one bell only and thinks the extra noise came from bowls or branches."
}
};
let selectedFact = "dusk";
let activeMemory = null;
let reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
// ---------------------------------------------------------------------
// Renderer and scene
// ---------------------------------------------------------------------
const canvas = $("scene");
const stage = $("stage");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.5));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce6df);
scene.fog = new THREE.Fog(0xdce6df, 18, 33);
const camera = new THREE.OrthographicCamera(-8, 8, 5, -5, 0.1, 80);
const hemisphere = new THREE.HemisphereLight(0xfff6d9, 0x5c756b, 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe2ad, 3.2);
sun.position.set(-6, 11, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(1024, 1024);
sun.shadow.camera.left = -11;
sun.shadow.camera.right = 11;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -9;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0006;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x8eb9c0, 1.3);
rim.position.set(8, 5, -8);
scene.add(rim);
function box(parent, size, color, position, options = {}) {
const geometry = new THREE.BoxGeometry(size[0], size[1], size[2]);
const material = new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
flatShading: true,
...options
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makePerson(parent, x, z, shirt, skin = 0xd7a378, facing = 0) {
const group = new THREE.Group();
group.position.set(x, 0.15, z);
group.rotation.y = facing;
parent.add(group);
box(group, [0.28, 0.42, 0.22], shirt, [0, 0.58, 0]);
box(group, [0.24, 0.24, 0.24], skin, [0, 0.92, 0]);
box(group, [0.11, 0.3, 0.12], 0x334f52, [-0.08, 0.2, 0]);
box(group, [0.11, 0.3, 0.12], 0x334f52, [0.08, 0.2, 0]);
box(group, [0.09, 0.34, 0.11], shirt, [-0.2, 0.59, 0]);
box(group, [0.09, 0.34, 0.11], shirt, [0.2, 0.59, 0]);
return group;
}
const base = new THREE.Group();
scene.add(base);
box(base, [13.4, 0.58, 7.7], 0x506b61, [0, -0.44, 0]);
const grassColors = [0x829d70, 0x8ca779, 0x78936b, 0x92ae7e, 0x849c72];
for (let x = -6; x <= 6; x++) {
for (let z = -3; z <= 3; z++) {
let color = grassColors[(x * 3 + z * 5 + 21) % grassColors.length];
if (z === -2) {
color = (x + 12) % 2 ? 0x78a9ae : 0x87b7ba;
} else if (z === 1) {
color = (x + 12) % 2 ? 0xc6b582 : 0xd2c18f;
} else if ((x + z) % 4 === 0) {
color = 0x95ae7f;
}
box(base, [0.98, 0.14, 0.98], color, [x, -0.07, z]);
}
}
const grid = new THREE.GridHelper(30, 30, 0x6f847b, 0x6f847b);
grid.position.y = -0.75;
grid.material.transparent = true;
grid.material.opacity = 0.13;
scene.add(grid);
// Shared link path between the two personal displays.
for (let i = -3; i <= 3; i++) {
box(base, [0.58, 0.1, 0.46], 0xd4b56f, [i * 0.6, 0.05, 1.05]);
}
// ---------------------------------------------------------------------
// Memory 01: sound and arrival
// ---------------------------------------------------------------------
const maraGroup = new THREE.Group();
maraGroup.position.set(-3.35, 0, 0.25);
maraGroup.userData.memory = "mara";
scene.add(maraGroup);
box(maraGroup, [3.75, 0.26, 3.35], 0x576e64, [0, 0.02, 0]);
box(maraGroup, [3.45, 0.18, 3.05], 0xd7c996, [0, 0.22, 0]);
box(maraGroup, [2.9, 0.18, 1.05], 0x8d664e, [0, 0.39, -0.78]);
box(maraGroup, [0.18, 1.65, 0.18], 0x4a625d, [-1.18, 1.18, -0.8]);
box(maraGroup, [0.18, 1.65, 0.18], 0x4a625d, [1.18, 1.18, -0.8]);
box(maraGroup, [2.55, 0.2, 0.22], 0x4a625d, [0, 2.0, -0.8]);
box(maraGroup, [1.0, 0.16, 0.18], 0xc47751, [0, 2.15, -0.8]);
box(maraGroup, [0.55, 0.9, 0.5], 0x344c4d, [-1.02, 0.92, -0.4]);
box(maraGroup, [0.43, 0.43, 0.05], 0x9eaaa4, [-1.02, 1.02, -0.12]);
box(maraGroup, [0.74, 0.46, 0.65], 0xb95f4f, [0.45, 0.75, -0.35]);
box(maraGroup, [0.82, 0.08, 0.7], 0xe4c790, [0.45, 1.01, -0.35]);
makePerson(maraGroup, -0.08, 0.55, 0x476d78, 0xd7a378, -0.35);
makePerson(maraGroup, 0.95, 0.6, 0xc17855, 0xa87555, 0.55);
const maraLanterns = new THREE.Group();
maraGroup.add(maraLanterns);
const miniLanternColors = [0xe7a24f, 0xe4bd62, 0xdb7d51, 0xe8cf82];
for (let i = 0; i < 4; i++) {
box(
maraLanterns,
[0.2, 0.28, 0.2],
miniLanternColors[i],
[-0.9 + i * 0.6, 1.78, -0.8]
);
}
// ---------------------------------------------------------------------
// Memory 02: food and fellowship
// ---------------------------------------------------------------------
const tomaGroup = new THREE.Group();
tomaGroup.position.set(3.35, 0, 0.3);
tomaGroup.userData.memory = "toma";
scene.add(tomaGroup);
box(tomaGroup, [3.75, 0.26, 3.35], 0x576e64, [0, 0.02, 0]);
box(tomaGroup, [3.45, 0.18, 3.05], 0xd7c996, [0, 0.22, 0]);
box(tomaGroup, [2.7, 0.18, 0.7], 0x9b6a45, [0, 0.98, 0]);
box(tomaGroup, [0.18, 0.75, 0.48], 0x744d38, [-1.1, 0.65, 0]);
box(tomaGroup, [0.18, 0.75, 0.48], 0x744d38, [1.1, 0.65, 0]);
box(tomaGroup, [2.7, 0.18, 0.32], 0x76513c, [0, 0.58, 0.76]);
box(tomaGroup, [2.7, 0.18, 0.32], 0x76513c, [0, 0.58, -0.76]);
const bowlColors = [0xe8ddd0, 0xd5c3a6, 0xe3b66c, 0xbfd0c1];
for (let i = 0; i < 7; i++) {
const x = -1.02 + i * 0.34;
box(tomaGroup, [0.24, 0.13, 0.24], bowlColors[i % bowlColors.length], [x, 1.14, 0]);
box(tomaGroup, [0.18, 0.05, 0.18], 0xd08a45, [x, 1.23, 0]);
}
makePerson(tomaGroup, -0.65, 1.05, 0x9a6148, 0xbb805e, Math.PI);
makePerson(tomaGroup, 0.65, -1.02, 0x637f67, 0xd6a17b, 0);
makePerson(tomaGroup, 1.2, 1.02, 0x836d88, 0x8e624a, Math.PI);
const treeGroup = new THREE.Group();
treeGroup.position.set(1.1, 0.25, 0.65);
tomaGroup.add(treeGroup);
box(treeGroup, [0.38, 2.0, 0.38], 0x70513a, [0, 1.0, 0]);
box(treeGroup, [0.55, 0.45, 0.55], 0x70513a, [0.17, 1.65, 0]);
const leafColors = [0x688e62, 0x769c69, 0x87aa72, 0x5f855e];
const leafPositions = [
[-0.65, 2.0, 0], [0, 2.12, 0], [0.65, 2.0, 0],
[-0.42, 2.48, 0.12], [0.32, 2.52, -0.08], [0, 2.85, 0],
[-0.1, 2.18, 0.58], [0.2, 2.2, -0.55], [-0.72, 2.36, -0.25],
[0.72, 2.38, 0.28], [-0.35, 1.78, 0.4], [0.42, 1.8, -0.38]
];
leafPositions.forEach((position, index) => {
box(treeGroup, [0.72, 0.65, 0.72], leafColors[index % leafColors.length], position);
});
for (let i = -2; i <= 2; i++) {
box(treeGroup, [0.22, 0.75 + Math.abs(i) * 0.12, 0.22], 0x77996b,
[i * 0.29, 1.55 - Math.abs(i) * 0.08, 0.54]);
}
// ---------------------------------------------------------------------
// Shared scene objects
// ---------------------------------------------------------------------
const lanternGroup = new THREE.Group();
lanternGroup.position.set(0, 0, -1.18);
lanternGroup.userData.fact = "lanterns";
scene.add(lanternGroup);
const lanternMeshes = [];
const lanternColors = [0xe6a54d, 0xe8bd64, 0xd97d4d, 0xefc978, 0xcbd18b];
for (let i = 0; i < 17; i++) {
const column = i % 9;
const row = Math.floor(i / 9);
const lantern = new THREE.Group();
const x = (column - 4) * 0.44;
const y = 2.05 + row * 0.32;
const z = row * 0.38 - 0.15;
lantern.position.set(x, y, z);
lantern.userData.baseY = y;
lantern.userData.phase = i * 0.63;
box(lantern, [0.23, 0.31, 0.23], lanternColors[i % lanternColors.length], [0, 0, 0]);
box(lantern, [0.13, 0.06, 0.13], 0x6c593d, [0, 0.18, 0]);
lanternGroup.add(lantern);
lanternMeshes.push(lantern);
}
const lanternLight = new THREE.PointLight(0xffb95b, 2.2, 7, 2);
lanternLight.position.set(0, 2.25, -1.15);
scene.add(lanternLight);
const bellGroup = new THREE.Group();
bellGroup.position.set(0, 0.08, 1.35);
bellGroup.userData.fact = "bell";
scene.add(bellGroup);
box(bellGroup, [0.18, 2.15, 0.18], 0x5b5748, [0, 1.08, 0]);
box(bellGroup, [0.8, 0.16, 0.18], 0x5b5748, [0, 2.05, 0]);
box(bellGroup, [0.42, 0.48, 0.42], 0xb88a42, [0, 1.76, 0]);
box(bellGroup, [0.55, 0.09, 0.55], 0xd5b25d, [0, 2.01, 0]);
const duskGroup = new THREE.Group();
duskGroup.userData.fact = "dusk";
scene.add(duskGroup);
box(duskGroup, [1.25, 1.25, 0.4], 0xe4a45f, [-5.15, 2.65, -3.05]);
box(duskGroup, [1.6, 0.18, 0.42], 0xc87d55, [-5.15, 1.93, -3.05]);
// A low band of warm blocks suggests the last light on the horizon.
for (let i = 0; i < 6; i++) {
box(duskGroup, [0.8, 0.18 + (i % 2) * 0.08, 0.3], 0xd7a06e,
[-5.9 + i * 0.82, 1.45, -3.12]);
}
// ---------------------------------------------------------------------
// Fact highlighting
// ---------------------------------------------------------------------
const highlightGroups = {
dusk: [duskGroup],
lanterns: [lanternGroup],
table: [tomaGroup],
bell: [bellGroup]
};
const highlightObjects = [];
Object.values(highlightGroups).forEach((groups) => {
groups.forEach((group) => {
group.traverse((object) => {
if (!object.isMesh) return;
object.userData.baseEmissive = object.material.emissive.clone();
object.userData.baseEmissiveIntensity = object.material.emissiveIntensity;
highlightObjects.push(object);
});
});
});
function applyFactHighlight(factId) {
highlightObjects.forEach((object) => {
object.material.emissive.copy(object.userData.baseEmissive);
object.material.emissiveIntensity = object.userData.baseEmissiveIntensity;
});
highlightGroups[factId].forEach((group) => {
group.traverse((object) => {
if (!object.isMesh) return;
object.material.emissive.set(0xd18a35);
object.material.emissiveIntensity = 0.42;
});
});
}
function selectFact(factId) {
selectedFact = factId;
const fact = facts[factId];
document.querySelectorAll(".fact-button").forEach((button) => {
button.setAttribute("aria-pressed", String(button.dataset.fact === factId));
});
$("shared-kind").textContent = `Shared fact ${fact.number}`;
$("shared-anchor").textContent = fact.anchor;
$("shared-title").textContent = fact.shared;
$("shared-description").textContent = fact.description;
$("shared-evidence").textContent = fact.evidence;
$("scene-fact-short").textContent = fact.short;
$("mara-shared").textContent = fact.shared;
$("toma-shared").textContent = fact.shared;
$("mara-personal").textContent = fact.mara;
$("toma-personal").textContent = fact.toma;
applyFactHighlight(factId);
}
// ---------------------------------------------------------------------
// Custom orthographic camera controls
// ---------------------------------------------------------------------
const desired = {
target: new THREE.Vector3(0, 0.65, 0),
yaw: 0.62,
pitch: 0.72,
zoom: 1
};
const current = {
target: desired.target.clone(),
yaw: desired.yaw,
pitch: desired.pitch,
zoom: desired.zoom
};
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
function lerpAngle(a, b, amount) {
let difference = ((b - a + Math.PI) % (Math.PI * 2)) - Math.PI;
if (difference < -Math.PI) difference += Math.PI * 2;
return a + difference * amount;
}
function setActiveCard(memory) {
activeMemory = memory;
document.querySelectorAll(".memory-card").forEach((card) => {
card.classList.toggle("active", card.dataset.memory === memory);
});
}
function focusView(view) {
if (view === "mara") {
desired.target.set(-3.35, 0.85, 0.2);
desired.yaw = 0.63;
desired.pitch = 0.74;
desired.zoom = 1.48;
setActiveCard("mara");
} else if (view === "toma") {
desired.target.set(3.35, 0.8, 0.25);
desired.yaw = 0.56;
desired.pitch = 0.75;
desired.zoom = 1.48;
setActiveCard("toma");
} else {
desired.target.set(0, 0.65, 0);
desired.yaw = 0.62;
desired.pitch = 0.72;
desired.zoom = 1;
setActiveCard(null);
}
}
$("reset-view").addEventListener("click", () => focusView("overview"));
function updateMotionButton() {
$("motion-toggle").textContent = reducedMotion ? "Motion: reduced" : "Motion: full";
$("motion-toggle").setAttribute("aria-pressed", String(reducedMotion));
}
$("motion-toggle").addEventListener("click", () => {
reducedMotion = !reducedMotion;
updateMotionButton();
});
updateMotionButton();
document.querySelectorAll(".fact-button").forEach((button) => {
button.addEventListener("click", () => selectFact(button.dataset.fact));
});
document.querySelectorAll(".memory-card").forEach((card) => {
const activate = () => focusView(card.dataset.memory);
card.addEventListener("click", activate);
card.addEventListener("keydown", (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
activate();
}
});
});
document.querySelectorAll(".scene-label[data-view]").forEach((button) => {
button.addEventListener("click", () => focusView(button.dataset.view));
});
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const interactiveRoots = [
maraGroup,
tomaGroup,
lanternGroup,
bellGroup,
duskGroup
];
function findInteractiveTarget(object) {
let currentObject = object;
while (currentObject) {
if (currentObject.userData.memory || currentObject.userData.fact) {
return currentObject;
}
currentObject = currentObject.parent;
}
return null;
}
function pick(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;
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(interactiveRoots, true);
if (!intersections.length) return null;
return findInteractiveTarget(intersections[0].object);
}
let pointerDown = null;
canvas.addEventListener("pointerdown", (event) => {
pointerDown = {
x: event.clientX,
y: event.clientY,
lastX: event.clientX,
lastY: event.clientY,
moved: false
};
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (pointerDown) {
const totalDistance = Math.hypot(
event.clientX - pointerDown.x,
event.clientY - pointerDown.y
);
if (totalDistance > 5) pointerDown.moved = true;
if (pointerDown.moved) {
const deltaX = event.clientX - pointerDown.lastX;
const deltaY = event.clientY - pointerDown.lastY;
desired.yaw -= deltaX * 0.006;
desired.pitch = clamp(desired.pitch + deltaY * 0.0045, 0.38, 1.12);
}
pointerDown.lastX = event.clientX;
pointerDown.lastY = event.clientY;
} else {
canvas.style.cursor = pick(event) ? "pointer" : "grab";
}
});
canvas.addEventListener("pointerup", (event) => {
if (!pointerDown) return;
const wasDrag = pointerDown.moved;
pointerDown = null;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
if (!wasDrag) {
const target = pick(event);
if (target?.userData.memory) {
focusView(target.userData.memory);
} else if (target?.userData.fact) {
selectFact(target.userData.fact);
}
}
});
canvas.addEventListener("pointercancel", () => {
pointerDown = null;
});
canvas.addEventListener("wheel", (event) => {
event.preventDefault();
desired.zoom = clamp(desired.zoom * Math.exp(-event.deltaY * 0.001), 0.72, 2.15);
}, { passive: false });
// ---------------------------------------------------------------------
// Projected HTML labels
// ---------------------------------------------------------------------
const projectedLabels = [
{
element: document.querySelector(".label-mara"),
position: new THREE.Vector3(-3.35, 2.65, 0.2)
},
{
element: document.querySelector(".label-toma"),
position: new THREE.Vector3(3.35, 2.7, 0.3)
},
{
element: $("shared-scene-label"),
position: new THREE.Vector3(0, 3.25, -1.18)
}
];
const projected = new THREE.Vector3();
function updateLabels() {
const width = stage.clientWidth;
const height = stage.clientHeight;
projectedLabels.forEach((label) => {
projected.copy(label.position).project(camera);
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
const visible = projected.z > -1 && projected.z < 1;
label.element.style.visibility = visible ? "visible" : "hidden";
label.element.style.transform =
`translate(-50%, -50%) translate(${x}px, ${y}px)`;
});
}
// ---------------------------------------------------------------------
// Resize and animation
// ---------------------------------------------------------------------
function resize() {
const width = stage.clientWidth;
const height = stage.clientHeight;
const aspect = width / Math.max(height, 1);
let viewHeight = 8.6;
if (aspect < 1.2) viewHeight = 14;
if (aspect < 0.75) viewHeight = 23;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height, false);
}
window.addEventListener("resize", resize);
resize();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const amount = reducedMotion ? 1 : 1 - Math.exp(-dt * 7.5);
current.target.lerp(desired.target, amount);
current.yaw = lerpAngle(current.yaw, desired.yaw, amount);
current.pitch += (desired.pitch - current.pitch) * amount;
current.zoom += (desired.zoom - current.zoom) * amount;
const radius = 16;
const cosPitch = Math.cos(current.pitch);
camera.position.set(
current.target.x + radius * Math.sin(current.yaw) * cosPitch,
current.target.y + radius * Math.sin(current.pitch),
current.target.z + radius * Math.cos(current.yaw) * cosPitch
);
camera.lookAt(current.target);
camera.zoom = current.zoom;
camera.updateProjectionMatrix();
if (!reducedMotion) {
lanternMeshes.forEach((lantern) => {
lantern.position.y =
lantern.userData.baseY +
Math.sin(clock.elapsedTime * 1.35 + lantern.userData.phase) * 0.075;
});
}
renderer.render(scene, camera);
updateLabels();
}
selectFact("dusk");
animate();
requestAnimationFrame(() => {
$("loading").classList.add("hidden");
setTimeout(() => $("loading").remove(), 400);
});
</script>
</body>
</html>
```