Prompt specification
Build or customize the Three.js 3D scene "Bukchon tiled eave and courtyard gate" 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: Bukchon tiled eave and courtyard gate
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/bukchon-tiled-eave-and-courtyard-gate-x3017
Scene Description Prompt:
Please use Three.js from cdnjs for a voxel scene based on this idea: Bukchon tiled eave and courtyard gate. Build a referenced hanok eave and gate fragment with visible roof layering. Keep the gate opening and roof support geometry readable without excessive decorative detail. Return one self-contained HTML file.
Working Three.js Starter (bukchon-tiled-eave-and-courtyard-gate-x3017):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bukchon Courtyard Gate — Voxel Study</title>
<style>
:root {
--ink: #292722;
--muted: #746d62;
--paper: #eee7da;
--line: rgba(54, 48, 40, 0.2);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e8e0d3;
color: var(--ink);
font-family: Inter, "Helvetica Neue", Arial, sans-serif;
}
#stage {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.overlay {
position: fixed;
inset: 0;
pointer-events: none;
z-index: 2;
}
.title-block {
position: absolute;
top: 30px;
left: 34px;
max-width: 390px;
}
.eyebrow {
margin: 0 0 10px;
color: var(--muted);
font-size: 10px;
font-weight: 700;
letter-spacing: 0.22em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4.2vw, 58px);
font-weight: 400;
line-height: 0.98;
letter-spacing: -0.035em;
}
.subtitle {
width: min(340px, 78vw);
margin: 16px 0 0;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
.subtitle strong {
color: var(--ink);
font-weight: 600;
}
.controls {
position: absolute;
right: 28px;
bottom: 25px;
display: flex;
align-items: center;
gap: 14px;
color: var(--muted);
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.divider {
width: 1px;
height: 18px;
background: var(--line);
}
button {
pointer-events: auto;
padding: 9px 13px;
border: 1px solid var(--line);
border-radius: 2px;
background: rgba(244, 239, 230, 0.72);
color: var(--ink);
font: inherit;
font-size: 10px;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(8px);
transition: background 160ms ease, transform 160ms ease;
}
button:hover {
background: rgba(255, 252, 246, 0.94);
transform: translateY(-1px);
}
.legend {
position: absolute;
left: 34px;
bottom: 28px;
display: flex;
gap: 18px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.legend span {
display: flex;
align-items: center;
gap: 7px;
}
.swatch {
width: 9px;
height: 9px;
background: #4a504d;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.swatch.stone {
background: #918a7c;
}
.swatch.wood {
background: #68402d;
}
#loading {
position: fixed;
inset: 0;
z-index: 5;
display: grid;
place-items: center;
background: #e8e0d3;
transition: opacity 500ms ease, visibility 500ms ease;
}
#loading.hidden {
opacity: 0;
visibility: hidden;
}
.loading-mark {
width: 130px;
height: 2px;
overflow: hidden;
background: rgba(41, 39, 34, 0.12);
}
.loading-mark::after {
content: "";
display: block;
width: 45%;
height: 100%;
background: #514a40;
animation: load 900ms ease-in-out infinite alternate;
}
@keyframes load {
from { transform: translateX(-15%); }
to { transform: translateX(140%); }
}
@media (max-width: 700px) {
.title-block {
top: 22px;
left: 20px;
}
.subtitle {
max-width: 270px;
font-size: 11px;
}
.legend {
display: none;
}
.controls {
right: 18px;
bottom: 18px;
}
.controls .hint {
display: none;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<div class="overlay">
<div class="title-block">
<p class="eyebrow">Seoul · Bukchon · Architectural Fragment</p>
<h1>Courtyard Gate</h1>
<p class="subtitle">
A restrained voxel study of a <strong>hanok haechi</strong>: open passage,
exposed timber support, and layered ceramic tile eaves.
</p>
</div>
<div class="legend" aria-hidden="true">
<span><i class="swatch"></i>Tile</span>
<span><i class="swatch stone"></i>Stone</span>
<span><i class="swatch wood"></i>Timber</span>
</div>
<div class="controls">
<span class="hint">Drag to orbit · Scroll to zoom</span>
<span class="divider"></span>
<button id="reset" type="button">Reset view</button>
</div>
</div>
<div id="loading"><div class="loading-mark"></div></div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const resetButton = document.getElementById("reset");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe8e0d3);
scene.fog = new THREE.Fog(0xe8e0d3, 24, 48);
const camera = new THREE.PerspectiveCamera(41, 1, 0.1, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
stage.appendChild(renderer.domElement);
renderer.domElement.setAttribute("aria-label", "Interactive voxel model of a Bukchon hanok courtyard gate");
const hemisphere = new THREE.HemisphereLight(0xfff4df, 0x756c60, 1.8);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff0d5, 3.2);
sun.position.set(-8, 15, 10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -16;
sun.shadow.camera.right = 16;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 40;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xc8d5d7, 0.7);
fill.position.set(11, 7, -9);
scene.add(fill);
const palette = {
plaster: new THREE.MeshStandardMaterial({ color: 0xe2d7c1, roughness: 0.95 }),
plasterLight: new THREE.MeshStandardMaterial({ color: 0xebe0cc, roughness: 0.96 }),
stone: new THREE.MeshStandardMaterial({ color: 0x918a7d, roughness: 1 }),
stoneDark: new THREE.MeshStandardMaterial({ color: 0x777267, roughness: 1 }),
timber: new THREE.MeshStandardMaterial({ color: 0x65402d, roughness: 0.84 }),
timberDark: new THREE.MeshStandardMaterial({ color: 0x3f2c23, roughness: 0.9 }),
roofDeck: new THREE.MeshStandardMaterial({ color: 0x353936, roughness: 0.94 }),
tile: new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 0.82 }),
paving: new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 0.98 }),
passage: new THREE.MeshStandardMaterial({ color: 0x77766e, roughness: 0.96 }),
accent: new THREE.MeshStandardMaterial({ color: 0x8b5540, roughness: 0.85 }),
accentGreen: new THREE.MeshStandardMaterial({ color: 0x53695c, roughness: 0.88 })
};
const geometryCache = new Map();
function getBoxGeometry(width, height, depth) {
const key = `${width}:${height}:${depth}`;
if (!geometryCache.has(key)) {
geometryCache.set(key, new THREE.BoxGeometry(width, height, depth));
}
return geometryCache.get(key);
}
function box(width, height, depth, x, y, z, material, rotationX = 0, castShadow = true) {
const mesh = new THREE.Mesh(getBoxGeometry(width, height, depth), material);
mesh.position.set(x, y, z);
mesh.rotation.x = rotationX;
mesh.castShadow = castShadow;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
function beamBetween(a, b, width, depth, material) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const geometry = new THREE.BoxGeometry(width, depth, length);
const mesh = new THREE.Mesh(geometry, material);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 0, 1),
direction.clone().normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
scene.add(mesh);
return mesh;
}
// Courtyard paving
const pavingBase = box(29, 0.18, 23, 0, -0.14, 0, palette.stoneDark, 0, false);
const paverGeometry = new THREE.BoxGeometry(0.92, 0.075, 0.92);
const paverColumns = 27;
const paverRows = 21;
const pavers = new THREE.InstancedMesh(
paverGeometry,
palette.paving,
paverColumns * paverRows
);
pavers.receiveShadow = true;
const paverMatrix = new THREE.Matrix4();
const paverColors = [0xc9bea9, 0xd1c6b1, 0xc1b6a3, 0xcfc4af, 0xbab19f];
let paverIndex = 0;
for (let row = 0; row < paverRows; row++) {
for (let column = 0; column < paverColumns; column++) {
const x = column - (paverColumns - 1) / 2;
const z = row - (paverRows - 1) / 2;
paverMatrix.makeTranslation(x, -0.025, z);
pavers.setMatrixAt(paverIndex, paverMatrix);
const color = new THREE.Color(
paverColors[(column * 7 + row * 11 + column * row) % paverColors.length]
);
pavers.setColorAt(paverIndex, color);
paverIndex++;
}
}
pavers.instanceMatrix.needsUpdate = true;
pavers.instanceColor.needsUpdate = true;
scene.add(pavers);
// Slightly darker passage makes the gate opening immediately legible.
box(4.75, 0.055, 2.65, 0, 0.035, 0, palette.passage, 0, false);
// Low courtyard walls
function buildWingWall(sign) {
const inner = 4.12;
const outer = 9.25;
const center = sign * (inner + outer) / 2;
const width = outer - inner;
const stoneCount = 7;
for (let i = 0; i < stoneCount; i++) {
const blockWidth = width / stoneCount;
const x = sign * (inner + blockWidth * (i + 0.5));
const material = i % 3 === 0 ? palette.stoneDark : palette.stone;
box(blockWidth - 0.045, 0.88, 0.94, x, 0.54, 0, material);
}
const panelCount = 4;
for (let i = 0; i < panelCount; i++) {
const panelWidth = width / panelCount;
const x = sign * (inner + panelWidth * (i + 0.5));
const material = i % 2 ? palette.plaster : palette.plasterLight;
box(panelWidth - 0.035, 2.68, 0.74, x, 2.38, 0, material);
}
box(width + 0.08, 0.15, 0.91, center, 3.8, 0, palette.timberDark);
// Low tiled coping: two restrained courses.
const tileWidth = 0.36;
const count = Math.floor(width / tileWidth);
const coping = new THREE.InstancedMesh(
new THREE.BoxGeometry(tileWidth - 0.025, 0.14, 0.62),
palette.tile,
count * 2
);
const matrix = new THREE.Matrix4();
const roofColors = [0x464b48, 0x3d423f, 0x505552];
let index = 0;
for (let row = 0; row < 2; row++) {
for (let i = 0; i < count; i++) {
const x = sign * (inner + tileWidth * (i + 0.5));
const y = 4.02 + row * 0.14;
const z = row === 0 ? -0.22 : 0.22;
matrix.makeTranslation(x, y, z);
coping.setMatrixAt(index, matrix);
coping.setColorAt(index, new THREE.Color(roofColors[(i + row * 2) % roofColors.length]));
index++;
}
}
coping.castShadow = true;
coping.receiveShadow = true;
coping.instanceMatrix.needsUpdate = true;
coping.instanceColor.needsUpdate = true;
scene.add(coping);
box(width + 0.12, 0.16, 0.16, center, 3.88, 0.56, palette.roofDeck);
box(width + 0.12, 0.16, 0.16, center, 3.88, -0.56, palette.roofDeck);
// Outer upright and a restrained central seam.
box(0.24, 3.75, 0.86, sign * outer, 2.25, 0, palette.timber);
box(0.09, 2.56, 0.79, sign * (inner + width * 0.52), 2.38, 0, palette.timberDark);
}
buildWingWall(-1);
buildWingWall(1);
// Gate structure: two post lines establish a clear passage through the roof.
const postXs = [-2.65, 2.65];
const postZs = [-1.15, 1.15];
for (const x of postXs) {
for (const z of postZs) {
box(0.86, 0.25, 0.86, x, 0.13, z, palette.stoneDark);
box(0.48, 4.48, 0.48, x, 2.49, z, palette.timber);
box(0.53, 0.10, 0.53, x, 0.29, z, palette.timberDark);
}
}
// Main lintels and the upper longitudinal frame.
for (const z of postZs) {
box(6.15, 0.36, 0.43, 0, 4.66, z, palette.timberDark);
box(6.35, 0.18, 0.28, 0, 5.55, z, palette.timber);
}
for (const x of postXs) {
box(0.28, 0.34, 2.55, x, 4.66, 0, palette.timberDark);
box(0.23, 0.50, 0.23, x, 5.14, 1.15, palette.timber);
box(0.23, 0.50, 0.23, x, 5.14, -1.15, palette.timber);
}
// Simple bracket sets: enough structure to read, without ornamental overload.
function addBracket(x, z) {
box(0.30, 0.55, 0.31, x, 4.43, z, palette.timberDark);
box(1.05, 0.17, 0.34, x, 4.88, z, palette.timber);
box(1.46, 0.15, 0.24, x, 4.18, z, palette.timberDark);
box(0.68, 0.18, 0.33, x, 3.99, z, palette.timber);
box(0.42, 0.11, 0.36, x, 4.98, z, palette.accent);
box(0.38, 0.10, 0.38, x - 0.52, 4.75, z, palette.accentGreen);
box(0.38, 0.10, 0.38, x + 0.52, 4.75, z, palette.accentGreen);
}
addBracket(-2.65, 1.15);
addBracket(2.65, 1.15);
addBracket(-2.65, -1.15);
addBracket(2.65, -1.15);
// Exposed triangular roof trusses keep the support geometry readable.
const trussXs = [-3.72, -2.65, -1.30, 0, 1.30, 2.65, 3.72];
for (const x of trussXs) {
box(0.20, 0.20, 2.50, x, 5.67, 0, palette.timberDark);
box(0.17, 2.10, 0.17, x, 6.73, 0, palette.timberDark);
beamBetween(
new THREE.Vector3(x, 5.68, 1.15),
new THREE.Vector3(x, 7.78, 0),
0.15,
0.15,
palette.timber
);
beamBetween(
new THREE.Vector3(x, 5.68, -1.15),
new THREE.Vector3(x, 7.78, 0),
0.15,
0.15,
palette.timber
);
}
// Sloped roof decks.
const roofAngle = Math.atan2(2.14, 3.40);
const roofLength = Math.hypot(2.14, 3.40);
box(8.72, 0.17, roofLength, 0, 6.85, 1.70, palette.roofDeck, roofAngle);
box(8.72, 0.17, roofLength, 0, 6.85, -1.70, palette.roofDeck, -roofAngle);
// Individually colored, stepped tile courses create the visible roof layers.
function addTileCourses(side) {
const rows = 9;
const columns = 25;
const count = rows * columns;
const tiles = new THREE.InstancedMesh(
new THREE.BoxGeometry(0.322, 0.145, 0.43),
palette.tile,
count
);
const matrix = new THREE.Matrix4();
const colors = [0x454a47, 0x3d423f, 0x505552, 0x363b39, 0x474c48];
let index = 0;
for (let row = 0; row < rows; row++) {
const y = 8.05 - row * 0.2625;
const z = side * (0.16 + row * 0.405);
for (let column = 0; column < columns; column++) {
const x = (column - (columns - 1) / 2) * 0.345;
matrix.makeTranslation(x, y, z);
tiles.setMatrixAt(index, matrix);
tiles.setColorAt(
index,
new THREE.Color(colors[(column * 3 + row * 5 + (side > 0 ? 1 : 0)) % colors.length])
);
index++;
}
}
tiles.castShadow = true;
tiles.receiveShadow = true;
tiles.instanceMatrix.needsUpdate = true;
tiles.instanceColor.needsUpdate = true;
scene.add(tiles);
}
addTileCourses(1);
addTileCourses(-1);
// Ridge cap.
for (let i = 0; i < 25; i++) {
const x = (i - 12) * 0.345;
const material = palette.tile.clone();
material.color.setHex(i % 3 === 0 ? 0x343936 : 0x454a47);
box(0.325, 0.22, 0.43, x, 8.17, 0, material);
}
// Deep front and rear fascia layers.
for (const side of [-1, 1]) {
box(8.92, 0.18, 0.18, 0, 5.82, side * 3.49, palette.roofDeck);
box(8.78, 0.12, 0.14, 0, 5.62, side * 3.38, palette.timberDark);
}
// Exposed rafters below the tile surface.
for (let x = -3.85; x <= 3.86; x += 0.64) {
beamBetween(
new THREE.Vector3(x, 7.72, -0.05),
new THREE.Vector3(x, 5.68, 3.43),
0.11,
0.15,
palette.timberDark
);
beamBetween(
new THREE.Vector3(x, 7.72, 0.05),
new THREE.Vector3(x, 5.68, -3.43),
0.11,
0.15,
palette.timberDark
);
}
box(8.75, 0.19, 0.19, 0, 5.67, 3.28, palette.timberDark);
box(8.75, 0.19, 0.19, 0, 5.67, -3.28, palette.timberDark);
box(8.80, 0.20, 0.20, 0, 7.72, 0, palette.timberDark);
// Stepped plaster gables and dark bargeboards.
for (const sign of [-1, 1]) {
const x = sign * 4.34;
for (let row = 0; row < 7; row++) {
box(
0.18,
0.29,
6.80,
x,
6.06 + row * 0.31,
0,
row % 2 ? palette.plasterLight : palette.plaster
);
}
for (const side of [-1, 1]) {
beamBetween(
new THREE.Vector3(x, 8.03, 0),
new THREE.Vector3(x, 5.88, side * 3.47),
0.17,
0.17,
palette.timberDark
);
box(0.22, 2.18, 0.22, x, 6.95, side * 3.38, palette.timberDark);
}
}
// Small end blocks clarify the roof thickness without adding ornament.
for (const sign of [-1, 1]) {
for (const side of [-1, 1]) {
box(0.35, 0.26, 0.50, sign * 4.35, 5.86, side * 3.43, palette.roofDeck);
}
}
// Custom orbit / pan / zoom controls implemented without external addons.
class CameraController {
constructor(camera, domElement) {
this.camera = camera;
this.domElement = domElement;
this.target = new THREE.Vector3(0, 2.75, 0);
this.spherical = new THREE.Spherical(17.4, 1.17, 0.66);
this.goal = this.spherical.clone();
this.pointers = new Map();
this.pinchDistance = 0;
domElement.addEventListener("pointerdown", this.onPointerDown.bind(this));
domElement.addEventListener("pointermove", this.onPointerMove.bind(this));
domElement.addEventListener("pointerup", this.onPointerUp.bind(this));
domElement.addEventListener("pointercancel", this.onPointerUp.bind(this));
domElement.addEventListener("contextmenu", (event) => event.preventDefault());
domElement.addEventListener("wheel", this.onWheel.bind(this), { passive: false });
this.updateCamera(1);
}
onPointerDown(event) {
this.domElement.setPointerCapture(event.pointerId);
this.pointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY,
button: event.button
});
if (this.pointers.size === 2) {
this.pinchDistance = this.getPinchDistance();
}
}
onPointerMove(event) {
const pointer = this.pointers.get(event.pointerId);
if (!pointer) return;
const previousX = pointer.x;
const previousY = pointer.y;
pointer.x = event.clientX;
pointer.y = event.clientY;
if (this.pointers.size === 1) {
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
if (pointer.button === 2) {
this.pan(dx, dy);
} else {
this.goal.theta -= dx * 0.006;
this.goal.phi = THREE.MathUtils.clamp(
this.goal.phi - dy * 0.005,
0.48,
1.43
);
}
} else if (this.pointers.size === 2) {
const distance = this.getPinchDistance();
if (this.pinchDistance > 0) {
this.goal.radius = THREE.MathUtils.clamp(
this.goal.radius * (this.pinchDistance / distance),
10.5,
29
);
}
this.pinchDistance = distance;
}
}
onPointerUp(event) {
this.pointers.delete(event.pointerId);
if (this.pointers.size < 2) this.pinchDistance = 0;
}
onWheel(event) {
event.preventDefault();
this.goal.radius = THREE.MathUtils.clamp(
this.goal.radius * Math.exp(event.deltaY * 0.001),
10.5,
29
);
}
pan(dx, dy) {
const distance = this.goal.radius * 0.0015;
const right = new THREE.Vector3();
const up = new THREE.Vector3();
this.camera.matrixWorld.extractBasis(right, up, new THREE.Vector3());
this.target.addScaledVector(right, -dx * distance);
this.target.addScaledVector(up, dy * distance);
this.target.x = THREE.MathUtils.clamp(this.target.x, -5, 5);
this.target.y = THREE.MathUtils.clamp(this.target.y, 1.2, 5.5);
this.target.z = THREE.MathUtils.clamp(this.target.z, -5, 5);
}
getPinchDistance() {
const values = [...this.pointers.values()];
if (values.length < 2) return 0;
return Math.hypot(values[0].x - values[1].x, values[0].y - values[1].y);
}
updateCamera(alpha = 0.09) {
this.spherical.radius = THREE.MathUtils.lerp(
this.spherical.radius,
this.goal.radius,
alpha
);
this.spherical.phi = THREE.MathUtils.lerp(
this.spherical.phi,
this.goal.phi,
alpha
);
this.spherical.theta = THREE.MathUtils.lerp(
this.spherical.theta,
this.goal.theta,
alpha
);
const position = new THREE.Vector3().setFromSpherical(this.spherical);
this.camera.position.copy(this.target).add(position);
this.camera.lookAt(this.target);
}
reset() {
this.goal.set(17.4, 1.17, 0.66);
this.target.set(0, 2.75, 0);
}
}
const controls = new CameraController(camera, renderer.domElement);
resetButton.addEventListener("click", () => controls.reset());
window.addEventListener("keydown", (event) => {
if (event.key.toLowerCase() === "r") controls.reset();
});
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
}
window.addEventListener("resize", resize);
resize();
let firstFrame = true;
renderer.setAnimationLoop(() => {
controls.updateCamera();
renderer.render(scene, camera);
if (firstFrame) {
firstFrame = false;
requestAnimationFrame(() => loading.classList.add("hidden"));
}
});
</script>
</body>
</html>
```