@snaptrude/plugin-core 0.7.1 → 0.9.0

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 (193) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/api-manifest.full.json +7703 -0
  3. package/api-manifest.json +2946 -259
  4. package/dist/api/analysis/daylight.d.ts +603 -0
  5. package/dist/api/analysis/daylight.d.ts.map +1 -0
  6. package/dist/api/analysis/heatmaps.d.ts +438 -14
  7. package/dist/api/analysis/heatmaps.d.ts.map +1 -1
  8. package/dist/api/analysis/index.d.ts +15 -0
  9. package/dist/api/analysis/index.d.ts.map +1 -1
  10. package/dist/api/analysis/solar.d.ts +249 -0
  11. package/dist/api/analysis/solar.d.ts.map +1 -0
  12. package/dist/api/analysis/weather.d.ts +193 -0
  13. package/dist/api/analysis/weather.d.ts.map +1 -0
  14. package/dist/api/core/camera/index.d.ts +245 -0
  15. package/dist/api/core/camera/index.d.ts.map +1 -0
  16. package/dist/api/core/comment/index.d.ts +105 -2
  17. package/dist/api/core/comment/index.d.ts.map +1 -1
  18. package/dist/api/core/geom/create/index.d.ts +331 -14
  19. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  20. package/dist/api/core/geom/delete/index.d.ts +8 -2
  21. package/dist/api/core/geom/delete/index.d.ts.map +1 -1
  22. package/dist/api/core/geom/query/arc.d.ts +5 -5
  23. package/dist/api/core/geom/query/brep.d.ts +18 -18
  24. package/dist/api/core/geom/query/circle.d.ts +18 -18
  25. package/dist/api/core/geom/query/contour.d.ts +20 -20
  26. package/dist/api/core/geom/query/curve.d.ts +49 -49
  27. package/dist/api/core/geom/query/edge.d.ts +5 -5
  28. package/dist/api/core/geom/query/face.d.ts +16 -16
  29. package/dist/api/core/geom/query/halfedge.d.ts +8 -8
  30. package/dist/api/core/geom/query/profile.d.ts +19 -19
  31. package/dist/api/core/geom/query/vertex.d.ts +8 -8
  32. package/dist/api/core/geom/update/contour.d.ts +14 -14
  33. package/dist/api/core/geom/update/curve.d.ts +7 -7
  34. package/dist/api/core/geom/update/profile.d.ts +16 -16
  35. package/dist/api/core/handles/index.d.ts +210 -0
  36. package/dist/api/core/handles/index.d.ts.map +1 -0
  37. package/dist/api/core/index.d.ts +24 -0
  38. package/dist/api/core/index.d.ts.map +1 -1
  39. package/dist/api/core/io/export/index.d.ts +134 -0
  40. package/dist/api/core/io/export/index.d.ts.map +1 -0
  41. package/dist/api/core/io/import/index.d.ts +62 -1
  42. package/dist/api/core/io/import/index.d.ts.map +1 -1
  43. package/dist/api/core/io/index.d.ts +5 -0
  44. package/dist/api/core/io/index.d.ts.map +1 -1
  45. package/dist/api/core/layers.d.ts +7 -7
  46. package/dist/api/core/mode/index.d.ts +99 -0
  47. package/dist/api/core/mode/index.d.ts.map +1 -0
  48. package/dist/api/core/proposals/index.d.ts +65 -9
  49. package/dist/api/core/proposals/index.d.ts.map +1 -1
  50. package/dist/api/core/storeys/index.d.ts +251 -0
  51. package/dist/api/core/storeys/index.d.ts.map +1 -0
  52. package/dist/api/core/tags.d.ts +24 -0
  53. package/dist/api/core/tags.d.ts.map +1 -1
  54. package/dist/api/core/user.d.ts +44 -0
  55. package/dist/api/core/user.d.ts.map +1 -0
  56. package/dist/api/core/zoom/index.d.ts +4 -0
  57. package/dist/api/core/zoom/index.d.ts.map +1 -1
  58. package/dist/api/design/boolean/index.d.ts +4 -4
  59. package/dist/api/design/create/index.d.ts +253 -47
  60. package/dist/api/design/create/index.d.ts.map +1 -1
  61. package/dist/api/design/delete/index.d.ts +3 -0
  62. package/dist/api/design/delete/index.d.ts.map +1 -1
  63. package/dist/api/design/doors/index.d.ts +36 -0
  64. package/dist/api/design/doors/index.d.ts.map +1 -1
  65. package/dist/api/design/edit/index.d.ts +1 -1
  66. package/dist/api/design/erase/index.d.ts +2 -2
  67. package/dist/api/design/furniture/index.d.ts +114 -3
  68. package/dist/api/design/furniture/index.d.ts.map +1 -1
  69. package/dist/api/design/index.d.ts +10 -0
  70. package/dist/api/design/index.d.ts.map +1 -1
  71. package/dist/api/design/materials/index.d.ts +111 -14
  72. package/dist/api/design/materials/index.d.ts.map +1 -1
  73. package/dist/api/design/query/geometry/index.d.ts +112 -0
  74. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  75. package/dist/api/design/query/index.d.ts +35 -1
  76. package/dist/api/design/query/index.d.ts.map +1 -1
  77. package/dist/api/design/query/referenceLines.d.ts +45 -0
  78. package/dist/api/design/query/referenceLines.d.ts.map +1 -0
  79. package/dist/api/design/query/spaces.d.ts +178 -5
  80. package/dist/api/design/query/spaces.d.ts.map +1 -1
  81. package/dist/api/design/transform/index.d.ts +95 -14
  82. package/dist/api/design/transform/index.d.ts.map +1 -1
  83. package/dist/api/design/types/index.d.ts +181 -0
  84. package/dist/api/design/types/index.d.ts.map +1 -0
  85. package/dist/api/design/update/index.d.ts +385 -2
  86. package/dist/api/design/update/index.d.ts.map +1 -1
  87. package/dist/api/design/visibility.d.ts +98 -0
  88. package/dist/api/design/visibility.d.ts.map +1 -0
  89. package/dist/api/entity/buildableEnvelope.d.ts +4 -0
  90. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  91. package/dist/api/entity/referenceLine.d.ts +10 -2
  92. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  93. package/dist/api/entity/space.d.ts +19 -19
  94. package/dist/api/entity/story.d.ts +148 -15
  95. package/dist/api/entity/story.d.ts.map +1 -1
  96. package/dist/api/index.d.ts +5 -0
  97. package/dist/api/index.d.ts.map +1 -1
  98. package/dist/api/presentation/annotate.d.ts +448 -0
  99. package/dist/api/presentation/annotate.d.ts.map +1 -0
  100. package/dist/api/presentation/diagrams.d.ts +49 -8
  101. package/dist/api/presentation/diagrams.d.ts.map +1 -1
  102. package/dist/api/presentation/export.d.ts +108 -0
  103. package/dist/api/presentation/export.d.ts.map +1 -0
  104. package/dist/api/presentation/import.d.ts +6 -0
  105. package/dist/api/presentation/import.d.ts.map +1 -1
  106. package/dist/api/presentation/index.d.ts +47 -0
  107. package/dist/api/presentation/index.d.ts.map +1 -1
  108. package/dist/api/presentation/placedViews.d.ts +370 -0
  109. package/dist/api/presentation/placedViews.d.ts.map +1 -0
  110. package/dist/api/presentation/shapes.d.ts +481 -0
  111. package/dist/api/presentation/shapes.d.ts.map +1 -0
  112. package/dist/api/presentation/sheets.d.ts +410 -13
  113. package/dist/api/presentation/sheets.d.ts.map +1 -1
  114. package/dist/api/presentation/views.d.ts +165 -10
  115. package/dist/api/presentation/views.d.ts.map +1 -1
  116. package/dist/api/program/areas.d.ts +63 -3
  117. package/dist/api/program/areas.d.ts.map +1 -1
  118. package/dist/api/program/cores.d.ts +3 -99
  119. package/dist/api/program/cores.d.ts.map +1 -1
  120. package/dist/api/program/index.d.ts +2 -2
  121. package/dist/api/program/index.d.ts.map +1 -1
  122. package/dist/api/program/layout.d.ts +172 -12
  123. package/dist/api/program/layout.d.ts.map +1 -1
  124. package/dist/api/program/site.d.ts +105 -8
  125. package/dist/api/program/site.d.ts.map +1 -1
  126. package/dist/api/program/spreadsheet.d.ts +365 -41
  127. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  128. package/dist/api/workspace/index.d.ts +460 -0
  129. package/dist/api/workspace/index.d.ts.map +1 -0
  130. package/dist/handles.d.ts +64 -25
  131. package/dist/handles.d.ts.map +1 -1
  132. package/dist/index.cjs +3210 -1671
  133. package/dist/index.cjs.map +1 -1
  134. package/dist/index.js +3008 -1666
  135. package/dist/index.js.map +1 -1
  136. package/package.json +3 -2
  137. package/scripts/generate-manifest.mjs +45 -0
  138. package/src/api/analysis/daylight.ts +470 -0
  139. package/src/api/analysis/heatmaps.ts +444 -17
  140. package/src/api/analysis/index.ts +15 -0
  141. package/src/api/analysis/solar.ts +237 -0
  142. package/src/api/analysis/weather.ts +179 -0
  143. package/src/api/core/camera/index.ts +251 -0
  144. package/src/api/core/comment/index.ts +120 -2
  145. package/src/api/core/geom/create/index.ts +344 -1
  146. package/src/api/core/geom/delete/index.ts +6 -0
  147. package/src/api/core/handles/index.ts +233 -0
  148. package/src/api/core/index.ts +24 -0
  149. package/src/api/core/io/export/index.ts +126 -0
  150. package/src/api/core/io/import/index.ts +64 -0
  151. package/src/api/core/io/index.ts +5 -0
  152. package/src/api/core/mode/index.ts +96 -0
  153. package/src/api/core/proposals/index.ts +71 -11
  154. package/src/api/core/storeys/index.ts +279 -0
  155. package/src/api/core/tags.ts +27 -0
  156. package/src/api/core/user.ts +46 -0
  157. package/src/api/core/zoom/index.ts +4 -0
  158. package/src/api/design/create/index.ts +303 -36
  159. package/src/api/design/delete/index.ts +3 -0
  160. package/src/api/design/doors/index.ts +40 -0
  161. package/src/api/design/furniture/index.ts +127 -3
  162. package/src/api/design/index.ts +10 -0
  163. package/src/api/design/materials/index.ts +157 -30
  164. package/src/api/design/query/geometry/index.ts +125 -3
  165. package/src/api/design/query/index.ts +37 -7
  166. package/src/api/design/query/referenceLines.ts +52 -0
  167. package/src/api/design/query/spaces.ts +143 -0
  168. package/src/api/design/transform/index.ts +101 -12
  169. package/src/api/design/types/index.ts +156 -0
  170. package/src/api/design/update/index.ts +467 -6
  171. package/src/api/design/visibility.ts +109 -0
  172. package/src/api/entity/buildableEnvelope.ts +4 -0
  173. package/src/api/entity/referenceLine.ts +8 -0
  174. package/src/api/entity/story.ts +161 -15
  175. package/src/api/index.ts +5 -0
  176. package/src/api/presentation/annotate.ts +360 -0
  177. package/src/api/presentation/diagrams.ts +53 -8
  178. package/src/api/presentation/export.ts +108 -0
  179. package/src/api/presentation/import.ts +6 -0
  180. package/src/api/presentation/index.ts +55 -0
  181. package/src/api/presentation/placedViews.ts +363 -0
  182. package/src/api/presentation/shapes.ts +274 -0
  183. package/src/api/presentation/sheets.ts +346 -13
  184. package/src/api/presentation/views.ts +164 -12
  185. package/src/api/program/areas.ts +57 -6
  186. package/src/api/program/cores.ts +3 -91
  187. package/src/api/program/index.ts +2 -2
  188. package/src/api/program/layout.ts +182 -12
  189. package/src/api/program/site.ts +106 -8
  190. package/src/api/program/spreadsheet.ts +376 -35
  191. package/src/api/workspace/index.ts +516 -0
  192. package/src/handles.ts +77 -13
  193. package/tsconfig.json +7 -2
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
- import { Vec3Handle, ComponentHandle } from "../../../handles"
3
+ import { Vec3Handle, ComponentHandle, Vec3Components } from "../../../handles"
4
4
 
5
5
  /**
6
6
  * Comments — create, edit, resolve, tag, and list scene/project comments.
@@ -140,7 +140,10 @@ export abstract class PluginCommentApi {
140
140
  * await snaptrude.core.comment.tag(comment, "alex@acme.com")
141
141
  * ```
142
142
  */
143
- public abstract tag(comment: CommentHandle, email: string): PluginApiReturn<boolean>
143
+ public abstract tag(
144
+ comment: CommentHandle,
145
+ email: string,
146
+ ): PluginApiReturn<boolean>
144
147
 
145
148
  /**
146
149
  * Permanently remove a comment from the project.
@@ -176,6 +179,57 @@ export abstract class PluginCommentApi {
176
179
  * ```
177
180
  */
178
181
  public abstract list(): PluginApiReturn<CommentHandle[]>
182
+
183
+ /**
184
+ * Read a comment's full detail — its text, author, pin location, resolved
185
+ * state, and reply thread. Comments are otherwise write-only; this is the read
186
+ * side. Pass a top-level comment handle or a reply handle (a reply has an empty
187
+ * `thread`). Returns `null` if the handle doesn't match a live comment.
188
+ *
189
+ * @param comment - The comment (or reply) to read.
190
+ * @returns the {@link PluginCommentDetails}, or `null` if not found.
191
+ *
192
+ * @examplePrompt Read the comment on this wall and tell me what it says
193
+ * @examplePrompt Who left this comment and where is it pinned?
194
+ * @examplePrompt Show me the full thread for this comment
195
+ * @examplePrompt Get the text and author of the selected comment
196
+ *
197
+ * # Example
198
+ * ```ts
199
+ * const [first] = await snaptrude.core.comment.list()
200
+ * const details = await snaptrude.core.comment.get(first)
201
+ * console.log(details?.content, "by", details?.author?.name)
202
+ * console.log(`${details?.thread.length ?? 0} replies`)
203
+ * ```
204
+ */
205
+ public abstract get(
206
+ comment: CommentHandle,
207
+ ): PluginApiReturn<PluginCommentDetails | null>
208
+
209
+ /**
210
+ * Reply to a comment — posts a new comment threaded under `comment` (which must
211
+ * be a top-level comment, not itself a reply). Notifies the thread's
212
+ * participants, mirroring the sidebar Reply action.
213
+ *
214
+ * @param comment - The top-level comment to reply to.
215
+ * @param text - The reply text (emojis = plain unicode).
216
+ * @returns the new reply's {@link CommentHandle}.
217
+ *
218
+ * @examplePrompt Reply to this comment saying I fixed the wall height
219
+ * @examplePrompt Add a reply to the review note confirming it's done
220
+ * @examplePrompt Respond to the comment about the door with "looks good now"
221
+ * @examplePrompt Post a follow-up on the selected comment thread
222
+ *
223
+ * # Example
224
+ * ```ts
225
+ * const [thread] = await snaptrude.core.comment.list()
226
+ * const reply = await snaptrude.core.comment.reply(thread, "Fixed 👍")
227
+ * ```
228
+ */
229
+ public abstract reply(
230
+ comment: CommentHandle,
231
+ text: string,
232
+ ): PluginApiReturn<CommentHandle>
179
233
  }
180
234
 
181
235
  /**
@@ -256,3 +310,67 @@ export const PluginCommentTagArgs = z.object({
256
310
  })
257
311
 
258
312
  export type PluginCommentTagArgs = z.infer<typeof PluginCommentTagArgs>
313
+
314
+ /**
315
+ * Arguments for {@link PluginCommentApi.reply}.
316
+ *
317
+ * | Property | Type | Description |
318
+ * |---|---|---|
319
+ * | `comment` | {@link CommentHandle} | The top-level comment to reply to |
320
+ * | `text` | `string` | The reply text (emojis = unicode) |
321
+ */
322
+ export const PluginCommentReplyArgs = z.object({
323
+ comment: CommentHandle,
324
+ text: z.string(),
325
+ })
326
+
327
+ export type PluginCommentReplyArgs = z.infer<typeof PluginCommentReplyArgs>
328
+
329
+ /**
330
+ * The author of a comment or reply — the display name and email of the teammate
331
+ * who posted it. `null` on the rare comment with no recorded author.
332
+ */
333
+ export interface PluginCommentAuthor {
334
+ /** The author's display name (falls back to their email). */
335
+ name: string
336
+ /** The author's email. */
337
+ email: string
338
+ }
339
+
340
+ /**
341
+ * One reply in a comment's thread (returned by {@link PluginCommentApi.get}).
342
+ */
343
+ export interface PluginCommentReply {
344
+ /** The reply's own {@link CommentHandle}. */
345
+ id: CommentHandle
346
+ /** The reply text. */
347
+ content: string
348
+ /** Who posted the reply. */
349
+ author: PluginCommentAuthor | null
350
+ /** ISO-8601 timestamp of when the reply was posted (empty if unknown). */
351
+ createdAt: string
352
+ }
353
+
354
+ /**
355
+ * The read model of a comment — returned by {@link PluginCommentApi.get}. The
356
+ * inverse of {@link PluginCommentApi.create}: `content`/`component`/`position`
357
+ * echo what was posted, plus the resolved state and reply `thread`.
358
+ */
359
+ export interface PluginCommentDetails {
360
+ /** The comment's {@link CommentHandle}. */
361
+ id: CommentHandle
362
+ /** The comment text. */
363
+ content: string
364
+ /** Who posted the comment. */
365
+ author: PluginCommentAuthor | null
366
+ /** The pin point (engine world coordinates), or `null` if un-anchored. */
367
+ position: Vec3Components | null
368
+ /** The component the comment is anchored to, or `null` if un-anchored. */
369
+ component: ComponentHandle | null
370
+ /** Whether the comment has been marked resolved. */
371
+ isResolved: boolean
372
+ /** ISO-8601 timestamp of when the comment was posted (empty if unknown). */
373
+ createdAt: string
374
+ /** The reply thread, oldest first. Empty for a comment with no replies. */
375
+ thread: PluginCommentReply[]
376
+ }
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../../types"
3
- import { Vec3Handle, LineHandle, ArcHandle, CircleHandle, CurveHandle, ProfileHandle, ContourHandle } from "../../../../handles"
3
+ import { Vec3Handle, LineHandle, ArcHandle, CircleHandle, CurveHandle, ProfileHandle, ContourHandle, BrepHandle, Vec3Components } from "../../../../handles"
4
4
 
5
5
  /**
6
6
  * Curve creation — construct new geometric curves from point handles (all-handle
@@ -177,6 +177,260 @@ export abstract class PluginGeomCreateApi {
177
177
  outer: ProfileHandle,
178
178
  holes?: ProfileHandle[],
179
179
  ): PluginApiReturn<ContourHandle>
180
+
181
+ /**
182
+ * Create a closed solid **B-rep** from explicit face loops. Host API call —
183
+ * returns a {@linkcode BrepHandle}. Faces are plain arrays of `{x, y, z}`
184
+ * point components, NOT point handles (bulk-data precedent:
185
+ * `design.query.geometry.getTriangulatedMeshes`), in raw Babylon units.
186
+ *
187
+ * Each face is one planar loop of at least 3 points; at least 4 faces are
188
+ * required. Loops may be authored in any consistent winding — the host
189
+ * validates edge coherence (every edge shared by exactly two faces, in
190
+ * opposite directions) and fixes the global orientation so faces point
191
+ * outward. Faces must be planar and the solid must be closed; holes in faces
192
+ * are not supported (v1).
193
+ *
194
+ * Inspect the result via `core.geom.query.brep.*`, or commit it to the scene
195
+ * with `design.create.massFromBrep`.
196
+ *
197
+ * @param faces Face loops — each an ordered array of `{x, y, z}` points (≥3 points per face, ≥4 faces)
198
+ * @returns The new solid as a {@linkcode BrepHandle}
199
+ * @throws if a face is degenerate or non-planar, an edge is not shared by
200
+ * exactly two faces (open shell, non-manifold, or inconsistent winding), or
201
+ * the faces do not form a valid closed solid
202
+ *
203
+ * @examplePrompt Create a brep from faces
204
+ * @examplePrompt Build a custom solid from a set of faces
205
+ * @examplePrompt Make a pyramid from triangular faces
206
+ *
207
+ * # Example
208
+ * ```ts
209
+ * // A pyramid: square base + 4 triangular sides
210
+ * const apex = { x: 0, y: 4, z: 0 }
211
+ * const a = { x: -2, y: 0, z: -2 }
212
+ * const b = { x: 2, y: 0, z: -2 }
213
+ * const c = { x: 2, y: 0, z: 2 }
214
+ * const d = { x: -2, y: 0, z: 2 }
215
+ * const brep = await snaptrude.core.geom.create.brepFromFaces([
216
+ * [a, d, c, b], // base
217
+ * [a, b, apex],
218
+ * [b, c, apex],
219
+ * [c, d, apex],
220
+ * [d, a, apex],
221
+ * ])
222
+ * const faceCount = await snaptrude.core.geom.query.brep.getFaceCount(brep) // 5
223
+ * ```
224
+ */
225
+ public abstract brepFromFaces(faces: Vec3Components[][]): PluginApiReturn<BrepHandle>
226
+
227
+ /**
228
+ * Create a closed solid **B-rep** by extruding a contour along a direction.
229
+ * Host API call — returns a {@linkcode BrepHandle}. The direction is
230
+ * normalised by the host, so `amount` is the extrusion distance in raw
231
+ * Babylon units (negative extrudes the opposite way). The contour is copied —
232
+ * the input handle is never mutated. Holes and arc/circle profiles extrude
233
+ * natively (a circle profile yields a cylinder).
234
+ *
235
+ * Inspect the result via `core.geom.query.brep.*`, or commit it to the scene
236
+ * with `design.create.massFromBrep`.
237
+ *
238
+ * @param contour The cross-section to extrude (outer profile + optional holes)
239
+ * @param direction Extrusion direction as plain `{x, y, z}` components (non-zero, normalised by the host)
240
+ * @param amount Extrusion distance (non-zero; negative extrudes opposite to `direction`)
241
+ * @returns The new solid as a {@linkcode BrepHandle}
242
+ * @throws if the extrusion is degenerate (zero amount, zero direction, or a
243
+ * direction lying in the contour plane) or the contour cannot be extruded
244
+ * into a valid solid
245
+ *
246
+ * @examplePrompt Extrude this profile 3 metres up
247
+ * @examplePrompt Make a solid by extruding this outline
248
+ * @examplePrompt Create a cylinder from a circle profile
249
+ *
250
+ * # Example
251
+ * ```ts
252
+ * const rect = await snaptrude.core.geom.create.profileRect(4, 3)
253
+ * const contour = await snaptrude.core.geom.create.contourFromProfile(rect)
254
+ * const brep = await snaptrude.core.geom.create.brepFromExtrusion(contour, { x: 0, y: 1, z: 0 }, 3)
255
+ * const faceCount = await snaptrude.core.geom.query.brep.getFaceCount(brep) // 6
256
+ * ```
257
+ */
258
+ public abstract brepFromExtrusion(
259
+ contour: ContourHandle,
260
+ direction: Vec3Components,
261
+ amount: number,
262
+ ): PluginApiReturn<BrepHandle>
263
+
264
+ /**
265
+ * Create a closed solid **B-rep** by lofting between a bottom and a top
266
+ * contour. Host API call — returns a {@linkcode BrepHandle}. Both contours
267
+ * must have the same number of edges (and matching hole counts); side faces
268
+ * connect corresponding edges by authored index. Corresponding edges must
269
+ * stay coplanar — a twisted loft would produce non-planar side faces and is
270
+ * rejected. The contours are copied — the input handles are never mutated.
271
+ *
272
+ * Inspect the result via `core.geom.query.brep.*`, or commit it to the scene
273
+ * with `design.create.massFromBrep`.
274
+ *
275
+ * @param bottomContour The bottom cross-section
276
+ * @param topContour The top cross-section (same edge and hole counts as the bottom)
277
+ * @returns The new solid as a {@linkcode BrepHandle}
278
+ * @throws if the contours are coincident, their edge or hole counts differ,
279
+ * a side face between corresponding edges would be non-planar, or the
280
+ * contours cannot be lofted into a valid solid
281
+ *
282
+ * @examplePrompt Make a tapered tower from these two outlines
283
+ * @examplePrompt Loft between a large base and a smaller top
284
+ * @examplePrompt Create a frustum from two squares
285
+ *
286
+ * # Example
287
+ * ```ts
288
+ * // A square frustum: 4m base lofted to a 2m top, 3m up
289
+ * const base = await snaptrude.core.geom.create.profileRect(4, 4)
290
+ * const top = await snaptrude.core.geom.create.profileRect(2, 2, await snaptrude.core.math.vec3.new(0, 3, 0))
291
+ * const brep = await snaptrude.core.geom.create.brepFromLoft(
292
+ * await snaptrude.core.geom.create.contourFromProfile(base),
293
+ * await snaptrude.core.geom.create.contourFromProfile(top),
294
+ * )
295
+ * const faceCount = await snaptrude.core.geom.query.brep.getFaceCount(brep) // 6
296
+ * ```
297
+ */
298
+ public abstract brepFromLoft(
299
+ bottomContour: ContourHandle,
300
+ topContour: ContourHandle,
301
+ ): PluginApiReturn<BrepHandle>
302
+
303
+ /**
304
+ * Create a closed solid **B-rep** from indexed mesh data: a vertex position
305
+ * array plus face loops of indices into it. Host API call — returns a
306
+ * {@linkcode BrepHandle}. The indexed form of
307
+ * {@linkcode PluginGeomCreateApi.brepFromFaces} — same validation (planar
308
+ * faces, closed manifold solid, every edge shared by exactly two faces) after
309
+ * the indices are expanded to point loops.
310
+ *
311
+ * Inspect the result via `core.geom.query.brep.*`, or commit it to the scene
312
+ * with `design.create.massFromBrep`.
313
+ *
314
+ * @param positions Vertex positions as plain `{x, y, z}` components (≥4)
315
+ * @param faces Face loops — each an ordered array of indices into `positions` (≥3 indices per face, ≥4 faces)
316
+ * @returns The new solid as a {@linkcode BrepHandle}
317
+ * @throws if an index is not an integer within `positions` bounds, a face is
318
+ * degenerate or non-planar, or the faces do not form a valid closed solid
319
+ *
320
+ * @examplePrompt Create a brep from mesh vertices and indices
321
+ * @examplePrompt Turn this indexed mesh into a solid
322
+ * @examplePrompt Build a solid from vertex positions and face indices
323
+ *
324
+ * # Example
325
+ * ```ts
326
+ * // A tetrahedron from 4 vertices and 4 triangular faces
327
+ * const positions = [
328
+ * { x: 0, y: 0, z: 0 },
329
+ * { x: 4, y: 0, z: 0 },
330
+ * { x: 2, y: 0, z: 4 },
331
+ * { x: 2, y: 3, z: 1.5 },
332
+ * ]
333
+ * const brep = await snaptrude.core.geom.create.brepFromMesh(positions, [
334
+ * [0, 2, 1], // base
335
+ * [0, 1, 3],
336
+ * [1, 2, 3],
337
+ * [2, 0, 3],
338
+ * ])
339
+ * const vertexCount = await snaptrude.core.geom.query.brep.getVertexCount(brep) // 4
340
+ * ```
341
+ */
342
+ public abstract brepFromMesh(
343
+ positions: Vec3Components[],
344
+ faces: number[][],
345
+ ): PluginApiReturn<BrepHandle>
346
+
347
+ /**
348
+ * Create a closed solid **B-rep** as the boolean **union** of two breps
349
+ * (`a ∪ b`). Host API call — returns a new {@linkcode BrepHandle}. Inputs are
350
+ * read-only and may be authored breps (any `core.geom.create` brep
351
+ * constructor) or scene-derived breps from `design.query.geometry.getBrep`;
352
+ * coordinates are combined as-is, so both inputs must share a frame. The
353
+ * result must be a single solid — disjoint inputs are rejected.
354
+ *
355
+ * The first boolean call loads the OpenCascade geometry kernel (a wasm of
356
+ * tens of MB — expect a pause of seconds); subsequent calls are fast.
357
+ *
358
+ * @param a First solid
359
+ * @param b Second solid
360
+ * @returns The union as a new {@linkcode BrepHandle}
361
+ * @throws if the inputs do not overlap or touch (the union would be disjoint
362
+ * solids) or the result cannot be built as a valid single solid
363
+ *
364
+ * @examplePrompt Union these two solids
365
+ * @examplePrompt Merge these breps into one mass
366
+ * @examplePrompt Combine the tower and the podium into a single solid
367
+ *
368
+ * # Example
369
+ * ```ts
370
+ * const a = await snaptrude.core.geom.create.brepFromExtrusion(baseContour, { x: 0, y: 1, z: 0 }, 3)
371
+ * const b = await snaptrude.core.geom.create.brepFromExtrusion(overlappingContour, { x: 0, y: 1, z: 0 }, 5)
372
+ * const merged = await snaptrude.core.geom.create.brepFromUnion(a, b)
373
+ * ```
374
+ */
375
+ public abstract brepFromUnion(a: BrepHandle, b: BrepHandle): PluginApiReturn<BrepHandle>
376
+
377
+ /**
378
+ * Create a closed solid **B-rep** as the boolean **subtraction** of two
379
+ * breps: **`a` minus `b`** — `b` is cut away from `a`. Host API call —
380
+ * returns a new {@linkcode BrepHandle}. Argument order matters:
381
+ * `brepFromSubtraction(a, b)` removes `b`'s volume from `a`. Inputs are
382
+ * read-only and may be authored or scene-derived breps (see
383
+ * {@linkcode PluginGeomCreateApi.brepFromUnion}); coordinates are combined
384
+ * as-is.
385
+ *
386
+ * The first boolean call loads the OpenCascade geometry kernel (a wasm of
387
+ * tens of MB — expect a pause of seconds); subsequent calls are fast.
388
+ *
389
+ * @param a The solid to subtract from
390
+ * @param b The solid to remove from `a`
391
+ * @returns `a` minus `b` as a new {@linkcode BrepHandle}
392
+ * @throws if `b` consumes `a` entirely (empty result), the result splits into
393
+ * disjoint solids, or it cannot be built as a valid single solid
394
+ *
395
+ * @examplePrompt Subtract the courtyard from the building mass
396
+ * @examplePrompt Cut this solid out of that one
397
+ * @examplePrompt Punch a hole through the slab with this box
398
+ *
399
+ * # Example
400
+ * ```ts
401
+ * // buildingBrep minus courtyardBrep — order matters
402
+ * const carved = await snaptrude.core.geom.create.brepFromSubtraction(buildingBrep, courtyardBrep)
403
+ * ```
404
+ */
405
+ public abstract brepFromSubtraction(a: BrepHandle, b: BrepHandle): PluginApiReturn<BrepHandle>
406
+
407
+ /**
408
+ * Create a closed solid **B-rep** as the boolean **intersection** of two
409
+ * breps (`a ∩ b` — the shared volume only). Host API call — returns a new
410
+ * {@linkcode BrepHandle}. Inputs are read-only and may be authored or
411
+ * scene-derived breps (see {@linkcode PluginGeomCreateApi.brepFromUnion});
412
+ * coordinates are combined as-is.
413
+ *
414
+ * The first boolean call loads the OpenCascade geometry kernel (a wasm of
415
+ * tens of MB — expect a pause of seconds); subsequent calls are fast.
416
+ *
417
+ * @param a First solid
418
+ * @param b Second solid
419
+ * @returns The shared volume as a new {@linkcode BrepHandle}
420
+ * @throws if the inputs do not overlap (empty intersection), the result
421
+ * splits into disjoint solids, or it cannot be built as a valid single
422
+ * solid
423
+ *
424
+ * @examplePrompt Keep only the overlap of these two solids
425
+ * @examplePrompt Intersect these two masses
426
+ * @examplePrompt Clip the tower to the zoning envelope
427
+ *
428
+ * # Example
429
+ * ```ts
430
+ * const overlap = await snaptrude.core.geom.create.brepFromIntersection(towerBrep, envelopeBrep)
431
+ * ```
432
+ */
433
+ public abstract brepFromIntersection(a: BrepHandle, b: BrepHandle): PluginApiReturn<BrepHandle>
180
434
  }
181
435
 
182
436
  /**
@@ -291,3 +545,92 @@ export const PluginGeomCreateContourFromProfilesArgs = z.object({
291
545
  export type PluginGeomCreateContourFromProfilesArgs = z.infer<
292
546
  typeof PluginGeomCreateContourFromProfilesArgs
293
547
  >
548
+
549
+ /**
550
+ * Arguments for {@linkcode PluginGeomCreateApi.brepFromFaces}.
551
+ *
552
+ * | Property | Type | Description |
553
+ * |---|---|---|
554
+ * | `faces` | {@linkcode Vec3Components}`[][]` | Face loops — each an ordered array of `{x, y, z}` points (≥3 points per face, ≥4 faces) |
555
+ */
556
+ export const PluginGeomCreateBrepFromFacesArgs = z.object({
557
+ faces: z.array(z.array(Vec3Components).min(3)).min(4),
558
+ })
559
+
560
+ export type PluginGeomCreateBrepFromFacesArgs = z.infer<
561
+ typeof PluginGeomCreateBrepFromFacesArgs
562
+ >
563
+
564
+ /**
565
+ * Arguments for {@linkcode PluginGeomCreateApi.brepFromExtrusion}.
566
+ *
567
+ * | Property | Type | Description |
568
+ * |---|---|---|
569
+ * | `contour` | {@linkcode ContourHandle} | The cross-section to extrude |
570
+ * | `direction` | {@linkcode Vec3Components} | Extrusion direction (non-zero, finite components) |
571
+ * | `amount` | `number` | Extrusion distance (finite, non-zero) |
572
+ */
573
+ export const PluginGeomCreateBrepFromExtrusionArgs = z.object({
574
+ contour: ContourHandle,
575
+ direction: z.object({
576
+ x: z.number().finite(),
577
+ y: z.number().finite(),
578
+ z: z.number().finite(),
579
+ }),
580
+ amount: z
581
+ .number()
582
+ .finite()
583
+ .refine((value) => value !== 0, { message: "amount must be non-zero" }),
584
+ })
585
+
586
+ export type PluginGeomCreateBrepFromExtrusionArgs = z.infer<
587
+ typeof PluginGeomCreateBrepFromExtrusionArgs
588
+ >
589
+
590
+ /**
591
+ * Arguments for {@linkcode PluginGeomCreateApi.brepFromLoft}.
592
+ *
593
+ * | Property | Type | Description |
594
+ * |---|---|---|
595
+ * | `bottomContour` | {@linkcode ContourHandle} | The bottom cross-section |
596
+ * | `topContour` | {@linkcode ContourHandle} | The top cross-section |
597
+ */
598
+ export const PluginGeomCreateBrepFromLoftArgs = z.object({
599
+ bottomContour: ContourHandle,
600
+ topContour: ContourHandle,
601
+ })
602
+
603
+ export type PluginGeomCreateBrepFromLoftArgs = z.infer<typeof PluginGeomCreateBrepFromLoftArgs>
604
+
605
+ /**
606
+ * Arguments for {@linkcode PluginGeomCreateApi.brepFromMesh}.
607
+ *
608
+ * | Property | Type | Description |
609
+ * |---|---|---|
610
+ * | `positions` | {@linkcode Vec3Components}`[]` | Vertex positions (≥4) |
611
+ * | `faces` | `number[][]` | Face loops of indices into `positions` (≥3 indices per face, ≥4 faces) |
612
+ */
613
+ export const PluginGeomCreateBrepFromMeshArgs = z.object({
614
+ positions: z.array(Vec3Components).min(4),
615
+ faces: z.array(z.array(z.number()).min(3)).min(4),
616
+ })
617
+
618
+ export type PluginGeomCreateBrepFromMeshArgs = z.infer<typeof PluginGeomCreateBrepFromMeshArgs>
619
+
620
+ /**
621
+ * Arguments for the brep boolean constructors —
622
+ * {@linkcode PluginGeomCreateApi.brepFromUnion},
623
+ * {@linkcode PluginGeomCreateApi.brepFromSubtraction} (`a` minus `b`), and
624
+ * {@linkcode PluginGeomCreateApi.brepFromIntersection}.
625
+ *
626
+ * | Property | Type | Description |
627
+ * |---|---|---|
628
+ * | `a` | {@linkcode BrepHandle} | First solid (the subtraction target) |
629
+ * | `b` | {@linkcode BrepHandle} | Second solid (the subtraction tool) |
630
+ */
631
+ export const PluginGeomCreateBrepBooleanArgs = z.object({
632
+ a: BrepHandle,
633
+ b: BrepHandle,
634
+ })
635
+
636
+ export type PluginGeomCreateBrepBooleanArgs = z.infer<typeof PluginGeomCreateBrepBooleanArgs>
@@ -20,6 +20,9 @@ export abstract class PluginGeomDeleteApi {
20
20
  * reclaims its share of the plugin's resource quota. This is a handle-lifecycle
21
21
  * operation only and does NOT tear down any engine-side geometry.
22
22
  *
23
+ * @deprecated Use `core.handles.release([profile])` — the universal, batched
24
+ * release API for every arena handle kind.
25
+ *
23
26
  * @param profile The transient profile handle to release
24
27
  * @returns Nothing
25
28
  *
@@ -37,6 +40,9 @@ export abstract class PluginGeomDeleteApi {
37
40
  * reclaims its share of the plugin's resource quota. Handle-lifecycle only; does
38
41
  * NOT tear down engine-side geometry, nor the contour's child profile handles.
39
42
  *
43
+ * @deprecated Use `core.handles.release([contour])` — the universal, batched
44
+ * release API for every arena handle kind.
45
+ *
40
46
  * @param contour The transient contour handle to release
41
47
  * @returns Nothing
42
48
  *