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