Prompt specification
Build or customize the Three.js 3D scene "Neighborhood shoe shop fitting area" 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: Neighborhood shoe shop fitting area
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/neighborhood-shoe-shop-fitting-area-x0539
Scene Description Prompt:
Build a self-contained HTML scene with Three.js from cdnjs featuring shoe fitting. Compose a shop with bench, measuring board, sample shelves, and mirror; a visitor compares two pairs while keeping removed shoes and bags out of the route. Voxel style.
Working Three.js Starter (neighborhood-shoe-shop-fitting-area-x0539):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Voxel Fit Lab</title>
<style>
:root {
--ink: #24312f;
--paper: #f6f1e8;
--panel: rgba(250, 247, 239, 0.92);
--mint: #43a99a;
--coral: #e76550;
--line: rgba(36, 49, 47, 0.16);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: #e9e3d8;
color: var(--ink);
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.brand {
position: fixed;
top: 24px;
left: 26px;
z-index: 10;
display: flex;
align-items: center;
gap: 12px;
pointer-events: none;
}
.brand-mark {
display: grid;
width: 44px;
height: 44px;
place-items: center;
border-radius: 12px;
background: var(--ink);
color: var(--paper);
box-shadow: 0 8px 28px rgba(36, 49, 47, 0.2);
}
.brand-mark svg {
width: 28px;
height: 28px;
}
.brand-copy strong {
display: block;
font-size: 17px;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.brand-copy span {
display: block;
margin-top: 3px;
color: rgba(36, 49, 47, 0.64);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.top-right {
position: fixed;
top: 22px;
right: 24px;
z-index: 12;
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 9px;
}
.status {
display: flex;
align-items: center;
gap: 9px;
padding: 10px 14px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 999px;
background: var(--panel);
box-shadow: 0 10px 35px rgba(36, 49, 47, 0.13);
backdrop-filter: blur(12px);
font-size: 12px;
font-weight: 800;
letter-spacing: 0.04em;
}
.status-dot {
width: 9px;
height: 9px;
border-radius: 50%;
background: var(--mint);
box-shadow: 0 0 0 4px rgba(67, 169, 154, 0.15);
}
.views {
display: flex;
gap: 6px;
padding: 5px;
border-radius: 13px;
background: var(--panel);
box-shadow: 0 10px 35px rgba(36, 49, 47, 0.12);
backdrop-filter: blur(12px);
}
.views button {
border: 0;
border-radius: 9px;
padding: 8px 10px;
background: transparent;
color: var(--ink);
cursor: pointer;
font-size: 11px;
font-weight: 800;
transition: 160ms ease;
}
.views button:hover,
.views button.active {
background: var(--ink);
color: white;
}
.panel {
position: fixed;
z-index: 10;
border: 1px solid rgba(255, 255, 255, 0.65);
border-radius: 20px;
background: var(--panel);
box-shadow: 0 18px 60px rgba(36, 49, 47, 0.17);
backdrop-filter: blur(16px);
}
.compare-panel {
left: 24px;
bottom: 24px;
width: min(430px, calc(100vw - 48px));
padding: 16px;
}
.panel-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin: 0 2px 12px;
}
.panel-heading h2 {
margin: 0;
font-size: 15px;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.panel-heading span {
color: rgba(36, 49, 47, 0.52);
font-size: 11px;
font-weight: 700;
}
.pair-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.pair-card {
position: relative;
min-height: 132px;
padding: 13px;
overflow: hidden;
text-align: left;
border: 1px solid var(--line);
border-radius: 14px;
background: rgba(255, 255, 255, 0.58);
color: var(--ink);
cursor: pointer;
transition: 180ms ease;
}
.pair-card::after {
position: absolute;
right: -15px;
bottom: -18px;
width: 70px;
height: 70px;
border-radius: 50%;
background: var(--swatch);
content: "";
opacity: 0.16;
}
.pair-card:hover {
transform: translateY(-2px);
border-color: rgba(36, 49, 47, 0.35);
}
.pair-card.active {
border-color: var(--swatch);
box-shadow: inset 0 0 0 1px var(--swatch);
background: white;
}
.pair-tag {
display: inline-block;
margin-bottom: 11px;
padding: 4px 7px;
border-radius: 6px;
background: var(--swatch);
color: white;
font-size: 10px;
font-weight: 900;
letter-spacing: 0.09em;
}
.pair-card strong {
display: block;
font-size: 14px;
}
.pair-card small {
display: block;
margin-top: 5px;
color: rgba(36, 49, 47, 0.58);
font-size: 11px;
line-height: 1.4;
}
.fit-detail {
display: grid;
grid-template-columns: 1fr auto;
align-items: end;
gap: 10px;
margin-top: 12px;
padding: 12px 3px 2px;
border-top: 1px solid var(--line);
}
.fit-detail span {
color: rgba(36, 49, 47, 0.62);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.fit-detail strong {
display: block;
margin-top: 3px;
font-size: 13px;
}
.score {
font-size: 23px;
font-weight: 900;
line-height: 1;
}
.score small {
color: rgba(36, 49, 47, 0.45);
font-size: 10px;
}
.meter {
grid-column: 1 / -1;
height: 6px;
overflow: hidden;
border-radius: 99px;
background: rgba(36, 49, 47, 0.1);
}
.meter i {
display: block;
width: 94%;
height: 100%;
border-radius: inherit;
background: var(--coral);
transition: width 300ms ease, background 300ms ease;
}
.route-panel {
right: 24px;
bottom: 24px;
width: 280px;
padding: 15px;
}
.route-panel h3 {
margin: 0 0 10px;
font-size: 13px;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.route-row {
display: flex;
align-items: center;
gap: 9px;
margin: 8px 0;
color: rgba(36, 49, 47, 0.75);
font-size: 11px;
font-weight: 700;
}
.check {
display: grid;
width: 18px;
height: 18px;
flex: 0 0 18px;
place-items: center;
border-radius: 5px;
background: rgba(67, 169, 154, 0.15);
color: #277b70;
font-size: 11px;
font-weight: 900;
}
.route-button {
width: 100%;
margin-top: 12px;
padding: 10px 12px;
border: 0;
border-radius: 10px;
background: var(--ink);
color: white;
cursor: pointer;
font-size: 11px;
font-weight: 900;
letter-spacing: 0.05em;
text-transform: uppercase;
transition: 160ms ease;
}
.route-button:hover {
transform: translateY(-1px);
background: #344743;
}
.camera-hint {
position: fixed;
top: 92px;
left: 50%;
z-index: 8;
padding: 8px 12px;
border-radius: 999px;
background: rgba(36, 49, 47, 0.78);
color: white;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.04em;
pointer-events: none;
transform: translateX(-50%);
opacity: 0.8;
}
.toast {
position: fixed;
top: 140px;
left: 50%;
z-index: 30;
max-width: calc(100vw - 40px);
padding: 11px 16px;
border-radius: 11px;
background: var(--ink);
color: white;
box-shadow: 0 12px 40px rgba(36, 49, 47, 0.25);
font-size: 12px;
font-weight: 700;
pointer-events: none;
opacity: 0;
transform: translate(-50%, -10px);
transition: 220ms ease;
}
.toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#loading {
position: fixed;
inset: 0;
z-index: 100;
display: grid;
place-items: center;
background: #eee8dd;
color: var(--ink);
font-size: 12px;
font-weight: 900;
letter-spacing: 0.16em;
text-transform: uppercase;
transition: opacity 300ms ease;
}
#loading.hidden {
pointer-events: none;
opacity: 0;
}
@media (max-width: 760px) {
.brand {
top: 14px;
left: 14px;
}
.brand-copy span {
display: none;
}
.top-right {
top: 14px;
right: 14px;
}
.views {
display: none;
}
.status {
padding: 9px 11px;
font-size: 10px;
}
.compare-panel {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
padding: 12px;
}
.route-panel {
display: none;
}
.camera-hint {
top: 76px;
}
}
</style>
</head>
<body>
<div id="scene"></div>
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 32 32" fill="none">
<path d="M5 20h6l4-10 4 10h8" stroke="currentColor" stroke-width="2.5"
stroke-linecap="square" stroke-linejoin="miter"/>
<path d="M7 24h19" stroke="currentColor" stroke-width="2.5"/>
</svg>
</div>
<div class="brand-copy">
<strong>Voxel Fit Lab</strong>
<span>Shoe comparison studio</span>
</div>
</div>
<div class="top-right">
<div class="status">
<span class="status-dot"></span>
<span id="statusText">Route clear · 1.2 m</span>
</div>
<div class="views" aria-label="Camera views">
<button class="active" data-view="overview">Overview</button>
<button data-view="compare">Compare</button>
<button data-view="service">Service bay</button>
</div>
</div>
<div class="camera-hint">Drag to orbit · Scroll to zoom · Shift-drag to pan · 1 / 2 to compare</div>
<section class="panel compare-panel" aria-label="Shoe comparison controls">
<div class="panel-heading">
<h2>Compare your pairs</h2>
<span>Select a display</span>
</div>
<div class="pair-grid">
<button class="pair-card active" data-pair="0" style="--swatch: #e76550">
<span class="pair-tag">PAIR A</span>
<strong>Cinder Trail</strong>
<small>Structured road runner<br>Medium width · firm heel</small>
</button>
<button class="pair-card" data-pair="1" style="--swatch: #319b91">
<span class="pair-tag">PAIR B</span>
<strong>Harbor Knit</strong>
<small>Roomy everyday sneaker<br>Wide width · soft heel</small>
</button>
</div>
<div class="fit-detail">
<div>
<span>Current fit recommendation</span>
<strong id="fitName">True to size</strong>
</div>
<div class="score"><span id="fitScore">94</span><small>/100</small></div>
<div class="meter"><i id="fitMeter"></i></div>
</div>
</section>
<aside class="panel route-panel">
<h3>Fitting bay protocol</h3>
<div class="route-row"><span class="check">✓</span> Removed shoes → Bay 03</div>
<div class="route-row"><span class="check">✓</span> Shopping bags → side rack</div>
<div class="route-row"><span class="check">✓</span> Main customer route clear</div>
<button class="route-button" id="clearRoute">Verify clear route</button>
</aside>
<div class="toast" id="toast">Route verified — all removed items are off the customer path.</div>
<div id="loading">Building the fit lab…</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 mount = document.getElementById("scene");
const scene = new THREE.Scene();
scene.background = new THREE.Color(0xe9e3d8);
scene.fog = new THREE.Fog(0xe9e3d8, 23, 43);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
mount.appendChild(renderer.domElement);
const camera = new THREE.PerspectiveCamera(
43,
window.innerWidth / window.innerHeight,
0.1,
100
);
const hemisphere = new THREE.HemisphereLight(0xfff7e9, 0x7f8d84, 2.15);
scene.add(hemisphere);
const sun = new THREE.DirectionalLight(0xfff2d5, 3.1);
sun.position.set(-6, 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 = 12;
sun.shadow.camera.bottom = -12;
sun.shadow.camera.near = 1;
sun.shadow.camera.far = 35;
sun.shadow.bias = -0.00035;
scene.add(sun);
const fill = new THREE.DirectionalLight(0xb9dcff, 1.1);
fill.position.set(9, 7, -4);
scene.add(fill);
// ------------------------------------------------------------
// Materials and construction helpers
// ------------------------------------------------------------
const material = (color, roughness = 0.82, metalness = 0) =>
new THREE.MeshStandardMaterial({ color, roughness, metalness });
const M = {
floor: material(0xd8d0c2),
floorLight: material(0xe5ded2),
wall: material(0xeee8dc),
wallInset: material(0xe1d9cc),
dark: material(0x263431),
darkSoft: material(0x43504c),
wood: material(0xc7925d),
woodDark: material(0x9d6d45),
mint: material(0x43a99a),
mintDark: material(0x287d73),
coral: material(0xe76550),
cream: material(0xf5efe4),
white: material(0xfbfaf6, 0.65),
steel: material(0x99aaa6, 0.38, 0.38),
black: material(0x1d2525),
skin: material(0xd89a72),
hair: material(0x352a24),
blue: material(0x547da3),
mustard: material(0xd9aa48),
lilac: material(0x9b83ad)
};
function box(w, h, d, mat, x = 0, y = 0, z = 0, parent = scene, cast = true) {
const mesh = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat);
mesh.position.set(x, y, z);
mesh.castShadow = cast;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function label(
text,
width,
height,
{
x = 0,
y = 0,
z = 0,
bg = "#263431",
fg = "#ffffff",
border = null,
fontSize = 0.45,
parent = scene
} = {}
) {
const canvas = document.createElement("canvas");
const heightPx = 256;
const widthPx = Math.min(
1536,
Math.max(512, Math.round(heightPx * width / height))
);
canvas.width = widthPx;
canvas.height = heightPx;
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, widthPx, heightPx);
if (bg) {
ctx.fillStyle = bg;
ctx.fillRect(0, 0, widthPx, heightPx);
}
if (border) {
ctx.strokeStyle = border;
ctx.lineWidth = 14;
ctx.strokeRect(7, 7, widthPx - 14, heightPx - 14);
}
const lines = text.split("\n");
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = fg;
if (lines.length === 1) {
ctx.font = `900 ${Math.floor(heightPx * fontSize)}px Arial, sans-serif`;
ctx.fillText(lines[0], widthPx / 2, heightPx / 2, widthPx * 0.9);
} else {
ctx.font = `900 ${Math.floor(heightPx * fontSize * 0.78)}px Arial, sans-serif`;
lines.forEach((line, index) => {
const y = heightPx / 2 + (index - (lines.length - 1) / 2) * heightPx * 0.36;
ctx.fillText(line, widthPx / 2, y, widthPx * 0.9);
});
}
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
const mesh = new THREE.Mesh(
new THREE.PlaneGeometry(width, height),
new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
})
);
mesh.position.set(x, y, z);
parent.add(mesh);
return mesh;
}
function floorLabel(text, x, z, width, height, bg, fg) {
const mesh = label(text, width, height, {
x,
y: 0.045,
z,
bg,
fg,
fontSize: 0.5
});
mesh.rotation.x = -Math.PI / 2;
return mesh;
}
// ------------------------------------------------------------
// Architecture
// ------------------------------------------------------------
box(22, 0.32, 16, M.floor, 0, -0.16, 0);
box(22, 5.3, 0.35, M.wall, 0, 2.65, -8);
box(0.35, 5.3, 16, M.wallInset, -11, 2.65, 0);
// Back wall voxel paneling.
for (let x = -10; x <= 10; x += 2) {
box(0.05, 5.05, 0.04, M.wallInset, x, 2.68, -7.80, scene, false);
}
for (let y = 0.65; y < 5; y += 1.1) {
box(21.5, 0.045, 0.04, M.wallInset, 0, y, -7.79, scene, false);
}
box(21.8, 0.18, 0.12, M.woodDark, 0, 0.1, -7.78);
box(0.12, 0.18, 15.8, M.woodDark, -10.8, 0.1, 0);
// Shop sign.
label("SOLE / FIT LAB", 6.8, 0.85, {
x: 0.8,
y: 4.55,
z: -7.77,
bg: "#263431",
fg: "#fff8e9",
border: "#43a99a"
});
// Voxel pendant lamps.
for (const x of [-5.5, 0.8, 7]) {
box(0.07, 1.1, 0.07, M.dark, x, 4.75, -1.8);
box(1.35, 0.22, 0.8, M.dark, x, 4.13, -1.8);
box(1.05, 0.06, 0.58, material(0xffe2a4, 0.4), x, 3.99, -1.8, scene, false);
}
// ------------------------------------------------------------
// Main route and fitting areas
// ------------------------------------------------------------
// Broad customer route through the right side.
box(3.15, 0.025, 12.0, M.floorLight, 2.65, 0.008, 1.1, scene, false);
const routeMaterial = new THREE.MeshStandardMaterial({
color: 0x4fae9f,
emissive: 0x174a41,
emissiveIntensity: 0.12,
roughness: 0.8
});
for (let z = -4.4; z <= 7.2; z += 1.05) {
box(0.09, 0.035, 0.64, routeMaterial, 1.0, 0.035, z, scene, false);
box(0.09, 0.035, 0.64, routeMaterial, 4.3, 0.035, z, scene, false);
}
floorLabel("KEEP CLEAR • 1.2 m", 2.65, 5.6, 2.7, 0.55, "#e5ded2", "#327e72");
// Forward arrows in the customer route.
for (const z of [4.5, 1.8, -1.0, -3.8]) {
box(0.12, 0.035, 0.68, routeMaterial, 2.65, 0.043, z, scene, false);
const left = box(0.12, 0.035, 0.65, routeMaterial, 2.48, 0.043, z - 0.28, scene, false);
const right = box(0.12, 0.035, 0.65, routeMaterial, 2.82, 0.043, z - 0.28, scene, false);
left.rotation.y = -0.65;
right.rotation.y = 0.65;
}
// Comparison bay mat.
box(8.05, 0.035, 5.25, material(0xeee4d5), -3.35, 0.018, 0.25, scene, false);
// ------------------------------------------------------------
// Sample shelving
// ------------------------------------------------------------
const shelfX = -4.85;
const shelfLevels = [1.25, 2.35, 3.45];
for (const y of shelfLevels) {
box(7.25, 0.16, 0.95, M.wood, shelfX, y, -7.25);
box(7.25, 0.09, 0.08, M.woodDark, shelfX, y + 0.12, -6.79);
}
for (const x of [-8.25, -4.85, -1.45]) {
box(0.16, 3.55, 0.82, M.woodDark, x, 1.88, -7.27);
}
label("SAMPLE WALL", 3.0, 0.42, {
x: -4.85,
y: 3.95,
z: -7.76,
bg: "#e8dfd0",
fg: "#34413e",
border: "#c7925d",
fontSize: 0.48
});
// Sample boxes.
const sampleColors = [M.coral, M.mint, M.mustard, M.blue, M.lilac];
for (let level = 0; level < shelfLevels.length; level++) {
for (let i = 0; i < 6; i++) {
const x = -7.8 + i * 1.13 + (level % 2) * 0.18;
const y = shelfLevels[level] + 0.42;
const sample = box(
0.73,
0.68,
0.62,
sampleColors[(i + level) % sampleColors.length],
x,
y,
-7.22
);
box(0.38, 0.12, 0.64, M.cream, x, y + 0.37, -7.21);
}
}
// ------------------------------------------------------------
// Bench and measuring board
// ------------------------------------------------------------
box(1.55, 0.28, 3.8, M.wood, -9.1, 0.9, -0.5);
box(0.18, 1.35, 3.8, M.woodDark, -9.82, 1.52, -0.5);
for (const z of [-2.0, 1.0]) {
box(0.16, 0.9, 0.16, M.dark, -9.62, 0.45, z);
box(0.16, 0.9, 0.16, M.dark, -8.62, 0.45, z);
}
box(0.88, 0.09, 5.1, M.cream, -7.72, 0.08, 1.15, scene, false);
for (let i = 0; i <= 20; i++) {
const z = -1.2 + i * 0.235;
const major = i % 4 === 0;
box(
major ? 0.45 : 0.27,
0.025,
major ? 0.045 : 0.025,
M.dark,
-7.91,
0.145,
z,
scene,
false
);
}
floorLabel("MEASURE", -7.72, 3.25, 0.78, 0.35, "#f5efe4", "#43504c");
// ------------------------------------------------------------
// Voxel shoe construction
// ------------------------------------------------------------
function createShoe(primary, accent) {
const group = new THREE.Group();
const upperMat = material(primary, 0.75);
const accentMat = material(accent, 0.65);
const soleMat = material(0xf5f0e7, 0.68);
box(1.52, 0.18, 2.72, soleMat, 0, 0.09, 0, group);
box(1.42, 0.12, 2.58, accentMat, 0, 0.24, 0, group);
box(1.40, 0.58, 1.58, upperMat, 0, 0.52, 0.48, group);
box(1.34, 1.00, 0.78, upperMat, 0, 0.78, -0.82, group);
box(0.66, 0.28, 0.92, accentMat, 0, 1.06, -0.16, group);
// Laces.
for (let i = 0; i < 3; i++) {
box(0.87, 0.065, 0.10, M.cream, 0, 1.21, -0.46 + i * 0.28, group);
}
// Side overlays.
box(0.07, 0.25, 1.12, accentMat, 0.72, 0.58, 0.28, group);
box(0.07, 0.25, 1.12, accentMat, -0.72, 0.58, 0.28, group);
box(0.42, 0.23, 0.06, M.cream, 0, 0.96, -1.23, group);
return group;
}
function createPair(primary, accent) {
const group = new THREE.Group();
const left = createShoe(primary, accent);
const right = createShoe(primary, accent);
left.position.set(-0.77, 0, 0);
right.position.set(0.77, 0, 0);
left.rotation.y = -0.08;
right.rotation.y = 0.08;
group.add(left, right);
return group;
}
function createPlinth(x, z, accent) {
const base = box(2.42, 0.52, 2.5, M.cream, x, 0.26, z);
box(2.26, 0.08, 2.33, M.floorLight, x, 0.56, z);
const frameMat = new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.15,
roughness: 0.55,
metalness: 0.12
});
box(2.22, 0.055, 0.07, frameMat, x, 0.64, z + 1.12);
box(2.22, 0.055, 0.07, frameMat, x, 0.64, z - 1.12);
box(0.07, 0.055, 2.17, frameMat, x + 1.08, 0.64, z);
box(0.07, 0.055, 2.17, frameMat, x - 1.08, 0.64, z);
return { base, frameMat };
}
const pairA = createPair(0xe76550, 0x303541);
const pairB = createPair(0x319b91, 0xf0e2bd);
const plinthA = createPlinth(-4.65, -1.0, 0xe76550);
const plinthB = createPlinth(-1.95, -1.0, 0x319b91);
pairA.position.set(-4.65, 0.65, -1.0);
pairB.position.set(-1.95, 0.65, -1.0);
pairA.scale.setScalar(0.69);
pairB.scale.setScalar(0.69);
scene.add(pairA, pairB);
label("PAIR A", 1.38, 0.34, {
x: -4.65,
y: 0.39,
z: 0.34,
bg: "#e76550",
fg: "#ffffff",
fontSize: 0.5
});
label("PAIR B", 1.38, 0.34, {
x: -1.95,
y: 0.39,
z: 0.34,
bg: "#319b91",
fg: "#ffffff",
fontSize: 0.5
});
// ------------------------------------------------------------
// Voxel visitor
// ------------------------------------------------------------
const visitor = new THREE.Group();
visitor.position.set(-3.28, 0, 1.45);
scene.add(visitor);
box(0.32, 0.88, 0.38, M.blue, -0.22, 0.44, 0, visitor);
box(0.32, 0.88, 0.38, M.blue, 0.22, 0.44, 0, visitor);
box(0.38, 0.18, 0.62, M.dark, -0.22, 0.09, 0.10, visitor);
box(0.38, 0.18, 0.62, M.dark, 0.22, 0.09, 0.10, visitor);
box(0.86, 1.02, 0.46, M.coral, 0, 1.38, 0, visitor);
box(0.90, 0.18, 0.50, M.cream, 0, 1.62, 0, visitor);
const headPivot = new THREE.Group();
headPivot.position.set(0, 1.92, 0);
visitor.add(headPivot);
box(0.64, 0.64, 0.62, M.skin, 0, 0.31, 0, headPivot);
box(0.68, 0.16, 0.67, M.hair, 0, 0.63, 0.02, headPivot);
box(0.16, 0.12, 0.08, M.black, -0.16, 0.34, -0.33, headPivot);
box(0.16, 0.12, 0.08, M.black, 0.16, 0.34, -0.33, headPivot);
box(0.12, 0.08, 0.08, M.skin, 0, 0.23, -0.35, headPivot);
function createArm(x) {
const pivot = new THREE.Group();
pivot.position.set(x, 1.69, 0);
visitor.add(pivot);
box(0.23, 0.82, 0.25, M.coral, 0, -0.39, 0, pivot);
box(0.22, 0.22, 0.24, M.skin, 0, -0.87, 0, pivot);
return pivot;
}
const leftArm = createArm(-0.56);
const rightArm = createArm(0.56);
// Small fitting card in the visitor's hand.
box(0.36, 0.03, 0.25, M.cream, -0.68, 0.93, -0.18, visitor);
// ------------------------------------------------------------
// Off-route storage bay for removed shoes and shopping bags
// ------------------------------------------------------------
box(4.75, 0.045, 4.0, material(0xcfe4dc), 7.45, 0.023, 2.35, scene, false);
box(0.16, 1.05, 4.3, M.mintDark, 5.03, 0.525, 2.35);
box(4.85, 0.13, 0.16, M.mintDark, 7.45, 0.93, 4.45);
// Shopping bag.
const bag = new THREE.Group();
bag.position.set(6.8, 0.08, 2.45);
scene.add(bag);
box(1.02, 1.12, 0.68, material(0xd6a85e), 0, 0.56, 0, bag);
box(0.34, 0.22, 0.03, M.cream, 0, 0.78, -0.36, bag);
box(0.08, 0.42, 0.08, M.woodDark, -0.28, 1.28, 0, bag);
box(0.08, 0.42, 0.08, M.woodDark, 0.28, 1.28, 0, bag);
box(0.64, 0.08, 0.08, M.woodDark, 0, 1.48, 0, bag);
// Removed pair, clearly inside the service bay.
const removedPair = createPair(0x6d7d83, 0xd8c59c);
removedPair.position.set(8.35, 0.08, 1.45);
removedPair.scale.setScalar(0.58);
removedPair.rotation.y = -0.18;
scene.add(removedPair);
// Bag cubbies on the rear of the storage bay.
box(2.3, 0.12, 0.65, M.wood, 8.4, 1.45, 4.0);
box(2.3, 0.12, 0.65, M.wood, 8.4, 2.55, 4.0);
for (const x of [7.25, 9.55]) {
box(0.13, 2.25, 0.65, M.woodDark, x, 2.1, 4.0);
}
box(0.62, 0.75, 0.48, M.lilac, 7.8, 1.87, 3.95);
box(0.70, 0.68, 0.48, M.blue, 8.9, 1.86, 3.95);
box(0.68, 0.72, 0.48, M.coral, 8.25, 2.99, 3.95);
// Sign and beacon.
box(0.1, 1.5, 0.1, M.dark, 7.35, 0.75, 0.22);
label("REMOVED ITEMS\nBAY 03 • OFF ROUTE", 3.15, 0.85, {
x: 7.35,
y: 1.83,
z: 0.28,
bg: "#287d73",
fg: "#ffffff",
border: "#d9eee7",
fontSize: 0.42
});
const beaconMaterial = new THREE.MeshStandardMaterial({
color: 0x43a99a,
emissive: 0x43a99a,
emissiveIntensity: 0.35
});
box(0.22, 0.22, 0.22, beaconMaterial, 9.42, 1.18, 0.25);
// ------------------------------------------------------------
// Voxel-style mirror using a core CubeCamera reflection
// ------------------------------------------------------------
const mirrorTarget = new THREE.WebGLCubeRenderTarget(256, {
generateMipmaps: true,
minFilter: THREE.LinearMipmapLinearFilter
});
const mirrorCamera = new THREE.CubeCamera(0.1, 50, mirrorTarget);
mirrorCamera.position.set(6.85, 2.35, -7.15);
scene.add(mirrorCamera);
const mirrorMaterial = new THREE.MeshStandardMaterial({
color: 0xaac5c8,
roughness: 0.08,
metalness: 0.92,
envMap: mirrorTarget.texture,
envMapIntensity: 0.82
});
box(3.65, 0.18, 0.18, M.woodDark, 6.85, 0.35, -7.61);
box(3.65, 0.18, 0.18, M.woodDark, 6.85, 4.35, -7.61);
box(0.18, 4.18, 0.18, M.woodDark, 5.02, 2.35, -7.61);
box(0.18, 4.18, 0.18, M.woodDark, 8.68, 2.35, -7.61);
box(3.47, 3.85, 0.08, mirrorMaterial, 6.85, 2.35, -7.60);
// Graphic reflections keep the voxel treatment.
const reflectionMat = new THREE.MeshBasicMaterial({
color: 0xeaf7f4,
transparent: true,
opacity: 0.28,
depthWrite: false
});
const reflectionA = box(0.14, 3.2, 0.02, reflectionMat, 5.85, 2.45, -7.54, scene, false);
const reflectionB = box(0.08, 2.7, 0.02, reflectionMat, 6.25, 2.2, -7.535, scene, false);
reflectionA.rotation.z = -0.28;
reflectionB.rotation.z = -0.28;
label("MIRROR", 1.45, 0.32, {
x: 6.85,
y: 4.72,
z: -7.73,
bg: "#e8dfd0",
fg: "#34413e",
fontSize: 0.48
});
// ------------------------------------------------------------
// Custom camera controls — no external controls addon
// ------------------------------------------------------------
const controls = {
target: new THREE.Vector3(0, 1, -0.5),
desiredTarget: new THREE.Vector3(0, 1, -0.5),
theta: 0.64,
desiredTheta: 0.64,
phi: 1.04,
desiredPhi: 1.04,
radius: 19,
desiredRadius: 19,
dragging: false,
panning: false,
lastX: 0,
lastY: 0
};
function updateCamera(dt) {
const ease = 1 - Math.exp(-dt * 8);
controls.target.lerp(controls.desiredTarget, ease);
controls.theta = THREE.MathUtils.lerp(controls.theta, controls.desiredTheta, ease);
controls.phi = THREE.MathUtils.lerp(controls.phi, controls.desiredPhi, ease);
controls.radius = THREE.MathUtils.lerp(controls.radius, controls.desiredRadius, ease);
const sinPhi = Math.sin(controls.phi);
camera.position.set(
controls.target.x + controls.radius * sinPhi * Math.sin(controls.theta),
controls.target.y + controls.radius * Math.cos(controls.phi),
controls.target.z + controls.radius * sinPhi * Math.cos(controls.theta)
);
camera.lookAt(controls.target);
}
const canvas = renderer.domElement;
canvas.addEventListener("pointerdown", event => {
controls.dragging = true;
controls.panning = event.shiftKey;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", event => {
if (!controls.dragging) return;
const dx = event.clientX - controls.lastX;
const dy = event.clientY - controls.lastY;
controls.lastX = event.clientX;
controls.lastY = event.clientY;
if (controls.panning) {
const right = new THREE.Vector3(
Math.cos(controls.theta),
0,
-Math.sin(controls.theta)
);
const forward = new THREE.Vector3(
-Math.sin(controls.theta),
0,
-Math.cos(controls.theta)
);
const scale = controls.radius * 0.0013;
controls.desiredTarget.addScaledVector(right, -dx * scale);
controls.desiredTarget.addScaledVector(forward, -dy * scale);
controls.desiredTarget.x = THREE.MathUtils.clamp(controls.desiredTarget.x, -7, 7);
controls.desiredTarget.z = THREE.MathUtils.clamp(controls.desiredTarget.z, -5, 6);
} else {
controls.desiredTheta -= dx * 0.006;
controls.desiredPhi = THREE.MathUtils.clamp(
controls.desiredPhi - dy * 0.005,
0.42,
1.38
);
}
});
function endDrag(event) {
controls.dragging = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endDrag);
canvas.addEventListener("pointercancel", endDrag);
canvas.addEventListener(
"wheel",
event => {
event.preventDefault();
controls.desiredRadius = THREE.MathUtils.clamp(
controls.desiredRadius + event.deltaY * 0.012,
7,
27
);
},
{ passive: false }
);
canvas.addEventListener("dblclick", () => setView("overview"));
const views = {
overview: {
target: [0, 1, -0.5],
theta: 0.64,
phi: 1.04,
radius: 19
},
compare: {
target: [-3.3, 1.05, -0.3],
theta: 0.08,
phi: 1.08,
radius: 10.5
},
service: {
target: [7.2, 1.0, 2.2],
theta: 0.12,
phi: 1.08,
radius: 8.4
}
};
function setView(name) {
const view = views[name];
if (!view) return;
controls.desiredTarget.set(...view.target);
controls.desiredTheta = view.theta;
controls.desiredPhi = view.phi;
controls.desiredRadius = view.radius;
document.querySelectorAll("[data-view]").forEach(button => {
button.classList.toggle("active", button.dataset.view === name);
});
}
document.querySelectorAll("[data-view]").forEach(button => {
button.addEventListener("click", () => setView(button.dataset.view));
});
// ------------------------------------------------------------
// Pair comparison UI and scene reactions
// ------------------------------------------------------------
const pairData = [
{
fit: "True to size",
score: 94,
accent: "#e76550",
displayY: 0.77,
rotation: -0.16,
head: -0.34
},
{
fit: "Size up ½ for a roomier toe box",
score: 88,
accent: "#319b91",
displayY: 0.68,
rotation: 0.16,
head: 0.34
}
];
const cards = [...document.querySelectorAll("[data-pair]")];
const fitName = document.getElementById("fitName");
const fitScore = document.getElementById("fitScore");
const fitMeter = document.getElementById("fitMeter");
let activePair = 0;
let targetHead = pairData[0].head;
let targetLeftArm = 0.92;
let targetRightArm = 0.18;
function selectPair(index) {
activePair = index;
const data = pairData[index];
cards.forEach((card, cardIndex) => {
card.classList.toggle("active", cardIndex === index);
});
fitName.textContent = data.fit;
fitScore.textContent = data.score;
fitMeter.style.width = `${data.score}%`;
fitMeter.style.background = data.accent;
pairA.position.y = index === 0 ? data.displayY : 0.65;
pairB.position.y = index === 1 ? data.displayY : 0.65;
pairA.rotation.y = index === 0 ? data.rotation : 0;
pairB.rotation.y = index === 1 ? data.rotation : 0;
plinthA.frameMat.emissiveIntensity = index === 0 ? 0.34 : 0.06;
plinthB.frameMat.emissiveIntensity = index === 1 ? 0.34 : 0.06;
targetHead = data.head;
targetLeftArm = index === 0 ? 0.92 : 0.18;
targetRightArm = index === 1 ? 0.92 : 0.18;
document.getElementById("statusText").textContent =
index === 0 ? "Comparing Pair A · route clear" : "Comparing Pair B · route clear";
}
cards.forEach(card => {
card.addEventListener("click", () => selectPair(Number(card.dataset.pair)));
});
document.addEventListener("keydown", event => {
if (event.key === "1") selectPair(0);
if (event.key === "2") selectPair(1);
if (event.key.toLowerCase() === "v") setView("overview");
});
// Route verification.
const toast = document.getElementById("toast");
let toastTimer;
document.getElementById("clearRoute").addEventListener("click", () => {
routeMaterial.color.set(0x43d0b8);
routeMaterial.emissive.set(0x197c6b);
routeMaterial.emissiveIntensity = 0.4;
beaconMaterial.emissiveIntensity = 1.2;
document.getElementById("statusText").textContent = "Route verified · 1.2 m clear";
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2800);
});
// ------------------------------------------------------------
// Resize and animation
// ------------------------------------------------------------
function resize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.75));
}
window.addEventListener("resize", resize);
const clock = new THREE.Clock();
let frame = 0;
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
frame++;
updateCamera(dt);
const ease = 1 - Math.exp(-dt * 8);
headPivot.rotation.y = THREE.MathUtils.lerp(headPivot.rotation.y, targetHead, ease);
leftArm.rotation.x = THREE.MathUtils.lerp(leftArm.rotation.x, targetLeftArm, ease);
rightArm.rotation.x = THREE.MathUtils.lerp(rightArm.rotation.x, targetRightArm, ease);
leftArm.rotation.z = THREE.MathUtils.lerp(leftArm.rotation.z, activePair === 0 ? 0.22 : 0, ease);
rightArm.rotation.z = THREE.MathUtils.lerp(rightArm.rotation.z, activePair === 1 ? -0.22 : 0, ease);
// Gentle breathing motion for the visitor.
visitor.position.y = Math.sin(clock.elapsedTime * 1.8) * 0.012;
// Update the mirror at a lower frequency.
if (frame % 36 === 0) {
mirrorCamera.update(renderer, scene);
}
renderer.render(scene, camera);
}
selectPair(0);
updateCamera(1);
mirrorCamera.update(renderer, scene);
animate();
requestAnimationFrame(() => {
document.getElementById("loading").classList.add("hidden");
});
</script>
</body>
</html>
```