// The Mellis HB-7 console, laid out at 1600 x 900 after the Cessna console and the reference app recordings: the // orange HB-7 badge and title with the sim status cells, the wing beat with its live stroke chart, power, the six leg // servos, flight telemetry with an attitude ball, the views, the display toggles, the subsystem registry, the flight // log with the operator's actions on its timeline, the flight-mode word in the viewport, the labels with leaders into // the bee and the operator's pointer. Panels are light paper over the near-white studio; the bee's orange is the one // accent. update(s) redraws every live part from the frame's state; the film and a live page share it. export const C = {ink: '#24211d', mute: '#9a8f82', faint: '#e0d7ca', line: '#ece5da', panel: 'rgba(253,251,247,.95)', or: '#ff5a1f', green: '#2fa36b', track: '#efe8de'}; export const VIEWS = ['hero', 'front', 'side', 'wing', 'legs']; export const VIEW_LABEL = {hero: 'HERO', front: 'FRONT', side: 'SIDE', wing: 'WING', legs: 'LEGS'}; export const DISPLAY = ['labels', 'xray', 'exploded', 'blur', 'orbit']; export const DISPLAY_LABEL = {labels: 'LABELS', xray: 'X-RAY', exploded: 'EXPLODED', blur: 'MOTION BLUR', orbit: 'ORBIT'}; // the viewport: the 3D shows between the side columns, above the flight log export const VIEWPORT = {x0: 330, x1: 1270, y0: 108, y1: 744}; const CSS = ` #app{font-family:Inter,system-ui,sans-serif;color:${C.ink};-webkit-font-smoothing:antialiased;font-variant-numeric:tabular-nums} .ui{position:absolute;inset:0;pointer-events:none} .mo{font-family:'JetBrains Mono',ui-monospace,monospace} .cp{position:absolute;background:${C.panel};border:1px solid ${C.line};border-radius:6px;box-shadow:0 2px 10px rgba(120,90,50,.07)} .ph{position:absolute;display:flex;align-items:center;gap:9px;font:700 10.5px 'JetBrains Mono',monospace;letter-spacing:1.8px} .ph i{display:block;width:3px;height:13px;background:${C.or}} .pn{position:absolute;font:500 9.5px 'JetBrains Mono',monospace;color:${C.mute};letter-spacing:1px} .sm{font:500 9px 'JetBrains Mono',monospace;letter-spacing:1.6px;color:${C.mute};text-transform:uppercase;white-space:nowrap} .v{font:600 11px 'JetBrains Mono',monospace;color:${C.ink};white-space:nowrap} .bt{position:absolute;height:23px;padding:0 10px;display:flex;align-items:center;justify-content:center;border:1px solid ${C.faint};border-radius:4px;background:#fffdf9;font:700 9.4px 'JetBrains Mono',monospace;letter-spacing:1.3px;color:${C.ink};white-space:nowrap;box-sizing:border-box} .call{position:absolute;white-space:nowrap;padding:3px 6px 3px 5px;margin:-3px 0 0 -5px;background:rgba(253,251,247,.86);border-radius:3px} .call b{display:flex;align-items:center;gap:6px;font:700 9.4px 'JetBrains Mono',monospace;letter-spacing:1.3px;color:${C.ink}} .call b i{display:block;width:6px;height:6px;background:${C.or}} .call span{display:block;font:500 7.8px 'JetBrains Mono',monospace;letter-spacing:1.2px;color:${C.mute};margin-top:2px} .chip{position:absolute;height:15px;padding:0 6px;border-radius:3px;font:700 7.6px 'JetBrains Mono',monospace;letter-spacing:1.1px;display:flex;align-items:center;white-space:nowrap} .cur{position:absolute;left:0;top:0;z-index:50;filter:drop-shadow(0 1px 2px rgba(0,0,0,.3))} .ring{position:absolute;width:34px;height:34px;margin:-17px 0 0 -17px;border-radius:50%;border:1.5px solid ${C.or};opacity:0;z-index:49} `; const el = (h) => { const d = document.createElement('div'); d.innerHTML = h.trim(); return d.firstElementChild; }; const SUBS = [ ['OPTIC HEAD', '2 × 18 MM LENS · AMBER IR'], ['NECK BEARING', '10-SEGMENT COLLAR'], ['THORAX DRIVE', '3 GEARS · 11 ACTUATORS'], ['WING ROOTS', '4 HINGES · 7.5 HZ CRANK'], ['LEG SERVOS', '6 LEGS × 3 JOINTS'], ['ABDOMEN BANDS', '5 SEGMENTS · GLASS STING'], ]; const LEGS = ['L1', 'L2', 'L3', 'R1', 'R2', 'R3']; // opts (all optional, the first film's console when absent): views / viewLabel / viewsTitle / viewRows for the view // panel (the second film puts its assemblies there, in two rows), display / displayLabel for the toggles; the panels // below move down to make room and the subsystem rows close up. export function createConsole(app, opts = {}) { const views = opts.views ?? VIEWS; const viewLabel = opts.viewLabel ?? VIEW_LABEL; const display = opts.display ?? DISPLAY; const displayLabel = opts.displayLabel ?? DISPLAY_LABEL; const viewRows = opts.viewRows ?? 1; const style = document.createElement('style'); style.textContent = CSS; document.head.appendChild(style); const ui = el(`
`); app.appendChild(ui); const add = (h) => { const n = el(h); ui.appendChild(n); return n; }; const panel = (x, y, w, h, title, n) => { add(`
`); add(`
${title}
`); add(`
${n}
`); }; const hr = (x, y, w) => add(`
`); const L = {x: 24, w: 290}; const R = {x: 1286, w: 290}; // ------------------------------------------------------------ header: badge, title, the lift bar, the status cells add(`
`); add(``); add(`
VX-9
`); add(`
ROBOTIC WASP · MICRO AIR VEHICLE
`); add(`
Vespion VX-9 /
`); add(`
FLAPPING-WING DRONE / FIELD SIMULATOR
`); add(`
LIFT LOAD
`); const liftPct = add(`
`); const liftCells = []; for (let i = 0; i < 40; i++) liftCells.push(add(`
`)); add(`
IDLE
`); add(`
HOVER
`); add(`
MAX
`); const cells = [ ['SIM ID', 'HB7-0412'], ['RUNTIME', ''], ['STATUS', ''], ['OPERATOR', 'LAB 3 · R.K.'], ]; const cellV = cells.map(([k, v], i) => { const x = 1086 + i * 118; if (i) add(`
`); add(`
${k}
`); return add(`
${v}
`); }); { let h = ''; for (let r = 0; r < 2; r++) for (let c = 0; c < 14; c++) h += ``; add(`${h}`); } // ------------------------------------------------------------ 01 wing beat panel(L.x, 108, L.w, 226, 'WING BEAT', '01'); const fq = add(`
`); add(`
STROKE FREQUENCY
`); const amp = add(`
`); add(`
AMPLITUDE
`); const chart = add(``); hr(38, 302, 262); add(`
PLAYBACK
`); const pb = add(`
`); const shutter = add(`
`); // ------------------------------------------------------------ 02 power panel(L.x, 346, L.w, 148, 'POWER', '02'); const batt = add(`
`); add(`
BATTERY
`); const battCells = []; for (let i = 0; i < 10; i++) battCells.push(add(`
`)); hr(38, 428, 262); const pw = [['DRAW', 444], ['CELL', 444], ['MOTOR', 444]].map(([k], i) => { const x = 38 + i * 90; add(`
${k}
`); return add(`
`); }); // ------------------------------------------------------------ 03 leg servos panel(L.x, 506, L.w, 238, 'LEG SERVOS', '03'); const legState = add(`
`); add(`
LOAD PER LEG · KNEE TORQUE
`); const servo = LEGS.map((n, i) => { const y = 566 + i * 27; add(`
${n}
`); add(`
`); const f = add(`
`); const v = add(`
`); return {f, v}; }); // ------------------------------------------------------------ 04 flight panel(R.x, 108, R.w, 196, 'FLIGHT', '04'); const ball = add(``); const fl = [['ALT AGL', 0], ['V/S', 1], ['PITCH', 2], ['ROLL', 3]].map(([k], i) => { const y = 142 + i * 24; add(`
${k}
`); return add(`
`); }); hr(1300, 252, 262); add(`
HOLD
`); const hold = add(`
`); add(`
AIRSPEED
`); const air = add(`
`); // ------------------------------------------------------------ 05 views, 06 display const btn = {}; const btnRow = (keys, labels, x0, y, wmax = 262, pad = 22) => { let x = x0; let yy = y; for (const k of keys) { const w = Math.round(labels[k].length * 7.1 + pad); if (x + w > x0 + wmax) { x = x0; yy += 30; } btn[k] = add(`
${labels[k]}
`); x += w + 6; } }; const viewsH = 50 + 30 * viewRows; panel(R.x, 316, R.w, viewsH, opts.viewsTitle ?? 'VIEWS', '05'); btnRow(views, viewLabel, 1300, 353, 262, 16); const dispY = 316 + viewsH + 12; panel(R.x, dispY, R.w, 110, 'DISPLAY', '06'); btnRow(display, displayLabel, 1300, dispY + 37); const subY = dispY + 122; const subStep = Math.min(29, (744 - subY - 40) / 6); // ------------------------------------------------------------ 07 subsystems panel(R.x, subY, R.w, 744 - subY, 'SUBSYSTEMS', '07'); const subs = SUBS.map(([n, d], i) => { const y = subY + 34 + i * subStep; const bar = add(`
`); add(`
0${i + 1}
`); const name = add(`
${n}
`); add(`
${d}
`); const chip = add(`
`); return {bar, name, chip}; }); // ------------------------------------------------------------ 08 flight log panel(330, 760, 940, 98, 'FLIGHT LOG', '08'); add(`
❚❚
`); const logMode = add(`
`); add(`
TAKE-OFF
`); add(`
LAND
`); const TLB = {x: 408, w: 840}; add(`
`); const tlFill = add(`
`); const tlTicks = add(`
`); const tlKnob = add(`
`); const tlTime = add(`
`); const tlNext = add(`
`); // ------------------------------------------------------------ viewport notes: model, the view, the flight mode add(`
MODEL VX-9 · REV A
`); const viewNote = add(`
`); add(``); add(``); add(`
FLIGHT MODE
`); const mode = add(`
`); const modeSub = add(`
`); // ------------------------------------------------------------ footer add(`
FIELD SIMULATOR  ·  PROCEDURAL MODEL  ·  6 LEGS · 4 WINGS · 2 OPTICS
`); add(`
VESPION ROBOTICS · INTERCEPT LAB //////
`); // ------------------------------------------------------------ labels, the pointer const callSvg = add(``); const callG = add(`
`); const ring = add(`
`); const cur = add(`
`); const centre = (n) => { const r = n.getBoundingClientRect(); return [r.left + r.width / 2, r.top + r.height / 2]; }; const spots = Object.fromEntries(Object.entries(btn).map(([k, n]) => [k, centre(n)])); const pointer = (c) => { cur.style.display = c.x < 0 ? 'none' : 'block'; cur.style.transform = `translate(${(c.x - 3).toFixed(2)}px, ${(c.y - 2).toFixed(2)}px) scale(${c.press ? 0.88 : 1})`; ring.style.left = `${c.ringX}px`; ring.style.top = `${c.ringY}px`; ring.style.opacity = String(c.ring * 0.85); ring.style.transform = `scale(${(0.35 + 0.9 * (1 - c.ring)).toFixed(3)})`; }; const clock = (s) => `${String(Math.floor(s / 60)).padStart(2, '0')}:${String(Math.floor(s) % 60).padStart(2, '0')}`; const chipStyle = (n, kind, text) => { const k = {ok: [C.green, '#fff'], warn: [C.or, '#fff'], idle: [C.track, C.mute]}[kind]; n.style.background = k[0]; n.style.color = k[1]; n.textContent = text; }; let tickKey = ''; return { spots, btn, root: ui, TLB, update(s) { // header const lift = Math.round(s.lift * 40); liftCells.forEach((c, i) => (c.style.background = i < lift ? (i > 30 ? C.or : C.ink) : C.track)); liftPct.textContent = `${Math.round(s.lift * 100)}%`; cellV[1].textContent = `00:00:${String(Math.floor(s.time)).padStart(2, '0')}`; cellV[2].innerHTML = `● ${s.status}`; // wing beat: the frequency, the amplitude, the stroke of the near forewing (orange) and hindwing (grey) over the // last 1.2 s, with the now marker on the right fq.innerHTML = `${s.freq.toFixed(1)} HZ`; amp.textContent = `±${Math.round(s.amp)}°`; { const W = 262; const H = 96; const Y = (a) => H / 2 - (a / 40) * (H / 2 - 8); let g = ``; for (const a of [-32, 32]) g += `${a > 0 ? '+' : ''}${a}°`; const path = (k) => s.stroke.map((p, i) => `${i ? 'L' : 'M'}${((i / (s.stroke.length - 1)) * (W - 10)).toFixed(1)} ${Y(p[k]).toFixed(1)}`).join(''); g += ``; const last = s.stroke[s.stroke.length - 1]; g += ``; g += `−1.2 SNOW`; chart.innerHTML = g; } pb.textContent = `${s.playback.toFixed(1)}×`; shutter.textContent = s.blur > 0.5 ? 'SHUTTER 1/60' : 'HI-SPEED 1/2000'; // power batt.innerHTML = `${Math.round(s.battery * 100)}%`; const bc = Math.round(s.battery * 10); battCells.forEach((c, i) => (c.style.background = i < bc ? (i < 2 ? C.or : C.green) : C.track)); pw[0].textContent = `${s.power.toFixed(1)} W`; pw[1].textContent = `${s.volt.toFixed(2)} V`; pw[2].textContent = `${s.motorT.toFixed(0)} °C`; // leg servos chipStyle(legState, s.legsFree ? 'warn' : 'ok', s.legsFree ? 'DETACHED' : 'HOLDING'); servo.forEach((b, i) => { const v = s.servos[i]; b.f.style.width = `${(v * 178).toFixed(1)}px`; const free = s.legFreeEach ? s.legFreeEach[i] : s.legsFree; b.f.style.background = v > 0.6 ? C.or : C.ink; b.v.textContent = free ? 'DETACHED' : `${Math.round(v * 100)}%`; b.v.style.color = free ? C.or : C.ink; b.v.style.fontSize = free ? '8.6px' : '11px'; }); // flight: the attitude ball (the horizon tilts with roll and slides with pitch) and the numbers { const r = 44; const off = s.pitch * 2.2; ball.innerHTML = `${[-20, -10, 10, 20].map((p) => ``).join('')}`; fl[0].textContent = s.airborne ? `${s.alt.toFixed(1)} MM` : '—'; fl[1].textContent = s.airborne ? `${s.vs >= 0 ? '+' : '−'}${Math.abs(s.vs).toFixed(1)} MM/S` : '—'; fl[2].textContent = `${s.pitch >= 0 ? '+' : '−'}${Math.abs(s.pitch).toFixed(2)}°`; fl[3].textContent = `${s.roll >= 0 ? '+' : '−'}${Math.abs(s.roll).toFixed(2)}°`; hold.textContent = s.airborne ? 'POSITION' : 'OFF'; air.textContent = `${s.airspeed.toFixed(2)} M/S`; } // views, display const onBtn = (k, on) => { btn[k].style.background = on ? C.or : '#fffdf9'; btn[k].style.color = on ? '#fff' : C.ink; btn[k].style.borderColor = on ? C.or : C.faint; }; for (const k of views) onBtn(k, s.view === k); for (const k of display) onBtn(k, !!s.display[k]); // subsystems: a status chip each, the row the current view looks at marked subs.forEach((r, i) => { const [kind, text] = s.subs[i]; chipStyle(r.chip, kind, text); r.bar.style.background = s.focus === i ? C.or : 'transparent'; r.name.style.color = s.focus === i ? C.or : C.ink; }); // flight log: the film's progress, a tick for every press, the mode const kx = TLB.x + (s.time / s.dur) * TLB.w; tlFill.style.width = `${(kx - TLB.x).toFixed(1)}px`; tlKnob.style.left = `${kx.toFixed(1)}px`; const key = s.events.length; if (key !== tickKey) { tickKey = key; tlTicks.innerHTML = s.events.map((e) => `
`).join(''); } tlTime.textContent = `${clock(s.time)} / ${clock(s.dur)}`; tlNext.textContent = s.next; logMode.textContent = s.log; viewNote.textContent = s.viewNote ?? `VIEW · ${viewLabel[s.view]}${s.display.orbit ? ' · ORBIT' : ''}`; mode.textContent = s.mode; modeSub.textContent = s.modeSub; // labels: an orange square, the name, the note, a thin leader to the part let lh = ''; let ch = ''; for (const c of s.callouts) { if (c.o < 0.02 || !c.at) continue; const [ax, ay] = c.at; const [lx, ly] = c.label; const right = lx > ax; const ex = right ? lx - 6 : lx + c.w + 6; lh += ``; ch += `
${c.name}${c.sub}
`; } callSvg.innerHTML = lh; callG.innerHTML = ch; pointer(s.cursor); }, pointer, }; }