Display selected joint local coordinate system
This commit is contained in:
@@ -16,7 +16,7 @@ export type MachinePartDraft = MachinePartSource & {
|
||||
nodeParents: Record<string, string | null>;
|
||||
nodeRoles: Record<string, MachinePartRole | "">;
|
||||
};
|
||||
export type MachineTreeNode = { path: string; name: string; type: "group" | "mesh"; originMm: Vec3; children: MachineTreeNode[] };
|
||||
export type MachineTreeNode = { path: string; name: string; type: "group" | "mesh"; originMm: Vec3; worldOriginMm: Vec3; rotationDeg: Vec3; children: MachineTreeNode[] };
|
||||
export type PhysicalZero = { x: number; y: number; z: number; a: number; b: number; c: number };
|
||||
export type ManagedMachineGeometry = {
|
||||
schema: "linuxcnc.machine-manager/1";
|
||||
@@ -74,11 +74,14 @@ export function machineSceneNode(scene: THREE.Object3D, path: string) {
|
||||
|
||||
export function machinePartTree(part: Pick<MachinePartDraft, "filename" | "scene" | "nodeParents">): MachineTreeNode {
|
||||
const scene = part.scene.clone(true), { paths } = scenePathMap(scene); applyMachineNodeParents(scene, part.nodeParents ?? {});
|
||||
scene.updateMatrixWorld(true);
|
||||
const build = (node: THREE.Object3D): MachineTreeNode => ({
|
||||
path: paths.get(node)!,
|
||||
name: node.name || (paths.get(node) === "scene" ? part.filename : `${(node as THREE.Mesh).isMesh ? "Mesh" : "Node"} ${paths.get(node)!.split("/").at(-1)}`),
|
||||
type: (node as THREE.Mesh).isMesh ? "mesh" : "group",
|
||||
originMm: node.position.toArray().map((value) => value * 1000) as Vec3,
|
||||
worldOriginMm: node.getWorldPosition(new THREE.Vector3()).toArray().map((value) => value * 1000) as Vec3,
|
||||
rotationDeg: new THREE.Euler().setFromQuaternion(node.quaternion, "XYZ").toArray().slice(0, 3).map((value) => THREE.MathUtils.radToDeg(Number(value))) as Vec3,
|
||||
children: node.children.map(build),
|
||||
});
|
||||
return build(scene);
|
||||
|
||||
Reference in New Issue
Block a user