Prompt specification
Build or customize the Three.js 3D scene "Supplier Links and Dependency Plugs" 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: Supplier Links and Dependency Plugs
Category: Art & Culture · Style: Procedural Solid / Shader 3D
License: MIT · Reference: https://three3d.app/scene/supplier-links-and-dependency-plugs-x3169
Scene Description Prompt:
Please use Three.js from cdnjs for a cutaway scene based on this idea: supplier links and dependency plugs. Model three component blocks connected to one assembly block by removable plugs. Removing a required input must leave a visible empty slot in the final product. Return one self-contained HTML file.
Working Three.js Starter (supplier-links-and-dependency-plugs-x3169):
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Dependency Plugs — Interactive Cutaway</title>
<style>
:root {
color-scheme: dark;
--bg: #07111d;
--panel: rgba(11, 25, 39, 0.82);
--border: rgba(155, 205, 225, 0.17);
--text: #e8f4fa;
--muted: #87a4b3;
--green: #56e6a5;
--red: #ff6278;
--amber: #ffc55c;
}
* { 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;
}
body { overscroll-behavior: none; }
#scene {
position: fixed;
inset: 0;
z-index: 0;
}
#scene canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
cursor: grab;
}
#scene canvas:active { cursor: grabbing; }
#labelLayer {
position: fixed;
inset: 0;
z-index: 3;
pointer-events: none;
overflow: hidden;
}
.masthead {
position: fixed;
z-index: 10;
top: 22px;
left: 24px;
max-width: 560px;
pointer-events: none;
text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}
.eyebrow {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 9px;
color: #9fc5d5;
font-size: 10px;
font-weight: 800;
letter-spacing: 0.22em;
text-transform: uppercase;
}
.eyebrow::before {
content: "";
width: 24px;
height: 2px;
background: #4dd4dc;
box-shadow: 0 0 12px rgba(77, 212, 220, 0.7);
}
h1 {
margin: 0;
font-size: clamp(27px, 3.3vw, 48px);
line-height: 0.98;
letter-spacing: -0.055em;
font-weight: 760;
}
.masthead p {
max-width: 500px;
margin: 12px 0 0;
color: #a9c1ce;
font-size: 13px;
line-height: 1.55;
}
.panel {
border: 1px solid var(--border);
border-radius: 16px;
background: var(--panel);
box-shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
}
#statusPanel {
position: fixed;
z-index: 12;
top: 22px;
right: 24px;
width: 300px;
padding: 17px 18px 16px;
}
.panel-label {
color: #8da9b8;
font-size: 9px;
font-weight: 800;
letter-spacing: 0.18em;
text-transform: uppercase;
}
.status-line {
display: flex;
align-items: center;
gap: 10px;
margin-top: 10px;
}
#statusDot {
width: 10px;
height: 10px;
flex: 0 0 auto;
border-radius: 50%;
background: var(--green);
box-shadow: 0 0 16px currentColor;
color: var(--green);
}
#statusTitle {
font-size: 13px;
line-height: 1.2;
letter-spacing: 0.025em;
}
#statusCopy {
min-height: 38px;
margin: 10px 0 13px;
color: #9bb2bf;
font-size: 11px;
line-height: 1.55;
}
.progress {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 5px;
}
.progress span {
height: 4px;
border-radius: 999px;
background: var(--green);
box-shadow: 0 0 10px rgba(86, 230, 165, 0.28);
transition: background 250ms, box-shadow 250ms;
}
.progress span.missing {
background: var(--red);
box-shadow: 0 0 10px rgba(255, 98, 120, 0.35);
}
.completion-row {
display: flex;
justify-content: space-between;
margin-top: 8px;
color: #718e9d;
font-size: 9px;
font-weight: 700;
letter-spacing: 0.08em;
text-transform: uppercase;
}
#completionCount { color: #b9cfda; }
#controls {
position: fixed;
z-index: 20;
left: 24px;
bottom: 22px;
width: 430px;
padding: 15px;
}
.control-heading {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.control-heading strong {
font-size: 11px;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.control-heading small {
color: #76909e;
font-size: 9px;
}
#plugButtons {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 7px;
}
.plug-button {
position: relative;
display: grid;
grid-template-columns: 9px 1fr;
grid-template-rows: auto auto;
column-gap: 8px;
min-width: 0;
padding: 10px 9px;
border: 1px solid rgba(151, 194, 213, 0.15);
border-radius: 11px;
background: rgba(255, 255, 255, 0.035);
color: var(--text);
font: inherit;
text-align: left;
cursor: pointer;
transition: border-color 160ms, background 160ms, transform 160ms;
}
.plug-button:hover {
transform: translateY(-1px);
border-color: rgba(151, 194, 213, 0.38);
background: rgba(255, 255, 255, 0.065);
}
.plug-button:focus-visible {
outline: 2px solid #55d8e0;
outline-offset: 2px;
}
.plug-button.is-missing {
border-color: rgba(255, 98, 120, 0.48);
background: rgba(255, 98, 120, 0.065);
}
.plug-swatch {
grid-row: 1 / 3;
width: 8px;
height: 28px;
align-self: center;
border-radius: 999px;
background: var(--accent);
box-shadow: 0 0 13px color-mix(in srgb, var(--accent) 65%, transparent);
}
.plug-copy { min-width: 0; }
.plug-copy strong {
display: block;
overflow: hidden;
font-size: 11px;
white-space: nowrap;
text-overflow: ellipsis;
}
.link-state {
display: block;
margin-top: 3px;
color: #87a2b1;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.12em;
}
.is-missing .link-state { color: var(--red); }
.link-action {
grid-column: 2;
margin-top: 7px;
color: #6e8997;
font-size: 8px;
font-weight: 800;
letter-spacing: 0.08em;
}
.control-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 11px;
}
.control-footer p {
margin: 0;
color: #748f9d;
font-size: 9px;
line-height: 1.45;
}
.mini-button {
flex: 0 0 auto;
padding: 8px 10px;
border: 1px solid rgba(113, 219, 225, 0.32);
border-radius: 8px;
background: rgba(67, 207, 215, 0.08);
color: #aeeef1;
font: inherit;
font-size: 9px;
font-weight: 750;
letter-spacing: 0.05em;
cursor: pointer;
}
.mini-button:hover { background: rgba(67, 207, 215, 0.16); }
.mini-button:disabled { opacity: 0.35; cursor: default; }
#legend {
position: fixed;
z-index: 10;
right: 24px;
bottom: 22px;
width: 210px;
padding: 13px 15px;
pointer-events: none;
}
.legend-row {
display: flex;
align-items: center;
gap: 9px;
margin-top: 8px;
color: #91a9b6;
font-size: 9px;
}
.legend-row:first-of-type { margin-top: 10px; }
.legend-symbol {
width: 19px;
height: 9px;
border: 2px solid #46d8df;
border-radius: 3px;
}
.legend-symbol.empty {
border-color: var(--red);
box-shadow: 0 0 8px rgba(255, 98, 120, 0.38);
}
.legend-symbol.shell {
border-color: rgba(130, 196, 219, 0.45);
border-style: dashed;
}
.scene-tag {
position: absolute;
transform: translate(-50%, -50%);
white-space: nowrap;
transition: opacity 100ms;
}
.supplier-tag,
.assembly-tag {
padding: 7px 10px;
border: 1px solid rgba(133, 184, 205, 0.22);
border-radius: 8px;
background: rgba(7, 17, 29, 0.78);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
backdrop-filter: blur(8px);
text-align: center;
}
.supplier-tag::before {
content: "";
display: inline-block;
width: 6px;
height: 6px;
margin-right: 6px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 8px var(--accent);
vertical-align: 1px;
}
.supplier-tag strong,
.assembly-tag strong {
font-size: 9px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.supplier-tag small,
.assembly-tag small {
display: block;
margin-top: 3px;
color: #7f9aa8;
font-size: 7px;
font-weight: 750;
letter-spacing: 0.09em;
text-transform: uppercase;
}
.assembly-tag {
border-color: rgba(86, 230, 165, 0.28);
}
.empty-tag {
display: none;
padding: 5px 8px;
border: 1px solid rgba(255, 98, 120, 0.62);
border-radius: 6px;
background: rgba(72, 10, 24, 0.9);
color: #ff9aaa;
font-size: 8px;
font-weight: 850;
letter-spacing: 0.1em;
text-transform: uppercase;
box-shadow: 0 0 18px rgba(255, 98, 120, 0.22);
}
@media (max-width: 820px) {
.masthead {
top: 14px;
left: 14px;
max-width: calc(100vw - 28px);
}
.masthead p { display: none; }
#statusPanel {
top: 95px;
right: 12px;
width: 235px;
padding: 13px;
}
#statusCopy { display: none; }
#controls {
left: 12px;
right: 12px;
bottom: 12px;
width: auto;
padding: 11px;
}
#legend { display: none; }
.control-heading small { display: none; }
.control-footer p { max-width: 210px; }
}
@media (max-width: 480px) {
#statusPanel {
top: 87px;
width: 205px;
}
#plugButtons { gap: 5px; }
.plug-button {
grid-template-columns: 1fr;
padding: 8px;
}
.plug-swatch {
grid-row: auto;
width: 22px;
height: 4px;
margin-bottom: 7px;
}
.link-action { display: none; }
.control-footer p { max-width: 155px; }
}
</style>
</head>
<body>
<div id="scene"></div>
<div id="labelLayer">
<div id="assemblyTag" class="scene-tag assembly-tag">
<strong>Final Assembly</strong>
<small>Cutaway / required inputs</small>
</div>
</div>
<header class="masthead">
<div class="eyebrow">Supply Chain Cutaway</div>
<h1>Dependency Plugs</h1>
<p>
Three upstream component suppliers feed one final assembly through removable,
required links. Pull any required plug and its empty receiving slot remains visible.
</p>
</header>
<section id="statusPanel" class="panel" aria-live="polite">
<div class="panel-label">Final Product Status</div>
<div class="status-line">
<span id="statusDot"></span>
<strong id="statusTitle">FINAL PRODUCT COMPLETE</strong>
</div>
<p id="statusCopy">
All three required inputs are seated. The final product is ready for release.
</p>
<div id="progress" class="progress">
<span></span><span></span><span></span>
</div>
<div class="completion-row">
<span>Required inputs</span>
<span id="completionCount">3 / 3 connected</span>
</div>
</section>
<section id="controls" class="panel">
<div class="control-heading">
<strong>Dependency Plugs</strong>
<small>Click a plug in the scene or use a button</small>
</div>
<div id="plugButtons"></div>
<div class="control-footer">
<p>Drag to orbit · Scroll to zoom · Click a plug to remove or restore it.</p>
<button id="restoreAll" class="mini-button" type="button">RESTORE ALL</button>
</div>
</section>
<aside id="legend" class="panel">
<div class="panel-label">Scene Key</div>
<div class="legend-row"><span class="legend-symbol"></span>Removable dependency link</div>
<div class="legend-row"><span class="legend-symbol empty"></span>Required empty slot</div>
<div class="legend-row"><span class="legend-symbol shell"></span>Removed cutaway cover</div>
</aside>
<script type="module">
import * as THREE from "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js";
const sceneHost = document.getElementById("scene");
const labelLayer = document.getElementById("labelLayer");
const statusPanel = document.getElementById("statusPanel");
const statusDot = document.getElementById("statusDot");
const statusTitle = document.getElementById("statusTitle");
const statusCopy = document.getElementById("statusCopy");
const completionCount = document.getElementById("completionCount");
const progressSegments = [...document.querySelectorAll("#progress span")];
const plugButtonsHost = document.getElementById("plugButtons");
const restoreAllButton = document.getElementById("restoreAll");
const COLORS = [0xffb24a, 0x35d6d0, 0xb77cff];
const COLOR_CSS = ["#ffb24a", "#35d6d0", "#b77cff"];
const LETTERS = ["A", "B", "C"];
const SLOT_X = [-1.45, 0, 1.45];
const ASSEMBLY_Z = -1.1;
const SOCKET_Y = 1.42;
const SOCKET_WORLD_Z = 0.44;
const PLUG_INSERTED_Z = 0.74;
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.12;
renderer.domElement.setAttribute("aria-label", "Interactive 3D dependency plug cutaway");
sceneHost.appendChild(renderer.domElement);
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x07111d);
scene.fog = new THREE.Fog(0x07111d, 16, 34);
const camera = new THREE.PerspectiveCamera(
42,
window.innerWidth / window.innerHeight,
0.1,
80
);
const orbit = {
target: new THREE.Vector3(0, 0.8, 0.8),
theta: 0.48,
phi: 1.0,
radius: window.innerWidth < 820 ? 22 : 18.5
};
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);
camera.updateMatrixWorld();
}
updateCamera();
const hemi = new THREE.HemisphereLight(0xa7dcff, 0x08111a, 1.7);
scene.add(hemi);
const keyLight = new THREE.DirectionalLight(0xffffff, 3.2);
keyLight.position.set(7, 13, 9);
keyLight.castShadow = true;
keyLight.shadow.mapSize.set(2048, 2048);
keyLight.shadow.camera.left = -12;
keyLight.shadow.camera.right = 12;
keyLight.shadow.camera.top = 12;
keyLight.shadow.camera.bottom = -12;
keyLight.shadow.bias = -0.0008;
scene.add(keyLight);
const fillLight = new THREE.DirectionalLight(0x4c9dff, 1.5);
fillLight.position.set(-9, 7, -5);
scene.add(fillLight);
const rimLight = new THREE.PointLight(0x35d6d0, 18, 16, 2);
rimLight.position.set(-4, 4, -2);
scene.add(rimLight);
const groundMaterial = new THREE.MeshStandardMaterial({
color: 0x08131f,
roughness: 0.93,
metalness: 0.05
});
const ground = new THREE.Mesh(new THREE.PlaneGeometry(50, 50), groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.position.y = -0.025;
ground.receiveShadow = true;
scene.add(ground);
const grid = new THREE.GridHelper(40, 40, 0x285064, 0x142b38);
grid.position.y = -0.005;
grid.material.transparent = true;
grid.material.opacity = 0.32;
scene.add(grid);
const metal = new THREE.MeshStandardMaterial({
color: 0x203548,
metalness: 0.76,
roughness: 0.3
});
const darkMetal = new THREE.MeshStandardMaterial({
color: 0x101d29,
metalness: 0.72,
roughness: 0.35
});
const edgeMetal = new THREE.MeshStandardMaterial({
color: 0x38566b,
metalness: 0.8,
roughness: 0.23
});
const black = new THREE.MeshStandardMaterial({
color: 0x02070b,
metalness: 0.12,
roughness: 0.72
});
const gold = new THREE.MeshStandardMaterial({
color: 0xd6a84e,
metalness: 0.85,
roughness: 0.25
});
function roundedGeometry(width, height, depth, radius = 0.1) {
const r = Math.min(radius, width / 2, height / 2);
const shape = new THREE.Shape();
const x = -width / 2;
const y = -height / 2;
shape.moveTo(x + r, y);
shape.lineTo(x + width - r, y);
shape.quadraticCurveTo(x + width, y, x + width, y + r);
shape.lineTo(x + width, y + height - r);
shape.quadraticCurveTo(x + width, y + height, x + width - r, y + height);
shape.lineTo(x + r, y + height);
shape.quadraticCurveTo(x, y + height, x, y + height - r);
shape.lineTo(x, y + r);
shape.quadraticCurveTo(x, y, x + r, y);
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: false,
curveSegments: 8,
steps: 1
});
geometry.translate(0, 0, -depth / 2);
geometry.computeVertexNormals();
return geometry;
}
function addMesh(geometry, material, parent, x = 0, y = 0, z = 0) {
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
mesh.castShadow = true;
mesh.receiveShadow = true;
parent.add(mesh);
return mesh;
}
function addBox(parent, w, h, d, material, x = 0, y = 0, z = 0) {
return addMesh(new THREE.BoxGeometry(w, h, d), material, parent, x, y, z);
}
function addRounded(parent, w, h, d, radius, material, x = 0, y = 0, z = 0) {
return addMesh(roundedGeometry(w, h, d, radius), material, parent, x, y, z);
}
function addEdges(mesh, color, opacity = 0.35) {
const edges = new THREE.LineSegments(
new THREE.EdgesGeometry(mesh.geometry, 28),
new THREE.LineBasicMaterial({
color,
transparent: true,
opacity
})
);
mesh.add(edges);
return edges;
}
function makeBadgeTexture(text, color) {
const canvas = document.createElement("canvas");
canvas.width = 256;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(5, 15, 24, 0.94)";
ctx.fillRect(0, 0, 256, 128);
ctx.strokeStyle = color;
ctx.lineWidth = 7;
ctx.strokeRect(4, 4, 248, 120);
ctx.fillStyle = color;
ctx.font = "800 62px system-ui, sans-serif";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(text, 128, 66);
const texture = new THREE.CanvasTexture(canvas);
texture.colorSpace = THREE.SRGBColorSpace;
texture.anisotropy = Math.min(8, renderer.capabilities.getMaxAnisotropy());
return texture;
}
function addBadge(parent, text, color, x, y, z, width = 0.52, height = 0.27) {
const texture = makeBadgeTexture(text, color);
const material = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
depthWrite: false,
toneMapped: false
});
const badge = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
badge.position.set(x, y, z);
parent.add(badge);
return badge;
}
const suppliers = [];
const supplierLabels = [];
const supplierPositions = [
new THREE.Vector3(-4.45, 0, 2.7),
new THREE.Vector3(0, 0, 2.7),
new THREE.Vector3(4.45, 0, 2.7)
];
for (let i = 0; i < 3; i++) {
const group = new THREE.Group();
group.position.copy(supplierPositions[i]);
scene.add(group);
const accent = new THREE.Color(COLORS[i]);
const bodyMaterial = new THREE.MeshStandardMaterial({
color: accent.clone().lerp(new THREE.Color(0x162a39), 0.72),
metalness: 0.56,
roughness: 0.4
});
const accentMaterial = new THREE.MeshStandardMaterial({
color: accent,
emissive: accent,
emissiveIntensity: 0.12,
metalness: 0.38,
roughness: 0.3
});
const base = addMesh(
new THREE.CylinderGeometry(1.14, 1.2, 0.18, 48),
darkMetal,
group,
0,
0.09,
0
);
addEdges(base, COLORS[i], 0.22);
const baseRing = addMesh(
new THREE.TorusGeometry(1.06, 0.025, 8, 64),
accentMaterial,
group,
0,
0.19,
0
);
baseRing.rotation.x = Math.PI / 2;
const body = addRounded(group, 2.2, 1.35, 1.5, 0.16, bodyMaterial, 0, 0.92, 0);
addEdges(body, COLORS[i], 0.43);
addRounded(group, 2.0, 0.12, 1.31, 0.05, edgeMetal, 0, 1.64, 0);
addBox(group, 1.48, 0.06, 0.035, accentMaterial, 0, 1.72, 0.08);
const frontPanel = addRounded(
group, 1.5, 0.58, 0.07, 0.07, darkMetal, 0, 0.98, 0.775
);
addEdges(frontPanel, COLORS[i], 0.3);
for (let line = 0; line < 4; line++) {
addBox(
group,
0.83 - line * 0.12,
0.025,
0.025,
line === 3 ? accentMaterial : edgeMetal,
-0.18,
1.12 - line * 0.09,
0.825
);
}
const port = addMesh(
new THREE.CylinderGeometry(0.19, 0.22, 0.36, 28),
edgeMetal,
group,
0,
0.82,
0.9
);
port.rotation.x = Math.PI / 2;
const portRing = addMesh(
new THREE.TorusGeometry(0.18, 0.032, 8, 32),
accentMaterial,
group,
0,
0.82,
1.085
);
const indicator = addMesh(
new THREE.SphereGeometry(0.075, 16, 12),
accentMaterial,
group,
0.72,
1.73,
0.2
);
indicator.castShadow = false;
const label = document.createElement("div");
label.className = "scene-tag supplier-tag";
label.style.setProperty("--accent", COLOR_CSS[i]);
label.innerHTML = `
<strong>Supplier ${LETTERS[i]}</strong>
<small class="supplier-state">Required input · seated</small>
`;
labelLayer.appendChild(label);
const dockPosition = new THREE.Vector3(
supplierPositions[i].x,
0.27,
4.22
);
const dockPad = addMesh(
new THREE.CylinderGeometry(0.59, 0.63, 0.04, 40),
new THREE.MeshStandardMaterial({
color: 0x0d1a25,
metalness: 0.55,
roughness: 0.5
}),
scene,
dockPosition.x,
0.015,
dockPosition.z
);
const dockRingMaterial = new THREE.MeshBasicMaterial({
color: COLORS[i],
transparent: true,
opacity: 0.38
});
const dockRing = addMesh(
new THREE.TorusGeometry(0.56, 0.022, 8, 48),
dockRingMaterial,
scene,
dockPosition.x,
0.045,
dockPosition.z
);
dockRing.rotation.x = Math.PI / 2;
suppliers.push({
group,
body,
port,
portPosition: new THREE.Vector3(
supplierPositions[i].x,
0.82,
3.61
),
dockPosition,
dockRingMaterial
});
supplierLabels.push(label);
}
const assembly = new THREE.Group();
assembly.position.z = ASSEMBLY_Z;
scene.add(assembly);
const assemblyBase = addRounded(
assembly, 5.65, 0.34, 3.18, 0.14, metal, 0, 0.18, 0
);
addEdges(assemblyBase, 0x6f9eb1, 0.32);
const backPanel = addBox(assembly, 5.48, 2.43, 0.16, metal, 0, 1.46, -1.49);
addEdges(backPanel, 0x52768a, 0.25);
const leftPanel = addBox(assembly, 0.16, 2.43, 3.0, metal, -2.68, 1.46, 0);
addEdges(leftPanel, 0x52768a, 0.25);
const rightLowerPanel = addBox(
assembly, 0.16, 0.78, 3.0, edgeMetal, 2.68, 0.72, 0
);
addEdges(rightLowerPanel, 0x6f9eb1, 0.22);
addBox(assembly, 5.48, 0.25, 0.18, edgeMetal, 0, 2.61, 1.49);
addBox(assembly, 5.48, 0.23, 0.18, metal, 0, 0.40, 1.49);
addBox(assembly, 0.16, 2.16, 0.18, edgeMetal, -2.67, 1.50, 1.49);
addBox(assembly, 0.16, 2.16, 0.18, edgeMetal, 2.67, 1.50, 1.49);
const cutMaterial = new THREE.MeshBasicMaterial({
color: 0xffb24a,
transparent: true,
opacity: 0.76
});
addBox(assembly, 0.06, 2.35, 0.06, cutMaterial, -2.58, 1.47, -1.39);
addBox(assembly, 0.06, 0.06, 2.86, cutMaterial, -2.58, 2.62, -0.04);
const shellGeometry = new THREE.BoxGeometry(5.52, 2.52, 3.04);
const shellEdges = new THREE.LineSegments(
new THREE.EdgesGeometry(shellGeometry),
new THREE.LineBasicMaterial({
color: 0x73c9dc,
transparent: true,
opacity: 0.16
})
);
shellEdges.position.set(0, 1.48, 0);
assembly.add(shellEdges);
const coverMaterial = new THREE.MeshPhysicalMaterial({
color: 0x5dc8df,
transparent: true,
opacity: 0.065,
metalness: 0.25,
roughness: 0.22,
depthWrite: false,
side: THREE.DoubleSide
});
const floatingCover = addRounded(
assembly, 5.45, 0.075, 3.0, 0.1, coverMaterial, 0, 3.15, -0.03
);
floatingCover.rotation.z = 0.025;
floatingCover.castShadow = false;
const floatingCoverEdges = addEdges(floatingCover, 0x67d6e4, 0.24);
floatingCoverEdges.material.depthWrite = false;
const boardMaterial = new THREE.MeshStandardMaterial({
color: 0x12352f,
metalness: 0.42,
roughness: 0.48
});
addBox(assembly, 4.85, 0.07, 2.25, boardMaterial, 0, 0.42, -0.15);
const traceMaterial = new THREE.MeshBasicMaterial({
color: 0x2a8f85,
transparent: true,
opacity: 0.62
});
for (let i = 0; i < 9; i++) {
const x = -2.0 + i * 0.48;
addBox(assembly, 0.025, 0.012, 1.6 - (i % 3) * 0.18,
traceMaterial, x, 0.465, -0.25);
}
const slotFrames = [];
const emptyFrames = [];
const emptyLabels = [];
for (let i = 0; i < 3; i++) {
const x = SLOT_X[i];
const processorMaterial = new THREE.MeshPhysicalMaterial({
color: 0x244a5d,
metalness: 0.4,
roughness: 0.28,
transparent: true,
opacity: 0.73
});
const processor = addRounded(
assembly, 0.95, 1.18, 0.76, 0.09, processorMaterial, x, 1.04, -0.54
);
addEdges(processor, COLORS[i], 0.3);
const coreMaterial = new THREE.MeshStandardMaterial({
color: COLORS[i],
emissive: COLORS[i],
emissiveIntensity: 0.48,
metalness: 0.25,
roughness: 0.3
});
addRounded(assembly, 0.54, 0.58, 0.83, 0.07, coreMaterial, x, 1.1, -0.5);
addBox(assembly, 0.88, 1.08, 0.06, black, x, SOCKET_Y, 1.46);
const frameGroup = new THREE.Group();
assembly.add(frameGroup);
addBox(frameGroup, 0.12, 1.35, 0.16, darkMetal, x - 0.5, SOCKET_Y, 1.58);
addBox(frameGroup, 0.12, 1.35, 0.16, darkMetal, x + 0.5, SOCKET_Y, 1.58);
addBox(frameGroup, 0.88, 0.12, 0.16, edgeMetal, x, SOCKET_Y + 0.615, 1.58);
addBox(frameGroup, 0.88, 0.12, 0.16, edgeMetal, x, SOCKET_Y - 0.615, 1.58);
for (let contact = 0; contact < 3; contact++) {
addBox(
frameGroup,
0.1,
0.18,
0.035,
gold,
x - 0.18 + contact * 0.18,
SOCKET_Y - 0.36,
1.515
);
}
const emptyMaterial = new THREE.MeshBasicMaterial({
color: 0xff526e,
transparent: true,
opacity: 0.9,
depthWrite: false
});
const emptyGroup = new THREE.Group();
assembly.add(emptyGroup);
addBox(emptyGroup, 0.045, 1.43, 0.025, emptyMaterial, x - 0.57, SOCKET_Y, 1.69);
addBox(emptyGroup, 0.045, 1.43, 0.025, emptyMaterial, x + 0.57, SOCKET_Y, 1.69);
addBox(emptyGroup, 1.16, 0.045, 0.025, emptyMaterial, x, SOCKET_Y + 0.69, 1.69);
addBox(emptyGroup, 1.16, 0.045, 0.025, emptyMaterial, x, SOCKET_Y - 0.69, 1.69);
emptyGroup.visible = false;
addBadge(
assembly,
LETTERS[i],
COLOR_CSS[i],
x,
2.31,
1.64,
0.46,
0.23
);
const emptyLabel = document.createElement("div");
emptyLabel.className = "scene-tag empty-tag";
emptyLabel.textContent = "Empty slot · required";
labelLayer.appendChild(emptyLabel);
slotFrames.push(frameGroup);
emptyFrames.push({ group: emptyGroup, material: emptyMaterial });
emptyLabels.push(emptyLabel);
}
const beaconGroup = new THREE.Group();
beaconGroup.position.set(2.2, 2.77, -0.72);
assembly.add(beaconGroup);
addMesh(
new THREE.CylinderGeometry(0.19, 0.22, 0.12, 24),
darkMetal,
beaconGroup,
0,
0,
0
);
const beaconMaterial = new THREE.MeshStandardMaterial({
color: 0x56e6a5,
emissive: 0x56e6a5,
emissiveIntensity: 2.4,
metalness: 0.05,
roughness: 0.22
});
addMesh(
new THREE.CylinderGeometry(0.12, 0.15, 0.34, 24),
beaconMaterial,
beaconGroup,
0,
0.2,
0
);
const beaconLight = new THREE.PointLight(0x56e6a5, 2.2, 4, 2);
beaconLight.position.set(0, 0.3, 0);
beaconGroup.add(beaconLight);
const plugs = [];
const pickablePlugMeshes = [];
for (let i = 0; i < 3; i++) {
const group = new THREE.Group();
scene.add(group);
const accentMaterial = new THREE.MeshStandardMaterial({
color: COLORS[i],
emissive: COLORS[i],
emissiveIntensity: 0.1,
metalness: 0.38,
roughness: 0.31
});
const body = addRounded(
group, 0.74, 0.9, 0.38, 0.1, accentMaterial
);
body.userData.plugIndex = i;
pickablePlugMeshes.push(body);
addEdges(body, 0xffffff, 0.18);
addRounded(group, 0.49, 0.55, 0.035, 0.06, darkMetal, 0, -0.01, 0.205);
for (let ridge = 0; ridge < 3; ridge++) {
addBox(
group,
0.38,
0.035,
0.04,
edgeMetal,
0,
-0.13 + ridge * 0.12,
0.235
);
}
addRounded(group, 0.25, 0.12, 0.12, 0.035, darkMetal, 0, 0.48, 0.01);
const ledMaterial = new THREE.MeshStandardMaterial({
color: 0xe9ffff,
emissive: 0xbffaff,
emissiveIntensity: 1.3
});
const led = addMesh(
new THREE.SphereGeometry(0.052, 14, 10),
ledMaterial,
group,
0,
0.26,
0.225
);
led.castShadow = false;
const insertedPosition = new THREE.Vector3(
SLOT_X[i],
SOCKET_Y,
PLUG_INSERTED_Z
);
group.position.copy(insertedPosition);
const removedQuaternion = new THREE.Quaternion().setFromEuler(
new THREE.Euler(-Math.PI / 2, 0, (i - 1) * 0.06)
);
plugs.push({
group,
body,
insertedPosition,
removedPosition: suppliers[i].dockPosition.clone(),
removedQuaternion,
removed: false,
transition: null,
cableFactor: 1,
cable: null,
cableCurve: null,
particles: []
});
}
function makeCableMaterial(color) {
return new THREE.MeshStandardMaterial({
color: new THREE.Color(color).lerp(new THREE.Color(0x08131c), 0.55),
metalness: 0.24,
roughness: 0.56
});
}
for (let i = 0; i < 3; i++) {
const plug = plugs[i];
const cableMaterial = makeCableMaterial(COLORS[i]);
const cable = new THREE.Mesh(
new THREE.BufferGeometry(),
cableMaterial
);
cable.castShadow = true;
cable.receiveShadow = true;
scene.add(cable);
plug.cable = cable;
for (let p = 0; p < 3; p++) {
const particleMaterial = new THREE.MeshBasicMaterial({
color: COLORS[i],
toneMapped: false
});
const particle = new THREE.Mesh(
new THREE.SphereGeometry(0.055, 12, 8),
particleMaterial
);
particle.visible = false;
scene.add(particle);
plug.particles.push(particle);
}
updateCable(i, 1);
}
function updateCable(index, factor) {
const plug = plugs[index];
const supplier = suppliers[index];
const factorClamped = THREE.MathUtils.clamp(factor, 0, 1);
const port = supplier.portPosition;
const fullEnd = new THREE.Vector3(
SLOT_X[index],
SOCKET_Y,
0.515
);
const retractedEnd = port.clone().add(new THREE.Vector3(0, 0.13, -0.3));
const p0 = port.clone();
const p1 = port.clone().add(new THREE.Vector3(0, -0.38, 0.2));
const p2 = retractedEnd.clone().lerp(
new THREE.Vector3(SLOT_X[index], 0.52, 1.2),
factorClamped
);
const p3 = retractedEnd.clone().lerp(fullEnd, factorClamped);
const curve = new THREE.CatmullRomCurve3(
[p0, p1, p2, p3],
false,
"catmullrom",
0.42
);
const geometry = new THREE.TubeGeometry(curve, 48, 0.073, 8, false);
plug.cable.geometry.dispose();
plug.cable.geometry = geometry;
plug.cableCurve = curve;
plug.cableFactor = factorClamped;
}
const buttons = [];
for (let i = 0; i < 3; i++) {
const button = document.createElement("button");
button.type = "button";
button.className = "plug-button";
button.style.setProperty("--accent", COLOR_CSS[i]);
button.innerHTML = `
<span class="plug-swatch"></span>
<span class="plug-copy">
<strong>Link ${LETTERS[i]}</strong>
<small class="link-state">SEATED</small>
</span>
<span class="link-action">REMOVE</span>
`;
button.addEventListener("click", () => togglePlug(i));
plugButtonsHost.appendChild(button);
buttons.push(button);
}
function isMissing(index) {
const plug = plugs[index];
return plug.transition
? plug.transition.targetRemoved
: plug.removed;
}
function refreshStatus() {
const missing = plugs
.map((_, index) => isMissing(index))
.filter(Boolean);
const moving = plugs.some((plug) => plug.transition);
const connected = 3 - missing.length;
for (let i = 0; i < 3; i++) {
const missingLink = isMissing(i);
const movingLink = Boolean(plugs[i].transition);
buttons[i].classList.toggle("is-missing", missingLink);
buttons[i].querySelector(".link-state").textContent =
movingLink ? "MOVING" : missingLink ? "REMOVED" : "SEATED";
buttons[i].querySelector(".link-action").textContent =
missingLink ? "RESTORE" : "REMOVE";
buttons[i].disabled = movingLink;
progressSegments[i].classList.toggle("missing", missingLink);
suppliers[i].dockRingMaterial.color.setHex(
missingLink ? 0xff526e : COLORS[i]
);
suppliers[i].dockRingMaterial.opacity = missingLink ? 0.92 : 0.38;
supplierLabels[i].querySelector(".supplier-state").textContent =
missingLink
? "Required input · detached"
: "Required input · seated";
}
completionCount.textContent = `${connected} / 3 connected`;
restoreAllButton.disabled = missing.length === 0 || moving;
if (missing.length > 0) {
const names = missing.map((_, index) => LETTERS[index]).join(", ");
statusTitle.textContent = "FINAL PRODUCT INCOMPLETE";
statusCopy.textContent =
`Required input${missing.length > 1 ? "s" : ""} ${names} ` +
`${missing.length > 1 ? "are" : "is"} missing. ` +
`The corresponding empty slot${missing.length > 1 ? "s remain" : " remains"} visible in the final product.`;
statusDot.style.color = "#ff6278";
statusDot.style.background = "#ff6278";
statusPanel.dataset.state = "incomplete";
} else if (moving) {
statusTitle.textContent = "RECONNECTING INPUTS";
statusCopy.textContent =
"The dependency plugs are returning to their required receiving slots.";
statusDot.style.color = "#ffc55c";
statusDot.style.background = "#ffc55c";
statusPanel.dataset.state = "moving";
} else {
statusTitle.textContent = "FINAL PRODUCT COMPLETE";
statusCopy.textContent =
"All three required inputs are seated. The final product is ready for release.";
statusDot.style.color = "#56e6a5";
statusDot.style.background = "#56e6a5";
statusPanel.dataset.state = "complete";
}
}
function togglePlug(index) {
const plug = plugs[index];
if (plug.transition) return;
const targetRemoved = !plug.removed;
const now = performance.now();
plug.transition = {
start: now,
duration: targetRemoved ? 1050 : 1200,
fromPosition: plug.group.position.clone(),
fromQuaternion: plug.group.quaternion.clone(),
toPosition: targetRemoved
? plug.removedPosition.clone()
: plug.insertedPosition.clone(),
toQuaternion: targetRemoved
? plug.removedQuaternion.clone()
: new THREE.Quaternion(),
targetRemoved
};
refreshStatus();
}
restoreAllButton.addEventListener("click", () => {
plugs.forEach((plug, index) => {
if (isMissing(index) && !plug.transition) togglePlug(index);
});
});
function smoothStep(min, max, value) {
const t = THREE.MathUtils.clamp((value - min) / (max - min), 0, 1);
return t * t * (3 - 2 * t);
}
function updateTransitions(now) {
for (let i = 0; i < plugs.length; i++) {
const plug = plugs[i];
if (!plug.transition) continue;
const transition = plug.transition;
const raw = THREE.MathUtils.clamp(
(now - transition.start) / transition.duration,
0,
1
);
const eased = raw * raw * (3 - 2 * raw);
plug.group.position.lerpVectors(
transition.fromPosition,
transition.toPosition,
eased
);
plug.group.position.y += Math.sin(Math.PI * raw) * 1.15;
plug.group.quaternion.slerpQuaternions(
transition.fromQuaternion,
transition.toQuaternion,
eased
);
const cableFactor = transition.targetRemoved
? 1 - smoothStep(0.12, 0.82, raw)
: smoothStep(0.18, 1, raw);
if (Math.abs(cableFactor - plug.cableFactor) > 0.002) {
updateCable(i, cableFactor);
}
if (raw >= 1) {
plug.removed = transition.targetRemoved;
plug.transition = null;
plug.group.position.copy(
plug.removed ? plug.removedPosition : plug.insertedPosition
);
plug.group.quaternion.copy(
plug.removed ? plug.removedQuaternion : new THREE.Quaternion()
);
updateCable(i, plug.removed ? 0 : 1);
refreshStatus();
}
}
}
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
const pointerDown = { x: 0, y: 0, moved: 0, active: false };
let hoveringPlug = false;
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;
}
function plugAtPointer(event) {
setPointer(event);
raycaster.setFromCamera(pointer, camera);
const hits = raycaster.intersectObjects(pickablePlugMeshes, false);
return hits.length ? hits[0].object.userData.plugIndex : null;
}
renderer.domElement.addEventListener("pointerdown", (event) => {
pointerDown.x = event.clientX;
pointerDown.y = event.clientY;
pointerDown.moved = 0;
pointerDown.active = true;
renderer.domElement.setPointerCapture(event.pointerId);
});
renderer.domElement.addEventListener("pointermove", (event) => {
if (pointerDown.active) {
const dx = event.clientX - pointerDown.x;
const dy = event.clientY - pointerDown.y;
pointerDown.moved += Math.abs(dx) + Math.abs(dy);
pointerDown.x = event.clientX;
pointerDown.y = event.clientY;
orbit.theta -= dx * 0.006;
orbit.phi = THREE.MathUtils.clamp(
orbit.phi - dy * 0.005,
0.45,
1.38
);
updateCamera();
} else {
const index = plugAtPointer(event);
hoveringPlug = index !== null;
renderer.domElement.style.cursor = hoveringPlug ? "pointer" : "grab";
}
});
renderer.domElement.addEventListener("pointerup", (event) => {
const wasClick = pointerDown.moved < 7;
pointerDown.active = false;
if (renderer.domElement.hasPointerCapture(event.pointerId)) {
renderer.domElement.releasePointerCapture(event.pointerId);
}
if (wasClick) {
const index = plugAtPointer(event);
if (index !== null) togglePlug(index);
}
});
renderer.domElement.addEventListener("pointercancel", () => {
pointerDown.active = false;
});
renderer.domElement.addEventListener(
"wheel",
(event) => {
event.preventDefault();
orbit.radius = THREE.MathUtils.clamp(
orbit.radius + event.deltaY * 0.012,
12,
29
);
updateCamera();
},
{ passive: false }
);
renderer.domElement.addEventListener("contextmenu", (event) => event.preventDefault());
function positionLabel(element, position, visible = true) {
const projected = position.clone().project(camera);
const inView =
projected.z > -1 &&
projected.z < 1 &&
projected.x > -1.12 &&
projected.x < 1.12 &&
projected.y > -1.12 &&
projected.y < 1.12;
if (!visible || !inView) {
element.style.display = "none";
return;
}
element.style.display = "block";
element.style.left = `${(projected.x * 0.5 + 0.5) * window.innerWidth}px`;
element.style.top = `${(-projected.y * 0.5 + 0.5) * window.innerHeight}px`;
}
const assemblyLabel = document.getElementById("assemblyTag");
function updateLabels() {
for (let i = 0; i < 3; i++) {
const supplierTop = supplierPositions[i].clone();
supplierTop.y = 2.06;
positionLabel(supplierLabels[i], supplierTop);
const emptyPosition = new THREE.Vector3(
SLOT_X[i],
2.08,
SOCKET_WORLD_Z + 0.15
);
positionLabel(emptyLabels[i], emptyPosition, isMissing(i));
}
positionLabel(
assemblyLabel,
new THREE.Vector3(0, 3.52, ASSEMBLY_Z)
);
}
function updateBeacon() {
const missing = plugs.some((_, index) => isMissing(index));
const moving = plugs.some((plug) => plug.transition);
const targetHex = missing ? 0xff526e : moving ? 0xffc55c : 0x56e6a5;
beaconMaterial.color.setHex(targetHex);
beaconMaterial.emissive.setHex(targetHex);
beaconLight.color.setHex(targetHex);
const pulse = 0.88 + Math.sin(performance.now() * 0.004) * 0.16;
beaconMaterial.emissiveIntensity = (missing ? 2.8 : 2.1) * pulse;
beaconLight.intensity = missing ? 3.2 : 2.1;
}
function updateFlowParticles(elapsed) {
for (let i = 0; i < plugs.length; i++) {
const plug = plugs[i];
const visible = plug.cableFactor > 0.975;
for (let p = 0; p < plug.particles.length; p++) {
const particle = plug.particles[p];
particle.visible = visible;
if (visible && plug.cableCurve) {
const u = (elapsed * 0.25 + p / plug.particles.length) % 1;
particle.position.copy(plug.cableCurve.getPoint(u));
}
}
}
}
function onResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
}
window.addEventListener("resize", onResize);
refreshStatus();
const clock = new THREE.Clock();
renderer.setAnimationLoop(() => {
const elapsed = clock.getElapsedTime();
const now = performance.now();
updateTransitions(now);
for (let i = 0; i < emptyFrames.length; i++) {
const frame = emptyFrames[i];
frame.group.visible = isMissing(i);
frame.material.opacity =
0.57 + Math.sin(elapsed * 4.2 + i) * 0.28;
}
updateFlowParticles(elapsed);
updateBeacon();
updateLabels();
renderer.render(scene, camera);
});
</script>
</body>
</html>
```