Fix web homing motion and synchronize preview state

This commit is contained in:
2026-09-09 09:31:32 +08:00
parent bade560372
commit eb5c58cdb3
11 changed files with 375 additions and 33 deletions

View File

@@ -119,6 +119,7 @@ export function XyzacToolPreview({ visual, view = "p", zoom = 1, rotateMode = fa
let historyVertexCount = 0;
let activeLiveLine: THREE.Line | null = null;
let livePathEpoch = -1;
let poseEpoch = -1;
let lastHistoryTick = -1;
let lastActiveKey = "";
let lastPreset = "";
@@ -165,6 +166,29 @@ export function XyzacToolPreview({ visual, view = "p", zoom = 1, rotateMode = fa
const segments = state.toolpath as Segment[];
const layer = layersRef.current;
const now = performance.now();
// A HOME transaction can reset the canonical pose without advancing the
// simulation tick. Treat the source home sequence as an explicit pose
// barrier so stale queued jog samples cannot keep the old value on the
// HUD or tool marker. Keep the Live Plot history intact.
if (state.poseEpoch !== poseEpoch) {
poseEpoch = state.poseEpoch;
playbackQueue = [];
playbackStart = 0;
queuedLastTick = state.tick;
renderedTick = state.tick;
renderedPose = state.livePose;
renderedJoints = state.joints;
renderedActiveSegment = state.activeSegmentId ?? 0;
renderedProgress = state.activeProgress;
paintedTick = renderedTick;
paintedPose = renderedPose;
paintedJoints = renderedJoints;
paintedActiveSegment = renderedActiveSegment;
paintedProgress = renderedProgress;
liveTick = renderedTick;
if (activeLiveLine) { activeLiveLine.geometry.dispose(); liveGroup.remove(activeLiveLine); activeLiveLine = null; }
lastActiveKey = "";
}
if (state.livePathEpoch !== livePathEpoch) {
livePathEpoch = state.livePathEpoch;
clearLines(liveGroup);