Prompt specification
Build or customize the Three.js 3D scene "Interoperability workshop display" 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: Interoperability workshop display
Category: Everyday & Industrial · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/interoperability-workshop-display-x0312
Scene Description Prompt:
Make a standalone HTML scene with Three.js from cdnjs that depicts socket adapters. Create miniature mechanical modules with several connector standards; visitors build valid transmission chains using adapters and observe which combinations preserve a continuous motion path. Low-poly.
Working Three.js Starter (interoperability-workshop-display-x0312):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Socket Works — Transmission Bench</title>
<style>
:root {
--bg: #07111b;
--panel: rgba(13, 26, 39, 0.88);
--panel-strong: rgba(17, 34, 49, 0.96);
--line: rgba(163, 201, 224, 0.16);
--text: #e8f3fa;
--muted: #8da7b9;
--hex: #f7c85a;
--tri: #5ce1e6;
--star: #c084fc;
--good: #70f0b3;
--bad: #ff657a;
--shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
* {
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
overflow: hidden;
background: var(--bg);
color: var(--text);
font-family: Inter, ui-sans-serif, system-ui, -apple-system,
BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button {
font: inherit;
}
#scene {
position: fixed;
inset: 0;
display: block;
width: 100%;
height: 100%;
touch-action: none;
outline: none;
}
.brand {
position: fixed;
top: 22px;
left: 24px;
z-index: 5;
pointer-events: none;
}
.brand-kicker {
color: var(--muted);
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.brand h1 {
margin: 5px 0 4px;
font-size: clamp(25px, 3vw, 40px);
line-height: 0.95;
letter-spacing: -0.055em;
text-transform: uppercase;
}
.brand h1 span {
color: var(--tri);
}
.brand p {
margin: 0;
color: var(--muted);
font-size: 11px;
letter-spacing: 0.08em;
}
.signal {
position: fixed;
top: 126px;
left: 24px;
z-index: 5;
display: flex;
align-items: center;
gap: 11px;
min-width: 220px;
padding: 11px 14px;
border: 1px solid var(--line);
border-radius: 12px;
background: rgba(10, 23, 35, 0.75);
box-shadow: var(--shadow);
backdrop-filter: blur(12px);
pointer-events: none;
}
.signal-dot {
width: 11px;
height: 11px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--bad);
box-shadow: 0 0 16px var(--bad);
}
.signal.good .signal-dot {
background: var(--good);
box-shadow: 0 0 16px var(--good);
}
.signal span {
display: block;
color: var(--muted);
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
}
.signal strong {
display: block;
margin-top: 2px;
font-size: 12px;
letter-spacing: 0.06em;
}
#panel {
position: fixed;
z-index: 10;
top: 20px;
right: 20px;
width: 330px;
max-height: calc(100vh - 40px);
overflow: hidden auto;
padding: 18px;
border: 1px solid var(--line);
border-radius: 18px;
background: var(--panel);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
scrollbar-width: thin;
scrollbar-color: #355069 transparent;
}
.panel-title {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
margin-bottom: 13px;
}
.panel-title h2 {
margin: 0;
font-size: 17px;
letter-spacing: -0.02em;
}
.panel-title p {
margin: 5px 0 0;
color: var(--muted);
font-size: 11px;
line-height: 1.45;
}
.bench-number {
color: var(--tri);
font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.12em;
white-space: nowrap;
}
.section-label {
display: flex;
align-items: center;
gap: 9px;
margin: 17px 0 9px;
color: var(--muted);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.section-label::after {
content: "";
height: 1px;
flex: 1;
background: var(--line);
}
.part-card {
display: grid;
grid-template-columns: 42px 1fr 30px;
align-items: center;
gap: 10px;
margin-bottom: 7px;
padding: 10px;
border: 1px solid rgba(155, 195, 220, 0.12);
border-radius: 11px;
background: rgba(255, 255, 255, 0.025);
transition:
border-color 160ms ease,
background 160ms ease,
transform 160ms ease;
}
.part-card:hover {
border-color: rgba(92, 225, 230, 0.42);
background: rgba(92, 225, 230, 0.06);
transform: translateX(-2px);
}
.part-visual {
position: relative;
width: 42px;
height: 34px;
}
.part-body {
position: absolute;
left: 7px;
top: 8px;
width: 28px;
height: 18px;
border: 1px solid #5c7387;
border-radius: 4px;
background: linear-gradient(145deg, #31475b, #172838);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}
.part-body::before,
.part-body::after {
content: "";
position: absolute;
top: 5px;
width: 7px;
height: 8px;
background: var(--port-color);
clip-path: var(--port-shape);
}
.part-body::before {
left: -5px;
}
.part-body::after {
right: -5px;
background: var(--exit-color);
}
.part-copy {
min-width: 0;
}
.part-copy strong {
display: block;
font-size: 12px;
letter-spacing: 0.01em;
}
.part-copy span {
display: block;
margin-top: 3px;
color: var(--muted);
font: 700 9px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
}
.add-button {
width: 28px;
height: 28px;
padding: 0;
border: 1px solid rgba(92, 225, 230, 0.34);
border-radius: 8px;
color: var(--tri);
background: rgba(92, 225, 230, 0.07);
cursor: pointer;
font-size: 19px;
line-height: 1;
transition: 150ms ease;
}
.add-button:hover {
color: #06131d;
background: var(--tri);
transform: rotate(90deg);
}
.actions {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-top: 17px;
}
.action {
min-height: 36px;
border: 1px solid var(--line);
border-radius: 9px;
color: var(--text);
background: rgba(255, 255, 255, 0.04);
cursor: pointer;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
transition: 150ms ease;
}
.action:hover {
border-color: rgba(255, 255, 255, 0.3);
background: rgba(255, 255, 255, 0.08);
}
.action.primary {
grid-column: 1 / -1;
border-color: rgba(92, 225, 230, 0.38);
color: #07151e;
background: var(--tri);
}
.action.primary:hover {
background: #8cf2f6;
}
.help {
margin: 13px 2px 0;
color: #6f899b;
font-size: 9px;
line-height: 1.55;
letter-spacing: 0.04em;
}
#chainPanel {
position: fixed;
z-index: 8;
left: 20px;
bottom: 20px;
width: min(760px, calc(100vw - 390px));
padding: 15px 16px 14px;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--panel-strong);
box-shadow: var(--shadow);
backdrop-filter: blur(18px);
}
.chain-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 11px;
}
.chain-heading > span {
color: var(--muted);
font-size: 9px;
font-weight: 900;
letter-spacing: 0.18em;
}
#chainStatus {
color: var(--bad);
font-size: 11px;
font-weight: 900;
letter-spacing: 0.08em;
text-align: right;
}
#chainStatus.good {
color: var(--good);
}
#chainStrip {
display: flex;
align-items: stretch;
min-height: 56px;
overflow-x: auto;
padding: 2px 1px 7px;
scrollbar-width: thin;
scrollbar-color: #355069 transparent;
}
.chain-chip {
position: relative;
flex: 0 0 auto;
min-width: 92px;
padding: 9px 10px;
border: 1px solid rgba(164, 202, 225, 0.18);
border-radius: 9px;
background: #172a3a;
}
.chain-chip strong {
display: block;
overflow: hidden;
font-size: 10px;
letter-spacing: 0.07em;
text-overflow: ellipsis;
white-space: nowrap;
}
.chain-chip span {
display: block;
margin-top: 5px;
color: var(--muted);
font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
letter-spacing: 0.08em;
}
.chain-chip.bad {
border-color: rgba(255, 101, 122, 0.45);
background: rgba(255, 101, 122, 0.08);
}
.chain-chip.good {
border-color: rgba(112, 240, 179, 0.4);
}
.remove-piece {
position: absolute;
top: 4px;
right: 4px;
width: 17px;
height: 17px;
padding: 0;
border: 0;
border-radius: 50%;
color: #9bb1c1;
background: rgba(255, 255, 255, 0.06);
cursor: pointer;
font-size: 12px;
line-height: 15px;
}
.remove-piece:hover {
color: white;
background: var(--bad);
}
.chain-link {
position: relative;
display: flex;
flex: 0 0 33px;
align-items: center;
justify-content: center;
color: var(--good);
font-weight: 900;
}
.chain-link::before {
content: "";
position: absolute;
left: 5px;
right: 5px;
height: 2px;
background: currentColor;
box-shadow: 0 0 8px currentColor;
}
.chain-link::after {
content: "";
position: absolute;
right: 3px;
width: 6px;
height: 6px;
border-top: 2px solid currentColor;
border-right: 2px solid currentColor;
transform: rotate(45deg);
}
.chain-link.bad {
color: var(--bad);
}
.chain-link.bad::before {
background: repeating-linear-gradient(
90deg,
currentColor 0 5px,
transparent 5px 9px
);
box-shadow: none;
}
#chainNote {
min-height: 13px;
margin-top: 7px;
color: var(--muted);
font-size: 9px;
letter-spacing: 0.04em;
}
#panelToggle {
position: fixed;
z-index: 20;
top: 20px;
right: 20px;
display: none;
width: 42px;
height: 42px;
border: 1px solid rgba(92, 225, 230, 0.35);
border-radius: 11px;
color: var(--tri);
background: rgba(13, 26, 39, 0.92);
cursor: pointer;
font-size: 20px;
}
#toast {
position: fixed;
z-index: 30;
left: 50%;
top: 24px;
max-width: min(440px, calc(100vw - 32px));
padding: 11px 15px;
border: 1px solid rgba(255, 255, 255, 0.15);
border-radius: 10px;
color: var(--text);
background: rgba(9, 21, 32, 0.94);
box-shadow: var(--shadow);
font-size: 11px;
opacity: 0;
pointer-events: none;
transform: translate(-50%, -12px);
transition: 180ms ease;
}
#toast.show {
opacity: 1;
transform: translate(-50%, 0);
}
#toast.bad {
border-color: rgba(255, 101, 122, 0.42);
}
#loading {
position: fixed;
z-index: 100;
inset: 0;
display: grid;
place-items: center;
color: var(--tri);
background: #07111b;
font-size: 11px;
font-weight: 900;
letter-spacing: 0.18em;
transition: opacity 350ms ease;
}
#loading.hidden {
opacity: 0;
pointer-events: none;
}
@media (max-width: 800px) {
.brand {
top: 15px;
left: 15px;
}
.brand h1 {
font-size: 26px;
}
.signal {
top: 92px;
left: 15px;
min-width: 190px;
}
#panelToggle {
display: block;
}
#panel {
top: 12px;
right: 12px;
width: min(330px, calc(100vw - 24px));
max-height: calc(100vh - 24px);
opacity: 0;
pointer-events: none;
transform: translateX(calc(100% + 24px));
transition: 180ms ease;
}
body.panel-open #panel {
opacity: 1;
pointer-events: auto;
transform: translateX(0);
}
#chainPanel {
right: 12px;
bottom: 12px;
left: 12px;
width: auto;
}
.chain-heading {
align-items: flex-start;
}
#chainStatus {
max-width: 65%;
}
}
@media (max-width: 520px) {
.brand p,
.brand-kicker {
display: none;
}
.signal {
top: 56px;
padding: 8px 11px;
}
#chainPanel {
padding: 12px;
}
.chain-heading > span {
display: none;
}
#chainStatus {
max-width: none;
text-align: left;
}
#chainNote {
display: none;
}
}
</style>
</head>
<body>
<canvas id="scene" aria-label="Interactive low-poly adapter assembly bench"></canvas>
<header class="brand">
<div class="brand-kicker">Mechanical systems lab</div>
<h1>Socket<span>Works</span></h1>
<p>Transmission bench / bay 04</p>
</header>
<div class="signal" id="signalCard" aria-live="polite">
<i class="signal-dot"></i>
<div>
<span>BENCH STATUS</span>
<strong id="signalText">AWAITING ROUTE</strong>
</div>
</div>
<button id="panelToggle" aria-label="Open parts library">+</button>
<aside id="panel">
<div class="panel-title">
<div>
<h2>Parts Library</h2>
<p>
Build from the HEX drive to the HEX load. Every adjacent connector
must match for motion to continue.
</p>
</div>
<span class="bench-number">SW–04</span>
</div>
<div class="section-label">Adapters</div>
<div id="adapterList"></div>
<div class="section-label">Mechanical modules</div>
<div id="moduleList"></div>
<div class="actions">
<button class="action primary" id="autoRoute">Build valid route</button>
<button class="action" id="undo">Undo</button>
<button class="action" id="clear">Clear</button>
</div>
<p class="help">
Drag to orbit · Wheel to zoom · Right-drag to pan · Double-click to reset
the camera
</p>
</aside>
<section id="chainPanel">
<div class="chain-heading">
<span>LIVE TRANSMISSION CHAIN</span>
<strong id="chainStatus">ROUTE INCOMPLETE</strong>
</div>
<div id="chainStrip"></div>
<div id="chainNote">Add a coupling or module to begin.</div>
</section>
<div id="toast" role="status"></div>
<div id="loading">INITIALIZING TRANSMISSION BENCH…</div>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
// -------------------------------------------------------------------------
// Data
// -------------------------------------------------------------------------
const STANDARD = {
hex: {
name: "HEX",
color: 0xf7c85a,
css: "#f7c85a",
shape:
"polygon(25% 2%, 75% 2%, 98% 50%, 75% 98%, 25% 98%, 2% 50%)",
sides: 6
},
tri: {
name: "TRI",
color: 0x5ce1e6,
css: "#5ce1e6",
shape:
"polygon(50% 2%, 98% 96%, 2% 96%)",
sides: 3
},
star: {
name: "STAR",
color: 0xc084fc,
css: "#c084fc",
shape:
"polygon(50% 1%, 61% 35%, 98% 35%, 69% 57%, 80% 94%, 50% 72%, 20% 94%, 31% 57%, 2% 35%, 39% 35%)",
sides: 5
}
};
const SOURCE = {
id: "source",
name: "Drive motor",
short: "DRIVE",
type: "source",
out: "hex",
outLocal: 0.83,
span: 1.72,
bodyW: 1.35
};
const LOAD = {
id: "load",
name: "Load receiver",
short: "LOAD",
type: "load",
in: "hex",
inLocal: -0.83,
span: 1.72,
bodyW: 1.35
};
const PARTS = {
direct: {
id: "direct",
name: "Direct sleeve",
short: "DIRECT",
category: "adapter",
in: "hex",
out: "hex",
inLocal: -0.34,
outLocal: 0.34,
span: 0.88,
bodyW: 0.54
},
ht: {
id: "ht",
name: "Step sleeve",
short: "H–T",
category: "adapter",
in: "hex",
out: "tri",
inLocal: -0.34,
outLocal: 0.34,
span: 0.88,
bodyW: 0.54
},
ts: {
id: "ts",
name: "Cross sleeve",
short: "T–S",
category: "adapter",
in: "tri",
out: "star",
inLocal: -0.34,
outLocal: 0.34,
span: 0.88,
bodyW: 0.54
},
sh: {
id: "sh",
name: "Return sleeve",
short: "S–H",
category: "adapter",
in: "star",
out: "hex",
inLocal: -0.34,
outLocal: 0.34,
span: 0.88,
bodyW: 0.54
},
rotor: {
id: "rotor",
name: "Tri-Star rotor",
short: "ROTOR",
category: "module",
module: "rotor",
in: "tri",
out: "star",
inLocal: -0.84,
outLocal: 0.84,
span: 1.95,
bodyW: 1.45
},
gearbox: {
id: "gearbox",
name: "Hex-Tri gearbox",
short: "GEARBOX",
category: "module",
module: "gearbox",
in: "hex",
out: "tri",
inLocal: -0.84,
outLocal: 0.84,
span: 1.95,
bodyW: 1.45
}
};
const state = {
userParts: [],
analysis: null,
items: [],
pathPoints: [],
pulses: [],
breakMarker: null,
valid: false
};
const $ = (selector) => document.querySelector(selector);
const canvas = $("#scene");
// -------------------------------------------------------------------------
// Renderer and camera
// -------------------------------------------------------------------------
const renderer = new THREE.WebGLRenderer({
canvas,
antialias: true,
powerPreference: "high-performance"
});
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111b);
scene.fog = new THREE.FogExp2(0x07111b, 0.026);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
100
);
const cameraControls = {
theta: 0.29,
phi: 0.97,
radius: 12.4,
target: new THREE.Vector3(0.72, 0.78, 0),
dragging: false,
panning: false,
lastX: 0,
lastY: 0
};
function updateCamera() {
const offset = new THREE.Vector3().setFromSphericalCoords(
cameraControls.radius,
cameraControls.phi,
cameraControls.theta
);
camera.position.copy(cameraControls.target).add(offset);
camera.lookAt(cameraControls.target);
}
function resetCamera() {
cameraControls.theta = 0.29;
cameraControls.phi = 0.97;
cameraControls.radius = 12.4;
cameraControls.target.set(0.72, 0.78, 0);
updateCamera();
}
canvas.addEventListener("pointerdown", (event) => {
cameraControls.dragging = true;
cameraControls.panning = event.button === 2 || event.shiftKey;
cameraControls.lastX = event.clientX;
cameraControls.lastY = event.clientY;
canvas.setPointerCapture(event.pointerId);
});
canvas.addEventListener("pointermove", (event) => {
if (!cameraControls.dragging) return;
const dx = event.clientX - cameraControls.lastX;
const dy = event.clientY - cameraControls.lastY;
cameraControls.lastX = event.clientX;
cameraControls.lastY = event.clientY;
if (cameraControls.panning) {
const right = new THREE.Vector3();
const up = new THREE.Vector3();
camera.matrixWorld.extractBasis(right, up, new THREE.Vector3());
const scale = cameraControls.radius * 0.0013;
cameraControls.target.addScaledVector(right, -dx * scale);
cameraControls.target.addScaledVector(up, dy * scale);
cameraControls.target.y = THREE.MathUtils.clamp(
cameraControls.target.y,
-0.5,
3
);
} else {
cameraControls.theta -= dx * 0.006;
cameraControls.phi = THREE.MathUtils.clamp(
cameraControls.phi - dy * 0.005,
0.38,
1.43
);
}
updateCamera();
});
function endPointer(event) {
cameraControls.dragging = false;
cameraControls.panning = false;
if (canvas.hasPointerCapture(event.pointerId)) {
canvas.releasePointerCapture(event.pointerId);
}
}
canvas.addEventListener("pointerup", endPointer);
canvas.addEventListener("pointercancel", endPointer);
canvas.addEventListener("contextmenu", (event) => event.preventDefault());
canvas.addEventListener(
"wheel",
(event) => {
event.preventDefault();
cameraControls.radius = THREE.MathUtils.clamp(
cameraControls.radius * Math.exp(event.deltaY * 0.001),
6.8,
19
);
updateCamera();
},
{ passive: false }
);
canvas.addEventListener("dblclick", resetCamera);
updateCamera();
// -------------------------------------------------------------------------
// Lighting and bench
// -------------------------------------------------------------------------
const hemisphere = new THREE.HemisphereLight(0x9bdcff, 0x16202a, 1.45);
scene.add(hemisphere);
const keyLight = new THREE.DirectionalLight(0xd9f4ff, 3.1);
keyLight.position.set(3.5, 8, 5.5);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -9;
keyLight.shadow.camera.right = 9;
keyLight.shadow.camera.top = 7;
keyLight.shadow.camera.bottom = -7;
keyLight.shadow.bias = -0.0003;
scene.add(keyLight);
const rimLight = new THREE.PointLight(0x5ce1e6, 22, 13, 2);
rimLight.position.set(-5.5, 3.5, 2.8);
scene.add(rimLight);
const warmLight = new THREE.PointLight(0xf7c85a, 13, 11, 2);
warmLight.position.set(5, 2.5, -2.5);
scene.add(warmLight);
const benchRoot = new THREE.Group();
const chainRoot = new THREE.Group();
const routeRoot = new THREE.Group();
scene.add(benchRoot, chainRoot, routeRoot);
function material(color, options = {}) {
return new THREE.MeshStandardMaterial({
color,
roughness: 0.58,
metalness: 0.24,
flatShading: true,
...options
});
}
function addBox(
parent,
dimensions,
position,
color,
options = {},
edges = false
) {
const geometry = new THREE.BoxGeometry(...dimensions);
const mesh = new THREE.Mesh(geometry, material(color, options));
mesh.position.set(...position);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
if (edges) {
const outline = new THREE.LineSegments(
new THREE.EdgesGeometry(geometry),
new THREE.LineBasicMaterial({
color: 0x9bb9ca,
transparent: true,
opacity: 0.28
})
);
mesh.add(outline);
}
return mesh;
}
function makeTextSprite(text, color = "#dcecf5", scale = 0.52) {
const labelCanvas = document.createElement("canvas");
labelCanvas.width = 256;
labelCanvas.height = 96;
const ctx = labelCanvas.getContext("2d");
ctx.fillStyle = "rgba(8, 20, 31, 0.88)";
ctx.fillRect(0, 0, 256, 96);
ctx.strokeStyle = color;
ctx.lineWidth = 6;
ctx.strokeRect(3, 3, 250, 90);
ctx.fillStyle = color;
ctx.font = "800 34px ui-monospace, SFMono-Regular, Menlo, monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 128, 50);
const texture = new THREE.CanvasTexture(labelCanvas);
texture.colorSpace = THREE.SRGBColorSpace;
const sprite = new THREE.Sprite(
new THREE.SpriteMaterial({
map: texture,
transparent: true,
depthTest: false,
depthWrite: false
})
);
sprite.scale.set(scale, scale * 0.375, 1);
sprite.renderOrder = 20;
return sprite;
}
function buildBench() {
const floor = new THREE.Mesh(
new THREE.PlaneGeometry(40, 40),
material(0x0a1722, { roughness: 0.95, metalness: 0.02 })
);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.42;
floor.receiveShadow = true;
scene.add(floor);
const grid = new THREE.GridHelper(34, 34, 0x244556, 0x142c3b);
grid.position.y = -0.405;
grid.material.transparent = true;
grid.material.opacity = 0.38;
scene.add(grid);
addBox(
benchRoot,
[11.7, 0.32, 3.65],
[0, -0.16, 0],
0x182735,
{ roughness: 0.72 },
true
);
addBox(
benchRoot,
[11.32, 0.055, 3.28],
[0, 0.035, 0],
0x223849,
{ roughness: 0.7 }
);
[-1.55, 1.55].forEach((z) => {
addBox(
benchRoot,
[11.35, 0.11, 0.1],
[0, 0.12, z],
0x557487,
{ metalness: 0.7, roughness: 0.35 }
);
});
const plate = makeTextSprite("TRANSMISSION BAY 04", "#5ce1e6", 2.2);
plate.position.set(0, -0.02, 1.87);
benchRoot.add(plate);
for (let x = -4.9; x <= 4.9; x += 1.1) {
const bolt = new THREE.Mesh(
new THREE.CylinderGeometry(0.035, 0.035, 0.025, 8),
material(0x8ca4b3, { metalness: 0.8 })
);
bolt.position.set(x, 0.08, 1.47);
benchRoot.add(bolt);
}
}
buildBench();
// -------------------------------------------------------------------------
// Geometry helpers
// -------------------------------------------------------------------------
function silhouetteGeometry(standardId, radius, depth) {
const standard = STANDARD[standardId];
const shape = new THREE.Shape();
const points = [];
if (standardId === "star") {
for (let i = 0; i < 10; i++) {
const angle = (i / 10) * Math.PI * 2 + Math.PI / 2;
const r = i % 2 === 0 ? radius : radius * 0.48;
points.push(
new THREE.Vector2(Math.cos(angle) * r, Math.sin(angle) * r)
);
}
} else {
for (let i = 0; i < standard.sides; i++) {
const angle = (i / standard.sides) * Math.PI * 2 + Math.PI / 2;
points.push(
new THREE.Vector2(
Math.cos(angle) * radius,
Math.sin(angle) * radius
)
);
}
}
points.forEach((point, index) => {
if (index === 0) shape.moveTo(point.x, point.y);
else shape.lineTo(point.x, point.y);
});
shape.closePath();
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: false,
steps: 1,
curveSegments: 1
});
geometry.translate(0, 0, -depth / 2);
geometry.rotateY(Math.PI / 2);
return geometry;
}
function addPort(parent, x, standardId, direction, label = true) {
const group = new THREE.Group();
group.position.set(x, 0.62, 0);
parent.add(group);
const standard = STANDARD[standardId];
const outer = new THREE.Mesh(
silhouetteGeometry(standardId, 0.25, 0.17),
material(standard.color, {
emissive: standard.color,
emissiveIntensity: 0.16,
metalness: 0.42,
roughness: 0.38
})
);
outer.castShadow = true;
group.add(outer);
const inner = new THREE.Mesh(
silhouetteGeometry(standardId, 0.105, 0.026),
material(0x071018, {
metalness: 0.55,
roughness: 0.45
})
);
inner.position.x = direction === "out" ? 0.092 : -0.092;
group.add(inner);
const pin = new THREE.Mesh(
new THREE.CylinderGeometry(0.038, 0.038, 0.04, 8),
material(0xe5f6ff, {
emissive: standard.color,
emissiveIntensity: 0.75,
metalness: 0.6
})
);
pin.rotation.z = Math.PI / 2;
pin.position.x = direction === "out" ? 0.113 : -0.113;
group.add(pin);
if (label) {
const tag = makeTextSprite(standard.name, standard.css, 0.47);
tag.position.set(x, 1.04, 0.61);
parent.add(tag);
}
}
function createGear(radius, teeth, color) {
const group = new THREE.Group();
const disc = new THREE.Mesh(
new THREE.CylinderGeometry(radius * 0.75, radius * 0.75, 0.13, 12),
material(color, {
emissive: color,
emissiveIntensity: 0.08,
metalness: 0.48
})
);
disc.castShadow = true;
group.add(disc);
for (let i = 0; i < teeth; i++) {
const angle = (i / teeth) * Math.PI * 2;
const tooth = addBox(
group,
[radius * 0.31, 0.14, radius * 0.22],
[
Math.sin(angle) * radius * 0.78,
0,
Math.cos(angle) * radius * 0.78
],
color,
{ emissive: color, emissiveIntensity: 0.06, metalness: 0.42 }
);
tooth.rotation.y = angle;
}
const hub = new THREE.Mesh(
new THREE.CylinderGeometry(radius * 0.22, radius * 0.22, 0.18, 10),
material(0xd3e7ef, { metalness: 0.72, roughness: 0.3 })
);
group.add(hub);
return group;
}
function addPedestal(parent, width) {
addBox(
parent,
[width * 0.72, 0.27, 0.48],
[0, 0.17, 0],
0x111f2c,
{ metalness: 0.55 }
);
}
function createAdapter(item) {
const group = item.group;
const def = item.def;
addPedestal(group, def.bodyW);
const body = addBox(
group,
[def.bodyW, 0.5, 0.68],
[0, 0.59, 0],
0x2d4153,
{ metalness: 0.38 },
true
);
body.rotation.y = 0.015;
const topStripe = addBox(
group,
[def.bodyW * 0.72, 0.035, 0.69],
[0, 0.86, 0],
STANDARD[def.out].color,
{
emissive: STANDARD[def.out].color,
emissiveIntensity: 0.18,
metalness: 0.38
}
);
const arrow = new THREE.Mesh(
new THREE.ConeGeometry(0.085, 0.18, 3),
material(STANDARD[def.out].color, {
emissive: STANDARD[def.out].color,
emissiveIntensity: 0.25
})
);
arrow.rotation.z = -Math.PI / 2;
arrow.position.set(0, 0.91, 0.22);
group.add(arrow);
addPort(group, def.inLocal, def.in, "in");
addPort(group, def.outLocal, def.out, "out");
}
function createRotor(item) {
const group = item.group;
const def = item.def;
addPedestal(group, def.bodyW);
addBox(
group,
[def.bodyW, 0.84, 1.08],
[0, 0.75, 0],
0x304659,
{ metalness: 0.35 },
true
);
addBox(
group,
[def.bodyW * 0.82, 0.07, 1.1],
[0, 1.2, 0],
STANDARD[def.out].color,
{
emissive: STANDARD[def.out].color,
emissiveIntensity: 0.12,
metalness: 0.45
}
);
const largeGear = createGear(0.35, 9, STANDARD[def.out].color);
largeGear.position.set(-0.26, 1.31, 0);
group.add(largeGear);
const smallGear = createGear(0.23, 8, STANDARD[def.in].color);
smallGear.position.set(0.31, 1.31, 0);
group.add(smallGear);
item.gears.push(
{ object: largeGear, speed: 2.0 },
{ object: smallGear, speed: -2.75 }
);
addPort(group, def.inLocal, def.in, "in");
addPort(group, def.outLocal, def.out, "out");
}
function createGearbox(item) {
const group = item.group;
const def = item.def;
addPedestal(group, def.bodyW);
addBox(
group,
[def.bodyW, 0.86, 1.1],
[0, 0.76, 0],
0x3d3650,
{ metalness: 0.36 },
true
);
addBox(
group,
[def.bodyW * 0.84, 0.07, 1.12],
[0, 1.22, 0],
STANDARD[def.out].color,
{
emissive: STANDARD[def.out].color,
emissiveIntensity: 0.13,
metalness: 0.48
}
);
const gearA = createGear(0.31, 8, STANDARD[def.in].color);
gearA.position.set(-0.3, 1.34, 0);
group.add(gearA);
const gearB = createGear(0.37, 10, STANDARD[def.out].color);
gearB.position.set(0.3, 1.34, 0);
group.add(gearB);
item.gears.push(
{ object: gearA, speed: 1.45 },
{ object: gearB, speed: -1.1 }
);
addPort(group, def.inLocal, def.in, "in");
addPort(group, def.outLocal, def.out, "out");
}
function createSource(item) {
const group = item.group;
const def = item.def;
addPedestal(group, def.bodyW);
addBox(
group,
[def.bodyW, 0.95, 1.16],
[0, 0.75, 0],
0x293e51,
{ metalness: 0.42 },
true
);
const motor = new THREE.Mesh(
new THREE.CylinderGeometry(0.31, 0.31, 0.8, 10),
material(0x526b7d, { metalness: 0.65, roughness: 0.34 })
);
motor.rotation.z = Math.PI / 2;
motor.position.set(0.04, 1.38, 0);
motor.castShadow = true;
group.add(motor);
const fan = new THREE.Group();
fan.position.set(0.48, 1.38, 0);
group.add(fan);
for (let i = 0; i < 4; i++) {
const holder = new THREE.Group();
holder.rotation.x = (i / 4) * Math.PI * 2;
fan.add(holder);
addBox(
holder,
[0.045, 0.34, 0.1],
[0, 0.13, 0],
STANDARD.hex.color,
{
emissive: STANDARD.hex.color,
emissiveIntensity: 0.08,
metalness: 0.45
}
);
}
item.fan = fan;
addPort(group, def.outLocal, def.out, "out");
}
function createLoad(item) {
const group = item.group;
const def = item.def;
addPedestal(group, def.bodyW);
addBox(
group,
[def.bodyW, 0.92, 1.16],
[0, 0.74, 0],
0x293c4d,
{ metalness: 0.4 },
true
);
addBox(
group,
[def.bodyW * 0.72, 0.08, 0.78],
[0.08, 1.25, 0],
0x3d5668,
{ metalness: 0.55 }
);
for (let i = 0; i < 3; i++) {
addBox(
group,
[0.07, 0.52, 1.2],
[0.35 + i * 0.11, 0.84, 0],
0x456074,
{ metalness: 0.55 }
);
}
const lamp = new THREE.Mesh(
new THREE.SphereGeometry(0.105, 10, 6),
material(0xff657a, {
emissive: 0xff657a,
emissiveIntensity: 0.8
})
);
lamp.position.set(-0.33, 1.31, 0.27);
group.add(lamp);
item.lamp = lamp;
addPort(group, def.inLocal, def.in, "in");
}
function createItemVisual(item) {
item.gears = [];
item.group = new THREE.Group();
item.group.position.x = item.x;
if (item.def.type === "source") {
createSource(item);
} else if (item.def.type === "load") {
createLoad(item);
} else if (item.def.module === "rotor") {
createRotor(item);
} else if (item.def.module === "gearbox") {
createGearbox(item);
} else {
createAdapter(item);
}
const slot = new THREE.Mesh(
new THREE.CylinderGeometry(0.39, 0.39, 0.025, 8),
material(0x0c1924, { metalness: 0.45 })
);
slot.position.set(item.x, 0.09, 0);
chainRoot.add(slot);
chainRoot.add(item.group);
item.inWorld =
item.def.inLocal !== undefined
? item.x + item.def.inLocal
: null;
item.outWorld =
item.def.outLocal !== undefined
? item.x + item.def.outLocal
: null;
}
// -------------------------------------------------------------------------
// Chain evaluation and route graphics
// -------------------------------------------------------------------------
function evaluateChain() {
const sequence = [
{ id: "source", def: SOURCE, type: "source" },
...state.userParts.map((id) => ({
id,
def: PARTS[id],
type: "part"
})),
{ id: "load", def: LOAD, type: "load" }
];
const links = [];
let upstreamReachable = true;
for (let i = 1; i < sequence.length; i++) {
const from = sequence[i - 1];
const to = sequence[i];
const match = from.def.out === to.def.in;
const reachable = upstreamReachable && match;
links.push({
fromIndex: i - 1,
toIndex: i,
from,
to,
match,
reachable
});
upstreamReachable = reachable;
}
const valid =
state.userParts.length > 0 && links.every((link) => link.match);
return {
sequence,
links,
valid,
loadReachable: links.length ? links[links.length - 1].reachable : false,
firstBreak: links.find((link) => !link.match) || null
};
}
function disposeGroup(group) {
group.traverse((object) => {
if (object.geometry) object.geometry.dispose();
if (object.material) {
const materials = Array.isArray(object.material)
? object.material
: [object.material];
materials.forEach((mat) => {
if (mat.map) mat.map.dispose();
mat.dispose();
});
}
});
group.clear();
}
function routeLine(a, b, color, dashed = false) {
const geometry = new THREE.BufferGeometry().setFromPoints([
new THREE.Vector3(a.x, 0.645, 0),
new THREE.Vector3(b.x, 0.645, 0)
]);
const options = {
color,
transparent: true,
opacity: dashed ? 0.9 : 0.72,
depthTest: false,
depthWrite: false
};
const line = dashed
? new THREE.Line(
geometry,
new THREE.LineDashedMaterial({
...options,
dashSize: 0.12,
gapSize: 0.075
})
)
: new THREE.Line(geometry, new THREE.LineBasicMaterial(options));
if (dashed) line.computeLineDistances();
line.renderOrder = 15;
routeRoot.add(line);
}
function buildRoute() {
disposeGroup(routeRoot);
state.pulses = [];
state.pathPoints = [];
state.breakMarker = null;
const analysis = state.analysis;
if (!state.userParts.length) {
const source = state.items[0];
const load = state.items[state.items.length - 1];
routeLine(
{ x: source.outWorld },
{ x: load.inWorld },
0xff657a,
true
);
const marker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.13),
material(0xff657a, {
emissive: 0xff657a,
emissiveIntensity: 0.9
})
);
marker.position.set(
(source.outWorld + load.inWorld) / 2,
1.13,
0
);
marker.renderOrder = 18;
routeRoot.add(marker);
state.breakMarker = marker;
return;
}
for (let i = 1; i < state.items.length; i++) {
const item = state.items[i];
const link = analysis.links[i - 1];
const previous = state.items[i - 1];
const good = link.match && link.reachable;
routeLine(
{ x: previous.outWorld },
{ x: item.inWorld },
good ? 0x70f0b3 : 0xff657a,
!good
);
}
state.items.forEach((item) => {
if (item.inWorld === null || item.outWorld === null) return;
routeLine(
{ x: item.inWorld },
{ x: item.outWorld },
item.reachable ? 0x70f0b3 : 0xff657a,
!item.reachable
);
});
if (analysis.valid) {
const points = [];
for (let i = 0; i < state.items.length; i++) {
const item = state.items[i];
if (i === 0) {
points.push(new THREE.Vector3(item.outWorld, 0.665, 0));
} else {
points.push(new THREE.Vector3(item.inWorld, 0.665, 0));
if (i < state.items.length - 1) {
points.push(new THREE.Vector3(item.outWorld, 0.665, 0));
}
}
}
state.pathPoints = points;
const pulseGeometry = new THREE.OctahedronGeometry(0.075);
const pulseMaterial = material(0x9cffff, {
emissive: 0x5ce1e6,
emissiveIntensity: 1.8,
roughness: 0.2
});
for (let i = 0; i < 7; i++) {
const pulse = new THREE.Mesh(pulseGeometry, pulseMaterial);
pulse.renderOrder = 19;
routeRoot.add(pulse);
state.pulses.push(pulse);
}
}
if (analysis.firstBreak) {
const link = analysis.firstBreak;
const from = state.items[link.fromIndex];
const to = state.items[link.toIndex];
const marker = new THREE.Mesh(
new THREE.OctahedronGeometry(0.13),
material(0xff657a, {
emissive: 0xff657a,
emissiveIntensity: 0.9
})
);
marker.position.set(
(from.outWorld + to.inWorld) / 2,
1.15,
0
);
marker.renderOrder = 18;
routeRoot.add(marker);
state.breakMarker = marker;
}
}
function rebuildChain() {
disposeGroup(chainRoot);
state.analysis = evaluateChain();
state.valid = state.analysis.valid;
state.items = [];
const gap = 0.1;
const total =
state.analysis.sequence.reduce(
(sum, entry) => sum + entry.def.span,
0
) +
gap * (state.analysis.sequence.length - 1);
let cursor = -total / 2;
state.analysis.sequence.forEach((entry) => {
const item = {
id: entry.id,
def: entry.def,
type: entry.type,
x: cursor + entry.def.span / 2,
reachable:
entry.type === "source"
? true
: state.analysis.links[entry.type === "load" ? -1 : state.analysis.sequence.indexOf(entry) - 1]
?.reachable ?? false
};
state.items.push(item);
createItemVisual(item);
cursor += entry.def.span + gap;
});
buildRoute();
renderUI();
}
// -------------------------------------------------------------------------
// UI
// -------------------------------------------------------------------------
function portBadge(standardId) {
const standard = STANDARD[standardId];
return `
<span
class="port-badge"
style="
--port-color:${standard.css};
--port-shape:${standard.shape};
"
></span>
`;
}
function buildInventory() {
Object.values(PARTS).forEach((part) => {
const card = document.createElement("article");
card.className = "part-card";
card.innerHTML = `
<div
class="part-visual"
style="
--port-color:${STANDARD[part.in].css};
--exit-color:${STANDARD[part.out].css};
--port-shape:${STANDARD[part.in].shape};
"
>
<div class="part-body"></div>
</div>
<div class="part-copy">
<strong>${part.name}</strong>
<span>${STANDARD[part.in].name} → ${STANDARD[part.out].name}</span>
</div>
<button class="add-button" aria-label="Add ${part.name}">+</button>
`;
card.querySelector(".add-button").addEventListener("click", () => {
addPart(part.id);
});
const target =
part.category === "adapter" ? $("#adapterList") : $("#moduleList");
target.appendChild(card);
});
}
function renderChainStrip() {
const strip = $("#chainStrip");
strip.innerHTML = "";
const analysis = state.analysis;
analysis.sequence.forEach((entry, index) => {
if (index > 0) {
const link = analysis.links[index - 1];
const connector = document.createElement("span");
connector.className = `chain-link ${
link.match && link.reachable ? "" : "bad"
}`;
connector.textContent = "›";
connector.title = link.match
? `${link.from.def.out.toUpperCase()} matches ${link.to.def.in.toUpperCase()}`
: `${link.from.def.out.toUpperCase()} does not match ${link.to.def.in.toUpperCase()}`;
strip.appendChild(connector);
}
const chip = document.createElement("div");
const removable = entry.type === "part";
const inputText = entry.type === "load"
? `${STANDARD[entry.def.in].name} IN`
: entry.def.in
? `${STANDARD[entry.def.in].name} → ${STANDARD[entry.def.out].name}`
: `${STANDARD[entry.def.out].name} OUT`;
const malformed =
entry.type === "part" &&
!analysis.links[index - 1]?.reachable;
chip.className = `chain-chip ${
entry.type === "load" && analysis.loadReachable ? "good" : ""
} ${malformed ? "bad" : ""}`;
chip.innerHTML = `
<strong>${entry.def.short}</strong>
<span>${inputText}</span>
${
removable
? `<button class="remove-piece" aria-label="Remove ${entry.def.name}">×</button>`
: ""
}
`;
if (removable) {
chip.querySelector(".remove-piece").addEventListener("click", () => {
state.userParts.splice(index - 1, 1);
rebuildChain();
notify("Part removed from chain.");
});
}
strip.appendChild(chip);
});
if (!state.userParts.length) {
const emptyLink = document.createElement("span");
emptyLink.className = "chain-link bad";
emptyLink.textContent = "›";
emptyLink.title = "No coupling installed";
const loadChip = strip.lastElementChild;
strip.insertBefore(emptyLink, loadChip);
}
}
function renderUI() {
const analysis = state.analysis;
const signalCard = $("#signalCard");
const signalText = $("#signalText");
const chainStatus = $("#chainStatus");
const chainNote = $("#chainNote");
signalCard.classList.toggle("good", analysis.valid);
chainStatus.classList.toggle("good", analysis.valid);
if (analysis.valid) {
signalText.textContent = "CONTINUOUS PATH";
chainStatus.textContent = "CONTINUOUS PATH";
chainNote.textContent =
"All couplings match. The drive signal reaches the load and motion is propagating through the full chain.";
} else if (!state.userParts.length) {
signalText.textContent = "AWAITING ROUTE";
chainStatus.textContent = "ROUTE INCOMPLETE";
chainNote.textContent =
"Add a coupling or module between the HEX drive and HEX load.";
} else {
const breakLink = analysis.firstBreak;
signalText.textContent = "TRANSMISSION BROKEN";
chainStatus.textContent = breakLink
? `BREAK: ${STANDARD[breakLink.from.def.out].name} ≠ ${STANDARD[breakLink.to.def.in].name}`
: "ROUTE INCOMPLETE";
chainNote.textContent = breakLink
? `The ${breakLink.from.def.short} output and ${breakLink.to.def.short} input use different standards. Remove a part or build a compatible route.`
: "The chain does not yet reach the load.";
}
renderChainStrip();
}
let toastTimer;
function notify(message, bad = false) {
const toast = $("#toast");
toast.textContent = message;
toast.classList.toggle("bad", bad);
toast.classList.add("show");
clearTimeout(toastTimer);
toastTimer = setTimeout(() => {
toast.classList.remove("show");
}, 2200);
}
function addPart(id) {
state.userParts.push(id);
rebuildChain();
const part = PARTS[id];
const analysis = state.analysis;
if (analysis.firstBreak) {
notify(
`${part.short} added, but the chain breaks at ${
analysis.firstBreak.from.def.short
} → ${analysis.firstBreak.to.def.short}.`,
true
);
} else {
notify(`${part.name} added to the transmission chain.`);
}
}
buildInventory();
$("#autoRoute").addEventListener("click", () => {
state.userParts = ["ht", "rotor", "sh"];
rebuildChain();
notify("Valid route assembled: HEX → TRI → STAR → HEX.");
});
$("#undo").addEventListener("click", () => {
if (!state.userParts.length) {
notify("The chain is already empty.");
return;
}
state.userParts.pop();
rebuildChain();
notify("Last part removed.");
});
$("#clear").addEventListener("click", () => {
state.userParts = [];
rebuildChain();
notify("Transmission chain cleared.");
});
$("#panelToggle").addEventListener("click", () => {
document.body.classList.toggle("panel-open");
});
rebuildChain();
// -------------------------------------------------------------------------
// Animation
// -------------------------------------------------------------------------
function samplePath(progress) {
const points = state.pathPoints;
if (points.length < 2) return new THREE.Vector3();
let totalLength = 0;
const lengths = [];
for (let i = 0; i < points.length - 1; i++) {
const length = points[i + 1].x - points[i].x;
lengths.push(length);
totalLength += length;
}
let remaining = progress * totalLength;
for (let i = 0; i < lengths.length; i++) {
if (remaining <= lengths[i]) {
const t = lengths[i] === 0 ? 0 : remaining / lengths[i];
return new THREE.Vector3().lerpVectors(points[i], points[i + 1], t);
}
remaining -= lengths[i];
}
return points[points.length - 1].clone();
}
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const dt = Math.min(clock.getDelta(), 0.05);
const elapsed = clock.elapsedTime;
state.items.forEach((item) => {
if (item.fan) {
item.fan.rotation.x += dt * 2.35;
}
if (item.gears.length && item.reachable) {
item.gears.forEach((gear) => {
gear.object.rotation.y += dt * gear.speed;
});
}
if (item.lamp) {
const lit = item.reachable;
item.lamp.material.color.setHex(lit ? 0x70f0b3 : 0xff657a);
item.lamp.material.emissive.setHex(lit ? 0x70f0b3 : 0xff657a);
item.lamp.material.emissiveIntensity = lit ? 1.1 : 0.65;
item.lamp.scale.setScalar(
1 + Math.sin(elapsed * (lit ? 5 : 2)) * (lit ? 0.08 : 0.025)
);
}
});
if (state.valid && state.pulses.length) {
state.pulses.forEach((pulse, index) => {
const progress =
(elapsed * 0.19 + index / state.pulses.length) % 1;
pulse.position.copy(samplePath(progress));
pulse.rotation.y += dt * 4;
pulse.rotation.z += dt * 2;
});
}
if (state.breakMarker) {
state.breakMarker.rotation.y += dt * 1.8;
state.breakMarker.position.y =
1.15 + Math.sin(elapsed * 4) * 0.045;
}
renderer.render(scene, camera);
}
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
});
animate();
requestAnimationFrame(() => {
$("#loading").classList.add("hidden");
setTimeout(() => $("#loading").remove(), 400);
});
</script>
</body>
</html>
```