Prompt specification
Build or customize the Three.js 3D scene "Width and length comparison" 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: Width and length comparison
Category: Architecture & Cities · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/width-and-length-comparison-x0538
Scene Description Prompt:
Use Three.js from cdnjs to place several shoe forms around the same foot model; highlight geometric overlap and spare room separately while clearly labeling the demonstration as a simplified sizing illustration. Deliver one self-contained HTML file with low-poly forms.
Working Three.js Starter (width-and-length-comparison-x0538):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Form / Fit — Simplified Sizing Illustration</title>
<style>
:root {
color-scheme: dark;
--bg: #080d16;
--panel: #0e1624;
--panel-2: #121d2d;
--line: #263348;
--line-bright: #3b4b64;
--text: #edf2fa;
--muted: #93a0b4;
--faint: #65738a;
--coral: #ff6178;
--coral-soft: rgba(255, 97, 120, 0.13);
--teal: #35d6c4;
--teal-soft: rgba(53, 214, 196, 0.12);
--violet: #a995ff;
--shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
background: var(--bg);
color: var(--text);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
body {
overflow: hidden;
}
button {
font: inherit;
}
.app {
display: grid;
grid-template-rows: 64px minmax(0, 1fr);
height: 100%;
}
header {
position: relative;
z-index: 20;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
min-width: 0;
padding: 0 22px;
background: rgba(11, 17, 28, 0.92);
border-bottom: 1px solid var(--line);
backdrop-filter: blur(16px);
}
.brand {
display: flex;
align-items: center;
gap: 13px;
min-width: 0;
}
.brand-mark {
display: grid;
place-items: center;
width: 34px;
height: 34px;
flex: 0 0 auto;
border: 1px solid rgba(169, 149, 255, 0.5);
border-radius: 10px;
background:
linear-gradient(135deg, rgba(169, 149, 255, 0.22), rgba(53, 214, 196, 0.08));
color: #d8d0ff;
box-shadow: inset 0 0 20px rgba(169, 149, 255, 0.08);
}
.brand-mark svg {
width: 19px;
height: 19px;
}
.brand-copy {
display: flex;
align-items: baseline;
gap: 11px;
white-space: nowrap;
}
.brand-copy strong {
font-size: 14px;
letter-spacing: 0.15em;
}
.brand-copy span {
color: var(--muted);
font-size: 12px;
}
.demo-banner {
display: inline-flex;
align-items: center;
gap: 9px;
flex: 0 0 auto;
padding: 8px 12px;
border: 1px solid rgba(255, 97, 120, 0.32);
border-radius: 999px;
background: var(--coral-soft);
color: #ffacb8;
font-size: 10px;
font-weight: 750;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.demo-banner::before {
content: "";
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--coral);
box-shadow: 0 0 0 4px rgba(255, 97, 120, 0.09);
}
.workspace {
display: grid;
grid-template-columns: minmax(0, 1fr) 350px;
min-height: 0;
}
.stage {
position: relative;
min-width: 0;
min-height: 0;
overflow: hidden;
background:
radial-gradient(circle at 48% 42%, rgba(71, 87, 126, 0.16), transparent 38%),
var(--bg);
}
canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
canvas.dragging {
cursor: grabbing;
}
.stage-heading {
position: absolute;
z-index: 5;
top: 22px;
left: 24px;
pointer-events: none;
}
.eyebrow {
margin: 0 0 7px;
color: var(--violet);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.15em;
text-transform: uppercase;
}
.stage-heading h1 {
margin: 0;
font-size: clamp(22px, 2.4vw, 35px);
font-weight: 620;
letter-spacing: -0.04em;
}
.stage-heading p:last-child {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
}
.scene-tools {
position: absolute;
z-index: 7;
right: 18px;
top: 18px;
display: flex;
gap: 7px;
}
.tool-button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 7px;
min-height: 34px;
padding: 0 11px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(14, 22, 36, 0.78);
color: #b9c4d6;
font-size: 11px;
font-weight: 650;
cursor: pointer;
backdrop-filter: blur(12px);
transition:
border-color 150ms ease,
color 150ms ease,
background 150ms ease;
}
.tool-button:hover,
.tool-button[aria-pressed="true"] {
border-color: rgba(169, 149, 255, 0.58);
background: rgba(31, 37, 58, 0.88);
color: #e6e0ff;
}
.tool-button svg {
width: 14px;
height: 14px;
}
.legend {
position: absolute;
z-index: 6;
left: 20px;
bottom: 20px;
display: flex;
flex-wrap: wrap;
gap: 8px;
max-width: calc(100% - 40px);
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 8px 10px;
border: 1px solid var(--line);
border-radius: 9px;
background: rgba(10, 16, 27, 0.78);
color: #c4ccda;
font-size: 10px;
font-weight: 650;
backdrop-filter: blur(12px);
}
.legend-swatch {
width: 10px;
height: 10px;
border-radius: 3px;
box-shadow: 0 0 12px currentColor;
}
.legend-swatch.overlap {
color: var(--coral);
background: var(--coral);
}
.legend-swatch.spare {
color: var(--teal);
background: var(--teal);
}
.legend-swatch.neutral {
color: #9ba8bb;
background: #9ba8bb;
}
.gesture-hint {
position: absolute;
z-index: 5;
right: 20px;
bottom: 22px;
color: var(--faint);
font-size: 10px;
pointer-events: none;
}
.world-label {
position: absolute;
z-index: 4;
min-width: 126px;
padding: 8px 10px;
border: 1px solid rgba(79, 94, 119, 0.68);
border-radius: 9px;
background: rgba(10, 16, 27, 0.82);
color: #dce3ef;
box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
font-size: 10px;
pointer-events: none;
transform: translate(-50%, -100%);
backdrop-filter: blur(10px);
transition:
border-color 150ms ease,
opacity 150ms ease;
}
.world-label.active {
border-color: rgba(169, 149, 255, 0.76);
background: rgba(23, 25, 42, 0.9);
}
.world-label .label-main {
display: flex;
align-items: center;
gap: 7px;
font-weight: 750;
}
.world-label .label-code {
display: grid;
place-items: center;
width: 18px;
height: 18px;
border-radius: 5px;
background: rgba(169, 149, 255, 0.16);
color: #c8bcff;
font-size: 9px;
}
.world-label .label-detail {
margin-top: 5px;
color: var(--muted);
font-size: 9px;
}
.world-label .label-dot {
display: inline-block;
width: 6px;
height: 6px;
margin-right: 4px;
border-radius: 50%;
}
.world-label.reference {
min-width: 0;
padding: 7px 10px;
color: #cfd7e4;
text-align: center;
letter-spacing: 0.08em;
text-transform: uppercase;
}
aside {
position: relative;
z-index: 10;
min-height: 0;
overflow-y: auto;
background:
linear-gradient(180deg, rgba(18, 29, 45, 0.72), transparent 220px),
var(--panel);
border-left: 1px solid var(--line);
scrollbar-width: thin;
scrollbar-color: var(--line-bright) transparent;
}
.aside-inner {
padding: 23px 21px 26px;
}
.aside-header {
margin-bottom: 18px;
}
.aside-header h2 {
margin: 0 0 7px;
font-size: 24px;
font-weight: 620;
letter-spacing: -0.035em;
}
.aside-header p {
margin: 0;
color: var(--muted);
font-size: 12px;
line-height: 1.55;
}
.section-label {
display: flex;
align-items: center;
justify-content: space-between;
margin: 20px 0 9px;
color: var(--faint);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.14em;
text-transform: uppercase;
}
.section-label::after {
content: "";
width: 48px;
height: 1px;
margin-left: 12px;
background: var(--line);
}
.layer-toggles {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.layer-toggle {
display: flex;
align-items: center;
gap: 9px;
min-height: 42px;
padding: 0 11px;
border: 1px solid var(--line);
border-radius: 10px;
background: #111b2a;
color: var(--muted);
font-size: 11px;
font-weight: 700;
cursor: pointer;
}
.layer-toggle[aria-pressed="true"] {
color: var(--text);
}
.toggle-mark {
display: grid;
place-items: center;
width: 15px;
height: 15px;
flex: 0 0 auto;
border: 1px solid var(--line-bright);
border-radius: 4px;
color: transparent;
font-size: 10px;
}
.layer-toggle[aria-pressed="true"] .toggle-mark {
border-color: currentColor;
background: currentColor;
}
.layer-toggle.overlap[aria-pressed="true"] .toggle-mark {
color: var(--coral);
}
.layer-toggle.spare[aria-pressed="true"] .toggle-mark {
color: var(--teal);
}
.candidate-list {
display: grid;
gap: 8px;
}
.candidate-card {
position: relative;
display: grid;
grid-template-columns: 36px minmax(0, 1fr) auto;
align-items: center;
gap: 10px;
width: 100%;
min-height: 63px;
padding: 10px;
overflow: hidden;
border: 1px solid var(--line);
border-radius: 11px;
background: rgba(17, 27, 42, 0.82);
color: var(--text);
text-align: left;
cursor: pointer;
transition:
border-color 150ms ease,
background 150ms ease,
transform 150ms ease;
}
.candidate-card:hover {
border-color: var(--line-bright);
transform: translateY(-1px);
}
.candidate-card.active {
border-color: rgba(169, 149, 255, 0.72);
background:
linear-gradient(90deg, rgba(169, 149, 255, 0.1), transparent 70%),
#141e2e;
}
.candidate-card::before {
content: "";
position: absolute;
inset: 0 auto 0 0;
width: 3px;
background: transparent;
}
.candidate-card.active::before {
background: var(--violet);
}
.candidate-code {
display: grid;
place-items: center;
width: 34px;
height: 34px;
border: 1px solid var(--line-bright);
border-radius: 9px;
background: #0d1522;
color: #c4bdff;
font-size: 12px;
font-weight: 800;
}
.candidate-copy {
min-width: 0;
}
.candidate-copy strong {
display: block;
overflow: hidden;
font-size: 12px;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
.candidate-copy span {
display: block;
margin-top: 4px;
color: var(--muted);
font-size: 10px;
}
.candidate-bars {
display: grid;
gap: 5px;
width: 46px;
}
.candidate-bars span {
display: block;
height: 3px;
overflow: hidden;
border-radius: 999px;
background: #253146;
}
.candidate-bars i {
display: block;
height: 100%;
border-radius: inherit;
}
.candidate-bars .overlap-bar i {
background: var(--coral);
}
.candidate-bars .spare-bar i {
background: var(--teal);
}
.detail-panel {
margin-top: 11px;
padding: 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: #0c1522;
}
.detail-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 13px;
}
.detail-title strong {
font-size: 12px;
}
.status-chip {
padding: 5px 8px;
border: 1px solid var(--line-bright);
border-radius: 999px;
color: var(--muted);
font-size: 9px;
font-weight: 750;
}
.status-chip.overlap {
border-color: rgba(255, 97, 120, 0.38);
background: var(--coral-soft);
color: #ff9dac;
}
.status-chip.clear {
border-color: rgba(53, 214, 196, 0.34);
background: var(--teal-soft);
color: #83eadf;
}
.metrics {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.metric {
padding: 10px;
border: 1px solid #202c40;
border-radius: 9px;
background: #101a28;
}
.metric span {
display: block;
color: var(--muted);
font-size: 9px;
}
.metric strong {
display: block;
margin-top: 5px;
font-size: 18px;
font-weight: 620;
}
.metric.overlap strong {
color: #ff8799;
}
.metric.spare strong {
color: #63dfd1;
}
.disclaimer {
position: relative;
margin-top: 17px;
padding: 13px 13px 13px 37px;
border: 1px solid rgba(255, 97, 120, 0.24);
border-radius: 11px;
background: rgba(255, 97, 120, 0.055);
color: #b7c0cf;
font-size: 10px;
line-height: 1.55;
}
.disclaimer::before {
content: "i";
position: absolute;
top: 13px;
left: 13px;
display: grid;
place-items: center;
width: 16px;
height: 16px;
border: 1px solid rgba(255, 97, 120, 0.6);
border-radius: 50%;
color: #ff8b9c;
font-family: Georgia, serif;
font-size: 11px;
font-weight: 700;
}
.disclaimer strong {
display: block;
margin-bottom: 4px;
color: #f0b0ba;
font-size: 10px;
}
.aside-footnote {
margin: 15px 2px 0;
color: var(--faint);
font-size: 9px;
line-height: 1.55;
}
@media (max-width: 900px) {
.workspace {
grid-template-columns: minmax(0, 1fr) 310px;
}
.brand-copy span {
display: none;
}
.gesture-hint {
display: none;
}
}
@media (max-width: 700px) {
body {
overflow: auto;
}
.app {
height: auto;
min-height: 100svh;
grid-template-rows: 58px auto;
}
header {
padding: 0 14px;
}
.demo-banner {
padding: 7px 9px;
font-size: 8px;
}
.workspace {
display: block;
}
.stage {
height: 64svh;
min-height: 470px;
}
aside {
border-top: 1px solid var(--line);
border-left: 0;
}
.aside-inner {
padding: 21px 16px 30px;
}
.stage-heading {
top: 17px;
left: 17px;
}
.stage-heading p:last-child {
display: none;
}
.scene-tools {
top: 14px;
right: 12px;
}
.tool-button span {
display: none;
}
.legend {
left: 12px;
bottom: 12px;
gap: 5px;
}
.legend-item {
padding: 7px 8px;
font-size: 9px;
}
.world-label {
min-width: 105px;
padding: 6px 8px;
}
}
@media (prefers-reduced-motion: reduce) {
* {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<div class="app">
<header>
<div class="brand">
<div class="brand-mark" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none">
<path d="M5 17.5c0-5 2.3-10.8 6.7-10.8 3.2 0 3.7 2.8 5.7 4.1 1.5 1 3.1.9 3.1 3.1 0 3.3-2.6 5.6-6 5.6H5v-2Z"
stroke="currentColor" stroke-width="1.7" stroke-linejoin="round"/>
<path d="M8.2 11.4c1.5.4 2.7-.2 3.5-1.7"
stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
</svg>
</div>
<div class="brand-copy">
<strong>FORM / FIT</strong>
<span>Geometric envelope study</span>
</div>
</div>
<div class="demo-banner">Simplified sizing illustration</div>
</header>
<main class="workspace">
<section class="stage" id="stage" aria-label="Interactive 3D shoe and foot comparison">
<div class="stage-heading">
<p class="eyebrow">Shared-foot comparison</p>
<h1>Geometry around one reference</h1>
<p>Low-poly shoe envelopes evaluated against the same stylized foot.</p>
</div>
<div class="scene-tools" aria-label="3D view controls">
<button class="tool-button" id="autoRotate" type="button" aria-pressed="false">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M20 12a8 8 0 1 1-2.3-5.7M20 4v5h-5"
stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>Orbit</span>
</button>
<button class="tool-button" id="topView" type="button">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="m12 3 9 5-9 5-9-5 9-5Z"
stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>
<path d="m5 12 7 4 7-4M5 16l7 4 7-4"
stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>Top</span>
</button>
<button class="tool-button" id="resetView" type="button">
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M4 12a8 8 0 1 0 2.3-5.7M4 4v5h5"
stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span>Reset</span>
</button>
</div>
<div class="legend" aria-label="Color legend">
<div class="legend-item">
<span class="legend-swatch overlap"></span>
Geometric overlap
</div>
<div class="legend-item">
<span class="legend-swatch spare"></span>
Spare room
</div>
<div class="legend-item">
<span class="legend-swatch neutral"></span>
Shoe envelope
</div>
</div>
<div class="gesture-hint">Drag to orbit · Scroll to zoom · Select a form</div>
</section>
<aside>
<div class="aside-inner">
<div class="aside-header">
<p class="eyebrow">Illustrative model</p>
<h2>Compare envelopes</h2>
<p>Four simplified shoe forms surround one shared foot reference. Select a form to inspect its geometric regions.</p>
</div>
<div class="section-label">Visible layers</div>
<div class="layer-toggles">
<button class="layer-toggle overlap" id="overlapToggle" type="button" aria-pressed="true">
<span class="toggle-mark">✓</span>
Overlap
</button>
<button class="layer-toggle spare" id="spareToggle" type="button" aria-pressed="true">
<span class="toggle-mark">✓</span>
Spare room
</button>
</div>
<div class="section-label">Shoe forms</div>
<div class="candidate-list" id="candidateList"></div>
<div class="detail-panel" id="detailPanel">
<div class="detail-title">
<strong id="detailName">Balanced profile</strong>
<span class="status-chip clear" id="detailStatus">Clear in this model</span>
</div>
<div class="metrics">
<div class="metric overlap">
<span>Overlap zones</span>
<strong id="overlapValue">0</strong>
</div>
<div class="metric spare">
<span>Spare-room zones</span>
<strong id="spareValue">0</strong>
</div>
</div>
</div>
<div class="disclaimer">
<strong>Simplified sizing illustration — not a fit recommendation.</strong>
The colored areas are approximate regions produced from a stylized low-poly foot envelope. This does not account for brand variation, swelling, socks, gait, comfort, or real-world fit.
</div>
<p class="aside-footnote">
“Zones” indicate simplified regions in the demonstration model, not measured medical or sizing values. Click any shoe in the scene or use the list above.
</p>
</div>
</aside>
</main>
</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const stage = document.getElementById("stage");
const candidateList = document.getElementById("candidateList");
const detailName = document.getElementById("detailName");
const detailStatus = document.getElementById("detailStatus");
const overlapValue = document.getElementById("overlapValue");
const spareValue = document.getElementById("spareValue");
const colors = {
background: 0x080d16,
foot: 0xd8d4ca,
footEdge: 0x8994a6,
neutral: 0xb8c4d9,
overlap: 0xff6178,
spare: 0x35d6c4,
sole: 0x1a2434,
violet: 0xa995ff,
guide: 0x66758e
};
const renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.05;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(colors.background);
scene.fog = new THREE.Fog(colors.background, 16, 29);
const camera = new THREE.PerspectiveCamera(41, 1, 0.1, 60);
const hemisphere = new THREE.HemisphereLight(0xb8ccff, 0x182033, 2.0);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.1);
keyLight.position.set(5, 10, 7);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(1024, 1024);
keyLight.shadow.camera.left = -11;
keyLight.shadow.camera.right = 11;
keyLight.shadow.camera.top = 11;
keyLight.shadow.camera.bottom = -11;
keyLight.shadow.camera.near = 1;
keyLight.shadow.camera.far = 28;
keyLight.shadow.bias = -0.0007;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x8d7dff, 1.55);
rimLight.position.set(-7, 5, -6);
scene.add(rimLight);
const tealLight = new THREE.PointLight(0x38d7c5, 1.2, 18, 2);
tealLight.position.set(4, 3, -5);
scene.add(tealLight);
const floor = new THREE.Mesh(
new THREE.CircleGeometry(10.5, 48),
new THREE.MeshStandardMaterial({
color: 0x0d1522,
roughness: 0.98,
metalness: 0.04
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.035;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(20, 40, 0x35425a, 0x202b3e);
grid.position.y = -0.02;
grid.material.transparent = true;
grid.material.opacity = 0.3;
scene.add(grid);
const centerHalo = new THREE.Mesh(
new THREE.RingGeometry(2.62, 2.67, 48),
new THREE.MeshBasicMaterial({
color: colors.violet,
transparent: true,
opacity: 0.22,
side: THREE.DoubleSide,
depthWrite: false
})
);
centerHalo.rotation.x = -Math.PI / 2;
centerHalo.position.y = 0.015;
scene.add(centerHalo);
const FOOT_RINGS = [
{ z: -2.35, w: 0.05, h: 0.08, y: 0.30 },
{ z: -2.08, w: 0.38, h: 0.38, y: 0.42 },
{ z: -1.62, w: 0.52, h: 0.54, y: 0.49 },
{ z: -0.92, w: 0.54, h: 0.60, y: 0.51 },
{ z: -0.15, w: 0.53, h: 0.62, y: 0.52 },
{ z: 0.65, w: 0.67, h: 0.66, y: 0.52 },
{ z: 1.32, w: 0.80, h: 0.64, y: 0.50 },
{ z: 1.95, w: 0.72, h: 0.51, y: 0.45 },
{ z: 2.36, w: 0.42, h: 0.30, y: 0.39 },
{ z: 2.52, w: 0.06, h: 0.08, y: 0.31 }
];
const SHOE_BASE_W = [0.34, 0.52, 0.62, 0.58, 0.66, 0.82, 0.86, 0.75, 0.51, 0.12];
const SHOE_BASE_H = [0.35, 0.56, 0.68, 0.70, 0.74, 0.78, 0.72, 0.58, 0.40, 0.16];
const SHOE_BASE_Y = [0.42, 0.48, 0.52, 0.54, 0.56, 0.58, 0.58, 0.54, 0.47, 0.38];
const candidates = [
{
code: "A",
name: "Close profile",
description: "Compressed forefoot",
width: 0.87,
height: 0.91,
length: 5.05
},
{
code: "B",
name: "Balanced profile",
description: "Even illustrative clearance",
width: 1.01,
height: 1.03,
length: 5.20
},
{
code: "C",
name: "Roomy profile",
description: "Expanded forefoot",
width: 1.14,
height: 1.11,
length: 5.45
},
{
code: "D",
name: "Extended toe",
description: "Longer forward envelope",
width: 1.00,
height: 1.04,
length: 5.85
}
];
function sampleFoot(z) {
if (z <= FOOT_RINGS[0].z) {
return { w: 0, h: 0 };
}
const last = FOOT_RINGS[FOOT_RINGS.length - 1];
if (z >= last.z) {
return { w: 0, h: 0 };
}
for (let i = 0; i < FOOT_RINGS.length - 1; i++) {
const a = FOOT_RINGS[i];
const b = FOOT_RINGS[i + 1];
if (z >= a.z && z <= b.z) {
const t = (z - a.z) / (b.z - a.z);
return {
w: THREE.MathUtils.lerp(a.w, b.w, t),
h: THREE.MathUtils.lerp(a.h, b.h, t)
};
}
}
return { w: 0, h: 0 };
}
function candidateMetrics(candidate) {
let overlapZones = 0;
let spareZones = 0;
let maxOverlap = 0;
let maxSpare = 0;
for (let i = 0; i < SHOE_BASE_W.length; i++) {
const t = i / (SHOE_BASE_W.length - 1);
const z = -2.42 + t * candidate.length;
const ref = sampleFoot(z);
const shoeW = SHOE_BASE_W[i] * candidate.width;
const shoeH = SHOE_BASE_H[i] * candidate.height;
const penetration =
Math.max(0, ref.w - shoeW) +
0.55 * Math.max(0, ref.h - shoeH);
const clearance =
Math.max(0, shoeW - ref.w) +
0.25 * Math.max(0, shoeH - ref.h);
maxOverlap = Math.max(maxOverlap, penetration);
maxSpare = Math.max(maxSpare, clearance);
if (penetration > 0.035) overlapZones++;
if (clearance > 0.065) spareZones++;
}
return {
overlapZones,
spareZones,
maxOverlap,
maxSpare,
overlapScore: Math.min(100, overlapZones * 30 + maxOverlap * 85),
spareScore: Math.min(100, spareZones * 22 + maxSpare * 65)
};
}
function createFoot() {
const segments = 10;
const positions = [];
const indices = [];
FOOT_RINGS.forEach((ring) => {
for (let j = 0; j < segments; j++) {
const angle = (j / segments) * Math.PI * 2;
const x = Math.cos(angle) * ring.w;
const rawY = ring.y + Math.sin(angle) * ring.h;
const y = Math.max(0.105, rawY);
positions.push(x, y, ring.z);
}
});
for (let i = 0; i < FOOT_RINGS.length - 1; i++) {
for (let j = 0; j < segments; j++) {
const a = i * segments + j;
const b = i * segments + ((j + 1) % segments);
const c = (i + 1) * segments + j;
const d = (i + 1) * segments + ((j + 1) % segments);
indices.push(a, c, b, b, c, d);
}
}
const startCenter = positions.length / 3;
positions.push(0, 0.30, FOOT_RINGS[0].z);
const endCenter = positions.length / 3;
positions.push(0, 0.31, FOOT_RINGS[FOOT_RINGS.length - 1].z);
for (let j = 0; j < segments; j++) {
const next = (j + 1) % segments;
indices.push(startCenter, next, j);
indices.push(
endCenter,
(FOOT_RINGS.length - 1) * segments + j,
(FOOT_RINGS.length - 1) * segments + next
);
}
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.setIndex(indices);
geometry.computeVertexNormals();
const material = new THREE.MeshStandardMaterial({
color: colors.foot,
roughness: 0.87,
metalness: 0.02,
flatShading: true
});
const mesh = new THREE.Mesh(geometry, material);
mesh.castShadow = true;
mesh.receiveShadow = true;
const group = new THREE.Group();
group.add(mesh);
const edge = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry, 22),
new THREE.LineBasicMaterial({
color: colors.footEdge,
transparent: true,
opacity: 0.42
})
);
group.add(edge);
const shadow = new THREE.Mesh(
new THREE.CircleGeometry(1.16, 24),
new THREE.MeshBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0.23,
depthWrite: false
})
);
shadow.scale.set(0.72, 1.75, 1);
shadow.rotation.x = -Math.PI / 2;
shadow.position.set(0.05, 0.018, 0.03);
group.add(shadow);
return group;
}
const footGroup = createFoot();
footGroup.position.y = 0.015;
scene.add(footGroup);
function pushTriangle(target, a, b, c) {
target.push(a.x, a.y, a.z, b.x, b.y, b.z, c.x, c.y, c.z);
}
function makeGeometry(positions) {
const geometry = new THREE.BufferGeometry();
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometry.computeVertexNormals();
return geometry;
}
function createShoe(candidate, index) {
const group = new THREE.Group();
const segments = 12;
const rings = SHOE_BASE_W.length;
const neutralPositions = [];
const overlapPositions = [];
const sparePositions = [];
const allPositions = [];
const metrics = candidateMetrics(candidate);
const ringData = [];
for (let i = 0; i < rings; i++) {
const t = i / (rings - 1);
const z = -2.42 + t * candidate.length;
const width = SHOE_BASE_W[i] * candidate.width;
const height = SHOE_BASE_H[i] * candidate.height;
const centerY = SHOE_BASE_Y[i];
const points = [];
for (let j = 0; j < segments; j++) {
const angle = (j / segments) * Math.PI * 2;
const x = Math.cos(angle) * width;
const y = Math.max(0.12, centerY + Math.sin(angle) * height);
points.push(new THREE.Vector3(x, y, z));
}
ringData.push({ z, width, height, centerY, points });
}
for (let i = 0; i < rings - 1; i++) {
const ringA = ringData[i];
const ringB = ringData[i + 1];
const midZ = (ringA.z + ringB.z) / 2;
const ref = sampleFoot(midZ);
const averageWidth = (ringA.width + ringB.width) / 2;
const averageHeight = (ringA.height + ringB.height) / 2;
const penetration =
Math.max(0, ref.w - averageWidth) +
0.55 * Math.max(0, ref.h - averageHeight);
const clearance =
Math.max(0, averageWidth - ref.w) +
0.25 * Math.max(0, averageHeight - ref.h);
for (let j = 0; j < segments; j++) {
const next = (j + 1) % segments;
const angleMid = ((j + 0.5) / segments) * Math.PI * 2;
const opening =
i <= 3 &&
angleMid > Math.PI * 0.25 &&
angleMid < Math.PI * 0.75;
if (opening) continue;
const a = ringA.points[j];
const b = ringA.points[next];
const c = ringB.points[j];
const d = ringB.points[next];
let target = neutralPositions;
if (penetration > 0.035) {
target = overlapPositions;
} else if (clearance > 0.065) {
target = sparePositions;
}
pushTriangle(target, a, c, b);
pushTriangle(target, b, c, d);
pushTriangle(allPositions, a, c, b);
pushTriangle(allPositions, b, c, d);
}
}
const neutralMaterial = new THREE.MeshStandardMaterial({
color: colors.neutral,
roughness: 0.68,
metalness: 0.04,
transparent: true,
opacity: 0.23,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const overlapMaterial = new THREE.MeshStandardMaterial({
color: colors.overlap,
emissive: 0x5e1020,
emissiveIntensity: 0.55,
roughness: 0.58,
transparent: true,
opacity: 0.83,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const spareMaterial = new THREE.MeshStandardMaterial({
color: colors.spare,
emissive: 0x0b514b,
emissiveIntensity: 0.48,
roughness: 0.62,
transparent: true,
opacity: 0.65,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
});
const neutralMesh = new THREE.Mesh(
makeGeometry(neutralPositions),
neutralMaterial
);
neutralMesh.renderOrder = 2;
const overlapMesh = new THREE.Mesh(
makeGeometry(overlapPositions),
overlapMaterial
);
overlapMesh.renderOrder = 3;
const spareMesh = new THREE.Mesh(
makeGeometry(sparePositions),
spareMaterial
);
spareMesh.renderOrder = 3;
group.add(neutralMesh, overlapMesh, spareMesh);
const edgeGeometry = new THREE.EdgesGeometry(
makeGeometry(allPositions),
19
);
const edges = new THREE.LineSegments(
edgeGeometry,
new THREE.LineBasicMaterial({
color: 0xaab8cc,
transparent: true,
opacity: 0.46,
depthWrite: false
})
);
edges.renderOrder = 4;
group.add(edges);
// Low-poly outsole band around the lower half of the form.
const solePositions = [];
for (let i = 0; i < rings - 1; i++) {
const a = ringData[i];
const b = ringData[i + 1];
for (let j = 0; j < segments; j++) {
const next = (j + 1) % segments;
const angleMid = ((j + 0.5) / segments) * Math.PI * 2;
if (angleMid > Math.PI + 0.1 && angleMid < Math.PI * 2 - 0.1) {
continue;
}
const a0 = a.points[j].clone();
const b0 = a.points[next].clone();
const c0 = b.points[j].clone();
const d0 = b.points[next].clone();
a0.y -= 0.075;
b0.y -= 0.075;
c0.y -= 0.075;
d0.y -= 0.075;
a0.y = Math.max(0.035, a0.y);
b0.y = Math.max(0.035, b0.y);
c0.y = Math.max(0.035, c0.y);
d0.y = Math.max(0.035, d0.y);
pushTriangle(solePositions, a0, c0, b0);
pushTriangle(solePositions, b0, c0, d0);
}
}
const soleMesh = new THREE.Mesh(
makeGeometry(solePositions),
new THREE.MeshStandardMaterial({
color: colors.sole,
roughness: 0.92,
transparent: true,
opacity: 0.82,
side: THREE.DoubleSide,
depthWrite: false,
flatShading: true
})
);
soleMesh.renderOrder = 1;
group.add(soleMesh);
// Collar rim makes the open ankle region read as a shoe form.
const collarPoints = [];
const collarRing = ringData[3];
for (let j = 3; j <= 9; j++) {
const angle = (j / segments) * Math.PI * 2;
collarPoints.push(
new THREE.Vector3(
Math.cos(angle) * collarRing.width,
Math.max(
0.12,
collarRing.centerY + Math.sin(angle) * collarRing.height
),
collarRing.z
)
);
}
const collar = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(collarPoints),
new THREE.LineBasicMaterial({
color: 0xc4d0e2,
transparent: true,
opacity: 0.62
})
);
collar.renderOrder = 5;
group.add(collar);
const selectionRing = new THREE.Mesh(
new THREE.TorusGeometry(1, 0.018, 6, 48),
new THREE.MeshBasicMaterial({
color: colors.violet,
transparent: true,
opacity: 0.8,
depthWrite: false
})
);
selectionRing.rotation.x = Math.PI / 2;
selectionRing.scale.set(0.52, 1.55, 1);
selectionRing.position.y = 0.018;
selectionRing.visible = false;
group.add(selectionRing);
const radius = 5.25;
const angle = Math.PI / 4 + index * Math.PI / 2;
group.position.set(
Math.sin(angle) * radius,
0.03,
Math.cos(angle) * radius
);
// Each shoe's toe points toward the shared reference foot.
group.rotation.y = Math.atan2(-group.position.x, -group.position.z);
group.userData.candidateIndex = index;
group.userData.metrics = metrics;
for (const mesh of [neutralMesh, overlapMesh, spareMesh, soleMesh]) {
mesh.userData.candidateIndex = index;
}
scene.add(group);
const guideGeometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(group.position.x, 0.035, group.position.z),
new THREE.Vector3(0, 0.035, 0)
]);
const guide = new THREE.Line(
guideGeometry,
new THREE.LineDashedMaterial({
color: colors.guide,
dashSize: 0.13,
gapSize: 0.16,
transparent: true,
opacity: 0.22,
depthWrite: false
})
);
guide.computeLineDistances();
scene.add(guide);
return {
group,
guide,
selectionRing,
neutralMaterial,
overlapMaterial,
spareMaterial,
overlapMesh,
spareMesh,
metrics
};
}
const shoeObjects = candidates.map(createShoe);
const clickTargets = [];
shoeObjects.forEach((shoe) => {
shoe.group.traverse((object) => {
if (object.isMesh) clickTargets.push(object);
});
});
// DOM labels projected from 3D positions.
const worldLabels = [];
candidates.forEach((candidate, index) => {
const label = document.createElement("div");
label.className = "world-label";
label.innerHTML = `
<div class="label-main">
<span class="label-code">${candidate.code}</span>
${candidate.name}
</div>
<div class="label-detail"></div>
`;
stage.appendChild(label);
worldLabels.push(label);
});
const referenceLabel = document.createElement("div");
referenceLabel.className = "world-label reference";
referenceLabel.textContent = "Shared reference foot";
stage.appendChild(referenceLabel);
let selectedIndex = 1;
let showOverlap = true;
let showSpare = true;
let autoRotate = false;
function updateLabels() {
candidates.forEach((candidate, index) => {
const metrics = shoeObjects[index].metrics;
const detail = worldLabels[index].querySelector(".label-detail");
const overlapText = metrics.overlapZones
? `<span class="label-dot" style="background:${"#ff6178"}"></span>${metrics.overlapZones} overlap zone${metrics.overlapZones === 1 ? "" : "s"}`
: `<span class="label-dot" style="background:${"#35d6c4"}"></span>No overlap`;
const spareText = metrics.spareZones
? `<span class="label-dot" style="background:${"#35d6c4"}"></span>${metrics.spareZones} spare zone${metrics.spareZones === 1 ? "" : "s"}`
: `<span class="label-dot" style="background:${"#35d6c4"}"></span>No spare zone`;
detail.innerHTML = `${overlapText} · ${spareText}`;
worldLabels[index].classList.toggle("active", index === selectedIndex);
});
}
function selectCandidate(index) {
selectedIndex = index;
shoeObjects.forEach((shoe, i) => {
const selected = i === index;
shoe.selectionRing.visible = selected;
shoe.group.scale.setScalar(selected ? 1.035 : 1);
shoe.guide.material.opacity = selected ? 0.46 : 0.2;
shoe.guide.material.color.set(selected ? colors.violet : colors.guide);
shoe.neutralMaterial.opacity = selected ? 0.3 : 0.19;
shoe.overlapMaterial.opacity = selected ? 0.9 : 0.72;
shoe.spareMaterial.opacity = selected ? 0.75 : 0.57;
});
document.querySelectorAll(".candidate-card").forEach((card, i) => {
card.classList.toggle("active", i === index);
card.setAttribute("aria-pressed", String(i === index));
});
const candidate = candidates[index];
const metrics = shoeObjects[index].metrics;
detailName.textContent = `${candidate.code} · ${candidate.name}`;
overlapValue.textContent = String(metrics.overlapZones);
spareValue.textContent = String(metrics.spareZones);
if (metrics.overlapZones > 0) {
detailStatus.textContent = "Overlap highlighted";
detailStatus.className = "status-chip overlap";
} else {
detailStatus.textContent = "Clear in this model";
detailStatus.className = "status-chip clear";
}
updateLabels();
}
candidates.forEach((candidate, index) => {
const metrics = candidateMetrics(candidate);
const button = document.createElement("button");
button.type = "button";
button.className = "candidate-card";
button.setAttribute("aria-pressed", String(index === selectedIndex));
button.innerHTML = `
<span class="candidate-code">${candidate.code}</span>
<span class="candidate-copy">
<strong>${candidate.name}</strong>
<span>${candidate.description}</span>
</span>
<span class="candidate-bars" aria-hidden="true">
<span class="overlap-bar"><i style="width:${metrics.overlapScore}%"></i></span>
<span class="spare-bar"><i style="width:${metrics.spareScore}%"></i></span>
</span>
`;
button.addEventListener("click", () => selectCandidate(index));
candidateList.appendChild(button);
});
const overlapToggle = document.getElementById("overlapToggle");
const spareToggle = document.getElementById("spareToggle");
overlapToggle.addEventListener("click", () => {
showOverlap = !showOverlap;
overlapToggle.setAttribute("aria-pressed", String(showOverlap));
shoeObjects.forEach((shoe) => {
shoe.overlapMesh.visible = showOverlap;
});
});
spareToggle.addEventListener("click", () => {
showSpare = !showSpare;
spareToggle.setAttribute("aria-pressed", String(showSpare));
shoeObjects.forEach((shoe) => {
shoe.spareMesh.visible = showSpare;
});
});
// Direct camera controls: no add-ons or examples are imported.
const orbit = {
theta: 0.72,
phi: 0.91,
radius: 16.2,
target: new THREE.Vector3(0, 0.35, 0)
};
const defaultOrbit = {
theta: orbit.theta,
phi: orbit.phi,
radius: orbit.radius
};
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);
}
function resetCamera() {
orbit.theta = defaultOrbit.theta;
orbit.phi = defaultOrbit.phi;
orbit.radius = defaultOrbit.radius;
updateCamera();
}
const autoRotateButton = document.getElementById("autoRotate");
autoRotateButton.addEventListener("click", () => {
autoRotate = !autoRotate;
autoRotateButton.setAttribute("aria-pressed", String(autoRotate));
});
document.getElementById("resetView").addEventListener("click", resetCamera);
document.getElementById("topView").addEventListener("click", () => {
orbit.theta = 0;
orbit.phi = 0.28;
orbit.radius = 16.5;
updateCamera();
});
const pointer = new THREE.Vector2();
const raycaster = new THREE.Raycaster();
let dragging = false;
let moved = 0;
let previousX = 0;
let previousY = 0;
function setPointer(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;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
dragging = true;
moved = 0;
previousX = event.clientX;
previousY = event.clientY;
renderer.domElement.setPointerCapture(event.pointerId);
renderer.domElement.classList.add("dragging");
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (!dragging) return;
const dx = event.clientX - previousX;
const dy = event.clientY - previousY;
moved += Math.abs(dx) + Math.abs(dy);
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi + dy * 0.005,
0.22,
1.42
);
previousX = event.clientX;
previousY = event.clientY;
updateCamera();
});
renderer.domElement.addEventListener("pointerup", (event) => {
dragging = false;
renderer.domElement.classList.remove("dragging");
if (moved < 7) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(clickTargets, false);
if (hits.length) {
const index = hits[0].object.userData.candidateIndex;
if (Number.isInteger(index)) selectCandidate(index);
}
}
});
renderer.domElement.addEventListener("pointercancel", () => {
dragging = false;
renderer.domElement.classList.remove("dragging");
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.012,
10,
22
);
updateCamera();
},
{ passive: false }
);
document.addEventListener("keydown", (event) => {
const key = event.key;
if (key === "ArrowLeft") {
orbit.theta -= 0.1;
updateCamera();
} else if (key === "ArrowRight") {
orbit.theta += 0.1;
updateCamera();
} else if (key === "ArrowUp") {
orbit.phi = THREE.MathUtils.clamp(orbit.phi - 0.08, 0.22, 1.42);
updateCamera();
} else if (key === "ArrowDown") {
orbit.phi = THREE.MathUtils.clamp(orbit.phi + 0.08, 0.22, 1.42);
updateCamera();
} else if (key === "+" || key === "=") {
orbit.radius = Math.max(10, orbit.radius - 1);
updateCamera();
} else if (key === "-") {
orbit.radius = Math.min(22, orbit.radius + 1);
updateCamera();
} else if (key === "0") {
resetCamera();
} else if (key === " ") {
event.preventDefault();
autoRotateButton.click();
}
});
function resize() {
const width = Math.max(1, stage.clientWidth);
const height = Math.max(1, stage.clientHeight);
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resize);
resizeObserver.observe(stage);
function projectLabel(element, worldPosition) {
const projected = worldPosition.clone().project(camera);
const visible =
projected.z > -1 &&
projected.z < 1 &&
Math.abs(projected.x) < 1.25 &&
Math.abs(projected.y) < 1.25;
element.style.display = visible ? "block" : "none";
if (!visible) return;
const x = (projected.x * 0.5 + 0.5) * stage.clientWidth;
const y = (-projected.y * 0.5 + 0.5) * stage.clientHeight;
element.style.left = `${x}px`;
element.style.top = `${y}px`;
}
const labelPoint = new THREE.Vector3();
const referencePoint = new THREE.Vector3();
selectCandidate(selectedIndex);
resize();
updateCamera();
const reduceMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
let lastTime = performance.now();
function animate(time) {
const delta = Math.min(0.05, (time - lastTime) / 1000);
lastTime = time;
if (autoRotate && !dragging && !reduceMotion) {
orbit.theta += delta * 0.12;
updateCamera();
}
scene.updateMatrixWorld();
candidates.forEach((candidate, index) => {
labelPoint.set(0, 1.15, -0.25);
shoeObjects[index].group.localToWorld(labelPoint);
projectLabel(worldLabels[index], labelPoint);
});
referencePoint.set(0, 1.42, 0.25);
footGroup.localToWorld(referencePoint);
projectLabel(referenceLabel, referencePoint);
renderer.render(scene, camera);
requestAnimationFrame(animate);
}
requestAnimationFrame(animate);
</script>
</body>
</html>
```