fluidcad 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/lib/dist/common/scene-object.d.ts +4 -14
  2. package/lib/dist/common/scene-object.js +10 -127
  3. package/lib/dist/common/transformable-primitive.d.ts +16 -0
  4. package/lib/dist/common/transformable-primitive.js +116 -0
  5. package/lib/dist/core/chamfer.d.ts +5 -5
  6. package/lib/dist/core/color.d.ts +3 -3
  7. package/lib/dist/core/fillet.d.ts +6 -6
  8. package/lib/dist/core/index.d.ts +1 -1
  9. package/lib/dist/core/interfaces.d.ts +32 -24
  10. package/lib/dist/core/load.d.ts +2 -2
  11. package/lib/dist/core/mirror.d.ts +7 -7
  12. package/lib/dist/core/mirror.js +42 -57
  13. package/lib/dist/core/plane.d.ts +5 -7
  14. package/lib/dist/core/remove.d.ts +2 -2
  15. package/lib/dist/core/rotate.d.ts +5 -5
  16. package/lib/dist/core/subtract.d.ts +2 -2
  17. package/lib/dist/core/translate.d.ts +9 -9
  18. package/lib/dist/features/2d/slot.d.ts +3 -0
  19. package/lib/dist/features/2d/slot.js +28 -7
  20. package/lib/dist/features/cylinder.d.ts +2 -2
  21. package/lib/dist/features/cylinder.js +2 -2
  22. package/lib/dist/features/plane-from-object.d.ts +1 -1
  23. package/lib/dist/features/plane-from-object.js +11 -6
  24. package/lib/dist/features/plane-mid.d.ts +1 -1
  25. package/lib/dist/features/plane.d.ts +1 -1
  26. package/lib/dist/features/select.d.ts +1 -1
  27. package/lib/dist/features/select.js +1 -1
  28. package/lib/dist/features/sphere.d.ts +2 -2
  29. package/lib/dist/features/sphere.js +2 -2
  30. package/lib/dist/math/index.d.ts +1 -1
  31. package/lib/dist/math/plane.d.ts +1 -2
  32. package/lib/dist/math/plane.js +20 -19
  33. package/lib/dist/tests/features/cut-two-distances.test.js +1 -1
  34. package/lib/dist/tests/features/cut.test.js +1 -1
  35. package/lib/dist/tests/features/primitive-chain.test.js +45 -0
  36. package/lib/dist/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/ui/dist/assets/{index-D2eOzshJ.js → index-BeLxRMCv.js} +1 -1
  39. package/ui/dist/index.html +1 -1
  40. package/lib/dist/tests/features/scene-object-chain.test.js +0 -64
  41. /package/lib/dist/tests/features/{scene-object-chain.test.d.ts → primitive-chain.test.d.ts} +0 -0
@@ -0,0 +1,45 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { setupOC, render } from "../setup.js";
3
+ import sphere from "../../core/sphere.js";
4
+ import cylinder from "../../core/cylinder.js";
5
+ import { ShapeOps } from "../../oc/shape-ops.js";
6
+ describe("chained transforms on primitive shapes", () => {
7
+ setupOC();
8
+ it("applies .translate() on a cylinder", () => {
9
+ const c = cylinder(5, 10).translate(20, 0, 0);
10
+ render();
11
+ const shapes = c.getShapes();
12
+ expect(shapes).toHaveLength(1);
13
+ const bbox = ShapeOps.getBoundingBox(shapes[0]);
14
+ expect(bbox.minX).toBeCloseTo(15, 0);
15
+ expect(bbox.maxX).toBeCloseTo(25, 0);
16
+ });
17
+ it("composes chained transforms left-to-right on a sphere", () => {
18
+ const s = sphere(1).translate(5, 0, 0).rotate("z", 90);
19
+ render();
20
+ const shapes = s.getShapes();
21
+ const bbox = ShapeOps.getBoundingBox(shapes[0]);
22
+ const cx = (bbox.minX + bbox.maxX) / 2;
23
+ const cy = (bbox.minY + bbox.maxY) / 2;
24
+ expect(cx).toBeCloseTo(0, 1);
25
+ expect(cy).toBeCloseTo(5, 1);
26
+ });
27
+ it("accepts a PointLike array in .translate()", () => {
28
+ const s = sphere(1).translate([7, 8, 9]);
29
+ render();
30
+ const bbox = ShapeOps.getBoundingBox(s.getShapes()[0]);
31
+ const cx = (bbox.minX + bbox.maxX) / 2;
32
+ const cy = (bbox.minY + bbox.maxY) / 2;
33
+ const cz = (bbox.minZ + bbox.maxZ) / 2;
34
+ expect(cx).toBeCloseTo(7, 1);
35
+ expect(cy).toBeCloseTo(8, 1);
36
+ expect(cz).toBeCloseTo(9, 1);
37
+ });
38
+ it("chained .mirror() across a plane", () => {
39
+ const c = cylinder(5, 10).translate(15, 0, 0).mirror("yz");
40
+ render();
41
+ const bbox = ShapeOps.getBoundingBox(c.getShapes()[0]);
42
+ expect(bbox.maxX).toBeCloseTo(-10, 0);
43
+ expect(bbox.minX).toBeCloseTo(-20, 0);
44
+ });
45
+ });