Use independent XYZAC and XYZBC boat programs and models
This commit is contained in:
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { projectXyzacVisual, XYZAC_MACHINE_GROUPS } from "./xyzac-visual-adapter.ts";
|
||||
import * as THREE from "three";
|
||||
import { buildXyzacMachine } from "./xyzac-machine-model.ts";
|
||||
import { buildXyzacMachine, buildXyzbcMachine } from "./xyzac-machine-model.ts";
|
||||
|
||||
const source = await readFile(new URL("./XyzacMachineView.tsx", import.meta.url), "utf8") + await readFile(new URL("./xyzac-machine-model.ts", import.meta.url), "utf8");
|
||||
const panelSource = await readFile(new URL("./XyzacTrtPanel.tsx", import.meta.url), "utf8");
|
||||
@@ -52,10 +52,18 @@ for (const token of ["J0", "J1", "J2", "J3", "J4"]) {
|
||||
assert.ok(toolSource.includes(token), `tool preview ${token}`);
|
||||
assert.ok(source.includes("J${index}"), "machine preview joint label template");
|
||||
}
|
||||
const close = (actual, expected) => assert.ok(Math.abs(actual - expected) < 1e-7, `${actual} != ${expected}`);
|
||||
const model = buildXyzacMachine();
|
||||
const xyzbcModel = buildXyzbcMachine();
|
||||
assert.equal(xyzbcModel.machine.name, "xyzbc-machine");
|
||||
assert.ok(xyzbcModel.machine.getObjectByName("tilt-b"));
|
||||
assert.equal(xyzbcModel.machine.getObjectByName("tilt-a"), undefined);
|
||||
xyzbcModel.update({ joints: [0, 0, 0, 30, 45], offsets: { x_rot_point: 0, y_rot_point: 0, z_rot_point: 0, x_offset: -20, y_offset: 0, z_offset: -15, tool_offset: 0 } });
|
||||
close(xyzbcModel.joints.tilt.rotation.z, -30 * Math.PI / 180);
|
||||
assert.equal(xyzbcModel.joints.tilt.rotation.y, Math.PI / 2);
|
||||
xyzbcModel.dispose();
|
||||
const original = structuredClone(visual);
|
||||
const zero = { joints: [0, 0, 0, 0, 0], offsets: { x_rot_point: 0, y_offset: 20, z_offset: 10, tool_offset: 0 } };
|
||||
const close = (actual, expected) => assert.ok(Math.abs(actual - expected) < 1e-7, `${actual} != ${expected}`);
|
||||
const position = (node) => node.getWorldPosition(new THREE.Vector3());
|
||||
model.update(zero);
|
||||
close(position(model.toolTip).y, 2);
|
||||
|
||||
Reference in New Issue
Block a user