Prompt specification
Build or customize the Three.js 3D scene "Shared Pond Fish 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: Shared Pond Fish Counter
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/shared-pond-fish-counter-x3129
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows a shared pond's fish stock. Build a transparent pond tray with counted fish tokens and a marked stock scale. Keep this a symbolic population model rather than a realistic ecological forecast. Stylized solid forms.
Working Three.js Starter (shared-pond-fish-counter-x3129):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Shared Pond — Symbolic Stock Board</title>
<style>
:root {
--ink: #173b3a;
--muted: #6b807b;
--paper: #f7f8f0;
--line: rgba(23, 59, 58, 0.13);
--blue: #35a39b;
--sun: #efb64f;
--silver: #9bafb2;
--accent: #d9f06c;
--shadow: 0 18px 50px rgba(30, 63, 59, 0.15);
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(circle at 52% 42%, #f9fbf3 0%, #e8f0e7 58%, #dce8df 100%);
}
button { font: inherit; }
#app, #scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.topbar {
position: fixed;
z-index: 5;
top: 24px;
left: 28px;
right: 28px;
display: flex;
align-items: center;
justify-content: space-between;
pointer-events: none;
}
.brand {
display: flex;
align-items: center;
gap: 13px;
}
.brand-mark {
width: 43px;
height: 43px;
border-radius: 50%;
display: grid;
place-items: center;
background: var(--ink);
box-shadow: 0 9px 25px rgba(23, 59, 58, 0.2);
}
.brand-mark svg { width: 25px; height: 25px; }
.brand-copy small {
display: block;
margin-bottom: 3px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.17em;
text-transform: uppercase;
}
.brand-copy h1 {
margin: 0;
font-size: 19px;
line-height: 1;
letter-spacing: -0.03em;
}
.top-actions {
display: flex;
align-items: center;
gap: 9px;
pointer-events: auto;
}
.presence {
display: flex;
align-items: center;
margin-right: 7px;
}
.avatar {
width: 30px;
height: 30px;
margin-left: -6px;
display: grid;
place-items: center;
border: 2px solid #edf3eb;
border-radius: 50%;
color: #fff;
font-size: 10px;
font-weight: 800;
box-shadow: 0 4px 12px rgba(23, 59, 58, 0.12);
}
.avatar:first-child { margin-left: 0; }
.avatar:nth-child(1) { background: #3b8f87; }
.avatar:nth-child(2) { background: #c6913f; }
.avatar:nth-child(3) { background: #718c91; }
.live-pill {
display: flex;
align-items: center;
gap: 7px;
padding: 8px 11px;
border: 1px solid rgba(255,255,255,0.75);
border-radius: 999px;
background: rgba(247,248,240,0.78);
color: var(--muted);
font-size: 11px;
font-weight: 700;
backdrop-filter: blur(14px);
}
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #55ad69;
box-shadow: 0 0 0 4px rgba(85, 173, 105, 0.13);
}
.ghost-button {
min-height: 36px;
padding: 0 13px;
border: 1px solid rgba(23,59,58,0.13);
border-radius: 10px;
background: rgba(247,248,240,0.78);
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 800;
backdrop-filter: blur(14px);
transition: transform .18s ease, background .18s ease;
}
.ghost-button:hover {
transform: translateY(-1px);
background: #fff;
}
.stock-panel {
position: fixed;
z-index: 4;
top: 112px;
left: 28px;
width: 278px;
padding: 20px;
border: 1px solid rgba(255,255,255,0.8);
border-radius: 20px;
background: rgba(247,248,240,0.87);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.eyebrow {
display: flex;
align-items: center;
justify-content: space-between;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: .13em;
text-transform: uppercase;
}
.sync-badge {
color: #54816d;
letter-spacing: 0;
text-transform: none;
}
.total-wrap {
display: flex;
align-items: flex-end;
justify-content: space-between;
margin: 13px 0 12px;
}
.total-wrap strong {
font-size: 50px;
line-height: .9;
letter-spacing: -0.07em;
font-weight: 750;
}
.total-wrap strong span {
margin-left: 3px;
color: #94a39e;
font-size: 20px;
font-weight: 600;
letter-spacing: -0.03em;
}
.remaining {
padding-bottom: 4px;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
text-align: right;
}
.capacity-track {
height: 7px;
overflow: hidden;
border-radius: 999px;
background: rgba(23,59,58,0.09);
}
#capacityFill {
width: 84%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #2f9a91, #a9cf65);
transition: width .35s ease;
}
.species-list {
display: grid;
gap: 4px;
margin: 17px 0 0;
}
.species-row {
display: grid;
grid-template-columns: 10px 1fr auto;
align-items: center;
gap: 9px;
padding: 8px 0;
border-top: 1px solid var(--line);
font-size: 12px;
}
.species-row:first-child { border-top: 0; }
.species-dot {
width: 9px;
height: 9px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.species-row small {
display: block;
margin-top: 2px;
color: var(--muted);
font-size: 9px;
letter-spacing: .07em;
text-transform: uppercase;
}
.species-row b {
font-size: 15px;
}
.model-note {
margin-top: 15px;
padding: 12px 13px;
border-radius: 12px;
background: rgba(23,59,58,0.055);
color: #60736e;
font-size: 10px;
line-height: 1.5;
}
.model-note strong {
display: block;
margin-bottom: 3px;
color: var(--ink);
font-size: 10px;
letter-spacing: .05em;
text-transform: uppercase;
}
.control-dock {
position: fixed;
z-index: 5;
left: 50%;
bottom: 24px;
width: min(730px, calc(100vw - 56px));
transform: translateX(-50%);
display: flex;
align-items: center;
gap: 10px;
padding: 11px;
border: 1px solid rgba(255,255,255,0.86);
border-radius: 18px;
background: rgba(247,248,240,0.9);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.species-picker {
display: flex;
flex: 1;
gap: 5px;
min-width: 0;
}
.species-button {
min-width: 0;
flex: 1;
padding: 9px 8px;
border: 1px solid transparent;
border-radius: 11px;
background: transparent;
color: var(--muted);
cursor: pointer;
text-align: left;
transition: background .18s ease, color .18s ease;
}
.species-button:hover { background: rgba(23,59,58,0.05); }
.species-button.active {
border-color: rgba(23,59,58,0.08);
background: #fff;
color: var(--ink);
box-shadow: 0 4px 14px rgba(23,59,58,0.07);
}
.species-button span {
display: flex;
align-items: center;
gap: 6px;
overflow: hidden;
white-space: nowrap;
font-size: 10px;
font-weight: 800;
}
.species-button i {
flex: 0 0 auto;
width: 8px;
height: 8px;
border-radius: 3px;
}
.species-button small {
display: block;
margin: 3px 0 0 14px;
font-size: 9px;
font-weight: 650;
}
.dock-divider {
width: 1px;
height: 34px;
background: var(--line);
}
.action-button {
min-height: 39px;
padding: 0 14px;
border: 0;
border-radius: 11px;
background: var(--ink);
color: #fff;
cursor: pointer;
font-size: 11px;
font-weight: 800;
white-space: nowrap;
transition: transform .18s ease, opacity .18s ease;
}
.action-button:hover:not(:disabled) { transform: translateY(-1px); }
.action-button:disabled { cursor: default; opacity: .35; }
.action-button.secondary {
border: 1px solid rgba(23,59,58,0.12);
background: #fff;
color: var(--ink);
}
.action-button.lime {
background: var(--accent);
color: var(--ink);
}
.view-help {
position: fixed;
z-index: 3;
right: 28px;
bottom: 28px;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
pointer-events: none;
}
.view-buttons {
display: flex;
gap: 6px;
pointer-events: auto;
}
.view-buttons button {
padding: 8px 10px;
border: 1px solid rgba(23,59,58,0.1);
border-radius: 9px;
background: rgba(247,248,240,0.82);
color: var(--ink);
cursor: pointer;
font-size: 9px;
font-weight: 850;
letter-spacing: .08em;
text-transform: uppercase;
}
.gesture-note {
color: rgba(23,59,58,0.55);
font-size: 9px;
font-weight: 700;
letter-spacing: .04em;
}
.selection-card {
position: fixed;
z-index: 3;
top: 112px;
right: 28px;
min-width: 185px;
padding: 12px 14px;
border: 1px solid rgba(255,255,255,0.8);
border-radius: 13px;
background: rgba(247,248,240,0.82);
color: var(--muted);
box-shadow: 0 10px 30px rgba(30,63,59,0.1);
font-size: 10px;
line-height: 1.5;
backdrop-filter: blur(14px);
pointer-events: none;
}
.selection-card strong {
color: var(--ink);
font-size: 11px;
}
#toast {
position: fixed;
z-index: 20;
left: 50%;
top: 88px;
padding: 10px 15px;
transform: translate(-50%, -12px);
border-radius: 999px;
background: var(--ink);
color: #fff;
box-shadow: 0 12px 30px rgba(23,59,58,0.2);
font-size: 11px;
font-weight: 750;
opacity: 0;
pointer-events: none;
transition: opacity .2s ease, transform .2s ease;
}
#toast.visible {
opacity: 1;
transform: translate(-50%, 0);
}
@media (max-width: 900px) {
.view-help { display: none; }
.selection-card { top: 92px; right: 16px; }
.stock-panel { left: 18px; width: 250px; }
.topbar { left: 18px; right: 18px; }
}
@media (max-width: 680px) {
.topbar { top: 14px; }
.brand-copy h1 { font-size: 16px; }
.brand-copy small, .presence, .live-pill { display: none; }
.stock-panel {
top: 76px;
left: 12px;
width: 208px;
padding: 14px;
}
.total-wrap strong { font-size: 40px; }
.species-row { padding: 5px 0; }
.model-note { display: none; }
.selection-card { display: none; }
.control-dock {
bottom: 12px;
width: calc(100vw - 24px);
flex-wrap: wrap;
gap: 7px;
padding: 9px;
}
.species-picker {
order: 1;
width: 100%;
flex-basis: 100%;
}
.species-button { padding: 7px; }
.dock-divider { display: none; }
.action-button { flex: 1; padding: 0 8px; }
}
</style>
</head>
<body>
<main id="app">
<div id="scene" aria-label="Interactive three-dimensional shared pond stock model"></div>
<header class="topbar">
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 32 32" fill="none">
<path d="M4 17.5c3.6 0 3.6-4 7.2-4s3.6 4 7.2 4 3.6-4 7.2-4 3.6 4 7.2 4"
stroke="#D9F06C" stroke-width="2.4" stroke-linecap="round"/>
<path d="M4 23c3.6 0 3.6-4 7.2-4s3.6 4 7.2 4 3.6-4 7.2-4"
stroke="#78C7BD" stroke-width="2.4" stroke-linecap="round"/>
<circle cx="16" cy="8" r="2" fill="#fff"/>
</svg>
</div>
<div class="brand-copy">
<small>Shared habitat / board 07</small>
<h1>Common Pond Stock</h1>
</div>
</div>
<div class="top-actions">
<div class="presence" aria-label="Three board members">
<div class="avatar">AM</div>
<div class="avatar">JL</div>
<div class="avatar">SK</div>
</div>
<div class="live-pill"><span class="live-dot"></span> Synced just now</div>
<button class="ghost-button" id="copyButton" type="button">Copy stock</button>
</div>
</header>
<aside class="stock-panel">
<div class="eyebrow">
<span>Symbolic stock</span>
<span class="sync-badge">● Live view</span>
</div>
<div class="total-wrap">
<strong><b id="totalValue">42</b><span>/ 50</span></strong>
<div class="remaining">
<b id="remainingValue">8</b> slots open<br />
token capacity
</div>
</div>
<div class="capacity-track"><div id="capacityFill"></div></div>
<div class="species-list">
<div class="species-row">
<i class="species-dot" style="background:#35a39b"></i>
<div>Bluefin<small>Shared group A</small></div>
<b id="countBlue">24</b>
</div>
<div class="species-row">
<i class="species-dot" style="background:#efb64f"></i>
<div>Sunfin<small>Shared group B</small></div>
<b id="countSun">11</b>
</div>
<div class="species-row">
<i class="species-dot" style="background:#9bafb2"></i>
<div>Silverfin<small>Shared group C</small></div>
<b id="countSilver">7</b>
</div>
</div>
<div class="model-note">
<strong>Bookkeeping model</strong>
Tokens represent a counted shared stock. Capacity is a visual limit, not an ecological forecast.
</div>
</aside>
<div class="selection-card" id="selectionCard">
<strong>No token selected</strong><br />
Click any fish to inspect it.
</div>
<section class="control-dock" aria-label="Stock controls">
<div class="species-picker">
<button class="species-button active" type="button" data-species="blue">
<span><i style="background:#35a39b"></i>Bluefin</span>
<small id="buttonCountBlue">24 tokens</small>
</button>
<button class="species-button" type="button" data-species="sun">
<span><i style="background:#efb64f"></i>Sunfin</span>
<small id="buttonCountSun">11 tokens</small>
</button>
<button class="species-button" type="button" data-species="silver">
<span><i style="background:#9bafb2"></i>Silverfin</span>
<small id="buttonCountSilver">7 tokens</small>
</button>
</div>
<div class="dock-divider"></div>
<button class="action-button secondary" id="removeButton" type="button">− Remove</button>
<button class="action-button lime" id="addButton" type="button">+ Add token</button>
<button class="action-button secondary" id="resetButton" type="button">Reset</button>
</section>
<div class="view-help">
<div class="view-buttons">
<button id="isoButton" type="button">3D view</button>
<button id="topButton" type="button">Top view</button>
</div>
<div class="gesture-note">Drag to orbit · Scroll to zoom · Click a fish</div>
</div>
<div id="toast" role="status" aria-live="polite"></div>
</main>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const CAPACITY = 50;
const INITIAL_COUNTS = { blue: 24, sun: 11, silver: 7 };
const species = {
blue: {
name: "Bluefin",
color: 0x35a39b,
tailColor: 0x247c78,
css: "#35a39b"
},
sun: {
name: "Sunfin",
color: 0xefb64f,
tailColor: 0xc98c32,
css: "#efb64f"
},
silver: {
name: "Silverfin",
color: 0x9bafb2,
tailColor: 0x70888b,
css: "#9bafb2"
}
};
const counts = { ...INITIAL_COUNTS };
let activeSpecies = "blue";
let selectedFish = null;
let nextFishId = 1;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xeaf0e7);
scene.fog = new THREE.Fog(0xeaf0e7, 25, 48);
const camera = new THREE.PerspectiveCamera(
36,
innerWidth / innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.domElement.setAttribute("tabindex", "0");
renderer.domElement.setAttribute(
"aria-label",
"Three-dimensional pond. Drag to orbit, scroll to zoom, and click a fish to select it."
);
document.getElementById("scene").appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xffffff, 0x75958b, 2.1);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(7, 13, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 35;
keyLight.shadow.normalBias = 0.025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0xa8e4da, 1.25);
rimLight.position.set(-8, 6, -7);
scene.add(rimLight);
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0xe3ebe1,
roughness: 0.96,
metalness: 0
});
const ground = new THREE.Mesh(new THREE.PlaneGeometry(60, 60), groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.39;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(44, 44, 0x9ab4aa, 0xb8c9c0);
grid.position.y = -0.382;
grid.material.transparent = true;
grid.material.opacity = 0.13;
grid.material.depthWrite = false;
scene.add(grid);
const pond = new THREE.Group();
scene.add(pond);
const acrylicMaterial = new THREE.MeshPhysicalMaterial({
color: 0xc4ebe6,
transparent: true,
opacity: 0.24,
roughness: 0.18,
metalness: 0,
depthWrite: false,
side: THREE.DoubleSide
});
const acrylicEdgeMaterial = new THREE.MeshStandardMaterial({
color: 0x174c4b,
roughness: 0.48,
metalness: 0.08
});
const baseShadow = new THREE.Mesh(
new THREE.BoxGeometry(12.7, 0.1, 7.7),
new THREE.MeshBasicMaterial({
color: 0x315f59,
transparent: true,
opacity: 0.13,
depthWrite: false
})
);
baseShadow.position.y = -0.34;
baseShadow.renderOrder = 0;
pond.add(baseShadow);
const trayBottom = new THREE.Mesh(
new THREE.BoxGeometry(12.25, 0.16, 7.25),
new THREE.MeshPhysicalMaterial({
color: 0x9bd8d1,
transparent: true,
opacity: 0.28,
roughness: 0.26,
depthWrite: false
})
);
trayBottom.position.y = -0.09;
trayBottom.receiveShadow = true;
pond.add(trayBottom);
const walls = [
[12.2, 0.72, 0.11, 0, 0.26, 3.56],
[12.2, 0.72, 0.11, 0, 0.26, -3.56],
[0.11, 0.72, 7.1, 6.04, 0.26, 0],
[0.11, 0.72, 7.1, -6.04, 0.26, 0]
];
for (const [w, h, d, x, y, z] of walls) {
const wall = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
acrylicMaterial
);
wall.position.set(x, y, z);
wall.renderOrder = 3;
pond.add(wall);
}
const rims = [
[12.35, 0.09, 0.12, 0, 0.64, 3.57],
[12.35, 0.09, 0.12, 0, 0.64, -3.57],
[0.12, 0.09, 7.17, 6.05, 0.64, 0],
[0.12, 0.09, 7.17, -6.05, 0.64, 0]
];
for (const [w, h, d, x, y, z] of rims) {
const rim = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
acrylicEdgeMaterial
);
rim.position.set(x, y, z);
rim.castShadow = true;
pond.add(rim);
}
const water = new THREE.Mesh(
new THREE.PlaneGeometry(11.9, 6.9),
new THREE.MeshPhysicalMaterial({
color: 0x77d3cf,
transparent: true,
opacity: 0.13,
roughness: 0.36,
metalness: 0,
depthWrite: false,
side: THREE.DoubleSide
})
);
water.rotation.x = -Math.PI / 2;
water.position.y = 0.55;
water.renderOrder = 4;
pond.add(water);
const slotPositions = [];
const slotGeometry = new THREE.RingGeometry(0.13, 0.165, 20);
const slotMaterial = new THREE.MeshBasicMaterial({
color: 0x2d7772,
transparent: true,
opacity: 0.18,
depthWrite: false,
side: THREE.DoubleSide
});
let slotIndex = 0;
for (let row = 0; row < 5; row++) {
for (let col = 0; col < 10; col++) {
const x = -4.36 + col * 0.97;
const z = -2.12 + row * 1.05;
slotPositions.push(new THREE.Vector3(x, 0.015, z));
const marker = new THREE.Mesh(slotGeometry, slotMaterial);
marker.rotation.x = -Math.PI / 2;
marker.position.set(x, 0.015, z);
marker.renderOrder = 1;
pond.add(marker);
}
}
function roundedRect(context, x, y, width, height, radius) {
const r = Math.min(radius, width / 2, height / 2);
context.beginPath();
context.moveTo(x + r, y);
context.arcTo(x + width, y, x + width, y + height, r);
context.arcTo(x + width, y + height, x, y + height, r);
context.arcTo(x, y + height, x, y, r);
context.arcTo(x, y, x + width, y, r);
context.closePath();
}
function makeTextSprite(text, options = {}) {
const {
width = 2.1,
height = 0.48,
color = "#173b3a",
background = "rgba(247,248,240,0.92)",
fontSize = 46,
fontWeight = 800
} = options;
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 192;
const context = canvas.getContext("2d");
roundedRect(context, 8, 8, 752, 176, 42);
context.fillStyle = background;
context.fill();
context.fillStyle = color;
context.font = `${fontWeight} ${fontSize}px system-ui, sans-serif`;
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 384, 98);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.scale.set(width, height, 1);
sprite.renderOrder = 20;
return sprite;
}
function updateTextSprite(sprite, text, options = {}) {
const {
color = "#173b3a",
background = "rgba(247,248,240,0.92)",
fontSize = 46,
fontWeight = 800
} = options;
const texture = sprite.material.map;
const context = texture.image.getContext("2d");
context.clearRect(0, 0, texture.image.width, texture.image.height);
roundedRect(context, 8, 8, 752, 176, 42);
context.fillStyle = background;
context.fill();
context.fillStyle = color;
context.font = `${fontWeight} ${fontSize}px system-ui, sans-serif`;
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 384, 98);
texture.needsUpdate = true;
}
const scaleGroup = new THREE.Group();
scene.add(scaleGroup);
const scaleBase = new THREE.Mesh(
new THREE.BoxGeometry(10.45, 0.09, 0.46),
new THREE.MeshStandardMaterial({
color: 0x234d4a,
roughness: 0.68,
metalness: 0.04
})
);
scaleBase.position.set(0, -0.22, 4.15);
scaleBase.castShadow = true;
scaleBase.receiveShadow = true;
scaleGroup.add(scaleBase);
const gaugeFill = new THREE.Mesh(
new THREE.BoxGeometry(1, 0.075, 0.28),
new THREE.MeshStandardMaterial({
color: 0xd9f06c,
roughness: 0.5
})
);
gaugeFill.position.set(-5, -0.145, 4.13);
scaleGroup.add(gaugeFill);
const tickMaterial = new THREE.MeshStandardMaterial({
color: 0xcfe5d8,
roughness: 0.7
});
for (let value = 0; value <= CAPACITY; value += 2) {
const major = value % 10 === 0;
const tick = new THREE.Mesh(
new THREE.BoxGeometry(major ? 0.045 : 0.022, 0.035, major ? 0.28 : 0.17),
major ? tickMaterial : new THREE.MeshBasicMaterial({ color: 0x71928a })
);
tick.position.set(-5 + (value / CAPACITY) * 10, -0.135, 4.09);
scaleGroup.add(tick);
if (major) {
const label = makeTextSprite(String(value), {
width: 0.75,
height: 0.25,
fontSize: 44,
background: "rgba(247,248,240,0.95)"
});
label.position.set(-5 + (value / CAPACITY) * 10, 0.09, 4.55);
scaleGroup.add(label);
}
}
const scaleTitle = makeTextSprite("STOCK SCALE · 50 TOKEN CAPACITY", {
width: 3.8,
height: 0.42,
fontSize: 38
});
scaleTitle.position.set(0, 0.22, 4.92);
scaleGroup.add(scaleTitle);
const marker = new THREE.Group();
const markerStem = new THREE.Mesh(
new THREE.CylinderGeometry(0.025, 0.025, 0.42, 12),
new THREE.MeshBasicMaterial({ color: 0xffffff })
);
markerStem.position.y = 0.18;
marker.add(markerStem);
const markerTip = new THREE.Mesh(
new THREE.ConeGeometry(0.09, 0.19, 3),
new THREE.MeshBasicMaterial({ color: 0xffffff })
);
markerTip.rotation.z = Math.PI;
markerTip.position.y = -0.05;
marker.add(markerTip);
scaleGroup.add(marker);
const markerLabel = makeTextSprite("42", {
width: 0.83,
height: 0.31,
fontSize: 47,
color: "#ffffff",
background: "rgba(23,59,58,0.96)"
});
markerLabel.position.y = 0.47;
marker.add(markerLabel);
const bodyGeometry = new THREE.SphereGeometry(0.5, 16, 10);
const eyeGeometry = new THREE.SphereGeometry(0.046, 10, 8);
const eyeMaterial = new THREE.MeshStandardMaterial({
color: 0x173332,
roughness: 0.45
});
const tailShape = new THREE.Shape();
tailShape.moveTo(0, 0);
tailShape.lineTo(-0.31, 0.21);
tailShape.lineTo(-0.25, 0);
tailShape.lineTo(-0.31, -0.21);
tailShape.closePath();
const tailGeometry = new THREE.ExtrudeGeometry(tailShape, {
depth: 0.075,
bevelEnabled: false
});
tailGeometry.rotateX(-Math.PI / 2);
const speciesMaterials = {};
for (const key of Object.keys(species)) {
speciesMaterials[key] = {
body: new THREE.MeshStandardMaterial({
color: species[key].color,
roughness: 0.52,
metalness: 0.06
}),
tail: new THREE.MeshStandardMaterial({
color: species[key].tailColor,
roughness: 0.58,
metalness: 0.03
})
};
}
const fishes = [];
const fishMeshes = [];
const occupiedSlots = new Set();
function createFish(type, slotIndex) {
const group = new THREE.Group();
const position = slotPositions[slotIndex];
const id = nextFishId++;
group.position.set(position.x, 0.21, position.z);
group.rotation.y = ((id * 17) % 7 - 3) * 0.085 +
(id % 3 === 0 ? Math.PI : 0);
const body = new THREE.Mesh(bodyGeometry, speciesMaterials[type].body);
body.scale.set(0.47, 0.18, 0.21);
body.castShadow = true;
body.receiveShadow = true;
body.userData.fishId = id;
group.add(body);
fishMeshes.push(body);
const tailPivot = new THREE.Group();
tailPivot.position.x = -0.37;
const tail = new THREE.Mesh(tailGeometry, speciesMaterials[type].tail);
tail.castShadow = true;
tail.userData.fishId = id;
tailPivot.add(tail);
fishMeshes.push(tail);
group.add(tailPivot);
const eyeA = new THREE.Mesh(eyeGeometry, eyeMaterial);
eyeA.position.set(0.31, 0.055, 0.18);
eyeA.userData.fishId = id;
group.add(eyeA);
fishMeshes.push(eyeA);
const eyeB = new THREE.Mesh(eyeGeometry, eyeMaterial);
eyeB.position.set(0.31, 0.055, -0.18);
eyeB.userData.fishId = id;
group.add(eyeB);
fishMeshes.push(eyeB);
const fin = new THREE.Mesh(
new THREE.SphereGeometry(0.5, 10, 6),
speciesMaterials[type].tail
);
fin.scale.set(0.13, 0.045, 0.11);
fin.position.set(-0.04, 0.17, 0);
fin.castShadow = true;
fin.userData.fishId = id;
group.add(fin);
fishMeshes.push(fin);
const fish = {
id,
type,
group,
tailPivot,
slotIndex,
baseY: 0.21,
phase: id * 0.73
};
group.userData.fishId = id;
fishes.push(fish);
occupiedSlots.add(slotIndex);
pond.add(group);
return fish;
}
function removeFish(fish) {
if (!fish) return;
pond.remove(fish.group);
occupiedSlots.delete(fish.slotIndex);
counts[fish.type] = Math.max(0, counts[fish.type] - 1);
for (let i = fishMeshes.length - 1; i >= 0; i--) {
if (fishMeshes[i].userData.fishId === fish.id) {
fishMeshes.splice(i, 1);
}
}
const fishIndex = fishes.indexOf(fish);
if (fishIndex >= 0) fishes.splice(fishIndex, 1);
if (selectedFish === fish) {
selectedFish = null;
selectionRing.visible = false;
}
}
function seededShuffle(array) {
let seed = 713;
for (let i = array.length - 1; i > 0; i--) {
seed = (seed * 9301 + 49297) % 233280;
const j = seed % (i + 1);
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function resetStock() {
for (const fish of [...fishes]) removeFish(fish);
Object.assign(counts, INITIAL_COUNTS);
occupiedSlots.clear();
selectedFish = null;
selectionRing.visible = false;
const plan = [];
for (const [type, amount] of Object.entries(INITIAL_COUNTS)) {
for (let i = 0; i < amount; i++) plan.push(type);
}
seededShuffle(plan);
const slots = seededShuffle(
Array.from({ length: CAPACITY }, (_, i) => i)
);
for (let i = 0; i < plan.length; i++) {
createFish(plan[i], slots[i]);
}
updateUI();
}
const selectionRing = new THREE.Mesh(
new THREE.RingGeometry(0.42, 0.5, 36),
new THREE.MeshBasicMaterial({
color: 0xf5ffbf,
transparent: true,
opacity: 0.95,
side: THREE.DoubleSide,
depthTest: false,
depthWrite: false
})
);
selectionRing.rotation.x = -Math.PI / 2;
selectionRing.position.y = 0.045;
selectionRing.renderOrder = 15;
selectionRing.visible = false;
pond.add(selectionRing);
const totalValue = document.getElementById("totalValue");
const remainingValue = document.getElementById("remainingValue");
const capacityFill = document.getElementById("capacityFill");
const addButton = document.getElementById("addButton");
const removeButton = document.getElementById("removeButton");
const selectionCard = document.getElementById("selectionCard");
const speciesButtons = [...document.querySelectorAll(".species-button")];
function updateUI() {
const total = counts.blue + counts.sun + counts.silver;
totalValue.textContent = total;
remainingValue.textContent = CAPACITY - total;
capacityFill.style.width = `${(total / CAPACITY) * 100}%`;
document.getElementById("countBlue").textContent = counts.blue;
document.getElementById("countSun").textContent = counts.sun;
document.getElementById("countSilver").textContent = counts.silver;
document.getElementById("buttonCountBlue").textContent =
`${counts.blue} token${counts.blue === 1 ? "" : "s"}`;
document.getElementById("buttonCountSun").textContent =
`${counts.sun} token${counts.sun === 1 ? "" : "s"}`;
document.getElementById("buttonCountSilver").textContent =
`${counts.silver} token${counts.silver === 1 ? "" : "s"}`;
addButton.disabled = total >= CAPACITY;
removeButton.disabled = total === 0;
updateTextSprite(markerLabel, String(total), {
color: "#ffffff",
background: "rgba(23,59,58,0.96)",
fontSize: 47
});
marker.position.x = -5 + (total / CAPACITY) * 10;
gaugeFill.scale.x = Math.max(0.001, total / CAPACITY);
gaugeFill.position.x = -5 + (total / CAPACITY) * 5;
if (selectedFish) {
selectionCard.innerHTML =
`<strong>${species[selectedFish.type].name} selected</strong><br />` +
`Token ${String(selectedFish.id).padStart(2, "0")} · slot ${selectedFish.slotIndex + 1}`;
} else {
selectionCard.innerHTML =
"<strong>No token selected</strong><br />Click any fish to inspect it.";
}
}
function setActiveSpecies(type) {
activeSpecies = type;
speciesButtons.forEach(button => {
button.classList.toggle("active", button.dataset.species === type);
});
}
function addToken() {
const total = counts.blue + counts.sun + counts.silver;
if (total >= CAPACITY) return;
let slot = -1;
for (let i = 0; i < CAPACITY; i++) {
if (!occupiedSlots.has(i)) {
slot = i;
break;
}
}
if (slot >= 0) {
createFish(activeSpecies, slot);
counts[activeSpecies]++;
updateUI();
showToast(`${species[activeSpecies].name} token added`);
}
}
function removeToken() {
let fish = selectedFish;
if (!fish) {
for (let i = fishes.length - 1; i >= 0; i--) {
if (fishes[i].type === activeSpecies) {
fish = fishes[i];
break;
}
}
}
if (fish) {
const removedName = species[fish.type].name;
removeFish(fish);
updateUI();
showToast(`${removedName} token removed`);
}
}
let toastTimer;
function showToast(message) {
const toast = document.getElementById("toast");
toast.textContent = message;
toast.classList.add("visible");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("visible"), 1500);
}
speciesButtons.forEach(button => {
button.addEventListener("click", () => {
setActiveSpecies(button.dataset.species);
});
});
addButton.addEventListener("click", addToken);
removeButton.addEventListener("click", removeToken);
document.getElementById("resetButton").addEventListener("click", () => {
resetStock();
showToast("Stock reset to 42 tokens");
});
document.getElementById("copyButton").addEventListener("click", async () => {
const total = counts.blue + counts.sun + counts.silver;
const text =
`Common Pond / Board 07 — ${total} symbolic tokens ` +
`(Bluefin ${counts.blue}, Sunfin ${counts.sun}, Silverfin ${counts.silver}).`;
try {
await navigator.clipboard.writeText(text);
showToast("Stock summary copied");
} catch {
const textarea = document.createElement("textarea");
textarea.value = text;
textarea.style.position = "fixed";
textarea.style.opacity = "0";
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
textarea.remove();
showToast("Stock summary copied");
}
});
// Direct, dependency-free camera controls.
const cameraState = {
yaw: 0.16,
pitch: 0.72,
distance: 16.8,
target: new THREE.Vector3(0, 0.05, 0)
};
function updateCamera() {
const horizontal = Math.cos(cameraState.pitch) * cameraState.distance;
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);
}
function setView(mode) {
if (mode === "top") {
cameraState.yaw = 0;
cameraState.pitch = 1.49;
cameraState.distance = 15.2;
} else {
cameraState.yaw = 0.16;
cameraState.pitch = 0.72;
cameraState.distance = 16.8;
}
updateCamera();
}
document.getElementById("isoButton").addEventListener("click", () => setView("iso"));
document.getElementById("topButton").addEventListener("click", () => setView("top"));
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const pointers = new Map();
let dragDistance = 0;
let previousX = 0;
let previousY = 0;
let pinchStartDistance = 0;
let pinchStartCameraDistance = 0;
renderer.domElement.addEventListener("pointerdown", event => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
startX: event.clientX,
startY: event.clientY
});
if (pointers.size === 1) {
previousX = event.clientX;
previousY = event.clientY;
dragDistance = 0;
} else if (pointers.size === 2) {
const values = [...pointers.values()];
pinchStartDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
pinchStartCameraDistance = cameraState.distance;
}
});
renderer.domElement.addEventListener("pointermove", event => {
const current = pointers.get(event.pointerId);
if (!current) return;
current.x = event.clientX;
current.y = event.clientY;
if (pointers.size === 2) {
const values = [...pointers.values()];
const distance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
if (pinchStartDistance > 0) {
cameraState.distance = THREE.MathUtils.clamp(
pinchStartCameraDistance * pinchStartDistance / distance,
9.5,
25
);
updateCamera();
}
return;
}
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
dragDistance += Math.hypot(dx, dy);
cameraState.yaw -= dx * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.0045,
0.27,
1.49
);
updateCamera();
});
renderer.domElement.addEventListener("pointerup", event => {
const start = pointers.get(event.pointerId);
const wasClick = start &&
Math.hypot(event.clientX - start.startX, event.clientY - start.startY) < 5 &&
dragDistance < 7;
pointers.delete(event.pointerId);
if (wasClick && event.pointerType !== "touch") {
selectAt(event.clientX, event.clientY);
}
});
renderer.domElement.addEventListener("pointercancel", event => {
pointers.delete(event.pointerId);
pinchStartDistance = 0;
});
renderer.domElement.addEventListener("wheel", event => {
event.preventDefault();
cameraState.distance = THREE.MathUtils.clamp(
cameraState.distance + event.deltaY * 0.012,
9.5,
25
);
updateCamera();
}, { passive: false });
function selectAt(clientX, clientY) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(fishMeshes, false);
if (hits.length) {
const id = hits[0].object.userData.fishId;
selectedFish = fishes.find(fish => fish.id === id) || null;
if (selectedFish) {
setActiveSpecies(selectedFish.type);
selectionRing.visible = true;
selectionRing.position.x = selectedFish.group.position.x;
selectionRing.position.z = selectedFish.group.position.z;
}
} else {
selectedFish = null;
selectionRing.visible = false;
}
updateUI();
}
window.addEventListener("keydown", event => {
const key = event.key.toLowerCase();
if (key === "arrowleft") cameraState.yaw += 0.08;
else if (key === "arrowright") cameraState.yaw -= 0.08;
else if (key === "arrowup") cameraState.pitch += 0.06;
else if (key === "arrowdown") cameraState.pitch -= 0.06;
else if (key === "+" || key === "=") cameraState.distance -= 0.5;
else if (key === "-") cameraState.distance += 0.5;
else if (key === "r") setView("iso");
else return;
cameraState.pitch = THREE.MathUtils.clamp(cameraState.pitch, 0.27, 1.49);
cameraState.distance = THREE.MathUtils.clamp(cameraState.distance, 9.5, 25);
updateCamera();
event.preventDefault();
});
window.addEventListener("resize", () => {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
});
resetStock();
updateCamera();
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
for (const fish of fishes) {
fish.group.position.y = fish.baseY + Math.sin(elapsed * 1.35 + fish.phase) * 0.018;
fish.tailPivot.rotation.y = Math.sin(elapsed * 3.1 + fish.phase) * 0.14;
fish.group.rotation.z = Math.sin(elapsed * 1.05 + fish.phase) * 0.018;
}
if (selectedFish) {
selectionRing.position.x = selectedFish.group.position.x;
selectionRing.position.z = selectedFish.group.position.z;
const pulse = 1 + Math.sin(elapsed * 4.2) * 0.07;
selectionRing.scale.set(pulse, pulse, pulse);
}
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>
```