feat: release v0.2 multi-robot simulator

Add declarative robot packages, shared simulation lifecycle and Microban ONNX/PD walking with independent head control.

Unify comic UI and chase camera; default robot packages to a 4.5m arena with real collision walls. Include regression tests, asset provenance/licenses and verification evidence.
This commit is contained in:
2026-10-28 14:00:26 +08:00
parent 44d3681726
commit fa089d5f0c
179 changed files with 28087 additions and 4997 deletions
+143
View File
@@ -0,0 +1,143 @@
import { useEffect, useState } from "react";
import Box from "@mui/material/Box";
import { useGame, gameApi } from "../store.js";
import { readLayoutMap, resolveKeycaps } from "./keyboard-layout.js";
const caps = {
ArrowUp: "↑",
ArrowDown: "↓",
ArrowLeft: "←",
ArrowRight: "→",
Space: "Space",
Escape: "Esc",
};
export default function ControlsHelp() {
const open = useGame((s) => s.helpOpen),
bindings = useGame((s) => s.inputBindings),
neutral = useGame((s) => s.presentationTheme === "neutral"),
physicalDrag = useGame((s) => s.runtimeCapabilities.physicalDrag),
blocked = useGame((s) => s.runtimePhase !== "ready");
const disabled = useGame(
(s) => s.runtimePhase !== "ready" || s.paused || s.fallen,
),
license = useGame((s) => s.robotLicense);
const [map, setMap] = useState(null);
useEffect(() => {
let cancelled = false;
const update = async () => {
const next = await readLayoutMap();
if (!cancelled) setMap(next);
};
update();
navigator.keyboard?.addEventListener?.("layoutchange", update);
return () => {
cancelled = true;
navigator.keyboard?.removeEventListener?.("layoutchange", update);
};
}, []);
const { labels } = resolveKeycaps(
bindings.flatMap((b) => b.codes.filter((c) => c.startsWith("Key"))),
map,
);
return (
<Box
component="aside"
aria-label="Keyboard controls"
sx={{
position: "fixed",
right: 24,
top: 20,
zIndex: 12,
maxWidth: 300,
maxHeight: "calc(100vh - 140px)",
overflowY: "auto",
color: "#faf8f2",
background: "rgba(8,8,12,.82)",
border: "1px solid #777",
fontFamily: "monospace",
fontSize: 12,
p: 1.5,
}}
>
<button
type="button"
aria-expanded={open}
onClick={() => useGame.setState({ helpOpen: !open })}
style={{
font: "inherit",
background: "none",
border: 0,
color: "inherit",
cursor: "pointer",
padding: 0,
}}
>
Keyboard controls {open ? "−" : "+"}
</button>
{open && (
<Box sx={{ display: "grid", gap: 1, mt: 1.5 }}>
{bindings.map((row) => {
const clickable = ![
"move_forward",
"move_backward",
"turn_left",
"turn_right",
"reset",
"pause",
].includes(row.action);
return (
<Box
key={row.action}
component={clickable ? "button" : "div"}
type={clickable ? "button" : undefined}
disabled={
clickable
? row.action === "chaseToggle"
? blocked
: disabled
: undefined
}
onClick={
clickable
? () => gameApi.triggerAction?.(row.action)
: undefined
}
sx={{
font: "inherit",
color: "inherit",
textAlign: "left",
background: "none",
border: 0,
p: 0,
cursor: clickable ? "pointer" : "default",
"&:disabled": { opacity: 0.45 },
"&:focus-visible": { outline: "2px solid #83bfff" },
}}
>
<strong style={{ color: neutral ? "#83bfff" : "#ff9a55" }}>
{row.codes.map((c) => caps[c] ?? labels[c] ?? c).join(" / ")}
</strong>
<br />
{row.label}
</Box>
);
})}
<div>
Mouse drag: orbit · wheel: zoom
{physicalDrag && (
<>
<br />
Drag robot / ball: apply force
</>
)}
</div>
{license && (
<details>
<summary>Asset license</summary>
<small>{license}</small>
</details>
)}
</Box>
)}
</Box>
);
}