Prompt specification
Build or customize the Three.js 3D scene "Three land-use parcels on a 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: Three land-use parcels on a tile
Category: Space & Earth · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/three-land-use-parcels-on-a-tile-x1309
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows land-use mosaics. Build adjacent housing, crop, and woodland parcels separated by simple boundaries. Make each use recognizable through geometry rather than color alone, with a shared scale marker. Stylized solid forms.
Working Three.js Starter (three-land-use-parcels-on-a-tile-x1309):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Land-Use Mosaic</title>
<style>
:root {
color-scheme: light;
--ink: #25312c;
--paper: rgba(250, 248, 240, 0.92);
--line: rgba(37, 49, 44, 0.22);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e5db;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#app {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
.panel {
position: fixed;
z-index: 10;
pointer-events: none;
background: var(--paper);
border: 1px solid var(--line);
border-radius: 12px;
box-shadow: 0 10px 30px rgba(35, 43, 38, 0.10);
backdrop-filter: blur(8px);
}
#heading {
top: 20px;
left: 20px;
padding: 15px 17px 14px;
max-width: 340px;
}
.eyebrow {
margin: 0 0 5px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
opacity: 0.62;
}
h1 {
margin: 0;
font-size: clamp(20px, 2.4vw, 30px);
line-height: 1;
letter-spacing: -0.035em;
}
#heading p {
margin: 9px 0 0;
font-size: 12px;
line-height: 1.45;
opacity: 0.72;
}
#controls {
right: 20px;
top: 20px;
padding: 10px 12px;
display: flex;
align-items: center;
gap: 12px;
pointer-events: auto;
}
#controls span {
font-size: 11px;
white-space: nowrap;
opacity: 0.7;
}
button {
border: 1px solid rgba(37, 49, 44, 0.28);
border-radius: 8px;
background: #fffdf7;
color: var(--ink);
padding: 7px 10px;
font: inherit;
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
button:hover {
background: #f0ede3;
}
#note {
left: 20px;
bottom: 20px;
padding: 10px 13px;
font-size: 11px;
line-height: 1.4;
opacity: 0.78;
}
@media (max-width: 640px) {
#heading {
top: 12px;
left: 12px;
right: 12px;
max-width: none;
}
#controls {
top: auto;
right: 12px;
bottom: 12px;
}
#note {
display: none;
}
}
</style>
</head>
<body>
<div id="app"></div>
<section id="heading" class="panel">
<p class="eyebrow">Geometric land-use study</p>
<h1>Land-use mosaic</h1>
<p>
Housing, cropland and woodland are distinguished by built form,
repeated rows and tree geometry—not color alone.
</p>
</section>
<section id="controls" class="panel">
<span>Drag to orbit · wheel to zoom</span>
<button id="reset" type="button">Reset view</button>
</section>
<div id="note" class="panel">
Common metric scale · 1 scene unit = 1 metre
</div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const app = document.getElementById("app");
// ------------------------------------------------------------------
// Renderer, scene and camera
// ------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e5db);
scene.fog = new THREE.Fog(0xe9e5db, 360, 650);
const renderer = new THREE.WebGLRenderer({ antialias: 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.domElement.setAttribute(
"aria-label",
"Interactive three-dimensional land-use mosaic"
);
app.appendChild(renderer.domElement);
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0.1, 1000);
const target = new THREE.Vector3(2, 0, 8);
const cameraState = {
azimuth: 0.48,
polar: 0.79,
zoom: 1
};
const cameraRadius = 300;
function updateCamera() {
const { azimuth, polar } = cameraState;
const horizontal = cameraRadius * Math.sin(polar);
camera.position.set(
target.x + horizontal * Math.sin(azimuth),
target.y + cameraRadius * Math.cos(polar),
target.z + horizontal * Math.cos(azimuth)
);
camera.lookAt(target);
camera.zoom = cameraState.zoom;
camera.updateProjectionMatrix();
}
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
const aspect = width / height;
// Ensure the complete mosaic remains framed, including on narrow screens.
const fitHeight = Math.max(205, 320 / aspect);
camera.left = (-fitHeight * aspect) / 2;
camera.right = (fitHeight * aspect) / 2;
camera.top = fitHeight / 2;
camera.bottom = -fitHeight / 2;
renderer.setSize(width, height);
updateCamera();
}
window.addEventListener("resize", resize);
// ------------------------------------------------------------------
// Lighting
// ------------------------------------------------------------------
scene.add(
new THREE.HemisphereLight(0xfff8e8, 0x7d8b7b, 2.0)
);
const sun = new THREE.DirectionalLight(0xfff0d2, 3.1);
sun.position.set(-90, 150, 80);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -180;
sun.shadow.camera.right = 180;
sun.shadow.camera.top = 150;
sun.shadow.camera.bottom = -150;
sun.shadow.camera.near = 10;
sun.shadow.camera.far = 420;
sun.shadow.bias = -0.00025;
sun.shadow.normalBias = 0.035;
sun.target.position.set(0, 0, 0);
scene.add(sun, sun.target);
const fill = new THREE.DirectionalLight(0xbcd2d7, 0.8);
fill.position.set(100, 80, -120);
scene.add(fill);
// ------------------------------------------------------------------
// Materials
// ------------------------------------------------------------------
const standard = (color, extra = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.88,
metalness: 0,
...extra
});
const materials = {
backdrop: standard(0xe9e5db),
slab: standard(0xd1c9b8),
housingGround: standard(0xd9d5c8),
cropGround: standard(0xb78a58),
woodlandGround: standard(0x74855d),
lawn: standard(0x9eae7b),
road: standard(0x9d9d94),
driveway: standard(0xb7afa0),
house: standard(0xe9e1cf),
roofTerracotta: standard(0x9b553e, { flatShading: true }),
roofSlate: standard(0x4e5d5b, { flatShading: true }),
roofOlive: standard(0x6e7355, { flatShading: true }),
door: standard(0x6b4939),
window: standard(0x517985, { roughness: 0.38 }),
chimney: standard(0xa55c47),
boundary: standard(0x686e65),
hedge: standard(0x667a4f, { flatShading: true }),
ridge: standard(0x8b603d),
crop: standard(0xd5b54d, { flatShading: true }),
cropLight: standard(0xe2c866, { flatShading: true }),
trunk: standard(0x73513a, { flatShading: true }),
coniferDark: standard(0x385943, { flatShading: true }),
coniferLight: standard(0x4e704f, { flatShading: true }),
broadleaf: standard(0x718754, { flatShading: true }),
broadleafLight: standard(0x8b9b61, { flatShading: true }),
shrub: standard(0x718057, { flatShading: true }),
scaleDark: standard(0x28362f),
scaleLight: standard(0xf5edda),
marker: standard(0x466b78)
};
// ------------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------------
function addBox(w, h, d, material, x, y, z, parent = scene) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBoundary(w, d, x, z, material = materials.boundary) {
return addBox(
w,
0.85,
d,
material,
x,
0.75,
z
);
}
function createGableRoof(width, height, depth) {
const profile = new THREE.Shape();
profile.moveTo(-width / 2, 0);
profile.lineTo(width / 2, 0);
profile.lineTo(0, height);
profile.closePath();
const geometry = new THREE.ExtrudeGeometry(profile, {
depth,
bevelEnabled: false,
steps: 1
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
return geometry;
}
function roundedRect(context, x, y, w, h, radius) {
const r = Math.min(radius, w / 2, h / 2);
context.beginPath();
context.moveTo(x + r, y);
context.arcTo(x + w, y, x + w, y + h, r);
context.arcTo(x + w, y + h, x, y + h, r);
context.arcTo(x, y + h, x, y, r);
context.arcTo(x, y, x + w, y, r);
context.closePath();
}
function makeLabel(text, width = 28) {
const canvas = document.createElement("canvas");
canvas.width = 768;
canvas.height = 160;
const context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
roundedRect(context, 12, 16, 744, 128, 34);
context.fillStyle = "rgba(250, 248, 240, 0.96)";
context.fill();
context.lineWidth = 7;
context.strokeStyle = "rgba(37, 49, 44, 0.35)";
context.stroke();
context.fillStyle = "#25312c";
context.font = "800 58px system-ui, sans-serif";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 384, 81);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(width, width * (160 / 768), 1);
sprite.renderOrder = 20;
return sprite;
}
function seededRandom(seed) {
return function () {
let t = seed += 0x6D2B79F5;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
// ------------------------------------------------------------------
// Ground and parcel surfaces
// One world unit is treated as one metre.
// ------------------------------------------------------------------
const backdrop = new THREE.Mesh(
new THREE.PlaneGeometry(1200, 1200),
materials.backdrop
);
backdrop.rotation.x = -Math.PI / 2;
backdrop.position.y = -4.5;
backdrop.receiveShadow = true;
scene.add(backdrop);
addBox(294, 4, 214, materials.slab, 5, -2.35, 8);
// Parcel extents:
// Housing: x [-127.5, -42.5]
// Crop: x [ -42.5, 42.5]
// Woodland:x [ 42.5, 137.5]
addBox(85, 0.8, 120, materials.housingGround, -85, 0.05, 0);
addBox(85, 0.8, 120, materials.cropGround, 0, 0.05, 0);
addBox(95, 0.8, 120, materials.woodlandGround, 90, 0.05, 0);
// Simple perimeter and two internal parcel boundaries.
addBoundary(265, 0.7, 5, -60);
addBoundary(265, 0.7, 5, 60);
addBoundary(0.7, 120, -127.5, 0);
addBoundary(0.7, 120, 137.5, 0);
addBoundary(0.7, 120, -42.5, 0);
addBoundary(0.7, 120, 42.5, 0);
// ------------------------------------------------------------------
// Housing parcel: yards, lane, driveways, cubic houses and pitched roofs
// ------------------------------------------------------------------
const housingX = [-106, -64];
for (const x of housingX) {
for (const z of [-30, 29]) {
addBox(36, 0.12, 47, materials.lawn, x, 0.51, z);
}
}
// Shared residential lane.
addBox(78, 0.16, 6.5, materials.road, -85, 0.52, 0);
// Road markings.
for (let x = -118; x <= -52; x += 10) {
addBox(4.2, 0.035, 0.28, materials.scaleLight, x, 0.62, 0);
}
// Internal lot divisions, interrupted by the lane.
addBoundary(0.45, 47, -85, -30, materials.hedge);
addBoundary(0.45, 47, -85, 29, materials.hedge);
// Driveways connect each home toward the central lane.
for (const x of housingX) {
addBox(4, 0.12, 20, materials.driveway, x, 0.61, -15);
addBox(4, 0.12, 20, materials.driveway, x, 0.61, 14);
}
function createHouse(x, z, rotation, roofMaterial, variant = 0) {
const house = new THREE.Group();
house.position.set(x, 0.58, z);
house.rotation.y = rotation;
addBox(12, 7, 10, materials.house, 0, 3.5, 0, house);
const roof = new THREE.Mesh(
createGableRoof(14, 4.5, 12),
roofMaterial
);
roof.position.y = 7;
roof.castShadow = true;
roof.receiveShadow = true;
house.add(roof);
// Front door and windows.
addBox(2.2, 3.2, 0.28, materials.door, 0, 1.6, 5.08, house);
addBox(2.4, 2.0, 0.24, materials.window, -3.5, 4.1, 5.08, house);
addBox(2.4, 2.0, 0.24, materials.window, 3.5, 4.1, 5.08, house);
// Side window.
addBox(0.24, 2.0, 2.6, materials.window, 6.08, 4.1, 0.6, house);
// Chimney and porch step.
addBox(1.5, 3.0, 1.5, materials.chimney, 3.6, 9.0, -2.0, house);
addBox(3.4, 0.35, 1.5, materials.driveway, 0, 0.18, 5.6, house);
if (variant === 1) {
// Small rear extension.
addBox(7, 4.5, 6, materials.house, -1, 2.25, -7, house);
const extensionRoof = new THREE.Mesh(
createGableRoof(8, 3, 7),
roofMaterial
);
extensionRoof.position.set(-1, 4.5, -7);
extensionRoof.castShadow = true;
house.add(extensionRoof);
}
scene.add(house);
}
createHouse(-106, -30, 0, materials.roofTerracotta, 0);
createHouse(-64, -30, 0, materials.roofSlate, 1);
createHouse(-106, 29, Math.PI, materials.roofOlive, 0);
createHouse(-64, 29, Math.PI, materials.roofTerracotta, 1);
// Low hedges establish individual lots.
addBox(30, 0.8, 0.65, materials.hedge, -106, 0.95, -52.5);
addBox(30, 0.8, 0.65, materials.hedge, -64, 0.95, -52.5);
addBox(30, 0.8, 0.65, materials.hedge, -106, 0.95, 52.5);
addBox(30, 0.8, 0.65, materials.hedge, -64, 0.95, 52.5);
// ------------------------------------------------------------------
// Crop parcel: raised parallel beds and repeated stalk geometry
// ------------------------------------------------------------------
// Central farm track.
addBox(78, 0.14, 4.2, materials.driveway, 0, 0.51, 0);
const cropPositions = [];
const rowX = [-34, -25.5, -17, -8.5, 0, 8.5, 17, 25.5, 34];
for (const x of rowX) {
for (const fieldZ of [-29, 29]) {
// Each bed is a raised solid strip.
addBox(2.5, 0.55, 49, materials.ridge, x, 0.725, fieldZ);
// Two planted lines on each bed.
for (const offset of [-1.25, 1.25]) {
for (let z = fieldZ - 21; z <= fieldZ + 21; z += 7) {
cropPositions.push({
x: x + offset,
z,
rotation: Math.random() * Math.PI,
scale: 0.86 + Math.random() * 0.24
});
}
}
}
}
const cropGeometry = new THREE.ConeGeometry(0.62, 3.4, 5);
const cropMesh = new THREE.InstancedMesh(
cropGeometry,
materials.crop,
cropPositions.length
);
cropMesh.castShadow = true;
cropMesh.receiveShadow = true;
const dummy = new THREE.Object3D();
cropPositions.forEach((plant, index) => {
dummy.position.set(plant.x, 2.7, plant.z);
dummy.rotation.set(0, plant.rotation, 0);
dummy.scale.setScalar(plant.scale);
dummy.updateMatrix();
cropMesh.setMatrixAt(index, dummy.matrix);
});
cropMesh.instanceMatrix.needsUpdate = true;
scene.add(cropMesh);
// Small scarecrow gives an additional agricultural cue.
const scarecrow = new THREE.Group();
scarecrow.position.set(18, 0.45, 29);
addBox(0.35, 6.3, 0.35, materials.trunk, 0, 3.15, 0, scarecrow);
addBox(5.2, 0.35, 0.35, materials.trunk, 0, 4.6, 0, scarecrow);
const head = new THREE.Mesh(
new THREE.SphereGeometry(0.85, 8, 6),
materials.cropLight
);
head.position.y = 5.9;
head.castShadow = true;
scarecrow.add(head);
const hat = new THREE.Mesh(
new THREE.ConeGeometry(1.35, 1.15, 8),
materials.crop
);
hat.position.y = 6.7;
hat.castShadow = true;
scarecrow.add(hat);
scene.add(scarecrow);
// ------------------------------------------------------------------
// Woodland parcel: trunks, layered conifers and faceted broadleaf crowns
// ------------------------------------------------------------------
const random = seededRandom(481516);
const treePositions = [];
while (treePositions.length < 32) {
const x = 49 + random() * 83;
const z = -54 + random() * 108;
const tooClose = treePositions.some(
(p) => Math.hypot(p.x - x, p.z - z) < 8.2
);
if (!tooClose) {
treePositions.push({ x, z });
}
}
const coniferCount = 19;
const conifers = treePositions.slice(0, coniferCount);
const broadleaf = treePositions.slice(coniferCount);
// All tree trunks.
const trunkGeometry = new THREE.CylinderGeometry(0.65, 0.9, 5, 6);
const trunkMesh = new THREE.InstancedMesh(
trunkGeometry,
materials.trunk,
treePositions.length
);
trunkMesh.castShadow = true;
trunkMesh.receiveShadow = true;
treePositions.forEach((tree, index) => {
const scale = 0.78 + random() * 0.5;
dummy.position.set(tree.x, 0.45 + 2.5 * scale, tree.z);
dummy.rotation.set(0, random() * Math.PI, 0);
dummy.scale.set(scale, scale, scale);
dummy.updateMatrix();
trunkMesh.setMatrixAt(index, dummy.matrix);
});
trunkMesh.instanceMatrix.needsUpdate = true;
scene.add(trunkMesh);
// Lower and upper conifer crowns.
const lowerConiferGeometry = new THREE.ConeGeometry(3.8, 7, 7);
const upperConiferGeometry = new THREE.ConeGeometry(2.8, 6, 7);
const lowerConifers = new THREE.InstancedMesh(
lowerConiferGeometry,
materials.coniferDark,
conifers.length
);
const upperConifers = new THREE.InstancedMesh(
upperConiferGeometry,
materials.coniferLight,
conifers.length
);
lowerConifers.castShadow = true;
lowerConifers.receiveShadow = true;
upperConifers.castShadow = true;
upperConifers.receiveShadow = true;
conifers.forEach((tree, index) => {
const scale = 0.78 + random() * 0.5;
dummy.position.set(tree.x, 0.45 + 5.8 * scale, tree.z);
dummy.rotation.set(0, random() * Math.PI, 0);
dummy.scale.set(scale, scale, scale);
dummy.updateMatrix();
lowerConifers.setMatrixAt(index, dummy.matrix);
dummy.position.set(tree.x, 0.45 + 8.7 * scale, tree.z);
dummy.rotation.set(0, random() * Math.PI, 0);
dummy.scale.set(scale, scale, scale);
dummy.updateMatrix();
upperConifers.setMatrixAt(index, dummy.matrix);
});
lowerConifers.instanceMatrix.needsUpdate = true;
upperConifers.instanceMatrix.needsUpdate = true;
scene.add(lowerConifers, upperConifers);
// Irregular low-poly broadleaf crowns.
const crownGeometry = new THREE.IcosahedronGeometry(4, 1);
const crownMesh = new THREE.InstancedMesh(
crownGeometry,
materials.broadleaf,
broadleaf.length
);
crownMesh.castShadow = true;
crownMesh.receiveShadow = true;
broadleaf.forEach((tree, index) => {
const scale = 0.82 + random() * 0.45;
dummy.position.set(tree.x, 0.45 + 7.6 * scale, tree.z);
dummy.rotation.set(random() * 0.35, random() * Math.PI, random() * 0.25);
dummy.scale.set(scale * 1.1, scale * 0.92, scale);
dummy.updateMatrix();
crownMesh.setMatrixAt(index, dummy.matrix);
});
crownMesh.instanceMatrix.needsUpdate = true;
scene.add(crownMesh);
// Understory shrubs.
const shrubGeometry = new THREE.IcosahedronGeometry(1, 0);
const shrubCount = 28;
const shrubMesh = new THREE.InstancedMesh(
shrubGeometry,
materials.shrub,
shrubCount
);
shrubMesh.castShadow = true;
shrubMesh.receiveShadow = true;
for (let i = 0; i < shrubCount; i++) {
const x = 49 + random() * 82;
const z = -53 + random() * 106;
const scale = 0.7 + random() * 1.05;
dummy.position.set(x, 0.45 + 0.8 * scale, z);
dummy.rotation.set(0, random() * Math.PI, 0);
dummy.scale.set(scale, scale * 0.7, scale);
dummy.updateMatrix();
shrubMesh.setMatrixAt(i, dummy.matrix);
}
shrubMesh.instanceMatrix.needsUpdate = true;
scene.add(shrubMesh);
// Fallen logs and stumps.
function addLog(x, z, length, rotation = 0) {
const log = new THREE.Mesh(
new THREE.CylinderGeometry(1.15, 1.3, length, 8),
materials.trunk
);
log.position.set(x, 1.55, z);
log.rotation.z = Math.PI / 2;
log.rotation.y = rotation;
log.castShadow = true;
log.receiveShadow = true;
scene.add(log);
}
addLog(78, 25, 9, 0.35);
addLog(111, -21, 7, -0.6);
const stump = new THREE.Mesh(
new THREE.CylinderGeometry(1.5, 1.8, 2.2, 8),
materials.trunk
);
stump.position.set(99, 1.55, 40);
stump.castShadow = true;
stump.receiveShadow = true;
scene.add(stump);
// ------------------------------------------------------------------
// Shared metric scale marker
// The alternating bar is exactly 50 world units = 50 metres.
// ------------------------------------------------------------------
addBox(70, 0.5, 14, materials.scaleLight, 0, -0.1, 80);
addBox(25, 0.9, 3.2, materials.scaleDark, -12.5, 0.55, 80);
addBox(25, 0.9, 3.2, materials.scaleLight, 12.5, 0.55, 80);
// End and midpoint ticks.
for (const x of [-25, 0, 25]) {
addBox(0.65, 1.2, 5.2, materials.scaleDark, x, 0.9, 80);
}
const scaleLabel = makeLabel("50 m · COMMON SCALE", 31);
scaleLabel.position.set(0, 7.5, 80);
scene.add(scaleLabel);
// A 1.8 metre figure beside the bar provides a familiar secondary cue.
const person = new THREE.Group();
person.position.set(-39, 0.15, 80);
const torso = addBox(0.75, 0.9, 0.4, materials.marker, 0, 1.1, 0, person);
torso.rotation.y = -0.25;
const personHead = new THREE.Mesh(
new THREE.SphereGeometry(0.31, 8, 6),
materials.chimney
);
personHead.position.y = 1.85;
personHead.castShadow = true;
person.add(personHead);
const legGeometry = new THREE.CylinderGeometry(0.11, 0.11, 0.75, 6);
const leftLeg = new THREE.Mesh(legGeometry, materials.scaleDark);
leftLeg.position.set(-0.2, 0.38, 0);
leftLeg.castShadow = true;
person.add(leftLeg);
const rightLeg = leftLeg.clone();
rightLeg.position.x = 0.2;
person.add(rightLeg);
scene.add(person);
// Parcel labels are supplemental; the geometry remains the primary cue.
const housingLabel = makeLabel("HOUSING", 27);
housingLabel.position.set(-85, 5.5, 68);
scene.add(housingLabel);
const cropLabel = makeLabel("CROPLAND", 29);
cropLabel.position.set(0, 5.5, 68);
scene.add(cropLabel);
const woodlandLabel = makeLabel("WOODLAND", 31);
woodlandLabel.position.set(90, 5.5, 68);
scene.add(woodlandLabel);
// ------------------------------------------------------------------
// Direct camera controls: drag to orbit, wheel to zoom
// ------------------------------------------------------------------
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.style.cursor = "grabbing";
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const deltaX = event.clientX - previousX;
const deltaY = event.clientY - previousY;
previousX = event.clientX;
previousY = event.clientY;
cameraState.azimuth -= deltaX * 0.006;
cameraState.polar = THREE.MathUtils.clamp(
cameraState.polar + deltaY * 0.005,
0.43,
1.12
);
updateCamera();
});
function stopDragging(event) {
dragging = false;
renderer.domElement.style.cursor = "grab";
if (event && renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
}
renderer.domElement.addEventListener("pointerup", stopDragging);
renderer.domElement.addEventListener("pointercancel", stopDragging);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraState.zoom = THREE.MathUtils.clamp(
cameraState.zoom * Math.exp(event.deltaY * 0.001),
0.65,
1.8
);
updateCamera();
},
{ passive: false }
);
function resetView() {
cameraState.azimuth = 0.48;
cameraState.polar = 0.79;
cameraState.zoom = 1;
updateCamera();
}
document.getElementById("reset").addEventListener("click", resetView);
renderer.domElement.addEventListener("dblclick", resetView);
// ------------------------------------------------------------------
// Start
// ------------------------------------------------------------------
resize();
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```