Prompt specification
Build or customize the Three.js 3D scene "Graduated rain collector on a garden stake" 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: Graduated rain collector on a garden stake
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/graduated-rain-collector-on-a-garden-stake-x1233
Scene Description Prompt:
A low-poly rain gauge with transparent graduated cylinder, collected water, and a connected funnel. One HTML file, Three.js from cdnjs.
Working Three.js Starter (graduated-rain-collector-on-a-garden-stake-x1233):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Low-Poly Rain Gauge</title>
<style>
:root {
color-scheme: light;
--ink: #183b40;
--muted: #597276;
--accent: #1698a8;
--panel: rgba(247, 250, 247, 0.82);
--line: rgba(24, 59, 64, 0.13);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8ede7;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.hud {
position: fixed;
z-index: 5;
top: 32px;
left: 34px;
width: min(310px, calc(100vw - 68px));
pointer-events: none;
color: var(--ink);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 12px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 24px;
height: 2px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-size: clamp(34px, 5vw, 58px);
font-weight: 650;
letter-spacing: -0.055em;
line-height: 0.95;
}
.subtitle {
max-width: 250px;
margin: 15px 0 0;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.reading {
position: fixed;
z-index: 5;
top: 32px;
right: 32px;
width: 178px;
padding: 16px 17px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(29, 61, 58, 0.08);
backdrop-filter: blur(12px);
color: var(--ink);
pointer-events: none;
}
.reading-label {
display: flex;
align-items: center;
gap: 7px;
margin-bottom: 9px;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.live-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px rgba(22, 152, 168, 0.11);
animation: pulse 2s infinite;
}
.reading-value {
font-variant-numeric: tabular-nums;
font-size: 27px;
font-weight: 700;
letter-spacing: -0.045em;
}
.reading-value small {
color: var(--muted);
font-size: 12px;
font-weight: 600;
letter-spacing: 0;
}
.level-bar {
height: 4px;
margin-top: 13px;
overflow: hidden;
border-radius: 8px;
background: rgba(24, 59, 64, 0.09);
}
.level-bar span {
display: block;
width: 38.6%;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #36b8c5, #168f9f);
}
.controls {
position: fixed;
z-index: 5;
right: 32px;
bottom: 28px;
display: flex;
align-items: center;
gap: 12px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.controls span {
padding: 9px 12px;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--panel);
backdrop-filter: blur(10px);
}
button {
border: 0;
cursor: pointer;
font: inherit;
}
#reset {
width: 34px;
height: 34px;
padding: 0;
border: 1px solid var(--line);
border-radius: 50%;
background: var(--panel);
color: var(--ink);
backdrop-filter: blur(10px);
transition: transform 160ms ease, background 160ms ease;
}
#reset:hover {
transform: rotate(-25deg);
background: #fff;
}
.corner-mark {
position: fixed;
z-index: 5;
bottom: 30px;
left: 34px;
width: 42px;
height: 42px;
border-left: 1px solid rgba(24, 59, 64, 0.18);
border-bottom: 1px solid rgba(24, 59, 64, 0.18);
pointer-events: none;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.35; }
}
@media (max-width: 680px) {
.hud {
top: 22px;
left: 22px;
}
.subtitle {
display: none;
}
.reading {
top: auto;
right: 20px;
bottom: 74px;
width: 158px;
}
.controls {
right: 20px;
bottom: 20px;
}
.controls span {
display: none;
}
.corner-mark {
display: none;
}
}
</style>
</head>
<body>
<div class="hud">
<div class="eyebrow">Weather series · Instrument 07</div>
<h1>Rain<br>gauge</h1>
<p class="subtitle">
A transparent graduated collector with a connected funnel, rendered as a
low-poly field instrument.
</p>
</div>
<div class="reading">
<div class="reading-label">
<span class="live-dot"></span>
Collected volume
</div>
<div class="reading-value">38.6 <small>mL</small></div>
<div class="level-bar"><span></span></div>
</div>
<div class="controls">
<span>Drag to orbit · Scroll to zoom</span>
<button id="reset" aria-label="Reset camera" title="Reset camera">↻</button>
</div>
<div class="corner-mark"></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// Scene
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8ede7);
scene.fog = new THREE.Fog(0xe8ede7, 9, 18);
const camera = new THREE.PerspectiveCamera(
35,
innerWidth / innerHeight,
0.1,
50
);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
document.body.prepend(renderer.domElement);
// Lighting
scene.add(new THREE.HemisphereLight(0xf7fbff, 0x788479, 2.25));
const keyLight = new THREE.DirectionalLight(0xffffff, 3.4);
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 = 7;
keyLight.shadow.camera.bottom = -2;
keyLight.shadow.bias = -0.0004;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xbceff4, 1.5);
fillLight.position.set(-4, 3, -3);
scene.add(fillLight);
const rimLight = new THREE.DirectionalLight(0xffd9aa, 1.15);
rimLight.position.set(1, 5, -5);
scene.add(rimLight);
// Materials
const glassMaterial = new THREE.MeshPhysicalMaterial({
color: 0xc8eef2,
roughness: 0.12,
metalness: 0.02,
transparent: true,
opacity: 0.26,
clearcoat: 1,
clearcoatRoughness: 0.08,
side: THREE.DoubleSide,
depthWrite: false
});
const funnelMaterial = new THREE.MeshPhysicalMaterial({
color: 0x9edbe2,
roughness: 0.16,
metalness: 0.02,
transparent: true,
opacity: 0.38,
clearcoat: 0.8,
side: THREE.DoubleSide,
depthWrite: false
});
const waterMaterial = new THREE.MeshPhysicalMaterial({
color: 0x159eb3,
roughness: 0.12,
metalness: 0.02,
transparent: true,
opacity: 0.72,
clearcoat: 1,
clearcoatRoughness: 0.05,
side: THREE.DoubleSide,
depthWrite: false
});
const surfaceMaterial = new THREE.MeshPhysicalMaterial({
color: 0x36b7c5,
roughness: 0.08,
metalness: 0.02,
transparent: true,
opacity: 0.82,
clearcoat: 1,
side: THREE.DoubleSide,
depthWrite: false
});
const rimMaterial = new THREE.MeshStandardMaterial({
color: 0x285d62,
roughness: 0.45,
metalness: 0.28,
flatShading: true
});
const baseMaterial = new THREE.MeshStandardMaterial({
color: 0xc4d1c9,
roughness: 0.8,
metalness: 0.05,
flatShading: true
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: 0x188f9f,
roughness: 0.35,
metalness: 0.18,
flatShading: true
});
// Ground
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(30, 30),
new THREE.MeshStandardMaterial({
color: 0xe1e8e1,
roughness: 0.96,
metalness: 0
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.01;
ground.receiveShadow = true;
scene.add(ground);
const groundRing = new THREE.Mesh(
new THREE.RingGeometry(2.15, 2.17, 64),
new THREE.MeshBasicMaterial({
color: 0x9aaea4,
transparent: true,
opacity: 0.28,
side: THREE.DoubleSide
})
);
groundRing.rotation.x = -Math.PI / 2;
groundRing.position.y = 0.002;
scene.add(groundRing);
// Gauge assembly
const gauge = new THREE.Group();
scene.add(gauge);
const base = new THREE.Mesh(
new THREE.CylinderGeometry(0.94, 1.04, 0.16, 12),
baseMaterial
);
base.position.y = 0.08;
base.castShadow = true;
base.receiveShadow = true;
gauge.add(base);
const baseInset = new THREE.Mesh(
new THREE.CylinderGeometry(0.75, 0.81, 0.045, 12),
accentMaterial
);
baseInset.position.y = 0.175;
baseInset.castShadow = true;
gauge.add(baseInset);
// Transparent graduated cylinder
const cylinderRadius = 0.72;
const cylinderBottom = 0.19;
const cylinderHeight = 2.59;
const cylinderTop = cylinderBottom + cylinderHeight;
const cylinder = new THREE.Mesh(
new THREE.CylinderGeometry(
cylinderRadius,
cylinderRadius,
cylinderHeight,
16,
1,
true
),
glassMaterial
);
cylinder.position.y = cylinderBottom + cylinderHeight / 2;
cylinder.renderOrder = 4;
gauge.add(cylinder);
const bottomRing = new THREE.Mesh(
new THREE.TorusGeometry(cylinderRadius, 0.035, 6, 20),
rimMaterial
);
bottomRing.rotation.x = Math.PI / 2;
bottomRing.position.y = cylinderBottom;
bottomRing.castShadow = true;
gauge.add(bottomRing);
const topRing = new THREE.Mesh(
new THREE.TorusGeometry(cylinderRadius, 0.037, 6, 20),
rimMaterial
);
topRing.rotation.x = Math.PI / 2;
topRing.position.y = cylinderTop;
topRing.castShadow = true;
gauge.add(topRing);
// Collected water
const waterBottom = 0.235;
const waterTop = 1.21;
const waterHeight = waterTop - waterBottom;
const water = new THREE.Mesh(
new THREE.CylinderGeometry(
cylinderRadius - 0.055,
cylinderRadius - 0.055,
waterHeight,
16
),
waterMaterial
);
water.position.y = waterBottom + waterHeight / 2;
water.renderOrder = 2;
gauge.add(water);
const waterSurface = new THREE.Mesh(
new THREE.CircleGeometry(cylinderRadius - 0.052, 20),
surfaceMaterial
);
waterSurface.rotation.x = -Math.PI / 2;
waterSurface.position.y = waterTop;
waterSurface.renderOrder = 3;
gauge.add(waterSurface);
// Small ripple rings
const rippleMeshes = [];
for (let i = 0; i < 3; i++) {
const ripple = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.008, 4, 24),
new THREE.MeshBasicMaterial({
color: 0xb9f1f4,
transparent: true,
opacity: 0.25,
depthWrite: false
})
);
ripple.rotation.x = Math.PI / 2;
ripple.position.y = waterTop + 0.006;
ripple.renderOrder = 4;
gauge.add(ripple);
rippleMeshes.push(ripple);
}
// Connected funnel
const funnelTop = 4.0;
const funnelBottom = 3.05;
const funnelHeight = funnelTop - funnelBottom;
const funnel = new THREE.Mesh(
new THREE.CylinderGeometry(
1.24,
0.13,
funnelHeight,
14,
1,
true
),
funnelMaterial
);
funnel.position.y = funnelBottom + funnelHeight / 2;
funnel.renderOrder = 4;
gauge.add(funnel);
const funnelInterior = new THREE.Mesh(
new THREE.CylinderGeometry(
1.18,
0.105,
funnelHeight - 0.025,
14,
1,
true
),
new THREE.MeshBasicMaterial({
color: 0x5bb9c4,
transparent: true,
opacity: 0.075,
side: THREE.BackSide,
depthWrite: false
})
);
funnelInterior.position.copy(funnel.position);
funnelInterior.renderOrder = 3;
gauge.add(funnelInterior);
const funnelRim = new THREE.Mesh(
new THREE.TorusGeometry(1.24, 0.052, 6, 24),
rimMaterial
);
funnelRim.rotation.x = Math.PI / 2;
funnelRim.position.y = funnelTop;
funnelRim.castShadow = true;
gauge.add(funnelRim);
const tube = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.13, 0.38, 12, 1, true),
funnelMaterial
);
tube.position.y = 2.91;
tube.renderOrder = 4;
gauge.add(tube);
const tubeBand = new THREE.Mesh(
new THREE.TorusGeometry(0.135, 0.026, 5, 16),
accentMaterial
);
tubeBand.rotation.x = Math.PI / 2;
tubeBand.position.y = 2.76;
gauge.add(tubeBand);
// Thin water stream from funnel into the collector
const streamTop = 3.01;
const streamBottom = waterTop + 0.015;
const stream = new THREE.Mesh(
new THREE.CylinderGeometry(
0.013,
0.02,
streamTop - streamBottom,
7
),
new THREE.MeshPhysicalMaterial({
color: 0x37bacb,
transparent: true,
opacity: 0.55,
roughness: 0.05,
depthWrite: false
})
);
stream.position.y = (streamTop + streamBottom) / 2;
stream.renderOrder = 5;
gauge.add(stream);
// Graduations
const graduationPositions = [];
const graduationBottom = 0.29;
const graduationTop = 2.68;
const graduationCount = 11;
for (let i = 0; i < graduationCount; i++) {
const t = i / (graduationCount - 1);
const y = THREE.MathUtils.lerp(graduationBottom, graduationTop, t);
const major = i % 2 === 0 || i === graduationCount - 1;
const startX = -0.18;
const endX = major ? 0.25 : 0.08;
graduationPositions.push(
startX, y, 0.73,
endX, y, 0.73
);
}
const graduationGeometry = new THREE.BufferGeometry();
graduationGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(graduationPositions, 3)
);
const graduations = new THREE.LineSegments(
graduationGeometry,
new THREE.LineBasicMaterial({
color: 0x174e56,
transparent: true,
opacity: 0.72
})
);
graduations.renderOrder = 6;
gauge.add(graduations);
function makeLabel(text, width = 0.31) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 128;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.fillStyle = "#24535a";
context.font = "700 58px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 128, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false,
toneMapped: false
})
);
sprite.scale.set(width, width * 0.5, 1);
sprite.renderOrder = 10;
return sprite;
}
for (let i = 0; i < graduationCount; i++) {
const t = i / (graduationCount - 1);
const y = THREE.MathUtils.lerp(graduationBottom, graduationTop, t);
const label = makeLabel(String(i * 10), i === 10 ? 0.35 : 0.30);
label.position.set(0.43, y, 0.75);
gauge.add(label);
}
const unitLabel = makeLabel("mL", 0.34);
unitLabel.position.set(0.51, 2.79, 0.73);
gauge.add(unitLabel);
// Stylized low-poly rain
const rainCount = 38;
const rainGeometry = new THREE.SphereGeometry(1, 6, 4);
const rainMaterial = new THREE.MeshPhysicalMaterial({
color: 0x46aebe,
transparent: true,
opacity: 0.54,
roughness: 0.05,
depthWrite: false
});
const rain = new THREE.InstancedMesh(
rainGeometry,
rainMaterial,
rainCount
);
rain.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
rain.frustumCulled = false;
scene.add(rain);
const rainDrops = [];
for (let i = 0; i < rainCount; i++) {
const angle = Math.random() * Math.PI * 2;
const radius = Math.sqrt(Math.random()) * 1.8;
rainDrops.push({
x: Math.cos(angle) * radius,
z: Math.sin(angle) * radius,
y: 3.4 + Math.random() * 4,
speed: 2.2 + Math.random() * 2.1
});
}
const rainDummy = new THREE.Object3D();
function resetDrop(drop) {
const angle = Math.random() * Math.PI * 2;
const radius = Math.sqrt(Math.random()) * 1.8;
drop.x = Math.cos(angle) * radius;
drop.z = Math.sin(angle) * radius;
drop.y = 5.7 + Math.random() * 1.8;
drop.speed = 2.2 + Math.random() * 2.1;
}
// Direct camera controls
const target = new THREE.Vector3(0, 2.05, 0);
const defaultCamera = {
theta: 0.57,
phi: 1.18,
radius: 7.1
};
const desired = { ...defaultCamera };
const current = { ...defaultCamera };
const spherical = new THREE.Spherical();
const pointer = new THREE.Vector2();
let dragging = false;
let previousX = 0;
let previousY = 0;
const canvas = renderer.domElement;
canvas.tabIndex = 0;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
canvas.setPointerCapture(event.pointerId);
canvas.style.cursor = "grabbing";
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
desired.theta -= deltaX * 0.006;
desired.phi = THREE.MathUtils.clamp(
desired.phi - deltaY * 0.005,
0.48,
1.48
);
});
function endDrag(event) {
dragging = false;
canvas.style.cursor = "grab";
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.style.cursor = "grab";
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius * Math.exp(event.deltaY * 0.001),
4.2,
11
);
},
{ passive: false }
);
function resetCamera() {
Object.assign(desired, defaultCamera);
}
document.getElementById("reset").addEventListener("click", resetCamera);
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
const step = 0.08;
if (event.key === "ArrowLeft") desired.theta += step;
if (event.key === "ArrowRight") desired.theta -= step;
if (event.key === "ArrowUp") {
desired.phi = Math.max(0.48, desired.phi - step);
}
if (event.key === "ArrowDown") {
desired.phi = Math.min(1.48, desired.phi + step);
}
if (event.key === "+" || event.key === "=") {
desired.radius = Math.max(4.2, desired.radius - 0.5);
}
if (event.key === "-") {
desired.radius = Math.min(11, desired.radius + 0.5);
}
if (event.key.toLowerCase() === "r") resetCamera();
});
// Resize
function resize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
// Animation
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
const delta = Math.min(clock.getDelta(), 0.04);
// Smooth camera orbit
current.theta = THREE.MathUtils.lerp(
current.theta,
desired.theta,
1 - Math.exp(-10 * delta)
);
current.phi = THREE.MathUtils.lerp(
current.phi,
desired.phi,
1 - Math.exp(-10 * delta)
);
current.radius = THREE.MathUtils.lerp(
current.radius,
desired.radius,
1 - Math.exp(-10 * delta)
);
spherical.set(current.radius, current.phi, current.theta);
camera.position.setFromSpherical(spherical).add(target);
camera.lookAt(target);
// Water surface shimmer
waterSurface.scale.set(
1 + Math.sin(elapsed * 1.8) * 0.006,
1 + Math.cos(elapsed * 1.55) * 0.006,
1
);
// Expanding ripples
rippleMeshes.forEach((ripple, index) => {
const phase = (elapsed * 0.38 + index / rippleMeshes.length) % 1;
const scale = 1 + phase * 3.3;
ripple.scale.setScalar(scale);
ripple.material.opacity = 0.28 * (1 - phase);
});
// Falling rain
rainDrops.forEach((drop, index) => {
drop.y -= drop.speed * delta;
const radialDistance = Math.hypot(drop.x, drop.z);
const caughtByFunnel = radialDistance < 1.08 && drop.y < 3.35;
if (drop.y < 0.08 || caughtByFunnel) {
resetDrop(drop);
}
rainDummy.position.set(drop.x, drop.y, drop.z);
rainDummy.rotation.set(0, 0, -0.12);
rainDummy.scale.set(0.018, 0.068, 0.018);
rainDummy.updateMatrix();
rain.setMatrixAt(index, rainDummy.matrix);
});
rain.instanceMatrix.needsUpdate = true;
stream.material.opacity = 0.48 + Math.sin(elapsed * 7) * 0.08;
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```