Prompt specification
Build or customize the Three.js 3D scene "Settling sediment at a river mouth" 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: Settling sediment at a river mouth
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/settling-sediment-at-a-river-mouth-x1130
Scene Description Prompt:
Settling sediment at a river mouth. Use a clear tank with a channel entering wider water; depict colored suspended particles settling schematically near the mouth, explicitly labeling the animation qualitative. Please build this with Three.js from cdnjs in one self-contained HTML file, using stylized solid shapes.
Working Three.js Starter (settling-sediment-at-a-river-mouth-x1130):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>River Mouth Sediment Settling</title>
<style>
:root {
color-scheme: light;
--ink: #173846;
--muted: #55727f;
--accent: #d96137;
--teal: #16869a;
}
* { box-sizing: border-box; }
html, body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background:
radial-gradient(circle at 68% 20%, #ffffff 0, #edf5f7 48%, #dfecef 100%);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
color: var(--ink);
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.title-card {
position: absolute;
top: 22px;
left: 24px;
max-width: 440px;
padding: 15px 18px 14px;
border: 1px solid rgba(23, 56, 70, 0.13);
border-radius: 16px;
background: rgba(255, 255, 255, 0.82);
box-shadow: 0 12px 34px rgba(39, 79, 94, 0.10);
backdrop-filter: blur(12px);
}
.eyebrow {
margin-bottom: 4px;
color: var(--teal);
font-size: 11px;
font-weight: 800;
letter-spacing: 0.13em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(21px, 2.5vw, 31px);
line-height: 1.08;
letter-spacing: -0.035em;
}
.subtitle {
margin-top: 8px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.qualitative {
position: absolute;
top: 24px;
right: 24px;
padding: 10px 13px;
border: 1px solid rgba(217, 97, 55, 0.36);
border-radius: 999px;
background: rgba(255, 247, 240, 0.92);
color: #a84121;
box-shadow: 0 8px 24px rgba(100, 57, 36, 0.08);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.075em;
text-transform: uppercase;
}
.legend {
position: absolute;
left: 24px;
bottom: 22px;
display: flex;
flex-wrap: wrap;
gap: 9px 17px;
max-width: min(620px, calc(100vw - 48px));
padding: 12px 15px;
border: 1px solid rgba(23, 56, 70, 0.12);
border-radius: 14px;
background: rgba(255, 255, 255, 0.84);
box-shadow: 0 10px 28px rgba(39, 79, 94, 0.09);
backdrop-filter: blur(10px);
color: var(--muted);
font-size: 12px;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 7px;
white-space: nowrap;
}
.swatch {
width: 11px;
height: 11px;
border-radius: 3px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.swatch.sand { background: #c99561; }
.swatch.rust { background: #d85f3c; }
.swatch.amber { background: #e9a447; }
.swatch.water { background: #56bdd2; }
.note {
position: absolute;
right: 24px;
bottom: 24px;
max-width: 260px;
color: #587581;
font-size: 11px;
line-height: 1.4;
text-align: right;
}
@media (max-width: 700px) {
.title-card {
top: 12px;
left: 12px;
right: 12px;
max-width: none;
padding: 11px 13px;
}
.subtitle { display: none; }
.qualitative {
top: 93px;
right: 12px;
font-size: 9px;
}
.legend {
left: 12px;
bottom: 12px;
right: 12px;
max-width: none;
}
.note { display: none; }
}
</style>
</head>
<body>
<main id="scene" aria-label="Qualitative Three.js animation of sediment settling at a river mouth"></main>
<div class="hud">
<section class="title-card">
<div class="eyebrow">River mouth process</div>
<h1>Sediment settling as flow enters wider water</h1>
<div class="subtitle">
Suspended particles advect through the channel, spread near the mouth,
and settle onto the bed.
</div>
</section>
<div class="qualitative">Qualitative animation — not to scale</div>
<div class="legend" aria-label="Color legend">
<span class="legend-item"><i class="swatch water"></i> Flowing water</span>
<span class="legend-item"><i class="swatch rust"></i> Suspended sediment</span>
<span class="legend-item"><i class="swatch amber"></i> Settling particles</span>
<span class="legend-item"><i class="swatch sand"></i> Deposited bed</span>
</div>
<div class="note">
Particle size, speed, concentration, and fall rate are illustrative.
No physical units are represented.
</div>
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const container = document.getElementById("scene");
// ---------------------------------------------------------------------
// Renderer, scene, camera, and lighting
// ---------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.setClearColor(0xf1f6f8, 1);
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.Fog(0xf1f6f8, 30, 56);
const camera = new THREE.PerspectiveCamera(
38,
window.innerWidth / window.innerHeight,
0.1,
100
);
camera.position.set(16.5, 13.8, 20.5);
camera.lookAt(-0.7, 1.1, 0);
const hemisphere = new THREE.HemisphereLight(0xffffff, 0x8fa7ae, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.0);
keyLight.position.set(-7, 15, 10);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -18;
keyLight.shadow.camera.right = 18;
keyLight.shadow.camera.top = 16;
keyLight.shadow.camera.bottom = -16;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 42;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0xbdeeff, 1.25);
fillLight.position.set(10, 7, -12);
scene.add(fillLight);
const warmLight = new THREE.DirectionalLight(0xffd7a9, 0.7);
warmLight.position.set(4, 5, 12);
scene.add(warmLight);
// ---------------------------------------------------------------------
// Materials and reusable geometry
// ---------------------------------------------------------------------
const bedMaterial = new THREE.MeshStandardMaterial({
color: 0xc7a982,
roughness: 0.93,
metalness: 0.0
});
const sedimentMoundMaterial = new THREE.MeshStandardMaterial({
color: 0xb98258,
roughness: 0.98,
flatShading: true
});
const glassMaterial = new THREE.MeshStandardMaterial({
color: 0xbceaf2,
transparent: true,
opacity: 0.12,
roughness: 0.12,
metalness: 0.0,
depthWrite: false,
side: THREE.DoubleSide
});
const glassEdgeMaterial = new THREE.LineBasicMaterial({
color: 0x5b91a2,
transparent: true,
opacity: 0.48
});
const waterSurfaceMaterial = new THREE.MeshStandardMaterial({
color: 0x60c4d9,
transparent: true,
opacity: 0.25,
roughness: 0.24,
metalness: 0.03,
depthWrite: false,
side: THREE.DoubleSide
});
const waterVolumeMaterial = new THREE.MeshStandardMaterial({
color: 0x70cfe2,
transparent: true,
opacity: 0.045,
roughness: 0.2,
depthWrite: false
});
const tealArrowMaterial = new THREE.MeshStandardMaterial({
color: 0x148da1,
roughness: 0.45,
emissive: 0x0b5360,
emissiveIntensity: 0.18
});
const orangeArrowMaterial = new THREE.MeshStandardMaterial({
color: 0xe46b3f,
roughness: 0.5,
transparent: true,
opacity: 0.82
});
function addBox(parent, size, position, material, castShadow = false) {
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;
parent.add(mesh);
return mesh;
}
function addGlassPanel(size, position) {
const geometry = new THREE.BoxGeometry(size.x, size.y, size.z);
const panel = new THREE.Mesh(geometry, glassMaterial);
panel.position.copy(position);
panel.renderOrder = 4;
scene.add(panel);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry),
glassEdgeMaterial
);
edges.position.copy(position);
edges.renderOrder = 5;
scene.add(edges);
}
// ---------------------------------------------------------------------
// Ground, bed, and clear tank geometry
// Channel enters from x = -11 to -4; basin spans x = -4 to 10.
// ---------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(70, 70),
new THREE.MeshStandardMaterial({
color: 0xeaf1f2,
roughness: 1
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.58;
ground.receiveShadow = true;
scene.add(ground);
addBox(
scene,
new THREE.Vector3(7, 0.34, 4.8),
new THREE.Vector3(-7.5, -0.17, 0),
bedMaterial,
true
);
addBox(
scene,
new THREE.Vector3(14, 0.34, 12),
new THREE.Vector3(3, -0.17, 0),
bedMaterial,
true
);
// Low-poly sediment deposit spreading from the mouth.
const depositMound = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 16),
sedimentMoundMaterial
);
depositMound.position.set(-0.25, -0.035, 0.15);
depositMound.scale.set(3.8, 0.21, 3.55);
depositMound.rotation.y = -0.18;
depositMound.receiveShadow = true;
depositMound.castShadow = true;
scene.add(depositMound);
// Clear tank walls.
addGlassPanel(
new THREE.Vector3(7, 3.2, 0.08),
new THREE.Vector3(-7.5, 1.6, 2.45)
);
addGlassPanel(
new THREE.Vector3(7, 3.2, 0.08),
new THREE.Vector3(-7.5, 1.6, -2.45)
);
addGlassPanel(
new THREE.Vector3(0.08, 3.2, 4.9),
new THREE.Vector3(-11, 1.6, 0)
);
addGlassPanel(
new THREE.Vector3(14, 3.2, 0.08),
new THREE.Vector3(3, 1.6, 6)
);
addGlassPanel(
new THREE.Vector3(14, 3.2, 0.08),
new THREE.Vector3(3, 1.6, -6)
);
addGlassPanel(
new THREE.Vector3(0.08, 3.2, 12),
new THREE.Vector3(10, 1.6, 0)
);
addGlassPanel(
new THREE.Vector3(0.08, 3.2, 3.45),
new THREE.Vector3(-4, 1.6, 4.2)
);
addGlassPanel(
new THREE.Vector3(0.08, 3.2, 3.45),
new THREE.Vector3(-4, 1.6, -4.2)
);
// Subtle transparent water volumes.
const channelWater = addBox(
scene,
new THREE.Vector3(7, 3.1, 4.8),
new THREE.Vector3(-7.5, 1.5, 0),
waterVolumeMaterial
);
channelWater.renderOrder = 2;
const basinWater = addBox(
scene,
new THREE.Vector3(14, 3.1, 12),
new THREE.Vector3(3, 1.5, 0),
waterVolumeMaterial
);
basinWater.renderOrder = 2;
// Water surfaces.
const channelSurface = new THREE.Mesh(
new THREE.PlaneGeometry(7, 4.8),
waterSurfaceMaterial
);
channelSurface.rotation.x = -Math.PI / 2;
channelSurface.position.set(-7.5, 3.12, 0);
channelSurface.renderOrder = 3;
scene.add(channelSurface);
const basinSurface = new THREE.Mesh(
new THREE.PlaneGeometry(14, 12),
waterSurfaceMaterial
);
basinSurface.rotation.x = -Math.PI / 2;
basinSurface.position.set(3, 3.12, 0);
basinSurface.renderOrder = 3;
scene.add(basinSurface);
// ---------------------------------------------------------------------
// Stylized directional arrows
// ---------------------------------------------------------------------
const flowArrows = [];
function createFlowArrow(x, z, scale = 1) {
const group = new THREE.Group();
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.075, 0.075, 1.05, 8),
tealArrowMaterial
);
shaft.rotation.z = -Math.PI / 2;
shaft.position.x = -0.25;
group.add(shaft);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.22, 0.48, 10),
tealArrowMaterial
);
head.rotation.z = -Math.PI / 2;
head.position.x = 0.49;
group.add(head);
group.position.set(x, 1.55, z);
group.scale.setScalar(scale);
scene.add(group);
flowArrows.push({
group,
baseX: x,
phase: Math.random() * Math.PI * 2
});
}
createFlowArrow(-9.5, -1.15, 0.78);
createFlowArrow(-7.3, 0.35, 0.86);
createFlowArrow(-5.15, 1.15, 0.78);
const settleArrows = [];
function createSettleArrow(x, y, z, phase) {
const group = new THREE.Group();
const shaft = new THREE.Mesh(
new THREE.CylinderGeometry(0.045, 0.045, 0.62, 8),
orangeArrowMaterial
);
shaft.position.y = 0.18;
group.add(shaft);
const head = new THREE.Mesh(
new THREE.ConeGeometry(0.16, 0.34, 9),
orangeArrowMaterial
);
head.rotation.z = Math.PI;
head.position.y = -0.27;
group.add(head);
group.position.set(x, y, z);
scene.add(group);
settleArrows.push({ group, baseY: y, phase });
}
createSettleArrow(-1.8, 2.55, -2.45, 0.0);
createSettleArrow(0.35, 2.75, 0.15, 0.7);
createSettleArrow(2.05, 2.45, 2.55, 1.4);
// ---------------------------------------------------------------------
// Canvas-based labels drawn as Three.js sprites
// ---------------------------------------------------------------------
function roundedRect(ctx, x, y, width, height, radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
}
function createLabel(text, position, width = 4.0, color = "#173846") {
const canvas = document.createElement("canvas");
canvas.width = 640;
canvas.height = 144;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.shadowColor = "rgba(29, 61, 72, 0.18)";
ctx.shadowBlur = 14;
ctx.shadowOffsetY = 5;
roundedRect(ctx, 8, 8, 624, 124, 26);
ctx.fillStyle = "rgba(255,255,255,0.92)";
ctx.fill();
ctx.shadowColor = "transparent";
ctx.lineWidth = 4;
ctx.strokeStyle = "rgba(23,56,70,0.18)";
ctx.stroke();
const fontSize = text.length > 20 ? 30 : 35;
ctx.font = `800 ${fontSize}px Arial, sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = color;
ctx.fillText(text, 320, 69);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.generateMipmaps = false;
const material = new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
});
const sprite = new THREE.Sprite(material);
sprite.position.copy(position);
sprite.scale.set(width, width * 0.225, 1);
sprite.renderOrder = 20;
scene.add(sprite);
return sprite;
}
createLabel(
"NARROW CHANNEL",
new THREE.Vector3(-8.0, 4.15, 0.0),
4.4,
"#116d7d"
);
createLabel(
"FLOW →",
new THREE.Vector3(-7.6, 3.35, 1.8),
2.25,
"#116d7d"
);
createLabel(
"WIDER WATER",
new THREE.Vector3(4.7, 4.15, 0.0),
3.55,
"#116d7d"
);
createLabel(
"RIVER MOUTH",
new THREE.Vector3(-3.4, 4.35, -2.8),
3.35,
"#9b4c2d"
);
createLabel(
"SUSPENDED SEDIMENT",
new THREE.Vector3(-1.1, 4.65, 2.8),
4.8,
"#b64c2d"
);
createLabel(
"SETTLING",
new THREE.Vector3(0.7, 3.45, -3.5),
2.75,
"#b64c2d"
);
createLabel(
"DEPOSITED BED",
new THREE.Vector3(2.2, 0.55, 4.7),
3.6,
"#76523b"
);
// ---------------------------------------------------------------------
// Suspended particles: instanced low-poly solids
// ---------------------------------------------------------------------
const particleCount = 240;
const particleGeometry = new THREE.IcosahedronGeometry(1, 0);
const particleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.58,
metalness: 0.02,
flatShading: true
});
const suspendedParticles = new THREE.InstancedMesh(
particleGeometry,
particleMaterial,
particleCount
);
suspendedParticles.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
suspendedParticles.frustumCulled = false;
scene.add(suspendedParticles);
const sedimentPalette = [
new THREE.Color(0xd85d39),
new THREE.Color(0xe49a3d),
new THREE.Color(0xc94b3f),
new THREE.Color(0xb97835),
new THREE.Color(0xe5b15b)
];
const seeds = [];
for (let i = 0; i < particleCount; i++) {
seeds.push({
offset: Math.random(),
rate: 0.052 + Math.random() * 0.034,
z0: (Math.random() - 0.5) * 3.2,
y0: 0.5 + Math.random() * 2.25,
lateral: (Math.random() - 0.5) * 7.7,
phase: Math.random() * Math.PI * 2,
scale: 0.052 + Math.random() * 0.075
});
suspendedParticles.setColorAt(
i,
sedimentPalette[Math.floor(Math.random() * sedimentPalette.length)]
);
}
if (suspendedParticles.instanceColor) {
suspendedParticles.instanceColor.needsUpdate = true;
}
// ---------------------------------------------------------------------
// Static deposited particles on the bed
// ---------------------------------------------------------------------
const depositCount = 170;
const depositedParticles = new THREE.InstancedMesh(
particleGeometry,
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.9,
flatShading: true
}),
depositCount
);
depositedParticles.frustumCulled = false;
scene.add(depositedParticles);
const dummy = new THREE.Object3D();
const depositPalette = [
new THREE.Color(0xa96843),
new THREE.Color(0xb87b50),
new THREE.Color(0x8f5c3d),
new THREE.Color(0xc18b5b),
new THREE.Color(0x9d6847)
];
for (let i = 0; i < depositCount; i++) {
const angle = Math.random() * Math.PI * 2;
const radius = Math.sqrt(Math.random());
const x = -0.25 + Math.cos(angle) * radius * 3.35;
const z = 0.15 + Math.sin(angle) * radius * 3.05;
const size = 0.045 + Math.random() * 0.065;
dummy.position.set(x, 0.205 + Math.random() * 0.035, z);
dummy.rotation.set(
Math.random() * Math.PI,
Math.random() * Math.PI,
Math.random() * Math.PI
);
dummy.scale.set(size, size * 0.72, size);
dummy.updateMatrix();
depositedParticles.setMatrixAt(i, dummy.matrix);
depositedParticles.setColorAt(
i,
depositPalette[Math.floor(Math.random() * depositPalette.length)]
);
}
depositedParticles.instanceMatrix.needsUpdate = true;
if (depositedParticles.instanceColor) {
depositedParticles.instanceColor.needsUpdate = true;
}
// ---------------------------------------------------------------------
// Animation helpers
// ---------------------------------------------------------------------
function smoothstep(min, max, value) {
const t = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return t * t * (3 - 2 * t);
}
function updateParticles(time) {
for (let i = 0; i < particleCount; i++) {
const seed = seeds[i];
const p = (time * seed.rate + seed.offset) % 1;
// Advection through the channel, followed by slower spreading.
let x;
if (p < 0.38) {
x = -10.25 + (6.25 * p) / 0.38;
} else {
const spread = smoothstep(0.38, 0.88, p);
x = -4.0 + 5.25 * spread;
}
const settle = smoothstep(0.38, 0.94, p);
const lateral = seed.lateral * settle;
const swirl = Math.sin(p * 15 + seed.phase) * 0.24 * settle;
const z = THREE.MathUtils.clamp(seed.z0 + lateral + swirl, -5.3, 5.3);
const bob = Math.sin(time * 2.2 + seed.phase) * 0.055 * (1 - settle);
const y = seed.y0 - (seed.y0 - 0.205) * settle + bob;
const fade = 1 - smoothstep(0.95, 1, p);
const scale = seed.scale * fade;
dummy.position.set(x, Math.max(0.205, y), z);
dummy.rotation.set(
seed.phase + p * 5,
seed.phase * 0.7 + p * 7,
seed.phase * 1.3
);
dummy.scale.setScalar(scale);
dummy.updateMatrix();
suspendedParticles.setMatrixAt(i, dummy.matrix);
}
suspendedParticles.instanceMatrix.needsUpdate = true;
}
function animateArrows(time) {
for (const arrow of flowArrows) {
arrow.group.position.x =
arrow.baseX + Math.sin(time * 1.35 + arrow.phase) * 0.18;
}
for (const arrow of settleArrows) {
const cycle = (time * 0.42 + arrow.phase) % 1;
arrow.group.position.y = arrow.baseY - cycle * 0.42;
}
}
// ---------------------------------------------------------------------
// Render loop and responsive resize
// ---------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const time = clock.getElapsedTime();
updateParticles(time);
animateArrows(time);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
animate();
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
```