Prompt specification
Build or customize the Three.js 3D scene "Gamcheon hillside lane and viewpoint slice" 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: Gamcheon hillside lane and viewpoint slice
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/gamcheon-hillside-lane-and-viewpoint-slice-x2975
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts Gamcheon's hillside lanes in Busan. Build a bounded voxel scene with referenced house massing, stepped lanes, and a small public viewpoint. Use varied shapes as well as colors to express the dense terrain relationship. Voxel style.
Working Three.js Starter (gamcheon-hillside-lane-and-viewpoint-slice-x2975):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Gamcheon Hillside Lanes — Voxel Study</title>
<style>
:root {
color-scheme: light;
--ink: #243b3a;
--paper: rgba(248, 243, 228, 0.9);
--accent: #e66f5c;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce8e3;
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-card {
position: fixed;
top: 22px;
left: 22px;
z-index: 10;
max-width: min(360px, calc(100vw - 44px));
padding: 17px 19px 16px;
color: var(--ink);
background: var(--paper);
border: 1px solid rgba(36, 59, 58, 0.12);
border-radius: 3px 18px 18px 18px;
box-shadow: 0 14px 45px rgba(39, 62, 61, 0.13);
backdrop-filter: blur(12px);
pointer-events: none;
}
.eyebrow {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
color: #b65345;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 18px;
height: 3px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-size: clamp(25px, 4vw, 37px);
line-height: 0.96;
letter-spacing: -0.055em;
}
.subtitle {
margin: 10px 0 0;
color: rgba(36, 59, 58, 0.68);
font-size: 12px;
line-height: 1.5;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 7px;
margin-top: 13px;
}
.legend span {
padding: 5px 8px;
border: 1px solid rgba(36, 59, 58, 0.11);
border-radius: 999px;
color: rgba(36, 59, 58, 0.72);
font-size: 10px;
font-weight: 650;
background: rgba(255, 255, 255, 0.38);
}
.controls {
position: fixed;
right: 18px;
bottom: 18px;
z-index: 10;
padding: 10px 13px;
color: rgba(36, 59, 58, 0.74);
background: rgba(248, 243, 228, 0.76);
border: 1px solid rgba(36, 59, 58, 0.1);
border-radius: 999px;
font-size: 11px;
backdrop-filter: blur(10px);
pointer-events: none;
}
.loading {
position: fixed;
inset: 0;
z-index: 30;
display: grid;
place-items: center;
color: var(--ink);
background: #dce8e3;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
transition: opacity 400ms ease;
}
.loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 620px) {
.title-card {
top: 12px;
left: 12px;
padding: 13px 15px;
}
.subtitle {
display: none;
}
.legend {
margin-top: 8px;
}
.controls {
right: 10px;
bottom: 10px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<header class="title-card">
<div class="eyebrow">Busan · South Korea</div>
<h1>Gamcheon<br />Hillside Lanes</h1>
<p class="subtitle">
An interpretive voxel study of stacked homes, narrow stepped passages,
and a small public lookout above the Busan harbor.
</p>
<div class="legend">
<span>Stair lanes</span>
<span>Flat-roof homes</span>
<span>Public viewpoint</span>
</div>
</header>
<div class="controls">Drag to orbit · Scroll to zoom · Right-drag to pan</div>
<div class="loading" id="loading">Building the hillside…</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, lighting
// -------------------------------------------------------------------------
const container = document.querySelector("#scene");
const loading = document.querySelector("#loading");
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
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.12;
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdce8e3);
scene.fog = new THREE.Fog(0xdce8e3, 48, 82);
const camera = new THREE.PerspectiveCamera(
37,
window.innerWidth / window.innerHeight,
0.1,
160
);
const hemi = new THREE.HemisphereLight(0xf4fbff, 0x9d765d, 1.8);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff1d7, 3.1);
sun.position.set(-16, 28, 20);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 25;
sun.shadow.camera.bottom = -25;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 70;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9d9e3, 0.8);
fill.position.set(20, 12, -18);
scene.add(fill);
// -------------------------------------------------------------------------
// Shared geometry and materials
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
function getMaterial(color) {
const key = String(color);
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.86,
metalness: 0
})
);
}
return materialCache.get(key);
}
function addBox(
parent,
sx,
sy,
sz,
x,
y,
z,
color,
options = {}
) {
const material = options.material || getMaterial(color);
const mesh = new THREE.Mesh(unitBox, material);
mesh.scale.set(sx, sy, sz);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow !== false;
mesh.receiveShadow = options.receiveShadow !== false;
parent.add(mesh);
return mesh;
}
let randomSeed = 73519;
function random() {
randomSeed = (1664525 * randomSeed + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function randomFrom(list) {
return list[Math.floor(random() * list.length)];
}
// -------------------------------------------------------------------------
// Voxel terrain grid
// -------------------------------------------------------------------------
const NX = 34;
const NZ = 23;
const CELL = 0.8;
const UNIT = 0.55;
const WIDTH = NX * CELL;
const DEPTH = NZ * CELL;
const heights = Array.from({ length: NX }, () =>
Array(NZ).fill(0)
);
function terrainLevel(i, j) {
const u = (i + 0.5) / NX;
const v = (j + 0.5) / NZ;
const irregularity =
Math.sin(i * 0.71 + j * 0.37) * 0.42 +
Math.sin(j * 0.91 - i * 0.21) * 0.24;
const level =
1 +
6.4 * (1 - u) +
2.8 * (1 - v) +
irregularity;
return THREE.MathUtils.clamp(Math.round(level), 1, 10);
}
for (let i = 0; i < NX; i++) {
for (let j = 0; j < NZ; j++) {
const isWater = i >= 30 && j >= 19;
heights[i][j] = isWater ? 0 : terrainLevel(i, j);
}
}
function cellX(i) {
return (i + 0.5 - NX / 2) * CELL;
}
function cellZ(j) {
return (j + 0.5 - NZ / 2) * CELL;
}
// A zig-zag staircase rising from the harbor to the upper neighborhood.
const waypoints = [
[29, 20],
[27, 19],
[24, 16],
[22, 13],
[18, 11],
[15, 8],
[13, 5],
[9, 3],
[6, 1]
];
const pathCells = [];
const pathMap = new Map();
const segmentLengths = [];
let totalPathLength = 0;
for (let k = 0; k < waypoints.length - 1; k++) {
const a = waypoints[k];
const b = waypoints[k + 1];
const length = Math.hypot(b[0] - a[0], b[1] - a[1]);
segmentLengths.push(length);
totalPathLength += length;
}
let cumulativeLength = 0;
for (let k = 0; k < waypoints.length - 1; k++) {
const a = waypoints[k];
const b = waypoints[k + 1];
const dx = b[0] - a[0];
const dz = b[1] - a[1];
const steps = Math.max(Math.abs(dx), Math.abs(dz));
for (let s = 0; s < steps; s++) {
const t = s / steps;
const i = Math.round(a[0] + dx * t);
const j = Math.round(a[1] + dz * t);
const globalT =
(cumulativeLength + segmentLengths[k] * t) / totalPathLength;
const level = Math.round(1 + 8 * globalT);
const key = `${i},${j}`;
pathMap.set(key, level);
heights[i][j] = level;
const previous = pathCells[pathCells.length - 1];
if (!previous || previous.i !== i || previous.j !== j) {
pathCells.push({ i, j, level });
}
}
cumulativeLength += segmentLengths[k];
}
const finalWaypoint = waypoints[waypoints.length - 1];
pathMap.set(`${finalWaypoint[0]},${finalWaypoint[1]}`, 9);
heights[finalWaypoint[0]][finalWaypoint[1]] = 9;
pathCells.push({
i: finalWaypoint[0],
j: finalWaypoint[1],
level: 9
});
// Secondary cross alleys make the settlement read as a connected village.
const alleyCells = new Set();
for (let i = 1; i <= 18; i++) {
alleyCells.add(`${i},11`);
alleyCells.add(`${i},16`);
}
for (let j = 2; j <= 10; j++) {
alleyCells.add(`4,${j}`);
}
// -------------------------------------------------------------------------
// Bounded diorama base
// -------------------------------------------------------------------------
addBox(
scene,
WIDTH + 0.58,
1.12,
DEPTH + 0.58,
0,
-0.61,
0,
"#354b49"
);
addBox(
scene,
WIDTH + 0.8,
0.18,
DEPTH + 0.8,
0,
-1.2,
0,
"#263b3a"
);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(120, 120),
new THREE.MeshStandardMaterial({
color: 0xd4e0dc,
roughness: 1
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -1.31;
floor.receiveShadow = true;
scene.add(floor);
// Instanced voxels keep the terrain lightweight.
const terrainTransforms = [];
const terrainColors = [];
const topPalette = ["#d9b990", "#d0ad84", "#e0c39c", "#c9a67f"];
const sidePalette = ["#9e8068", "#aa896e", "#92755f", "#b09174"];
for (let i = 0; i < NX; i++) {
for (let j = 0; j < NZ; j++) {
const level = heights[i][j];
for (let k = 0; k < level; k++) {
terrainTransforms.push({
x: cellX(i),
y: k * UNIT + UNIT * 0.48,
z: cellZ(j),
sx: CELL * 0.975,
sy: UNIT * 0.94,
sz: CELL * 0.975
});
let color;
if (k === level - 1) {
color = randomFrom(topPalette);
} else {
color = randomFrom(sidePalette);
}
terrainColors.push(color);
}
}
}
const terrainMaterial = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.98
});
const terrain = new THREE.InstancedMesh(
unitBox,
terrainMaterial,
terrainTransforms.length
);
const matrix = new THREE.Matrix4();
const quaternion = new THREE.Quaternion();
const position = new THREE.Vector3();
const scale = new THREE.Vector3();
terrainTransforms.forEach((t, index) => {
position.set(t.x, t.y, t.z);
scale.set(t.sx, t.sy, t.sz);
matrix.compose(position, quaternion, scale);
terrain.setMatrixAt(index, matrix);
terrain.setColorAt(index, new THREE.Color(terrainColors[index]));
});
terrain.instanceMatrix.needsUpdate = true;
terrain.instanceColor.needsUpdate = true;
terrain.castShadow = true;
terrain.receiveShadow = true;
scene.add(terrain);
// -------------------------------------------------------------------------
// Lanes, stair treads, curbs and harbor
// -------------------------------------------------------------------------
const pathColor = "#b9b4a6";
const pathTopColor = "#d8d0bb";
const alleyColor = "#c7c0ad";
function addRoadCap(i, j, color) {
const y = heights[i][j] * UNIT;
return addBox(
scene,
CELL * 0.91,
0.07,
CELL * 0.91,
cellX(i),
y + 0.035,
cellZ(j),
color
);
}
for (const cell of pathCells) {
addRoadCap(cell.i, cell.j, pathColor);
}
for (const key of alleyCells) {
if (pathMap.has(key)) continue;
const [i, j] = key.split(",").map(Number);
addRoadCap(i, j, alleyColor);
}
for (let k = 0; k < pathCells.length - 1; k++) {
const current = pathCells[k];
const next = pathCells[k + 1];
const x1 = cellX(current.i);
const z1 = cellZ(current.j);
const x2 = cellX(next.i);
const z2 = cellZ(next.j);
const dx = x2 - x1;
const dz = z2 - z1;
const distance = Math.hypot(dx, dz);
const angle = -Math.atan2(dz, dx);
const tread = addBox(
scene,
distance + 0.12,
0.08,
0.34,
(x1 + x2) * 0.5,
current.level * UNIT + 0.08,
(z1 + z2) * 0.5,
pathTopColor
);
tread.rotation.y = angle;
if (next.level !== current.level) {
const rise = Math.abs(next.level - current.level) * UNIT;
const lowerLevel = Math.min(current.level, next.level);
const riser = addBox(
scene,
0.14,
rise,
0.42,
(x1 + x2) * 0.5,
lowerLevel * UNIT + rise * 0.5,
(z1 + z2) * 0.5,
"#8e8b82"
);
riser.rotation.y = angle;
}
}
// Small harbor inset at the low, seaward corner.
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x4eaaa8,
roughness: 0.28,
metalness: 0.08,
transparent: true,
opacity: 0.9
});
for (let i = 30; i < NX; i++) {
for (let j = 19; j < NZ; j++) {
addBox(
scene,
CELL * 0.99,
0.08,
CELL * 0.99,
cellX(i),
0.035,
cellZ(j),
0x4eaaa8,
{ material: waterMaterial, castShadow: false }
);
if (random() > 0.55) {
addBox(
scene,
0.34,
0.018,
0.055,
cellX(i) + random() * 0.22 - 0.11,
0.087,
cellZ(j) + random() * 0.25 - 0.125,
"#bde4dc",
{ castShadow: false }
);
}
}
}
// Concrete quay edges.
for (let j = 19; j < NZ; j++) {
addBox(
scene,
0.28,
0.43,
CELL * 0.94,
10.22,
0.18,
cellZ(j),
"#aaa89b"
);
}
for (let i = 30; i < NX; i++) {
addBox(
scene,
CELL * 0.94,
0.43,
0.28,
cellX(i),
0.18,
5.86,
"#aaa89b"
);
}
function createBoat(x, z, hullColor, scale = 1) {
const boat = new THREE.Group();
boat.position.set(x, 0.12, z);
boat.scale.setScalar(scale);
addBox(boat, 0.92, 0.2, 0.42, 0, 0, 0, hullColor);
addBox(boat, 0.44, 0.28, 0.3, -0.08, 0.22, 0, "#f5ead3");
addBox(boat, 0.05, 0.72, 0.05, 0.18, 0.52, 0, "#536665");
addBox(boat, 0.24, 0.15, 0.04, 0.27, 0.75, 0, "#e96f5e");
scene.add(boat);
return boat;
}
const boatA = createBoat(11.55, 7.25, "#f4e9d3", 1);
const boatB = createBoat(12.2, 6.55, "#e97c63", 0.72);
// -------------------------------------------------------------------------
// Dense, varied house massing
// -------------------------------------------------------------------------
const palettes = [
["#ef8c78", "#f5ae77", "#f8dfb7"],
["#75beb5", "#e6d6a4", "#3e7472"],
["#efc957", "#f7e5ad", "#a66f4b"],
["#91b5ce", "#e9dfca", "#536f82"],
["#d39ab8", "#f1d5dc", "#805773"],
["#98bc76", "#e9dfbf", "#587151"],
["#df865f", "#f5c894", "#825445"],
["#b9a7cd", "#ebe2ef", "#675a7d"]
];
const windowMaterial = new THREE.MeshStandardMaterial({
color: 0x35545c,
roughness: 0.28,
metalness: 0.12
});
const doorMaterial = new THREE.MeshStandardMaterial({
color: 0x47645e,
roughness: 0.65
});
const houseSpecs = [
[2, 4, 3, 2, 2],
[6, 3, 2, 2, 3],
[9, 5, 2, 2, 2],
[2, 8, 3, 2, 3],
[6, 8, 2, 2, 2],
[11, 7, 2, 2, 3],
[14, 9, 3, 2, 2],
[19, 7, 2, 3, 3],
[23, 6, 3, 2, 2],
[28, 5, 2, 3, 3],
[1, 12, 2, 2, 2],
[5, 13, 3, 2, 3],
[9, 12, 2, 2, 2],
[13, 12, 3, 2, 3],
[17, 13, 2, 2, 2],
[21, 9, 3, 2, 2],
[26, 11, 2, 2, 3],
[30, 10, 3, 2, 2],
[1, 17, 3, 2, 3],
[5, 18, 2, 2, 2],
[9, 17, 3, 2, 2],
[13, 18, 2, 2, 3],
[17, 18, 3, 2, 2],
[22, 17, 3, 2, 3],
[26, 19, 2, 2, 2],
[30, 17, 2, 2, 2]
];
function plotOverlapsPath(i, j, w, d) {
for (let x = i; x < i + w; x++) {
for (let z = j; z < j + d; z++) {
if (pathMap.has(`${x},${z}`)) return true;
}
}
return false;
}
function addWindow(parent, sx, sy, sz, x, y, z) {
addBox(
parent,
sx,
sy,
sz,
x,
y,
z,
0x35545c,
{ material: windowMaterial, castShadow: false }
);
}
function createHouse(spec, index) {
const [i, j, plotW, plotD, floors] = spec;
if (plotOverlapsPath(i, j, plotW, plotD)) return;
const palette = palettes[index % palettes.length];
const group = new THREE.Group();
const levels = [];
for (let x = i; x < i + plotW; x++) {
for (let z = j; z < j + plotD; z++) {
levels.push(heights[x][z]);
}
}
const minLevel = Math.min(...levels);
const maxLevel = Math.max(...levels);
const cx = (i + plotW / 2 - NX / 2) * CELL;
const cz = (j + plotD / 2 - NZ / 2) * CELL;
const foundationBottom = minLevel * UNIT - 0.04;
const foundationTop = maxLevel * UNIT + 0.12;
const fullW = plotW * CELL * 0.82;
const fullD = plotD * CELL * 0.82;
addBox(
group,
plotW * CELL * 0.88,
foundationTop - foundationBottom,
plotD * CELL * 0.88,
cx,
(foundationBottom + foundationTop) * 0.5,
cz,
"#ad9782"
);
let currentY = foundationTop;
let topWidth = fullW;
let topDepth = fullD;
let topX = cx;
let topZ = cz;
let topFloorY = currentY;
const side = index % 2 === 0 ? -1 : 1;
for (let floor = 0; floor < floors; floor++) {
let fw = fullW;
let fd = fullD;
let fx = cx;
let fz = cz;
let floorHeight = 1.02;
if (floor === 1 && index % 3 === 0) {
fw *= 0.9;
fd *= 0.94;
fx += side * fullW * 0.035;
}
if (floor >= 2) {
fw *= 0.67;
fd *= 0.72;
fx += side * fullW * 0.14;
fz -= fullD * 0.06;
floorHeight = 0.96;
}
const wallColor = palette[floor % palette.length];
addBox(
group,
fw,
floorHeight,
fd,
fx,
currentY + floorHeight * 0.5,
fz,
wallColor
);
const windowY = currentY + floorHeight * 0.56;
const horizontalCount = fw > 2.25 ? 2 : 1;
for (let n = 0; n < horizontalCount; n++) {
const wx =
fx +
(horizontalCount === 1 ? 0 : (n - 0.5) * fw * 0.48);
addWindow(group, 0.34, 0.43, 0.045, wx, windowY, fz + fd / 2 + 0.026);
addWindow(group, 0.34, 0.43, 0.045, wx, windowY, fz - fd / 2 - 0.026);
}
const sideCount = fd > 2.05 ? 2 : 1;
for (let n = 0; n < sideCount; n++) {
const wz =
fz +
(sideCount === 1 ? 0 : (n - 0.5) * fd * 0.48);
addWindow(group, 0.045, 0.43, 0.3, fx + fw / 2 + 0.026, windowY, wz);
addWindow(group, 0.045, 0.43, 0.3, fx - fw / 2 - 0.026, windowY, wz);
}
// Small projecting balconies break up the facade.
if (floor > 0 && index % 3 === 1) {
const balconyY = currentY + 0.02;
const balconyZ = fz + fd / 2 + 0.2;
const balconyW = Math.min(1.1, fw * 0.65);
addBox(
group,
balconyW,
0.09,
0.46,
fx,
balconyY,
balconyZ,
"#e9dfc8"
);
addBox(
group,
balconyW,
0.055,
0.055,
fx,
balconyY + 0.36,
balconyZ + 0.19,
"#536b68"
);
for (let p = -1; p <= 1; p++) {
addBox(
group,
0.045,
0.36,
0.045,
fx + p * balconyW * 0.45,
balconyY + 0.18,
balconyZ + 0.19,
"#536b68"
);
}
}
currentY += floorHeight;
topFloorY = currentY;
topWidth = fw;
topDepth = fd;
topX = fx;
topZ = fz;
}
// Side annex produces an L-shaped silhouette.
if (index % 4 === 1) {
const annexW = fullW * 0.3;
const annexD = fullD * 0.58;
addBox(
group,
annexW,
0.94,
annexD,
cx + side * (fullW * 0.5 - annexW * 0.35),
foundationTop + 0.47,
cz - fullD * 0.15,
palette[1]
);
}
// Flat roof, penthouse, tanks, vents and antennas.
addBox(
group,
topWidth + 0.18,
0.15,
topDepth + 0.18,
topX,
topFloorY + 0.075,
topZ,
index % 2 ? "#5c6e6c" : "#765f57"
);
addBox(
group,
Math.min(0.7, topWidth * 0.42),
0.52,
Math.min(0.68, topDepth * 0.45),
topX - topWidth * 0.16,
topFloorY + 0.41,
topZ + topDepth * 0.1,
palette[0]
);
addBox(
group,
0.42,
0.42,
0.42,
topX + topWidth * 0.2,
topFloorY + 0.36,
topZ - topDepth * 0.15,
"#d6d1bd"
);
if (index % 3 !== 0) {
addBox(
group,
0.045,
0.78,
0.045,
topX + topWidth * 0.27,
topFloorY + 0.54,
topZ,
"#455957"
);
addBox(
group,
0.36,
0.035,
0.035,
topX + topWidth * 0.27,
topFloorY + 0.77,
topZ,
"#455957"
);
}
// Front door and little voxel steps.
const doorX = topX + topWidth * 0.18;
const doorZ = topZ + fullD / 2 + 0.035;
addBox(
group,
0.43,
0.68,
0.055,
doorX,
foundationTop + 0.35,
doorZ,
0x47645e,
{ material: doorMaterial }
);
for (let step = 0; step < 3; step++) {
addBox(
group,
0.58,
0.1,
0.22 + step * 0.06,
doorX,
foundationTop - 0.04 + step * 0.1,
doorZ + 0.12 + step * 0.06,
"#c7bda8"
);
}
scene.add(group);
}
houseSpecs.forEach(createHouse);
// -------------------------------------------------------------------------
// Street lamps along the staircase
// -------------------------------------------------------------------------
const lampMaterial = new THREE.MeshStandardMaterial({
color: 0xffe3a0,
emissive: 0xe4a94f,
emissiveIntensity: 0.6,
roughness: 0.45
});
for (let k = 2; k < pathCells.length - 1; k += 5) {
const cell = pathCells[k];
const x = cellX(cell.i) + 0.52;
const z = cellZ(cell.j) + 0.18;
const ground = cell.level * UNIT;
addBox(scene, 0.09, 1.6, 0.09, x, ground + 0.8, z, "#526662");
addBox(
scene,
0.25,
0.22,
0.25,
x,
ground + 1.64,
z,
0xffe3a0,
{ material: lampMaterial }
);
}
// -------------------------------------------------------------------------
// Small public viewpoint at the upper edge of the village
// -------------------------------------------------------------------------
const viewpointGroup = new THREE.Group();
scene.add(viewpointGroup);
const deckLevels = [];
for (let i = 2; i <= 5; i++) {
for (let j = 0; j <= 2; j++) {
deckLevels.push(heights[i][j]);
}
}
const deckLevel = Math.max(...deckLevels);
const deckY = deckLevel * UNIT;
const deckX = (3.5 - NX / 2) * CELL;
const deckZ = (1.5 - NZ / 2) * CELL;
addBox(
viewpointGroup,
4.5,
0.26,
2.35,
deckX,
deckY + 0.13,
deckZ,
"#d8c7a4"
);
// Support posts.
for (const dx of [-1.95, 1.95]) {
for (const dz of [-0.9, 0.9]) {
addBox(
viewpointGroup,
0.16,
1.15,
0.16,
deckX + dx,
deckY - 0.48,
deckZ + dz,
"#8e7967"
);
}
}
// Front and side railings.
const railY = deckY + 0.85;
for (let x = -2.05; x <= 2.1; x += 0.68) {
addBox(
viewpointGroup,
0.075,
0.72,
0.075,
deckX + x,
deckY + 0.6,
deckZ + 1.04,
"#f0e5ce"
);
}
addBox(
viewpointGroup,
4.25,
0.07,
0.07,
deckX,
railY,
deckZ + 1.04,
"#f0e5ce"
);
for (let z = -0.95; z <= 1.0; z += 0.65) {
addBox(
viewpointGroup,
0.075,
0.72,
0.075,
deckX + 2.08,
deckY + 0.6,
deckZ + z,
"#f0e5ce"
);
}
addBox(
viewpointGroup,
0.07,
0.07,
2.12,
deckX + 2.08,
railY,
deckZ,
"#f0e5ce"
);
// Bench.
addBox(
viewpointGroup,
1.35,
0.13,
0.42,
deckX - 0.8,
deckY + 0.58,
deckZ - 0.63,
"#a9684c"
);
addBox(
viewpointGroup,
1.35,
0.45,
0.1,
deckX - 0.8,
deckY + 0.83,
deckZ - 0.84,
"#a9684c"
);
for (const dx of [-0.48, 0.48]) {
addBox(
viewpointGroup,
0.12,
0.4,
0.32,
deckX - 0.8 + dx,
deckY + 0.34,
deckZ - 0.63,
"#53635f"
);
}
function addPerson(x, y, z, shirt, facing = 1) {
const person = new THREE.Group();
addBox(person, 0.11, 0.27, 0.12, -0.08, 0.14, 0, "#405457");
addBox(person, 0.11, 0.27, 0.12, 0.08, 0.14, 0, "#405457");
addBox(person, 0.3, 0.38, 0.18, 0, 0.46, 0, shirt);
addBox(person, 0.25, 0.25, 0.23, 0, 0.77, 0, "#d9a47b");
person.position.set(x, y, z);
person.rotation.y = facing;
scene.add(person);
}
addPerson(
deckX + 0.72,
deckY + 0.27,
deckZ + 0.45,
"#e87563",
-0.4
);
addPerson(
deckX + 0.23,
deckY + 0.27,
deckZ + 0.55,
"#3f8e92",
0.2
);
// A simple block-built viewing scope.
addBox(
viewpointGroup,
0.1,
0.62,
0.1,
deckX + 1.63,
deckY + 0.58,
deckZ + 0.38,
"#526662"
);
addBox(
viewpointGroup,
0.38,
0.18,
0.22,
deckX + 1.63,
deckY + 0.94,
deckZ + 0.38,
"#314b4d"
);
// Planters.
for (const dx of [-1.72, 1.72]) {
addBox(
viewpointGroup,
0.42,
0.25,
0.42,
deckX + dx,
deckY + 0.39,
deckZ + 0.54,
"#b66f55"
);
addBox(
viewpointGroup,
0.33,
0.28,
0.33,
deckX + dx,
deckY + 0.64,
deckZ + 0.54,
"#71945f"
);
}
// -------------------------------------------------------------------------
// Embedded graphic labels
// -------------------------------------------------------------------------
function makeLabelTexture({
title,
subtitle,
background = "#263b3a",
foreground = "#f5ead2",
accent = "#e56d59"
}) {
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = 256;
const context = canvas.getContext("2d");
context.fillStyle = background;
context.fillRect(0, 0, canvas.width, canvas.height);
context.fillStyle = accent;
context.fillRect(35, 35, 13, 186);
context.textBaseline = "middle";
context.fillStyle = foreground;
context.font = "800 78px system-ui, sans-serif";
context.fillText(title, 73, 102);
context.fillStyle = "rgba(245, 234, 210, 0.66)";
context.font = "600 29px system-ui, sans-serif";
context.fillText(subtitle, 77, 178);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
const titleTexture = makeLabelTexture({
title: "GAMCHEON · BUSAN",
subtitle: "HILLSIDE LANES / VOXEL MASSING STUDY"
});
const titlePanel = new THREE.Mesh(
new THREE.PlaneGeometry(8.7, 0.78),
new THREE.MeshBasicMaterial({ map: titleTexture })
);
titlePanel.position.set(0, -0.56, DEPTH / 2 + 0.302);
scene.add(titlePanel);
const viewpointTexture = makeLabelTexture({
title: "VIEWPOINT",
subtitle: "GAMCHEON",
background: "#f0e5ce",
foreground: "#314b4a",
accent: "#e56d59"
});
const viewpointPanel = new THREE.Mesh(
new THREE.PlaneGeometry(1.15, 0.29),
new THREE.MeshBasicMaterial({
map: viewpointTexture,
side: THREE.DoubleSide
})
);
viewpointPanel.position.set(deckX - 0.85, deckY + 1.08, deckZ + 1.01);
scene.add(viewpointPanel);
for (const dx of [-0.43, 0.43]) {
addBox(
viewpointGroup,
0.055,
0.72,
0.055,
deckX - 0.85 + dx,
deckY + 0.64,
deckZ + 1.01,
"#536762"
);
}
// -------------------------------------------------------------------------
// Custom camera controls — no external control addons
// -------------------------------------------------------------------------
const target = new THREE.Vector3(0, 2.3, 0);
let yaw = 0.64;
let pitch = 0.55;
let radius = 41;
function updateCamera() {
const horizontal = Math.cos(pitch) * radius;
camera.position.set(
target.x + Math.sin(yaw) * horizontal,
target.y + Math.sin(pitch) * radius,
target.z + Math.cos(yaw) * horizontal
);
camera.lookAt(target);
}
updateCamera();
const pointers = new Map();
let pinchDistance = 0;
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
button: event.button
});
if (pointers.size === 2) {
const values = [...pointers.values()];
pinchDistance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
button: previous.button
});
if (pointers.size === 2) {
const values = [...pointers.values()];
const distance = Math.hypot(
values[0].x - values[1].x,
values[0].y - values[1].y
);
if (pinchDistance > 0) {
radius = THREE.MathUtils.clamp(
radius * (pinchDistance / Math.max(distance, 1)),
24,
61
);
pinchDistance = distance;
updateCamera();
}
return;
}
if (previous.button === 2) {
const rightX = Math.cos(yaw);
const rightZ = -Math.sin(yaw);
const panScale = radius * 0.00135;
target.x += rightX * -dx * panScale;
target.z += rightZ * -dx * panScale;
target.y = THREE.MathUtils.clamp(
target.y + dy * panScale,
0.5,
8
);
} else {
yaw -= dx * 0.0052;
pitch = THREE.MathUtils.clamp(
pitch + dy * 0.0042,
0.22,
1.08
);
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
if (pointers.size < 2) {
pinchDistance = 0;
}
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
radius = THREE.MathUtils.clamp(
radius * Math.exp(event.deltaY * 0.001),
24,
61
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
});
// -------------------------------------------------------------------------
// Render loop
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
function animate() {
const elapsed = clock.getElapsedTime();
boatA.position.y = 0.12 + Math.sin(elapsed * 0.9) * 0.025;
boatA.rotation.z = Math.sin(elapsed * 0.75) * 0.012;
boatB.position.y = 0.12 + Math.sin(elapsed * 1.05 + 1.2) * 0.022;
boatB.rotation.z = Math.sin(elapsed * 0.8 + 1.2) * 0.015;
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
renderer.render(scene, camera);
loading.classList.add("hidden");
window.setTimeout(() => loading.remove(), 500);
animate();
</script>
</body>
</html>
```