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(office): rebuild the arcade floor as clear rooms without lag

rubenluetke10-beepd2f96bb3bb08
diff --git a/docs/agent-society/office-map.md b/docs/agent-society/office-map.md
index d5f5fcb655..7efc504663 100644
--- a/docs/agent-society/office-map.md
+++ b/docs/agent-society/office-map.md
@@ -273,17 +273,31 @@ which follows like on the coding floor).
a click, Enter on the focused floor or the floor's number key (0 agents,
1 coding, 2 arcade) rides there, Escape closes it. The call button shows
up, down or both arrows depending on the floor (`callDirection`).
-- **Floor plan** (`arcade/arcadeFloorLayout.ts`, `buildArcadeLayout()`): a
- fixed hall with the main room, a prize counter corner and a snack bar by
- the elevator. Cabinets are furniture of kind `retroCabinet` with the id
- `cabinet-<gameId>`; the person plays standing 0.85 m in front of one
- (`OfficePlayer` nearest-interactable, E opens it). Tests prove every play
- spot is reachable from the elevator.
+- **Floor plan** (`arcade/arcadeFloorLayout.ts`, `buildArcadeLayout()`),
+ reworked 2026-10-02 after the maintainer found the first open hall
+ confusing: it now reads like the floors below. North strip: three walled
+ game rooms (Classics: Pixel Raiders, Maze Muncher, City Defense, Paddle
+ Duel; Puzzle corner: Block Drop, Neon Snake, Brick Breaker; Action zone:
+ Asteroid Run, Desert Dash, Road Hopper), cabinets on each back wall facing
+ the door. Middle: the open hall (pinballs, air hockey, dance floor, floor
+ logo). South strip: the foyer with the elevator and token machines, the
+ prize shop (counter, claw machines) and the snack bar. The doors of north
+ and south rooms face each other on three lanes that stay clear. Cabinets
+ are furniture of kind `retroCabinet` with the id `cabinet-<gameId>`; the
+ person plays standing 0.85 m in front of one (`OfficePlayer`
+ nearest-interactable, E opens it). Tests prove every play spot, counter
+ and room is reachable from the elevator and that the lanes stay free.
- **Look** (`arcade/ArcadeHall.tsx`, `ArcadeHallProps.tsx`,
- `arcadeHallLook.ts`, `arcadeScreens.ts`): blacklight carpet, neon from
- self-lit materials (one shadow light, three small point lights), merged
- geometry per machine, two-frame attract screens on every cabinet; the
- cabinet the person stands at shows its game's title screen live.
+ `arcadeHallLook.ts`, `arcadeScreens.ts`): smoked-glass walls with a neon
+ cap in each room's colour (never hidden or popping away at any camera
+ angle; frames, glass and neon are three merged meshes), a lit name board
+ over every door, each room's own floor and neon floor logo, a calm
+ blacklight carpet in the hall. One shadow light plus hemisphere and
+ ambient; neon is self-lit. Cabinets show two-frame attract screens
+ flipped by a texture offset. The first version's live title-screen
+ preview froze the frame for 0.2-0.6 s whenever the person walked up to a
+ cabinet and was removed; frames at a cabinet now take 2-11 ms in a dev
+ build (measured with `window.__officeGl.info` and timed `__officeStep`).
- **Games** (`arcade/games/*.ts`, contract in `arcade/retroGame.ts`, registry
in `arcade/arcadeGames.ts`): Neon Snake, Brick Breaker, Paddle Duel, Block
Drop, Maze Muncher, Desert Dash, Pixel Raiders, Road Hopper and City
diff --git a/jarvis/ui/web/frontend/src/components/society/arcade/ArcadeHall.tsx b/jarvis/ui/web/frontend/src/components/society/arcade/ArcadeHall.tsx
index f0edbee4e4..f45b4e3226 100644
--- a/jarvis/ui/web/frontend/src/components/society/arcade/ArcadeHall.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/arcade/ArcadeHall.tsx
@@ -1,57 +1,62 @@
/**
- * The arcade floor: a neon-lit 80s/90s arcade hall floating in a violet
- * night — the top floor of the building. A blacklight carpet, two midnight
- * back walls with neon signs (the camera looks in from the south-east like
- * into a doll's house; the walls are one-sided, so from behind they vanish),
- * glass railings on the open sides, the prize corner and the snack bar, and
- * every machine of the layout.
+ * The arcade floor: a neon-lit arcade floating in a violet night, the top
+ * floor of the building. Its rooms (arcadeFloorLayout) stand behind smoked
+ * glass with a neon cap in each room's colour, a lit name board over every
+ * door, the room's own floor and a neon logo inlaid in it; the open hall in
+ * the middle keeps the blacklight carpet, the pinballs, the air hockey and
+ * the dance floor.
*
* Renders everything floor-specific; OfficeScene adds the person, the
* camera, the elevator's call button and the checkpoint marker on top.
*
- * Light budget: one shadow-casting sun, a hemisphere and an ambient light
- * and three small point lights. The neon look comes from self-lit materials.
- * Screens: every cabinet shows its game's two-frame attract screen (flipped
- * by moving a texture offset, nothing redrawn); the cabinet the person stands
- * at runs its game's own title screen live, a dozen frames a second.
+ * Kept cheap on purpose: one shadow-casting light plus a hemisphere and an
+ * ambient light (the neon comes from self-lit materials, not from lamps);
+ * all wall frames are one merged mesh, all glass another, all neon caps a
+ * third; cabinet screens flip between two baked attract frames by moving a
+ * texture offset, so nothing is redrawn or re-uploaded while you walk around.
*/
-import { useEffect, useMemo, useRef, useState } from "react";
+import { useEffect, useMemo, useRef } from "react";
import { Stars } from "@react-three/drei";
import { useFrame, type ThreeEvent } from "@react-three/fiber";
import {
- AdditiveBlending, BoxGeometry, Color, InstancedMesh, MeshBasicMaterial, MeshStandardMaterial, Object3D, PlaneGeometry, RepeatWrapping,
+ AdditiveBlending, BoxGeometry, Color, DoubleSide, InstancedMesh, MeshBasicMaterial, MeshStandardMaterial, Object3D, PlaneGeometry, RepeatWrapping,
type BufferGeometry, type Texture,
} from "three";
import { useT } from "@/i18n";
import { cachedCanvasTexture } from "../office/canvasMaterials";
import { Box, Railing } from "../office/OfficeFurniture";
import { FurniturePiece } from "../office/OfficeProps";
-import { RoomSign, RoomWalls } from "../office/OfficeRooms";
-import type { Furniture, OfficeLayout, Point, Rect, Room } from "../office/officeLayout";
-import { ARCADE_GAMES, gameForCabinet, isRetroGame, loadRetroGame } from "./arcadeGames";
-import { ARCADE_WALL_INSET, arcadeDecor } from "./arcadeFloorLayout";
-import {
- CARPET_METRES, drawCarpet, drawGlowSpot, drawPrizeCarpet, drawSnackFloor, drawWallPanels, HALL, HALL_MAT, PartKit, ROOM_FLOOR_METRES,
-} from "./arcadeHallLook";
-import { CABINET_SCREEN } from "./ArcadeHallProps";
-import { createLiveScreen, medallionMaterial, neonMaterial, setScreenFrame, type LiveScreen, type NeonSymbol } from "./arcadeScreens";
+import type { Furniture, OfficeLayout, Point, Rect, Room, RoomKind, WallSegment } from "../office/officeLayout";
+import { ARCADE_GAMES, gameForCabinet } from "./arcadeGames";
+import { arcadeDecor, ROOM_ACCENT } from "./arcadeFloorLayout";
+import { drawGlowSpot, HALL, HALL_MAT, PartKit, ROOM_FLOORS, type ArcadeRoomKind } from "./arcadeHallLook";
+import { floorLogoMaterial, neonMaterial, roomBoardMaterial, setScreenFrame, type NeonSymbol } from "./arcadeScreens";
export interface ArcadeHallProps {
layout: OfficeLayout;
onFloorClick: (event: ThreeEvent<MouseEvent>) => void;
- /** Furniture id of the cabinet the person stands at, or null. */
+ /** Furniture id of the cabinet the person stands at, or null. Its screen and floor glow brighten. */
nearCabinet: string | null;
awake: boolean;
reduced: boolean;
}
-/** Height of the back walls. */
-const WALL_H = 3.0;
+/** Height of the rooms' glass walls; the name boards sit on top of the door headers. */
+const WALL_H = 2.2;
+/** The name board over a door: width, height, and how far above the wall top its centre sits. */
+const BOARD = { w: 2.5, h: 0.58, lift: 0.36 } as const;
/** Seconds each attract frame stays on the cabinets' screens. */
const ATTRACT_FRAME_S = 0.6;
/** Seconds between two steps of the dance pad's light chase. */
const PAD_STEP_S = 0.45;
+/** Each room's neon symbol: on its glass and in its floor logo. */
+const ROOM_SYMBOL: Partial<Record<RoomKind, NeonSymbol>> = {
+ classics: "alien", puzzle: "joystick", action: "bolt", foyer: "coin", prizes: "ticket", snack: "soda", arcade: "star",
+};
+
+const accentOf = (kind: RoomKind) => ROOM_ACCENT[kind] ?? HALL.neon.magenta;
+
/** A cached base texture, cloned per surface with its own repeat (the clone belongs to the caller). */
function repeated(base: Texture | null, repeatX: number, repeatY: number): Texture | null {
if (!base) return null;
@@ -63,39 +68,43 @@ function repeated(base: Texture | null, repeatX: number, repeatY: number): Textu
return map;
}
-// ---------------------------------------------------------------------------
-// Slab, carpets, walls
-// ---------------------------------------------------------------------------
-
const RIM = new MeshBasicMaterial({ color: HALL.rim, toneMapped: false });
-const STRIP = {
- magenta: new MeshBasicMaterial({ color: HALL.neon.magenta, toneMapped: false }),
- cyan: new MeshBasicMaterial({ color: HALL.neon.cyan, toneMapped: false }),
-};
-const UNIT_PLANE = new PlaneGeometry(1, 1);
const UNIT_BOX = new BoxGeometry(1, 1, 1);
/** The dance pad's dark frame between its lit tiles. */
const PAD_BASE = new MeshStandardMaterial({ color: "#07060d", roughness: 0.4 });
+/** Smoked glass: dark enough to read as a wall, clear enough that no camera angle loses a room behind it. */
+const SMOKED_GLASS = new MeshStandardMaterial({
+ color: "#3a3358", transparent: true, opacity: 0.3, roughness: 0.08, metalness: 0.2, side: DoubleSide, depthWrite: false,
+});
+const BOARD_BACK = new MeshStandardMaterial({ color: HALL.frame, roughness: 0.5, metalness: 0.3 });
+const BOARD_PLANE = new PlaneGeometry(BOARD.w - 0.06, BOARD.h - 0.06);
+const LOGO_PLANE = new PlaneGeometry(1, 1);
-/** The slab: a dark edge with a glowing rim, and the blacklight carpet everyone walks (and clicks) on. */
+// ---------------------------------------------------------------------------
+// Slab and floors
+// ---------------------------------------------------------------------------
+
+function floorMaterial(kind: ArcadeRoomKind, w: number, d: number): MeshStandardMaterial {
+ const floor = ROOM_FLOORS[kind];
+ const map = repeated(cachedCanvasTexture(`arcade:floor:${kind}`, 256, 256, floor.draw), w / floor.metres, d / floor.metres);
+ return new MeshStandardMaterial({
+ color: map ? "#ffffff" : HALL.carpet.base, map, roughness: floor.roughness,
+ // Carpets glow faintly under the "blacklight"; stone and tiles do not.
+ ...(map && floor.glow > 0 ? { emissive: "#ffffff", emissiveMap: map, emissiveIntensity: floor.glow } : {}),
+ });
+}
+
+/** The slab: a dark edge with a glowing rim, the hall's carpet over all of it (everyone walks and clicks on it), railings round it. */
function HallSlab({ layout, onFloorClick }: { layout: OfficeLayout; onFloorClick: (event: ThreeEvent<MouseEvent>) => void }) {
const { minX, maxX, minZ, maxZ } = layout.bounds;
const w = maxX - minX, d = maxZ - minZ, cx = (minX + maxX) / 2, cz = (minZ + maxZ) / 2;
- const carpet = useMemo(() => {
- const map = repeated(cachedCanvasTexture("arcade:carpet", 512, 512, drawCarpet), w / CARPET_METRES, d / CARPET_METRES);
- // The neon fibres glow faintly under the "blacklight"; the near-black ground barely does.
- return new MeshStandardMaterial({
- color: map ? "#ffffff" : HALL.carpet.base, map, roughness: 0.95,
- emissive: map ? "#ffffff" : "#000000", emissiveMap: map, emissiveIntensity: 0.22,
- });
- }, [w, d]);
+ const carpet = useMemo(() => floorMaterial("arcade", w, d), [w, d]);
const edge = useMemo(() => new MeshStandardMaterial({ color: HALL.slabEdge, roughness: 0.8 }), []);
useEffect(() => () => { carpet.map?.dispose(); carpet.dispose(); edge.dispose(); }, [carpet, edge]);
- const glow = 0.05;
+ const glow = 0.05, inset = 0.15;
return (
<group>
<Box size={[w, 0.6, d]} position={[cx, -0.3, cz]} material={edge} cast={false} />
- {/* The rim runs just below the floor's edge on all four sides. */}
<mesh geometry={UNIT_BOX} material={RIM} position={[cx, -0.06, maxZ]} scale={[w + glow, glow, glow]} />
<mesh geometry={UNIT_BOX} material={RIM} position={[maxX, -0.06, cz]} scale={[glow, glow, d + glow]} />
<mesh geometry={UNIT_BOX} material={RIM} position={[cx, -0.06, minZ]} scale={[w + glow, glow, glow]} />
@@ -103,20 +112,20 @@ function HallSlab({ layout, onFloorClick }: { layout: OfficeLayout; onFloorClick
<mesh position={[cx, 0.001, cz]} rotation={[-Math.PI / 2, 0, 0]} material={carpet} receiveShadow onClick={onFloorClick}>
<planeGeometry args={[w, d]} />
</mesh>
+ <Railing from={[minX + inset, maxZ - inset]} to={[maxX - inset, maxZ - inset]} />
+ <Railing from={[maxX - inset, maxZ - inset]} to={[maxX - inset, minZ + inset]} />
+ <Railing from={[maxX - inset, minZ + inset]} to={[minX + inset, minZ + inset]} />
+ <Railing from={[minX + inset, minZ + inset]} to={[minX + inset, maxZ - inset]} />
</group>
);
}
-/** The prize corner's plum star carpet and the snack bar's diner checker, laid over the hall's carpet. */
-function RoomCarpet({ room, onFloorClick }: { room: Room; onFloorClick: (event: ThreeEvent<MouseEvent>) => void }) {
+/** A walled room's own floor, laid over the hall's carpet (and just as clickable). */
+function RoomFloor({ room, onFloorClick }: { room: Room; onFloorClick: (event: ThreeEvent<MouseEvent>) => void }) {
const w = room.maxX - room.minX, d = room.maxZ - room.minZ;
- const material = useMemo(() => {
- const prizes = room.kind === "prizes";
- const base = cachedCanvasTexture(`arcade:floor:${room.kind}`, 256, 256, prizes ? drawPrizeCarpet : drawSnackFloor);
- const map = repeated(base, w / ROOM_FLOOR_METRES, d / ROOM_FLOOR_METRES);
- return new MeshStandardMaterial({ color: map ? "#ffffff" : prizes ? HALL.prizes.base : HALL.snack.red, map, roughness: prizes ? 0.95 : 0.4 });
- }, [room.kind, w, d]);
- useEffect(() => () => { material.map?.dispose(); material.dispose(); }, [material]);
+ const material = useMemo(() => (room.kind in ROOM_FLOORS ? floorMaterial(room.kind as ArcadeRoomKind, w, d) : null), [room.kind, w, d]);
+ useEffect(() => () => { material?.map?.dispose(); material?.dispose(); }, [material]);
+ if (!material) return null;
return (
<mesh position={[(room.minX + room.maxX) / 2, 0.004, (room.minZ + room.maxZ) / 2]} rotation={[-Math.PI / 2, 0, 0]}
material={material} receiveShadow onClick={onFloorClick}>
@@ -125,72 +134,121 @@ function RoomCarpet({ room, onFloorClick }: { room: Room; onFloorClick: (event:
);
}
-interface NeonSign { symbol: NeonSymbol; wall: "north" | "west"; along: number; y: number; size: number }
+// ---------------------------------------------------------------------------
+// Walls, door headers and name boards
+// ---------------------------------------------------------------------------
-/** Where the neon signs hang: over the prize counter, the pinballs, both ends of cabinet row A, the dance pad, the claws and the snack bar. */
-function neonSigns(layout: OfficeLayout): NeonSign[] {
- const at = (id: string): Point | null => layout.furniture.find((f) => f.id === id) ?? null;
- const room = (kind: Room["kind"]) => layout.rooms.find((r) => r.kind === kind) ?? null;
- const signs: NeonSign[] = [];
- const prizes = room("prizes"), snack = room("snack"), hall = room("arcade");
- if (prizes) signs.push({ symbol: "ticket", wall: "north", along: (prizes.minX + prizes.maxX) / 2, y: 2.72, size: 0.62 });
- const pinball = at("pinball-1");
- if (pinball) signs.push({ symbol: "bolt", wall: "north", along: pinball.x, y: 2.45, size: 0.95 });
- const rowA = layout.furniture.filter((f) => f.kind === "retroCabinet" && f.rotationY === 0 && hall && f.z < hall.minZ + 1.5);
- if (rowA.length > 0) {
- const xs = rowA.map((f) => f.x);
- signs.push({ symbol: "joystick", wall: "north", along: Math.min(...xs) - 0.95, y: 2.35, size: 0.9 });
- signs.push({ symbol: "star", wall: "north", along: Math.max(...xs) + 0.95, y: 2.35, size: 0.9 });
- }
- if (hall) signs.push({ symbol: "alien", wall: "north", along: hall.maxX - 2.7, y: 2.2, size: 1.2 });
- const claws = layout.furniture.filter((f) => f.kind === "clawMachine");
- if (claws.length > 0) signs.push({ symbol: "claw", wall: "west", along: claws.reduce((s, c) => s + c.z, 0) / claws.length, y: 2.45, size: 0.9 });
- if (snack) {
- signs.push({ symbol: "coin", wall: "west", along: snack.minZ + 1.4, y: 2.1, size: 0.8 });
- signs.push({ symbol: "soda", wall: "west", along: snack.minZ + 4.4, y: 2.2, size: 1.0 });
+/** An axis-aligned box along a wall run (or across a door), `thick` deep, from y0 to y1. */
+function runBox(kit: PartKit, from: Point, to: Point, thick: number, y0: number, y1: number, colour: string): void {
+ const length = Math.hypot(to.x - from.x, to.z - from.z);
+ if (length < 0.02) return;
+ const alongX = Math.abs(to.x - from.x) >= Math.abs(to.z - from.z);
+ kit.box(alongX ? [length, y1 - y0, thick] : [thick, y1 - y0, length], [(from.x + to.x) / 2, (y0 + y1) / 2, (from.z + to.z) / 2], colour);
+}
+
+/** Every door of the walled rooms as a run across its gap, with the room it belongs to. */
+function doorRuns(rooms: readonly Room[]): { room: Room; from: Point; to: Point }[] {
+ return rooms.filter((r) => r.walled).flatMap((room) => room.doors.map((door) => {
+ const half = door.width / 2;
+ switch (door.side) {
+ case "north": return { room, from: { x: door.at - half, z: room.minZ }, to: { x: door.at + half, z: room.minZ } };
+ case "south": return { room, from: { x: door.at - half, z: room.maxZ }, to: { x: door.at + half, z: room.maxZ } };
+ case "west": return { room, from: { x: room.minX, z: door.at - half }, to: { x: room.minX, z: door.at + half } };
+ case "east": return { room, from: { x: room.maxX, z: door.at - half }, to: { x: room.maxX, z: door.at + half } };
+ }
+ }));
+}
+
+/**
+ * All glass walls in three draws: the dark steel frames (foot, posts, top
+ * rail, door headers), the smoked panes, and the neon caps in each room's colour.
+ */
+function GlassWalls({ walls, rooms }: { walls: readonly WallSegment[]; rooms: readonly Room[] }) {
+ const geometries = useMemo(() => {
+ const frame = new PartKit(), glass = new PartKit(), neon = new PartKit();
+ for (const wall of walls) {
+ const from = { x: wall.x1, z: wall.z1 }, to = { x: wall.x2, z: wall.z2 };
+ const length = Math.hypot(to.x - from.x, to.z - from.z);
+ if (length < 0.05) continue;
+ runBox(frame, from, to, 0.1, 0, 0.1, HALL.frame);
+ runBox(glass, from, to, 0.02, 0.1, WALL_H - 0.05, "#ffffff");
+ runBox(frame, from, to, 0.08, WALL_H - 0.05, WALL_H, HALL.frame);
+ runBox(neon, from, to, 0.05, WALL_H, WALL_H + 0.025, accentOf(wall.room));
+ // Posts at both ends and at most every two metres between.
+ const posts = Math.max(2, Math.ceil(length / 2) + 1);
+ for (let i = 0; i < posts; i += 1) {
+ const k = i / (posts - 1);
+ const p = { x: from.x + (to.x - from.x) * k, z: from.z + (to.z - from.z) * k };
+ frame.box([0.06, WALL_H, 0.06], [p.x, WALL_H / 2, p.z], HALL.frame);
+ }
+ }
+ // Each door: a header across the top of the gap, lit underneath like an entrance.
+ for (const { room, from, to } of doorRuns(rooms)) {
+ runBox(frame, from, to, 0.1, WALL_H - 0.1, WALL_H, HALL.frame);
+ runBox(neon, from, to, 0.05, WALL_H - 0.125, WALL_H - 0.1, accentOf(room.kind));
+ }
+ return { frame: frame.build(), glass: glass.build(), neon: neon.build() };
+ }, [walls, rooms]);
+ useEffect(() => () => { geometries.frame.dispose(); geometries.glass.dispose(); geometries.neon.dispose(); }, [geometries]);
+ return (
+ <group>
+ <mesh geometry={geometries.frame} material={HALL_MAT.gloss} castShadow receiveShadow />
+ <mesh geometry={geometries.glass} material={SMOKED_GLASS} renderOrder={2} />
+ <mesh geometry={geometries.neon} material={HALL_MAT.glow} />
+ </group>
+ );
+}
+
+/** A lit name board over a room's door, readable from both sides. */
+function RoomBoard({ room, label }: { room: Room; label: string }) {
+ const door = doorRuns([room])[0];
+ if (!door) return null;
+ const along = Math.abs(door.to.x - door.from.x) >= Math.abs(door.to.z - door.from.z);
+ const material = roomBoardMaterial(label, accentOf(room.kind));
+ return (
+ <group position={[(door.from.x + door.to.x) / 2, WALL_H + BOARD.lift, (door.from.z + door.to.z) / 2]} rotation={[0, along ? 0 : Math.PI / 2, 0]}>
+ <mesh geometry={UNIT_BOX} material={BOARD_BACK} scale={[BOARD.w, BOARD.h, 0.05]} />
+ <mesh geometry={BOARD_PLANE} material={material} position={[0, 0, 0.026]} />
+ <mesh geometry={BOARD_PLANE} material={material} position={[0, 0, -0.026]} rotation={[0, Math.PI, 0]} />
+ </group>
+ );
+}
+
+interface WallSign { symbol: NeonSymbol; x: number; z: number; y: number; size: number }
+
+/**
+ * Each room's neon symbol on its glass: on the back wall beside the cabinets
+ * in the game rooms, on the far (south) wall in the rooms of the south strip.
+ */
+function wallSigns(layout: OfficeLayout): WallSign[] {
+ const hall = layout.rooms.find((r) => r.kind === "arcade");
+ const signs: WallSign[] = [];
+ for (const room of layout.rooms) {
+ const symbol = ROOM_SYMBOL[room.kind];
+ if (!symbol || !room.walled) continue;
+ const north = !!hall && room.maxZ <= hall.minZ + 1e-6;
+ if (north) {
+ const cabinets = layout.furniture.filter((f) => f.kind === "retroCabinet" && f.room === room.kind);
+ const xs = cabinets.map((c) => c.x);
+ // On whichever side of the cabinet row has more room.
+ const left = xs.length ? Math.min(...xs) - room.minX : 0, right = xs.length ? room.maxX - Math.max(...xs) : 0;
+ const x = left >= right ? (room.minX + Math.min(...xs)) / 2 - 0.2 : (room.maxX + Math.max(...xs)) / 2 + 0.2;
+ signs.push({ symbol, x, z: room.minZ + 0.04, y: 1.45, size: 0.95 });
+ } else {
+ signs.push({ symbol, x: (room.minX + room.maxX) / 2 + 1.2, z: room.maxZ - 0.04, y: 1.45, size: 1.0 });
+ }
}
return signs;
}
-/** The north and west walls: midnight panels with neon strips along the top and the foot, and the neon signs. */
-function BackWalls({ layout }: { layout: OfficeLayout }) {
- const { minX, maxX, minZ, maxZ } = layout.bounds;
- const west = minX + ARCADE_WALL_INSET, east = maxX - ARCADE_WALL_INSET, north = minZ + ARCADE_WALL_INSET, south = maxZ - ARCADE_WALL_INSET;
- const northLen = east - west, westLen = south - north;
- const [northWall, westWall] = useMemo(() => {
- const base = cachedCanvasTexture("arcade:wall", 256, 256, drawWallPanels);
- const make = (length: number) => {
- const map = repeated(base, length / 2.4, 1);
- return new MeshStandardMaterial({ color: map ? "#ffffff" : HALL.wall.base, map, roughness: 0.85 });
- };
- return [make(northLen), make(westLen)];
- }, [northLen, westLen]);
- useEffect(() => () => { for (const m of [northWall, westWall]) { m.map?.dispose(); m.dispose(); } }, [northWall, westWall]);
- const signs = useMemo(() => neonSigns(layout), [layout]);
- const strip = (key: string, wall: "north" | "west", y: number, h: number, material: MeshBasicMaterial) => wall === "north"
- ? <mesh key={key} geometry={UNIT_PLANE} material={material} position={[(west + east) / 2, y, north + 0.012]} scale={[northLen, h, 1]} />
- : <mesh key={key} geometry={UNIT_PLANE} material={material} position={[west + 0.012, y, (north + south) / 2]} rotation={[0, Math.PI / 2, 0]}
- scale={[westLen, h, 1]} />;
+function WallSigns({ layout }: { layout: OfficeLayout }) {
+ const signs = useMemo(() => wallSigns(layout), [layout]);
return (
<group>
- {/* One-sided planes facing into the hall: from outside (an orbiting camera) the walls disappear. */}
- <mesh position={[(west + east) / 2, WALL_H / 2, north]} material={northWall} receiveShadow>
- <planeGeometry args={[northLen, WALL_H]} />
- </mesh>
- <mesh position={[west, WALL_H / 2, (north + south) / 2]} rotation={[0, Math.PI / 2, 0]} material={westWall} receiveShadow>
- <planeGeometry args={[westLen, WALL_H]} />
- </mesh>
- {strip("n-top", "north", WALL_H - 0.12, 0.045, STRIP.magenta)}
- {strip("w-top", "west", WALL_H - 0.12, 0.045, STRIP.magenta)}
- {strip("n-foot", "north", 0.16, 0.03, STRIP.cyan)}
- {strip("w-foot", "west", 0.16, 0.03, STRIP.cyan)}
{signs.map((sign) => (
- <mesh key={sign.symbol} geometry={UNIT_PLANE} material={neonMaterial(sign.symbol)} scale={[sign.size, sign.size, 1]}
- position={sign.wall === "north" ? [sign.along, sign.y, north + 0.02] : [west + 0.02, sign.y, sign.along]}
- rotation={sign.wall === "north" ? [0, 0, 0] : [0, Math.PI / 2, 0]} />
+ <mesh key={`${sign.symbol}:${sign.x}`} geometry={LOGO_PLANE} material={neonMaterial(sign.symbol)} scale={[sign.size, sign.size, 1]}
+ position={[sign.x, sign.y, sign.z]} />
))}
- <Railing from={[west, south]} to={[east, south]} />
- <Railing from={[east, south]} to={[east, north]} />
</group>
);
}
@@ -202,20 +260,14 @@ function BackWalls({ layout }: { layout: OfficeLayout }) {
function HallLights({ layout }: { layout: OfficeLayout }) {
const { minX, maxX, minZ, maxZ } = layout.bounds;
const span = Math.max(maxX - minX, maxZ - minZ);
- const hall = layout.rooms.find((r) => r.kind === "arcade");
- const prizes = layout.rooms.find((r) => r.kind === "prizes");
- const hockey = layout.furniture.find((f) => f.kind === "airHockey");
return (
<>
- <hemisphereLight args={[HALL.sky, HALL.ground, 0.8]} />
- <ambientLight intensity={0.2} />
- <directionalLight position={[maxX + 10, 26, maxZ + 6]} intensity={1.15} color={HALL.sun} castShadow
+ <hemisphereLight args={[HALL.sky, HALL.ground, 1.05]} />
+ <ambientLight intensity={0.32} />
+ <directionalLight position={[maxX + 10, 26, maxZ + 6]} intensity={1.2} color={HALL.sun} castShadow
shadow-mapSize={[2048, 2048]} shadow-bias={-0.0004} shadow-normalBias={0.03}
shadow-camera-left={-span * 0.7} shadow-camera-right={span * 0.7}
shadow-camera-top={span * 0.7} shadow-camera-bottom={-span * 0.7} shadow-camera-far={120} />
- {hall && <pointLight position={[(hall.minX + hall.maxX) / 2, 2.9, hall.minZ + 4]} color={HALL.neon.magenta} intensity={9} distance={10} decay={2} />}
- {prizes && <pointLight position={[(prizes.minX + prizes.maxX) / 2, 2.6, prizes.maxZ]} color="#ffb36b" intensity={7} distance={8} decay={2} />}
- {hockey && <pointLight position={[hockey.x, 2.4, hockey.z]} color={HALL.neon.cyan} intensity={6} distance={8} decay={2} />}
</>
);
}
@@ -310,48 +362,54 @@ function DancePad({ pad, animate }: { pad: Rect; animate: boolean }) {
);
}
-function Medallion({ at }: { at: Point & { r: number } }) {
- if (at.r <= 0) return null;
+/** The neon logos inlaid in the floors: each game room's symbol, the foyer's welcome coin and the hall's star. */
+function FloorLogos({ logos }: { logos: { x: number; z: number; r: number; room: RoomKind }[] }) {
return (
- <mesh position={[at.x, 0.006, at.z]} rotation={[-Math.PI / 2, 0, 0]} material={medallionMaterial()} renderOrder={1}>
- <planeGeometry args={[at.r * 2, at.r * 2]} />
- </mesh>
+ <group>
+ {logos.map((logo) => {
+ const symbol = ROOM_SYMBOL[logo.room];
+ if (!symbol) return null;
+ return (
+ <mesh key={`${logo.room}:${logo.x}`} geometry={LOGO_PLANE} material={floorLogoMaterial(symbol, accentOf(logo.room))}
+ position={[logo.x, 0.009, logo.z]} rotation={[-Math.PI / 2, 0, 0]} scale={[logo.r * 2, logo.r * 2, 1]} renderOrder={1} />
+ );
+ })}
+ </group>
);
}
/** The coloured pool of light each cabinet throws on the carpet in front of it; one instanced draw for all of them. */
-function CabinetGlows({ cabinets }: { cabinets: Furniture[] }) {
+function CabinetGlows({ cabinets, near }: { cabinets: Furniture[]; near: string | null }) {
const mesh = useMemo(() => {
const map = cachedCanvasTexture("arcade:glow-spot", 128, 128, drawGlowSpot);
const material = new MeshBasicMaterial({
map, color: "#ffffff", transparent: true, opacity: map ? 1 : 0, depthWrite: false, blending: AdditiveBlending, toneMapped: false,
});
const made = new InstancedMesh(new PlaneGeometry(1, 1).rotateX(-Math.PI / 2), material, Math.max(1, cabinets.length));
+ made.count = cabinets.length;
+ return made;
+ }, [cabinets]);
+ // Placing and tinting is cheap (ten instances) and only happens when the cabinet you stand at changes.
+ useEffect(() => {
const dummy = new Object3D();
const colour = new Color();
cabinets.forEach((cabinet, i) => {
- const ahead = 0.75;
+ const ahead = 0.75, big = cabinet.id === near;
dummy.position.set(cabinet.x + Math.sin(cabinet.rotationY) * ahead, 0.012, cabinet.z + Math.cos(cabinet.rotationY) * ahead);
dummy.rotation.set(0, cabinet.rotationY, 0);
- dummy.scale.set(1.15, 1, 0.95);
+ dummy.scale.set(big ? 1.6 : 1.15, 1, big ? 1.3 : 0.95);
dummy.updateMatrix();
- made.setMatrixAt(i, dummy.matrix);
- made.setColorAt(i, colour.set(gameForCabinet(cabinet.id)?.look.accent ?? HALL.neon.violet));
+ mesh.setMatrixAt(i, dummy.matrix);
+ mesh.setColorAt(i, colour.set(gameForCabinet(cabinet.id)?.look.accent ?? HALL.neon.violet).multiplyScalar(big ? 1.6 : 1));
});
- made.count = cabinets.length;
- made.instanceMatrix.needsUpdate = true;
- if (made.instanceColor) made.instanceColor.needsUpdate = true;
- made.computeBoundingSphere();
- return made;
- }, [cabinets]);
+ mesh.instanceMatrix.needsUpdate = true;
+ if (mesh.instanceColor) mesh.instanceColor.needsUpdate = true;
+ mesh.computeBoundingSphere();
+ }, [mesh, cabinets, near]);
useEffect(() => () => { mesh.geometry.dispose(); (mesh.material as MeshBasicMaterial).dispose(); mesh.dispose(); }, [mesh]);
return <primitive object={mesh} />;
}
-// ---------------------------------------------------------------------------
-// Screens
-// ---------------------------------------------------------------------------
-
/** Flips every attract screen between its two frames; neighbours in the registry run out of step. */
function AttractScreens({ animate }: { animate: boolean }) {
const since = useRef(0);
@@ -367,43 +425,6 @@ function AttractScreens({ animate }: { animate: boolean }) {
return null;
}
-const PREVIEW_GEOMETRY = new PlaneGeometry(CABINET_SCREEN.w, CABINET_SCREEN.h);
-
-/**
- * The cabinet the person stands at shows its game's own title screen, live.
- * A game whose code fails to load (or is still being written) keeps its
- * static attract screen: the preview is decoration, the overlay reports
- * real load errors when the person starts the game.
- */
-function LivePreview({ cabinet }: { cabinet: Furniture }) {
- const game = gameForCabinet(cabinet.id);
- const [screen, setScreen] = useState<LiveScreen | null>(null);
- useEffect(() => {
- if (!game || !isRetroGame(game.id)) return undefined;
- let alive = true;
- let made: LiveScreen | null = null;
- loadRetroGame(game.id).then((retro) => {
- if (!alive) return;
- made = createLiveScreen(retro);
- setScreen(made);
- }, () => {
- // See above: no preview, the static attract screen stays.
- });
- return () => {
- alive = false;
- made?.dispose();
- };
- }, [game]);
- useFrame((_, dt) => screen?.tick(dt));
- if (!screen) return null;
- return (
- <group position={[cabinet.x, 0, cabinet.z]} rotation={[0, cabinet.rotationY, 0]}>
- <mesh geometry={PREVIEW_GEOMETRY} material={screen.material} position={[0, CABINET_SCREEN.y, CABINET_SCREEN.z + 0.003]}
- rotation={[CABINET_SCREEN.tilt, 0, 0]} />
- </group>
- );
-}
-
// ---------------------------------------------------------------------------
// The hall
// ---------------------------------------------------------------------------
@@ -415,7 +436,7 @@ export function ArcadeHall({ layout, onFloorClick, nearCabinet, awake, reduced }
const span = Math.max(maxX - minX, maxZ - minZ);
const cabinets = useMemo(() => layout.furniture.filter((f) => f.kind === "retroCabinet"), [layout]);
const decor = useMemo(() => arcadeDecor(layout.rooms), [layout]);
- const near = nearCabinet ? cabinets.find((c) => c.id === nearCabinet) ?? null : null;
+ const walled = useMemo(() => layout.rooms.filter((r) => r.walled), [layout]);
const animate = awake && !reduced;
return (
<>
@@ -424,19 +445,16 @@ export function ArcadeHall({ layout, onFloorClick, nearCabinet, awake, reduced }
<Stars radius={span * 3} depth={span} count={2200} factor={4} saturation={0.35} fade speed={reduced ? 0 : 0.3} />
<HallLights layout={layout} />
<HallSlab layout={layout} onFloorClick={onFloorClick} />
- {layout.rooms.filter((r) => r.kind === "prizes" || r.kind === "snack").map((room) => (
- <RoomCarpet key={room.id} room={room} onFloorClick={onFloorClick} />
- ))}
- <BackWalls layout={layout} />
- <RoomWalls walls={layout.walls} />
- {layout.rooms.map((room) => <RoomSign key={room.id} room={room} label={t(`society.office.room_${room.kind}`)} />)}
+ {walled.map((room) => <RoomFloor key={room.id} room={room} onFloorClick={onFloorClick} />)}
+ <GlassWalls walls={layout.walls} rooms={layout.rooms} />
+ {walled.map((room) => <RoomBoard key={room.id} room={room} label={t(`society.office.room_${room.kind}`)} />)}
+ <WallSigns layout={layout} />
{layout.furniture.map((item) => <FurniturePiece key={item.id} item={item} />)}
<SnackTables tables={decor.tables} />
<DancePad pad={decor.pad} animate={animate} />
- <Medallion at={decor.medallion} />
- <CabinetGlows cabinets={cabinets} />
+ <FloorLogos logos={decor.logos} />
+ <CabinetGlows cabinets={cabinets} near={nearCabinet} />
<AttractScreens animate={animate} />
- {near && animate && <LivePreview key={near.id} cabinet={near} />}
</>
);
}
diff --git a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.test.ts b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.test.ts
index 839fc425cc..89717be8e7 100644
--- a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { ARCADE_GAMES, cabinetId, gameForCabinet } from "./arcadeGames";
-import { arcadeDecor, buildArcadeLayout, cabinetPlaySpot, SNACK_TABLE_HALF } from "./arcadeFloorLayout";
-import { archPosts, ARCH, FURNITURE_SIZE, footprint, roomAt, wallRect, type Rect } from "../office/officeLayout";
+import { arcadeDecor, buildArcadeLayout, cabinetPlaySpot, GAME_ROOMS, hallLanes, ROOM_ACCENT, SNACK_TABLE_HALF, uniqueWalls } from "./arcadeFloorLayout";
+import { FURNITURE_SIZE, footprint, roomAt, wallRect, wallsOf, type Rect } from "../office/officeLayout";
import { buildNavGrid, findPath, isWalkable } from "../office/officeNav";
import { arrivalPose } from "../office/officeFloors";
@@ -12,6 +12,8 @@ describe("arcade floor layout", () => {
const layout = buildArcadeLayout();
const grid = buildNavGrid(layout);
const cabinets = layout.furniture.filter((f) => f.kind === "retroCabinet");
+ const pose = arrivalPose(layout, "elevator");
+ const room = (kind: string) => layout.rooms.find((r) => r.kind === kind)!;
it("is the arcade variant with no agents' places on it", () => {
expect(layout.variant).toBe("arcade");
@@ -26,74 +28,108 @@ describe("arcade floor layout", () => {
expect(buildArcadeLayout()).toEqual(layout);
});
- it("has a compact slab of the size the other floors float at", () => {
+ it("floats on a slab the size of the floors below", () => {
const { minX, maxX, minZ, maxZ } = layout.bounds;
- expect(maxX - minX).toBeGreaterThanOrEqual(22);
- expect(maxX - minX).toBeLessThanOrEqual(28);
- expect(maxZ - minZ).toBeGreaterThanOrEqual(16);
- expect(maxZ - minZ).toBeLessThanOrEqual(20);
+ expect(maxX - minX).toBeGreaterThanOrEqual(24);
+ expect(maxX - minX).toBeLessThanOrEqual(30);
+ expect(maxZ - minZ).toBeGreaterThanOrEqual(18);
+ expect(maxZ - minZ).toBeLessThanOrEqual(22);
expect(inside(layout.floor, layout.bounds)).toBe(true);
});
- it("has the hall, the prize corner and the snack bar, side by side", () => {
- expect(layout.rooms.map((r) => r.kind).sort()).toEqual(["arcade", "prizes", "snack"]);
+ it("has three game rooms in the north, the open hall between, foyer, prize shop and snack bar in the south", () => {
+ expect(layout.rooms.map((r) => r.kind)).toEqual(["classics", "puzzle", "action", "arcade", "foyer", "prizes", "snack"]);
for (const a of layout.rooms) {
expect(inside(a, layout.bounds)).toBe(true);
- for (const b of layout.rooms) if (a !== b) expect(overlaps(a, b)).toBe(false);
+ expect(ROOM_ACCENT[a.kind], a.kind).toBeDefined();
+ for (const b of layout.rooms) if (a !== b) expect(overlaps(a, b), `${a.kind} × ${b.kind}`).toBe(false);
+ }
+ for (const kind of ["classics", "puzzle", "action"]) expect(room(kind).maxZ).toBeLessThanOrEqual(room("arcade").minZ);
+ for (const kind of ["foyer", "prizes", "snack"]) expect(room(kind).minZ).toBeGreaterThanOrEqual(room("arcade").maxZ);
+ expect(room("arcade").walled).toBe(false);
+ for (const r of layout.rooms.filter((x) => x.kind !== "arcade")) {
+ expect(r.walled, r.kind).toBe(true);
+ expect(r.doors, r.kind).toHaveLength(1);
}
- const kinds = (room: string) => layout.furniture.filter((f) => f.room === room).map((f) => f.kind);
- expect(kinds("prizes")).toEqual(expect.arrayContaining(["prizeCounter", "tokenMachine", "clawMachine"]));
- expect(kinds("snack")).toEqual(expect.arrayContaining(["snackCounter", "elevator"]));
- expect(kinds("arcade")).toEqual(expect.arrayContaining(["retroCabinet", "pinball", "airHockey"]));
});
- it("puts every furniture piece in the room it names", () => {
- for (const item of layout.furniture) expect(roomAt(layout, item)?.kind, item.id).toBe(item.room);
+ it("opens every walled room onto the hall, the doors facing each other on three lanes", () => {
+ const hall = room("arcade");
+ for (const r of layout.rooms.filter((x) => x.walled)) {
+ const door = r.doors[0];
+ expect(door.side, r.kind).toBe(r.maxZ <= hall.minZ ? "south" : "north");
+ expect(door.at).toBeGreaterThan(r.minX + door.width / 2);
+ expect(door.at).toBeLessThan(r.maxX - door.width / 2);
+ }
+ const lanes = hallLanes(layout);
+ expect(lanes).toHaveLength(3);
+ const southDoors = ["foyer", "prizes", "snack"].map((k) => room(k).doors[0].at);
+ expect(southDoors).toEqual(lanes);
+ // Nothing solid in the hall stands on a lane.
+ for (const item of layout.furniture.filter((f) => f.room === "arcade")) {
+ const r = footprint(item);
+ for (const x of lanes) expect(r.maxX < x - 0.9 || r.minX > x + 0.9, `${item.id} on lane ${x}`).toBe(true);
+ }
});
- it("has exactly one cabinet per game, turned by quarter turns", () => {
+ it("draws and blocks every wall run once", () => {
+ const all = layout.rooms.flatMap(wallsOf);
+ expect(layout.walls.length).toBeLessThan(all.length);
+ expect(uniqueWalls(layout.rooms)).toEqual(layout.walls);
+ const keys = layout.walls.map((w) => [w.x1, w.z1, w.x2, w.z2].map((v) => v.toFixed(3)).join(","));
+ expect(new Set(keys).size).toBe(keys.length);
+ });
+
+ it("groups the games by room and puts every one in exactly one cabinet", () => {
+ expect(Object.values(GAME_ROOMS).flat().sort()).toEqual(ARCADE_GAMES.map((g) => g.id).sort());
expect(cabinets).toHaveLength(ARCADE_GAMES.length);
- for (const game of ARCADE_GAMES) {
- expect(cabinets.filter((c) => c.id === cabinetId(game.id))).toHaveLength(1);
- }
- for (const cabinet of cabinets) {
- expect(gameForCabinet(cabinet.id)).not.toBeNull();
- const quarters = cabinet.rotationY / (Math.PI / 2);
- expect(Math.abs(quarters - Math.round(quarters))).toBeLessThan(1e-9);
+ for (const game of ARCADE_GAMES) expect(cabinets.filter((c) => c.id === cabinetId(game.id))).toHaveLength(1);
+ for (const [kind, games] of Object.entries(GAME_ROOMS)) {
+ const inRoom = cabinets.filter((c) => c.room === kind).sort((a, b) => a.x - b.x);
+ expect(inRoom.map((c) => gameForCabinet(c.id)?.id)).toEqual(games);
}
expect(new Set(layout.furniture.map((f) => f.id)).size).toBe(layout.furniture.length);
});
- it("turns every cabinet's screen towards the camera (south or east)", () => {
+ it("stands every cabinet on its room's back wall, screen to the south", () => {
for (const cabinet of cabinets) {
- const facing = { x: Math.round(Math.sin(cabinet.rotationY)), z: Math.round(Math.cos(cabinet.rotationY)) };
- expect(facing.x >= 0 && facing.z >= 0, cabinet.id).toBe(true);
+ expect(cabinet.rotationY).toBe(0);
+ const r = room(cabinet.room);
+ expect(footprint(cabinet).minZ - r.minZ, cabinet.id).toBeLessThan(0.15);
}
});
- it("keeps solid furniture, decor and arch posts apart and inside the slab", () => {
+ it("puts every furniture piece in the room it names", () => {
+ for (const item of layout.furniture) expect(roomAt(layout, item)?.kind, item.id).toBe(item.room);
+ });
+
+ it("keeps solid furniture, tables and walls apart and inside the slab", () => {
const solids = layout.furniture.filter((f) => FURNITURE_SIZE[f.kind].solid).map((f) => ({ id: f.id, rect: footprint(f) }));
const tables = arcadeDecor(layout.rooms).tables.map((t, i) => ({
id: `table-${i}`, rect: { minX: t.x - SNACK_TABLE_HALF, maxX: t.x + SNACK_TABLE_HALF, minZ: t.z - SNACK_TABLE_HALF, maxZ: t.z + SNACK_TABLE_HALF },
}));
- const posts = layout.rooms.flatMap(archPosts).map((p, i) => ({
- id: `post-${i}`, rect: { minX: p.x - ARCH.post / 2, maxX: p.x + ARCH.post / 2, minZ: p.z - ARCH.post / 2, maxZ: p.z + ARCH.post / 2 },
- }));
const walls = layout.walls.map((w, i) => ({ id: `wall-${i}`, rect: wallRect(w) }));
- const all = [...solids, ...tables, ...posts, ...walls];
- expect(tables).toHaveLength(3);
- for (let i = 0; i < all.length; i += 1) {
- expect(inside(all[i].rect, layout.bounds), all[i].id).toBe(true);
- for (let j = i + 1; j < all.length; j += 1) {
- expect(overlaps(all[i].rect, all[j].rect), `${all[i].id} × ${all[j].id}`).toBe(false);
+ const things = [...solids, ...tables];
+ expect(tables).toHaveLength(4);
+ for (let i = 0; i < things.length; i += 1) {
+ expect(inside(things[i].rect, layout.bounds), things[i].id).toBe(true);
+ for (let j = i + 1; j < things.length; j += 1) {
+ expect(overlaps(things[i].rect, things[j].rect), `${things[i].id} × ${things[j].id}`).toBe(false);
}
+ for (const wall of walls) expect(overlaps(things[i].rect, wall.rect), `${things[i].id} × ${wall.id}`).toBe(false);
}
- // Navigation walks round every one of them.
- for (const { rect } of all) expect(layout.obstacles).toContainEqual(rect);
+ for (const { rect } of [...things, ...walls]) expect(layout.obstacles).toContainEqual(rect);
+ });
+
+ it("keeps the floor logos and the dance floor clear of everything solid", () => {
+ const decor = arcadeDecor(layout.rooms);
+ const solids = layout.obstacles;
+ const flats: Rect[] = [decor.pad, ...decor.logos.map((l) => ({ minX: l.x - l.r, maxX: l.x + l.r, minZ: l.z - l.r, maxZ: l.z + l.r }))];
+ expect(decor.logos.map((l) => l.room).sort()).toEqual(["action", "arcade", "classics", "foyer", "puzzle"]);
+ for (const flat of flats) for (const solid of solids) expect(overlaps(flat, solid)).toBe(false);
});
it("can reach every cabinet's play spot from the elevator", () => {
- const pose = arrivalPose(layout, "elevator");
expect(isWalkable(grid, pose)).toBe(true);
expect(isWalkable(grid, layout.spawn)).toBe(true);
expect(isWalkable(grid, layout.arrival)).toBe(true);
@@ -115,25 +151,35 @@ describe("arcade floor layout", () => {
}
});
- it("keeps the elevator stop clear of the cabinets", () => {
+ it("arrives in the foyer, clear of the token machines", () => {
const stop = layout.checkpoints[0];
- expect(stop.room).toBe("snack");
- for (const cabinet of cabinets) {
- const spot = cabinetPlaySpot(cabinet);
- expect(Math.hypot(spot.x - stop.x, spot.z - stop.z)).toBeGreaterThan(stop.radius + 1);
+ expect(stop.room).toBe("foyer");
+ expect(roomAt(layout, layout.arrival)?.kind).toBe("foyer");
+ for (const token of layout.furniture.filter((f) => f.kind === "tokenMachine")) {
+ expect(Math.hypot(token.x - stop.x, token.z - stop.z)).toBeGreaterThan(stop.radius + 0.4);
}
});
- it("reaches the counters, the claw machines and the snack tables on foot", () => {
- const pose = arrivalPose(layout, "elevator");
+ it("reaches the counters, claw machines, token machines, pinballs and the air hockey on foot", () => {
const front = (id: string) => {
const item = layout.furniture.find((f) => f.id === id)!;
const reach = FURNITURE_SIZE[item.kind].d / 2 + 0.5;
return { x: item.x + Math.sin(item.rotationY) * reach, z: item.z + Math.cos(item.rotationY) * reach };
};
- for (const id of ["prize-counter", "token-machine", "claw-a", "claw-b", "snack-counter", "air-hockey", "pinball-1"]) {
+ const ids = layout.furniture.filter((f) => ["prizeCounter", "snackCounter", "clawMachine", "tokenMachine", "pinball", "airHockey"].includes(f.kind)).map((f) => f.id);
+ expect(ids.length).toBeGreaterThanOrEqual(12);
+ for (const id of ids) {
expect(isWalkable(grid, front(id)), id).toBe(true);
expect(findPath(grid, pose, front(id)), id).not.toBeNull();
}
});
+
+ it("lets the person walk from the foyer through the hall into every room", () => {
+ for (const r of layout.rooms) {
+ const centre = { x: (r.minX + r.maxX) / 2, z: r.kind === "arcade" ? (r.minZ + r.maxZ) / 2 + 1.2 : (r.minZ + r.maxZ) / 2 };
+ const target = isWalkable(grid, centre) ? centre : { x: r.doors[0]?.at ?? centre.x, z: r.maxZ <= room("arcade").minZ ? r.maxZ - 1 : r.minZ + 1 };
+ expect(isWalkable(grid, target), r.kind).toBe(true);
+ expect(findPath(grid, pose, target), r.kind).not.toBeNull();
+ }
+ });
});
diff --git a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.ts b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.ts
index 74781a91d0..f742d4d425 100644
--- a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.ts
+++ b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeFloorLayout.ts
@@ -1,50 +1,53 @@
/**
* The arcade floor as data: the top floor of the building, one elevator ride
- * above the coding floor. A dark, neon-lit 80s/90s arcade hall with every
- * playable cabinet of the registry, a pinball row, an air-hockey table, a
- * prize counter with claw machines and a token changer, and a snack bar by
- * the elevator.
+ * above the coding floor. It reads like the floors below it: a strip of
+ * walled rooms in the north, an open hall in the middle and a strip of
+ * walled rooms in the south, each room with its own door, sign, carpet and
+ * neon colour, so the person always knows where they are.
*
- * Pure and deterministic, like officeLayout: the plan never depends on who is
- * online (nobody works up here, so it has no departments, desks or hangout
- * spots). Units are metres, +x east, +z south, origin at the floor centre.
- * The camera looks from the south-east, so the floor is a diorama with two
- * back walls (north and west, drawn by ArcadeHall) and glass railings on the
- * south and east; tall pieces stand along the back walls, every cabinet's
- * screen faces south or east, towards the camera.
+ * ┌──────────── Classics ────────────┬──── Puzzle corner ────┬──────────── Action zone ───────────┐
+ * │ 4 cabinets on the back wall │ 3 cabinets │ 3 cabinets │
+ * └───────────────[door]─────────────┴────────[door]─────────┴──────────────[door]───────────────┘
+ * pinballs · pinball row · ✪ floor logo · air hockey · dance floor ← the hall
+ * ┌───────────────[door]─────────────┬────────[door]─────────┬──────────────[door]───────────────┐
+ * │ Foyer: elevator · token machines │ Prize shop: counter, │ Snack bar: counter, bistro tables │
+ * │ welcome logo │ claw machines │ │
+ * └──────────────────────────────────┴───────────────────────┴─────────────────────────────────────┘
*
- * ┌───────── north wall ─────────────────────────────────────────────┐
- * │ PRIZES: counter · tokens │ pinballs · cabinet row A · dance pad │
- * │ claw machines (west wall) │ row B (faces east) · island C │
- * │ SNACK: counter · tables │ │
- * │ elevator (west wall) │ air hockey │
- * └──────────────────────────────────────────────────────── railing ─┘
+ * The doors of the north and south rooms line up on three lanes across the
+ * hall, and nothing in the hall stands on a lane. Every cabinet stands on a
+ * game room's back wall with its screen to the south, towards the camera and
+ * the door. The walls are smoked glass (ArcadeHall), so no camera angle ever
+ * hides a room or makes a wall pop away.
*
- * Open rooms only: each one's name arch stands on its north edge, right
- * behind the counter (prizes, snack) or the cabinet row (hall), so the sign
- * reads as the counter's own gantry.
+ * Pure and deterministic, like officeLayout: the plan never depends on who is
+ * online (nobody works up here: no departments, desks or hangout spots).
+ * Units are metres, +x east, +z south, origin at the floor centre.
*/
-import { ARCADE_GAMES, cabinetId } from "./arcadeGames";
+import { cabinetId, type ArcadeGameId } from "./arcadeGames";
import {
- archPosts, ARCH, FURNITURE_SIZE, footprint, wallRect, wallsOf,
- type Checkpoint, type Furniture, type FurnitureKind, type OfficeLayout, type Point, type Rect, type Room, type RoomKind,
+ FURNITURE_SIZE, footprint, wallRect, wallsOf,
+ type Checkpoint, type Furniture, type FurnitureKind, type OfficeLayout, type Point, type Rect, type Room, type RoomKind, type WallSegment,
} from "../office/officeLayout";
-/** Half the slab's size (bounds = ±HALF_W × ±HALF_D). */
-const HALF_W = 11.5;
-const HALF_D = 8.5;
-/** The back walls and the railings stand this far in from the slab's edge. */
-export const ARCADE_WALL_INSET = 0.2;
+/** The building's footprint: rooms and hall fill ±FLOOR_X × ±FLOOR_Z; a ledge of EDGE runs round it to the railing. */
+const FLOOR_X = 12;
+const FLOOR_Z = 9;
+const EDGE = 1.2;
/** How far a figure's centre stays from the slab edge (see officeLayout's RAIL_CLEARANCE). */
const RAIL_CLEARANCE = 0.65;
-/** Width of the west column holding the prize corner (north) and the snack bar (south). */
-const WEST_COLUMN = 5.8;
-/** Where the prize corner ends and the snack bar begins. */
-const PRIZES_DEPTH = 5.8;
-/** Centre-to-centre pitch of cabinets standing side by side (a 0.8 m cabinet and a 0.3 m gap). */
-const CABINET_PITCH = 1.1;
-/** The arch posts stand right behind a counter or a cabinet row; this keeps them clear of it. */
-const BEHIND_ARCH = ARCH.post / 2 + 0.06;
+/** The x where the three columns of rooms meet; the middle column is the narrower one. */
+const COLUMN_SPLIT = 3.6;
+/** The north strip (game rooms) ends here; the south strip (foyer, prize shop, snack bar) starts here. */
+const NORTH_END = -3.6;
+const SOUTH_START = 2.6;
+/** Door widths: game rooms, and the wider foyer door everyone arriving walks through. */
+const DOOR = 1.8;
+const FOYER_DOOR = 2.4;
+/** Wall thickness used by officeLayout's wallRect; furniture stands this far plus a gap from a wall line. */
+const WALL_GAP = 0.08;
+/** Centre-to-centre pitch of cabinets standing side by side on a back wall. */
+const CABINET_PITCH = 1.3;
/** A cabinet is played standing this far in front of it, along its local +z (OfficePlayer). */
export const CABINET_PLAY_DISTANCE = 0.85;
@@ -52,37 +55,62 @@ export const CABINET_PLAY_DISTANCE = 0.85;
/** The bistro tables of the snack bar: table and stools fit inside a square of this half size. */
export const SNACK_TABLE_HALF = 0.62;
-/** Floor decor that is drawn by ArcadeHall but placed here, so navigation knows the solid parts. */
+/** Which games stand in which game room, west to east along its back wall. */
+export const GAME_ROOMS: Readonly<Record<"classics" | "puzzle" | "action", readonly ArcadeGameId[]>> = {
+ classics: ["pixel-raiders", "maze-muncher", "city-defense", "paddle-duel"],
+ puzzle: ["block-drop", "neon-snake", "brick-breaker"],
+ action: ["asteroid-run", "desert-dash", "road-hopper"],
+};
+
+/** Each room's neon colour: its wall caps, its sign, its floor logo. */
+export const ROOM_ACCENT: Partial<Record<RoomKind, string>> = {
+ classics: "#a77bff",
+ puzzle: "#2de2e6",
+ action: "#ff8a3d",
+ arcade: "#ff3fa4",
+ foyer: "#ff3fa4",
+ prizes: "#ffd23f",
+ snack: "#ff5a6e",
+};
+
+/** Floor decor drawn by ArcadeHall but placed here, so navigation knows the solid parts. */
export interface ArcadeDecor {
/** Bistro tables (with their stools) in the snack bar; solid. */
tables: Point[];
- /** The light-up dance pad in the hall's north-east corner; flat, walkable. */
+ /** The light-up dance floor at the hall's east end; flat, walkable. */
pad: Rect;
- /** A neon star medallion inlaid in the carpet in the open south of the hall; flat, walkable. */
- medallion: Point & { r: number };
+ /** Neon logos inlaid in the floors: one per game room, the foyer's welcome logo and the hall's centrepiece; flat, walkable. */
+ logos: (Point & { r: number; room: RoomKind })[];
}
-/** The snack bar's three bistro tables, south of its counter, clear of the elevator stop. */
-function snackTables(room: Rect): Point[] {
- const cx = (room.minX + room.maxX) / 2;
- return [
- { x: cx - 1.2, z: room.minZ + 3.4 },
- { x: cx + 1.2, z: room.minZ + 3.4 },
- { x: cx, z: room.minZ + 5.6 },
- ];
+/** The building's column x-ranges, west to east, shared by the north and the south strip. */
+function columns(): [number, number][] {
+ return [[-FLOOR_X, -COLUMN_SPLIT], [-COLUMN_SPLIT, COLUMN_SPLIT], [COLUMN_SPLIT, FLOOR_X]];
}
-/** Where the floor decor lies, from the rooms of an arcade layout (empty when a room is missing). */
+const centreX = (r: Rect) => (r.minX + r.maxX) / 2;
+const centreZ = (r: Rect) => (r.minZ + r.maxZ) / 2;
+
+/** Where the floor decor lies, from the rooms of an arcade layout (missing rooms leave their decor out). */
export function arcadeDecor(rooms: readonly Room[]): ArcadeDecor {
- const snack = rooms.find((r) => r.kind === "snack");
- const hall = rooms.find((r) => r.kind === "arcade");
- return {
- tables: snack ? snackTables(snack) : [],
- pad: hall
- ? { minX: hall.maxX - 3.9, maxX: hall.maxX - 1.5, minZ: hall.minZ + 0.9, maxZ: hall.minZ + 3.3 }
- : { minX: 0, maxX: 0, minZ: 0, maxZ: 0 },
- medallion: hall ? { x: hall.minX + 6.6, z: hall.maxZ - 3.6, r: 1.5 } : { x: 0, z: 0, r: 0 },
- };
+ const room = (kind: RoomKind) => rooms.find((r) => r.kind === kind) ?? null;
+ const snack = room("snack"), hall = room("arcade");
+ const tables: Point[] = snack ? [
+ { x: snack.minX + 3.3, z: snack.minZ + 2.5 }, { x: snack.minX + 6.1, z: snack.minZ + 2.5 },
+ { x: snack.minX + 3.3, z: snack.minZ + 4.9 }, { x: snack.minX + 6.1, z: snack.minZ + 4.9 },
+ ] : [];
+ const pad: Rect = hall
+ ? { minX: hall.maxX - 2.6, maxX: hall.maxX - 0.4, minZ: centreZ(hall) - 1.1, maxZ: centreZ(hall) + 1.1 }
+ : { minX: 0, maxX: 0, minZ: 0, maxZ: 0 };
+ const logos: ArcadeDecor["logos"] = [];
+ for (const kind of ["classics", "puzzle", "action"] as const) {
+ const r = room(kind);
+ if (r) logos.push({ x: centreX(r), z: r.maxZ - 1.9, r: 1.05, room: kind });
+ }
+ const foyer = room("foyer");
+ if (foyer) logos.push({ x: centreX(foyer) + 0.6, z: centreZ(foyer) + 0.3, r: 1.3, room: "foyer" });
+ if (hall) logos.push({ x: centreX(hall), z: centreZ(hall), r: 1.25, room: "arcade" });
+ return { tables, pad, logos };
}
/** The spot in front of a cabinet where the person stands to play it. */
@@ -90,77 +118,94 @@ export function cabinetPlaySpot(item: Pick<Furniture, "x" | "z" | "rotationY">):
return { x: item.x + Math.sin(item.rotationY) * CABINET_PLAY_DISTANCE, z: item.z + Math.cos(item.rotationY) * CABINET_PLAY_DISTANCE };
}
+/** Wall runs of all rooms, each run once: two rooms sharing a wall line would otherwise both draw (and both block) it. */
+export function uniqueWalls(rooms: readonly Room[]): WallSegment[] {
+ const seen = new Set<string>();
+ const out: WallSegment[] = [];
+ for (const wall of rooms.flatMap(wallsOf)) {
+ const [a, b] = [`${wall.x1.toFixed(3)},${wall.z1.toFixed(3)}`, `${wall.x2.toFixed(3)},${wall.z2.toFixed(3)}`].sort();
+ const key = `${a}|${b}`;
+ if (seen.has(key)) continue;
+ seen.add(key);
+ out.push(wall);
+ }
+ return out;
+}
+
/** Build the arcade floor. Takes no input: the hall is the same for everyone. */
export function buildArcadeLayout(): OfficeLayout {
- // The lines of the back walls (north, west) and the railings (south, east).
- const west = -HALF_W + ARCADE_WALL_INSET, east = HALF_W - ARCADE_WALL_INSET;
- const north = -HALF_D + ARCADE_WALL_INSET, south = HALF_D - ARCADE_WALL_INSET;
- const split = west + WEST_COLUMN;
+ const [west, middle, east] = columns();
+ const north = -FLOOR_Z, south = FLOOR_Z;
+ const walled = (kind: RoomKind, [minX, maxX]: [number, number], minZ: number, maxZ: number, doorSide: "north" | "south", width = DOOR): Room =>
+ ({ id: kind, kind, walled: true, minX, maxX, minZ, maxZ, doors: [{ side: doorSide, at: (minX + maxX) / 2, width }] });
- const prizes: Room = { id: "prizes", kind: "prizes", walled: false, doors: [], minX: west, maxX: split, minZ: north, maxZ: north + PRIZES_DEPTH };
- const snack: Room = { id: "snack", kind: "snack", walled: false, doors: [], minX: west, maxX: split, minZ: prizes.maxZ, maxZ: south };
- const hall: Room = { id: "arcade", kind: "arcade", walled: false, doors: [], minX: split, maxX: east, minZ: north, maxZ: south };
- const rooms = [hall, prizes, snack];
+ const classics = walled("classics", west, north, NORTH_END, "south");
+ const puzzle = walled("puzzle", middle, north, NORTH_END, "south");
+ const action = walled("action", east, north, NORTH_END, "south");
+ const hall: Room = { id: "arcade", kind: "arcade", walled: false, doors: [], minX: -FLOOR_X, maxX: FLOOR_X, minZ: NORTH_END, maxZ: SOUTH_START };
+ const foyer = walled("foyer", west, SOUTH_START, south, "north", FOYER_DOOR);
+ const prizes = walled("prizes", middle, SOUTH_START, south, "north");
+ const snack = walled("snack", east, SOUTH_START, south, "north");
+ const rooms = [classics, puzzle, action, hall, foyer, prizes, snack];
const piece = (id: string, kind: FurnitureKind, room: RoomKind, x: number, z: number, rotationY = 0): Furniture =>
({ id, kind, x, z, rotationY, room });
- /** z of a piece facing south whose back stands just in front of its room's name arch. */
- const underArch = (room: Room, kind: FurnitureKind) => archPosts(room)[0].z + BEHIND_ARCH + FURNITURE_SIZE[kind].d / 2;
- /** z of a piece facing south with its back against the north wall. */
- const againstNorth = (kind: FurnitureKind) => north + 0.08 + FURNITURE_SIZE[kind].d / 2;
- /** x of a piece turned to face east with its back against the west wall. */
- const againstWest = (kind: FurnitureKind) => west + 0.08 + FURNITURE_SIZE[kind].d / 2;
- const pcx = (prizes.minX + prizes.maxX) / 2, scx = (snack.minX + snack.maxX) / 2, hcx = (hall.minX + hall.maxX) / 2;
-
- // The cabinets, in registry order: row A along the north wall under the hall's
- // arch, row B down the hall's west side facing east, island C in the middle.
- const slots: { x: number; z: number; rotationY: number }[] = [
- ...[0, 1, 2, 3].map((i) => ({ x: hcx + (i - 1.5) * CABINET_PITCH, z: underArch(hall, "retroCabinet"), rotationY: 0 })),
- ...[0, 1, 2].map((i) => ({ x: split + 1.2, z: north + 4.9 + i * CABINET_PITCH, rotationY: Math.PI / 2 })),
- ...[0, 1, 2].map((i) => ({ x: hcx + (i - 1) * CABINET_PITCH - 1.1, z: north + 5.9, rotationY: 0 })),
- ];
- const cabinets: Furniture[] = ARCADE_GAMES.map((game, i) => {
- const slot = slots[i % slots.length];
- return piece(cabinetId(game.id), "retroCabinet", "arcade", slot.x, slot.z, slot.rotationY);
- });
-
- const elevatorZ = south - 2.7;
- const elevator = piece("elevator", "elevator", "snack", againstWest("elevator"), elevatorZ, Math.PI / 2);
- const furniture: Furniture[] = [
- ...cabinets,
- // Prize corner: the counter under its arch, the token changer beside it, two claw machines on the west wall.
- piece("prize-counter", "prizeCounter", "prizes", pcx, underArch(prizes, "prizeCounter")),
- piece("token-machine", "tokenMachine", "prizes", prizes.maxX - 0.55, againstNorth("tokenMachine") + 0.2),
- piece("claw-a", "clawMachine", "prizes", againstWest("clawMachine"), prizes.minZ + 2.6, Math.PI / 2),
- piece("claw-b", "clawMachine", "prizes", againstWest("clawMachine"), prizes.minZ + 3.8, Math.PI / 2),
- // Snack bar: the counter under its arch; the elevator on the west wall.
- piece("snack-counter", "snackCounter", "snack", scx, underArch(snack, "snackCounter")),
- elevator,
- // Hall: a pinball row on the north wall west of row A, the air-hockey table in the open south-east.
- ...[0, 1, 2].map((i) => piece(`pinball-${i}`, "pinball", "arcade", split + 1.9 + i * 0.85, againstNorth("pinball"))),
- piece("air-hockey", "airHockey", "arcade", east - 3.7, south - 4.7),
+ /** Centre offset of a piece standing with its back against a wall (its depth along the wall's normal). */
+ const off = (kind: FurnitureKind) => WALL_GAP + FURNITURE_SIZE[kind].d / 2;
+
+ // The cabinets: each game room's games side by side on its back (north) wall, screens to the south.
+ const cabinets: Furniture[] = [];
+ for (const room of [classics, puzzle, action]) {
+ const games = GAME_ROOMS[room.kind as keyof typeof GAME_ROOMS];
+ games.forEach((game, i) => {
+ const x = centreX(room) + (i - (games.length - 1) / 2) * CABINET_PITCH;
+ cabinets.push(piece(cabinetId(game), "retroCabinet", room.kind, x, room.minZ + off("retroCabinet")));
+ });
+ }
+
+ // The foyer: the elevator on the west wall like on every floor (doors facing east), the token machines north of it.
+ const elevator = piece("elevator", "elevator", "foyer", foyer.minX + off("elevator"), foyer.maxZ - 2.8, Math.PI / 2);
+ const tokens = [0, 1].map((i) => piece(`token-${i}`, "tokenMachine", "foyer", foyer.minX + off("tokenMachine"), foyer.minZ + 1.0 + i * 0.8, Math.PI / 2));
+ // Two big plants soften the foyer's east corners.
+ const plants = [foyer.minZ + 0.5, foyer.maxZ - 0.5].map((z, i) => piece(`foyer-plant-${i}`, "plant", "foyer", foyer.maxX - 0.5, z));
+
+ // The prize shop: the counter on its west wall facing the room, a claw machine either side of the door and one on the east wall.
+ const counterZ = centreZ(prizes) + 0.4;
+ const prizeFurniture = [
+ piece("prize-counter", "prizeCounter", "prizes", prizes.minX + off("prizeCounter"), counterZ, Math.PI / 2),
+ piece("claw-a", "clawMachine", "prizes", centreX(prizes) - 2.0, prizes.minZ + off("clawMachine")),
+ piece("claw-b", "clawMachine", "prizes", centreX(prizes) + 2.0, prizes.minZ + off("clawMachine")),
+ piece("claw-c", "clawMachine", "prizes", prizes.maxX - off("clawMachine"), counterZ + 0.6, -Math.PI / 2),
];
- // The elevator's doors face east into the snack bar; its stop is the floor in front of them.
- const elevatorStop: Checkpoint = { id: "elevator", room: "snack", x: elevator.x + 0.95, z: elevator.z, radius: 1.0 };
+ // The snack bar: its counter on the west wall facing the tables.
+ const snackCounter = piece("snack-counter", "snackCounter", "snack", snack.minX + off("snackCounter"), centreZ(snack) + 0.3, Math.PI / 2);
+
+ // The hall: a pinball pair at the west end and a row of three west of the middle lane, the air-hockey table east of it.
+ // The three lanes (x of the doors) stay clear.
+ const mid = centreZ(hall);
+ const pinballZ = mid - 0.4;
+ const pinballs = [-11.0, -10.1, -5.4, -4.5, -3.6].map((x, i) => piece(`pinball-${i}`, "pinball", "arcade", x, pinballZ));
+ const hockey = piece("air-hockey", "airHockey", "arcade", 4.3, mid);
+
+ const furniture: Furniture[] = [...cabinets, elevator, ...tokens, ...plants, ...prizeFurniture, snackCounter, ...pinballs, hockey];
+
+ // The elevator's doors face east into the foyer; its stop is the floor in front of them.
+ const elevatorStop: Checkpoint = { id: "elevator", room: "foyer", x: elevator.x + 0.95, z: elevator.z, radius: 1.0 };
const decor = arcadeDecor(rooms);
- const walls = rooms.flatMap(wallsOf);
+ const walls = uniqueWalls(rooms);
const obstacles: Rect[] = [
...walls.map(wallRect),
...furniture.filter((f) => FURNITURE_SIZE[f.kind].solid).map(footprint),
...decor.tables.map((t) => ({ minX: t.x - SNACK_TABLE_HALF, maxX: t.x + SNACK_TABLE_HALF, minZ: t.z - SNACK_TABLE_HALF, maxZ: t.z + SNACK_TABLE_HALF })),
- // The posts of the open rooms' name arches.
- ...rooms.filter((r) => !r.walled).flatMap(archPosts).map((p) => ({
- minX: p.x - ARCH.post / 2, maxX: p.x + ARCH.post / 2, minZ: p.z - ARCH.post / 2, maxZ: p.z + ARCH.post / 2,
- })),
];
- const bounds: Rect = { minX: -HALF_W, maxX: HALF_W, minZ: -HALF_D, maxZ: HALF_D };
+ const bounds: Rect = { minX: -FLOOR_X - EDGE, maxX: FLOOR_X + EDGE, minZ: -FLOOR_Z - EDGE, maxZ: FLOOR_Z + EDGE };
return {
variant: "arcade",
departments: [],
- // Nobody leads up here; the rect is the prize corner so it stays a real place on the floor.
- lead: { minX: prizes.minX, maxX: prizes.maxX, minZ: prizes.minZ, maxZ: prizes.maxZ, desks: [] },
+ // Nobody leads up here; the rect is the foyer so it stays a real place on the floor.
+ lead: { minX: foyer.minX, maxX: foyer.maxX, minZ: foyer.minZ, maxZ: foyer.maxZ, desks: [] },
rooms,
walls,
furniture,
@@ -176,3 +221,8 @@ export function buildArcadeLayout(): OfficeLayout {
bounds,
};
}
+
+/** The three lanes across the hall: the x of the doors that face each other across it. */
+export function hallLanes(layout: Pick<OfficeLayout, "rooms">): number[] {
+ return layout.rooms.filter((r) => r.walled && r.maxZ <= NORTH_END + 1e-6).map((r) => r.doors[0].at);
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.test.ts b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.test.ts
index 8f47c8e3a7..2b406965dd 100644
--- a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.test.ts
@@ -1,9 +1,8 @@
import { describe, expect, it } from "vitest";
import { Color } from "three";
import { ARCADE_GAMES } from "./arcadeGames";
-import { drawCarpet, drawGlowSpot, drawPrizeCarpet, drawSnackFloor, drawWallPanels, PartKit } from "./arcadeHallLook";
-import { createLiveScreen, drawScreenFrame, FACE_DRAWINGS, NEON_DRAW, PREVIEW_FPS, type NeonSymbol } from "./arcadeScreens";
-import type { RetroGame } from "./retroGame";
+import { drawCarpet, drawGlowSpot, drawPrizeCarpet, drawRoomFloor, drawSnackFloor, PartKit, ROOM_FLOORS } from "./arcadeHallLook";
+import { drawFloorLogo, drawRoomBoard, drawScreenFrame, FACE_DRAWINGS, NEON_DRAW, type NeonSymbol } from "./arcadeScreens";
/**
* A stand-in 2D context (jsdom has no canvas): every method is recorded, the
@@ -71,7 +70,7 @@ describe("PartKit", () => {
describe("hall surfaces", () => {
it.each([
["carpet", drawCarpet], ["prize carpet", drawPrizeCarpet], ["snack floor", drawSnackFloor],
- ["wall panels", drawWallPanels], ["glow spot", drawGlowSpot],
+ ["glow spot", drawGlowSpot],
] as const)("draws the %s the same way every time", (_name, draw) => {
const a = fakeContext(), b = fakeContext();
draw(a.ctx, 256, 256);
@@ -119,50 +118,24 @@ describe("machine faces and neon signs", () => {
});
});
-describe("live preview", () => {
- interface Counter { draws: number }
- const fakeCanvas = () => {
- const { ctx } = fakeContext();
- return { width: 0, height: 0, getContext: () => ctx } as unknown as HTMLCanvasElement;
- };
- const game = (draw: (state: Counter, idle: boolean, time: number) => void): RetroGame<Counter> => ({
- id: "fake", width: 160, height: 120,
- create: () => ({ draws: 0 }),
- step: () => undefined,
- draw: (_ctx, state, info) => draw(state, info.idle, info.time),
- status: () => ({ score: 0, over: false }),
- });
-
- it("is unavailable without a 2D canvas", () => {
- expect(createLiveScreen(game(() => undefined) as RetroGame<unknown>, { canvas: () => null })).toBeNull();
- });
-
- it("repaints the game's idle title screen a dozen times a second", () => {
- const seen: { idle: boolean; time: number }[] = [];
- let state: Counter | null = null;
- const screen = createLiveScreen(game((s, idle, time) => { state = s; s.draws += 1; seen.push({ idle, time }); }) as RetroGame<unknown>,
- { canvas: fakeCanvas });
- expect(screen).not.toBeNull();
- screen!.tick(0.01);
- screen!.tick(0.5 / PREVIEW_FPS);
- expect(state!.draws).toBe(1);
- screen!.tick(0.6 / PREVIEW_FPS);
- expect(state!.draws).toBe(2);
- expect(seen.every((s) => s.idle)).toBe(true);
- expect(seen[1].time).toBeGreaterThan(seen[0].time);
- screen!.dispose();
+describe("room boards and floor logos", () => {
+ it("writes exactly the room's name on its board", () => {
+ const fake = fakeContext();
+ drawRoomBoard(fake.ctx, 680, 160, "Klassiker", "#a77bff");
+ expect(new Set(fake.texts)).toEqual(new Set(["Klassiker"]));
});
- it("freezes on a game that throws while drawing", () => {
- let calls = 0;
- const screen = createLiveScreen(game(() => { calls += 1; throw new Error("broken"); }) as RetroGame<unknown>, { canvas: fakeCanvas });
- screen!.tick(1);
- screen!.tick(1);
- expect(calls).toBe(1);
+ it.each(Object.keys(NEON_DRAW) as NeonSymbol[])("lays the %s logo on the floor without words", (symbol) => {
+ const fake = fakeContext();
+ drawFloorLogo(fake.ctx, 512, symbol, "#2de2e6");
+ expect(fake.calls.some((c) => c.startsWith("stroke("))).toBe(true);
+ expect(fake.texts).toEqual([]);
});
- it("gives up on a game that cannot start", () => {
- const broken: RetroGame<unknown> = { ...game(() => undefined), create: () => { throw new Error("no start"); } } as RetroGame<unknown>;
- expect(createLiveScreen(broken, { canvas: fakeCanvas })).toBeNull();
+ it.each(Object.keys(ROOM_FLOORS))("paints the %s floor", (kind) => {
+ const fake = fakeContext();
+ drawRoomFloor(kind as keyof typeof ROOM_FLOORS)(fake.ctx, 256, 256);
+ expect(fake.calls.length).toBeGreaterThan(0);
+ expect(fake.texts).toEqual([]);
});
});
diff --git a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.ts b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.ts
index 4e7f26b247..3b32c6e8d8 100644
--- a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.ts
+++ b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeHallLook.ts
@@ -1,6 +1,6 @@
/**
- * The arcade floor's look: its palette, the blacklight carpet and the room
- * floors, and a small kit that bakes many coloured primitives into ONE
+ * The arcade floor's look: its palette, the hall's blacklight carpet and each
+ * room's own floor, and a small kit that bakes many coloured primitives into ONE
* geometry with vertex colours.
*
* The kit is why ten cabinets, a pinball row and shelves full of plush cost
@@ -28,8 +28,8 @@ export const HALL = {
slabEdge: "#130d22",
/** The glowing rim under the slab's edge. */
rim: "#ff3fa4",
- /** The back walls: midnight panels with a faint pinstripe. */
- wall: { base: "#160f2c", panel: "#1c1438", groove: "#0d0920" },
+ /** The rooms' glass walls: a dark steel frame round smoked glass. */
+ frame: "#1a1726",
neon: { magenta: "#ff3fa4", cyan: "#2de2e6", yellow: "#ffd23f", violet: "#8b5cff", green: "#39ff88", orange: "#ff8a3d" },
/** The blacklight carpet: near-black ground and its neon squiggles. */
carpet: { base: "#0d0a1c", shapes: ["#ff3fa4", "#2de2e6", "#ffd23f", "#8b5cff", "#39ff88"] },
@@ -132,8 +132,9 @@ function wrapped(w: number, h: number, paint: (dx: number, dy: number) => void):
/**
* The blacklight arcade carpet: a near-black ground scattered with neon
* squiggles, rings, triangles, zigzags and specks. Seamless on both axes.
+ * `density` thins the pattern out (the hall uses a calm 0.4).
*/
-export function drawCarpet(ctx: Ctx, w: number, h: number): void {
+export function drawCarpet(ctx: Ctx, w: number, h: number, density = 1): void {
const { base, shapes } = HALL.carpet;
const rand = lcg(0xa2cade);
ctx.fillStyle = base;
@@ -146,7 +147,8 @@ export function drawCarpet(ctx: Ctx, w: number, h: number): void {
ctx.lineCap = "round";
ctx.lineJoin = "round";
const pick = () => shapes[Math.floor(rand() * shapes.length)];
- for (let i = 0; i < 64; i += 1) {
+ ctx.globalAlpha = density < 1 ? 0.7 : 1;
+ for (let i = 0; i < Math.round(64 * density); i += 1) {
const x = rand() * w, y = rand() * h, colour = pick(), size = 10 + rand() * 18, turn = rand() * Math.PI * 2;
const kind = i % 5;
ctx.strokeStyle = colour;
@@ -191,7 +193,7 @@ export function drawCarpet(ctx: Ctx, w: number, h: number): void {
});
}
// Small neon specks between the shapes.
- for (let i = 0; i < 140; i += 1) {
+ for (let i = 0; i < Math.round(140 * density); i += 1) {
ctx.fillStyle = pick();
const x = rand() * w, y = rand() * h, r = 1.5 + rand() * 2;
wrapped(w, h, (dx, dy) => {
@@ -200,6 +202,7 @@ export function drawCarpet(ctx: Ctx, w: number, h: number): void {
ctx.fill();
});
}
+ ctx.globalAlpha = 1;
}
/** The prize corner's plum carpet: a fine dot grid with small gold stars. Seamless. */
@@ -261,22 +264,101 @@ export function drawGlowSpot(ctx: Ctx, w: number, h: number): void {
ctx.fillRect(0, 0, w, h);
}
-/** The back walls: tall midnight panels with dark grooves and a faint violet sheen. Seamless horizontally. */
-export function drawWallPanels(ctx: Ctx, w: number, h: number): void {
- const { base, panel, groove } = HALL.wall;
- ctx.fillStyle = base;
+/** The classics room: a violet carpet with tiny gold and lilac sparkles in a loose grid. Seamless. */
+function drawClassicsFloor(ctx: Ctx, w: number, h: number): void {
+ ctx.fillStyle = "#241446";
ctx.fillRect(0, 0, w, h);
- const panels = 4, pw = w / panels;
- for (let i = 0; i < panels; i += 1) {
- const g = ctx.createLinearGradient(0, 0, 0, h);
- g.addColorStop(0, panel);
- g.addColorStop(1, base);
- ctx.fillStyle = g;
- ctx.fillRect(i * pw + 3, 0, pw - 6, h);
- ctx.fillStyle = groove;
- ctx.fillRect(i * pw - 1.5, 0, 3, h);
+ const rand = lcg(0xc1a551c);
+ for (let i = 0; i < 1400; i += 1) {
+ ctx.fillStyle = rand() > 0.5 ? "rgba(60,36,110,0.6)" : "rgba(18,8,36,0.5)";
+ ctx.fillRect(Math.floor(rand() * w), Math.floor(rand() * h), 2, 2);
+ }
+ const cell = w / 4;
+ for (let row = 0; row < 4; row += 1) {
+ for (let col = 0; col < 4; col += 1) {
+ const x = col * cell + (row % 2 === 0 ? cell / 2 : 0), y = row * cell + cell / 2;
+ ctx.fillStyle = (row + col) % 3 === 0 ? "#ffd23f" : "#a77bff";
+ wrapped(w, h, (dx, dy) => {
+ // A four-point pixel sparkle.
+ ctx.fillRect(x + dx - 1, y + dy - 5, 2, 10);
+ ctx.fillRect(x + dx - 5, y + dy - 1, 10, 2);
+ });
+ }
}
- // A skirting band at the foot.
- ctx.fillStyle = groove;
- ctx.fillRect(0, h - h * 0.04, w, h * 0.04);
+}
+
+/** The puzzle corner: deep teal with faint outlined blocks in a stepped pattern. Seamless. */
+function drawPuzzleFloor(ctx: Ctx, w: number, h: number): void {
+ ctx.fillStyle = "#0f2a33";
+ ctx.fillRect(0, 0, w, h);
+ const cell = w / 8;
+ ctx.lineWidth = 2;
+ for (let row = 0; row < 8; row += 1) {
+ for (let col = 0; col < 8; col += 1) {
+ const lit = (row * 3 + col * 5) % 7 === 0;
+ ctx.strokeStyle = lit ? "rgba(45,226,230,0.45)" : "rgba(30,74,88,0.7)";
+ ctx.strokeRect(col * cell + 3, row * cell + 3, cell - 6, cell - 6);
+ }
+ }
+}
+
+/** The action zone: dark ember with diagonal racing stripes. Seamless (the stripes repeat with the tile). */
+function drawActionFloor(ctx: Ctx, w: number, h: number): void {
+ ctx.fillStyle = "#2e160c";
+ ctx.fillRect(0, 0, w, h);
+ ctx.lineWidth = w / 16;
+ ctx.strokeStyle = "rgba(70,32,14,0.9)";
+ for (let k = -2; k <= 2; k += 1) {
+ ctx.beginPath();
+ ctx.moveTo(k * w, h);
+ ctx.lineTo(k * w + w, 0);
+ ctx.stroke();
+ ctx.beginPath();
+ ctx.moveTo(k * w + w / 2, h);
+ ctx.lineTo(k * w + w * 1.5, 0);
+ ctx.stroke();
+ }
+ ctx.lineWidth = 3;
+ ctx.strokeStyle = "rgba(255,138,61,0.55)";
+ for (let k = -2; k <= 2; k += 1) {
+ ctx.beginPath();
+ ctx.moveTo(k * w + w / 4, h);
+ ctx.lineTo(k * w + w * 1.25, 0);
+ ctx.stroke();
+ }
+}
+
+/** The foyer: dark terrazzo with pale chips and the odd neon fleck. Seamless. */
+function drawFoyerFloor(ctx: Ctx, w: number, h: number): void {
+ ctx.fillStyle = "#24202e";
+ ctx.fillRect(0, 0, w, h);
+ const rand = lcg(0xf0e7e2);
+ const chips = ["#3b3550", "#4a4462", "#17141f", "#5b5574"];
+ for (let i = 0; i < 520; i += 1) {
+ const x = rand() * w, y = rand() * h, r = 1 + rand() * 3;
+ ctx.fillStyle = i % 37 === 0 ? HALL.neon.magenta : i % 41 === 0 ? HALL.neon.cyan : chips[Math.floor(rand() * chips.length)];
+ wrapped(w, h, (dx, dy) => {
+ ctx.beginPath();
+ ctx.arc(x + dx, y + dy, r, 0, Math.PI * 2);
+ ctx.fill();
+ });
+ }
+}
+
+/** Each room's floor: its drawing, how many metres one tile covers, and how shiny it is. */
+export const ROOM_FLOORS = {
+ arcade: { draw: (ctx: Ctx, w: number, h: number) => drawCarpet(ctx, w, h, 0.4), metres: CARPET_METRES, roughness: 0.95, glow: 0.18 },
+ classics: { draw: drawClassicsFloor, metres: ROOM_FLOOR_METRES, roughness: 0.95, glow: 0.12 },
+ puzzle: { draw: drawPuzzleFloor, metres: ROOM_FLOOR_METRES, roughness: 0.9, glow: 0.12 },
+ action: { draw: drawActionFloor, metres: ROOM_FLOOR_METRES, roughness: 0.9, glow: 0.1 },
+ foyer: { draw: drawFoyerFloor, metres: 2.4, roughness: 0.45, glow: 0 },
+ prizes: { draw: drawPrizeCarpet, metres: ROOM_FLOOR_METRES, roughness: 0.95, glow: 0.08 },
+ snack: { draw: drawSnackFloor, metres: ROOM_FLOOR_METRES, roughness: 0.4, glow: 0 },
+} as const;
+
+export type ArcadeRoomKind = keyof typeof ROOM_FLOORS;
+
+/** The drawing of a room's floor tile. */
+export function drawRoomFloor(kind: ArcadeRoomKind): (ctx: Ctx, w: number, h: number) => void {
+ return ROOM_FLOORS[kind].draw;
}
diff --git a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeScreens.ts b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeScreens.ts
index 695849449e..d40183e509 100644
--- a/jarvis/ui/web/frontend/src/components/society/arcade/arcadeScreens.ts
+++ b/jarvis/ui/web/frontend/src/components/society/arcade/arcadeScreens.ts
@@ -1,18 +1,19 @@
/**
* Everything the arcade floor draws on canvases: each cabinet's attract
- * screen and lit marquee, the neon signs on the back walls, the faces of the
- * other machines (prize counter, token changer, claw machine, pinball, air
- * hockey, snack bar) and the live preview of the cabinet the person stands at.
+ * screen and lit marquee, the neon signs on the glass walls and the floor
+ * logos, the rooms' lit name boards, and the faces of the other machines
+ * (prize counter, token changer, claw machine, pinball, air hockey, snack bar).
*
- * No words: only the games' own titles (never translated, see arcadeGames),
- * digits and symbols. Static faces are drawn once and cached; an attract
+ * No words on the machines: only the games' own titles (never translated, see
+ * arcadeGames), digits and symbols; the room boards show the translated room
+ * names they are given. Static faces are drawn once and cached; an attract
* screen holds two frames stacked in one texture, and the hall flips between
* them by moving the texture's offset, so ten cabinets animate for free.
*/
-import { CanvasTexture, MeshBasicMaterial, MeshStandardMaterial, SRGBColorSpace, type Texture } from "three";
+import { DoubleSide, MeshBasicMaterial, MeshStandardMaterial, type Texture } from "three";
import { cachedCanvasTexture, canvasMaterial } from "../office/canvasMaterials";
import type { ArcadeGameId, ArcadeGameInfo, CabinetLook } from "./arcadeGames";
-import { retroFont, seededRandom, type RetroDrawInfo, type RetroGame } from "./retroGame";
+import { retroFont } from "./retroGame";
import { HALL, lcg, starPath } from "./arcadeHallLook";
type Ctx = CanvasRenderingContext2D;
@@ -427,7 +428,7 @@ export function marqueeMaterial(game: ArcadeGameInfo | null): MeshStandardMateri
}
// ---------------------------------------------------------------------------
-// Neon signs on the back walls
+// Neon signs on the glass walls
// ---------------------------------------------------------------------------
export type NeonSymbol = "joystick" | "alien" | "bolt" | "star" | "ticket" | "soda" | "claw" | "coin";
@@ -572,8 +573,9 @@ export function neonMaterial(symbol: NeonSymbol): MeshBasicMaterial {
ctx.clearRect(0, 0, w, w);
NEON_DRAW[symbol](ctx, w);
});
+ // Double-sided: the signs hang on glass, so they read from inside the room and through the glass from outside.
material = map
- ? new MeshBasicMaterial({ map, transparent: true, depthWrite: false, toneMapped: false })
+ ? new MeshBasicMaterial({ map, transparent: true, depthWrite: false, toneMapped: false, side: DoubleSide })
: new MeshBasicMaterial({ color: HALL.neon.magenta, transparent: true, opacity: 0, depthWrite: false });
neonMaterials.set(symbol, material);
}
@@ -848,95 +850,65 @@ export const FACES = {
};
// ---------------------------------------------------------------------------
-// Live preview
+// Room boards and floor logos
// ---------------------------------------------------------------------------
-/** How often the live preview repaints, per second. */
-export const PREVIEW_FPS = 12;
+/** A room's lit name board in canvas pixels (the board is 2.5 m × 0.58 m). */
+export const ROOM_BOARD_PX = { w: 860, h: 200 } as const;
-export interface LiveScreen {
- material: MeshBasicMaterial;
- /** Advance the preview's clock by `dt` seconds; repaints at PREVIEW_FPS. */
- tick(dt: number): void;
- dispose(): void;
+/** A midnight board with a neon frame in the room's colour and its name written in the pixel face, glowing. */
+export function drawRoomBoard(ctx: Ctx, w: number, h: number, label: string, accent: string): void {
+ ctx.fillStyle = "#0b0816";
+ ctx.fillRect(0, 0, w, h);
+ ctx.beginPath();
+ ctx.roundRect(10, 10, w - 20, h - 20, 18);
+ tube(ctx, accent, 6);
+ ctx.textAlign = "center";
+ ctx.textBaseline = "middle";
+ fitFont(ctx, label, w - 90, 112, 48, 600);
+ ctx.shadowColor = accent;
+ ctx.shadowBlur = 18;
+ ctx.fillStyle = accent;
+ ctx.fillText(label, w / 2, h / 2 + 4);
+ ctx.shadowBlur = 4;
+ ctx.fillStyle = "rgba(255,255,255,0.85)";
+ ctx.fillText(label, w / 2, h / 2 + 4);
+ ctx.shadowBlur = 0;
}
-function defaultCanvas(): HTMLCanvasElement | null {
- return typeof document === "undefined" ? null : document.createElement("canvas");
+/** The cached, self-lit name board of a room (one per label and colour). */
+export function roomBoardMaterial(label: string, accent: string): MeshStandardMaterial {
+ return fontCanvasMaterial(`arcade:board:${accent}:${label}`, ROOM_BOARD_PX.w, ROOM_BOARD_PX.h,
+ (ctx, w, h) => drawRoomBoard(ctx, w, h, label, accent), { glow: 1, fallback: "#0b0816", roughness: 0.5 });
}
-/**
- * A game's own title screen, repainted a dozen times a second into a canvas
- * texture of the attract screen's size (the game's frame letterboxed into it).
- * Null where there is no 2D canvas. A game that throws while drawing freezes
- * on its last good frame: the preview is decoration, the overlay is the game.
- */
-export function createLiveScreen(
- game: RetroGame<unknown>,
- { seed = 7, canvas = defaultCanvas }: { seed?: number; canvas?: () => HTMLCanvasElement | null } = {},
-): LiveScreen | null {
- const source = canvas();
- const output = canvas();
- if (!source || !output) return null;
- let sourceCtx: Ctx | null = null, outputCtx: Ctx | null = null;
- try {
- sourceCtx = source.getContext("2d");
- outputCtx = output.getContext("2d");
- } catch {
- // jsdom without the canvas package throws "not implemented": no live preview, the static screen stays.
- return null;
- }
- if (!sourceCtx || !outputCtx) return null;
- let state: unknown;
- try {
- state = game.create(seededRandom(seed));
- } catch {
- // A game that cannot even start leaves its static attract screen; the overlay reports it when played.
- return null;
+/** A floor logo: two neon rings in the room's colour round the room's symbol. */
+export function drawFloorLogo(ctx: Ctx, w: number, symbol: NeonSymbol, accent: string): void {
+ ctx.clearRect(0, 0, w, w);
+ ctx.beginPath();
+ ctx.arc(w / 2, w / 2, w * 0.45, 0, Math.PI * 2);
+ tube(ctx, accent, w * 0.016);
+ ctx.beginPath();
+ ctx.arc(w / 2, w / 2, w * 0.4, 0, Math.PI * 2);
+ tube(ctx, accent, w * 0.008);
+ ctx.save();
+ ctx.translate(w * 0.2, w * 0.2);
+ NEON_DRAW[symbol](ctx, w * 0.6);
+ ctx.restore();
+}
+
+const logoMaterials = new Map<string, MeshBasicMaterial>();
+
+/** The cached floor logo of a symbol in a colour, on a transparent sheet that lies on the carpet. */
+export function floorLogoMaterial(symbol: NeonSymbol, accent: string): MeshBasicMaterial {
+ const key = `${symbol}:${accent}`;
+ let material = logoMaterials.get(key);
+ if (!material) {
+ const map = cachedCanvasTexture(`arcade:logo:${key}`, 512, 512, (ctx, w) => drawFloorLogo(ctx, w, symbol, accent));
+ material = map
+ ? new MeshBasicMaterial({ map, transparent: true, depthWrite: false, toneMapped: false, polygonOffset: true, polygonOffsetFactor: -2 })
+ : new MeshBasicMaterial({ color: accent, transparent: true, opacity: 0, depthWrite: false });
+ logoMaterials.set(key, material);
}
- source.width = Math.max(1, game.width);
- source.height = Math.max(1, game.height);
- output.width = SCREEN_PX.w;
- output.height = SCREEN_PX.h;
- const texture = new CanvasTexture(output);
- texture.colorSpace = SRGBColorSpace;
- const material = new MeshBasicMaterial({ map: texture, toneMapped: false });
- const info: RetroDrawInfo = { time: 0, reduced: false, idle: true };
- // Letterbox: the largest copy of the game's frame that fits the screen.
- const scale = Math.min(SCREEN_PX.w / source.width, SCREEN_PX.h / source.height);
- const dw = source.width * scale, dh = source.height * scale;
- const dx = (SCREEN_PX.w - dw) / 2, dy = (SCREEN_PX.h - dh) / 2;
- const src = sourceCtx, out = outputCtx;
- out.imageSmoothingEnabled = false;
- let since = Infinity;
- let broken = false;
- const paint = () => {
- try {
- game.draw(src, state, info);
- } catch {
- // See above: a broken draw keeps the last good frame; the game's own overlay reports real errors.
- broken = true;
- return;
- }
- out.fillStyle = "#05040b";
- out.fillRect(0, 0, SCREEN_PX.w, SCREEN_PX.h);
- out.drawImage(source, dx, dy, dw, dh);
- scanlines(out, 0, SCREEN_PX.w, SCREEN_PX.h);
- texture.needsUpdate = true;
- };
- return {
- material,
- tick(dt: number) {
- if (broken) return;
- info.time += dt;
- since += dt;
- if (since < 1 / PREVIEW_FPS) return;
- since = 0;
- paint();
- },
- dispose() {
- texture.dispose();
- material.dispose();
- },
- };
+ return material;
}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeFrameDriver.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeFrameDriver.tsx
index 9f9f2520bc..8f11f8a207 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeFrameDriver.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeFrameDriver.tsx
@@ -5,6 +5,11 @@ import { startOfficeFrameBudget } from "./officeFrameBudget";
/** The narrow IDE companion animates at 30 fps; the full view stays unrestricted. */
export function OfficeFrameDriver({ enabled }: { enabled: boolean }) {
const invalidate = useThree((state) => state.invalidate);
+ // Dev-only handle for runtime checks of the draw-call and memory budget (renderer.info).
+ const gl = useThree((state) => state.gl);
+ useEffect(() => {
+ if (import.meta.env.DEV && typeof window !== "undefined") Object.assign(window, { __officeGl: gl });
+ }, [gl]);
useEffect(() => {
if (!enabled) return;
return startOfficeFrameBudget(invalidate, 30);
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeFullMap.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeFullMap.tsx
index a4b9f1222d..27dc6e49be 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeFullMap.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeFullMap.tsx
@@ -124,6 +124,10 @@ function FullMapDialog({ onClose, layout, agents, selectedId }: Omit<OfficeFullM
command: t("society.office.room_command"),
server: t("society.office.room_server"),
arcade: t("society.office.room_arcade"),
+ classics: t("society.office.room_classics"),
+ puzzle: t("society.office.room_puzzle"),
+ action: t("society.office.room_action"),
+ foyer: t("society.office.room_foyer"),
prizes: t("society.office.room_prizes"),
snack: t("society.office.room_snack"),
};
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeMinimap.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeMinimap.tsx
index 3ef950cf0e..e60c6e4245 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeMinimap.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeMinimap.tsx
@@ -231,6 +231,10 @@ export function OfficeMinimap({ layout, agents, selectedId, onOpenMap }: OfficeM
command: t("society.office.room_command"),
server: t("society.office.room_server"),
arcade: t("society.office.room_arcade"),
+ classics: t("society.office.room_classics"),
+ puzzle: t("society.office.room_puzzle"),
+ action: t("society.office.room_action"),
+ foyer: t("society.office.room_foyer"),
prizes: t("society.office.room_prizes"),
snack: t("society.office.room_snack"),
};
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeRooms.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeRooms.tsx
index b53c7e2dcf..6624f68b60 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeRooms.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeRooms.tsx
@@ -25,7 +25,8 @@ function lcg(seed: number): () => number {
}
/** Metres covered by one repeat of each floor pattern. */
-const PATTERN_METRES: Record<RoomKind, number> = { lead: 2.6, team: 2, wardrobe: 2, reception: 3.2, break: 2.4, command: 3.2, server: 2, arcade: 2.4, prizes: 2, snack: 1.6 };
+const PATTERN_METRES: Record<RoomKind, number> = { lead: 2.6, team: 2, wardrobe: 2, reception: 3.2, break: 2.4, command: 3.2, server: 2,
+ arcade: 2.4, classics: 2, puzzle: 2, action: 2, foyer: 2.4, prizes: 2, snack: 1.6 };
function drawFloor(kind: RoomKind, ctx: CanvasRenderingContext2D, w: number, h: number): void {
const { base, accents } = ROOM_FLOOR_COLOURS[kind];
diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts b/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts
index bef5188cbd..d233b8790d 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/officeLayout.ts
@@ -66,9 +66,11 @@ export interface Department extends Rect {
/**
* "command" (Mission Control) and "server" only exist on the coding floor, in place of the lead office and the wardrobe.
- * "arcade" (the main hall), "prizes" (the prize counter corner) and "snack" (the snack bar) only exist on the arcade floor.
+ * The arcade floor has its own rooms: three game rooms ("classics", "puzzle", "action"), the open hall between them
+ * ("arcade"), and the "foyer" with the elevator, the prize shop ("prizes") and the "snack" bar.
*/
-export type RoomKind = "lead" | "team" | "wardrobe" | "reception" | "break" | "command" | "server" | "arcade" | "prizes" | "snack";
+export type RoomKind = "lead" | "team" | "wardrobe" | "reception" | "break" | "command" | "server"
+ | "arcade" | "classics" | "puzzle" | "action" | "foyer" | "prizes" | "snack";
/** Which floor a layout draws: the society agents' office, the coding agents' floor above it, or the arcade floor on top. */
export type OfficeVariant = "agents" | "coding" | "arcade";
diff --git a/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts b/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts
index 93edc87c0d..5e6ed2ced2 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/officePalette.ts
@@ -170,8 +170,13 @@ export const ROOM_FLOOR_COLOURS = {
// Mission Control: dark graphite microcement.
command: { base: "#454b54", accents: ["#3e444c", "#4d535c", "#41474f", "#51575f"] },
server: { base: "#c3c8cf", accents: ["#c9ced4", "#bcc2c9"] },
- // Arcade floor: the hall's midnight carpet, the prize corner's plum, the snack bar's checker red.
+ // Arcade floor: the hall's midnight carpet, the game rooms' violet, teal and ember carpets, the foyer's terrazzo,
+ // the prize shop's plum, the snack bar's checker red.
arcade: { base: "#1a1430", accents: ["#211a3d", "#151027", "#2a1f4a"] },
+ classics: { base: "#241446", accents: ["#2c1a55", "#1d1039"] },
+ puzzle: { base: "#0f2a33", accents: ["#13343f", "#0b2129"] },
+ action: { base: "#2e160c", accents: ["#3a1c0f", "#241008"] },
+ foyer: { base: "#24202e", accents: ["#2c2838", "#1d1a26"] },
prizes: { base: "#3a1838", accents: ["#431c41", "#33152f"] },
snack: { base: "#5a1e22", accents: ["#e9e2d6", "#4c191c"] },
} as const;
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
index cd745c68d9..4fa2d6e9c5 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/de.json
@@ -1042,7 +1042,11 @@
"room_break": "Pausenraum",
"room_server": "Serverraum",
"room_arcade": "Spielhalle",
- "room_prizes": "Preistheke",
+ "room_classics": "Klassiker",
+ "room_puzzle": "Knobelecke",
+ "room_action": "Action-Zone",
+ "room_foyer": "Foyer",
+ "room_prizes": "Preisshop",
"room_snack": "Snackbar",
"dog_treat": "Knochen geben",
"dog_take_bone": "Leckerli nehmen",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
index 0ebdaa64df..b0a4cf254f 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/en.json
@@ -1042,7 +1042,11 @@
"room_break": "Break room",
"room_server": "Server room",
"room_arcade": "Arcade hall",
- "room_prizes": "Prize counter",
+ "room_classics": "Classics",
+ "room_puzzle": "Puzzle corner",
+ "room_action": "Action zone",
+ "room_foyer": "Foyer",
+ "room_prizes": "Prize shop",
"room_snack": "Snack bar",
"dog_treat": "Give the bone",
"dog_take_bone": "Take a dog treat",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
index b1a45cc04c..b8fab1b343 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/society/es.json
@@ -1042,7 +1042,11 @@
"room_break": "Sala de descanso",
"room_server": "Sala de servidores",
"room_arcade": "Sala arcade",
- "room_prizes": "Mostrador de premios",
+ "room_classics": "Clásicos",
+ "room_puzzle": "Rincón de puzles",
+ "room_action": "Zona de acción",
+ "room_foyer": "Vestíbulo",
+ "room_prizes": "Tienda de premios",
"room_snack": "Bar de aperitivos",
"dog_treat": "Darle el hueso",
"dog_take_bone": "Coger una golosina",