Prompt specification
Build or customize the Three.js 3D scene "High Line block above Chelsea streets" 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: High Line block above Chelsea streets
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/high-line-block-above-chelsea-streets-x2771
Scene Description Prompt:
A voxel Chelsea block with New York's High Line above an active street, showing life on both levels. Three.js from cdnjs, one HTML file.
Working Three.js Starter (high-line-block-above-chelsea-streets-x2771):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="theme-color" content="#d8dfdc">
<title>Chelsea — The High Line</title>
<style>
:root {
color-scheme: light;
--ink: #202826;
--paper: rgba(247, 245, 235, 0.9);
--accent: #db594f;
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8dfdc;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas:active {
cursor: grabbing;
}
.hud {
position: fixed;
inset: 0;
z-index: 2;
pointer-events: none;
}
.title-card {
position: absolute;
top: clamp(18px, 4vw, 42px);
left: clamp(18px, 4vw, 48px);
width: min(370px, calc(100vw - 36px));
padding: 20px 22px 18px;
color: var(--ink);
background: var(--paper);
border: 1px solid rgba(32, 40, 38, 0.12);
border-radius: 4px;
box-shadow: 0 12px 35px rgba(38, 46, 43, 0.12);
backdrop-filter: blur(12px);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #53605c;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.2em;
text-transform: uppercase;
}
.eyebrow::before {
width: 23px;
height: 3px;
content: "";
background: var(--accent);
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(32px, 5vw, 48px);
font-weight: 500;
line-height: 0.95;
letter-spacing: -0.04em;
}
.subtitle {
margin: 13px 0 0;
color: #5d6763;
font-size: 12px;
line-height: 1.55;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 12px;
margin-top: 16px;
padding-top: 14px;
border-top: 1px solid rgba(32, 40, 38, 0.11);
color: #3e4945;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.legend span {
display: flex;
align-items: center;
gap: 6px;
}
.swatch {
width: 8px;
height: 8px;
border-radius: 2px;
}
.controls {
position: absolute;
right: clamp(14px, 3vw, 34px);
bottom: clamp(14px, 3vw, 28px);
display: flex;
align-items: center;
gap: 12px;
color: #33403b;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.controls kbd {
padding: 7px 9px;
color: #33403b;
background: rgba(247, 245, 235, 0.82);
border: 1px solid rgba(32, 40, 38, 0.14);
border-radius: 3px;
box-shadow: 0 4px 12px rgba(38, 46, 43, 0.08);
font: inherit;
}
button {
pointer-events: auto;
padding: 9px 12px;
color: #f8f4e8;
background: #26312e;
border: 0;
border-radius: 3px;
font: inherit;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
cursor: pointer;
transition: transform 160ms ease, background 160ms ease;
}
button:hover {
background: #405049;
transform: translateY(-1px);
}
button:focus-visible {
outline: 3px solid rgba(219, 89, 79, 0.45);
outline-offset: 3px;
}
@media (max-width: 600px) {
.title-card {
padding: 15px 17px;
}
.subtitle,
.legend {
display: none;
}
.controls span {
display: none;
}
}
</style>
</head>
<body>
<div class="hud">
<section class="title-card" aria-label="Scene description">
<div class="eyebrow">New York · Chelsea</div>
<h1>Two levels<br>of city life.</h1>
<p class="subtitle">
An elevated garden threads through a working Manhattan block while taxis,
bikes, pedestrians, and cafés animate below.
</p>
<div class="legend">
<span><i class="swatch" style="background:#4f8b57"></i>High Line</span>
<span><i class="swatch" style="background:#f2bd2e"></i>Street</span>
<span><i class="swatch" style="background:#d85e55"></i>People</span>
</div>
</section>
<div class="controls">
<span>Drag to orbit · Scroll to zoom</span>
<kbd>← → ↑ ↓</kbd>
<button id="reset" type="button">Reset view</button>
</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, camera, and lighting
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
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;
document.body.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color("#d6dfdc");
scene.fog = new THREE.Fog("#d6dfdc", 72, 155);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
240
);
const hemisphere = new THREE.HemisphereLight("#e8f3f4", "#8c7d68", 2.25);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight("#fff0d0", 3.2);
sun.position.set(-32, 48, 26);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -52;
sun.shadow.camera.right = 52;
sun.shadow.camera.top = 55;
sun.shadow.camera.bottom = -55;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 125;
sun.shadow.bias = -0.00035;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const fill = new THREE.DirectionalLight("#bfd4df", 0.8);
fill.position.set(30, 18, -35);
scene.add(fill);
// -------------------------------------------------------------------------
// Small utilities and a deterministic random generator
// -------------------------------------------------------------------------
const unitBox = new THREE.BoxGeometry(1, 1, 1);
const materialCache = new Map();
const dynamicPeople = [];
const vehicles = [];
const cyclists = [];
let randomSeed = 202503;
function random() {
randomSeed = (randomSeed * 1664525 + 1013904223) >>> 0;
return randomSeed / 4294967296;
}
function range(min, max) {
return min + random() * (max - min);
}
function pick(list) {
return list[Math.floor(random() * list.length)];
}
function material(color, emissive = 0) {
const key = `${color}_${emissive}`;
if (!materialCache.has(key)) {
materialCache.set(
key,
new THREE.MeshStandardMaterial({
color,
roughness: 0.82,
metalness: 0.02,
emissive: emissive ? color : 0x000000,
emissiveIntensity: emissive
})
);
}
return materialCache.get(key);
}
function box(
width,
height,
depth,
color,
x = 0,
y = 0,
z = 0,
options = {}
) {
const mesh = new THREE.Mesh(
unitBox,
options.material || material(color, options.emissive || 0)
);
mesh.scale.set(width, height, depth);
mesh.position.set(x, y, z);
if (options.rotation) {
mesh.rotation.set(...options.rotation);
}
mesh.castShadow = options.cast ?? height > 0.12;
mesh.receiveShadow = options.receive ?? true;
if (options.parent) {
options.parent.add(mesh);
} else {
scene.add(mesh);
}
return mesh;
}
function groupAt(x = 0, y = 0, z = 0, parent = scene) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
return group;
}
// -------------------------------------------------------------------------
// Diorama base and street
// -------------------------------------------------------------------------
box(67, 1.4, 74, "#a99d87", 0, -0.85, 0, { cast: false });
box(64, 0.22, 71, "#c7bda6", 0, -0.08, 0, { cast: false });
// Broad pale ground beyond the model.
box(240, 0.25, 240, "#cdd8d4", 0, -1.65, -12, { cast: false });
const road = box(20, 0.2, 68, "#343b3d", 0, 0.08, 0, {
cast: false
});
// Sidewalks and curbs.
box(4.5, 0.36, 68, "#bdb8aa", -11.9, 0.2, 0);
box(4.5, 0.36, 68, "#bdb8aa", 11.9, 0.2, 0);
box(0.24, 0.38, 68, "#777c77", -9.45, 0.2, 0);
box(0.24, 0.38, 68, "#777c77", 9.45, 0.2, 0);
// Lane markings.
for (let z = -31; z <= 31; z += 4.2) {
box(0.13, 0.025, 2.2, "#e9e4cd", -3.9, 0.195, z, { cast: false });
box(0.13, 0.025, 2.2, "#e9e4cd", 3.9, 0.195, z, { cast: false });
box(0.11, 0.025, 2.1, "#d5aa45", 0, 0.195, z, { cast: false });
}
// Zebra crossings.
function crosswalk(z) {
for (let x = -8.8; x <= 8.8; x += 1.35) {
box(0.67, 0.028, 3.6, "#ece8d8", x, 0.205, z, { cast: false });
}
}
crosswalk(17);
crosswalk(-23);
// Manhole covers and drains.
for (let z = -27; z < 29; z += 11) {
box(1.25, 0.03, 1.25, "#555c5b", -4.1, 0.205, z, { cast: false });
for (let i = 0; i < 5; i++) {
box(0.85, 0.035, 0.08, "#252c2c", 8.5, 0.215, z - 0.5 + i * 0.24, {
cast: false
});
}
}
// -------------------------------------------------------------------------
// High Line structure
// -------------------------------------------------------------------------
const deckX = 3;
const deckTop = 7.45;
// Columns and cross-bracing.
for (let z = -29; z <= 30; z += 11.5) {
box(0.72, 6.85, 0.72, "#4b5554", deckX - 1.55, 3.35, z);
box(0.72, 6.85, 0.72, "#4b5554", deckX + 1.55, 3.35, z);
box(3.85, 0.32, 0.45, "#56605e", deckX, 6.38, z);
}
// Main underside beams.
box(0.5, 0.58, 61, "#343d3d", deckX - 1.55, 6.63, 0);
box(0.5, 0.58, 61, "#343d3d", deckX + 1.55, 6.63, 0);
// Deck and track bed.
box(5.6, 0.56, 61, "#6e746d", deckX, 6.98, 0);
box(4.95, 0.15, 60.5, "#8d8b76", deckX, 7.32, 0, { cast: false });
box(1.15, 0.035, 60.5, "#b9b39d", deckX - 1.7, 7.415, 0, { cast: false });
box(1.15, 0.035, 60.5, "#b9b39d", deckX + 1.7, 7.415, 0, { cast: false });
// Track ties embedded in the gravel path.
for (let z = -29.5; z <= 29.5; z += 1.1) {
box(0.78, 0.035, 0.16, "#665f50", deckX - 1.72, 7.445, z, {
cast: false
});
box(0.78, 0.035, 0.16, "#665f50", deckX + 1.72, 7.445, z, {
cast: false
});
}
// Thin outer railings.
const railLeft = deckX - 2.65;
const railRight = deckX + 2.65;
for (let z = -30; z <= 30; z += 2.5) {
box(0.09, 1.05, 0.09, "#8c9692", railLeft, 7.92, z);
box(0.09, 1.05, 0.09, "#8c9692", railRight, 7.92, z);
}
box(0.1, 0.1, 60.8, "#aab2ad", railLeft, 8.42, 0);
box(0.1, 0.1, 60.8, "#aab2ad", railRight, 8.42, 0);
function planter(x, z, width = 1.25, depth = 4.7) {
box(width, 0.72, depth, "#858b82", x, 7.78, z);
box(width - 0.18, 0.08, depth - 0.18, "#4c4638", x, 8.16, z, {
cast: false
});
const pieces = Math.max(2, Math.floor(depth / 1.25));
for (let i = 0; i < pieces; i++) {
const pz = z - depth / 2 + 0.65 + i * ((depth - 1.3) / Math.max(1, pieces - 1));
const bush = box(
width * range(0.65, 0.85),
range(0.55, 1.0),
range(0.8, 1.25),
pick(["#3f7447", "#4d8650", "#628f54", "#315e3d"]),
x + range(-0.08, 0.08),
8.55,
pz
);
bush.rotation.y = range(-0.15, 0.15);
}
}
function voxelTree(x, y, z, scale = 1) {
box(0.38 * scale, 3.4 * scale, 0.38 * scale, "#705743", x, y + 1.7 * scale, z);
box(1.7 * scale, 1.45 * scale, 1.7 * scale, "#527b49", x, y + 3.45 * scale, z);
box(2.45 * scale, 1.25 * scale, 2.15 * scale, "#426e43", x, y + 4.35 * scale, z);
box(1.45 * scale, 1.3 * scale, 1.5 * scale, "#679050", x + 0.45 * scale, y + 5.05 * scale, z);
box(1.1 * scale, 0.95 * scale, 1.2 * scale, "#739758", x - 0.65 * scale, y + 4.55 * scale, z + 0.2);
}
for (let z = -27; z < 29; z += 7.5) {
planter(deckX - 2.02, z);
if (Math.floor((z + 27) / 7.5) % 2 === 0) {
planter(deckX + 2.02, z + 2.2, 1.05, 4.0);
}
}
voxelTree(deckX - 2.03, 8.13, -24.8, 1.1);
voxelTree(deckX - 2.03, 8.13, -9.8, 0.95);
voxelTree(deckX - 2.03, 8.13, 9.7, 1.08);
voxelTree(deckX - 2.03, 8.13, 24.7, 1.0);
// Benches.
for (const z of [-20, -5, 10, 25]) {
const x = deckX + 1.95;
box(0.8, 0.15, 2.15, "#9b7753", x, 8.03, z);
box(0.15, 0.78, 2.15, "#9b7753", x + 0.33, 8.35, z);
box(0.12, 0.7, 0.12, "#3d4845", x - 0.25, 7.68, z - 0.72);
box(0.12, 0.7, 0.12, "#3d4845", x - 0.25, 7.68, z + 0.72);
}
// Small High Line lamps.
for (let z = -27; z <= 27; z += 13.5) {
box(0.12, 3.2, 0.12, "#394441", deckX + 2.36, 8.92, z);
box(0.12, 0.12, 1.15, "#394441", deckX + 1.88, 10.45, z);
box(0.38, 0.16, 0.7, "#e8dfbd", deckX + 1.38, 10.36, z, {
emissive: 0.28
});
}
// -------------------------------------------------------------------------
// Chelsea buildings
// -------------------------------------------------------------------------
const buildingColors = [
"#a85f4d",
"#c48364",
"#8b7669",
"#b39579",
"#697b78",
"#9d8e79",
"#766965"
];
const windowColors = ["#3e5962", "#46666d", "#263f48", "#71878a"];
function addBuilding(x, z, width, depth, height, color) {
const facadeX = x < 0 ? x + width / 2 - 0.08 : x - width / 2 + 0.08;
const streetDirection = x < 0 ? 1 : -1;
box(width, height, depth, color, x, height / 2, z);
// Roof cap and parapet.
box(width + 0.18, 0.35, depth + 0.18, "#77766d", x, height + 0.12, z);
box(width, 0.75, 0.28, color, x, height + 0.55, z - depth / 2);
box(width, 0.75, 0.28, color, x, height + 0.55, z + depth / 2);
box(0.28, 0.75, depth, color, x - width / 2, height + 0.55, z);
box(0.28, 0.75, depth, color, x + width / 2, height + 0.55, z);
// Floor bands and windows.
const floors = Math.floor((height - 4) / 3.15);
for (let floor = 0; floor < floors; floor++) {
const y = 4.5 + floor * 3.05;
box(0.24, 0.18, depth - 0.25, "#d2c4ad", facadeX, y - 1.48, z);
for (let wz = z - depth / 2 + 2; wz < z + depth / 2 - 1.2; wz += 3.25) {
const lit = random() > 0.78;
const windowColor = lit ? "#e5c477" : pick(windowColors);
box(
0.16,
1.35,
1.55,
windowColor,
facadeX,
y,
wz,
{
cast: false,
emissive: lit ? 0.25 : 0
}
);
box(0.18, 0.12, 1.75, "#d7cbb6", facadeX, y - 0.74, wz, {
cast: false
});
}
}
// Ground-floor storefront glass.
const storefrontCount = Math.max(2, Math.floor(depth / 5));
const storefrontWidth = depth / storefrontCount - 1.2;
for (let i = 0; i < storefrontCount; i++) {
const wz = z - depth / 2 + 2.5 + i * (depth / storefrontCount);
box(
0.18,
2.25,
storefrontWidth,
"#304b51",
facadeX,
1.6,
wz,
{ cast: false }
);
box(
0.2,
0.16,
storefrontWidth + 0.2,
"#e5d8bd",
facadeX,
2.82,
wz
);
const awningColor = pick(["#9d4f45", "#526d67", "#bd8054", "#3e5c65"]);
box(
1.25,
0.18,
storefrontWidth + 0.15,
awningColor,
facadeX + streetDirection * 0.55,
3.1,
wz
);
// Awning valance.
box(
0.12,
0.42,
storefrontWidth + 0.15,
awningColor,
facadeX + streetDirection * 1.08,
2.91,
wz
);
}
// Rooftop equipment and a water tower.
if (random() > 0.35) {
box(2.4, 1.05, 2.8, "#818681", x + range(-2, 2), height + 0.82, z + range(-2, 2));
}
if (random() > 0.5) {
const tx = x + range(-width * 0.22, width * 0.22);
const tz = z + range(-depth * 0.2, depth * 0.2);
box(1.65, 2.15, 1.65, "#78614d", tx, height + 1.75, tz);
box(1.9, 0.18, 1.9, "#4a4c46", tx, height + 2.85, tz);
for (const sx of [-0.55, 0.55]) {
for (const sz of [-0.55, 0.55]) {
box(0.12, 1.45, 0.12, "#4d504b", tx + sx, height + 0.9, tz + sz);
}
}
}
}
// Left side of the avenue.
addBuilding(-24, -26, 12, 14, 23, pick(buildingColors));
addBuilding(-24, -9, 13, 16, 29, pick(buildingColors));
addBuilding(-24, 10, 12, 17, 20, pick(buildingColors));
addBuilding(-24, 28, 13, 13, 25, pick(buildingColors));
// Right side, with a slightly lower foreground to keep the garden visible.
addBuilding(25, -26, 13, 15, 26, pick(buildingColors));
addBuilding(25, -9, 12, 17, 22, pick(buildingColors));
addBuilding(25, 10, 13, 17, 16, pick(buildingColors));
// Distant skyline.
for (let i = 0; i < 24; i++) {
const side = i % 2 === 0 ? -1 : 1;
const x = side * range(37, 58);
const z = range(-62, 50);
const h = range(13, 38);
box(
range(7, 13),
h,
range(8, 16),
pick(["#80908d", "#8b9994", "#778784", "#929d95"]),
x,
h / 2 - 0.4,
z
);
}
// -------------------------------------------------------------------------
// Sidewalk details: trees, lamps, café furniture, and street furniture
// -------------------------------------------------------------------------
function streetTree(x, z) {
box(2.2, 0.65, 2.2, "#767d74", x, 0.55, z);
box(1.8, 0.12, 1.8, "#504b3d", x, 0.91, z, { cast: false });
box(0.32, 3.1, 0.32, "#705743", x, 2.4, z);
box(1.65, 1.35, 1.65, "#4f7b48", x, 3.8, z);
box(2.15, 1.15, 1.85, "#426e43", x, 4.6, z);
box(1.25, 1.1, 1.3, "#6b9454", x - 0.45, 5.25, z + 0.1);
}
for (const z of [-27, -14, 2, 18, 29]) {
streetTree(-13.2, z);
streetTree(13.2, z - 3);
}
function streetLamp(x, z, direction) {
box(0.13, 5.5, 0.13, "#36423f", x, 2.85, z);
box(1.4, 0.13, 0.13, "#36423f", x + direction * 0.6, 5.5, z);
box(0.55, 0.18, 0.35, "#e4dcc4", x + direction * 1.18, 5.42, z, {
emissive: 0.16
});
}
for (let z = -28; z <= 29; z += 12) {
streetLamp(-9.85, z, -1);
streetLamp(9.85, z - 4, 1);
}
// Café tables and chairs.
function cafeSet(x, z) {
box(1.15, 0.13, 1.15, "#8d775f", x, 1.25, z);
box(0.18, 0.85, 0.18, "#4a514e", x, 0.78, z);
box(0.75, 0.12, 0.75, "#405b55", x, 0.72, z + 1.05);
box(0.75, 0.68, 0.12, "#405b55", x, 1.03, z + 1.38);
box(0.75, 0.12, 0.75, "#405b55", x, 0.72, z - 1.05);
box(0.75, 0.68, 0.12, "#405b55", x, 1.03, z - 1.38);
}
cafeSet(-12.0, -17);
cafeSet(-12.0, -15.4);
cafeSet(12.0, 8);
cafeSet(12.0, 9.6);
// Traffic lights.
function trafficLight(x, z, direction) {
box(0.14, 5.3, 0.14, "#333c3b", x, 2.7, z);
box(0.45, 1.25, 0.45, "#2c3434", x, 5.25, z);
box(0.19, 0.19, 0.08, "#df5a45", x, 5.58, z + 0.26, {
emissive: 0.45
});
box(0.19, 0.19, 0.08, "#d6aa39", x, 5.24, z + 0.26, {
emissive: 0.35
});
box(0.19, 0.19, 0.08, "#4b9b58", x, 4.9, z + 0.26, {
emissive: 0.35
});
}
trafficLight(-9.5, 15.7, -1);
trafficLight(9.5, 15.7, 1);
// Bollards and a subway entrance.
for (let z = -25; z <= 27; z += 8) {
box(0.22, 0.95, 0.22, "#38423f", -10.25, 0.82, z);
box(0.22, 0.95, 0.22, "#38423f", 10.25, 0.82, z + 2);
}
box(3.2, 0.35, 5.2, "#52625e", -13.2, 0.5, 3);
box(2.4, 0.12, 4.2, "#252e2d", -13.2, 0.72, 3, { cast: false });
for (const z of [1.1, 4.9]) {
box(0.12, 1.7, 0.12, "#3d4c48", -14.5, 1.25, z);
box(0.12, 1.7, 0.12, "#3d4c48", -11.9, 1.25, z);
}
box(1.4, 0.25, 0.7, "#4e7663", -13.2, 1.85, 0.75);
// -------------------------------------------------------------------------
// Voxel people
// -------------------------------------------------------------------------
const shirts = [
"#d85e55",
"#f0bf37",
"#4e79a1",
"#596d58",
"#8e5c81",
"#e7e0ce",
"#397b78"
];
const trousers = ["#33414c", "#4b4f47", "#6a5548", "#273a46"];
const skins = ["#e6b38c", "#bf815f", "#8f5f47", "#f0c8a5", "#744936"];
function makePerson(shirtColor = pick(shirts), scale = 1) {
const person = groupAt();
person.scale.setScalar(scale);
const skin = pick(skins);
const pants = pick(trousers);
box(0.48, 0.65, 0.29, shirtColor, 0, 1.03, 0, { parent: person });
box(0.31, 0.32, 0.3, skin, 0, 1.56, 0, { parent: person });
box(0.34, 0.1, 0.33, "#3c3732", 0, 1.74, -0.01, { parent: person });
const leftLeg = groupAt(-0.13, 0.72, 0, person);
const rightLeg = groupAt(0.13, 0.72, 0, person);
box(0.17, 0.67, 0.19, pants, 0, -0.32, 0, { parent: leftLeg });
box(0.17, 0.67, 0.19, pants, 0, -0.32, 0, { parent: rightLeg });
box(0.19, 0.12, 0.31, "#343633", 0, -0.62, 0.06, { parent: leftLeg });
box(0.19, 0.12, 0.31, "#343633", 0, -0.62, 0.06, { parent: rightLeg });
const leftArm = groupAt(-0.31, 1.27, 0, person);
const rightArm = groupAt(0.31, 1.27, 0, person);
box(0.14, 0.58, 0.16, shirtColor, 0, -0.27, 0, { parent: leftArm });
box(0.14, 0.58, 0.16, shirtColor, 0, -0.27, 0, { parent: rightArm });
box(0.14, 0.14, 0.15, skin, 0, -0.58, 0, { parent: leftArm });
box(0.14, 0.14, 0.15, skin, 0, -0.58, 0, { parent: rightArm });
person.userData.leftLeg = leftLeg;
person.userData.rightLeg = rightLeg;
person.userData.leftArm = leftArm;
person.userData.rightArm = rightArm;
return person;
}
function addWalker(options = {}) {
const person = makePerson(options.shirt, options.scale || 1);
const axis = options.axis || "z";
const min = options.min ?? -31;
const max = options.max ?? 31;
const direction = options.direction ?? (random() > 0.5 ? 1 : -1);
person.position.set(
options.x ?? range(-9.7, 9.7),
options.y ?? 0.37,
options.z ?? range(min, max)
);
dynamicPeople.push({
person,
axis,
min,
max,
direction,
speed: options.speed ?? range(0.55, 1.35),
phase: range(0, Math.PI * 2),
baseY: person.position.y,
bob: range(0.015, 0.055)
});
}
// Sidewalk pedestrians.
for (let i = 0; i < 18; i++) {
const side = i % 2 === 0 ? -1 : 1;
addWalker({
x: side * range(10.65, 12.6),
z: range(-30, 30),
min: -31,
max: 31,
y: 0.38
});
}
// Crosswalk pedestrians.
for (let i = 0; i < 4; i++) {
addWalker({
x: range(-8.5, 8.5),
z: 16.65 + range(-0.3, 0.3),
axis: "x",
min: -9,
max: 9,
y: 0.39,
speed: range(0.65, 1.05)
});
}
// High Line visitors.
for (let i = 0; i < 13; i++) {
addWalker({
x: range(1.6, 4.55),
z: range(-28, 28),
min: -29,
max: 29,
y: deckTop + 0.05,
speed: range(0.42, 0.9)
});
}
// A few people pausing at the rail.
for (const z of [-13, 6, 22]) {
const person = makePerson(pick(shirts), 0.98);
person.position.set(4.7, deckTop + 0.05, z);
person.rotation.y = Math.PI;
dynamicPeople.push({
person,
axis: "none",
min: z,
max: z,
direction: 0,
speed: 0,
phase: range(0, 6),
baseY: person.position.y,
bob: 0
});
}
// -------------------------------------------------------------------------
// Vehicles
// -------------------------------------------------------------------------
function makeCar(color, taxi = false, bus = false) {
const car = groupAt();
if (bus) {
box(2.25, 2.25, 6.1, color, 0, 1.35, 0, { parent: car });
box(2.08, 0.9, 0.08, "#30464d", 0, 1.72, 3.08, {
parent: car,
cast: false
});
box(2.08, 0.9, 0.08, "#30464d", 0, 1.72, -3.08, {
parent: car,
cast: false
});
for (const side of [-1, 1]) {
for (let z = -2; z <= 2; z += 1.2) {
box(0.06, 0.78, 0.82, "#30464d", side * 1.14, 1.72, z, {
parent: car,
cast: false
});
}
}
box(1.2, 0.3, 0.08, "#f1d994", 0, 2.65, 2.95, {
parent: car,
emissive: 0.2
});
} else {
box(1.8, 0.64, 3.65, color, 0, 0.68, 0, { parent: car });
box(1.55, 0.68, 1.85, color, 0, 1.22, -0.15, { parent: car });
box(1.42, 0.45, 0.08, "#344d55", 0, 1.25, 0.8, {
parent: car,
cast: false
});
box(1.42, 0.43, 0.08, "#344d55", 0, 1.25, -1.1, {
parent: car,
cast: false
});
for (const side of [-1, 1]) {
box(0.08, 0.44, 1.35, "#344d55", side * 0.79, 1.25, -0.15, {
parent: car,
cast: false
});
}
for (const side of [-1, 1]) {
box(0.35, 0.18, 0.08, "#fff0b3", side * 0.57, 0.76, 1.85, {
parent: car,
emissive: 0.35
});
box(0.32, 0.16, 0.08, "#aa3e37", side * 0.57, 0.76, -1.85, {
parent: car
});
}
if (taxi) {
box(1.62, 0.2, 0.2, "#292f2e", 0, 0.94, 0.3, { parent: car });
box(0.66, 0.24, 0.34, "#f4d767", 0, 1.69, 0.05, {
parent: car,
emissive: 0.12
});
for (let i = 0; i < 5; i++) {
box(0.25, 0.22, 0.025, "#343936", -0.65 + i * 0.32, 0.94, 0.415, {
parent: car,
cast: false
});
}
}
}
// Chunky, deliberately square wheels.
for (const side of [-1, 1]) {
for (const z of bus ? [-2.05, 2.05] : [-1.15, 1.15]) {
box(0.28, 0.62, 0.64, "#242a2a", side * 0.95, 0.48, z, {
parent: car
});
box(0.31, 0.24, 0.24, "#8d918d", side * 0.97, 0.48, z, {
parent: car
});
}
}
return car;
}
function addVehicle(x, z, color, direction, taxi = false, bus = false) {
const vehicle = makeCar(color, taxi, bus);
vehicle.position.set(x, 0.22, z);
vehicle.rotation.y = direction > 0 ? 0 : Math.PI;
vehicles.push({
object: vehicle,
direction,
speed: bus ? range(2.4, 3.2) : range(3.2, 5.5),
min: -35,
max: 35
});
}
addVehicle(-6.6, -18, "#efb92f", 1, true);
addVehicle(-6.6, 11, "#d6d8d1", 1);
addVehicle(-2.8, -4, "#476d78", -1);
addVehicle(-2.8, 24, "#e6e1d2", -1);
addVehicle(2.0, -25, "#b85045", 1);
addVehicle(2.0, 8, "#394b51", 1);
addVehicle(6.4, -10, "#dfb62e", -1, true);
addVehicle(6.4, 21, "#ded8c8", -1);
// -------------------------------------------------------------------------
// Cyclist
// -------------------------------------------------------------------------
function makeCyclist() {
const bike = groupAt();
const wheelGeometry = new THREE.CylinderGeometry(0.43, 0.43, 0.14, 10);
const wheelMaterial = material("#252c2c");
const wheels = [];
for (const z of [-0.9, 0.9]) {
const wheel = new THREE.Mesh(wheelGeometry, wheelMaterial);
wheel.rotation.z = Math.PI / 2;
wheel.position.set(0, 0.58, z);
wheel.castShadow = true;
bike.add(wheel);
wheels.push(wheel);
}
box(0.12, 0.12, 1.65, "#d75d52", 0, 0.85, 0, { parent: bike });
box(0.12, 0.12, 1.1, "#d75d52", 0, 1.05, 0.35, { parent: bike });
box(0.12, 0.85, 0.12, "#d75d52", 0, 1.08, -0.45, { parent: bike });
box(0.12, 0.7, 0.12, "#d75d52", 0, 1.05, 0.56, { parent: bike });
box(0.72, 0.1, 0.1, "#303a3a", 0, 1.42, 0.5, { parent: bike });
box(0.42, 0.1, 0.1, "#303a3a", 0, 1.42, -0.55, { parent: bike });
// Compact seated rider.
box(0.45, 0.55, 0.3, "#365e72", 0, 1.65, -0.05, { parent: bike });
box(0.3, 0.3, 0.3, pick(skins), 0, 2.05, 0.05, { parent: bike });
box(0.12, 0.55, 0.14, "#365e72", -0.28, 1.68, 0.2, { parent: bike });
box(0.12, 0.55, 0.14, "#365e72", 0.28, 1.68, 0.2, { parent: bike });
box(0.16, 0.5, 0.17, "#33424d", -0.2, 1.2, -0.32, { parent: bike });
box(0.16, 0.5, 0.17, "#33424d", 0.2, 1.2, 0.18, { parent: bike });
bike.userData.wheels = wheels;
return bike;
}
const bicycle = makeCyclist();
bicycle.position.set(8.1, 0.2, -15);
scene.add(bicycle);
cyclists.push({
object: bicycle,
speed: 4.1,
min: -34,
max: 34
});
// -------------------------------------------------------------------------
// Background sun and blocky clouds
// -------------------------------------------------------------------------
const sunDisc = new THREE.Mesh(
new THREE.SphereGeometry(4.8, 16, 12),
new THREE.MeshBasicMaterial({ color: "#f5d49b" })
);
sunDisc.position.set(-53, 39, -72);
scene.add(sunDisc);
function cloud(x, y, z, scale) {
const group = groupAt(x, y, z);
box(7 * scale, 2.2 * scale, 2.4 * scale, "#eef1e9", 0, 0, 0, {
parent: group,
cast: false
});
box(4.2 * scale, 2.8 * scale, 2.5 * scale, "#eef1e9", -1.5 * scale, 1.1 * scale, 0, {
parent: group,
cast: false
});
box(3.4 * scale, 2.2 * scale, 2.4 * scale, "#eef1e9", 2.1 * scale, 0.7 * scale, 0, {
parent: group,
cast: false
});
}
cloud(-28, 32, -66, 1.7);
cloud(27, 39, -79, 2.1);
cloud(-48, 43, -95, 2.4);
// -------------------------------------------------------------------------
// Custom camera controls — no external controls addon
// -------------------------------------------------------------------------
const controls = {
theta: 0.68,
phi: 1.02,
radius: 67,
target: new THREE.Vector3(0, 5.1, 0)
};
const defaultControls = {
theta: 0.68,
phi: 1.02,
radius: 67
};
function updateCamera() {
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
const pointers = new Map();
let lastPinchDistance = 0;
renderer.domElement.addEventListener("pointerdown", (event) => {
renderer.domElement.setPointerCapture(event.pointerId);
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
lastPinchDistance = Math.hypot(a.x - b.x, a.y - b.y);
}
});
renderer.domElement.addEventListener("pointermove", (event) => {
const previous = pointers.get(event.pointerId);
if (!previous) return;
if (pointers.size === 1) {
const dx = event.clientX - previous.x;
const dy = event.clientY - previous.y;
controls.theta -= dx * 0.0052;
controls.phi = THREE.MathUtils.clamp(
controls.phi - dy * 0.0045,
0.38,
1.38
);
}
pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });
if (pointers.size === 2) {
const [a, b] = [...pointers.values()];
const distance = Math.hypot(a.x - b.x, a.y - b.y);
if (lastPinchDistance > 0) {
controls.radius = THREE.MathUtils.clamp(
controls.radius * (lastPinchDistance / distance),
28,
100
);
}
lastPinchDistance = distance;
}
updateCamera();
});
function releasePointer(event) {
pointers.delete(event.pointerId);
lastPinchDistance = 0;
}
renderer.domElement.addEventListener("pointerup", releasePointer);
renderer.domElement.addEventListener("pointercancel", releasePointer);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
controls.radius = THREE.MathUtils.clamp(
controls.radius + event.deltaY * 0.055,
28,
100
);
updateCamera();
},
{ passive: false }
);
window.addEventListener("keydown", (event) => {
let changed = true;
switch (event.key) {
case "ArrowLeft":
controls.theta += 0.08;
break;
case "ArrowRight":
controls.theta -= 0.08;
break;
case "ArrowUp":
controls.phi = Math.max(0.38, controls.phi - 0.06);
break;
case "ArrowDown":
controls.phi = Math.min(1.38, controls.phi + 0.06);
break;
default:
changed = false;
}
if (changed) {
event.preventDefault();
updateCamera();
}
});
document.getElementById("reset").addEventListener("click", () => {
controls.theta = defaultControls.theta;
controls.phi = defaultControls.phi;
controls.radius = defaultControls.radius;
updateCamera();
});
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
const clock = new THREE.Clock();
let elapsed = 0;
function animate() {
const delta = Math.min(clock.getDelta(), 0.05);
elapsed += delta;
// Traffic.
for (const vehicle of vehicles) {
vehicle.object.position.z += vehicle.speed * vehicle.direction * delta;
if (vehicle.object.position.z > vehicle.max) {
vehicle.object.position.z = vehicle.min;
} else if (vehicle.object.position.z < vehicle.min) {
vehicle.object.position.z = vehicle.max;
}
}
// Cyclist.
for (const cyclist of cyclists) {
cyclist.object.position.z += cyclist.speed * delta;
if (cyclist.object.position.z > cyclist.max) {
cyclist.object.position.z = cyclist.min;
}
for (const wheel of cyclist.object.userData.wheels) {
wheel.rotation.x -= cyclist.speed * delta * 2.2;
}
}
// Pedestrians.
for (const walker of dynamicPeople) {
const { person } = walker;
const stride = Math.sin(elapsed * walker.speed * 7 + walker.phase);
if (walker.axis === "z") {
person.position.z += walker.speed * walker.direction * delta;
if (person.position.z > walker.max) {
walker.direction = -1;
} else if (person.position.z < walker.min) {
walker.direction = 1;
}
person.rotation.y = walker.direction > 0 ? 0 : Math.PI;
} else if (walker.axis === "x") {
person.position.x += walker.speed * walker.direction * delta;
if (person.position.x > walker.max) {
walker.direction = -1;
} else if (person.position.x < walker.min) {
walker.direction = 1;
}
person.rotation.y = walker.direction > 0 ? Math.PI / 2 : -Math.PI / 2;
}
person.position.y =
walker.baseY + Math.abs(stride) * walker.bob;
const amplitude = walker.speed > 0 ? 0.52 : 0.08;
person.userData.leftLeg.rotation.x = stride * amplitude;
person.userData.rightLeg.rotation.x = -stride * amplitude;
person.userData.leftArm.rotation.x = -stride * amplitude * 0.75;
person.userData.rightArm.rotation.x = stride * amplitude * 0.75;
}
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.8));
renderer.setSize(window.innerWidth, window.innerHeight);
});
updateCamera();
renderer.setAnimationLoop(animate);
</script>
</body>
</html>
```