Prompt specification
Build or customize the Three.js 3D scene "Water-quality teaching kiosk" 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: Water-quality teaching kiosk
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/water-quality-teaching-kiosk-x1923
Scene Description Prompt:
I'd like to see this as a voxel Three.js scene: water-quality teaching kiosk. Compose a fictional pond sample display with synthetic pH readings and an explanatory scale; distinguish pH from general cleanliness, toxicity, or drinkability. Use cdnjs and return one self-contained HTML file.
Working Three.js Starter (water-quality-teaching-kiosk-x1923):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pond pH — Voxel Teaching Kiosk</title>
<style>
:root {
color-scheme: dark;
--accent: #4fd1c5;
--panel: rgba(7, 20, 29, 0.86);
--border: rgba(163, 216, 224, 0.19);
--text: #edf9f7;
--muted: #9db4ba;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #061018;
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.brand,
.info-card,
.scale-card,
.scene-hint {
position: fixed;
z-index: 10;
}
.brand {
top: 24px;
left: 26px;
width: min(390px, calc(100vw - 52px));
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
color: #9cc2c7;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 8px;
height: 8px;
border-radius: 2px;
background: var(--accent);
box-shadow: 0 0 16px var(--accent);
content: "";
}
.brand h1 {
margin: 0;
font-size: clamp(29px, 4vw, 52px);
line-height: 0.98;
letter-spacing: -0.045em;
text-shadow: 0 5px 28px rgba(0, 0, 0, 0.34);
}
.brand p {
max-width: 350px;
margin: 12px 0 0;
color: #b5c8cb;
font-size: 13px;
line-height: 1.55;
}
.reset-button {
display: inline-flex;
align-items: center;
gap: 8px;
margin-top: 14px;
padding: 8px 11px;
border: 1px solid var(--border);
border-radius: 9px;
background: rgba(8, 24, 34, 0.72);
color: #d8ecec;
cursor: pointer;
pointer-events: auto;
transition:
border-color 160ms ease,
background 160ms ease;
}
.reset-button:hover {
border-color: rgba(163, 216, 224, 0.42);
background: rgba(15, 39, 50, 0.9);
}
.info-card {
top: 24px;
right: 26px;
width: min(365px, calc(100vw - 52px));
max-height: calc(100vh - 235px);
overflow: auto;
padding: 19px;
border: 1px solid var(--border);
border-radius: 17px;
background:
linear-gradient(145deg, rgba(13, 36, 47, 0.92), rgba(5, 17, 25, 0.92)),
var(--panel);
box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
backdrop-filter: blur(14px);
}
.info-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 14px;
}
.sample-id {
color: #9bb7bc;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.synthetic-badge {
flex: 0 0 auto;
padding: 5px 7px;
border: 1px solid rgba(255, 193, 100, 0.28);
border-radius: 6px;
background: rgba(255, 193, 100, 0.08);
color: #ffd397;
font-size: 9px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.reading {
display: flex;
align-items: baseline;
gap: 10px;
margin-top: 5px;
}
.reading strong {
color: var(--accent);
font-size: 52px;
font-weight: 750;
line-height: 1;
letter-spacing: -0.055em;
text-shadow: 0 0 26px color-mix(in srgb, var(--accent) 22%, transparent);
}
.reading span {
color: #e3efef;
font-size: 15px;
font-weight: 750;
}
.sample-note {
min-height: 56px;
margin: 13px 0 17px;
color: #b7c9cc;
font-size: 12.5px;
line-height: 1.55;
}
.divider {
height: 1px;
margin: 16px 0;
background: var(--border);
}
.section-label {
margin: 0 0 8px;
color: #78969c;
font-size: 10px;
font-weight: 850;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.lesson {
margin: 0;
color: #d8e7e8;
font-size: 12.5px;
line-height: 1.55;
}
.lesson + .lesson {
margin-top: 9px;
}
.lesson strong {
color: #f2fbfb;
}
.lesson.warning strong {
color: #ffc47d;
}
.can-not-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
margin-top: 9px;
}
.can-not {
min-height: 66px;
padding: 9px;
border: 1px solid rgba(163, 216, 224, 0.12);
border-radius: 9px;
background: rgba(255, 255, 255, 0.025);
}
.can-not b {
display: block;
margin-bottom: 5px;
color: #effafa;
font-size: 11px;
}
.can-not span {
display: block;
color: #91a9ae;
font-size: 10px;
line-height: 1.35;
}
.drink-warning {
margin-top: 12px;
padding: 11px 12px;
border-left: 3px solid #ffc47d;
border-radius: 0 8px 8px 0;
background: rgba(255, 183, 102, 0.07);
color: #d9e3e2;
font-size: 11px;
line-height: 1.5;
}
.scale-card {
bottom: 18px;
left: 50%;
width: min(820px, calc(100vw - 32px));
padding: 14px 16px 12px;
transform: translateX(-50%);
border: 1px solid var(--border);
border-radius: 16px;
background: rgba(5, 18, 26, 0.9);
box-shadow: 0 16px 52px rgba(0, 0, 0, 0.4);
backdrop-filter: blur(15px);
}
.sample-tabs {
display: flex;
gap: 8px;
margin-bottom: 12px;
}
.sample-button {
display: flex;
flex: 1;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 0;
padding: 8px 10px;
border: 1px solid rgba(163, 216, 224, 0.13);
border-radius: 9px;
background: rgba(255, 255, 255, 0.025);
color: #a9bdc1;
cursor: pointer;
transition:
border-color 150ms ease,
color 150ms ease,
background 150ms ease,
transform 150ms ease;
}
.sample-button:hover {
transform: translateY(-1px);
border-color: color-mix(in srgb, var(--sample) 50%, transparent);
color: #e8f4f4;
}
.sample-button[aria-selected="true"] {
border-color: color-mix(in srgb, var(--sample) 70%, transparent);
background: color-mix(in srgb, var(--sample) 12%, transparent);
color: #f5ffff;
}
.sample-dot {
width: 9px;
height: 9px;
border-radius: 2px;
background: var(--sample);
box-shadow: 0 0 11px color-mix(in srgb, var(--sample) 65%, transparent);
}
.sample-button b {
font-size: 12px;
}
.sample-button span:last-child {
color: #80999f;
font-size: 11px;
}
.scale-labels {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
color: #849da2;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
.scale-labels .middle {
color: #a9c9b9;
}
#pH-range {
width: 100%;
height: 20px;
margin: 0;
accent-color: var(--accent);
cursor: pointer;
}
.ticks {
display: flex;
justify-content: space-between;
margin-top: 1px;
color: #657f85;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 9px;
}
.scale-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 9px;
color: #789196;
font-size: 9.5px;
line-height: 1.35;
}
.scale-footer strong {
color: #b7cccf;
font-weight: 700;
}
.scene-hint {
bottom: 174px;
left: 26px;
padding: 7px 9px;
border: 1px solid rgba(163, 216, 224, 0.11);
border-radius: 8px;
background: rgba(4, 15, 22, 0.6);
color: #779097;
font-size: 10px;
pointer-events: none;
}
@media (max-width: 860px) {
.brand {
top: 16px;
left: 16px;
}
.brand h1 {
font-size: 32px;
}
.brand p {
display: none;
}
.info-card {
top: auto;
right: 16px;
bottom: 170px;
width: min(350px, calc(100vw - 32px));
max-height: 38vh;
padding: 15px;
}
.reading strong {
font-size: 42px;
}
.sample-note {
min-height: 0;
}
.scene-hint {
display: none;
}
.scale-card {
bottom: 12px;
width: calc(100vw - 24px);
padding: 11px 12px;
}
.sample-button {
padding: 8px 5px;
}
.sample-button span:last-child {
display: none;
}
.scale-footer span:last-child {
display: none;
}
}
@media (max-height: 690px) {
.info-card {
max-height: calc(100vh - 205px);
}
.sample-note {
margin-bottom: 10px;
}
.divider {
margin: 10px 0;
}
.can-not {
min-height: 52px;
}
}
</style>
</head>
<body>
<div
id="scene"
role="img"
aria-label="Interactive voxel scene of a fictional pond pH teaching kiosk with three synthetic samples."
></div>
<header class="brand">
<div class="eyebrow">Fictional pond · Station P-17</div>
<h1>Pond pH<br />teaching kiosk</h1>
<p>
Explore a synthetic pond sample set. pH describes acidity—not whether
water is clean, toxic, or safe to drink.
</p>
<button class="reset-button" id="reset-view" type="button">
<span aria-hidden="true">↺</span> Reset view
</button>
</header>
<aside class="info-card" id="info-card" aria-live="polite">
<div class="info-top">
<div>
<div class="sample-id" id="sample-id">Synthetic sample P-02</div>
<div class="reading">
<strong id="reading-value">7.1</strong>
<span id="reading-label">pH</span>
</div>
</div>
<div class="synthetic-badge">Synthetic</div>
</div>
<p class="sample-note" id="sample-note"></p>
<div class="divider"></div>
<p class="section-label">What pH tells you</p>
<p class="lesson">
<strong>Relative acidity or alkalinity.</strong> A conventional classroom
scale runs from 0 to 14, with approximately 7 neutral at 25°C. Each whole
pH step represents roughly a tenfold change in hydrogen-ion activity.
</p>
<p class="section-label" style="margin-top: 16px">
What pH does not tell you
</p>
<div class="can-not-grid">
<div class="can-not">
<b>Cleanliness</b>
<span>Pollution and pathogens need separate evidence.</span>
</div>
<div class="can-not">
<b>Toxicity</b>
<span>Metals, chemicals, and other hazards are not measured by pH.</span>
</div>
<div class="can-not">
<b>Drinkability</b>
<span>Potability requires many tests, treatment, and approval.</span>
</div>
</div>
<div class="drink-warning">
<strong>Do not drink this sample.</strong> “Near neutral” does not mean
safe. Real drinking-water decisions require microbiological and chemical
testing, appropriate treatment, and local regulatory approval.
</div>
</aside>
<section class="scale-card" aria-label="Synthetic sample controls and pH scale">
<div class="sample-tabs" role="tablist" aria-label="Synthetic samples">
<button
class="sample-button"
style="--sample:#ff8a5b"
data-sample="0"
role="tab"
aria-selected="false"
type="button"
>
<span class="sample-dot"></span>
<b>P-01</b>
<span>pH 5.2</span>
</button>
<button
class="sample-button"
style="--sample:#4fd1c5"
data-sample="1"
role="tab"
aria-selected="true"
type="button"
>
<span class="sample-dot"></span>
<b>P-02</b>
<span>pH 7.1</span>
</button>
<button
class="sample-button"
style="--sample:#8c7cff"
data-sample="2"
role="tab"
aria-selected="false"
type="button"
>
<span class="sample-dot"></span>
<b>P-03</b>
<span>pH 8.6</span>
</button>
</div>
<div class="scale-labels">
<span>More acidic</span>
<span class="middle">Neutral ≈ 7</span>
<span>More alkaline</span>
</div>
<label for="pH-range" class="section-label" style="display: block">
Explore the conventional pH scale
</label>
<input
id="pH-range"
type="range"
min="0"
max="14"
step="0.1"
value="7.1"
aria-describedby="scale-live"
/>
<div class="ticks" aria-hidden="true">
<span>0</span><span>2</span><span>4</span><span>6</span><span>7</span>
<span>8</span><span>10</span><span>12</span><span>14</span>
</div>
<div class="scale-footer">
<span id="scale-live">
Marker: <strong>pH 7.1</strong> · Colors are teaching cues, not quality grades.
</span>
<span>0–14 is a classroom range; real measurements can fall outside it.</span>
</div>
</section>
<div class="scene-hint">Drag to orbit · Scroll to zoom · Click a sample vial</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const samples = [
{
id: "P-01",
code: "A",
ph: 5.2,
category: "Acidic",
color: "#ff8a5b",
note:
"This synthetic sample sits on the acidic side of the scale. Acidity can affect organisms and chemical behavior, but the reading does not reveal what caused it—or whether pollutants are present."
},
{
id: "P-02",
code: "B",
ph: 7.1,
category: "Near neutral",
color: "#4fd1c5",
note:
"This synthetic sample is slightly above neutral, so it is not acidic. That fact alone does not make it clean, non-toxic, or suitable for drinking."
},
{
id: "P-03",
code: "C",
ph: 8.6,
category: "Alkaline",
color: "#8c7cff",
note:
"This synthetic sample lies on the alkaline side of the scale. “Alkaline” describes acidity—not hygiene, chemical safety, or whether living conditions are good for every organism."
}
];
const sceneHost = document.getElementById("scene");
const infoCard = document.getElementById("info-card");
const sampleIdEl = document.getElementById("sample-id");
const readingValueEl = document.getElementById("reading-value");
const readingLabelEl = document.getElementById("reading-label");
const sampleNoteEl = document.getElementById("sample-note");
const rangeEl = document.getElementById("pH-range");
const scaleLiveEl = document.getElementById("scale-live");
const sampleButtons = [...document.querySelectorAll(".sample-button")];
// ------------------------------------------------------------
// Three.js scene
// ------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x061018);
scene.fog = new THREE.FogExp2(0x061018, 0.032);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute("aria-label", "Voxel pond pH teaching kiosk");
renderer.domElement.tabIndex = 0;
sceneHost.appendChild(renderer.domElement);
const world = new THREE.Group();
scene.add(world);
const cameraState = {
yaw: 0.58,
pitch: 0.52,
radius: 12.8,
target: new THREE.Vector3(0.15, 1.65, 0.05)
};
function updateCamera() {
const { yaw, pitch, radius, target } = cameraState;
const horizontal = Math.cos(pitch) * radius;
camera.position.set(
target.x + Math.sin(yaw) * horizontal,
target.y + Math.sin(pitch) * radius,
target.z + Math.cos(yaw) * horizontal
);
camera.lookAt(target);
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xbbeeff, 0x102a24, 2.25);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xfff2da, 3.3);
keyLight.position.set(5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 8;
keyLight.shadow.camera.bottom = -8;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 30;
keyLight.shadow.bias = -0.0005;
scene.add(keyLight);
const cyanLight = new THREE.PointLight(0x42d7d0, 22, 10, 2);
cyanLight.position.set(-3.5, 4.2, 2.8);
scene.add(cyanLight);
const violetLight = new THREE.PointLight(0x8b75ff, 18, 9, 2);
violetLight.position.set(4.4, 3.7, -0.6);
scene.add(violetLight);
const materials = {
floor: new THREE.MeshStandardMaterial({
color: 0x0a1921,
roughness: 0.95,
metalness: 0.02
}),
floorAlt: new THREE.MeshStandardMaterial({
color: 0x0c2028,
roughness: 0.95,
metalness: 0.02
}),
platform: new THREE.MeshStandardMaterial({
color: 0x18313a,
roughness: 0.72,
metalness: 0.14
}),
platformTop: new THREE.MeshStandardMaterial({
color: 0x27444b,
roughness: 0.65,
metalness: 0.08
}),
soil: new THREE.MeshStandardMaterial({
color: 0x66523d,
roughness: 1,
metalness: 0
}),
soilDark: new THREE.MeshStandardMaterial({
color: 0x3f352f,
roughness: 1,
metalness: 0
}),
grass: new THREE.MeshStandardMaterial({
color: 0x4d8b58,
roughness: 0.95,
metalness: 0
}),
grassLight: new THREE.MeshStandardMaterial({
color: 0x70a969,
roughness: 0.95,
metalness: 0
}),
reed: new THREE.MeshStandardMaterial({
color: 0x9fbd63,
roughness: 0.9,
metalness: 0
}),
rock: new THREE.MeshStandardMaterial({
color: 0x60747a,
roughness: 0.92,
metalness: 0.03
}),
board: new THREE.MeshStandardMaterial({
color: 0x071a23,
roughness: 0.58,
metalness: 0.25
}),
frame: new THREE.MeshStandardMaterial({
color: 0x34555d,
roughness: 0.42,
metalness: 0.58
}),
frameDark: new THREE.MeshStandardMaterial({
color: 0x183039,
roughness: 0.5,
metalness: 0.4
}),
white: new THREE.MeshStandardMaterial({
color: 0xe7f6f2,
emissive: 0x294c4a,
emissiveIntensity: 0.12,
roughness: 0.5
}),
glass: new THREE.MeshStandardMaterial({
color: 0xbfe9ed,
transparent: true,
opacity: 0.18,
roughness: 0.16,
metalness: 0.02,
depthWrite: false
})
};
function box(parent, size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeCanvasTexture(width, height, draw) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const context = canvas.getContext("2d");
draw(context, width, height);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return { canvas, context, texture };
}
function makeTextPlane(text, subtext, options = {}) {
const width = options.width || 512;
const height = options.height || 220;
const accent = options.accent || "#8ee9dc";
const transparent = options.transparent ?? false;
const result = makeCanvasTexture(width, height, (ctx, w, h) => {
if (!transparent) {
ctx.fillStyle = options.background || "#0b202a";
ctx.fillRect(0, 0, w, h);
}
if (options.border) {
ctx.strokeStyle = options.border;
ctx.lineWidth = 5;
ctx.strokeRect(3, 3, w - 6, h - 6);
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
if (text) {
ctx.fillStyle = options.textColor || "#eaf9f6";
ctx.font = options.font || `800 ${Math.round(h * 0.38)}px system-ui`;
ctx.fillText(text, w / 2, subtext ? h * 0.39 : h * 0.5);
}
if (subtext) {
ctx.fillStyle = options.subtextColor || accent;
ctx.font = options.subtextFont ||
`700 ${Math.round(h * 0.13)}px system-ui`;
ctx.fillText(subtext, w / 2, h * 0.75);
}
});
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(options.planeWidth, options.planeHeight),
new THREE.MeshBasicMaterial({
map: result.texture,
transparent,
depthWrite: false,
toneMapped: false
})
);
return { mesh, ...result };
}
// Ground tiles.
for (let x = -10; x <= 10; x++) {
for (let z = -8; z <= 8; z++) {
const material = (x + z) % 2 === 0
? materials.floor
: materials.floorAlt;
box(
scene,
[0.96, 0.05, 0.96],
[x, -0.04, z],
material,
false
);
}
}
// Main stepped voxel platform.
box(
world,
[9.65, 0.42, 5.65],
[0.12, 0.2, 0.02],
materials.platform
);
box(
world,
[9.28, 0.18, 5.3],
[0.12, 0.49, 0.02],
materials.platformTop
);
// Accent blocks along the platform.
for (let i = 0; i < 12; i++) {
const accentMaterial = new THREE.MeshStandardMaterial({
color: i % 3 === 0 ? 0x5ad4c8 : 0x29535b,
emissive: i % 3 === 0 ? 0x174842 : 0x000000,
emissiveIntensity: 0.28,
roughness: 0.65
});
box(
world,
[0.32, 0.08, 0.12],
[-4.0 + i * 0.73, 0.62, 2.72],
accentMaterial,
false
);
}
// ------------------------------------------------------------
// Voxel pond cutaway
// ------------------------------------------------------------
const pond = new THREE.Group();
world.add(pond);
const pondCenterX = -2.15;
const pondCenterZ = 0.18;
const pondCell = 0.4;
const pondCols = 12;
const pondRows = 9;
const waterTiles = [];
const waterMaterials = [
new THREE.MeshStandardMaterial({
color: 0x238b99,
emissive: 0x0d3945,
emissiveIntensity: 0.35,
roughness: 0.32,
metalness: 0.06,
transparent: true,
opacity: 0.9
}),
new THREE.MeshStandardMaterial({
color: 0x2b9aa3,
emissive: 0x0d3c44,
emissiveIntensity: 0.3,
roughness: 0.36,
metalness: 0.05,
transparent: true,
opacity: 0.9
}),
new THREE.MeshStandardMaterial({
color: 0x337e8f,
emissive: 0x0c303b,
emissiveIntensity: 0.3,
roughness: 0.38,
metalness: 0.05,
transparent: true,
opacity: 0.92
})
];
for (let row = 0; row < pondRows; row++) {
for (let col = 0; col < pondCols; col++) {
const x =
pondCenterX + (col - (pondCols - 1) / 2) * pondCell;
const z =
pondCenterZ + (row - (pondRows - 1) / 2) * pondCell;
const edge =
col === 0 ||
col === pondCols - 1 ||
row === 0 ||
row === pondRows - 1;
if (edge) {
const soilMaterial = (row + col) % 3 === 0
? materials.soilDark
: materials.soil;
box(
pond,
[0.39, 0.5, 0.39],
[x, 0.79, z],
soilMaterial
);
box(
pond,
[0.39, 0.11, 0.39],
[x, 1.09, z],
(row + col) % 2 ? materials.grass : materials.grassLight
);
} else {
const tile = box(
pond,
[0.37, 0.14, 0.37],
[x, 0.76, z],
waterMaterials[(row * 3 + col) % waterMaterials.length],
false
);
tile.userData.baseY = tile.position.y;
tile.userData.phase = (row * 1.7 + col * 0.93) % 6.28;
waterTiles.push(tile);
}
}
}
// Small island.
const island = new THREE.Group();
pond.add(island);
box(island, [0.65, 0.2, 0.55], [-2.7, 0.91, 0.22], materials.soil);
box(island, [0.59, 0.1, 0.49], [-2.7, 1.06, 0.22], materials.grass);
box(
island,
[0.27, 0.27, 0.27],
[-2.78, 1.23, 0.18],
materials.rock
);
// Lily pads.
const padMaterial = new THREE.MeshStandardMaterial({
color: 0x5ba05e,
roughness: 0.85
});
const padPositions = [
[-3.42, 0.82, 0.66],
[-1.42, 0.82, -0.45],
[-0.65, 0.82, 0.77]
];
for (const [x, y, z] of padPositions) {
box(pond, [0.46, 0.055, 0.38], [x, y, z], padMaterial);
box(
pond,
[0.08, 0.06, 0.12],
[x + 0.11, y + 0.045, z],
materials.grassLight
);
}
// Reeds.
const reedPositions = [
[-4.0, 0.95],
[-3.83, 1.18],
[-3.55, 1.32],
[-0.05, 1.18],
[0.06, 1.42],
[-1.42, -1.28],
[-1.22, -1.32]
];
for (const [x, z] of reedPositions) {
for (let i = 0; i < 3; i++) {
const height = 0.48 + i * 0.16;
box(
pond,
[0.07, height, 0.07],
[x + i * 0.09, 1.08 + height / 2, z + (i % 2) * 0.06],
materials.reed
);
}
}
// Three synthetic sampling probes in the pond.
const probePositions = [
[-3.55, -0.35],
[-2.15, 0.7],
[-0.85, -0.42]
];
probePositions.forEach(([x, z], index) => {
const sample = samples[index];
const probeMaterial = new THREE.MeshStandardMaterial({
color: sample.color,
emissive: sample.color,
emissiveIntensity: 0.48,
roughness: 0.38
});
box(
pond,
[0.08, 0.8, 0.08],
[x, 1.12, z],
materials.frameDark
);
box(
pond,
[0.24, 0.24, 0.24],
[x, 1.61, z],
probeMaterial
);
});
// ------------------------------------------------------------
// Kiosk board and physical pH scale
// ------------------------------------------------------------
const kiosk = new THREE.Group();
world.add(kiosk);
box(
kiosk,
[5.65, 3.45, 0.24],
[2.1, 2.78, -1.45],
materials.board
);
// Frame rails.
box(kiosk, [5.85, 0.16, 0.32], [2.1, 4.49, -1.42], materials.frame);
box(kiosk, [5.85, 0.16, 0.32], [2.1, 1.08, -1.42], materials.frame);
box(kiosk, [0.16, 3.56, 0.32], [-0.74, 2.78, -1.42], materials.frame);
box(kiosk, [0.16, 3.56, 0.32], [4.94, 2.78, -1.42], materials.frame);
// Supports.
box(kiosk, [0.24, 1.52, 0.28], [-0.54, 1.1, -1.49], materials.frameDark);
box(kiosk, [0.24, 1.52, 0.28], [4.74, 1.1, -1.49], materials.frameDark);
const title = makeTextPlane(
"POND pH",
"MOSSBANK TEACHING POND · SYNTHETIC SET",
{
width: 900,
height: 260,
planeWidth: 3.2,
planeHeight: 0.74,
background: "#0a222b",
textColor: "#effcf9",
subtextColor: "#79d9cf",
font: "850 112px system-ui",
subtextFont: "750 27px system-ui"
}
);
title.mesh.position.set(0.89, 3.82, -1.315);
kiosk.add(title.mesh);
const readout = makeCanvasTexture(900, 360, () => {});
const readoutMesh = new THREE.Mesh(
new THREE.PlaneGeometry(1.92, 0.77),
new THREE.MeshBasicMaterial({
map: readout.texture,
toneMapped: false
})
);
readoutMesh.position.set(3.53, 3.68, -1.31);
kiosk.add(readoutMesh);
// Physical 0–14 scale: 29 voxel segments.
const scale = new THREE.Group();
kiosk.add(scale);
const scaleLeft = 0.08;
const scaleRight = 4.12;
const scaleWidth = scaleRight - scaleLeft;
function pHColor(value) {
let hue;
if (value <= 3) hue = THREE.MathUtils.lerp(0.0, 0.09, value / 3);
else if (value <= 6) hue = THREE.MathUtils.lerp(0.09, 0.2, (value - 3) / 3);
else if (value <= 9) hue = THREE.MathUtils.lerp(0.2, 0.47, (value - 6) / 3);
else hue = THREE.MathUtils.lerp(0.47, 0.76, (value - 9) / 5);
return new THREE.Color().setHSL(hue, 0.78, 0.56);
}
for (let i = 0; i <= 28; i++) {
const ph = i / 2;
const x = scaleLeft + (ph / 14) * scaleWidth;
const color = pHColor(ph);
const segmentMaterial = new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: 0.16,
roughness: 0.45,
metalness: 0.08
});
box(
scale,
[0.126, 0.25, 0.15],
[x, 2.47, -1.205],
segmentMaterial,
false
);
}
// Scale labels.
for (const ph of [0, 2, 4, 6, 7, 8, 10, 12, 14]) {
const x = scaleLeft + (ph / 14) * scaleWidth;
const label = makeTextPlane(
String(ph),
"",
{
width: 128,
height: 96,
planeWidth: ph === 7 ? 0.3 : 0.25,
planeHeight: 0.19,
transparent: true,
textColor: ph === 7 ? "#bfffea" : "#b6ced1",
font: "800 60px ui-monospace, monospace"
}
);
label.mesh.position.set(x, 2.12, -1.08);
kiosk.add(label.mesh);
}
const statement = makeTextPlane(
"pH measures acidity — not cleanliness, toxicity, or drinkability",
"CONVENTIONAL CLASSROOM SCALE · NEUTRAL ≈ 7 AT 25°C",
{
width: 1100,
height: 240,
planeWidth: 5.0,
planeHeight: 0.76,
background: "#0a2029",
textColor: "#d8eceb",
subtextColor: "#78aaa9",
font: "750 43px system-ui",
subtextFont: "700 25px system-ui",
border: "#173b44"
}
);
statement.mesh.position.set(2.1, 1.6, -1.31);
kiosk.add(statement.mesh);
// Marker above the physical scale.
const marker = new THREE.Group();
kiosk.add(marker);
const markerMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
emissive: 0xb9fff2,
emissiveIntensity: 0.72,
roughness: 0.3
});
box(marker, [0.07, 0.44, 0.12], [0, 2.71, -1.06], markerMaterial, false);
box(marker, [0.19, 0.13, 0.13], [0, 2.91, -1.06], markerMaterial, false);
function pHToX(value) {
return scaleLeft + (THREE.MathUtils.clamp(value, 0, 14) / 14) * scaleWidth;
}
// ------------------------------------------------------------
// Three voxel sample vials
// ------------------------------------------------------------
const bottleGroups = [];
const pickables = [];
const bottlePositions = [1.23, 2.48, 3.73];
samples.forEach((sample, index) => {
const group = new THREE.Group();
group.position.set(bottlePositions[index], 0.59, 1.23);
group.userData.sampleIndex = index;
world.add(group);
const liquidMaterial = new THREE.MeshStandardMaterial({
color: sample.color,
emissive: sample.color,
emissiveIntensity: 0.25,
roughness: 0.3,
metalness: 0.04,
transparent: true,
opacity: 0.92
});
const capMaterial = new THREE.MeshStandardMaterial({
color: new THREE.Color(sample.color).multiplyScalar(0.65),
roughness: 0.48,
metalness: 0.22
});
const ringMaterial = new THREE.MeshBasicMaterial({
color: sample.color,
transparent: true,
opacity: 0.18,
depthWrite: false
});
const ring = box(
group,
[0.92, 0.045, 0.92],
[0, 0.03, 0],
ringMaterial,
false
);
const glass = box(
group,
[0.67, 1.32, 0.67],
[0, 0.78, 0],
materials.glass,
false
);
const liquid = box(
group,
[0.48, 0.82, 0.48],
[0, 0.55, 0],
liquidMaterial
);
box(group, [0.32, 0.28, 0.32], [0, 1.57, 0], materials.glass, false);
box(group, [0.39, 0.16, 0.39], [0, 1.77, 0], capMaterial);
const bottleLabel = makeTextPlane(
`pH ${sample.ph.toFixed(1)}`,
sample.id,
{
width: 420,
height: 250,
planeWidth: 0.69,
planeHeight: 0.41,
background: "#e8f5f0",
textColor: "#102b31",
subtextColor: "#28565a",
font: "850 74px system-ui",
subtextFont: "800 30px system-ui"
}
);
bottleLabel.mesh.position.set(0, 0.79, 0.342);
group.add(bottleLabel.mesh);
// Small physical sample-code tile.
const codeMaterial = new THREE.MeshStandardMaterial({
color: sample.color,
emissive: sample.color,
emissiveIntensity: 0.35
});
box(group, [0.19, 0.19, 0.06], [0, 1.16, 0.35], codeMaterial);
group.traverse((child) => {
if (child.isMesh) {
child.userData.sampleIndex = index;
pickables.push(child);
}
});
bottleGroups.push({
group,
ring,
ringMaterial,
liquidMaterial
});
});
// Front platform plaque.
const plaque = makeTextPlane(
"FICTIONAL POND · STATION P-17",
"SYNTHETIC TEACHING DISPLAY · NOT FOR CONSUMPTION",
{
width: 1000,
height: 220,
planeWidth: 4.3,
planeHeight: 0.56,
background: "#0a2028",
textColor: "#d7eeeb",
subtextColor: "#6fa29f",
font: "800 51px system-ui",
subtextFont: "750 24px system-ui"
}
);
plaque.mesh.position.set(0.1, 0.3, 2.856);
world.add(plaque.mesh);
// ------------------------------------------------------------
// Readout and UI updates
// ------------------------------------------------------------
function categoryForValue(value) {
if (value < 6.5) return "Acidic";
if (value <= 7.5) return "Near neutral";
return "Alkaline";
}
function drawReadout(value, label, accent, preview = false) {
const ctx = readout.context;
const w = readout.canvas.width;
const h = readout.canvas.height;
ctx.clearRect(0, 0, w, h);
ctx.fillStyle = "#071b24";
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = accent;
ctx.fillRect(0, 0, 12, h);
ctx.textAlign = "left";
ctx.textBaseline = "middle";
ctx.fillStyle = preview ? "#8bb0b4" : "#83aaa9";
ctx.font = "750 27px system-ui";
ctx.fillText(preview ? "SCALE PREVIEW" : label.toUpperCase(), 42, 60);
ctx.fillStyle = "#effcf9";
ctx.font = "850 105px system-ui";
ctx.fillText(`pH ${value.toFixed(1)}`, 38, 163);
ctx.fillStyle = accent;
ctx.font = "750 34px system-ui";
ctx.fillText(categoryForValue(value).toUpperCase(), 42, 262);
ctx.strokeStyle = "#1d424b";
ctx.lineWidth = 4;
ctx.strokeRect(2, 2, w - 4, h - 4);
readout.texture.needsUpdate = true;
}
function updateMarker(value) {
marker.position.x = pHToX(value);
}
function selectSample(index) {
const sample = samples[index];
sampleIdEl.textContent = `Synthetic sample ${sample.id}`;
readingValueEl.textContent = sample.ph.toFixed(1);
readingLabelEl.textContent = `pH · ${sample.category}`;
sampleNoteEl.textContent = sample.note;
infoCard.style.setProperty("--accent", sample.color);
rangeEl.style.setProperty("--accent", sample.color);
rangeEl.value = sample.ph.toFixed(1);
sampleButtons.forEach((button, buttonIndex) => {
button.setAttribute("aria-selected", String(buttonIndex === index));
});
bottleGroups.forEach((bottle, bottleIndex) => {
const selected = bottleIndex === index;
bottle.ringMaterial.opacity = selected ? 0.74 : 0.1;
bottle.ring.scale.setScalar(selected ? 1.08 : 0.9);
bottle.liquidMaterial.emissiveIntensity = selected ? 0.4 : 0.12;
});
updateMarker(sample.ph);
drawReadout(sample.ph, sample.id, sample.color);
scaleLiveEl.innerHTML =
`Marker: <strong>pH ${sample.ph.toFixed(1)}</strong> · ` +
"Colors are teaching cues, not quality grades.";
}
sampleButtons.forEach((button) => {
button.addEventListener("click", () => {
selectSample(Number(button.dataset.sample));
});
});
rangeEl.addEventListener("input", () => {
const value = Number(rangeEl.value);
updateMarker(value);
const accent = pHColor(value).getStyle();
drawReadout(value, "Scale preview", accent, true);
scaleLiveEl.innerHTML =
`Exploring <strong>pH ${value.toFixed(1)}</strong> · ` +
"This moves the scale marker only; it does not change the selected sample.";
});
// ------------------------------------------------------------
// Direct camera controls: drag to orbit, wheel/pinch to zoom
// ------------------------------------------------------------
const pointer = {
down: false,
dragging: false,
startX: 0,
startY: 0,
lastX: 0,
lastY: 0
};
const raycaster = new THREE.Raycaster();
const pointerNDC = new THREE.Vector2();
renderer.domElement.addEventListener("pointerdown", (event) => {
pointer.down = true;
pointer.dragging = false;
pointer.startX = pointer.lastX = event.clientX;
pointer.startY = pointer.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!pointer.down) return;
const dx = event.clientX - pointer.lastX;
const dy = event.clientY - pointer.lastY;
const totalDistance = Math.hypot(
event.clientX - pointer.startX,
event.clientY - pointer.startY
);
if (totalDistance > 4) pointer.dragging = true;
cameraState.yaw -= dx * 0.006;
cameraState.pitch = THREE.MathUtils.clamp(
cameraState.pitch + dy * 0.005,
0.2,
1.12
);
pointer.lastX = event.clientX;
pointer.lastY = event.clientY;
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
pointer.down = false;
if (!pointer.dragging) {
const rect = renderer.domElement.getBoundingClientRect();
pointerNDC.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointerNDC.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointerNDC, camera);
const intersections = raycaster.intersectObjects(pickables, false);
if (intersections.length) {
const hit = intersections[0].object;
if (Number.isInteger(hit.userData.sampleIndex)) {
selectSample(hit.userData.sampleIndex);
}
}
}
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointer.down = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.008,
8.4,
17
);
updateCamera();
},
{ passive: false }
);
document.getElementById("reset-view").addEventListener("click", () => {
cameraState.yaw = 0.58;
cameraState.pitch = 0.52;
cameraState.radius = 12.8;
cameraState.target.set(0.15, 1.65, 0.05);
updateCamera();
selectSample(1);
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
const time = clock.getElapsedTime();
for (const tile of waterTiles) {
tile.position.y =
tile.userData.baseY + Math.sin(time * 1.25 + tile.userData.phase) * 0.018;
}
bottleGroups.forEach((bottle, index) => {
const pulse = 1 + Math.sin(time * 2.1 + index * 1.7) * 0.025;
bottle.ring.scale.set(
(index === 1 ? 1.08 : 0.9) * pulse,
1,
(index === 1 ? 1.08 : 0.9) * pulse
);
});
marker.children[0].position.y =
2.71 + Math.sin(time * 2.6) * 0.025;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
selectSample(1);
animate();
</script>
</body>
</html>
```