Prompt specification
Build or customize the Three.js 3D scene "Retaining wall holding one soil step" 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: Retaining wall holding one soil step
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/retaining-wall-holding-one-soil-step-x2213
Scene Description Prompt:
Make a stylized Three.js scene in a self-contained HTML file using cdnjs: retaining wall holding one soil step. Build a short retaining wall with a soil cutaway behind it. Distinguish retained ground, level terrace, and lower path through visible material boundaries.
Working Three.js Starter (retaining-wall-holding-one-soil-step-x2213):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>One-Step Retaining Wall</title>
<style>
* { box-sizing: border-box; }
html, body {
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #e9e5dc;
color: #28332e;
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%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.title {
position: fixed;
top: 28px;
left: 30px;
z-index: 2;
pointer-events: none;
user-select: none;
}
.eyebrow {
margin-bottom: 6px;
color: #738078;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(28px, 4vw, 48px);
font-weight: 500;
letter-spacing: -0.035em;
line-height: 0.98;
}
.subtitle {
margin-top: 10px;
color: #6b766f;
font-size: 13px;
}
.legend {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 2;
width: 218px;
padding: 15px 16px;
border: 1px solid rgba(52, 66, 57, 0.12);
border-radius: 14px;
background: rgba(250, 248, 241, 0.84);
box-shadow: 0 12px 34px rgba(49, 55, 47, 0.1);
backdrop-filter: blur(10px);
user-select: none;
}
.legend-title {
margin-bottom: 10px;
color: #7c867f;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.legend-row {
display: flex;
align-items: center;
gap: 10px;
margin-top: 8px;
font-size: 12px;
font-weight: 650;
}
.swatch {
width: 17px;
height: 17px;
flex: 0 0 auto;
border: 1px solid rgba(0, 0, 0, 0.08);
border-radius: 4px;
}
.soil { background: #a76f3f; }
.terrace { background: #71865d; }
.path { background: #aaa9a1; }
.help {
position: fixed;
left: 30px;
bottom: 25px;
z-index: 2;
padding: 8px 11px;
border-radius: 999px;
background: rgba(250, 248, 241, 0.72);
color: #6b766f;
font-size: 11px;
letter-spacing: 0.03em;
user-select: none;
}
#reset {
position: fixed;
top: 26px;
right: 26px;
z-index: 3;
border: 1px solid rgba(52, 66, 57, 0.16);
border-radius: 999px;
padding: 9px 14px;
background: rgba(250, 248, 241, 0.86);
color: #45534b;
font: 700 11px/1 ui-sans-serif, system-ui, sans-serif;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
}
#reset:hover {
background: #fffaf0;
}
@media (max-width: 700px) {
.title { top: 20px; left: 20px; }
.subtitle { display: none; }
.legend { right: 14px; bottom: 14px; width: 190px; }
.help { display: none; }
#reset { top: 18px; right: 18px; }
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="title">
<div class="eyebrow">Landscape section</div>
<h1>One-Step<br />Terrace</h1>
<div class="subtitle">A short masonry retaining wall holding a single upper level.</div>
</div>
<button id="reset" type="button">Reset view</button>
<div class="legend" aria-label="Material legend">
<div class="legend-title">Visible materials</div>
<div class="legend-row"><span class="swatch soil"></span>Retained ground</div>
<div class="legend-row"><span class="swatch terrace"></span>Level terrace</div>
<div class="legend-row"><span class="swatch path"></span>Lower path</div>
</div>
<div class="help">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";
const container = document.getElementById("scene");
const resetButton = document.getElementById("reset");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e5dc);
scene.fog = new THREE.Fog(0xe9e5dc, 24, 42);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.08;
container.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
36,
window.innerWidth / window.innerHeight,
0.1,
100
);
const target = new THREE.Vector3(0, 1.15, -0.35);
const initialView = {
azimuth: 0.64,
polar: 0.98,
radius: 16.2
};
const view = { ...initialView };
function updateCamera() {
const sinPolar = Math.sin(view.polar);
camera.position.set(
target.x + view.radius * sinPolar * Math.sin(view.azimuth),
target.y + view.radius * Math.cos(view.polar),
target.z + view.radius * sinPolar * Math.cos(view.azimuth)
);
camera.lookAt(target);
}
updateCamera();
// Lighting
scene.add(new THREE.HemisphereLight(0xfff8e9, 0x667466, 2.25));
const sun = new THREE.DirectionalLight(0xfff0d2, 3.4);
sun.position.set(-6, 11, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -10;
sun.shadow.camera.right = 10;
sun.shadow.camera.top = 10;
sun.shadow.camera.bottom = -10;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 30;
sun.shadow.bias = -0.00015;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d1d7, 1.15);
fill.position.set(7, 5, -6);
scene.add(fill);
const materials = {
foundation: new THREE.MeshStandardMaterial({
color: 0x71513c,
roughness: 1
}),
soilDark: new THREE.MeshStandardMaterial({
color: 0x795039,
roughness: 1
}),
soilMid: new THREE.MeshStandardMaterial({
color: 0xa36d42,
roughness: 1
}),
soilTop: new THREE.MeshStandardMaterial({
color: 0xb98552,
roughness: 1
}),
rawEarth: new THREE.MeshStandardMaterial({
color: 0xb58a5d,
roughness: 1
}),
terrace: new THREE.MeshStandardMaterial({
color: 0x71865d,
roughness: 0.96
}),
terraceEdge: new THREE.MeshStandardMaterial({
color: 0x526744,
roughness: 1
}),
wall: [
new THREE.MeshStandardMaterial({ color: 0xc4b69c, roughness: 0.96 }),
new THREE.MeshStandardMaterial({ color: 0xb9aa8e, roughness: 0.98 }),
new THREE.MeshStandardMaterial({ color: 0xd0c2a8, roughness: 0.94 }),
new THREE.MeshStandardMaterial({ color: 0xbaad95, roughness: 0.98 })
],
coping: new THREE.MeshStandardMaterial({
color: 0xded1b9,
roughness: 0.9
}),
mortar: new THREE.MeshStandardMaterial({
color: 0x8d806d,
roughness: 1
}),
path: [
new THREE.MeshStandardMaterial({ color: 0xaaa9a1, roughness: 0.95 }),
new THREE.MeshStandardMaterial({ color: 0xb4b2a9, roughness: 0.95 }),
new THREE.MeshStandardMaterial({ color: 0x9f9f98, roughness: 0.97 }),
new THREE.MeshStandardMaterial({ color: 0xb9b6ad, roughness: 0.93 })
],
trunk: new THREE.MeshStandardMaterial({
color: 0x73513b,
roughness: 1
}),
leaves: [
new THREE.MeshStandardMaterial({ color: 0x667b50, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x819363, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x58714d, roughness: 1 })
],
stone: [
new THREE.MeshStandardMaterial({ color: 0x8c806b, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0xb0a187, roughness: 1 }),
new THREE.MeshStandardMaterial({ color: 0x776b59, roughness: 1 })
],
root: new THREE.MeshStandardMaterial({
color: 0x63452f,
roughness: 1
}),
pipe: new THREE.MeshStandardMaterial({
color: 0x39413d,
roughness: 0.68,
metalness: 0.12
})
};
function box(width, height, depth, material, x, y, z, cast = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(width, height, depth),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Neutral floor beneath the cutaway model.
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(80, 80),
new THREE.MeshStandardMaterial({ color: 0xe9e5dc, roughness: 1 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.56;
floor.receiveShadow = true;
scene.add(floor);
// Dark soil plinth makes the lower path read as a distinct level.
box(11.8, 0.5, 8.5, materials.foundation, 0, -0.28, 0);
// Exposed retained soil: three broad strata form a readable cutaway.
box(10.8, 0.86, 4.25, materials.soilDark, 0, 0.43, -2.0);
box(10.8, 0.69, 4.25, materials.soilMid, 0, 1.205, -2.0);
box(10.8, 0.50, 4.25, materials.soilTop, 0, 1.80, -2.0);
// Raw earth immediately behind the wall.
box(10.8, 0.08, 1.75, materials.rawEarth, 0, 2.09, -0.725);
// The level terrace is a crisp green cap with a sharply visible boundary.
box(10.8, 0.18, 2.58, materials.terrace, 0, 2.11, -2.87);
box(10.82, 0.075, 2.58, materials.terraceEdge, 0, 2.015, -2.87);
// Lower path: separated slabs with narrow dark joints.
const paverColors = [0, 1, 2, 3, 1, 0, 3, 2];
let paverIndex = 0;
for (let row = 0; row < 2; row++) {
for (let col = 0; col < 4; col++) {
const x = -4.2 + col * 2.8;
const z = 1.65 + row * 2.45;
box(
2.66,
0.16,
2.30,
materials.path[paverColors[paverIndex++]],
x,
0.015,
z
);
}
}
// A thin mortar bed behind the individual wall blocks.
box(7.95, 1.96, 0.49, materials.mortar, 0, 1.0, 0.31);
// Four courses of individually offset masonry blocks.
const blockRows = [
{ y: 0.25, count: 6, width: 1.27 },
{ y: 0.73, count: 5, width: 1.55 },
{ y: 1.21, count: 6, width: 1.27 },
{ y: 1.69, count: 5, width: 1.55 }
];
blockRows.forEach((row, rowIndex) => {
for (let i = 0; i < row.count; i++) {
const x = -row.width * row.count / 2 + row.width * (i + 0.5);
const material = materials.wall[(i + rowIndex * 2) % materials.wall.length];
const block = box(
row.width - 0.045,
0.445,
0.66,
material,
x,
row.y,
0.36
);
block.rotation.z = ((i + rowIndex) % 3 - 1) * 0.0025;
}
});
// Broad coping cap.
box(8.05, 0.22, 0.87, materials.coping, 0, 2.015, 0.36);
box(7.72, 0.055, 0.73, materials.rawEarth, 0, 2.14, 0.36);
// Small end returns emphasize the wall as a compact retaining structure.
box(0.55, 1.92, 1.0, materials.wall[2], -3.72, 1.0, 0.54);
box(0.55, 1.92, 1.0, materials.wall[1], 3.72, 1.0, 0.54);
// Drain outlet in the wall face.
const drain = new THREE.Mesh(
new THREE.CylinderGeometry(0.12, 0.12, 0.12, 20),
materials.pipe
);
drain.rotation.x = Math.PI / 2;
drain.position.set(2.75, 0.28, 0.73);
drain.castShadow = true;
scene.add(drain);
const drainRim = new THREE.Mesh(
new THREE.TorusGeometry(0.13, 0.025, 8, 24),
materials.coping
);
drainRim.position.set(2.75, 0.28, 0.805);
scene.add(drainRim);
// Stones embedded in the exposed soil face.
let seed = 19;
function random() {
seed = (seed * 9301 + 49297) % 233280;
return seed / 233280;
}
const stoneGeometry = new THREE.DodecahedronGeometry(0.11, 0);
for (let i = 0; i < 17; i++) {
const stone = new THREE.Mesh(
stoneGeometry,
materials.stone[i % materials.stone.length]
);
stone.position.set(
5.40 + random() * 0.035,
0.22 + random() * 1.68,
-3.95 + random() * 3.5
);
stone.scale.set(
0.35 + random() * 0.22,
0.65 + random() * 0.75,
0.65 + random() * 0.65
);
stone.rotation.set(random() * 2, random() * 2, random() * 2);
stone.castShadow = true;
scene.add(stone);
}
// A visible root tracing the cut face.
const rootCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(5.43, 2.08, -2.05),
new THREE.Vector3(5.46, 1.78, -2.12),
new THREE.Vector3(5.45, 1.43, -2.28),
new THREE.Vector3(5.47, 1.06, -2.14),
new THREE.Vector3(5.45, 0.69, -2.33),
new THREE.Vector3(5.46, 0.35, -2.20)
]);
const root = new THREE.Mesh(
new THREE.TubeGeometry(rootCurve, 32, 0.028, 6, false),
materials.root
);
root.castShadow = true;
scene.add(root);
// Minimal stylized tree on the upper terrace.
const trunk = new THREE.Mesh(
new THREE.CylinderGeometry(0.13, 0.18, 1.55, 9),
materials.trunk
);
trunk.position.set(-3.15, 2.94, -3.05);
trunk.castShadow = true;
scene.add(trunk);
const canopyGeometry = new THREE.DodecahedronGeometry(0.78, 1);
const canopyData = [
[-3.15, 3.78, -3.05, 1.05],
[-3.58, 3.57, -2.87, 0.78],
[-2.73, 3.62, -3.22, 0.82],
[-3.12, 4.12, -3.02, 0.68]
];
canopyData.forEach((data, i) => {
const leaf = new THREE.Mesh(
canopyGeometry,
materials.leaves[i % materials.leaves.length]
);
leaf.position.set(data[0], data[1], data[2]);
leaf.scale.setScalar(data[3]);
leaf.rotation.set(i * 0.31, i * 0.57, i * 0.22);
leaf.castShadow = true;
leaf.receiveShadow = true;
scene.add(leaf);
});
// Low shrubs, kept away from the material boundaries.
const shrubGeometry = new THREE.DodecahedronGeometry(0.38, 1);
[
[2.55, 2.54, -3.20, 1.0],
[3.05, 2.48, -3.38, 0.72],
[-0.55, 2.43, -3.42, 0.72]
].forEach((data, i) => {
const shrub = new THREE.Mesh(
shrubGeometry,
materials.leaves[(i + 1) % materials.leaves.length]
);
shrub.position.set(data[0], data[1], data[2]);
shrub.scale.set(data[3], data[3] * 0.85, data[3]);
shrub.castShadow = true;
scene.add(shrub);
});
// Sparse upright grass blades on the terrace.
const grassMaterial = new THREE.MeshStandardMaterial({
color: 0x8c9c6c,
roughness: 1
});
const grassGeometry = new THREE.ConeGeometry(0.035, 0.38, 4);
for (let i = 0; i < 22; i++) {
const blade = new THREE.Mesh(grassGeometry, grassMaterial);
blade.position.set(
-4.8 + random() * 9.5,
2.37,
-4.0 + random() * 2.25
);
blade.rotation.z = (random() - 0.5) * 0.35;
blade.castShadow = true;
scene.add(blade);
}
// Direct camera controls: no addons or examples modules are used.
let dragging = false;
let previousX = 0;
let previousY = 0;
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 dx = event.clientX - previousX;
const dy = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
view.azimuth -= dx * 0.006;
view.polar = THREE.MathUtils.clamp(
view.polar - dy * 0.005,
0.48,
1.38
);
updateCamera();
});
function endDrag(event) {
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", endDrag);
renderer.domElement.addEventListener("pointercancel", endDrag);
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
view.radius = THREE.MathUtils.clamp(
view.radius + event.deltaY * 0.012,
10.5,
23
);
updateCamera();
}, { passive: false });
resetButton.addEventListener("click", () => {
Object.assign(view, initialView);
updateCamera();
});
renderer.domElement.addEventListener("dblclick", () => {
Object.assign(view, initialView);
updateCamera();
});
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
renderer.setAnimationLoop(() => {
renderer.render(scene, camera);
});
</script>
</body>
</html>
```