fluidcad 0.0.3 → 0.0.4

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 (123) hide show
  1. package/README.md +2 -2
  2. package/lib/dist/common/shape-factory.d.ts +1 -1
  3. package/lib/dist/oc/boolean-ops.d.ts +2 -2
  4. package/lib/dist/tsconfig.tsbuildinfo +1 -1
  5. package/package.json +3 -2
  6. package/lib/dist/constraints/constraint.d.ts +0 -11
  7. package/lib/dist/constraints/constraint.js +0 -51
  8. package/lib/dist/constraints/outside.d.ts +0 -3
  9. package/lib/dist/constraints/outside.js +0 -4
  10. package/lib/dist/core/2d/aslot.d.ts +0 -12
  11. package/lib/dist/core/2d/aslot.js +0 -40
  12. package/lib/dist/core/2d/crect.d.ts +0 -12
  13. package/lib/dist/core/2d/crect.js +0 -74
  14. package/lib/dist/core/2d/face-maker.d.ts +0 -13
  15. package/lib/dist/core/2d/face-maker.js +0 -119
  16. package/lib/dist/core/2d/face-maker2.d.ts +0 -6
  17. package/lib/dist/core/2d/face-maker2.js +0 -54
  18. package/lib/dist/core/region.d.ts +0 -13
  19. package/lib/dist/core/region.js +0 -18
  20. package/lib/dist/features/2d/amove.d.ts +0 -14
  21. package/lib/dist/features/2d/amove.js +0 -33
  22. package/lib/dist/features/2d/constraints/constraint.d.ts +0 -11
  23. package/lib/dist/features/2d/constraints/constraint.js +0 -49
  24. package/lib/dist/features/2d/constraints/outside.d.ts +0 -3
  25. package/lib/dist/features/2d/constraints/outside.js +0 -4
  26. package/lib/dist/features/2d/tarc-two-circles.d.ts +0 -18
  27. package/lib/dist/features/2d/tarc-two-circles.js +0 -61
  28. package/lib/dist/features/2d/tcircle-three-tan.d.ts +0 -13
  29. package/lib/dist/features/2d/tcircle-three-tan.js +0 -33
  30. package/lib/dist/features/2d/tcircle-two-tan.d.ts +0 -13
  31. package/lib/dist/features/2d/tcircle-two-tan.js +0 -33
  32. package/lib/dist/features/Extrude.d.ts +0 -1
  33. package/lib/dist/features/Extrude.js +0 -1
  34. package/lib/dist/features/cut-base.d.ts +0 -49
  35. package/lib/dist/features/cut-base.js +0 -312
  36. package/lib/dist/features/cut-symmetric.d.ts +0 -23
  37. package/lib/dist/features/cut-symmetric.js +0 -119
  38. package/lib/dist/features/cut-two-distances.d.ts +0 -24
  39. package/lib/dist/features/cut-two-distances.js +0 -110
  40. package/lib/dist/features/cut.d.ts +0 -27
  41. package/lib/dist/features/cut.js +0 -101
  42. package/lib/dist/features/extrude-symmetric.d.ts +0 -28
  43. package/lib/dist/features/extrude-symmetric.js +0 -177
  44. package/lib/dist/features/region2d.d.ts +0 -25
  45. package/lib/dist/features/region2d.js +0 -185
  46. package/lib/dist/features/repeat-circular2d.d.ts +0 -17
  47. package/lib/dist/features/repeat-circular2d.js +0 -90
  48. package/lib/dist/features/repeat-linear2d.d.ts +0 -17
  49. package/lib/dist/features/repeat-linear2d.js +0 -114
  50. package/lib/dist/features/revolve-options.d.ts +0 -6
  51. package/lib/dist/features/revolve-options.js +0 -1
  52. package/lib/dist/features/split.d.ts +0 -14
  53. package/lib/dist/features/split.js +0 -74
  54. package/lib/dist/features/state-scene-object.d.ts +0 -15
  55. package/lib/dist/features/state-scene-object.js +0 -44
  56. package/lib/dist/features/state-select.d.ts +0 -21
  57. package/lib/dist/features/state-select.js +0 -73
  58. package/lib/dist/features/translate2d.d.ts +0 -16
  59. package/lib/dist/features/translate2d.js +0 -61
  60. package/lib/dist/filters/all-filter.d.ts +0 -8
  61. package/lib/dist/filters/all-filter.js +0 -12
  62. package/lib/dist/filters/near-point-filter.d.ts +0 -11
  63. package/lib/dist/filters/near-point-filter.js +0 -33
  64. package/lib/dist/helpers/resolve-filters.d.ts +0 -6
  65. package/lib/dist/helpers/resolve-filters.js +0 -25
  66. package/lib/dist/math/axis.test.d.ts +0 -1
  67. package/lib/dist/math/axis.test.js +0 -287
  68. package/lib/dist/math/coordinate-system.test.d.ts +0 -1
  69. package/lib/dist/math/coordinate-system.test.js +0 -308
  70. package/lib/dist/math/matrix4.test.d.ts +0 -1
  71. package/lib/dist/math/matrix4.test.js +0 -357
  72. package/lib/dist/math/plane.test.d.ts +0 -1
  73. package/lib/dist/math/plane.test.js +0 -398
  74. package/lib/dist/math/point.test.d.ts +0 -1
  75. package/lib/dist/math/point.test.js +0 -385
  76. package/lib/dist/math/quaternion.test.d.ts +0 -1
  77. package/lib/dist/math/quaternion.test.js +0 -278
  78. package/lib/dist/math/vector3d.test.d.ts +0 -1
  79. package/lib/dist/math/vector3d.test.js +0 -276
  80. package/lib/dist/oc/constraint-resolver.d.ts +0 -7
  81. package/lib/dist/oc/constraint-resolver.js +0 -31
  82. package/lib/dist/oc/constraints/curve-constraint-solver.d.ts +0 -1
  83. package/lib/dist/oc/constraints/curve-constraint-solver.js +0 -2
  84. package/lib/dist/oc/constraints/geometric-constraint-solver.d.ts +0 -1
  85. package/lib/dist/oc/constraints/geometric-constraint-solver.js +0 -5
  86. package/lib/dist/oc/face-maker.d.ts +0 -14
  87. package/lib/dist/oc/face-maker.js +0 -191
  88. package/lib/dist/oc/measure.d.ts +0 -21
  89. package/lib/dist/oc/measure.js +0 -256
  90. package/lib/dist/oc/tangent-circle-solver.d.ts +0 -17
  91. package/lib/dist/oc/tangent-circle-solver.js +0 -72
  92. package/lib/dist/oc/tangent-line-solver.d.ts +0 -17
  93. package/lib/dist/oc/tangent-line-solver.js +0 -83
  94. package/lib/dist/oc/tangent-solver.d.ts +0 -14
  95. package/lib/dist/oc/tangent-solver.js +0 -199
  96. package/lib/dist/rendering/builder-context.d.ts +0 -16
  97. package/lib/dist/rendering/builder-context.js +0 -63
  98. package/lib/dist/tests/extrude.test.d.ts +0 -1
  99. package/lib/dist/tests/extrude.test.js +0 -48
  100. package/lib/dist/tests/features/copy.test.d.ts +0 -1
  101. package/lib/dist/tests/features/copy.test.js +0 -158
  102. package/lib/dist/tests/features/dispose.test.d.ts +0 -1
  103. package/lib/dist/tests/features/dispose.test.js +0 -189
  104. package/lib/dist/tests/features/part-pick.test.d.ts +0 -1
  105. package/lib/dist/tests/features/part-pick.test.js +0 -73
  106. package/lib/dist/tests/features/part-repeat.test.d.ts +0 -1
  107. package/lib/dist/tests/features/part-repeat.test.js +0 -109
  108. package/server/dist/fluidcad-server.d.ts +0 -32
  109. package/server/dist/fluidcad-server.js +0 -150
  110. package/server/dist/index.d.ts +0 -1
  111. package/server/dist/index.js +0 -290
  112. package/server/dist/routes/actions.d.ts +0 -3
  113. package/server/dist/routes/actions.js +0 -100
  114. package/server/dist/routes/export.d.ts +0 -3
  115. package/server/dist/routes/export.js +0 -55
  116. package/server/dist/routes/properties.d.ts +0 -3
  117. package/server/dist/routes/properties.js +0 -46
  118. package/server/dist/routes/screenshot.d.ts +0 -2
  119. package/server/dist/routes/screenshot.js +0 -76
  120. package/server/dist/vite-manager.d.ts +0 -10
  121. package/server/dist/vite-manager.js +0 -64
  122. package/server/dist/ws-protocol.d.ts +0 -138
  123. package/server/dist/ws-protocol.js +0 -4
@@ -1,398 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { Plane, toPlane, isPlaneLike } from "./plane.js";
3
- import { Point, Point2D } from "./point.js";
4
- import { Vector3d } from "./vector3d.js";
5
- import { Axis } from "./axis.js";
6
- describe("Plane", () => {
7
- describe("constructor", () => {
8
- it("creates plane with origin, xDirection, and normal", () => {
9
- const origin = new Point(1, 2, 3);
10
- const xDir = Vector3d.unitX();
11
- const normal = Vector3d.unitZ();
12
- const plane = new Plane(origin, xDir, normal);
13
- expect(plane.origin.equals(origin)).toBe(true);
14
- expect(plane.xDirection.equals(xDir)).toBe(true);
15
- expect(plane.normal.equals(normal)).toBe(true);
16
- });
17
- it("computes yDirection automatically", () => {
18
- const plane = Plane.XY();
19
- expect(plane.yDirection.x).toBeCloseTo(0);
20
- expect(plane.yDirection.y).toBeCloseTo(1);
21
- expect(plane.yDirection.z).toBeCloseTo(0);
22
- });
23
- it("creates axes", () => {
24
- const plane = Plane.XY();
25
- expect(plane.xAxis).toBeInstanceOf(Axis);
26
- expect(plane.yAxis).toBeInstanceOf(Axis);
27
- expect(plane.zAxis).toBeInstanceOf(Axis);
28
- });
29
- });
30
- describe("standard planes", () => {
31
- it("XY plane at origin with Z normal", () => {
32
- const plane = Plane.XY();
33
- expect(plane.origin.equals(Point.origin())).toBe(true);
34
- expect(plane.normal.equals(Vector3d.unitZ())).toBe(true);
35
- expect(plane.xDirection.equals(Vector3d.unitX())).toBe(true);
36
- });
37
- it("XZ plane at origin with -Y normal", () => {
38
- const plane = Plane.XZ();
39
- expect(plane.origin.equals(Point.origin())).toBe(true);
40
- expect(plane.normal.y).toBeCloseTo(-1);
41
- });
42
- it("YZ plane at origin with X normal", () => {
43
- const plane = Plane.YZ();
44
- expect(plane.origin.equals(Point.origin())).toBe(true);
45
- expect(plane.normal.equals(Vector3d.unitX())).toBe(true);
46
- });
47
- });
48
- describe("worldToLocal", () => {
49
- it("converts world point to local 2D coordinates", () => {
50
- const plane = Plane.XY();
51
- const worldPoint = new Point(3, 4, 0);
52
- const local = plane.worldToLocal(worldPoint);
53
- expect(local.x).toBeCloseTo(3);
54
- expect(local.y).toBeCloseTo(4);
55
- });
56
- it("ignores z component for XY plane", () => {
57
- const plane = Plane.XY();
58
- const worldPoint = new Point(3, 4, 100);
59
- const local = plane.worldToLocal(worldPoint);
60
- expect(local.x).toBeCloseTo(3);
61
- expect(local.y).toBeCloseTo(4);
62
- });
63
- it("works with offset plane", () => {
64
- const plane = new Plane(new Point(10, 20, 0), Vector3d.unitX(), Vector3d.unitZ());
65
- const worldPoint = new Point(15, 25, 0);
66
- const local = plane.worldToLocal(worldPoint);
67
- expect(local.x).toBeCloseTo(5);
68
- expect(local.y).toBeCloseTo(5);
69
- });
70
- });
71
- describe("localToWorld", () => {
72
- it("converts local 2D coordinates to world point", () => {
73
- const plane = Plane.XY();
74
- const local = new Point2D(3, 4);
75
- const world = plane.localToWorld(local);
76
- expect(world.x).toBeCloseTo(3);
77
- expect(world.y).toBeCloseTo(4);
78
- expect(world.z).toBeCloseTo(0);
79
- });
80
- it("works with offset plane", () => {
81
- const plane = new Plane(new Point(10, 20, 30), Vector3d.unitX(), Vector3d.unitZ());
82
- const local = new Point2D(5, 5);
83
- const world = plane.localToWorld(local);
84
- expect(world.x).toBeCloseTo(15);
85
- expect(world.y).toBeCloseTo(25);
86
- expect(world.z).toBeCloseTo(30);
87
- });
88
- });
89
- describe("worldToLocal and localToWorld roundtrip", () => {
90
- it("roundtrip returns original point (on plane)", () => {
91
- const plane = Plane.XY();
92
- const original = new Point(7, 11, 0);
93
- const local = plane.worldToLocal(original);
94
- const back = plane.localToWorld(local);
95
- expect(back.x).toBeCloseTo(original.x);
96
- expect(back.y).toBeCloseTo(original.y);
97
- expect(back.z).toBeCloseTo(original.z);
98
- });
99
- it("roundtrip works with rotated plane", () => {
100
- const plane = new Plane(Point.origin(), new Vector3d(1, 1, 0).normalize(), Vector3d.unitZ());
101
- const local = new Point2D(5, 3);
102
- const world = plane.localToWorld(local);
103
- const backToLocal = plane.worldToLocal(world);
104
- expect(backToLocal.x).toBeCloseTo(local.x);
105
- expect(backToLocal.y).toBeCloseTo(local.y);
106
- });
107
- });
108
- describe("offset", () => {
109
- it("offsets plane along normal", () => {
110
- const plane = Plane.XY();
111
- const offset = plane.offset(10);
112
- expect(offset.origin.z).toBe(10);
113
- expect(offset.normal.equals(plane.normal)).toBe(true);
114
- });
115
- it("negative offset moves in opposite direction", () => {
116
- const plane = Plane.XY();
117
- const offset = plane.offset(-5);
118
- expect(offset.origin.z).toBe(-5);
119
- });
120
- });
121
- describe("transform", () => {
122
- it("applies offset", () => {
123
- const plane = Plane.XY();
124
- const transformed = plane.transform({ offset: 10 });
125
- expect(transformed.origin.z).toBeCloseTo(10);
126
- });
127
- it("applies rotation around X", () => {
128
- const plane = Plane.XY();
129
- const transformed = plane.transform({ rotateX: 90 });
130
- // Rotating (0,0,1) by 90° around X gives (0,-1,0) in right-hand convention
131
- expect(transformed.normal.y).toBeCloseTo(-1);
132
- expect(transformed.normal.z).toBeCloseTo(0);
133
- });
134
- it("applies rotation around Z", () => {
135
- const plane = Plane.XY();
136
- const transformed = plane.transform({ rotateZ: 90 });
137
- expect(transformed.xDirection.x).toBeCloseTo(0);
138
- expect(transformed.xDirection.y).toBeCloseTo(1);
139
- });
140
- it("combines transformations without gimbal lock", () => {
141
- const plane = Plane.XY();
142
- // 90° Y rotation would cause gimbal lock with sequential Euler angles
143
- const transformed = plane.transform({
144
- rotateX: 45,
145
- rotateY: 90,
146
- rotateZ: 45,
147
- });
148
- // Should complete without issues and produce valid plane
149
- expect(transformed.normal.length()).toBeCloseTo(1);
150
- expect(transformed.xDirection.length()).toBeCloseTo(1);
151
- });
152
- });
153
- describe("translate", () => {
154
- it("translates plane origin", () => {
155
- const plane = Plane.XY();
156
- const translated = plane.translate(1, 2, 3);
157
- expect(translated.origin.x).toBe(1);
158
- expect(translated.origin.y).toBe(2);
159
- expect(translated.origin.z).toBe(3);
160
- expect(translated.normal.equals(plane.normal)).toBe(true);
161
- });
162
- });
163
- describe("translateVector", () => {
164
- it("translates by vector", () => {
165
- const plane = Plane.XY();
166
- const translated = plane.translateVector(new Vector3d(5, 10, 15));
167
- expect(translated.origin.x).toBe(5);
168
- expect(translated.origin.y).toBe(10);
169
- expect(translated.origin.z).toBe(15);
170
- });
171
- });
172
- describe("rotateAroundAxis", () => {
173
- it("rotates plane around axis", () => {
174
- const plane = Plane.XY();
175
- const axis = Axis.X();
176
- const rotated = plane.rotateAroundAxis(axis, Math.PI / 2);
177
- // Rotating (0,0,1) by π/2 around X gives (0,-1,0) in right-hand convention
178
- expect(rotated.normal.y).toBeCloseTo(-1);
179
- expect(rotated.normal.z).toBeCloseTo(0);
180
- });
181
- });
182
- describe("projectPoint", () => {
183
- it("projects point onto plane", () => {
184
- const plane = Plane.XY();
185
- const point = new Point(3, 4, 10);
186
- const projected = plane.projectPoint(point);
187
- expect(projected.x).toBeCloseTo(3);
188
- expect(projected.y).toBeCloseTo(4);
189
- expect(projected.z).toBeCloseTo(0);
190
- });
191
- });
192
- describe("distanceToPoint", () => {
193
- it("returns absolute distance to plane", () => {
194
- const plane = Plane.XY();
195
- expect(plane.distanceToPoint(new Point(0, 0, 5))).toBe(5);
196
- expect(plane.distanceToPoint(new Point(0, 0, -5))).toBe(5);
197
- });
198
- });
199
- describe("signedDistanceToPoint", () => {
200
- it("returns positive distance for point above plane", () => {
201
- const plane = Plane.XY();
202
- expect(plane.signedDistanceToPoint(new Point(0, 0, 5))).toBe(5);
203
- });
204
- it("returns negative distance for point below plane", () => {
205
- const plane = Plane.XY();
206
- expect(plane.signedDistanceToPoint(new Point(0, 0, -5))).toBe(-5);
207
- });
208
- });
209
- describe("containsPoint", () => {
210
- it("returns true for point on plane", () => {
211
- const plane = Plane.XY();
212
- expect(plane.containsPoint(new Point(5, 5, 0))).toBe(true);
213
- });
214
- it("returns false for point off plane", () => {
215
- const plane = Plane.XY();
216
- expect(plane.containsPoint(new Point(5, 5, 1))).toBe(false);
217
- });
218
- it("supports tolerance", () => {
219
- const plane = Plane.XY();
220
- expect(plane.containsPoint(new Point(5, 5, 0.001), 0.01)).toBe(true);
221
- });
222
- });
223
- describe("isParallelTo", () => {
224
- it("returns true for parallel planes", () => {
225
- const p1 = Plane.XY();
226
- const p2 = Plane.XY().offset(10);
227
- expect(p1.isParallelTo(p2)).toBe(true);
228
- });
229
- it("returns false for non-parallel planes", () => {
230
- const p1 = Plane.XY();
231
- const p2 = Plane.XZ();
232
- expect(p1.isParallelTo(p2)).toBe(false);
233
- });
234
- });
235
- describe("isCoplanarWith", () => {
236
- it("returns true for same plane", () => {
237
- const p1 = Plane.XY();
238
- const p2 = new Plane(new Point(5, 5, 0), Vector3d.unitX(), Vector3d.unitZ());
239
- expect(p1.isCoplanarWith(p2)).toBe(true);
240
- });
241
- it("returns false for parallel but offset planes", () => {
242
- const p1 = Plane.XY();
243
- const p2 = Plane.XY().offset(10);
244
- expect(p1.isCoplanarWith(p2)).toBe(false);
245
- });
246
- });
247
- describe("reverse", () => {
248
- it("reverses normal and xDirection", () => {
249
- const plane = Plane.XY();
250
- const reversed = plane.reverse();
251
- expect(reversed.normal.z).toBe(-1);
252
- expect(reversed.xDirection.x).toBe(-1);
253
- });
254
- });
255
- describe("mirror methods", () => {
256
- it("mirrorAroundPoint mirrors through point", () => {
257
- const plane = new Plane(new Point(2, 0, 0), Vector3d.unitX(), Vector3d.unitZ());
258
- const mirrored = plane.mirrorAroundPoint(Point.origin());
259
- expect(mirrored.origin.x).toBeCloseTo(-2);
260
- });
261
- it("mirrorAroundPlane mirrors through plane", () => {
262
- const plane = Plane.XY().offset(5);
263
- const mirrored = plane.mirrorAroundPlane(Vector3d.unitZ(), Point.origin());
264
- expect(mirrored.origin.z).toBeCloseTo(-5);
265
- });
266
- it("mirrorAroundAxis mirrors through axis", () => {
267
- const plane = new Plane(new Point(2, 0, 0), Vector3d.unitY(), Vector3d.unitZ());
268
- const mirrored = plane.mirrorAroundAxis(Axis.Z());
269
- expect(mirrored.origin.x).toBeCloseTo(-2);
270
- });
271
- it("mirrorAroundPlane preserves yDirection when it has no component along mirror normal", () => {
272
- // Mirror XY plane around YZ plane (flip X)
273
- // yDirection (0,1,0) has no X component, so it should stay (0,1,0)
274
- const plane = Plane.XY();
275
- const mirrored = plane.mirrorAroundPlane(Vector3d.unitX(), Point.origin());
276
- expect(mirrored.yDirection.x).toBeCloseTo(0);
277
- expect(mirrored.yDirection.y).toBeCloseTo(1);
278
- expect(mirrored.yDirection.z).toBeCloseTo(0);
279
- });
280
- it("mirrorAroundPlane gives correct localToWorld after mirror", () => {
281
- // Mirror XY plane around YZ plane (flip X)
282
- // A point at local (0, 5) should map to world (0, 5, 0), not (0, -5, 0)
283
- const plane = Plane.XY();
284
- const mirrored = plane.mirrorAroundPlane(Vector3d.unitX(), Point.origin());
285
- const world = mirrored.localToWorld(new Point2D(0, 5));
286
- expect(world.x).toBeCloseTo(0);
287
- expect(world.y).toBeCloseTo(5);
288
- expect(world.z).toBeCloseTo(0);
289
- });
290
- it("mirrorAroundPlane flips yDirection when it has a component along mirror normal", () => {
291
- // Mirror XY plane around XZ plane (flip Y)
292
- // yDirection (0,1,0) has Y component, so it should become (0,-1,0)
293
- const plane = Plane.XY();
294
- const mirrored = plane.mirrorAroundPlane(Vector3d.unitY(), Point.origin());
295
- expect(mirrored.yDirection.x).toBeCloseTo(0);
296
- expect(mirrored.yDirection.y).toBeCloseTo(-1);
297
- expect(mirrored.yDirection.z).toBeCloseTo(0);
298
- });
299
- });
300
- describe("normalizeAxis", () => {
301
- it("returns xAxis for 'x'", () => {
302
- const plane = Plane.XY();
303
- const axis = plane.normalizeAxis("x");
304
- expect(axis).toBe(plane.xAxis);
305
- });
306
- it("returns yAxis for 'y'", () => {
307
- const plane = Plane.XY();
308
- const axis = plane.normalizeAxis("y");
309
- expect(axis).toBe(plane.yAxis);
310
- });
311
- it("returns zAxis for 'z'", () => {
312
- const plane = Plane.XY();
313
- const axis = plane.normalizeAxis("z");
314
- expect(axis).toBe(plane.zAxis);
315
- });
316
- it("returns same axis for Axis input", () => {
317
- const plane = Plane.XY();
318
- const input = new Axis(Point.origin(), Vector3d.unitX());
319
- const axis = plane.normalizeAxis(input);
320
- expect(axis).toBe(input);
321
- });
322
- });
323
- describe("compareTo", () => {
324
- it("returns true for identical planes", () => {
325
- const p1 = Plane.XY();
326
- const p2 = Plane.XY();
327
- expect(p1.compareTo(p2)).toBe(true);
328
- });
329
- it("returns false for different planes", () => {
330
- const p1 = Plane.XY();
331
- const p2 = Plane.XY().offset(1);
332
- expect(p1.compareTo(p2)).toBe(false);
333
- });
334
- });
335
- describe("fromPointAndNormal", () => {
336
- it("creates plane from point and normal", () => {
337
- const point = new Point(1, 2, 3);
338
- const normal = Vector3d.unitZ();
339
- const plane = Plane.fromPointAndNormal(point, normal);
340
- expect(plane.origin.equals(point)).toBe(true);
341
- expect(plane.normal.z).toBeCloseTo(1);
342
- });
343
- });
344
- describe("fromThreePoints", () => {
345
- it("creates plane from three points", () => {
346
- const p1 = new Point(0, 0, 0);
347
- const p2 = new Point(1, 0, 0);
348
- const p3 = new Point(0, 1, 0);
349
- const plane = Plane.fromThreePoints(p1, p2, p3);
350
- expect(plane.origin.equals(p1)).toBe(true);
351
- expect(plane.normal.z).toBeCloseTo(1);
352
- });
353
- });
354
- describe("clone", () => {
355
- it("creates independent copy", () => {
356
- const plane = Plane.XY();
357
- const clone = plane.clone();
358
- expect(clone.compareTo(plane)).toBe(true);
359
- expect(clone).not.toBe(plane);
360
- });
361
- });
362
- });
363
- describe("helper functions", () => {
364
- describe("toPlane", () => {
365
- it("returns same instance for Plane", () => {
366
- const plane = Plane.XY();
367
- expect(toPlane(plane)).toBe(plane);
368
- });
369
- it("converts 'xy' to XY plane", () => {
370
- const plane = toPlane("xy");
371
- expect(plane.normal.z).toBeCloseTo(1);
372
- });
373
- it("converts 'top' to XY plane", () => {
374
- const plane = toPlane("top");
375
- expect(plane.normal.z).toBeCloseTo(1);
376
- });
377
- it("converts '-xy' to reversed XY plane", () => {
378
- const plane = toPlane("-xy");
379
- expect(plane.normal.z).toBeCloseTo(-1);
380
- });
381
- });
382
- describe("isPlaneLike", () => {
383
- it("returns true for Plane", () => {
384
- expect(isPlaneLike(Plane.XY())).toBe(true);
385
- });
386
- it("returns true for standard plane strings", () => {
387
- expect(isPlaneLike("xy")).toBe(true);
388
- expect(isPlaneLike("xz")).toBe(true);
389
- expect(isPlaneLike("yz")).toBe(true);
390
- expect(isPlaneLike("top")).toBe(true);
391
- expect(isPlaneLike("bottom")).toBe(true);
392
- });
393
- it("returns false for other values", () => {
394
- expect(isPlaneLike("abc")).toBe(false);
395
- expect(isPlaneLike(123)).toBe(false);
396
- });
397
- });
398
- });
@@ -1 +0,0 @@
1
- export {};