Prompt specification
Build or customize the Three.js 3D scene "Shirakawa canal rail and wooden facade bay" 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: Shirakawa canal rail and wooden facade bay
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/shirakawa-canal-rail-and-wooden-facade-bay-x3001
Scene Description Prompt:
Create a single self-contained HTML file using Three.js from cdnjs that shows Gion's Shirakawa canal in Kyoto. Build a referenced Kyoto canal-edge fragment with low railing and timber facade bay. Show the separate boundaries of water, walking path, and building threshold. Voxel style.
Working Three.js Starter (shirakawa-canal-rail-and-wooden-facade-bay-x3001):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gion’s Shirakawa Canal — Voxel Kyoto</title>
<style>
:root {
--ink: #172c30;
--paper: #f5f1e7;
--muted: #6c7773;
--water: #5e9da8;
--path: #b8a98d;
--threshold: #493129;
--line: rgba(23, 44, 48, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #c7d8d6;
color: var(--ink);
font-family: Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active {
cursor: grabbing;
}
.panel {
position: fixed;
z-index: 10;
background: rgba(247, 244, 235, 0.91);
border: 1px solid rgba(255, 255, 255, 0.7);
box-shadow: 0 12px 35px rgba(31, 49, 48, 0.12);
backdrop-filter: blur(12px);
}
#title {
top: 22px;
left: 22px;
width: min(390px, calc(100vw - 44px));
padding: 18px 20px 17px;
border-radius: 4px;
}
.eyebrow {
margin: 0 0 8px;
color: #9a3e32;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.23em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Yu Mincho", "Hiragino Mincho ProN", serif;
font-size: clamp(25px, 3vw, 38px);
font-weight: 500;
line-height: 1.02;
letter-spacing: -0.025em;
}
.subtitle {
margin: 10px 0 0;
max-width: 340px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
#legend {
top: 22px;
right: 22px;
width: 245px;
padding: 15px 16px 13px;
border-radius: 4px;
}
.legend-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 11px;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.switch {
position: relative;
width: 31px;
height: 17px;
}
.switch input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.switch span {
position: absolute;
inset: 0;
border-radius: 20px;
background: #bcc4bf;
transition: 0.2s ease;
}
.switch span::after {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 11px;
height: 11px;
border-radius: 50%;
background: white;
transition: 0.2s ease;
}
.switch input:checked + span {
background: #527c7a;
}
.switch input:checked + span::after {
transform: translateX(14px);
}
.legend-row {
display: grid;
grid-template-columns: 13px 1fr auto;
align-items: center;
gap: 9px;
min-height: 27px;
border-top: 1px solid var(--line);
font-size: 11px;
}
.legend-row:first-of-type {
border-top: 0;
}
.swatch {
width: 10px;
height: 10px;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.13);
}
.legend-row small {
color: #8a938e;
font-size: 9px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
#navigation {
left: 22px;
bottom: 22px;
width: min(410px, calc(100vw - 44px));
padding: 13px 15px;
border-radius: 4px;
}
.view-buttons {
display: flex;
gap: 7px;
margin-bottom: 10px;
}
button {
appearance: none;
border: 1px solid rgba(23, 44, 48, 0.18);
border-radius: 2px;
padding: 8px 10px;
background: transparent;
color: var(--ink);
cursor: pointer;
font: inherit;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.08em;
text-transform: uppercase;
transition:
background 0.18s ease,
color 0.18s ease,
transform 0.18s ease;
}
button:hover {
background: var(--ink);
color: #fffaf0;
transform: translateY(-1px);
}
.hint {
display: flex;
align-items: center;
gap: 9px;
color: var(--muted);
font-size: 10px;
line-height: 1.45;
}
.mouse-icon {
position: relative;
flex: 0 0 15px;
width: 15px;
height: 21px;
border: 1.5px solid #71807a;
border-radius: 9px;
}
.mouse-icon::after {
content: "";
position: absolute;
top: 3px;
left: 5px;
width: 2px;
height: 5px;
border-radius: 2px;
background: #71807a;
}
#marker-layer {
position: fixed;
inset: 0;
z-index: 5;
overflow: hidden;
pointer-events: none;
transition: opacity 0.2s ease;
}
#marker-layer.hidden {
opacity: 0;
}
.marker {
--dx: 0px;
--dy: 0px;
position: absolute;
display: flex;
align-items: center;
gap: 7px;
white-space: nowrap;
transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)));
transition: opacity 0.15s ease;
}
.marker.offscreen {
opacity: 0;
}
.marker-dot {
width: 9px;
height: 9px;
border: 2px solid rgba(255, 255, 255, 0.9);
border-radius: 50%;
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}
.marker-label {
padding: 6px 9px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 2px;
background: rgba(248, 245, 235, 0.91);
box-shadow: 0 5px 16px rgba(26, 44, 42, 0.15);
color: var(--ink);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.marker-label span {
display: block;
margin-top: 2px;
color: #7c8580;
font-size: 8px;
font-weight: 600;
letter-spacing: 0.04em;
text-transform: none;
}
#credit {
position: fixed;
right: 22px;
bottom: 20px;
z-index: 5;
color: rgba(23, 44, 48, 0.62);
font-size: 9px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}
@media (max-width: 760px) {
#title {
top: 12px;
left: 12px;
width: calc(100vw - 24px);
padding: 14px 16px;
}
.subtitle {
display: none;
}
#legend {
top: 116px;
right: 12px;
width: 204px;
padding: 11px 13px;
}
#navigation {
left: 12px;
bottom: 12px;
width: calc(100vw - 24px);
}
#credit {
display: none;
}
.view-buttons {
flex-wrap: wrap;
}
button {
padding: 7px 8px;
font-size: 9px;
}
.marker-label {
padding: 5px 7px;
font-size: 8px;
}
.marker-label span {
display: none;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="title" class="panel">
<p class="eyebrow">Kyoto · Gion</p>
<h1>Shirakawa Canal</h1>
<p class="subtitle">
A voxel canal-edge fragment: water, stone walking path, and the raised timber
threshold of a traditional machiya facade.
</p>
</section>
<aside id="legend" class="panel">
<div class="legend-heading">
Spatial boundaries
<label class="switch" aria-label="Toggle boundary labels">
<input id="marker-toggle" type="checkbox" checked />
<span></span>
</label>
</div>
<div class="legend-row">
<i class="swatch" style="background:#5e9da8"></i>
<span>Canal water</span>
<small>Water</small>
</div>
<div class="legend-row">
<i class="swatch" style="background:#b8a98d"></i>
<span>Walking path</span>
<small>Path</small>
</div>
<div class="legend-row">
<i class="swatch" style="background:#493129"></i>
<span>Building threshold</span>
<small>Raised</small>
</div>
</aside>
<section id="navigation" class="panel">
<div class="view-buttons">
<button type="button" data-view="overview">Canal overview</button>
<button type="button" data-view="path">Path edge</button>
<button type="button" data-view="facade">Timber bay</button>
</div>
<div class="hint">
<i class="mouse-icon"></i>
<span>Drag to orbit · scroll to zoom · arrow keys to rotate · R to reset</span>
</div>
</section>
<div id="marker-layer">
<div class="marker" id="marker-water">
<i class="marker-dot" style="background:#5e9da8"></i>
<div class="marker-label">Canal water<span>Stone-lined channel</span></div>
</div>
<div class="marker" id="marker-path">
<i class="marker-dot" style="background:#b8a98d"></i>
<div class="marker-label">Walking path<span>Narrow pedestrian edge</span></div>
</div>
<div class="marker" id="marker-threshold">
<i class="marker-dot" style="background:#493129"></i>
<div class="marker-label">Building threshold<span>Raised timber datum</span></div>
</div>
</div>
<div id="credit">Voxel Kyoto · Shirakawa Canal</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Renderer and scene
// -------------------------------------------------------------------------
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xc7d8d6);
scene.fog = new THREE.Fog(0xc7d8d6, 24, 58);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
120
);
const renderer = new THREE.WebGLRenderer({ antialias: false, powerPreference: "high-performance" });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.6));
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;
document.querySelector("#scene").appendChild(renderer.domElement);
const hemisphere = new THREE.HemisphereLight(0xe8f4ef, 0x756958, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff1d3, 3.25);
sun.position.set(-11, 18, -10);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -25;
sun.shadow.camera.right = 25;
sun.shadow.camera.top = 20;
sun.shadow.camera.bottom = -20;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 55;
sun.shadow.bias = -0.0007;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight(0x9dc9cf, 0.85);
fill.position.set(12, 8, 8);
scene.add(fill);
// -------------------------------------------------------------------------
// Small voxel construction helpers
// -------------------------------------------------------------------------
const materialCache = new Map();
function material(color, options = {}) {
const key = `${color}-${options.roughness ?? 0.9}-${options.metalness ?? 0}-${options.emissive ?? 0}-${options.emissiveIntensity ?? 0}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: options.roughness ?? 0.9,
metalness: options.metalness ?? 0,
emissive: options.emissive ?? 0x000000,
emissiveIntensity: options.emissiveIntensity ?? 0
})
);
}
return materialCache.get(key);
}
function box(w, h, d, color, x, y, z, options = {}) {
const geometry = new THREE.BoxGeometry(w, h, d);
const mesh = new THREE.Mesh(
geometry,
options.material || material(color, options)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
if (options.rotationY) mesh.rotation.y = options.rotationY;
if (options.rotationZ) mesh.rotation.z = options.rotationZ;
if (options.rotationX) mesh.rotation.x = options.rotationX;
scene.add(mesh);
return mesh;
}
function groupBox(group, w, h, d, color, x, y, z, options = {}) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(w, h, d),
options.material || material(color, options)
);
mesh.position.set(x, y, z);
mesh.castShadow = options.castShadow ?? true;
mesh.receiveShadow = options.receiveShadow ?? true;
group.add(mesh);
return mesh;
}
let seed = 4817;
function random() {
seed = (seed * 16807) % 2147483647;
return (seed - 1) / 2147483646;
}
function pick(array) {
return array[Math.floor(random() * array.length)];
}
// -------------------------------------------------------------------------
// Ground, canal, and separate edge bands
// -------------------------------------------------------------------------
box(90, 0.3, 70, 0x9d9b8e, 0, -0.7, 5, { castShadow: false });
box(33, 0.6, 4.75, 0x536c70, 0, -0.42, 0, { castShadow: false });
// Canal water is a separate, low horizontal surface.
const waterMaterial = new THREE.MeshStandardMaterial({
color: 0x5e9da8,
roughness: 0.26,
metalness: 0.06
});
box(30.8, 0.14, 4.08, 0xffffff, 0, -0.07, 0, {
material: waterMaterial,
castShadow: false,
receiveShadow: true
});
// Darker submerged channel floor gives the water depth.
box(30.6, 0.035, 3.88, 0x3c747f, 0, -0.15, 0, {
castShadow: false
});
// Stone coping on both sides of the water.
const copingColors = [0x8f9187, 0x9a9a8e, 0x858a82, 0xa4a093];
for (let x = -15; x < 15; x += 0.72) {
const width = 0.64 + random() * 0.08;
box(
width,
0.32,
0.42,
pick(copingColors),
x + 0.36,
0.02,
-2.22,
{ rotationY: (random() - 0.5) * 0.025 }
);
box(
width,
0.32,
0.42,
pick(copingColors),
x + 0.36,
0.02,
2.22,
{ rotationY: (random() - 0.5) * 0.025 }
);
}
// Near-side stone promenade.
for (let x = -15; x < 15; x += 1.05) {
box(
0.94,
0.16,
1.58,
pick([0x858983, 0x92938b, 0x797e79, 0x9b9c92]),
x + 0.5,
0.02,
-3.22
);
}
// The walking path is a distinct field of pale rectangular paving stones.
const pathColors = [0xb8a98d, 0xc1b398, 0xada087, 0xc7b99e, 0xb2a58b];
const pathRows = [2.86, 3.58, 4.3];
for (let x = -15; x < 15; x += 1.02) {
pathRows.forEach((z, row) => {
box(
0.92,
0.17,
0.64,
pick(pathColors),
x + 0.5 + (random() - 0.5) * 0.035,
0.105 + (random() - 0.5) * 0.015,
z + (random() - 0.5) * 0.025
);
});
}
// A continuous dark timber datum separates path from buildings.
box(30.4, 0.22, 0.52, 0x493129, 0, 0.24, 5.16, {
roughness: 0.96
});
// Individual threshold boards make this boundary legible as timber.
for (let x = -15; x < 15; x += 0.48) {
box(
0.42,
0.025,
0.47,
pick([0x3c2822, 0x4a3027, 0x56392d]),
x + 0.24,
0.362,
5.16,
{ castShadow: false }
);
}
// -------------------------------------------------------------------------
// Low timber canal railing
// -------------------------------------------------------------------------
const railingGroup = new THREE.Group();
scene.add(railingGroup);
for (let x = -14.4; x <= 14.4; x += 1.45) {
groupBox(railingGroup, 0.34, 0.13, 0.34, 0x8d8e83, x, 0.21, 2.34);
groupBox(railingGroup, 0.14, 0.66, 0.14, 0x49352b, x, 0.56, 2.34);
groupBox(railingGroup, 0.2, 0.08, 0.2, 0x2f2824, x, 0.9, 2.34);
}
groupBox(railingGroup, 29.4, 0.105, 0.13, 0x574034, 0, 0.53, 2.34);
groupBox(railingGroup, 29.4, 0.105, 0.13, 0x49352b, 0, 0.78, 2.34);
// -------------------------------------------------------------------------
// Central machiya timber facade bay
// -------------------------------------------------------------------------
const central = new THREE.Group();
scene.add(central);
// Raised threshold and stone base under the facade.
groupBox(central, 6.55, 0.16, 0.78, 0x8e9188, 0, 0.34, 5.43);
groupBox(central, 6.2, 0.12, 0.55, 0x3f2b24, 0, 0.44, 5.39);
// Main plastered volume, set behind the timber frontage.
groupBox(central, 6.2, 3.35, 3.75, 0xe3ddcb, 0, 2.02, 7.53);
groupBox(central, 6.12, 1.08, 0.18, 0x5a3e31, 0, 0.86, 5.59);
// Stepped voxel roof and deep eaves.
groupBox(central, 7.05, 0.22, 4.38, 0x272b29, 0, 3.72, 7.53);
groupBox(central, 6.65, 0.34, 3.85, 0x333735, 0, 3.98, 7.76);
groupBox(central, 6.05, 0.16, 3.25, 0x414744, 0, 4.2, 7.86);
groupBox(central, 5.9, 0.13, 0.16, 0x252a28, 0, 4.34, 7.88);
// Front posts.
[-2.82, -1.42, 0, 1.42, 2.82].forEach((x) => {
groupBox(central, 0.13, 3.25, 0.2, 0x493229, x, 1.96, 5.42);
});
// Horizontal beams.
groupBox(central, 6.08, 0.15, 0.2, 0x4d352b, 0, 0.48, 5.4);
groupBox(central, 6.08, 0.14, 0.2, 0x4d352b, 0, 1.42, 5.4);
groupBox(central, 6.08, 0.16, 0.2, 0x4d352b, 0, 2.77, 5.4);
groupBox(central, 6.3, 0.2, 0.3, 0x372a24, 0, 3.58, 5.39);
// Warm shoji panels.
const shojiMaterial = new THREE.MeshStandardMaterial({
color: 0xe9d9ac,
roughness: 0.74,
emissive: 0x6a4d24,
emissiveIntensity: 0.16
});
[-1.95, 0, 1.95].forEach((x) => {
groupBox(central, 1.58, 1.18, 0.06, 0xffffff, x, 2.08, 5.44, {
material: shojiMaterial
});
// Pixel lattice.
for (let dx = -0.63; dx <= 0.63; dx += 0.315) {
groupBox(central, 0.035, 1.18, 0.045, 0x72513a, x + dx, 2.08, 5.39);
}
groupBox(central, 1.58, 0.04, 0.045, 0x72513a, x, 2.08, 5.38);
});
// Central recessed sliding-door bay.
groupBox(central, 1.28, 1.0, 0.08, 0x31231e, 0, 0.98, 5.39);
groupBox(central, 0.48, 0.86, 0.055, 0xdfc89d, -0.27, 0.99, 5.32, {
material: shojiMaterial
});
groupBox(central, 0.48, 0.86, 0.055, 0xdfc89d, 0.27, 0.99, 5.32, {
material: shojiMaterial
});
// Small upper transom.
groupBox(central, 1.52, 0.3, 0.07, 0xffffff, 0, 3.2, 5.39, {
material: shojiMaterial
});
// Entry plaque.
const plaqueCanvas = document.createElement("canvas");
plaqueCanvas.width = 512;
plaqueCanvas.height = 160;
const plaqueContext = plaqueCanvas.getContext("2d");
plaqueContext.fillStyle = "#3c2c24";
plaqueContext.fillRect(0, 0, 512, 160);
plaqueContext.strokeStyle = "#b99461";
plaqueContext.lineWidth = 7;
plaqueContext.strokeRect(12, 12, 488, 136);
plaqueContext.fillStyle = "#ead8ad";
plaqueContext.font = "700 72px serif";
plaqueContext.textAlign = "center";
plaqueContext.textBaseline = "middle";
plaqueContext.fillText("白 川", 256, 82);
const plaqueTexture = new THREE.CanvasTexture(plaqueCanvas);
plaqueTexture.colorSpace = THREE.SRGBColorSpace;
const plaque = new THREE.Mesh(
new THREE.PlaneGeometry(1.35, 0.42),
new THREE.MeshBasicMaterial({ map: plaqueTexture })
);
plaque.position.set(0, 3.2, 5.31);
central.add(plaque);
// -------------------------------------------------------------------------
// Neighboring machiya volumes
// -------------------------------------------------------------------------
function sideMachiya(x, width, height, variation = 0) {
const g = new THREE.Group();
g.position.x = x;
scene.add(g);
const frontZ = 5.68 + variation * 0.08;
const depth = 3.7;
const plaster = variation === 0 ? 0xd5d0c0 : 0xe0d9c7;
groupBox(g, width, height, depth, plaster, 0, height / 2 + 0.22, frontZ + depth / 2);
groupBox(g, width - 0.08, 1.08, 0.17, 0x563a2f, 0, 0.79, frontZ - 0.07);
const postXs = [-width / 2 + 0.22, 0, width / 2 - 0.22];
postXs.forEach((px) => {
groupBox(g, 0.12, height - 0.1, 0.19, 0x493128, px, height / 2 + 0.25, frontZ - 0.13);
});
groupBox(g, width - 0.1, 0.13, 0.19, 0x4c3429, 0, 1.36, frontZ - 0.13);
groupBox(g, width - 0.1, 0.16, 0.2, 0x493128, 0, height + 0.05, frontZ - 0.13);
// Two simple glowing paper windows.
[-width * 0.23, width * 0.23].forEach((wx) => {
groupBox(g, width * 0.29, 1.12, 0.065, 0xffffff, wx, height * 0.66, frontZ - 0.11, {
material: shojiMaterial
});
groupBox(g, 0.045, 1.12, 0.05, 0x76523c, wx, height * 0.66, frontZ - 0.15);
});
groupBox(g, width + 0.72, 0.22, depth + 0.55, 0x282d2b, 0, height + 0.3, frontZ + depth / 2);
groupBox(g, width + 0.3, 0.3, depth + 0.15, 0x363c39, 0, height + 0.55, frontZ + depth / 2 + 0.12);
groupBox(g, width - 0.15, 0.12, 0.14, 0x252a28, 0, height + 0.75, frontZ + depth / 2 + 0.15);
// Small sign under the eave.
groupBox(g, 0.72, 0.24, 0.12, 0x3e2c23, width * 0.28, height + 0.04, frontZ - 0.2);
}
sideMachiya(-8.45, 5.7, 3.2, 0);
sideMachiya(8.7, 5.9, 3.45, 1);
// Distant roofline to suggest the dense Gion block.
const distantColors = [0xaaa99e, 0x9b9d94, 0xb3b0a4, 0x8f958d];
for (let i = 0; i < 11; i++) {
const x = -20 + i * 4.1 + (random() - 0.5) * 0.6;
const h = 2.4 + random() * 2.2;
box(
3.4 + random() * 1.2,
h,
3.4,
pick(distantColors),
x,
h / 2 - 0.15,
14 + random() * 2,
{ castShadow: false }
);
box(
3.8 + random() * 1.2,
0.24,
4.0,
0x505653,
x,
h + 0.03,
14 + random() * 2,
{ castShadow: false }
);
}
// -------------------------------------------------------------------------
// Paper lanterns
// -------------------------------------------------------------------------
function addLantern(x, z, flip = 1) {
const g = new THREE.Group();
g.position.set(x, 0, z);
scene.add(g);
groupBox(g, 0.12, 1.0, 0.12, 0x332923, 0, 0.92, 0);
groupBox(g, 0.55, 0.12, 0.12, 0x332923, flip * 0.22, 1.45, 0);
groupBox(g, 0.12, 0.12, 0.12, 0x332923, flip * 0.42, 1.31, 0);
const lanternMaterial = new THREE.MeshStandardMaterial({
color: 0xf1d89d,
roughness: 0.72,
emissive: 0xffb95f,
emissiveIntensity: 0.72
});
groupBox(g, 0.38, 0.58, 0.38, 0xffffff, flip * 0.43, 1.02, 0, {
material: lanternMaterial
});
groupBox(g, 0.42, 0.07, 0.42, 0x312923, flip * 0.43, 1.34, 0);
groupBox(g, 0.42, 0.07, 0.42, 0x312923, flip * 0.43, 0.7, 0);
const light = new THREE.PointLight(0xffbb72, 2.0, 5.2, 2);
light.position.set(flip * 0.43, 1.0, -0.12);
g.add(light);
}
addLantern(-3.6, 5.17, 1);
addLantern(3.6, 5.17, -1);
// -------------------------------------------------------------------------
// Blocky willow, stone lantern, and pots
// -------------------------------------------------------------------------
const willow = new THREE.Group();
willow.position.set(-6.0, 0, 4.12);
scene.add(willow);
groupBox(willow, 0.38, 2.8, 0.38, 0x665039, 0, 1.47, 0);
groupBox(willow, 0.25, 1.65, 0.25, 0x725a40, -0.55, 2.65, 0, { rotationZ: -0.52 });
groupBox(willow, 0.25, 1.6, 0.25, 0x725a40, 0.52, 2.7, 0.08, { rotationZ: 0.5 });
const leafColors = [0x6f8662, 0x7f946c, 0x879b70, 0x627d5c];
const leafClusters = [
[-0.85, 3.48, 0, 1.65, 0.72, 1.25],
[0.78, 3.55, 0.05, 1.8, 0.82, 1.4],
[0, 3.92, 0.12, 2.25, 0.75, 1.55],
[-0.25, 3.42, -0.4, 1.5, 0.65, 1.0]
];
leafClusters.forEach((v, i) => {
groupBox(willow, v[3], v[4], v[5], leafColors[i], v[0], v[1], v[2]);
});
// Hanging, block-like willow strands.
for (let i = 0; i < 15; i++) {
const x = -1.25 + i * 0.18;
const top = 3.35 - Math.abs(i - 7) * 0.055;
const length = 0.55 + random() * 0.75;
groupBox(
willow,
0.13,
length,
0.15,
pick(leafColors),
x,
top - length / 2,
0.28 + random() * 0.34
);
}
// Small stone lantern beside the path.
const stoneLantern = new THREE.Group();
stoneLantern.position.set(10.15, 0, 4.18);
scene.add(stoneLantern);
groupBox(stoneLantern, 0.62, 0.18, 0.62, 0x747c77, 0, 0.25, 0);
groupBox(stoneLantern, 0.3, 0.76, 0.3, 0x8a9189, 0, 0.7, 0);
groupBox(stoneLantern, 0.66, 0.16, 0.66, 0x92978e, 0, 1.15, 0);
groupBox(stoneLantern, 0.42, 0.44, 0.42, 0xb8b8a4, 0, 1.43, 0, {
material: new THREE.MeshStandardMaterial({
color: 0xe5d89c,
emissive: 0x9a743b,
emissiveIntensity: 0.22
})
});
groupBox(stoneLantern, 0.72, 0.18, 0.72, 0x7e857f, 0, 1.74, 0);
// Potted plants beside the threshold.
for (const x of [-4.35, 4.38]) {
box(0.46, 0.42, 0.46, 0x6d5745, x, 0.57, 5.0);
box(0.5, 0.08, 0.5, 0x594639, x, 0.81, 5.0);
box(0.42, 0.44, 0.42, 0x627a54, x, 1.05, 5.0);
box(0.34, 0.33, 0.34, 0x73895d, x + 0.08, 1.33, 5.0);
}
// -------------------------------------------------------------------------
// Water highlights: tiny rectangular, slowly drifting reflections
// -------------------------------------------------------------------------
const waterHighlights = [];
const highlightMaterials = [
new THREE.MeshBasicMaterial({ color: 0xc7e0de, transparent: true, opacity: 0.56 }),
new THREE.MeshBasicMaterial({ color: 0x91c0c4, transparent: true, opacity: 0.62 }),
new THREE.MeshBasicMaterial({ color: 0xe0ece5, transparent: true, opacity: 0.42 })
];
for (let i = 0; i < 55; i++) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(0.18 + random() * 0.62, 0.018, 0.025 + random() * 0.04),
highlightMaterials[i % highlightMaterials.length]
);
mesh.position.set(
-14.7 + random() * 29.4,
0.012 + random() * 0.005,
-1.85 + random() * 3.7
);
mesh.castShadow = false;
mesh.receiveShadow = false;
scene.add(mesh);
waterHighlights.push({
mesh,
baseX: mesh.position.x,
phase: random() * Math.PI * 2,
speed: 0.25 + random() * 0.35
});
}
// -------------------------------------------------------------------------
// Direct camera controls — no addons or example modules
// -------------------------------------------------------------------------
const target = new THREE.Vector3(0, 1.15, 2.45);
const desiredTarget = target.clone();
const cameraState = {
theta: 2.78,
phi: 1.17,
radius: 20.5
};
const desired = {
theta: cameraState.theta,
phi: cameraState.phi,
radius: cameraState.radius
};
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
target.y + cameraState.radius * Math.cos(cameraState.phi),
target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(target);
}
let dragging = false;
let pointerX = 0;
let pointerY = 0;
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
pointerX = event.clientX;
pointerY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - pointerX;
const dy = event.clientY - pointerY;
pointerX = event.clientX;
pointerY = event.clientY;
desired.theta -= dx * 0.006;
desired.phi = THREE.MathUtils.clamp(desired.phi - dy * 0.005, 0.56, 1.47);
});
function stopDragging(event) {
dragging = false;
if (event.pointerId !== undefined && canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", stopDragging);
canvas.addEventListener("pointercancel", stopDragging);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
desired.radius = THREE.MathUtils.clamp(
desired.radius + event.deltaY * 0.012,
7.5,
30
);
},
{ passive: false }
);
function resetView() {
desired.theta = 2.78;
desired.phi = 1.17;
desired.radius = 20.5;
desiredTarget.set(0, 1.15, 2.45);
}
const views = {
overview: () => {
desired.theta = 2.78;
desired.phi = 1.17;
desired.radius = 20.5;
desiredTarget.set(0, 1.15, 2.45);
},
path: () => {
desired.theta = 2.93;
desired.phi = 1.31;
desired.radius = 11.5;
desiredTarget.set(0, 0.72, 3.25);
},
facade: () => {
desired.theta = 2.87;
desired.phi = 1.34;
desired.radius = 8.7;
desiredTarget.set(0, 1.75, 5.2);
}
};
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => views[button.dataset.view]());
});
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") desired.theta -= 0.12;
if (event.key === "ArrowRight") desired.theta += 0.12;
if (event.key === "ArrowUp") desired.phi = Math.max(0.56, desired.phi - 0.08);
if (event.key === "ArrowDown") desired.phi = Math.min(1.47, desired.phi + 0.08);
if (event.key.toLowerCase() === "r") resetView();
});
// -------------------------------------------------------------------------
// Projected HTML boundary labels
// -------------------------------------------------------------------------
const markerData = [
{
element: document.querySelector("#marker-water"),
anchor: new THREE.Vector3(-2.4, 0.08, 0.1),
offset: new THREE.Vector2(-74, 34)
},
{
element: document.querySelector("#marker-path"),
anchor: new THREE.Vector3(3.35, 0.24, 3.48),
offset: new THREE.Vector2(85, -7)
},
{
element: document.querySelector("#marker-threshold"),
anchor: new THREE.Vector3(0.35, 0.43, 5.18),
offset: new THREE.Vector2(44, -49)
}
];
const markerToggle = document.querySelector("#marker-toggle");
const markerLayer = document.querySelector("#marker-layer");
markerToggle.addEventListener("change", () => {
markerLayer.classList.toggle("hidden", !markerToggle.checked);
});
const projected = new THREE.Vector3();
function updateMarkers() {
if (!markerToggle.checked) return;
const compact = window.innerWidth < 760;
const width = window.innerWidth;
const height = window.innerHeight;
markerData.forEach((marker) => {
projected.copy(marker.anchor).project(camera);
const visible = projected.z > -1 && projected.z < 1;
const x = (projected.x * 0.5 + 0.5) * width;
const y = (-projected.y * 0.5 + 0.5) * height;
marker.element.classList.toggle("offscreen", !visible);
marker.element.style.left = `${x}px`;
marker.element.style.top = `${y}px`;
marker.element.style.setProperty(
"--dx",
`${marker.offset.x * (compact ? 0.55 : 1)}px`
);
marker.element.style.setProperty(
"--dy",
`${marker.offset.y * (compact ? 0.65 : 1)}px`
);
});
}
// -------------------------------------------------------------------------
// Resize and render loop
// -------------------------------------------------------------------------
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.6));
renderer.setSize(window.innerWidth, window.innerHeight);
});
const clock = new THREE.Clock();
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const smoothing = 1 - Math.exp(-dt * 8);
cameraState.theta = THREE.MathUtils.lerp(cameraState.theta, desired.theta, smoothing);
cameraState.phi = THREE.MathUtils.lerp(cameraState.phi, desired.phi, smoothing);
cameraState.radius = THREE.MathUtils.lerp(cameraState.radius, desired.radius, smoothing);
target.lerp(desiredTarget, smoothing);
updateCamera();
waterHighlights.forEach((item) => {
item.mesh.position.x =
item.baseX + Math.sin(elapsed * item.speed + item.phase) * 0.22;
item.mesh.scale.x = 0.82 + Math.sin(elapsed * 0.7 + item.phase) * 0.16;
});
updateMarkers();
renderer.render(scene, camera);
}
resetView();
updateCamera();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```