Prompt specification
Build or customize the Three.js 3D scene "Neighborhood donation sorting wall" 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: Neighborhood donation sorting wall
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/neighborhood-donation-sorting-wall-x0036
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows refrigerator magnets. Construct a community pantry with magnetic category boards, shelves, and reusable crates; selecting a donation highlights its corresponding board symbol and storage location together. Low-poly.
Working Three.js Starter (neighborhood-donation-sorting-wall-x0036):
```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="#f3efe5">
<title>The Common Shelf — Community Pantry</title>
<style>
:root {
--ink: #183c37;
--muted: #6b7c76;
--cream: #fbf8ef;
--line: rgba(24, 60, 55, 0.13);
--teal: #28766b;
--gold: #f3bc4c;
--coral: #dc755f;
--green: #7da65c;
--shadow: 0 24px 70px rgba(28, 57, 49, 0.18);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9eee7;
color: var(--ink);
font-family: "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
cursor: grab;
}
.topbar {
position: fixed;
z-index: 10;
top: 0;
left: 0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 22px 26px;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
width: 48px;
height: 48px;
display: grid;
place-items: center;
border-radius: 16px;
background: var(--ink);
box-shadow: 0 10px 24px rgba(24, 60, 55, 0.2);
}
.brand-mark svg {
width: 28px;
height: 28px;
}
.eyebrow {
margin-bottom: 3px;
color: var(--teal);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.brand h1 {
margin: 0;
font-size: clamp(22px, 2.4vw, 32px);
line-height: 1;
letter-spacing: -0.045em;
}
.open-status {
display: flex;
align-items: center;
gap: 9px;
padding: 10px 14px;
border: 1px solid rgba(24, 60, 55, 0.1);
border-radius: 999px;
background: rgba(251, 248, 239, 0.8);
color: var(--ink);
font-size: 12px;
font-weight: 700;
backdrop-filter: blur(12px);
}
.open-status span {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 0 4px rgba(125, 166, 92, 0.15);
}
.panel {
position: fixed;
z-index: 20;
top: 22px;
right: 22px;
bottom: 22px;
width: 354px;
padding: 23px;
overflow: auto;
border: 1px solid rgba(255, 255, 255, 0.72);
border-radius: 28px;
background: rgba(251, 248, 239, 0.92);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.panel-header h2 {
margin: 0 0 7px;
font-size: 25px;
letter-spacing: -0.045em;
}
.panel-header p {
margin: 0 0 20px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.section-label span:last-child {
letter-spacing: 0;
text-transform: none;
font-weight: 600;
}
.donation-list {
display: grid;
gap: 9px;
margin-bottom: 18px;
}
.donation {
width: 100%;
display: grid;
grid-template-columns: 43px 1fr 16px;
align-items: center;
gap: 11px;
padding: 11px;
border: 1px solid var(--line);
border-radius: 16px;
background: rgba(255, 255, 255, 0.55);
color: var(--ink);
text-align: left;
cursor: pointer;
transition:
transform 160ms ease,
border-color 160ms ease,
background 160ms ease,
box-shadow 160ms ease;
}
.donation:hover {
transform: translateY(-2px);
border-color: rgba(24, 60, 55, 0.25);
background: white;
}
.donation.active {
border-color: var(--accent);
background: white;
box-shadow: 0 8px 20px rgba(24, 60, 55, 0.08);
}
.donation.done {
opacity: 0.67;
}
.item-icon {
width: 43px;
height: 43px;
display: grid;
place-items: center;
border-radius: 13px;
background: color-mix(in srgb, var(--accent) 17%, white);
color: var(--accent);
}
.item-icon svg {
width: 24px;
height: 24px;
}
.donation-copy {
min-width: 0;
}
.donation-copy strong {
display: block;
overflow: hidden;
margin-bottom: 3px;
font-size: 13px;
text-overflow: ellipsis;
white-space: nowrap;
}
.donation-copy small {
display: block;
overflow: hidden;
color: var(--muted);
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
}
.chevron {
color: #9aaba5;
font-size: 19px;
transition: transform 160ms ease;
}
.donation.active .chevron {
color: var(--accent);
transform: translateX(2px);
}
.detail-card {
padding: 17px;
border-radius: 20px;
background: var(--ink);
color: #fbf8ef;
box-shadow: 0 14px 30px rgba(24, 60, 55, 0.17);
}
.detail-top {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 9px;
color: rgba(251, 248, 239, 0.68);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.detail-top .quantity {
color: #f4ca6c;
}
.detail-card h3 {
margin: 0 0 15px;
font-size: 19px;
letter-spacing: -0.025em;
}
.route {
display: grid;
grid-template-columns: 1fr 20px 1fr;
align-items: stretch;
gap: 6px;
}
.route-cell {
min-width: 0;
padding: 11px 9px;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 13px;
background: rgba(255, 255, 255, 0.06);
}
.route-cell span {
display: block;
margin-bottom: 6px;
color: rgba(251, 248, 239, 0.55);
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.route-cell strong {
display: block;
overflow: hidden;
font-size: 11px;
line-height: 1.35;
text-overflow: ellipsis;
}
.route-arrow {
display: grid;
place-items: center;
color: #f4ca6c;
font-size: 18px;
}
.detail-note {
margin: 13px 0 15px;
color: rgba(251, 248, 239, 0.67);
font-size: 11px;
line-height: 1.5;
}
.received-button {
width: 100%;
padding: 11px 14px;
border: 0;
border-radius: 12px;
background: #f4ca6c;
color: var(--ink);
font-size: 12px;
font-weight: 800;
cursor: pointer;
transition: transform 160ms ease, background 160ms ease;
}
.received-button:hover {
transform: translateY(-1px);
background: #ffd97e;
}
.received-button.received {
background: #9fc17f;
}
.panel-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 16px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.legend {
display: flex;
align-items: center;
gap: 8px;
}
.legend-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: #f4ca6c;
box-shadow: 0 0 0 4px rgba(244, 202, 108, 0.16);
}
.view-controls {
position: fixed;
z-index: 12;
left: 24px;
bottom: 24px;
display: flex;
align-items: center;
gap: 9px;
}
.control-button {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 13px;
border: 1px solid rgba(24, 60, 55, 0.1);
border-radius: 13px;
background: rgba(251, 248, 239, 0.88);
color: var(--ink);
box-shadow: 0 8px 24px rgba(24, 60, 55, 0.1);
backdrop-filter: blur(12px);
font-size: 11px;
font-weight: 800;
cursor: pointer;
}
.control-button:hover {
background: white;
transform: translateY(-1px);
}
.control-button svg {
width: 15px;
height: 15px;
}
.help {
padding: 10px 13px;
border-radius: 13px;
background: rgba(24, 60, 55, 0.76);
color: rgba(255, 255, 255, 0.82);
backdrop-filter: blur(10px);
font-size: 10px;
letter-spacing: 0.02em;
}
.scene-tag {
position: fixed;
z-index: 9;
display: none;
min-width: 135px;
padding: 9px 12px;
border: 1px solid rgba(255, 255, 255, 0.75);
border-radius: 12px;
background: rgba(24, 60, 55, 0.9);
color: white;
box-shadow: 0 8px 24px rgba(24, 60, 55, 0.2);
pointer-events: none;
transform: translate(-50%, -100%);
backdrop-filter: blur(8px);
}
.scene-tag::after {
content: "";
position: absolute;
left: 50%;
bottom: -6px;
width: 11px;
height: 11px;
background: rgba(24, 60, 55, 0.9);
transform: translateX(-50%) rotate(45deg);
}
.scene-tag span {
display: block;
margin-bottom: 2px;
color: #f4ca6c;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.scene-tag strong {
display: block;
font-size: 11px;
white-space: nowrap;
}
.loading {
position: fixed;
z-index: 50;
inset: 0;
display: grid;
place-items: center;
background: #eef1e9;
transition: opacity 350ms ease, visibility 350ms ease;
}
.loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading-inner {
text-align: center;
}
.loading-magnet {
width: 38px;
height: 38px;
margin: 0 auto 15px;
border: 8px solid var(--ink);
border-top-color: #f4ca6c;
border-radius: 50%;
animation: spin 1.4s linear infinite;
}
.loading p {
color: var(--muted);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
@media (max-width: 780px) {
.topbar {
padding: 14px;
}
.brand-mark {
width: 42px;
height: 42px;
border-radius: 14px;
}
.open-status {
display: none;
}
.panel {
top: auto;
right: 10px;
bottom: 10px;
left: 10px;
width: auto;
max-height: 47vh;
padding: 16px;
border-radius: 22px;
}
.panel-header p {
margin-bottom: 12px;
}
.donation-list {
display: flex;
gap: 8px;
margin: 0 -2px 12px;
padding: 0 2px 4px;
overflow-x: auto;
}
.donation {
flex: 0 0 215px;
}
.detail-card {
padding: 14px;
}
.detail-card h3 {
margin-bottom: 11px;
}
.detail-note,
.panel-foot {
display: none;
}
.view-controls {
left: 12px;
bottom: calc(47vh + 20px);
}
.help {
display: none;
}
}
@media (max-height: 680px) and (min-width: 781px) {
.panel {
padding: 18px;
}
.panel-header p {
margin-bottom: 13px;
}
.donation {
padding: 8px;
}
.panel-foot {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly community pantry scene"></canvas>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 32 32" fill="none">
<path d="M8 21V13a8 8 0 0 1 16 0v8" stroke="#F8F4E8" stroke-width="5" stroke-linecap="round"/>
<path d="M8 20h5M19 20h5" stroke="#F4CA6C" stroke-width="5" stroke-linecap="round"/>
</svg>
</div>
<div>
<div class="eyebrow">Community pantry</div>
<h1>The Common Shelf</h1>
</div>
</div>
<div class="open-status">
<span></span>
Open today · 9–5
</div>
</header>
<aside class="panel" aria-label="Donation selection">
<div class="panel-header">
<div class="eyebrow">Donation map</div>
<h2>Where it goes</h2>
<p>Choose a donation to connect its magnetic board symbol with its reusable storage location.</p>
</div>
<div class="section-label">
<span>Incoming donations</span>
<span>3 categories</span>
</div>
<div class="donation-list">
<button class="donation" data-select="canned" style="--accent:#d99b27">
<span class="item-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<ellipse cx="12" cy="5" rx="6" ry="2.5"/>
<path d="M6 5v7c0 1.4 2.7 2.5 6 2.5s6-1.1 6-2.5V5"/>
<path d="M6 10c0 1.4 2.7 2.5 6 2.5s6-1.1 6-2.5"/>
</svg>
</span>
<span class="donation-copy">
<strong>Canned tomatoes</strong>
<small data-meta="canned">24 cans · shelf-stable</small>
</span>
<span class="chevron">›</span>
</button>
<button class="donation" data-select="produce" style="--accent:#d66f58">
<span class="item-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 8c-1-3-5-3-6-1-2 4 0 10 4 12 1 .5 2 .5 3 0 4-2 6-8 4-12-1-2-4-2-5 1Z"/>
<path d="M12 8c0-3 2-5 5-5 0 3-2 5-5 5Z"/>
</svg>
</span>
<span class="donation-copy">
<strong>Fresh produce</strong>
<small data-meta="produce">18 baskets · needed today</small>
</span>
<span class="chevron">›</span>
</button>
<button class="donation" data-select="staples" style="--accent:#28766b">
<span class="item-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 21V4"/>
<path d="M12 6c-3-3-6-1-6-1 0 3 2 5 6 5M12 6c3-3 6-1 6-1 0 3-2 5-6 5"/>
<path d="M12 12c-3-3-6-1-6-1 0 3 2 5 6 5M12 12c3-3 6-1 6-1 0 3-2 5-6 5"/>
<path d="M12 18c-3-3-6-1-6-1 0 3 2 5 6 5M12 18c3-3 6-1 6-1 0 3-2 5-6 5"/>
</svg>
</span>
<span class="donation-copy">
<strong>Dry staples</strong>
<small data-meta="staples">32 bags · needed this week</small>
</span>
<span class="chevron">›</span>
</button>
</div>
<section class="detail-card" aria-live="polite">
<div class="detail-top">
<span id="detailStatus">Incoming donation</span>
<span class="quantity" id="detailQuantity">24 cans</span>
</div>
<h3 id="detailName">Canned tomatoes</h3>
<div class="route">
<div class="route-cell">
<span>01 · Board symbol</span>
<strong id="detailBoard">Canned goods</strong>
</div>
<div class="route-arrow">→</div>
<div class="route-cell">
<span>02 · Storage</span>
<strong id="detailStorage">Shelf A · Crate A1</strong>
</div>
</div>
<p class="detail-note" id="detailNote">
Stack upright in the labeled reusable crate. The magnetic can symbol matches this pantry category.
</p>
<button class="received-button" id="receivedButton">Mark as received</button>
</section>
<div class="panel-foot">
<span class="legend"><span class="legend-dot"></span>Gold marks the selected route</span>
<span>Tap a magnet, board, or crate</span>
</div>
</aside>
<div class="scene-tag" id="boardTag">
<span>Board symbol</span>
<strong id="boardTagText">Canned goods</strong>
</div>
<div class="scene-tag" id="storeTag">
<span>Storage location</span>
<strong id="storeTagText">Shelf A · Crate A1</strong>
</div>
<div class="view-controls">
<button class="control-button" id="resetView" title="Reset camera view">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 12a9 9 0 1 0 3-6.7L3 8"/>
<path d="M3 3v5h5"/>
</svg>
Reset view
</button>
<div class="help">Drag to orbit · Scroll to zoom · Select an item</div>
</div>
<div class="loading" id="loading">
<div class="loading-inner">
<div class="loading-magnet"></div>
<p>Opening the pantry</p>
</div>
</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.getElementById("scene");
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9eee7);
scene.fog = new THREE.Fog(0xe9eee7, 19, 34);
const camera = new THREE.PerspectiveCamera(
33,
window.innerWidth / window.innerHeight,
0.1,
60
);
const clock = new THREE.Clock();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const projected = new THREE.Vector3();
const cameraState = {
yaw: 0.55,
pitch: 0.44,
distance: 15.4,
target: new THREE.Vector3(-0.5, 1.35, -0.25)
};
let cameraMotion = null;
let currentId = null;
let highlight = null;
const donations = [
{
id: "canned",
name: "Canned tomatoes",
quantity: "24 cans",
meta: "24 cans · shelf-stable",
board: "Canned goods",
symbolName: "Can symbol",
storage: "Shelf A · Crate A1",
note: "Stack upright in the labeled reusable crate. The magnetic can symbol matches this pantry category.",
accent: 0xd99b27,
panel: 0xffdc85,
boardX: -0.65,
storageX: -0.65,
shelfY: 0.56,
magnetX: -5.0,
symbolGroup: null,
boardGroup: null,
crateGroup: null,
magnetGroup: null,
received: false
},
{
id: "produce",
name: "Fresh produce",
quantity: "18 baskets",
meta: "18 baskets · needed today",
board: "Fresh produce",
symbolName: "Apple symbol",
storage: "Shelf A · Crate A2",
note: "Keep in the cool lower crate for same-day pickup. The magnetic apple symbol identifies fresh items.",
accent: 0xd66f58,
panel: 0xf6bd91,
boardX: 1.45,
storageX: 1.45,
shelfY: 0.56,
magnetX: -4.43,
symbolGroup: null,
boardGroup: null,
crateGroup: null,
magnetGroup: null,
received: false
},
{
id: "staples",
name: "Dry staples",
quantity: "32 bags",
meta: "32 bags · needed this week",
board: "Pantry staples",
symbolName: "Grain symbol",
storage: "Shelf B · Crate B1",
note: "Place sealed bags in the upper reusable crate. The magnetic grain symbol identifies dry pantry goods.",
accent: 0x28766b,
panel: 0xa9d3c5,
boardX: 3.45,
storageX: 3.45,
shelfY: 1.68,
magnetX: -3.86,
symbolGroup: null,
boardGroup: null,
crateGroup: null,
magnetGroup: null,
received: false
}
];
const donationsById = Object.fromEntries(
donations.map(donation => [donation.id, donation])
);
donations.forEach(donation => {
donation.boardAnchor = new THREE.Vector3(
donation.boardX,
3.63,
-3.00
);
donation.storageAnchor = new THREE.Vector3(
donation.storageX,
donation.shelfY + 0.39,
-2.24
);
donation.magnetAnchor = new THREE.Vector3(
donation.magnetX,
2.03,
-1.55
);
});
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0,
flatShading: true,
...options
});
}
const palette = {
wall: material(0xf1eee4),
wallSide: material(0xe7e5da),
floor: material(0xd9d1bf),
trim: material(0xf7f3e8),
teal: material(0x28766b),
darkTeal: material(0x183c37),
wood: material(0xb9824f),
woodLight: material(0xd2a46f),
woodDark: material(0x875d3d),
fridge: material(0xf7f4e9),
fridgeSide: material(0xc9d8cf),
mustard: material(0xe6aa32),
coral: material(0xd86f58),
green: material(0x79a457),
cream: material(0xfff7df),
metal: material(0x6f817d, { metalness: 0.25, roughness: 0.48 })
};
function addBox(parent, width, height, depth, mat, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
segments,
mat,
x = 0,
y = 0,
z = 0
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
mat
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function makeTextPlane(
text,
width,
height,
options = {}
) {
const {
background = "#ffffff",
foreground = "#183c37",
border = null,
fontSize = 70
} = options;
const textCanvas = document.createElement("canvas");
textCanvas.width = 1024;
textCanvas.height = 256;
const ctx = textCanvas.getContext("2d");
ctx.clearRect(0, 0, 1024, 256);
if (background) {
roundedRect(ctx, 8, 8, 1008, 240, 34);
ctx.fillStyle = background;
ctx.fill();
if (border) {
ctx.strokeStyle = border;
ctx.lineWidth = 8;
ctx.stroke();
}
}
ctx.fillStyle = foreground;
ctx.font = `800 ${fontSize}px "Arial Rounded MT Bold", "Trebuchet MS", sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 512, 132, 930);
const texture = new THREE.CanvasTexture(textCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
renderer.capabilities.getMaxAnisotropy(),
8
);
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false,
side: THREE.DoubleSide
})
);
return mesh;
}
function tagDonation(object, id) {
object.traverse(child => {
if (child.isMesh || child.isLine || child.isPoints) {
child.userData.donationId = id;
}
});
}
function createSymbol(id) {
const group = new THREE.Group();
if (id === "canned") {
const body = addCylinder(
group,
0.27,
0.27,
0.50,
10,
material(0xe2a52f)
);
body.rotation.x = Math.PI / 2;
addBox(
group,
0.34,
0.18,
0.025,
material(0xfff4d5),
0,
0,
0.265
);
addBox(
group,
0.23,
0.045,
0.032,
material(0xd86f58),
0,
0,
0.282
);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(0.245, 0.025, 6, 16),
material(0xf1c45b)
);
rim.position.z = 0.25;
group.add(rim);
}
if (id === "produce") {
const apple = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.34, 0),
material(0xd86f58)
);
apple.position.y = -0.05;
apple.scale.set(1, 0.93, 0.72);
apple.castShadow = true;
group.add(apple);
const stem = addCylinder(
group,
0.025,
0.035,
0.18,
6,
material(0x6f6944)
);
stem.position.set(0.03, 0.26, 0);
const leaf = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.13, 0),
material(0x79a457)
);
leaf.position.set(0.15, 0.29, 0);
leaf.scale.set(1.6, 0.45, 0.55);
leaf.rotation.z = -0.35;
group.add(leaf);
}
if (id === "staples") {
const stem = addCylinder(
group,
0.025,
0.03,
0.55,
6,
material(0x28766b)
);
stem.position.y = -0.02;
const grainMaterial = material(0xe2aa35);
for (let side = -1; side <= 1; side += 2) {
for (let index = 0; index < 3; index += 1) {
const grain = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 6, 4),
grainMaterial
);
grain.position.set(
side * (0.11 + index * 0.015),
0.19 - index * 0.17,
0
);
grain.scale.set(0.62, 1.25, 0.52);
grain.rotation.z = side * (0.55 + index * 0.08);
grain.castShadow = true;
group.add(grain);
}
}
}
return group;
}
function createCrate(donation) {
const group = new THREE.Group();
const width = 1.08;
const height = 0.76;
const depth = 0.86;
addBox(
group,
width,
0.08,
depth,
palette.wood,
0,
-height / 2 + 0.04,
0
);
for (const x of [-0.48, 0.48]) {
for (const z of [-0.37, 0.37]) {
addBox(
group,
0.09,
height,
0.09,
palette.woodDark,
x,
0,
z
);
}
}
for (const z of [-0.40, 0.40]) {
for (const y of [-0.25, -0.04, 0.17]) {
addBox(
group,
0.98,
0.08,
0.07,
palette.woodLight,
0,
y,
z
);
}
}
for (const x of [-0.50, 0.50]) {
for (const y of [-0.25, -0.04, 0.17]) {
addBox(
group,
0.07,
0.08,
0.72,
palette.woodLight,
x,
y,
0
);
}
}
addBox(
group,
0.42,
0.075,
0.075,
palette.darkTeal,
0,
0.31,
0.43
);
if (donation.id === "canned") {
for (let x = -0.28; x <= 0.28; x += 0.28) {
for (let z = -0.18; z <= 0.18; z += 0.36) {
const can = addCylinder(
group,
0.12,
0.12,
0.37,
9,
material(x < 0 ? 0xd96f57 : 0xe2a52f),
x,
-0.07,
z
);
const band = addCylinder(
group,
0.122,
0.122,
0.08,
9,
palette.cream,
x,
-0.05,
z
);
band.castShadow = false;
}
}
}
if (donation.id === "produce") {
const produceColors = [
0xd96f57,
0xe2a52f,
0x79a457,
0xe48645
];
for (let index = 0; index < 8; index += 1) {
const produce = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.18, 0),
material(produceColors[index % produceColors.length])
);
produce.position.set(
-0.34 + (index % 4) * 0.22,
-0.11 + Math.floor(index / 4) * 0.22,
index % 2 === 0 ? -0.13 : 0.13
);
produce.scale.set(1, 0.9, 0.9);
produce.castShadow = true;
group.add(produce);
}
}
if (donation.id === "staples") {
for (let index = 0; index < 5; index += 1) {
const bag = addBox(
group,
0.27,
0.38,
0.27,
material(index % 2 === 0 ? 0xdfb758 : 0xe6d8ad),
-0.34 + index * 0.17,
-0.05,
index % 2 === 0 ? -0.11 : 0.11
);
bag.rotation.y = (index - 2) * 0.08;
}
}
const code = donation.storage.split("Crate ")[1];
const label = makeTextPlane(
code,
0.33,
0.16,
{
background: "#fff8e7",
foreground: "#183c37",
fontSize: 92
}
);
label.position.set(0, -0.13, 0.447);
group.add(label);
group.position.copy(donation.storageAnchor);
tagDonation(group, donation.id);
return group;
}
function createMagnet(donation) {
const group = new THREE.Group();
addBox(
group,
0.47,
0.59,
0.065,
palette.cream,
0,
0,
0
);
addBox(
group,
0.47,
0.12,
0.08,
material(donation.accent),
0,
0.235,
0.015
);
const symbol = createSymbol(donation.id);
symbol.scale.setScalar(0.33);
symbol.position.set(0, -0.025, 0.085);
group.add(symbol);
const pin = addCylinder(
group,
0.035,
0.035,
0.025,
8,
palette.metal,
0,
0.235,
0.065
);
pin.rotation.x = Math.PI / 2;
group.position.copy(donation.magnetAnchor);
tagDonation(group, donation.id);
return group;
}
function createBoard(donation) {
const group = new THREE.Group();
addBox(
group,
1.52,
1.38,
0.14,
material(0xe4dece),
donation.boardX,
3.51,
-3.24
);
addBox(
group,
1.40,
1.26,
0.065,
material(donation.panel),
donation.boardX,
3.51,
-3.145
);
for (const xOffset of [-0.64, 0.64]) {
for (const yOffset of [-0.55, 0.55]) {
const magnet = new THREE.Mesh(
new THREE.CylinderGeometry(0.04, 0.04, 0.025, 8),
material(donation.accent)
);
magnet.rotation.x = Math.PI / 2;
magnet.position.set(
donation.boardX + xOffset,
3.51 + yOffset,
-3.095
);
group.add(magnet);
}
}
const symbol = createSymbol(donation.id);
symbol.position.copy(donation.boardAnchor);
group.add(symbol);
donation.symbolGroup = symbol;
const label = makeTextPlane(
donation.board.toUpperCase(),
1.18,
0.23,
{
background: "#fff8e7",
foreground: "#183c37",
fontSize: 64
}
);
label.position.set(donation.boardX, 3.06, -3.095);
group.add(label);
tagDonation(group, donation.id);
donation.boardGroup = group;
return group;
}
// Room shell.
addBox(scene, 12.2, 0.22, 7.4, palette.floor, 0, -0.12, 0);
addBox(scene, 12.2, 5.6, 0.18, palette.wall, 0, 2.7, -3.42);
addBox(scene, 0.18, 5.6, 7.2, palette.wallSide, -6.02, 2.7, -0.02);
addBox(scene, 12.0, 0.17, 0.09, palette.trim, 0, 0.08, -3.28);
addBox(scene, 0.09, 0.17, 7.0, palette.trim, -5.88, 0.08, 0);
// Subtle floor tile lines.
const tileMaterial = material(0xcfc5b1);
for (let x = -5; x <= 5; x += 2) {
addBox(scene, 0.018, 0.008, 7.0, tileMaterial, x, 0.005, 0);
}
for (let z = -2.5; z <= 2.5; z += 1.7) {
addBox(scene, 11.8, 0.008, 0.018, tileMaterial, 0, 0.006, z);
}
// Fridge.
const fridge = new THREE.Group();
addBox(fridge, 2.15, 3.25, 1.55, palette.fridge, -4.45, 1.625, -2.55);
addBox(fridge, 0.10, 3.15, 1.58, palette.fridgeSide, -3.365, 1.63, -2.55);
addBox(fridge, 2.04, 1.25, 0.12, palette.fridge, -4.45, 2.48, -1.72);
addBox(fridge, 2.04, 1.94, 0.12, palette.fridge, -4.45, 0.96, -1.72);
addBox(fridge, 0.08, 0.48, 0.08, palette.metal, -3.63, 2.37, -1.57);
addBox(fridge, 0.08, 0.57, 0.08, palette.metal, -3.63, 1.35, -1.57);
addBox(fridge, 0.26, 0.12, 0.26, palette.darkTeal, -5.1, 0.07, -2.12);
addBox(fridge, 0.26, 0.12, 0.26, palette.darkTeal, -3.8, 0.07, -2.12);
const fridgeTitle = makeTextPlane(
"COMMON PANTRY",
1.45,
0.31,
{
background: "#28766b",
foreground: "#fff8e7",
fontSize: 72
}
);
fridgeTitle.position.set(-4.45, 2.91, -1.645);
fridge.add(fridgeTitle);
scene.add(fridge);
// Wall messaging.
const welcomeSign = makeTextPlane(
"TAKE WHAT YOU NEED · SHARE WHAT YOU CAN",
4.65,
0.43,
{
background: "#183c37",
foreground: "#fff8e7",
fontSize: 58
}
);
welcomeSign.position.set(-4.33, 4.58, -3.29);
scene.add(welcomeSign);
const sortSign = makeTextPlane(
"SORT · MATCH · REUSE",
4.70,
0.42,
{
background: "#fff8e7",
foreground: "#28766b",
border: "#d8cfbd",
fontSize: 64
}
);
sortSign.position.set(1.42, 4.67, -3.29);
scene.add(sortSign);
// Shelving.
const shelfGroup = new THREE.Group();
addBox(shelfGroup, 6.15, 0.12, 1.28, palette.woodLight, 1.45, 0.50, -2.32);
addBox(shelfGroup, 6.15, 0.12, 1.28, palette.woodLight, 1.45, 1.62, -2.32);
for (const x of [-1.52, 4.42]) {
addBox(shelfGroup, 0.12, 3.05, 0.12, palette.woodDark, x, 1.50, -2.87);
}
addBox(shelfGroup, 0.12, 0.12, 1.20, palette.woodDark, -1.52, 0.40, -2.32);
addBox(shelfGroup, 0.12, 0.12, 1.20, palette.woodDark, 4.42, 0.40, -2.32);
addBox(shelfGroup, 0.12, 0.12, 1.20, palette.woodDark, -1.52, 1.52, -2.32);
addBox(shelfGroup, 0.12, 0.12, 1.20, palette.woodDark, 4.42, 1.52, -2.32);
const shelfALabel = makeTextPlane(
"SHELF A",
0.84,
0.22,
{
background: "#fff8e7",
foreground: "#183c37",
fontSize: 80
}
);
shelfALabel.position.set(-1.02, 0.50, -1.665);
shelfGroup.add(shelfALabel);
const shelfBLabel = makeTextPlane(
"SHELF B",
0.84,
0.22,
{
background: "#fff8e7",
foreground: "#183c37",
fontSize: 80
}
);
shelfBLabel.position.set(-1.02, 1.62, -1.665);
shelfGroup.add(shelfBLabel);
// Small pantry jars and boxes.
const jarColors = [0xd8a33a, 0x6c9e7b, 0xd77b63];
for (let index = 0; index < 3; index += 1) {
const jar = addCylinder(
shelfGroup,
0.16,
0.18,
0.42,
8,
material(jarColors[index]),
-0.85 + index * 0.48,
1.92,
-2.44
);
const lid = addCylinder(
shelfGroup,
0.18,
0.18,
0.07,
8,
palette.cream,
jar.position.x,
2.16,
jar.position.z
);
lid.castShadow = false;
}
addBox(shelfGroup, 0.52, 0.44, 0.50, palette.cream, 0.78, 1.90, -2.45);
addBox(shelfGroup, 0.43, 0.36, 0.45, material(0xb9c99f), 1.28, 1.88, -2.47);
addBox(shelfGroup, 0.55, 0.45, 0.48, material(0xd6b575), -1.06, 0.82, -2.43);
scene.add(shelfGroup);
// Donation crates, magnetic boards, and fridge magnets.
for (const donation of donations) {
donation.crateGroup = createCrate(donation);
scene.add(donation.crateGroup);
scene.add(createBoard(donation));
donation.magnetGroup = createMagnet(donation);
scene.add(donation.magnetGroup);
}
// Community donation table.
const table = new THREE.Group();
addBox(table, 2.45, 0.14, 1.20, palette.woodLight, -2.50, 1.02, 0.35);
for (const x of [-3.47, -1.53]) {
for (const z of [-0.05, 0.75]) {
addBox(table, 0.11, 1.00, 0.11, palette.woodDark, x, 0.49, z);
}
}
addBox(table, 1.75, 0.55, 0.12, palette.darkTeal, -2.50, 1.48, -0.10);
const tableSign = makeTextPlane(
"ADD TO THE COMMON SHELF",
1.60,
0.34,
{
background: "#28766b",
foreground: "#fff8e7",
fontSize: 56
}
);
tableSign.position.set(-2.50, 1.48, -0.025);
table.add(tableSign);
addBox(table, 0.82, 0.42, 0.62, material(0xc9975c), -2.83, 1.30, 0.52);
addBox(table, 0.58, 0.26, 0.46, material(0xe2a52f), -2.83, 1.61, 0.52);
scene.add(table);
// Rug.
addBox(scene, 3.65, 0.035, 1.75, material(0xc8b28f), 0.20, 0.025, 0.85);
addBox(scene, 3.30, 0.039, 1.40, material(0xe3d3ad), 0.20, 0.030, 0.85);
addBox(scene, 2.94, 0.043, 1.04, material(0x82a98f), 0.20, 0.035, 0.85);
// Reusable collection basket.
const basket = new THREE.Group();
addBox(basket, 0.95, 0.55, 0.75, material(0xd0a36b), 0.95, 0.29, 1.10);
addBox(basket, 0.78, 0.045, 0.58, palette.darkTeal, 0.95, 0.58, 1.10);
const basketLabel = makeTextPlane(
"GIVE",
0.52,
0.23,
{
background: "#fff8e7",
foreground: "#28766b",
fontSize: 90
}
);
basketLabel.position.set(0.95, 0.33, 1.482);
basket.add(basketLabel);
scene.add(basket);
// Low-poly plant.
const plant = new THREE.Group();
addCylinder(plant, 0.34, 0.25, 0.48, 8, material(0xc87352), 4.75, 0.25, 0.12);
addCylinder(plant, 0.025, 0.035, 1.05, 6, material(0x517448), 4.75, 0.82, 0.12);
const leafColors = [0x557d50, 0x6e9b58, 0x83aa64];
for (let index = 0; index < 8; index += 1) {
const leaf = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.33, 0),
material(leafColors[index % leafColors.length])
);
const angle = index * 1.35;
leaf.position.set(
4.75 + Math.cos(angle) * 0.30,
0.82 + index * 0.12,
0.12 + Math.sin(angle) * 0.27
);
leaf.scale.set(0.55, 1.35, 0.30);
leaf.rotation.set(Math.sin(angle) * 0.65, angle, Math.cos(angle) * 0.65);
leaf.castShadow = true;
plant.add(leaf);
}
scene.add(plant);
// Lighting.
scene.add(new THREE.HemisphereLight(0xfff8e8, 0x80948b, 2.1));
const sun = new THREE.DirectionalLight(0xfff1d8, 3.1);
sun.position.set(-4.5, 10, 7.5);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -9;
sun.shadow.camera.right = 9;
sun.shadow.camera.top = 9;
sun.shadow.camera.bottom = -7;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.0007;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d9e3, 1.2);
fill.position.set(7, 6, -2);
scene.add(fill);
const frontLight = new THREE.DirectionalLight(0xffdca6, 0.75);
frontLight.position.set(0, 3, 10);
scene.add(frontLight);
function updateCamera() {
const horizontal = cameraState.distance * Math.cos(cameraState.pitch);
camera.position.set(
cameraState.target.x + Math.sin(cameraState.yaw) * horizontal,
cameraState.target.y + Math.sin(cameraState.pitch) * cameraState.distance,
cameraState.target.z + Math.cos(cameraState.yaw) * horizontal
);
camera.lookAt(cameraState.target);
camera.updateMatrixWorld();
}
function disposeHighlight() {
if (!highlight) return;
scene.remove(highlight.group);
highlight.group.traverse(object => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
if (Array.isArray(object.material)) {
object.material.forEach(mat => mat.dispose());
} else {
object.material.dispose();
}
}
});
highlight = null;
}
function selectDonation(id, announce = true) {
const donation = donationsById[id];
if (!donation) return;
currentId = id;
disposeHighlight();
const group = new THREE.Group();
const boardRing = new THREE.Mesh(
new THREE.TorusGeometry(0.50, 0.028, 6, 32),
new THREE.MeshBasicMaterial({
color: 0xffd76b,
transparent: true,
opacity: 0.9,
depthWrite: false,
toneMapped: false
})
);
boardRing.position.copy(donation.boardAnchor);
boardRing.position.z += 0.06;
group.add(boardRing);
const storageOutline = new THREE.LineSegments(
new THREE.EdgesGeometry(
new THREE.BoxGeometry(1.20, 0.90, 0.99)
),
new THREE.LineBasicMaterial({
color: 0xffd76b,
transparent: true,
opacity: 0.9,
depthWrite: false,
toneMapped: false
})
);
storageOutline.position.copy(donation.storageAnchor);
group.add(storageOutline);
const magnetRing = new THREE.Mesh(
new THREE.TorusGeometry(0.36, 0.022, 6, 28),
new THREE.MeshBasicMaterial({
color: 0xffd76b,
transparent: true,
opacity: 0.85,
depthWrite: false,
toneMapped: false
})
);
magnetRing.position.copy(donation.magnetAnchor);
magnetRing.position.z += 0.10;
group.add(magnetRing);
const connectorGeometry = new THREE.BufferGeometry().setFromPoints([
donation.boardAnchor.clone().add(new THREE.Vector3(0, 0, 0.10)),
donation.storageAnchor.clone().add(new THREE.Vector3(0, 0, 0.18))
]);
const connector = new THREE.Line(
connectorGeometry,
new THREE.LineDashedMaterial({
color: 0xd89e2e,
dashSize: 0.12,
gapSize: 0.075,
transparent: true,
opacity: 0.72,
depthWrite: false
})
);
connector.computeLineDistances();
group.add(connector);
scene.add(group);
highlight = {
group,
boardRing,
storageOutline,
magnetRing,
connector
};
document.querySelectorAll("[data-select]").forEach(button => {
const selected = button.dataset.select === id;
button.classList.toggle("active", selected);
button.classList.toggle("done", selected && donation.received);
button.setAttribute("aria-pressed", String(selected));
});
document.getElementById("detailName").textContent = donation.name;
document.getElementById("detailQuantity").textContent = donation.quantity;
document.getElementById("detailBoard").textContent = donation.board;
document.getElementById("detailStorage").textContent = donation.storage;
document.getElementById("detailNote").textContent = donation.note;
document.getElementById("detailStatus").textContent = donation.received
? "Received"
: "Incoming donation";
document.getElementById("boardTagText").textContent = donation.board;
document.getElementById("storeTagText").textContent = donation.storage;
const receivedButton = document.getElementById("receivedButton");
receivedButton.classList.toggle("received", donation.received);
receivedButton.textContent = donation.received
? "Received — thank you!"
: "Mark as received";
document.querySelector(`[data-meta="${id}"]`).textContent = donation.received
? "Received · thank you!"
: donation.meta;
if (announce) {
document.getElementById("detailStatus").textContent = donation.received
? "Received"
: "Selected donation";
}
}
function toggleReceived() {
if (!currentId) return;
const donation = donationsById[currentId];
donation.received = !donation.received;
selectDonation(currentId, false);
}
document.getElementById("receivedButton").addEventListener("click", toggleReceived);
document.querySelectorAll("[data-select]").forEach(button => {
button.addEventListener("click", () => {
selectDonation(button.dataset.select);
});
});
function getDonationFromObject(object) {
let current = object;
while (current) {
if (current.userData.donationId) {
return current.userData.donationId;
}
current = current.parent;
}
return null;
}
function pickAtEvent(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(scene.children, true);
for (const intersection of intersections) {
const id = getDonationFromObject(intersection.object);
if (id) {
selectDonation(id);
return;
}
}
}
function pointerIntersectsDonation(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(scene.children, true);
return intersections.some(
intersection => getDonationFromObject(intersection.object)
);
}
let dragging = false;
let moved = false;
let lastX = 0;
let lastY = 0;
let activePointer = null;
canvas.addEventListener("pointerdown", event => {
if (event.button !== 0) return;
dragging = true;
moved = false;
activePointer = event.pointerId;
lastX = event.clientX;
lastY = event.clientY;
cameraMotion = null;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", event => {
if (dragging && event.pointerId === activePointer) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(dx) + Math.abs(dy) > 2) moved = true;
cameraState.yaw -= dx * 0.005;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.004,
0.18,
0.90
);
lastX = event.clientX;
lastY = event.clientY;
} else if (!dragging) {
canvas.style.cursor = pointerIntersectsDonation(event)
? "pointer"
: "grab";
}
});
canvas.addEventListener("pointerup", event => {
if (event.pointerId !== activePointer) return;
if (!moved) {
pickAtEvent(event);
}
dragging = false;
activePointer = null;
canvas.style.cursor = "grab";
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
activePointer = null;
canvas.style.cursor = "grab";
});
canvas.addEventListener("wheel", event => {
event.preventDefault();
cameraMotion = null;
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance * Math.exp(event.deltaY * 0.001),
9.5,
21
);
}, { passive: false });
canvas.addEventListener("contextmenu", event => event.preventDefault());
function resetView() {
cameraMotion = {
elapsed: 0,
from: {
yaw: cameraState.yaw,
pitch: cameraState.pitch,
distance: cameraState.distance,
target: cameraState.target.clone()
},
to: {
yaw: 0.55,
pitch: 0.44,
distance: 15.4,
target: new THREE.Vector3(-0.5, 1.35, -0.25)
}
};
}
document.getElementById("resetView").addEventListener("click", resetView);
window.addEventListener("keydown", event => {
if (event.key.toLowerCase() === "r") {
resetView();
}
if (event.key === "ArrowLeft") cameraState.yaw += 0.08;
if (event.key === "ArrowRight") cameraState.yaw -= 0.08;
if (event.key === "ArrowUp") cameraState.pitch += 0.05;
if (event.key === "ArrowDown") cameraState.pitch -= 0.05;
if (event.key === "+" || event.key === "=") cameraState.distance -= 0.5;
if (event.key === "-") cameraState.distance += 0.5;
cameraState.pitch = THREE.MathUtils.clamp(cameraState.pitch, 0.18, 0.90);
cameraState.distance = THREE.MathUtils.clamp(cameraState.distance, 9.5, 21);
});
function updateTag(element, worldPosition, offsetY) {
projected.copy(worldPosition);
projected.y += offsetY;
projected.project(camera);
const visible = projected.z > -1 && projected.z < 1;
element.style.display = visible ? "block" : "none";
element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (cameraMotion) {
cameraMotion.elapsed += delta / 0.75;
const t = Math.min(cameraMotion.elapsed, 1);
const eased = 1 - Math.pow(1 - t, 3);
cameraState.yaw = THREE.MathUtils.lerp(
cameraMotion.from.yaw,
cameraMotion.to.yaw,
eased
);
cameraState.pitch = THREE.MathUtils.lerp(
cameraMotion.from.pitch,
cameraMotion.to.pitch,
eased
);
cameraState.distance = THREE.MathUtils.lerp(
cameraMotion.from.distance,
cameraMotion.to.distance,
eased
);
cameraState.target.lerpVectors(
cameraMotion.from.target,
cameraMotion.to.target,
eased
);
if (t >= 1) cameraMotion = null;
}
updateCamera();
for (const donation of donations) {
const selected = donation.id === currentId;
const pulse = 1 + Math.sin(elapsed * 3.2) * 0.025;
donation.symbolGroup.scale.setScalar(selected ? 1.07 * pulse : 1);
donation.magnetGroup.scale.setScalar(selected ? 1 + Math.sin(elapsed * 3.2) * 0.035 : 1);
donation.crateGroup.scale.setScalar(selected ? 1.015 * pulse : 1);
donation.symbolGroup.rotation.z = selected
? Math.sin(elapsed * 1.4) * 0.025
: 0;
donation.magnetGroup.rotation.z = selected
? Math.sin(elapsed * 2.0) * 0.045
: 0;
}
if (highlight) {
const pulse = 0.5 + 0.5 * Math.sin(elapsed * 3.2);
highlight.boardRing.material.opacity = 0.62 + pulse * 0.34;
highlight.storageOutline.material.opacity = 0.58 + pulse * 0.38;
highlight.magnetRing.material.opacity = 0.52 + pulse * 0.40;
highlight.connector.material.opacity = 0.48 + pulse * 0.28;
highlight.boardRing.scale.setScalar(1 + pulse * 0.055);
highlight.storageOutline.scale.setScalar(1 + pulse * 0.018);
highlight.magnetRing.scale.setScalar(1 + pulse * 0.06);
}
renderer.render(scene, camera);
if (currentId) {
const donation = donationsById[currentId];
updateTag(
document.getElementById("boardTag"),
donation.boardAnchor,
0.60
);
updateTag(
document.getElementById("storeTag"),
donation.storageAnchor,
0.65
);
}
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener("resize", resize);
updateCamera();
selectDonation("canned", false);
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```