@snaptrude/plugin-core 0.0.5 → 0.0.7

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 (63) hide show
  1. package/dist/api/core/geom/arc.d.ts +50 -1
  2. package/dist/api/core/geom/arc.d.ts.map +1 -1
  3. package/dist/api/core/geom/curve.d.ts +26 -1
  4. package/dist/api/core/geom/curve.d.ts.map +1 -1
  5. package/dist/api/core/geom/index.d.ts +16 -0
  6. package/dist/api/core/geom/index.d.ts.map +1 -1
  7. package/dist/api/core/geom/line.d.ts +35 -1
  8. package/dist/api/core/geom/line.d.ts.map +1 -1
  9. package/dist/api/core/geom/profile.d.ts +66 -2
  10. package/dist/api/core/geom/profile.d.ts.map +1 -1
  11. package/dist/api/core/index.d.ts +8 -0
  12. package/dist/api/core/index.d.ts.map +1 -1
  13. package/dist/api/core/math/index.d.ts +8 -0
  14. package/dist/api/core/math/index.d.ts.map +1 -1
  15. package/dist/api/core/math/quat.d.ts +156 -15
  16. package/dist/api/core/math/quat.d.ts.map +1 -1
  17. package/dist/api/core/math/vec3.d.ts +131 -14
  18. package/dist/api/core/math/vec3.d.ts.map +1 -1
  19. package/dist/api/entity/index.d.ts +13 -0
  20. package/dist/api/entity/index.d.ts.map +1 -1
  21. package/dist/api/entity/referenceLine.d.ts +259 -0
  22. package/dist/api/entity/referenceLine.d.ts.map +1 -0
  23. package/dist/api/entity/space.d.ts +467 -7
  24. package/dist/api/entity/space.d.ts.map +1 -1
  25. package/dist/api/entity/story.d.ts +166 -0
  26. package/dist/api/entity/story.d.ts.map +1 -1
  27. package/dist/api/index.d.ts +14 -0
  28. package/dist/api/index.d.ts.map +1 -1
  29. package/dist/api/tools/index.d.ts +8 -0
  30. package/dist/api/tools/index.d.ts.map +1 -1
  31. package/dist/api/tools/selection.d.ts +37 -0
  32. package/dist/api/tools/selection.d.ts.map +1 -1
  33. package/dist/api/tools/transform.d.ts +82 -0
  34. package/dist/api/tools/transform.d.ts.map +1 -1
  35. package/dist/api/units/index.d.ts +81 -13
  36. package/dist/api/units/index.d.ts.map +1 -1
  37. package/dist/index.cjs +547 -126
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.js +533 -126
  40. package/dist/index.js.map +1 -1
  41. package/dist/types.d.ts +8 -1
  42. package/dist/types.d.ts.map +1 -1
  43. package/package.json +2 -2
  44. package/src/api/core/geom/arc.ts +50 -1
  45. package/src/api/core/geom/curve.ts +26 -1
  46. package/src/api/core/geom/index.ts +16 -0
  47. package/src/api/core/geom/line.ts +35 -1
  48. package/src/api/core/geom/profile.ts +66 -2
  49. package/src/api/core/index.ts +8 -0
  50. package/src/api/core/math/index.ts +8 -0
  51. package/src/api/core/math/quat.ts +156 -15
  52. package/src/api/core/math/vec3.ts +131 -14
  53. package/src/api/entity/index.ts +13 -0
  54. package/src/api/entity/referenceLine.ts +215 -0
  55. package/src/api/entity/space.ts +447 -11
  56. package/src/api/entity/story.ts +166 -0
  57. package/src/api/index.ts +14 -0
  58. package/src/api/tools/index.ts +8 -0
  59. package/src/api/tools/selection.ts +37 -0
  60. package/src/api/tools/transform.ts +82 -0
  61. package/src/api/units/index.ts +81 -13
  62. package/src/types.ts +8 -1
  63. package/tsup.config.ts +0 -1
package/dist/index.js CHANGED
@@ -3,27 +3,78 @@ import * as z from "zod";
3
3
  var PluginVec3Api = class {
4
4
  constructor() {
5
5
  }
6
- /** Create a new PVec3. */
7
- new(x, y, z12) {
8
- return { x, y, z: z12 };
9
- }
10
- /** Add two vectors. */
6
+ /**
7
+ * Create a new 3D vector.
8
+ *
9
+ * @param x - The X component
10
+ * @param y - The Y component
11
+ * @param z - The Z component
12
+ * @returns A new {@linkcode PVec3}
13
+ *
14
+ * # Example
15
+ * ```ts
16
+ * const position = snaptrude.core.math.vec3.new(1, 2, 3)
17
+ * // { x: 1, y: 2, z: 3 }
18
+ * ```
19
+ */
20
+ new(x, y, z13) {
21
+ return { x, y, z: z13 };
22
+ }
23
+ /**
24
+ * Add two vectors component-wise.
25
+ *
26
+ * @param a - First vector
27
+ * @param b - Second vector
28
+ * @returns A new {@linkcode PVec3} where each component is `a[i] + b[i]`
29
+ */
11
30
  add(a, b) {
12
31
  return { x: a.x + b.x, y: a.y + b.y, z: a.z + b.z };
13
32
  }
14
- /** Subtract b from a. */
33
+ /**
34
+ * Subtract vector {@linkcode b} from vector {@linkcode a} component-wise.
35
+ *
36
+ * @param a - Vector to subtract from
37
+ * @param b - Vector to subtract
38
+ * @returns A new {@linkcode PVec3} where each component is `a[i] - b[i]`
39
+ */
15
40
  subtract(a, b) {
16
41
  return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
17
42
  }
18
- /** Scale a vector by a scalar. */
43
+ /**
44
+ * Scale a vector by a scalar value.
45
+ *
46
+ * @param v - The vector to scale
47
+ * @param scalar - The scalar multiplier
48
+ * @returns A new {@linkcode PVec3} where each component is `v[i] * scalar`
49
+ */
19
50
  scale(v, scalar) {
20
51
  return { x: v.x * scalar, y: v.y * scalar, z: v.z * scalar };
21
52
  }
22
- /** Dot product of two vectors. */
53
+ /**
54
+ * Compute the dot product of two vectors.
55
+ *
56
+ * The dot product equals `|a| * |b| * cos(θ)` where `θ` is the angle
57
+ * between the vectors. Useful for checking orthogonality (result = 0)
58
+ * or projection.
59
+ *
60
+ * @param a - First vector
61
+ * @param b - Second vector
62
+ * @returns The scalar dot product
63
+ */
23
64
  dot(a, b) {
24
65
  return a.x * b.x + a.y * b.y + a.z * b.z;
25
66
  }
26
- /** Cross product of two vectors. */
67
+ /**
68
+ * Compute the cross product of two vectors.
69
+ *
70
+ * The result is a vector perpendicular to both inputs, with magnitude
71
+ * equal to the area of the parallelogram they span. Useful for computing
72
+ * surface normals.
73
+ *
74
+ * @param a - First vector
75
+ * @param b - Second vector
76
+ * @returns A new {@linkcode PVec3} perpendicular to both {@linkcode a} and {@linkcode b}
77
+ */
27
78
  cross(a, b) {
28
79
  return {
29
80
  x: a.y * b.z - a.z * b.y,
@@ -31,25 +82,57 @@ var PluginVec3Api = class {
31
82
  z: a.x * b.y - a.y * b.x
32
83
  };
33
84
  }
34
- /** Length (magnitude) of a vector. */
85
+ /**
86
+ * Compute the length (magnitude) of a vector.
87
+ *
88
+ * @param v - The vector
89
+ * @returns The Euclidean length `√(x² + y² + z²)`
90
+ */
35
91
  length(v) {
36
92
  return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
37
93
  }
38
- /** Squared length of a vector (avoids sqrt). */
94
+ /**
95
+ * Compute the squared length of a vector.
96
+ *
97
+ * Avoids the `sqrt` call — prefer this over {@linkcode PluginVec3Api.length}
98
+ * when comparing relative magnitudes.
99
+ *
100
+ * @param v - The vector
101
+ * @returns The squared length `x² + y² + z²`
102
+ */
39
103
  lengthSquared(v) {
40
104
  return v.x * v.x + v.y * v.y + v.z * v.z;
41
105
  }
42
- /** Normalize a vector to unit length. Returns zero vector if length is 0. */
106
+ /**
107
+ * Normalize a vector to unit length.
108
+ *
109
+ * @param v - The vector to normalize
110
+ * @returns A new unit-length {@linkcode PVec3} in the same direction,
111
+ * or a zero vector `(0, 0, 0)` if the input has zero length
112
+ */
43
113
  normalize(v) {
44
114
  const len = this.length(v);
45
115
  if (len === 0) return { x: 0, y: 0, z: 0 };
46
116
  return { x: v.x / len, y: v.y / len, z: v.z / len };
47
117
  }
48
- /** Distance between two points. */
118
+ /**
119
+ * Compute the Euclidean distance between two points.
120
+ *
121
+ * @param a - First point
122
+ * @param b - Second point
123
+ * @returns The distance `|a - b|`
124
+ */
49
125
  distance(a, b) {
50
126
  return this.length(this.subtract(a, b));
51
127
  }
52
- /** Linearly interpolate between two vectors. */
128
+ /**
129
+ * Linearly interpolate between two vectors.
130
+ *
131
+ * @param a - Start vector (returned when `t = 0`)
132
+ * @param b - End vector (returned when `t = 1`)
133
+ * @param t - Interpolation factor, typically in `[0, 1]`
134
+ * @returns A new {@linkcode PVec3} at `a + (b - a) * t`
135
+ */
53
136
  lerp(a, b, t) {
54
137
  return {
55
138
  x: a.x + (b.x - a.x) * t,
@@ -57,15 +140,35 @@ var PluginVec3Api = class {
57
140
  z: a.z + (b.z - a.z) * t
58
141
  };
59
142
  }
60
- /** Negate a vector. */
143
+ /**
144
+ * Negate a vector (reverse its direction).
145
+ *
146
+ * @param v - The vector to negate
147
+ * @returns A new {@linkcode PVec3} with all components negated
148
+ */
61
149
  negate(v) {
62
150
  return { x: -v.x, y: -v.y, z: -v.z };
63
151
  }
64
- /** Check if two vectors are equal (exact). */
152
+ /**
153
+ * Check if two vectors are exactly equal (strict equality per component).
154
+ *
155
+ * For floating-point comparisons, prefer {@linkcode PluginVec3Api.equalsApprox}.
156
+ *
157
+ * @param a - First vector
158
+ * @param b - Second vector
159
+ * @returns `true` if all components match exactly
160
+ */
65
161
  equals(a, b) {
66
162
  return a.x === b.x && a.y === b.y && a.z === b.z;
67
163
  }
68
- /** Check if two vectors are approximately equal within an epsilon. */
164
+ /**
165
+ * Check if two vectors are approximately equal within a tolerance.
166
+ *
167
+ * @param a - First vector
168
+ * @param b - Second vector
169
+ * @param epsilon - Maximum allowed difference per component (default `1e-6`)
170
+ * @returns `true` if `|a[i] - b[i]| < epsilon` for all components
171
+ */
69
172
  equalsApprox(a, b, epsilon = 1e-6) {
70
173
  return Math.abs(a.x - b.x) < epsilon && Math.abs(a.y - b.y) < epsilon && Math.abs(a.z - b.z) < epsilon;
71
174
  }
@@ -81,15 +184,43 @@ import * as z2 from "zod";
81
184
  var PluginQuatApi = class {
82
185
  constructor() {
83
186
  }
84
- /** Create a new PQuat. */
85
- new(x, y, z12, w) {
86
- return { x, y, z: z12, w };
87
- }
88
- /** Create an identity quaternion (no rotation). */
187
+ /**
188
+ * Create a new quaternion from raw components.
189
+ *
190
+ * For most use cases prefer {@linkcode PluginQuatApi.fromAxisAngle}
191
+ * or {@linkcode PluginQuatApi.fromEuler} instead.
192
+ *
193
+ * @param x - The X component
194
+ * @param y - The Y component
195
+ * @param z - The Z component
196
+ * @param w - The W (scalar) component
197
+ * @returns A new {@linkcode PQuat}
198
+ */
199
+ new(x, y, z13, w) {
200
+ return { x, y, z: z13, w };
201
+ }
202
+ /**
203
+ * Create an identity quaternion representing no rotation.
204
+ *
205
+ * @returns `{ x: 0, y: 0, z: 0, w: 1 }`
206
+ */
89
207
  identity() {
90
208
  return { x: 0, y: 0, z: 0, w: 1 };
91
209
  }
92
- /** Create a quaternion from an axis and angle (radians). */
210
+ /**
211
+ * Create a quaternion from an axis and an angle.
212
+ *
213
+ * @param axis - The rotation axis as a {@linkcode PVec3} (will be normalized internally)
214
+ * @param angle - The rotation angle in **radians**
215
+ * @returns A new unit {@linkcode PQuat}, or identity if {@linkcode axis} has zero length
216
+ *
217
+ * # Example
218
+ * ```ts
219
+ * const { vec3, quat } = snaptrude.core.math
220
+ * // 90° rotation around the Y axis
221
+ * const rot = quat.fromAxisAngle(vec3.new(0, 1, 0), Math.PI / 2)
222
+ * ```
223
+ */
93
224
  fromAxisAngle(axis, angle) {
94
225
  const halfAngle = angle / 2;
95
226
  const s = Math.sin(halfAngle);
@@ -102,14 +233,21 @@ var PluginQuatApi = class {
102
233
  w: Math.cos(halfAngle)
103
234
  };
104
235
  }
105
- /** Create a quaternion from Euler angles (radians, XYZ order). */
106
- fromEuler(x, y, z12) {
236
+ /**
237
+ * Create a quaternion from Euler angles in **XYZ** rotation order.
238
+ *
239
+ * @param x - Rotation around X axis in **radians**
240
+ * @param y - Rotation around Y axis in **radians**
241
+ * @param z - Rotation around Z axis in **radians**
242
+ * @returns A new {@linkcode PQuat}
243
+ */
244
+ fromEuler(x, y, z13) {
107
245
  const cx = Math.cos(x / 2);
108
246
  const sx = Math.sin(x / 2);
109
247
  const cy = Math.cos(y / 2);
110
248
  const sy = Math.sin(y / 2);
111
- const cz = Math.cos(z12 / 2);
112
- const sz = Math.sin(z12 / 2);
249
+ const cz = Math.cos(z13 / 2);
250
+ const sz = Math.sin(z13 / 2);
113
251
  return {
114
252
  x: sx * cy * cz + cx * sy * sz,
115
253
  y: cx * sy * cz - sx * cy * sz,
@@ -117,7 +255,16 @@ var PluginQuatApi = class {
117
255
  w: cx * cy * cz - sx * sy * sz
118
256
  };
119
257
  }
120
- /** Multiply two quaternions (a * b). */
258
+ /**
259
+ * Multiply two quaternions, combining their rotations.
260
+ *
261
+ * Quaternion multiplication is **not commutative**: `a * b ≠ b * a`.
262
+ * The result applies rotation {@linkcode b} first, then {@linkcode a}.
263
+ *
264
+ * @param a - First quaternion (applied second)
265
+ * @param b - Second quaternion (applied first)
266
+ * @returns A new {@linkcode PQuat} representing the combined rotation
267
+ */
121
268
  multiply(a, b) {
122
269
  return {
123
270
  x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
@@ -126,34 +273,83 @@ var PluginQuatApi = class {
126
273
  w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z
127
274
  };
128
275
  }
129
- /** Conjugate of a quaternion. */
276
+ /**
277
+ * Compute the conjugate of a quaternion.
278
+ *
279
+ * For unit quaternions the conjugate equals the inverse.
280
+ *
281
+ * @param q - The quaternion
282
+ * @returns A new {@linkcode PQuat} with negated vector part `(-x, -y, -z, w)`
283
+ */
130
284
  conjugate(q) {
131
285
  return { x: -q.x, y: -q.y, z: -q.z, w: q.w };
132
286
  }
133
- /** Length (magnitude) of a quaternion. */
287
+ /**
288
+ * Compute the length (magnitude) of a quaternion.
289
+ *
290
+ * @param q - The quaternion
291
+ * @returns The magnitude `√(x² + y² + z² + w²)`
292
+ */
134
293
  length(q) {
135
294
  return Math.sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w);
136
295
  }
137
- /** Normalize a quaternion to unit length. Returns identity if length is 0. */
296
+ /**
297
+ * Normalize a quaternion to unit length.
298
+ *
299
+ * @param q - The quaternion to normalize
300
+ * @returns A new unit-length {@linkcode PQuat}, or identity if the input has zero length
301
+ */
138
302
  normalize(q) {
139
303
  const len = this.length(q);
140
304
  if (len === 0) return { x: 0, y: 0, z: 0, w: 1 };
141
305
  return { x: q.x / len, y: q.y / len, z: q.z / len, w: q.w / len };
142
306
  }
143
- /** Inverse of a quaternion (conjugate / lengthSquared). */
307
+ /**
308
+ * Compute the inverse of a quaternion.
309
+ *
310
+ * The inverse satisfies `q * inverse(q) = identity`.
311
+ *
312
+ * @param q - The quaternion to invert
313
+ * @returns A new {@linkcode PQuat} that is the multiplicative inverse,
314
+ * or identity if the input has zero length
315
+ */
144
316
  inverse(q) {
145
317
  const lenSq = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
146
318
  if (lenSq === 0) return { x: 0, y: 0, z: 0, w: 1 };
147
319
  return { x: -q.x / lenSq, y: -q.y / lenSq, z: -q.z / lenSq, w: q.w / lenSq };
148
320
  }
149
- /** Rotate a vector by a quaternion. */
321
+ /**
322
+ * Rotate a 3D vector by a quaternion.
323
+ *
324
+ * Computes `q * v * conjugate(q)` using the Hamilton product.
325
+ *
326
+ * @param q - The rotation quaternion (should be unit-length)
327
+ * @param v - The vector to rotate as a {@linkcode PVec3}
328
+ * @returns A new rotated {@linkcode PVec3}
329
+ *
330
+ * # Example
331
+ * ```ts
332
+ * const { vec3, quat } = snaptrude.core.math
333
+ * const rot = quat.fromAxisAngle(vec3.new(0, 1, 0), Math.PI / 2)
334
+ * const rotated = quat.rotateVec3(rot, vec3.new(1, 0, 0))
335
+ * // ≈ { x: 0, y: 0, z: -1 }
336
+ * ```
337
+ */
150
338
  rotateVec3(q, v) {
151
339
  const vq = { x: v.x, y: v.y, z: v.z, w: 0 };
152
340
  const conj = this.conjugate(q);
153
341
  const result = this.multiply(this.multiply(q, vq), conj);
154
342
  return { x: result.x, y: result.y, z: result.z };
155
343
  }
156
- /** Convert a quaternion to axis-angle representation. */
344
+ /**
345
+ * Convert a quaternion to axis-angle representation.
346
+ *
347
+ * @param q - The quaternion to convert
348
+ * @returns An object with:
349
+ * - `axis` — The rotation axis as a unit {@linkcode PVec3}
350
+ * (defaults to `(1, 0, 0)` when angle is zero)
351
+ * - `angle` — The rotation angle in **radians**
352
+ */
157
353
  toAxisAngle(q) {
158
354
  const nq = this.normalize(q);
159
355
  const angle = 2 * Math.acos(Math.min(1, Math.max(-1, nq.w)));
@@ -166,7 +362,16 @@ var PluginQuatApi = class {
166
362
  angle
167
363
  };
168
364
  }
169
- /** Spherical linear interpolation between two quaternions. */
365
+ /**
366
+ * Spherical linear interpolation between two quaternions.
367
+ *
368
+ * Produces smooth constant-speed rotation between {@linkcode a} and {@linkcode b}.
369
+ *
370
+ * @param a - Start quaternion (returned when `t = 0`)
371
+ * @param b - End quaternion (returned when `t = 1`)
372
+ * @param t - Interpolation factor, typically in `[0, 1]`
373
+ * @returns A new interpolated {@linkcode PQuat}
374
+ */
170
375
  slerp(a, b, t) {
171
376
  let cosHalf = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
172
377
  let bx = b.x, by = b.y, bz = b.z, bw = b.w;
@@ -191,15 +396,39 @@ var PluginQuatApi = class {
191
396
  w: a.w * ratioA + bw * ratioB
192
397
  };
193
398
  }
194
- /** Dot product of two quaternions. */
399
+ /**
400
+ * Compute the dot product of two quaternions.
401
+ *
402
+ * A value close to `1` or `-1` indicates similar orientations;
403
+ * a value close to `0` indicates maximally different orientations.
404
+ *
405
+ * @param a - First quaternion
406
+ * @param b - Second quaternion
407
+ * @returns The scalar dot product
408
+ */
195
409
  dot(a, b) {
196
410
  return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
197
411
  }
198
- /** Check if two quaternions are equal (exact). */
412
+ /**
413
+ * Check if two quaternions are exactly equal (strict equality per component).
414
+ *
415
+ * For floating-point comparisons, prefer {@linkcode PluginQuatApi.equalsApprox}.
416
+ *
417
+ * @param a - First quaternion
418
+ * @param b - Second quaternion
419
+ * @returns `true` if all components match exactly
420
+ */
199
421
  equals(a, b) {
200
422
  return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w;
201
423
  }
202
- /** Check if two quaternions are approximately equal within an epsilon. */
424
+ /**
425
+ * Check if two quaternions are approximately equal within a tolerance.
426
+ *
427
+ * @param a - First quaternion
428
+ * @param b - Second quaternion
429
+ * @param epsilon - Maximum allowed difference per component (default `1e-6`)
430
+ * @returns `true` if `|a[i] - b[i]| < epsilon` for all components
431
+ */
203
432
  equalsApprox(a, b, epsilon = 1e-6) {
204
433
  return Math.abs(a.x - b.x) < epsilon && Math.abs(a.y - b.y) < epsilon && Math.abs(a.z - b.z) < epsilon && Math.abs(a.w - b.w) < epsilon;
205
434
  }
@@ -222,7 +451,21 @@ import * as z3 from "zod";
222
451
  var PluginLineApi = class {
223
452
  constructor() {
224
453
  }
225
- /** Create a new PLine from start and end points. */
454
+ /**
455
+ * Create a new line segment between two points.
456
+ *
457
+ * @param startPoint - The start point as a {@linkcode PVec3}
458
+ * @param endPoint - The end point as a {@linkcode PVec3}
459
+ * @returns A new {@linkcode PLine}
460
+ *
461
+ * # Example
462
+ * ```ts
463
+ * const { vec3 } = snaptrude.core.math
464
+ * const { line } = snaptrude.core.geom
465
+ *
466
+ * const edge = line.new(vec3.new(0, 0, 0), vec3.new(5, 0, 0))
467
+ * ```
468
+ */
226
469
  new(startPoint, endPoint) {
227
470
  return { curveType: "Line", startPoint, endPoint };
228
471
  }
@@ -238,7 +481,34 @@ import * as z4 from "zod";
238
481
  var PluginArcApi = class {
239
482
  constructor() {
240
483
  }
241
- /** Create a new PArc from start, end, centre and axis. */
484
+ /**
485
+ * Create a new arc from start, end, centre, and axis.
486
+ *
487
+ * The arc sweeps from {@linkcode startPoint} to {@linkcode endPoint}
488
+ * along the circle centred at {@linkcode centrePoint}, in the
489
+ * direction determined by the right-hand rule around {@linkcode axis}.
490
+ *
491
+ * @param startPoint - The start point as a {@linkcode PVec3}
492
+ * @param endPoint - The end point as a {@linkcode PVec3}
493
+ * @param centrePoint - The centre of the arc's circle as a {@linkcode PVec3}
494
+ * @param axis - The arc's rotation axis as a {@linkcode PVec3}
495
+ * (perpendicular to the arc's plane)
496
+ * @returns A new {@linkcode PArc}
497
+ *
498
+ * # Example
499
+ * ```ts
500
+ * const { vec3 } = snaptrude.core.math
501
+ * const { arc } = snaptrude.core.geom
502
+ *
503
+ * // Quarter-circle arc on the XZ plane
504
+ * const a = arc.new(
505
+ * vec3.new(1, 0, 0), // start
506
+ * vec3.new(0, 0, 1), // end
507
+ * vec3.new(0, 0, 0), // centre
508
+ * vec3.new(0, 1, 0), // Y-up axis
509
+ * )
510
+ * ```
511
+ */
242
512
  new(startPoint, endPoint, centrePoint, axis) {
243
513
  return { curveType: "Arc", startPoint, endPoint, centrePoint, axis };
244
514
  }
@@ -256,7 +526,15 @@ import * as z5 from "zod";
256
526
  var PluginCurveApi = class {
257
527
  constructor() {
258
528
  }
259
- /** Create a PCurve from a PLine or PArc. */
529
+ /**
530
+ * Wrap a {@linkcode PLine} or {@linkcode PArc} as a {@linkcode PCurve}.
531
+ *
532
+ * This is an identity operation — it simply returns the input unchanged.
533
+ * It exists for type-level clarity when building mixed curve lists.
534
+ *
535
+ * @param curve - A {@linkcode PLine} or {@linkcode PArc} to wrap
536
+ * @returns The same value typed as {@linkcode PCurve}
537
+ */
260
538
  new(curve) {
261
539
  return curve;
262
540
  }
@@ -268,7 +546,15 @@ import * as z6 from "zod";
268
546
  var PluginProfileApi = class {
269
547
  constructor() {
270
548
  }
271
- /** Create a new PProfile from an array of PCurves. */
549
+ /**
550
+ * Create a profile from an ordered list of curves.
551
+ *
552
+ * The curves should form a closed loop — the end point of each curve
553
+ * should coincide with the start point of the next.
554
+ *
555
+ * @param curves - An ordered array of {@linkcode PCurve}s forming a closed loop
556
+ * @returns A new {@linkcode PProfile}
557
+ */
272
558
  new(curves) {
273
559
  return { curves };
274
560
  }
@@ -292,73 +578,178 @@ var PluginCoreApi = class {
292
578
  }
293
579
  };
294
580
 
295
- // src/api/entity/space.ts
581
+ // src/api/entity/referenceLine.ts
296
582
  import * as z7 from "zod";
583
+ var PluginReferenceLineApi = class {
584
+ constructor() {
585
+ }
586
+ };
587
+ var PluginReferenceLineCreateMultiArgs = z7.object({
588
+ profile: PProfile
589
+ });
590
+ var PluginReferenceLineCreateMultiResult = z7.object({
591
+ referenceLineIds: z7.array(z7.string())
592
+ });
593
+ var PluginReferenceLineGetProperty = z7.enum([
594
+ "curve"
595
+ ]);
596
+ var PluginReferenceLineGetArgs = z7.object({
597
+ referenceLineId: z7.string(),
598
+ properties: z7.array(PluginReferenceLineGetProperty)
599
+ });
600
+ var PluginReferenceLineGetResult = z7.object({
601
+ curve: PCurve
602
+ }).partial();
603
+ var PluginReferenceLineGetAllResult = z7.object({
604
+ referenceLineIds: z7.array(z7.string())
605
+ });
606
+ var PluginReferenceLineDeleteArgs = z7.object({
607
+ referenceLineId: z7.string()
608
+ });
609
+
610
+ // src/api/entity/space.ts
611
+ import * as z8 from "zod";
297
612
  var PluginSpaceApi = class {
298
613
  constructor() {
299
614
  }
300
615
  };
301
- var PluginSpaceCreateRectangularArgs = z7.object({
616
+ var PluginSpaceCreateRectangularArgs = z8.object({
302
617
  position: PVec3,
303
- dimensions: z7.object({
304
- width: z7.number(),
305
- height: z7.number(),
306
- depth: z7.number()
618
+ dimensions: z8.object({
619
+ width: z8.number(),
620
+ height: z8.number(),
621
+ depth: z8.number()
307
622
  })
308
623
  });
309
- var PluginSpaceCreateRectangularResult = z7.object({
310
- spaceId: z7.string()
624
+ var PluginSpaceCreateRectangularResult = z8.object({
625
+ spaceId: z8.string()
311
626
  });
312
- var PluginSpaceCreateFromProfileArgs = z7.object({
627
+ var PluginSpaceCreateFromProfileArgs = z8.object({
313
628
  profile: PProfile,
314
- extrudeHeight: z7.number(),
629
+ extrudeHeight: z8.number(),
315
630
  position: PVec3
316
631
  });
317
- var PluginSpaceCreateFromProfileResult = z7.object({
318
- spaceId: z7.string()
632
+ var PluginSpaceCreateFromProfileResult = z8.object({
633
+ spaceId: z8.string()
319
634
  });
320
- var PluginSpaceGetProperty = z7.enum([
635
+ var PluginSpaceGetProperty = z8.enum([
636
+ // Basic
321
637
  "id",
322
638
  "type",
323
639
  "room_type",
324
640
  "name",
641
+ // Derived from parametric data
325
642
  "area",
326
- "department",
643
+ "breadth",
644
+ "depth",
645
+ "height",
646
+ "massType",
647
+ "spaceType",
648
+ "storey",
649
+ "departmentId",
650
+ "departmentName",
651
+ "departmentColor",
652
+ // Derived from mesh
327
653
  "position",
328
654
  "absolutePosition",
329
655
  "rotation",
330
- "rotationQuaternion"
656
+ "rotationQuaternion",
657
+ // Derived from brep
658
+ "planPoints"
659
+ ]);
660
+ var PluginSpaceGetArgs = z8.object({
661
+ spaceId: z8.string(),
662
+ properties: z8.array(PluginSpaceGetProperty)
663
+ });
664
+ var PluginSpaceType = z8.enum([
665
+ "Room",
666
+ "Program Block",
667
+ "Balcony",
668
+ "Road",
669
+ "Garden",
670
+ "Deck",
671
+ "Pool",
672
+ "Walkway"
331
673
  ]);
332
- var PluginSpaceGetArgs = z7.object({
333
- spaceId: z7.string(),
334
- properties: z7.array(PluginSpaceGetProperty)
335
- });
336
- var PluginSpaceGetResult = z7.object({
337
- id: z7.string(),
338
- type: z7.string(),
339
- room_type: z7.string(),
340
- name: z7.string(),
341
- area: z7.number(),
342
- department: z7.string(),
674
+ var PluginSpaceGetResult = z8.object({
675
+ // Basic
676
+ id: z8.string(),
677
+ type: z8.string(),
678
+ room_type: z8.string(),
679
+ name: z8.string(),
680
+ // Derived from parametric data
681
+ area: z8.number(),
682
+ breadth: z8.number(),
683
+ depth: z8.number(),
684
+ height: z8.number(),
685
+ massType: z8.string().nullable(),
686
+ spaceType: PluginSpaceType.nullable(),
687
+ storey: z8.number().nullable(),
688
+ departmentId: z8.string().nullable(),
689
+ departmentName: z8.string(),
690
+ departmentColor: z8.string(),
691
+ // Derived from mesh
343
692
  position: PVec3,
344
693
  absolutePosition: PVec3,
345
694
  rotation: PVec3,
346
- rotationQuaternion: PQuat.nullable()
695
+ rotationQuaternion: PQuat.nullable(),
696
+ // Derived from brep
697
+ planPoints: z8.array(PVec3)
347
698
  }).partial();
348
- var PluginSpaceGetAllResult = z7.object({
349
- spacesIds: z7.array(z7.string())
699
+ var PluginSpaceGetAllResult = z8.object({
700
+ spacesIds: z8.array(z8.string())
701
+ });
702
+ var PluginSpaceDeleteArgs = z8.object({
703
+ spaceId: z8.string()
704
+ });
705
+ var PluginMassType = z8.enum([
706
+ "Plinth",
707
+ "Void",
708
+ "Pergola",
709
+ "Furniture",
710
+ "Facade element",
711
+ "Generic mass",
712
+ "Room",
713
+ "Department",
714
+ "Building",
715
+ "Revit Import",
716
+ "Mass",
717
+ "Site"
718
+ ]);
719
+ var PluginWellKnownDepartmentId = z8.enum([
720
+ "DEFAULT",
721
+ "SITE",
722
+ "ENVELOPE",
723
+ "CORE"
724
+ ]);
725
+ var PluginDepartmentId = z8.union([
726
+ PluginWellKnownDepartmentId,
727
+ z8.uuid()
728
+ ]);
729
+ var PluginSpaceUpdateArgs = z8.object({
730
+ spaceId: z8.string(),
731
+ properties: z8.object({
732
+ room_type: z8.string().optional(),
733
+ massType: PluginMassType.optional(),
734
+ spaceType: PluginSpaceType.optional(),
735
+ departmentId: PluginDepartmentId.optional()
736
+ })
350
737
  });
351
- var PluginSpaceDeleteByIdArgs = z7.object({
352
- spaceId: z7.string()
738
+ var PluginSpaceUpdateResult = z8.object({
739
+ spaceId: z8.string(),
740
+ room_type: z8.string().optional(),
741
+ massType: z8.string().optional(),
742
+ spaceType: z8.string().optional(),
743
+ departmentId: z8.string().nullable().optional()
353
744
  });
354
745
 
355
746
  // src/api/entity/story.ts
356
- import * as z8 from "zod";
747
+ import * as z9 from "zod";
357
748
  var PluginStoryApi = class {
358
749
  constructor() {
359
750
  }
360
751
  };
361
- var PluginStoryGetProperty = z8.enum([
752
+ var PluginStoryGetProperty = z9.enum([
362
753
  "value",
363
754
  "id",
364
755
  "name",
@@ -368,44 +759,44 @@ var PluginStoryGetProperty = z8.enum([
368
759
  "spacesCount",
369
760
  "totalArea"
370
761
  ]);
371
- var PluginStoryGetArgs = z8.object({
372
- storyValue: z8.number().int(),
373
- properties: z8.array(PluginStoryGetProperty)
762
+ var PluginStoryGetArgs = z9.object({
763
+ storyValue: z9.number().int(),
764
+ properties: z9.array(PluginStoryGetProperty)
374
765
  });
375
- var PluginStoryGetResult = z8.object({
376
- value: z8.number(),
377
- id: z8.string(),
378
- name: z8.string(),
379
- height: z8.number(),
380
- base: z8.number(),
381
- hidden: z8.boolean(),
382
- spacesCount: z8.number(),
383
- totalArea: z8.number()
766
+ var PluginStoryGetResult = z9.object({
767
+ value: z9.number(),
768
+ id: z9.string(),
769
+ name: z9.string(),
770
+ height: z9.number(),
771
+ base: z9.number(),
772
+ hidden: z9.boolean(),
773
+ spacesCount: z9.number(),
774
+ totalArea: z9.number()
384
775
  }).partial();
385
- var PluginStoryGetAllResult = z8.object({
386
- stories: z8.array(
387
- z8.object({
388
- value: z8.number(),
389
- id: z8.string(),
390
- name: z8.string()
776
+ var PluginStoryGetAllResult = z9.object({
777
+ stories: z9.array(
778
+ z9.object({
779
+ value: z9.number(),
780
+ id: z9.string(),
781
+ name: z9.string()
391
782
  })
392
783
  )
393
784
  });
394
- var PluginStoryCreateArgs = z8.object({
395
- storyValue: z8.number().int(),
396
- height: z8.number().optional()
785
+ var PluginStoryCreateArgs = z9.object({
786
+ storyValue: z9.number().int(),
787
+ height: z9.number().optional()
397
788
  });
398
- var PluginStoryCreateResult = z8.object({
399
- storyId: z8.string(),
400
- storyValue: z8.number()
789
+ var PluginStoryCreateResult = z9.object({
790
+ storyId: z9.string(),
791
+ storyValue: z9.number()
401
792
  });
402
- var PluginStoryUpdateArgs = z8.object({
403
- storyValue: z8.number().int(),
404
- height: z8.number()
793
+ var PluginStoryUpdateArgs = z9.object({
794
+ storyValue: z9.number().int(),
795
+ height: z9.number()
405
796
  });
406
- var PluginStoryUpdateResult = z8.object({
407
- storyValue: z8.number(),
408
- height: z8.number()
797
+ var PluginStoryUpdateResult = z9.object({
798
+ storyValue: z9.number(),
799
+ height: z9.number()
409
800
  });
410
801
 
411
802
  // src/api/entity/index.ts
@@ -415,28 +806,28 @@ var PluginEntityApi = class {
415
806
  };
416
807
 
417
808
  // src/api/tools/selection.ts
418
- import * as z9 from "zod";
809
+ import * as z10 from "zod";
419
810
  var PluginSelectionApi = class {
420
811
  constructor() {
421
812
  }
422
813
  };
423
- var PluginSelectionGetResult = z9.object({
424
- selected: z9.array(z9.string())
814
+ var PluginSelectionGetResult = z10.object({
815
+ selected: z10.array(z10.string())
425
816
  });
426
817
 
427
818
  // src/api/tools/transform.ts
428
- import * as z10 from "zod";
819
+ import * as z11 from "zod";
429
820
  var PluginTransformApi = class {
430
821
  constructor() {
431
822
  }
432
823
  };
433
- var PluginMoveArgs = z10.object({
434
- componentIds: z10.array(z10.string()),
824
+ var PluginMoveArgs = z11.object({
825
+ componentIds: z11.array(z11.string()),
435
826
  displacement: PVec3
436
827
  });
437
- var PluginRotateArgs = z10.object({
438
- componentIds: z10.array(z10.string()),
439
- angle: z10.number(),
828
+ var PluginRotateArgs = z11.object({
829
+ componentIds: z11.array(z11.string()),
830
+ angle: z11.number(),
440
831
  axis: PVec3,
441
832
  pivot: PVec3
442
833
  });
@@ -448,12 +839,12 @@ var PluginToolsApi = class {
448
839
  };
449
840
 
450
841
  // src/api/units/index.ts
451
- import * as z11 from "zod";
842
+ import * as z12 from "zod";
452
843
  var PluginUnitsApi = class {
453
844
  constructor() {
454
845
  }
455
846
  };
456
- var PUnitType = z11.enum([
847
+ var PUnitType = z12.enum([
457
848
  "meters",
458
849
  "feet-inches",
459
850
  "inches",
@@ -462,19 +853,21 @@ var PUnitType = z11.enum([
462
853
  "kilometers",
463
854
  "miles"
464
855
  ]);
465
- var PluginUnitsConvertFromArgs = z11.object({
856
+ var PluginUnitsConvertFromArgs = z12.object({
466
857
  unit: PUnitType,
467
- value: z11.number()
858
+ value: z12.number(),
859
+ degree: z12.number().int().min(1).max(3).optional()
468
860
  });
469
- var PluginUnitsConvertFromResult = z11.object({
470
- value: z11.number()
861
+ var PluginUnitsConvertFromResult = z12.object({
862
+ value: z12.number()
471
863
  });
472
- var PluginUnitsConvertToArgs = z11.object({
864
+ var PluginUnitsConvertToArgs = z12.object({
473
865
  unit: PUnitType,
474
- value: z11.number()
866
+ value: z12.number(),
867
+ degree: z12.number().int().min(1).max(3).optional()
475
868
  });
476
- var PluginUnitsConvertToResult = z11.object({
477
- value: z11.number()
869
+ var PluginUnitsConvertToResult = z12.object({
870
+ value: z12.number()
478
871
  });
479
872
 
480
873
  // src/api/index.ts
@@ -494,14 +887,24 @@ export {
494
887
  PluginArcApi,
495
888
  PluginCoreApi,
496
889
  PluginCurveApi,
890
+ PluginDepartmentId,
497
891
  PluginEntityApi,
498
892
  PluginGeomApi,
499
893
  PluginLineApi,
894
+ PluginMassType,
500
895
  PluginMathApi,
501
896
  PluginMoveArgs,
502
897
  PluginProfileApi,
503
898
  PluginProfileFromLinePointsArgs,
504
899
  PluginQuatApi,
900
+ PluginReferenceLineApi,
901
+ PluginReferenceLineCreateMultiArgs,
902
+ PluginReferenceLineCreateMultiResult,
903
+ PluginReferenceLineDeleteArgs,
904
+ PluginReferenceLineGetAllResult,
905
+ PluginReferenceLineGetArgs,
906
+ PluginReferenceLineGetProperty,
907
+ PluginReferenceLineGetResult,
505
908
  PluginRotateArgs,
506
909
  PluginSelectionApi,
507
910
  PluginSelectionGetResult,
@@ -510,11 +913,14 @@ export {
510
913
  PluginSpaceCreateFromProfileResult,
511
914
  PluginSpaceCreateRectangularArgs,
512
915
  PluginSpaceCreateRectangularResult,
513
- PluginSpaceDeleteByIdArgs,
916
+ PluginSpaceDeleteArgs,
514
917
  PluginSpaceGetAllResult,
515
918
  PluginSpaceGetArgs,
516
919
  PluginSpaceGetProperty,
517
920
  PluginSpaceGetResult,
921
+ PluginSpaceType,
922
+ PluginSpaceUpdateArgs,
923
+ PluginSpaceUpdateResult,
518
924
  PluginStoryApi,
519
925
  PluginStoryCreateArgs,
520
926
  PluginStoryCreateResult,
@@ -531,6 +937,7 @@ export {
531
937
  PluginUnitsConvertFromResult,
532
938
  PluginUnitsConvertToArgs,
533
939
  PluginUnitsConvertToResult,
534
- PluginVec3Api
940
+ PluginVec3Api,
941
+ PluginWellKnownDepartmentId
535
942
  };
536
943
  //# sourceMappingURL=index.js.map