Complete XYZAC LinuxCNC WASM parity and smooth 3D preview
This commit is contained in:
@@ -57,7 +57,7 @@ function payload<T>(message: MessageEnvelope): T {
|
||||
function projection(result: Record<string, unknown>, message: MessageEnvelope, previous: FrontendState) {
|
||||
const panel = result.panel_snapshot as PanelSnapshotV1 | undefined;
|
||||
if (panel?.schema === "axis-panel-snapshot.v1") {
|
||||
const visualSegments = panel.visual.toolpath
|
||||
const visualSegments = (Array.isArray(panel.visual.toolpath) ? panel.visual.toolpath : previous.toolpath)
|
||||
.filter((segment) => segment && typeof segment === "object" && Number.isSafeInteger((segment as { id?: unknown }).id ?? 0))
|
||||
.map((segment, index) => {
|
||||
const value = segment as Record<string, unknown>;
|
||||
@@ -68,13 +68,22 @@ function projection(result: Record<string, unknown>, message: MessageEnvelope, p
|
||||
end: value.end as Record<string, number>,
|
||||
...(value.center ? { center: value.center as Record<string, number> } : {}),
|
||||
...(value.normal ? { normal: value.normal as Record<string, number> } : {}),
|
||||
...(Array.isArray(value.samples) ? { samples: value.samples as Array<Record<string, number>> } : {}),
|
||||
...(typeof value.samples_source === "string" ? { samples_source: value.samples_source } : {}),
|
||||
...(typeof value.kind === "string" ? { kind: value.kind } : {}),
|
||||
...(typeof value.helix === "boolean" ? { helix: value.helix } : {}),
|
||||
...(typeof value.radius === "number" ? { radius: value.radius } : {}),
|
||||
...(typeof value.turns === "number" ? { turns: value.turns } : {}),
|
||||
...(typeof value.axial_delta === "number" ? { axial_delta: value.axial_delta } : {}),
|
||||
...(typeof value.canonical_motion_mode === "number" ? { canonical_motion_mode: value.canonical_motion_mode } : {}),
|
||||
...(typeof value.kinematics_mode === "number" ? { kinematics_mode: value.kinematics_mode } : {}),
|
||||
...(typeof value.motion_type === "number" ? { motion_type: value.motion_type } : {}),
|
||||
...(typeof value.turn === "number" ? { turn: value.turn } : {}),
|
||||
active: value.id === panel.visual.active_segment_id,
|
||||
};
|
||||
});
|
||||
const pose = panel.visual.pose;
|
||||
const axes = [pose.x, pose.y, pose.z].map((value) => Number.isFinite(value) ? value : 0);
|
||||
const axes = [pose.x, pose.y, pose.z, pose.a, pose.c].map((value) => Number.isFinite(value) ? value : 0);
|
||||
const snapshot = {
|
||||
schema: panel.schema,
|
||||
simulation_tick: panel.simulation_tick,
|
||||
@@ -85,17 +94,20 @@ function projection(result: Record<string, unknown>, message: MessageEnvelope, p
|
||||
overrides: panel.overrides,
|
||||
wasm_motion: panel.wasm_motion,
|
||||
authoritative: panel.authoritative as SimSnapshotV1["authoritative"],
|
||||
configuration: panel.configuration as SimSnapshotV1["configuration"],
|
||||
visual: panel.visual,
|
||||
configuration: (panel.configuration ?? previous.snapshot?.configuration ?? null) as SimSnapshotV1["configuration"],
|
||||
visual: { ...panel.visual, toolpath: visualSegments },
|
||||
kinematics: panel.kinematics,
|
||||
xyzac: panel.xyzac,
|
||||
gates: panel.gates,
|
||||
} satisfies SimSnapshotV1;
|
||||
return {
|
||||
snapshot,
|
||||
toolpath: visualSegments,
|
||||
task: panel.task,
|
||||
program: panel.program,
|
||||
devices: panel.devices,
|
||||
deviceIo: panel.device_io,
|
||||
hal: panel.hal,
|
||||
devices: panel.devices ?? previous.devices,
|
||||
deviceIo: panel.device_io ?? previous.deviceIo,
|
||||
hal: panel.hal ?? previous.hal,
|
||||
axisState: panel.axis_state,
|
||||
gates: { ...panel.gates, jog: panel.gates.jogStart, load: panel.gates.load, run: panel.gates.run, step: panel.gates.step, pause: panel.gates.pause, resume: panel.gates.resume, abort: panel.gates.abort, mdi: panel.gates.mdi, home: panel.gates.home },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user