@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,164 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unit-type queries and conversion.
|
|
6
|
+
*
|
|
7
|
+
* Snaptrude stores all geometry in an internal `babylon` unit. These methods
|
|
8
|
+
* read the available unit types, the internal (`babylon`) type, and the current
|
|
9
|
+
* project type; set the current project type; and convert values between any two
|
|
10
|
+
* unit types.
|
|
11
|
+
*
|
|
12
|
+
* Accessed via `snaptrude.core.units`.
|
|
13
|
+
*/
|
|
14
|
+
export abstract class PluginUnitsApi {
|
|
15
|
+
constructor() {}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* List the selectable real-world unit types (excludes the internal `babylon`
|
|
19
|
+
* storage type, which is read via {@linkcode PluginUnitsApi.getBabylonType}).
|
|
20
|
+
*
|
|
21
|
+
* @examplePrompt What units can I use in this project?
|
|
22
|
+
* @examplePrompt List all the available measurement units
|
|
23
|
+
* @examplePrompt Which unit systems does Snaptrude support?
|
|
24
|
+
* @examplePrompt Show the unit options I could switch the model to
|
|
25
|
+
*
|
|
26
|
+
* # Example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const types = await snaptrude.core.units.listTypes()
|
|
29
|
+
* console.log(types) // ["meters", "feet-inches", "inches", ...]
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
public abstract listTypes(): PluginApiReturn<PUnitType[]>
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the internal storage unit type that all geometry is kept in — always
|
|
36
|
+
* `"babylon"` — for use as one side of a {@linkcode PluginUnitsApi.convert} call.
|
|
37
|
+
*
|
|
38
|
+
* @examplePrompt What unit does Snaptrude store geometry in internally?
|
|
39
|
+
* @examplePrompt Get the internal babylon unit type
|
|
40
|
+
* @examplePrompt Which unit are raw model coordinates saved in?
|
|
41
|
+
*
|
|
42
|
+
* # Example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const babylon = await snaptrude.core.units.getBabylonType() // "babylon"
|
|
45
|
+
* const meters = await snaptrude.core.units.convert(10, babylon, "meters")
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
public abstract getBabylonType(): PluginApiReturn<PUnitType>
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get the current project's unit type — the unit lengths are displayed and
|
|
52
|
+
* entered in. Paired with {@linkcode PluginUnitsApi.setType}.
|
|
53
|
+
*
|
|
54
|
+
* @examplePrompt What units is this project using?
|
|
55
|
+
* @examplePrompt Are we working in metric or imperial?
|
|
56
|
+
* @examplePrompt Check the current measurement unit of the model
|
|
57
|
+
* @examplePrompt Is the file set to millimetres or feet and inches?
|
|
58
|
+
*
|
|
59
|
+
* # Example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const type = await snaptrude.core.units.getType()
|
|
62
|
+
* console.log(type) // e.g. "millimeters"
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
public abstract getType(): PluginApiReturn<PUnitType>
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Set the current project's unit type. Paired with {@linkcode PluginUnitsApi.getType}.
|
|
69
|
+
*
|
|
70
|
+
* @param type - The unit type to set as the project unit.
|
|
71
|
+
* @returns `true` if applied; `false` if `type` is not a settable project unit
|
|
72
|
+
* (e.g. `kilometers`, `miles`, `babylon`).
|
|
73
|
+
*
|
|
74
|
+
* @examplePrompt Change the project units to millimeters
|
|
75
|
+
* @examplePrompt Switch this model to feet and inches
|
|
76
|
+
* @examplePrompt Set the working units to metric
|
|
77
|
+
* @examplePrompt Make the drawing use centimetres instead of meters
|
|
78
|
+
*
|
|
79
|
+
* # Example
|
|
80
|
+
* ```ts
|
|
81
|
+
* await snaptrude.core.units.setType("meters")
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
public abstract setType(type: PUnitType): PluginApiReturn<boolean>
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Convert a value between two unit types.
|
|
88
|
+
*
|
|
89
|
+
* @param value - The numeric value to convert.
|
|
90
|
+
* @param from - Source unit type.
|
|
91
|
+
* @param to - Target unit type.
|
|
92
|
+
* @param degree - (Optional) 1 = length, 2 = area, 3 = volume. Defaults to 1.
|
|
93
|
+
* @returns The converted numeric value.
|
|
94
|
+
*
|
|
95
|
+
* @examplePrompt Convert 5 meters to feet and inches
|
|
96
|
+
* @examplePrompt How many millimetres is 12 feet?
|
|
97
|
+
* @examplePrompt Change this area from internal units to square metres
|
|
98
|
+
* @examplePrompt Turn 2500 mm into meters
|
|
99
|
+
* @examplePrompt Convert a volume value from babylon units to cubic feet
|
|
100
|
+
*
|
|
101
|
+
* # Example
|
|
102
|
+
* ```ts
|
|
103
|
+
* // 5 meters → internal babylon units
|
|
104
|
+
* const b = await snaptrude.core.units.convert(5, "meters", "babylon")
|
|
105
|
+
* // an internal area → square metres
|
|
106
|
+
* const m2 = await snaptrude.core.units.convert(area, "babylon", "meters", 2)
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
public abstract convert(
|
|
110
|
+
value: number,
|
|
111
|
+
from: PUnitType,
|
|
112
|
+
to: PUnitType,
|
|
113
|
+
degree?: number,
|
|
114
|
+
): PluginApiReturn<number>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Supported unit types. `babylon` is Snaptrude's internal storage unit; the rest
|
|
119
|
+
* are real-world units. Mirrors the engine `Converter.UNITS` vocabulary.
|
|
120
|
+
*/
|
|
121
|
+
export const PUnitType = z.enum([
|
|
122
|
+
"meters",
|
|
123
|
+
"feet-inches",
|
|
124
|
+
"inches",
|
|
125
|
+
"centimeters",
|
|
126
|
+
"millimeters",
|
|
127
|
+
"kilometers",
|
|
128
|
+
"miles",
|
|
129
|
+
"babylon",
|
|
130
|
+
])
|
|
131
|
+
|
|
132
|
+
export type PUnitType = z.infer<typeof PUnitType>
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Arguments for {@linkcode PluginUnitsApi.setType}.
|
|
136
|
+
*
|
|
137
|
+
* | Property | Type | Description |
|
|
138
|
+
* |---|---|---|
|
|
139
|
+
* | `type` | {@linkcode PUnitType} | The unit type to set as the project unit |
|
|
140
|
+
*/
|
|
141
|
+
export const PluginUnitsSetTypeArgs = z.object({
|
|
142
|
+
type: PUnitType,
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
export type PluginUnitsSetTypeArgs = z.infer<typeof PluginUnitsSetTypeArgs>
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Arguments for {@linkcode PluginUnitsApi.convert}.
|
|
149
|
+
*
|
|
150
|
+
* | Property | Type | Description |
|
|
151
|
+
* |---|---|---|
|
|
152
|
+
* | `value` | `number` | The numeric value to convert |
|
|
153
|
+
* | `from` | {@linkcode PUnitType} | Source unit type |
|
|
154
|
+
* | `to` | {@linkcode PUnitType} | Target unit type |
|
|
155
|
+
* | `degree` | `1 \| 2 \| 3` | (Optional) 1 = length, 2 = area, 3 = volume. Defaults to 1 |
|
|
156
|
+
*/
|
|
157
|
+
export const PluginUnitsConvertArgs = z.object({
|
|
158
|
+
value: z.number(),
|
|
159
|
+
from: PUnitType,
|
|
160
|
+
to: PUnitType,
|
|
161
|
+
degree: z.number().int().min(1).max(3).optional(),
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
export type PluginUnitsConvertArgs = z.infer<typeof PluginUnitsConvertArgs>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../../types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Camera zoom controls.
|
|
5
|
+
*
|
|
6
|
+
* Frame the viewport camera onto scene geometry — mirrors the canvas zoom menu
|
|
7
|
+
* ("Zoom extents" / "Zoom to selection"). Accessed via `snaptrude.core.zoom`.
|
|
8
|
+
*/
|
|
9
|
+
export abstract class PluginZoomApi {
|
|
10
|
+
constructor() {}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Zoom (fit) the camera to all geometry in the scene — the "zoom extents" action.
|
|
14
|
+
*
|
|
15
|
+
* @returns `true` once the camera has been framed to the scene.
|
|
16
|
+
*
|
|
17
|
+
* @examplePrompt Zoom out so I can see the whole model
|
|
18
|
+
* @examplePrompt Fit everything in the view
|
|
19
|
+
* @examplePrompt Frame the entire building in the viewport
|
|
20
|
+
* @examplePrompt Do a zoom extents on the canvas
|
|
21
|
+
* @examplePrompt Show me the full scene
|
|
22
|
+
*
|
|
23
|
+
* # Example
|
|
24
|
+
* ```ts
|
|
25
|
+
* await snaptrude.core.zoom.extents()
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
public abstract extents(): PluginApiReturn<boolean>
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Zoom (fit) the camera to the current selection.
|
|
32
|
+
*
|
|
33
|
+
* @returns `true` if there was a selection to frame; `false` if nothing is
|
|
34
|
+
* selected (no-op).
|
|
35
|
+
*
|
|
36
|
+
* @examplePrompt Zoom in on what I have selected
|
|
37
|
+
* @examplePrompt Frame the selected walls in the view
|
|
38
|
+
* @examplePrompt Focus the camera on my current selection
|
|
39
|
+
* @examplePrompt Fit the view to the selected room
|
|
40
|
+
*
|
|
41
|
+
* # Example
|
|
42
|
+
* ```ts
|
|
43
|
+
* await snaptrude.core.zoom.selection()
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
public abstract selection(): PluginApiReturn<boolean>
|
|
47
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../../types"
|
|
3
|
+
import { ComponentHandle, Vec3Handle } from "../../../handles"
|
|
4
|
+
import { BooleanOutcome } from "../shared"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `snaptrude.design.boolean` — OpenCascade CSG on scene masses/spaces.
|
|
8
|
+
*
|
|
9
|
+
* Every method **commits** the operation as one undoable step (engine `run()`
|
|
10
|
+
* queues create/delete/group/dimension commands, `execute()` runs them through
|
|
11
|
+
* `CommandManager`) and returns the committed {@linkcode BooleanOutcome}. Failures
|
|
12
|
+
* **throw** (RPC rejects) — no `Result<>` monad crosses the boundary.
|
|
13
|
+
*
|
|
14
|
+
* Eligibility (all inputs): a `Mass` that is a room OR a DEPARTMENT, has a brep, is
|
|
15
|
+
* unlocked (mesh + bucket), visible, and NOT in a parametric-copy group; the whole
|
|
16
|
+
* set must be all-planar OR all-non-planar; **≥2** components; all inputs share one
|
|
17
|
+
* group or are ungrouped; inputs must be adjacent/overlapping.
|
|
18
|
+
*
|
|
19
|
+
* `design.boolean.subtract` is a **CSG geometry delete** — distinct from
|
|
20
|
+
* `design.delete.entities` (hard entity removal) and `design.erase.edge`
|
|
21
|
+
* (adjacency-edge topology op).
|
|
22
|
+
*
|
|
23
|
+
* TRANSPORT: positional args per method.
|
|
24
|
+
*/
|
|
25
|
+
export abstract class PluginDesignBooleanApi {
|
|
26
|
+
constructor() {}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Fuse two or more masses into a single combined mass (`A ∪ B ∪ …`) — a boolean
|
|
30
|
+
* (CSG) union that merges the adjacent or overlapping inputs into one solid,
|
|
31
|
+
* committed as a single undoable step. Order-independent.
|
|
32
|
+
* @param components - The ≥2 entities to fuse (order-independent)
|
|
33
|
+
* @param options - Optional output offset — {@linkcode BooleanOptions}
|
|
34
|
+
* @returns The committed CSG delta — {@linkcode BooleanOutcome}
|
|
35
|
+
* @throws if inputs are ineligible, disjoint, non-manifold when joined, span
|
|
36
|
+
* different groups, or the CSG yields no / invalid geometry.
|
|
37
|
+
*
|
|
38
|
+
* @examplePrompt Merge these two masses into one
|
|
39
|
+
* @examplePrompt Union the selected volumes into a single mass
|
|
40
|
+
* @examplePrompt Combine the overlapping rooms into one shape
|
|
41
|
+
* @examplePrompt Join the tower and podium blocks together
|
|
42
|
+
* @examplePrompt Fuse all the selected massing blocks into a single solid
|
|
43
|
+
*
|
|
44
|
+
* # Example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // Fuse the overlapping massing blocks on the ground storey into one solid
|
|
47
|
+
* const masses = await snaptrude.design.query.listMasses({ storeys: [1] })
|
|
48
|
+
* const { created, deleted } = await snaptrude.design.boolean.union(masses)
|
|
49
|
+
* console.log("created", created.length, "mass; consumed", deleted.length)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
public abstract union(
|
|
53
|
+
components: ComponentHandle[],
|
|
54
|
+
options?: BooleanOptions,
|
|
55
|
+
): PluginApiReturn<BooleanOutcome>
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Cut one or more tool masses out of a target mass (`target − ⋃tools`) — a
|
|
59
|
+
* boolean (CSG) subtraction that carves the tools' volume out of the target and
|
|
60
|
+
* commits the remainder as a single undoable step.
|
|
61
|
+
*
|
|
62
|
+
* ORDER-SENSITIVE: the host seeds `[target, ...tools]`; index 0 is the arg brep,
|
|
63
|
+
* the rest are tool breps. `deleted` includes the target AND every tool;
|
|
64
|
+
* `created` is the remainder mass(es).
|
|
65
|
+
* @param target - The entity subtracted FROM (arg brep)
|
|
66
|
+
* @param tools - The ≥1 entities subtracted (tool breps)
|
|
67
|
+
* @param options - Optional output offset — {@linkcode BooleanOptions}
|
|
68
|
+
* @returns The committed CSG delta — {@linkcode BooleanOutcome}
|
|
69
|
+
* @throws as {@linkcode union}; a `NoResult` here carries the "select the target
|
|
70
|
+
* object first" hint from the engine.
|
|
71
|
+
*
|
|
72
|
+
* @examplePrompt Cut this shape out of the bigger mass
|
|
73
|
+
* @examplePrompt Subtract the cylinder from the building volume
|
|
74
|
+
* @examplePrompt Punch an opening through this block using the small box
|
|
75
|
+
* @examplePrompt Carve the courtyard volume out of the main massing
|
|
76
|
+
* @examplePrompt Remove the overlapping part of mass B from mass A
|
|
77
|
+
*
|
|
78
|
+
* # Example
|
|
79
|
+
* ```ts
|
|
80
|
+
* // Order matters: the first arg is the target, the array holds the tools
|
|
81
|
+
* const [building, courtyard] = await snaptrude.design.selection.get()
|
|
82
|
+
* const { created, deleted } = await snaptrude.design.boolean.subtract(building, [courtyard])
|
|
83
|
+
* // deleted includes the target AND every tool; created is the remainder
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
public abstract subtract(
|
|
87
|
+
target: ComponentHandle,
|
|
88
|
+
tools: ComponentHandle[],
|
|
89
|
+
options?: BooleanOptions,
|
|
90
|
+
): PluginApiReturn<BooleanOutcome>
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Keep only the overlapping volume of exactly two masses (`A ∩ B`) — a boolean
|
|
94
|
+
* (CSG) intersection that discards everything outside the shared region and
|
|
95
|
+
* commits the overlap as a single undoable step. Order-independent.
|
|
96
|
+
*
|
|
97
|
+
* HARD constraint: **EXACTLY 2** components (schema `.length(2)`; the engine
|
|
98
|
+
* also throws `MoreThan2ComponentsForIntersect` on >2).
|
|
99
|
+
* @param components - **EXACTLY 2** entities to intersect (order-independent)
|
|
100
|
+
* @param options - Optional output offset — {@linkcode BooleanOptions}
|
|
101
|
+
* @returns The committed CSG delta — {@linkcode BooleanOutcome}
|
|
102
|
+
* @throws as {@linkcode union}, plus `MoreThan2ComponentsForIntersect` on >2.
|
|
103
|
+
*
|
|
104
|
+
* @examplePrompt Keep only the part where these two masses overlap
|
|
105
|
+
* @examplePrompt Intersect the two selected volumes
|
|
106
|
+
* @examplePrompt Give me the common volume between the tower and the zoning envelope
|
|
107
|
+
* @examplePrompt Trim this mass down to just its overlap with the other one
|
|
108
|
+
*
|
|
109
|
+
* # Example
|
|
110
|
+
* ```ts
|
|
111
|
+
* // Keep only the overlap of the tower and the zoning envelope (EXACTLY 2 inputs),
|
|
112
|
+
* // shifting the result mass 10 units in x via the optional offset
|
|
113
|
+
* const [tower, envelope] = await snaptrude.design.query.listMasses()
|
|
114
|
+
* const offset = await snaptrude.core.math.vec3.new(10, 0, 0)
|
|
115
|
+
* const { created } = await snaptrude.design.boolean.intersect([tower, envelope], { offset })
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
public abstract intersect(
|
|
119
|
+
components: ComponentHandle[],
|
|
120
|
+
options?: BooleanOptions,
|
|
121
|
+
): PluginApiReturn<BooleanOutcome>
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Optional knobs shared by all boolean ops. The only safe one is a world-space
|
|
126
|
+
* translation applied to the output mass(es) — maps to `Boolean3dOperation.offset`.
|
|
127
|
+
*
|
|
128
|
+
* | Property | Type | Description |
|
|
129
|
+
* |---|---|---|
|
|
130
|
+
* | `offset` | {@linkcode Vec3Handle} | Translation added to the created result mass(es) (default: none) |
|
|
131
|
+
*/
|
|
132
|
+
export const BooleanOptions = z.object({
|
|
133
|
+
offset: Vec3Handle.optional(),
|
|
134
|
+
})
|
|
135
|
+
export type BooleanOptions = z.infer<typeof BooleanOptions>
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Arguments for {@linkcode PluginDesignBooleanApi.union}.
|
|
139
|
+
*
|
|
140
|
+
* | Property | Type | Description |
|
|
141
|
+
* |---|---|---|
|
|
142
|
+
* | `components` | {@linkcode ComponentHandle}`[]` | The ≥2 entities to fuse (order-independent) |
|
|
143
|
+
* | `options` | {@linkcode BooleanOptions} | Optional output offset |
|
|
144
|
+
*/
|
|
145
|
+
export const PluginDesignBooleanUnionArgs = z.object({
|
|
146
|
+
components: z.array(ComponentHandle).min(2),
|
|
147
|
+
options: BooleanOptions.optional(),
|
|
148
|
+
})
|
|
149
|
+
export type PluginDesignBooleanUnionArgs = z.infer<typeof PluginDesignBooleanUnionArgs>
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Arguments for {@linkcode PluginDesignBooleanApi.subtract}.
|
|
153
|
+
*
|
|
154
|
+
* | Property | Type | Description |
|
|
155
|
+
* |---|---|---|
|
|
156
|
+
* | `target` | {@linkcode ComponentHandle} | The entity subtracted FROM (arg brep) |
|
|
157
|
+
* | `tools` | {@linkcode ComponentHandle}`[]` | The ≥1 entities subtracted (tool breps) |
|
|
158
|
+
* | `options` | {@linkcode BooleanOptions} | Optional output offset |
|
|
159
|
+
*/
|
|
160
|
+
export const PluginDesignBooleanSubtractArgs = z.object({
|
|
161
|
+
target: ComponentHandle,
|
|
162
|
+
tools: z.array(ComponentHandle).min(1),
|
|
163
|
+
options: BooleanOptions.optional(),
|
|
164
|
+
})
|
|
165
|
+
export type PluginDesignBooleanSubtractArgs = z.infer<typeof PluginDesignBooleanSubtractArgs>
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Arguments for {@linkcode PluginDesignBooleanApi.intersect}.
|
|
169
|
+
*
|
|
170
|
+
* | Property | Type | Description |
|
|
171
|
+
* |---|---|---|
|
|
172
|
+
* | `components` | {@linkcode ComponentHandle}`[]` | **EXACTLY 2** entities to intersect (order-independent) |
|
|
173
|
+
* | `options` | {@linkcode BooleanOptions} | Optional output offset |
|
|
174
|
+
*/
|
|
175
|
+
export const PluginDesignBooleanIntersectArgs = z.object({
|
|
176
|
+
components: z.array(ComponentHandle).length(2),
|
|
177
|
+
options: BooleanOptions.optional(),
|
|
178
|
+
})
|
|
179
|
+
export type PluginDesignBooleanIntersectArgs = z.infer<typeof PluginDesignBooleanIntersectArgs>
|