Prompt specification
Build or customize the Three.js 3D scene "Stage setup cable organization" 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: Stage setup cable organization
Category: Voxel Worlds · Style: Voxel 3D
License: MIT · Reference: https://three3d.app/scene/stage-setup-cable-organization-x0247
Scene Description Prompt:
Please create one self-contained HTML file with Three.js from cdnjs showing locking cable ties. Compose a small performance platform with lights and reusable cable straps; organize loose cables into labeled bundles routed away from the musicians' movement paths. Voxel style.
Working Three.js Starter (stage-setup-cable-organization-x0247):
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>Voxel Stage — Cable Management</title>
<style>
:root{
--bg:#0d1014; --panel:rgba(16,20,26,.82); --edge:rgba(255,255,255,.12);
--txt:#dfe7ef; --dim:#8b98a8; --cy:#35e0d0; --or:#ff7a2f; --yl:#f2c53d; --rd:#e2564a; --bl:#4f9be0;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--bg);overflow:hidden;
font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace;color:var(--txt)}
canvas{display:block;width:100%;height:100%;touch-action:none}
#hud{position:fixed;top:14px;left:14px;width:288px;padding:14px 15px 13px;
background:var(--panel);border:1px solid var(--edge);border-radius:10px;backdrop-filter:blur(6px);
box-shadow:0 10px 30px rgba(0,0,0,.45);user-select:none}
#hud h1{margin:0 0 2px;font-size:14px;letter-spacing:.14em;text-transform:uppercase}
#hud h1 span{color:var(--or)}
#hud .sub{font-size:10.5px;color:var(--dim);margin-bottom:10px;letter-spacing:.05em}
.row{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:9px}
button{font:inherit;font-size:10.5px;letter-spacing:.08em;text-transform:uppercase;color:var(--txt);
background:rgba(255,255,255,.06);border:1px solid var(--edge);border-radius:6px;padding:6px 8px;cursor:pointer;
transition:background .15s,color .15s,border-color .15s}
button:hover{background:rgba(255,255,255,.13)}
button.on{background:rgba(53,224,208,.16);border-color:rgba(53,224,208,.55);color:#b9fff5}
button.hot{background:rgba(255,122,47,.18);border-color:rgba(255,122,47,.55);color:#ffcdae}
.lg{border-top:1px solid var(--edge);padding-top:9px;margin-top:2px}
.lg div{display:flex;align-items:center;gap:7px;font-size:10px;color:var(--dim);margin:4px 0}
.sw{width:11px;height:11px;border-radius:2px;flex:none;box-shadow:0 0 0 1px rgba(0,0,0,.5)}
.keys{border-top:1px solid var(--edge);margin-top:8px;padding-top:8px;font-size:9.5px;color:var(--dim);line-height:1.55}
#stat{position:fixed;right:14px;bottom:12px;font-size:10px;color:var(--dim);
background:var(--panel);border:1px solid var(--edge);border-radius:8px;padding:7px 10px;letter-spacing:.06em}
#stat b{color:var(--or);font-weight:600}
@media (max-width:640px){#hud{width:calc(100% - 28px)}#stat{display:none}}
</style>
</head>
<body>
<canvas id="app"></canvas>
<div id="hud">
<h1>Voxel Stage <span>//</span> Cable Ops</h1>
<div class="sub">LOCKING STRAPS · LABELED BUNDLES · CLEAR PATHS</div>
<div class="row">
<button id="bCable" class="hot">Cables: organized</button>
<button id="bLabels" class="on">Labels</button>
<button id="bPaths" class="on">Paths</button>
</div>
<div class="row">
<button id="bSpin" class="on">Auto‑orbit</button>
<button id="bReset">Reset view</button>
</div>
<div class="lg">
<div><i class="sw" style="background:#e2564a"></i>Bundle A — MIC / XLR lines</div>
<div><i class="sw" style="background:#f2c53d"></i>Bundle B — POWER (heavy duty)</div>
<div><i class="sw" style="background:#4f9be0"></i>Bundle C — MONITOR returns</div>
<div><i class="sw" style="background:#ff7a2f"></i>Reusable locking strap + buckle</div>
<div><i class="sw" style="background:#35e0d0"></i>Artist movement path — keep clear</div>
</div>
<div class="keys">
DRAG orbit · RIGHT‑DRAG / SHIFT‑DRAG pan · WHEEL or PINCH zoom<br>
Tap <b>Cables</b> to compare the loose rig with the strapped, routed rig.
</div>
</div>
<div id="stat">STATE: <b id="stTxt">ORGANIZED</b> · 3 BUNDLES · 13 LOCKING STRAPS</div>
<script type="module">
import * as THREE from 'https://cdnjs.cloudflare.com/ajax/libs/three.js/0.160.0/three.module.min.js';
/* ──────────────────────────── setup ──────────────────────────── */
const canvas = document.getElementById('app');
const renderer = new THREE.WebGLRenderer({canvas, antialias:true, powerPreference:'high-performance'});
renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
renderer.setSize(innerWidth, innerHeight);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.06;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x14171c);
scene.fog = new THREE.Fog(0x14171c, 46, 95);
const camera = new THREE.PerspectiveCamera(46, innerWidth/innerHeight, 0.1, 220);
const cam = {theta:0.78, phi:1.00, radius:27, target:new THREE.Vector3(0,1.4,0.6)};
function applyCam(){
const sp = Math.sin(cam.phi), cp = Math.cos(cam.phi);
camera.position.set(
cam.target.x + cam.radius*sp*Math.sin(cam.theta),
cam.target.y + cam.radius*cp,
cam.target.z + cam.radius*sp*Math.cos(cam.theta));
camera.lookAt(cam.target);
}
applyCam();
scene.add(new THREE.HemisphereLight(0x9fc4ff, 0x2a2318, 0.62));
scene.add(new THREE.AmbientLight(0xffffff, 0.22));
const sun = new THREE.DirectionalLight(0xfff2dc, 1.35);
sun.position.set(13, 20, 14); sun.castShadow = true;
sun.shadow.mapSize.set(2048,2048);
const sc = sun.shadow.camera;
sc.left=-26; sc.right=26; sc.top=26; sc.bottom=-26; sc.near=1; sc.far=70;
sun.shadow.bias = -0.0008; sun.shadow.normalBias = 0.03;
scene.add(sun);
const rim = new THREE.DirectionalLight(0x66a6ff, 0.35);
rim.position.set(-14, 9, -12); scene.add(rim);
/* ──────────────────────────── materials ──────────────────────────── */
const C = {
deck:[0x6d4c31,0x75522f,0x60432b,0x7b5634],
frame:0x3a3e46, truss:0x9aa1a9, dark:0x22252b, metal:0x8b9199,
cableK:0x15171b, cableR:0xc23b30, cableY:0xe3b231, cableB:0x3f7fbf,
strap:0x24262c, acc:0xff7a2f, path:0x35e0d0, haz:0xf2c53d, hazD:0x202329,
wood:0x7a5a3c, grille:0x15181d, keyw:0xe8e6df
};
const matCache = new Map();
function M(color, o={}){
const key = color+'|'+JSON.stringify(o);
if(!matCache.has(key))
matCache.set(key, new THREE.MeshStandardMaterial({color, roughness:0.92, metalness:0.02, flatShading:true, ...o}));
return matCache.get(key);
}
const boxGeo = new THREE.BoxGeometry(1,1,1);
function box(w,h,d,color,x,y,z,parent=scene,o={}){
const m = new THREE.Mesh(boxGeo, typeof color==='object'?color:M(color,o));
m.scale.set(w,h,d); m.position.set(x,y,z);
m.castShadow = true; m.receiveShadow = true;
parent.add(m); return m;
}
function group(x=0,y=0,z=0,parent=scene){ const g=new THREE.Group(); g.position.set(x,y,z); parent.add(g); return g; }
/* ──────────────────────────── ground ──────────────────────────── */
const N = 42, T = 1.7, HALF = (N*T)/2;
const gm = new THREE.InstancedMesh(boxGeo, M(0xffffff,{roughness:1}), N*N);
gm.receiveShadow = true;
const d = new THREE.Object3D(); const col = new THREE.Color();
let gi = 0;
for(let i=0;i<N;i++) for(let j=0;j<N;j++){
d.position.set(-HALF+T/2+i*T, -0.06, -HALF+T/2+j*T);
d.scale.set(T-0.045, 0.12, T-0.045); d.updateMatrix();
gm.setMatrixAt(gi, d.matrix);
const v = 0.055 + ((i*7+j*13)%11)*0.006;
col.setRGB(v*0.92, v, v*1.06); gm.setColorAt(gi, col); gi++;
}
gm.instanceMatrix.needsUpdate = true; gm.instanceColor.needsUpdate = true;
scene.add(gm);
/* ──────────────────────────── stage deck ──────────────────────────── */
const DECK = 1.4, SX = 8, SZ = 4.5; // deck half-width / half-depth
for(let i=0;i<16;i++){
const c = C.deck[i % C.deck.length];
box(0.99, 0.22, SZ*2, c, -SX+0.5+i, DECK-0.11, 0);
}
box(SX*2, 0.06, 0.14, 0x8a6a45, 0, DECK+0.02, SZ); // front nosing
box(0.14, 0.06, SZ*2, 0x8a6a45, -SX, DECK+0.02, 0);
box(0.14, 0.06, SZ*2, 0x8a6a45, SX, DECK+0.02, 0);
box(SX*2, DECK, 0.14, C.frame, 0, DECK/2, SZ+0.07); // fascia
box(0.14, DECK, SZ*2, C.frame, -SX-0.07, DECK/2, 0);
box(0.14, DECK, SZ*2, C.frame, SX+0.07, DECK/2, 0);
for(const x of [-7.2,-3.6,0,3.6,7.2]) for(const z of [-3.9,0,3.9])
box(0.34, DECK-0.22, 0.34, 0x2c3037, x, (DECK-0.22)/2, z);
// stage stairs, front-left
for(let s=0;s<3;s++){
const h = 0.466*(s+1);
box(3.0, h, 0.5, 0x5e4530, -5.8, h/2, SZ+0.28+0.5*(2-s));
box(3.0, 0.05, 0.12, 0xa9b0b8, -5.8, h+0.02, SZ+0.03+0.5*(2-s));
}
// cable ramp where the trunk leaves the deck (right rear)
box(0.9, 0.16, 0.55, C.haz, 8.25, 0.08, -3.95);
box(0.9, 0.16, 0.55, C.haz, 8.25, 0.08, -3.35);
/* ──────────────────────────── backdrop + LED wall ──────────────────────────── */
box(SX*2, 3.7, 0.3, 0x1b1f26, 0, DECK+1.85, -5.35);
box(SX*2+0.5, 0.3, 0.5, 0x2b3038, 0, DECK+3.75, -5.35);
const LEDW=26, LEDH=9, PX=0.30;
const led = new THREE.InstancedMesh(boxGeo, M(0xffffff,{emissive:0xffffff, emissiveIntensity:1.4, roughness:1}), LEDW*LEDH);
led.position.set(0, DECK+1.95, -5.16);
scene.add(led);
const ledCols = new Float32Array(LEDW*LEDH*3);
for(let i=0;i<LEDW;i++) for(let j=0;j<LEDH;j++){
d.position.set(-(LEDW-1)*PX/2 + i*PX, (LEDH-1)*PX/2 - j*PX, 0);
d.scale.set(PX*0.86, PX*0.86, 0.06); d.updateMatrix();
led.setMatrixAt(i*LEDH+j, d.matrix);
}
led.instanceMatrix.needsUpdate = true;
// frame
box(LEDW*PX+0.3, 0.12, 0.2, 0x33383f, 0, DECK+1.95+(LEDH*PX)/2+0.1, -5.16);
box(LEDW*PX+0.3, 0.12, 0.2, 0x33383f, 0, DECK+1.95-(LEDH*PX)/2-0.1, -5.16);
/* ──────────────────────────── truss + par cans + beams ──────────────────────────── */
const trussG = group(0,0,-5.9);
for(const x of [-8.6, 8.6]){
box(0.28, 6.6, 0.28, C.truss, x, 3.3, 0, trussG);
for(let i=0;i<7;i++) box(0.10,0.10,0.10,C.metal, x+ (i%2?0.22:-0.22), 0.6+i*0.9, 0, trussG);
}
box(17.6, 0.30, 0.30, C.truss, 0, 6.5, 0, trussG);
box(17.6, 0.16, 0.16, C.metal, 0, 6.05, 0, trussG);
for(let i=0;i<14;i++) box(0.12,0.12,0.12,C.metal, -8.2+i*1.26, 6.28, 0.14, trussG);
const BEAM_COLORS=[0xff5a3c,0xffc24a,0x49d7ff,0x7b6bff,0xff5a3c,0x62ff9b];
const beams=[];
function makeBeam(origin, dir, len, color){
const g = group(origin.x,origin.y,origin.z);
const mm = new THREE.MeshBasicMaterial({color, transparent:true, opacity:0.10,
depthWrite:false, blending:THREE.AdditiveBlending, side:THREE.DoubleSide});
const n = 14, dirv = dir.clone().normalize();
const q = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0,0,1), dirv);
for(let i=0;i<n;i++){
const t = (i+0.5)/n;
const s = 0.34 + t*2.4;
const m = new THREE.Mesh(boxGeo, mm);
m.position.copy(dirv.clone().multiplyScalar(t*len));
m.quaternion.copy(q);
m.scale.set(s, s, len/n*1.1);
g.add(m);
}
beams.push({g, base:origin.clone(), phase:Math.random()*6.28});
return g;
}
const parCans=[];
for(let i=0;i<6;i++){
const x = -6.4 + i*2.55, col = BEAM_COLORS[i];
const pg = group(x, 6.1, -5.75);
box(0.14,0.55,0.14,C.metal, 0, 0.34, 0, pg); // clamp
box(0.52,0.58,0.52, C.dark, 0, 0.0, 0, pg); // body
box(0.44,0.10,0.44, C.metal, 0, -0.30, 0, pg); // barn door
box(0.40,0.40,0.10, M(col,{emissive:col, emissiveIntensity:1.6}), 0, -0.02, 0.28, pg);
const pl = new THREE.PointLight(col, 26, 24, 1.6);
pl.position.set(x, 5.85, -5.1); scene.add(pl);
makeBeam(new THREE.Vector3(x,5.85,-5.05), new THREE.Vector3(0,-1,0.55).normalize(), 8.4, col);
parCans.push({pg, phase:i*0.7});
}
// front-of-house floor uplights
for(const x of [-9.6, 9.6]){
box(0.5,0.6,0.5, C.dark, x, 0.3, 5.6);
box(0.42,0.12,0.42, M(0x9fd6ff,{emissive:0x9fd6ff, emissiveIntensity:1.2}), x, 0.62, 5.6);
const pl = new THREE.PointLight(0x9fd6ff, 16, 18, 1.6); pl.position.set(x,0.9,5.6); scene.add(pl);
makeBeam(new THREE.Vector3(x,0.75,5.6), new THREE.Vector3(0,1,0).normalize(), 5.2, 0x9fd6ff);
}
/* ──────────────────────────── gear & musicians ──────────────────────────── */
function micStand(x,z,y=DECK){
const g = group(x,y,z);
box(0.48,0.07,0.48, 0x2c3037, 0,0.035,0,g);
box(0.07,1.55,0.07, C.metal, 0,0.80,0,g);
box(0.06,0.06,0.60, C.metal, 0,1.52,0.24,g);
box(0.15,0.22,0.15, C.dark, 0,1.42,0.50,g);
box(0.10,0.10,0.10, 0x9aa1a9, 0,1.52,0.24,g);
return g;
}
function ampCabinet(x,z,y=DECK){
const g = group(x,y,z);
box(1.35,1.05,0.66, 0x1e2126, 0,0.53,0,g);
box(1.10,0.78,0.06, C.grille, 0,0.55,0.34,g);
box(0.40,0.40,0.05, 0x30353d, -0.28,0.55,0.38,g);
box(0.40,0.40,0.05, 0x30353d, 0.28,0.55,0.38,g);
box(1.35,0.10,0.70, 0x2b3038, 0,1.10,0,g);
box(0.30,0.08,0.08, C.metal, 0.45,1.16,0,g);
return g;
}
function keyboard(x,z,y=DECK){
const g = group(x,y,z);
box(0.10,0.95,0.10, C.metal, -0.6,0.47,0,g);
box(0.10,0.95,0.10, C.metal, 0.6,0.47,0,g);
box(0.10,0.10,0.60, C.metal, 0,0.30,0,g);
box(1.55,0.13,0.48, C.dark, 0,1.00,0,g);
box(1.40,0.04,0.30, C.keyw, 0,1.08,-0.04,g);
for(let i=0;i<13;i++) box(0.05,0.03,0.18, 0x24272d, -0.63+i*0.105, 1.10,0.10,g);
return g;
}
function monitor(x,z,y=DECK){
const g = group(x,y,z);
const m = box(1.15,0.42,0.72, 0x1b1e24, 0,0.21,0,g); m.rotation.x = -0.28;
const f = box(1.0,0.06,0.60, C.grille, 0,0.30,0.06,g); f.rotation.x = -0.28;
return g;
}
function drumKit(x,z,y=DECK){
const g = group(x,y,z);
box(0.95,0.85,0.95, 0x7d2a25, 0,0.43,0,g);
box(0.90,0.08,0.90, 0xd9d3c6, 0,0.88,0,g);
box(0.52,0.30,0.52, 0xb03a2f, -0.62,1.05,0,g);
box(0.55,0.08,0.55, 0xd9d3c6, -0.62,1.22,0,g);
box(0.42,0.24,0.42, 0x8e2f28, 0.60,1.02,0.1,g);
box(0.06,1.25,0.06, C.metal, -1.05,0.62,-0.55,g);
const cy = box(0.62,0.05,0.62, 0xc9b45a, -1.05,1.24,-0.55,g); cy.rotation.z = 0.12;
box(0.06,1.45,0.06, C.metal, 1.15,0.72,-0.62,g);
const cy2 = box(0.70,0.05,0.70, 0xc9b45a, 1.15,1.46,-0.62,g); cy2.rotation.x = -0.14;
box(0.06,0.55,0.06, C.metal, -0.35,0.27,0.95,g);
box(0.44,0.08,0.44, 0x24272d, -0.35,0.56,0.95,g);
return g;
}
function musician(o){
const g = group(o.x, DECK, o.z);
const shirt=o.shirt, pants=o.pants, skin=o.skin||0xd7a06a, hair=o.hair||0x2b2119;
box(0.25,0.74,0.25, pants, -0.17,0.37,0,g);
box(0.25,0.74,0.25, pants, 0.17,0.37,0,g);
box(0.29,0.13,0.36, 0x1d1f24, -0.17,0.065,0.05,g);
box(0.29,0.13,0.36, 0x1d1f24, 0.17,0.065,0.05,g);
box(0.66,0.74,0.38, shirt, 0,1.11,0,g);
box(0.70,0.10,0.40, M(shirt,{roughness:.8}), 0,0.80,0,g);
box(0.40,0.42,0.40, skin, 0,1.70,0,g);
box(0.44,0.16,0.44, hair, 0,1.92,0,g);
box(0.44,0.08,0.14, hair, 0,1.86,0.20,g);
box(0.09,0.09,0.05, 0x1a1c20, -0.11,1.72,0.21,g);
box(0.09,0.09,0.05, 0x1a1c20, 0.11,1.72,0.21,g);
const aL = box(0.18,0.62,0.18, shirt, -0.44,1.06,0.02,g); aL.rotation.z = 0.30; aL.rotation.x = o.armL||0;
const aR = box(0.18,0.62,0.18, shirt, 0.44,1.06,0.02,g); aR.rotation.z = -0.30; aR.rotation.x = o.armR||0;
return g;
}
micStand(-4.8, 1.25); micStand(-1.75,-1.15);
ampCabinet(5.35,-1.85); keyboard(2.45,-1.15);
monitor(-4.45,3.30); monitor(4.80,3.30);
drumKit(-0.55,-2.75);
musician({x:-4.30,z:0.30,shirt:0xd8452f,pants:0x2f3540,hair:0x241a12,armL:-0.5,armR:0.4});
musician({x:-0.55,z:-1.75,shirt:0x2f7fb5,pants:0x22262d,hair:0x6b4a2c});
musician({x:2.50,z:-0.35,shirt:0x54b36a,pants:0x33383f,hair:0x141414});
musician({x:4.85,z:-0.35,shirt:0xe0a13c,pants:0x24282f,hair:0xb07a3a});
// guitar + case
box(0.42,0.72,0.10, 0xa8483a, 4.62,1.05,-0.55);
box(0.16,0.16,0.11, 0x2a2d33, 4.62,0.72,-0.55);
box(1.5,0.35,0.45, 0x1d2026, -7.0,DECK+0.18,2.6);
/* ──────────────────────────── movement paths (dashed) ──────────────────────────── */
const pathG = group(0,0,0);
function dashLine(x1,z1,x2,z2,y,color,size=0.30,step=0.80,parent=pathG){
const dx=x2-x1, dz=z2-z1, len=Math.hypot(dx,dz), n=Math.max(1,Math.floor(len/step));
for(let i=0;i<n;i++){
const t=(i+0.5)/n;
const m = new THREE.Mesh(boxGeo, M(color,{emissive:color, emissiveIntensity:0.75}));
m.scale.set(size,0.05,size); m.position.set(x1+dx*t, y, z1+dz*t);
m.receiveShadow=false; parent.add(m);
}
}
function chevron(x,z,y,color,dir=1,parent=pathG){
for(let i=0;i<3;i++){
const m = new THREE.Mesh(boxGeo, M(color,{emissive:color, emissiveIntensity:0.9}));
m.scale.set(0.22,0.05,0.22);
m.position.set(x + (i-1)*0.26*dir, y, z + Math.abs(i-1)*0.26);
parent.add(m);
}
}
// artist lane across the deck front
dashLine(-5.6,2.45,5.6,2.45, DECK+0.035, C.path);
dashLine(-5.6,1.75,5.6,1.75, DECK+0.035, C.path, 0.22, 1.4);
chevron(5.95,2.45,DECK+0.035,C.path,1); chevron(-5.95,2.45,DECK+0.035,C.path,-1);
// side connector lane
dashLine(6.1,-0.4,6.1,3.3, DECK+0.035, C.path, 0.26, 0.8);
// hazard hatching beside the lane
for(let x=-5.6;x<=5.6;x+=0.42){
const t = Math.round(x/0.42)%2===0;
box(0.30,0.045,0.16, t?C.haz:C.hazD, x, DECK+0.03, 3.0);
box(0.30,0.045,0.16, t?C.hazD:C.haz, x, DECK+0.03, 1.22);
}
// front-of-house walkway on the floor
dashLine(-9.4,7.2,9.4,7.2, 0.045, C.haz, 0.30, 0.9);
chevron(9.8,7.2,0.045,C.haz,1); chevron(-9.8,7.2,0.045,C.haz,-1);
// crew access lane on the right side (floor)
dashLine(9.1,-5.0,9.1,5.6, 0.045, C.haz, 0.24, 0.9);
/* ──────────────────────────── cable voxel builder ──────────────────────────── */
const zAxis = new THREE.Vector3(0,0,1);
function voxelCable(pts, color, thick=0.16, step=0.30, parent=scene){
const curve = new THREE.CatmullRomCurve3(pts.map(p=>new THREE.Vector3(p[0],p[1],p[2])), false, 'catmullrom', 0.35);
const len = curve.getLength();
const count = Math.max(3, Math.ceil(len/step));
const mesh = new THREE.InstancedMesh(boxGeo, M(color,{roughness:0.75, metalness:0.05}), count);
mesh.castShadow = true; mesh.receiveShadow = true;
const o = new THREE.Object3D();
for(let i=0;i<count;i++){
const t=i/(count-1);
const p=curve.getPointAt(t), tan=curve.getTangentAt(t).normalize();
o.position.copy(p);
o.quaternion.setFromUnitVectors(zAxis, tan);
o.scale.set(thick, thick, step*1.35);
o.updateMatrix(); mesh.setMatrixAt(i,o.matrix);
}
mesh.instanceMatrix.needsUpdate = true;
parent.add(mesh); return mesh;
}
const D = DECK+0.085, F = 0.10; // deck cable height / floor cable height
/* upstage trunk helper: source -> upstage lane -> off deck -> snake box */
function trunkPath(sx,sz,off,lane=-3.95,dropX=8.25,boxX=10.45){
return [
[sx, D, sz],[sx, D, sz-1.1],[sx+0.35, D, lane+off],
[dropX-1.3, D, lane+off],[dropX, D, lane+off],
[dropX+0.12, F, lane+off],[9.7, F, lane+off],[boxX, F, lane+off]
];
}
function frontLanePath(mx,off){
return [
[mx, D, 3.30],[mx, D, 4.16+off],[7.2, D, 4.16+off],[8.05, D, 4.2+off],
[8.18, F, 4.3+off],[9.25, F, 4.3+off],[9.55, F, 0.2],[9.55, F, -3.95+off],[10.45, F, -3.95+off]
];
}
/* ──────────────────────────── ORGANIZED rig ──────────────────────────── */
const orgG = group(0,0,0);
const A = [trunkPath(-4.8,1.25,-0.16), trunkPath(-1.75,-1.15,0.0)];
const B = [trunkPath(5.35,-1.85,0.0,-3.35,8.25,10.45), trunkPath(2.45,-1.15,0.22,-3.15,8.25,10.45)];
const Cb= [frontLanePath(-4.45,-0.14), frontLanePath(4.80,0.0)];
voxelCable(A[0], C.cableR, 0.16, 0.28, orgG);
voxelCable(A[1], C.cableK, 0.16, 0.28, orgG);
voxelCable(B[0], C.cableK, 0.22, 0.30, orgG);
voxelCable(B[1], C.cableY, 0.20, 0.30, orgG);
voxelCable(Cb[0], C.cableB, 0.16, 0.28, orgG);
voxelCable(Cb[1], C.cableK, 0.16, 0.28, orgG);
/* ──────────────────────────── LOOSE rig ──────────────────────────── */
const looseG = group(0,0,0);
const LA = [
[[-4.8,1.25],[-4.2,2.05],[-3.0,2.95],[-1.5,2.05],[0.0,3.05],[1.5,2.15],[3.0,3.25],[5.0,2.55],[7.2,3.45],[8.35,F,3.9],[9.9,F,3.9],[10.45,F,1.0]],
[[-1.75,-1.15],[-0.65,0.35],[0.6,1.25],[1.8,0.35],[3.0,1.45],[4.5,0.55],[6.0,1.65],[7.6,1.35],[8.3,F,2.6],[10.0,F,2.6],[10.45,F,0.2]]
];
const LB = [
[[5.35,-1.85],[6.0,-0.55],[6.4,0.85],[5.55,1.65],[6.6,2.65],[7.8,2.15],[8.4,F,2.2],[10.0,F,2.2],[10.45,F,-1.2]],
[[2.45,-1.15],[2.95,0.25],[3.6,1.45],[4.6,0.95],[6.0,2.05],[7.4,1.75],[8.3,F,2.0],[9.8,F,2.0],[10.45,F,-0.6]]
];
const LC = [
[[-4.45,3.30],[-4.6,4.25],[-2.0,4.45],[0.0,4.0],[2.0,4.5],[4.80,4.2],[7.0,4.55],[8.3,F,4.6],[9.6,F,4.6],[9.8,F,1.0],[10.45,F,0.4]]
];
voxelCable(LA[0], C.cableR, 0.16, 0.26, looseG);
voxelCable(LA[1], C.cableK, 0.16, 0.26, looseG);
voxelCable(LB[0], C.cableK, 0.22, 0.28, looseG);
voxelCable(LB[1], C.cableY, 0.20, 0.28, looseG);
voxelCable(LC[0], C.cableB, 0.16, 0.26, looseG);
// coiled cable dumped in the front-of-house walkway
const coil=[];
for(let i=0;i<=64;i++){ const t=i/64, a=t*Math.PI*4.4, r=1.35-t*1.1;
coil.push([-2.6+Math.cos(a)*r, F, 7.05+Math.sin(a)*r*0.55]); }
voxelCable(coil, C.cableK, 0.15, 0.22, looseG);
// cable draped across the walkway
voxelCable([[-6.4,F,5.6],[-5.6,F,6.9],[-4.2,F,7.7],[-2.4,F,6.9],[-0.6,F,7.8],[1.2,F,7.0],[3.0,F,7.6]],
C.cableR, 0.16, 0.26, looseG);
looseG.visible = false;
/* ──────────────────────────── reusable locking straps ──────────────────────────── */
const strapG = group(0,0,0);
const strapAnims = [];
function makeStrap(W=0.62,H=0.34){
const g = group(0,0,0,strapG);
const t=0.07;
box(t,t,W, C.strap, 0, H/2, 0, g);
box(t,t,W, C.strap, 0,-H/2, 0, g);
box(t,H,t, C.strap, 0, 0,-W/2, g);
box(t,H,t, C.strap, 0, 0, W/2, g);
// locking buckle (ratchet head) + release lever
box(0.20,0.22,0.16, C.acc, 0.0, H/2+0.12,-W/2-0.06, g);
box(0.05,0.12,0.05, 0xf4f4f4, 0.10, H/2+0.12,-W/2-0.12, g);
box(0.16,0.05,0.05, 0xf4f4f4, 0.0, H/2+0.12,-W/2-0.06, g);
// tail
const tail = box(0.05,0.035,0.36, C.strap, 0,-H/2-0.03, 0.14, g); tail.rotation.x = 0.28;
const tail2 = box(0.05,0.035,0.16, C.acc, 0,-H/2-0.10, 0.24, g); tail2.rotation.x = 0.28;
return g;
}
function placeStrap(x,y,z,rotY=0,W=0.62,H=0.34){
const s = makeStrap(W,H);
s.position.set(x,y,z); s.rotation.y = rotY;
strapAnims.push({obj:s, final:s.position.clone(), t:0, delay:0});
return s;
}
// bundle A (mic) straps along the upstage trunk
[-3.0,-0.4,2.2,4.8].forEach((x,i)=>placeStrap(x, D, -3.95+ (i%2?0.02:-0.02), 0, 0.60));
// bundle B (power) straps
[6.9,7.6].forEach((x,i)=>placeStrap(x, D, i? -3.16 : -3.34, 0, 0.66));
// bundle C (monitor) straps along the stage lip lane
[-2.0,1.0,4.0,6.6].forEach(x=>placeStrap(x, D, 4.16, 0, 0.58));
// floor trunk strap
placeStrap(9.55, F+0.02, 0.6, Math.PI/2, 0.62);
// spare reusable straps hanging on a peg rack
const rack = group(11.5, 0, -0.6);
box(0.14,1.1,0.14, C.metal, 0,0.55,0,rack);
box(1.3,0.10,0.14, C.metal, 0.5,1.02,0,rack);
for(let i=0;i<4;i++){
const s = makeStrap(0.42,0.26);
s.position.set(0.12+i*0.28, 0.86, 0.02); s.rotation.y = Math.PI/2;
strapAnims.push({obj:s, final:s.position.clone(), t:0, delay:0});
}
/* ──────────────────────────── snake box + distribution ──────────────────────────── */
const snakeBox = group(10.9, 0, -3.6);
box(1.9,0.75,1.2, 0x24282f, 0,0.38,0,snakeBox);
box(1.95,0.10,1.25, 0x343a43, 0,0.80,0,snakeBox);
for(let i=0;i<6;i++) box(0.16,0.30,0.16, C.cableK, -0.72+i*0.29, 0.98, 0.35, snakeBox);
for(let i=0;i<4;i++) box(0.16,0.26,0.16, i%2?C.cableR:C.cableY, -0.45+i*0.3, 0.96, -0.30, snakeBox);
const pwr = group(12.7, 0, -4.9);
box(1.0,0.85,0.8, 0x2b3038, 0,0.42,0,pwr);
box(0.85,0.5,0.05, C.grille, 0,0.45,0.42,pwr);
for(let i=0;i<4;i++) box(0.14,0.14,0.06, 0x101216, -0.3+i*0.2, 0.62,0.45,pwr);
box(0.6,0.3,0.5, 0x8a6a45, 0,0.25,0.75,pwr);
/* ──────────────────────────── labels (voxel sign boards) ──────────────────────────── */
const labelG = group(0,0,0);
const billboards = [];
function labelTexture(text, accent){
const cv=document.createElement('canvas'); cv.width=256; cv.height=64;
const ctx=cv.getContext('2d');
ctx.fillStyle='#0e1117'; ctx.fillRect(0,0,256,64);
ctx.fillStyle=accent; ctx.fillRect(0,0,256,7); ctx.fillRect(0,0,7,64);
ctx.fillStyle='rgba(255,255,255,.06)'; ctx.fillRect(7,7,249,57);
let size=25; ctx.font=`bold ${size}px "Courier New", monospace`;
while(ctx.measureText(text).width>228 && size>11){ size--; ctx.font=`bold ${size}px "Courier New", monospace`; }
ctx.fillStyle='#e9f0f8'; ctx.textAlign='center'; ctx.textBaseline='middle';
ctx.fillText(text,132,38);
const t=new THREE.CanvasTexture(cv);
t.magFilter=THREE.NearestFilter; t.minFilter=THREE.NearestFilter; t.colorSpace=THREE.SRGBColorSpace;
return t;
}
function sign(text, accent, x, y, z, boardW=2.0){
const g = group(x,y,z,labelG);
box(0.07,1.05,0.07, C.metal, 0,0.52,0,g);
box(boardW,0.48,0.09, 0x101319, 0,1.28,0,g);
box(boardW+0.10,0.06,0.11, M(accent,{emissive:accent, emissiveIntensity:0.5}), 0,1.52,0,g);
const tex = labelTexture(text, accent);
const plane = new THREE.Mesh(new THREE.PlaneGeometry(boardW-0.08,(boardW-0.08)*0.25),
new THREE.MeshBasicMaterial({map:tex, transparent:true, side:THREE.DoubleSide}));
plane.position.set(0,1.28,0.05); g.add(plane);
billboards.push(g);
return g;
}
sign('A · MIC / XLR', '#e2564a', -2.3, DECK, -4.45);
sign('B · POWER 16A', '#f2c53d', 4.5, DECK, -3.80);
sign('C · MONITOR RET', '#4f9be0', 0.2, DECK, 4.55);
sign('SNAKE BOX', '#35e0d0', 10.9, 0.0, -2.85, 1.6);
sign('REUSABLE STRAPS', '#ff7a2f', 11.5, 0.0, -0.15, 1.8);
sign('ARTIST PATH · KEEP CLEAR', '#35e0d0', -7.6, DECK, 2.6, 2.4);
sign('FOH WALKWAY · KEEP CLEAR', '#f2c53d', -7.4, 0.0, 7.9, 2.4);
/* ──────────────────────────── UI wiring ──────────────────────────── */
let organized = true, labelsOn = true, pathsOn = true, spin = true;
const bCable=document.getElementById('bCable'), stTxt=document.getElementById('stTxt');
function setCable(){
organized=!organized;
orgG.visible=organized; looseG.visible=!organized; strapG.visible=organized;
bCable.textContent = organized?'Cables: organized':'Cables: loose';
bCable.classList.toggle('hot', organized);
bCable.classList.toggle('on', !organized);
stTxt.textContent = organized?'ORGANIZED':'LOOSE';
if(organized) strapAnims.forEach((s,i)=>{ s.t=0; s.delay=i*0.045; s.obj.position.copy(s.final).add(new THREE.Vector3(0,1.6,0)); });
}
bCable.onclick=setCable;
const bLabels=document.getElementById('bLabels');
bLabels.onclick=()=>{ labelsOn=!labelsOn; labelG.visible=labelsOn; bLabels.classList.toggle('on',labelsOn); };
const bPaths=document.getElementById('bPaths');
bPaths.onclick=()=>{ pathsOn=!pathsOn; pathG.visible=pathsOn; bPaths.classList.toggle('on',pathsOn); };
const bSpin=document.getElementById('bSpin');
bSpin.onclick=()=>{ spin=!spin; bSpin.classList.toggle('on',spin); };
document.getElementById('bReset').onclick=()=>{ cam.theta=0.78; cam.phi=1.00; cam.radius=27; cam.target.set(0,1.4,0.6); applyCam(); };
/* ──────────────────────────── custom camera controls ──────────────────────────── */
const pointers=new Map(); let prevDist=0, prevMid={x:0,y:0};
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v));
function pan(dx,dy){
const right=new THREE.Vector3().setFromMatrixColumn(camera.matrix,0);
const up=new THREE.Vector3().setFromMatrixColumn(camera.matrix,1);
const s=cam.radius*0.0016;
cam.target.addScaledVector(right,-dx*s).addScaledVector(up,dy*s);
cam.target.x=clamp(cam.target.x,-16,16); cam.target.y=clamp(cam.target.y,0,8); cam.target.z=clamp(cam.target.z,-12,14);
}
canvas.addEventListener('contextmenu', e=>e.preventDefault());
canvas.addEventListener('pointerdown', e=>{
pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
canvas.setPointerCapture(e.pointerId);
if(pointers.size===2){
const [a,b]=[...pointers.values()];
prevDist=Math.hypot(a.x-b.x,a.y-b.y);
prevMid={x:(a.x+b.x)/2,y:(a.y+b.y)/2};
}
});
canvas.addEventListener('pointermove', e=>{
if(!pointers.has(e.pointerId)) return;
const prev=pointers.get(e.pointerId);
const dx=e.clientX-prev.x, dy=e.clientY-prev.y;
pointers.set(e.pointerId,{x:e.clientX,y:e.clientY});
if(pointers.size===1){
if(e.button===2 || e.shiftKey || e.ctrlKey) pan(dx,dy);
else { cam.theta-=dx*0.006; cam.phi=clamp(cam.phi-dy*0.005,0.12,1.46); }
} else if(pointers.size===2){
const [a,b]=[...pointers.values()];
const dist=Math.hypot(a.x-b.x,a.y-b.y);
const mid={x:(a.x+b.x)/2,y:(a.y+b.y)/2};
if(prevDist) cam.radius=clamp(cam.radius*(prevDist/dist),9,62);
pan(mid.x-prevMid.x, mid.y-prevMid.y);
prevDist=dist; prevMid=mid;
}
});
const release=e=>{ pointers.delete(e.pointerId); prevDist=0; };
canvas.addEventListener('pointerup',release);
canvas.addEventListener('pointercancel',release);
canvas.addEventListener('wheel',e=>{ e.preventDefault(); cam.radius=clamp(cam.radius*Math.exp(e.deltaY*0.0011),9,62); },{passive:false});
addEventListener('resize',()=>{ camera.aspect=innerWidth/innerHeight; camera.updateProjectionMatrix(); renderer.setSize(innerWidth,innerHeight); });
/* ──────────────────────────── animation ──────────────────────────── */
const clock=new THREE.Clock();
const tmpCol=new THREE.Color();
const ledPal=[[0.12,0.45,0.85],[0.9,0.25,0.35],[0.95,0.72,0.2],[0.2,0.8,0.75],[0.5,0.3,0.85]];
function animate(){
requestAnimationFrame(animate);
const t=clock.getElapsedTime();
if(spin) cam.theta+=0.0016;
applyCam();
// LED wall pattern
for(let i=0;i<LEDW;i++) for(let j=0;j<LEDH;j++){
const k=i*LEDH+j;
const w=Math.sin(i*0.55+t*1.6)+Math.sin(j*0.7-t*1.1)+Math.sin((i+j)*0.33+t*0.7);
const idx=Math.abs(Math.round(w*1.6))%ledPal.length;
const c=ledPal[idx];
const kk=0.55+0.45*Math.abs(Math.sin(i*0.9+j*0.5+t*2.1));
tmpCol.setRGB(c[0]*kk, c[1]*kk, c[2]*kk);
led.setColorAt(k, tmpCol);
}
led.instanceColor.needsUpdate=true;
// light shafts sway
beams.forEach(b=>{ b.g.rotation.z=Math.sin(t*0.5+b.phase)*0.06; b.g.rotation.x=Math.sin(t*0.37+b.phase)*0.04; });
parCans.forEach(p=>{ p.pg.rotation.x=Math.sin(t*0.8+p.phase)*0.05; });
// straps drop into place when the organized rig is selected
if(organized && strapG.visible){
let moved=false;
strapAnims.forEach(s=>{
if(s.t<1){
s.t=Math.min(1, s.t+0.035);
const e=1-Math.pow(1-Math.max(0,(s.t*1.6-s.delay)),3);
s.obj.position.lerpVectors(s.final.clone().add(new THREE.Vector3(0,1.6,0)), s.final, e);
s.obj.rotation.z=(1-e)*0.5;
moved=true;
}
});
}
// labels always face the viewer (yaw only) so they stay readable
billboards.forEach(g=>{
g.rotation.y=Math.atan2(camera.position.x-g.position.x, camera.position.z-g.position.z);
});
renderer.render(scene,camera);
}
animate();
</script>
</body>
</html>
```