Prompt specification
Build or customize the Three.js 3D scene "Evening street-food lane" 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: Evening street-food lane
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/evening-street-food-lane-x0519
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing night-market lighting. Compose three stalls with varied food displays, seating, and warm practical lights; customers remain readable in silhouette without losing the separation between counters and walking space. Stylized solid forms.
Working Three.js Starter (evening-street-food-lane-x0519):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lantern Lane — Night Market</title>
<style>
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #10111d;
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;
}
.title-card {
position: fixed;
top: 24px;
left: 26px;
z-index: 10;
color: #f7dfbc;
pointer-events: none;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75);
}
.title-card .kicker {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 6px;
color: #eab873;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.title-card .kicker::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: #ffb75c;
box-shadow: 0 0 14px #ff9a42;
}
.title-card h1 {
margin: 0;
font-size: clamp(25px, 4vw, 48px);
font-weight: 650;
line-height: 0.95;
letter-spacing: -0.04em;
}
.title-card p {
margin: 10px 0 0;
color: rgba(235, 219, 198, 0.67);
font-size: 12px;
letter-spacing: 0.08em;
}
.time-card {
position: fixed;
top: 25px;
right: 26px;
z-index: 10;
padding: 9px 12px;
border: 1px solid rgba(255, 220, 168, 0.16);
border-radius: 999px;
background: rgba(13, 14, 25, 0.46);
color: #e9c48d;
font-size: 10px;
font-weight: 700;
letter-spacing: 0.16em;
backdrop-filter: blur(8px);
pointer-events: none;
}
.hint {
position: fixed;
left: 50%;
bottom: 22px;
z-index: 10;
transform: translateX(-50%);
padding: 9px 14px;
border: 1px solid rgba(255, 255, 255, 0.09);
border-radius: 999px;
background: rgba(12, 13, 23, 0.58);
color: rgba(239, 230, 218, 0.62);
font-size: 10px;
letter-spacing: 0.07em;
white-space: nowrap;
backdrop-filter: blur(8px);
pointer-events: none;
}
@media (max-width: 640px) {
.title-card {
top: 18px;
left: 18px;
}
.title-card p,
.time-card {
display: none;
}
.hint {
bottom: 14px;
font-size: 9px;
}
}
</style>
</head>
<body>
<div class="title-card">
<div class="kicker">Night market</div>
<h1>Lantern Lane</h1>
<p>Warm food, cool streets, late evening.</p>
</div>
<div class="time-card">OPEN · 22:40</div>
<div class="hint">Drag to orbit · Scroll or pinch to zoom · Double-click to reset</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.createElement("canvas");
document.body.appendChild(canvas);
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.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x10111e);
scene.fog = new THREE.Fog(0x111321, 18, 35);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
70
);
const cameraTarget = new THREE.Vector3(0, 1.25, -0.8);
const view = {
yaw: -0.12,
pitch: 0.48,
radius: window.innerWidth < 700 ? 19.5 : 16.7,
targetYaw: -0.12,
targetPitch: 0.48,
targetRadius: window.innerWidth < 700 ? 19.5 : 16.7
};
// -------------------------------------------------------------------------
// Materials and geometry helpers
// -------------------------------------------------------------------------
function standard(color, roughness = 0.78, metalness = 0) {
return new THREE.MeshStandardMaterial({
color,
roughness,
metalness
});
}
function emissive(color, intensity = 1.7) {
return new THREE.MeshStandardMaterial({
color,
emissive: color,
emissiveIntensity: intensity,
roughness: 0.38
});
}
const M = {
ground: standard(0x171925),
aisle: standard(0x252738),
aisleEdge: standard(0x746049, 0.55, 0.38),
dark: standard(0x11131f),
black: standard(0x090b12),
steel: standard(0x333746, 0.4, 0.65),
brass: standard(0xb6874f, 0.38, 0.62),
cream: standard(0xe8d5b4),
wood: standard(0x754d3d),
woodLight: standard(0xa97854),
brick: standard(0x563a3e),
teal: standard(0x318b86),
red: standard(0xc7533f),
plum: standard(0x8e4778),
blue: standard(0x35486e),
green: standard(0x496d4d),
orange: standard(0xd8793d),
noodle: standard(0xe8c47c),
broth: standard(0x9c6335),
meat: standard(0x8e4133),
meatLight: standard(0xc47750),
cherry: standard(0xc83f44),
customer: standard(0x202238),
customerHead: standard(0x161827)
};
function mesh(
parent,
geometry,
material,
x = 0,
y = 0,
z = 0,
rx = 0,
ry = 0,
rz = 0,
castShadow = true
) {
const object = new THREE.Mesh(geometry, material);
object.position.set(x, y, z);
object.rotation.set(rx, ry, rz);
object.castShadow = castShadow;
object.receiveShadow = true;
parent.add(object);
return object;
}
function box(parent, w, h, d, material, x, y, z, castShadow = true) {
return mesh(
parent,
new THREE.BoxGeometry(w, h, d),
material,
x,
y,
z,
0,
0,
0,
castShadow
);
}
function cylinder(
parent,
rt,
rb,
h,
material,
x,
y,
z,
segments = 12,
castShadow = true
) {
return mesh(
parent,
new THREE.CylinderGeometry(rt, rb, h, segments),
material,
x,
y,
z,
0,
0,
0,
castShadow
);
}
function sphere(parent, radius, material, x, y, z, scaleY = 1) {
const object = mesh(
parent,
new THREE.SphereGeometry(radius, 16, 12),
material,
x,
y,
z
);
object.scale.y = scaleY;
return object;
}
function rod(parent, a, b, radius, material) {
const start = new THREE.Vector3(...a);
const end = new THREE.Vector3(...b);
const direction = end.clone().sub(start);
const midpoint = start.clone().add(end).multiplyScalar(0.5);
const object = mesh(
parent,
new THREE.CylinderGeometry(radius, radius, direction.length(), 8),
material,
midpoint.x,
midpoint.y,
midpoint.z
);
object.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
return object;
}
// -------------------------------------------------------------------------
// Shared procedural textures
// -------------------------------------------------------------------------
function createGlowTexture() {
const c = document.createElement("canvas");
c.width = c.height = 128;
const ctx = c.getContext("2d");
const gradient = ctx.createRadialGradient(64, 64, 0, 64, 64, 64);
gradient.addColorStop(0, "rgba(255,255,255,1)");
gradient.addColorStop(0.14, "rgba(255,255,255,0.82)");
gradient.addColorStop(0.42, "rgba(255,255,255,0.22)");
gradient.addColorStop(1, "rgba(255,255,255,0)");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 128, 128);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
return texture;
}
const glowTexture = createGlowTexture();
function addGlow(parent, position, color, scale = 0.5, opacity = 0.46) {
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: glowTexture,
color,
transparent: true,
opacity,
depthWrite: false,
blending: THREE.AdditiveBlending,
toneMapped: false
})
);
sprite.position.set(...position);
sprite.scale.set(scale, scale, 1);
parent.add(sprite);
return sprite;
}
function createSignTexture(title, subtitle, accent) {
const c = document.createElement("canvas");
c.width = 1024;
c.height = 256;
const ctx = c.getContext("2d");
ctx.fillStyle = "#171722";
ctx.fillRect(0, 0, c.width, c.height);
ctx.strokeStyle = accent;
ctx.lineWidth = 7;
ctx.strokeRect(13, 13, c.width - 26, c.height - 26);
ctx.textAlign = "center";
ctx.fillStyle = "#f3dfbb";
ctx.font = "700 67px system-ui, sans-serif";
ctx.fillText(title, c.width / 2, 116);
ctx.fillStyle = accent;
ctx.font = "600 30px system-ui, sans-serif";
ctx.fillText(subtitle, c.width / 2, 178);
ctx.fillStyle = "rgba(255,255,255,0.18)";
ctx.fillRect(365, 205, 294, 3);
const texture = new THREE.CanvasTexture(c);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(
8,
renderer.capabilities.getMaxAnisotropy()
);
return texture;
}
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0x7b91c9, 0x2b1d28, 1.2);
scene.add(hemisphere);
const moonLight = new THREE.DirectionalLight(0x91aaff, 2.1);
moonLight.position.set(-5, 10, 7);
moonLight.castShadow = true;
moonLight.shadow.mapSize.set(2048, 2048);
moonLight.shadow.camera.left = -12;
moonLight.shadow.camera.right = 12;
moonLight.shadow.camera.top = 11;
moonLight.shadow.camera.bottom = -8;
moonLight.shadow.camera.near = 1;
moonLight.shadow.camera.far = 30;
moonLight.shadow.bias = -0.0004;
scene.add(moonLight);
const warmFill = new THREE.PointLight(0xffb45f, 18, 14, 2);
warmFill.position.set(0, 5.2, 2.5);
scene.add(warmFill);
// -------------------------------------------------------------------------
// Ground, lane and distant environment
// -------------------------------------------------------------------------
box(scene, 23, 0.18, 19, M.ground, 0, -0.13, 0, false);
box(scene, 18.8, 0.045, 6.6, M.aisle, 0, -0.012, 1.65, false);
// A restrained brass edge makes the open walking route easy to read.
box(scene, 0.045, 0.028, 5.4, M.aisleEdge, -2.55, 0.025, 2.9, false);
box(scene, 0.045, 0.028, 5.4, M.aisleEdge, 2.55, 0.025, 2.9, false);
for (let i = 0; i < 6; i++) {
box(
scene,
0.08,
0.025,
0.38,
M.aisleEdge,
0,
0.026,
1.1 + i * 0.72,
false
);
}
// Distant building silhouettes.
const buildingMat = standard(0x171a2b);
const windowMat = emissive(0xb77545, 0.48);
const buildingData = [
[-8.2, 4.5, 3.8, 3.0],
[-4.0, 5.7, 3.2, 2.6],
[0.3, 4.8, 4.2, 2.4],
[4.5, 6.1, 3.5, 2.7],
[8.3, 4.6, 3.7, 3.0]
];
for (const [x, height, width, depth] of buildingData) {
box(
scene,
width,
height,
depth,
buildingMat,
x,
height / 2 - 0.1,
-7.1 - depth / 2
);
for (let row = 0; row < Math.floor(height / 1.3); row++) {
for (let col = 0; col < 2; col++) {
if ((row + col + Math.round(x)) % 3 !== 0) {
box(
scene,
0.26,
0.38,
0.035,
windowMat,
x - width * 0.22 + col * width * 0.44,
1.1 + row * 1.2,
-7.08,
false
);
}
}
}
}
// Moon and a sparse star field.
sphere(
scene,
0.72,
emissive(0xc7d5f4, 1.25),
-8.8,
8.6,
-12.5
);
const starPositions = [];
for (let i = 0; i < 120; i++) {
starPositions.push(
THREE.MathUtils.randFloatSpread(24),
THREE.MathUtils.randFloat(4.5, 12),
THREE.MathUtils.randFloat(-15, -10)
);
}
const starGeometry = new THREE.BufferGeometry();
starGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starPositions, 3)
);
scene.add(
new THREE.Points(
starGeometry,
new THREE.PointsMaterial({
color: 0xa8b7de,
size: 0.055,
transparent: true,
opacity: 0.65,
sizeAttenuation: true
})
)
);
// -------------------------------------------------------------------------
// Stall construction
// -------------------------------------------------------------------------
const bulbMaterials = [];
const stallLights = [];
function addBulb(parent, position, color = 0xffbf69, size = 0.07) {
const material = emissive(color, 2.5);
bulbMaterials.push(material);
const bulb = sphere(
parent,
size,
material,
position[0],
position[1],
position[2]
);
bulb.castShadow = false;
addGlow(
parent,
position,
color,
size * 8.5,
0.38
);
return bulb;
}
function makePendant(parent, x, z, lightColor) {
rod(
parent,
[x, 3.18, z],
[x, 2.72, z],
0.018,
M.dark
);
cylinder(
parent,
0.075,
0.29,
0.26,
M.steel,
x,
2.62,
z,
16
);
addBulb(parent, [x, 2.43, z], lightColor, 0.085);
const light = new THREE.PointLight(lightColor, 31, 7.5, 2);
light.position.set(x, 2.25, z);
parent.add(light);
stallLights.push(light);
}
function makeCanopy(parent, color, accent) {
const panels = 10;
const width = 3.8;
const panelWidth = width / panels;
for (let i = 0; i < panels; i++) {
const x = -width / 2 + panelWidth * (i + 0.5);
const material = i % 2 === 0 ? color : accent;
const roof = box(
parent,
panelWidth + 0.012,
0.1,
3.48,
material,
x,
3.34,
-2.76
);
roof.rotation.x = 0.065;
box(
parent,
panelWidth + 0.01,
0.31,
0.13,
material,
x,
3.02,
-0.965
);
}
}
function makeSign(parent, title, subtitle, accent) {
box(parent, 2.45, 0.62, 0.13, M.dark, 0, 2.58, -0.97);
const texture = createSignTexture(title, subtitle, accent);
const material = new THREE.MeshBasicMaterial({
map: texture,
toneMapped: false
});
mesh(
parent,
new THREE.PlaneGeometry(2.38, 0.56),
material,
0,
2.58,
-0.895,
0,
0,
0,
false
);
}
function makeShelf(parent) {
box(parent, 3.15, 0.12, 0.48, M.wood, 0, 1.84, -3.74);
box(parent, 3.15, 0.12, 0.48, M.wood, 0, 2.48, -3.82);
for (const x of [-1.32, 1.32]) {
box(parent, 0.11, 1.2, 0.16, M.wood, x, 2.1, -3.9);
}
}
function makeGrillFood(parent) {
box(parent, 1.75, 0.18, 0.72, M.black, -0.28, 1.33, -2.35);
for (let i = 0; i < 5; i++) {
const emberMat = emissive(i % 2 ? 0xe34b22 : 0xff8b32, 1.4);
sphere(
parent,
0.075,
emberMat,
-1.0 + i * 0.35,
1.425,
-2.57,
0.45
);
}
for (let row = 0; row < 3; row++) {
const x = -0.88 + row * 0.53;
rod(
parent,
[x, 1.52, -2.83],
[x, 1.52, -1.93],
0.013,
M.woodLight
);
for (let piece = 0; piece < 3; piece++) {
const food = box(
parent,
0.16,
0.11,
0.19,
piece % 2 ? M.meat : M.meatLight,
x,
1.59,
-2.66 + piece * 0.24
);
food.rotation.y = (piece - 1) * 0.13;
}
}
// Sauce bottles and stacked plates.
cylinder(parent, 0.075, 0.09, 0.34, M.red, 0.96, 1.37, -2.3);
cylinder(parent, 0.07, 0.08, 0.29, M.green, 1.18, 1.345, -2.38);
for (let i = 0; i < 3; i++) {
cylinder(
parent,
0.24,
0.2,
0.055,
M.cream,
1.0,
1.24 + i * 0.055,
-1.98
);
}
}
function makeNoodleFood(parent) {
const bowlPositions = [
[-1.12, -2.28],
[-0.38, -2.37],
[0.4, -2.27],
[1.12, -2.42]
];
for (const [x, z] of bowlPositions) {
cylinder(parent, 0.26, 0.17, 0.23, M.cream, x, 1.31, z, 16);
cylinder(parent, 0.215, 0.215, 0.025, M.broth, x, 1.435, z, 16);
const noodles = mesh(
parent,
new THREE.TorusGeometry(0.155, 0.025, 6, 20),
M.noodle,
x,
1.462,
z,
Math.PI / 2,
0,
0
);
noodles.castShadow = false;
sphere(parent, 0.075, M.cream, x - 0.07, 1.49, z + 0.03);
sphere(parent, 0.07, M.cream, x + 0.08, 1.485, z - 0.025);
}
// Stock pots on the rear shelf.
for (let i = 0; i < 2; i++) {
const x = -0.85 + i * 1.1;
cylinder(parent, 0.25, 0.25, 0.36, M.steel, x, 2.04, -3.73);
cylinder(parent, 0.26, 0.26, 0.055, M.brass, x, 2.24, -3.73);
sphere(parent, 0.045, M.black, x + 0.11, 2.29, -3.73);
}
// Bamboo steamer stack.
for (let i = 0; i < 3; i++) {
cylinder(
parent,
0.3,
0.3,
0.105,
M.woodLight,
1.02,
1.93 + i * 0.115,
-3.75
);
}
}
function makeDessertFood(parent) {
// Cupcakes.
for (let i = 0; i < 3; i++) {
const x = -1.1 + i * 0.48;
cylinder(
parent,
0.145,
0.09,
0.2,
M.cream,
x,
1.29,
-2.22,
12
);
const frosting = sphere(
parent,
0.19,
i === 1 ? M.plum : M.cream,
x,
1.48,
-2.22,
0.75
);
frosting.scale.z = 0.88;
sphere(parent, 0.055, M.cherry, x, 1.62, -2.22);
}
// Small layered cakes.
cylinder(parent, 0.32, 0.32, 0.18, M.cream, 0.66, 1.29, -2.44);
cylinder(parent, 0.31, 0.31, 0.13, M.plum, 0.66, 1.445, -2.44);
cylinder(parent, 0.29, 0.29, 0.1, M.cream, 0.66, 1.56, -2.44);
// Fruit skewers.
for (let i = 0; i < 2; i++) {
const x = 1.12 + i * 0.27;
rod(
parent,
[x, 1.26, -2.76],
[x, 1.26, -1.98],
0.012,
M.woodLight
);
sphere(parent, 0.085, M.orange, x, 1.36, -2.62);
sphere(parent, 0.082, M.red, x, 1.36, -2.39);
sphere(parent, 0.083, M.green, x, 1.36, -2.16);
}
}
function createStall(x, config, type) {
const group = new THREE.Group();
group.position.x = x;
scene.add(group);
const accent = new THREE.Color(config.accent);
// Back wall and structure.
box(group, 3.62, 2.82, 0.18, config.wall, 0, 1.4, -4.26);
box(group, 3.3, 0.12, 0.18, M.wood, 0, 2.73, -4.12);
for (const px of [-1.72, 1.72]) {
for (const pz of [-4.08, -1.14]) {
cylinder(group, 0.055, 0.065, 3.22, M.steel, px, 1.6, pz, 8);
}
}
// Counter and its bright front edge.
box(group, 3.42, 1.04, 1.24, config.counter, 0, 0.53, -2.4);
box(group, 3.68, 0.16, 1.43, M.woodLight, 0, 1.1, -2.35);
box(group, 3.4, 0.8, 0.08, config.counter, 0, 0.58, -1.755);
box(group, 3.4, 0.035, 0.045, M.brass, 0, 1.015, -1.69);
box(group, 3.05, 0.025, 0.04, emissive(config.accent, 1.2), 0, 0.12, -1.69);
makeShelf(group);
makeCanopy(group, config.canvas, config.stripe);
makeSign(group, config.title, config.subtitle, config.accent);
makePendant(group, 0, -1.56, config.light);
if (type === "grill") makeGrillFood(group);
if (type === "noodle") makeNoodleFood(group);
if (type === "dessert") makeDessertFood(group);
// A broad warm pool directly in front of the counter.
const poolTexture = glowTexture;
const poolMaterial = new THREE.MeshBasicMaterial({
map: poolTexture,
color: accent,
transparent: true,
opacity: 0.11,
depthWrite: false,
blending: THREE.AdditiveBlending,
toneMapped: false
});
const pool = mesh(
group,
new THREE.PlaneGeometry(4.5, 3.2),
poolMaterial,
0,
0.038,
-0.2,
-Math.PI / 2,
0,
0,
false
);
pool.castShadow = false;
return group;
}
createStall(
-4.55,
{
wall: standard(0x392b2c),
counter: standard(0x7c3e32),
canvas: standard(0xc4543f),
stripe: standard(0xe7c99c),
accent: "#ef9a58",
light: 0xff9f50,
title: "EMBER GRILL",
subtitle: "CHARCOAL · SKEWERS · NIGHT FIRE"
},
"grill"
);
createStall(
0,
{
wall: standard(0x203b3b),
counter: standard(0x236d69),
canvas: standard(0x318b84),
stripe: standard(0xe1d5b2),
accent: "#8dd8c7",
light: 0xffd18c,
title: "MOON NOODLES",
subtitle: "BROTH · DUMPLINGS · COMFORT"
},
"noodle"
);
createStall(
4.55,
{
wall: standard(0x3d2940),
counter: standard(0x743b69),
canvas: standard(0x914874),
stripe: standard(0xe7c6b3),
accent: "#ef9fc3",
light: 0xffb87c,
title: "SUNSET SWEETS",
subtitle: "CAKE · FRUIT · SOFT COLORS"
},
"dessert"
);
// -------------------------------------------------------------------------
// Overhead string lights
// -------------------------------------------------------------------------
const stringCurve = new THREE.CatmullRomCurve3([
new THREE.Vector3(-8.5, 4.35, -0.48),
new THREE.Vector3(-5.1, 3.78, -0.48),
new THREE.Vector3(-2.4, 3.95, -0.48),
new THREE.Vector3(0, 3.66, -0.48),
new THREE.Vector3(2.5, 3.95, -0.48),
new THREE.Vector3(5.2, 3.78, -0.48),
new THREE.Vector3(8.5, 4.35, -0.48)
]);
mesh(
scene,
new THREE.TubeGeometry(stringCurve, 100, 0.018, 6, false),
M.dark,
0,
0,
0,
0,
0,
0,
false
);
const stringColors = [
0xffbd66,
0xff8f58,
0xffd99b,
0xf16f6f,
0xffc16c
];
for (let i = 0; i < 17; i++) {
const t = 0.035 + (i / 16) * 0.93;
const point = stringCurve.getPointAt(t);
const color = stringColors[i % stringColors.length];
cylinder(
scene,
0.032,
0.045,
0.09,
M.dark,
point.x,
point.y - 0.045,
point.z,
8,
false
);
addBulb(
scene,
[point.x, point.y - 0.135, point.z],
color,
0.068
);
}
[0.19, 0.49, 0.79].forEach((t, index) => {
const point = stringCurve.getPointAt(t);
const light = new THREE.PointLight(
index === 1 ? 0xffc487 : 0xff925d,
10,
7,
2
);
light.position.set(point.x, point.y - 0.15, point.z + 0.1);
scene.add(light);
});
// -------------------------------------------------------------------------
// Lantern posts and side dressing
// -------------------------------------------------------------------------
function makeLantern(x, z, color) {
cylinder(scene, 0.06, 0.09, 3.85, M.dark, x, 1.92, z, 10);
box(scene, 0.52, 0.12, 0.52, M.dark, x, 3.83, z);
const paperMat = emissive(color, 1.25);
box(scene, 0.39, 0.58, 0.39, paperMat, x, 3.47, z);
for (const offset of [-0.22, 0.22]) {
box(scene, 0.035, 0.65, 0.035, M.dark, x + offset, 3.47, z + 0.21);
box(scene, 0.035, 0.65, 0.035, M.dark, x + offset, 3.47, z - 0.21);
}
box(scene, 0.5, 0.12, 0.5, M.dark, x, 3.12, z);
addGlow(scene, [x, 3.47, z], color, 1.5, 0.24);
const light = new THREE.PointLight(color, 19, 7, 2);
light.position.set(x, 3.42, z);
scene.add(light);
}
makeLantern(-9.25, -0.05, 0xff9c55);
makeLantern(9.25, 0.15, 0xff7862);
function makePlanter(x, z) {
cylinder(scene, 0.42, 0.3, 0.65, M.brick, x, 0.325, z, 10);
cylinder(scene, 0.36, 0.36, 0.06, M.dark, x, 0.68, z, 10);
for (let i = 0; i < 5; i++) {
const angle = (i / 5) * Math.PI * 2;
const leaf = sphere(
scene,
0.25,
M.green,
x + Math.cos(angle) * 0.18,
0.95 + (i % 2) * 0.12,
z + Math.sin(angle) * 0.18,
1.35
);
leaf.rotation.z = Math.cos(angle) * 0.35;
leaf.rotation.x = Math.sin(angle) * 0.35;
}
}
makePlanter(-9.3, 2.3);
makePlanter(9.3, 3.15);
// -------------------------------------------------------------------------
// Seating at the outer edges, leaving the central walking space open
// -------------------------------------------------------------------------
function makeStool(x, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
scene.add(group);
cylinder(group, 0.28, 0.3, 0.13, M.wood, 0, 0.66, 0, 14);
for (let i = 0; i < 3; i++) {
const angle = (i / 3) * Math.PI * 2;
rod(
group,
[Math.cos(angle) * 0.2, 0.61, Math.sin(angle) * 0.2],
[Math.cos(angle) * 0.27, 0.03, Math.sin(angle) * 0.27],
0.025,
M.steel
);
}
return group;
}
function makeTable(x, z) {
cylinder(scene, 0.8, 0.8, 0.13, M.woodLight, x, 1.0, z, 24);
cylinder(scene, 0.08, 0.1, 0.9, M.steel, x, 0.49, z, 12);
cylinder(scene, 0.38, 0.42, 0.08, M.dark, x, 0.05, z, 16);
// Cup and small plate.
cylinder(scene, 0.11, 0.085, 0.2, M.cream, x - 0.25, 1.17, z + 0.12, 12);
cylinder(scene, 0.22, 0.22, 0.035, M.cream, x + 0.28, 1.085, z - 0.12, 16);
}
makeTable(7.65, 2.55);
makeStool(6.55, 2.55);
makeStool(8.75, 2.55);
makeStool(7.65, 1.45);
makeStool(7.65, 3.65);
// A simple bench on the opposite side.
box(scene, 2.3, 0.16, 0.62, M.woodLight, -7.65, 0.72, 2.45);
box(scene, 0.16, 0.66, 0.52, M.steel, -8.55, 0.35, 2.45);
box(scene, 0.16, 0.66, 0.52, M.steel, -6.75, 0.35, 2.45);
// -------------------------------------------------------------------------
// Customers: faceless, dark silhouettes with readable outlines
// -------------------------------------------------------------------------
const customerOutlineMaterial = new THREE.MeshBasicMaterial({
color: 0x070811,
side: THREE.BackSide
});
function outlinedMesh(geometry, material) {
const group = new THREE.Group();
const outline = new THREE.Mesh(geometry, customerOutlineMaterial);
outline.scale.setScalar(1.055);
group.add(outline);
const object = new THREE.Mesh(geometry, material);
object.castShadow = true;
object.receiveShadow = true;
group.add(object);
return group;
}
function makePerson(x, z, scale = 1, rotation = 0, bag = false) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.rotation.y = rotation;
group.scale.setScalar(scale);
scene.add(group);
const torso = outlinedMesh(
new THREE.CylinderGeometry(0.21, 0.27, 0.62, 9),
M.customer
);
torso.position.y = 1.03;
group.add(torso);
const head = outlinedMesh(
new THREE.SphereGeometry(0.16, 14, 10),
M.customerHead
);
head.position.y = 1.51;
group.add(head);
cylinder(group, 0.065, 0.075, 0.13, M.customerHead, 0, 1.31, 0, 8);
for (const side of [-1, 1]) {
rod(
group,
[side * 0.11, 0.75, 0],
[side * 0.13, 0.09, side * 0.035],
0.064,
M.customer
);
box(
group,
0.15,
0.09,
0.27,
M.black,
side * 0.13,
0.055,
0.065 + side * 0.02
);
rod(
group,
[side * 0.21, 1.24, 0],
[side * 0.29, 0.82, side * 0.04],
0.055,
M.customer
);
}
if (bag) {
box(group, 0.25, 0.32, 0.16, M.blue, 0.31, 0.75, 0.02);
rod(
group,
[0.28, 1.19, 0],
[0.31, 0.92, 0],
0.014,
M.woodLight
);
}
return group;
}
// Queues stay just beyond the counters, leaving the foreground lane open.
makePerson(-5.05, -0.48, 1.02, Math.PI, true);
makePerson(-4.13, 0.25, 0.91, Math.PI);
makePerson(-0.62, -0.52, 1.08, Math.PI, true);
makePerson(0.58, 0.28, 0.9, Math.PI);
makePerson(4.03, -0.48, 1.0, Math.PI);
makePerson(5.12, 0.28, 0.94, Math.PI, true);
// A walker and a seated customer add human scale.
makePerson(-3.15, 2.55, 1.0, 0.35, true);
makePerson(6.55, 2.52, 0.88, -Math.PI / 2);
// -------------------------------------------------------------------------
// Small crates and practical market details
// -------------------------------------------------------------------------
function makeCrate(x, y, z, rotation = 0) {
const group = new THREE.Group();
group.position.set(x, y, z);
group.rotation.y = rotation;
scene.add(group);
box(group, 0.65, 0.13, 0.65, M.wood, 0, 0.065, 0);
for (const side of [-1, 1]) {
for (let i = 0; i < 3; i++) {
box(
group,
0.08,
0.42,
0.65,
M.woodLight,
side * 0.28,
0.25,
-0.22 + i * 0.22
);
}
}
}
makeCrate(-7.15, 0, -1.45, 0.08);
makeCrate(-7.15, 0.48, -1.45, -0.03);
makeCrate(7.25, 0, -1.55, -0.1);
makeCrate(7.25, 0.48, -1.55, 0.06);
// -------------------------------------------------------------------------
// Custom orbit / pinch / wheel camera controls
// -------------------------------------------------------------------------
const activePointers = new Map();
let gestureMode = "none";
let lastX = 0;
let lastY = 0;
let lastPinchDistance = 0;
function pointerDistance() {
const points = [...activePointers.values()];
if (points.length < 2) return 0;
return Math.hypot(points[0].x - points[1].x, points[0].y - points[1].y);
}
canvas.addEventListener("pointerdown", (event) => {
canvas.setPointerCapture(event.pointerId);
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (activePointers.size === 1) {
gestureMode = "rotate";
lastX = event.clientX;
lastY = event.clientY;
} else if (activePointers.size === 2) {
gestureMode = "pinch";
lastPinchDistance = pointerDistance();
}
});
canvas.addEventListener("pointermove", (event) => {
if (!activePointers.has(event.pointerId)) return;
activePointers.set(event.pointerId, {
x: event.clientX,
y: event.clientY
});
if (gestureMode === "rotate" && activePointers.size === 1) {
const dx = event.clientX - lastX;
const dy = event.clientY - lastY;
lastX = event.clientX;
lastY = event.clientY;
view.targetYaw -= dx * 0.006;
view.targetPitch = THREE.MathUtils.clamp(
view.targetPitch + dy * 0.0045,
0.2,
1.05
);
} else if (gestureMode === "pinch" && activePointers.size === 2) {
const distance = pointerDistance();
if (lastPinchDistance > 0 && distance > 0) {
view.targetRadius = THREE.MathUtils.clamp(
view.targetRadius * (lastPinchDistance / distance),
10,
25
);
}
lastPinchDistance = distance;
}
});
function releasePointer(event) {
activePointers.delete(event.pointerId);
if (activePointers.size === 1) {
gestureMode = "rotate";
const point = [...activePointers.values()][0];
lastX = point.x;
lastY = point.y;
} else {
gestureMode = "none";
lastPinchDistance = 0;
}
}
canvas.addEventListener("pointerup", releasePointer);
canvas.addEventListener("pointercancel", releasePointer);
canvas.addEventListener("pointerleave", (event) => {
if (event.buttons === 0) releasePointer(event);
});
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
view.targetRadius = THREE.MathUtils.clamp(
view.targetRadius * Math.exp(event.deltaY * 0.001),
10,
25
);
},
{ passive: false }
);
function resetCamera() {
view.targetYaw = -0.12;
view.targetPitch = 0.48;
view.targetRadius = window.innerWidth < 700 ? 19.5 : 16.7;
}
canvas.addEventListener("dblclick", resetCamera);
window.addEventListener("keydown", (event) => {
if (event.key === "ArrowLeft") view.targetYaw += 0.08;
if (event.key === "ArrowRight") view.targetYaw -= 0.08;
if (event.key === "ArrowUp") view.targetPitch += 0.04;
if (event.key === "ArrowDown") view.targetPitch -= 0.04;
if (event.key === "+" || event.key === "=") view.targetRadius -= 0.5;
if (event.key === "-") view.targetRadius += 0.5;
view.targetPitch = THREE.MathUtils.clamp(view.targetPitch, 0.2, 1.05);
view.targetRadius = THREE.MathUtils.clamp(view.targetRadius, 10, 25);
});
// -------------------------------------------------------------------------
// Resize and animation loop
// -------------------------------------------------------------------------
function resize() {
const width = window.innerWidth;
const height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
renderer.setSize(width, height);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
const damping = 1 - Math.exp(-delta * 8);
view.yaw = THREE.MathUtils.lerp(view.yaw, view.targetYaw, damping);
view.pitch = THREE.MathUtils.lerp(view.pitch, view.targetPitch, damping);
view.radius = THREE.MathUtils.lerp(view.radius, view.targetRadius, damping);
const horizontal = Math.cos(view.pitch) * view.radius;
camera.position.set(
cameraTarget.x + Math.sin(view.yaw) * horizontal,
cameraTarget.y + Math.sin(view.pitch) * view.radius,
cameraTarget.z + Math.cos(view.yaw) * horizontal
);
camera.lookAt(cameraTarget);
// Gentle practical-light breathing, kept subtle enough to preserve readability.
for (let i = 0; i < bulbMaterials.length; i++) {
bulbMaterials[i].emissiveIntensity =
2.35 + Math.sin(elapsed * 1.7 + i * 0.73) * 0.12;
}
for (let i = 0; i < stallLights.length; i++) {
stallLights[i].intensity =
30 + Math.sin(elapsed * 1.25 + i * 1.8) * 1.2;
}
renderer.render(scene, camera);
}
animate();
</script>
</body>
</html>
```