@snaptrude/plugin-core 0.3.0 → 0.5.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.
- package/AGENTS.md +130 -48
- package/CHANGELOG.md +111 -0
- package/api-manifest.full.json +3999 -0
- package/api-manifest.json +3845 -0
- package/dist/api/core/buildings.d.ts +427 -0
- package/dist/api/core/buildings.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +230 -0
- package/dist/api/core/comment/index.d.ts.map +1 -0
- package/dist/api/core/geom/create/index.d.ts +247 -0
- package/dist/api/core/geom/create/index.d.ts.map +1 -0
- package/dist/api/core/geom/delete/index.d.ts +72 -0
- package/dist/api/core/geom/delete/index.d.ts.map +1 -0
- package/dist/api/core/geom/index.d.ts +24 -23
- package/dist/api/core/geom/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +169 -0
- package/dist/api/core/geom/query/arc.d.ts.map +1 -0
- package/dist/api/core/geom/query/brep.d.ts +402 -0
- package/dist/api/core/geom/query/brep.d.ts.map +1 -0
- package/dist/api/core/geom/query/circle.d.ts +378 -0
- package/dist/api/core/geom/query/circle.d.ts.map +1 -0
- package/dist/api/core/geom/query/contour.d.ts +450 -0
- package/dist/api/core/geom/query/contour.d.ts.map +1 -0
- package/dist/api/core/geom/query/curve.d.ts +918 -0
- package/dist/api/core/geom/query/curve.d.ts.map +1 -0
- package/dist/api/core/geom/query/edge.d.ts +128 -0
- package/dist/api/core/geom/query/edge.d.ts.map +1 -0
- package/dist/api/core/geom/query/face.d.ts +363 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -0
- package/dist/api/core/geom/query/halfedge.d.ts +206 -0
- package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
- package/dist/api/core/geom/query/index.d.ts +61 -0
- package/dist/api/core/geom/query/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/profile.d.ts +410 -0
- package/dist/api/core/geom/query/profile.d.ts.map +1 -0
- package/dist/api/core/geom/query/vertex.d.ts +187 -0
- package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
- package/dist/api/core/geom/update/contour.d.ts +272 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -0
- package/dist/api/core/geom/update/curve.d.ts +180 -0
- package/dist/api/core/geom/update/curve.d.ts.map +1 -0
- package/dist/api/core/geom/update/index.d.ts +27 -0
- package/dist/api/core/geom/update/index.d.ts.map +1 -0
- package/dist/api/core/geom/update/profile.d.ts +329 -0
- package/dist/api/core/geom/update/profile.d.ts.map +1 -0
- package/dist/api/core/groups.d.ts +485 -0
- package/dist/api/core/groups.d.ts.map +1 -0
- package/dist/api/core/history/index.d.ts +78 -0
- package/dist/api/core/history/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +46 -1
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/layers.d.ts +402 -0
- package/dist/api/core/layers.d.ts.map +1 -0
- package/dist/api/core/math/quat.d.ts +111 -128
- package/dist/api/core/math/quat.d.ts.map +1 -1
- package/dist/api/core/math/vec3.d.ts +120 -102
- package/dist/api/core/math/vec3.d.ts.map +1 -1
- package/dist/api/core/project/index.d.ts +399 -0
- package/dist/api/core/project/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +755 -0
- package/dist/api/core/tags.d.ts.map +1 -0
- package/dist/api/core/units/index.d.ts +175 -0
- package/dist/api/core/units/index.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +45 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +168 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +828 -0
- package/dist/api/design/create/index.d.ts.map +1 -0
- package/dist/api/design/delete/index.d.ts +63 -0
- package/dist/api/design/delete/index.d.ts.map +1 -0
- package/dist/api/design/doors/index.d.ts +268 -0
- package/dist/api/design/doors/index.d.ts.map +1 -0
- package/dist/api/design/edit/index.d.ts +49 -0
- package/dist/api/design/edit/index.d.ts.map +1 -0
- package/dist/api/design/erase/index.d.ts +160 -0
- package/dist/api/design/erase/index.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +123 -0
- package/dist/api/design/furniture/index.d.ts.map +1 -0
- package/dist/api/design/index.d.ts +153 -0
- package/dist/api/design/index.d.ts.map +1 -0
- package/dist/api/design/lock.d.ts +41 -0
- package/dist/api/design/lock.d.ts.map +1 -0
- package/dist/api/design/materials/index.d.ts +297 -0
- package/dist/api/design/materials/index.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +140 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +1011 -0
- package/dist/api/design/query/index.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +221 -0
- package/dist/api/design/query/spaces.d.ts.map +1 -0
- package/dist/api/design/selection/index.d.ts +138 -0
- package/dist/api/design/selection/index.d.ts.map +1 -0
- package/dist/api/design/shared.d.ts +38 -0
- package/dist/api/design/shared.d.ts.map +1 -0
- package/dist/api/design/transform/index.d.ts +87 -0
- package/dist/api/design/transform/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +178 -0
- package/dist/api/design/update/index.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +189 -0
- package/dist/api/design/windows/index.d.ts.map +1 -0
- package/dist/api/entity/buildableEnvelope.d.ts +261 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
- package/dist/api/entity/department.d.ts +0 -98
- package/dist/api/entity/department.d.ts.map +1 -1
- package/dist/api/entity/index.d.ts +9 -9
- package/dist/api/entity/index.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +49 -106
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +482 -249
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/entity/story.d.ts +49 -39
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +17 -12
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +440 -0
- package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +81 -0
- package/dist/api/presentation/diagrams.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +113 -0
- package/dist/api/presentation/import.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +46 -0
- package/dist/api/presentation/index.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +176 -0
- package/dist/api/presentation/sheets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +296 -0
- package/dist/api/presentation/views.d.ts.map +1 -0
- package/dist/api/program/adjacency.d.ts +155 -0
- package/dist/api/program/adjacency.d.ts.map +1 -0
- package/dist/api/program/areas.d.ts +360 -0
- package/dist/api/program/areas.d.ts.map +1 -0
- package/dist/api/program/classification.d.ts +135 -0
- package/dist/api/program/classification.d.ts.map +1 -0
- package/dist/api/program/cores.d.ts +174 -0
- package/dist/api/program/cores.d.ts.map +1 -0
- package/dist/api/program/departments.d.ts +431 -0
- package/dist/api/program/departments.d.ts.map +1 -0
- package/dist/api/program/index.d.ts +69 -0
- package/dist/api/program/index.d.ts.map +1 -0
- package/dist/api/program/layout.d.ts +63 -0
- package/dist/api/program/layout.d.ts.map +1 -0
- package/dist/api/program/metrics.d.ts +108 -0
- package/dist/api/program/metrics.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +367 -0
- package/dist/api/program/site.d.ts.map +1 -0
- package/dist/api/program/spreadsheet.d.ts +2041 -0
- package/dist/api/program/spreadsheet.d.ts.map +1 -0
- package/dist/handles.d.ts +138 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/host-utils.d.ts +7 -5
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +4001 -904
- 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 +3392 -870
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/scripts/generate-manifest.mjs +193 -0
- package/scripts/generate-manifest.test.mjs +193 -0
- package/src/api/core/buildings.ts +485 -0
- package/src/api/core/comment/index.ts +258 -0
- package/src/api/core/geom/create/index.ts +293 -0
- package/src/api/core/geom/delete/index.ts +78 -0
- package/src/api/core/geom/index.ts +24 -23
- package/src/api/core/geom/query/arc.ts +169 -0
- package/src/api/core/geom/query/brep.ts +444 -0
- package/src/api/core/geom/query/circle.ts +404 -0
- package/src/api/core/geom/query/contour.ts +540 -0
- package/src/api/core/geom/query/curve.ts +1078 -0
- package/src/api/core/geom/query/edge.ts +130 -0
- package/src/api/core/geom/query/face.ts +403 -0
- package/src/api/core/geom/query/halfedge.ts +210 -0
- package/src/api/core/geom/query/index.ts +63 -0
- package/src/api/core/geom/query/profile.ts +473 -0
- package/src/api/core/geom/query/vertex.ts +205 -0
- package/src/api/core/geom/update/contour.ts +315 -0
- package/src/api/core/geom/update/curve.ts +209 -0
- package/src/api/core/geom/update/index.ts +29 -0
- package/src/api/core/geom/update/profile.ts +377 -0
- package/src/api/core/groups.ts +521 -0
- package/src/api/core/history/index.ts +84 -0
- package/src/api/core/index.ts +46 -1
- package/src/api/core/layers.ts +333 -0
- package/src/api/core/math/quat.ts +112 -235
- package/src/api/core/math/vec3.ts +124 -159
- package/src/api/core/project/index.ts +418 -0
- package/src/api/core/tags.ts +808 -0
- package/src/api/core/units/index.ts +164 -0
- package/src/api/core/zoom/index.ts +47 -0
- package/src/api/design/boolean/index.ts +179 -0
- package/src/api/design/create/index.ts +886 -0
- package/src/api/design/delete/index.ts +67 -0
- package/src/api/design/doors/index.ts +285 -0
- package/src/api/design/edit/index.ts +54 -0
- package/src/api/design/erase/index.ts +151 -0
- package/src/api/design/furniture/index.ts +130 -0
- package/src/api/design/index.ts +162 -0
- package/src/api/design/lock.ts +42 -0
- package/src/api/design/materials/index.ts +301 -0
- package/src/api/design/query/geometry/index.ts +166 -0
- package/src/api/design/query/index.ts +937 -0
- package/src/api/design/query/spaces.ts +132 -0
- package/src/api/design/selection/index.ts +144 -0
- package/src/api/design/shared.ts +40 -0
- package/src/api/design/transform/index.ts +93 -0
- package/src/api/design/update/index.ts +117 -0
- package/src/api/design/windows/index.ts +207 -0
- package/src/api/entity/buildableEnvelope.ts +318 -0
- package/src/api/entity/department.ts +0 -113
- package/src/api/entity/index.ts +9 -9
- package/src/api/entity/referenceLine.ts +50 -38
- package/src/api/entity/space.ts +285 -226
- package/src/api/entity/story.ts +53 -42
- package/src/api/index.ts +17 -12
- package/src/api/presentation/aiInspiration.ts +362 -0
- package/src/api/presentation/diagrams.ts +84 -0
- package/src/api/presentation/import.ts +112 -0
- package/src/api/presentation/index.ts +48 -0
- package/src/api/presentation/sheets.ts +198 -0
- package/src/api/presentation/views.ts +303 -0
- package/src/api/program/adjacency.ts +164 -0
- package/src/api/program/areas.ts +335 -0
- package/src/api/program/classification.ts +138 -0
- package/src/api/program/cores.ts +171 -0
- package/src/api/program/departments.ts +465 -0
- package/src/api/program/index.ts +71 -0
- package/src/api/program/layout.ts +68 -0
- package/src/api/program/metrics.ts +120 -0
- package/src/api/program/site.ts +326 -0
- package/src/api/program/spreadsheet.ts +2075 -0
- package/src/handles.ts +148 -0
- package/src/host-utils.ts +10 -6
- package/src/index.ts +1 -0
- package/dist/api/core/geom/arc.d.ts +0 -81
- package/dist/api/core/geom/arc.d.ts.map +0 -1
- package/dist/api/core/geom/curve.d.ts +0 -70
- package/dist/api/core/geom/curve.d.ts.map +0 -1
- package/dist/api/core/geom/line.d.ts +0 -56
- package/dist/api/core/geom/line.d.ts.map +0 -1
- package/dist/api/core/geom/profile.d.ts +0 -121
- package/dist/api/core/geom/profile.d.ts.map +0 -1
- package/dist/api/tools/copy.d.ts +0 -59
- package/dist/api/tools/copy.d.ts.map +0 -1
- package/dist/api/tools/index.d.ts +0 -33
- package/dist/api/tools/index.d.ts.map +0 -1
- package/dist/api/tools/material.d.ts +0 -51
- package/dist/api/tools/material.d.ts.map +0 -1
- package/dist/api/tools/offset.d.ts +0 -43
- package/dist/api/tools/offset.d.ts.map +0 -1
- package/dist/api/tools/selection.d.ts +0 -48
- package/dist/api/tools/selection.d.ts.map +0 -1
- package/dist/api/tools/transform.d.ts +0 -114
- package/dist/api/tools/transform.d.ts.map +0 -1
- package/dist/api/units/index.d.ts +0 -163
- package/dist/api/units/index.d.ts.map +0 -1
- package/src/api/core/geom/arc.ts +0 -70
- package/src/api/core/geom/curve.ts +0 -41
- package/src/api/core/geom/line.ts +0 -53
- package/src/api/core/geom/profile.ts +0 -94
- package/src/api/tools/copy.ts +0 -55
- package/src/api/tools/index.ts +0 -39
- package/src/api/tools/material.ts +0 -49
- package/src/api/tools/offset.ts +0 -43
- package/src/api/tools/selection.ts +0 -51
- package/src/api/tools/transform.ts +0 -117
- package/src/api/units/index.ts +0 -163
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { ComponentHandle } from "../../../handles"
|
|
4
|
+
import { PluginDesignChangeResult } from "../lock"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Arguments for {@linkcode PluginDesignDeleteApi.entities}.
|
|
8
|
+
*
|
|
9
|
+
* | Property | Type | Description |
|
|
10
|
+
* |---|---|---|
|
|
11
|
+
* | `components` | {@linkcode ComponentHandle}`[]` | Entities to delete. Unknown/forged handles reject the whole call (fail-fast). |
|
|
12
|
+
*
|
|
13
|
+
* `.min(1)` is deliberately stricter than the shipped `PluginDesignLockArgs`
|
|
14
|
+
* (which allows an empty array) — an empty delete is a caller error, not a no-op.
|
|
15
|
+
*
|
|
16
|
+
* TRANSPORT: positional args — validated host-side as `{ components }`.
|
|
17
|
+
*/
|
|
18
|
+
export const PluginDesignDeleteEntitiesArgs = z.object({
|
|
19
|
+
components: z.array(ComponentHandle).min(1),
|
|
20
|
+
})
|
|
21
|
+
export type PluginDesignDeleteEntitiesArgs = z.infer<typeof PluginDesignDeleteEntitiesArgs>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `snaptrude.design.delete.*` — **hard removal** of scene BIM entities.
|
|
25
|
+
*
|
|
26
|
+
* This is hard entity delete — distinct from `design.erase.edge` (a plan-level
|
|
27
|
+
* adjacency-edge topology op) and `design.boolean.subtract` (a CSG geometry
|
|
28
|
+
* delete). The constitution forbids `erase`/`clear`/`remove` as synonyms for
|
|
29
|
+
* `delete`; these are three separate operations.
|
|
30
|
+
*
|
|
31
|
+
* TRANSPORT: positional args per method.
|
|
32
|
+
*/
|
|
33
|
+
export abstract class PluginDesignDeleteApi {
|
|
34
|
+
constructor() {}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Delete one or more entities. Generic hard delete (backed by the same batched,
|
|
38
|
+
* undoable path as `entity.space.delete`). Cascade is opinionated by the engine:
|
|
39
|
+
* children are removed and linked-list neighbours are fixed up — not caller-tunable
|
|
40
|
+
* in v1. Undoable — commits as a **single** undo entry.
|
|
41
|
+
*
|
|
42
|
+
* @param components - Entities to delete. Unknown/forged handles reject the whole call (fail-fast).
|
|
43
|
+
* @returns The entities that were deleted, as {@linkcode ComponentHandle}`[]`
|
|
44
|
+
* (echoed host-side from the resolved+deleted set — the engine returns no ids).
|
|
45
|
+
* Deleted handles are **stale** afterwards: re-resolving one throws `HANDLE_INVALID`.
|
|
46
|
+
* @throws If any supplied handle is unknown/forged (`HANDLE_INVALID`) — the whole
|
|
47
|
+
* call rejects before anything is deleted (all-or-nothing resolution).
|
|
48
|
+
*
|
|
49
|
+
* @examplePrompt Delete the selected objects
|
|
50
|
+
* @examplePrompt Remove these walls from the model
|
|
51
|
+
* @examplePrompt Get rid of this mass entirely
|
|
52
|
+
* @examplePrompt Delete all the furniture I picked
|
|
53
|
+
* @examplePrompt Remove the door and window I just created
|
|
54
|
+
*
|
|
55
|
+
* # Example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // Hard-delete every furniture item on storey 2 (a single undo entry)
|
|
58
|
+
* const furniture = await snaptrude.design.query.listFurniture({ storeys: [2] })
|
|
59
|
+
* if (furniture.length > 0) {
|
|
60
|
+
* const { affected } = await snaptrude.design.delete.entities(furniture)
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
public abstract entities(
|
|
65
|
+
components: ComponentHandle[],
|
|
66
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
67
|
+
}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { ComponentHandle } from "../../../handles"
|
|
4
|
+
import { PluginDesignChangeResult } from "../lock"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `snaptrude.design.doors` — door-specific reads + edits. Creation lives at
|
|
8
|
+
* `design.create.door`; generic reads (`listDoors`/`getHost`/`getProperties`) live at
|
|
9
|
+
* `design.query.*`. Door targets are {@linkcode ComponentHandle}s.
|
|
10
|
+
*
|
|
11
|
+
* `getSwingDirection` is a DERIVED read (no persisted field) — computed from the door
|
|
12
|
+
* mesh reflection state. `mirror` reflects the door across an axis (undoable, one
|
|
13
|
+
* command); `setType` is intentionally absent (the engine has no in-place re-type —
|
|
14
|
+
* it would require delete+recreate).
|
|
15
|
+
*/
|
|
16
|
+
export abstract class PluginDesignDoorsApi {
|
|
17
|
+
constructor() {}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the type name of a door — the label that identifies which kind of door
|
|
21
|
+
* the instance is, as shown in its properties.
|
|
22
|
+
*
|
|
23
|
+
* @param door The door to query
|
|
24
|
+
* @returns The type as a `string`, or `null`
|
|
25
|
+
*
|
|
26
|
+
* @examplePrompt What type of door is this?
|
|
27
|
+
* @examplePrompt Tell me the door type of the selected door
|
|
28
|
+
* @examplePrompt Is this a single or a double door?
|
|
29
|
+
* @examplePrompt Check what kind of door is on this wall
|
|
30
|
+
*
|
|
31
|
+
* # Example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
|
|
34
|
+
* const type = await snaptrude.design.doors.getType(door)
|
|
35
|
+
* if (type) console.log("door type:", type)
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
public abstract getType(door: ComponentHandle): PluginApiReturn<string | null>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the family name of a door — the Revit or native family the door
|
|
42
|
+
* instance comes from.
|
|
43
|
+
*
|
|
44
|
+
* @param door The door to query
|
|
45
|
+
* @returns The family as a `string`, or `null`
|
|
46
|
+
*
|
|
47
|
+
* @examplePrompt Which family does this door belong to?
|
|
48
|
+
* @examplePrompt What's the Revit family of the selected door?
|
|
49
|
+
* @examplePrompt Show the family name for this door
|
|
50
|
+
* @examplePrompt Find out which door family the imported door uses
|
|
51
|
+
*
|
|
52
|
+
* # Example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const [door] = await snaptrude.design.query.listDoors()
|
|
55
|
+
* const family = await snaptrude.design.doors.getFamily(door)
|
|
56
|
+
* if (family) console.log("family:", family)
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
public abstract getFamily(door: ComponentHandle): PluginApiReturn<string | null>
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get the width of a door — how wide its opening is along the host wall.
|
|
63
|
+
*
|
|
64
|
+
* @param door The door to query
|
|
65
|
+
* @returns The width as a `number`, or `null`
|
|
66
|
+
*
|
|
67
|
+
* @examplePrompt How wide is this door?
|
|
68
|
+
* @examplePrompt What's the width of the selected door?
|
|
69
|
+
* @examplePrompt Measure the width of the entrance door
|
|
70
|
+
* @examplePrompt Check whether this door is 900mm wide
|
|
71
|
+
*
|
|
72
|
+
* # Example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
|
|
75
|
+
* const width = await snaptrude.design.doors.getWidth(door)
|
|
76
|
+
* if (width !== null) console.log("door width:", width)
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
public abstract getWidth(door: ComponentHandle): PluginApiReturn<number | null>
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get the height of a door — how tall its opening is from base to head.
|
|
83
|
+
*
|
|
84
|
+
* @param door The door to query
|
|
85
|
+
* @returns The height as a `number`, or `null`
|
|
86
|
+
*
|
|
87
|
+
* @examplePrompt How tall is this door?
|
|
88
|
+
* @examplePrompt What's the height of the selected door?
|
|
89
|
+
* @examplePrompt Check the door height for this opening
|
|
90
|
+
* @examplePrompt Is the front door 2100mm high?
|
|
91
|
+
*
|
|
92
|
+
* # Example
|
|
93
|
+
* ```ts
|
|
94
|
+
* const [door] = await snaptrude.design.query.listDoors()
|
|
95
|
+
* const height = await snaptrude.design.doors.getHeight(door)
|
|
96
|
+
* if (height !== null) console.log("door height:", height)
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
public abstract getHeight(door: ComponentHandle): PluginApiReturn<number | null>
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get the floor a door is hosted on — the storey/level component that
|
|
103
|
+
* supports the door.
|
|
104
|
+
*
|
|
105
|
+
* @param door The door to query
|
|
106
|
+
* @returns The support floor {@linkcode ComponentHandle}, or `null`
|
|
107
|
+
*
|
|
108
|
+
* @examplePrompt Which floor is this door on?
|
|
109
|
+
* @examplePrompt What storey does the selected door belong to?
|
|
110
|
+
* @examplePrompt Find the level that hosts this door
|
|
111
|
+
* @examplePrompt Tell me which floor the entrance door sits on
|
|
112
|
+
*
|
|
113
|
+
* # Example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
|
|
116
|
+
* const floor = await snaptrude.design.doors.getSupportFloor(door)
|
|
117
|
+
* if (floor) {
|
|
118
|
+
* const props = await snaptrude.design.query.getProperties(floor)
|
|
119
|
+
* console.log("hosted on storey:", props.storey)
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
public abstract getSupportFloor(door: ComponentHandle): PluginApiReturn<ComponentHandle | null>
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get a door's swing (hinge) handedness — whether it opens as a left-hand or
|
|
127
|
+
* right-hand door. Derived from the door mesh's reflection state, not a
|
|
128
|
+
* persisted field.
|
|
129
|
+
*
|
|
130
|
+
* @param door The door to query
|
|
131
|
+
* @returns `'left'` / `'right'`, or `null` if indeterminate
|
|
132
|
+
*
|
|
133
|
+
* @examplePrompt Which way does this door swing?
|
|
134
|
+
* @examplePrompt Is the selected door left-handed or right-handed?
|
|
135
|
+
* @examplePrompt Check the hinge side of this door
|
|
136
|
+
* @examplePrompt Does the entrance door open to the left or the right?
|
|
137
|
+
*
|
|
138
|
+
* # Example
|
|
139
|
+
* ```ts
|
|
140
|
+
* const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
|
|
141
|
+
* const swing = await snaptrude.design.doors.getSwingDirection(door)
|
|
142
|
+
* if (swing) console.log("opens as a", swing, "hand door")
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
public abstract getSwingDirection(
|
|
146
|
+
door: ComponentHandle
|
|
147
|
+
): PluginApiReturn<"left" | "right" | null>
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Mirror a door across an axis, flipping its swing so it opens from the
|
|
151
|
+
* other side. Undoable as a single command.
|
|
152
|
+
*
|
|
153
|
+
* @param door The door to mirror
|
|
154
|
+
* @param axis Reflection axis (optional; default `'x'` — the swing-flip axis)
|
|
155
|
+
* @returns The affected door(s)
|
|
156
|
+
*
|
|
157
|
+
* @examplePrompt Flip this door's swing
|
|
158
|
+
* @examplePrompt Mirror the selected door
|
|
159
|
+
* @examplePrompt Make this door open the other way
|
|
160
|
+
* @examplePrompt Reverse the hinge side of the entrance door
|
|
161
|
+
* @examplePrompt Change the door to swing from the other side
|
|
162
|
+
*
|
|
163
|
+
* # Example
|
|
164
|
+
* ```ts
|
|
165
|
+
* // Flip the selected door's swing — axis defaults to "x" (the swing-flip
|
|
166
|
+
* // axis); pass "y" or "z" to reflect across a different axis
|
|
167
|
+
* const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
|
|
168
|
+
* const { affected } = await snaptrude.design.doors.mirror(door)
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
public abstract mirror(
|
|
172
|
+
door: ComponentHandle,
|
|
173
|
+
axis?: PluginMirrorAxis
|
|
174
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set the width of one or more doors, resizing each opening and re-cutting
|
|
178
|
+
* the host wall. Width is in engine units; the change is undoable.
|
|
179
|
+
*
|
|
180
|
+
* @param doors The doors to resize
|
|
181
|
+
* @param width New width (engine units)
|
|
182
|
+
* @returns The affected doors
|
|
183
|
+
*
|
|
184
|
+
* @examplePrompt Make this door 900mm wide
|
|
185
|
+
* @examplePrompt Widen the selected doors to 1 metre
|
|
186
|
+
* @examplePrompt Change the door width to 3 feet
|
|
187
|
+
* @examplePrompt Resize all the bathroom doors to 750 wide
|
|
188
|
+
* @examplePrompt Narrow the entrance door a bit
|
|
189
|
+
*
|
|
190
|
+
* # Example
|
|
191
|
+
* ```ts
|
|
192
|
+
* // Resize every ground-floor door to a common width (engine units)
|
|
193
|
+
* const doors = await snaptrude.design.query.listDoors({ storeys: [1] })
|
|
194
|
+
* const { affected } = await snaptrude.design.doors.setWidth(doors, 900)
|
|
195
|
+
* console.log("resized", affected.length, "doors")
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
public abstract setWidth(
|
|
199
|
+
doors: ComponentHandle[],
|
|
200
|
+
width: number
|
|
201
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Set the height of one or more doors, resizing each opening and re-cutting
|
|
205
|
+
* the host wall. Height is in engine units; the change is undoable.
|
|
206
|
+
*
|
|
207
|
+
* @param doors The doors to resize
|
|
208
|
+
* @param height New height (engine units)
|
|
209
|
+
* @returns The affected doors
|
|
210
|
+
*
|
|
211
|
+
* @examplePrompt Make this door 2100mm tall
|
|
212
|
+
* @examplePrompt Change the door height to 7 feet
|
|
213
|
+
* @examplePrompt Raise the selected doors to 2.4m high
|
|
214
|
+
* @examplePrompt Set all the doors on this storey to 2100 high
|
|
215
|
+
*
|
|
216
|
+
* # Example
|
|
217
|
+
* ```ts
|
|
218
|
+
* // setHeight takes an array — wrap a single door
|
|
219
|
+
* const [door] = await snaptrude.design.query.listDoors({ isSelected: true })
|
|
220
|
+
* await snaptrude.design.doors.setHeight([door], 2100)
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
public abstract setHeight(
|
|
224
|
+
doors: ComponentHandle[],
|
|
225
|
+
height: number
|
|
226
|
+
): PluginApiReturn<PluginDesignChangeResult>
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Arguments for the single-door read methods.
|
|
231
|
+
*
|
|
232
|
+
* | Property | Type | Description |
|
|
233
|
+
* |---|---|---|
|
|
234
|
+
* | `door` | {@linkcode ComponentHandle} | The door to query |
|
|
235
|
+
*/
|
|
236
|
+
export const PluginDesignDoorArgs = z.object({
|
|
237
|
+
door: ComponentHandle,
|
|
238
|
+
})
|
|
239
|
+
export type PluginDesignDoorArgs = z.infer<typeof PluginDesignDoorArgs>
|
|
240
|
+
|
|
241
|
+
/** Mirror axis — tokens mirror the engine `FlipDirection` verbatim (§6.1). */
|
|
242
|
+
export const PluginMirrorAxis = z.enum(["x", "y", "z"])
|
|
243
|
+
export type PluginMirrorAxis = z.infer<typeof PluginMirrorAxis>
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Arguments for {@linkcode PluginDesignDoorsApi.mirror}.
|
|
247
|
+
*
|
|
248
|
+
* | Property | Type | Description |
|
|
249
|
+
* |---|---|---|
|
|
250
|
+
* | `door` | {@linkcode ComponentHandle} | The door to mirror |
|
|
251
|
+
* | `axis` | {@linkcode PluginMirrorAxis} | Reflection axis (optional; default `'x'` — the swing-flip axis) |
|
|
252
|
+
*/
|
|
253
|
+
export const PluginDesignDoorMirrorArgs = z.object({
|
|
254
|
+
door: ComponentHandle,
|
|
255
|
+
axis: PluginMirrorAxis.optional(),
|
|
256
|
+
})
|
|
257
|
+
export type PluginDesignDoorMirrorArgs = z.infer<typeof PluginDesignDoorMirrorArgs>
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Arguments for {@linkcode PluginDesignDoorsApi.setWidth}.
|
|
261
|
+
*
|
|
262
|
+
* | Property | Type | Description |
|
|
263
|
+
* |---|---|---|
|
|
264
|
+
* | `doors` | {@linkcode ComponentHandle}`[]` | The doors to resize |
|
|
265
|
+
* | `width` | `number` | New width (engine units) |
|
|
266
|
+
*/
|
|
267
|
+
export const PluginDesignDoorSetWidthArgs = z.object({
|
|
268
|
+
doors: z.array(ComponentHandle),
|
|
269
|
+
width: z.number(),
|
|
270
|
+
})
|
|
271
|
+
export type PluginDesignDoorSetWidthArgs = z.infer<typeof PluginDesignDoorSetWidthArgs>
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Arguments for {@linkcode PluginDesignDoorsApi.setHeight}.
|
|
275
|
+
*
|
|
276
|
+
* | Property | Type | Description |
|
|
277
|
+
* |---|---|---|
|
|
278
|
+
* | `doors` | {@linkcode ComponentHandle}`[]` | The doors to resize |
|
|
279
|
+
* | `height` | `number` | New height (engine units) |
|
|
280
|
+
*/
|
|
281
|
+
export const PluginDesignDoorSetHeightArgs = z.object({
|
|
282
|
+
doors: z.array(ComponentHandle),
|
|
283
|
+
height: z.number(),
|
|
284
|
+
})
|
|
285
|
+
export type PluginDesignDoorSetHeightArgs = z.infer<typeof PluginDesignDoorSetHeightArgs>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { ComponentHandle, Vec3Handle } from "../../../handles"
|
|
4
|
+
import { OffsetSplitOutcome } from "../shared"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* STAGED (LLD Wave 2) — abstract shell only. NOT yet wired into `PluginDesignApi`
|
|
8
|
+
* and has no host implementation. `offsetSplit` migrates off `tools.offset` (adding
|
|
9
|
+
* the previously-dropped `offsetValue` to the result).
|
|
10
|
+
*
|
|
11
|
+
* `snaptrude.design.edit` — non-create geometry edits (offset-split, and later
|
|
12
|
+
* push-pull / topology edits). Undoable.
|
|
13
|
+
*
|
|
14
|
+
* TRANSPORT: positional args per method.
|
|
15
|
+
*/
|
|
16
|
+
export abstract class PluginDesignEditApi {
|
|
17
|
+
constructor() {}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Offset the top profile of a component by a distance and split the face along
|
|
21
|
+
* the offset curve. Positive distances offset outward, negative inward.
|
|
22
|
+
* Single-component only (the engine rejects batches).
|
|
23
|
+
* @param component - The component whose top profile is offset-split.
|
|
24
|
+
* @param offsetDistance - Offset distance; positive = outward, negative = inward.
|
|
25
|
+
* @param options - Optional settings: `profilePickPoint` picks the profile when ambiguous.
|
|
26
|
+
* @returns {@linkcode OffsetSplitOutcome} `{ createdIds, deletedIds, offsetValue }`
|
|
27
|
+
*
|
|
28
|
+
* @examplePrompt Offset the top face of this mass inward by 2 metres and split it
|
|
29
|
+
* @examplePrompt Create a 1m setback border on top of the selected mass
|
|
30
|
+
* @examplePrompt Split the roof profile with a 500mm inward offset
|
|
31
|
+
* @examplePrompt Offset-split the slab's top profile outward by 3 feet
|
|
32
|
+
*
|
|
33
|
+
* # Example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // Offset the top profile inward by 2 units and split the face along it
|
|
36
|
+
* const [mass] = await snaptrude.design.query.listMasses()
|
|
37
|
+
* const { createdIds, offsetValue } = await snaptrude.design.edit.offsetSplit(mass, -2)
|
|
38
|
+
* // offsetValue is the post-clamp distance the engine actually applied
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
public abstract offsetSplit(
|
|
42
|
+
component: ComponentHandle,
|
|
43
|
+
offsetDistance: number,
|
|
44
|
+
options?: { profilePickPoint?: Vec3Handle },
|
|
45
|
+
): PluginApiReturn<OffsetSplitOutcome>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Positional target: offsetSplit(component, offsetDistance, options?)
|
|
49
|
+
export const PluginDesignOffsetSplitArgs = z.object({
|
|
50
|
+
component: ComponentHandle,
|
|
51
|
+
offsetDistance: z.number(),
|
|
52
|
+
profilePickPoint: Vec3Handle.optional(),
|
|
53
|
+
})
|
|
54
|
+
export type PluginDesignOffsetSplitArgs = z.infer<typeof PluginDesignOffsetSplitArgs>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { ComponentHandle, Vec3Handle } from "../../../handles"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The erase strategies exposed to plugins. `SplitAndUnion` is *enumerable* but
|
|
7
|
+
* NOT committable via {@linkcode PluginDesignEraseApi.edge} (it needs an
|
|
8
|
+
* interactive screen-space re-pick); `SplitAndDelete` is reserved in the engine
|
|
9
|
+
* and intentionally omitted. Derived host-side by the engine's `decideStrategy`.
|
|
10
|
+
*/
|
|
11
|
+
export const EraseStrategy = z.enum(["DirectDelete", "DirectUnion", "SplitAndUnion"])
|
|
12
|
+
export type EraseStrategy = z.infer<typeof EraseStrategy>
|
|
13
|
+
|
|
14
|
+
/** Default enumerated strategies — the two the scripted `edge()` can commit. */
|
|
15
|
+
export const DEFAULT_ERASE_STRATEGIES: readonly EraseStrategy[] = ["DirectDelete", "DirectUnion"]
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A **transient** reference to one erasable edge in the current plan's
|
|
19
|
+
* bottom-adjacency graph.
|
|
20
|
+
*
|
|
21
|
+
* ⚠️ **Lifetime**: valid ONLY until the next geometry-modifying operation. Any
|
|
22
|
+
* mutation (erase, boolean, transform, create, delete, …) rebuilds the adjacency
|
|
23
|
+
* graph and invalidates every previously-returned ref. Passing a stale ref to
|
|
24
|
+
* {@linkcode PluginDesignEraseApi.edge} throws `NO_STRATEGY_FOR_PICK_INFO`.
|
|
25
|
+
* Always re-list after a mutation.
|
|
26
|
+
*
|
|
27
|
+
* This is a by-value record (round-trip it back to `edge()` unmodified), NOT a
|
|
28
|
+
* registry handle. `components` and `snapPoint` are the marshalled public forms
|
|
29
|
+
* of the engine's raw `mesh.uniqueId` numbers / by-value point.
|
|
30
|
+
*/
|
|
31
|
+
export const ErasableEdgeRef = z.object({
|
|
32
|
+
/** Opaque bottom-graph edge id (engine form `"e-<n>"`). Do not mutate. Pass verbatim to {@linkcode PluginDesignEraseApi.edge}. */
|
|
33
|
+
id: z.string().min(1),
|
|
34
|
+
/** What erasing this edge would do: `DirectDelete` drops a mass; `DirectUnion` merges two adjacent masses. */
|
|
35
|
+
strategy: EraseStrategy,
|
|
36
|
+
/** Bottom-graph edge weight: `1` = external boundary edge, `>=2` = internal edge shared between components. */
|
|
37
|
+
edgeWeight: z.number(),
|
|
38
|
+
/** The components this edge is incident to — one for external (DirectDelete), two for internal (DirectUnion). */
|
|
39
|
+
components: z.array(ComponentHandle),
|
|
40
|
+
/** A representative point on the edge (its head endpoint). Diagnostic only. */
|
|
41
|
+
snapPoint: Vec3Handle,
|
|
42
|
+
})
|
|
43
|
+
export type ErasableEdgeRef = z.infer<typeof ErasableEdgeRef>
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Options for {@linkcode PluginDesignEraseApi.listErasableEdges}.
|
|
47
|
+
*
|
|
48
|
+
* | Property | Type | Description |
|
|
49
|
+
* |---|---|---|
|
|
50
|
+
* | `components` | {@linkcode ComponentHandle}`[]?` | Restrict to edges adjacent to at least one of these entities |
|
|
51
|
+
* | `strategies` | {@linkcode EraseStrategy}`[]?` | Restrict to these strategies. Default `["DirectDelete","DirectUnion"]` (hides interactive-only `SplitAndUnion`) |
|
|
52
|
+
*
|
|
53
|
+
* TRANSPORT: positional now — `listErasableEdges(options?)`; this schema is
|
|
54
|
+
* retained for host-side validation.
|
|
55
|
+
*/
|
|
56
|
+
export const PluginDesignListErasableEdgesArgs = z.object({
|
|
57
|
+
components: z.array(ComponentHandle).optional(),
|
|
58
|
+
strategies: z.array(EraseStrategy).optional(),
|
|
59
|
+
})
|
|
60
|
+
export type PluginDesignListErasableEdgesArgs = z.infer<typeof PluginDesignListErasableEdgesArgs>
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Arguments for {@linkcode PluginDesignEraseApi.edge}.
|
|
64
|
+
*
|
|
65
|
+
* TRANSPORT: positional now — `edge(edge: ErasableEdgeRef)`; this schema is
|
|
66
|
+
* retained for host-side validation.
|
|
67
|
+
*/
|
|
68
|
+
export const PluginDesignEraseEdgeArgs = z.object({
|
|
69
|
+
edge: ErasableEdgeRef,
|
|
70
|
+
})
|
|
71
|
+
export type PluginDesignEraseEdgeArgs = z.infer<typeof PluginDesignEraseEdgeArgs>
|
|
72
|
+
|
|
73
|
+
/** Result of {@linkcode PluginDesignEraseApi.edge} — success sentinel; the engine yields no survivor id. */
|
|
74
|
+
export const PluginDesignEraseEdgeResult = z.object({ ok: z.literal(true) })
|
|
75
|
+
export type PluginDesignEraseEdgeResult = z.infer<typeof PluginDesignEraseEdgeResult>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* `snaptrude.design.erase` — **adjacency-edge erase** (plan-level topology op).
|
|
79
|
+
*
|
|
80
|
+
* Erase is NOT delete. The erase tool operates on an **edge**, and the effect is
|
|
81
|
+
* derived from that edge: erasing an internal edge between two masses **unions**
|
|
82
|
+
* them (`DirectUnion`); erasing an external boundary edge of a single mass
|
|
83
|
+
* **drops** it behind the edge (`DirectDelete`). For hard entity removal use
|
|
84
|
+
* `design.delete.entities`; for CSG geometry delete use `design.boolean.subtract`.
|
|
85
|
+
*
|
|
86
|
+
* Two-step: {@linkcode listErasableEdges} to enumerate, then {@linkcode edge} to
|
|
87
|
+
* commit one ref (single undo entry). Scoped to **2D plan adjacency edges** in v1.
|
|
88
|
+
*
|
|
89
|
+
* TRANSPORT: positional args per method.
|
|
90
|
+
*/
|
|
91
|
+
export abstract class PluginDesignEraseApi {
|
|
92
|
+
constructor() {}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Enumerate every erasable edge in the current plan's bottom-adjacency graph
|
|
96
|
+
* (one {@linkcode ErasableEdgeRef} per edge). Pure read — no scene mutation, no
|
|
97
|
+
* command, not undoable. Erase-ineligible components (locked, hidden, off-storey)
|
|
98
|
+
* are filtered out.
|
|
99
|
+
*
|
|
100
|
+
* ⚠️ Returned refs are **transient** — see {@linkcode ErasableEdgeRef}. Re-list
|
|
101
|
+
* after any geometry mutation.
|
|
102
|
+
*
|
|
103
|
+
* @param options - {@linkcode PluginDesignListErasableEdgesArgs} — optional filters (`components`, `strategies`)
|
|
104
|
+
* @returns The erasable edges (`[]` when none) — never `null`.
|
|
105
|
+
*
|
|
106
|
+
* @examplePrompt Which edges in my floor plan can be erased?
|
|
107
|
+
* @examplePrompt List the erasable edges on this storey
|
|
108
|
+
* @examplePrompt Show me the shared edges I could erase to merge rooms
|
|
109
|
+
* @examplePrompt What edges between these two spaces can be removed?
|
|
110
|
+
*
|
|
111
|
+
* # Example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const edges = await snaptrude.design.erase.listErasableEdges()
|
|
114
|
+
* const union = edges.find((e) => e.strategy === "DirectUnion")
|
|
115
|
+
* if (union) await snaptrude.design.erase.edge(union)
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
public abstract listErasableEdges(
|
|
119
|
+
options?: PluginDesignListErasableEdgesArgs,
|
|
120
|
+
): PluginApiReturn<ErasableEdgeRef[]>
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Commit the erase for one edge. `DirectUnion` merges the two adjacent masses;
|
|
124
|
+
* `DirectDelete` drops the single mass behind the boundary edge. Single undo entry.
|
|
125
|
+
*
|
|
126
|
+
* Pass an {@linkcode ErasableEdgeRef} from {@linkcode listErasableEdges}
|
|
127
|
+
* unmodified. A stale ref (graph rebuilt by a prior mutation) or a `SplitAndUnion`
|
|
128
|
+
* edge throws.
|
|
129
|
+
*
|
|
130
|
+
* @param edge - The {@linkcode ErasableEdgeRef} to erase, from {@linkcode listErasableEdges} unmodified
|
|
131
|
+
* @returns `{ ok: true }` on success (the engine yields no survivor id today).
|
|
132
|
+
* @throws when the ref is stale, its components are all erase-ineligible, or the
|
|
133
|
+
* strategy is not committable via the scripted path.
|
|
134
|
+
*
|
|
135
|
+
* @examplePrompt Erase the edge between these two rooms so they merge
|
|
136
|
+
* @examplePrompt Remove the shared boundary between the kitchen and the dining space
|
|
137
|
+
* @examplePrompt Merge the two adjacent rooms by erasing their common edge
|
|
138
|
+
* @examplePrompt Knock through the partition line between these spaces
|
|
139
|
+
* @examplePrompt Erase this boundary edge from the plan
|
|
140
|
+
*
|
|
141
|
+
* # Example
|
|
142
|
+
* ```ts
|
|
143
|
+
* // Merge two adjacent rooms by erasing an internal edge they share
|
|
144
|
+
* const edges = await snaptrude.design.erase.listErasableEdges({ strategies: ["DirectUnion"] })
|
|
145
|
+
* if (edges.length > 0) {
|
|
146
|
+
* const { ok } = await snaptrude.design.erase.edge(edges[0])
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
public abstract edge(edge: ErasableEdgeRef): PluginApiReturn<PluginDesignEraseEdgeResult>
|
|
151
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `snaptrude.design.furniture` — the placeable furniture **catalog** (a library of
|
|
6
|
+
* source items, NOT scene entities). Placement lives at `design.create.furniture`
|
|
7
|
+
* (returns a {@linkcode ComponentHandle}); reads of placed furniture live at
|
|
8
|
+
* `design.query.listFurniture`/`getProperties`.
|
|
9
|
+
*
|
|
10
|
+
* Catalog items are plain value records ({@linkcode PluginFurnitureCatalogItem}) keyed
|
|
11
|
+
* by a library id (team `_id` or general `fullName`) — not handles. Reads are async
|
|
12
|
+
* (network-backed) but carry no `Async` suffix (§6.6).
|
|
13
|
+
*/
|
|
14
|
+
export abstract class PluginDesignFurnitureApi {
|
|
15
|
+
constructor() {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* List the placeable furniture catalog (team + general libraries).
|
|
19
|
+
* @param source Restrict to one library (optional)
|
|
20
|
+
* @returns The catalog as {@linkcode PluginFurnitureCatalogItem}`[]` (`[]` when empty)
|
|
21
|
+
*
|
|
22
|
+
* @examplePrompt What furniture can I place in this project?
|
|
23
|
+
* @examplePrompt Show me all the furniture available in the library
|
|
24
|
+
* @examplePrompt List the chairs and tables I can add to the model
|
|
25
|
+
* @examplePrompt Which furniture items are in my team's library?
|
|
26
|
+
* @examplePrompt Browse the furniture catalog
|
|
27
|
+
*
|
|
28
|
+
* # Example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const teamItems = await snaptrude.design.furniture.listCatalog("team")
|
|
31
|
+
* for (const item of teamItems) console.log(item.id, item.name, item.cost)
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
public abstract listCatalog(
|
|
35
|
+
source?: "team" | "general"
|
|
36
|
+
): PluginApiReturn<PluginFurnitureCatalogItem[]>
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get a single catalog item by its library id.
|
|
40
|
+
* @param id The catalog library id
|
|
41
|
+
* @returns The item, or `null` if no catalog item matches
|
|
42
|
+
*
|
|
43
|
+
* @examplePrompt Get the details of this furniture item from the library
|
|
44
|
+
* @examplePrompt Look up the catalog entry for this chair id
|
|
45
|
+
* @examplePrompt What is the cost of this furniture item?
|
|
46
|
+
* @examplePrompt Show me the family name of the sofa in the catalog
|
|
47
|
+
*
|
|
48
|
+
* # Example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const [entry] = await snaptrude.design.furniture.listCatalog()
|
|
51
|
+
* const item = await snaptrude.design.furniture.getCatalogItem(entry.id)
|
|
52
|
+
* if (item) console.log(item.name, item.source, item.familyName)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
public abstract getCatalogItem(
|
|
56
|
+
id: string
|
|
57
|
+
): PluginApiReturn<PluginFurnitureCatalogItem | null>
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Test whether a catalog item exists for the given library id.
|
|
61
|
+
* @param id The catalog library id
|
|
62
|
+
* @returns `true` if it exists, otherwise `false`
|
|
63
|
+
*
|
|
64
|
+
* @examplePrompt Is this furniture item still in the library?
|
|
65
|
+
* @examplePrompt Check whether a catalog item with this id exists
|
|
66
|
+
* @examplePrompt Does my team library have this chair?
|
|
67
|
+
* @examplePrompt Verify the sofa is available in the catalog before placing it
|
|
68
|
+
*
|
|
69
|
+
* # Example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const [entry] = await snaptrude.design.furniture.listCatalog()
|
|
72
|
+
* const stillAvailable = await snaptrude.design.furniture.exists(entry.id)
|
|
73
|
+
* console.log(stillAvailable ? "safe to place" : "removed from library")
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
public abstract exists(id: string): PluginApiReturn<boolean>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A placeable furniture catalog item (value record — not a scene entity/handle).
|
|
81
|
+
*
|
|
82
|
+
* | Property | Type | Description |
|
|
83
|
+
* |---|---|---|
|
|
84
|
+
* | `id` | `string` | Library id (team `_id` or general `fullName`) — pass to `design.create.furniture` |
|
|
85
|
+
* | `name` | `string` | Display name |
|
|
86
|
+
* | `source` | `'team' \| 'general'` | Which library it came from |
|
|
87
|
+
* | `subType` | `string` | Sub-type (optional) |
|
|
88
|
+
* | `cost` | `number` | Cost (optional; team items) |
|
|
89
|
+
* | `familyName` | `string` | Family name (optional) |
|
|
90
|
+
*/
|
|
91
|
+
export const PluginFurnitureCatalogItem = z.object({
|
|
92
|
+
id: z.string(),
|
|
93
|
+
name: z.string(),
|
|
94
|
+
source: z.enum(["team", "general"]),
|
|
95
|
+
subType: z.string().optional(),
|
|
96
|
+
cost: z.number().optional(),
|
|
97
|
+
familyName: z.string().optional(),
|
|
98
|
+
})
|
|
99
|
+
export type PluginFurnitureCatalogItem = z.infer<typeof PluginFurnitureCatalogItem>
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Arguments for {@linkcode PluginDesignFurnitureApi.listCatalog}.
|
|
103
|
+
*
|
|
104
|
+
* | Property | Type | Description |
|
|
105
|
+
* |---|---|---|
|
|
106
|
+
* | `source` | `'team' \| 'general'` | Restrict to one library (optional) |
|
|
107
|
+
*/
|
|
108
|
+
export const PluginDesignFurnitureListCatalogArgs = z.object({
|
|
109
|
+
source: z.enum(["team", "general"]).optional(),
|
|
110
|
+
})
|
|
111
|
+
export type PluginDesignFurnitureListCatalogArgs = z.infer<
|
|
112
|
+
typeof PluginDesignFurnitureListCatalogArgs
|
|
113
|
+
>
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Arguments for {@linkcode PluginDesignFurnitureApi.getCatalogItem} / {@linkcode PluginDesignFurnitureApi.exists}.
|
|
117
|
+
*
|
|
118
|
+
* | Property | Type | Description |
|
|
119
|
+
* |---|---|---|
|
|
120
|
+
* | `id` | `string` | The catalog library id |
|
|
121
|
+
*/
|
|
122
|
+
export const PluginDesignFurnitureGetCatalogItemArgs = z.object({
|
|
123
|
+
id: z.string(),
|
|
124
|
+
})
|
|
125
|
+
export type PluginDesignFurnitureGetCatalogItemArgs = z.infer<
|
|
126
|
+
typeof PluginDesignFurnitureGetCatalogItemArgs
|
|
127
|
+
>
|
|
128
|
+
|
|
129
|
+
export const PluginDesignFurnitureExistsArgs = PluginDesignFurnitureGetCatalogItemArgs
|
|
130
|
+
export type PluginDesignFurnitureExistsArgs = z.infer<typeof PluginDesignFurnitureExistsArgs>
|