|
| 1 | +import { expect, test } from "bun:test" |
| 2 | +import { getMeshOrigin } from "../../lib/utils/cad-mesh-placement" |
| 3 | + |
| 4 | +test("getMeshOrigin ignores inferred alignment without explicit origin position", () => { |
| 5 | + const origin = getMeshOrigin( |
| 6 | + { |
| 7 | + type: "cad_component", |
| 8 | + cad_component_id: "cad1", |
| 9 | + pcb_component_id: "pcb1", |
| 10 | + source_component_id: "source1", |
| 11 | + position: { x: 0, y: 0, z: 0 }, |
| 12 | + model_object_fit: "contain_within_bounds", |
| 13 | + anchor_alignment: "center", |
| 14 | + model_origin_alignment: "center_of_component_on_board_surface", |
| 15 | + }, |
| 16 | + { |
| 17 | + min: { x: -2, y: -3, z: -4 }, |
| 18 | + max: { x: 6, y: 7, z: 8 }, |
| 19 | + }, |
| 20 | + ) |
| 21 | + |
| 22 | + expect(origin).toEqual({ x: 0, y: 0, z: 0 }) |
| 23 | +}) |
| 24 | + |
| 25 | +test("getMeshOrigin returns explicit model origin position", () => { |
| 26 | + const origin = getMeshOrigin( |
| 27 | + { |
| 28 | + type: "cad_component", |
| 29 | + cad_component_id: "cad1", |
| 30 | + pcb_component_id: "pcb1", |
| 31 | + source_component_id: "source1", |
| 32 | + position: { x: 0, y: 0, z: 0 }, |
| 33 | + model_object_fit: "contain_within_bounds", |
| 34 | + anchor_alignment: "center", |
| 35 | + model_origin_alignment: "center_of_component_on_board_surface", |
| 36 | + model_origin_position: { x: 1, y: 2, z: 3 }, |
| 37 | + }, |
| 38 | + { |
| 39 | + min: { x: -2, y: -3, z: -4 }, |
| 40 | + max: { x: 6, y: 7, z: 8 }, |
| 41 | + }, |
| 42 | + ) |
| 43 | + |
| 44 | + expect(origin).toEqual({ x: 1, y: 2, z: 3 }) |
| 45 | +}) |
0 commit comments