Prompt specification
Build or customize the Three.js 3D scene "Roof Catchment Gutter and Measured Tank" 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: Roof Catchment Gutter and Measured Tank
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/roof-catchment-gutter-and-measured-tank-x3953
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a stylized roof-catchment model. A small pitched roof drains into a gutter along its lower edge, then through a downpipe into a transparent cylindrical tank. The gutter, bend, pipe, and tank inlet should form one continuous route. Mark the roof's projected collection area with a thin outline and place readable capacity marks on the tank wall. Include a small overflow outlet above the maximum storage level and a simple ground pad under the assembly. Use warm roof tiles, pale walls, and contrasting blue water. Keep the composition compact enough to understand the entire collection route in one view.
Working Three.js Starter (roof-catchment-gutter-and-measured-tank-x3953):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Roof Catchment Model</title>
<style>
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #edf1ec;
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;
}
.info {
position: fixed;
top: 18px;
left: 18px;
z-index: 10;
max-width: 270px;
padding: 13px 16px;
border: 1px solid rgba(42, 75, 82, 0.14);
border-radius: 12px;
color: #24424a;
background: rgba(250, 252, 249, 0.9);
box-shadow: 0 8px 28px rgba(42, 67, 70, 0.1);
backdrop-filter: blur(8px);
pointer-events: none;
}
.info h1 {
margin: 0 0 4px;
font-size: 14px;
line-height: 1.2;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.info p {
margin: 0;
font-size: 12px;
line-height: 1.45;
color: #597078;
}
.controls {
position: fixed;
right: 16px;
bottom: 14px;
z-index: 10;
padding: 7px 10px;
border-radius: 8px;
color: #577078;
background: rgba(250, 252, 249, 0.82);
font-size: 11px;
pointer-events: none;
}
@media (max-width: 600px) {
.info {
top: 10px;
left: 10px;
max-width: 220px;
padding: 10px 12px;
}
.info h1 { font-size: 12px; }
.info p { font-size: 11px; }
.controls { right: 8px; bottom: 8px; }
}
</style>
</head>
<body>
<div class="info">
<h1>Roof Catchment</h1>
<p>Roof runoff is collected by the gutter and carried through the bent downpipe into the transparent storage tank.</p>
</div>
<div class="controls">Drag to orbit • Scroll to zoom</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// ---------------------------------------------------------------------
// Renderer, scene, and camera
// ---------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xedf1ec);
scene.fog = new THREE.Fog(0xedf1ec, 14, 29);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
60
);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
document.body.appendChild(renderer.domElement);
// Simple custom orbit controls; no addons are used.
const target = new THREE.Vector3(-0.15, 1.48, 0.25);
let theta = 0.68;
let phi = 1.18;
let radius = 10.8;
let dragging = false;
let previousX = 0;
let previousY = 0;
function updateCamera() {
const sinPhi = Math.sin(phi);
camera.position.set(
target.x + radius * sinPhi * Math.sin(theta),
target.y + radius * Math.cos(phi),
target.z + radius * sinPhi * Math.cos(theta)
);
camera.lookAt(target);
}
updateCamera();
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
theta -= deltaX * 0.006;
phi = THREE.MathUtils.clamp(phi - deltaY * 0.005, 0.38, 1.48);
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
6.6,
16.5
);
updateCamera();
}, { passive: false });
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
// ---------------------------------------------------------------------
// Lighting
// ---------------------------------------------------------------------
scene.add(new THREE.HemisphereLight(0xf6fbff, 0xb5a68c, 2.0));
const sun = new THREE.DirectionalLight(0xfff4dc, 3.1);
sun.position.set(-5, 9, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -7;
sun.shadow.camera.right = 7;
sun.shadow.camera.top = 7;
sun.shadow.camera.bottom = -7;
sun.shadow.camera.near = 0.5;
sun.shadow.camera.far = 22;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9ed7ea, 0.7);
fill.position.set(6, 4, -5);
scene.add(fill);
// ---------------------------------------------------------------------
// Materials
// ---------------------------------------------------------------------
const mat = {
ground: new THREE.MeshStandardMaterial({
color: 0xe7e4db,
roughness: 0.95
}),
pad: new THREE.MeshStandardMaterial({
color: 0xd8d1c2,
roughness: 0.9
}),
wall: new THREE.MeshStandardMaterial({
color: 0xeee8da,
roughness: 0.82
}),
wallEdge: new THREE.MeshStandardMaterial({
color: 0xdfd7c8,
roughness: 0.85
}),
roofEdge: new THREE.MeshStandardMaterial({
color: 0x93482f,
roughness: 0.8
}),
gutter: new THREE.MeshStandardMaterial({
color: 0x435f68,
roughness: 0.45,
metalness: 0.22
}),
pipe: new THREE.MeshPhysicalMaterial({
color: 0x527987,
roughness: 0.3,
metalness: 0.05,
transparent: true,
opacity: 0.72,
depthWrite: false
}),
water: new THREE.MeshPhysicalMaterial({
color: 0x168fc1,
roughness: 0.16,
metalness: 0.02,
transparent: true,
opacity: 0.72,
depthWrite: false
}),
tank: new THREE.MeshPhysicalMaterial({
color: 0xb6e0e8,
roughness: 0.12,
metalness: 0,
transparent: true,
opacity: 0.27,
side: THREE.DoubleSide,
depthWrite: false
}),
tankRim: new THREE.MeshStandardMaterial({
color: 0x6f939c,
roughness: 0.3,
metalness: 0.35
}),
dark: new THREE.MeshStandardMaterial({
color: 0x294750,
roughness: 0.45,
metalness: 0.25
}),
glass: new THREE.MeshStandardMaterial({
color: 0x79aebd,
roughness: 0.25,
metalness: 0.12
})
};
// ---------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------
function addBox(size, position, material, castShadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size.x, size.y, size.z),
material
);
mesh.position.copy(position);
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function makeRoofTexture() {
const canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 512;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "#a84d31";
ctx.fillRect(0, 0, 512, 512);
const rows = 7;
const cols = 8;
const tileH = 512 / rows;
const tileW = 512 / cols;
const colors = [
"#c96d42", "#bd6039", "#d1784c",
"#b95a35", "#cc7044", "#c3643b"
];
for (let row = 0; row < rows; row++) {
const offset = row % 2 === 0 ? 0 : tileW * 0.5;
for (let col = -1; col <= cols; col++) {
const x = col * tileW + offset + 3;
const y = row * tileH + 3;
const w = tileW - 6;
const h = tileH - 6;
const colorIndex = (row * 3 + col + 8) % colors.length;
ctx.fillStyle = colors[colorIndex];
ctx.beginPath();
ctx.roundRect(x, y, w, h, 8);
ctx.fill();
ctx.strokeStyle = "rgba(91, 40, 27, 0.45)";
ctx.lineWidth = 3;
ctx.stroke();
ctx.fillStyle = "rgba(255, 211, 157, 0.16)";
ctx.fillRect(x + 4, y + 4, w - 8, 5);
}
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(2.0, 1.35);
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function makeRoofPlane(xLeft, xRight, zRidge, yRidge, zEave, yEave, front) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
xLeft, yRidge, zRidge,
xRight, yRidge, zRidge,
xRight, yEave, zEave,
xLeft, yEave, zEave
], 3)
);
geometry.setAttribute(
"uv",
new THREE.Float32BufferAttribute([
0, 1,
1, 1,
1, 0,
0, 0
], 2)
);
if (front) {
geometry.setIndex([0, 2, 1, 0, 3, 2]);
} else {
geometry.setIndex([0, 1, 2, 0, 2, 3]);
}
geometry.computeVertexNormals();
return geometry;
}
function makeGable(x) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute([
x, 2.62, -1.30,
x, 3.38, 0.08,
x, 2.62, 1.48
], 3)
);
geometry.setIndex([0, 1, 2]);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, mat.wall);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
}
function makeLabel(text, options = {}) {
const canvas = document.createElement("canvas");
canvas.width = options.width || 512;
canvas.height = options.height || 128;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = options.background || "rgba(249, 252, 249, 0.92)";
ctx.strokeStyle = options.border || "rgba(45, 88, 96, 0.22)";
ctx.lineWidth = 4;
ctx.beginPath();
ctx.roundRect(3, 3, canvas.width - 6, canvas.height - 6, 22);
ctx.fill();
ctx.stroke();
ctx.fillStyle = options.color || "#244c57";
ctx.font = `${options.weight || 700} ${options.fontSize || 44}px ui-sans-serif, system-ui, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, canvas.width / 2, canvas.height / 2 + 2);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(
options.scaleX || 1.35,
options.scaleY || 0.34,
1
);
sprite.renderOrder = 30;
scene.add(sprite);
return sprite;
}
function addTube(path, radius, material, radialSegments = 12) {
const mesh = new THREE.Mesh(
new THREE.TubeGeometry(path, 72, radius, radialSegments, false),
material
);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// ---------------------------------------------------------------------
// Ground and simple pad
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
mat.ground
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.09;
ground.receiveShadow = true;
scene.add(ground);
addBox(
new THREE.Vector3(8.4, 0.18, 5.3),
new THREE.Vector3(-0.25, 0.01, 0.12),
mat.pad
);
// Thin projected collection-area outline on the pad.
const collectionArea = new THREE.Mesh(
new THREE.PlaneGeometry(4.42, 3.35),
new THREE.MeshBasicMaterial({
color: 0x4a9eae,
transparent: true,
opacity: 0.055,
depthWrite: false,
side: THREE.DoubleSide
})
);
collectionArea.rotation.x = -Math.PI / 2;
collectionArea.position.set(-1.16, 0.108, 0.18);
scene.add(collectionArea);
const outlinePoints = [
new THREE.Vector3(-3.38, 0.116, -1.50),
new THREE.Vector3(1.07, 0.116, -1.50),
new THREE.Vector3(1.07, 0.116, 1.88),
new THREE.Vector3(-3.38, 0.116, 1.88)
];
const outline = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(outlinePoints),
new THREE.LineDashedMaterial({
color: 0x3e91a2,
dashSize: 0.17,
gapSize: 0.10,
transparent: true,
opacity: 0.9
})
);
outline.computeLineDistances();
scene.add(outline);
const areaLabel = makeLabel("PROJECTED COLLECTION AREA", {
scaleX: 1.85,
scaleY: 0.30,
fontSize: 35
});
areaLabel.position.set(-1.18, 0.27, 2.18);
// ---------------------------------------------------------------------
// Pale house walls
// ---------------------------------------------------------------------
addBox(
new THREE.Vector3(4.0, 2.45, 2.72),
new THREE.Vector3(-1.20, 1.425, 0.08),
mat.wall
);
// Wall plinth.
addBox(
new THREE.Vector3(4.05, 0.16, 2.76),
new THREE.Vector3(-1.20, 0.28, 0.08),
mat.wallEdge
);
makeGable(-3.21);
makeGable(0.81);
// A small window provides scale without distracting from the water route.
addBox(
new THREE.Vector3(0.94, 0.78, 0.07),
new THREE.Vector3(-2.30, 1.62, 1.46),
mat.dark
);
addBox(
new THREE.Vector3(0.78, 0.61, 0.08),
new THREE.Vector3(-2.30, 1.62, 1.50),
mat.glass
);
addBox(
new THREE.Vector3(0.035, 0.62, 0.09),
new THREE.Vector3(-2.30, 1.62, 1.55),
mat.dark
);
// ---------------------------------------------------------------------
// Pitched roof with warm terracotta tiles
// ---------------------------------------------------------------------
const roofTexture = makeRoofTexture();
const roofMaterial = new THREE.MeshStandardMaterial({
map: roofTexture,
color: 0xffffff,
roughness: 0.78,
side: THREE.DoubleSide
});
const backRoofMaterial = roofMaterial.clone();
backRoofMaterial.color.setHex(0xe8d7c5);
const frontRoof = new THREE.Mesh(
makeRoofPlane(-3.36, 0.98, 0.08, 3.42, 1.60, 2.69, true),
roofMaterial
);
frontRoof.castShadow = true;
frontRoof.receiveShadow = true;
scene.add(frontRoof);
const backRoof = new THREE.Mesh(
makeRoofPlane(-3.36, 0.98, 0.08, 3.42, -1.38, 2.69, false),
backRoofMaterial
);
backRoof.castShadow = true;
backRoof.receiveShadow = true;
scene.add(backRoof);
// Rounded ridge cap.
const ridge = new THREE.Mesh(
new THREE.CylinderGeometry(0.105, 0.105, 4.55, 18),
mat.roofEdge
);
ridge.rotation.z = Math.PI / 2;
ridge.position.set(-1.19, 3.44, 0.08);
ridge.castShadow = true;
scene.add(ridge);
// Eave trim.
addBox(
new THREE.Vector3(4.55, 0.15, 0.11),
new THREE.Vector3(-1.19, 2.64, 1.61),
mat.roofEdge
);
// ---------------------------------------------------------------------
// Open gutter and visible blue runoff
// ---------------------------------------------------------------------
const gutterCenterX = -1.17;
const gutterZ = 1.70;
addBox(
new THREE.Vector3(4.48, 0.055, 0.26),
new THREE.Vector3(gutterCenterX, 2.585, gutterZ),
mat.gutter
);
addBox(
new THREE.Vector3(4.48, 0.17, 0.045),
new THREE.Vector3(gutterCenterX, 2.65, gutterZ - 0.13),
mat.gutter
);
// Lower front lip keeps the water visible from the camera.
addBox(
new THREE.Vector3(4.48, 0.095, 0.045),
new THREE.Vector3(gutterCenterX, 2.625, gutterZ + 0.13),
mat.gutter
);
addBox(
new THREE.Vector3(4.38, 0.018, 0.135),
new THREE.Vector3(gutterCenterX, 2.622, gutterZ),
mat.water,
false
);
// Gutter supports.
for (const x of [-2.75, -1.30, 0.25]) {
addBox(
new THREE.Vector3(0.09, 0.19, 0.34),
new THREE.Vector3(x, 2.50, 1.55),
mat.dark
);
}
// ---------------------------------------------------------------------
// Continuous gutter outlet, downpipe, bends, and tank inlet
// ---------------------------------------------------------------------
const route = new THREE.CurvePath();
const p0 = new THREE.Vector3(1.02, 2.61, gutterZ);
const p1 = new THREE.Vector3(1.02, 2.43, gutterZ);
const p2 = new THREE.Vector3(1.18, 2.27, gutterZ);
const p3 = new THREE.Vector3(1.99, 2.27, gutterZ);
const p4 = new THREE.Vector3(2.15, 2.11, gutterZ);
const p5 = new THREE.Vector3(2.15, 1.98, gutterZ);
route.add(new THREE.LineCurve3(p0, p1));
route.add(new THREE.QuadraticBezierCurve3(
p1,
new THREE.Vector3(1.02, 2.27, gutterZ),
p2
));
route.add(new THREE.LineCurve3(p2, p3));
route.add(new THREE.QuadraticBezierCurve3(
p3,
new THREE.Vector3(2.15, 2.27, gutterZ),
p4
));
route.add(new THREE.LineCurve3(p4, p5));
const outerPipe = addTube(route, 0.087, mat.pipe, 14);
outerPipe.renderOrder = 3;
const flowCore = addTube(
route,
0.035,
new THREE.MeshBasicMaterial({
color: 0x139ac9,
transparent: true,
opacity: 0.9,
depthWrite: false
}),
10
);
flowCore.renderOrder = 2;
// A compact wall bracket secures the short downpipe.
addBox(
new THREE.Vector3(0.20, 0.07, 0.36),
new THREE.Vector3(0.88, 2.45, 1.60),
mat.dark
);
// ---------------------------------------------------------------------
// Transparent cylindrical storage tank
// ---------------------------------------------------------------------
const tankX = 2.15;
const tankZ = 1.70;
const tankBottom = 0.22;
const tankTop = 2.02;
const tankHeight = tankTop - tankBottom;
const tankRadius = 0.85;
const tankWall = new THREE.Mesh(
new THREE.CylinderGeometry(
tankRadius,
tankRadius,
tankHeight,
64,
1,
true
),
mat.tank
);
tankWall.position.set(tankX, (tankTop + tankBottom) / 2, tankZ);
tankWall.renderOrder = 4;
scene.add(tankWall);
const tankBottomMesh = new THREE.Mesh(
new THREE.CylinderGeometry(tankRadius, tankRadius, 0.035, 64),
new THREE.MeshPhysicalMaterial({
color: 0x92c7d2,
roughness: 0.25,
transparent: true,
opacity: 0.45,
depthWrite: false
})
);
tankBottomMesh.position.set(tankX, tankBottom, tankZ);
tankBottomMesh.renderOrder = 3;
scene.add(tankBottomMesh);
for (const y of [tankBottom, tankTop]) {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(tankRadius, 0.027, 12, 64),
mat.tankRim
);
ring.rotation.x = Math.PI / 2;
ring.position.set(tankX, y, tankZ);
ring.castShadow = true;
scene.add(ring);
}
// Subtle vertical seams clarify the cylindrical transparent wall.
for (const angle of [-0.72, 0.72]) {
const x = tankX + Math.sin(angle) * tankRadius;
const z = tankZ + Math.cos(angle) * tankRadius;
const seam = new THREE.Mesh(
new THREE.BoxGeometry(0.018, tankHeight, 0.018),
new THREE.MeshBasicMaterial({
color: 0x78aab5,
transparent: true,
opacity: 0.35
})
);
seam.position.set(x, (tankTop + tankBottom) / 2, z);
scene.add(seam);
}
// Blue stored water.
const currentWaterTop = 1.18;
const waterHeight = currentWaterTop - (tankBottom + 0.035);
const water = new THREE.Mesh(
new THREE.CylinderGeometry(0.775, 0.775, waterHeight, 64),
mat.water
);
water.position.set(
tankX,
tankBottom + 0.035 + waterHeight / 2,
tankZ
);
water.renderOrder = 2;
scene.add(water);
// A brighter surface disc makes the water level easy to read.
const waterSurface = new THREE.Mesh(
new THREE.CircleGeometry(0.773, 64),
new THREE.MeshPhysicalMaterial({
color: 0x38b4df,
roughness: 0.13,
transparent: true,
opacity: 0.76,
side: THREE.DoubleSide,
depthWrite: false
})
);
waterSurface.rotation.x = -Math.PI / 2;
waterSurface.position.set(tankX, currentWaterTop + 0.003, tankZ);
waterSurface.renderOrder = 3;
scene.add(waterSurface);
// Inlet collar where the downpipe enters the open tank.
const inletCollar = new THREE.Mesh(
new THREE.TorusGeometry(0.105, 0.025, 10, 32),
mat.tankRim
);
inletCollar.rotation.x = Math.PI / 2;
inletCollar.position.set(tankX, tankTop, tankZ);
scene.add(inletCollar);
// ---------------------------------------------------------------------
// Capacity marks on the tank wall
// ---------------------------------------------------------------------
const capacityLevels = [
{ liters: 0, y: 0.24 },
{ liters: 25, y: 0.585 },
{ liters: 50, y: 0.93 },
{ liters: 75, y: 1.275 },
{ liters: 100, y: 1.62 }
];
for (const level of capacityLevels) {
const tick = new THREE.Mesh(
new THREE.BoxGeometry(0.30, 0.018, 0.025),
mat.dark
);
tick.position.set(tankX + 0.18, level.y, tankZ + 0.855);
scene.add(tick);
const isMaximum = level.liters === 100;
const label = makeLabel(
isMaximum ? "100 L MAX" : `${level.liters} L`,
{
scaleX: isMaximum ? 0.80 : 0.60,
scaleY: isMaximum ? 0.235 : 0.215,
fontSize: isMaximum ? 38 : 43,
color: isMaximum ? "#17647b" : "#294e58",
border: isMaximum
? "rgba(22, 100, 123, 0.42)"
: "rgba(45, 88, 96, 0.22)"
}
);
label.position.set(tankX - 0.39, level.y, tankZ + 0.89);
}
// ---------------------------------------------------------------------
// Small overflow outlet above maximum storage level
// ---------------------------------------------------------------------
const overflowY = 1.78; // Above the 100 L maximum mark at 1.62.
const overflowFlange = new THREE.Mesh(
new THREE.CylinderGeometry(0.135, 0.135, 0.10, 24),
mat.dark
);
overflowFlange.rotation.z = Math.PI / 2;
overflowFlange.position.set(tankX + tankRadius - 0.015, overflowY, tankZ);
overflowFlange.castShadow = true;
scene.add(overflowFlange);
const overflowPath = new THREE.CurvePath();
overflowPath.add(new THREE.LineCurve3(
new THREE.Vector3(tankX + 0.80, overflowY, tankZ),
new THREE.Vector3(3.22, overflowY, tankZ)
));
overflowPath.add(new THREE.QuadraticBezierCurve3(
new THREE.Vector3(3.22, overflowY, tankZ),
new THREE.Vector3(3.40, overflowY, tankZ),
new THREE.Vector3(3.40, overflowY - 0.16, tankZ)
));
overflowPath.add(new THREE.LineCurve3(
new THREE.Vector3(3.40, overflowY - 0.16, tankZ),
new THREE.Vector3(3.40, 1.50, tankZ)
));
const overflowPipe = addTube(
overflowPath,
0.068,
new THREE.MeshStandardMaterial({
color: 0x557681,
roughness: 0.38,
metalness: 0.2
}),
12
);
overflowPipe.renderOrder = 1;
const overflowLabel = makeLabel("OVERFLOW", {
scaleX: 0.78,
scaleY: 0.23,
fontSize: 39,
color: "#315b67"
});
overflowLabel.position.set(3.28, 2.02, tankZ + 0.05);
// Small drain grate below the overflow outlet.
addBox(
new THREE.Vector3(0.48, 0.025, 0.48),
new THREE.Vector3(3.40, 0.125, tankZ),
mat.dark
);
for (let i = 0; i < 5; i++) {
addBox(
new THREE.Vector3(0.035, 0.035, 0.40),
new THREE.Vector3(3.21 + i * 0.095, 0.145, tankZ),
mat.tankRim,
false
);
}
// ---------------------------------------------------------------------
// Animation: a restrained water shimmer, keeping the scene calm.
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
waterSurface.position.y = currentWaterTop + 0.003 +
Math.sin(elapsed * 1.15) * 0.0025;
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```