Make machine configuration authoritative and restore native checkpoints exactly

This commit is contained in:
2026-09-18 09:09:41 +08:00
parent 6a69511276
commit 4a568f1f4c
94 changed files with 10882 additions and 301 deletions

View File

@@ -1,4 +1,5 @@
import { useEffect, useRef } from "react";
import { WEB_SETTINGS } from "../../workspace/web-settings.mjs";
import * as THREE from "three";
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
import { projectXyzacVisual, type XyzacVisualSource, type XyzacVisualState } from "./xyzac-visual-adapter";
@@ -8,7 +9,7 @@ type Segment = { id?: number; source_line?: number | null; active?: boolean; kin
type Props = { visual: XyzacVisualState; view?: "z" | "z2" | "x" | "y" | "y2" | "p"; zoom?: number; rotateMode?: boolean; showPath?: boolean; showLive?: boolean; showLimits?: boolean; showVelocity?: boolean; showOffsets?: boolean; showExtents?: boolean };
const DEG = Math.PI / 180;
const MM = 0.01;
const MM = WEB_SETTINGS.viewer.mm_scale;
const sourcePoint = (point: Point) => new THREE.Vector3(Number(point.x ?? 0) * MM, Number(point.z ?? 0) * MM, Number(point.y ?? 0) * MM);
export function XyzacToolPreview({ visual, view = "p", zoom = 1, rotateMode = false, showPath = true, showLive = true, showLimits = false, showVelocity = false, showOffsets = false, showExtents = false }: Props) {
@@ -24,11 +25,11 @@ export function XyzacToolPreview({ visual, view = "p", zoom = 1, rotateMode = fa
const element = host.current;
if (!element) return;
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x050a0e);
scene.background = new THREE.Color(WEB_SETTINGS.viewer.toolpath_colors.background);
scene.add(new THREE.HemisphereLight(0xdcecff, 0x121820, 1.4));
let camera: THREE.PerspectiveCamera | THREE.OrthographicCamera = new THREE.PerspectiveCamera(40, 1, 0.001, 100);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false, preserveDrawingBuffer: true });
renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio || 1, 2));
renderer.setPixelRatio(Math.min(globalThis.devicePixelRatio || 1, WEB_SETTINGS.viewer.pixel_ratio_limit));
renderer.domElement.dataset.engine = "three.js r185 / xyzac-tool-preview";
element.appendChild(renderer.domElement);
let controls: OrbitControls<THREE.PerspectiveCamera | THREE.OrthographicCamera> = new OrbitControls(camera, renderer.domElement);
@@ -85,12 +86,12 @@ export function XyzacToolPreview({ visual, view = "p", zoom = 1, rotateMode = fa
}
group.clear();
};
const completed = new THREE.LineBasicMaterial({ color: 0xd8dfe3, depthTest: false });
const rapid = new THREE.LineDashedMaterial({ color: 0xa85d5d, dashSize: .025, gapSize: .018, depthTest: false });
const completed = new THREE.LineBasicMaterial({ color: WEB_SETTINGS.viewer.toolpath_colors.completed, depthTest: false });
const rapid = new THREE.LineDashedMaterial({ color: WEB_SETTINGS.viewer.toolpath_colors.rapid, dashSize: .025, gapSize: .018, depthTest: false });
// LinuxCNC uses yellow for jog backplot. Coordinated program execution is
// red (live plot), while an unambiguous current program block is cyan.
const live = new THREE.LineBasicMaterial({ color: 0x00ffff, depthTest: false });
const liveHistory = new THREE.LineBasicMaterial({ color: 0xff6b4a, depthTest: false });
const live = new THREE.LineBasicMaterial({ color: WEB_SETTINGS.viewer.toolpath_colors.active, depthTest: false });
const liveHistory = new THREE.LineBasicMaterial({ color: WEB_SETTINGS.viewer.toolpath_colors.live, depthTest: false });
let frame = 0;
let liveTick = -1;
let liveTrace: THREE.Vector3[] = [];