Prompt specification
Build or customize the Three.js 3D scene "Offer and Want Token Pair" 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: Offer and Want Token Pair
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/offer-and-want-token-pair-x3121
Scene Description Prompt:
Low-poly fish and grain exchange cards clearly separate goods owned from goods wanted. Build one HTML file with Three.js from cdnjs.
Working Three.js Starter (offer-and-want-token-pair-x3121):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tide & Grain — Exchange Board</title>
<style>
:root {
--ink: #173c3d;
--muted: #667a76;
--paper: #f4f1e9;
--card: #fffdf8;
--line: #d9ded4;
--owned: #2f735d;
--owned-soft: #e5f1e8;
--owned-line: #a9cdb8;
--wanted: #c16c3c;
--wanted-soft: #f8eadc;
--wanted-line: #e4b58f;
--gold: #e6b94e;
--teal: #2f7778;
--shadow: 0 18px 50px rgba(35, 67, 62, 0.1);
}
* {
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
body {
margin: 0;
min-width: 320px;
min-height: 100vh;
color: var(--ink);
background:
radial-gradient(circle at 12% 20%, rgba(230, 185, 78, 0.1), transparent 26rem),
radial-gradient(circle at 88% 78%, rgba(47, 119, 120, 0.09), transparent 30rem),
var(--paper);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
width: min(1480px, calc(100% - 40px));
margin: 0 auto;
padding: 24px 0 38px;
}
.topbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
padding: 4px 2px 24px;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
text-decoration: none;
color: var(--ink);
}
.brand-mark {
position: relative;
width: 47px;
height: 47px;
border: 1px solid rgba(23, 60, 61, 0.22);
border-radius: 14px;
background: var(--ink);
box-shadow: 0 8px 20px rgba(23, 60, 61, 0.14);
overflow: hidden;
}
.brand-mark::before,
.brand-mark::after {
content: "";
position: absolute;
left: 9px;
width: 28px;
height: 14px;
border: 3px solid var(--gold);
border-color: var(--gold) transparent transparent;
border-radius: 50%;
}
.brand-mark::before {
top: 10px;
transform: rotate(8deg);
}
.brand-mark::after {
bottom: 8px;
transform: rotate(-8deg);
}
.brand-copy strong {
display: block;
font-size: 16px;
line-height: 1.1;
letter-spacing: -0.02em;
}
.brand-copy span {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.topbar-nav {
display: flex;
align-items: center;
gap: 9px;
}
.nav-pill {
padding: 10px 14px;
border: 1px solid transparent;
border-radius: 999px;
color: var(--muted);
font-size: 12px;
font-weight: 750;
}
.nav-pill.active {
color: var(--ink);
border-color: var(--line);
background: rgba(255, 253, 248, 0.72);
}
.market-status {
display: flex;
align-items: center;
gap: 9px;
padding: 9px 13px;
border: 1px solid var(--line);
border-radius: 999px;
background: rgba(255, 253, 248, 0.76);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #4eae73;
box-shadow: 0 0 0 4px rgba(78, 174, 115, 0.13);
}
.exchange-layout {
display: grid;
grid-template-columns: minmax(0, 1.42fr) minmax(450px, 0.9fr);
gap: 18px;
align-items: stretch;
}
.scene-card {
position: relative;
min-height: 680px;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 30px;
background:
radial-gradient(circle at 50% 38%, rgba(60, 130, 124, 0.34), transparent 36%),
linear-gradient(155deg, #214f50 0%, #153d3e 56%, #103234 100%);
box-shadow: var(--shadow);
isolation: isolate;
}
.scene-card::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
opacity: 0.15;
background-image:
linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
background-size: 54px 54px;
mask-image: linear-gradient(to bottom, black, transparent 74%);
}
#scene {
position: absolute;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
#scene canvas:active {
cursor: grabbing;
}
.scene-heading {
position: absolute;
top: 28px;
left: 30px;
z-index: 2;
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 9px;
color: rgba(255, 255, 255, 0.64);
font-size: 10px;
font-weight: 850;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 21px;
height: 1px;
background: currentColor;
}
.scene-heading h1 {
max-width: 420px;
margin: 0;
color: #fffaf0;
font-size: clamp(30px, 3.6vw, 56px);
font-weight: 780;
line-height: 0.98;
letter-spacing: -0.055em;
}
.scene-heading h1 em {
color: #e9c664;
font-family: Georgia, serif;
font-weight: 500;
}
.scene-subtitle {
max-width: 330px;
margin: 13px 0 0;
color: rgba(255, 255, 255, 0.63);
font-size: 13px;
line-height: 1.6;
}
.scene-labels {
position: absolute;
z-index: 3;
top: 210px;
left: 27px;
right: 27px;
display: flex;
justify-content: space-between;
pointer-events: none;
}
.scene-label {
width: min(210px, 43%);
padding: 13px 14px;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 15px;
color: #fff;
background: rgba(12, 44, 45, 0.58);
box-shadow: 0 12px 25px rgba(0, 0, 0, 0.08);
backdrop-filter: blur(9px);
}
.scene-label.wanted-label {
text-align: right;
}
.label-kind {
display: inline-flex;
align-items: center;
gap: 6px;
margin-bottom: 6px;
font-size: 9px;
font-weight: 900;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.label-kind::before {
content: "";
width: 7px;
height: 7px;
border-radius: 2px;
background: #83c69e;
}
.wanted-label .label-kind::before {
background: #efa466;
}
.scene-label strong {
display: block;
font-size: 13px;
letter-spacing: -0.01em;
}
.scene-label span:last-child {
display: block;
margin-top: 4px;
color: rgba(255, 255, 255, 0.54);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.scene-footer {
position: absolute;
z-index: 3;
right: 27px;
bottom: 25px;
left: 27px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 18px;
pointer-events: none;
}
.gesture-hint {
display: flex;
align-items: center;
gap: 10px;
color: rgba(255, 255, 255, 0.55);
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.gesture-icon {
display: grid;
width: 36px;
height: 36px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 50%;
background: rgba(255, 255, 255, 0.06);
}
.market-count {
color: rgba(255, 255, 255, 0.48);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.11em;
text-align: right;
text-transform: uppercase;
}
.market-count strong {
display: block;
margin-bottom: 3px;
color: #fff7df;
font-size: 17px;
letter-spacing: 0;
}
.trade-card {
display: flex;
min-width: 0;
flex-direction: column;
padding: 26px;
border: 1px solid rgba(23, 60, 61, 0.08);
border-radius: 30px;
background: rgba(255, 253, 248, 0.9);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
}
.trade-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 21px;
}
.trade-heading h2 {
margin: 0;
font-size: 24px;
line-height: 1.1;
letter-spacing: -0.04em;
}
.trade-heading p {
margin: 7px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.5;
}
.reset-button {
flex: 0 0 auto;
padding: 8px 11px;
border: 1px solid var(--line);
border-radius: 10px;
color: var(--muted);
background: transparent;
cursor: pointer;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: 160ms ease;
}
.reset-button:hover {
color: var(--ink);
border-color: #aab8ad;
background: #f4f3ec;
}
.ledger-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 11px;
}
.ledger-column {
min-width: 0;
padding: 12px;
border: 1px solid;
border-radius: 20px;
}
.ledger-column.owned {
border-color: var(--owned-line);
background: var(--owned-soft);
}
.ledger-column.wanted {
border-color: var(--wanted-line);
background: var(--wanted-soft);
}
.ledger-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
min-height: 40px;
padding: 0 3px 10px;
}
.ledger-heading strong {
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.owned .ledger-heading strong {
color: var(--owned);
}
.wanted .ledger-heading strong {
color: var(--wanted);
}
.ledger-heading span {
color: var(--muted);
font-size: 9px;
font-weight: 750;
}
.goods-list {
display: grid;
gap: 9px;
}
.goods-card {
position: relative;
display: grid;
grid-template-columns: 58px minmax(0, 1fr);
gap: 10px;
width: 100%;
min-height: 111px;
padding: 11px;
overflow: hidden;
border: 1px solid rgba(23, 60, 61, 0.09);
border-radius: 15px;
color: var(--ink);
background: rgba(255, 253, 248, 0.88);
cursor: pointer;
text-align: left;
transition:
transform 160ms ease,
border-color 160ms ease,
box-shadow 160ms ease,
background 160ms ease;
}
.goods-card:hover:not(:disabled) {
transform: translateY(-2px);
border-color: rgba(23, 60, 61, 0.24);
box-shadow: 0 9px 18px rgba(23, 60, 61, 0.08);
}
.goods-card.selected {
border-color: var(--teal);
background: #fffdf8;
box-shadow:
0 0 0 2px rgba(47, 119, 120, 0.12),
0 10px 20px rgba(23, 60, 61, 0.09);
}
.wanted .goods-card.selected {
border-color: var(--wanted);
box-shadow:
0 0 0 2px rgba(193, 108, 60, 0.12),
0 10px 20px rgba(23, 60, 61, 0.09);
}
.goods-card:disabled {
cursor: not-allowed;
opacity: 0.54;
}
.goods-card.fulfilled {
opacity: 0.6;
}
.goods-icon {
display: grid;
width: 58px;
height: 58px;
place-items: center;
border-radius: 13px;
background: #edf0e8;
}
.wanted .goods-icon {
background: #f2e6d7;
}
.goods-icon svg {
width: 52px;
height: 45px;
overflow: visible;
filter: drop-shadow(0 5px 4px rgba(23, 60, 61, 0.1));
}
.goods-copy {
min-width: 0;
padding-top: 2px;
}
.item-type {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-size: 8px;
font-weight: 900;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.goods-copy h3 {
margin: 0;
overflow: hidden;
font-size: 13px;
line-height: 1.15;
letter-spacing: -0.02em;
text-overflow: ellipsis;
white-space: nowrap;
}
.stock {
display: flex;
align-items: baseline;
gap: 4px;
margin-top: 8px;
}
.stock strong {
font-size: 18px;
line-height: 1;
letter-spacing: -0.04em;
}
.stock span {
color: var(--muted);
font-size: 9px;
font-weight: 750;
text-transform: uppercase;
}
.selection-mark {
position: absolute;
top: 9px;
right: 9px;
display: grid;
width: 18px;
height: 18px;
place-items: center;
border: 1px solid #cfd5ce;
border-radius: 50%;
color: transparent;
background: rgba(255, 255, 255, 0.7);
font-size: 10px;
font-weight: 900;
}
.selected .selection-mark {
color: #fff;
border-color: var(--teal);
background: var(--teal);
}
.wanted .selected .selection-mark {
border-color: var(--wanted);
background: var(--wanted);
}
.offer-box {
display: grid;
grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr);
align-items: center;
gap: 8px;
margin-top: 13px;
padding: 14px;
border-radius: 18px;
color: #fff;
background: var(--ink);
}
.offer-side {
min-width: 0;
}
.offer-side:last-child {
text-align: right;
}
.offer-side span {
display: block;
margin-bottom: 5px;
color: rgba(255, 255, 255, 0.5);
font-size: 8px;
font-weight: 900;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.offer-side strong {
display: block;
overflow: hidden;
font-size: 12px;
text-overflow: ellipsis;
white-space: nowrap;
}
.offer-side small {
display: block;
margin-top: 3px;
color: #e9c664;
font-size: 10px;
font-weight: 750;
}
.offer-arrow {
display: grid;
width: 34px;
height: 34px;
place-items: center;
border: 1px solid rgba(255, 255, 255, 0.13);
border-radius: 50%;
color: #e9c664;
background: rgba(255, 255, 255, 0.05);
font-size: 17px;
}
.trade-button {
width: 100%;
margin-top: 12px;
padding: 15px 18px;
border: 0;
border-radius: 15px;
color: var(--ink);
background: var(--gold);
box-shadow: 0 8px 18px rgba(230, 185, 78, 0.22);
cursor: pointer;
font-size: 12px;
font-weight: 900;
letter-spacing: 0.07em;
text-transform: uppercase;
transition:
transform 160ms ease,
filter 160ms ease,
opacity 160ms ease;
}
.trade-button:hover:not(:disabled) {
transform: translateY(-2px);
filter: brightness(1.05);
}
.trade-button:active:not(:disabled) {
transform: translateY(0);
}
.trade-button:disabled {
cursor: not-allowed;
opacity: 0.45;
box-shadow: none;
}
.trade-note {
display: flex;
align-items: flex-start;
gap: 8px;
margin: 12px 2px 0;
color: var(--muted);
font-size: 10px;
line-height: 1.55;
}
.trade-note::before {
content: "◆";
flex: 0 0 auto;
color: var(--gold);
font-size: 8px;
line-height: 1.8;
}
.toast {
position: fixed;
z-index: 20;
right: 24px;
bottom: 24px;
max-width: min(380px, calc(100% - 48px));
padding: 15px 18px;
border: 1px solid rgba(255, 255, 255, 0.12);
border-radius: 15px;
color: #fff;
background: #173c3d;
box-shadow: 0 18px 40px rgba(23, 60, 61, 0.25);
font-size: 12px;
font-weight: 700;
line-height: 1.5;
opacity: 0;
pointer-events: none;
transform: translateY(12px);
transition: 220ms ease;
}
.toast.show {
opacity: 1;
transform: translateY(0);
}
.footer-note {
display: flex;
justify-content: space-between;
gap: 20px;
padding: 18px 3px 0;
color: #7d8c87;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.1em;
text-transform: uppercase;
}
@media (max-width: 1120px) {
.exchange-layout {
grid-template-columns: 1fr;
}
.scene-card {
min-height: 620px;
}
.trade-card {
min-height: auto;
}
}
@media (max-width: 720px) {
.app {
width: min(100% - 24px, 1480px);
padding-top: 14px;
}
.topbar {
padding-bottom: 15px;
}
.topbar-nav {
display: none;
}
.market-status {
padding: 8px 10px;
font-size: 9px;
}
.scene-card {
min-height: 570px;
border-radius: 23px;
}
.scene-heading {
top: 22px;
left: 22px;
}
.scene-heading h1 {
font-size: 37px;
}
.scene-subtitle {
max-width: 270px;
font-size: 11px;
}
.scene-labels {
top: 190px;
right: 18px;
left: 18px;
}
.scene-label {
width: 45%;
padding: 10px;
}
.scene-label strong {
font-size: 11px;
}
.scene-footer {
right: 18px;
bottom: 18px;
left: 18px;
}
.market-count {
display: none;
}
.trade-card {
padding: 18px;
border-radius: 23px;
}
.ledger-grid {
grid-template-columns: 1fr;
}
.goods-card {
grid-template-columns: 64px minmax(0, 1fr);
}
.goods-icon {
width: 64px;
height: 64px;
}
.footer-note {
flex-direction: column;
gap: 7px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<div class="app">
<header class="topbar">
<a class="brand" href="#" aria-label="Tide and Grain home">
<span class="brand-mark" aria-hidden="true"></span>
<span class="brand-copy">
<strong>Tide & Grain</strong>
<span>Neighborhood exchange</span>
</span>
</a>
<nav class="topbar-nav" aria-label="Primary navigation">
<span class="nav-pill active">Exchange board</span>
<span class="nav-pill">Trade history</span>
<span class="nav-pill">How it works</span>
</nav>
<div class="market-status">
<span class="status-dot"></span>
Market open
</div>
</header>
<main class="exchange-layout">
<section class="scene-card" aria-labelledby="scene-title">
<div id="scene" aria-label="Interactive low-poly fish and grain exchange scene"></div>
<div class="scene-heading">
<div class="eyebrow">Exchange floor · Port 07</div>
<h1 id="scene-title">Trade what you have.<br /><em>Want what you need.</em></h1>
<p class="scene-subtitle">
A clearer way to barter. Pick one item from each side of the ledger,
then seal the exchange.
</p>
</div>
<div class="scene-labels">
<div class="scene-label">
<span class="label-kind">Goods owned</span>
<strong>Coral Salmon</strong>
<span id="owned-stage-qty">12 crates in stock</span>
</div>
<div class="scene-label wanted-label">
<span class="label-kind">Goods wanted</span>
<strong>Pearl Barley</strong>
<span id="wanted-stage-qty">4 bags requested</span>
</div>
</div>
<div class="scene-footer">
<div class="gesture-hint">
<span class="gesture-icon" aria-hidden="true">↔</span>
Drag to orbit · Scroll to zoom
</div>
<div class="market-count">
<strong id="active-trades">2 / 4</strong>
active orders
</div>
</div>
</section>
<section class="trade-card" aria-labelledby="trade-title">
<div class="trade-heading">
<div>
<h2 id="trade-title">Your exchange ledger</h2>
<p>Select one owned item and one wanted item.</p>
</div>
<button class="reset-button" id="reset-demo" type="button">Reset demo</button>
</div>
<div class="ledger-grid">
<section class="ledger-column owned" aria-labelledby="owned-heading">
<div class="ledger-heading">
<strong id="owned-heading">Goods owned</strong>
<span>Your side</span>
</div>
<div class="goods-list" id="owned-list"></div>
</section>
<section class="ledger-column wanted" aria-labelledby="wanted-heading">
<div class="ledger-heading">
<strong id="wanted-heading">Goods wanted</strong>
<span>Open requests</span>
</div>
<div class="goods-list" id="wanted-list"></div>
</section>
</div>
<div class="offer-box" aria-live="polite">
<div class="offer-side">
<span>You offer</span>
<strong id="offer-owned-name">Coral Salmon</strong>
<small id="offer-owned-qty">6 crates</small>
</div>
<div class="offer-arrow" aria-hidden="true">→</div>
<div class="offer-side">
<span>You receive</span>
<strong id="offer-wanted-name">Pearl Barley</strong>
<small id="offer-wanted-qty">4 bags</small>
</div>
</div>
<button class="trade-button" id="trade-button" type="button">
Seal exchange · 6 for 4
</button>
<p class="trade-note">
No money changes hands. The offered stock is deducted when the exchange is sealed,
and the matching request is marked fulfilled.
</p>
</section>
</main>
<footer class="footer-note">
<span>Tide & Grain · Community barter exchange</span>
<span>Fair rates · Local goods · No fees</span>
</footer>
</div>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const goods = {
salmon: {
id: "salmon",
side: "owned",
name: "Coral Salmon",
type: "Fish",
quantity: 12,
initial: 12,
unit: "crates",
color: "#e77d57",
accent: "#f2b06b"
},
wheat: {
id: "wheat",
side: "owned",
name: "Amber Wheat",
type: "Grain",
quantity: 8,
initial: 8,
unit: "bags",
color: "#dba943",
accent: "#f0d078"
},
trout: {
id: "trout",
side: "wanted",
name: "Silver Trout",
type: "Fish",
quantity: 4,
initial: 4,
unit: "crates",
color: "#87aeb0",
accent: "#d2e3df"
},
barley: {
id: "barley",
side: "wanted",
name: "Pearl Barley",
type: "Grain",
quantity: 4,
initial: 4,
unit: "bags",
color: "#c3a66c",
accent: "#ead7a3"
}
};
const rateMap = {
"salmon-trout": [2, 1],
"salmon-barley": [3, 2],
"wheat-trout": [4, 3],
"wheat-barley": [3, 2]
};
let selectedOwned = "salmon";
let selectedWanted = "barley";
let toastTimer;
const ownedList = document.querySelector("#owned-list");
const wantedList = document.querySelector("#wanted-list");
const tradeButton = document.querySelector("#trade-button");
const toast = document.querySelector("#toast");
function fishSVG(item) {
return `
<svg viewBox="0 0 110 78" aria-hidden="true">
<polygon points="5,39 25,20 27,58" fill="${item.accent}" />
<polygon points="22,39 48,13 75,20 94,39 75,58 47,64" fill="${item.color}" />
<polygon points="42,18 55,2 70,17" fill="${item.accent}" />
<polygon points="48,57 60,73 72,55" fill="${item.accent}" opacity=".86" />
<polygon points="52,39 73,39 66,54 51,51" fill="#fff" opacity=".24" />
<circle cx="78" cy="31" r="6" fill="#f8f3df" />
<circle cx="80" cy="31" r="2.7" fill="#173c3d" />
<path d="M89 42l8 3-8 3" fill="none" stroke="#173c3d" stroke-width="2" opacity=".6" />
</svg>
`;
}
function grainSVG(item) {
return `
<svg viewBox="0 0 110 78" aria-hidden="true">
<path d="M27 68c0-16 8-27 20-31 14-5 26 1 31 13l4 18z" fill="#b98c56" />
<path d="M25 53c13 2 26-1 39-10" fill="none" stroke="#dfbd78" stroke-width="3" opacity=".65" />
<path d="M45 43C44 26 49 12 57 4" fill="none" stroke="#826a38" stroke-width="4" />
<path d="M61 44c3-18 10-29 19-35" fill="none" stroke="#826a38" stroke-width="4" />
<path d="M37 51c-3-14-1-24 6-33" fill="none" stroke="#826a38" stroke-width="3" />
<g fill="${item.color}">
<polygon points="54,14 59,7 64,13 59,19" />
<polygon points="61,25 66,18 71,25 66,31" />
<polygon points="51,26 55,19 61,25 56,32" />
<polygon points="69,28 77,20 82,27 76,34" />
<polygon points="77,17 81,10 86,17 81,23" />
<polygon points="36,29 42,21 47,28 42,35" />
<polygon points="42,39 47,32 52,39 47,46" />
</g>
<g fill="${item.accent}">
<polygon points="58,15 60,11 63,15 60,18" />
<polygon points="65,27 68,23 71,27 68,30" />
<polygon points="77,29 80,25 82,29 80,32" />
</g>
<path d="M43 47c8-7 16-7 25-1" fill="none" stroke="#6f5531" stroke-width="4" />
</svg>
`;
}
function itemSVG(item) {
return item.type === "Fish" ? fishSVG(item) : grainSVG(item);
}
function cardMarkup(item) {
const selected =
(item.side === "owned" && selectedOwned === item.id) ||
(item.side === "wanted" && selectedWanted === item.id);
const fulfilled = item.side === "wanted" && item.quantity === 0;
const unavailable = item.side === "owned" && item.quantity === 0;
return `
<button
class="goods-card ${selected ? "selected" : ""} ${fulfilled ? "fulfilled" : ""}"
type="button"
data-id="${item.id}"
data-side="${item.side}"
aria-pressed="${selected}"
${fulfilled || unavailable ? "disabled" : ""}
>
<span class="selection-mark" aria-hidden="true">✓</span>
<span class="goods-icon">${itemSVG(item)}</span>
<span class="goods-copy">
<span class="item-type">${item.type}</span>
<h3>${item.name}</h3>
<span class="stock">
<strong>${item.quantity}</strong>
<span>${fulfilled ? "fulfilled" : item.unit}</span>
</span>
</span>
</button>
`;
}
function getOffer() {
const owned = goods[selectedOwned];
const wanted = goods[selectedWanted];
if (!owned || !wanted) {
return null;
}
const rate = rateMap[`${owned.id}-${wanted.id}`] || [1, 1];
const amount = Math.ceil((wanted.quantity * rate[0]) / rate[1]);
return { owned, wanted, amount };
}
function renderLedger() {
ownedList.innerHTML = Object.values(goods)
.filter((item) => item.side === "owned")
.map(cardMarkup)
.join("");
wantedList.innerHTML = Object.values(goods)
.filter((item) => item.side === "wanted")
.map(cardMarkup)
.join("");
const offer = getOffer();
const activeOrders = Object.values(goods).filter(
(item) => item.side === "wanted" && item.quantity > 0
).length;
document.querySelector("#active-trades").textContent = `${activeOrders} / 4`;
document.querySelector("#owned-stage-qty").textContent =
`${goods.salmon.quantity} crates in stock`;
document.querySelector("#wanted-stage-qty").textContent =
goods.barley.quantity > 0
? `${goods.barley.quantity} bags requested`
: "Exchange fulfilled";
if (!offer) {
tradeButton.disabled = true;
tradeButton.textContent = "Select two items";
return;
}
const { owned, wanted, amount } = offer;
const enoughStock = owned.quantity >= amount;
document.querySelector("#offer-owned-name").textContent = owned.name;
document.querySelector("#offer-owned-qty").textContent = `${amount} ${owned.unit}`;
document.querySelector("#offer-wanted-name").textContent = wanted.name;
document.querySelector("#offer-wanted-qty").textContent = `${wanted.quantity} ${wanted.unit}`;
tradeButton.disabled = !enoughStock || wanted.quantity === 0;
tradeButton.textContent = enoughStock
? `Seal exchange · ${amount} for ${wanted.quantity}`
: "Not enough stock";
}
function showToast(message) {
clearTimeout(toastTimer);
toast.textContent = message;
toast.classList.add("show");
toastTimer = setTimeout(() => toast.classList.remove("show"), 3600);
}
ownedList.addEventListener("click", (event) => {
const card = event.target.closest(".goods-card");
if (!card || card.disabled) return;
selectedOwned = card.dataset.id;
renderLedger();
});
wantedList.addEventListener("click", (event) => {
const card = event.target.closest(".goods-card");
if (!card || card.disabled) return;
selectedWanted = card.dataset.id;
renderLedger();
});
tradeButton.addEventListener("click", () => {
const offer = getOffer();
if (!offer) return;
const { owned, wanted, amount } = offer;
if (owned.quantity < amount) {
showToast(`You need ${amount} ${owned.unit} to complete this exchange.`);
return;
}
owned.quantity -= amount;
wanted.quantity = 0;
selectedWanted = null;
renderLedger();
createTradeBurst();
showToast(
`Exchange sealed: ${amount} ${owned.unit} of ${owned.name} sent for ${goods[wanted.id].initial} ${goods[wanted.id].unit} of ${wanted.name}.`
);
});
document.querySelector("#reset-demo").addEventListener("click", () => {
Object.values(goods).forEach((item) => {
item.quantity = item.initial;
});
selectedOwned = "salmon";
selectedWanted = "barley";
renderLedger();
showToast("The exchange ledger has been reset.");
});
renderLedger();
// ------------------------------------------------------------
// Three.js scene
// ------------------------------------------------------------
const sceneHost = document.querySelector("#scene");
const reduceMotion = 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(sceneHost.clientWidth, sceneHost.clientHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute("aria-label", "Low-poly fish and grain on an exchange platform");
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0x173f40, 8.5, 16);
const camera = new THREE.PerspectiveCamera(
34,
sceneHost.clientWidth / sceneHost.clientHeight,
0.1,
50
);
const cameraState = {
theta: 0.12,
phi: 1.06,
radius: 8.8,
targetTheta: 0.12,
targetPhi: 1.06,
targetRadius: 8.8,
target: new THREE.Vector3(0, 0.9, 0)
};
const hemisphere = new THREE.HemisphereLight(0xe5fbf2, 0x102f30, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2cc, 3.3);
keyLight.position.set(4.5, 7.5, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -5;
keyLight.shadow.camera.right = 5;
keyLight.shadow.camera.top = 5;
keyLight.shadow.camera.bottom = -5;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x76c5c8, 1.8);
rimLight.position.set(-5, 3, -4);
scene.add(rimLight);
const exchangeRoot = new THREE.Group();
scene.add(exchangeRoot);
const floor = new THREE.Mesh(
new THREE.CircleGeometry(6.8, 64),
new THREE.MeshStandardMaterial({
color: 0x123739,
roughness: 0.95,
metalness: 0
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.16;
floor.receiveShadow = true;
exchangeRoot.add(floor);
function createPedestal(x, topColor, edgeColor) {
const group = new THREE.Group();
const base = new THREE.Mesh(
new THREE.CylinderGeometry(1.05, 1.14, 0.28, 10),
new THREE.MeshStandardMaterial({
color: 0x315c59,
roughness: 0.82,
flatShading: true
})
);
base.position.y = 0;
base.castShadow = true;
base.receiveShadow = true;
group.add(base);
const top = new THREE.Mesh(
new THREE.CylinderGeometry(1.06, 1.06, 0.055, 10),
new THREE.MeshStandardMaterial({
color: topColor,
roughness: 0.74,
flatShading: true
})
);
top.position.y = 0.16;
top.castShadow = true;
top.receiveShadow = true;
group.add(top);
const rim = new THREE.Mesh(
new THREE.TorusGeometry(1.01, 0.025, 4, 10),
new THREE.MeshBasicMaterial({ color: edgeColor })
);
rim.rotation.x = Math.PI / 2;
rim.position.y = 0.195;
group.add(rim);
group.position.x = x;
exchangeRoot.add(group);
return group;
}
createPedestal(-1.7, 0x2f7778, 0x83c69e);
createPedestal(1.7, 0xa77d35, 0xefa466);
function makeTriangleGeometry(triangles, palette) {
const positions = [];
const colors = [];
triangles.forEach((triangle, index) => {
const color = new THREE.Color(palette[index % palette.length]);
triangle.forEach((point) => {
positions.push(point[0], point[1], point[2]);
colors.push(color.r, color.g, color.b);
});
});
const geometry = new THREE.BufferGeometry();
geometry.setAttribute("position", new THREE.Float32BufferAttribute(positions, 3));
geometry.setAttribute("color", new THREE.Float32BufferAttribute(colors, 3));
geometry.computeVertexNormals();
return geometry;
}
function createFish() {
const fish = new THREE.Group();
const rings = [
{ x: -0.95, r: 0.16 },
{ x: -0.56, r: 0.48 },
{ x: 0.0, r: 0.66 },
{ x: 0.55, r: 0.47 },
{ x: 0.94, r: 0.13 }
];
const segments = 7;
const triangles = [];
function ringPoint(ringIndex, segmentIndex) {
const ring = rings[ringIndex];
const angle = (segmentIndex / segments) * Math.PI * 2;
return [
ring.x,
Math.cos(angle) * ring.r * 0.88,
Math.sin(angle) * ring.r
];
}
for (let r = 0; r < rings.length - 1; r++) {
for (let s = 0; s < segments; s++) {
const a = ringPoint(r, s);
const b = ringPoint(r, s + 1);
const c = ringPoint(r + 1, s);
const d = ringPoint(r + 1, s + 1);
triangles.push([a, c, b], [b, c, d]);
}
}
const bodyGeometry = makeTriangleGeometry(triangles, [
0xe87552,
0xef8b5f,
0xd96748,
0xf39a67,
0xe77951
]);
const bodyMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.58,
metalness: 0.04,
flatShading: true,
side: THREE.DoubleSide
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.castShadow = true;
body.receiveShadow = true;
fish.add(body);
const tailPivot = new THREE.Group();
tailPivot.position.x = -0.93;
const tailGeometry = makeTriangleGeometry(
[
[[0, 0, 0], [-0.67, 0.56, 0], [-0.55, -0.54, 0]],
[[0, 0, 0], [-0.55, -0.54, 0], [-0.67, 0.56, 0]]
],
[0xe87552, 0xd96547]
);
const tailMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.65,
flatShading: true,
side: THREE.DoubleSide
});
const tail = new THREE.Mesh(tailGeometry, tailMaterial);
tail.castShadow = true;
tailPivot.add(tail);
fish.add(tailPivot);
const finGeometry = makeTriangleGeometry(
[
[[-0.38, 0.39, 0], [-0.12, 0.88, 0], [0.25, 0.36, 0]],
[[0.15, -0.38, 0.05], [0.35, -0.72, 0.12], [0.53, -0.32, 0.1]]
],
[0xf3a56d, 0xdf754d]
);
const finMaterial = new THREE.MeshStandardMaterial({
vertexColors: true,
roughness: 0.7,
flatShading: true,
side: THREE.DoubleSide
});
const fins = new THREE.Mesh(finGeometry, finMaterial);
fins.castShadow = true;
fish.add(fins);
const eyeWhite = new THREE.Mesh(
new THREE.SphereGeometry(0.115, 10, 7),
new THREE.MeshStandardMaterial({ color: 0xf8f1d7, roughness: 0.48 })
);
eyeWhite.position.set(0.66, 0.18, 0.43);
fish.add(eyeWhite);
const eyeBlack = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 8, 6),
new THREE.MeshStandardMaterial({ color: 0x173c3d, roughness: 0.35 })
);
eyeBlack.position.set(0.69, 0.2, 0.52);
fish.add(eyeBlack);
fish.userData.tail = tailPivot;
fish.scale.setScalar(1.03);
return fish;
}
function cylinderBetween(start, end, radius, material, radialSegments = 5) {
const direction = new THREE.Vector3().subVectors(end, start);
const midpoint = new THREE.Vector3()
.addVectors(start, end)
.multiplyScalar(0.5);
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius * 0.8, direction.length(), radialSegments),
material
);
mesh.position.copy(midpoint);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
mesh.castShadow = true;
return mesh;
}
function createGrain() {
const group = new THREE.Group();
const sackMaterial = new THREE.MeshStandardMaterial({
color: 0xb9905c,
roughness: 0.93,
flatShading: true
});
const grainMaterial = new THREE.MeshStandardMaterial({
color: 0xd9a841,
roughness: 0.76,
flatShading: true
});
const lightGrainMaterial = new THREE.MeshStandardMaterial({
color: 0xefd176,
roughness: 0.74,
flatShading: true
});
const stemMaterial = new THREE.MeshStandardMaterial({
color: 0x776039,
roughness: 0.9,
flatShading: true
});
const sack = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.56, 0),
sackMaterial
);
sack.scale.set(1, 1.12, 0.88);
sack.position.set(0, 0.57, 0);
sack.rotation.set(0.05, 0.3, -0.03);
sack.castShadow = true;
sack.receiveShadow = true;
group.add(sack);
const neck = new THREE.Mesh(
new THREE.CylinderGeometry(0.2, 0.28, 0.28, 7),
sackMaterial
);
neck.position.set(0.03, 1.08, 0);
neck.castShadow = true;
group.add(neck);
const tie = new THREE.Mesh(
new THREE.TorusGeometry(0.21, 0.035, 4, 10),
stemMaterial
);
tie.rotation.x = Math.PI / 2;
tie.position.set(0.03, 1.06, 0);
group.add(tie);
const stalkData = [
{ start: [-0.03, 1.05, 0], end: [0.05, 2.25, 0.02] },
{ start: [0.03, 1.08, -0.02], end: [0.42, 2.38, -0.04] },
{ start: [0.03, 1.07, 0.02], end: [0.49, 2.08, 0.08] },
{ start: [-0.05, 1.05, -0.04], end: [-0.4, 2.1, -0.05] },
{ start: [-0.02, 1.06, 0.05], end: [0.18, 2.48, 0.03] }
];
stalkData.forEach((stalk, stalkIndex) => {
const start = new THREE.Vector3(...stalk.start);
const end = new THREE.Vector3(...stalk.end);
group.add(cylinderBetween(start, end, 0.022, stemMaterial, 5));
const direction = end.clone().sub(start).normalize();
const length = end.distanceTo(start);
for (let i = 0; i < 4; i++) {
const t = 0.58 + i * 0.12;
const center = start.clone().lerp(end, t);
const kernel = new THREE.Mesh(
new THREE.OctahedronGeometry(0.115, 0),
i % 2 ? grainMaterial : lightGrainMaterial
);
kernel.position.copy(center);
kernel.scale.set(0.75, 1.65, 0.75);
kernel.rotation.z = (i % 2 ? 1 : -1) * 0.18;
kernel.castShadow = true;
group.add(kernel);
}
const leaf = new THREE.Mesh(
new THREE.ConeGeometry(0.14, 0.48, 3),
i => i
);
leaf.visible = false;
group.add(leaf);
const leafShape = new THREE.Mesh(
new THREE.ConeGeometry(0.13, 0.44, 3),
lightGrainMaterial
);
leafShape.position.copy(start.clone().lerp(end, 0.7));
leafShape.position.x += stalkIndex % 2 ? 0.12 : -0.12;
leafShape.rotation.z = stalkIndex % 2 ? -1.05 : 1.05;
leafShape.scale.z = 0.45;
leafShape.castShadow = true;
group.add(leafShape);
});
const kernelGeometry = new THREE.OctahedronGeometry(0.075, 0);
const scattered = [
[-0.65, 0.22, 0.48, 0.2],
[-0.38, 0.22, 0.62, 0.8],
[0.54, 0.22, 0.48, 1.4],
[0.66, 0.22, 0.3, 0.5],
[0.12, 0.22, 0.72, 2.1]
];
scattered.forEach(([x, y, z, rotation]) => {
const kernel = new THREE.Mesh(kernelGeometry, grainMaterial);
kernel.position.set(x, y, z);
kernel.rotation.set(rotation, rotation * 0.7, rotation * 0.4);
kernel.scale.y = 1.25;
kernel.castShadow = true;
group.add(kernel);
});
return group;
}
const fish = createFish();
fish.position.set(-1.7, 1.02, 0.05);
fish.rotation.y = -0.08;
fish.rotation.z = -0.03;
exchangeRoot.add(fish);
const grain = createGrain();
grain.position.set(1.7, 0.19, 0.02);
grain.rotation.y = -0.18;
exchangeRoot.add(grain);
function createExchangeMedallion() {
const group = new THREE.Group();
const gold = new THREE.MeshStandardMaterial({
color: 0xe6b94e,
roughness: 0.42,
metalness: 0.22,
flatShading: true
});
const teal = new THREE.MeshStandardMaterial({
color: 0x78c2bd,
roughness: 0.45,
metalness: 0.12,
flatShading: true
});
const upperArc = new THREE.Mesh(
new THREE.TorusGeometry(0.42, 0.065, 5, 26, Math.PI * 1.2),
gold
);
upperArc.rotation.z = -0.45;
group.add(upperArc);
const lowerArc = new THREE.Mesh(
new THREE.TorusGeometry(0.42, 0.065, 5, 26, Math.PI * 1.2),
teal
);
lowerArc.rotation.z = Math.PI * 0.75;
group.add(lowerArc);
const upperHead = new THREE.Mesh(
new THREE.ConeGeometry(0.15, 0.29, 4),
gold
);
upperHead.position.set(0.37, 0.12, 0);
upperHead.rotation.z = -Math.PI / 2;
group.add(upperHead);
const lowerHead = new THREE.Mesh(
new THREE.ConeGeometry(0.15, 0.29, 4),
teal
);
lowerHead.position.set(-0.37, -0.12, 0);
lowerHead.rotation.z = Math.PI / 2;
group.add(lowerHead);
const center = new THREE.Mesh(
new THREE.DodecahedronGeometry(0.18, 0),
new THREE.MeshStandardMaterial({
color: 0xf1d37e,
roughness: 0.42,
metalness: 0.15,
flatShading: true
})
);
group.add(center);
group.position.set(0, 1.25, 0.45);
group.scale.setScalar(0.85);
group.traverse((child) => {
if (child.isMesh) child.castShadow = true;
});
exchangeRoot.add(group);
return group;
}
const medallion = createExchangeMedallion();
const ambientParticles = [];
const particleGeometry = new THREE.TetrahedronGeometry(0.055, 0);
for (let i = 0; i < 22; i++) {
const particle = new THREE.Mesh(
particleGeometry,
new THREE.MeshBasicMaterial({
color: i % 3 === 0 ? 0xe6b94e : 0x7fc3bb,
transparent: true,
opacity: 0.22 + Math.random() * 0.22
})
);
const angle = Math.random() * Math.PI * 2;
const radius = 2.8 + Math.random() * 2.7;
particle.position.set(
Math.cos(angle) * radius,
0.4 + Math.random() * 3.1,
Math.sin(angle) * radius
);
particle.userData.speed = 0.1 + Math.random() * 0.16;
particle.userData.phase = Math.random() * Math.PI * 2;
ambientParticles.push(particle);
exchangeRoot.add(particle);
}
const burstGroup = new THREE.Group();
exchangeRoot.add(burstGroup);
const burstParticles = [];
function createTradeBurst() {
const colors = [0xe6b94e, 0xf3d37e, 0x78c2bd, 0xe87552];
for (let i = 0; i < 28; i++) {
const particle = new THREE.Mesh(
new THREE.TetrahedronGeometry(0.075, 0),
new THREE.MeshBasicMaterial({
color: colors[i % colors.length],
transparent: true,
opacity: 1
})
);
particle.position.set(0, 1.25, 0.45);
particle.userData.velocity = new THREE.Vector3(
(Math.random() - 0.5) * 3.6,
1.2 + Math.random() * 2.2,
(Math.random() - 0.5) * 2.4
);
particle.userData.spin = new THREE.Vector3(
Math.random() * 0.12,
Math.random() * 0.12,
Math.random() * 0.12
);
particle.userData.life = 1.1;
burstGroup.add(particle);
burstParticles.push(particle);
}
}
function updateBurst(delta) {
for (let i = burstParticles.length - 1; i >= 0; i--) {
const particle = burstParticles[i];
particle.userData.life -= delta;
particle.userData.velocity.y -= 3.4 * delta;
particle.position.addScaledVector(particle.userData.velocity, delta);
particle.rotation.x += particle.userData.spin.x;
particle.rotation.y += particle.userData.spin.y;
particle.rotation.z += particle.userData.spin.z;
particle.material.opacity = Math.max(0, particle.userData.life);
if (particle.userData.life <= 0) {
burstGroup.remove(particle);
particle.geometry.dispose();
particle.material.dispose();
burstParticles.splice(i, 1);
}
}
}
// Custom orbit controls implemented without addons.
let dragging = false;
let previousPointerX = 0;
let previousPointerY = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousPointerX = event.clientX;
previousPointerY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousPointerX;
const deltaY = event.clientY - previousPointerY;
cameraState.targetTheta -= deltaX * 0.006;
cameraState.targetPhi = THREE.MathUtils.clamp(
cameraState.targetPhi + deltaY * 0.005,
0.67,
1.43
);
previousPointerX = event.clientX;
previousPointerY = event.clientY;
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.targetRadius = THREE.MathUtils.clamp(
cameraState.targetRadius + event.deltaY * 0.006,
6.7,
11.6
);
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", () => {
cameraState.targetTheta = 0.12;
cameraState.targetPhi = 1.06;
cameraState.targetRadius = 8.8;
});
const resizeObserver = new ResizeObserver(() => {
const width = sceneHost.clientWidth;
const height = sceneHost.clientHeight;
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
});
resizeObserver.observe(sceneHost);
const clock = new THREE.Clock();
function animate() {
const delta = Math.min(clock.getDelta(), 0.04);
const time = clock.elapsedTime;
cameraState.theta += (cameraState.targetTheta - cameraState.theta) * 0.08;
cameraState.phi += (cameraState.targetPhi - cameraState.phi) * 0.08;
cameraState.radius += (cameraState.targetRadius - cameraState.radius) * 0.08;
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
if (!reduceMotion) {
fish.position.y = 1.02 + Math.sin(time * 1.6) * 0.1;
fish.rotation.z = -0.03 + Math.sin(time * 0.9) * 0.045;
fish.userData.tail.rotation.y = Math.sin(time * 4.2) * 0.22;
grain.rotation.y = -0.18 + Math.sin(time * 0.42) * 0.045;
medallion.rotation.y = Math.sin(time * 0.65) * 0.16;
medallion.position.y = 1.25 + Math.sin(time * 1.2) * 0.07;
ambientParticles.forEach((particle) => {
particle.position.y += Math.sin(time * particle.userData.speed + particle.userData.phase) * 0.0025;
particle.rotation.x += 0.002;
particle.rotation.y += 0.003;
});
}
updateBurst(delta);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```