Prompt specification
Build or customize the Three.js 3D scene "Bank Beside a River and Bank Counter" 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: Bank Beside a River and Bank Counter
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/bank-beside-a-river-and-bank-counter-x3362
Scene Description Prompt:
Create stylized riverbank and financial-bank vignettes that reveal surrounding context before asking which meaning of 'bank' applies. Three.js from cdnjs, one HTML file.
Working Three.js Starter (bank-beside-a-river-and-bank-counter-x3362):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#f3ede1" />
<title>Bank — One Word, Two Worlds</title>
<style>
:root {
--paper: #f3ede1;
--ink: #172b3a;
--muted: #69747b;
--line: rgba(23, 43, 58, 0.14);
--water: #2f9eaa;
--water-dark: #19717d;
--leaf: #668b62;
--gold: #d69b46;
--coral: #d97962;
--navy: #172b3a;
--white: #fffdf7;
--shadow: 0 18px 60px rgba(23, 43, 58, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--paper);
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
button:focus-visible,
canvas:focus-visible {
outline: 3px solid rgba(214, 155, 70, 0.75);
outline-offset: 4px;
}
#app {
position: relative;
width: 100%;
height: 100%;
isolation: isolate;
background:
radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.85), transparent 42%),
linear-gradient(145deg, #f8f3e9 0%, #eee6d7 100%);
}
#stage {
position: absolute;
inset: 0;
}
#stage canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#stage canvas:active {
cursor: grabbing;
}
.vignette {
position: absolute;
inset: 0;
z-index: 2;
pointer-events: none;
background: radial-gradient(
ellipse at center,
transparent 52%,
rgba(35, 48, 53, 0.08) 100%
);
}
.topbar {
position: absolute;
z-index: 10;
top: 0;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 24px 28px;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 12px;
color: var(--ink);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.brand-mark {
position: relative;
width: 34px;
height: 34px;
border: 1px solid rgba(23, 43, 58, 0.24);
border-radius: 50%;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
border-radius: 50%;
}
.brand-mark::before {
width: 13px;
height: 13px;
top: 5px;
left: 5px;
background: var(--water);
}
.brand-mark::after {
width: 10px;
height: 10px;
right: 4px;
bottom: 4px;
background: var(--gold);
}
.view-tools {
display: flex;
align-items: center;
gap: 9px;
pointer-events: auto;
}
.view-hint,
.icon-button {
border: 1px solid var(--line);
background: rgba(255, 253, 247, 0.72);
backdrop-filter: blur(10px);
color: var(--ink);
border-radius: 999px;
box-shadow: 0 6px 24px rgba(23, 43, 58, 0.06);
}
.view-hint {
padding: 10px 14px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.03em;
color: var(--muted);
}
.icon-button {
width: 38px;
height: 38px;
display: grid;
place-items: center;
cursor: pointer;
transition: transform 160ms ease, background 160ms ease;
}
.icon-button:hover {
transform: translateY(-1px);
background: var(--white);
}
.icon-button svg {
width: 17px;
height: 17px;
}
.intro-card {
position: absolute;
z-index: 8;
top: 50%;
left: clamp(28px, 7vw, 112px);
width: min(430px, calc(100vw - 56px));
transform: translateY(-47%);
transition:
opacity 500ms ease,
transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1),
visibility 500ms;
}
.intro-card.is-hidden {
opacity: 0;
visibility: hidden;
transform: translateY(-42%) translateX(-20px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 18px;
color: var(--water-dark);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 28px;
height: 2px;
background: currentColor;
}
h1,
h2,
h3,
p {
margin-top: 0;
}
h1 {
margin-bottom: 20px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(52px, 7vw, 88px);
font-weight: 500;
line-height: 0.91;
letter-spacing: -0.055em;
}
h1 em {
color: var(--coral);
font-weight: 400;
}
.intro-copy {
max-width: 390px;
margin-bottom: 26px;
color: var(--muted);
font-size: 16px;
line-height: 1.65;
}
.primary-button,
.secondary-button,
.choice-button {
border: 0;
cursor: pointer;
transition:
transform 160ms ease,
box-shadow 160ms ease,
background 160ms ease;
}
.primary-button {
display: inline-flex;
align-items: center;
gap: 14px;
padding: 15px 20px;
border-radius: 999px;
background: var(--navy);
color: var(--white);
font-size: 13px;
font-weight: 800;
letter-spacing: 0.02em;
box-shadow: 0 12px 28px rgba(23, 43, 58, 0.2);
}
.primary-button:hover {
transform: translateY(-2px);
box-shadow: 0 16px 34px rgba(23, 43, 58, 0.25);
}
.primary-button .arrow {
display: grid;
place-items: center;
width: 24px;
height: 24px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.13);
font-size: 16px;
}
.intro-note {
display: flex;
align-items: center;
gap: 9px;
margin-top: 20px;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.03em;
}
.intro-note::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 0 5px rgba(214, 155, 70, 0.14);
}
.story-panel {
position: absolute;
z-index: 9;
top: 50%;
right: clamp(28px, 6vw, 90px);
width: min(390px, calc(100vw - 56px));
padding: 27px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 24px;
background: rgba(23, 43, 58, 0.95);
color: var(--white);
box-shadow: var(--shadow);
transform: translateY(-48%);
opacity: 0;
visibility: hidden;
transition:
opacity 450ms ease,
transform 550ms cubic-bezier(0.2, 0.8, 0.2, 1),
visibility 450ms;
}
.story-panel.is-visible {
opacity: 1;
visibility: visible;
transform: translateY(-50%);
}
.story-panel .eyebrow {
margin-bottom: 14px;
color: #83c9ce;
}
.story-panel h2 {
margin-bottom: 12px;
font-family: Georgia, "Times New Roman", serif;
font-size: 39px;
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.035em;
}
.story-panel p {
margin-bottom: 18px;
color: rgba(255, 253, 247, 0.72);
font-size: 14px;
line-height: 1.65;
}
.clue-list {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-bottom: 21px;
}
.clue {
padding: 7px 10px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 999px;
color: rgba(255, 253, 247, 0.78);
background: rgba(255, 255, 255, 0.05);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.example {
margin-bottom: 22px;
padding: 13px 14px;
border-left: 2px solid var(--gold);
color: rgba(255, 253, 247, 0.84);
background: rgba(255, 255, 255, 0.04);
font-family: Georgia, "Times New Roman", serif;
font-size: 14px;
font-style: italic;
line-height: 1.5;
}
.story-panel .primary-button {
width: 100%;
justify-content: center;
background: var(--gold);
color: var(--navy);
box-shadow: none;
}
.story-panel .primary-button:hover {
background: #e5ac5c;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.16);
}
.scene-label {
position: absolute;
z-index: 6;
display: flex;
align-items: center;
gap: 8px;
padding: 9px 12px;
border: 1px solid rgba(23, 43, 58, 0.15);
border-radius: 999px;
background: rgba(255, 253, 247, 0.88);
backdrop-filter: blur(9px);
color: var(--ink);
box-shadow: 0 8px 24px rgba(23, 43, 58, 0.1);
font-size: 10px;
font-weight: 900;
letter-spacing: 0.12em;
text-transform: uppercase;
opacity: 0;
visibility: hidden;
transform: translate(-50%, -50%) translateY(7px);
transition:
opacity 300ms ease,
transform 300ms ease,
visibility 300ms;
white-space: nowrap;
cursor: pointer;
}
.scene-label.is-visible {
opacity: 1;
visibility: visible;
transform: translate(-50%, -50%);
}
.scene-label:hover {
background: var(--white);
}
.scene-label .label-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.scene-label.river .label-dot {
background: var(--water);
}
.scene-label.finance .label-dot {
background: var(--gold);
}
.progress {
position: absolute;
z-index: 8;
left: 28px;
bottom: 25px;
display: flex;
align-items: center;
gap: 12px;
color: var(--muted);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.progress-dots {
display: flex;
align-items: center;
gap: 6px;
}
.progress-dot {
width: 9px;
height: 9px;
border: 1px solid rgba(23, 43, 58, 0.25);
border-radius: 50%;
background: transparent;
transition: background 300ms ease, transform 300ms ease;
}
.progress-dot.is-active {
border-color: var(--water);
background: var(--water);
transform: scale(1.15);
}
.progress-dot.is-done {
border-color: var(--gold);
background: var(--gold);
}
.final-layer {
position: absolute;
inset: 0;
z-index: 20;
display: grid;
place-items: center;
padding: 24px;
background: rgba(23, 43, 58, 0.16);
backdrop-filter: blur(7px);
opacity: 0;
visibility: hidden;
pointer-events: none;
transition: opacity 450ms ease, visibility 450ms;
}
.final-layer.is-open {
opacity: 1;
visibility: visible;
pointer-events: auto;
}
.question-card {
width: min(760px, 100%);
padding: clamp(25px, 5vw, 48px);
border: 1px solid rgba(255, 255, 255, 0.5);
border-radius: 30px;
background: rgba(255, 253, 247, 0.96);
box-shadow: 0 28px 90px rgba(23, 43, 58, 0.22);
text-align: center;
transform: translateY(18px) scale(0.98);
transition: transform 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.final-layer.is-open .question-card {
transform: translateY(0) scale(1);
}
.question-card .eyebrow {
justify-content: center;
margin-bottom: 14px;
}
.question-card h2 {
max-width: 620px;
margin: 0 auto 13px;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(34px, 5vw, 53px);
font-weight: 500;
line-height: 1.04;
letter-spacing: -0.04em;
}
.question-card > p {
max-width: 540px;
margin: 0 auto 26px;
color: var(--muted);
font-size: 14px;
line-height: 1.6;
}
.choices {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 14px;
text-align: left;
}
.choice-button {
position: relative;
min-height: 145px;
padding: 21px;
border: 1px solid var(--line);
border-radius: 20px;
background: #faf6ed;
color: var(--ink);
overflow: hidden;
}
.choice-button::after {
content: "";
position: absolute;
right: -28px;
bottom: -38px;
width: 110px;
height: 110px;
border-radius: 50%;
background: rgba(47, 158, 170, 0.1);
transition: transform 220ms ease;
}
.choice-button.finance::after {
background: rgba(214, 155, 70, 0.14);
}
.choice-button:hover {
transform: translateY(-3px);
border-color: rgba(23, 43, 58, 0.28);
box-shadow: 0 14px 30px rgba(23, 43, 58, 0.08);
}
.choice-button:hover::after {
transform: scale(1.35);
}
.choice-button.is-selected {
border-color: var(--navy);
box-shadow: 0 0 0 2px var(--navy);
}
.choice-icon {
display: grid;
place-items: center;
width: 42px;
height: 42px;
margin-bottom: 14px;
border-radius: 13px;
background: rgba(47, 158, 170, 0.13);
color: var(--water-dark);
}
.finance .choice-icon {
background: rgba(214, 155, 70, 0.16);
color: #9c681f;
}
.choice-icon svg {
width: 24px;
height: 24px;
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linecap: round;
stroke-linejoin: round;
}
.choice-button strong {
display: block;
margin-bottom: 5px;
font-family: Georgia, "Times New Roman", serif;
font-size: 21px;
font-weight: 500;
}
.choice-button small {
display: block;
color: var(--muted);
font-size: 12px;
line-height: 1.45;
}
.answer-feedback {
min-height: 47px;
margin: 18px 0 0;
padding: 12px 15px;
border-radius: 14px;
color: var(--ink);
background: rgba(214, 155, 70, 0.12);
font-size: 13px;
line-height: 1.5;
opacity: 0;
transform: translateY(5px);
transition: opacity 250ms ease, transform 250ms ease;
}
.answer-feedback.is-visible {
opacity: 1;
transform: translateY(0);
}
.replay-button {
margin-top: 14px;
padding: 8px 12px;
border: 0;
background: transparent;
color: var(--muted);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
cursor: pointer;
opacity: 0;
pointer-events: none;
transition: opacity 250ms ease, color 160ms ease;
}
.replay-button.is-visible {
opacity: 1;
pointer-events: auto;
}
.replay-button:hover {
color: var(--ink);
}
.loading {
position: absolute;
inset: 0;
z-index: 50;
display: grid;
place-items: center;
background: var(--paper);
transition: opacity 600ms ease, visibility 600ms;
}
.loading.is-done {
opacity: 0;
visibility: hidden;
}
.loading-inner {
text-align: center;
}
.loading-word {
font-family: Georgia, "Times New Roman", serif;
font-size: 44px;
letter-spacing: -0.04em;
}
.loading-line {
width: 130px;
height: 2px;
margin: 14px auto 0;
overflow: hidden;
border-radius: 99px;
background: rgba(23, 43, 58, 0.1);
}
.loading-line::after {
content: "";
display: block;
width: 50%;
height: 100%;
border-radius: inherit;
background: var(--water);
animation: load 1s ease-in-out infinite alternate;
}
@keyframes load {
from { transform: translateX(-100%); }
to { transform: translateX(200%); }
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (max-width: 820px) {
.topbar {
padding: 18px;
}
.view-hint {
display: none;
}
.intro-card {
top: auto;
bottom: 78px;
left: 22px;
width: calc(100vw - 44px);
transform: none;
}
.intro-card.is-hidden {
transform: translateY(20px);
}
h1 {
font-size: clamp(46px, 14vw, 68px);
}
.intro-copy {
max-width: 440px;
font-size: 14px;
}
.story-panel {
top: auto;
right: 16px;
bottom: 61px;
width: calc(100vw - 32px);
max-height: 56vh;
overflow: auto;
padding: 22px;
transform: translateY(20px);
}
.story-panel.is-visible {
transform: translateY(0);
}
.story-panel h2 {
font-size: 33px;
}
.progress {
left: 18px;
bottom: 18px;
}
.scene-label {
font-size: 9px;
}
.choices {
grid-template-columns: 1fr;
}
.choice-button {
min-height: 112px;
}
.question-card {
max-height: calc(100vh - 32px);
overflow: auto;
border-radius: 24px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<main id="app">
<div id="stage" aria-label="Interactive 3D scene showing two possible meanings of the word bank"></div>
<div class="vignette"></div>
<header class="topbar">
<div class="brand">
<span class="brand-mark" aria-hidden="true"></span>
<span>Wordscapes / Context Study 01</span>
</div>
<div class="view-tools">
<div class="view-hint">Drag to orbit · Scroll to zoom</div>
<button class="icon-button" id="resetView" type="button" aria-label="Reset camera view" title="Reset view">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M4 12a8 8 0 1 0 2.3-5.7L4 8.6M4 4v4.6h4.6"
fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
</div>
</header>
<section class="intro-card" id="introCard">
<div class="eyebrow">A tiny exercise in meaning</div>
<h1>One word.<br><em>Two worlds.</em></h1>
<p class="intro-copy">
“Bank” can point to a quiet edge of land—or a building full of money.
Let the surrounding scenes tell you which world is meant.
</p>
<button class="primary-button" id="startButton" type="button">
Reveal the first context <span class="arrow" aria-hidden="true">→</span>
</button>
<div class="intro-note">Context comes before the choice</div>
</section>
<section class="story-panel" id="storyPanel" aria-live="polite">
<div class="eyebrow" id="storyEyebrow">Context 01 of 02</div>
<h2 id="storyTitle">Along the water</h2>
<p id="storyDescription"></p>
<div class="clue-list" id="clueList"></div>
<div class="example" id="storyExample"></div>
<button class="primary-button" id="nextButton" type="button">
<span id="nextButtonText">Reveal the financial context</span>
<span class="arrow" aria-hidden="true">→</span>
</button>
</section>
<button class="scene-label river" id="riverLabel" type="button">
<span class="label-dot"></span> Riverbank
</button>
<button class="scene-label finance" id="financeLabel" type="button">
<span class="label-dot"></span> Financial bank
</button>
<div class="progress" aria-label="Context reveal progress">
<span>Context</span>
<div class="progress-dots">
<span class="progress-dot" id="progressRiver"></span>
<span class="progress-dot" id="progressFinance"></span>
</div>
<span id="progressText">0 / 2</span>
</div>
<section class="final-layer" id="finalLayer" aria-hidden="true">
<div class="question-card" role="dialog" aria-modal="true" aria-labelledby="questionTitle">
<div class="eyebrow">Now choose the meaning</div>
<h2 id="questionTitle">Which meaning of “bank” applies?</h2>
<p>
Both scenes are now in view. Choose the context that best matches the
meaning you want to carry forward.
</p>
<div class="choices">
<button class="choice-button river" id="chooseRiver" type="button">
<span class="choice-icon" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path d="M3 8c2.2-1.3 4.1 1.3 6.3 0S13.4 6.7 15.6 8 20 9.3 22 8" />
<path d="M3 13c2.2-1.3 4.1 1.3 6.3 0s4.1-1.3 6.3 0 4.4 1.3 6.4 0" />
<path d="M5 18h14M8 18l2-4h4l2 4" />
</svg>
</span>
<strong>Riverbank</strong>
<small>The sloping land beside a river or stream.</small>
</button>
<button class="choice-button finance" id="chooseFinance" type="button">
<span class="choice-icon" aria-hidden="true">
<svg viewBox="0 0 24 24">
<path d="M3 9h18L12 4 3 9Z" />
<path d="M5 10v7M9.5 10v7M14.5 10v7M19 10v7M3 20h18" />
</svg>
</span>
<strong>Financial bank</strong>
<small>An institution that stores, lends, and manages money.</small>
</button>
</div>
<div class="answer-feedback" id="answerFeedback" aria-live="polite"></div>
<button class="replay-button" id="replayButton" type="button">Replay the context study</button>
</div>
</section>
<div class="loading" id="loading">
<div class="loading-inner">
<div class="loading-word">bank</div>
<div class="loading-line"></div>
</div>
</div>
<noscript>This interactive scene requires JavaScript.</noscript>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const introCard = document.getElementById("introCard");
const storyPanel = document.getElementById("storyPanel");
const finalLayer = document.getElementById("finalLayer");
const riverLabel = document.getElementById("riverLabel");
const financeLabel = document.getElementById("financeLabel");
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.06;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.tabIndex = 0;
renderer.domElement.setAttribute("aria-label", "Three-dimensional riverbank and financial bank scenes");
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xf3ede1, 15, 34);
const camera = new THREE.PerspectiveCamera(
34,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xfff8e9, 0x668277, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff3d7, 3.7);
keyLight.position.set(-5, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -11;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x9edce0, 1.1);
fillLight.position.set(8, 5, -7);
scene.add(fillLight);
const world = new THREE.Group();
scene.add(world);
const colors = {
cream: 0xf4ead6,
creamLight: 0xfffaf0,
navy: 0x183443,
teal: 0x2f9eaa,
tealDark: 0x19717d,
grass: 0x78966a,
grassDark: 0x577552,
wood: 0x9a6848,
woodDark: 0x634634,
gold: 0xd69b46,
coral: 0xd97962,
stone: 0xc8bda8,
dark: 0x243641
};
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
function addMesh(group, geometry, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, mat);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
return mesh;
}
function addBox(group, width, height, depth, mat, x = 0, y = 0, z = 0) {
return addMesh(group, new THREE.BoxGeometry(width, height, depth), mat, x, y, z);
}
function addCylinder(
group,
radiusTop,
radiusBottom,
height,
segments,
mat,
x = 0,
y = 0,
z = 0
) {
return addMesh(
group,
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat,
x,
y,
z
);
}
function makeTextTexture({
title,
subtitle = "",
background = "#f4ead6",
foreground = "#183443",
accent = "#d69b46"
}) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 512;
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = accent;
ctx.lineWidth = 10;
ctx.strokeRect(28, 28, canvas.width - 56, canvas.height - 56);
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = foreground;
ctx.font = "700 180px Georgia, serif";
ctx.fillText(title, canvas.width / 2, subtitle ? 212 : 265);
if (subtitle) {
ctx.fillStyle = accent;
ctx.font = "700 35px Arial, sans-serif";
ctx.letterSpacing = "8px";
ctx.fillText(subtitle.toUpperCase(), canvas.width / 2, 355);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function addTextPanel(group, options, width, height, x, y, z) {
const texture = makeTextTexture(options);
const mat = material(0xffffff, {
map: texture,
roughness: 0.9,
side: THREE.DoubleSide
});
return addMesh(group, new THREE.PlaneGeometry(width, height), mat, x, y, z);
}
function makeTree(group, x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
group.add(tree);
addCylinder(tree, 0.09, 0.13, 1.35, 7, material(colors.woodDark), 0, 0.68, 0);
const crown = addMesh(
tree,
new THREE.DodecahedronGeometry(0.66, 0),
material(colors.grassDark),
0,
1.55,
0
);
crown.scale.set(1, 1.18, 0.95);
const crownTop = addMesh(
tree,
new THREE.DodecahedronGeometry(0.45, 0),
material(0x86a876),
0.13,
1.95,
-0.04
);
crownTop.scale.set(1, 1.1, 0.9);
return { tree, crown, crownTop };
}
function makeRock(group, x, y, z, scale = 1) {
const rock = addMesh(
group,
new THREE.DodecahedronGeometry(0.28, 0),
material(colors.stone),
x,
y,
z
);
rock.scale.set(1.25 * scale, 0.65 * scale, 0.9 * scale);
rock.rotation.y = Math.random() * Math.PI;
return rock;
}
function makeReeds(group, x, z, count = 6) {
const reeds = new THREE.Group();
reeds.position.set(x, 0, z);
group.add(reeds);
for (let i = 0; i < count; i++) {
const h = 0.35 + Math.random() * 0.38;
addCylinder(
reeds,
0.018,
0.025,
h,
5,
material(i % 2 ? colors.grassDark : 0x91a56d),
(Math.random() - 0.5) * 0.5,
h / 2,
(Math.random() - 0.5) * 0.25
);
}
return reeds;
}
function makeGableRoof(width, height, depth) {
const w = width / 2;
const d = depth / 2;
const vertices = new Float32Array([
-w, 0, -d,
w, 0, -d,
0, height, -d,
-w, 0, d,
w, 0, d,
0, height, d
]);
const indices = [
0, 2, 1,
3, 4, 5,
0, 3, 5, 0, 5, 2,
1, 2, 5, 1, 5, 4,
0, 1, 4, 0, 4, 3
];
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.BufferAttribute(vertices, 3));
geometry.setIndex(indices);
geometry.computeVertexNormals();
return geometry;
}
function prepareFade(root) {
root.traverse((object) => {
if (!object.isMesh) return;
object.material = object.material.clone();
object.material.transparent = true;
object.userData.baseOpacity = object.material.opacity;
object.userData.baseDepthWrite = object.material.depthWrite;
});
}
function setGroupOpacity(root, alpha) {
root.traverse((object) => {
if (!object.isMesh) return;
const mat = object.material;
const base = object.userData.baseOpacity ?? 1;
mat.opacity = base * alpha;
mat.depthWrite = alpha > 0.96 ? (object.userData.baseDepthWrite ?? true) : false;
object.castShadow = alpha > 0.38;
});
const s = 0.88 + alpha * 0.12;
root.scale.setScalar(s);
}
// Shared ground and decorative rings.
const ground = addMesh(
world,
new THREE.CircleGeometry(22, 72),
material(0xf5efe4),
0,
-0.38,
0
);
ground.rotation.x = -Math.PI / 2;
ground.castShadow = false;
for (const radius of [6.9, 9.2, 11.5]) {
const ring = addMesh(
world,
new THREE.RingGeometry(radius, radius + 0.025, 96),
material(0xd7cebd, { transparent: true, opacity: 0.42 }),
0,
-0.365,
0
);
ring.rotation.x = -Math.PI / 2;
ring.castShadow = false;
}
// Riverbank vignette.
const riverGroup = new THREE.Group();
riverGroup.position.set(-4.15, 0, 0.05);
world.add(riverGroup);
addBox(riverGroup, 5.25, 0.3, 5.05, material(0xd5c7ae), 0, -0.18, 0);
addBox(riverGroup, 5.25, 0.22, 3.15, material(colors.grass), 0, 0.02, -0.88);
const waterMaterial = material(colors.teal, {
transparent: true,
opacity: 0.84,
roughness: 0.42,
metalness: 0.02
});
addBox(riverGroup, 5.25, 0.14, 1.85, waterMaterial, 0, 0.02, 1.36);
for (let i = 0; i < 10; i++) {
const x = -2.25 + i * 0.5;
const rock = makeRock(riverGroup, x, 0.16, 0.51 + Math.random() * 0.12, 0.55 + Math.random() * 0.3);
rock.rotation.y = Math.random() * Math.PI;
}
const treeA = makeTree(riverGroup, -1.68, -1.28, 1.02);
const treeB = makeTree(riverGroup, 1.72, -1.35, 0.86);
// Bench.
const bench = new THREE.Group();
bench.position.set(-0.45, 0, -0.28);
riverGroup.add(bench);
const benchWood = material(colors.wood);
addBox(bench, 1.38, 0.12, 0.42, benchWood, 0, 0.48, 0);
addBox(bench, 1.38, 0.48, 0.1, benchWood, 0, 0.75, -0.2);
addBox(bench, 0.11, 0.52, 0.11, material(colors.dark), -0.48, 0.23, 0);
addBox(bench, 0.11, 0.52, 0.11, material(colors.dark), 0.48, 0.23, 0);
// Footbridge over the water.
const bridge = new THREE.Group();
bridge.position.set(0.7, 0, 1.34);
riverGroup.add(bridge);
const bridgeWood = material(colors.woodDark);
addBox(bridge, 0.78, 0.12, 2.45, bridgeWood, 0, 0.36, 0);
for (const x of [-0.42, 0.42]) {
addBox(bridge, 0.08, 0.08, 2.5, material(colors.creamLight), x, 0.86, 0);
for (const z of [-0.92, 0, 0.92]) {
addBox(bridge, 0.08, 0.55, 0.08, bridgeWood, x, 0.62, z);
}
}
// Small canoe.
const canoe = new THREE.Group();
canoe.position.set(-1.15, 0.26, 1.35);
canoe.rotation.y = -0.12;
riverGroup.add(canoe);
const canoeOuter = addMesh(
canoe,
new THREE.SphereGeometry(0.72, 20, 10),
material(colors.coral),
0,
0,
0
);
canoeOuter.scale.set(1, 0.18, 0.37);
const canoeInner = addMesh(
canoe,
new THREE.SphereGeometry(0.61, 18, 8),
material(0x9d5648),
0,
0.07,
0
);
canoeInner.scale.set(1, 0.13, 0.28);
addBox(canoe, 0.62, 0.05, 0.07, material(colors.woodDark), 0, 0.17, 0);
// Reeds and stones.
const reedsA = makeReeds(riverGroup, -2.0, 0.57, 7);
const reedsB = makeReeds(riverGroup, 2.05, 0.64, 5);
makeRock(riverGroup, -2.14, 0.18, 1.93, 0.7);
makeRock(riverGroup, 2.22, 0.16, 1.96, 0.8);
// Little duck.
const duck = new THREE.Group();
duck.position.set(0.05, 0.24, 1.65);
riverGroup.add(duck);
const duckBody = addMesh(duck, new THREE.SphereGeometry(0.16, 12, 8), material(0xf0c968), 0, 0, 0);
duckBody.scale.set(1.35, 0.72, 0.86);
addMesh(duck, new THREE.SphereGeometry(0.1, 10, 8), material(0xf0c968), 0.16, 0.13, 0);
addBox(duck, 0.15, 0.045, 0.065, material(colors.coral), 0.27, 0.12, 0);
// Small riverside sign.
const riverSign = new THREE.Group();
riverSign.position.set(1.5, 0, -0.35);
riverGroup.add(riverSign);
addCylinder(riverSign, 0.045, 0.055, 0.82, 6, material(colors.woodDark), 0, 0.41, 0);
addBox(riverSign, 0.8, 0.38, 0.08, material(colors.creamLight), 0, 0.72, 0);
addTextPanel(
riverSign,
{
title: "RIVER",
subtitle: "walk",
background: "#fffaf0",
foreground: "#19717d",
accent: "#2f9eaa"
},
0.74,
0.34,
0,
0.72,
0.045
);
// Water glints.
const waterGlints = [];
const glintMat = material(0xc7f0ea, { transparent: true, opacity: 0.72 });
for (let i = 0; i < 9; i++) {
const glint = addBox(
riverGroup,
0.25 + Math.random() * 0.25,
0.012,
0.025,
glintMat,
-2.25 + i * 0.5,
0.105,
1.02 + Math.random() * 0.72
);
waterGlints.push(glint);
}
// Financial-bank vignette.
const financeGroup = new THREE.Group();
financeGroup.position.set(4.15, 0, 0.05);
world.add(financeGroup);
addBox(financeGroup, 5.25, 0.3, 5.05, material(0xd5c7ae), 0, -0.18, 0);
addBox(financeGroup, 5.25, 0.17, 5.05, material(0xe8dfcd), 0, 0.015, 0);
const bank = new THREE.Group();
bank.position.set(0, 0, -0.78);
financeGroup.add(bank);
addBox(bank, 3.95, 1.45, 1.65, material(colors.creamLight), 0, 1.03, 0);
addBox(bank, 4.15, 0.18, 1.82, material(colors.cream), 0, 0.3, 0);
addMesh(bank, makeGableRoof(4.25, 0.75, 1.92), material(colors.navy), 0, 1.75, 0);
addBox(bank, 3.68, 0.09, 0.08, material(colors.gold), 0, 1.72, 0.99);
addTextPanel(
bank,
{
title: "BANK",
subtitle: "money & trust",
background: "#f4ead6",
foreground: "#183443",
accent: "#d69b46"
},
1.62,
0.62,
0,
2.1,
0.99
);
const columnPositions = [-1.48, -0.5, 0.5, 1.48];
for (const x of columnPositions) {
addCylinder(bank, 0.13, 0.15, 1.38, 12, material(0xfff9eb), x, 0.98, 1.02);
addCylinder(bank, 0.2, 0.2, 0.13, 12, material(colors.cream), x, 0.35, 1.02);
addCylinder(bank, 0.2, 0.2, 0.13, 12, material(colors.cream), x, 1.62, 1.02);
}
addBox(bank, 3.42, 0.14, 0.42, material(colors.stone), 0, 0.18, 1.31);
addBox(bank, 3.82, 0.12, 0.46, material(colors.stone), 0, 0.08, 1.72);
// Bank doors.
addBox(bank, 0.92, 1.13, 0.09, material(colors.navy), 0, 0.91, 0.86);
addBox(bank, 0.62, 0.82, 0.025, material(0x9bc6c8), 0, 0.9, 0.92);
// ATM.
const atm = new THREE.Group();
atm.position.set(1.72, 0, 1.35);
atm.rotation.y = -0.18;
financeGroup.add(atm);
addBox(atm, 0.7, 1.22, 0.5, material(colors.navy), 0, 0.61, 0);
addBox(atm, 0.52, 0.38, 0.03, material(0x79c5c7, { emissive: 0x214e50, emissiveIntensity: 0.3 }), 0, 0.86, 0.265);
addBox(atm, 0.44, 0.05, 0.04, material(colors.dark), 0, 0.49, 0.27);
addBox(atm, 0.19, 0.025, 0.05, material(colors.gold), 0.13, 0.32, 0.27);
// Coin stacks.
const coinGroup = new THREE.Group();
coinGroup.position.set(-1.55, 0, 1.52);
financeGroup.add(coinGroup);
const coinMat = material(colors.gold, { metalness: 0.35, roughness: 0.38 });
for (const [x, z, count] of [[0, 0, 5], [0.32, 0.08, 3], [-0.25, 0.17, 2]]) {
for (let i = 0; i < count; i++) {
addCylinder(coinGroup, 0.17, 0.17, 0.075, 18, coinMat, x, 0.12 + i * 0.075, z);
}
}
// Floating bank card.
const card = new THREE.Group();
card.position.set(0.52, 1.55, 1.05);
card.rotation.set(-0.2, -0.45, 0.12);
financeGroup.add(card);
addBox(card, 0.68, 0.42, 0.045, material(colors.coral), 0, 0, 0);
addBox(card, 0.19, 0.14, 0.01, material(colors.gold), -0.15, 0, 0.029);
addBox(card, 0.38, 0.025, 0.012, material(colors.creamLight), 0.06, -0.1, 0.03);
// Planters.
for (const x of [-2.06, 2.08]) {
addBox(financeGroup, 0.46, 0.43, 0.46, material(colors.coral), x, 0.22, -1.58);
const shrub = addMesh(
financeGroup,
new THREE.DodecahedronGeometry(0.4, 0),
material(colors.grassDark),
x,
0.68,
-1.58
);
shrub.scale.y = 1.15;
}
// Central ambiguous word sign.
const centralSign = new THREE.Group();
centralSign.position.set(0, 0, 1.15);
world.add(centralSign);
addCylinder(centralSign, 0.065, 0.085, 1.3, 7, material(colors.woodDark), 0, 0.65, 0);
addBox(centralSign, 2.55, 1.16, 0.15, material(colors.creamLight), 0, 1.35, 0);
addTextPanel(
centralSign,
{
title: "BANK",
subtitle: "which world?",
background: "#fffdf7",
foreground: "#183443",
accent: "#d69b46"
},
2.43,
1.02,
0,
1.35,
0.081
);
const wordAnchor = new THREE.Object3D();
wordAnchor.position.set(0, 2.08, 0);
centralSign.add(wordAnchor);
// Label anchors.
const riverAnchor = new THREE.Object3D();
riverAnchor.position.set(-0.2, 2.05, -0.1);
riverGroup.add(riverAnchor);
const financeAnchor = new THREE.Object3D();
financeAnchor.position.set(0, 2.75, -0.55);
financeGroup.add(financeAnchor);
prepareFade(riverGroup);
prepareFade(financeGroup);
let riverOpacity = 0.1;
let financeOpacity = 0.1;
setGroupOpacity(riverGroup, riverOpacity);
setGroupOpacity(financeGroup, financeOpacity);
// Camera and custom controls.
const desiredTarget = new THREE.Vector3(0, 1.05, 0);
const currentTarget = desiredTarget.clone();
let desiredYaw = 0;
let desiredPitch = 0.48;
let desiredDistance = 14.8;
let currentYaw = desiredYaw;
let currentPitch = desiredPitch;
let currentDistance = desiredDistance;
function setCameraView(view) {
if (view === "river") {
desiredTarget.set(-4.05, 0.95, 0.15);
desiredYaw = -0.37;
desiredPitch = 0.45;
desiredDistance = 9.1;
} else if (view === "finance") {
desiredTarget.set(4.05, 1.05, -0.05);
desiredYaw = 0.37;
desiredPitch = 0.42;
desiredDistance = 9.2;
} else {
desiredTarget.set(0, 1.05, 0.05);
desiredYaw = 0;
desiredPitch = 0.48;
desiredDistance = 14.8;
}
}
const pointer = {
down: false,
x: 0,
y: 0,
moved: false
};
renderer.domElement.addEventListener("pointerdown", (event) => {
pointer.down = true;
pointer.x = event.clientX;
pointer.y = event.clientY;
pointer.moved = false;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointer.down) return;
const dx = event.clientX - pointer.x;
const dy = event.clientY - pointer.y;
if (Math.abs(dx) + Math.abs(dy) > 2) pointer.moved = true;
desiredYaw -= dx * 0.005;
desiredPitch = THREE.MathUtils.clamp(desiredPitch + dy * 0.0035, 0.18, 0.92);
pointer.x = event.clientX;
pointer.y = event.clientY;
});
function endPointer(event) {
pointer.down = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endPointer);
renderer.domElement.addEventListener("pointercancel", endPointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desiredDistance = THREE.MathUtils.clamp(
desiredDistance + event.deltaY * 0.008,
6.5,
22
);
},
{ passive: false }
);
renderer.domElement.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
if (key === "arrowleft") desiredYaw -= 0.12;
if (key === "arrowright") desiredYaw += 0.12;
if (key === "arrowup") desiredPitch = Math.min(0.92, desiredPitch + 0.08);
if (key === "arrowdown") desiredPitch = Math.max(0.18, desiredPitch - 0.08);
if (key === "+" || key === "=") desiredDistance = Math.max(6.5, desiredDistance - 0.6);
if (key === "-") desiredDistance = Math.min(22, desiredDistance + 0.6);
});
// Interface state.
const visited = new Set();
let currentView = "intro";
let answerSelected = null;
const contextData = {
river: {
eyebrow: "Context 01 of 02 · Shoreline",
title: "Along the water",
description:
"Water, reeds, a canoe, and a footbridge establish the setting. Here, a bank is the sloping ground that borders a river.",
clues: ["Waterline", "Canoe", "Footbridge"],
example: "“We picnicked on the riverbank.”",
next: "Reveal the financial context"
},
finance: {
eyebrow: "Context 02 of 02 · Institution",
title: "A place for money",
description:
"Columns, an ATM, coins, and a formal entrance signal a financial institution. Here, a bank stores, lends, and manages money.",
clues: ["Columns", "ATM", "Coins"],
example: "“She deposited her check at the bank.”",
next: "Bring both contexts together"
}
};
function updateProgress() {
document.getElementById("progressRiver").classList.toggle("is-active", visited.has("river"));
document.getElementById("progressRiver").classList.toggle("is-done", visited.has("river"));
document.getElementById("progressFinance").classList.toggle("is-active", visited.has("finance"));
document.getElementById("progressFinance").classList.toggle("is-done", visited.has("finance"));
document.getElementById("progressText").textContent = `${visited.size} / 2`;
}
function showScene(name) {
currentView = name;
visited.add(name);
introCard.classList.add("is-hidden");
storyPanel.classList.add("is-visible");
setCameraView(name);
const data = contextData[name];
document.getElementById("storyEyebrow").textContent = data.eyebrow;
document.getElementById("storyTitle").textContent = data.title;
document.getElementById("storyDescription").textContent = data.description;
document.getElementById("storyExample").textContent = data.example;
document.getElementById("nextButtonText").textContent =
visited.size === 2 ? "Bring both contexts together" : data.next;
const clueList = document.getElementById("clueList");
clueList.innerHTML = "";
for (const clue of data.clues) {
const item = document.createElement("span");
item.className = "clue";
item.textContent = clue;
clueList.appendChild(item);
}
riverLabel.classList.toggle("is-visible", visited.has("river"));
financeLabel.classList.toggle("is-visible", visited.has("finance"));
updateProgress();
}
function compareScenes() {
if (visited.size < 2) return;
currentView = "compare";
storyPanel.classList.remove("is-visible");
setCameraView("compare");
riverLabel.classList.add("is-visible");
financeLabel.classList.add("is-visible");
window.setTimeout(() => {
finalLayer.classList.add("is-open");
finalLayer.setAttribute("aria-hidden", "false");
document.getElementById("chooseRiver").focus({ preventScroll: true });
}, reducedMotion ? 100 : 850);
}
document.getElementById("startButton").addEventListener("click", () => {
showScene("river");
});
document.getElementById("nextButton").addEventListener("click", () => {
if (currentView === "river") {
showScene("finance");
} else if (currentView === "finance") {
compareScenes();
} else if (visited.size < 2) {
showScene(visited.has("river") ? "finance" : "river");
} else {
compareScenes();
}
});
riverLabel.addEventListener("click", () => {
if (visited.size) showScene("river");
});
financeLabel.addEventListener("click", () => {
if (visited.size) showScene("finance");
});
document.getElementById("resetView").addEventListener("click", () => {
setCameraView(currentView === "intro" ? "compare" : currentView);
});
function chooseAnswer(choice) {
answerSelected = choice;
const riverButton = document.getElementById("chooseRiver");
const financeButton = document.getElementById("chooseFinance");
const feedback = document.getElementById("answerFeedback");
riverButton.classList.toggle("is-selected", choice === "river");
financeButton.classList.toggle("is-selected", choice === "finance");
riverButton.setAttribute("aria-pressed", String(choice === "river"));
financeButton.setAttribute("aria-pressed", String(choice === "finance"));
if (choice === "river") {
feedback.textContent =
"Riverbank selected — the land along the edge of a river. Try: “The ducks swam near the riverbank.”";
} else {
feedback.textContent =
"Financial bank selected — an institution that holds and manages money. Try: “The bank approved her loan.”";
}
feedback.classList.add("is-visible");
document.getElementById("replayButton").classList.add("is-visible");
}
document.getElementById("chooseRiver").addEventListener("click", () => chooseAnswer("river"));
document.getElementById("chooseFinance").addEventListener("click", () => chooseAnswer("finance"));
document.getElementById("replayButton").addEventListener("click", () => {
visited.clear();
answerSelected = null;
currentView = "intro";
finalLayer.classList.remove("is-open");
finalLayer.setAttribute("aria-hidden", "true");
storyPanel.classList.remove("is-visible");
introCard.classList.remove("is-hidden");
riverLabel.classList.remove("is-visible");
financeLabel.classList.remove("is-visible");
document.getElementById("answerFeedback").classList.remove("is-visible");
document.getElementById("answerFeedback").textContent = "";
document.getElementById("replayButton").classList.remove("is-visible");
document.getElementById("chooseRiver").classList.remove("is-selected");
document.getElementById("chooseFinance").classList.remove("is-selected");
updateProgress();
setCameraView("compare");
});
// Project DOM labels from their 3D anchors.
const projected = new THREE.Vector3();
function positionLabel(element, anchor, visible) {
if (!visible) {
element.classList.remove("is-visible");
return;
}
anchor.getWorldPosition(projected);
projected.project(camera);
const inFront = projected.z > -1 && projected.z < 1;
if (!inFront) {
element.classList.remove("is-visible");
return;
}
const x = (projected.x * 0.5 + 0.5) * window.innerWidth;
const y = (-projected.y * 0.5 + 0.5) * window.innerHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
element.classList.add("is-visible");
}
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
const targetRiver = currentView === "river" || currentView === "compare" ? 1 : 0.1;
const targetFinance = currentView === "finance" || currentView === "compare" ? 1 : 0.1;
const opacitySpeed = reducedMotion ? 1 : 0.055;
riverOpacity = THREE.MathUtils.lerp(riverOpacity, targetRiver, opacitySpeed);
financeOpacity = THREE.MathUtils.lerp(financeOpacity, targetFinance, opacitySpeed);
setGroupOpacity(riverGroup, riverOpacity);
setGroupOpacity(financeGroup, financeOpacity);
const cameraSpeed = reducedMotion ? 1 : 1 - Math.pow(0.0009, delta);
currentTarget.lerp(desiredTarget, cameraSpeed);
currentYaw = THREE.MathUtils.lerp(currentYaw, desiredYaw, cameraSpeed);
currentPitch = THREE.MathUtils.lerp(currentPitch, desiredPitch, cameraSpeed);
currentDistance = THREE.MathUtils.lerp(currentDistance, desiredDistance, cameraSpeed);
const horizontal = Math.cos(currentPitch) * currentDistance;
camera.position.set(
currentTarget.x + Math.sin(currentYaw) * horizontal,
currentTarget.y + Math.sin(currentPitch) * currentDistance,
currentTarget.z + Math.cos(currentYaw) * horizontal
);
camera.lookAt(currentTarget);
// Gentle vignette life.
canoe.position.y = 0.26 + Math.sin(elapsed * 1.35) * 0.025;
canoe.rotation.z = Math.sin(elapsed * 1.1) * 0.018;
duck.position.y = 0.24 + Math.sin(elapsed * 1.8 + 1) * 0.018;
duck.position.x = 0.05 + Math.sin(elapsed * 0.28) * 0.18;
centralSign.position.y = Math.sin(elapsed * 0.8) * 0.035;
card.rotation.y = -0.45 + Math.sin(elapsed * 0.9) * 0.12;
card.position.y = 1.55 + Math.sin(elapsed * 1.15) * 0.07;
treeA.crown.rotation.z = Math.sin(elapsed * 0.65) * 0.018;
treeB.crown.rotation.z = Math.sin(elapsed * 0.58 + 1.5) * 0.016;
reedsA.rotation.z = Math.sin(elapsed * 1.1) * 0.025;
reedsB.rotation.z = Math.sin(elapsed * 0.95 + 1) * 0.022;
waterGlints.forEach((glint, index) => {
glint.position.x += delta * (0.06 + index * 0.004);
if (glint.position.x > 2.5) glint.position.x = -2.45;
glint.scale.x = 0.85 + Math.sin(elapsed * 1.4 + index) * 0.2;
});
positionLabel(riverLabel, riverAnchor, visited.has("river") && currentView !== "compare");
positionLabel(financeLabel, financeAnchor, visited.has("finance") && currentView !== "compare");
renderer.render(scene, camera);
}
// Start in a broad view with the central word visible.
setCameraView("compare");
currentTarget.set(0, 1.05, 0.05);
currentYaw = 0;
currentPitch = 0.48;
currentDistance = 15.8;
animate();
window.setTimeout(() => {
loading.classList.add("is-done");
}, 500);
</script>
</body>
</html>
```