Prompt specification
Build or customize the Three.js 3D scene "Design Language Translation Studio" 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: Design Language Translation Studio
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/design-language-translation-studio-x3284
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts architectural expression through form, light, and gathering spaces. Create modular original facade elements that preserve a chosen rhythm across a home, school, and market. Show functional changes while avoiding imitation of a living architect's exact project. Low-poly.
Working Three.js Starter (design-language-translation-studio-x3284):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Common Threshold — Architectural Rhythm</title>
<style>
:root {
--ink: #24302e;
--muted: #5c6965;
--paper: rgba(244, 240, 229, 0.91);
--line: rgba(36, 48, 46, 0.19);
--accent: #b9573e;
--active: #274d4e;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dce5e0;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
#scene {
display: block;
width: 100%;
height: 100%;
cursor: grab;
touch-action: none;
outline: none;
}
#scene:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
pointer-events: none;
}
.topbar {
position: absolute;
top: 24px;
left: 28px;
right: 28px;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 20px;
}
.title-block {
max-width: 430px;
padding: 15px 17px 16px;
border: 1px solid var(--line);
border-radius: 3px;
background: var(--paper);
backdrop-filter: blur(12px);
box-shadow: 0 12px 40px rgba(33, 45, 42, 0.08);
}
.eyebrow {
margin-bottom: 7px;
color: var(--accent);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: clamp(24px, 3vw, 39px);
font-weight: 520;
letter-spacing: -0.045em;
line-height: 0.98;
}
.subtitle {
margin: 11px 0 0;
max-width: 365px;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.controls {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 7px;
pointer-events: auto;
}
button {
appearance: none;
border: 1px solid rgba(36, 48, 46, 0.22);
border-radius: 2px;
background: rgba(244, 240, 229, 0.86);
color: var(--ink);
padding: 10px 13px;
font: inherit;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.11em;
text-transform: uppercase;
cursor: pointer;
backdrop-filter: blur(10px);
transition:
background 160ms ease,
color 160ms ease,
border-color 160ms ease,
transform 160ms ease;
}
button:hover {
transform: translateY(-1px);
border-color: rgba(36, 48, 46, 0.52);
}
button.active {
border-color: var(--active);
background: var(--active);
color: #f8f2e5;
}
#light-toggle {
min-width: 116px;
}
.story {
position: absolute;
right: 28px;
bottom: 28px;
width: min(355px, calc(100vw - 56px));
padding: 18px 19px 17px;
border: 1px solid var(--line);
border-radius: 3px;
background: var(--paper);
backdrop-filter: blur(12px);
box-shadow: 0 14px 44px rgba(33, 45, 42, 0.1);
pointer-events: auto;
}
.story-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-bottom: 9px;
color: var(--accent);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.16em;
text-transform: uppercase;
}
.story h2 {
margin: 0 0 8px;
font-size: 20px;
font-weight: 580;
letter-spacing: -0.025em;
}
.story p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.6;
}
.datum {
position: absolute;
left: 28px;
bottom: 28px;
display: flex;
align-items: center;
gap: 14px;
padding: 11px 14px;
border: 1px solid var(--line);
border-radius: 3px;
background: rgba(244, 240, 229, 0.83);
backdrop-filter: blur(10px);
}
.datum-bars {
display: flex;
align-items: flex-end;
gap: 3px;
height: 25px;
}
.datum-bars i {
display: block;
width: 4px;
height: 25px;
background: var(--active);
}
.datum-bars i:nth-child(2) {
height: 17px;
}
.datum-bars i:nth-child(3) {
height: 21px;
}
.datum-text {
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
line-height: 1.6;
text-transform: uppercase;
}
.hint {
position: absolute;
left: 50%;
bottom: 29px;
transform: translateX(-50%);
color: rgba(36, 48, 46, 0.68);
font-size: 9px;
font-weight: 750;
letter-spacing: 0.13em;
text-transform: uppercase;
white-space: nowrap;
text-shadow: 0 1px 10px rgba(255, 255, 255, 0.8);
}
@media (max-width: 900px) {
.topbar {
top: 14px;
left: 14px;
right: 14px;
}
.title-block {
max-width: 315px;
padding: 12px 13px;
}
.subtitle {
display: none;
}
.controls {
max-width: 190px;
}
button {
padding: 9px 10px;
font-size: 9px;
}
.story {
right: 14px;
bottom: 14px;
width: min(330px, calc(100vw - 28px));
}
.datum {
left: 14px;
bottom: 14px;
}
.hint {
display: none;
}
}
@media (max-width: 560px) {
.topbar {
display: block;
}
.title-block {
max-width: calc(100vw - 28px);
}
.controls {
position: absolute;
top: 118px;
left: 0;
max-width: none;
justify-content: flex-start;
}
.datum {
display: none;
}
.story {
padding: 13px 14px;
}
.story p {
font-size: 11px;
}
}
</style>
</head>
<body>
<canvas
id="scene"
tabindex="0"
aria-label="Interactive low-poly architectural scene showing a home, school, and market sharing one facade rhythm"
></canvas>
<div class="hud">
<header class="topbar">
<div class="title-block">
<div class="eyebrow">Architectural study · R–01 portal</div>
<h1>Common Threshold</h1>
<p class="subtitle">
One measured facade cadence becomes shelter, learning, and exchange.
Original modular forms; no borrowed architectural signature.
</p>
</div>
<nav class="controls" aria-label="Scene controls">
<button class="active" data-select="all">All</button>
<button data-select="home">Home</button>
<button data-select="school">School</button>
<button data-select="market">Market</button>
<button id="light-toggle">Dusk light</button>
</nav>
</header>
<aside class="story" aria-live="polite">
<div class="story-meta">
<span id="story-index">Composition / 01</span>
<span id="story-rhythm">3 · 5 · 7 bays</span>
</div>
<h2 id="story-title">A shared civic cadence</h2>
<p id="story-text">
The same 1.5-metre portal repeats across three scales. Its deep
reveals hold changing shadows, while each threshold becomes a
different kind of gathering space.
</p>
</aside>
<div class="datum">
<div class="datum-bars" aria-hidden="true">
<i></i><i></i><i></i>
</div>
<div class="datum-text">
Module 1.50 m<br />
Portal / reveal / return tab
</div>
</div>
<div class="hint">Drag to orbit · Scroll to zoom · Click a building</div>
</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 canvas = document.querySelector("#scene");
const renderer = new THREE.WebGLRenderer({
canvas,
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.05;
const scene = new THREE.Scene();
const daySky = new THREE.Color(0xdce6e1);
const duskSky = new THREE.Color(0x71817f);
const dayFog = new THREE.Color(0xdce6e1);
const duskFog = new THREE.Color(0x71817f);
scene.background = daySky.clone();
scene.fog = new THREE.Fog(dayFog.clone(), 22, 53);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xf4f0df, 0x78827a, 1.75);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe8bd, 3.1);
sun.position.set(-9, 16, 11);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -19;
sun.shadow.camera.right = 19;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 48;
sun.shadow.normalBias = 0.035;
scene.add(sun);
const sunDisc = new THREE.Mesh(
new THREE.IcosahedronGeometry(1.15, 1),
new THREE.MeshBasicMaterial({
color: 0xffd998,
fog: false,
transparent: true,
opacity: 0.8
})
);
scene.add(sunDisc);
// ------------------------------------------------------------
// Materials: deliberately simple, matte, and low-poly
// ------------------------------------------------------------
const MAT = {
plaster: new THREE.MeshStandardMaterial({
color: 0xd6c8ad,
roughness: 0.91,
flatShading: true
}),
frame: new THREE.MeshStandardMaterial({
color: 0xeee4ce,
roughness: 0.76,
flatShading: true
}),
dark: new THREE.MeshStandardMaterial({
color: 0x293432,
roughness: 0.82,
flatShading: true
}),
wood: new THREE.MeshStandardMaterial({
color: 0x9b5b3d,
roughness: 0.86,
flatShading: true
}),
woodLight: new THREE.MeshStandardMaterial({
color: 0xc28a5d,
roughness: 0.85,
flatShading: true
}),
teal: new THREE.MeshStandardMaterial({
color: 0x315858,
roughness: 0.7,
flatShading: true
}),
red: new THREE.MeshStandardMaterial({
color: 0xb9573e,
roughness: 0.8,
flatShading: true
}),
ochre: new THREE.MeshStandardMaterial({
color: 0xd5a24d,
roughness: 0.82,
flatShading: true
}),
paving: new THREE.MeshStandardMaterial({
color: 0xc4c4b5,
roughness: 0.97,
flatShading: true
}),
ground: new THREE.MeshStandardMaterial({
color: 0xa8b39f,
roughness: 1,
flatShading: true
}),
stone: new THREE.MeshStandardMaterial({
color: 0x7f8b81,
roughness: 1,
flatShading: true
}),
foliage: new THREE.MeshStandardMaterial({
color: 0x657e61,
roughness: 1,
flatShading: true
}),
foliageLight: new THREE.MeshStandardMaterial({
color: 0x83966e,
roughness: 1,
flatShading: true
}),
glow: new THREE.MeshStandardMaterial({
color: 0xffd18b,
emissive: 0xff9d4c,
emissiveIntensity: 0.8,
roughness: 0.6,
flatShading: true
})
};
const glass = new THREE.MeshStandardMaterial({
color: 0x9fc2bd,
roughness: 0.24,
metalness: 0.05,
transparent: true,
opacity: 0.72,
depthWrite: false,
emissive: 0xe6a35c,
emissiveIntensity: 0.03,
flatShading: true
});
const groundGeometry = new THREE.PlaneGeometry(48, 34, 18, 12);
const groundPositions = groundGeometry.attributes.position;
for (let i = 0; i < groundPositions.count; i++) {
const x = groundPositions.getX(i);
const y = groundPositions.getY(i);
const h =
Math.sin(x * 0.43) * 0.055 +
Math.cos(y * 0.57) * 0.045 +
Math.sin((x + y) * 0.25) * 0.025;
groundPositions.setZ(i, h);
}
groundGeometry.rotateX(-Math.PI / 2);
groundGeometry.computeVertexNormals();
const ground = new THREE.Mesh(groundGeometry, MAT.ground);
ground.position.y = -0.045;
ground.receiveShadow = true;
scene.add(ground);
// ------------------------------------------------------------
// Geometry helpers
// ------------------------------------------------------------
function box(parent, size, position, material, shadow = true) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = shadow;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
radiusTop,
radiusBottom,
height,
segments,
position,
material
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
radiusTop,
radiusBottom,
height,
segments
),
material
);
mesh.position.set(position[0], position[1], position[2]);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function quad(parent, vertices, indices, material) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(vertices.flat(), 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function lowPolyPerson(parent, x, y, z, color, rotation = 0) {
const person = new THREE.Group();
person.position.set(x, y, z);
person.rotation.y = rotation;
const clothing = new THREE.MeshStandardMaterial({
color,
roughness: 0.9,
flatShading: true
});
const skin = new THREE.MeshStandardMaterial({
color: 0xc18c68,
roughness: 0.95,
flatShading: true
});
cylinder(person, 0.13, 0.18, 0.66, 5, [0, 1.0, 0], clothing);
const head = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.145, 0),
skin
);
head.position.y = 1.47;
head.castShadow = true;
person.add(head);
box(person, [0.075, 0.65, 0.085], [-0.09, 0.34, 0], MAT.dark);
box(person, [0.075, 0.65, 0.085], [0.09, 0.34, 0], MAT.dark);
box(person, [0.085, 0.55, 0.085], [-0.2, 1.0, 0], clothing);
box(person, [0.085, 0.55, 0.085], [0.2, 1.0, 0], clothing);
parent.add(person);
return person;
}
function makeLabel(text, subtitle) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 640;
labelCanvas.height = 150;
const ctx = labelCanvas.getContext("2d");
ctx.clearRect(0, 0, 640, 150);
ctx.fillStyle = "rgba(244,240,229,0.94)";
ctx.strokeStyle = "rgba(36,48,46,0.35)";
ctx.lineWidth = 3;
ctx.beginPath();
ctx.roundRect(8, 8, 624, 134, 12);
ctx.fill();
ctx.stroke();
ctx.fillStyle = "#b9573e";
ctx.font = "800 24px system-ui";
ctx.letterSpacing = "3px";
ctx.fillText(subtitle, 34, 48);
ctx.fillStyle = "#24302e";
ctx.font = "600 43px system-ui";
ctx.fillText(text, 34, 104);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthWrite: false
})
);
sprite.scale.set(3.15, 0.74, 1);
return sprite;
}
// ------------------------------------------------------------
// Shared architectural module
//
// R–01 portal:
// twin piers + lintel + a projecting return blade + datum tile.
// The 1.5 m bay stays constant while its infill changes.
// ------------------------------------------------------------
function addPortal(root, x, bayWidth, height, frontZ, options = {}) {
const base = 0.34;
const frameHeight = height - base;
const depth = options.depth ?? 0.38;
box(
root,
[0.14, frameHeight, depth],
[x - bayWidth / 2 + 0.07, base + frameHeight / 2, frontZ + 0.18],
MAT.frame
);
box(
root,
[0.14, frameHeight, depth],
[x + bayWidth / 2 - 0.07, base + frameHeight / 2, frontZ + 0.18],
MAT.frame
);
box(
root,
[bayWidth, 0.22, depth],
[x, base + frameHeight - 0.11, frontZ + 0.18],
MAT.frame
);
// Original "return tab": a narrow blade projected through
// the reveal, making a directional shadow across every bay.
box(
root,
[0.075, frameHeight * 0.61, 0.74],
[x + bayWidth / 2 - 0.21, base + frameHeight * 0.57, frontZ + 0.36],
options.accent || MAT.woodLight
);
// Small datum tile repeats at the lintel.
box(
root,
[0.19, 0.19, 0.045],
[x + bayWidth * 0.18, base + frameHeight - 0.11, frontZ + 0.43],
options.accent || MAT.red
);
if (options.sill !== false) {
box(
root,
[bayWidth - 0.2, 0.12, 0.31],
[x, base + 0.06, frontZ + 0.12],
MAT.frame
);
}
}
function addShell(root, width, depth, height, wallMaterial = MAT.plaster) {
box(root, [width + 0.22, 0.22, depth + 0.22], [0, 0.08, 0], MAT.stone);
box(root, [width, 0.12, depth], [0, 0.25, 0], MAT.woodLight);
box(
root,
[width, height, 0.18],
[0, height / 2 + 0.2, -depth / 2 + 0.09],
wallMaterial
);
box(
root,
[0.18, height, depth],
[-width / 2 + 0.09, height / 2 + 0.2, 0],
wallMaterial
);
box(
root,
[0.18, height, depth],
[width / 2 - 0.09, height / 2 + 0.2, 0],
wallMaterial
);
}
function addGableRoof(root, width, depth, baseY, rise) {
const angle = Math.atan2(rise, width / 2);
const slopeLength = Math.hypot(width / 2, rise) + 0.22;
const left = box(
root,
[slopeLength, 0.16, depth + 0.48],
[-width / 4, baseY + rise / 2, 0],
MAT.dark
);
left.rotation.z = angle;
const right = box(
root,
[slopeLength, 0.16, depth + 0.48],
[width / 4, baseY + rise / 2, 0],
MAT.dark
);
right.rotation.z = -angle;
for (const side of [-1, 1]) {
const x = side * width / 2;
const vertices = [
[x, baseY, -depth / 2],
[x, baseY, depth / 2],
[x, baseY + rise, 0]
];
const material = MAT.plaster.clone();
material.side = THREE.DoubleSide;
quad(root, vertices, [0, 1, 2], material);
}
}
function addButterflyRoof(root, width, depth, edgeY, valleyY) {
const half = width / 2;
quad(
root,
[
[-half, edgeY, -depth / 2 - 0.25],
[-half, edgeY, depth / 2 + 0.25],
[0, valleyY, depth / 2 + 0.25],
[0, valleyY, -depth / 2 - 0.25]
],
[0, 1, 2, 0, 2, 3],
MAT.dark
);
quad(
root,
[
[0, valleyY, -depth / 2 - 0.25],
[0, valleyY, depth / 2 + 0.25],
[half, edgeY, depth / 2 + 0.25],
[half, edgeY, -depth / 2 - 0.25]
],
[0, 1, 2, 0, 2, 3],
MAT.dark
);
box(
root,
[0.08, 0.08, depth + 0.55],
[0, valleyY - 0.04, 0],
MAT.teal
);
}
function addMonoRoof(root, width, depth, backY, frontY) {
const half = width / 2;
quad(
root,
[
[-half, backY, -depth / 2 - 0.25],
[-half, frontY, depth / 2 + 0.25],
[half, frontY, depth / 2 + 0.25],
[half, backY, -depth / 2 - 0.25]
],
[0, 1, 2, 0, 2, 3],
MAT.dark
);
box(
root,
[width + 0.45, 0.14, 0.12],
[0, frontY - 0.04, depth / 2 + 0.25],
MAT.wood
);
}
function addRoundTable(parent, x, z, radius = 0.62) {
cylinder(parent, radius, radius, 0.1, 8, [x, 0.72, z], MAT.woodLight);
cylinder(parent, 0.09, 0.14, 0.66, 6, [x, 0.36, z], MAT.dark);
cylinder(parent, 0.28, 0.28, 0.06, 8, [x, 0.05, z], MAT.dark);
}
function addBench(parent, x, z, width = 1.2) {
box(parent, [width, 0.11, 0.36], [x, 0.43, z], MAT.wood);
box(parent, [0.12, 0.38, 0.28], [x - width * 0.34, 0.21, z], MAT.dark);
box(parent, [0.12, 0.38, 0.28], [x + width * 0.34, 0.21, z], MAT.dark);
}
// ------------------------------------------------------------
// Home: 3 repeated domestic bays, hearth-like interior,
// intimate courtyard and a protected threshold.
// ------------------------------------------------------------
function buildHome() {
const width = 4.65;
const depth = 4.05;
const height = 3.18;
const bay = 1.55;
const root = new THREE.Group();
root.position.set(-8.25, 0, 0.3);
scene.add(root);
addShell(root, width, depth, height, MAT.plaster);
const front = depth / 2;
for (let i = 0; i < 3; i++) {
const x = -width / 2 + bay * (i + 0.5);
addPortal(root, x, bay, height, front, {
accent: i === 1 ? MAT.teal : MAT.woodLight
});
if (i === 2) {
// A recessed domestic door, still held by the same frame.
box(
root,
[0.77, 2.36, 0.08],
[x, 1.52, front - 0.18],
MAT.wood
);
box(
root,
[0.05, 0.05, 0.08],
[x + 0.22, 1.47, front - 0.1],
MAT.ochre
);
} else {
box(
root,
[bay - 0.27, 2.35, 0.06],
[x, 1.53, front - 0.18],
glass
);
box(
root,
[0.055, 2.35, 0.09],
[x, 1.53, front - 0.11],
MAT.teal
);
box(
root,
[bay - 0.27, 0.055, 0.09],
[x, 1.53, front - 0.11],
MAT.teal
);
}
}
// Warm inner wall and hearth-like pendant.
box(root, [2.8, 1.3, 0.05], [-0.55, 1.32, -0.78], MAT.ochre);
cylinder(root, 0.035, 0.035, 0.72, 5, [-0.8, 2.72, 0.15], MAT.dark);
const lamp = new THREE.Mesh(
new THREE.ConeGeometry(0.19, 0.24, 7),
MAT.glow
);
lamp.position.set(-0.8, 2.28, 0.15);
root.add(lamp);
addGableRoof(root, width, depth, height + 0.16, 1.05);
box(
root,
[0.34, 0.72, 0.38],
[1.35, height + 0.75, -0.95],
MAT.red
);
// Courtyard: protected, domestic gathering around one table.
box(
root,
[width + 0.8, 0.08, 2.65],
[0, 0.025, front + 1.45],
MAT.paving
);
addRoundTable(root, -0.3, front + 1.55, 0.64);
addBench(root, -0.3, front + 0.86, 1.1);
addBench(root, -0.3, front + 2.23, 1.1);
cylinder(
root,
0.46,
0.56,
0.42,
7,
[1.45, 0.25, front + 1.55],
MAT.wood
);
const shrub = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.47, 0),
MAT.foliageLight
);
shrub.position.set(1.45, 0.73, front + 1.55);
shrub.castShadow = true;
root.add(shrub);
const light = new THREE.PointLight(0xffa257, 7, 6.5, 2);
light.position.set(-0.6, 2.05, 0.05);
light.userData.day = 2;
light.userData.night = 24;
root.add(light);
lowPolyPerson(root, -1.1, 0.07, front + 1.18, MAT.teal, 0.4);
lowPolyPerson(root, 0.6, 0.07, front + 1.8, MAT.red, -0.8);
const label = makeLabel("HOME", "01 / DWELLING");
label.position.set(0, height + 1.62, -0.05);
root.add(label);
return {
id: "home",
root,
width,
depth,
height,
label,
roofY: height + 1.1,
front
};
}
// ------------------------------------------------------------
// School: 5 learning bays, deep shaded arcade, clerestory,
// butterfly roof and a stepped civic forum.
// ------------------------------------------------------------
function buildSchool() {
const width = 7.75;
const depth = 4.9;
const height = 4.0;
const bay = 1.55;
const root = new THREE.Group();
root.position.set(0, 0, -0.3);
scene.add(root);
addShell(root, width, depth, height, MAT.plaster);
const front = depth / 2;
for (let i = 0; i < 5; i++) {
const x = -width / 2 + bay * (i + 0.5);
addPortal(root, x, bay, height, front, {
accent: MAT.teal,
depth: 0.44
});
box(
root,
[bay - 0.25, 3.1, 0.055],
[x, 1.92, front - 0.18],
glass
);
box(
root,
[0.065, 3.1, 0.09],
[x, 1.92, front - 0.11],
MAT.teal
);
// A continuous datum separates learning from clerestory light.
box(
root,
[bay - 0.25, 0.075, 0.1],
[x, 2.67, front - 0.1],
MAT.teal
);
}
// Deep arcade canopy.
box(
root,
[width + 0.35, 0.15, 2.05],
[0, 3.12, front + 0.98],
MAT.teal
);
for (const x of [-width / 2, 0, width / 2]) {
cylinder(
root,
0.065,
0.085,
2.88,
6,
[x, 1.75, front + 1.75],
MAT.teal
);
}
addButterflyRoof(root, width + 0.25, depth, height + 0.34, height + 0.06);
// Forum steps make the front edge a place to assemble.
box(
root,
[width + 0.7, 0.11, 3.3],
[0, 0.015, front + 1.55],
MAT.paving
);
for (let i = 0; i < 3; i++) {
box(
root,
[5.5 - i * 0.28, 0.13, 0.62],
[0, 0.065 + i * 0.13, front + 0.15 + i * 0.51],
MAT.stone
);
}
cylinder(
root,
1.25,
1.25,
0.035,
12,
[0.25, 0.11, front + 2.0],
MAT.teal
);
addBench(root, -1.2, front + 2.55, 1.1);
addBench(root, 1.55, front + 2.55, 1.1);
const lightA = new THREE.PointLight(0xffc07a, 6, 7, 2);
lightA.position.set(-2, 2.7, 0.55);
lightA.userData.day = 1.5;
lightA.userData.night = 23;
root.add(lightA);
const lightB = new THREE.PointLight(0xffc07a, 6, 7, 2);
lightB.position.set(2, 2.7, 0.55);
lightB.userData.day = 1.5;
lightB.userData.night = 23;
root.add(lightB);
lowPolyPerson(root, -0.85, 0.14, front + 1.8, MAT.ochre, 0.7);
lowPolyPerson(root, 0.15, 0.14, front + 2.25, MAT.teal, -0.5);
lowPolyPerson(root, 0.95, 0.14, front + 1.75, MAT.red, 2.2);
const label = makeLabel("SCHOOL", "02 / LEARNING");
label.position.set(0, height + 1.38, -0.1);
root.add(label);
return {
id: "school",
root,
width,
depth,
height,
label,
roofY: height + 0.5,
front
};
}
// ------------------------------------------------------------
// Market: 7 open bays, counters, shade awnings and a long
// communal table that turns circulation into exchange.
// ------------------------------------------------------------
function buildMarket() {
const width = 10.85;
const depth = 5.15;
const height = 3.22;
const bay = 1.55;
const root = new THREE.Group();
root.position.set(8.75, 0, 0.15);
scene.add(root);
addShell(root, width, depth, height, MAT.plaster);
const front = depth / 2;
box(
root,
[width - 0.3, 2.55, 0.1],
[0, 1.55, -depth / 2 + 0.2],
MAT.wood
);
for (let i = 0; i < 7; i++) {
const x = -width / 2 + bay * (i + 0.5);
const awningMaterial = i % 2 === 0 ? MAT.red : MAT.ochre;
addPortal(root, x, bay, height, front, {
accent: MAT.teal,
sill: false
});
// Open stall counter.
box(
root,
[bay - 0.18, 0.92, 0.72],
[x, 0.74, front - 0.58],
MAT.woodLight
);
box(
root,
[bay - 0.14, 0.08, 0.78],
[x, 1.24, front - 0.57],
MAT.frame
);
// Repeating low-poly awning.
quad(
root,
[
[x - bay / 2, 3.29, front],
[x + bay / 2, 3.29, front],
[x + bay / 2, 2.96, front + 1.03],
[x - bay / 2, 2.96, front + 1.03]
],
[0, 1, 2, 0, 2, 3],
awningMaterial
);
// Produce crates and faceted goods.
box(
root,
[0.38, 0.2, 0.32],
[x - 0.28, 1.36, front - 0.55],
MAT.wood
);
box(
root,
[0.38, 0.2, 0.32],
[x + 0.25, 1.36, front - 0.55],
MAT.wood
);
for (let j = 0; j < 3; j++) {
const produce = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.105, 0),
j % 2 ? MAT.ochre : MAT.red
);
produce.position.set(
x - 0.4 + j * 0.14,
1.51,
front - 0.57 + (j % 2) * 0.1
);
produce.castShadow = true;
root.add(produce);
}
// Hanging light under the open frame.
cylinder(
root,
0.018,
0.018,
0.34,
5,
[x, 2.82, front + 0.08],
MAT.dark
);
const bulb = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.09, 0),
MAT.glow
);
bulb.position.set(x, 2.62, front + 0.08);
root.add(bulb);
}
addMonoRoof(root, width + 0.25, depth, 3.98, 3.38);
// Broad public trading floor.
box(
root,
[width + 0.8, 0.08, 4.1],
[0, 0.015, front + 2.15],
MAT.paving
);
// Long communal table.
box(
root,
[3.25, 0.13, 0.9],
[0.6, 0.76, front + 2.45],
MAT.woodLight
);
for (const x of [-0.55, 1.75]) {
box(root, [0.12, 0.68, 0.62], [x, 0.37, front + 2.45], MAT.dark);
}
addBench(root, -0.2, front + 3.15, 1.5);
addBench(root, 1.45, front + 3.15, 1.5);
const lightA = new THREE.PointLight(0xffa85d, 5, 6, 2);
lightA.position.set(-3.6, 2.45, front - 0.1);
lightA.userData.day = 1;
lightA.userData.night = 21;
root.add(lightA);
const lightB = new THREE.PointLight(0xffa85d, 5, 6, 2);
lightB.position.set(3.6, 2.45, front - 0.1);
lightB.userData.day = 1;
lightB.userData.night = 21;
root.add(lightB);
lowPolyPerson(root, -1.7, 0.07, front + 1.6, MAT.teal, 0.1);
lowPolyPerson(root, -0.7, 0.07, front + 2.55, MAT.red, -1.1);
lowPolyPerson(root, 0.45, 0.07, front + 1.6, MAT.ochre, 1.2);
lowPolyPerson(root, 2.1, 0.07, front + 2.2, MAT.teal, -0.3);
lowPolyPerson(root, 3.25, 0.07, front + 1.5, MAT.red, 2.8);
const label = makeLabel("MARKET", "03 / EXCHANGE");
label.position.set(0, height + 1.52, -0.15);
root.add(label);
return {
id: "market",
root,
width,
depth,
height,
label,
roofY: height + 0.8,
front
};
}
const home = buildHome();
const school = buildSchool();
const market = buildMarket();
const buildings = { home, school, market };
// ------------------------------------------------------------
// Low-poly landscape and site markers
// ------------------------------------------------------------
function addTree(x, z, scale = 1) {
const tree = new THREE.Group();
tree.position.set(x, 0, z);
tree.scale.setScalar(scale);
cylinder(tree, 0.12, 0.19, 2.2, 5, [0, 1.1, 0], MAT.wood);
const crownA = new THREE.Mesh(
new THREE.IcosahedronGeometry(1.18, 0),
MAT.foliage
);
crownA.position.y = 2.65;
crownA.scale.set(1, 1.15, 0.92);
crownA.castShadow = true;
tree.add(crownA);
const crownB = new THREE.Mesh(
new THREE.IcosahedronGeometry(0.73, 0),
MAT.foliageLight
);
crownB.position.set(0.48, 3.15, -0.15);
crownB.castShadow = true;
tree.add(crownB);
scene.add(tree);
}
addTree(-13.4, -5.8, 1.25);
addTree(-11.3, -7.1, 0.92);
addTree(12.6, -6.1, 1.18);
addTree(15.0, -5.4, 0.86);
addTree(-4.8, -8.0, 1.0);
addTree(5.2, -8.2, 1.12);
// Pale folded forms establish a quiet distant horizon.
for (const mountain of [
[-15, -14, 5.7, 5.0],
[-6, -16, 7.0, 6.8],
[6, -16, 6.5, 5.8],
[16, -14, 5.8, 5.4]
]) {
const mesh = new THREE.Mesh(
new THREE.ConeGeometry(mountain[2], mountain[3], 5),
new THREE.MeshStandardMaterial({
color: 0xa7b5ae,
roughness: 1,
flatShading: true
})
);
mesh.position.set(mountain[0], mountain[3] / 2 - 0.2, mountain[1]);
mesh.rotation.y = 0.3;
mesh.receiveShadow = true;
scene.add(mesh);
}
// Selection outlines and pickable geometry.
const selectables = [];
const outlines = {};
for (const building of Object.values(buildings)) {
const halfW = building.width / 2 + 0.42;
const backZ = -building.depth / 2 - 0.35;
const frontZ = building.front + 3.85;
const points = [
new THREE.Vector3(-halfW, 0.045, backZ),
new THREE.Vector3(halfW, 0.045, backZ),
new THREE.Vector3(halfW, 0.045, frontZ),
new THREE.Vector3(-halfW, 0.045, frontZ)
];
const material = new THREE.LineBasicMaterial({
color: 0xb9573e,
transparent: true,
opacity: 0.8,
depthTest: false
});
const outline = new THREE.LineLoop(
new THREE.BufferGeometry().setFromPoints(points),
material
);
outline.renderOrder = 10;
building.root.add(outline);
outlines[building.id] = outline;
building.root.traverse((object) => {
if (object.isMesh) {
object.userData.buildingId = building.id;
selectables.push(object);
}
});
}
// ------------------------------------------------------------
// Selection and story panel
// ------------------------------------------------------------
const storyIndex = document.querySelector("#story-index");
const storyRhythm = document.querySelector("#story-rhythm");
const storyTitle = document.querySelector("#story-title");
const storyText = document.querySelector("#story-text");
const selectButtons = [...document.querySelectorAll("[data-select]")];
const stories = {
all: {
index: "Composition / 01",
rhythm: "3 · 5 · 7 bays",
title: "A shared civic cadence",
text:
"The same 1.5-metre portal repeats across three scales. Its deep reveals hold changing shadows, while each threshold becomes a different kind of gathering space."
},
home: {
index: "Program / 01",
rhythm: "3 domestic bays",
title: "Shelter becomes a room",
text:
"Deep reveals frame two contemplative windows and one open door. A low gable gathers light toward the hearth, while the courtyard turns the facade edge into an intimate place to meet."
},
school: {
index: "Program / 02",
rhythm: "5 learning bays",
title: "A shaded place to learn",
text:
"Five repeated portals become classrooms beneath a continuous arcade. The folded roof opens learning to high light, and broad steps turn the entrance into a small civic forum."
},
market: {
index: "Program / 03",
rhythm: "7 exchange bays",
title: "The edge becomes public",
text:
"Seven open frames hold counters, goods, and small suspended lights. Repeating awnings modulate shade, while the long table extends the market from private transaction into shared gathering."
}
};
let selected = "all";
function updateSelection(id) {
selected = id;
const story = stories[id];
storyIndex.textContent = story.index;
storyRhythm.textContent = story.rhythm;
storyTitle.textContent = story.title;
storyText.textContent = story.text;
for (const button of selectButtons) {
button.classList.toggle("active", button.dataset.select === id);
}
for (const [buildingId, outline] of Object.entries(outlines)) {
const active = id === "all" || id === buildingId;
outline.visible = active;
outline.material.opacity = id === buildingId ? 0.95 : 0.22;
}
}
for (const button of selectButtons) {
button.addEventListener("click", () => {
const id = button.dataset.select;
updateSelection(id);
focusCamera(id);
});
}
// ------------------------------------------------------------
// Camera controls implemented directly, without add-ons
// ------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 1.65, 1.2),
radius: 24,
theta: 0.48,
phi: 0.97
};
const spherical = new THREE.Spherical();
const cameraOffset = new THREE.Vector3();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let cameraTween = null;
let dragging = false;
let dragMoved = false;
let dragMode = "orbit";
let lastX = 0;
let lastY = 0;
function updateCameraFromState() {
spherical.set(controls.radius, controls.phi, controls.theta);
cameraOffset.setFromSpherical(spherical);
camera.position.copy(controls.target).add(cameraOffset);
camera.lookAt(controls.target);
}
function focusCamera(id, instant = false) {
let target;
let position;
if (id === "home") {
target = new THREE.Vector3(-8.25, 1.5, 1.15);
position = new THREE.Vector3(-3.25, 5.5, 10.1);
} else if (id === "school") {
target = new THREE.Vector3(0, 1.75, 0.7);
position = new THREE.Vector3(6.0, 7.1, 12.7);
} else if (id === "market") {
target = new THREE.Vector3(8.75, 1.45, 1.35);
position = new THREE.Vector3(15.3, 7.6, 14.0);
} else {
target = new THREE.Vector3(0, 1.65, 1.2);
position = new THREE.Vector3(12.4, 10.2, 20.2);
}
if (instant) {
controls.target.copy(target);
camera.position.copy(position);
camera.lookAt(target);
cameraOffset.copy(camera.position).sub(controls.target);
spherical.setFromVector3(cameraOffset);
controls.radius = spherical.radius;
controls.theta = spherical.theta;
controls.phi = spherical.phi;
cameraTween = null;
return;
}
cameraTween = {
start: performance.now(),
duration: 950,
fromTarget: controls.target.clone(),
toTarget: target,
fromPosition: camera.position.clone(),
toPosition: position
};
}
updateCameraFromState();
canvas.addEventListener("pointerdown", (event) => {
dragging = true;
dragMoved = false;
dragMode = event.shiftKey || event.button === 2 ? "pan" : "orbit";
lastX = event.clientX;
lastY = event.clientY;
cameraTween = null;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
if (Math.abs(dx) + Math.abs(dy) > 2) dragMoved = true;
if (dragMode === "orbit") {
controls.theta -= dx * 0.006;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.005,
0.34,
1.38
);
} else {
const right = new THREE.Vector3();
const up = new THREE.Vector3();
camera.matrix.extractBasis(right, up, new THREE.Vector3());
const panScale = controls.radius * 0.0014;
controls.target.addScaledVector(right, -dx * panScale);
controls.target.addScaledVector(up, dy * panScale);
}
lastX = event.clientX;
lastY = event.clientY;
updateCameraFromState();
});
canvas.addEventListener("pointerup", (event) => {
dragging = false;
if (!dragMoved) {
const rect = canvas.getBoundingClientRect();
pointer.x =
((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y =
-((event.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const hit = raycaster.intersectObjects(selectables, false)[0];
if (hit?.object.userData.buildingId) {
updateSelection(hit.object.userData.buildingId);
}
}
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
});
canvas.addEventListener("pointercancel", () => {
dragging = false;
});
canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTween = null;
controls.radius = THREE.MathUtils.clamp(
controls.radius * Math.exp(event.deltaY * 0.001),
7,
38
);
updateCameraFromState();
},
{ passive: false }
);
// ------------------------------------------------------------
// Day / dusk lighting
// ------------------------------------------------------------
const lightToggle = document.querySelector("#light-toggle");
let dusk = false;
let lightMix = 0;
const daySunPosition = new THREE.Vector3(-9, 16, 11);
const duskSunPosition = new THREE.Vector3(-13, 5.2, 6);
const daySunColor = new THREE.Color(0xffe8bd);
const duskSunColor = new THREE.Color(0xff9865);
lightToggle.addEventListener("click", () => {
dusk = !dusk;
lightToggle.textContent = dusk ? "Daylight" : "Dusk light";
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = clock.getDelta();
// Smooth theme transition.
const targetMix = dusk ? 1 : 0;
lightMix += (targetMix - lightMix) * (1 - Math.exp(-delta * 3.6));
scene.background.copy(daySky).lerp(duskSky, lightMix);
scene.fog.color.copy(dayFog).lerp(duskFog, lightMix);
hemisphere.intensity = THREE.MathUtils.lerp(1.75, 0.54, lightMix);
sun.intensity = THREE.MathUtils.lerp(3.1, 0.78, lightMix);
sun.color.copy(daySunColor).lerp(duskSunColor, lightMix);
sun.position.copy(daySunPosition).lerp(duskSunPosition, lightMix);
glass.emissiveIntensity = THREE.MathUtils.lerp(0.03, 0.62, lightMix);
MAT.glow.emissiveIntensity = THREE.MathUtils.lerp(0.35, 1.25, lightMix);
renderer.toneMappingExposure = THREE.MathUtils.lerp(1.05, 0.92, lightMix);
scene.traverse((object) => {
if (object.isPointLight && object.userData.day !== undefined) {
object.intensity = THREE.MathUtils.lerp(
object.userData.day,
object.userData.night,
lightMix
);
}
});
sunDisc.position
.copy(sun.position)
.normalize()
.multiplyScalar(34)
.add(new THREE.Vector3(0, 1, -5));
sunDisc.material.color.copy(daySunColor).lerp(duskSunColor, lightMix);
// Camera focus transitions.
if (cameraTween) {
const raw = (performance.now() - cameraTween.start) / cameraTween.duration;
const t = THREE.MathUtils.clamp(raw, 0, 1);
const eased = 1 - Math.pow(1 - t, 3);
camera.position.lerpVectors(
cameraTween.fromPosition,
cameraTween.toPosition,
eased
);
controls.target.lerpVectors(
cameraTween.fromTarget,
cameraTween.toTarget,
eased
);
camera.lookAt(controls.target);
if (t >= 1) {
cameraOffset.copy(camera.position).sub(controls.target);
spherical.setFromVector3(cameraOffset);
controls.radius = spherical.radius;
controls.theta = spherical.theta;
controls.phi = spherical.phi;
cameraTween = null;
}
} else if (!dragging) {
updateCameraFromState();
}
// Very subtle label breathing.
const pulse = 1 + Math.sin(performance.now() * 0.0016) * 0.018;
for (const building of Object.values(buildings)) {
building.label.scale.set(3.15 * pulse, 0.74 * pulse, 1);
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```