Prompt specification
Build or customize the Three.js 3D scene "Lacing-pattern comparison table" 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: Lacing-pattern comparison table
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/lacing-pattern-comparison-table-x0624
Scene Description Prompt:
Lacing-pattern comparison table. Create three shoe models with different lace routes; users trace each continuous path and compare where pulls concentrate in a clearly qualitative force-distribution diagram. Please build this with Three.js from cdnjs in one self-contained HTML file, using visible voxel blocks.
Working Three.js Starter (lacing-pattern-comparison-table-x0624):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lace Lab — Voxel Lacing Comparison</title>
<style>
:root {
color-scheme: dark;
--bg: #071019;
--panel: #0d1822;
--panel-2: #111f2b;
--line: #22323f;
--text: #eef4f5;
--muted: #91a4af;
--gold: #ffd166;
--low: #48d6bd;
--mid: #ffd166;
--high: #ff6077;
--cross: #ff7b61;
--bar: #55d8c7;
--ladder: #a08cff;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-width: 320px;
color: var(--text);
background:
radial-gradient(circle at 15% 0%, rgba(66, 123, 144, 0.16), transparent 34rem),
radial-gradient(circle at 95% 15%, rgba(132, 91, 177, 0.12), transparent 32rem),
var(--bg);
font-family:
Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
}
button,
input {
font: inherit;
}
button {
color: inherit;
}
.app {
width: min(1500px, calc(100% - 36px));
margin: 0 auto;
padding: 34px 0 48px;
}
.hero {
display: grid;
grid-template-columns: minmax(0, 1fr) auto;
gap: 32px;
align-items: end;
margin-bottom: 25px;
}
.eyebrow {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 12px;
color: #9bb0ba;
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.eyebrow::before {
width: 28px;
height: 2px;
content: "";
background: var(--gold);
}
h1 {
max-width: 780px;
margin: 0;
font-size: clamp(2.1rem, 4.6vw, 4.4rem);
font-weight: 750;
line-height: 0.98;
letter-spacing: -0.055em;
}
.hero-copy {
max-width: 690px;
margin: 17px 0 0;
color: var(--muted);
font-size: 1rem;
line-height: 1.65;
}
.hero-actions {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 9px;
}
.control-button {
min-height: 40px;
padding: 9px 14px;
border: 1px solid #314452;
border-radius: 10px;
background: rgba(13, 24, 34, 0.78);
cursor: pointer;
font-size: 0.78rem;
font-weight: 750;
letter-spacing: 0.03em;
transition: 160ms ease;
}
.control-button:hover {
border-color: #577181;
background: #172633;
transform: translateY(-1px);
}
.control-button:focus-visible,
.model-button:focus-visible,
.toggle input:focus-visible {
outline: 2px solid var(--gold);
outline-offset: 3px;
}
.control-button.ghost {
background: transparent;
}
.view-tools {
display: flex;
align-items: center;
justify-content: space-between;
gap: 18px;
margin: 0 0 12px;
color: var(--muted);
font-size: 0.78rem;
}
.view-tools strong {
color: var(--text);
}
.toggle {
display: inline-flex;
align-items: center;
gap: 9px;
cursor: pointer;
user-select: none;
}
.toggle input {
width: 16px;
height: 16px;
accent-color: var(--gold);
}
.stage-shell {
overflow: hidden;
border: 1px solid var(--line);
border-radius: 22px;
background:
linear-gradient(180deg, rgba(20, 35, 47, 0.7), rgba(8, 17, 25, 0.96)),
var(--panel);
box-shadow: 0 25px 70px rgba(0, 0, 0, 0.26);
}
.stage-scroll {
overflow-x: auto;
scrollbar-color: #39505f #101c26;
}
.stage {
position: relative;
min-width: 960px;
height: 535px;
overflow: hidden;
}
.stage canvas {
position: absolute;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
.stage canvas:active {
cursor: grabbing;
}
.loading {
position: absolute;
z-index: 5;
inset: 0;
display: grid;
place-items: center;
color: var(--muted);
background: #0a151e;
font-size: 0.82rem;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.model-labels {
position: absolute;
z-index: 2;
inset: 0;
pointer-events: none;
}
.model-label {
position: absolute;
top: 19px;
width: 180px;
transform: translateX(-50%);
text-align: center;
}
.model-label .index {
display: inline-grid;
width: 27px;
height: 27px;
margin-bottom: 7px;
place-items: center;
border: 1px solid var(--accent);
border-radius: 50%;
color: var(--accent);
background: rgba(7, 16, 25, 0.8);
font-size: 0.66rem;
font-weight: 900;
}
.model-label strong {
display: block;
font-size: 0.72rem;
letter-spacing: 0.12em;
text-transform: uppercase;
}
.model-label small {
display: block;
margin-top: 3px;
color: #8298a4;
font-size: 0.66rem;
}
.stage-hint {
position: absolute;
z-index: 2;
bottom: 18px;
left: 20px;
display: flex;
align-items: center;
gap: 9px;
padding: 9px 12px;
border: 1px solid rgba(94, 119, 133, 0.38);
border-radius: 9px;
color: #a8bac3;
background: rgba(6, 14, 21, 0.78);
backdrop-filter: blur(8px);
pointer-events: none;
font-size: 0.72rem;
}
.stage-hint .dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--gold);
box-shadow: 0 0 12px var(--gold);
}
.table-shell {
margin-top: 25px;
overflow-x: auto;
border: 1px solid var(--line);
border-radius: 20px;
background: rgba(10, 20, 29, 0.82);
}
table {
width: 100%;
min-width: 960px;
border-collapse: separate;
border-spacing: 0;
table-layout: fixed;
}
th,
td {
width: 33.333%;
padding: 22px;
vertical-align: top;
border-right: 1px solid var(--line);
}
th:last-child,
td:last-child {
border-right: 0;
}
thead th {
padding-top: 24px;
background: linear-gradient(180deg, rgba(19, 33, 44, 0.86), rgba(12, 23, 32, 0.78));
}
.model-head {
position: relative;
min-height: 102px;
padding-left: 47px;
}
.model-head .number {
position: absolute;
top: 1px;
left: 0;
color: var(--accent);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.72rem;
font-weight: 800;
letter-spacing: 0.08em;
}
.model-head h2 {
margin: 0;
font-size: 1.35rem;
letter-spacing: -0.025em;
}
.model-head p {
margin: 6px 0 0;
color: var(--muted);
font-size: 0.8rem;
}
.route-chip {
display: inline-flex;
align-items: center;
gap: 7px;
margin-top: 15px;
padding: 6px 9px;
border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
border-radius: 999px;
color: var(--accent);
background: color-mix(in srgb, var(--accent) 8%, transparent);
font-size: 0.66rem;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.route-chip::before {
width: 6px;
height: 6px;
content: "";
border-radius: 50%;
background: var(--accent);
}
tbody tr + tr td {
border-top: 1px solid var(--line);
}
.trace-status {
min-height: 42px;
margin: 0 0 13px;
color: #a5b7c0;
font-size: 0.78rem;
line-height: 1.5;
}
.progress-track {
height: 5px;
overflow: hidden;
margin-bottom: 15px;
border-radius: 99px;
background: #1d2b36;
}
.progress-fill {
width: 0;
height: 100%;
border-radius: inherit;
background: var(--accent);
box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent);
transition: width 240ms ease;
}
.progress-meta {
display: flex;
justify-content: space-between;
margin: -7px 0 15px;
color: #708794;
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 0.65rem;
}
.model-actions {
display: flex;
gap: 8px;
}
.model-button {
flex: 1;
min-height: 37px;
padding: 8px 10px;
border: 1px solid #314553;
border-radius: 9px;
background: #152431;
cursor: pointer;
font-size: 0.72rem;
font-weight: 750;
transition: 150ms ease;
}
.model-button:hover {
border-color: color-mix(in srgb, var(--accent) 70%, #314553);
background: color-mix(in srgb, var(--accent) 10%, #152431);
}
.model-button.primary {
border-color: color-mix(in srgb, var(--accent) 65%, #314553);
color: var(--accent);
}
.map-wrap {
display: grid;
place-items: center;
}
.force-map {
display: block;
width: min(100%, 285px);
height: auto;
overflow: visible;
}
.force-map text {
fill: #78909c;
font-family: ui-sans-serif, system-ui, sans-serif;
font-size: 8px;
letter-spacing: 0.08em;
}
.force-map .heat-dot {
opacity: 0.72;
transition: opacity 180ms ease;
}
.force-map .heat-dot.visited {
opacity: 1;
}
.force-map .map-segment {
stroke-linecap: round;
transition: stroke-width 180ms ease, stroke-opacity 180ms ease;
}
.force-map .map-segment.traced {
stroke-width: 3.2px;
stroke-opacity: 1;
}
.map-caption {
margin-top: -4px;
color: #718792;
text-align: center;
font-size: 0.67rem;
}
.readout {
display: grid;
gap: 9px;
}
.readout-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
padding-bottom: 9px;
border-bottom: 1px solid rgba(42, 59, 71, 0.7);
}
.readout-row:last-child {
padding-bottom: 0;
border-bottom: 0;
}
.readout-row span {
color: #718792;
font-size: 0.68rem;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.readout-row strong {
color: #d7e2e6;
text-align: right;
font-size: 0.78rem;
font-weight: 750;
}
.heat-legend {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
margin-top: 20px;
color: #80949f;
font-size: 0.69rem;
letter-spacing: 0.04em;
text-transform: uppercase;
}
.heat-scale {
display: flex;
align-items: center;
gap: 6px;
}
.heat-scale i {
display: block;
width: 10px;
height: 10px;
border-radius: 50%;
background: var(--low);
}
.heat-scale i:nth-child(2) {
width: 14px;
height: 14px;
background: var(--mid);
}
.heat-scale i:nth-child(3) {
width: 19px;
height: 19px;
background: var(--high);
}
.footnote {
margin: 14px 0 0;
color: #627783;
text-align: center;
font-size: 0.69rem;
line-height: 1.5;
}
.toast {
position: fixed;
z-index: 20;
right: 22px;
bottom: 22px;
max-width: 340px;
padding: 12px 15px;
border: 1px solid #425865;
border-radius: 10px;
color: #e5edef;
background: rgba(11, 23, 32, 0.96);
box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
opacity: 0;
transform: translateY(12px);
pointer-events: none;
transition: 180ms ease;
font-size: 0.78rem;
}
.toast.show {
opacity: 1;
transform: translateY(0);
}
@media (max-width: 850px) {
.app {
width: min(100% - 22px, 1500px);
padding-top: 24px;
}
.hero {
grid-template-columns: 1fr;
gap: 18px;
}
.hero-actions {
justify-content: flex-start;
}
.view-tools {
align-items: flex-start;
flex-direction: column;
gap: 9px;
}
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
scroll-behavior: auto !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<main class="app">
<header class="hero">
<div>
<div class="eyebrow">Voxel footwear study · 03 routes</div>
<h1>Where does the pull land?</h1>
<p class="hero-copy">
Trace each continuous lace route through its voxel eyelets. The diagrams use
the same qualitative scale to compare where tension spreads, funnels,
and concentrates—without implying a biomechanical simulation.
</p>
</div>
<div class="hero-actions">
<button class="control-button" id="reset-traces" type="button">Reset traces</button>
<button class="control-button ghost" id="reset-view" type="button">Reset view</button>
</div>
</header>
<div class="view-tools">
<div>
<strong>Interactive route board</strong>
· Drag to orbit · Scroll to zoom · Click the pulsing gold eyelet
</div>
<label class="toggle">
<input id="pull-toggle" type="checkbox" checked />
Show 3D pull stems
</label>
</div>
<section class="stage-shell" aria-label="Interactive three-dimensional shoe models">
<div class="stage-scroll">
<div class="stage" id="stage">
<div class="loading" id="loading">Building voxel routes…</div>
<div class="model-labels" id="model-labels"></div>
<div class="stage-hint">
<span class="dot"></span>
The gold ring marks the next anchor in the route
</div>
</div>
</div>
</section>
<section class="table-shell" aria-label="Lacing pattern comparison table">
<table id="comparison-table"></table>
</section>
<div class="heat-legend" aria-label="Qualitative pull concentration legend">
<span>Broad / low pull</span>
<span class="heat-scale">
<i></i><i></i><i></i>
</span>
<span>Concentrated / high pull</span>
</div>
<p class="footnote">
Pull maps are intentionally qualitative. Circle size and heat color show the
relative concentration associated with each route geometry.
</p>
</main>
<div class="toast" id="toast" role="status" aria-live="polite"></div>
<script type="module">
import * as THREE from
"https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const MODELS = [
{
id: "cross",
name: "Criss-cross",
descriptor: "Diagonal spread",
accent: "#ff7b61",
route: [
"L0", "R1", "L2", "R3", "L4", "R5",
"L5", "R4", "L3", "R2", "L1", "R0"
],
peak: "Mid-lacing eyelets",
spread: "Broad / balanced",
tension: "Moderate, distributed",
insight:
"Diagonal crossings spread pull through the central lace bed, so no single eyelet pair dominates."
},
{
id: "bar",
name: "Straight bar",
descriptor: "Horizontal transfer",
accent: "#55d8c7",
route: [
"L0", "R0", "L1", "R1", "L2", "R2",
"L3", "R3", "L4", "R4", "L5", "R5"
],
peak: "Two lace exits",
spread: "Narrow / funneled",
tension: "High at the exits",
insight:
"Horizontal bars move tension along the rows, but the working pull still funnels toward the cord exits."
},
{
id: "ladder",
name: "Ladder rail",
descriptor: "Edge-biased path",
accent: "#a08cff",
route: [
"L0", "L1", "L2", "L3", "L4", "L5",
"R5", "R4", "R3", "R2", "R1", "R0"
],
peak: "Side rails + heel edge",
spread: "Edge-biased",
tension: "Concentrated along rails",
insight:
"The rail-like route bypasses the center of the lace bed and loads the side edges, especially near the heel."
}
];
const EYELET_ROWS = 6;
const ROUTE_COUNTS = MODELS.map(() => 0);
const AUTO_TIMERS = MODELS.map(() => null);
const AUTO_ACTIVE = MODELS.map(() => false);
const stage = document.getElementById("stage");
const loading = document.getElementById("loading");
const table = document.getElementById("comparison-table");
const toast = document.getElementById("toast");
let toastTimer;
let hoveredModel = -1;
function showToast(message) {
toast.textContent = message;
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => toast.classList.remove("show"), 2200);
}
function eyeletPosition(id) {
const side = id[0] === "L" ? -1 : 1;
const row = Number(id.slice(1));
return new THREE.Vector3(
side * 0.72,
0.965,
-1.05 + row * 0.42
);
}
function mapPosition(id) {
const side = id[0] === "L" ? -1 : 1;
const row = Number(id.slice(1));
return {
x: 130 + side * 43,
y: 181 - row * 27
};
}
function heatColor(t) {
const low = new THREE.Color("#48d6bd");
const mid = new THREE.Color("#ffd166");
const high = new THREE.Color("#ff6077");
const color = new THREE.Color();
if (t < 0.5) {
color.copy(low).lerp(mid, t * 2);
} else {
color.copy(mid).lerp(high, (t - 0.5) * 2);
}
return `#${color.getHexString()}`;
}
function calculatePulls(model) {
const incidence = {};
const endpointIds = new Set([model.route[0], model.route.at(-1)]);
for (const id of model.route) {
incidence[id] = (incidence[id] || 0) + 1;
}
const values = {};
let maximum = 0;
for (const id of Object.keys(incidence)) {
const row = Number(id.slice(1));
const edges = incidence[id];
let value = 0;
if (model.id === "cross") {
value =
0.27 +
edges * 0.13 +
Math.max(0, 4 - Math.abs(row - 2.5)) * 0.115;
if (endpointIds.has(id)) value += 0.035;
}
if (model.id === "bar") {
value = 0.25 + edges * 0.08;
if (endpointIds.has(id)) value += 0.78;
if (row === 5) value += 0.12;
}
if (model.id === "ladder") {
value = 0.28 + edges * 0.08;
if (row <= 1) value += 0.16;
if (row === 5) value += 0.12;
if (endpointIds.has(id)) value += 0.45;
}
values[id] = value;
maximum = Math.max(maximum, value);
}
for (const id of Object.keys(values)) {
values[id] = THREE.MathUtils.clamp(values[id] / maximum, 0.12, 1);
}
return values;
}
const PULLS = MODELS.map(calculatePulls);
function renderLabels() {
document.getElementById("model-labels").innerHTML = MODELS.map(
(model, index) => `
<div
class="model-label"
style="left:${16.666 + index * 33.333}%;--accent:${model.accent}"
>
<span class="index">0${index + 1}</span>
<strong>${model.name}</strong>
<small>${model.descriptor}</small>
</div>
`
).join("");
}
function mapSVG(model, modelIndex) {
const routeIndex = Object.fromEntries(
model.route.map((id, index) => [id, index])
);
const heatDots = Object.entries(PULLS[modelIndex])
.map(([id, load]) => {
const p = mapPosition(id);
const radius = 4 + load * 11;
const opacity = 0.18 + load * 0.42;
return `
<circle
class="heat-dot"
data-load-model="${modelIndex}"
data-load-node="${id}"
cx="${p.x}"
cy="${p.y}"
r="${radius.toFixed(1)}"
fill="${heatColor(load)}"
fill-opacity="${opacity.toFixed(2)}"
/>
`;
})
.join("");
const segments = model.route.slice(0, -1).map((id, index) => {
const next = model.route[index + 1];
const a = mapPosition(id);
const b = mapPosition(next);
return `
<line
class="map-segment"
data-map-seg="${modelIndex}-${index}"
x1="${a.x}"
y1="${a.y}"
x2="${b.x}"
y2="${b.y}"
stroke="${model.accent}"
stroke-opacity="0.34"
stroke-width="2.2"
/>
`;
}).join("");
const eyelets = Object.keys(routeIndex).map((id) => {
const p = mapPosition(id);
const index = routeIndex[id];
return `
<circle
data-map-eye="${modelIndex}-${index}"
cx="${p.x}"
cy="${p.y}"
r="3.2"
fill="#09131c"
stroke="#c3d0d5"
stroke-width="1.15"
/>
`;
}).join("");
const endDots = [model.route[0], model.route.at(-1)].map((id) => {
const p = mapPosition(id);
return `
<circle
cx="${p.x}"
cy="${p.y}"
r="6"
fill="none"
stroke="#ffffff"
stroke-opacity="0.75"
stroke-width="1"
/>
`;
}).join("");
return `
<svg
class="force-map"
viewBox="0 0 260 230"
role="img"
aria-label="${model.name} qualitative pull-distribution map"
>
<defs>
<pattern
id="grid-${modelIndex}"
width="13"
height="13"
patternUnits="userSpaceOnUse"
>
<path
d="M 13 0 L 0 0 0 13"
fill="none"
stroke="#263744"
stroke-width="0.55"
/>
</pattern>
</defs>
<path
d="M130 12
C100 13 80 31 73 64
C69 85 75 106 71 127
C67 153 74 187 96 207
C108 218 152 218 164 207
C186 187 193 153 189 127
C185 106 191 85 187 64
C180 31 160 13 130 12 Z"
fill="url(#grid-${modelIndex})"
stroke="#334754"
stroke-width="1.3"
/>
<path
d="M130 22 L130 208"
stroke="#3c4e59"
stroke-width="0.8"
stroke-dasharray="3 5"
/>
${heatDots}
${segments}
${eyelets}
${endDots}
<text x="130" y="224" text-anchor="middle">HEEL</text>
<text x="130" y="8" text-anchor="middle">TOE</text>
</svg>
`;
}
function renderTable() {
const head = `
<thead>
<tr>
${MODELS.map((model, index) => `
<th style="--accent:${model.accent}">
<div class="model-head">
<span class="number">0${index + 1} / ROUTE</span>
<h2>${model.name}</h2>
<p>${model.descriptor}</p>
<span class="route-chip">${model.route.length} anchor route</span>
</div>
</th>
`).join("")}
</tr>
</thead>
`;
const body = `
<tbody>
<tr>
${MODELS.map((model, index) => `
<td>
<p class="trace-status" id="status-${index}">
Click the pulsing gold eyelet to begin.
</p>
<div
class="progress-track"
role="progressbar"
aria-label="${model.name} trace progress"
aria-valuemin="0"
aria-valuemax="${model.route.length}"
aria-valuenow="0"
id="progress-${index}"
>
<div class="progress-fill" id="fill-${index}"></div>
</div>
<div class="progress-meta">
<span id="count-${index}">0 / ${model.route.length} anchors</span>
<span>CONTINUOUS PATH</span>
</div>
<div class="model-actions">
<button
class="model-button primary"
id="auto-${index}"
type="button"
>Auto trace</button>
<button
class="model-button"
id="reset-${index}"
type="button"
>Reset</button>
</div>
</td>
`).join("")}
</tr>
<tr>
${MODELS.map((model, index) => `
<td>
<div class="map-wrap">
${mapSVG(model, index)}
</div>
<div class="map-caption">Relative pull · identical scale</div>
</td>
`).join("")}
</tr>
<tr>
${MODELS.map((model, index) => `
<td>
<div class="readout">
<div class="readout-row">
<span>Peak zone</span>
<strong>${model.peak}</strong>
</div>
<div class="readout-row">
<span>Footprint</span>
<strong>${model.spread}</strong>
</div>
<div class="readout-row">
<span>Tension</span>
<strong>${model.tension}</strong>
</div>
<div class="readout-row">
<span>Readout</span>
<strong>${model.insight}</strong>
</div>
</div>
</td>
`).join("")}
</tr>
</tbody>
`;
table.innerHTML = head + body;
}
renderLabels();
renderTable();
// -----------------------------------------------------------------------
// Three.js scene
// -----------------------------------------------------------------------
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.15;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
stage.prepend(renderer.domElement);
const scene = new THREE.Scene();
scene.fog = new THREE.FogExp2(0x09141d, 0.023);
const camera = new THREE.PerspectiveCamera(
35,
stage.clientWidth / stage.clientHeight,
0.1,
100
);
const cameraTarget = new THREE.Vector3(0, 0.25, 0);
let cameraYaw = 0.34;
let cameraPitch = 0.67;
let cameraRadius = 16.5;
function updateCamera() {
const horizontal = Math.cos(cameraPitch) * cameraRadius;
camera.position.set(
cameraTarget.x + Math.sin(cameraYaw) * horizontal,
cameraTarget.y + Math.sin(cameraPitch) * cameraRadius,
cameraTarget.z + Math.cos(cameraYaw) * horizontal
);
camera.lookAt(cameraTarget);
}
function resetCamera() {
cameraYaw = 0.34;
cameraPitch = 0.67;
cameraRadius = 16.5;
updateCamera();
}
updateCamera();
const hemisphere = new THREE.HemisphereLight(0xcdefff, 0x18202a, 2.2);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.3);
keyLight.position.set(-5, 11, 8);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -13;
keyLight.shadow.camera.right = 13;
keyLight.shadow.camera.top = 10;
keyLight.shadow.camera.bottom = -10;
keyLight.shadow.camera.near = 0.5;
keyLight.shadow.camera.far = 35;
keyLight.shadow.bias = -0.00025;
scene.add(keyLight);
const rimLight = new THREE.DirectionalLight(0x78b9d4, 1.7);
rimLight.position.set(7, 5, -9);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xffc777, 22, 12, 2);
warmLight.position.set(0, 5, 2);
scene.add(warmLight);
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 28),
new THREE.MeshStandardMaterial({
color: 0x09141d,
roughness: 0.96,
metalness: 0.02
})
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.22;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(34, 34, 0x28404d, 0x182a35);
grid.position.y = -0.205;
grid.material.transparent = true;
grid.material.opacity = 0.42;
scene.add(grid);
const modelGroups = [];
const segmentMeshes = [];
const eyeletRecords = [];
const pullGroups = [];
const hitMeshes = [];
const pulses = [];
const invisibleMaterial = new THREE.MeshBasicMaterial({
transparent: true,
opacity: 0,
depthWrite: false
});
function addVoxel(blocks, x, y, z, color, seed) {
const c = new THREE.Color(color);
const n = ((Math.imul(Math.round(x * 100), 73856093) ^
Math.imul(Math.round(z * 100), 19349663) ^
Math.imul(Math.round(y * 100), 83492791) ^
Math.imul(seed, 2654435761)) >>> 0) / 4294967295;
c.offsetHSL(
(n - 0.5) * 0.012,
(n - 0.5) * 0.018,
(n - 0.5) * 0.025
);
blocks.push({ x, y, z, color: c });
}
function buildVoxelShoe(group, modelIndex) {
const blocks = [];
for (let zi = -13; zi <= 13; zi++) {
const z = zi * 0.2;
let halfWidth = 1.0;
if (z > 1.55) halfWidth = 0.72;
else if (z > 1.0) halfWidth = 0.84;
else if (z < -1.75) halfWidth = 0.85;
for (let xi = -5; xi <= 5; xi++) {
const x = xi * 0.2;
if (Math.abs(x) > halfWidth) continue;
addVoxel(blocks, x, 0, z, "#eee9dc", modelIndex * 31 + zi * 7 + xi);
addVoxel(blocks, x, 0.19, z, "#d5d9d8", modelIndex * 19 + zi * 11 + xi);
if (z >= 1.35) {
addVoxel(
blocks,
x,
0.38,
z,
z > 1.5 ? "#aebdc6" : "#bdc9ce",
modelIndex * 17 + zi * 5 + xi
);
if (z > 1.48) {
addVoxel(
blocks,
x,
0.56,
z,
"#cbd4d7",
modelIndex * 13 + zi * 3 + xi
);
}
} else {
const edgeStart = halfWidth - 0.28;
if (Math.abs(x) >= edgeStart) {
addVoxel(
blocks,
x,
0.38,
z,
"#aebdc6",
modelIndex * 23 + zi * 5 + xi
);
addVoxel(
blocks,
x,
0.57,
z,
"#c4ced2",
modelIndex * 29 + zi * 7 + xi
);
addVoxel(
blocks,
x,
0.76,
z,
"#d8dfe0",
modelIndex * 37 + zi * 11 + xi
);
}
if (z > -1.48 && z < 1.3 && Math.abs(x) <= 0.42) {
addVoxel(
blocks,
x,
0.38,
z,
"#d9dfe0",
modelIndex * 41 + zi * 13 + xi
);
addVoxel(
blocks,
x,
0.56,
z,
"#e5e9e7",
modelIndex * 43 + zi * 17 + xi
);
addVoxel(
blocks,
x,
0.74,
z,
"#f0f1ec",
modelIndex * 47 + zi * 19 + xi
);
addVoxel(
blocks,
x,
0.87,
z,
"#dde3e2",
modelIndex * 53 + zi * 23 + xi
);
}
if (z < -1.82 && z > -2.42 && Math.abs(x) <= 0.62) {
addVoxel(
blocks,
x,
0.38,
z,
"#b8c5ca",
modelIndex * 59 + zi * 29 + xi
);
addVoxel(
blocks,
x,
0.57,
z,
"#ccd4d6",
modelIndex * 61 + zi * 31 + xi
);
addVoxel(
blocks,
x,
0.76,
z,
"#dce1e1",
modelIndex * 67 + zi * 37 + xi
);
}
}
}
}
// Accent heel tabs make the three models easy to distinguish.
for (const x of [-0.8, -0.6, 0.6, 0.8]) {
addVoxel(blocks, x, 0.78, -2.22, MODELS[modelIndex].accent, modelIndex + 91);
}
const geometry = new THREE.BoxGeometry(0.186, 0.186, 0.186);
const material = new THREE.MeshStandardMaterial({
color: 0xffffff,
roughness: 0.76,
metalness: 0.06,
vertexColors: true
});
const mesh = new THREE.InstancedMesh(geometry, material, blocks.length);
const dummy = new THREE.Object3D();
blocks.forEach((block, index) => {
dummy.position.set(block.x, block.y, block.z);
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
mesh.setMatrixAt(index, dummy.matrix);
mesh.setColorAt(index, block.color);
});
mesh.instanceMatrix.needsUpdate = true;
mesh.instanceColor.needsUpdate = true;
mesh.castShadow = true;
mesh.receiveShadow = true;
group.add(mesh);
}
function buildPedestal(group, accent) {
const pedestal = new THREE.Mesh(
new THREE.BoxGeometry(2.78, 0.12, 6.25),
new THREE.MeshStandardMaterial({
color: 0x101e28,
roughness: 0.72,
metalness: 0.28
})
);
pedestal.position.y = -0.12;
pedestal.receiveShadow = true;
pedestal.castShadow = true;
group.add(pedestal);
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(pedestal.geometry),
new THREE.LineBasicMaterial({
color: new THREE.Color(accent),
transparent: true,
opacity: 0.48
})
);
edges.position.copy(pedestal.position);
group.add(edges);
}
function buildRoute(group, model, modelIndex) {
const segmentGroup = new THREE.Group();
const pullGroup = new THREE.Group();
group.add(segmentGroup, pullGroup);
pullGroups.push(pullGroup);
const blockGeometry = new THREE.BoxGeometry(0.07, 0.075, 0.07);
const modelSegments = [];
for (let index = 0; index < model.route.length - 1; index++) {
const start = eyeletPosition(model.route[index]);
const end = eyeletPosition(model.route[index + 1]);
const direction = new THREE.Vector3().subVectors(end, start);
const length = direction.length();
const count = Math.max(2, Math.ceil(length / 0.058));
const material = new THREE.MeshStandardMaterial({
color: 0x657783,
roughness: 0.56,
metalness: 0.08,
emissive: 0x000000,
emissiveIntensity: 0
});
const mesh = new THREE.InstancedMesh(
blockGeometry,
material,
count
);
const dummy = new THREE.Object3D();
for (let blockIndex = 0; blockIndex < count; blockIndex++) {
const t = blockIndex / (count - 1);
dummy.position.lerpVectors(start, end, t);
dummy.position.y += (index % 2) * 0.004;
dummy.rotation.set(0, 0, 0);
dummy.scale.set(1, 1, 1);
dummy.updateMatrix();
mesh.setMatrixAt(blockIndex, dummy.matrix);
}
mesh.instanceMatrix.needsUpdate = true;
mesh.castShadow = true;
segmentGroup.add(mesh);
modelSegments.push(mesh);
}
segmentMeshes.push(modelSegments);
const records = [];
for (const id of model.route) {
const position = eyeletPosition(id);
const routeIndex = model.route.indexOf(id);
const eyeletMaterial = new THREE.MeshStandardMaterial({
color: 0x84939a,
roughness: 0.24,
metalness: 0.76,
emissive: 0x000000,
emissiveIntensity: 0
});
const eyelet = new THREE.Mesh(
new THREE.TorusGeometry(0.075, 0.022, 6, 14),
eyeletMaterial
);
eyelet.position.copy(position);
eyelet.rotation.x = Math.PI / 2;
eyelet.castShadow = true;
group.add(eyelet);
const hit = new THREE.Mesh(
new THREE.SphereGeometry(0.15, 8, 8),
invisibleMaterial
);
hit.position.copy(position);
hit.userData.modelIndex = modelIndex;
hit.userData.routeIndex = routeIndex;
group.add(hit);
hitMeshes.push(hit);
const load = PULLS[modelIndex][id];
const stemHeight = 0.07 + load * 0.28;
const stemMaterial = new THREE.MeshBasicMaterial({
color: heatColor(load),
transparent: true,
opacity: 0.28 + load * 0.62,
depthWrite: false
});
const stem = new THREE.Mesh(
new THREE.BoxGeometry(0.027, stemHeight, 0.027),
stemMaterial
);
stem.position.set(
position.x,
position.y + stemHeight * 0.5 + 0.025,
position.z
);
pullGroup.add(stem);
const tip = new THREE.Mesh(
new THREE.BoxGeometry(0.052, 0.052, 0.052),
stemMaterial
);
tip.position.set(position.x, position.y + stemHeight + 0.04, position.z);
pullGroup.add(tip);
records.push({
id,
routeIndex,
eyelet,
material: eyeletMaterial,
hit,
stem,
tip
});
}
eyeletRecords.push(records);
}
MODELS.forEach((model, index) => {
const group = new THREE.Group();
group.position.x = (index - 1) * 4.25;
buildPedestal(group, model.accent);
buildVoxelShoe(group, index);
buildRoute(group, model, index);
scene.add(group);
modelGroups.push(group);
});
// -----------------------------------------------------------------------
// Trace interaction
// -----------------------------------------------------------------------
function stopAuto(modelIndex) {
if (AUTO_TIMERS[modelIndex]) {
clearTimeout(AUTO_TIMERS[modelIndex]);
AUTO_TIMERS[modelIndex] = null;
}
AUTO_ACTIVE[modelIndex] = false;
const button = document.getElementById(`auto-${modelIndex}`);
if (button) button.textContent = "Auto trace";
}
function updateTrace(modelIndex) {
const model = MODELS[modelIndex];
const count = ROUTE_COUNTS[modelIndex];
const segments = segmentMeshes[modelIndex];
const records = eyeletRecords[modelIndex];
segments.forEach((mesh, index) => {
const traced = index < count - 1;
mesh.material.color.set(traced ? model.accent : 0x657783);
mesh.material.emissive.set(traced ? model.accent : 0x000000);
mesh.material.emissiveIntensity = traced ? 0.18 : 0;
});
records.forEach((record) => {
const visited = record.routeIndex < count;
const expected = record.routeIndex === count;
record.material.color.set(
visited ? model.accent : expected ? 0xffd166 : 0x84939a
);
record.material.emissive.set(
visited ? model.accent : expected ? 0xffc83d : 0x000000
);
record.material.emissiveIntensity = visited ? 0.2 : expected ? 0.9 : 0;
record.eyelet.scale.setScalar(expected ? 1.28 : visited ? 1.08 : 1);
const loadDot = document.querySelector(
`[data-load-model="${modelIndex}"][data-load-node="${record.id}"]`
);
loadDot?.classList.toggle("visited", visited);
const eye = document.querySelector(
`[data-map-eye="${modelIndex}-${record.routeIndex}"]`
);
eye?.setAttribute(
"stroke",
visited ? model.accent : expected ? "#ffd166" : "#c3d0d5"
);
});
segments.forEach((_, index) => {
document
.querySelector(`[data-map-seg="${modelIndex}-${index}"]`)
?.classList.toggle("traced", index < count - 1);
});
const progress = document.getElementById(`progress-${modelIndex}`);
const fill = document.getElementById(`fill-${modelIndex}`);
const counter = document.getElementById(`count-${modelIndex}`);
const status = document.getElementById(`status-${modelIndex}`);
fill.style.width = `${(count / model.route.length) * 100}%`;
counter.textContent = `${count} / ${model.route.length} anchors`;
progress.setAttribute("aria-valuenow", String(count));
if (count === model.route.length) {
status.textContent = "Route mapped. Compare the highlighted pull footprint.";
} else if (count === 0) {
status.textContent = "Click the pulsing gold eyelet to begin.";
} else {
status.textContent =
`Anchor ${count} locked. Continue following the gold pulse.`;
}
}
function spawnPulse(modelIndex, id, load) {
const group = modelGroups[modelIndex];
const material = new THREE.MeshBasicMaterial({
color: heatColor(load),
transparent: true,
opacity: 0.9,
depthWrite: false
});
const ring = new THREE.Mesh(
new THREE.TorusGeometry(0.14, 0.018, 6, 24),
material
);
ring.position.copy(eyeletPosition(id));
ring.position.y += 0.035;
ring.rotation.x = Math.PI / 2;
group.add(ring);
pulses.push({
ring,
material,
age: 0,
duration: 0.85
});
}
function visitAnchor(modelIndex, routeIndex) {
const model = MODELS[modelIndex];
if (routeIndex !== ROUTE_COUNTS[modelIndex]) return false;
ROUTE_COUNTS[modelIndex] = routeIndex + 1;
const id = model.route[routeIndex];
spawnPulse(modelIndex, id, PULLS[modelIndex][id]);
updateTrace(modelIndex);
if (ROUTE_COUNTS[modelIndex] === model.route.length) {
stopAuto(modelIndex);
showToast(`${model.name}: continuous route complete.`);
}
return true;
}
function runAuto(modelIndex) {
const model = MODELS[modelIndex];
if (ROUTE_COUNTS[modelIndex] >= model.route.length) {
stopAuto(modelIndex);
return;
}
AUTO_ACTIVE[modelIndex] = true;
document.getElementById(`auto-${modelIndex}`).textContent = "Pause";
const next = ROUTE_COUNTS[modelIndex];
visitAnchor(modelIndex, next);
if (ROUTE_COUNTS[modelIndex] < model.route.length) {
AUTO_TIMERS[modelIndex] = setTimeout(
() => runAuto(modelIndex),
430
);
}
}
function resetTrace(modelIndex) {
stopAuto(modelIndex);
ROUTE_COUNTS[modelIndex] = 0;
updateTrace(modelIndex);
}
MODELS.forEach((model, index) => {
document.getElementById(`auto-${index}`).addEventListener("click", () => {
if (AUTO_ACTIVE[index]) {
stopAuto(index);
} else {
if (ROUTE_COUNTS[index] === model.route.length) {
resetTrace(index);
}
runAuto(index);
}
});
document.getElementById(`reset-${index}`).addEventListener("click", () => {
resetTrace(index);
});
});
document.getElementById("reset-traces").addEventListener("click", () => {
MODELS.forEach((_, index) => resetTrace(index));
showToast("All three routes reset.");
});
document.getElementById("reset-view").addEventListener("click", resetCamera);
document.getElementById("pull-toggle").addEventListener("change", (event) => {
pullGroups.forEach((group) => {
group.visible = event.target.checked;
});
});
// -----------------------------------------------------------------------
// Direct camera controls and eyelet picking
// -----------------------------------------------------------------------
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
let pointerDown = null;
let pointerMoved = false;
function updatePointer(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 pickEyelet(event) {
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(hitMeshes, false);
if (!intersections.length) return;
const hit = intersections[0].object;
const modelIndex = hit.userData.modelIndex;
const routeIndex = hit.userData.routeIndex;
stopAuto(modelIndex);
if (routeIndex === ROUTE_COUNTS[modelIndex]) {
visitAnchor(modelIndex, routeIndex);
} else if (routeIndex < ROUTE_COUNTS[modelIndex]) {
showToast("That anchor is already part of the traced route.");
} else {
showToast("Follow the pulsing gold eyelet to keep the route continuous.");
}
}
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerDown = {
x: event.clientX,
y: event.clientY
};
pointerMoved = false;
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.abs(dx) + Math.abs(dy) > 4) {
pointerMoved = true;
}
cameraYaw -= dx * 0.006;
cameraPitch = THREE.MathUtils.clamp(
cameraPitch + dy * 0.0045,
0.25,
1.25
);
updateCamera();
return;
}
updatePointer(event);
raycaster.setFromCamera(pointer, camera);
const intersections = raycaster.intersectObjects(hitMeshes, false);
hoveredModel = intersections.length
? intersections[0].object.userData.modelIndex
: -1;
renderer.domElement.style.cursor = hoveredModel >= 0 ? "pointer" : "grab";
});
renderer.domElement.addEventListener("pointerup", (event) => {
if (pointerDown && !pointerMoved) {
pickEyelet(event);
}
pointerDown = null;
pointerMoved = false;
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown = null;
pointerMoved = false;
});
renderer.domElement.addEventListener("wheel", (event) => {
event.preventDefault();
cameraRadius = THREE.MathUtils.clamp(
cameraRadius + event.deltaY * 0.012,
10,
25
);
updateCamera();
}, { passive: false });
renderer.domElement.addEventListener("dblclick", resetCamera);
// -----------------------------------------------------------------------
// Resize and animation
// -----------------------------------------------------------------------
function resizeRenderer() {
const width = stage.clientWidth;
const height = stage.clientHeight;
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
const resizeObserver = new ResizeObserver(resizeRenderer);
resizeObserver.observe(stage);
resizeRenderer();
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const delta = Math.min(clock.getDelta(), 0.05);
for (let index = pulses.length - 1; index >= 0; index--) {
const pulse = pulses[index];
pulse.age += delta;
const progress = pulse.age / pulse.duration;
pulse.ring.scale.setScalar(1 + progress * 2.1);
pulse.material.opacity = Math.max(0, 0.9 * (1 - progress));
if (progress >= 1) {
modelGroups.forEach((group) => group.remove(pulse.ring));
pulse.ring.geometry.dispose();
pulse.material.dispose();
pulses.splice(index, 1);
}
}
renderer.render(scene, camera);
}
MODELS.forEach((_, index) => updateTrace(index));
loading.remove();
animate();
</script>
</body>
</html>
```