Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(verse): fire while aiming down the sights, in either button order (#977)

Ruben Lütke1084982f31b6
diff --git a/art/verse/decks/ops/build.py b/art/verse/decks/ops/build.py
index 07c12e3a9f..e62e1a5030 100644
--- a/art/verse/decks/ops/build.py
+++ b/art/verse/decks/ops/build.py
@@ -21,7 +21,7 @@ DECK_ID = "ops"
def build() -> None:
- from decks.ops import arch, dressing, facade, mats
+ from decks.ops import arch, cladding, dressing, facade, fitout, mats
from decks.ops import layout as L
mats.ensure()
@@ -32,6 +32,9 @@ def build() -> None:
arch.build(cavities=facade.cavities())
bays = facade.build()
dressing.build(bays)
+ # Eye-level detail: fit-out props and services, then the wall cladding
+ # (which keeps its terminals off the walls the props stand against).
+ cladding.build(fitout.build())
if __name__ == "__main__":
diff --git a/art/verse/decks/ops/cladding.py b/art/verse/decks/ops/cladding.py
new file mode 100644
index 0000000000..7bb39789cc
--- /dev/null
+++ b/art/verse/decks/ops/cladding.py
@@ -0,0 +1,275 @@
+"""Wall cladding of the Operations deck, seen at eye level.
+
+The plate camera sees the deck's room walls only as 1.1 m section caps or
+edge-on, so they were built as plain slabs; at eye level they were large flat
+grey fields. This module dresses every room wall and the corridor's upper
+walls in the ship's language with the kit's ``kit.architecture.cladding``
+(the bridge's wall-detail level, PR #910):
+
+* Rooms (charcoal hall walls): plinth with louvres, 0.6 m panels with seams
+ and insets, light columns in alternate bays between gunmetal ribs with dash
+ lamps (every third rib a red strip), a rail with a conduit bundle, an upper
+ field and a recessed cornice; wall terminals, status boards, junction boxes
+ with conduit drops and section sign plates in the bays the floor props
+ leave free.
+* Medical bay: the light-grey secondary panelling (room_wall).
+* Corridor: the plain upper wall between the slot-light columns gets inset
+ panels, a louvre, a conduit pair under the chamfer, and every few bays a
+ sign plate, status board or terminal.
+
+Everything is a ceiling ghost (``kit.ghost``): invisible to the plate camera
+and to shadow rays, nav ``none``, no occluders, so the plate, the nav grid
+and the occluders keep their shape. Faces the plate does see (the room side
+of the corridor's south wall and the med wall's south face) are clipped at
+the 1.1 m section.
+"""
+
+from __future__ import annotations
+
+from dataclasses import dataclass, field
+
+from decks.ops import layout as L
+from decks.ops.geo import CUT_H
+from kit.architecture import cladding as C
+from lib import kit, scene
+
+DOOR_HEAD = 2.5
+FRAME = 0.16 # door frame width either side of an opening
+
+
+@dataclass
+class Wall:
+ """One room wall face: plan line, room side, span and openings."""
+
+ key: str
+ room: str
+ axis: str # "x": face at plan z = fixed (u = x); "z": face at plan x = fixed (u = z)
+ fixed: float
+ sign: int # the room's side along the other axis
+ t0: float
+ t1: float
+ doors: list[tuple[float, float]] = field(default_factory=list) # (u0, u1)
+ style: str = "hall" # "hall" (charcoal) or "room" (light grey)
+ clip: float = -1.0 # ghost clip height: CUT_H for faces the plate sees
+ lit: int = 2 # every n-th bay gets a light column
+
+ def matrix(self):
+ return C.run_matrix(self.axis, self.fixed, self.sign)
+
+
+def _doors(doors: dict[str, tuple[float, float]], x0: float, x1: float):
+ out = []
+ for x, w in doors.values():
+ a, b = x - w / 2 - FRAME, x + w / 2 + FRAME
+ if b > x0 and a < x1:
+ out.append((a, b))
+ return sorted(out)
+
+
+def walls() -> list[Wall]:
+ """Every dressed room wall (the far hull wall has its own facade)."""
+ out: list[Wall] = []
+ trim = 0.2 # keep corner pieces from colliding
+ for rid in ("mess", "records", "simulator", "quartermaster"):
+ x0, x1, z0, z1 = L.ROOMS[rid].rect
+ out.append(Wall(f"{rid}_s", rid, "x", z1, -1, x0 + trim, x1 - trim,
+ _doors(L.DOORS_NORTH, x0, x1))) # fmt: skip
+ out.append(Wall(f"{rid}_w", rid, "z", x0, 1, z0 + 0.5, z1 - trim))
+ out.append(Wall(f"{rid}_e", rid, "z", x1, -1, z0 + 0.5, z1 - trim))
+ for rid in ("quarters", "team_a", "team_b", "medbay", "storage", "lobby"):
+ x0, x1, z0, z1 = L.ROOMS[rid].rect
+ style = "room" if rid == "medbay" else "hall"
+ lit = 3 if rid == "quarters" else 2
+ if rid == "medbay":
+ north = Wall(f"{rid}_n", rid, "x", z0, 1, x0 + trim, x1 - trim,
+ _doors(L.DOORS_MED, x0, x1), style, CUT_H) # fmt: skip
+ elif rid == "lobby":
+ north = None # the lift core and its two doors take the whole face
+ else:
+ north = Wall(f"{rid}_n", rid, "x", z0, 1, x0 + trim, x1 - trim,
+ _doors(L.DOORS_SOUTH, x0, x1), style, CUT_H, lit) # fmt: skip
+ if north is not None:
+ out.append(north)
+ south_doors = _doors(L.DOORS_MED, x0, x1) if rid in ("lobby", "storage") else []
+ out.append(Wall(f"{rid}_s", rid, "x", z1, -1, x0 + trim, x1 - trim, south_doors, style,
+ lit=lit)) # fmt: skip
+ out.append(Wall(f"{rid}_w", rid, "z", x0, 1, z0 + trim, z1 - trim, style=style, lit=lit))
+ out.append(Wall(f"{rid}_e", rid, "z", x1, -1, z0 + trim, z1 - trim, style=style, lit=lit))
+ # The washroom partition's east face (the berths' side).
+ out.append(Wall("quarters_wash", "quarters", "z", 11.3, 1, L.CORR_S + 0.2, 48.0 - 0.1, lit=3))
+ return out
+
+
+def _codes(w: Wall) -> str:
+ """Section code for a wall's sign plates: deck, room number, wall."""
+ rooms = list(L.ROOMS)
+ n = rooms.index(w.room) + 1
+ side = {"n": 1, "e": 2, "s": 3, "w": 4}.get(w.key.rsplit("_", 1)[-1], 5)
+ return f"2-{n:02d}-{side}"
+
+
+def dress_wall(w: Wall, reserved: list[tuple[float, float]]) -> None:
+ """Clad one wall; ``reserved`` u spans have floor props in front of them
+ (no terminals or boxes at their height there)."""
+ B = C.Builders().at(w.matrix())
+ seed = ("ops", w.key)
+ openings = [C.Opening(a, b, DOOR_HEAD) for a, b in w.doors]
+ mid = (w.t0 + w.t1) / 2
+ ribs = C.rib_stations(w.t0, w.t1, 4.8, origin=mid + 2.4)
+ ribs = [r for r in ribs if not any(a - 0.5 < r < b + 0.5 for a, b in w.doors)]
+ if w.style == "room":
+ C.room_wall(B, seed, w.t0, w.t1, top=L.ROOM_H, pilasters=ribs, openings=openings,
+ base_from=0.0 if w.clip < 0 else CUT_H - 0.1) # fmt: skip
+ bays = [(a, b) for a, b in zip([w.t0, *ribs], [*ribs, w.t1], strict=True)]
+ else:
+ nb = len(ribs) + 1
+ lit = {i for i in range(nb) if i % w.lit == 1}
+ red = {i for i in range(len(ribs)) if i % 3 == 1}
+ bays = C.hall_wall(B, seed, w.t0, w.t1, top=L.ROOM_H, ribs=ribs, lit_bays=lit,
+ red_ribs=red, openings=openings) # fmt: skip
+ _fittings(B, w, bays, reserved, seed)
+ B.finish(f"SM_Ops_Clad_{w.key}", room=w.room)
+
+
+def _fittings(B: C.Builders, w: Wall, bays, reserved, seed) -> None:
+ """Terminals, status boards, junction boxes and sign plates in the bays."""
+ code = _codes(w)
+ signed = False
+ for bi, (a, b) in enumerate(bays):
+ if b - a < 1.6:
+ continue
+ cu = (a + b) / 2
+ blocked = any(ra - 0.4 < cu < rb + 0.4 for ra, rb in reserved) or any(
+ da - 0.6 < cu < db + 0.6 for da, db in w.doors
+ )
+ lit = w.style == "hall" and bi % w.lit == 1 and b - a > 1.8
+ off = 0.0 if not lit else 0.75 # beside the light column
+ r = C.seed01(seed, "fit", bi)
+ if not signed and not lit and b - a > 2.0:
+ C.sign_plate(B, cu, 2.62, code)
+ signed = True
+ if blocked:
+ if r < 0.5:
+ C.status_panel(B, cu + off + 0.2, 1.95, seed=(seed, bi))
+ continue
+ if r < 0.35:
+ C.wall_terminal(B, cu + off, 1.0, seed=(seed, bi))
+ C.conduit_drop(B, cu + off + 0.42, 1.0, 2.73, n=1)
+ elif r < 0.65:
+ C.junction_box(B, cu + off - 0.1, 1.35, seed=(seed, bi))
+ C.conduit_drop(B, cu + off - 0.1, 1.85, 2.73, n=2)
+ elif r < 0.9:
+ C.status_panel(B, cu + off, 1.3, seed=(seed, bi))
+ if b - a > 3.0 and not lit:
+ # A second fitting in a wide bay.
+ du = (b - a) * 0.3 * (1 if r < 0.5 else -1)
+ if C.seed01(seed, "fit2", bi) < 0.5:
+ C.status_panel(B, cu + du, 1.5, seed=(seed, bi, 2))
+ else:
+ C.junction_box(B, cu + du, 0.55, w=0.5, h=0.4, seed=(seed, bi, 2))
+ C.conduit_drop(B, cu + du, 0.95, 2.73, n=2)
+
+
+# ---------------------------------------------------------------- corridor
+
+
+def corridor_upper() -> None:
+ """The corridor's upper walls (plan z 27.0 north, 33.0 south; 1.2 m to
+ the chamfer at 3.3 m) between the slot-light columns every 2.4 m."""
+ import math
+
+ zt = {True: L.CORR_FLOOR[0] - L.SLOPE_RUN, False: L.CORR_FLOOR[1] + L.SLOPE_RUN}
+ h0, h1 = L.SLOPE_TOP, L.CHAMFER_LOW
+ stops = (*L.BLAST_FRAMES, *L.END_PORTALS)
+ for north in (True, False):
+ doors = L.door_spans(L.DOORS_NORTH if north else L.DOORS_SOUTH)
+ B = C.Builders().at(C.run_matrix("x", zt[north], 1 if north else -1))
+ seed = ("ops", "corr", north)
+ for k in range(math.ceil(3.0 / 2.4), math.floor(93.0 / 2.4)):
+ a, b = 2.4 * k + 0.3, 2.4 * (k + 1) - 0.3 # between two columns
+ if any(fx - 1.5 < b and fx + 1.5 > a for fx in stops):
+ continue
+ if any(da - 0.2 < b and db + 0.2 > a for da, db in doors):
+ continue
+ cu = (a + b) / 2
+ r = C.seed01(seed, k)
+ C.box(B.flat, a, b, 0.0, C.BACK, h0 + 0.1, h1 - 0.08, C.RECESS)
+ # Gunmetal pilasters beside the light columns.
+ for p0, p1 in ((a, a + 0.07), (b - 0.07, b)):
+ C.box(B.struct, p0, p1, C.BACK, 0.07, h0 + 0.1, h1 - 0.08, C.GUNMETAL)
+ a2, b2 = a + 0.07, b - 0.07
+ bands = ((h0 + 0.1, h0 + 0.36), (h0 + 0.36, 2.12), (2.32, 2.86), (2.86, h1 - 0.08))
+ for m0, m1 in C.modules(a2, b2, 0.88):
+ C.panel(B, m0, m1, *bands[0], C.DARK, inset=False, v=0.03)
+ light = C.seed01(seed, k, m0) < 0.7
+ C.panel(B, m0, m1, *bands[1], C.MID if light else C.CHARCOAL, inset=True, v=0.04)
+ C.panel(B, m0, m1, *bands[2], C.CHARCOAL, inset=r < 0.5, v=0.035)
+ C.panel(B, m0, m1, *bands[3], C.DARK, inset=False, v=0.03)
+ # Rail between the light and the dark field, with a conduit pair.
+ C.box(B.struct, a2, b2, C.BACK, 0.07, 2.12, 2.32, C.GUNMETAL)
+ C.box(B.struct, a2, b2, C.BACK, 0.075, 2.3, 2.32, C.STEEL)
+ for dv, hh, rr in ((0.1, 2.18, 0.028), (0.1, 2.26, 0.02)):
+ B.pipes.tube((a2, dv, hh), (b2, dv, hh), rr, C.PIPE, 8)
+ # Conduit pair under the chamfer.
+ for dv, rr in ((0.06, 0.03), (0.13, 0.022)):
+ B.pipes.tube((a, dv, h1 - 0.22), (b, dv, h1 - 0.22), rr, C.PIPE, 8)
+ C.box(B.struct, cu - 0.03, cu + 0.03, C.BACK, 0.17, h1 - 0.32, h1 - 0.12, C.GUNMETAL)
+ if k % 5 == 2:
+ C.sign_plate(B, cu, 2.78, f"2-{k:02d}", ch=0.14)
+ elif k % 5 == 4:
+ C.status_panel(B, cu - 0.3, 1.45, seed=(seed, k))
+ C.junction_box(B, cu + 0.35, 1.5, seed=(seed, k))
+ elif r > 0.55:
+ C.louvre(B, cu, h0 + 0.13, w=0.9, h=0.2)
+ elif r < 0.2:
+ C.wall_terminal(B, cu, 1.3, seed=(seed, k))
+ B.finish(f"SM_Ops_Clad_corridor_{'n' if north else 's'}", room="corridor")
+
+
+def corridor_slopes() -> None:
+ """Dark inset vent plates in the middle of every sloped lower-wall panel
+ of the corridor, between the pill-lamp units (eye level only)."""
+ from decks.ops.arch import _on_slope
+ from decks.ops.geo import Mesh
+
+ stops = (*L.BLAST_FRAMES, *L.END_PORTALS)
+ for north in (True, False):
+ holes = L.door_spans(L.DOORS_NORTH if north else L.DOORS_SOUTH)
+ plates, slats = Mesh(), Mesh()
+ for j in range(3, 77):
+ a, b = 1.2 * j + 0.34, 1.2 * (j + 1) - 0.34
+ if any(ha - 0.5 < b and hb + 0.5 > a for ha, hb in holes):
+ continue
+ if any(fx - 1.5 < b and fx + 1.5 > a for fx in stops):
+ continue
+ if any(abs(4.8 * k - (a + b) / 2) < 0.45 for k in range(21)):
+ continue # structural rib
+ lo, hi = 0.3, 0.98
+ p = [_on_slope(north, lo, 0.01), _on_slope(north, lo, 0.022),
+ _on_slope(north, hi, 0.022), _on_slope(north, hi, 0.01)] # fmt: skip
+ plates.prism_x(p, a, b, C.CHARCOAL)
+ hh = lo + 0.08
+ while hh < hi - 0.1:
+ h2 = hh + 0.035
+ s = [_on_slope(north, hh, 0.021), _on_slope(north, hh, 0.03),
+ _on_slope(north, h2, 0.03), _on_slope(north, h2, 0.021)] # fmt: skip
+ slats.prism_x(s, a + 0.05, b - 0.05, C.GUNMETAL)
+ hh += 0.075
+ side = "n" if north else "s"
+ for m, name in ((plates, "plates"), (slats, "slats")):
+ o = m.build(f"SM_Ops_Clad_slope_{side}_{name}", "Ceiling", bevel=0.0, camera=False,
+ shadow=False) # fmt: skip
+ if o is not None:
+ o["room"] = "corridor"
+
+
+def build(reserved: dict[str, list[tuple[float, float]]] | None = None) -> None:
+ reserved = reserved or {}
+ with kit.into(scene.collection("Ceiling")):
+ for w in walls():
+ with kit.ghost(w.clip):
+ dress_wall(w, reserved.get(w.key, []))
+ with kit.ghost(CUT_H):
+ corridor_upper()
+ with kit.ghost(-1.0):
+ corridor_slopes()
diff --git a/art/verse/decks/ops/fitout.py b/art/verse/decks/ops/fitout.py
new file mode 100644
index 0000000000..c5375959e4
--- /dev/null
+++ b/art/verse/decks/ops/fitout.py
@@ -0,0 +1,176 @@
+"""Fit-out of the Operations deck: the working clutter of a lived-in deck.
+
+Floor props along the room walls (equipment racks, service cabinets,
+workstations with screens and stools), freestanding cargo case stacks, a holo
+plinth, flush floor grilles and hatches, and overhead services under the
+ceilings (pipe runs, ducts, cable ladders), all from ``kit.props.fitout``.
+
+Floor props stand on the plate (``Props``, nav ``block``) only along walls and
+in corners the room's lanes, doorways, sockets and stations leave free; the
+nav grid loses those strips and nothing else. Grilles and hatches are flush
+inlays (nav ``none``). Overhead services are ceiling ghosts: the plate never
+sees them, the eye-level view does.
+"""
+
+from __future__ import annotations
+
+from decks.ops import cladding
+from decks.ops import layout as L
+from kit.architecture import cladding as C
+from kit.props import fitout as F
+from lib import kit, scene
+
+# Floor props along walls: wall key -> [(kind, u0, u1)]. ``u`` as in the
+# wall's frame (plan x on east-west walls, plan z on north-south walls).
+RUNS: dict[str, list[tuple[str, float, float]]] = {
+ "mess_s": [("cabinet", 11.0, 15.8), ("rack", 16.4, 17.6), ("desk", 18.2, 19.8),
+ ("cases", 21.2, 22.4)],
+ "records_s": [("rack", 33.4, 34.6), ("desk", 35.2, 36.8), ("desk", 37.2, 38.8),
+ ("desk", 45.2, 46.8), ("desk", 47.2, 48.8), ("rack", 49.4, 50.6)],
+ "simulator_w": [("rack", 4.6, 9.4), ("rack", 12.4, 16.0), ("desk", 19.2, 20.8)],
+ "simulator_e": [("rack", 4.6, 9.4), ("rack", 12.4, 16.0)],
+ "simulator_s": [("cabinet", 53.4, 55.8), ("rack", 69.8, 72.2)],
+ "quartermaster_w": [("cabinet", 15.4, 20.2)],
+ "quartermaster_e": [("cabinet", 15.4, 20.2)],
+ "quartermaster_s": [("rack", 77.6, 80.0), ("desk", 81.6, 83.2)],
+ "quarters_s": [("cabinet", 4.0, 9.4), ("rack", 12.6, 17.4), ("cases", 23.4, 24.6),
+ ("cases", 25.0, 26.2), ("rack", 33.4, 36.4)], # fmt: skip
+ "quarters_e": [("rack", 35.0, 37.4), ("desk", 43.8, 45.4), ("cabinet", 52.4, 55.4)],
+ "team_a_w": [("rack", 36.2, 38.6), ("desk", 41.4, 43.0)],
+ "team_a_e": [("rack", 36.2, 38.6), ("desk", 41.4, 43.0)],
+ "team_a_s": [("desk", 39.8, 41.4), ("desk", 50.6, 52.2)],
+ "team_b_w": [("rack", 36.2, 38.6), ("desk", 41.4, 43.0)],
+ "team_b_e": [("rack", 36.2, 38.6), ("desk", 41.4, 43.0)],
+ "team_b_s": [("desk", 55.8, 57.4), ("desk", 66.6, 68.2)],
+ "lobby_s": [("cabinet", 71.6, 73.8), ("cabinet", 78.2, 80.4)],
+ "storage_s": [("cabinet", 83.4, 85.8), ("rack", 90.0, 92.4)],
+ "medbay_w": [("rack", 49.0, 51.4), ("cabinet", 53.4, 56.4)],
+ "medbay_e": [("rack", 49.0, 51.4), ("cabinet", 53.4, 56.4)],
+ "medbay_s": [("cabinet", 73.0, 77.2), ("cabinet", 82.0, 86.2), ("cabinet", 89.0, 92.0)],
+} # fmt: skip
+
+# Freestanding case stacks: (room, x, z, yaw).
+STACKS = (
+ ("quartermaster", 80.6, 23.7, 0.0),
+ ("quartermaster", 82.0, 23.9, 0.0),
+ ("simulator", 71.6, 21.6, 90.0),
+ ("storage", 85.6, 34.9, 0.0),
+)
+HOLO = (("simulator", 55.2, 23.6),)
+
+# Flush floor grilles / hatches: (room, kind, x0, x1, z0, z1).
+FLOOR = (
+ ("mess", "grille", 16.4, 17.6, 10.2, 10.8),
+ ("mess", "grille", 16.4, 17.6, 14.4, 15.0),
+ ("mess", "grille", 16.4, 17.6, 18.6, 19.2),
+ ("quartermaster", "hatch", 83.4, 84.6, 15.2, 16.4),
+ ("medbay", "grille", 81.4, 82.6, 52.3, 52.9),
+ ("team_a", "hatch", 40.0, 41.2, 45.0, 46.2),
+ ("team_b", "hatch", 56.0, 57.2, 45.0, 46.2),
+ ("records", "grille", 41.4, 42.6, 24.6, 25.2),
+ ("storage", "hatch", 85.6, 86.8, 41.0, 42.2),
+)
+
+# Overhead services per wall: wall key -> kind ("pipes", "duct", "ladder").
+OVERHEAD = {
+ "mess_w": ("pipes",),
+ "mess_e": ("pipes", "duct"),
+ "mess_s": ("ladder",),
+ "records_w": ("pipes",),
+ "records_e": ("pipes", "duct"),
+ "records_s": ("ladder",),
+ "simulator_w": ("pipes", "duct"),
+ "simulator_e": ("pipes",),
+ "simulator_s": ("ladder",),
+ "quartermaster_w": ("pipes",),
+ "quartermaster_e": ("pipes", "duct"),
+ "quartermaster_s": ("ladder",),
+ "quarters_s": ("pipes",),
+ "quarters_e": ("ladder",),
+ "quarters_w": ("ladder",),
+ "team_a_s": ("pipes",),
+ "team_a_w": ("ladder",),
+ "team_b_s": ("pipes",),
+ "team_b_e": ("ladder",),
+ "storage_w": ("ladder",),
+ "storage_e": ("pipes",),
+ "lobby_s": ("pipes",),
+ "medbay_s": ("pipes",),
+ "medbay_e": ("ladder",),
+}
+
+
+def reserved() -> dict[str, list[tuple[float, float]]]:
+ """Wall spans with floor props in front (the cladding keeps its
+ terminals off them)."""
+ return {key: [(a, b) for _, a, b in runs] for key, runs in RUNS.items()}
+
+
+def _floor_runs(walls: dict[str, cladding.Wall]) -> None:
+ for key, runs in RUNS.items():
+ w = walls[key]
+ B = C.Builders().at(w.matrix())
+ for i, (kind, a, b) in enumerate(runs):
+ seed = ("ops-fit", key, i)
+ if kind == "rack":
+ F.equipment_rack(B, a, b, seed=seed)
+ elif kind == "cabinet":
+ F.low_cabinet(B, a, b, seed=seed, h=0.95 if w.room != "quarters" else 0.8)
+ elif kind == "desk":
+ F.workstation(B, (a + b) / 2, width=b - a, seed=seed)
+ elif kind == "cases":
+ F.case_stack(B, (a + b) / 2, 0.5, seed)
+ B.finish(f"SM_Ops_Fit_{key}", room=w.room, nav="block")
+
+
+def _freestanding() -> None:
+ for i, (rid, x, z, yaw) in enumerate(STACKS):
+ B = C.Builders().at(C.place_matrix(x, z, yaw))
+ F.case_stack(B, 0.0, 0.0, ("ops-stack", i))
+ B.finish(f"SM_Ops_FitStack_{i}", room=rid, nav="block")
+ for i, (rid, x, z) in enumerate(HOLO):
+ B = C.Builders().at(C.place_matrix(x, z, 0.0))
+ F.holo_plinth(B, 0.0, 0.0, seed=("ops-holo", i))
+ B.finish(f"SM_Ops_FitHolo_{i}", room=rid, nav="block")
+
+
+def _floor_inlays() -> None:
+ by_room: dict[str, C.Builders] = {}
+ for rid, kind, x0, x1, z0, z1 in FLOOR:
+ B = by_room.setdefault(rid, C.Builders().at(C.place_matrix(0.0, 0.0, 0.0)))
+ # place_matrix(0, 0, 0): u = plan x, v = plan z.
+ (F.floor_grille if kind == "grille" else F.floor_hatch)(B, x0, x1, z0, z1)
+ for x in (12.0, 31.2, 50.4, 69.6, 88.8): # corridor service hatches
+ if all(abs(x - fx) > 1.6 for fx in (*L.BLAST_FRAMES, *L.END_PORTALS)):
+ B = by_room.setdefault("corridor", C.Builders().at(C.place_matrix(0.0, 0.0, 0.0)))
+ F.floor_hatch(B, x - 0.6, x + 0.6, L.CORR_Z_MID - 0.3, L.CORR_Z_MID + 0.3)
+ for rid, B in by_room.items():
+ B.finish(f"SM_Ops_FitFloor_{rid}", room=rid, nav="none")
+
+
+def _overhead(walls: dict[str, cladding.Wall]) -> None:
+ top = L.ROOM_H
+ for key, kinds in OVERHEAD.items():
+ w = walls[key]
+ B = C.Builders().at(w.matrix())
+ a, b = w.t0 + 0.3, w.t1 - 0.3
+ for kind in kinds:
+ if kind == "pipes":
+ F.pipe_run(B, a, b, 0.32, 3.86, top)
+ elif kind == "duct":
+ F.duct_run(B, a, b, 0.85, 1.35, 3.92, 4.28, top)
+ elif kind == "ladder":
+ F.cable_ladder(B, a, b, 0.25, 0.75, 4.12, top)
+ B.finish(f"SM_Ops_Overhead_{key}", room=w.room)
+
+
+def build() -> dict[str, list[tuple[float, float]]]:
+ """Build the fit-out; return the reserved wall spans for the cladding."""
+ walls = {w.key: w for w in cladding.walls()}
+ with kit.into(scene.collection("Props")):
+ _floor_runs(walls)
+ _freestanding()
+ _floor_inlays()
+ with kit.into(scene.collection("Ceiling")), kit.ghost(-1.0):
+ _overhead(walls)
+ return reserved()
diff --git a/art/verse/kit/architecture/cladding.py b/art/verse/kit/architecture/cladding.py
new file mode 100644
index 0000000000..bc9b443a85
--- /dev/null
+++ b/art/verse/kit/architecture/cladding.py
@@ -0,0 +1,571 @@
+"""Deck-agnostic wall cladding for the eye-level (realtime) view.
+
+The bridge's ``decks/bridge/cladding.py`` (PR #910) set the wall-detail level
+the eye-level view needs: panel seams, ribs with dash lamps, light columns,
+louvre vents, conduit runs on a rail, a recessed cornice. That module is tied
+to the bridge's layout; this one carries the same language with every height
+a parameter, so any deck can dress its walls with it, plus the wall-mounted
+fittings a working deck shows (terminals, sign plates, junction boxes,
+vertical conduit drops).
+
+Frame: every builder works in a wall's local frame ``(u, v, h)``: ``u`` runs
+along the wall in plan metres, ``v`` from the wall face into the room, ``h`` is
+the height above the deck. ``run_matrix`` makes that frame for a wall face
+(Blender axes, plan ``z`` = Blender ``-y``); ``place_matrix`` makes it for a
+freestanding prop (``v`` toward the prop's front).
+
+Builds go through ``kit.MeshBuilder``; call them inside ``kit.ghost(...)`` to
+make them ceiling ghosts (invisible to the plate camera, nav ``none``), which
+is how the walls are dressed without touching the plate, the nav grid or the
+occluders (docs/verse/realtime.md).
+"""
+
+from __future__ import annotations
+
+import math
+from dataclasses import dataclass, field
+
+from lib import kit
+from mathutils import Matrix
+
+CHARCOAL = "M_Wall_Charcoal"
+DARK = "M_Wall_PaintedDark"
+MID = "M_Wall_PaintedMid"
+LIGHT = "M_Wall_PaintedLight"
+GUNMETAL = "M_Struct_Gunmetal"
+STEEL = "M_Trim_BrushedSteel"
+RECESS = "M_Recess_Dark"
+RUBBER = "M_Rubber_Black"
+PIPE = "M_Hull_Pipe"
+PIPE_INS = "M_Hull_PipeInsulated"
+BACKLIT = "M_Light_Backlit"
+STRIP = "M_Light_WallStrip"
+RED = "M_Light_RedTrim"
+BODY = "M_Console_Body"
+KEYS = "M_Console_Keys"
+SCREEN = "M_Screen"
+WHITE_PAINT = "M_Deck_Marking_White"
+
+SEAM = 0.008 # reveal between panels
+BACK = 0.012 # dark backing plate: what the seams show
+PANEL_V = 0.045 # panel face, metres proud of the wall
+RIB_W = 0.6
+RIB_V = 0.15 # rib depth (inside the nav grid's 0.25 m body clearance)
+DASH = (0.1, 0.3, 0.15) # dash lamp width, height, gap
+LIGHT_W, LIGHT_H, LIGHT_GAP = 0.26, 0.15, 0.05 # backlit rectangles
+
+
+@dataclass(frozen=True)
+class Bands:
+ """Heights of a hall wall's bands (above deck level)."""
+
+ plinth_top: float = 0.3
+ lower: tuple[float, float] = (0.33, 2.73)
+ rail: tuple[float, float] = (2.73, 2.88)
+ conduit: tuple[float, float] = (2.88, 3.36)
+ cornice: float = 0.6 # recessed band under the ceiling
+
+
+@dataclass(frozen=True)
+class RoomBands:
+ """Heights of the light-grey room panelling."""
+
+ base: float = 0.6
+ channel: tuple[float, float] = (2.78, 3.02)
+
+
+DEFAULT_BANDS = Bands()
+DEFAULT_ROOM_BANDS = RoomBands()
+
+
+@dataclass
+class Opening:
+ u0: float
+ u1: float
+ head: float # top of the opening
+
+
+def run_matrix(axis: str, fixed: float, room_sign: int) -> Matrix:
+ """Local (u, v, h) -> Blender for a wall face.
+
+ The face lies at plan ``x = fixed`` (axis "z", ``u`` = plan z) or plan
+ ``z = fixed`` (axis "x", ``u`` = plan x); ``room_sign`` is the room's side
+ along the other plan axis.
+ """
+ if axis == "z":
+ return Matrix(((0, room_sign, 0, fixed), (-1, 0, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)))
+ return Matrix(((1, 0, 0, 0), (0, -room_sign, 0, -fixed), (0, 0, 1, 0), (0, 0, 0, 1)))
+
+
+def place_matrix(x: float, z: float, yaw_deg: float = 0.0) -> Matrix:
+ """Local (u, v, h) -> Blender for a freestanding prop at plan (x, z).
+
+ ``v`` points to the prop's front: yaw 0 faces plan +z (the plate camera),
+ 180 faces -z, 90 faces +x (same convention as ``kit.place``)."""
+ flip = Matrix(((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)))
+ return Matrix.Translation((x, -z, 0.0)) @ Matrix.Rotation(math.radians(yaw_deg), 4, "Z") @ flip
+
+
+def seed01(*parts) -> float:
+ return (kit.seed_for("clad", *parts) % 10000) / 10000.0
+
+
+@dataclass
+class Builders:
+ """One builder per finish, shared by every wall (or prop) of a group."""
+
+ panels: kit.MeshBuilder = field(default_factory=kit.MeshBuilder)
+ struct: kit.MeshBuilder = field(default_factory=kit.MeshBuilder)
+ flat: kit.MeshBuilder = field(default_factory=kit.MeshBuilder)
+ pipes: kit.MeshBuilder = field(default_factory=kit.MeshBuilder)
+ lamps: kit.MeshBuilder = field(default_factory=kit.MeshBuilder)
+
+ def at(self, matrix: Matrix) -> Builders:
+ for mb in self._all():
+ mb.matrix = matrix
+ return self
+
+ def _all(self):
+ return (self.panels, self.struct, self.flat, self.pipes, self.lamps)
+
+ def finish(self, prefix: str, **props) -> list:
+ """Build the meshes; ``props`` are cook properties for the solid parts
+ (lamps are always nav ``none`` and cast no shadow)."""
+ out = [
+ self.panels.build(f"{prefix}_panels", bevel_width=0.003, segments=1, **props),
+ self.struct.build(f"{prefix}_struct", bevel_width=0.006, segments=1, **props),
+ self.flat.build(f"{prefix}_flat", bevel_width=0.0, **props),
+ self.pipes.build(f"{prefix}_conduits", bevel_width=0.0, **props),
+ ]
+ lamp_props = {**props, "nav": "none"}
+ lamps = self.lamps.build(f"{prefix}_lamps", bevel_width=0.0, **lamp_props)
+ if lamps is not None:
+ lamps.visible_shadow = False
+ out.append(lamps)
+ return [o for o in out if o is not None]
+
+
+def box(mb: kit.MeshBuilder, u0, u1, v0, v1, h0, h1, material: str) -> None:
+ if u1 - u0 > 1e-4 and h1 - h0 > 1e-4 and v1 - v0 > 1e-5:
+ mb.box((u0, v0, h0), (u1, v1, h1), material)
+
+
+def modules(a: float, b: float, module: float) -> list[tuple[float, float]]:
+ n = max(1, round((b - a) / module))
+ step = (b - a) / n
+ return [(a + i * step, a + (i + 1) * step) for i in range(n)]
+
+
+def subtract(a: float, b: float, holes) -> list[tuple[float, float]]:
+ """Parts of [a, b] outside the given (u0, u1) holes."""
+ spans = [(a, b)]
+ for h0, h1 in sorted(holes):
+ out = []
+ for s0, s1 in spans:
+ if h1 <= s0 or h0 >= s1:
+ out.append((s0, s1))
+ continue
+ if h0 > s0:
+ out.append((s0, h0))
+ if h1 < s1:
+ out.append((h1, s1))
+ spans = out
+ return [(s0, s1) for s0, s1 in spans if s1 - s0 > 0.05]
+
+
+# ---------------------------------------------------------------- elements
+
+
+def louvre(B: Builders, cu: float, h0: float, w: float = 0.6, h: float = 0.3) -> None:
+ """Louvre vent: gunmetal frame, 8 dark slats."""
+ box(B.struct, cu - w / 2, cu + w / 2, BACK, PANEL_V + 0.012, h0, h0 + h, GUNMETAL)
+ box(B.flat, cu - w / 2 + 0.04, cu + w / 2 - 0.04, PANEL_V + 0.012, PANEL_V + 0.014,
+ h0 + 0.03, h0 + h - 0.03, RECESS) # fmt: skip
+ pitch = (h - 0.06) / 8
+ for k in range(8):
+ z = h0 + 0.03 + k * pitch + pitch * 0.3
+ box(B.flat, cu - w / 2 + 0.05, cu + w / 2 - 0.05, PANEL_V + 0.014, PANEL_V + 0.03,
+ z, z + pitch * 0.45, GUNMETAL) # fmt: skip
+
+
+def panel(B: Builders, u0, u1, h0, h1, material: str, *, inset: bool, v: float = PANEL_V):
+ """A panel proud of the backing; ``inset`` adds a recessed field with a
+ 50 mm border."""
+ a, b = u0 + SEAM / 2, u1 - SEAM / 2
+ z0, z1 = h0 + SEAM / 2, h1 - SEAM / 2
+ if not inset or b - a < 0.25 or z1 - z0 < 0.25:
+ box(B.panels, a, b, BACK, v, z0, z1, material)
+ return
+ bd = 0.05
+ box(B.panels, a, b, BACK, v, z0, z0 + bd, material)
+ box(B.panels, a, b, BACK, v, z1 - bd, z1, material)
+ box(B.panels, a, a + bd, BACK, v, z0 + bd, z1 - bd, material)
+ box(B.panels, b - bd, b, BACK, v, z0 + bd, z1 - bd, material)
+ box(B.panels, a + bd, b - bd, BACK, v - 0.02, z0 + bd, z1 - bd, material)
+
+
+def light_column(B: Builders, cu: float, h0: float, h1: float, seed) -> None:
+ """The hero wall's light column in one 0.6 m module: charcoal cheeks,
+ gunmetal ribs and a recessed bay of stacked backlit rectangles, every
+ fifth slot a dark plate."""
+ bay = 0.36
+ for s in (-1, 1):
+ cheek0, cheek1 = sorted((cu + s * (bay / 2 + 0.06), cu + s * (0.3 - SEAM / 2)))
+ box(B.panels, cheek0, cheek1, BACK, PANEL_V, h0 + SEAM / 2, h1 - SEAM / 2, CHARCOAL)
+ r0, r1 = sorted((cu + s * bay / 2, cu + s * (bay / 2 + 0.06)))
+ box(B.struct, r0, r1, BACK, PANEL_V + 0.02, h0, h1, GUNMETAL)
+ box(B.flat, cu - bay / 2, cu + bay / 2, BACK, BACK + 0.004, h0, h1, RECESS)
+ z = h0 + 0.1
+ slot = kit.seed_for(seed) % 5
+ while z + LIGHT_H < h1 - 0.06:
+ if slot % 5 != 4:
+ box(B.lamps, cu - LIGHT_W / 2, cu + LIGHT_W / 2, BACK + 0.012, BACK + 0.016,
+ z, z + LIGHT_H, BACKLIT) # fmt: skip
+ else:
+ box(B.struct, cu - LIGHT_W / 2, cu + LIGHT_W / 2, BACK + 0.004, BACK + 0.03,
+ z, z + LIGHT_H, GUNMETAL) # fmt: skip
+ z += LIGHT_H + LIGHT_GAP
+ slot += 1
+
+
+def rib(B: Builders, r: float, bottom: float, top: float, *, foot: bool, red: bool, dashes) -> None:
+ """Gunmetal rib: stepped core and front plates around a lamp slot, a
+ splayed foot and a chamfered capital."""
+ w = RIB_W / 2
+ box(B.struct, r - w, r + w, BACK, 0.11, bottom, top, GUNMETAL)
+ for s in (-1, 1):
+ a, b = sorted((r + s * 0.06, r + s * 0.19))
+ box(B.struct, a, b, 0.11, RIB_V, bottom + (0.4 if foot else 0.0), top - 0.5, GUNMETAL)
+ box(B.flat, r - 0.06, r + 0.06, 0.11, 0.128, bottom, top - 0.5, RECESS)
+ if foot:
+ B.struct.prism_x(
+ [(BACK, bottom), (0.2, bottom), (0.2, bottom + 0.22), (0.11, bottom + 0.4),
+ (BACK, bottom + 0.4)],
+ r - w - 0.06,
+ r + w + 0.06,
+ GUNMETAL,
+ ) # fmt: skip
+ B.struct.prism_x(
+ [(BACK, top - 0.5), (0.11, top - 0.5), (0.2, top - 0.36), (0.2, top), (BACK, top)],
+ r - w - 0.04,
+ r + w + 0.04,
+ GUNMETAL,
+ )
+ dw, dh, _ = DASH
+ for z in dashes:
+ box(B.lamps, r - dw / 2, r + dw / 2, 0.128, 0.132, z, z + dh, BACKLIT)
+ if red:
+ box(B.lamps, r - 0.025, r + 0.025, 0.128, 0.132, max(bottom + 2.0, top - 2.6), top - 0.6,
+ RED) # fmt: skip
+
+
+def conduits(B: Builders, u0: float, u1: float, h0: float, h1: float, ribs, seed) -> None:
+ """Conduit bundle on the rail: three pipes with clamps every 1.2 m and a
+ junction box every other bay."""
+ box(B.panels, u0, u1, BACK, BACK + 0.008, h0, h1, DARK)
+ span = h1 - h0
+ for f, r, mat in ((0.2, 0.045, PIPE_INS), (0.46, 0.03, PIPE), (0.7, 0.04, PIPE)):
+ v = BACK + r + 0.035
+ B.pipes.tube((u0 + 0.02, v, h0 + f * span), (u1 - 0.02, v, h0 + f * span), r, mat,
+ segments=10) # fmt: skip
+ u = u0 + 0.6
+ k = 0
+ while u < u1 - 0.3:
+ if all(abs(u - rr) > RIB_W / 2 + 0.1 for rr in ribs):
+ box(B.struct, u - 0.03, u + 0.03, BACK, 0.135, h0 + 0.03, h1 - 0.05, GUNMETAL)
+ if k % 4 == 2 and seed01(seed, "jbox", k) < 0.6:
+ box(B.panels, u + 0.15, u + 0.45, BACK, 0.16, h0 + 0.05, h1 - 0.1, MID)
+ lamp = "M_Indicator_Green" if seed01(seed, "jl", k) < 0.5 else "M_Indicator_White"
+ box(B.lamps, u + 0.38, u + 0.42, 0.16, 0.164, h1 - 0.18, h1 - 0.14, lamp)
+ u += 1.2
+ k += 1
+
+
+# ---------------------------------------------------------------- fittings
+
+
+def wall_terminal(B: Builders, cu: float, h0: float = 1.05, *, seed=0) -> None:
+ """Wall-mounted duty terminal: gunmetal housing, a recessed dark-blue
+ screen with thin readouts, a key strip and two status pips."""
+ w, h = 0.62, 0.86
+ box(B.struct, cu - w / 2, cu + w / 2, BACK, 0.11, h0, h0 + h, GUNMETAL)
+ box(B.panels, cu - w / 2 + 0.03, cu + w / 2 - 0.03, 0.11, 0.13, h0 + 0.02, h0 + h - 0.02, BODY)
+ box(B.flat, cu - 0.24, cu + 0.24, 0.13, 0.132, h0 + 0.33, h0 + 0.74, RECESS)
+ box(B.lamps, cu - 0.22, cu + 0.22, 0.132, 0.134, h0 + 0.35, h0 + 0.72, SCREEN)
+ # Sloped key shelf.
+ B.struct.prism_x(
+ [(0.13, h0 + 0.1), (0.24, h0 + 0.16), (0.24, h0 + 0.2), (0.13, h0 + 0.3)],
+ cu - 0.26,
+ cu + 0.26,
+ BODY,
+ )
+ for i in range(6):
+ k = cu - 0.2 + i * 0.08
+ box(B.flat, k - 0.025, k + 0.025, 0.2, 0.245, h0 + 0.2, h0 + 0.215, KEYS)
+ pips = ("M_Indicator_Green", "M_Indicator_White", "M_Indicator_Amber", "M_Indicator_Red")
+ first = pips[int(seed01(seed, "pip") * 2)]
+ second = pips[1 + int(seed01(seed, "pip2") * 3)]
+ for du, mat in ((-0.26, first), (-0.2, second)):
+ box(B.lamps, cu + du, cu + du + 0.035, 0.13, 0.136, h0 + 0.77, h0 + 0.8, mat)
+
+
+DIGITS = {
+ "0": "abcdef",
+ "1": "bc",
+ "2": "abged",
+ "3": "abgcd",
+ "4": "fgbc",
+ "5": "afgcd",
+ "6": "afgedc",
+ "7": "abc",
+ "8": "abcdefg",
+ "9": "abfgcd",
+ "-": "g",
+}
+
+
+def _segments(text: str, ch: float):
+ """Stencil segments of digit codes as (u0, u1, d0, d1); d down from the top."""
+ w, t, gap = ch * 0.5, ch * 0.13, ch * 0.06
+ out, u = [], 0.0
+ for c in text:
+ if c == " ":
+ u += w * 0.8
+ continue
+ hv = ch / 2
+ segs = {
+ "a": (u + gap, u + w - gap, 0.0, t),
+ "b": (u + w - t, u + w, gap, hv - gap / 2),
+ "c": (u + w - t, u + w, hv + gap / 2, ch - gap),
+ "d": (u + gap, u + w - gap, ch - t, ch),
+ "e": (u, u + t, hv + gap / 2, ch - gap),
+ "f": (u, u + t, gap, hv - gap / 2),
+ "g": (u + gap, u + w - gap, hv - t / 2, hv + t / 2),
+ }
+ out += [segs[s] for s in DIGITS[c]]
+ u += w + ch * 0.28
+ return out, u - ch * 0.28
+
+
+def sign_plate(B: Builders, cu: float, h_top: float, code: str, *, ch: float = 0.12,
+ stripe: str | None = "M_Paint_TrimRed") -> None: # fmt: skip
+ """Section sign: a dark plate with a brushed top edge, a white stencil
+ code (digits and dashes only, no words) and an optional colour stripe."""
+ segs, width = _segments(code, ch)
+ pad = ch * 0.5
+ w = width + 2 * pad + (0.1 if stripe else 0.0)
+ u0 = cu - w / 2
+ h0 = h_top - ch - 2 * pad
+ box(B.panels, u0, u0 + w, BACK, 0.03, h0, h_top, DARK)
+ box(B.struct, u0 - 0.01, u0 + w + 0.01, BACK, 0.036, h_top, h_top + 0.014, STEEL)
+ x = u0 + pad
+ if stripe:
+ box(B.panels, u0 + 0.03, u0 + 0.07, 0.03, 0.033, h0 + 0.03, h_top - 0.03, stripe)
+ x += 0.1
+ for a, b, d0, d1 in segs:
+ box(B.flat, x + a, x + b, 0.03, 0.034, h_top - pad - d1, h_top - pad - d0, WHITE_PAINT)
+
+
+def status_panel(B: Builders, cu: float, h0: float, *, seed=0) -> None:
+ """Backlit status board: a gunmetal frame around a column of white bars
+ with one coloured pip (amber or red only on some)."""
+ w, h = 0.36, 0.7
+ box(B.struct, cu - w / 2, cu + w / 2, BACK, 0.07, h0, h0 + h, GUNMETAL)
+ box(B.flat, cu - w / 2 + 0.04, cu + w / 2 - 0.04, 0.07, 0.072, h0 + 0.04, h0 + h - 0.04, RECESS)
+ for i in range(5):
+ z = h0 + 0.1 + i * 0.11
+ ln = 0.12 + 0.12 * seed01(seed, "bar", i)
+ box(B.lamps, cu - 0.12, cu - 0.12 + ln, 0.072, 0.075, z, z + 0.04, BACKLIT)
+ r = seed01(seed, "pip")
+ mat = "M_Indicator_Red" if r < 0.2 else "M_Indicator_Amber" if r < 0.45 else "M_Indicator_Green"
+ box(B.lamps, cu + 0.08, cu + 0.12, 0.072, 0.078, h0 + h - 0.12, h0 + h - 0.08, mat)
+
+
+def junction_box(B: Builders, cu: float, h0: float, w: float = 0.42, h: float = 0.5, *,
+ seed=0) -> None: # fmt: skip
+ """Electrical junction box with a hinged lid, bolts and a cable gland
+ feeding a conduit up to the rail."""
+ box(B.struct, cu - w / 2, cu + w / 2, BACK, 0.17, h0, h0 + h, MID)
+ box(B.panels, cu - w / 2 + 0.025, cu + w / 2 - 0.025, 0.17, 0.18, h0 + 0.025, h0 + h - 0.025,
+ DARK) # fmt: skip
+ for su in (-1, 1):
+ for sh in (0, 1):
+ box(B.flat, cu + su * (w / 2 - 0.045) - 0.012, cu + su * (w / 2 - 0.045) + 0.012,
+ 0.18, 0.186, h0 + 0.04 + sh * (h - 0.08) - 0.012,
+ h0 + 0.04 + sh * (h - 0.08) + 0.012, STEEL) # fmt: skip
+ mat = "M_Indicator_Green" if seed01(seed, "jb") < 0.7 else "M_Indicator_Amber"
+ box(B.lamps, cu - 0.02, cu + 0.02, 0.18, 0.186, h0 + h - 0.08, h0 + h - 0.05, mat)
+
+
+def conduit_drop(B: Builders, cu: float, h0: float, h1: float, n: int = 2) -> None:
+ """Vertical conduit pipes on stand-off clamps (a feed from the rail down
+ to a fitting)."""
+ for i in range(n):
+ u = cu + (i - (n - 1) / 2) * 0.09
+ B.pipes.tube((u, 0.06, h0), (u, 0.06, h1), 0.025, PIPE, segments=8)
+ z = h0 + 0.3
+ while z < h1 - 0.1:
+ box(B.struct, cu - 0.05 * n - 0.02, cu + 0.05 * n + 0.02, BACK, 0.1, z, z + 0.04, GUNMETAL)
+ z += 0.6
+
+
+# ---------------------------------------------------------------- walls
+
+
+def hall_wall(
+ B: Builders,
+ seed,
+ t0: float,
+ t1: float,
+ *,
+ top: float,
+ ribs: list[float],
+ floor: float = 0.0,
+ bands: Bands = DEFAULT_BANDS,
+ lit_bays: set[int] | None = None,
+ lit_upper: set[int] | None = None,
+ red_ribs: set[int] | None = None,
+ lower_material: str = CHARCOAL,
+ openings: list[Opening] = (),
+) -> list[tuple[float, float]]:
+ """Dress a hall wall face between ``t0`` and ``t1`` (plan metres along it)
+ in the hero language: plinth with louvres, a lower field of 0.6 m charcoal
+ panels with light columns in ``lit_bays``, a rail with a conduit bundle, an
+ upper field, a recessed cornice and gunmetal ribs at ``ribs``. Returns the
+ bays (u spans between ribs) for further fittings."""
+ lit_bays, lit_upper, red_ribs = lit_bays or set(), lit_upper or set(), red_ribs or set()
+ holes = [(o.u0, o.u1) for o in openings]
+ lower = (floor + bands.lower[0], floor + bands.lower[1])
+ rail = (floor + bands.rail[0], floor + bands.rail[1])
+ cond = (floor + bands.conduit[0], floor + bands.conduit[1])
+ plinth_top = floor + bands.plinth_top
+ for a, b in subtract(t0, t1, holes):
+ box(B.flat, a, b, 0.0, BACK, floor, top, RECESS)
+ for o in openings:
+ box(B.flat, o.u0, o.u1, 0.0, BACK, o.head, top, RECESS)
+ for a, b in subtract(t0, t1, holes):
+ for i, (m0, m1) in enumerate(modules(a, b, 1.2)):
+ box(B.panels, m0 + SEAM / 2, m1 - SEAM / 2, BACK, BACK + 0.022, floor, plinth_top, DARK)
+ if i % 2 == 1 and m1 - m0 > 0.8:
+ louvre(B, (m0 + m1) / 2, floor + 0.02, w=0.6, h=0.24)
+ box(B.struct, a, b, BACK, 0.05, plinth_top, lower[0], STEEL)
+ edges = [t0, *[r for r in ribs if t0 < r < t1], t1]
+ bays = []
+ for a, b in zip(edges[:-1], edges[1:], strict=True):
+ bays.append((a + (RIB_W / 2 if a in ribs else 0.0), b - (RIB_W / 2 if b in ribs else 0.0)))
+ upper = (cond[1], top - bands.cornice)
+ for bi, (a, b) in enumerate(bays):
+ cu = round(((a + b) / 2) / 0.3) * 0.3
+ lit_low = bi in lit_bays and b - a > 1.8 and not any(
+ o.u0 - 0.4 < cu < o.u1 + 0.4 for o in openings
+ )
+ lit_up = bi in lit_upper and b - a > 1.8 and upper[1] - upper[0] > 0.8
+ low_holes = holes + ([(cu - 0.3, cu + 0.3)] if lit_low else [])
+ for sa, sb in subtract(a, b, low_holes):
+ for i, (m0, m1) in enumerate(modules(sa, sb, 0.6)):
+ inset = seed01(seed, bi, sa, i) < 0.25
+ mat = DARK if seed01(seed, "m", bi, sa, i) < 0.12 else lower_material
+ panel(B, m0, m1, lower[0], lower[1], mat, inset=inset)
+ for o in openings:
+ for sa, sb in subtract(max(a, o.u0), min(b, o.u1), []):
+ if o.head < lower[1] - 0.1:
+ panel(B, sa, sb, o.head + 0.03, lower[1], lower_material, inset=False)
+ if lit_low:
+ light_column(B, cu, lower[0], lower[1], (seed, "low", bi))
+ if upper[1] - upper[0] < 0.1:
+ continue
+ up_holes = [(cu - 0.3, cu + 0.3)] if lit_up else []
+ rows = max(1, round((upper[1] - upper[0]) / 1.1))
+ rh = (upper[1] - upper[0]) / rows
+ for sa, sb in subtract(a, b, up_holes):
+ for i, (m0, m1) in enumerate(modules(sa, sb, 1.2)):
+ for j in range(rows):
+ h0, h1 = upper[0] + j * rh, upper[0] + (j + 1) * rh
+ r = seed01(seed, "u", bi, sa, i, j)
+ panel(B, m0, m1, h0, h1, MID if r < 0.16 else DARK, inset=0.16 <= r < 0.4)
+ if j == 0 and r > 0.88 and m1 - m0 > 0.9 and h1 - h0 > 0.5:
+ louvre(B, (m0 + m1) / 2, h0 + 0.12)
+ if lit_up:
+ light_column(B, cu, upper[0] + 0.08, upper[1] - 0.08, (seed, "up", bi))
+ box(B.struct, t0, t1, BACK, 0.09, rail[0], rail[1] - 0.015, GUNMETAL)
+ box(B.struct, t0, t1, BACK, 0.095, rail[1] - 0.015, rail[1], STEEL)
+ conduits(B, t0, t1, cond[0], cond[1], ribs, seed)
+ c0 = top - bands.cornice
+ box(B.struct, t0, t1, BACK, 0.07, c0, c0 + 0.06, GUNMETAL)
+ for m0, m1 in modules(t0, t1, 2.4):
+ box(B.panels, m0 + SEAM / 2, m1 - SEAM / 2, BACK, BACK + 0.01, c0 + 0.06, top - 0.06, DARK)
+ box(B.struct, t0, t1, BACK, 0.05, top - 0.06, top, GUNMETAL)
+ dw, dh, gap = DASH
+ for ri, r in enumerate(ribs):
+ if not t0 < r < t1:
+ continue
+ blocked = any(o.u0 - RIB_W < r < o.u1 + RIB_W for o in openings)
+ bottom = cond[0] if blocked else floor
+ dashes = [] if blocked else [floor + 0.6 + k * (dh + gap) for k in range(7)]
+ rib(B, r, bottom, top, foot=not blocked, red=ri in red_ribs, dashes=dashes)
+ return bays
+
+
+def room_wall(
+ B: Builders,
+ seed,
+ t0: float,
+ t1: float,
+ *,
+ top: float,
+ bands: RoomBands = DEFAULT_ROOM_BANDS,
+ pilasters: list[float] = (),
+ openings: list[Opening] = (),
+ base_from: float = 0.0,
+) -> None:
+ """Light-grey secondary panelling: base band with vents, panels with
+ hatches, a light channel with its fixture hidden under the lip, upper
+ panels, gunmetal pilasters."""
+ base = bands.base
+ c0, c1 = bands.channel
+ holes = [(o.u0, o.u1) for o in openings]
+ for a, b in subtract(t0, t1, holes):
+ box(B.flat, a, b, 0.0, BACK, base_from, top, RECESS)
+ for i, (m0, m1) in enumerate(modules(a, b, 1.2)):
+ box(B.panels, m0 + SEAM / 2, m1 - SEAM / 2, BACK, BACK + 0.022,
+ base_from, base - 0.025, DARK) # fmt: skip
+ if i % 2 == 1 and m1 - m0 > 0.8:
+ louvre(B, (m0 + m1) / 2, 0.14, w=0.6, h=0.3)
+ hatch = i % 4 == 2 and seed01(seed, "hatch", a, i) < 0.7
+ panel(B, m0, m1, base, c0, LIGHT, inset=hatch)
+ if hatch:
+ cu = (m0 + m1) / 2
+ box(B.struct, cu - 0.09, cu + 0.09, PANEL_V, PANEL_V + 0.01, 2.1, 2.15, STEEL)
+ panel(B, m0, m1, c1, top - 0.04, MID, inset=False)
+ box(B.struct, a, b, BACK, 0.05, base - 0.025, base, STEEL)
+ for o in openings:
+ if o.head < c0:
+ for m0, m1 in modules(o.u0, o.u1, 1.2):
+ panel(B, m0, m1, o.head + 0.03, c0, LIGHT, inset=False)
+ box(B.flat, o.u0, o.u1, 0.0, BACK, o.head, top, RECESS)
+ for m0, m1 in modules(o.u0, o.u1, 1.2):
+ panel(B, m0, m1, c1, top - 0.04, MID, inset=False)
+ box(B.struct, t0, t1, BACK, 0.065, c0, c0 + 0.05, STEEL)
+ box(B.panels, t0, t1, BACK, 0.1, c1 - 0.07, c1, MID)
+ box(B.flat, t0, t1, BACK, BACK + 0.006, c0 + 0.05, c1 - 0.07, LIGHT)
+ for a, b in modules(t0, t1, 2.4):
+ cu, half = (a + b) / 2, (b - a) / 4
+ box(B.lamps, cu - half, cu + half, 0.03, 0.09, c1 - 0.074, c1 - 0.07, STRIP)
+ box(B.struct, t0, t1, BACK, 0.04, top - 0.04, top, GUNMETAL)
+ for p in pilasters:
+ if t0 < p < t1:
+ box(B.struct, p - 0.15, p + 0.15, BACK, 0.1, base_from, top, GUNMETAL)
+ box(B.struct, p - 0.08, p + 0.08, 0.1, 0.12, base_from + 0.3, top - 0.3, GUNMETAL)
+ box(B.flat, p - 0.02, p + 0.02, 0.12, 0.122, 0.9, c0 - 0.2, RECESS)
+
+
+def rib_stations(t0: float, t1: float, step: float = 4.8, origin: float = 0.0) -> list[float]:
+ """Rib positions on a ``step`` grid from ``origin``, clear of the ends."""
+ out = []
+ k = math.ceil((t0 - origin) / step)
+ while origin + k * step < t1:
+ r = origin + k * step
+ if t0 + 0.5 < r < t1 - 0.5:
+ out.append(round(r, 3))
+ k += 1
+ return out
diff --git a/art/verse/kit/props/fitout.py b/art/verse/kit/props/fitout.py
new file mode 100644
index 0000000000..4a64fd76f9
--- /dev/null
+++ b/art/verse/kit/props/fitout.py
@@ -0,0 +1,364 @@
+"""Working-deck fit-out props for the Verse kit, deck-agnostic.
+
+The furniture a busy ship's deck collects along its walls and under its
+ceiling: equipment racks with status lights, low service cabinets, wall-side
+workstations with screens and a crew stool, stacked cargo cases, a small holo
+plinth, flush floor grilles and hatches, and the overhead services (pipe
+runs, ducts, cable ladders on hangers).
+
+Every builder adds boxes and tubes to a ``kit.architecture.cladding.Builders``
+in its current frame ``(u, v, h)``: ``u`` along, ``v`` out of the wall toward
+the prop's front, ``h`` up (``cladding.run_matrix`` for a wall run,
+``cladding.place_matrix`` for a freestanding piece). Lamps and screens go to
+``B.lamps`` (nav ``none``, no shadow); the deck decides what is a ghost and
+what stands on the plate. Only existing library materials are used.
+"""
+
+from __future__ import annotations
+
+import math
+
+from kit.architecture.cladding import (
+ BODY,
+ DARK,
+ GUNMETAL,
+ KEYS,
+ MID,
+ PIPE,
+ PIPE_INS,
+ RECESS,
+ RUBBER,
+ SCREEN,
+ STEEL,
+ WHITE_PAINT,
+ Builders,
+ box,
+ louvre,
+ seed01,
+)
+
+CRATE = "M_Crate_Paint"
+GRATING = "M_Floor_Grating"
+SEAT = "M_Seat_Upholstery"
+DECK = "M_Console_Deck"
+GLASS = "M_Glass_Clear"
+STATUS = ("M_Indicator_Green", "M_Indicator_White", "M_Indicator_Green", "M_Indicator_Amber")
+
+
+def _pip_mat(seed, *parts) -> str:
+ r = seed01(seed, *parts)
+ if r < 0.05:
+ return "M_Indicator_Red"
+ return STATUS[int(r * 4) % 4]
+
+
+# ---------------------------------------------------------------- racks
+
+
+def equipment_rack(B: Builders, u0: float, u1: float, *, h: float = 2.1, depth: float = 0.62,
+ seed=0) -> None: # fmt: skip
+ """Equipment rack against a wall: gunmetal frame, one door per 0.6 m
+ module (vent grille, a column of status pips, a handle), a plinth and a
+ cable bundle leaving the top toward the wall."""
+ v0, v1 = 0.04, 0.04 + depth
+ box(B.struct, u0, u1, v0, v1, 0.0, 0.08, RUBBER)
+ box(B.struct, u0, u1, v0, v1 - 0.03, 0.08, h, BODY)
+ box(B.struct, u0 - 0.01, u1 + 0.01, v0, v1, h, h + 0.04, GUNMETAL)
+ n = max(1, round((u1 - u0) / 0.6))
+ step = (u1 - u0) / n
+ for i in range(n):
+ a, b = u0 + i * step + 0.02, u0 + (i + 1) * step - 0.02
+ kind = seed01(seed, "door", i)
+ box(B.panels, a, b, v1 - 0.03, v1, 0.12, h - 0.04, DARK if kind < 0.6 else MID)
+ if kind < 0.35: # vented door
+ for k in range(10):
+ z = 0.3 + k * 0.08
+ box(B.flat, a + 0.06, b - 0.06, v1, v1 + 0.004, z, z + 0.03, RECESS)
+ elif kind < 0.7: # instrument window with blades
+ box(B.flat, a + 0.05, b - 0.05, v1, v1 + 0.003, 0.8, h - 0.3, RECESS)
+ for k in range(int((h - 1.1) / 0.09)):
+ z = 0.84 + k * 0.09
+ box(B.struct, a + 0.07, b - 0.07, v1 - 0.02, v1 + 0.002, z, z + 0.045, GUNMETAL)
+ else: # plain door with a label strip
+ box(B.flat, a + 0.08, a + 0.3, v1, v1 + 0.003, h - 0.42, h - 0.36, WHITE_PAINT)
+ # Status column on the hinge side, sparse.
+ z, k = 1.0, 0
+ while z < h - 0.3:
+ if seed01(seed, "led", i, k) < 0.55:
+ box(B.lamps, a + 0.03, a + 0.055, v1, v1 + 0.006, z, z + 0.02, _pip_mat(seed, i, k))
+ z += 0.07
+ k += 1
+ box(B.struct, b - 0.06, b - 0.04, v1, v1 + 0.03, 0.9, 1.25, STEEL)
+ # Cable bundle from the top into the wall.
+ for k in range(3):
+ cu = u0 + 0.2 + k * 0.1
+ B.pipes.tube((cu, v0 + 0.25, h + 0.04), (cu, v0 + 0.25, h + 0.25), 0.02, RUBBER, 6)
+ B.pipes.tube((cu, v0 + 0.25, h + 0.25), (cu, 0.01, h + 0.25), 0.02, RUBBER, 6)
+
+
+def low_cabinet(B: Builders, u0: float, u1: float, *, h: float = 0.95, depth: float = 0.6,
+ seed=0, clutter: bool = True) -> None: # fmt: skip
+ """Service cabinet run: plinth, doors per 0.6 m, a brushed top with a
+ few cases and a small readout on it."""
+ v0, v1 = 0.04, 0.04 + depth
+ box(B.struct, u0, u1, v0 + 0.06, v1 - 0.06, 0.0, 0.1, RUBBER)
+ box(B.struct, u0, u1, v0, v1 - 0.02, 0.1, h - 0.03, BODY)
+ box(B.struct, u0 - 0.02, u1 + 0.02, v0, v1 + 0.02, h - 0.03, h, STEEL)
+ n = max(1, round((u1 - u0) / 0.6))
+ step = (u1 - u0) / n
+ for i in range(n):
+ a, b = u0 + i * step + 0.015, u0 + (i + 1) * step - 0.015
+ box(B.panels, a, b, v1 - 0.02, v1, 0.14, h - 0.07, DARK if i % 3 else MID)
+ box(B.struct, (a + b) / 2 - 0.08, (a + b) / 2 + 0.08, v1, v1 + 0.025, h - 0.18, h - 0.15,
+ STEEL) # fmt: skip
+ if seed01(seed, "lv", i) < 0.3:
+ louvre(B, (a + b) / 2, 0.22, w=min(0.45, b - a - 0.1), h=0.22)
+ if not clutter:
+ return
+ u = u0 + 0.15
+ k = 0
+ while u < u1 - 0.5:
+ r = seed01(seed, "cl", k)
+ if r < 0.35:
+ w = 0.3 + 0.2 * seed01(seed, "w", k)
+ box(B.struct, u, u + w, v0 + 0.1, v0 + 0.42, h, h + 0.16 + 0.1 * r, CRATE)
+ u += w + 0.15
+ elif r < 0.5:
+ box(B.struct, u, u + 0.34, v0 + 0.08, v0 + 0.3, h, h + 0.03, BODY)
+ B.struct.prism_x([(v0 + 0.1, h + 0.03), (v0 + 0.16, h + 0.03), (v0 + 0.16, h + 0.26),
+ (v0 + 0.13, h + 0.26)], u + 0.04, u + 0.3, BODY) # fmt: skip
+ box(B.lamps, u + 0.06, u + 0.28, v0 + 0.161, v0 + 0.163, h + 0.07, h + 0.24, SCREEN)
+ u += 0.5
+ else:
+ u += 0.45
+ k += 1
+
+
+# ---------------------------------------------------------------- workstations
+
+
+def stool(B: Builders, cu: float, cv: float, *, back: bool = True, yaw_deg: float = 0.0) -> None:
+ """Crew stool: weighted base, column, cushion, optional low back (toward +v)."""
+ B.struct.tube((cu, cv, 0.0), (cu, cv, 0.04), 0.24, GUNMETAL, 16)
+ B.struct.tube((cu, cv, 0.04), (cu, cv, 0.42), 0.035, STEEL, 10)
+ B.struct.tube((cu, cv, 0.42), (cu, cv, 0.47), 0.22, BODY, 18)
+ B.panels.tube((cu, cv, 0.47), (cu, cv, 0.52), 0.21, SEAT, 18)
+ if back:
+ s, c = math.sin(math.radians(yaw_deg)), math.cos(math.radians(yaw_deg))
+ bu, bv = cu + 0.2 * s, cv + 0.2 * c
+ B.struct.tube((bu, bv, 0.47), (bu, bv, 0.62), 0.02, STEEL, 8)
+ box(B.panels, bu - 0.18, bu + 0.18, bv - 0.03, bv + 0.03, 0.62, 0.86, SEAT)
+
+
+def workstation(B: Builders, cu: float, *, width: float = 1.6, depth: float = 0.8, seed=0,
+ chair: bool = True) -> None: # fmt: skip
+ """Wall-side workstation: pedestal desk, a sloped key deck, two or three
+ screens on a riser at the back, a document tray and a crew stool."""
+ a, b = cu - width / 2, cu + width / 2
+ v0, v1 = 0.04, 0.04 + depth
+ top = 0.76
+ box(B.struct, a, a + 0.42, v0, v1 - 0.05, 0.0, top - 0.03, BODY) # drawer pedestal
+ for k in range(3):
+ z = 0.06 + k * 0.22
+ box(B.panels, a + 0.02, a + 0.4, v1 - 0.05, v1 - 0.035, z, z + 0.2, DARK)
+ box(B.struct, b - 0.08, b - 0.03, v0 + 0.05, v1 - 0.1, 0.0, top - 0.03, GUNMETAL) # leg
+ box(B.struct, a, b, v0, v1, top - 0.03, top, DECK)
+ box(B.struct, a, b, v1 - 0.01, v1 + 0.01, top - 0.05, top + 0.002, STEEL)
+ # Riser with screens.
+ box(B.struct, a + 0.05, b - 0.05, v0, v0 + 0.16, top, top + 0.12, BODY)
+ n = 3 if seed01(seed, "n") < 0.4 and width >= 1.5 else 2
+ sw = (width - 0.2) / n
+ for i in range(n):
+ su = a + 0.1 + (i + 0.5) * sw
+ tilt = 0.06 if n == 2 else (0.1 if i != 1 else 0.0)
+ box(B.struct, su - 0.04, su + 0.04, v0 + 0.05, v0 + 0.1, top + 0.12, top + 0.32, GUNMETAL)
+ lo, hi = top + 0.3, top + 0.3 + sw * 0.62
+ f_lo, f_hi = v0 + 0.12 + tilt, v0 + 0.1 # front face leans back to the top
+ B.struct.prism_x([(f_lo - 0.04, lo), (f_lo, lo), (f_hi, hi), (f_hi - 0.04, hi)],
+ su - sw / 2 + 0.03, su + sw / 2 - 0.03, BODY) # fmt: skip
+
+ def front(hh: float, out: float, f_lo=f_lo, f_hi=f_hi, lo=lo, hi=hi):
+ return f_lo + (f_hi - f_lo) * (hh - lo) / (hi - lo) + out
+
+ a0, a1 = lo + 0.03, hi - 0.03
+ B.lamps.prism_x([(front(a0, 0.001), a0), (front(a0, 0.004), a0),
+ (front(a1, 0.004), a1), (front(a1, 0.001), a1)],
+ su - sw / 2 + 0.06, su + sw / 2 - 0.06, SCREEN) # fmt: skip
+ # Sloped key deck and a tray.
+ B.struct.prism_x([(v0 + 0.3, top), (v0 + 0.62, top), (v0 + 0.62, top + 0.03),
+ (v0 + 0.3, top + 0.08)], cu - 0.35, cu + 0.25, BODY) # fmt: skip
+ for k in range(8):
+ ku = cu - 0.31 + k * 0.065
+ box(B.flat, ku, ku + 0.05, v0 + 0.38, v0 + 0.56, top + 0.035, top + 0.06, KEYS)
+ box(B.struct, b - 0.42, b - 0.12, v0 + 0.3, v0 + 0.62, top, top + 0.025, GUNMETAL)
+ box(B.struct, b - 0.4, b - 0.14, v0 + 0.32, v0 + 0.6, top + 0.025, top + 0.06, CRATE)
+ box(B.lamps, a + 0.12, a + 0.15, v1 + 0.01, v1 + 0.013, top - 0.02, top - 0.005,
+ _pip_mat(seed, "desk")) # fmt: skip
+ if chair:
+ stool(B, cu - 0.05, v1 + 0.42, yaw_deg=0.0)
+
+
+# ---------------------------------------------------------------- cargo
+
+
+def case(B: Builders, cu: float, cv: float, h0: float, w: float, d: float, h: float, seed,
+ mat: str = CRATE) -> None: # fmt: skip
+ """A hard cargo case: body, two reinforcing bands, corner caps, latches
+ and a white stencil bar on its front (+v)."""
+ box(B.struct, cu - w / 2, cu + w / 2, cv - d / 2, cv + d / 2, h0, h0 + h - 0.01, mat)
+ for f in (0.22, 0.78):
+ u = cu - w / 2 + f * w
+ box(B.struct, u - 0.03, u + 0.03, cv - d / 2 - 0.008, cv + d / 2 + 0.008, h0, h0 + h,
+ GUNMETAL) # fmt: skip
+ box(B.struct, cu - w / 2 - 0.006, cu + w / 2 + 0.006, cv - d / 2 - 0.006, cv + d / 2 + 0.006,
+ h0 + h * 0.62, h0 + h * 0.66, GUNMETAL) # fmt: skip
+ for su in (-1, 1):
+ box(B.flat, cu + su * w * 0.12 - 0.03, cu + su * w * 0.12 + 0.03, cv + d / 2,
+ cv + d / 2 + 0.018, h0 + h * 0.58, h0 + h * 0.7, STEEL) # fmt: skip
+ if seed01(seed, "st") < 0.7:
+ sw = w * (0.2 + 0.25 * seed01(seed, "sw"))
+ box(B.flat, cu - w * 0.38, cu - w * 0.38 + sw, cv + d / 2, cv + d / 2 + 0.003,
+ h0 + h * 0.3, h0 + h * 0.4, WHITE_PAINT) # fmt: skip
+
+
+def case_stack(B: Builders, cu: float, cv: float, seed, *, levels: int | None = None) -> float:
+ """1-3 cases stacked with a little offset, on a steel skid. Returns the
+ stack height."""
+ if levels is None:
+ levels = 1 + int(seed01(seed, "lv") * 3)
+ box(B.struct, cu - 0.62, cu + 0.62, cv - 0.42, cv + 0.42, 0.0, 0.1, GUNMETAL)
+ for k in (-0.4, 0.0, 0.4):
+ box(B.struct, cu + k - 0.05, cu + k + 0.05, cv - 0.44, cv + 0.44, 0.0, 0.11, STEEL)
+ h = 0.11
+ for i in range(levels):
+ w = 1.2 if i == 0 else 0.8 + 0.3 * seed01(seed, "w", i)
+ d = 0.8 if i == 0 else 0.6
+ ch = 0.55 if i == 0 else 0.35 + 0.15 * seed01(seed, "h", i)
+ du = (seed01(seed, "du", i) - 0.5) * (1.2 - w)
+ mat = CRATE if seed01(seed, "m", i) < 0.75 else DARK
+ case(B, cu + du, cv, h, w, d, ch, (seed, i), mat)
+ h += ch
+ return h
+
+
+def holo_plinth(B: Builders, cu: float, cv: float, *, r: float = 0.6, seed=0) -> None:
+ """Compact holo plinth: stepped round base, a dark glass top with a blue
+ emitter ring and a few pips round the rim."""
+ B.struct.tube((cu, cv, 0.0), (cu, cv, 0.08), r + 0.08, RUBBER, 32)
+ B.struct.tube((cu, cv, 0.08), (cu, cv, 0.78), r * 0.55, BODY, 28)
+ B.struct.tube((cu, cv, 0.78), (cu, cv, 0.9), r, GUNMETAL, 40)
+ B.panels.tube((cu, cv, 0.9), (cu, cv, 0.93), r - 0.05, "M_Lacquer_BlackGloss", 40)
+ ring = 40
+ for i in range(ring):
+ a0, a1 = 2 * math.pi * i / ring, 2 * math.pi * (i + 1) / ring
+ ri, ro = r * 0.35, r * 0.42
+ B.lamps.quad(
+ [
+ (cu + ro * math.cos(a0), cv + ro * math.sin(a0), 0.932),
+ (cu + ro * math.cos(a1), cv + ro * math.sin(a1), 0.932),
+ (cu + ri * math.cos(a1), cv + ri * math.sin(a1), 0.932),
+ (cu + ri * math.cos(a0), cv + ri * math.sin(a0), 0.932),
+ ],
+ "M_Indicator_Blue",
+ )
+ for i in range(6):
+ a = 2 * math.pi * (i + 0.5) / 6
+ pu, pv = cu + (r - 0.025) * math.cos(a), cv + (r - 0.025) * math.sin(a)
+ box(B.lamps, pu - 0.015, pu + 0.015, pv - 0.015, pv + 0.015, 0.9, 0.905,
+ _pip_mat(seed, "holo", i)) # fmt: skip
+
+
+# ---------------------------------------------------------------- floor
+
+
+def floor_grille(B: Builders, u0: float, u1: float, v0: float, v1: float) -> None:
+ """Flush floor grille: brushed frame and grating over a dark well."""
+ t = 0.05
+ box(B.flat, u0, u1, v0, v1, 0.0004, 0.002, RECESS)
+ box(B.flat, u0 + t, u1 - t, v0 + t, v1 - t, 0.002, 0.0045, GRATING)
+ for a, b, c, d in ((u0, u1, v0, v0 + t), (u0, u1, v1 - t, v1), (u0, u0 + t, v0, v1),
+ (u1 - t, u1, v0, v1)): # fmt: skip
+ box(B.flat, a, b, c, d, 0.0005, 0.005, STEEL)
+
+
+def floor_hatch(B: Builders, u0: float, u1: float, v0: float, v1: float) -> None:
+ """Flush access hatch: steel frame, a dark plate with two recessed
+ handle slots and a seam down the middle."""
+ t = 0.06
+ box(B.flat, u0, u1, v0, v1, 0.0004, 0.004, STEEL)
+ box(B.flat, u0 + t, u1 - t, v0 + t, v1 - t, 0.0004, 0.0048, DARK)
+ um = (u0 + u1) / 2
+ box(B.flat, um - 0.006, um + 0.006, v0 + t, v1 - t, 0.0004, 0.005, RECESS)
+ for uc in ((u0 + um) / 2, (um + u1) / 2):
+ box(B.flat, uc - 0.08, uc + 0.08, (v0 + v1) / 2 - 0.025, (v0 + v1) / 2 + 0.025, 0.0004,
+ 0.0052, RECESS) # fmt: skip
+
+
+# ---------------------------------------------------------------- overhead
+
+
+def _hanger(B: Builders, u: float, v0: float, v1: float, h: float, top: float) -> None:
+ box(B.struct, u - 0.02, u + 0.02, v0, v1, h - 0.04, h, GUNMETAL)
+ for v in (v0 + 0.02, v1 - 0.02):
+ box(B.struct, u - 0.012, u + 0.012, v - 0.012, v + 0.012, h, top, STEEL)
+
+
+def pipe_run(B: Builders, u0: float, u1: float, v: float, h: float, top: float, *,
+ pipes=((0.0, 0.07, PIPE_INS), (0.2, 0.045, PIPE), (0.36, 0.035, PIPE)),
+ hanger_every: float = 2.4) -> None: # fmt: skip
+ """Overhead pipe run along u: pipes side by side (offset in v), on
+ trapeze hangers from the ceiling."""
+ vmax = max(dv + r for dv, r, _ in pipes)
+ vmin = min(dv - r for dv, r, _ in pipes)
+ for dv, r, mat in pipes:
+ hh = h + r
+ B.pipes.tube((u0, v + dv, hh), (u1, v + dv, hh), r, mat, 12)
+ u = u0 + 0.3
+ while u < u1 - 0.1:
+ _hanger(B, u, v + vmin - 0.05, v + vmax + 0.05, h, top)
+ for dv, r, _ in pipes: # clamp bands
+ p0, p1 = (u + 0.05, v + dv, h + r), (u + 0.09, v + dv, h + r)
+ B.struct.tube(p0, p1, r + 0.008, GUNMETAL, 12)
+ u += hanger_every
+
+
+def duct_run(B: Builders, u0: float, u1: float, v0: float, v1: float, h0: float, h1: float,
+ top: float) -> None: # fmt: skip
+ """Rectangular ventilation duct along u: flanged sections every 1.2 m,
+ a louvred outlet every third section, hangers to the ceiling."""
+ box(B.panels, u0, u1, v0, v1, h0, h1, MID)
+ u, k = u0 + 1.2, 0
+ while u < u1 - 0.05:
+ box(B.struct, u - 0.025, u + 0.025, v0 - 0.02, v1 + 0.02, h0 - 0.02, h1 + 0.02, GUNMETAL)
+ if k % 3 == 1:
+ # Outlet grille on the duct's underside.
+ box(B.flat, u - 0.85, u - 0.35, v0 + 0.06, v1 - 0.06, h0 - 0.012, h0, RECESS)
+ for j in range(6):
+ vv = v0 + 0.08 + j * (v1 - v0 - 0.16) / 6
+ box(B.flat, u - 0.84, u - 0.36, vv, vv + 0.02, h0 - 0.02, h0 - 0.012, GUNMETAL)
+ if k % 2 == 0:
+ _hanger(B, u + 0.3, v0 - 0.04, v1 + 0.04, h0 - 0.02, top)
+ box(B.struct, u + 0.28, u + 0.32, v0 - 0.04, v0 - 0.02, h0 - 0.02, h1 + 0.02, GUNMETAL)
+ box(B.struct, u + 0.28, u + 0.32, v1 + 0.02, v1 + 0.04, h0 - 0.02, h1 + 0.02, GUNMETAL)
+ u += 1.2
+ k += 1
+
+
+def cable_ladder(B: Builders, u0: float, u1: float, v0: float, v1: float, h: float,
+ top: float, *, cables: int = 4) -> None: # fmt: skip
+ """Overhead cable ladder: two side rails, rungs every 0.3 m, a bundle of
+ cables laid in it, hangers every 2.4 m."""
+ for v in (v0, v1 - 0.03):
+ box(B.struct, u0, u1, v, v + 0.03, h, h + 0.08, GUNMETAL)
+ u = u0 + 0.15
+ while u < u1:
+ box(B.struct, u - 0.012, u + 0.012, v0, v1, h, h + 0.02, GUNMETAL)
+ u += 0.3
+ for i in range(cables):
+ v = v0 + 0.06 + i * (v1 - v0 - 0.12) / max(1, cables - 1)
+ B.pipes.tube((u0, v, h + 0.04), (u1, v, h + 0.04), 0.018 + 0.006 * (i % 2), RUBBER, 6)
+ u = u0 + 0.4
+ while u < u1 - 0.1:
+ for v in (v0 + 0.015, v1 - 0.015):
+ box(B.struct, u - 0.01, u + 0.01, v - 0.01, v + 0.01, h + 0.08, top, STEEL)
+ u += 2.4
diff --git a/docs/verse/combat.md b/docs/verse/combat.md
index 5ea5a2adfc..b35f9e57d7 100644
--- a/docs/verse/combat.md
+++ b/docs/verse/combat.md
@@ -745,8 +745,15 @@ stands in the line of fire.
| Space | dodge roll in the move direction |
| R | vent; again inside the gold window: perfect vent |
| 2 / 3, V | fight over the shoulder / through the eyes (V toggles); the bird's-eye view waits for the match's end |
+| Wheel | in: through the eyes; out: back over the shoulder |
| Esc | pause; again: leave |
+The buttons are read from the pointer events' `buttons` mask, not from `pointerdown` /
+`pointerup` alone: a browser sends `pointerdown` only for the first button of
+a chord and `pointerup` only for the last, so the left button pressed while
+the right holds the sights arrives as a `pointermove`. Fire and sights work in
+either order, in both persons.
+
Presses are latched until the next frame reads them. Keys the duel uses never
reach the stage's handlers. A click while the pointer is not locked locks it
again (*Click to aim* shows under the crosshair).
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/VerseStage.tsx b/dodaios/ui/web/frontend/src/components/society/verse/VerseStage.tsx
index 9eb3f0108e..1c4c5f49d9 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/VerseStage.tsx
+++ b/dodaios/ui/web/frontend/src/components/society/verse/VerseStage.tsx
@@ -577,6 +577,11 @@ export function VerseStage({ onOpenLedger, onSelectAgent, onCreateAgent, onOpenG
keyActions.current.showView(next);
return true;
},
+ // The wheel hands over too, as it does outside a match; firing never depends on the view.
+ zoom: (inward) => {
+ const next = inward ? "first" : "third";
+ if (viewRef.current !== next) keyActions.current.showView(next);
+ },
});
}
// Third and first person: shooter mouse look (a click takes the mouse), the wheel zooms and hands over between them.
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/duel/duel.test.ts b/dodaios/ui/web/frontend/src/components/society/verse/duel/duel.test.ts
index e45d731977..d8151ed607 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/duel/duel.test.ts
+++ b/dodaios/ui/web/frontend/src/components/society/verse/duel/duel.test.ts
@@ -378,6 +378,25 @@ describe("duel flow", () => {
expect(seen).toContain("shot");
});
+ it("fires in the sights (the tighter spread) with the right button held first, over the shoulder and through the eyes", () => {
+ for (const firstPerson of [false, true]) {
+ const { c, frame } = controller();
+ c.camera.firstPerson = firstPerson;
+ c.start("normal");
+ frame(200);
+ expect(c.view!.match.phase).toBe("live");
+ // Right button down (pointerdown), then the left joins the chord (a pointermove with both bits).
+ c.input.mouseButtons(2);
+ frame(30);
+ c.input.mouseButtons(3);
+ const shots: CombatEvent[] = [];
+ for (let i = 0; i < 30; i++) { frame(1); shots.push(...c.visualEvents.filter((e) => e.type === "shot" && e.player === c.view!.slot)); c.visualEvents.length = 0; }
+ expect(shots.length).toBeGreaterThan(0);
+ expect(shots.every((e) => e.type === "shot" && e.ads)).toBe(true);
+ expect(c.lastShotAds).toBe(true);
+ }
+ });
+
it("freezes the match while paused and goes on after resume", () => {
const { c, frame } = controller();
c.start("hard");
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInput.ts b/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInput.ts
index 5472f62b38..5cdfe88700 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInput.ts
+++ b/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInput.ts
@@ -13,6 +13,7 @@
* | Space | dodge roll (in the move direction) |
* | R | vent; again inside the window: perfect |
* | 2, 3, V | over the shoulder / through the eyes |
+ * | Wheel | in: through the eyes; out: the shoulder |
* | Esc | pause (pointer released); again: leave |
*
* Presses (dodge, vent) are latched until the next `control()` call reads
@@ -85,6 +86,20 @@ export class DuelInput {
else if (button === 2) this.ads = false;
}
+ /**
+ * The mouse buttons held right now, as a pointer event's `buttons` mask
+ * (1 left, 2 right). Browsers send `pointerdown` only for the first button
+ * of a chord and `pointerup` only for the last; a second button arrives as
+ * a `pointermove` with a changed mask, so the mask is the truth. `presses`
+ * false applies only releases (a move from outside the surface).
+ */
+ mouseButtons(buttons: number, presses = true): void {
+ const fire = (buttons & 1) !== 0;
+ const ads = (buttons & 2) !== 0;
+ if (presses || !fire) this.fire = fire;
+ if (presses || !ads) this.ads = ads;
+ }
+
/** Everything let go (the window lost focus, the match paused). Latched presses go too. */
clear(): void {
this.held.clear();
@@ -140,6 +155,8 @@ export interface DuelInputCallbacks {
live: () => boolean;
/** A key that may switch the view (third / first person); returns whether it did. */
view?: (code: string) => boolean;
+ /** The wheel turned while the match runs: in (true) goes through the eyes, out (false) back over the shoulder. */
+ zoom?: (inward: boolean) => void;
}
/**
@@ -182,12 +199,18 @@ export function attachDuelInput(el: HTMLElement, input: DuelInput, cb: DuelInput
if (e.pointerType !== "mouse") return;
if (!cb.live()) return;
if (!locked()) cb.relock();
- input.mouseDown(e.button);
+ input.mouseButtons(e.buttons);
e.preventDefault();
};
+ // A second button pressed (or one let go) while another is held comes only as a pointermove with a new mask.
+ const chord = (e: PointerEvent) => {
+ if (e.pointerType !== "mouse") return;
+ const onSurface = locked() || el.contains(e.target as Node);
+ input.mouseButtons(e.buttons, onSurface && cb.live());
+ };
const up = (e: PointerEvent) => {
if (e.pointerType !== "mouse") return;
- input.mouseUp(e.button);
+ input.mouseButtons(e.buttons, false);
};
// Mouse movement anywhere turns the aim while the pointer is locked to the surface; unlocked, over the surface only.
const move = (e: MouseEvent) => {
@@ -196,11 +219,19 @@ export function attachDuelInput(el: HTMLElement, input: DuelInput, cb: DuelInput
cb.look(e.movementX || 0, e.movementY || 0);
};
const menu = (e: Event) => e.preventDefault();
+ const wheel = (e: WheelEvent) => {
+ e.preventDefault();
+ if (!cb.live() || e.deltaY === 0 || e.ctrlKey) return;
+ cb.zoom?.(e.deltaY < 0);
+ };
+ el.addEventListener("wheel", wheel, { passive: false });
window.addEventListener("keydown", keyDown, true);
window.addEventListener("keyup", keyUp, true);
window.addEventListener("blur", blur);
el.addEventListener("pointerdown", down);
+ window.addEventListener("pointermove", chord);
window.addEventListener("pointerup", up);
+ window.addEventListener("pointercancel", up);
document.addEventListener("mousemove", move);
el.addEventListener("contextmenu", menu);
return () => {
@@ -208,9 +239,12 @@ export function attachDuelInput(el: HTMLElement, input: DuelInput, cb: DuelInput
window.removeEventListener("keyup", keyUp, true);
window.removeEventListener("blur", blur);
el.removeEventListener("pointerdown", down);
+ window.removeEventListener("pointermove", chord);
window.removeEventListener("pointerup", up);
+ window.removeEventListener("pointercancel", up);
document.removeEventListener("mousemove", move);
el.removeEventListener("contextmenu", menu);
+ el.removeEventListener("wheel", wheel);
input.clear();
};
}
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInputDom.test.ts b/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInputDom.test.ts
new file mode 100644
index 0000000000..0125d8d07f
--- /dev/null
+++ b/dodaios/ui/web/frontend/src/components/society/verse/duel/duelInputDom.test.ts
@@ -0,0 +1,112 @@
+// @vitest-environment jsdom
+/**
+ * The duel's mouse binding on a real DOM surface. Browsers send
+ * `pointerdown` only for the first button of a chord and `pointerup` only
+ * for the last one; a button pressed or let go while another is held comes
+ * as a `pointermove` with a new `buttons` mask. Holding the sights (right
+ * button) and then pulling the trigger (left button) must fire, in either
+ * order, and the right button never opens a menu.
+ */
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { attachDuelInput, DuelInput } from "./duelInput";
+
+const LEFT = 1;
+const RIGHT = 2;
+
+describe("duel mouse binding", () => {
+ let el: HTMLDivElement;
+ let lockedTo: Element | null = null;
+ let detach: () => void = () => {};
+ let input: DuelInput;
+ const cb = () => ({ look: vi.fn(), escape: vi.fn(), relock: vi.fn(), live: () => true, view: vi.fn(() => false), zoom: vi.fn() });
+
+ beforeEach(() => {
+ el = document.createElement("div");
+ document.body.appendChild(el);
+ Object.defineProperty(document, "pointerLockElement", { configurable: true, get: () => lockedTo });
+ lockedTo = el;
+ input = new DuelInput();
+ });
+ afterEach(() => {
+ detach();
+ el.remove();
+ lockedTo = null;
+ });
+
+ /** A mouse pointer event as Chrome sends it: `button` is what changed, `buttons` what is held after it. */
+ const send = (type: string, button: number, buttons: number) => {
+ const e = new MouseEvent(type, { bubbles: true, cancelable: true, button, buttons });
+ Object.defineProperty(e, "pointerType", { value: "mouse" });
+ el.dispatchEvent(e);
+ return e;
+ };
+ const state = () => {
+ const c = input.control(0, 0);
+ return { fire: c.fire, ads: c.ads };
+ };
+
+ it("fires with the sights held: right down, then left (the left press comes as a pointermove)", () => {
+ detach = attachDuelInput(el, input, cb());
+ send("pointerdown", 2, RIGHT);
+ expect(state()).toEqual({ fire: false, ads: true });
+ send("pointermove", 0, RIGHT | LEFT);
+ expect(state()).toEqual({ fire: true, ads: true });
+ send("pointermove", 0, RIGHT);
+ expect(state()).toEqual({ fire: false, ads: true });
+ send("pointerup", 2, 0);
+ expect(state()).toEqual({ fire: false, ads: false });
+ });
+
+ it("aims while firing: left down, then right; letting the right go mid-burst stops aiming only", () => {
+ detach = attachDuelInput(el, input, cb());
+ send("pointerdown", 0, LEFT);
+ send("pointermove", 2, LEFT | RIGHT);
+ expect(state()).toEqual({ fire: true, ads: true });
+ send("pointermove", 2, LEFT);
+ expect(state()).toEqual({ fire: true, ads: false });
+ send("pointerup", 0, 0);
+ expect(state()).toEqual({ fire: false, ads: false });
+ });
+
+ it("lets the trigger go when the left button is released before the right", () => {
+ detach = attachDuelInput(el, input, cb());
+ send("pointerdown", 0, LEFT);
+ send("pointermove", 2, LEFT | RIGHT);
+ send("pointermove", 0, RIGHT);
+ expect(state()).toEqual({ fire: false, ads: true });
+ send("pointerup", 2, 0);
+ expect(state()).toEqual({ fire: false, ads: false });
+ });
+
+ it("presses nothing while the match does not take input, but still lets go", () => {
+ let live = true;
+ detach = attachDuelInput(el, input, { ...cb(), live: () => live });
+ send("pointerdown", 2, RIGHT);
+ live = false;
+ send("pointermove", 0, RIGHT | LEFT);
+ expect(state().fire).toBe(false);
+ send("pointerup", 2, 0);
+ expect(state().ads).toBe(false);
+ });
+
+ it("never opens a context menu on the surface", () => {
+ detach = attachDuelInput(el, input, cb());
+ const e = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, button: 2 });
+ el.dispatchEvent(e);
+ expect(e.defaultPrevented).toBe(true);
+ });
+
+ it("the wheel hands over between the shoulder and the eyes, and fire keeps working after it", () => {
+ const callbacks = cb();
+ detach = attachDuelInput(el, input, callbacks);
+ const wheel = new WheelEvent("wheel", { deltaY: -100, cancelable: true });
+ el.dispatchEvent(wheel);
+ expect(wheel.defaultPrevented).toBe(true);
+ expect(callbacks.zoom).toHaveBeenCalledWith(true);
+ el.dispatchEvent(new WheelEvent("wheel", { deltaY: 100, cancelable: true }));
+ expect(callbacks.zoom).toHaveBeenLastCalledWith(false);
+ send("pointerdown", 2, RIGHT);
+ send("pointermove", 0, RIGHT | LEFT);
+ expect(state()).toEqual({ fire: true, ads: true });
+ });
+});
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/orbitInput.ts b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/orbitInput.ts
index 443c422bb2..05a0bd55db 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/orbitInput.ts
+++ b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/orbitInput.ts
@@ -61,12 +61,18 @@ export function attachOrbitInput(el: HTMLElement, rig: ShoulderRig, cb: OrbitCal
const zoom = (factor: number) => { if (cb.zoom) cb.zoom(factor); else rig.zoom(factor); };
let lockedHoverAt = -Infinity;
+ // Mouse buttons held (a pointer event's `buttons` mask). A button pressed while another is held sends no
+ // pointerdown, only a pointermove with a new mask, so the left button is watched there too.
+ let buttons = 0;
+ const aimAtCentre = () => {
+ const c = centre();
+ (cb.aim ?? cb.tap)(c.x, c.y);
+ };
+
const onDown = (e: PointerEvent) => {
+ if (e.pointerType === "mouse") buttons = e.buttons;
if (locked()) {
- if (e.button === 0) {
- const c = centre();
- (cb.aim ?? cb.tap)(c.x, c.y);
- }
+ if (e.button === 0) aimAtCentre();
return;
}
const mouse = e.pointerType === "mouse";
@@ -82,7 +88,10 @@ export function attachOrbitInput(el: HTMLElement, rig: ShoulderRig, cb: OrbitCal
};
const onMove = (e: PointerEvent) => {
+ const chordLeft = e.pointerType === "mouse" && (e.buttons & 1) !== 0 && (buttons & 1) === 0 && buttons !== 0;
+ if (e.pointerType === "mouse") buttons = e.buttons;
if (locked()) {
+ if (chordLeft) aimAtCentre();
rig.look(e.movementX || 0, e.movementY || 0, true);
const now = performance.now();
if (now - lockedHoverAt >= LOCKED_HOVER_MS) {
@@ -117,6 +126,7 @@ export function attachOrbitInput(el: HTMLElement, rig: ShoulderRig, cb: OrbitCal
};
const onUp = (e: PointerEvent) => {
+ if (e.pointerType === "mouse") buttons = e.buttons;
const press = presses.get(e.pointerId);
if (!press) return;
presses.delete(e.pointerId);
@@ -145,7 +155,11 @@ export function attachOrbitInput(el: HTMLElement, rig: ShoulderRig, cb: OrbitCal
el.addEventListener("pointercancel", onUp);
el.addEventListener("pointerleave", onLeave);
el.addEventListener("wheel", onWheel, { passive: false });
+ // With the mouse taken, the right button never opens a menu over the view.
+ const onMenu = (e: Event) => { if (locked()) e.preventDefault(); };
+ el.addEventListener("contextmenu", onMenu);
return () => {
+ el.removeEventListener("contextmenu", onMenu);
el.removeEventListener("pointerdown", onDown);
el.removeEventListener("pointermove", onMove);
el.removeEventListener("pointerup", onUp);
diff --git a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/views.test.tsx b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/views.test.tsx
index 524ce70449..a6580c25b3 100644
--- a/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/views.test.tsx
+++ b/dodaios/ui/web/frontend/src/components/society/verse/engine/realtime/views.test.tsx
@@ -268,7 +268,7 @@ describe("shooter input mapping", () => {
});
const pointer = (type: string, init: Record<string, number | string>) => {
- const e = new MouseEvent(type, { bubbles: true, clientX: Number(init.clientX ?? 0), clientY: Number(init.clientY ?? 0), button: Number(init.button ?? 0) });
+ const e = new MouseEvent(type, { bubbles: true, clientX: Number(init.clientX ?? 0), clientY: Number(init.clientY ?? 0), button: Number(init.button ?? 0), buttons: Number(init.buttons ?? 0) });
for (const key of ["pointerId", "pointerType", "movementX", "movementY"]) {
if (key in init) Object.defineProperty(e, key, { value: init[key] });
}
@@ -308,6 +308,23 @@ describe("shooter input mapping", () => {
detach();
});
+ it("with the mouse taken: the left button pressed while the right is held (a pointermove chord) still aims; no menu", () => {
+ const rig = new ShoulderRig();
+ const cb = callbacks();
+ const detach = attachOrbitInput(el, rig, cb);
+ lockedTo = el;
+ pointer("pointerdown", { pointerId: 1, pointerType: "mouse", button: 2, buttons: 2 });
+ expect(cb.aim).not.toHaveBeenCalled();
+ pointer("pointermove", { pointerId: 1, pointerType: "mouse", button: 0, buttons: 3 });
+ expect(cb.aim).toHaveBeenCalledTimes(1);
+ pointer("pointermove", { pointerId: 1, pointerType: "mouse", buttons: 3, movementX: 4 });
+ expect(cb.aim).toHaveBeenCalledTimes(1);
+ const menu = new MouseEvent("contextmenu", { bubbles: true, cancelable: true, button: 2 });
+ el.dispatchEvent(menu);
+ expect(menu.defaultPrevented).toBe(true);
+ detach();
+ });
+
it("zooms through the stage so it can hand over (wheel down moves out)", () => {
const rig = new ShoulderRig();
const cb = callbacks();