Enforce LinuxCNC WASM authority for XYZAC frontend

This commit is contained in:
2026-09-02 07:43:47 +08:00
parent c60e3a1e8f
commit 6b689fd69e
36 changed files with 514 additions and 210 deletions

View File

@@ -2,6 +2,7 @@ import type { XyzacKinematicsSnapshot } from "./protocol";
export type XyzacVisualState = {
schema: "xyzac-visual-state.v1";
authoritative: boolean;
tick: number;
stateHash: string;
pose: XyzacKinematicsSnapshot["pose"];
@@ -40,6 +41,7 @@ export function projectXyzacVisual(snapshot: XyzacVisualSource | null | undefine
const motionTrace = (snapshot?.visual?.motion_trace ?? []).filter((sample) => sample && Number.isSafeInteger(sample.tick) && sample.pose && Array.isArray(sample.joints)).map((sample) => ({ tick: sample.tick, pose: { ...ZERO_POSE, ...sample.pose }, joints: sample.joints.slice(0, 5).map(Number), activeSegmentId: Number(sample.active_segment_id ?? 0), activeProgress: Math.max(0, Math.min(1, Number(sample.active_progress ?? 0))) }));
return {
schema: "xyzac-visual-state.v1",
authoritative: Boolean(snapshot?.kinematics && snapshot?.visual),
tick: snapshot?.simulation_tick ?? 0,
stateHash: snapshot?.state_hash ?? "",
pose,