Prompt specification
Build or customize the Three.js 3D scene "Naschmarkt stall roof and counter module" 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: Naschmarkt stall roof and counter module
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/naschmarkt-stall-roof-and-counter-module-x2877
Scene Description Prompt:
Build a low-poly stall from Vienna's Naschmarkt with canopy, customer counter, and separate rear handling space. One HTML file using Three.js from cdnjs.
Working Three.js Starter (naschmarkt-stall-roof-and-counter-module-x2877):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Naschmarkt Low-Poly Market Stall</title>
<style>
:root {
color-scheme: light;
--cream: #f5ead2;
--ink: #2c2925;
--burgundy: #8d3040;
--glass: rgba(28, 26, 23, 0.68);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #d8d0bd;
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#stage,
#stage canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
display: block;
touch-action: none;
}
.panel {
position: absolute;
z-index: 2;
pointer-events: none;
}
#intro {
top: 24px;
left: 24px;
max-width: min(390px, calc(100vw - 48px));
padding: 18px 20px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 16px;
color: #fff9ec;
background:
linear-gradient(135deg, rgba(61, 35, 28, 0.88), rgba(90, 42, 43, 0.75));
box-shadow: 0 14px 36px rgba(50, 35, 24, 0.18);
backdrop-filter: blur(10px);
}
.eyebrow {
margin: 0 0 6px;
color: #f0c993;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.19em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(27px, 4vw, 42px);
font-weight: 600;
line-height: 0.98;
}
#intro p:last-child {
margin: 11px 0 0;
color: rgba(255, 249, 236, 0.82);
font-size: 13px;
line-height: 1.45;
}
#legend {
right: 24px;
bottom: 82px;
display: flex;
gap: 8px;
padding: 9px;
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 13px;
color: #fff;
background: var(--glass);
box-shadow: 0 12px 30px rgba(30, 25, 20, 0.15);
backdrop-filter: blur(8px);
}
.legend-item {
display: flex;
align-items: center;
gap: 7px;
padding: 7px 10px;
border-radius: 9px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.03em;
}
.swatch {
width: 9px;
height: 9px;
border-radius: 50%;
}
.customer {
background: #d49d51;
}
.handling {
background: #76a6a2;
}
#controls {
left: 50%;
bottom: 22px;
display: flex;
gap: 7px;
padding: 7px;
transform: translateX(-50%);
border: 1px solid rgba(255, 255, 255, 0.55);
border-radius: 14px;
background: var(--glass);
box-shadow: 0 12px 32px rgba(30, 25, 20, 0.2);
backdrop-filter: blur(10px);
pointer-events: auto;
}
button {
min-width: 76px;
padding: 10px 13px;
border: 0;
border-radius: 9px;
color: #fffaf0;
background: rgba(255, 255, 255, 0.09);
font: inherit;
font-size: 12px;
font-weight: 750;
cursor: pointer;
transition: background 150ms ease, transform 150ms ease;
}
button:hover,
button:focus-visible {
background: rgba(255, 255, 255, 0.2);
outline: none;
}
button:active {
transform: translateY(1px);
}
#hint {
right: 24px;
top: 24px;
max-width: 230px;
padding: 10px 13px;
border-radius: 11px;
color: rgba(255, 255, 255, 0.88);
background: rgba(40, 37, 32, 0.55);
font-size: 11px;
line-height: 1.5;
text-align: right;
backdrop-filter: blur(8px);
}
@media (max-width: 700px) {
#intro {
top: 14px;
left: 14px;
padding: 14px 16px;
}
#intro p:last-child,
#hint {
display: none;
}
#legend {
right: 12px;
bottom: 78px;
}
.legend-item {
padding: 7px;
}
#controls {
bottom: 14px;
width: calc(100vw - 28px);
justify-content: center;
}
button {
min-width: 0;
flex: 1;
padding: 10px 8px;
font-size: 11px;
}
}
</style>
</head>
<body>
<div id="stage"></div>
<section id="intro" class="panel">
<p class="eyebrow">Vienna · Naschmarkt</p>
<h1>Austrian Market Stall</h1>
<p>
A low-poly Viennese food stall with a striped canopy, customer display
counter, and a separate rear preparation and storage area.
</p>
</section>
<aside id="hint" class="panel">
Drag to orbit · Scroll to zoom<br />
Shift-drag or right-drag to pan<br />
Arrow keys orbit · R resets view
</aside>
<div id="legend" class="panel">
<div class="legend-item">
<span class="swatch customer"></span>
Customer area
</div>
<div class="legend-item">
<span class="swatch handling"></span>
Rear handling
</div>
</div>
<nav id="controls" class="panel" aria-label="Camera views">
<button type="button" data-view="front">Front</button>
<button type="button" data-view="rear">Rear workspace</button>
<button type="button" data-view="top">Overview</button>
<button type="button" data-view="reset">Reset</button>
</nav>
<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 stage = document.getElementById("stage");
const renderer = new THREE.WebGLRenderer({
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.08;
stage.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xd8d0bd);
scene.fog = new THREE.Fog(0xd8d0bd, 19, 38);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
// -------------------------------------------------------------------------
// Materials
// -------------------------------------------------------------------------
const material = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0,
flatShading: true,
...options
});
const M = {
burgundy: material(0x8c3040),
burgundyDark: material(0x63212c),
cream: material(0xf0dfbc),
creamLight: material(0xf8edcf),
wood: material(0x775039),
woodLight: material(0xaa7950),
woodDark: material(0x3e2d25),
sage: material(0x667f70),
sageDark: material(0x40594d),
teal: material(0x4f8885),
steel: material(0xaebbb9, { metalness: 0.48, roughness: 0.42 }),
steelDark: material(0x586563, { metalness: 0.45, roughness: 0.48 }),
black: material(0x272522),
white: material(0xf8f3e6),
yellow: material(0xe2b84f),
orange: material(0xd87531),
green: material(0x5d8e45),
greenDark: material(0x395f35),
red: material(0xb9443e),
blue: material(0x527f9d),
skin: material(0xc89065),
skinLight: material(0xe0ad80),
hair: material(0x44342b),
glass: material(0xcce3df, {
transparent: true,
opacity: 0.2,
depthWrite: false,
roughness: 0.12,
metalness: 0.1
}),
stucco: material(0xc9b99d),
stuccoDark: material(0x9f8e75),
window: material(0x425b61, { metalness: 0.24, roughness: 0.34 }),
bulb: material(0xffd995, {
emissive: 0xffb84d,
emissiveIntensity: 1.6,
roughness: 0.25
})
};
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function box(parent, mat, size, position, rotation = [0, 0, 0]) {
const mesh = new THREE.Mesh(
new THREE.BoxGeometry(size[0], size[1], size[2]),
mat
);
mesh.position.set(...position);
mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function cylinder(
parent,
mat,
dimensions,
position,
rotation = [0, 0, 0]
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(
dimensions[0],
dimensions[1],
dimensions[2],
dimensions[3]
),
mat
);
mesh.position.set(...position);
mesh.rotation.set(...rotation);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function polySphere(parent, mat, radius, position, detail = 1) {
const mesh = new THREE.Mesh(
new THREE.IcosahedronGeometry(radius, detail),
mat
);
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function beam(parent, mat, start, end, radius = 0.035) {
const a = new THREE.Vector3(...start);
const b = new THREE.Vector3(...end);
const direction = b.clone().sub(a);
const length = direction.length();
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radius, radius, length, 6),
mat
);
mesh.position.copy(a).add(b).multiplyScalar(0.5);
mesh.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.normalize()
);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function makeTexture(lines, background = "#8c3040", foreground = "#fff4dc") {
const aspect = lines.aspect || 3;
const canvas = document.createElement("canvas");
canvas.width = 1024;
canvas.height = Math.min(1024, Math.round(1024 / aspect));
const ctx = canvas.getContext("2d");
ctx.fillStyle = background;
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.strokeStyle = foreground;
ctx.globalAlpha = 0.45;
ctx.lineWidth = Math.max(4, canvas.height * 0.025);
ctx.strokeRect(
ctx.lineWidth,
ctx.lineWidth,
canvas.width - ctx.lineWidth * 2,
canvas.height - ctx.lineWidth * 2
);
ctx.globalAlpha = 1;
for (const line of lines.items) {
ctx.fillStyle = line.color || foreground;
ctx.font = `${line.weight || 700} ${line.size || 80}px Arial, sans-serif`;
ctx.textAlign = line.align || "center";
ctx.textBaseline = "middle";
ctx.fillText(
line.text,
line.align === "left" ? 80 : line.align === "right" ? 944 : 512,
line.y * canvas.height
);
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = renderer.capabilities.getMaxAnisotropy();
return texture;
}
function sign(
parent,
lines,
position,
width,
height,
background = "#8c3040",
foreground = "#fff4dc",
rotation = [0, 0, 0]
) {
const texture = makeTexture(
{ ...lines, aspect: width / height },
background,
foreground
);
const mat = new THREE.MeshStandardMaterial({
map: texture,
roughness: 0.85,
side: THREE.DoubleSide
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(width, height), mat);
mesh.position.set(...position);
mesh.rotation.set(...rotation);
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function crate(parent, x, y, z, tint = M.woodLight) {
const group = new THREE.Group();
group.position.set(x, y, z);
parent.add(group);
box(group, tint, [0.9, 0.08, 0.7], [0, 0, 0]);
for (const sx of [-0.41, 0.41]) {
for (const sz of [-0.31, 0.31]) {
box(group, tint, [0.08, 0.52, 0.08], [sx, 0.26, sz]);
}
}
for (const height of [0.14, 0.32, 0.5]) {
box(group, tint, [0.9, 0.09, 0.06], [0, height, -0.32]);
box(group, tint, [0.9, 0.09, 0.06], [0, height, 0.32]);
box(group, tint, [0.06, 0.09, 0.7], [-0.41, height, 0]);
box(group, tint, [0.06, 0.09, 0.7], [0.41, height, 0]);
}
return group;
}
// -------------------------------------------------------------------------
// Lighting
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0xfff0d2, 0x65716c, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xffe1b0, 3.1);
sun.position.set(-8, 13, 8);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -15;
sun.shadow.camera.right = 15;
sun.shadow.camera.top = 15;
sun.shadow.camera.bottom = -15;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0005;
scene.add(sun);
const stallLight = new THREE.PointLight(0xffc979, 18, 9, 2);
stallLight.position.set(0, 3.15, 1.1);
scene.add(stallLight);
const rearLight = new THREE.PointLight(0xc8ecdf, 8, 7, 2);
rearLight.position.set(0.4, 2.5, -2.1);
scene.add(rearLight);
// -------------------------------------------------------------------------
// Pavement and urban backdrop
// -------------------------------------------------------------------------
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(50, 50),
material(0xaaa18f)
);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.085;
ground.receiveShadow = true;
scene.add(ground);
const stoneGeometry = new THREE.BoxGeometry(0.73, 0.07, 0.48);
const stoneMaterial = material(0xffffff);
const columns = 30;
const rows = 19;
const paving = new THREE.InstancedMesh(
stoneGeometry,
stoneMaterial,
columns * rows
);
const dummy = new THREE.Object3D();
const pavingColor = new THREE.Color();
let stoneIndex = 0;
for (let row = 0; row < rows; row++) {
for (let col = 0; col < columns; col++) {
const offset = row % 2 === 0 ? 0 : 0.39;
const x = (col - columns / 2) * 0.78 + offset;
const z = -6.6 + row * 0.55;
const variation = Math.sin(col * 12.91 + row * 78.23) * 0.5 + 0.5;
dummy.position.set(x, -0.035 + variation * 0.015, z);
dummy.rotation.set(0, variation * 0.08, 0);
dummy.scale.set(
0.96 + variation * 0.05,
0.85 + variation * 0.25,
0.95 + variation * 0.06
);
dummy.updateMatrix();
paving.setMatrixAt(stoneIndex, dummy.matrix);
pavingColor.setHSL(0.11, 0.09, 0.56 + variation * 0.09);
paving.setColorAt(stoneIndex, pavingColor);
stoneIndex++;
}
}
paving.instanceMatrix.needsUpdate = true;
paving.instanceColor.needsUpdate = true;
paving.receiveShadow = true;
scene.add(paving);
const building = new THREE.Group();
scene.add(building);
box(building, M.stucco, [28, 7.2, 1.5], [0, 3.55, -8.45]);
box(building, M.stuccoDark, [28.4, 0.35, 1.8], [0, 0.15, -8.4]);
box(building, M.burgundyDark, [28.4, 0.5, 1.8], [0, 6.9, -8.35]);
const windowXs = [-10.5, -6.3, -2.1, 2.1, 6.3, 10.5];
for (const x of windowXs) {
box(building, M.creamLight, [1.9, 2.35, 0.12], [x, 3.8, -7.64]);
box(building, M.window, [1.58, 2.02, 0.08], [x, 3.8, -7.56]);
box(building, M.creamLight, [0.09, 2.05, 0.1], [x, 3.8, -7.49]);
box(building, M.creamLight, [1.62, 0.09, 0.1], [x, 3.8, -7.49]);
box(building, M.woodDark, [2.15, 0.16, 0.45], [x, 2.55, -7.45]);
}
box(building, M.woodDark, [1.7, 2.7, 0.14], [0, 1.35, -7.61]);
box(building, M.woodLight, [1.38, 2.35, 0.08], [0, 1.3, -7.51]);
sign(
building,
{
items: [
{ text: "NASCHMARKT", size: 0.28, y: 0.38, weight: 800 },
{ text: "WIENER MARKTSTAND", size: 0.105, y: 0.72 }
]
},
[0, 6.25, -7.58],
7.4,
1.15,
"#40594d",
"#f6e4bb"
);
// A few market crates and barrels near the building.
crate(scene, -5.7, 0, -6.7, M.woodLight);
crate(scene, -4.9, 0, -6.75, M.wood);
crate(scene, 5.5, 0, -6.8, M.woodLight);
crate(scene, 6.45, 0, -6.75, M.wood);
for (const x of [-5.3, 6.0]) {
cylinder(scene, M.wood, [0.34, 0.38, 0.9, 10], [x, 0.45, -6.1]);
cylinder(scene, M.steelDark, [0.35, 0.35, 0.07, 10], [x, 0.69, -6.1]);
cylinder(scene, M.steelDark, [0.35, 0.35, 0.07, 10], [x, 0.24, -6.1]);
}
// -------------------------------------------------------------------------
// Main stall structure
// -------------------------------------------------------------------------
const stall = new THREE.Group();
scene.add(stall);
// Customer floor and separate rear handling floor.
box(stall, M.wood, [7.55, 0.14, 4.12], [0, 0.02, 0.76]);
box(stall, M.sageDark, [7.55, 0.14, 2.18], [0, 0.02, -2.44]);
box(stall, M.woodDark, [7.7, 0.12, 0.16], [0, 0.08, -1.37]);
// Subtle floor divisions.
for (let x = -3.3; x <= 3.3; x += 0.6) {
box(stall, M.woodLight, [0.025, 0.012, 3.85], [x, 0.098, 0.77]);
}
// Canopy posts.
for (const x of [-3.45, 3.45]) {
for (const z of [-1.18, 2.42]) {
box(stall, M.woodDark, [0.17, 3.55, 0.17], [x, 1.88, z]);
box(stall, M.wood, [0.28, 0.12, 0.28], [x, 0.14, z]);
box(stall, M.wood, [0.27, 0.12, 0.27], [x, 3.6, z]);
}
}
// Canopy frame.
beam(stall, M.woodDark, [-3.75, 4.25, 0.65], [3.75, 4.25, 0.65], 0.065);
beam(stall, M.woodDark, [-3.75, 3.65, 2.65], [3.75, 3.65, 2.65], 0.06);
beam(stall, M.woodDark, [-3.75, 3.65, -1.35], [3.75, 3.65, -1.35], 0.06);
for (const x of [-3.45, 3.45]) {
beam(stall, M.woodDark, [x, 4.25, 0.65], [x, 3.65, 2.65], 0.055);
beam(stall, M.woodDark, [x, 4.25, 0.65], [x, 3.65, -1.35], 0.055);
}
// Striped canopy roof.
const roofWidth = 7.8;
const stripeCount = 14;
const stripeWidth = roofWidth / stripeCount;
const slopeAngle = Math.atan2(0.6, 2);
const slopeLength = Math.sqrt(2 * 2 + 0.6 * 0.6);
for (let i = 0; i < stripeCount; i++) {
const x = -roofWidth / 2 + stripeWidth * (i + 0.5);
const roofMaterial = i % 2 === 0 ? M.burgundy : M.cream;
box(
stall,
roofMaterial,
[stripeWidth - 0.015, 0.09, slopeLength],
[x, 3.95, 1.65],
[slopeAngle, 0, 0]
);
box(
stall,
roofMaterial,
[stripeWidth - 0.015, 0.09, slopeLength],
[x, 3.95, -0.35],
[-slopeAngle, 0, 0]
);
}
// Scalloped-looking front valance.
for (let i = 0; i < stripeCount; i++) {
const x = -roofWidth / 2 + stripeWidth * (i + 0.5);
const valanceMaterial = i % 2 === 0 ? M.burgundy : M.cream;
box(
stall,
valanceMaterial,
[stripeWidth - 0.012, 0.43, 0.09],
[x, 3.43, 2.67]
);
}
sign(
stall,
{
items: [
{ text: "NASCHMARKT", size: 0.28, y: 0.36, weight: 800 },
{ text: "BREZELN · KÄSE · WÜRSTEL", size: 0.105, y: 0.72 }
]
},
[0, 4.04, 2.72],
4.9,
0.82,
"#7d2939",
"#fff0cc"
);
// -------------------------------------------------------------------------
// Customer counter
// -------------------------------------------------------------------------
const counter = new THREE.Group();
stall.add(counter);
box(counter, M.burgundyDark, [6.65, 1.02, 1.02], [0, 0.62, 1.56]);
box(counter, M.woodLight, [6.85, 0.14, 1.17], [0, 1.17, 1.56]);
// Front vertical paneling.
for (let i = 0; i < 13; i++) {
const x = -3.03 + i * 0.505;
box(
counter,
i % 2 === 0 ? M.burgundy : M.burgundyDark,
[0.43, 0.77, 0.055],
[x, 0.61, 2.085]
);
}
box(counter, M.creamLight, [6.72, 0.11, 0.09], [0, 0.12, 2.1]);
box(counter, M.woodDark, [6.72, 0.1, 0.09], [0, 1.05, 2.1]);
sign(
counter,
{
items: [
{ text: "MARKTSTAND 08", size: 0.27, y: 0.5 },
{ text: "FRISCH & HANDGEMACHT", size: 0.12, y: 0.78 }
]
},
[0, 0.61, 2.145],
3.05,
0.67,
"#40594d",
"#f8e9c8"
);
// Menu board.
box(counter, M.woodDark, [1.22, 1.62, 0.1], [-2.52, 2.18, 1.91]);
sign(
counter,
{
items: [
{ text: "HEUTE FRISCH", size: 0.09, y: 0.12 },
{ text: "BREZELN", size: 0.075, y: 0.31 },
{ text: "KÄSE", size: 0.075, y: 0.46 },
{ text: "WÜRSTEL", size: 0.075, y: 0.61 },
{ text: "APFEL", size: 0.075, y: 0.76 },
{ text: "€ 3–6", size: 0.07, y: 0.91 }
]
},
[-2.52, 2.18, 1.969],
1.08,
1.47,
"#3f332b",
"#f4dfae"
);
// Display trays.
function displayTray(x, z, width, depth, trayMaterial = M.woodDark) {
box(counter, trayMaterial, [width, 0.055, depth], [x, 1.265, z]);
box(counter, M.steelDark, [width - 0.08, 0.025, depth - 0.08], [x, 1.3, z]);
}
displayTray(-2.0, 1.5, 1.65, 0.67);
displayTray(-0.45, 1.5, 1.65, 0.67);
displayTray(1.05, 1.5, 1.55, 0.67);
displayTray(2.55, 1.5, 1.25, 0.67);
// Cheese wheels.
cylinder(counter, M.yellow, [0.3, 0.3, 0.17, 8], [-2.46, 1.405, 1.47]);
cylinder(counter, M.orange, [0.26, 0.26, 0.15, 8], [-1.72, 1.39, 1.52]);
// Bread and pretzels.
polySphere(counter, M.woodLight, 0.25, [-0.96, 1.37, 1.48], 1).scale.set(1, 0.55, 0.72);
for (const [x, z, rotation] of [
[-0.48, 1.48, 0],
[-0.02, 1.52, 0.45],
[0.72, 1.49, 0.12],
[1.35, 1.5, -0.3]
]) {
const pretzel = new THREE.Mesh(
new THREE.TorusGeometry(0.19, 0.055, 5, 10),
M.woodLight
);
pretzel.position.set(x, 1.38, z);
pretzel.rotation.set(Math.PI / 2, 0, rotation);
pretzel.castShadow = true;
counter.add(pretzel);
}
// Sausages.
for (const z of [1.39, 1.58]) {
cylinder(
counter,
M.red,
[0.08, 0.08, 0.65, 8],
[2.18, 1.39, z],
[0, 0, Math.PI / 2]
);
}
// Apples.
for (const [x, z] of [
[2.43, 1.38],
[2.65, 1.58],
[2.78, 1.37]
]) {
polySphere(counter, M.red, 0.13, [x, 1.42, z], 0);
cylinder(counter, M.woodDark, [0.018, 0.018, 0.12, 5], [x, 1.58, z]);
}
// Small cash register.
box(counter, M.steelDark, [0.46, 0.24, 0.38], [3.05, 1.34, 1.85]);
const registerScreen = box(
counter,
M.window,
[0.35, 0.22, 0.04],
[3.05, 1.64, 1.82],
[-0.25, 0, 0]
);
registerScreen.castShadow = false;
// Glass guard over part of the display.
const glass = new THREE.Mesh(new THREE.PlaneGeometry(2.05, 0.62), M.glass);
glass.position.set(1.35, 1.62, 1.88);
glass.rotation.x = -0.12;
counter.add(glass);
for (const x of [0.31, 2.39]) {
box(counter, M.steel, [0.035, 0.66, 0.035], [x, 1.62, 1.89]);
}
// -------------------------------------------------------------------------
// Separate rear handling space
// -------------------------------------------------------------------------
const rear = new THREE.Group();
stall.add(rear);
// Low partition with a staff-only opening at the right.
box(rear, M.sage, [5.05, 1.12, 0.16], [-1.13, 0.63, -1.43]);
box(rear, M.sageDark, [0.9, 1.12, 0.16], [3.3, 0.63, -1.43]);
box(rear, M.woodDark, [5.1, 0.1, 0.2], [-1.13, 1.23, -1.43]);
box(rear, M.woodDark, [0.95, 0.1, 0.2], [3.3, 1.23, -1.43]);
// Low side walls and a taller back wall.
box(rear, M.sage, [0.16, 1.15, 2.12], [-3.72, 0.64, -2.46]);
box(rear, M.sage, [0.16, 1.15, 2.12], [3.72, 0.64, -2.46]);
box(rear, M.sageDark, [7.55, 2.2, 0.18], [0, 1.18, -3.53]);
box(rear, M.woodDark, [7.72, 0.15, 0.28], [0, 2.34, -3.53]);
sign(
rear,
{
items: [
{ text: "ARBEITSRAUM", size: 0.2, y: 0.37 },
{ text: "NUR FÜR PERSONAL", size: 0.105, y: 0.72 }
]
},
[-1.1, 0.79, -1.335],
2.75,
0.72,
"#40594d",
"#eaf1df"
);
// Prep table.
box(rear, M.steel, [3.65, 0.13, 1.02], [-0.35, 1.06, -2.4]);
box(rear, M.steelDark, [3.48, 0.15, 0.85], [-0.35, 0.97, -2.4]);
for (const x of [-1.95, 1.25]) {
for (const z of [-2.78, -2.02]) {
box(rear, M.steelDark, [0.09, 0.92, 0.09], [x, 0.55, z]);
}
}
box(rear, M.steelDark, [3.35, 0.08, 0.08], [-0.35, 0.3, -2.02]);
// Cutting board and vegetables.
box(rear, M.woodLight, [1.15, 0.065, 0.68], [-0.65, 1.16, -2.35]);
polySphere(rear, M.red, 0.13, [-0.95, 1.31, -2.35], 0);
polySphere(rear, M.green, 0.12, [-0.6, 1.3, -2.38], 0);
polySphere(rear, M.orange, 0.11, [-0.27, 1.3, -2.34], 0);
box(rear, M.steel, [0.42, 0.035, 0.12], [-0.47, 1.22, -2.08], [0, 0.25, 0]);
// Kitchen scale.
box(rear, M.creamLight, [0.52, 0.14, 0.45], [0.7, 1.2, -2.57]);
box(rear, M.window, [0.32, 0.16, 0.035], [0.7, 1.45, -2.41]);
// Sink unit.
box(rear, M.steel, [1.55, 0.13, 1.02], [2.55, 1.06, -2.42]);
box(rear, M.steelDark, [0.92, 0.035, 0.58], [2.48, 1.14, -2.38]);
box(rear, M.steelDark, [0.75, 0.04, 0.42], [2.48, 1.165, -2.38]);
beam(
rear,
M.steel,
[2.88, 1.14, -2.78],
[2.88, 1.7, -2.78],
0.035
);
beam(
rear,
M.steel,
[2.88, 1.7, -2.78],
[2.63, 1.7, -2.78],
0.035
);
// Wall shelving and storage.
box(rear, M.woodDark, [2.05, 0.11, 0.63], [-2.36, 2.03, -3.13]);
box(rear, M.woodDark, [2.05, 0.11, 0.63], [-2.36, 1.38, -3.13]);
crate(rear, -2.87, 2.1, -3.1, M.woodLight);
crate(rear, -1.86, 2.1, -3.1, M.wood);
crate(rear, -1.68, 0.12, -3.05, M.woodLight);
crate(rear, -0.72, 0.12, -3.05, M.wood);
// Hanging rail and simple utensils.
beam(rear, M.steelDark, [-1.45, 2.68, -3.28], [1.45, 2.68, -3.28], 0.03);
for (const x of [-1.05, -0.55, 0.0, 0.5, 0.95]) {
beam(rear, M.steel, [x, 2.68, -3.25], [x, 2.18, -3.25], 0.018);
cylinder(
rear,
M.steel,
[0.09, 0.09, 0.2, 8],
[x, 2.05, -3.25]
);
}
// Rear work sign.
sign(
rear,
{
items: [
{ text: "HANDLUNG", size: 0.24, y: 0.37 },
{ text: "ZUBEREITUNG · LAGER", size: 0.11, y: 0.72 }
]
},
[0.35, 1.9, -3.415],
3.2,
0.86,
"#40594d",
"#e8efdc"
);
// -------------------------------------------------------------------------
// Low-poly people
// -------------------------------------------------------------------------
function makePerson(x, z, shirtMaterial, options = {}) {
const group = new THREE.Group();
group.position.set(x, 0.1, z);
group.rotation.y = options.rotation || 0;
scene.add(group);
const skinMaterial = options.skin || M.skin;
const legMaterial = options.legs || M.black;
for (const side of [-1, 1]) {
cylinder(
group,
legMaterial,
[0.085, 0.095, 0.58, 7],
[side * 0.12, 0.38, 0]
);
box(group, M.black, [0.19, 0.1, 0.31], [side * 0.12, 0.07, 0.05]);
}
cylinder(
group,
shirtMaterial,
[0.25, 0.31, 0.67, 8],
[0, 1.02, 0]
);
cylinder(
group,
skinMaterial,
[0.08, 0.08, 0.58, 7],
[-0.31, 1.03, 0],
[0, 0, -0.12]
);
cylinder(
group,
skinMaterial,
[0.08, 0.08, 0.58, 7],
[0.31, 1.03, 0],
[0, 0, 0.12]
);
polySphere(group, skinMaterial, 0.16, [-0.34, 0.71, 0], 0);
polySphere(group, skinMaterial, 0.16, [0.34, 0.71, 0], 0);
polySphere(group, skinMaterial, 0.23, [0, 1.61, 0], 1);
const hair = polySphere(group, M.hair, 0.235, [0, 1.72, -0.015], 1);
hair.scale.set(1, 0.56, 1);
for (const side of [-1, 1]) {
polySphere(group, M.black, 0.018, [side * 0.073, 1.64, 0.207], 0);
}
if (options.apron) {
box(group, options.apron, [0.42, 0.62, 0.055], [0, 0.91, 0.255]);
box(group, options.apron, [0.1, 0.31, 0.045], [-0.14, 1.36, 0.16]);
box(group, options.apron, [0.1, 0.31, 0.045], [0.14, 1.36, 0.16]);
}
if (options.hat) {
cylinder(group, M.creamLight, [0.22, 0.24, 0.15, 9], [0, 1.82, 0]);
cylinder(group, M.creamLight, [0.35, 0.35, 0.035, 10], [0, 1.75, 0]);
}
return group;
}
makePerson(0.55, 0.15, M.teal, {
apron: M.creamLight,
hat: true,
rotation: 0
});
makePerson(1.55, -2.03, M.sage, {
apron: M.burgundy,
rotation: -0.2
});
const customer = makePerson(1.05, 3.15, M.orange, {
rotation: Math.PI,
skin: M.skinLight
});
box(customer, M.woodLight, [0.42, 0.28, 0.28], [0.42, 0.62, 0.1]);
box(customer, M.woodDark, [0.42, 0.045, 0.28], [0.42, 0.77, 0.1]);
// -------------------------------------------------------------------------
// Market lamps, lights, and simple neighboring details
// -------------------------------------------------------------------------
// String lights spanning the market lane.
for (const x of [-10.5, 10.5]) {
cylinder(scene, M.steelDark, [0.055, 0.075, 4.8, 8], [x, 2.4, 4.3]);
box(scene, M.steelDark, [0.42, 0.08, 0.42], [x, 0.08, 4.3]);
}
const wirePoints = [];
for (let i = 0; i <= 12; i++) {
const x = -10.5 + (21 / 12) * i;
const y = 4.55 - Math.sin((i / 12) * Math.PI) * 0.48;
wirePoints.push(new THREE.Vector3(x, y, 4.3));
}
for (let i = 0; i < wirePoints.length - 1; i++) {
beam(
scene,
M.black,
wirePoints[i].toArray(),
wirePoints[i + 1].toArray(),
0.012
);
}
for (let i = 1; i < wirePoints.length; i += 1) {
const point = wirePoints[i];
beam(scene, M.black, point.toArray(), [point.x, point.y - 0.14, point.z], 0.01);
polySphere(scene, M.bulb, 0.075, [point.x, point.y - 0.2, point.z], 0);
}
// Stylized trees.
function tree(x, z, scale = 1) {
const group = new THREE.Group();
group.position.set(x, 0, z);
group.scale.setScalar(scale);
scene.add(group);
cylinder(group, M.woodDark, [0.13, 0.18, 2.7, 7], [0, 1.35, 0]);
const crownA = polySphere(group, M.greenDark, 1.1, [0, 2.9, 0], 0);
crownA.scale.set(1.05, 1.12, 0.95);
const crownB = polySphere(group, M.green, 0.84, [0.5, 3.35, 0.15], 0);
crownB.scale.set(0.9, 1.15, 0.9);
const crownC = polySphere(group, M.greenDark, 0.78, [-0.48, 3.18, -0.08], 0);
}
tree(-11.1, -2.8, 1.05);
tree(11.0, -3.0, 1.1);
// Small adjacent stall for market context.
const neighbor = new THREE.Group();
neighbor.position.set(-7.4, 0, 1.4);
scene.add(neighbor);
box(neighbor, M.wood, [3.3, 0.95, 1.2], [0, 0.55, 0]);
box(neighbor, M.woodLight, [3.5, 0.12, 1.35], [0, 1.08, 0]);
for (const x of [-1.5, 1.5]) {
box(neighbor, M.woodDark, [0.12, 2.6, 0.12], [x, 1.3, 0]);
}
for (let i = 0; i < 6; i++) {
box(
neighbor,
i % 2 === 0 ? M.teal : M.cream,
[0.56, 0.08, 2.6],
[-1.4 + i * 0.56, 2.66, 0],
[0.16, 0, 0]
);
}
crate(neighbor, -0.8, 1.15, 0, M.woodLight);
crate(neighbor, 0.55, 1.15, 0, M.wood);
for (let i = 0; i < 8; i++) {
polySphere(
neighbor,
i % 2 === 0 ? M.orange : M.red,
0.12,
[-1.05 + (i % 4) * 0.25, 1.48 + Math.floor(i / 4) * 0.17, -0.12],
0
);
}
// -------------------------------------------------------------------------
// Custom camera controls — no external controls addon
// -------------------------------------------------------------------------
const orbit = {
theta: 0.67,
phi: 1.03,
radius: 13.2,
target: new THREE.Vector3(0, 1.62, 0.35)
};
function updateCamera() {
const sinPhi = Math.sin(orbit.phi);
camera.position.set(
orbit.target.x + orbit.radius * sinPhi * Math.sin(orbit.theta),
orbit.target.y + orbit.radius * Math.cos(orbit.phi),
orbit.target.z + orbit.radius * sinPhi * Math.cos(orbit.theta)
);
camera.lookAt(orbit.target);
camera.updateMatrixWorld();
}
const canvas = renderer.domElement;
let dragState = null;
let cameraTween = null;
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener("pointerdown", (event) => {
cameraTween = null;
dragState = {
x: event.clientX,
y: event.clientY,
pan: event.button === 2 || event.shiftKey
};
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!dragState) return;
const dx = event.clientX - dragState.x;
const dy = event.clientY - dragState.y;
dragState.x = event.clientX;
dragState.y = event.clientY;
if (dragState.pan) {
const right = new THREE.Vector3().setFromMatrixColumn(camera.matrix, 0);
orbit.target.addScaledVector(right, -dx * orbit.radius * 0.0014);
orbit.target.y += dy * orbit.radius * 0.0009;
} else {
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(orbit.phi - dy * 0.005, 0.42, 1.43);
}
updateCamera();
});
function endDrag(event) {
dragState = null;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTween = null;
orbit.radius = THREE.MathUtils.clamp(
orbit.radius * Math.exp(event.deltaY * 0.001),
6,
25
);
updateCamera();
},
{ passive: false }
);
const presets = {
front: {
theta: 0.67,
phi: 1.03,
radius: 13.2,
target: new THREE.Vector3(0, 1.62, 0.35)
},
rear: {
theta: 2.58,
phi: 1.0,
radius: 11.8,
target: new THREE.Vector3(0.25, 1.3, -1.65)
},
top: {
theta: 0.62,
phi: 0.55,
radius: 14.5,
target: new THREE.Vector3(0, 1.1, -0.35)
},
reset: {
theta: 0.67,
phi: 1.03,
radius: 13.2,
target: new THREE.Vector3(0, 1.62, 0.35)
}
};
function moveCamera(name) {
const target = presets[name];
if (!target) return;
cameraTween = {
start: performance.now(),
duration: 750,
from: {
theta: orbit.theta,
phi: orbit.phi,
radius: orbit.radius,
target: orbit.target.clone()
},
to: target
};
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => moveCamera(button.dataset.view));
});
window.addEventListener("keydown", (event) => {
const key = event.key.toLowerCase();
cameraTween = null;
if (key === "arrowleft") orbit.theta -= 0.09;
else if (key === "arrowright") orbit.theta += 0.09;
else if (key === "arrowup") orbit.phi = Math.max(0.42, orbit.phi - 0.07);
else if (key === "arrowdown") orbit.phi = Math.min(1.43, orbit.phi + 0.07);
else if (key === "+" || key === "=") orbit.radius = Math.max(6, orbit.radius - 0.7);
else if (key === "-" || key === "_") orbit.radius = Math.min(25, orbit.radius + 0.7);
else if (key === "r") {
moveCamera("reset");
return;
} else {
return;
}
updateCamera();
});
// -------------------------------------------------------------------------
// Animation and resize
// -------------------------------------------------------------------------
function animate(now) {
requestAnimationFrame(animate);
if (cameraTween) {
const elapsed = now - cameraTween.start;
const t = Math.min(1, elapsed / cameraTween.duration);
const eased = 1 - Math.pow(1 - t, 3);
orbit.theta = THREE.MathUtils.lerp(
cameraTween.from.theta,
cameraTween.to.theta,
eased
);
orbit.phi = THREE.MathUtils.lerp(
cameraTween.from.phi,
cameraTween.to.phi,
eased
);
orbit.radius = THREE.MathUtils.lerp(
cameraTween.from.radius,
cameraTween.to.radius,
eased
);
orbit.target.lerpVectors(
cameraTween.from.target,
cameraTween.to.target,
eased
);
if (t >= 1) cameraTween = null;
}
stallLight.intensity = 18 + Math.sin(now * 0.002) * 0.35;
updateCamera();
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
updateCamera();
requestAnimationFrame(animate);
</script>
</body>
</html>
```