Prompt specification
Build or customize the Three.js 3D scene "Corner shop parcel counter" 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: Corner shop parcel counter
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/corner-shop-parcel-counter-x0523
Scene Description Prompt:
Compose a neighborhood store with parcel shelves, scanner stand, queue, and shop goods; a pickup interaction retrieves the correct package while maintaining ordinary store circulation. Use Three.js from cdnjs in a single HTML file, with stylized solid shapes.
Working Three.js Starter (corner-shop-parcel-counter-x0523):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Parcel & Provisions</title>
<style>
:root {
--ink: #213b38;
--muted: #60746f;
--paper: rgba(255, 253, 245, 0.94);
--green: #347e68;
--line: rgba(33, 59, 56, 0.14);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #dbe7e2;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
#scene {
position: fixed;
inset: 0;
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}
.panel {
background: var(--paper);
border: 1px solid rgba(255, 255, 255, 0.8);
box-shadow:
0 18px 50px rgba(31, 62, 55, 0.16),
0 2px 8px rgba(31, 62, 55, 0.08);
backdrop-filter: blur(12px);
}
#ticket {
position: fixed;
top: 22px;
left: 22px;
width: min(340px, calc(100vw - 44px));
padding: 20px;
border-radius: 20px;
z-index: 10;
}
.eyebrow {
margin-bottom: 7px;
color: var(--green);
font-size: 11px;
font-weight: 850;
letter-spacing: 0.16em;
text-transform: uppercase;
}
h1 {
margin: 0;
font-size: 25px;
line-height: 1.08;
letter-spacing: -0.035em;
}
.subtitle {
margin: 8px 0 17px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.divider {
height: 1px;
margin: 15px 0;
background: var(--line);
}
.label {
margin-bottom: 7px;
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.target {
display: flex;
align-items: center;
gap: 12px;
min-height: 52px;
padding: 10px 12px;
border: 1px solid var(--line);
border-radius: 13px;
background: rgba(255, 255, 255, 0.55);
}
#colorDot {
width: 34px;
height: 34px;
flex: 0 0 auto;
border: 4px solid rgba(255, 255, 255, 0.88);
border-radius: 50%;
background: #ccc;
box-shadow: 0 2px 8px rgba(22, 43, 39, 0.18);
}
#targetText {
display: block;
font-size: 16px;
font-weight: 850;
line-height: 1.2;
}
#targetBay {
display: block;
margin-top: 3px;
color: var(--muted);
font-size: 12px;
}
.selected {
margin-top: 13px;
padding: 10px 12px;
border-radius: 11px;
background: #edf3ed;
color: var(--muted);
font-size: 12px;
line-height: 1.4;
}
.selected strong {
color: var(--ink);
}
.actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 9px;
margin-top: 15px;
}
button {
min-height: 43px;
padding: 10px 12px;
border: 0;
border-radius: 11px;
background: var(--green);
color: white;
font: inherit;
font-size: 12px;
font-weight: 800;
cursor: pointer;
transition:
transform 120ms ease,
opacity 120ms ease,
background 120ms ease;
}
button:hover:not(:disabled) {
transform: translateY(-1px);
background: #286a58;
}
button:active:not(:disabled) {
transform: translateY(0);
}
button:disabled {
cursor: not-allowed;
opacity: 0.42;
}
button.secondary {
border: 1px solid var(--line);
background: rgba(255, 255, 255, 0.72);
color: var(--ink);
}
button.secondary:hover:not(:disabled) {
background: white;
}
.steps {
margin-top: 14px;
color: var(--muted);
font-size: 11px;
line-height: 1.55;
}
.steps span {
display: inline-block;
width: 19px;
height: 19px;
margin-right: 4px;
border-radius: 50%;
background: #dce8df;
color: var(--green);
font-size: 10px;
font-weight: 900;
line-height: 19px;
text-align: center;
}
#viewControls {
position: fixed;
right: 22px;
bottom: 22px;
z-index: 10;
display: flex;
gap: 7px;
padding: 7px;
border-radius: 14px;
}
#viewControls button {
min-height: 35px;
padding: 8px 11px;
border-radius: 9px;
font-size: 11px;
}
#help {
position: fixed;
left: 22px;
bottom: 22px;
z-index: 8;
padding: 10px 13px;
border-radius: 11px;
background: rgba(33, 59, 56, 0.82);
color: rgba(255, 255, 255, 0.92);
font-size: 11px;
letter-spacing: 0.01em;
pointer-events: none;
}
#toast {
position: fixed;
top: 24px;
left: 50%;
z-index: 30;
max-width: min(430px, calc(100vw - 40px));
padding: 13px 18px;
border-radius: 13px;
background: #213b38;
color: white;
box-shadow: 0 12px 35px rgba(27, 49, 45, 0.22);
font-size: 13px;
font-weight: 700;
text-align: center;
opacity: 0;
transform: translate(-50%, -15px);
transition:
opacity 180ms ease,
transform 180ms ease;
pointer-events: none;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#toast.error {
background: #a84f45;
}
#toast.success {
background: #347e68;
}
#tooltip {
position: fixed;
z-index: 25;
padding: 8px 11px;
border-radius: 9px;
background: rgba(26, 49, 45, 0.93);
color: white;
font-size: 11px;
font-weight: 700;
opacity: 0;
transform: translate(12px, 12px);
transition: opacity 100ms ease;
pointer-events: none;
white-space: nowrap;
}
#tooltip.show {
opacity: 1;
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #dbe7e2;
color: var(--green);
font-size: 13px;
font-weight: 850;
letter-spacing: 0.12em;
text-transform: uppercase;
}
#loading.hidden {
display: none;
}
@media (max-width: 720px) {
#ticket {
top: 12px;
left: 12px;
width: min(320px, calc(100vw - 24px));
padding: 15px;
}
h1 {
font-size: 21px;
}
.subtitle,
.steps {
display: none;
}
#help {
display: none;
}
#viewControls {
right: 12px;
bottom: 12px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<section id="ticket" class="panel" aria-label="Pickup ticket">
<div class="eyebrow">Parcel & Provisions</div>
<h1>Neighborhood pickup</h1>
<p class="subtitle">
Find the parcel on the rear parcel rack, then scan it at the counter.
The overhead rail keeps the shopper aisle clear.
</p>
<div class="label">Pickup order</div>
<div class="target">
<div id="colorDot"></div>
<div>
<strong id="targetText">Loading order…</strong>
<small id="targetBay">Please wait</small>
</div>
</div>
<div id="selectedText" class="selected" aria-live="polite">
<strong>No parcel selected.</strong><br />Click a parcel on the rear shelf.
</div>
<div class="actions">
<button id="scanButton" disabled>Scan selected</button>
<button id="newOrderButton" class="secondary">New pickup</button>
</div>
<div class="steps">
<div><span>1</span>Choose the matching color and bay.</div>
<div><span>2</span>Click the scanner stand to retrieve it.</div>
</div>
</section>
<div id="viewControls" class="panel" aria-label="Camera views">
<button class="secondary" data-view="overview">Overview</button>
<button class="secondary" data-view="shelves">Parcel rack</button>
<button class="secondary" data-view="counter">Scanner</button>
</div>
<div id="help">Drag: orbit · Shift-drag: pan · Scroll: zoom · Click: interact</div>
<div id="toast" role="status" aria-live="polite"></div>
<div id="tooltip"></div>
<div id="loading">Opening neighborhood store…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const loading = document.getElementById("loading");
const toastElement = document.getElementById("toast");
const tooltipElement = document.getElementById("tooltip");
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: false,
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;
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xdbe7e2);
scene.fog = new THREE.Fog(0xdbe7e2, 26, 48);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const clock = new THREE.Clock();
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const interactiveMeshes = [];
const cameraState = {
target: new THREE.Vector3(0, 0.9, 0),
theta: 0.62,
phi: 1.02,
radius: 19.5
};
let cameraTween = null;
const hemi = new THREE.HemisphereLight(0xf5fff7, 0x7c8d83, 2.05);
scene.add(hemi);
const sun = new THREE.DirectionalLight(0xfff3d6, 3.15);
sun.position.set(-5, 14, 9);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -14;
sun.shadow.camera.right = 14;
sun.shadow.camera.top = 13;
sun.shadow.camera.bottom = -13;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.0004;
sun.shadow.normalBias = 0.025;
scene.add(sun);
const warmLight = new THREE.PointLight(0xffce87, 19, 10, 2);
warmLight.position.set(3.8, 5.5, -1.2);
scene.add(warmLight);
const standard = (color, options = {}) =>
new THREE.MeshStandardMaterial({
color,
roughness: 0.78,
metalness: 0.02,
...options
});
const palette = {
floor: standard(0xd9cdb8),
wall: standard(0xe9e4d7),
wallGreen: standard(0x9bb5a7),
trim: standard(0x426c60),
cream: standard(0xf3ead7),
dark: standard(0x264a43),
wood: standard(0x9c6844),
woodLight: standard(0xc99060),
metal: standard(0x63716c, { metalness: 0.65, roughness: 0.34 }),
black: standard(0x26322f),
tape: standard(0xfff1c9),
red: standard(0xcf5d4f),
green: standard(0x4c9b71)
};
function addBox(parent, w, h, d, material, x = 0, y = 0, z = 0, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), material);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addCylinder(
parent,
radiusTop,
radiusBottom,
height,
material,
x = 0,
y = 0,
z = 0,
segments = 24
) {
const mesh = new THREE.Mesh(
new THREE.CylinderGeometry(radiusTop, radiusBottom, height, segments),
material
);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addSphere(parent, radius, material, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(new THREE.SphereGeometry(radius, 20, 14), material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function textTexture(text, background = "#ffffff", foreground = "#24433d", width = 512, height = 160) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
if (background !== "transparent") {
ctx.fillStyle = background;
ctx.fillRect(0, 0, width, height);
}
ctx.fillStyle = foreground;
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `800 ${Math.floor(height * 0.48)}px system-ui, sans-serif`;
ctx.fillText(text, width / 2, height / 2 + 2, width * 0.9);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function addTextPlane(
parent,
text,
width,
height,
x,
y,
z,
background = "#ffffff",
foreground = "#24433d"
) {
const material = new THREE.MeshBasicMaterial({
map: textTexture(text, background, foreground),
transparent: background === "transparent",
side: THREE.DoubleSide,
depthWrite: background !== "transparent"
});
const mesh = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
function addBeamBetween(parent, a, b, radius, material) {
const direction = new THREE.Vector3().subVectors(b, a);
const length = direction.length();
const beam = addCylinder(
parent,
radius,
radius,
length,
material,
(a.x + b.x) / 2,
(a.y + b.y) / 2,
(a.z + b.z) / 2,
12
);
beam.quaternion.setFromUnitVectors(
new THREE.Vector3(0, 1, 0),
direction.clone().normalize()
);
return beam;
}
// Store shell.
addBox(scene, 18, 0.25, 14, palette.floor, 0, -0.125, 0, false);
addBox(scene, 18, 6, 0.25, palette.wall, 0, 3, -7);
addBox(scene, 0.25, 6, 14, palette.wall, -9, 3, 0);
addBox(scene, 18, 0.18, 0.14, palette.trim, 0, 0.12, -6.82);
addBox(scene, 0.14, 0.18, 14, palette.trim, -8.82, 0.12, 0);
// Subtle floor grid.
const tileMaterial = new THREE.MeshBasicMaterial({
color: 0x8e806d,
transparent: true,
opacity: 0.14,
depthWrite: false
});
for (let x = -8; x <= 8; x += 1.5) {
addBox(scene, 0.018, 0.008, 14, tileMaterial, x, 0.006, 0, false);
}
for (let z = -6; z <= 6; z += 1.5) {
addBox(scene, 18, 0.008, 0.018, tileMaterial, 0, 0.007, z, false);
}
// Entrance mat and doorway.
addBox(scene, 3.2, 0.025, 1.25, standard(0x3d7564), -1.25, 0.025, 6.1, false);
addBox(scene, 3.35, 0.04, 0.13, palette.trim, -1.25, 0.05, 6.76);
addBox(scene, 0.13, 3.2, 0.13, palette.trim, -2.95, 1.6, 6.78);
addBox(scene, 0.13, 3.2, 0.13, palette.trim, 0.45, 1.6, 6.78);
// Store signs.
addTextPlane(
scene,
"PARCEL & PROVISIONS",
5.2,
0.78,
-4.5,
4.85,
-6.85,
"#f4eddf",
"#315b50"
);
addTextPlane(
scene,
"PARCEL PICKUP",
3.7,
0.56,
3.8,
4.8,
-6.85,
"#315b50",
"#fff5df"
);
// Wall clock.
const clockGroup = new THREE.Group();
clockGroup.position.set(-1.5, 4.65, -6.82);
scene.add(clockGroup);
addCylinder(clockGroup, 0.4, 0.4, 0.08, palette.cream, 0, 0, 0, 32);
addBox(clockGroup, 0.04, 0.26, 0.025, palette.dark, 0, 0.1, 0.05);
const minuteHand = addBox(
clockGroup,
0.025,
0.31,
0.025,
palette.dark,
0.11,
0,
0.05
);
minuteHand.rotation.z = -0.7;
// Left-wall grocery shelving.
const grocery = new THREE.Group();
scene.add(grocery);
const shelfWood = standard(0x9b704d);
for (const z of [-4.15, 0.95]) {
addBox(grocery, 0.13, 3.75, 0.13, shelfWood, -8.68, 1.9, z);
addBox(grocery, 0.13, 3.75, 0.13, shelfWood, -7.12, 1.9, z);
}
const groceryShelfYs = [0.3, 1.25, 2.2, 3.15];
for (const y of groceryShelfYs) {
addBox(grocery, 1.65, 0.12, 5.25, shelfWood, -7.9, y, -1.6);
}
const groceryColors = [
0xd96f5d,
0xe5b84f,
0x5d9f88,
0x6c8fc2,
0xa978a8,
0xe0c99d
];
for (let row = 0; row < groceryShelfYs.length; row++) {
for (let col = 0; col < 7; col++) {
const z = -3.85 + col * 0.73;
const baseY = groceryShelfYs[row] + 0.06;
const material = standard(groceryColors[(row + col) % groceryColors.length]);
if ((row + col) % 3 === 0) {
addBox(grocery, 0.55, 0.52, 0.5, material, -7.92, baseY + 0.26, z);
addBox(
grocery,
0.08,
0.54,
0.52,
palette.cream,
-7.92,
baseY + 0.27,
z
);
} else if ((row + col) % 3 === 1) {
addCylinder(grocery, 0.19, 0.19, 0.48, material, -7.92, baseY + 0.24, z);
addCylinder(
grocery,
0.1,
0.1,
0.08,
palette.tape,
-7.92,
baseY + 0.52,
z
);
} else {
addBox(grocery, 0.48, 0.62, 0.38, material, -7.92, baseY + 0.31, z);
addBox(
grocery,
0.28,
0.15,
0.015,
palette.cream,
-7.67,
baseY + 0.32,
z
);
}
}
}
addTextPlane(
grocery,
"PANTRY",
1.25,
0.34,
-7.04,
3.82,
-1.6,
"#f6efdf",
"#315b50"
);
// Produce island.
const produce = new THREE.Group();
produce.position.set(-5.25, 0, -3.55);
scene.add(produce);
addBox(produce, 2.15, 0.72, 1.55, palette.woodLight, 0, 0.36, 0);
addBox(produce, 2.28, 0.12, 1.68, palette.cream, 0, 0.77, 0);
const produceColors = [0xe76f51, 0xe6b442, 0x74a957, 0xb45d70];
for (let i = 0; i < 4; i++) {
const x = -0.78 + (i % 2) * 1.03;
const z = -0.38 + Math.floor(i / 2) * 0.75;
addBox(produce, 0.83, 0.12, 0.6, standard(0x526c61), x, 0.88, z);
for (let j = 0; j < 5; j++) {
const fruit = addSphere(
produce,
0.13,
standard(produceColors[(i + j) % produceColors.length]),
x + (j % 3 - 1) * 0.2,
1.02,
z + (Math.floor(j / 3) - 0.5) * 0.23
);
fruit.scale.y = 0.9;
}
}
// Bread table.
const breadTable = new THREE.Group();
breadTable.position.set(-4.75, 0, 1.75);
scene.add(breadTable);
addBox(breadTable, 2.25, 0.18, 1.15, palette.woodLight, 0, 0.94, 0);
addBox(breadTable, 0.16, 0.9, 0.8, palette.wood, -0.85, 0.45, 0);
addBox(breadTable, 0.16, 0.9, 0.8, palette.wood, 0.85, 0.45, 0);
const breadColors = [0xc98b43, 0xd8a95a, 0xb97635];
for (let i = 0; i < 6; i++) {
const loaf = addSphere(
breadTable,
0.25,
standard(breadColors[i % breadColors.length]),
-0.78 + (i % 3) * 0.76,
1.14,
i < 3 ? -0.23 : 0.22
);
loaf.scale.set(1.45, 0.55, 0.75);
}
// Parcel rack structure.
const parcelRack = new THREE.Group();
scene.add(parcelRack);
for (const x of [0.35, 2.58, 4.84, 7.1]) {
addBox(parcelRack, 0.14, 3.9, 0.95, palette.trim, x, 1.95, -6.12);
}
const parcelShelfYs = [0.35, 1.35, 2.35, 3.35];
for (const y of parcelShelfYs) {
addBox(parcelRack, 7.0, 0.12, 1.05, palette.woodLight, 3.72, y, -6.12);
}
addTextPlane(
parcelRack,
"A",
0.35,
0.25,
1.45,
3.72,
-5.55,
"#f5eddd",
"#315b50"
);
addTextPlane(
parcelRack,
"B",
0.35,
0.25,
3.72,
3.72,
-5.55,
"#f5eddd",
"#315b50"
);
addTextPlane(
parcelRack,
"C",
0.35,
0.25,
5.99,
3.72,
-5.55,
"#f5eddd",
"#315b50"
);
// Nine stylized parcels.
const parcelPalette = [
{ name: "Coral", hex: 0xef8068 },
{ name: "Teal", hex: 0x42a89d },
{ name: "Mustard", hex: 0xe8b84a },
{ name: "Cobalt", hex: 0x5079c9 },
{ name: "Plum", hex: 0x8b68ad },
{ name: "Mint", hex: 0x77b982 },
{ name: "Clay", hex: 0xbd7559 },
{ name: "Sky", hex: 0x6cb9d2 },
{ name: "Lemon", hex: 0xf0d96a }
];
const columnCenters = [1.45, 3.72, 5.99];
const rowCenters = [0.78, 1.78, 2.78];
const parcels = [];
for (let row = 0; row < rowCenters.length; row++) {
for (let col = 0; col < columnCenters.length; col++) {
const index = row * 3 + col;
const definition = parcelPalette[index];
const bay = `${String.fromCharCode(65 + col)}${row + 1}`;
const group = new THREE.Group();
group.position.set(columnCenters[col], rowCenters[row], -5.94);
scene.add(group);
const bodyMaterial = standard(definition.hex);
const body = addBox(group, 0.86, 0.6, 0.72, bodyMaterial, 0, 0, 0);
const tape = addBox(group, 0.17, 0.615, 0.735, palette.tape, 0, 0, 0);
const label = addTextPlane(
group,
"PARCEL",
0.36,
0.15,
0.24,
-0.05,
0.366,
"#fff7e6",
"#4a5d57"
);
const parcel = {
index,
group,
body,
tape,
label,
bodyMaterial,
home: group.position.clone(),
name: definition.name,
hex: definition.hex,
bay,
status: "available"
};
body.userData.parcel = parcel;
tape.userData.parcel = parcel;
label.userData.parcel = parcel;
interactiveMeshes.push(body, tape, label);
parcels.push(parcel);
addTextPlane(
parcelRack,
bay,
0.44,
0.18,
columnCenters[col],
parcelShelfYs[row] + 0.04,
-5.57,
"#f6eddd",
"#315b50"
);
}
}
// Checkout counter.
const counter = new THREE.Group();
counter.position.set(5.3, 0, 0.15);
scene.add(counter);
addBox(counter, 4.55, 1.14, 1.25, palette.cream, 0, 0.57, 0);
addBox(counter, 4.72, 0.13, 1.38, palette.woodLight, 0, 1.2, 0);
addBox(counter, 4.25, 0.68, 0.025, palette.wallGreen, 0, 0.62, 0.64);
addTextPlane(
counter,
"PICKUP & PAY",
2.2,
0.34,
0.1,
0.67,
0.67,
"#9bb5a7",
"#244b42"
);
// Register terminal.
const terminal = new THREE.Group();
terminal.position.set(-2.15, 1.29, -0.12);
terminal.rotation.y = -0.15;
counter.add(terminal);
addBox(terminal, 0.76, 0.1, 0.48, palette.black, 0, 0.05, 0);
addBox(terminal, 0.65, 0.44, 0.08, palette.black, 0, 0.32, -0.04);
addTextPlane(
terminal,
"SCAN",
0.53,
0.29,
0,
0.33,
0.015,
"#88c6a7",
"#183d34"
);
// Scanner stand.
const scanner = new THREE.Group();
scanner.position.set(-1.4, 1.28, -0.12);
counter.add(scanner);
addBox(scanner, 0.64, 0.1, 0.55, palette.black, 0, 0.05, 0);
addBox(scanner, 0.12, 0.62, 0.12, palette.metal, 0, 0.4, 0);
const scannerHead = addBox(
scanner,
0.62,
0.28,
0.35,
standard(0x334a44),
0,
0.78,
0
);
scannerHead.rotation.x = -0.2;
const scannerLensMaterial = standard(0xd45d50, {
emissive: 0x7d1710,
emissiveIntensity: 0.55,
roughness: 0.25
});
const scannerLens = addBox(
scanner,
0.42,
0.04,
0.19,
scannerLensMaterial,
0,
0.92,
0.06
);
scannerLens.rotation.x = -0.2;
scannerHead.userData.scanner = true;
scannerLens.userData.scanner = true;
interactiveMeshes.push(scannerHead, scannerLens);
// Pickup tray.
addBox(counter, 1.25, 0.05, 0.84, palette.trim, 1.12, 1.31, 0);
addBox(counter, 1.25, 0.25, 0.06, palette.trim, 1.12, 1.43, 0.4);
addBox(counter, 0.06, 0.25, 0.84, palette.trim, 0.52, 1.43, 0);
addBox(counter, 0.06, 0.25, 0.84, palette.trim, 1.72, 1.43, 0);
// Queue stanchions.
const postMaterial = palette.metal;
const beltMaterial = standard(0x365c53);
const queueXs = [3.12, 5.12];
const queueZs = [2.2, 3.3, 4.4];
for (const x of queueXs) {
for (const z of queueZs) {
addCylinder(counter, 0.25, 0.3, 0.08, postMaterial, x - 5.3, 0.04, z - 0.15);
addCylinder(counter, 0.055, 0.055, 1.08, postMaterial, x - 5.3, 0.56, z - 0.15, 12);
addSphere(counter, 0.085, palette.metal, x - 5.3, 1.12, z - 0.15);
}
}
for (let i = 0; i < queueZs.length - 1; i++) {
for (const x of queueXs) {
addBox(
counter,
0.035,
0.12,
1.1,
beltMaterial,
x - 5.3,
0.88,
(queueZs[i] + queueZs[i + 1]) / 2 - 0.15
);
}
}
// Overhead parcel transfer rail.
const railMaterial = standard(0x34564f, { metalness: 0.45, roughness: 0.42 });
for (const x of [0.18, 0.52]) {
addBox(scene, 0.055, 0.07, 4.35, railMaterial, x, 4.03, -3.1);
addBox(scene, 0.055, 0.07, 4.35, railMaterial, x, 4.03, -3.1);
}
for (const z of [-1.18, -0.84]) {
addBox(scene, 4.25, 0.07, 0.055, railMaterial, 2.31, 4.03, z);
}
for (const p of [
[0.35, -5.18],
[0.35, -1.0],
[4.25, -1.0]
]) {
addCylinder(scene, 0.025, 0.025, 1.5, railMaterial, p[0], 4.78, p[1], 10);
}
// Plant near the entrance.
const plant = new THREE.Group();
plant.position.set(7.85, 0, 5.2);
scene.add(plant);
addCylinder(plant, 0.48, 0.37, 0.75, standard(0xbd7e5e), 0, 0.38, 0, 24);
addCylinder(plant, 0.06, 0.08, 1.6, palette.wood, 0, 1.45, 0, 10);
for (let i = 0; i < 7; i++) {
const angle = (i / 7) * Math.PI * 2;
const leaf = addSphere(
plant,
0.42,
standard(i % 2 ? 0x4d8c65 : 0x6ea875),
Math.cos(angle) * 0.42,
1.65 + (i % 3) * 0.23,
Math.sin(angle) * 0.42
);
leaf.scale.set(0.48, 1.15, 0.8);
leaf.rotation.z = Math.cos(angle) * 0.75;
leaf.rotation.x = Math.sin(angle) * 0.75;
}
// Stylized people.
function createPerson(outfitColor, skinColor, hairColor, hasBag = false) {
const person = new THREE.Group();
const outfit = standard(outfitColor);
const skin = standard(skinColor);
const hair = standard(hairColor);
const shoes = palette.black;
const torso = addCylinder(person, 0.26, 0.31, 0.72, outfit, 0, 1.04, 0, 16);
torso.scale.z = 0.8;
addSphere(person, 0.235, skin, 0, 1.62, 0);
const hairCap = addSphere(person, 0.242, hair, 0, 1.73, -0.025);
hairCap.scale.set(1.0, 0.55, 1.0);
addSphere(person, 0.055, skin, 0, 1.6, 0.225);
const leftLeg = addBox(person, 0.15, 0.58, 0.18, palette.dark, -0.13, 0.34, 0);
const rightLeg = addBox(person, 0.15, 0.58, 0.18, palette.dark, 0.13, 0.34, 0);
addBox(person, 0.18, 0.11, 0.29, shoes, -0.13, 0.055, 0.06);
addBox(person, 0.18, 0.11, 0.29, shoes, 0.13, 0.055, 0.06);
const leftArm = addBox(person, 0.12, 0.62, 0.14, outfit, -0.35, 1.03, 0);
const rightArm = addBox(person, 0.12, 0.62, 0.14, outfit, 0.35, 1.03, 0);
if (hasBag) {
addBox(person, 0.36, 0.4, 0.19, standard(0xd9b86e), 0.36, 0.61, 0.08);
addBox(person, 0.04, 0.48, 0.04, standard(0xd9b86e), 0.27, 0.93, 0.08);
}
person.userData.leftLeg = leftLeg;
person.userData.rightLeg = rightLeg;
person.userData.leftArm = leftArm;
person.userData.rightArm = rightArm;
scene.add(person);
return person;
}
function createWalker(route, outfit, skin, hair, speed, hasBag = false) {
const person = createPerson(outfit, skin, hair, hasBag);
const points = route.map(([x, z]) => new THREE.Vector3(x, 0, z));
person.position.copy(points[0]);
return {
person,
points,
index: 0,
speed,
phase: Math.random() * Math.PI * 2
};
}
const walkers = [
createWalker(
[
[-2.4, 5.55],
[-2.4, -4.55],
[1.12, -4.55],
[1.12, 2.55],
[-2.4, 5.55]
],
0xd9795e,
0xd6a47c,
0x49372e,
0.9,
true
),
createWalker(
[
[-5.8, 5.4],
[-5.8, -2.15],
[-3.25, -2.15],
[-3.25, 5.4]
],
0x608db3,
0x8d5f45,
0x211f1d,
0.72
)
];
const queuePeople = [
{
person: createPerson(0xc39b55, 0xe1b895, 0x6d4933, true),
z: 4.3,
phase: 0.3
},
{
person: createPerson(0x7ca18b, 0x9b6b4d, 0x2f2823, false),
z: 3.15,
phase: 1.6
}
];
for (const customer of queuePeople) {
customer.person.position.set(4.12, 0, customer.z);
customer.person.rotation.y = Math.PI;
}
const cashier = createPerson(0x365f56, 0xc98f67, 0x332923, false);
cashier.position.set(5.45, 0, -1.05);
cashier.rotation.y = 0;
// Pendant lights.
for (const x of [-4.8, 0.2, 5.2]) {
const lamp = new THREE.Group();
lamp.position.set(x, 5.5, -1.25);
scene.add(lamp);
addCylinder(lamp, 0.035, 0.035, 1.4, palette.black, 0, 0.7, 0, 10);
addCylinder(lamp, 0.18, 0.52, 0.38, standard(0xe1b66c), 0, -0.12, 0, 24);
const bulb = addSphere(lamp, 0.16, standard(0xffe7ae), 0, -0.28, 0);
bulb.material.emissive = new THREE.Color(0xffd58a);
bulb.material.emissiveIntensity = 0.5;
}
// Interaction and order state.
let activeTarget = null;
let selectedParcel = null;
let transfer = null;
let orderCounter = 1;
let scannerFlash = null;
let scannerFlashTimer = 0;
let toastTimer = 0;
const confetti = [];
function showToast(message, type = "") {
toastElement.textContent = message;
toastElement.className = `show ${type}`;
toastTimer = 3.2;
}
function updateTicket() {
document.getElementById("colorDot").style.background =
`#${activeTarget.hex.toString(16).padStart(6, "0")}`;
document.getElementById("targetText").textContent =
`${activeTarget.name} parcel`;
document.getElementById("targetBay").textContent =
`Bay ${activeTarget.bay} · order PM-${240 + orderCounter}`;
const selectedElement = document.getElementById("selectedText");
const scanButton = document.getElementById("scanButton");
const newOrderButton = document.getElementById("newOrderButton");
if (selectedParcel) {
selectedElement.innerHTML =
`<strong>Selected: ${selectedParcel.name} parcel</strong><br />` +
`Bay ${selectedParcel.bay} — ready to scan.`;
} else {
selectedElement.innerHTML =
"<strong>No parcel selected.</strong><br />Click a parcel on the rear shelf.";
}
scanButton.disabled = !selectedParcel || !!transfer || activeTarget.status === "done";
newOrderButton.disabled = !!transfer;
if (activeTarget.status === "done") {
document.getElementById("targetText").textContent = "Pickup complete";
document.getElementById("targetBay").textContent =
`Collected from bay ${activeTarget.bay}`;
scanButton.textContent = "Collected";
} else {
scanButton.textContent = "Scan selected";
}
}
function restoreParcel(parcel) {
parcel.group.position.copy(parcel.home);
parcel.group.rotation.set(0, 0, 0);
parcel.group.scale.set(1, 1, 1);
parcel.bodyMaterial.emissive.setHex(0x000000);
parcel.bodyMaterial.emissiveIntensity = 0;
parcel.status = "available";
}
function selectParcel(parcel) {
if (transfer || parcel.status === "done") return;
if (selectedParcel && selectedParcel !== parcel) {
selectedParcel.bodyMaterial.emissive.setHex(0x000000);
selectedParcel.bodyMaterial.emissiveIntensity = 0;
selectedParcel.group.scale.set(1, 1, 1);
}
selectedParcel = parcel;
parcel.bodyMaterial.emissive.setHex(0xffffff);
parcel.bodyMaterial.emissiveIntensity = 0.16;
updateTicket();
showToast(
`${parcel.name} parcel selected — check bay ${parcel.bay}.`,
""
);
}
function spawnConfetti(position) {
const colors = [0xef8068, 0x5079c9, 0xe8b84a, 0x42a89d, 0x8b68ad];
for (let i = 0; i < 22; i++) {
const mesh = addBox(
scene,
0.1,
0.04,
0.17,
standard(colors[i % colors.length]),
position.x,
position.y + 0.2,
position.z
);
mesh.rotation.set(Math.random() * 2, Math.random() * 2, Math.random() * 2);
confetti.push({
mesh,
velocity: new THREE.Vector3(
(Math.random() - 0.5) * 2.2,
2 + Math.random() * 2.1,
(Math.random() - 0.5) * 2.2
),
life: 1.6
});
}
}
function beginTransfer(parcel) {
parcel.status = "moving";
const p = parcel.group.position.clone();
transfer = {
parcel,
phase: "toScanner",
points: [
new THREE.Vector3(p.x, p.y, -5.18),
new THREE.Vector3(p.x, 3.7, -5.18),
new THREE.Vector3(0.35, 3.7, -5.18),
new THREE.Vector3(0.35, 3.7, -1.0),
new THREE.Vector3(4.22, 3.7, -1.0),
new THREE.Vector3(4.22, 1.78, -0.08)
],
index: 0,
t: 0,
speed: 3.1
};
scannerFlash = "green";
scannerFlashTimer = 1.2;
updateTicket();
showToast("Correct parcel found. Transferring along the overhead rail…", "success");
}
function scanSelected() {
if (!selectedParcel) {
showToast("Select a parcel from the rear rack first.", "error");
return;
}
if (transfer) return;
if (selectedParcel !== activeTarget) {
scannerFlash = "red";
scannerFlashTimer = 0.8;
showToast(
`Scan rejected. This order needs the ${activeTarget.name.toLowerCase()} parcel in bay ${activeTarget.bay}.`,
"error"
);
return;
}
beginTransfer(selectedParcel);
}
function newOrder() {
if (transfer) return;
for (const parcel of parcels) restoreParcel(parcel);
selectedParcel = null;
orderCounter += 1;
const choices = parcels.filter((parcel) => parcel !== activeTarget);
activeTarget = choices[Math.floor(Math.random() * choices.length)];
updateTicket();
showToast(
`New pickup: find the ${activeTarget.name.toLowerCase()} parcel in bay ${activeTarget.bay}.`,
""
);
}
function completeTransfer() {
const parcel = transfer.parcel;
parcel.status = "done";
parcel.bodyMaterial.emissive.setHex(0xffffff);
parcel.bodyMaterial.emissiveIntensity = 0.07;
const finalPosition = new THREE.Vector3(6.48, 1.57, 0.1);
parcel.group.position.copy(finalPosition);
scannerFlash = "green";
scannerFlashTimer = 1.5;
spawnConfetti(finalPosition);
transfer = null;
updateTicket();
showToast(
`Pickup complete — ${parcel.name} parcel is on the counter.`,
"success"
);
}
function updateTransfer(dt) {
if (!transfer) return;
if (transfer.phase === "toScanner") {
const a = transfer.points[transfer.index];
const b = transfer.points[transfer.index + 1];
if (!b) {
transfer.phase = "toTray";
transfer.points = [
transfer.parcel.group.position.clone(),
new THREE.Vector3(6.48, 1.57, 0.1)
];
transfer.index = 0;
transfer.t = 0;
transfer.speed = 2.2;
return;
}
const length = a.distanceTo(b);
transfer.t += (dt * transfer.speed) / Math.max(length, 0.001);
if (transfer.t >= 1) {
transfer.t = 0;
transfer.index += 1;
transfer.parcel.group.position.copy(b);
} else {
transfer.parcel.group.position.lerpVectors(a, b, transfer.t);
}
} else if (transfer.phase === "toTray") {
const a = transfer.points[transfer.index];
const b = transfer.points[transfer.index + 1];
if (!b) {
completeTransfer();
return;
}
const length = a.distanceTo(b);
transfer.t += (dt * transfer.speed) / Math.max(length, 0.001);
if (transfer.t >= 1) {
transfer.t = 0;
transfer.index += 1;
transfer.parcel.group.position.copy(b);
} else {
transfer.parcel.group.position.lerpVectors(a, b, transfer.t);
}
}
}
document.getElementById("scanButton").addEventListener("click", scanSelected);
document.getElementById("newOrderButton").addEventListener("click", newOrder);
// Custom camera controls implemented without external addons.
function updateCamera() {
const sinPhi = Math.sin(cameraState.phi);
camera.position.set(
cameraState.target.x + cameraState.radius * sinPhi * Math.sin(cameraState.theta),
cameraState.target.y + cameraState.radius * Math.cos(cameraState.phi),
cameraState.target.z + cameraState.radius * sinPhi * Math.cos(cameraState.theta)
);
camera.lookAt(cameraState.target);
camera.updateMatrixWorld();
}
function setView(view) {
const views = {
overview: {
target: new THREE.Vector3(0, 0.9, 0),
theta: 0.62,
phi: 1.02,
radius: 19.5
},
shelves: {
target: new THREE.Vector3(3.6, 1.8, -5.25),
theta: 0.28,
phi: 1.12,
radius: 8.4
},
counter: {
target: new THREE.Vector3(4.7, 1.45, 0.15),
theta: 0.64,
phi: 1.08,
radius: 6.6
}
};
const destination = views[view];
cameraTween = {
from: {
target: cameraState.target.clone(),
theta: cameraState.theta,
phi: cameraState.phi,
radius: cameraState.radius
},
to: {
target: destination.target.clone(),
theta: destination.theta,
phi: destination.phi,
radius: destination.radius
},
elapsed: 0
};
}
document.querySelectorAll("[data-view]").forEach((button) => {
button.addEventListener("click", () => setView(button.dataset.view));
});
let pointerDown = null;
let dragging = false;
function setPointerFromEvent(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
function intersectInteractive(event) {
setPointerFromEvent(event);
raycaster.setFromCamera(pointer, camera);
return raycaster.intersectObjects(interactiveMeshes, false);
}
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerDown = {
x: event.clientX,
y: event.clientY,
button: event.button,
shift: event.shiftKey
};
dragging = false;
cameraTween = null;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (pointerDown) {
const dx = event.clientX - pointerDown.x;
const dy = event.clientY - pointerDown.y;
if (Math.hypot(dx, dy) > 5) dragging = true;
if (dragging) {
if (pointerDown.button === 2 || pointerDown.shift) {
const right = new THREE.Vector3()
.setFromMatrixColumn(camera.matrix, 0)
.setY(0)
.normalize();
const forward = camera.getWorldDirection(new THREE.Vector3())
.setY(0)
.normalize();
const panScale = cameraState.radius * 0.0017;
cameraState.target.addScaledVector(right, -dx * panScale);
cameraState.target.addScaledVector(forward, dy * panScale);
cameraState.target.x = THREE.MathUtils.clamp(
cameraState.target.x,
-8,
8
);
cameraState.target.z = THREE.MathUtils.clamp(
cameraState.target.z,
-6,
6
);
} else {
cameraState.theta -= dx * 0.006;
cameraState.phi = THREE.MathUtils.clamp(
cameraState.phi - dy * 0.005,
0.48,
1.34
);
}
pointerDown.x = event.clientX;
pointerDown.y = event.clientY;
tooltipElement.classList.remove("show");
return;
}
}
const hits = intersectInteractive(event);
if (hits.length) {
const object = hits[0].object;
renderer.domElement.style.cursor = "pointer";
if (object.userData.parcel) {
const parcel = object.userData.parcel;
tooltipElement.textContent = `${parcel.name} parcel · Bay ${parcel.bay}`;
tooltipElement.classList.add("show");
} else if (object.userData.scanner) {
tooltipElement.textContent = "Scanner stand · Click to scan";
tooltipElement.classList.add("show");
}
} else {
renderer.domElement.style.cursor = "grab";
tooltipElement.classList.remove("show");
}
tooltipElement.style.left = `${event.clientX}px`;
tooltipElement.style.top = `${event.clientY}px`;
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (pointerDown && !dragging && pointerDown.button === 0) {
const hits = intersectInteractive(event);
if (hits.length) {
const object = hits[0].object;
if (object.userData.parcel) {
selectParcel(object.userData.parcel);
} else if (object.userData.scanner) {
scanSelected();
}
}
}
pointerDown = null;
dragging = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
});
renderer.domElement.addEventListener("pointerleave", () => {
tooltipElement.classList.remove("show");
});
renderer.domElement.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraTween = null;
cameraState.radius = THREE.MathUtils.clamp(
cameraState.radius + event.deltaY * 0.012,
5,
28
);
},
{ passive: false }
);
// Initialize a random pickup order.
activeTarget = parcels[Math.floor(Math.random() * parcels.length)];
updateTicket();
updateCamera();
function updateWalkers(dt, elapsed) {
for (const walker of walkers) {
const current = walker.points[walker.index];
const next = walker.points[(walker.index + 1) % walker.points.length];
const direction = new THREE.Vector3().subVectors(next, current);
const distance = direction.length();
const step = walker.speed * dt;
if (distance <= step) {
walker.person.position.copy(next);
walker.index = (walker.index + 1) % walker.points.length;
} else {
direction.normalize();
walker.person.position.addScaledVector(direction, step);
walker.person.rotation.y = Math.atan2(direction.x, direction.z);
}
const swing = Math.sin(elapsed * 6.3 + walker.phase) * 0.43;
walker.person.userData.leftLeg.rotation.x = swing;
walker.person.userData.rightLeg.rotation.x = -swing;
walker.person.userData.leftArm.rotation.x = -swing * 0.65;
walker.person.userData.rightArm.rotation.x = swing * 0.65;
walker.person.position.y = Math.abs(Math.sin(elapsed * 6.3 + walker.phase)) * 0.025;
}
for (const customer of queuePeople) {
const bob = Math.sin(elapsed * 2.3 + customer.phase) * 0.012;
customer.person.position.y = bob;
customer.person.userData.leftArm.rotation.x =
Math.sin(elapsed * 1.7 + customer.phase) * 0.08;
}
cashier.userData.rightArm.rotation.x =
-0.45 + Math.sin(elapsed * 2.5) * 0.08;
}
function updateScanner(dt) {
scannerFlashTimer = Math.max(0, scannerFlashTimer - dt);
if (scannerFlash === "red") {
scannerLensMaterial.color.setHex(0xe15d4f);
scannerLensMaterial.emissive.setHex(0x8c110a);
scannerLensMaterial.emissiveIntensity = 1.1;
if (scannerFlashTimer === 0) scannerFlash = null;
} else if (scannerFlash === "green") {
scannerLensMaterial.color.setHex(0x57c48d);
scannerLensMaterial.emissive.setHex(0x16794f);
scannerLensMaterial.emissiveIntensity = 1.05;
if (scannerFlashTimer === 0) scannerFlash = null;
} else {
scannerLensMaterial.color.setHex(0xd45d50);
scannerLensMaterial.emissive.setHex(0x7d1710);
scannerLensMaterial.emissiveIntensity = 0.55;
}
}
function updateConfetti(dt) {
for (let i = confetti.length - 1; i >= 0; i--) {
const item = confetti[i];
item.life -= dt;
item.velocity.y -= 4.5 * dt;
item.mesh.position.addScaledVector(item.velocity, dt);
item.mesh.rotation.x += dt * 5;
item.mesh.rotation.y += dt * 4;
item.mesh.scale.setScalar(Math.max(0.05, item.life / 1.6));
if (item.life <= 0) {
scene.remove(item.mesh);
item.mesh.geometry.dispose();
item.mesh.material.dispose();
confetti.splice(i, 1);
}
}
}
function animate() {
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
if (cameraTween) {
cameraTween.elapsed += dt;
const t = Math.min(1, cameraTween.elapsed / 0.75);
const eased = 1 - Math.pow(1 - t, 3);
cameraState.target.lerpVectors(
cameraTween.from.target,
cameraTween.to.target,
eased
);
cameraState.theta = THREE.MathUtils.lerp(
cameraTween.from.theta,
cameraTween.to.theta,
eased
);
cameraState.phi = THREE.MathUtils.lerp(
cameraTween.from.phi,
cameraTween.to.phi,
eased
);
cameraState.radius = THREE.MathUtils.lerp(
cameraTween.from.radius,
cameraTween.to.radius,
eased
);
if (t === 1) cameraTween = null;
}
updateCamera();
updateWalkers(dt, elapsed);
updateTransfer(dt);
updateScanner(dt);
updateConfetti(dt);
if (selectedParcel && selectedParcel.status === "available") {
const targetScale = 1.045 + Math.sin(elapsed * 3.5) * 0.012;
selectedParcel.group.scale.setScalar(targetScale);
}
if (toastTimer > 0) {
toastTimer -= dt;
if (toastTimer <= 0) toastElement.classList.remove("show");
}
renderer.render(scene, camera);
}
renderer.setAnimationLoop(animate);
loading.classList.add("hidden");
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
</script>
</body>
</html>
```