@hivey/cli 0.9.61 → 0.9.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/native/darwin-arm64/hivey +0 -0
  2. package/package.json +1 -1
  3. package/repo/skills/hivey/scripts/new_wiki.py +12 -0
  4. package/repo/skills/hivey-agent-map/SKILL.md +33 -0
  5. package/repo/skills/hivey-agent-map/scripts/agent_map.py +10 -0
  6. package/repo/skills/hivey-agent-map/scripts/office/OutlineEffect.js +539 -0
  7. package/repo/skills/hivey-agent-map/scripts/office/RoomEnvironment.js +148 -0
  8. package/repo/skills/hivey-agent-map/scripts/office/loaders/GLTFLoader.js +4663 -0
  9. package/repo/skills/hivey-agent-map/scripts/office/models/LICENSE-kenney-space-kit.txt +23 -0
  10. package/repo/skills/hivey-agent-map/scripts/office/models/LICENSE-kenney-space-station-kit.txt +28 -0
  11. package/repo/skills/hivey-agent-map/scripts/office/models/LICENSE-robot.txt +2 -0
  12. package/repo/skills/hivey-agent-map/scripts/office/models/astronautA.glb.b64 +1 -0
  13. package/repo/skills/hivey-agent-map/scripts/office/models/astronautB.glb.b64 +1 -0
  14. package/repo/skills/hivey-agent-map/scripts/office/models/barrels.glb.b64 +1 -0
  15. package/repo/skills/hivey-agent-map/scripts/office/models/barrels_rail.glb.b64 +1 -0
  16. package/repo/skills/hivey-agent-map/scripts/office/models/craft_cargoA.glb.b64 +1 -0
  17. package/repo/skills/hivey-agent-map/scripts/office/models/craft_racer.glb.b64 +1 -0
  18. package/repo/skills/hivey-agent-map/scripts/office/models/craft_speederA.glb.b64 +1 -0
  19. package/repo/skills/hivey-agent-map/scripts/office/models/desk_chairArms.glb.b64 +1 -0
  20. package/repo/skills/hivey-agent-map/scripts/office/models/desk_computer.glb.b64 +1 -0
  21. package/repo/skills/hivey-agent-map/scripts/office/models/machine_generator.glb.b64 +1 -0
  22. package/repo/skills/hivey-agent-map/scripts/office/models/machine_generatorLarge.glb.b64 +1 -0
  23. package/repo/skills/hivey-agent-map/scripts/office/models/machine_wireless.glb.b64 +1 -0
  24. package/repo/skills/hivey-agent-map/scripts/office/models/robot.glb.b64 +1 -0
  25. package/repo/skills/hivey-agent-map/scripts/office/models/satelliteDish_detailed.glb.b64 +1 -0
  26. package/repo/skills/hivey-agent-map/scripts/office/models/satelliteDish_large.glb.b64 +1 -0
  27. package/repo/skills/hivey-agent-map/scripts/office/models/station/Textures/colormap.png.b64 +1 -0
  28. package/repo/skills/hivey-agent-map/scripts/office/models/station/chair-cushion-headrest.glb.b64 +1 -0
  29. package/repo/skills/hivey-agent-map/scripts/office/models/station/computer-system.glb.b64 +1 -0
  30. package/repo/skills/hivey-agent-map/scripts/office/models/station/computer-wide.glb.b64 +1 -0
  31. package/repo/skills/hivey-agent-map/scripts/office/models/station/container-flat.glb.b64 +1 -0
  32. package/repo/skills/hivey-agent-map/scripts/office/models/station/container-tall.glb.b64 +1 -0
  33. package/repo/skills/hivey-agent-map/scripts/office/models/station/container-wide.glb.b64 +1 -0
  34. package/repo/skills/hivey-agent-map/scripts/office/models/station/display-wall-wide.glb.b64 +1 -0
  35. package/repo/skills/hivey-agent-map/scripts/office/models/station/pipe-ring-colored.glb.b64 +1 -0
  36. package/repo/skills/hivey-agent-map/scripts/office/music/README.txt +2 -0
  37. package/repo/skills/hivey-agent-map/scripts/office/music/space.mp3.b64 +1 -0
  38. package/repo/skills/hivey-agent-map/scripts/office/office.html +181 -0
  39. package/repo/skills/hivey-agent-map/scripts/office/office.js +814 -0
  40. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/EffectComposer.js +231 -0
  41. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/MaskPass.js +104 -0
  42. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/OutputPass.js +95 -0
  43. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/Pass.js +95 -0
  44. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/RenderPass.js +99 -0
  45. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/ShaderPass.js +77 -0
  46. package/repo/skills/hivey-agent-map/scripts/office/postprocessing/UnrealBloomPass.js +415 -0
  47. package/repo/skills/hivey-agent-map/scripts/office/shaders/CopyShader.js +45 -0
  48. package/repo/skills/hivey-agent-map/scripts/office/shaders/LuminosityHighPassShader.js +66 -0
  49. package/repo/skills/hivey-agent-map/scripts/office/shaders/OutputShader.js +81 -0
  50. package/repo/skills/hivey-agent-map/scripts/office/ship.js +578 -0
  51. package/repo/skills/hivey-agent-map/scripts/office/three.module.min.js +6 -0
  52. package/repo/skills/hivey-agent-map/scripts/office/utils/BufferGeometryUtils.js +1375 -0
  53. package/repo/skills/hivey-agent-map/scripts/office/utils/SkeletonUtils.js +413 -0
  54. package/repo/skills/hivey-agent-map/scripts/office.py +522 -0
  55. package/repo/skills/hivey-agent-map/scripts/serve.py +190 -9
  56. package/repo/skills/hivey-create-wiki/SKILL.md +27 -2
  57. package/repo/skills/hivey-swarm-creator/SKILL.md +4 -0
  58. package/repo/skills/hivey-swarm-creator/references/wiki-memory.md +3 -0
  59. package/repo/skills/hivey-wiki-lint/SKILL.md +7 -2
@@ -0,0 +1,578 @@
1
+ // hivey office, spacecraft edition: the deck of a ship, its workstations and its crew of mini robots.
2
+ // Everything is built from primitives and canvas textures (no image assets): physically based shells,
3
+ // glass visors and emissive LEDs that the bloom pass makes glow.
4
+ import * as THREE from './three.module.min.js';
5
+ import { GLTFLoader } from './loaders/GLTFLoader.js';
6
+ import * as SkeletonUtils from './utils/SkeletonUtils.js';
7
+
8
+ // CC0 models (see models/LICENSE-*): the animated robot (Tomás Laulhé / Quaternius) and Kenney's
9
+ // Space Kit and Space Station Kit. Anything that fails to load falls back to the built-in shapes.
10
+ const FILES = {
11
+ robot: 'models/robot.glb', desk: 'models/desk_computer.glb', chair: 'models/desk_chairArms.glb',
12
+ generator: 'models/machine_generator.glb', generatorL: 'models/machine_generatorLarge.glb', wireless: 'models/machine_wireless.glb',
13
+ dish: 'models/satelliteDish_detailed.glb', dishL: 'models/satelliteDish_large.glb', speeder: 'models/craft_speederA.glb',
14
+ racer: 'models/craft_racer.glb', cargo: 'models/craft_cargoA.glb', barrelsRail: 'models/barrels_rail.glb', barrels: 'models/barrels.glb',
15
+ astroA: 'models/astronautA.glb', astroB: 'models/astronautB.glb',
16
+ wallDisplay: 'models/station/display-wall-wide.glb', console: 'models/station/computer-system.glb', consoleWide: 'models/station/computer-wide.glb',
17
+ crateTall: 'models/station/container-tall.glb', crateWide: 'models/station/container-wide.glb', crateFlat: 'models/station/container-flat.glb',
18
+ lounger: 'models/station/chair-cushion-headrest.glb',
19
+ };
20
+
21
+ export function createShip({ mesh, hue, st }) {
22
+ const MODELS = {};
23
+ let robotScale = 1;
24
+ async function load() {
25
+ const loader = new GLTFLoader();
26
+ await Promise.all(Object.entries(FILES).map(([k, url]) => loader.loadAsync(url).then(g => { MODELS[k] = g; }).catch(e => console.warn('hivey office: model', k, e))));
27
+ const c = new THREE.Vector3();
28
+ for (const [k, g] of Object.entries(MODELS)) {
29
+ g.scene.updateMatrixWorld(true);
30
+ const b = new THREE.Box3().setFromObject(g.scene, true); // precise: counts skinning
31
+ if (k === 'robot') { robotScale = 1.8 / Math.max(0.001, b.max.y - b.min.y); continue; }
32
+ // Kenney models sit off their origin: re-centre each on its base so it lands where it is placed
33
+ b.getCenter(c); g.scene.position.set(-c.x, -b.min.y, -c.z);
34
+ g.pivot = new THREE.Group(); g.pivot.add(g.scene);
35
+ // their light metals blow out under bloom: tone them down once (materials are shared by clones)
36
+ g.scene.traverse(m => { if (!m.isMesh) return; [].concat(m.material).forEach(x => {
37
+ if (x.userData.toned) return; x.userData.toned = true;
38
+ x.color?.multiplyScalar(x.map ? 0.7 : 0.42); x.metalness = Math.max(x.metalness ?? 0, 0.5); x.roughness = 0.4; x.envMapIntensity = 0.45;
39
+ }); });
40
+ }
41
+ }
42
+ function model(k, scale = 1) {
43
+ const g = MODELS[k]; if (!g?.pivot) return null;
44
+ const o = g.pivot.clone(true); o.scale.setScalar(scale);
45
+ o.traverse(m => { if (m.isMesh) { m.castShadow = true; m.receiveShadow = true; } });
46
+ return o;
47
+ }
48
+ function place(grp, k, scale, x, y, z, ry = 0) { const o = model(k, scale); if (!o) return null; o.position.set(x, y, z); o.rotation.y = ry; grp.add(o); return o; }
49
+ // ---------------------------------------------------------------- helpers
50
+ let seedN = 11;
51
+ const rnd = () => (seedN = (seedN * 16807) % 2147483647) / 2147483647;
52
+ const tex = (w, h, draw, rx = 1, ry = 1) => {
53
+ const c = document.createElement('canvas'); c.width = w; c.height = h; draw(c.getContext('2d'), w, h);
54
+ const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; t.anisotropy = 8;
55
+ if (rx !== 1 || ry !== 1) { t.wrapS = t.wrapT = THREE.RepeatWrapping; t.repeat.set(rx, ry); }
56
+ return t;
57
+ };
58
+ const cache = {};
59
+ const once = (k, make) => cache[k] || (cache[k] = make());
60
+ const put = (grp, geo, mat, x, y, z, sx = 1, sy = 1, sz = 1, ry = 0, shadow = true) => {
61
+ const m = mesh(geo, mat, x, y, z, sx, sy, sz, shadow); m.rotation.y = ry; grp.add(m); return m;
62
+ };
63
+ const NO_LINE = { visible: false };
64
+ const flat = m => { m.userData.outlineParameters = NO_LINE; return m; };
65
+
66
+ const U = {
67
+ box: new THREE.BoxGeometry(1, 1, 1), cyl: new THREE.CylinderGeometry(0.5, 0.5, 1, 28), sph: new THREE.SphereGeometry(0.5, 28, 20),
68
+ plane: new THREE.PlaneGeometry(1, 1), circ: new THREE.CircleGeometry(0.5, 48), ring: new THREE.RingGeometry(0.42, 0.5, 48),
69
+ torus: new THREE.TorusGeometry(0.5, 0.05, 10, 48), cap: new THREE.CapsuleGeometry(0.5, 1, 8, 20), ico: new THREE.IcosahedronGeometry(0.5, 0),
70
+ cone: new THREE.ConeGeometry(0.5, 1, 28, 1, true), wire: new THREE.IcosahedronGeometry(0.5, 2),
71
+ visor: new THREE.SphereGeometry(0.5, 32, 16, Math.PI / 2 - 1.0, 2.0, Math.PI * 0.3, Math.PI * 0.36),
72
+ };
73
+
74
+ // ---------------------------------------------------------------- materials
75
+ const SHELLS = ['#e9edf2', '#3a3f47', '#5b6470', '#1c1f24', '#a3abb5', '#c8b69a', '#2d3f66', '#7a2e2e'];
76
+ const shell = c => once('shell' + c, () => new THREE.MeshPhysicalMaterial({ color: c, metalness: 0.35, roughness: 0.38, clearcoat: 0.5, clearcoatRoughness: 0.25, envMapIntensity: 0.7 }));
77
+ const joint = once('joint', () => new THREE.MeshStandardMaterial({ color: '#15171b', roughness: 0.55, metalness: 0.4 }));
78
+ const glass = once('glass', () => new THREE.MeshPhysicalMaterial({ color: '#020306', metalness: 0.1, roughness: 0.12, clearcoat: 1, clearcoatRoughness: 0.05, envMapIntensity: 0.35 }));
79
+ const led = (color, k = 3) => once(`led${color}${k}`, () => new THREE.MeshStandardMaterial({ color, emissive: color, emissiveIntensity: k, toneMapped: false }));
80
+ const statusLed = s => led(st(s).color, s === 'idle' ? 1.1 : s === 'working' ? 3.0 : 2.4);
81
+ const accent = h => led(`hsl(${h}, 85%, 58%)`, 1.3);
82
+ const M = {
83
+ deck: once('deck', () => new THREE.MeshStandardMaterial({ map: deckTex(), roughness: 0.42, metalness: 0.65 })),
84
+ hull: once('hull', () => new THREE.MeshStandardMaterial({ map: hullTex(), roughness: 0.5, metalness: 0.6 })),
85
+ rib: once('rib', () => new THREE.MeshStandardMaterial({ color: '#2a3039', roughness: 0.35, metalness: 0.8 })),
86
+ dark: once('dark', () => new THREE.MeshStandardMaterial({ color: '#1a1e25', roughness: 0.35, metalness: 0.6 })),
87
+ slab: once('slab', () => new THREE.MeshPhysicalMaterial({ color: '#20252e', roughness: 0.25, metalness: 0.5, clearcoat: 0.8 })),
88
+ white: once('white', () => new THREE.MeshPhysicalMaterial({ color: '#e7ebf0', roughness: 0.3, metalness: 0.1, clearcoat: 0.6 })),
89
+ leather: once('leather', () => new THREE.MeshStandardMaterial({ color: '#2a2f3a', roughness: 0.6, metalness: 0.05 })),
90
+ pane: flat(once('pane', () => new THREE.MeshPhysicalMaterial({ color: '#9fd8ff', roughness: 0.05, metalness: 0, transparent: true, opacity: 0.16, depthWrite: false }))),
91
+ leaf: once('leaf', () => new THREE.MeshStandardMaterial({ color: '#36b26a', roughness: 0.5, flatShading: true })),
92
+ hazard: flat(once('hazard', () => new THREE.MeshStandardMaterial({ map: hazardTex(), roughness: 0.6, metalness: 0.3 }))),
93
+ space: flat(once('space', () => new THREE.MeshBasicMaterial({ map: spaceTex(1024, 512, true), toneMapped: false }))),
94
+ };
95
+
96
+ // ---------------------------------------------------------------- textures
97
+ function deckTex() { // brushed metal deck plates with seams, rivets and wear
98
+ return tex(512, 512, (g, w, h) => {
99
+ g.fillStyle = '#2b313b'; g.fillRect(0, 0, w, h);
100
+ for (let i = 0; i < 9000; i++) { g.fillStyle = `rgba(255,255,255,${rnd() * 0.035})`; g.fillRect(rnd() * w, rnd() * h, 1 + rnd() * 10, 1); }
101
+ for (let y = 0; y < 4; y++) for (let x = 0; x < 4; x++) {
102
+ const px = x * 128, py = y * 128, l = 18 + rnd() * 5;
103
+ g.fillStyle = `hsla(215, 12%, ${l}%, .55)`; g.fillRect(px + 3, py + 3, 122, 122);
104
+ g.strokeStyle = 'rgba(0,0,0,.65)'; g.lineWidth = 3; g.strokeRect(px + 1.5, py + 1.5, 125, 125);
105
+ g.strokeStyle = 'rgba(255,255,255,.07)'; g.lineWidth = 1; g.strokeRect(px + 5, py + 5, 118, 118);
106
+ g.fillStyle = 'rgba(200,210,225,.35)'; [[10, 10], [118, 10], [10, 118], [118, 118]].forEach(([a, b]) => { g.beginPath(); g.arc(px + a, py + b, 2.2, 0, 7); g.fill(); });
107
+ if ((x + y) % 3 === 0) { g.strokeStyle = 'rgba(0,0,0,.35)'; for (let k = 0; k < 6; k++) { g.beginPath(); g.moveTo(px + 30 + k * 12, py + 40); g.lineTo(px + 30 + k * 12, py + 88); g.stroke(); } }
108
+ }
109
+ });
110
+ }
111
+ function hullTex() { // wall panels
112
+ return tex(512, 512, (g, w, h) => {
113
+ g.fillStyle = '#353c47'; g.fillRect(0, 0, w, h);
114
+ for (let i = 0; i < 4000; i++) { g.fillStyle = `rgba(255,255,255,${rnd() * 0.03})`; g.fillRect(rnd() * w, rnd() * h, 1, 1 + rnd() * 8); }
115
+ g.strokeStyle = 'rgba(0,0,0,.55)'; g.lineWidth = 3;
116
+ [[0, 0, 256, 170], [256, 0, 256, 170], [0, 170, 170, 342], [170, 170, 342, 200], [170, 370, 342, 142]].forEach(r => g.strokeRect(...r));
117
+ g.fillStyle = 'rgba(0,0,0,.25)'; g.fillRect(200, 200, 280, 26); g.fillRect(30, 220, 100, 240);
118
+ g.fillStyle = 'rgba(255,200,60,.5)'; g.font = 'bold 18px monospace'; g.fillText('HV-01 DECK 3', 210, 219);
119
+ });
120
+ }
121
+ function hazardTex() {
122
+ return tex(256, 32, (g, w, h) => { g.fillStyle = '#e8b511'; g.fillRect(0, 0, w, h); g.fillStyle = '#16181c'; for (let x = -32; x < w; x += 32) { g.beginPath(); g.moveTo(x, h); g.lineTo(x + 16, 0); g.lineTo(x + 32, 0); g.lineTo(x + 16, h); g.fill(); } }, 1, 1);
123
+ }
124
+ function spaceTex(w, h, planet) { // stars, a nebula and (in viewports) a planet with its atmosphere
125
+ return tex(w, h, (g) => {
126
+ const bg = g.createLinearGradient(0, 0, w, h); bg.addColorStop(0, '#02030a'); bg.addColorStop(1, '#070b1d');
127
+ g.fillStyle = bg; g.fillRect(0, 0, w, h);
128
+ [['rgba(120,60,200,.35)', .25, .35, .45], ['rgba(20,160,200,.25)', .7, .6, .4], ['rgba(220,60,120,.18)', .5, .2, .3]].forEach(([c, x, y, r]) => {
129
+ const n = g.createRadialGradient(x * w, y * h, 0, x * w, y * h, r * w); n.addColorStop(0, c); n.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = n; g.fillRect(0, 0, w, h);
130
+ });
131
+ for (let i = 0; i < w * h / 900; i++) { const b = rnd(); g.fillStyle = `rgba(${200 + b * 55},${210 + b * 45},255,${0.3 + b * 0.7})`; const s = b > 0.97 ? 2.4 : b > 0.85 ? 1.6 : 1; g.fillRect(rnd() * w, rnd() * h, s, s); }
132
+ if (!planet) return;
133
+ const px = w * 0.72, py = h * 0.78, pr = h * 0.42;
134
+ const atm = g.createRadialGradient(px, py, pr * 0.9, px, py, pr * 1.25); atm.addColorStop(0, 'rgba(90,180,255,.55)'); atm.addColorStop(1, 'rgba(90,180,255,0)');
135
+ g.fillStyle = atm; g.beginPath(); g.arc(px, py, pr * 1.25, 0, 7); g.fill();
136
+ const pg = g.createRadialGradient(px - pr * 0.4, py - pr * 0.5, pr * 0.1, px, py, pr); pg.addColorStop(0, '#5fb3ff'); pg.addColorStop(0.5, '#1f5fa8'); pg.addColorStop(1, '#06162e');
137
+ g.fillStyle = pg; g.beginPath(); g.arc(px, py, pr, 0, 7); g.fill();
138
+ g.save(); g.beginPath(); g.arc(px, py, pr, 0, 7); g.clip();
139
+ g.fillStyle = 'rgba(255,255,255,.18)'; for (let i = 0; i < 9; i++) { g.beginPath(); g.ellipse(px - pr + rnd() * 2 * pr, py - pr + rnd() * 2 * pr, 40 + rnd() * 90, 6 + rnd() * 10, -0.2, 0, 7); g.fill(); }
140
+ g.fillStyle = 'rgba(40,140,80,.35)'; for (let i = 0; i < 5; i++) { g.beginPath(); g.ellipse(px - pr * .6 + rnd() * pr, py - pr * .5 + rnd() * pr, 30 + rnd() * 50, 18 + rnd() * 30, rnd(), 0, 7); g.fill(); }
141
+ const sh = g.createLinearGradient(px - pr, py - pr, px + pr, py + pr); sh.addColorStop(0.35, 'rgba(0,0,0,0)'); sh.addColorStop(1, 'rgba(0,0,0,.8)');
142
+ g.fillStyle = sh; g.fillRect(px - pr, py - pr, pr * 2, pr * 2); g.restore();
143
+ g.fillStyle = '#c9ccd6'; g.beginPath(); g.arc(w * 0.18, h * 0.22, h * 0.05, 0, 7); g.fill(); // moon
144
+ });
145
+ }
146
+ const screenTex = kind => once('screen' + kind, () => tex(256, 160, (g, w, h) => { // wall displays
147
+ g.fillStyle = '#04121c'; g.fillRect(0, 0, w, h);
148
+ g.strokeStyle = '#2fd3ff'; g.fillStyle = '#2fd3ff'; g.lineWidth = 2; g.strokeRect(4, 4, w - 8, h - 8);
149
+ g.font = 'bold 12px monospace';
150
+ if (kind === 0) { g.fillText('NAV // SECTOR 7G', 12, 22); for (let r = 20; r < 70; r += 16) { g.beginPath(); g.arc(128, 92, r, 0, 7); g.stroke(); } g.beginPath(); g.moveTo(128, 92); g.lineTo(190, 60); g.stroke(); g.fillStyle = '#ffcf3a'; g.fillRect(160, 70, 5, 5); g.fillRect(100, 110, 4, 4); }
151
+ else if (kind === 1) { g.fillText('POWER 98.2%', 12, 22); for (let i = 0; i < 12; i++) { const bh = 20 + rnd() * 90; g.fillStyle = i % 4 ? '#2fd3ff' : '#ffcf3a'; g.fillRect(16 + i * 19, 145 - bh, 12, bh); } }
152
+ else if (kind === 2) { g.fillText('HIVEY-1 CREW', 12, 22); g.beginPath(); g.moveTo(30, 90); g.lineTo(90, 60); g.lineTo(200, 60); g.lineTo(230, 90); g.lineTo(200, 120); g.lineTo(90, 120); g.closePath(); g.stroke(); g.fillStyle = '#ff5d7a'; g.fillRect(120, 85, 8, 8); g.fillStyle = '#4ade80'; g.fillRect(150, 75, 8, 8); g.fillRect(170, 98, 8, 8); }
153
+ else { g.fillText('TELEMETRY', 12, 22); g.beginPath(); for (let x = 12; x < w - 12; x += 4) g.lineTo(x, 95 + Math.sin(x / 14) * 25 + rnd() * 10); g.stroke(); g.strokeStyle = '#ffcf3a'; g.beginPath(); for (let x = 12; x < w - 12; x += 4) g.lineTo(x, 120 + Math.cos(x / 22) * 12); g.stroke(); }
154
+ }));
155
+ const screenMat = k => flat(once('screenMat' + k, () => new THREE.MeshStandardMaterial({ color: '#000', emissive: '#fff', emissiveMap: screenTex(k), emissiveIntensity: 1.4, toneMapped: false })));
156
+ const rackTex = once('rackTex', () => tex(128, 256, (g, w, h) => {
157
+ g.fillStyle = '#06080c'; g.fillRect(0, 0, w, h);
158
+ for (let y = 8; y < h - 8; y += 22) { g.fillStyle = '#12161d'; g.fillRect(6, y, w - 12, 18); for (let x = 12; x < w - 12; x += 9) if (rnd() < 0.55) { g.fillStyle = rnd() < 0.8 ? '#35e0ff' : rnd() < 0.5 ? '#4ade80' : '#ffb020'; g.fillRect(x, y + 7, 4, 4); } }
159
+ }));
160
+ const holoTex = s => once('holo' + s, () => tex(256, 160, (g, w, h) => { // a desk screen when not working
161
+ const c = st(s).color;
162
+ g.fillStyle = 'rgba(4,14,24,.85)'; g.fillRect(0, 0, w, h); g.strokeStyle = c; g.lineWidth = 3; g.strokeRect(3, 3, w - 6, h - 6);
163
+ g.fillStyle = c; g.globalAlpha = 0.85; for (let i = 0; i < 6; i++) g.fillRect(16, 24 + i * 20, 60 + ((i * 53) % 140), 7);
164
+ g.globalAlpha = 1; g.font = 'bold 18px monospace'; g.fillText(s.toUpperCase(), w - 110, h - 16);
165
+ }));
166
+
167
+ // ---------------------------------------------------------------- the crew: mini robots
168
+ // A hash of the name picks shell, head, eyes, antenna and whether it hovers; shoulder pods and
169
+ // chest strip glow in its team colour, its eyes in its status colour.
170
+ function glbRobot(h, status, small, seed) {
171
+ const r = (k, n) => hue(seed + '|' + k) % n;
172
+ const root = new THREE.Group(), o = SkeletonUtils.clone(MODELS.robot.scene);
173
+ o.scale.setScalar(robotScale * (small ? 0.5 : 1));
174
+ const shellC = SHELLS[r('shell', SHELLS.length)];
175
+ o.traverse(m => {
176
+ if (!m.isMesh) return;
177
+ m.castShadow = m.receiveShadow = true; m.frustumCulled = false;
178
+ const one = x => {
179
+ const c = x.clone();
180
+ if (x.name === 'Main') { c.color.set(shellC); c.metalness = 0.55; c.roughness = 0.32; }
181
+ else if (x.name === 'Grey') { c.color.set('#262b33'); c.metalness = 0.6; c.roughness = 0.4; c.emissive = new THREE.Color(`hsl(${h}, 85%, 50%)`); c.emissiveIntensity = 0.45; }
182
+ else { c.metalness = 0.3; c.roughness = 0.18; }
183
+ return c;
184
+ };
185
+ m.material = Array.isArray(m.material) ? m.material.map(one) : one(m.material);
186
+ });
187
+ root.add(o);
188
+ const mixer = new THREE.AnimationMixer(o), clips = MODELS.robot.animations;
189
+ const act = n => { const c = clips.find(x => x.name === n); return c ? mixer.clipAction(c) : null; };
190
+ const still = (n, at) => { const a = act(n); if (!a) return; a.play(); a.time = a.getClip().duration * at; a.paused = true; mixer.update(0); };
191
+ let idle = null, nod = null;
192
+ if (status === 'working') { idle = act('Idle'); idle?.play(); nod = act('Yes'); if (nod) { nod.setLoop(THREE.LoopOnce); nod.clampWhenFinished = false; } }
193
+ else if (status === 'blocked') act('Wave')?.play();
194
+ else if (status === 'done') still('ThumbsUp', 0.45);
195
+ else if (status === 'idle' && !small) still('Sitting', 0.98);
196
+ else still('Idle', 0);
197
+ const animated = status === 'working' || status === 'blocked';
198
+ let nextNod = 2 + Math.random() * 4;
199
+ // working robots idle and nod every few seconds, as if confirming each step
200
+ const tick = (dt, t) => {
201
+ if (!animated) return;
202
+ if (nod && idle && t > nextNod) { nod.reset().fadeIn(0.25).play(); idle.fadeOut(0.25); nextNod = t + 4 + Math.random() * 4; setTimeout(() => { idle.reset().fadeIn(0.3).play(); nod.fadeOut(0.3); }, nod.getClip().duration * 1000); }
203
+ mixer.update(dt);
204
+ };
205
+ return { bot: root, body: new THREE.Group(), head: new THREE.Group(), arms: [], wings: [], scan: null, hover: false, glb: true, tick, seated: status === 'idle' && !small };
206
+ }
207
+
208
+ function makeRobot(h, status, small = false, seed = '') {
209
+ if (MODELS.robot) return glbRobot(h, status, small, seed);
210
+ const r = (k, n) => hue(seed + '|' + k) % n;
211
+ const sh = shell(SHELLS[r('shell', SHELLS.length)]);
212
+ const trim = shell(SHELLS[(r('shell', SHELLS.length) + 3) % SHELLS.length]);
213
+ const eye = statusLed(status), acc = accent(h);
214
+ const hover = r('hover', 4) === 0;
215
+ const bot = new THREE.Group(), body = new THREE.Group(); bot.add(body);
216
+ // torso
217
+ put(body, U.cap, sh, 0, 0.82, 0, 0.6, 0.32, 0.48);
218
+ put(body, U.box, glass, 0, 0.86, 0.2, 0.34, 0.24, 0.06);
219
+ put(body, U.box, acc, 0, 0.8, 0.235, 0.22, 0.03, 0.01, 0, false);
220
+ put(body, U.cyl, joint, 0, 0.5, 0, 0.42, 0.12, 0.34);
221
+ if (hover) { // thruster skirt instead of legs
222
+ put(body, U.cyl, trim, 0, 0.36, 0, 0.36, 0.2, 0.3);
223
+ const ring = put(body, U.torus, acc, 0, 0.24, 0, 0.5, 0.5, 0.5, 0, false); ring.rotation.x = Math.PI / 2;
224
+ put(body, U.circ, led('#8be9ff', 4), 0, 0.23, 0, 0.3, 0.3, 1, 0, false).rotation.x = Math.PI / 2;
225
+ } else { // seated legs
226
+ [-1, 1].forEach(sx => {
227
+ const th = put(body, U.cap, sh, 0.14 * sx, 0.46, 0.2, 0.17, 0.18, 0.17); th.rotation.x = Math.PI / 2;
228
+ put(body, U.sph, joint, 0.14 * sx, 0.46, 0.42, 0.15, 0.15, 0.15);
229
+ put(body, U.cap, trim, 0.14 * sx, 0.22, 0.44, 0.15, 0.2, 0.15);
230
+ put(body, U.box, joint, 0.14 * sx, 0.04, 0.5, 0.16, 0.07, 0.24);
231
+ });
232
+ }
233
+ // neck and head
234
+ put(body, U.cyl, joint, 0, 1.1, 0, 0.14, 0.12, 0.14);
235
+ const head = new THREE.Group(); head.position.set(0, 1.36, 0); body.add(head);
236
+ const pill = r('head', 3);
237
+ if (pill === 0) { const hh = put(head, U.cap, sh, 0, 0, 0, 0.5, 0.42, 0.5); hh.rotation.z = Math.PI / 2; }
238
+ else put(head, U.sph, sh, 0, 0, 0, pill === 1 ? 0.78 : 0.7, pill === 1 ? 0.6 : 0.68, 0.66);
239
+ put(head, U.visor, glass, 0, 0.01, 0.0, 0.8, 0.72, 0.72);
240
+ const eyes = r('eyes', 3);
241
+ let scan = null;
242
+ if (eyes === 0) [-1, 1].forEach(sx => { const e = put(head, U.cap, eye, 0.11 * sx, 0.02, 0.262, 0.075, 0.07, 0.04, 0, false); e.rotation.z = Math.PI / 2; });
243
+ else if (eyes === 1) { put(head, U.box, led('#0a0f16', 0.2), 0, 0.02, 0.258, 0.38, 0.08, 0.02, 0, false); scan = put(head, U.box, eye, 0, 0.02, 0.268, 0.14, 0.07, 0.02, 0, false); }
244
+ else { const ringE = put(head, U.torus, eye, 0, 0.02, 0.262, 0.2, 0.2, 0.2, 0, false); put(head, U.sph, eye, 0, 0.02, 0.258, 0.07, 0.07, 0.04, 0, false); ringE.rotation.x = 0; }
245
+ [-1, 1].forEach(sx => { // ear pods
246
+ const pod = put(head, U.cyl, trim, 0.37 * sx, 0, 0, 0.17, 0.08, 0.17); pod.rotation.z = Math.PI / 2;
247
+ const ring = put(head, U.torus, acc, 0.415 * sx, 0, 0, 0.13, 0.13, 0.13, 0, false); ring.rotation.y = Math.PI / 2;
248
+ });
249
+ if (r('antenna', 2) === 0) { put(head, U.cyl, joint, 0.16, 0.34, -0.05, 0.02, 0.24, 0.02); put(head, U.sph, eye, 0.16, 0.47, -0.05, 0.06, 0.06, 0.06, 0, false); }
250
+ // arms: shoulder, upper arm, elbow, forearm, hand
251
+ const arms = [-1, 1].map(sx => {
252
+ const pivot = new THREE.Group(); pivot.position.set(0.37 * sx, 0.98, 0); body.add(pivot);
253
+ put(pivot, U.sph, trim, 0, 0, 0, 0.17, 0.17, 0.17);
254
+ put(pivot, U.cap, sh, 0, -0.16, 0, 0.1, 0.12, 0.1);
255
+ put(pivot, U.sph, joint, 0, -0.29, 0, 0.09, 0.09, 0.09);
256
+ put(pivot, U.cap, sh, 0, -0.41, 0, 0.09, 0.1, 0.09);
257
+ put(pivot, U.sph, joint, 0, -0.53, 0, 0.1, 0.08, 0.1);
258
+ pivot.rotation.x = -1.0; pivot.rotation.z = 0.06 * sx;
259
+ return pivot;
260
+ });
261
+ if (hover) bot.position.y = 0.15;
262
+ head.rotation.x = -0.12;
263
+ bot.scale.setScalar(small ? 0.5 : 1.15);
264
+ return { bot, body, head, arms, wings: [], scan, hover };
265
+ }
266
+
267
+ // ---------------------------------------------------------------- a workstation
268
+ function makeStation(g, a, h, workMat) {
269
+ if (MODELS.desk) {
270
+ place(g, 'desk', 3.1, 0, 0, 0.05, 0);
271
+ put(g, U.box, accent(h), 0, 0.03, 0.5, 2.1, 0.03, 0.02, 0, false);
272
+ const scr = put(g, U.plane, a.status === 'working' ? workMat : holoMat(a.status), 0, 1.75, 0.3, 1.2, 0.62, 1, Math.PI, false);
273
+ scr.visible = a.status === 'working' || a.status === 'blocked';
274
+ const chair = new THREE.Group(); chair.position.set(0, 0, -0.95); g.add(chair);
275
+ place(chair, 'chair', 3.2, 0, 0, 0, Math.PI);
276
+ if (a.status !== 'idle') { chair.position.set(0.95, 0, -1.1); chair.rotation.y = -0.6; }
277
+ return { screen: scr, chair };
278
+ }
279
+ put(g, U.box, M.slab, 0, 0.78, 0, 2.1, 0.07, 1.0);
280
+ put(g, U.box, accent(h), 0, 0.765, 0.505, 2.1, 0.025, 0.012, 0, false);
281
+ put(g, U.box, M.dark, 0, 0.39, -0.1, 1.6, 0.74, 0.12);
282
+ put(g, U.box, M.dark, 0, 0.02, 0, 1.9, 0.04, 0.8);
283
+ // holo keyboard and a floating screen that faces the robot
284
+ put(g, U.plane, flat(led(st(a.status).color, 0.9)), 0, 0.82, -0.2, 0.7, 0.22, 1, 0, false).rotation.x = -Math.PI / 2;
285
+ const scr = put(g, U.plane, a.status === 'working' ? workMat : holoMat(a.status), 0, 1.38, 0.05, 1.15, 0.66, 1, Math.PI, false);
286
+ scr.rotation.x = 0.12;
287
+ put(g, U.box, M.dark, 0, 0.95, 0.12, 0.08, 0.3, 0.05);
288
+ // chair (hovering robots don't need one)
289
+ const chair = new THREE.Group(); chair.position.set(0, 0, -0.95); g.add(chair);
290
+ put(chair, U.box, M.leather, 0, 0.5, 0, 0.7, 0.1, 0.62); put(chair, U.box, M.leather, 0, 1.05, -0.32, 0.66, 1.0, 0.1);
291
+ put(chair, U.box, accent(h), 0, 1.05, -0.38, 0.05, 0.9, 0.01, 0, false); put(chair, U.cyl, M.rib, 0, 0.25, 0, 0.08, 0.5, 0.08); put(chair, U.cyl, M.dark, 0, 0.03, 0, 0.6, 0.05, 0.6);
292
+ return { screen: scr, chair };
293
+ }
294
+ const holoMats = {};
295
+ function holoMat(s) {
296
+ return holoMats[s] || (holoMats[s] = flat(new THREE.MeshBasicMaterial({ map: holoTex(s), transparent: true, opacity: 0.5, side: THREE.DoubleSide, toneMapped: false, depthWrite: false })));
297
+ }
298
+
299
+ // ---------------------------------------------------------------- furniture
300
+ function pod(grp, x, z) { // hydroponic plant pod
301
+ put(grp, U.cyl, M.rib, x, 0.12, z, 0.7, 0.24, 0.7); put(grp, U.cyl, M.rib, x, 1.62, z, 0.7, 0.1, 0.7);
302
+ put(grp, U.cyl, M.pane, x, 0.9, z, 0.62, 1.4, 0.62, 0, false);
303
+ for (let i = 0; i < 6; i++) put(grp, U.ico, M.leaf, x + Math.cos(i * 2.1) * 0.12, 0.45 + i * 0.14, z + Math.sin(i * 2.1) * 0.12, 0.3, 0.38, 0.3, i);
304
+ const gl = put(grp, U.torus, led('#e879f9', 3), x, 1.56, z, 0.62, 0.62, 0.62, 0, false); gl.rotation.x = Math.PI / 2;
305
+ }
306
+ function sofa(grp, x, z, len, ry, h) {
307
+ const g = new THREE.Group(); g.position.set(x, 0, z); g.rotation.y = ry; grp.add(g);
308
+ put(g, U.box, M.dark, 0, 0.2, 0, len, 0.22, 0.95);
309
+ put(g, U.box, M.leather, 0, 0.42, 0.05, len - 0.4, 0.2, 0.82);
310
+ put(g, U.box, M.leather, 0, 0.72, -0.36, len, 0.6, 0.24);
311
+ [-1, 1].forEach(sx => put(g, U.box, M.leather, sx * (len / 2 - 0.12), 0.5, 0, 0.24, 0.42, 0.95));
312
+ put(g, U.box, accent(h), 0, 0.1, 0.48, len, 0.02, 0.01, 0, false);
313
+ }
314
+ function rack(grp, x, z, ry) {
315
+ const g = new THREE.Group(); g.position.set(x, 0, z); g.rotation.y = ry; grp.add(g);
316
+ put(g, U.box, M.dark, 0, 1.1, 0, 0.9, 2.2, 0.8);
317
+ put(g, U.plane, flat(once('rackFace', () => new THREE.MeshStandardMaterial({ color: '#000', emissive: '#fff', emissiveMap: rackTex, emissiveIntensity: 2, toneMapped: false }))), 0, 1.1, 0.41, 0.8, 2.0, 1, 0, false);
318
+ }
319
+ function viewport(grp, x, z, ry, w = 3.0, hh = 1.9) {
320
+ const g = new THREE.Group(); g.position.set(x, 1.95, z); g.rotation.y = ry; grp.add(g);
321
+ put(g, U.plane, M.space, 0, 0, 0.01, w, hh, 1, 0, false);
322
+ put(g, U.box, M.rib, 0, hh / 2 + 0.08, 0.08, w + 0.4, 0.16, 0.2); put(g, U.box, M.rib, 0, -hh / 2 - 0.08, 0.1, w + 0.4, 0.16, 0.26);
323
+ [-1, 1].forEach(sx => put(g, U.box, M.rib, sx * (w / 2 + 0.12), 0, 0.08, 0.24, hh + 0.3, 0.2));
324
+ put(g, U.box, led('#5ad8ff', 2.4), 0, -hh / 2 + 0.01, 0.2, w, 0.02, 0.02, 0, false);
325
+ put(g, U.box, M.rib, 0, 0, 0.05, 0.06, hh, 0.06);
326
+ }
327
+ function wallScreen(grp, x, z, ry, k, w = 1.3, hh = 0.8, y = 1.95) {
328
+ const g = new THREE.Group(); g.position.set(x, y, z); g.rotation.y = ry; grp.add(g);
329
+ put(g, U.box, M.dark, 0, 0, 0.03, w + 0.1, hh + 0.1, 0.06); put(g, U.plane, screenMat(k), 0, 0, 0.065, w, hh, 1, 0, false);
330
+ }
331
+
332
+
333
+ // ---------------------------------------------------------------- the ship's exterior
334
+ // The deck is a cutaway section of a big ship: hull and keel under it, a superstructure behind it,
335
+ // a spine with spherical modules and an engine block to the left, a domed bridge to the right.
336
+ // Hull blocks get world-scaled panel UVs, lit window dots (emissive map) and instanced greebles.
337
+ function panelTex() {
338
+ return tex(512, 512, (g, w, h) => {
339
+ g.fillStyle = '#8b929c'; g.fillRect(0, 0, w, h);
340
+ for (let i = 0; i < 60; i++) { const pw = 40 + rnd() * 160, ph = 30 + rnd() * 120, x = rnd() * w, y = rnd() * h; g.fillStyle = `hsl(215, 6%, ${44 + rnd() * 18}%)`; g.fillRect(x, y, pw, ph); g.strokeStyle = 'rgba(20,24,30,.55)'; g.lineWidth = 2; g.strokeRect(x, y, pw, ph); }
341
+ for (let i = 0; i < 4000; i++) { g.fillStyle = `rgba(0,0,0,${rnd() * 0.08})`; g.fillRect(rnd() * w, rnd() * h, 2, 2); }
342
+ g.strokeStyle = 'rgba(15,18,24,.7)'; g.lineWidth = 3; for (let x = 0; x <= w; x += 128) { g.beginPath(); g.moveTo(x, 0); g.lineTo(x, h); g.stroke(); } for (let y = 0; y <= h; y += 128) { g.beginPath(); g.moveTo(0, y); g.lineTo(w, y); g.stroke(); }
343
+ g.fillStyle = 'rgba(30,34,40,.85)'; for (let i = 0; i < 40; i++) g.fillRect(rnd() * w, rnd() * h, 14, 7); // dark window frames
344
+ }, 1, 1);
345
+ }
346
+ function lightsTex() { // lit windows: a few strips and dots
347
+ return tex(512, 512, (g, w, h) => {
348
+ g.fillStyle = '#000'; g.fillRect(0, 0, w, h);
349
+ for (let i = 0; i < 26; i++) { const x = rnd() * w, y = rnd() * h, n = 2 + Math.floor(rnd() * 6); for (let k = 0; k < n; k++) { g.fillStyle = rnd() < 0.8 ? '#ffd27a' : '#9fe3ff'; g.fillRect(x + k * 12, y, 7, 5); } }
350
+ for (let i = 0; i < 40; i++) { g.fillStyle = rnd() < 0.85 ? '#ffd27a' : '#9fe3ff'; g.fillRect(rnd() * w, rnd() * h, 4, 4); }
351
+ }, 1, 1);
352
+ }
353
+ const HULL = once('hullExt', () => {
354
+ const map = panelTex(), em = lightsTex();
355
+ [map, em].forEach(t => { t.wrapS = t.wrapT = THREE.RepeatWrapping; });
356
+ return new THREE.MeshStandardMaterial({ color: '#a7adb6', map, emissiveMap: em, emissive: '#ffffff', emissiveIntensity: 1.8, roughness: 0.5, metalness: 0.6 });
357
+ });
358
+ const HULL_DARK = once('hullDark', () => new THREE.MeshStandardMaterial({ color: '#4a5059', roughness: 0.45, metalness: 0.7 }));
359
+ function hullGeo(w, h, d, scale = 5) { // a box whose texture repeats per world unit, so panels keep their size
360
+ const geo = new THREE.BoxGeometry(w, h, d), uv = geo.attributes.uv;
361
+ const dims = [[d, h], [d, h], [w, d], [w, d], [w, h], [w, h]];
362
+ for (let f = 0; f < 6; f++) for (let v = 0; v < 4; v++) { const i = f * 4 + v; uv.setXY(i, uv.getX(i) * dims[f][0] / scale, uv.getY(i) * dims[f][1] / scale); }
363
+ return geo;
364
+ }
365
+ const greebles = [];
366
+ function block(grp, x, y, z, w, h, d, mat = HULL, density = 1) {
367
+ const m = new THREE.Mesh(hullGeo(w, h, d), mat); m.position.set(x, y, z); m.castShadow = m.receiveShadow = true; grp.add(m);
368
+ // greebles on the top and on the faces we can see (+x, +z)
369
+ const n = Math.round(w * d * 0.12 * density);
370
+ for (let i = 0; i < n; i++) greebles.push([x + (rnd() - 0.5) * (w - 0.4), y + h / 2, z + (rnd() - 0.5) * (d - 0.4), 0.2 + rnd() * 0.9, 0.08 + rnd() * 0.35, 0.2 + rnd() * 0.9]);
371
+ const nf = Math.round(w * h * 0.05 * density);
372
+ for (let i = 0; i < nf; i++) greebles.push([x + (rnd() - 0.5) * (w - 0.4), y + (rnd() - 0.5) * (h - 0.3), z + d / 2, 0.2 + rnd() * 0.7, 0.1 + rnd() * 0.4, 0.06 + rnd() * 0.2]);
373
+ return m;
374
+ }
375
+ function glowSprite(color) {
376
+ return once('glow' + color, () => new THREE.SpriteMaterial({ map: tex(128, 128, (g) => { const r = g.createRadialGradient(64, 64, 0, 64, 64, 64); r.addColorStop(0, '#ffffff'); r.addColorStop(0.25, color); r.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = r; g.fillRect(0, 0, 128, 128); }), blending: THREE.AdditiveBlending, depthWrite: false, transparent: true, toneMapped: false }));
377
+ }
378
+ function navLight(grp, x, y, z, color) {
379
+ put(grp, U.sph, led(color, 4), x, y, z, 0.25, 0.25, 0.25, 0, false);
380
+ const s = new THREE.Sprite(glowSprite(color)); s.position.set(x, y, z); s.scale.setScalar(1.6); grp.add(s);
381
+ }
382
+ function exterior(grp, x0, x1, z0, z1) {
383
+ greebles.length = 0;
384
+ const fw = x1 - x0, fd = z1 - z0, cx = (x0 + x1) / 2, cz = (z0 + z1) / 2;
385
+ // hull under the deck: plating, a stepped keel, a low rim at the open edges
386
+ block(grp, cx, -1.35, cz, fw + 1.6, 2.4, fd + 1.6, HULL, 0.3);
387
+ block(grp, cx - 2, -3.3, cz - 1, fw * 0.82, 1.6, fd * 0.7, HULL, 0.4);
388
+ block(grp, cx - 4, -4.6, cz - 2, fw * 0.55, 1.0, fd * 0.4, HULL_DARK, 0.5);
389
+ put(grp, U.box, HULL_DARK, cx, 0.22, z1 + 0.5, fw + 1.6, 0.5, 0.6); put(grp, U.box, HULL_DARK, x1 + 0.5, 0.22, cz, 0.6, 0.5, fd + 1.6);
390
+ put(grp, U.box, led('#36d6ff', 2.2), cx, 0.48, z1 + 0.82, fw + 1.6, 0.04, 0.04, 0, false); put(grp, U.box, led('#36d6ff', 2.2), x1 + 0.82, 0.48, cz, 0.04, 0.04, fd + 1.6, 0, false);
391
+ // superstructure behind the back wall: stepped decks, a command tower, a dish, antennas, radiator wings
392
+ block(grp, cx, 1.1, z0 - 3.6, fw + 1.6, 5.0, 6.6);
393
+ let x = x0 + 1;
394
+ while (x < x1 - 2) { const w = 4 + rnd() * 7, hh = 1 + rnd() * 2.2, d = 2.4 + rnd() * 2.6; block(grp, Math.min(x + w / 2, x1 - w / 2), 3.6 + hh / 2, z0 - 1.8 - d / 2 - rnd() * 1.5, w, hh, d); x += w + 0.6 + rnd() * 2; }
395
+ const tx = cx + fw * 0.12, tz = z0 - 4.5;
396
+ block(grp, tx, 7.2, tz, 4.2, 4.2, 3.6); block(grp, tx, 9.9, tz, 2.6, 1.4, 2.4, HULL_DARK);
397
+ put(grp, U.sph, HULL, tx, 10.6, tz, 2.4, 1.4, 2.4);
398
+ put(grp, U.box, led('#9fe3ff', 2.5), tx, 8.4, tz + 1.82, 3.6, 0.35, 0.04, 0, false); // tower bridge windows
399
+ [[-0.8, 2.6], [0.6, 3.6], [1.1, 1.8]].forEach(([dx, hgt]) => { put(grp, U.cyl, HULL_DARK, tx + dx, 11.2 + hgt / 2, tz, 0.08, hgt, 0.08); navLight(grp, tx + dx, 11.2 + hgt, tz, '#ffffff'); });
400
+ if (!place(grp, 'dishL', 3.2, tx - fw * 0.3, 3.6, z0 - 3.4, 0.6)) { const dish = put(grp, U.sph, HULL_DARK, tx - fw * 0.3, 5.6, z0 - 3.4, 3.2, 1.0, 3.2); dish.rotation.x = -0.5; }
401
+ place(grp, 'dish', 3, cx - fw * 0.42, 3.6, z0 - 1.6, -0.4); place(grp, 'wireless', 3.5, cx + fw * 0.38, 3.6, z0 - 2.2); place(grp, 'wireless', 3.5, cx - fw * 0.05, 3.6, z0 - 5.5, 1);
402
+ const radMat = once('radiator', () => new THREE.MeshStandardMaterial({ map: tex(256, 128, (g, w, h) => { g.fillStyle = '#16233f'; g.fillRect(0, 0, w, h); g.strokeStyle = '#3a5ea8'; g.lineWidth = 2; for (let i = 0; i < w; i += 16) { g.beginPath(); g.moveTo(i, 0); g.lineTo(i, h); g.stroke(); } for (let j = 0; j < h; j += 16) { g.beginPath(); g.moveTo(0, j); g.lineTo(w, j); g.stroke(); } }), roughness: 0.3, metalness: 0.8 }));
403
+ [-1, 1].forEach(sd => { const r = put(grp, U.box, radMat, cx + sd * fw * 0.28, 4.2, z0 - 10.5, fw * 0.3, 0.12, 6.5); r.rotation.x = 0.12; put(grp, U.box, HULL_DARK, cx + sd * fw * 0.28, 4.0, z0 - 7.2, 0.5, 0.5, 1.6); });
404
+ // spine to the left with two spherical modules, then the engine block with glowing thrusters
405
+ const sy = 0.2, sz = cz - 2.5, len = 30;
406
+ const spine = put(grp, U.box, HULL, x0 - 1.5 - len / 2, sy, sz, len, 2.8, 3.2); spine.geometry = hullGeo(len, 2.8, 3.2); spine.scale.set(1, 1, 1);
407
+ [x0 - 10, x0 - 18.5].forEach(px => {
408
+ const sph = new THREE.Mesh(new THREE.SphereGeometry(4, 40, 28), HULL); sph.position.set(px, sy, sz); sph.castShadow = sph.receiveShadow = true;
409
+ sph.material = HULL; grp.add(sph);
410
+ const band = put(grp, U.torus, HULL_DARK, px, sy, sz, 8.2, 8.2, 8.2, 0, true); band.rotation.y = Math.PI / 2;
411
+ for (let i = 0; i < 6; i++) put(grp, U.box, led('#ffd27a', 2.2), px - 1.6 + i * 0.6, sy + 2.6 - (i % 2) * 0.3, sz + 3.05, 0.25, 0.14, 0.05, 0, false);
412
+ });
413
+ for (let i = 0; i < 8; i++) put(grp, U.box, HULL_DARK, x0 - 4 - i * 3.4, sy + 1.6, sz, 0.3, 0.4, 3.6); // spine ribs
414
+ const ex = x0 - 1.5 - len - 4.5;
415
+ block(grp, ex, sy + 0.6, sz, 9, 8, 11);
416
+ block(grp, ex + 1, sy + 5.6, sz - 1, 5, 2, 7, HULL_DARK);
417
+ [[-2.4, -2.4], [-2.4, 2.4], [2.0, -2.4], [2.0, 2.4]].forEach(([dy, dz]) => {
418
+ const n = put(grp, U.cyl, HULL_DARK, ex - 5.4, sy + 0.6 + dy, sz + dz, 2.2, 2.0, 2.2); n.rotation.z = Math.PI / 2;
419
+ const c = put(grp, U.circ, led('#5ad8ff', 5), ex - 6.42, sy + 0.6 + dy, sz + dz, 1.9, 1.9, 1, 0, false); c.rotation.y = -Math.PI / 2;
420
+ const s = new THREE.Sprite(glowSprite('#4cc8ff')); s.position.set(ex - 7.4, sy + 0.6 + dy, sz + dz); s.scale.setScalar(5.5); grp.add(s);
421
+ });
422
+ navLight(grp, ex - 1, sy + 6.8, sz + 5.6, '#ff3b3b');
423
+ // all greebles in two instanced draws
424
+ [HULL_DARK, HULL].forEach((mat, k) => {
425
+ const list = greebles.filter((_, i) => i % 2 === k);
426
+ const inst = new THREE.InstancedMesh(U.box, mat, list.length), m4 = new THREE.Matrix4(), q = new THREE.Quaternion();
427
+ list.forEach(([gx, gy, gz, w, h, d], i) => inst.setMatrixAt(i, m4.compose(new THREE.Vector3(gx, gy, gz), q, new THREE.Vector3(w, h, d))));
428
+ inst.castShadow = inst.receiveShadow = true; inst.computeBoundingBox?.(); inst.computeBoundingSphere(); grp.add(inst);
429
+ });
430
+ }
431
+
432
+
433
+ // ---------------------------------------------------------------- the captain's bridge (the CEO's room)
434
+ // A separate cutaway room in the nose: its own hull, a main viewscreen, gold trim, side consoles.
435
+ // Returns where to put the CEO's desks and the room label.
436
+ function bridge(grp, e) {
437
+ const BW = 10, BD = Math.min(Math.max((e.z1 - e.z0) * 0.7, 9), 12), cz = (e.z0 + e.z1) / 2 - 0.5;
438
+ const bx0 = e.x1 + 1.6, bx1 = bx0 + BW, bz0 = cz - BD / 2, bz1 = cz + BD / 2, bxc = (bx0 + bx1) / 2;
439
+ const gold = led('#ffc94a', 2.2);
440
+ block(grp, bxc, -1.35, cz, BW + 1.2, 2.4, BD + 1.2, HULL, 0.3);
441
+ block(grp, bxc + 1, -3.1, cz, BW * 0.8, 1.4, BD * 0.6, HULL_DARK, 0.4);
442
+ const fl = put(grp, U.plane, M.deck, bxc, 0.004, cz, BW, BD, 1, 0, false); fl.rotation.x = -Math.PI / 2; fl.receiveShadow = true;
443
+ const inlay = put(grp, U.ring, gold, bxc, 0.012, cz + 0.4, 3.4, 3.4, 1, 0, false); inlay.rotation.x = -Math.PI / 2;
444
+ // connecting gangway from the main deck
445
+ const gw = put(grp, U.plane, M.deck, (e.x1 + bx0) / 2 + 0.3, 0.003, cz, bx0 - e.x1 + 0.6, 2.4, 1, 0, false); gw.rotation.x = -Math.PI / 2;
446
+ put(grp, U.box, HULL, (e.x1 + bx0) / 2 + 0.3, -0.7, cz, bx0 - e.x1 + 0.6, 1.4, 2.6);
447
+ // back wall with the main viewscreen, left wall with a doorway, low rims in front and at the nose
448
+ put(grp, U.box, M.hull, bxc, 1.7, bz0 - 0.15, BW + 0.3, 3.4, 0.3);
449
+ viewport(grp, bxc, bz0 + 0.02, 0, 6.4, 2.4);
450
+ put(grp, U.box, gold, bxc, 3.25, bz0 + 0.03, BW, 0.06, 0.04, 0, false);
451
+ [[bz0, cz - 1.3], [cz + 1.3, bz1]].forEach(([a, b]) => put(grp, U.box, M.hull, bx0 - 0.15, 1.7, (a + b) / 2, 0.3, 3.4, b - a));
452
+ put(grp, U.box, HULL_DARK, bxc, 0.25, bz1 + 0.3, BW + 0.6, 0.5, 0.6); put(grp, U.box, gold, bxc, 0.52, bz1 + 0.58, BW + 0.6, 0.04, 0.04, 0, false);
453
+ put(grp, U.box, HULL_DARK, bx1 + 0.3, 0.25, cz, 0.6, 0.5, BD + 0.6); put(grp, U.box, gold, bx1 + 0.58, 0.52, cz, 0.04, 0.04, BD + 0.6, 0, false);
454
+ const dome = new THREE.Mesh(new THREE.SphereGeometry(2.4, 40, 20, 0, Math.PI * 2, 0, Math.PI / 2), HULL); dome.position.set(bx1 - 2, 3.4, bz0 - 1.2); dome.castShadow = true; grp.add(dome);
455
+ block(grp, bx1 - 2, 1.7, bz0 - 1.3, 4.6, 3.4, 2.2);
456
+ // the nose beyond the bridge
457
+ const nose = new THREE.Mesh(new THREE.CylinderGeometry(1.4, 3.2, 5.2, 6), HULL); nose.rotation.z = -Math.PI / 2; nose.position.set(bx1 + 3.2, -0.4, cz); nose.castShadow = true; grp.add(nose);
458
+ navLight(grp, bx1 + 5.9, -0.4, cz, '#3bff7a');
459
+ // side consoles and the captain's lounge chairs
460
+ place(grp, 'consoleWide', 2.4, bx0 + 0.9, 0, bz0 + 1.0, 0.6); place(grp, 'consoleWide', 2.4, bx1 - 0.9, 0, bz0 + 1.0, -0.6);
461
+ place(grp, 'lounger', 2.4, bx1 - 1.2, 0, bz1 - 1.4, -2.2);
462
+ pod(grp, bx0 + 0.7, bz1 - 0.8);
463
+ return {
464
+ slots: [{ x: bxc, z: cz + 0.4, captain: true }, { x: bxc - 3.4, z: cz + 2.2 }, { x: bxc + 3.4, z: cz + 2.2 }, { x: bxc, z: cz + 4.0 }],
465
+ label: new THREE.Vector3(bx0 + 0.3, 0.9, bz1 + 0.2),
466
+ bounds: { maxX: bx1 + 6.5 },
467
+ };
468
+ }
469
+
470
+ // ---------------------------------------------------------------- the deck
471
+ let holoPlanet = null;
472
+ function decorate(grp, W, D) {
473
+ seedN = 11;
474
+ const m = 2.8, L = 10, H = 3.4;
475
+ const x0 = -W / 2 - m, x1 = W / 2 + m + L, z0 = -D / 2 - m, z1 = D / 2 + 1.4;
476
+ const fw = x1 - x0, fd = z1 - z0;
477
+ M.deck.map.repeat.set(fw / 3, fd / 3); M.deck.map.wrapS = M.deck.map.wrapT = THREE.RepeatWrapping;
478
+ const fl = put(grp, U.plane, M.deck, (x0 + x1) / 2, 0, (z0 + z1) / 2, fw, fd, 1, 0, false); fl.rotation.x = -Math.PI / 2; fl.receiveShadow = true;
479
+ exterior(grp, x0, x1, z0, z1);
480
+ // hull walls with ribs, light strips and viewports
481
+ M.hull.map.wrapS = M.hull.map.wrapT = THREE.RepeatWrapping;
482
+ put(grp, U.box, M.hull, (x0 + x1) / 2, H / 2, z0 - 0.15, fw + 0.3, H, 0.3);
483
+ put(grp, U.box, M.hull, x0 - 0.15, H / 2, (z0 + z1) / 2, 0.3, H, fd);
484
+ put(grp, U.box, led('#36d6ff', 2.5), (x0 + x1) / 2, H - 0.18, z0 + 0.02, fw, 0.05, 0.04, 0, false);
485
+ put(grp, U.box, led('#36d6ff', 2.5), x0 + 0.02, H - 0.18, (z0 + z1) / 2, 0.04, 0.05, fd, 0, false);
486
+ put(grp, U.box, led('#36d6ff', 1.2), (x0 + x1) / 2, 0.08, z0 + 0.02, fw, 0.03, 0.03, 0, false);
487
+ for (let x = x0 + 0.4; x < x1; x += 2.6) put(grp, U.box, M.rib, x, H / 2, z0 + 0.05, 0.22, H, 0.2);
488
+ for (let z = z0 + 0.4; z < z1; z += 2.6) put(grp, U.box, M.rib, x0 + 0.05, H / 2, z, 0.2, H, 0.22);
489
+ let k = 0;
490
+ for (let x = x0 + 3.2; x < x1 - L - 1.6; x += 6.5) wallScreen(grp, x, z0 + 0.06, 0, k++ % 4, 1.5, 0.9, 1.9);
491
+ for (let z = z0 + 3.4; z < z1 - 1.6; z += 6.5) wallScreen(grp, x0 + 0.06, z, Math.PI / 2, k++ % 4, 1.5, 0.9, 1.9);
492
+ [0.55, 2.75].forEach(y => { // conduits along the hull walls
493
+ put(grp, U.cyl, M.rib, (x0 + x1 - L) / 2, y, z0 + 0.22, 0.14, x1 - L - x0, 0.14, 0, true).rotation.z = Math.PI / 2;
494
+ put(grp, U.cyl, M.rib, x0 + 0.22, y, (z0 + z1) / 2, 0.14, fd, 0.14, 0, true).rotation.x = Math.PI / 2;
495
+ });
496
+ put(grp, U.cyl, accent(28), (x0 + x1 - L) / 2, 2.95, z0 + 0.22, 0.07, x1 - L - x0, 0.07, 0, false).rotation.z = Math.PI / 2;
497
+ // a bulkhead door on the side wall
498
+ const dz = (z0 + z1) / 2 + 3.2;
499
+ put(grp, U.box, M.dark, x0 + 0.08, 1.2, dz, 0.1, 2.4, 1.6); put(grp, U.box, led('#36d6ff', 2), x0 + 0.14, 1.2, dz, 0.02, 2.5, 0.05, 0, false);
500
+ put(grp, U.box, M.hazard, x0 + 0.14, 2.5, dz, 0.02, 0.12, 1.7, 0, false);
501
+ // observation lounge: a big viewport, sofas around a holotable with a turning planet
502
+ const lx = x1 - L / 2, lz = Math.min(z0 + 6.4, (z0 + z1) / 2 + 0.6);
503
+ viewport(grp, lx, z0 + 0.06, 0, 6.5, 2.4);
504
+ const disc = put(grp, U.circ, flat(once('loungeFloor', () => new THREE.MeshStandardMaterial({ color: '#0e1b2a', roughness: 0.3, metalness: 0.6 }))), lx, 0.01, lz, 5.6, 5.6, 1, 0, false); disc.rotation.x = -Math.PI / 2;
505
+ const rim = put(grp, U.ring, led('#36d6ff', 1.6), lx, 0.015, lz, 5.7, 5.7, 1, 0, false); rim.rotation.x = -Math.PI / 2;
506
+ sofa(grp, lx, lz - 1.7, 3.4, 0, 200); sofa(grp, lx + 2.3, lz + 0.1, 2.4, -Math.PI / 2, 200); sofa(grp, lx - 2.3, lz + 0.1, 2.4, Math.PI / 2, 200);
507
+ put(grp, U.cyl, M.rib, lx, 0.25, lz, 1.2, 0.5, 1.2); put(grp, U.cyl, led('#36d6ff', 2.8), lx, 0.51, lz, 1.05, 0.03, 1.05, 0, false);
508
+ holoPlanet = new THREE.Group(); holoPlanet.position.set(lx, 1.25, lz); grp.add(holoPlanet);
509
+ holoPlanet.add(mesh(U.wire, flat(once('holoWire', () => new THREE.MeshBasicMaterial({ color: '#5ad8ff', wireframe: true, transparent: true, opacity: 0.55, toneMapped: false }))), 0, 0, 0, 0.9, 0.9, 0.9, false));
510
+ holoPlanet.add(mesh(U.sph, flat(once('holoCore', () => new THREE.MeshBasicMaterial({ color: '#1e90ff', transparent: true, opacity: 0.25, toneMapped: false }))), 0, 0, 0, 0.8, 0.8, 0.8, false));
511
+ const hr = mesh(U.torus, led('#ffcf3a', 2), 0, 0, 0, 1.4, 1.4, 1.4, false); hr.rotation.x = 1.2; holoPlanet.add(hr);
512
+ // galley on the back wall: counter, replicator, dispenser, cups; hazard stripe in front
513
+ const cx = x1 - L + 0.5;
514
+ put(grp, U.box, M.slab, cx + 1.9, 0.46, z0 + 0.45, 3.8, 0.92, 0.75); put(grp, U.box, M.white, cx + 1.9, 0.94, z0 + 0.45, 3.9, 0.05, 0.8);
515
+ put(grp, U.box, accent(190), cx + 1.9, 0.9, z0 + 0.86, 3.8, 0.03, 0.01, 0, false);
516
+ put(grp, U.box, M.dark, cx + 0.8, 1.35, z0 + 0.35, 0.8, 0.8, 0.5); put(grp, U.box, led('#ffb020', 2.5), cx + 0.8, 1.32, z0 + 0.61, 0.5, 0.25, 0.01, 0, false);
517
+ put(grp, U.cyl, M.white, cx + 2.0, 1.25, z0 + 0.4, 0.4, 0.6, 0.4); put(grp, U.cyl, led('#5ad8ff', 1.6), cx + 2.0, 1.5, z0 + 0.4, 0.42, 0.04, 0.42, 0, false);
518
+ for (let i = 0; i < 4; i++) put(grp, U.cyl, M.white, cx + 2.6 + i * 0.2, 1.03, z0 + 0.55, 0.12, 0.14, 0.12);
519
+ wallScreen(grp, cx + 3.2, z0 + 0.06, 0, 1, 1.0, 0.6, 1.75);
520
+ put(grp, U.plane, M.hazard, cx + 1.9, 0.013, z0 + 1.1, 3.8, 0.18, 1, 0, false).rotation.x = -Math.PI / 2;
521
+ // server racks and plant pods along the right side, more where the deck is deep
522
+ if (MODELS.generatorL) {
523
+ for (let i = 0; i < (fd > 13 ? 3 : 1); i++) place(grp, 'generatorL', 3, x1 - 0.9, 0, Math.min(lz + 3.4, z1 - 1.2) + i * 1.4, -Math.PI / 2);
524
+ place(grp, 'astroA', 2.2, lx - 1.2, 0, lz + 1.6, 2.6); place(grp, 'astroB', 2.2, lx + 1.0, 0, lz + 1.9, -2.4);
525
+ place(grp, 'barrelsRail', 2.6, x1 - L + 0.9, 0, z1 - 1.2, 0.3); place(grp, 'crateTall', 2.2, x1 - L + 2.2, 0, z1 - 0.9, 0.1); place(grp, 'crateWide', 2.2, x1 - L + 3.3, 0, z1 - 1.0, -0.2);
526
+ if (lz + 4.6 < z1 - 2.6) { // shuttle bay: two small craft on glowing pads
527
+ [[lx - 1.6, 'speeder', 1.4], [lx + 1.9, 'racer', 1.3]].forEach(([px, k, sc]) => {
528
+ const pz = z1 - 2.4;
529
+ const pad = put(grp, U.circ, flat(once('pad', () => new THREE.MeshStandardMaterial({ color: '#141b26', roughness: 0.4, metalness: 0.6 }))), px, 0.02, pz, 3.0, 3.0, 1, 0, false); pad.rotation.x = -Math.PI / 2;
530
+ const pr = put(grp, U.ring, led('#ffb020', 2), px, 0.025, pz, 3.0, 3.0, 1, 0, false); pr.rotation.x = -Math.PI / 2;
531
+ place(grp, k, sc, px, 0.05, pz, 0.5);
532
+ });
533
+ }
534
+ } else {
535
+ rack(grp, x1 - 0.5, Math.min(lz + 3.6, z1 - 1.0), -Math.PI / 2);
536
+ if (fd > 13) { rack(grp, x1 - 0.5, lz + 4.6, -Math.PI / 2); rack(grp, x1 - 0.5, lz + 5.6, -Math.PI / 2); }
537
+ }
538
+ place(grp, 'consoleWide', 2.4, x0 + 0.7, 0, (z0 + z1) / 2 - 1.5, Math.PI / 2); place(grp, 'console', 2.4, x0 + 0.7, 0, (z0 + z1) / 2 + 0.2, Math.PI / 2);
539
+ pod(grp, x1 - 0.7, z0 + 0.7); pod(grp, x0 + 0.7, z0 + 0.7); pod(grp, x0 + 0.7, z1 - 0.8); pod(grp, x1 - L - 0.5, z1 - 0.8);
540
+ // bridge console in the corner by the lounge
541
+ put(grp, U.box, M.slab, x1 - L - 0.5, 0.5, z0 + 0.7, 0.9, 1.0, 0.7); put(grp, U.plane, screenMat(0), x1 - L - 0.5, 1.02, z0 + 0.75, 0.75, 0.5, 1, 0, false).rotation.x = -1.0;
542
+ const lamp = new THREE.PointLight('#5ad8ff', 8, 7, 1.5); lamp.position.set(lx, 1.6, lz); grp.add(lamp);
543
+ return { minX: x0 - 6, maxX: x1 + 5, minZ: z0 - 4, maxZ: z1 + 1.2, x0, x1, z0, z1 };
544
+ }
545
+
546
+ function galaxyTex() {
547
+ return tex(2048, 1152, (g, w, h) => {
548
+ const bg = g.createRadialGradient(w * 0.5, h * 0.5, 0, w * 0.5, h * 0.5, w * 0.7); bg.addColorStop(0, '#0a0f2a'); bg.addColorStop(1, '#010208');
549
+ g.fillStyle = bg; g.fillRect(0, 0, w, h);
550
+ [['rgba(130,60,220,.30)', .18, .25, .35], ['rgba(20,170,210,.22)', .85, .7, .35], ['rgba(230,70,140,.18)', .6, .15, .25], ['rgba(60,90,255,.18)', .3, .85, .3]].forEach(([c, x, y, r]) => {
551
+ const n = g.createRadialGradient(x * w, y * h, 0, x * w, y * h, r * w); n.addColorStop(0, c); n.addColorStop(1, 'rgba(0,0,0,0)'); g.fillStyle = n; g.fillRect(0, 0, w, h);
552
+ });
553
+ for (let i = 0; i < 9000; i++) { const b = rnd(); g.fillStyle = `rgba(${190 + b * 65},${200 + b * 55},255,${0.25 + b * 0.75})`; const sz = b > 0.985 ? 3 : b > 0.9 ? 1.8 : 1; g.fillRect(rnd() * w, rnd() * h, sz, sz); }
554
+ // spiral galaxy, upper right
555
+ const gx = w * 0.78, gy = h * 0.24;
556
+ g.save(); g.translate(gx, gy); g.scale(1, 0.45); g.rotate(-0.4);
557
+ const core = g.createRadialGradient(0, 0, 0, 0, 0, 260); core.addColorStop(0, 'rgba(255,240,210,.95)'); core.addColorStop(0.15, 'rgba(255,200,150,.55)'); core.addColorStop(1, 'rgba(120,80,200,0)');
558
+ g.fillStyle = core; g.beginPath(); g.arc(0, 0, 260, 0, 7); g.fill();
559
+ for (let arm = 0; arm < 2; arm++) for (let i = 0; i < 1600; i++) {
560
+ const t = i / 1600 * 3.2 * Math.PI, rr = 18 + t * 26, a = t + arm * Math.PI + (rnd() - 0.5) * 0.5;
561
+ g.fillStyle = rnd() < 0.7 ? `rgba(170,190,255,${0.15 + rnd() * 0.5})` : `rgba(255,170,220,${0.2 + rnd() * 0.4})`;
562
+ g.fillRect(Math.cos(a) * rr + (rnd() - 0.5) * 14, Math.sin(a) * rr + (rnd() - 0.5) * 14, 1.6, 1.6);
563
+ }
564
+ g.restore();
565
+ // ringed gas giant, lower left
566
+ const px = w * 0.13, py = h * 0.8, pr = 120;
567
+ g.save(); g.translate(px, py); g.rotate(-0.35);
568
+ g.strokeStyle = 'rgba(230,200,160,.35)'; g.lineWidth = 10; g.beginPath(); g.ellipse(0, 0, pr * 2, pr * 0.45, 0, Math.PI, Math.PI * 2); g.stroke();
569
+ const pg = g.createRadialGradient(-pr * 0.4, -pr * 0.4, 10, 0, 0, pr); pg.addColorStop(0, '#f2c894'); pg.addColorStop(0.6, '#b36a3a'); pg.addColorStop(1, '#2a120a');
570
+ g.fillStyle = pg; g.beginPath(); g.arc(0, 0, pr, 0, 7); g.fill();
571
+ g.fillStyle = 'rgba(90,40,20,.25)'; for (let i = -3; i < 4; i++) g.fillRect(-pr, i * 26, pr * 2, 9);
572
+ g.strokeStyle = 'rgba(240,215,170,.55)'; g.lineWidth = 10; g.beginPath(); g.ellipse(0, 0, pr * 2, pr * 0.45, 0, 0, Math.PI); g.stroke();
573
+ g.restore();
574
+ });
575
+ }
576
+ const background = galaxyTex();
577
+ return { load, makeRobot, makeStation, decorate, bridge, background, pod, planet: () => holoPlanet, accent, statusLed, NO_LINE };
578
+ }