Prompt specification
Build or customize the Three.js 3D scene "Freshwater beach pebble and dune-grass tile" 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: Freshwater beach pebble and dune-grass tile
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/freshwater-beach-pebble-and-dune-grass-tile-x3077
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing a referenced Great Lakes shoreline fragment with pebbles, sand, and dune grass. Make the lake setting explicit without relying on ocean-specific shells or tides. Stylized solid forms.
Working Three.js Starter (freshwater-beach-pebble-and-dune-grass-tile-x3077):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Great Lakes Shoreline Fragment</title>
<style>
:root {
--ink: #173d3a;
--paper: #f4f0e3;
--sand: #d9c293;
--lake: #4e969a;
--grass: #647348;
--pebble: #8b8175;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce8e3;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
}
canvas.dragging {
cursor: grabbing;
}
.wash {
position: fixed;
inset: 0;
pointer-events: none;
background:
linear-gradient(90deg, rgba(238, 244, 237, 0.8) 0%,
rgba(238, 244, 237, 0.18) 34%,
transparent 55%),
linear-gradient(0deg, rgba(213, 226, 217, 0.22), transparent 30%);
}
.intro {
position: fixed;
top: clamp(24px, 5vw, 64px);
left: clamp(22px, 5vw, 68px);
width: min(390px, calc(100vw - 44px));
pointer-events: none;
z-index: 2;
}
.kicker {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 14px;
color: #315f59;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.kicker::before {
content: "";
width: 29px;
height: 2px;
background: #cf7f4b;
}
h1 {
margin: 0;
color: #183c38;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(38px, 5.2vw, 72px);
font-weight: 400;
line-height: 0.91;
letter-spacing: -0.045em;
text-wrap: balance;
text-shadow: 0 2px 18px rgba(244, 240, 227, 0.55);
}
h1 em {
color: #396c65;
font-weight: 400;
}
.description {
max-width: 330px;
margin: 20px 0 0;
color: #42655f;
font-size: 13px;
line-height: 1.6;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 8px 17px;
margin-top: 22px;
color: #46645e;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.legend span {
display: inline-flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 50%;
box-shadow: inset 0 0 0 1px rgba(20, 55, 50, 0.13);
}
.lake-tag {
position: fixed;
top: clamp(22px, 4vw, 50px);
right: clamp(22px, 4vw, 52px);
z-index: 3;
display: flex;
align-items: center;
gap: 12px;
padding: 11px 15px 10px;
border: 1px solid rgba(29, 77, 72, 0.16);
border-radius: 999px;
background: rgba(245, 242, 231, 0.76);
box-shadow: 0 10px 28px rgba(33, 67, 62, 0.08);
backdrop-filter: blur(10px);
pointer-events: none;
}
.lake-mark {
position: relative;
width: 31px;
height: 21px;
overflow: hidden;
}
.lake-mark::before,
.lake-mark::after {
content: "";
position: absolute;
left: 0;
width: 31px;
height: 9px;
border-top: 2px solid #3f8788;
border-radius: 50%;
}
.lake-mark::before {
top: 5px;
}
.lake-mark::after {
top: 11px;
}
.lake-tag strong,
.lake-tag small {
display: block;
}
.lake-tag strong {
font-size: 10px;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.lake-tag small {
margin-top: 2px;
color: #668079;
font-size: 9px;
letter-spacing: 0.08em;
}
.controls {
position: fixed;
right: clamp(20px, 4vw, 52px);
bottom: clamp(20px, 4vw, 44px);
z-index: 4;
display: flex;
align-items: center;
gap: 10px;
}
.hint {
color: #55716b;
font-size: 10px;
letter-spacing: 0.07em;
}
button {
appearance: none;
border: 1px solid rgba(27, 72, 67, 0.2);
border-radius: 999px;
padding: 10px 15px;
background: rgba(247, 243, 231, 0.84);
color: #244c47;
font: inherit;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
transition:
background 160ms ease,
transform 160ms ease;
}
button:hover {
background: #fbf7ec;
transform: translateY(-1px);
}
button:focus-visible {
outline: 2px solid #c9794a;
outline-offset: 3px;
}
.loading {
position: fixed;
inset: 0;
z-index: 10;
display: grid;
place-items: center;
background: #dce8e3;
color: #315e58;
font-size: 11px;
font-weight: 750;
letter-spacing: 0.18em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 720px) {
.intro {
top: 22px;
}
h1 {
font-size: clamp(36px, 11vw, 54px);
}
.description {
max-width: 280px;
font-size: 12px;
}
.legend {
display: none;
}
.lake-tag {
top: auto;
right: 18px;
bottom: 72px;
}
.hint {
display: none;
}
.controls {
right: 18px;
bottom: 18px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="wash"></div>
<header class="intro">
<div class="kicker">Great Lakes · Field Study 04</div>
<h1>Lake Michigan<br><em>shoreline fragment</em></h1>
<p class="description">
A fresh, inland-water edge shaped from pale sand, glacial pebbles,
and wind-cut dune grass.
</p>
<div class="legend" aria-label="Shore materials">
<span><i class="swatch" style="background:#d9c293"></i>Sand</span>
<span><i class="swatch" style="background:#8b8175"></i>Pebbles</span>
<span><i class="swatch" style="background:#647348"></i>Dune grass</span>
</div>
</header>
<aside class="lake-tag" aria-label="Lake Michigan, Great Lakes freshwater">
<div class="lake-mark"></div>
<div>
<strong>Lake Michigan</strong>
<small>Great Lakes · Freshwater</small>
</div>
</aside>
<div class="controls">
<span class="hint">Drag to orbit · Scroll to zoom</span>
<button id="reset" type="button">Reset view</button>
</div>
<div class="loading" id="loading">Preparing shoreline</div>
<noscript>This scene requires JavaScript and WebGL.</noscript>
<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.querySelector("#scene");
const loading = document.querySelector("#loading");
const resetButton = document.querySelector("#reset");
const scene = new THREE.Scene();
scene.background = new THREE.Color("#dce8e3");
scene.fog = new THREE.Fog("#dce8e3", 22, 43);
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.domElement.setAttribute(
"aria-label",
"Interactive stylized Lake Michigan shoreline with sand, pebbles, and dune grass"
);
container.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-10, 10, 7, -7, 0.1, 100);
// Camera controls are intentionally implemented here rather than
// importing an examples/jsm controls module.
const controls = {
target: new THREE.Vector3(0.9, 0.35, 0),
radius: 15.8,
theta: 0.67,
phi: 1.02,
dragging: false,
lastX: 0,
lastY: 0
};
const defaultControls = { ...controls };
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x +
controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y +
controls.radius * Math.cos(controls.phi),
controls.target.z +
controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
function resetCamera() {
controls.target.copy(defaultControls.target);
controls.radius = defaultControls.radius;
controls.theta = defaultControls.theta;
controls.phi = defaultControls.phi;
updateCamera();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
const viewHeight = aspect < 1.2 ? 17 / aspect : 12.8;
camera.left = (-viewHeight * aspect) / 2;
camera.right = (viewHeight * aspect) / 2;
camera.top = viewHeight / 2;
camera.bottom = -viewHeight / 2;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
resize();
updateCamera();
renderer.domElement.addEventListener("pointerdown", (event) => {
controls.dragging = true;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi + dy * 0.005,
0.38,
1.39
);
controls.lastX = event.clientX;
controls.lastY = event.clientY;
updateCamera();
});
function stopDragging(event) {
controls.dragging = false;
renderer.domElement.classList.remove("dragging");
if (event?.pointerId !== undefined) {
try {
renderer.domElement.releasePointerCapture(event.pointerId);
} catch (_) {
// Pointer capture may already have been released.
}
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
9,
25
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("dblclick", resetCamera);
resetButton.addEventListener("click", resetCamera);
window.addEventListener("keydown", (event) => {
let handled = true;
switch (event.key.toLowerCase()) {
case "arrowleft":
controls.theta += 0.08;
break;
case "arrowright":
controls.theta -= 0.08;
break;
case "arrowup":
controls.phi = Math.max(0.38, controls.phi - 0.06);
break;
case "arrowdown":
controls.phi = Math.min(1.39, controls.phi + 0.06);
break;
case "+":
case "=":
controls.radius = Math.max(9, controls.radius - 0.7);
break;
case "-":
controls.radius = Math.min(25, controls.radius + 0.7);
break;
case "r":
resetCamera();
break;
default:
handled = false;
}
if (handled) {
event.preventDefault();
updateCamera();
}
});
// Lighting
const hemi = new THREE.HemisphereLight("#eff8f2", "#7e7057", 2.15);
scene.add(hemi);
const sun = new THREE.DirectionalLight("#fff2d9", 3.15);
sun.position.set(-5, 11, 7);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -13;
sun.shadow.camera.right = 13;
sun.shadow.camera.top = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0008;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#9cc9c8", 1.1);
fill.position.set(8, 5, -8);
scene.add(fill);
// Deterministic pseudo-random placement
function mulberry32(seed) {
return function () {
let value = seed += 0x6D2B79F5;
value = Math.imul(value ^ (value >>> 15), value | 1);
value ^= value + Math.imul(value ^ (value >>> 7), value | 61);
return ((value ^ (value >>> 14)) >>> 0) / 4294967296;
};
}
const random = mulberry32(82473);
const smoothstep = THREE.MathUtils.smoothstep;
function hash2(a, b) {
const value = Math.sin(a * 127.1 + b * 311.7) * 43758.5453;
return value - Math.floor(value);
}
const LAND_MIN_X = -6.35;
const LAND_MIN_Z = -5;
const LAND_MAX_Z = 5;
const WATER_TOP = 0.075;
const BASE_TOP = -0.24;
function shoreX(z) {
return (
1.55 +
0.28 * Math.sin(z * 0.72) +
0.12 * Math.sin(z * 1.8 + 0.8)
);
}
function terrainHeight(x, z) {
const distance = shoreX(z) - x;
const beachRise = 0.14 * smoothstep(distance, 0, 0.65);
const dune =
0.57 * Math.exp(-Math.pow((distance - 2.05) / 1.28, 2));
const inlandRise = 0.12 * smoothstep(distance, 1.2, 5.8);
const roughness =
0.035 *
Math.sin(x * 2.1 + z * 0.7) *
Math.cos(z * 1.6 - x * 0.5);
return (
WATER_TOP +
beachRise +
dune +
inlandRise +
roughness * smoothstep(distance, 0.2, 1)
);
}
function roundedRectGeometry(width, depth, radius, extrusion) {
const shape = new THREE.Shape();
const w = width / 2;
const d = depth / 2;
shape.moveTo(-w + radius, -d);
shape.lineTo(w - radius, -d);
shape.quadraticCurveTo(w, -d, w, -d + radius);
shape.lineTo(w, d - radius);
shape.quadraticCurveTo(w, d, w - radius, d);
shape.lineTo(-w + radius, d);
shape.quadraticCurveTo(-w, d, -w, d - radius);
shape.lineTo(-w, -d + radius);
shape.quadraticCurveTo(-w, -d, -w + radius, -d);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: extrusion,
bevelEnabled: false,
curveSegments: 8
});
geometry.rotateX(-Math.PI / 2);
return geometry;
}
// Ground and rounded earth plinth
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
new THREE.MeshStandardMaterial({
color: "#d7e2db",
roughness: 1
})
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.585;
ground.receiveShadow = true;
scene.add(ground);
const base = new THREE.Mesh(
roundedRectGeometry(16, 10.8, 0.55, 0.34),
new THREE.MeshStandardMaterial({
color: "#696b55",
roughness: 0.98,
flatShading: true
})
);
base.position.set(1, -0.58, 0);
base.castShadow = true;
base.receiveShadow = true;
scene.add(base);
// Solid water slab. Its left boundary follows the same shoreline
// curve as the land, avoiding a generic rectangular intersection.
const TERRAIN_X_SEGMENTS = 24;
const TERRAIN_Z_SEGMENTS = 36;
const waterShape = new THREE.Shape();
for (let iz = 0; iz <= TERRAIN_Z_SEGMENTS; iz++) {
const z =
LAND_MIN_Z +
(LAND_MAX_Z - LAND_MIN_Z) * (iz / TERRAIN_Z_SEGMENTS);
const point = new THREE.Vector2(shoreX(z), -z);
if (iz === 0) waterShape.moveTo(point.x, point.y);
else waterShape.lineTo(point.x, point.y);
}
waterShape.lineTo(8.02, -5);
waterShape.quadraticCurveTo(8.35, -5, 8.35, -4.67);
waterShape.lineTo(8.35, 4.67);
waterShape.quadraticCurveTo(8.35, 5, 8.02, 5);
waterShape.closePath();
const waterGeometry = new THREE.ExtrudeGeometry(waterShape, {
depth: 0.3,
bevelEnabled: false
});
waterGeometry.rotateX(-Math.PI / 2);
const waterTopMaterial = new THREE.MeshStandardMaterial({
color: "#4e969a",
roughness: 0.4,
metalness: 0.03
});
const waterSideMaterial = new THREE.MeshStandardMaterial({
color: "#326f77",
roughness: 0.72
});
const water = new THREE.Mesh(
waterGeometry,
[waterTopMaterial, waterSideMaterial]
);
water.position.y = -0.225;
water.receiveShadow = true;
scene.add(water);
// Faceted land surface
const topPositions = [];
const topColors = [];
const sandColor = new THREE.Color("#d9c293");
const duneColor = new THREE.Color("#b9aa77");
const turfColor = new THREE.Color("#79845e");
function terrainColor(x, z, variation = 0) {
const distance = shoreX(z) - x;
const color = new THREE.Color();
if (distance < 1.05) {
color.copy(sandColor);
} else if (distance < 3.6) {
color.copy(sandColor).lerp(duneColor, smoothstep(distance, 1.05, 3.6));
} else {
color
.copy(duneColor)
.lerp(turfColor, smoothstep(distance, 3.6, 6.2));
}
color.offsetHSL(0, 0, variation);
return color;
}
function pushTriangle(positionArray, colorArray, a, b, c, color) {
positionArray.push(
a.x, a.y, a.z,
b.x, b.y, b.z,
c.x, c.y, c.z
);
for (let i = 0; i < 3; i++) {
colorArray.push(color.r, color.g, color.b);
}
}
for (let iz = 0; iz < TERRAIN_Z_SEGMENTS; iz++) {
const z0 =
LAND_MIN_Z +
(LAND_MAX_Z - LAND_MIN_Z) * (iz / TERRAIN_Z_SEGMENTS);
const z1 =
LAND_MIN_Z +
(LAND_MAX_Z - LAND_MIN_Z) * ((iz + 1) / TERRAIN_Z_SEGMENTS);
for (let ix = 0; ix < TERRAIN_X_SEGMENTS; ix++) {
const t0 = ix / TERRAIN_X_SEGMENTS;
const t1 = (ix + 1) / TERRAIN_X_SEGMENTS;
const x00 = THREE.MathUtils.lerp(LAND_MIN_X, shoreX(z0), t0);
const x10 = THREE.MathUtils.lerp(LAND_MIN_X, shoreX(z0), t1);
const x01 = THREE.MathUtils.lerp(LAND_MIN_X, shoreX(z1), t0);
const x11 = THREE.MathUtils.lerp(LAND_MIN_X, shoreX(z1), t1);
const p00 = new THREE.Vector3(x00, terrainHeight(x00, z0), z0);
const p10 = new THREE.Vector3(x10, terrainHeight(x10, z0), z0);
const p01 = new THREE.Vector3(x01, terrainHeight(x01, z1), z1);
const p11 = new THREE.Vector3(x11, terrainHeight(x11, z1), z1);
const variation = (hash2(ix, iz) - 0.5) * 0.055;
const c1 = terrainColor((x00 + x01) / 2, (z0 + z1) / 2, variation);
const c2 = terrainColor((x10 + x11) / 2, (z0 + z1) / 2, variation);
pushTriangle(topPositions, topColors, p00, p01, p11, c1);
pushTriangle(topPositions, topColors, p00, p11, p10, c2);
}
}
const terrainGeometry = new THREE.BufferGeometry();
terrainGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(topPositions, 3)
);
terrainGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(topColors, 3)
);
terrainGeometry.computeVertexNormals();
const terrain = new THREE.Mesh(
terrainGeometry,
new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 0.98,
flatShading: true
})
);
terrain.castShadow = true;
terrain.receiveShadow = true;
scene.add(terrain);
// Layered cutaway walls on the three open sides of the land fragment.
const wallPositions = [];
const wallColors = [];
const upperSoil = new THREE.Color("#b69e70");
const lowerSoil = new THREE.Color("#706750");
function addWallQuad(a, b, c, d, color) {
pushTriangle(wallPositions, wallColors, a, c, d, color);
pushTriangle(wallPositions, wallColors, a, d, b, color);
}
function addWallStrip(aTop, bTop, aBottom, bBottom, color) {
pushTriangle(wallPositions, wallColors, aTop, aBottom, bBottom, color);
pushTriangle(wallPositions, wallColors, aTop, bBottom, bTop, color);
}
// Front and back walls
for (const z of [LAND_MIN_Z, LAND_MAX_Z]) {
for (let ix = 0; ix < TERRAIN_X_SEGMENTS; ix++) {
const t0 = ix / TERRAIN_X_SEGMENTS;
const t1 = (ix + 1) / TERRAIN_X_SEGMENTS;
const x0 = THREE.MathUtils.lerp(LAND_MIN_X, shoreX(z), t0);
const x1 = THREE.MathUtils.lerp(LAND_MIN_X, shoreX(z), t1);
const aTop = new THREE.Vector3(x0, terrainHeight(x0, z), z);
const bTop = new THREE.Vector3(x1, terrainHeight(x1, z), z);
const aMid = new THREE.Vector3(x0, -0.015, z);
const bMid = new THREE.Vector3(x1, -0.015, z);
const aLow = new THREE.Vector3(x0, BASE_TOP, z);
const bLow = new THREE.Vector3(x1, BASE_TOP, z);
if (z === LAND_MAX_Z) {
addWallStrip(aTop, bTop, aMid, bMid, upperSoil);
addWallStrip(aMid, bMid, aLow, bLow, lowerSoil);
} else {
pushTriangle(wallPositions, wallColors, aTop, bMid, aMid, upperSoil);
pushTriangle(wallPositions, wallColors, aTop, bTop, bMid, upperSoil);
pushTriangle(wallPositions, wallColors, aMid, bMid, aLow, lowerSoil);
pushTriangle(wallPositions, wallColors, aMid, bLow, bTop, lowerSoil);
}
}
}
// Left cutaway wall
for (let iz = 0; iz < TERRAIN_Z_SEGMENTS; iz++) {
const z0 =
LAND_MIN_Z +
(LAND_MAX_Z - LAND_MIN_Z) * (iz / TERRAIN_Z_SEGMENTS);
const z1 =
LAND_MIN_Z +
(LAND_MAX_Z - LAND_MIN_Z) * ((iz + 1) / TERRAIN_Z_SEGMENTS);
const aTop = new THREE.Vector3(LAND_MIN_X, terrainHeight(LAND_MIN_X, z0), z0);
const bTop = new THREE.Vector3(LAND_MIN_X, terrainHeight(LAND_MIN_X, z1), z1);
const aMid = new THREE.Vector3(LAND_MIN_X, -0.015, z0);
const bMid = new THREE.Vector3(LAND_MIN_X, -0.015, z1);
const aLow = new THREE.Vector3(LAND_MIN_X, BASE_TOP, z0);
const bLow = new THREE.Vector3(LAND_MIN_X, BASE_TOP, z1);
addWallStrip(aTop, bTop, aMid, bMid, upperSoil);
addWallStrip(aMid, bMid, aLow, bLow, lowerSoil);
}
const wallGeometry = new THREE.BufferGeometry();
wallGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(wallPositions, 3)
);
wallGeometry.setAttribute(
"color",
new THREE.Float32BufferAttribute(wallColors, 3)
);
wallGeometry.computeVertexNormals();
const walls = new THREE.Mesh(
wallGeometry,
new THREE.MeshStandardMaterial({
color: 0xffffff,
vertexColors: true,
roughness: 1,
flatShading: true
})
);
walls.castShadow = true;
walls.receiveShadow = true;
scene.add(walls);
// Pebbles: faceted solid forms, mostly concentrated along the beach.
const pebbleCount = 58;
const pebbleGeometry = new THREE.IcosahedronGeometry(1, 1);
const pebbleMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.92,
flatShading: true
});
const pebbles = new THREE.InstancedMesh(
pebbleGeometry,
pebbleMaterial,
pebbleCount
);
pebbles.castShadow = true;
pebbles.receiveShadow = true;
const pebblePalette = [
"#77766f",
"#9e9786",
"#5f625f",
"#c0b59e",
"#8a8072",
"#b2a58c"
];
const dummy = new THREE.Object3D();
for (let i = 0; i < pebbleCount; i++) {
const z = THREE.MathUtils.lerp(-4.65, 4.65, random());
const distance = 0.18 + Math.pow(random(), 1.8) * 2.45;
const x = shoreX(z) - distance;
const y = terrainHeight(x, z);
const sx = 0.11 + random() * 0.25;
const sy = 0.055 + random() * 0.13;
const sz = 0.09 + random() * 0.24;
dummy.position.set(x, y + sy * 0.35, z);
dummy.rotation.set(
random() * 0.4,
random() * Math.PI * 2,
random() * 0.4
);
dummy.scale.set(sx, sy, sz);
dummy.updateMatrix();
pebbles.setMatrixAt(i, dummy.matrix);
pebbles.setColorAt(
i,
new THREE.Color(
pebblePalette[Math.floor(random() * pebblePalette.length)]
)
);
}
pebbles.instanceMatrix.needsUpdate = true;
pebbles.instanceColor.needsUpdate = true;
scene.add(pebbles);
// Fine sand grains
const gritCount = 150;
const grit = new THREE.InstancedMesh(
new THREE.IcosahedronGeometry(1, 0),
new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 1,
flatShading: true
}),
gritCount
);
grit.receiveShadow = true;
for (let i = 0; i < gritCount; i++) {
const z = THREE.MathUtils.lerp(-4.7, 4.7, random());
const distance = 0.05 + random() * 1.15;
const x = shoreX(z) - distance;
const size = 0.018 + random() * 0.032;
dummy.position.set(x, terrainHeight(x, z) + size * 0.35, z);
dummy.rotation.set(random(), random() * Math.PI, random());
dummy.scale.set(size * 1.5, size * 0.55, size);
dummy.updateMatrix();
grit.setMatrixAt(i, dummy.matrix);
grit.setColorAt(
i,
new THREE.Color().setHSL(
0.105,
0.28 + random() * 0.12,
0.58 + random() * 0.17
)
);
}
grit.instanceMatrix.needsUpdate = true;
grit.instanceColor.needsUpdate = true;
scene.add(grit);
// Solid triangular dune-grass blades, arranged in irregular clumps.
const grassClumps = [];
const grassPalette = [
"#526a3e",
"#697b47",
"#7d884f",
"#9c995a",
"#b0a263"
];
for (let clump = 0; clump < 35; clump++) {
const z = THREE.MathUtils.lerp(-4.55, 4.55, random());
const distance = 2.0 + random() * 3.9;
const x = shoreX(z) - distance;
if (Math.abs(z + 3.7) < 1.0 && Math.abs(x + 0.5) < 1.7) {
continue;
}
grassClumps.push({
x,
z,
y: terrainHeight(x, z),
blades: 4 + Math.floor(random() * 4)
});
}
let totalBlades = 0;
for (const clump of grassClumps) totalBlades += clump.blades;
const grassGeometry = new THREE.CylinderGeometry(0.003, 0.042, 1, 3);
const grassMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.88,
flatShading: true
});
const grass = new THREE.InstancedMesh(
grassGeometry,
grassMaterial,
totalBlades
);
grass.castShadow = true;
grass.receiveShadow = true;
const seedData = [];
let bladeIndex = 0;
for (const clump of grassClumps) {
for (let blade = 0; blade < clump.blades; blade++) {
const height = 0.38 + random() * 0.43;
const tiltX = (random() - 0.5) * 0.34;
const tiltZ = (random() - 0.5) * 0.38;
const offsetX = (random() - 0.5) * 0.24;
const offsetZ = (random() - 0.5) * 0.24;
const baseX = clump.x + offsetX;
const baseZ = clump.z + offsetZ;
dummy.position.set(baseX, clump.y + height * 0.48, baseZ);
dummy.rotation.set(tiltX, random() * Math.PI * 2, tiltZ);
dummy.scale.set(
0.75 + random() * 0.55,
height,
0.75 + random() * 0.55
);
dummy.updateMatrix();
grass.setMatrixAt(bladeIndex, dummy.matrix);
grass.setColorAt(
bladeIndex,
new THREE.Color(
grassPalette[Math.floor(random() * grassPalette.length)]
)
);
if (bladeIndex % 6 === 0) {
seedData.push({
x: baseX + Math.sin(tiltZ) * height,
y: clump.y + height * 0.93,
z: baseZ + Math.sin(tiltX) * height
});
}
bladeIndex++;
}
}
grass.instanceMatrix.needsUpdate = true;
grass.instanceColor.needsUpdate = true;
scene.add(grass);
// Occasional golden seed heads
const seedHeads = new THREE.InstancedMesh(
new THREE.IcosahedronGeometry(0.055, 0),
new THREE.MeshStandardMaterial({
color: "#987c45",
roughness: 1,
flatShading: true
}),
seedData.length
);
seedHeads.castShadow = true;
seedData.forEach((seed, index) => {
dummy.position.set(seed.x, seed.y, seed.z);
dummy.rotation.set(0.2, random() * Math.PI, 0.25);
dummy.scale.set(0.62, 1.8, 0.62);
dummy.updateMatrix();
seedHeads.setMatrixAt(index, dummy.matrix);
});
seedHeads.instanceMatrix.needsUpdate = true;
scene.add(seedHeads);
// Thin solid ripple marks. They indicate a calm freshwater lake
// without introducing ocean-specific tide imagery.
const rippleMaterial = new THREE.MeshBasicMaterial({
color: "#c1dfd7",
transparent: true,
opacity: 0.58,
depthWrite: false,
toneMapped: false
});
function addRipple(points, radius = 0.013) {
const curve = new THREE.CatmullRomCurve3(points);
const geometry = new THREE.TubeGeometry(
curve,
Math.max(12, points.length * 5),
radius,
4,
false
);
const mesh = new THREE.Mesh(geometry, rippleMaterial);
scene.add(mesh);
}
[
[-4.25, -2.75],
[-1.65, 0.1],
[0.65, 3.9]
].forEach(([z0, z1], index) => {
const points = [];
for (let i = 0; i < 7; i++) {
const t = i / 6;
const z = THREE.MathUtils.lerp(z0, z1, t);
const x = shoreX(z) + 0.18 + 0.055 * Math.sin(z * 2 + index);
points.push(new THREE.Vector3(x, WATER_TOP + 0.018, z));
}
addRipple(points, 0.012);
});
[
[2.65, -4.0, -1.8],
[4.8, -3.0, -0.7],
[6.7, -1.8, 0.5],
[3.6, 1.1, 3.9],
[5.9, 1.5, 4.2]
].forEach(([x, z0, z1], index) => {
const points = [];
for (let i = 0; i < 6; i++) {
const t = i / 5;
const z = THREE.MathUtils.lerp(z0, z1, t);
points.push(
new THREE.Vector3(
x + 0.09 * Math.sin(t * Math.PI * 2 + index),
WATER_TOP + 0.017,
z
)
);
}
addRipple(points, 0.011);
});
// Small Great Lakes navigation buoy.
const buoy = new THREE.Group();
buoy.position.set(4.15, WATER_TOP, -1.25);
const buoyBody = new THREE.Mesh(
new THREE.CylinderGeometry(0.17, 0.22, 0.4, 10),
new THREE.MeshStandardMaterial({
color: "#e5aa38",
roughness: 0.62,
flatShading: true
})
);
buoyBody.position.y = 0.2;
buoyBody.castShadow = true;
buoy.add(buoyBody);
const buoyBand = new THREE.Mesh(
new THREE.CylinderGeometry(0.194, 0.194, 0.075, 10),
new THREE.MeshStandardMaterial({
color: "#45504b",
roughness: 0.72,
flatShading: true
})
);
buoyBand.position.y = 0.23;
buoyBand.castShadow = true;
buoy.add(buoyBand);
const buoyStem = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.045, 0.34, 7),
new THREE.MeshStandardMaterial({
color: "#394a46",
roughness: 0.75
})
);
buoyStem.position.y = 0.55;
buoy.add(buoyStem);
const buoyTop = new THREE.Mesh(
new THREE.ConeGeometry(0.14, 0.23, 4),
new THREE.MeshStandardMaterial({
color: "#e5aa38",
roughness: 0.65,
flatShading: true
})
);
buoyTop.position.y = 0.8;
buoyTop.rotation.y = Math.PI / 4;
buoyTop.castShadow = true;
buoy.add(buoyTop);
scene.add(buoy);
const buoyRings = [];
[0.55, 0.9].forEach((radius, index) => {
const ring = new THREE.Mesh(
new THREE.TorusGeometry(radius, 0.012, 4, 48),
new THREE.MeshBasicMaterial({
color: "#b9d8cf",
transparent: true,
opacity: 0.5 - index * 0.12,
depthWrite: false,
toneMapped: false
})
);
ring.rotation.x = Math.PI / 2;
ring.position.set(4.15, WATER_TOP + 0.016, -1.25);
ring.scale.y = 0.62;
scene.add(ring);
buoyRings.push(ring);
});
// A specimen-style sign makes the lake identification explicit.
const signCanvas = document.createElement("canvas");
signCanvas.width = 1024;
signCanvas.height = 320;
const context = signCanvas.getContext("2d");
context.fillStyle = "#f2ead7";
context.fillRect(0, 0, 1024, 320);
context.strokeStyle = "#305c56";
context.lineWidth = 12;
context.strokeRect(18, 18, 988, 284);
context.fillStyle = "#c87849";
context.fillRect(18, 18, 988, 13);
context.textAlign = "center";
context.textBaseline = "middle";
context.fillStyle = "#315c56";
context.font = "700 34px Arial, sans-serif";
context.fillText("GREAT LAKES", 512, 66);
context.fillStyle = "#193f3a";
context.font = "700 88px Arial, sans-serif";
context.fillText("LAKE MICHIGAN", 512, 158);
context.fillStyle = "#56736d";
context.font = "600 29px Arial, sans-serif";
context.fillText("FRESHWATER SHORELINE STUDY", 512, 245);
const signTexture = new THREE.CanvasTexture(signCanvas);
signTexture.colorSpace = THREE.SRGBColorSpace;
signTexture.anisotropy = renderer.capabilities.getMaxAnisotropy();
const signPosition = new THREE.Vector3(-0.45, 0, -3.65);
const signBaseY = terrainHeight(signPosition.x, signPosition.z);
const postMaterial = new THREE.MeshStandardMaterial({
color: "#74664d",
roughness: 0.94,
flatShading: true
});
[-0.86, 0.86].forEach((offset) => {
const post = new THREE.Mesh(
new THREE.CylinderGeometry(0.045, 0.06, 1.25, 7),
postMaterial
);
post.position.set(
signPosition.x + offset,
signBaseY + 0.6,
signPosition.z
);
post.castShadow = true;
scene.add(post);
});
const signPlane = new THREE.Mesh(
new THREE.PlaneGeometry(2.55, 0.8),
new THREE.MeshBasicMaterial({
map: signTexture,
side: THREE.DoubleSide,
toneMapped: false
})
);
signPlane.position.set(
signPosition.x,
signBaseY + 1.32,
signPosition.z
);
signPlane.renderOrder = 4;
scene.add(signPlane);
// Render loop
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
// Only a tiny floating motion is used; no tide cycle is implied.
buoy.position.y = WATER_TOP + Math.sin(elapsed * 0.9) * 0.012;
buoy.rotation.z = Math.sin(elapsed * 0.65) * 0.018;
buoyRings.forEach((ring, index) => {
const pulse = 1 + Math.sin(elapsed * 0.55 + index) * 0.025;
ring.scale.set(pulse, 0.62 * pulse, pulse);
});
// Keep the small lake label legible while orbiting.
signPlane.lookAt(camera.position);
renderer.render(scene, camera);
});
requestAnimationFrame(() => {
loading.classList.add("hidden");
setTimeout(() => loading.remove(), 500);
});
</script>
</body>
</html>
```