@snaptrude/plugin-core 0.0.0-dev-20260708130115 → 0.0.0-dev-20260827135706
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.
- package/CHANGELOG.md +152 -1
- package/api-manifest.json +3620 -276
- package/dist/api/analysis/daylight.d.ts +603 -0
- package/dist/api/analysis/daylight.d.ts.map +1 -0
- package/dist/api/analysis/heatmaps.d.ts +658 -0
- package/dist/api/analysis/heatmaps.d.ts.map +1 -0
- package/dist/api/analysis/illuminance.d.ts +145 -0
- package/dist/api/analysis/illuminance.d.ts.map +1 -0
- package/dist/api/analysis/index.d.ts +59 -0
- package/dist/api/analysis/index.d.ts.map +1 -0
- package/dist/api/analysis/shadows.d.ts +165 -0
- package/dist/api/analysis/shadows.d.ts.map +1 -0
- package/dist/api/analysis/solar.d.ts +249 -0
- package/dist/api/analysis/solar.d.ts.map +1 -0
- package/dist/api/analysis/sunlightHours.d.ts +208 -0
- package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
- package/dist/api/analysis/sunpath.d.ts +80 -0
- package/dist/api/analysis/sunpath.d.ts.map +1 -0
- package/dist/api/analysis/weather.d.ts +193 -0
- package/dist/api/analysis/weather.d.ts.map +1 -0
- package/dist/api/core/camera/index.d.ts +261 -0
- package/dist/api/core/camera/index.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +105 -2
- package/dist/api/core/comment/index.d.ts.map +1 -1
- package/dist/api/core/geom/create/index.d.ts +840 -14
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/delete/index.d.ts +8 -2
- package/dist/api/core/geom/delete/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +5 -5
- package/dist/api/core/geom/query/brep.d.ts +130 -18
- package/dist/api/core/geom/query/brep.d.ts.map +1 -1
- package/dist/api/core/geom/query/circle.d.ts +18 -18
- package/dist/api/core/geom/query/contour.d.ts +20 -20
- package/dist/api/core/geom/query/curve.d.ts +49 -49
- package/dist/api/core/geom/query/edge.d.ts +5 -5
- package/dist/api/core/geom/query/face.d.ts +16 -16
- package/dist/api/core/geom/query/halfedge.d.ts +8 -8
- package/dist/api/core/geom/query/profile.d.ts +19 -19
- package/dist/api/core/geom/query/vertex.d.ts +8 -8
- package/dist/api/core/geom/update/contour.d.ts +14 -14
- package/dist/api/core/geom/update/curve.d.ts +7 -7
- package/dist/api/core/geom/update/profile.d.ts +16 -16
- package/dist/api/core/handles/index.d.ts +210 -0
- package/dist/api/core/handles/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +34 -0
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/export/index.d.ts +134 -0
- package/dist/api/core/io/export/index.d.ts.map +1 -0
- package/dist/api/core/io/import/index.d.ts +453 -0
- package/dist/api/core/io/import/index.d.ts.map +1 -0
- package/dist/api/core/io/index.d.ts +40 -0
- package/dist/api/core/io/index.d.ts.map +1 -0
- package/dist/api/core/io/job/index.d.ts +139 -0
- package/dist/api/core/io/job/index.d.ts.map +1 -0
- package/dist/api/core/io/query/index.d.ts +74 -0
- package/dist/api/core/io/query/index.d.ts.map +1 -0
- package/dist/api/core/io/terrain/index.d.ts +341 -0
- package/dist/api/core/io/terrain/index.d.ts.map +1 -0
- package/dist/api/core/io/underlay/index.d.ts +805 -0
- package/dist/api/core/io/underlay/index.d.ts.map +1 -0
- package/dist/api/core/layers.d.ts +7 -7
- package/dist/api/core/mode/index.d.ts +99 -0
- package/dist/api/core/mode/index.d.ts.map +1 -0
- package/dist/api/core/project/index.d.ts +68 -1
- package/dist/api/core/project/index.d.ts.map +1 -1
- package/dist/api/core/proposals/index.d.ts +531 -0
- package/dist/api/core/proposals/index.d.ts.map +1 -0
- package/dist/api/core/storeys/index.d.ts +265 -0
- package/dist/api/core/storeys/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +24 -0
- package/dist/api/core/tags.d.ts.map +1 -1
- package/dist/api/core/user.d.ts +44 -0
- package/dist/api/core/user.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +4 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -1
- package/dist/api/design/boolean/index.d.ts +4 -4
- package/dist/api/design/create/index.d.ts +568 -45
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/delete/index.d.ts +3 -0
- package/dist/api/design/delete/index.d.ts.map +1 -1
- package/dist/api/design/doors/index.d.ts +195 -0
- package/dist/api/design/doors/index.d.ts.map +1 -1
- package/dist/api/design/edit/index.d.ts +1 -1
- package/dist/api/design/erase/index.d.ts +2 -2
- package/dist/api/design/family.d.ts +349 -0
- package/dist/api/design/family.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +181 -8
- package/dist/api/design/furniture/index.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +98 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/lock.d.ts +26 -0
- package/dist/api/design/lock.d.ts.map +1 -1
- package/dist/api/design/materials/index.d.ts +270 -16
- package/dist/api/design/materials/index.d.ts.map +1 -1
- package/dist/api/design/query/geometry/index.d.ts +112 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/index.d.ts +282 -11
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/referenceLines.d.ts +45 -0
- package/dist/api/design/query/referenceLines.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +181 -8
- package/dist/api/design/query/spaces.d.ts.map +1 -1
- package/dist/api/design/selection/index.d.ts +144 -0
- package/dist/api/design/selection/index.d.ts.map +1 -1
- package/dist/api/design/transform/index.d.ts +172 -10
- package/dist/api/design/transform/index.d.ts.map +1 -1
- package/dist/api/design/types/index.d.ts +181 -0
- package/dist/api/design/types/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +553 -2
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/design/visibility.d.ts +126 -0
- package/dist/api/design/visibility.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +113 -2
- package/dist/api/design/windows/index.d.ts.map +1 -1
- package/dist/api/entity/buildableEnvelope.d.ts +4 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +10 -2
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +21 -21
- package/dist/api/entity/story.d.ts +242 -15
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +25 -25
- package/dist/api/presentation/annotate.d.ts +467 -0
- package/dist/api/presentation/annotate.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +111 -8
- package/dist/api/presentation/diagrams.d.ts.map +1 -1
- package/dist/api/presentation/export.d.ts +108 -0
- package/dist/api/presentation/export.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +55 -4
- package/dist/api/presentation/import.d.ts.map +1 -1
- package/dist/api/presentation/index.d.ts +58 -1
- package/dist/api/presentation/index.d.ts.map +1 -1
- package/dist/api/presentation/placedViews.d.ts +1139 -0
- package/dist/api/presentation/placedViews.d.ts.map +1 -0
- package/dist/api/presentation/shapes.d.ts +481 -0
- package/dist/api/presentation/shapes.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +452 -13
- package/dist/api/presentation/sheets.d.ts.map +1 -1
- package/dist/api/presentation/slideshow.d.ts +125 -0
- package/dist/api/presentation/slideshow.d.ts.map +1 -0
- package/dist/api/presentation/tables.d.ts +81 -0
- package/dist/api/presentation/tables.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +367 -7
- package/dist/api/presentation/views.d.ts.map +1 -1
- package/dist/api/program/areas.d.ts +102 -12
- package/dist/api/program/areas.d.ts.map +1 -1
- package/dist/api/program/cores.d.ts +3 -99
- package/dist/api/program/cores.d.ts.map +1 -1
- package/dist/api/program/index.d.ts +7 -15
- package/dist/api/program/index.d.ts.map +1 -1
- package/dist/api/program/layout.d.ts +346 -11
- package/dist/api/program/layout.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +469 -13
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/api/program/spreadsheet.d.ts +365 -41
- package/dist/api/program/spreadsheet.d.ts.map +1 -1
- package/dist/api/workspace/index.d.ts +505 -0
- package/dist/api/workspace/index.d.ts.map +1 -0
- package/dist/errors/codes.d.ts +34 -0
- package/dist/errors/codes.d.ts.map +1 -0
- package/dist/errors/envelope.d.ts +56 -0
- package/dist/errors/envelope.d.ts.map +1 -0
- package/dist/errors/index.d.ts +6 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/plugin-error.d.ts +69 -0
- package/dist/errors/plugin-error.d.ts.map +1 -0
- package/dist/handles.d.ts +97 -25
- package/dist/handles.d.ts.map +1 -1
- package/dist/host-utils.d.ts +4 -0
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +4582 -1422
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4171 -1411
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/scripts/generate-manifest.mjs +45 -0
- package/scripts/generate-manifest.test.mjs +103 -4
- package/src/api/analysis/daylight.ts +470 -0
- package/src/api/analysis/heatmaps.ts +683 -0
- package/src/api/analysis/illuminance.ts +155 -0
- package/src/api/analysis/index.ts +61 -0
- package/src/api/analysis/shadows.ts +183 -0
- package/src/api/analysis/solar.ts +237 -0
- package/src/api/analysis/sunlightHours.ts +211 -0
- package/src/api/analysis/sunpath.ts +83 -0
- package/src/api/analysis/weather.ts +179 -0
- package/src/api/core/camera/index.ts +268 -0
- package/src/api/core/comment/index.ts +120 -2
- package/src/api/core/geom/create/index.ts +912 -1
- package/src/api/core/geom/delete/index.ts +6 -0
- package/src/api/core/geom/query/brep.ts +119 -0
- package/src/api/core/handles/index.ts +233 -0
- package/src/api/core/index.ts +34 -0
- package/src/api/core/io/export/index.ts +126 -0
- package/src/api/core/io/import/index.ts +496 -0
- package/src/api/core/io/index.ts +42 -0
- package/src/api/core/io/job/index.ts +140 -0
- package/src/api/core/io/query/index.ts +71 -0
- package/src/api/core/io/terrain/index.ts +360 -0
- package/src/api/core/io/underlay/index.ts +705 -0
- package/src/api/core/mode/index.ts +96 -0
- package/src/api/core/project/index.ts +62 -1
- package/src/api/core/proposals/index.ts +569 -0
- package/src/api/core/storeys/index.ts +294 -0
- package/src/api/core/tags.ts +27 -0
- package/src/api/core/user.ts +46 -0
- package/src/api/core/zoom/index.ts +4 -0
- package/src/api/design/create/index.ts +670 -30
- package/src/api/design/delete/index.ts +3 -0
- package/src/api/design/doors/index.ts +208 -0
- package/src/api/design/erase/index.ts +1 -1
- package/src/api/design/family.ts +388 -0
- package/src/api/design/furniture/index.ts +197 -8
- package/src/api/design/index.ts +102 -0
- package/src/api/design/lock.ts +27 -0
- package/src/api/design/materials/index.ts +334 -27
- package/src/api/design/query/geometry/index.ts +125 -3
- package/src/api/design/query/index.ts +217 -7
- package/src/api/design/query/referenceLines.ts +52 -0
- package/src/api/design/query/spaces.ts +143 -0
- package/src/api/design/selection/index.ts +129 -0
- package/src/api/design/transform/index.ts +170 -9
- package/src/api/design/types/index.ts +156 -0
- package/src/api/design/update/index.ts +631 -3
- package/src/api/design/visibility.ts +143 -0
- package/src/api/design/windows/index.ts +128 -2
- package/src/api/entity/buildableEnvelope.ts +4 -0
- package/src/api/entity/referenceLine.ts +8 -0
- package/src/api/entity/story.ts +259 -15
- package/src/api/index.ts +10 -0
- package/src/api/presentation/annotate.ts +385 -0
- package/src/api/presentation/diagrams.ts +118 -8
- package/src/api/presentation/export.ts +108 -0
- package/src/api/presentation/import.ts +51 -4
- package/src/api/presentation/index.ts +66 -1
- package/src/api/presentation/placedViews.ts +1120 -0
- package/src/api/presentation/shapes.ts +274 -0
- package/src/api/presentation/sheets.ts +400 -13
- package/src/api/presentation/slideshow.ts +134 -0
- package/src/api/presentation/tables.ts +84 -0
- package/src/api/presentation/views.ts +376 -8
- package/src/api/program/areas.ts +88 -15
- package/src/api/program/cores.ts +3 -91
- package/src/api/program/index.ts +7 -15
- package/src/api/program/layout.ts +365 -11
- package/src/api/program/site.ts +435 -13
- package/src/api/program/spreadsheet.ts +376 -35
- package/src/api/workspace/index.ts +563 -0
- package/src/errors/codes.ts +136 -0
- package/src/errors/envelope.ts +75 -0
- package/src/errors/index.ts +21 -0
- package/src/errors/plugin-error.ts +134 -0
- package/src/handles.ts +123 -13
- package/src/host-utils.ts +4 -0
- package/src/index.ts +1 -0
- package/test/errors.test.mjs +184 -0
- package/tsconfig.json +7 -2
|
@@ -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
|
*
|
|
@@ -163,6 +163,64 @@ export abstract class PluginGeomQueryBrepApi {
|
|
|
163
163
|
vertexIndexB: number
|
|
164
164
|
): PluginApiReturn<EdgeHandle[]>
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Read the exact curve of a brep edge as plain values — a discriminated
|
|
168
|
+
* union on `type`. Pure read: no geometry kernel is loaded. Points and
|
|
169
|
+
* directions are {@linkcode Vec3Components}; lengths and radii are raw
|
|
170
|
+
* Babylon units.
|
|
171
|
+
*
|
|
172
|
+
* | `type` | Fields |
|
|
173
|
+
* |---|---|
|
|
174
|
+
* | `"line"` | `startPoint`, `endPoint`, `length` |
|
|
175
|
+
* | `"arc"` | `startPoint`, `endPoint`, `centre`, `axis`, `radius`, `length` |
|
|
176
|
+
* | `"circle"` | `centre`, `axis`, `radius`, `length` — a full-circle edge (e.g. a cylinder cap rim) |
|
|
177
|
+
*
|
|
178
|
+
* @param brep The brep the edge belongs to
|
|
179
|
+
* @param edge The edge whose curve to read
|
|
180
|
+
* @returns The curve data as a discriminated union on `type` (see table above)
|
|
181
|
+
* @throws VALIDATION if the edge is not on `brep`
|
|
182
|
+
*
|
|
183
|
+
* @examplePrompt Read the radius of this curved edge
|
|
184
|
+
* @examplePrompt Is this edge straight or an arc?
|
|
185
|
+
* @examplePrompt Get the exact start and end points of this edge
|
|
186
|
+
* @examplePrompt Measure the length of each edge of this mass
|
|
187
|
+
*
|
|
188
|
+
* # Example
|
|
189
|
+
* ```ts
|
|
190
|
+
* const [mass] = await snaptrude.design.query.listMasses()
|
|
191
|
+
* const brep = await snaptrude.design.query.geometry.getBrep(mass)
|
|
192
|
+
* if (brep) {
|
|
193
|
+
* const edges = await snaptrude.core.geom.query.brep.listEdges(brep)
|
|
194
|
+
* for (const edge of edges) {
|
|
195
|
+
* const curve = await snaptrude.core.geom.query.brep.getEdgeCurve(brep, edge)
|
|
196
|
+
* if (curve.type === "arc") console.log("arc radius:", curve.radius)
|
|
197
|
+
* }
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
public abstract getEdgeCurve(
|
|
202
|
+
brep: BrepHandle,
|
|
203
|
+
edge: EdgeHandle
|
|
204
|
+
): PluginApiReturn<
|
|
205
|
+
| { type: "line"; startPoint: Vec3Components; endPoint: Vec3Components; length: number }
|
|
206
|
+
| {
|
|
207
|
+
type: "arc"
|
|
208
|
+
startPoint: Vec3Components
|
|
209
|
+
endPoint: Vec3Components
|
|
210
|
+
centre: Vec3Components
|
|
211
|
+
axis: Vec3Components
|
|
212
|
+
radius: number
|
|
213
|
+
length: number
|
|
214
|
+
}
|
|
215
|
+
| {
|
|
216
|
+
type: "circle"
|
|
217
|
+
centre: Vec3Components
|
|
218
|
+
axis: Vec3Components
|
|
219
|
+
radius: number
|
|
220
|
+
length: number
|
|
221
|
+
}
|
|
222
|
+
>
|
|
223
|
+
|
|
166
224
|
/**
|
|
167
225
|
* Get the position of a vertex within a brep.
|
|
168
226
|
* @param brep The brep to query
|
|
@@ -328,6 +386,37 @@ export abstract class PluginGeomQueryBrepApi {
|
|
|
328
386
|
* ```
|
|
329
387
|
*/
|
|
330
388
|
public abstract isEqual(brepA: BrepHandle, brepB: BrepHandle): PluginApiReturn<boolean>
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Measures the minimum distance between two solids, with the closest witness
|
|
392
|
+
* point on each. Touching or overlapping solids report a distance of 0 with
|
|
393
|
+
* contact points.
|
|
394
|
+
*
|
|
395
|
+
* @param brepA First solid
|
|
396
|
+
* @param brepB Second solid
|
|
397
|
+
* @returns `{ distance, pointA, pointB }` — the minimum distance and the
|
|
398
|
+
* closest points on `brepA` and `brepB` as {@linkcode Vec3Components}
|
|
399
|
+
* @throws OPERATION_FAILED if the kernel cannot compute the distance
|
|
400
|
+
*
|
|
401
|
+
* @examplePrompt What is the clearance between these two masses?
|
|
402
|
+
* @examplePrompt How far apart are the tower and the neighbouring building?
|
|
403
|
+
* @examplePrompt Find the closest points between these two solids
|
|
404
|
+
*
|
|
405
|
+
* # Example
|
|
406
|
+
* ```ts
|
|
407
|
+
* const [a, b] = await snaptrude.design.query.listMasses()
|
|
408
|
+
* const brepA = await snaptrude.design.query.geometry.getBrep(a)
|
|
409
|
+
* const brepB = await snaptrude.design.query.geometry.getBrep(b)
|
|
410
|
+
* if (brepA && brepB) {
|
|
411
|
+
* const { distance, pointA, pointB } = await snaptrude.core.geom.query.brep.getDistance(brepA, brepB)
|
|
412
|
+
* console.log("clearance:", distance)
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
public abstract getDistance(
|
|
417
|
+
brepA: BrepHandle,
|
|
418
|
+
brepB: BrepHandle
|
|
419
|
+
): PluginApiReturn<{ distance: number; pointA: Vec3Components; pointB: Vec3Components }>
|
|
331
420
|
}
|
|
332
421
|
|
|
333
422
|
const brepArg = z.object({ brep: BrepHandle })
|
|
@@ -377,6 +466,22 @@ export type PluginGeomQueryBrepListEdgesBetweenArgs = z.infer<
|
|
|
377
466
|
typeof PluginGeomQueryBrepListEdgesBetweenArgs
|
|
378
467
|
>
|
|
379
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Arguments for {@linkcode PluginGeomQueryBrepApi.getEdgeCurve}.
|
|
471
|
+
*
|
|
472
|
+
* | Property | Type | Description |
|
|
473
|
+
* |---|---|---|
|
|
474
|
+
* | `brep` | {@linkcode BrepHandle} | The brep the edge belongs to |
|
|
475
|
+
* | `edge` | {@linkcode EdgeHandle} | The edge whose curve to read |
|
|
476
|
+
*/
|
|
477
|
+
export const PluginGeomQueryBrepGetEdgeCurveArgs = z.object({
|
|
478
|
+
brep: BrepHandle,
|
|
479
|
+
edge: EdgeHandle,
|
|
480
|
+
})
|
|
481
|
+
export type PluginGeomQueryBrepGetEdgeCurveArgs = z.infer<
|
|
482
|
+
typeof PluginGeomQueryBrepGetEdgeCurveArgs
|
|
483
|
+
>
|
|
484
|
+
|
|
380
485
|
/**
|
|
381
486
|
* Arguments for {@linkcode PluginGeomQueryBrepApi.getVertexPosition}.
|
|
382
487
|
*
|
|
@@ -442,3 +547,17 @@ export const PluginGeomQueryBrepIsEqualArgs = z.object({
|
|
|
442
547
|
brepB: BrepHandle,
|
|
443
548
|
})
|
|
444
549
|
export type PluginGeomQueryBrepIsEqualArgs = z.infer<typeof PluginGeomQueryBrepIsEqualArgs>
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Arguments for {@linkcode PluginGeomQueryBrepApi.getDistance}.
|
|
553
|
+
*
|
|
554
|
+
* | Property | Type | Description |
|
|
555
|
+
* |---|---|---|
|
|
556
|
+
* | `brepA` | {@linkcode BrepHandle} | First solid |
|
|
557
|
+
* | `brepB` | {@linkcode BrepHandle} | Second solid |
|
|
558
|
+
*/
|
|
559
|
+
export const PluginGeomQueryBrepGetDistanceArgs = z.object({
|
|
560
|
+
brepA: BrepHandle,
|
|
561
|
+
brepB: BrepHandle,
|
|
562
|
+
})
|
|
563
|
+
export type PluginGeomQueryBrepGetDistanceArgs = z.infer<typeof PluginGeomQueryBrepGetDistanceArgs>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
// Type-only: src/handles.ts type-only-imports ArenaKind from this file, so the
|
|
4
|
+
// cycle stays purely type-level and is erased at emit.
|
|
5
|
+
import type { AnyArenaHandle } from "../../../handles"
|
|
6
|
+
import { Handle } from "../../../handles"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The 12 registry-arena handle kinds — the releasable families. Entity-style
|
|
10
|
+
* handles (component / material / underlay / terrain / importJob / comment) are
|
|
11
|
+
* raw engine ids with no arena entry and therefore no lifecycle: passing one to
|
|
12
|
+
* `release` is a silent no-op like any other unknown id.
|
|
13
|
+
*/
|
|
14
|
+
export const ArenaKind = z.enum([
|
|
15
|
+
"vec3",
|
|
16
|
+
"quat",
|
|
17
|
+
"line",
|
|
18
|
+
"arc",
|
|
19
|
+
"circle",
|
|
20
|
+
"profile",
|
|
21
|
+
"contour",
|
|
22
|
+
"brep",
|
|
23
|
+
"face",
|
|
24
|
+
"edge",
|
|
25
|
+
"halfedge",
|
|
26
|
+
"vertex",
|
|
27
|
+
])
|
|
28
|
+
export type ArenaKind = z.infer<typeof ArenaKind>
|
|
29
|
+
|
|
30
|
+
/** Max handles accepted by a single `release` / `endScope(retain)` call. */
|
|
31
|
+
export const RELEASE_BATCH_MAX = 10_000
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An opaque token identifying a handle scope opened by
|
|
35
|
+
* {@linkcode PluginCoreHandlesApi.beginScope}. It is NOT an arena handle —
|
|
36
|
+
* it pins no memory, and `release(token)` is a silent no-op; only
|
|
37
|
+
* {@linkcode PluginCoreHandlesApi.endScope} consumes it.
|
|
38
|
+
*/
|
|
39
|
+
export type ScopeToken = string
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Handle lifecycle — free host-side handle registry entries the plugin no
|
|
43
|
+
* longer needs, individually ({@linkcode release}), by kind
|
|
44
|
+
* ({@linkcode releaseAll}), or as a mint-recording region
|
|
45
|
+
* ({@linkcode beginScope} / {@linkcode endScope}).
|
|
46
|
+
*
|
|
47
|
+
* Releasing is a handle-lifecycle operation only: it frees the registry entry
|
|
48
|
+
* (host memory + quota room) and makes the handle unresolvable. It never
|
|
49
|
+
* deletes engine-side geometry or scene entities.
|
|
50
|
+
*
|
|
51
|
+
* Accessed via `snaptrude.core.handles`.
|
|
52
|
+
*/
|
|
53
|
+
export abstract class PluginCoreHandlesApi {
|
|
54
|
+
constructor() {}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Free arena handles in bulk. Unknown, foreign, or already-released ids are
|
|
58
|
+
* silent no-ops — there is no per-id result and no count, so responses can
|
|
59
|
+
* never be used as an existence oracle.
|
|
60
|
+
*
|
|
61
|
+
* @param handles The handles to release (max {@linkcode RELEASE_BATCH_MAX} per call)
|
|
62
|
+
* @returns Nothing
|
|
63
|
+
*
|
|
64
|
+
* # Example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const faces = await snaptrude.core.geom.query.brep.listFaces(brep)
|
|
67
|
+
* // ... read what you need ...
|
|
68
|
+
* await snaptrude.core.handles.release(faces)
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
public abstract release(handles: ReadonlyArray<AnyArenaHandle>): PluginApiReturn<void>
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Free every live arena handle of one kind, or ALL arena handles when the
|
|
75
|
+
* kind is omitted. Useful at batch boundaries — e.g. a poll loop that mints
|
|
76
|
+
* a fresh footprint contour per tick.
|
|
77
|
+
*
|
|
78
|
+
* @param kind Optional arena kind to restrict the sweep to
|
|
79
|
+
* @returns Nothing
|
|
80
|
+
*
|
|
81
|
+
* # Example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const footprint = await snaptrude.design.query.spaces.getFootprint(space)
|
|
84
|
+
* // ... measure ...
|
|
85
|
+
* await snaptrude.core.handles.releaseAll("contour")
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
public abstract releaseAll(kind?: ArenaKind): PluginApiReturn<void>
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Open a mint-recording scope: every arena handle MINTED after this call
|
|
92
|
+
* (fresh mints only — identity-deduped re-registrations of pre-existing
|
|
93
|
+
* objects are not captured) is freed when the matching
|
|
94
|
+
* {@linkcode endScope} runs. Scopes nest, up to 64 deep — always pair
|
|
95
|
+
* begin/end in try/finally.
|
|
96
|
+
*
|
|
97
|
+
* @returns The scope token to pass to {@linkcode endScope}
|
|
98
|
+
*
|
|
99
|
+
* # Example
|
|
100
|
+
* ```ts
|
|
101
|
+
* for (const space of spaces) {
|
|
102
|
+
* const scope = await snaptrude.core.handles.beginScope()
|
|
103
|
+
* try {
|
|
104
|
+
* const footprint = await snaptrude.design.query.spaces.getFootprint(space)
|
|
105
|
+
* const area = await snaptrude.core.geom.query.contour.getArea(footprint)
|
|
106
|
+
* } finally {
|
|
107
|
+
* await snaptrude.core.handles.endScope(scope) // footprint (and intermediates) freed
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
public abstract beginScope(): PluginApiReturn<ScopeToken>
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Close a scope by its token and free every handle it recorded, except those
|
|
116
|
+
* listed in `retain`. Retained handles are promoted to the enclosing scope
|
|
117
|
+
* (if any), so nesting composes like block scopes. Closing is
|
|
118
|
+
* token-addressed: an out-of-order close (interleaved async tasks) frees
|
|
119
|
+
* only that scope's mints and leaves other open scopes intact. Always pair
|
|
120
|
+
* begin/end in try/finally so a thrown body cannot leak the scope.
|
|
121
|
+
*
|
|
122
|
+
* @param scope The token returned by the matching {@linkcode beginScope}
|
|
123
|
+
* @param retain Handles minted inside the scope that must survive it
|
|
124
|
+
* @returns Nothing
|
|
125
|
+
*
|
|
126
|
+
* # Example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const scope = await snaptrude.core.handles.beginScope()
|
|
129
|
+
* const outline = await snaptrude.design.query.spaces.getFootprint(space)
|
|
130
|
+
* const outer = await snaptrude.core.geom.query.contour.getOuterProfile(outline)
|
|
131
|
+
* await snaptrude.core.handles.endScope(scope, [outer]) // outline freed, outer survives
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
public abstract endScope(
|
|
135
|
+
scope: ScopeToken,
|
|
136
|
+
retain?: ReadonlyArray<AnyArenaHandle>
|
|
137
|
+
): PluginApiReturn<void>
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Live handle-registry statistics for the calling plugin, plus the host
|
|
141
|
+
* page's JS heap usage (when the browser exposes it). Diagnostic surface for
|
|
142
|
+
* verifying that releases actually shrink host memory.
|
|
143
|
+
*
|
|
144
|
+
* @returns Arena entry counts, open scope depth, and host heap bytes
|
|
145
|
+
*
|
|
146
|
+
* # Example
|
|
147
|
+
* ```ts
|
|
148
|
+
* const before = await snaptrude.core.handles.stats()
|
|
149
|
+
* await snaptrude.core.handles.releaseAll("vec3")
|
|
150
|
+
* const after = await snaptrude.core.handles.stats()
|
|
151
|
+
* console.log(`freed ${before.values - after.values} value entries`)
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
public abstract stats(): PluginApiReturn<PluginHandlesStatsResult>
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Wire-normalize one handle argument: a raw id string passes through; a live
|
|
159
|
+
* `Handle` instance (direct host callers — console harness, host-internal) or a
|
|
160
|
+
* structured-clone-stripped `{id}` / tagged `{__h}` shape collapses to its id.
|
|
161
|
+
* Deliberately shape-lax beyond that (non-empty string) — a malformed id is
|
|
162
|
+
* just an id that resolves nowhere (anti-oracle).
|
|
163
|
+
*/
|
|
164
|
+
const handleIdWire = z.preprocess((v) => {
|
|
165
|
+
if (typeof v === "string") return v
|
|
166
|
+
if (v instanceof Handle) return v.id
|
|
167
|
+
if (v && typeof v === "object") {
|
|
168
|
+
const o = v as Record<string, unknown>
|
|
169
|
+
if (typeof o.__h === "string") return o.__h
|
|
170
|
+
if (typeof o.id === "string") return o.id
|
|
171
|
+
}
|
|
172
|
+
return v
|
|
173
|
+
}, z.string().min(1))
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Arguments for {@linkcode PluginCoreHandlesApi.release}.
|
|
177
|
+
*
|
|
178
|
+
* | Property | Type | Description |
|
|
179
|
+
* |---|---|---|
|
|
180
|
+
* | `handles` | `string[]` | Handles to release (≤ {@linkcode RELEASE_BATCH_MAX}) |
|
|
181
|
+
*/
|
|
182
|
+
export const PluginHandlesReleaseArgs = z.object({
|
|
183
|
+
handles: z.array(handleIdWire).max(RELEASE_BATCH_MAX),
|
|
184
|
+
})
|
|
185
|
+
export type PluginHandlesReleaseArgs = z.infer<typeof PluginHandlesReleaseArgs>
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Arguments for {@linkcode PluginCoreHandlesApi.releaseAll}.
|
|
189
|
+
*
|
|
190
|
+
* | Property | Type | Description |
|
|
191
|
+
* |---|---|---|
|
|
192
|
+
* | `kind` | {@linkcode ArenaKind} (optional) | Restrict the sweep to one kind |
|
|
193
|
+
*/
|
|
194
|
+
export const PluginHandlesReleaseAllArgs = z.object({
|
|
195
|
+
kind: ArenaKind.optional(),
|
|
196
|
+
})
|
|
197
|
+
export type PluginHandlesReleaseAllArgs = z.infer<typeof PluginHandlesReleaseAllArgs>
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Arguments for {@linkcode PluginCoreHandlesApi.endScope}.
|
|
201
|
+
*
|
|
202
|
+
* | Property | Type | Description |
|
|
203
|
+
* |---|---|---|
|
|
204
|
+
* | `scope` | {@linkcode ScopeToken} | Token from the matching `beginScope` |
|
|
205
|
+
* | `retain` | `string[]` (optional) | Scope-minted handles that must survive |
|
|
206
|
+
*/
|
|
207
|
+
export const PluginHandlesEndScopeArgs = z.object({
|
|
208
|
+
scope: z.string().regex(/^scope_[A-Za-z0-9_-]+$/, 'expected a "scope" token'),
|
|
209
|
+
retain: z.array(handleIdWire).max(RELEASE_BATCH_MAX).optional(),
|
|
210
|
+
})
|
|
211
|
+
export type PluginHandlesEndScopeArgs = z.infer<typeof PluginHandlesEndScopeArgs>
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Result of {@linkcode PluginCoreHandlesApi.stats}.
|
|
215
|
+
*
|
|
216
|
+
* | Property | Type | Description |
|
|
217
|
+
* |---|---|---|
|
|
218
|
+
* | `resources` | `number` | Live resource-arena entries (profile/contour) |
|
|
219
|
+
* | `values` | `number` | Live value-arena entries (vec3/quat/line/arc/circle) |
|
|
220
|
+
* | `topology` | `number` | Live topology-arena entries (brep/face/edge/halfedge/vertex) |
|
|
221
|
+
* | `scopes` | `number` | Currently open handle scopes |
|
|
222
|
+
* | `hostHeapUsedBytes` | `number \| null` | Host page `usedJSHeapSize` (null where unsupported) |
|
|
223
|
+
* | `hostHeapTotalBytes` | `number \| null` | Host page `totalJSHeapSize` (null where unsupported) |
|
|
224
|
+
*/
|
|
225
|
+
export const PluginHandlesStatsResult = z.object({
|
|
226
|
+
resources: z.number().int().nonnegative(),
|
|
227
|
+
values: z.number().int().nonnegative(),
|
|
228
|
+
topology: z.number().int().nonnegative(),
|
|
229
|
+
scopes: z.number().int().nonnegative(),
|
|
230
|
+
hostHeapUsedBytes: z.number().nullable(),
|
|
231
|
+
hostHeapTotalBytes: z.number().nullable(),
|
|
232
|
+
})
|
|
233
|
+
export type PluginHandlesStatsResult = z.infer<typeof PluginHandlesStatsResult>
|
package/src/api/core/index.ts
CHANGED
|
@@ -9,6 +9,13 @@ import { PluginCoreGroupsApi } from "./groups"
|
|
|
9
9
|
import { PluginCoreBuildingsApi } from "./buildings"
|
|
10
10
|
import { PluginCoreLayersApi } from "./layers"
|
|
11
11
|
import { PluginCoreTagsApi } from "./tags"
|
|
12
|
+
import { PluginCoreIoApi } from "./io"
|
|
13
|
+
import { PluginCoreHandlesApi } from "./handles"
|
|
14
|
+
import { PluginCoreProposalsApi } from "./proposals"
|
|
15
|
+
import { PluginCameraApi } from "./camera"
|
|
16
|
+
import { PluginCoreStoreysApi } from "./storeys"
|
|
17
|
+
import { PluginCoreModeApi } from "./mode"
|
|
18
|
+
import { PluginUserApi } from "./user"
|
|
12
19
|
|
|
13
20
|
/**
|
|
14
21
|
* Core primitives and infrastructure used across the plugin API.
|
|
@@ -18,12 +25,18 @@ import { PluginCoreTagsApi } from "./tags"
|
|
|
18
25
|
* - {@linkcode PluginCoreApi.history} — Undo / redo of committed history entries
|
|
19
26
|
* - {@linkcode PluginCoreApi.units} — Unit-type queries and conversion
|
|
20
27
|
* - {@linkcode PluginCoreApi.zoom} — Camera zoom controls (extents / selection)
|
|
28
|
+
* - {@linkcode PluginCoreApi.camera} — Camera controls — position, standard views, 2D/3D mode
|
|
29
|
+
* - {@linkcode PluginCoreApi.user} — User locale — timezone & language
|
|
21
30
|
* - {@linkcode PluginCoreApi.project} — Project-level settings and info
|
|
22
31
|
* - {@linkcode PluginCoreApi.comment} — Comments: create, edit, resolve, tag, list
|
|
23
32
|
* - {@linkcode PluginCoreApi.groups} — Read & edit the group hierarchy
|
|
24
33
|
* - {@linkcode PluginCoreApi.buildings} — Read & edit buildings and their storeys
|
|
34
|
+
* - {@linkcode PluginCoreApi.storeys} — Create, read & edit storeys (floors)
|
|
25
35
|
* - {@linkcode PluginCoreApi.layers} — Read & toggle storey drawing/reference layers
|
|
26
36
|
* - {@linkcode PluginCoreApi.tags} — Tag catalog + assignment
|
|
37
|
+
* - {@linkcode PluginCoreApi.io} — Import files (image/pdf/cad/model/terrain), poll jobs, manage underlays
|
|
38
|
+
* - {@linkcode PluginCoreApi.handles} — Handle lifecycle: release, releaseAll, scopes
|
|
39
|
+
* - {@linkcode PluginCoreApi.proposals} — Design options: read, create, rename, switch, delete
|
|
27
40
|
*/
|
|
28
41
|
export abstract class PluginCoreApi {
|
|
29
42
|
/** Vector and quaternion math utilities. See {@linkcode PluginMathApi}. */
|
|
@@ -36,6 +49,10 @@ export abstract class PluginCoreApi {
|
|
|
36
49
|
public abstract units: PluginUnitsApi
|
|
37
50
|
/** Camera zoom controls. See {@linkcode PluginZoomApi}. */
|
|
38
51
|
public abstract zoom: PluginZoomApi
|
|
52
|
+
/** Camera controls — position, standard views, 2D/3D mode. See {@linkcode PluginCameraApi}. */
|
|
53
|
+
public abstract camera: PluginCameraApi
|
|
54
|
+
/** User locale — timezone & language. See {@linkcode PluginUserApi}. */
|
|
55
|
+
public abstract user: PluginUserApi
|
|
39
56
|
/** Project-level settings and info. See {@linkcode PluginProjectApi}. */
|
|
40
57
|
public abstract project: PluginProjectApi
|
|
41
58
|
/** Comments — create, edit, resolve, tag, list. See {@linkcode PluginCommentApi}. */
|
|
@@ -44,10 +61,20 @@ export abstract class PluginCoreApi {
|
|
|
44
61
|
public abstract groups: PluginCoreGroupsApi
|
|
45
62
|
/** Buildings — read & edit buildings and their storeys. See {@linkcode PluginCoreBuildingsApi}. */
|
|
46
63
|
public abstract buildings: PluginCoreBuildingsApi
|
|
64
|
+
/** Storeys — create, read & edit storeys (floors). See {@linkcode PluginCoreStoreysApi}. */
|
|
65
|
+
public abstract storeys: PluginCoreStoreysApi
|
|
66
|
+
/** Application mode — read & switch the editor's top-bar mode. See {@linkcode PluginCoreModeApi}. */
|
|
67
|
+
public abstract mode: PluginCoreModeApi
|
|
47
68
|
/** Layers — read & toggle storey drawing/reference layers. See {@linkcode PluginCoreLayersApi}. */
|
|
48
69
|
public abstract layers: PluginCoreLayersApi
|
|
49
70
|
/** Tags — tag catalog + assignment. See {@linkcode PluginCoreTagsApi}. */
|
|
50
71
|
public abstract tags: PluginCoreTagsApi
|
|
72
|
+
/** I/O — file import, import jobs, and underlay management. See {@linkcode PluginCoreIoApi}. */
|
|
73
|
+
public abstract io: PluginCoreIoApi
|
|
74
|
+
/** Handle lifecycle — release, releaseAll, and mint-recording scopes. See {@linkcode PluginCoreHandlesApi}. */
|
|
75
|
+
public abstract handles: PluginCoreHandlesApi
|
|
76
|
+
/** Proposals — design options: read, create, rename, switch, delete. See {@linkcode PluginCoreProposalsApi}. */
|
|
77
|
+
public abstract proposals: PluginCoreProposalsApi
|
|
51
78
|
|
|
52
79
|
constructor() {}
|
|
53
80
|
}
|
|
@@ -57,9 +84,16 @@ export * from "./geom"
|
|
|
57
84
|
export * from "./history"
|
|
58
85
|
export * from "./units"
|
|
59
86
|
export * from "./zoom"
|
|
87
|
+
export * from "./camera"
|
|
88
|
+
export * from "./user"
|
|
60
89
|
export * from "./project"
|
|
61
90
|
export * from "./comment"
|
|
62
91
|
export * from "./groups"
|
|
63
92
|
export * from "./buildings"
|
|
93
|
+
export * from "./storeys"
|
|
94
|
+
export * from "./mode"
|
|
64
95
|
export * from "./layers"
|
|
65
96
|
export * from "./tags"
|
|
97
|
+
export * from "./io"
|
|
98
|
+
export * from "./handles"
|
|
99
|
+
export * from "./proposals"
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Serialization format for {@link PluginCoreIoExportApi.model}.
|
|
6
|
+
*
|
|
7
|
+
* `glb` / `obj` serialize in the browser; `fbx` / `3ds` run the same server
|
|
8
|
+
* conversion the app's Export dialog uses and return a **zip** containing the
|
|
9
|
+
* converted file.
|
|
10
|
+
*/
|
|
11
|
+
export const ExportModelFormat = z.enum(["glb", "obj", "fbx", "3ds"])
|
|
12
|
+
export type ExportModelFormat = z.infer<typeof ExportModelFormat>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What to export: the whole model (`"scene"`, default) or only the current
|
|
16
|
+
* selection (`"selection"`).
|
|
17
|
+
*/
|
|
18
|
+
export const ExportScope = z.enum(["scene", "selection"])
|
|
19
|
+
export type ExportScope = z.infer<typeof ExportScope>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A serialized model file returned by {@link PluginCoreIoExportApi.model}.
|
|
23
|
+
*
|
|
24
|
+
* | Property | Type | Description |
|
|
25
|
+
* |---|---|---|
|
|
26
|
+
* | `fileName` | `string` | Suggested file name incl. extension (e.g. `"model.glb"`) |
|
|
27
|
+
* | `mimeType` | `string` | MIME type (`"model/gltf-binary"` for glb, `"text/plain"` for obj) |
|
|
28
|
+
* | `dataBase64` | `string` | The file's bytes, base64-encoded (decode to save/download) |
|
|
29
|
+
*/
|
|
30
|
+
export const ExportedFile = z.object({
|
|
31
|
+
fileName: z.string(),
|
|
32
|
+
mimeType: z.string(),
|
|
33
|
+
dataBase64: z.string(),
|
|
34
|
+
})
|
|
35
|
+
export type ExportedFile = z.infer<typeof ExportedFile>
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Model export — serialize the scene (or selection) to a downloadable 3D file.
|
|
39
|
+
*
|
|
40
|
+
* `core.io.export.model` hands you the file bytes as base64 — no download
|
|
41
|
+
* dialog opens; the plugin decides what to do with the result (save it, POST
|
|
42
|
+
* it, diff it). For a different export intent, see `presentation.export`
|
|
43
|
+
* (Present-mode layout sheets to PDF/PNG/JPG) and `program.spreadsheet.export`
|
|
44
|
+
* (the area-program / takeoff workbook). Four formats:
|
|
45
|
+
*
|
|
46
|
+
* - `"glb"` — binary glTF (`model/gltf-binary`); geometry + materials,
|
|
47
|
+
* serialized in the browser (nothing is uploaded).
|
|
48
|
+
* - `"obj"` — Wavefront OBJ text (`text/plain`); geometry only, serialized in
|
|
49
|
+
* the browser.
|
|
50
|
+
* - `"fbx"` / `"3ds"` — Autodesk FBX / 3D Studio; the scene is uploaded to the
|
|
51
|
+
* same `/exportmodel/` conversion service the app's Export dialog uses, and
|
|
52
|
+
* the call resolves once the converted artifact is fetched back — a **zip**
|
|
53
|
+
* (`application/zip`) containing the `.fbx`/`.3ds` file. Whole-scene only
|
|
54
|
+
* (`scope: "selection"` is rejected). Conversion runs on the server and is
|
|
55
|
+
* bounded by the per-call plugin timeout (60 s) — very large models may
|
|
56
|
+
* exceed it and reject with `TIMEOUT`.
|
|
57
|
+
*
|
|
58
|
+
* For the browser formats, only real model geometry is exported (walls, slabs,
|
|
59
|
+
* roofs, floors, doors, windows, furniture, staircases, masses, ceilings,
|
|
60
|
+
* mullions, beams, columns, terrain); UI helpers, hidden objects, and
|
|
61
|
+
* hidden-bucket objects are excluded — matching the app's GLB export. The
|
|
62
|
+
* server formats convert the full serialized scene (hidden-bucket objects
|
|
63
|
+
* excluded), exactly like the Export dialog. This is a **read**: it never
|
|
64
|
+
* mutates the model.
|
|
65
|
+
*
|
|
66
|
+
* > Server-backed BIM exports (RVT / IFC / DWG) are **not** exposed here — those
|
|
67
|
+
* > run as fire-and-forget Forge jobs that stream a browser download and return
|
|
68
|
+
* > no retrievable bytes. Use the app's Export menu for those.
|
|
69
|
+
*
|
|
70
|
+
* Accessed via `snaptrude.core.io.export`.
|
|
71
|
+
*/
|
|
72
|
+
export abstract class PluginCoreIoExportApi {
|
|
73
|
+
constructor() {}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Export the model to a 3D file and return its bytes as base64.
|
|
77
|
+
*
|
|
78
|
+
* @param format - `"glb"` (binary glTF, geometry + materials), `"obj"`
|
|
79
|
+
* (Wavefront OBJ text, geometry only) — both serialized in the browser —
|
|
80
|
+
* or `"fbx"` / `"3ds"`, converted by the app's export service and returned
|
|
81
|
+
* as a zip containing the converted file.
|
|
82
|
+
* @param scope - `"scene"` (default) for the whole model, or `"selection"` for
|
|
83
|
+
* only the currently selected objects (browser formats only — `"fbx"`/`"3ds"`
|
|
84
|
+
* reject it). An empty selection yields an empty file.
|
|
85
|
+
* @returns an {@linkcode ExportedFile} — `{ fileName, mimeType, dataBase64 }`.
|
|
86
|
+
* @throws if the format is unsupported, `scope: "selection"` is combined with a
|
|
87
|
+
* server format, or the serialization/conversion fails.
|
|
88
|
+
*
|
|
89
|
+
* @examplePrompt Export the model as a GLB
|
|
90
|
+
* @examplePrompt Give me the whole scene as an OBJ file
|
|
91
|
+
* @examplePrompt Export just my selection to GLB
|
|
92
|
+
* @examplePrompt Download the model as an FBX file
|
|
93
|
+
* @examplePrompt Export the scene to 3DS for 3ds Max
|
|
94
|
+
*
|
|
95
|
+
* # Example
|
|
96
|
+
* ```ts
|
|
97
|
+
* const file = await snaptrude.core.io.export.model("glb")
|
|
98
|
+
* // decode base64 → bytes and save/download in the plugin UI
|
|
99
|
+
* const bytes = Uint8Array.from(atob(file.dataBase64), (c) => c.charCodeAt(0))
|
|
100
|
+
* const blob = new Blob([bytes], { type: file.mimeType })
|
|
101
|
+
* // ...offer blob for download as file.fileName
|
|
102
|
+
*
|
|
103
|
+
* // Only the current selection, as OBJ text:
|
|
104
|
+
* const obj = await snaptrude.core.io.export.model("obj", "selection")
|
|
105
|
+
* const text = atob(obj.dataBase64)
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
public abstract model(
|
|
109
|
+
format: ExportModelFormat,
|
|
110
|
+
scope?: ExportScope,
|
|
111
|
+
): PluginApiReturn<ExportedFile>
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Arguments for {@link PluginCoreIoExportApi.model}.
|
|
116
|
+
*
|
|
117
|
+
* | Property | Type | Description |
|
|
118
|
+
* |---|---|---|
|
|
119
|
+
* | `format` | {@link ExportModelFormat} | `"glb"`, `"obj"`, `"fbx"`, or `"3ds"` |
|
|
120
|
+
* | `scope` | {@link ExportScope} | `"scene"` (default) or `"selection"` (browser formats only) |
|
|
121
|
+
*/
|
|
122
|
+
export const PluginExportModelArgs = z.object({
|
|
123
|
+
format: ExportModelFormat,
|
|
124
|
+
scope: ExportScope.optional(),
|
|
125
|
+
})
|
|
126
|
+
export type PluginExportModelArgs = z.infer<typeof PluginExportModelArgs>
|