@snaptrude/plugin-core 0.11.0-rc.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +176 -14
  3. package/api-manifest.json +872 -49
  4. package/dist/api/analysis/daylight.d.ts +5 -5
  5. package/dist/api/analysis/solar.d.ts +2 -2
  6. package/dist/api/core/camera/index.d.ts +447 -0
  7. package/dist/api/core/camera/index.d.ts.map +1 -1
  8. package/dist/api/core/geom/create/index.d.ts +942 -101
  9. package/dist/api/core/geom/create/index.d.ts.map +1 -1
  10. package/dist/api/core/geom/query/brep.d.ts +59 -2
  11. package/dist/api/core/geom/query/brep.d.ts.map +1 -1
  12. package/dist/api/core/geom/query/curve.d.ts +59 -35
  13. package/dist/api/core/geom/query/curve.d.ts.map +1 -1
  14. package/dist/api/core/geom/query/edge.d.ts +2 -2
  15. package/dist/api/core/geom/query/face.d.ts +105 -0
  16. package/dist/api/core/geom/query/face.d.ts.map +1 -1
  17. package/dist/api/core/geom/update/contour.d.ts +10 -2
  18. package/dist/api/core/geom/update/contour.d.ts.map +1 -1
  19. package/dist/api/core/geom/update/curve.d.ts +5 -5
  20. package/dist/api/core/geom/update/profile.d.ts +3 -1
  21. package/dist/api/core/geom/update/profile.d.ts.map +1 -1
  22. package/dist/api/core/handles/index.d.ts +4 -2
  23. package/dist/api/core/handles/index.d.ts.map +1 -1
  24. package/dist/api/core/index.d.ts +4 -4
  25. package/dist/api/core/index.d.ts.map +1 -1
  26. package/dist/api/core/io/import/index.d.ts +3 -1
  27. package/dist/api/core/io/import/index.d.ts.map +1 -1
  28. package/dist/api/core/layers.d.ts +377 -255
  29. package/dist/api/core/layers.d.ts.map +1 -1
  30. package/dist/api/core/mode/index.d.ts +19 -7
  31. package/dist/api/core/mode/index.d.ts.map +1 -1
  32. package/dist/api/core/proposals/index.d.ts +4 -3
  33. package/dist/api/core/proposals/index.d.ts.map +1 -1
  34. package/dist/api/core/storeys/index.d.ts +17 -2
  35. package/dist/api/core/storeys/index.d.ts.map +1 -1
  36. package/dist/api/core/storeys/layers.d.ts +408 -0
  37. package/dist/api/core/storeys/layers.d.ts.map +1 -0
  38. package/dist/api/core/tags.d.ts +84 -3
  39. package/dist/api/core/tags.d.ts.map +1 -1
  40. package/dist/api/core/zoom/index.d.ts +13 -0
  41. package/dist/api/core/zoom/index.d.ts.map +1 -1
  42. package/dist/api/design/bim.d.ts +299 -0
  43. package/dist/api/design/bim.d.ts.map +1 -0
  44. package/dist/api/design/boolean/index.d.ts +2 -0
  45. package/dist/api/design/boolean/index.d.ts.map +1 -1
  46. package/dist/api/design/catalog.d.ts +320 -0
  47. package/dist/api/design/catalog.d.ts.map +1 -0
  48. package/dist/api/design/create/bulk-items.d.ts +269 -0
  49. package/dist/api/design/create/bulk-items.d.ts.map +1 -0
  50. package/dist/api/design/create/grids.d.ts +132 -0
  51. package/dist/api/design/create/grids.d.ts.map +1 -0
  52. package/dist/api/design/create/index.d.ts +753 -102
  53. package/dist/api/design/create/index.d.ts.map +1 -1
  54. package/dist/api/design/create/opening-fields.d.ts +38 -0
  55. package/dist/api/design/create/opening-fields.d.ts.map +1 -0
  56. package/dist/api/design/delete/index.d.ts +7 -20
  57. package/dist/api/design/delete/index.d.ts.map +1 -1
  58. package/dist/api/design/dimensions.d.ts +427 -0
  59. package/dist/api/design/dimensions.d.ts.map +1 -0
  60. package/dist/api/design/doors/index.d.ts +24 -23
  61. package/dist/api/design/doors/index.d.ts.map +1 -1
  62. package/dist/api/design/family.d.ts +1446 -0
  63. package/dist/api/design/family.d.ts.map +1 -0
  64. package/dist/api/design/grids.d.ts +237 -0
  65. package/dist/api/design/grids.d.ts.map +1 -0
  66. package/dist/api/design/index.d.ts +30 -0
  67. package/dist/api/design/index.d.ts.map +1 -1
  68. package/dist/api/design/networks.d.ts +1703 -0
  69. package/dist/api/design/networks.d.ts.map +1 -0
  70. package/dist/api/design/query/geometry/index.d.ts +33 -5
  71. package/dist/api/design/query/geometry/index.d.ts.map +1 -1
  72. package/dist/api/design/query/grids.d.ts +287 -0
  73. package/dist/api/design/query/grids.d.ts.map +1 -0
  74. package/dist/api/design/query/index.d.ts +143 -36
  75. package/dist/api/design/query/index.d.ts.map +1 -1
  76. package/dist/api/design/query/spaces.d.ts +5 -66
  77. package/dist/api/design/query/spaces.d.ts.map +1 -1
  78. package/dist/api/design/selection/index.d.ts +12 -12
  79. package/dist/api/design/types/index.d.ts +40 -24
  80. package/dist/api/design/types/index.d.ts.map +1 -1
  81. package/dist/api/design/update/index.d.ts +412 -8
  82. package/dist/api/design/update/index.d.ts.map +1 -1
  83. package/dist/api/design/windows/index.d.ts +8 -8
  84. package/dist/api/design/windows/index.d.ts.map +1 -1
  85. package/dist/api/entity/buildableEnvelope.d.ts +84 -2
  86. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -1
  87. package/dist/api/entity/referenceLine.d.ts +13 -1
  88. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  89. package/dist/api/entity/space.d.ts +12 -15
  90. package/dist/api/entity/space.d.ts.map +1 -1
  91. package/dist/api/entity/story.d.ts +4 -4
  92. package/dist/api/presentation/aiInspiration.d.ts +24 -24
  93. package/dist/api/presentation/annotate.d.ts +38 -22
  94. package/dist/api/presentation/annotate.d.ts.map +1 -1
  95. package/dist/api/presentation/camera.d.ts +265 -0
  96. package/dist/api/presentation/camera.d.ts.map +1 -0
  97. package/dist/api/presentation/drawingContract.d.ts +32 -0
  98. package/dist/api/presentation/drawingContract.d.ts.map +1 -0
  99. package/dist/api/presentation/drawings.d.ts +3523 -0
  100. package/dist/api/presentation/drawings.d.ts.map +1 -0
  101. package/dist/api/presentation/export.d.ts +23 -5
  102. package/dist/api/presentation/export.d.ts.map +1 -1
  103. package/dist/api/presentation/graphics.d.ts +419 -0
  104. package/dist/api/presentation/graphics.d.ts.map +1 -0
  105. package/dist/api/presentation/index.d.ts +66 -12
  106. package/dist/api/presentation/index.d.ts.map +1 -1
  107. package/dist/api/presentation/placedViews.d.ts +117 -51
  108. package/dist/api/presentation/placedViews.d.ts.map +1 -1
  109. package/dist/api/presentation/sections.d.ts +461 -0
  110. package/dist/api/presentation/sections.d.ts.map +1 -0
  111. package/dist/api/presentation/shapes.d.ts +2 -2
  112. package/dist/api/presentation/sheets.d.ts +175 -37
  113. package/dist/api/presentation/sheets.d.ts.map +1 -1
  114. package/dist/api/presentation/standards.d.ts +590 -0
  115. package/dist/api/presentation/standards.d.ts.map +1 -0
  116. package/dist/api/presentation/viewPresets.d.ts +222 -0
  117. package/dist/api/presentation/viewPresets.d.ts.map +1 -0
  118. package/dist/api/presentation/views.d.ts +144 -9
  119. package/dist/api/presentation/views.d.ts.map +1 -1
  120. package/dist/api/presentation/walkthroughs.d.ts +1350 -0
  121. package/dist/api/presentation/walkthroughs.d.ts.map +1 -0
  122. package/dist/api/program/departments.d.ts +58 -2
  123. package/dist/api/program/departments.d.ts.map +1 -1
  124. package/dist/api/program/index.d.ts +16 -6
  125. package/dist/api/program/index.d.ts.map +1 -1
  126. package/dist/api/program/labels.d.ts +355 -0
  127. package/dist/api/program/labels.d.ts.map +1 -0
  128. package/dist/api/program/metadata.d.ts +328 -0
  129. package/dist/api/program/metadata.d.ts.map +1 -0
  130. package/dist/api/program/site.d.ts +4 -4
  131. package/dist/api/program/spreadsheet.d.ts +267 -4
  132. package/dist/api/program/spreadsheet.d.ts.map +1 -1
  133. package/dist/api/workspace/index.d.ts +49 -2
  134. package/dist/api/workspace/index.d.ts.map +1 -1
  135. package/dist/errors/codes.d.ts +5 -8
  136. package/dist/errors/codes.d.ts.map +1 -1
  137. package/dist/handles.d.ts +32 -3
  138. package/dist/handles.d.ts.map +1 -1
  139. package/dist/index.cjs +6534 -2865
  140. package/dist/index.cjs.map +1 -1
  141. package/dist/index.d.ts +2 -0
  142. package/dist/index.d.ts.map +1 -1
  143. package/dist/index.js +6118 -2857
  144. package/dist/index.js.map +1 -1
  145. package/dist/massParameters.d.ts +287 -0
  146. package/dist/massParameters.d.ts.map +1 -0
  147. package/dist/massParameters.ops.d.ts +138 -0
  148. package/dist/massParameters.ops.d.ts.map +1 -0
  149. package/package.json +2 -1
  150. package/scripts/check-dist-fresh.mjs +22 -0
  151. package/scripts/generate-manifest.mjs +5 -0
  152. package/scripts/generate-manifest.test.mjs +14 -3
  153. package/src/api/core/camera/index.ts +429 -1
  154. package/src/api/core/geom/create/index.ts +1037 -102
  155. package/src/api/core/geom/query/brep.ts +60 -2
  156. package/src/api/core/geom/query/curve.ts +26 -2
  157. package/src/api/core/geom/query/edge.ts +2 -2
  158. package/src/api/core/geom/query/face.ts +109 -4
  159. package/src/api/core/geom/update/contour.ts +10 -2
  160. package/src/api/core/geom/update/profile.ts +2 -0
  161. package/src/api/core/handles/index.ts +3 -2
  162. package/src/api/core/index.ts +4 -4
  163. package/src/api/core/io/import/index.ts +11 -3
  164. package/src/api/core/layers.ts +380 -173
  165. package/src/api/core/mode/index.ts +19 -7
  166. package/src/api/core/proposals/index.ts +4 -3
  167. package/src/api/core/storeys/index.ts +19 -2
  168. package/src/api/core/storeys/layers.ts +339 -0
  169. package/src/api/core/tags.ts +76 -0
  170. package/src/api/core/zoom/index.ts +13 -0
  171. package/src/api/design/bim.ts +210 -0
  172. package/src/api/design/boolean/index.ts +2 -0
  173. package/src/api/design/catalog.ts +203 -0
  174. package/src/api/design/create/bulk-items.ts +294 -0
  175. package/src/api/design/create/grids.ts +137 -0
  176. package/src/api/design/create/index.ts +824 -141
  177. package/src/api/design/create/opening-fields.ts +40 -0
  178. package/src/api/design/delete/index.ts +6 -20
  179. package/src/api/design/dimensions.ts +453 -0
  180. package/src/api/design/doors/index.ts +64 -41
  181. package/src/api/design/family.ts +1342 -0
  182. package/src/api/design/grids.ts +237 -0
  183. package/src/api/design/index.ts +49 -4
  184. package/src/api/design/networks.ts +607 -0
  185. package/src/api/design/query/geometry/index.ts +35 -4
  186. package/src/api/design/query/grids.ts +197 -0
  187. package/src/api/design/query/index.ts +105 -5
  188. package/src/api/design/query/spaces.ts +0 -68
  189. package/src/api/design/types/index.ts +31 -24
  190. package/src/api/design/update/index.ts +398 -4
  191. package/src/api/design/windows/index.ts +40 -22
  192. package/src/api/entity/buildableEnvelope.ts +77 -2
  193. package/src/api/entity/referenceLine.ts +25 -12
  194. package/src/api/entity/space.ts +0 -2
  195. package/src/api/presentation/annotate.ts +90 -58
  196. package/src/api/presentation/camera.ts +289 -0
  197. package/src/api/presentation/drawingContract.ts +70 -0
  198. package/src/api/presentation/drawings.ts +1179 -0
  199. package/src/api/presentation/export.ts +32 -6
  200. package/src/api/presentation/graphics.ts +324 -0
  201. package/src/api/presentation/index.ts +73 -14
  202. package/src/api/presentation/placedViews.ts +120 -57
  203. package/src/api/presentation/sections.ts +420 -0
  204. package/src/api/presentation/sheets.ts +182 -37
  205. package/src/api/presentation/standards.ts +445 -0
  206. package/src/api/presentation/viewPresets.ts +241 -0
  207. package/src/api/presentation/views.ts +81 -10
  208. package/src/api/presentation/walkthroughs.ts +1201 -0
  209. package/src/api/program/departments.ts +54 -2
  210. package/src/api/program/index.ts +16 -6
  211. package/src/api/program/labels.ts +332 -0
  212. package/src/api/program/metadata.ts +364 -0
  213. package/src/api/program/spreadsheet.ts +282 -0
  214. package/src/api/workspace/index.ts +51 -2
  215. package/src/errors/codes.ts +9 -30
  216. package/src/handles.ts +42 -3
  217. package/src/index.ts +2 -0
  218. package/src/massParameters.ops.ts +246 -0
  219. package/src/massParameters.ts +427 -0
  220. package/test/drawingContract.test.mjs +288 -0
  221. package/test/errors.test.mjs +1 -4
  222. package/test/massParameters.test.mjs +952 -0
  223. package/test/paperPensContract.test.mjs +75 -0
  224. package/test/presentationViewSettings.test.mjs +85 -0
  225. package/api-manifest.full.json +0 -6928
  226. package/snaptrude-plugin-core-0.11.0.tgz +0 -0
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod"
2
2
  import { PluginApiReturn } from "../../../types"
3
- import { Vec3Handle } from "../../../handles"
3
+ import { Vec3Components, Vec3Handle } from "../../../handles"
4
4
 
5
5
  /**
6
6
  * Camera controls.
@@ -10,6 +10,18 @@ import { Vec3Handle } from "../../../handles"
10
10
  * canvas view menu and the 2D/3D toggle. Like {@linkcode PluginZoomApi}, these
11
11
  * are transient VIEW-STATE changes: they are not model edits, so they are not
12
12
  * write-gated and are not undoable. Accessed via `snaptrude.core.camera`.
13
+ *
14
+ * Read and set the full camera pose (`getPose`/`setPose`), walk and turn it the
15
+ * way the arrow keys do (`move`/`rotate`), and read or change the arrow-key
16
+ * navigation settings (`getNavigationSettings`/`updateNavigationSettings`).
17
+ * Positions are world coordinates in internal `babylon` units (1 unit =
18
+ * 0.254 m, Y up); yaw is degrees clockwise from +z seen from above, pitch is
19
+ * degrees above level.
20
+ *
21
+ * While Present mode is open these calls set the Design frame a view saved in
22
+ * Present (`presentation.views.create`) is taken from; they never move the
23
+ * Present sheet canvas. To pan, zoom or screenshot the Present canvas, use
24
+ * {@linkcode PluginPresentationCameraApi} (`presentation.camera`).
13
25
  */
14
26
  export abstract class PluginCameraApi {
15
27
  constructor() {}
@@ -18,6 +30,10 @@ export abstract class PluginCameraApi {
18
30
  * Point the camera: place its eye at `eye` looking toward `target` (world
19
31
  * coordinates, internal `babylon` units). View-state only — not undoable.
20
32
  *
33
+ * While Present is open this sets the Design frame a view saved in Present
34
+ * is taken from; it never moves the Present sheet canvas; use
35
+ * `presentation.camera` for that.
36
+ *
21
37
  * @param eye - Camera position as a {@linkcode Vec3Handle}
22
38
  * @param target - Point the camera looks at as a {@linkcode Vec3Handle}
23
39
  * @returns `true` once the camera has been positioned.
@@ -44,6 +60,10 @@ export abstract class PluginCameraApi {
44
60
  * perspective) view. Mirrors the canvas view menu. View-state only — not
45
61
  * undoable. The orthographic presets exit 2D mode first if needed.
46
62
  *
63
+ * While Present is open this sets the Design frame a view saved in Present
64
+ * is taken from; it never moves the Present sheet canvas; use
65
+ * `presentation.camera` for that.
66
+ *
47
67
  * @param view - The standard view to snap to ({@linkcode PluginStandardView})
48
68
  * @returns `true` once the view has been applied.
49
69
  *
@@ -84,6 +104,10 @@ export abstract class PluginCameraApi {
84
104
  * 2D/3D toggle: `3d` enters the isometric perspective view, `2d` drops to the
85
105
  * orthographic plan of the active storey. View-state only — not undoable.
86
106
  *
107
+ * While Present is open this sets the Design frame a view saved in Present
108
+ * is taken from; it never moves the Present sheet canvas; use
109
+ * `presentation.camera` for that.
110
+ *
87
111
  * @param mode - `"2d"` or `"3d"` ({@linkcode PluginCameraMode})
88
112
  * @returns `true` once the mode switch has been requested.
89
113
  *
@@ -128,6 +152,10 @@ export abstract class PluginCameraApi {
128
152
  * `"orthographic"` is accepted as a no-op, while `"perspective"` is
129
153
  * rejected — switch to 3D first via `setMode("3d")`.
130
154
  *
155
+ * While Present is open this sets the Design frame a view saved in Present
156
+ * is taken from; it never moves the Present sheet canvas; use
157
+ * `presentation.camera` for that.
158
+ *
131
159
  * @param projection - `"perspective"` or `"orthographic"` ({@linkcode PluginCameraProjection})
132
160
  * @returns `true` once the projection has been applied.
133
161
  *
@@ -151,6 +179,10 @@ export abstract class PluginCameraApi {
151
179
  * action. View-state only — not undoable. Canonical home of the zoom-extents
152
180
  * read (the deprecated `core.zoom.extents`).
153
181
  *
182
+ * While Present is open this sets the Design frame a view saved in Present
183
+ * is taken from; it never moves the Present sheet canvas; use
184
+ * `presentation.camera` for that.
185
+ *
154
186
  * @returns `true` once the camera has been framed to the scene.
155
187
  *
156
188
  * @examplePrompt Zoom out so I can see the whole model
@@ -170,6 +202,10 @@ export abstract class PluginCameraApi {
170
202
  * undoable. Canonical home of the zoom-to-selection read (the deprecated
171
203
  * `core.zoom.selection`).
172
204
  *
205
+ * While Present is open this sets the Design frame a view saved in Present
206
+ * is taken from; it never moves the Present sheet canvas; use
207
+ * `presentation.camera` for that.
208
+ *
173
209
  * @returns `true` if there was a selection to frame; `false` if nothing is
174
210
  * selected (no-op).
175
211
  *
@@ -184,6 +220,180 @@ export abstract class PluginCameraApi {
184
220
  * ```
185
221
  */
186
222
  public abstract zoomSelection(): PluginApiReturn<boolean>
223
+
224
+ /**
225
+ * Read where the camera is and where it looks: the eye and target positions
226
+ * (world coordinates, internal `babylon` units), the view direction as yaw
227
+ * and pitch, the vertical field of view, the projection and the 2D/3D mode.
228
+ * Paired with {@linkcode PluginCameraApi.setPose}.
229
+ *
230
+ * @returns The current {@linkcode PluginCameraPose}.
231
+ * @throws PRECONDITION_FAILED when there is no active camera.
232
+ *
233
+ * @examplePrompt Where is the camera right now?
234
+ * @examplePrompt Remember this viewpoint so we can come back to it
235
+ * @examplePrompt Which way is the camera facing?
236
+ * @examplePrompt How high above the ground is the camera?
237
+ *
238
+ * # Example
239
+ * ```ts
240
+ * const pose = await snaptrude.core.camera.getPose()
241
+ * console.log(pose.eye, pose.yawInDegrees, pose.pitchInDegrees)
242
+ * ```
243
+ */
244
+ public abstract getPose(): PluginApiReturn<PluginCameraPose>
245
+
246
+ /**
247
+ * Place the camera, optionally easing there over `options.durationInSeconds`,
248
+ * and resolve once the new view has been drawn, so a capture that follows sees
249
+ * it without a fixed wait. `pose` is one of:
250
+ *
251
+ * - `{ eye, target }`: stand at `eye` looking at `target`, as
252
+ * {@linkcode PluginCameraApi.lookFrom} does with handles;
253
+ * - `{ eye, yawInDegrees, pitchInDegrees }`: stand at `eye` looking along a
254
+ * direction;
255
+ * - `{ standAt, yawInDegrees? }`: stand on the floor, stair, terrain or
256
+ * ground at or below `standAt`, at the user's eye height above it (the `I`
257
+ * key), facing `yawInDegrees` (the current yaw when omitted).
258
+ *
259
+ * Stops a playing walkthrough and switches from 2D plan view to 3D first.
260
+ * View-state only: not write-gated, not undoable.
261
+ *
262
+ * @param pose - Where to put the camera ({@linkcode PluginCameraPoseInput})
263
+ * @param options - `durationInSeconds`: ease over this long (0 to 10, default 0 jumps)
264
+ * @returns The camera's {@linkcode PluginCameraPose} once it has arrived.
265
+ * @throws PRECONDITION_FAILED when there is no active camera, while a
266
+ * walkthrough export is recording, or when `standAt` lies below the ground
267
+ * with nothing under it. VALIDATION when `eye` and `target` coincide or a
268
+ * pitch is beyond ±89°.
269
+ *
270
+ * @examplePrompt Stand in the living room at eye level facing the window
271
+ * @examplePrompt Move the camera to (40, 12, 30) looking at the entrance
272
+ * @examplePrompt Fly the camera smoothly over to the courtyard
273
+ * @examplePrompt Put me back at the viewpoint we saved earlier
274
+ *
275
+ * # Example
276
+ * ```ts
277
+ * const { camera } = snaptrude.core
278
+ * await camera.setPose({ standAt: { x: 20, y: 0, z: 35 }, yawInDegrees: 90 })
279
+ * await camera.setPose(
280
+ * { eye: { x: 60, y: 25, z: 60 }, target: { x: 0, y: 5, z: 0 } },
281
+ * { durationInSeconds: 1.5 },
282
+ * )
283
+ * ```
284
+ */
285
+ public abstract setPose(
286
+ pose: PluginCameraPoseInput,
287
+ options?: PluginCameraSetPoseOptions,
288
+ ): PluginApiReturn<PluginCameraPose>
289
+
290
+ /**
291
+ * Walk or fly the camera by a displacement in its own frame: `forward` along
292
+ * the level view direction, `right` to its side and `up` vertically, in
293
+ * internal `babylon` units. The view direction does not change. With
294
+ * `options.followsFloor` the camera keeps its height above the floor as it
295
+ * goes, climbing and descending stairs and ramps the way the arrow keys do.
296
+ * Stops a playing walkthrough and switches from 2D plan view to 3D first.
297
+ * View-state only: not write-gated, not undoable.
298
+ *
299
+ * @param displacement - {@linkcode PluginCameraMoveDisplacement}; omitted components are 0
300
+ * @param options - `followsFloor` (default `false`) and `durationInSeconds` (0 to 10, default 0)
301
+ * @returns The camera's {@linkcode PluginCameraPose} after the move.
302
+ * @throws PRECONDITION_FAILED when there is no active camera, or while a
303
+ * walkthrough export is recording.
304
+ *
305
+ * @examplePrompt Walk forward 3 metres
306
+ * @examplePrompt Step to the right a little
307
+ * @examplePrompt Walk up the stairs ahead
308
+ * @examplePrompt Raise the camera by 2 metres
309
+ *
310
+ * # Example
311
+ * ```ts
312
+ * const metre = 1 / 0.254
313
+ * await snaptrude.core.camera.move(
314
+ * { forward: 3 * metre },
315
+ * { followsFloor: true, durationInSeconds: 2 },
316
+ * )
317
+ * ```
318
+ */
319
+ public abstract move(
320
+ displacement: PluginCameraMoveDisplacement,
321
+ options?: PluginCameraMoveOptions,
322
+ ): PluginApiReturn<PluginCameraPose>
323
+
324
+ /**
325
+ * Turn the camera in place by signed angles: `yawInDegrees` to the right
326
+ * (clockwise seen from above) and `pitchInDegrees` up. The eye does not move;
327
+ * the resulting pitch is kept within ±89°. Stops a playing walkthrough and
328
+ * switches from 2D plan view to 3D first. View-state only: not write-gated,
329
+ * not undoable.
330
+ *
331
+ * @param yawInDegrees - Turn to the right by this much (negative turns left)
332
+ * @param pitchInDegrees - Tilt up by this much (negative tilts down; default 0)
333
+ * @param options - `durationInSeconds` (0 to 10, default 0)
334
+ * @returns The camera's {@linkcode PluginCameraPose} after turning.
335
+ * @throws PRECONDITION_FAILED when there is no active camera, or while a
336
+ * walkthrough export is recording.
337
+ *
338
+ * @examplePrompt Turn around
339
+ * @examplePrompt Look 45 degrees to the left
340
+ * @examplePrompt Tilt the camera down a bit
341
+ *
342
+ * # Example
343
+ * ```ts
344
+ * await snaptrude.core.camera.rotate(180, 0, { durationInSeconds: 1 })
345
+ * ```
346
+ */
347
+ public abstract rotate(
348
+ yawInDegrees: number,
349
+ pitchInDegrees?: number,
350
+ options?: PluginCameraRotateOptions,
351
+ ): PluginApiReturn<PluginCameraPose>
352
+
353
+ /**
354
+ * Read the arrow-key navigation settings: whether the arrow keys walk the
355
+ * camera, the eye height used by `setPose`'s `standAt` and by walkthroughs
356
+ * that follow the floor, the walking speed, and whether walking stops at
357
+ * walls. Paired with {@linkcode PluginCameraApi.updateNavigationSettings}.
358
+ *
359
+ * @returns The current {@linkcode PluginCameraNavigationSettings}.
360
+ *
361
+ * @examplePrompt Is arrow-key navigation on?
362
+ * @examplePrompt What eye height does the camera use?
363
+ *
364
+ * # Example
365
+ * ```ts
366
+ * const { isKeyboardNavigationEnabled } =
367
+ * await snaptrude.core.camera.getNavigationSettings()
368
+ * ```
369
+ */
370
+ public abstract getNavigationSettings(): PluginApiReturn<PluginCameraNavigationSettings>
371
+
372
+ /**
373
+ * Change arrow-key navigation settings; only the fields given change.
374
+ * `isKeyboardNavigationEnabled` is the user's Project Settings switch and is
375
+ * saved on this device; the other settings last for the session.
376
+ * Write-gated: this changes the user's preferences, not just the view.
377
+ *
378
+ * @param patch - The settings to change ({@linkcode PluginCameraNavigationSettingsPatch})
379
+ * @returns The {@linkcode PluginCameraNavigationSettings} after the change.
380
+ * @throws METHOD_NOT_PERMITTED when plugin writes are disabled.
381
+ *
382
+ * @examplePrompt Turn off arrow-key navigation
383
+ * @examplePrompt Use a 1.6 m eye height
384
+ * @examplePrompt Make walking stop at walls
385
+ *
386
+ * # Example
387
+ * ```ts
388
+ * await snaptrude.core.camera.updateNavigationSettings({
389
+ * eyeHeight: 1.6 / 0.254,
390
+ * isCollisionEnabled: true,
391
+ * })
392
+ * ```
393
+ */
394
+ public abstract updateNavigationSettings(
395
+ patch: PluginCameraNavigationSettingsPatch,
396
+ ): PluginApiReturn<PluginCameraNavigationSettings>
187
397
  }
188
398
 
189
399
  /**
@@ -266,3 +476,221 @@ export const PluginCameraSetProjectionArgs = z.object({
266
476
  export type PluginCameraSetProjectionArgs = z.infer<
267
477
  typeof PluginCameraSetProjectionArgs
268
478
  >
479
+
480
+ // Plain {x, y, z} record with finite components (the brepFromRevolution `axisOrigin` pattern).
481
+ const FiniteVec3Components = z.object({
482
+ x: z.number().finite(),
483
+ y: z.number().finite(),
484
+ z: z.number().finite(),
485
+ })
486
+
487
+ /** Pitch is kept off the vertical, where yaw has no meaning. */
488
+ const PitchInDegrees = z.number().finite().min(-89).max(89)
489
+
490
+ /** How long a camera move eases for; 0 jumps. */
491
+ const DurationInSeconds = z.number().finite().min(0).max(10)
492
+
493
+ /**
494
+ * The camera's pose — result of {@linkcode PluginCameraApi.getPose},
495
+ * {@linkcode PluginCameraApi.setPose}, {@linkcode PluginCameraApi.move} and
496
+ * {@linkcode PluginCameraApi.rotate}.
497
+ *
498
+ * | Property | Type | Description |
499
+ * |---|---|---|
500
+ * | `eye` | `{ x, y, z }` | Camera position (world, `babylon` units) |
501
+ * | `target` | `{ x, y, z }` | Point the camera looks at |
502
+ * | `yawInDegrees` | `number` | View direction, degrees clockwise from +z seen from above (-180 to 180) |
503
+ * | `pitchInDegrees` | `number` | View direction, degrees above level (negative looks down) |
504
+ * | `fieldOfViewInDegrees` | `number` | Vertical field of view |
505
+ * | `projection` | {@linkcode PluginCameraProjection} | `"perspective"` or `"orthographic"` |
506
+ * | `mode` | {@linkcode PluginCameraMode} | `"2d"` or `"3d"` |
507
+ */
508
+ export const PluginCameraPose = z.object({
509
+ eye: Vec3Components,
510
+ target: Vec3Components,
511
+ yawInDegrees: z.number(),
512
+ pitchInDegrees: z.number(),
513
+ fieldOfViewInDegrees: z.number(),
514
+ projection: PluginCameraProjection,
515
+ mode: PluginCameraMode,
516
+ })
517
+ export type PluginCameraPose = z.infer<typeof PluginCameraPose>
518
+
519
+ /**
520
+ * Where {@linkcode PluginCameraApi.setPose} puts the camera — exactly one of:
521
+ *
522
+ * | Shape | Meaning |
523
+ * |---|---|
524
+ * | `{ eye, target }` | Stand at `eye` looking at `target` |
525
+ * | `{ eye, yawInDegrees, pitchInDegrees }` | Stand at `eye` looking along a direction (pitch within ±89°) |
526
+ * | `{ standAt, yawInDegrees? }` | Stand at eye height on the floor, stair, terrain or ground at or below `standAt`, facing `yawInDegrees` (default: current yaw) |
527
+ *
528
+ * Points are plain `{ x, y, z }` world coordinates in `babylon` units.
529
+ */
530
+ export const PluginCameraPoseInput = z.union([
531
+ z
532
+ .object({ eye: FiniteVec3Components, target: FiniteVec3Components })
533
+ .strict(),
534
+ z
535
+ .object({
536
+ eye: FiniteVec3Components,
537
+ yawInDegrees: z.number().finite(),
538
+ pitchInDegrees: PitchInDegrees,
539
+ })
540
+ .strict(),
541
+ z
542
+ .object({
543
+ standAt: FiniteVec3Components,
544
+ yawInDegrees: z.number().finite().optional(),
545
+ })
546
+ .strict(),
547
+ ])
548
+ export type PluginCameraPoseInput = z.infer<typeof PluginCameraPoseInput>
549
+
550
+ /**
551
+ * Options for {@linkcode PluginCameraApi.setPose}.
552
+ *
553
+ * | Property | Type | Description |
554
+ * |---|---|---|
555
+ * | `durationInSeconds` | `number \| undefined` | Ease to the pose over this long (0 to 10; default 0 jumps) |
556
+ */
557
+ export const PluginCameraSetPoseOptions = z
558
+ .object({ durationInSeconds: DurationInSeconds.optional() })
559
+ .strict()
560
+ export type PluginCameraSetPoseOptions = z.infer<
561
+ typeof PluginCameraSetPoseOptions
562
+ >
563
+
564
+ /**
565
+ * Arguments for {@linkcode PluginCameraApi.setPose}.
566
+ */
567
+ export const PluginCameraSetPoseArgs = z.object({
568
+ pose: PluginCameraPoseInput,
569
+ options: PluginCameraSetPoseOptions.optional(),
570
+ })
571
+ export type PluginCameraSetPoseArgs = z.infer<typeof PluginCameraSetPoseArgs>
572
+
573
+ /**
574
+ * A displacement in the camera's own frame, for {@linkcode PluginCameraApi.move}
575
+ * (`babylon` units; omitted components are 0).
576
+ *
577
+ * | Property | Type | Description |
578
+ * |---|---|---|
579
+ * | `forward` | `number \| undefined` | Along the level view direction (negative walks back) |
580
+ * | `right` | `number \| undefined` | To the camera's right (negative steps left) |
581
+ * | `up` | `number \| undefined` | Vertically (negative descends) |
582
+ */
583
+ export const PluginCameraMoveDisplacement = z
584
+ .object({
585
+ forward: z.number().finite().optional(),
586
+ right: z.number().finite().optional(),
587
+ up: z.number().finite().optional(),
588
+ })
589
+ .strict()
590
+ export type PluginCameraMoveDisplacement = z.infer<
591
+ typeof PluginCameraMoveDisplacement
592
+ >
593
+
594
+ /**
595
+ * Options for {@linkcode PluginCameraApi.move}.
596
+ *
597
+ * | Property | Type | Description |
598
+ * |---|---|---|
599
+ * | `followsFloor` | `boolean \| undefined` | Keep the height above the floor, climbing stairs and ramps (default `false`) |
600
+ * | `durationInSeconds` | `number \| undefined` | Walk over this long (0 to 10; default 0 jumps) |
601
+ */
602
+ export const PluginCameraMoveOptions = z
603
+ .object({
604
+ followsFloor: z.boolean().optional(),
605
+ durationInSeconds: DurationInSeconds.optional(),
606
+ })
607
+ .strict()
608
+ export type PluginCameraMoveOptions = z.infer<typeof PluginCameraMoveOptions>
609
+
610
+ /**
611
+ * Arguments for {@linkcode PluginCameraApi.move}.
612
+ */
613
+ export const PluginCameraMoveArgs = z.object({
614
+ displacement: PluginCameraMoveDisplacement,
615
+ options: PluginCameraMoveOptions.optional(),
616
+ })
617
+ export type PluginCameraMoveArgs = z.infer<typeof PluginCameraMoveArgs>
618
+
619
+ /**
620
+ * Options for {@linkcode PluginCameraApi.rotate}.
621
+ *
622
+ * | Property | Type | Description |
623
+ * |---|---|---|
624
+ * | `durationInSeconds` | `number \| undefined` | Turn over this long (0 to 10; default 0 jumps) |
625
+ */
626
+ export const PluginCameraRotateOptions = z
627
+ .object({ durationInSeconds: DurationInSeconds.optional() })
628
+ .strict()
629
+ export type PluginCameraRotateOptions = z.infer<
630
+ typeof PluginCameraRotateOptions
631
+ >
632
+
633
+ /**
634
+ * Arguments for {@linkcode PluginCameraApi.rotate}.
635
+ */
636
+ export const PluginCameraRotateArgs = z.object({
637
+ yawInDegrees: z.number().finite(),
638
+ pitchInDegrees: z.number().finite().optional(),
639
+ options: PluginCameraRotateOptions.optional(),
640
+ })
641
+ export type PluginCameraRotateArgs = z.infer<typeof PluginCameraRotateArgs>
642
+
643
+ /**
644
+ * How fast the arrow keys walk: the Slow / Normal / Fast navigation setting.
645
+ */
646
+ export const PluginCameraWalkSpeed = z.enum(["slow", "normal", "fast"])
647
+ export type PluginCameraWalkSpeed = z.infer<typeof PluginCameraWalkSpeed>
648
+
649
+ /**
650
+ * The arrow-key navigation settings — result of
651
+ * {@linkcode PluginCameraApi.getNavigationSettings} and
652
+ * {@linkcode PluginCameraApi.updateNavigationSettings}.
653
+ *
654
+ * | Property | Type | Description |
655
+ * |---|---|---|
656
+ * | `isKeyboardNavigationEnabled` | `boolean` | Whether the arrow keys walk the camera (Project Settings) |
657
+ * | `eyeHeight` | `number` | Eye height above the floor, `babylon` units |
658
+ * | `walkSpeed` | {@linkcode PluginCameraWalkSpeed} | Arrow-key walking speed |
659
+ * | `isCollisionEnabled` | `boolean` | Whether walking stops at walls |
660
+ */
661
+ export const PluginCameraNavigationSettings = z.object({
662
+ isKeyboardNavigationEnabled: z.boolean(),
663
+ eyeHeight: z.number(),
664
+ walkSpeed: PluginCameraWalkSpeed,
665
+ isCollisionEnabled: z.boolean(),
666
+ })
667
+ export type PluginCameraNavigationSettings = z.infer<
668
+ typeof PluginCameraNavigationSettings
669
+ >
670
+
671
+ /**
672
+ * The settings to change in {@linkcode PluginCameraApi.updateNavigationSettings};
673
+ * omitted fields keep their value. `eyeHeight` is in `babylon` units, between
674
+ * 0.8 m and 2.5 m (3.15 to 9.84 units).
675
+ */
676
+ export const PluginCameraNavigationSettingsPatch = z
677
+ .object({
678
+ isKeyboardNavigationEnabled: z.boolean().optional(),
679
+ eyeHeight: z.number().finite().min(3.15).max(9.84).optional(),
680
+ walkSpeed: PluginCameraWalkSpeed.optional(),
681
+ isCollisionEnabled: z.boolean().optional(),
682
+ })
683
+ .strict()
684
+ export type PluginCameraNavigationSettingsPatch = z.infer<
685
+ typeof PluginCameraNavigationSettingsPatch
686
+ >
687
+
688
+ /**
689
+ * Arguments for {@linkcode PluginCameraApi.updateNavigationSettings}.
690
+ */
691
+ export const PluginCameraUpdateNavigationSettingsArgs = z.object({
692
+ patch: PluginCameraNavigationSettingsPatch,
693
+ })
694
+ export type PluginCameraUpdateNavigationSettingsArgs = z.infer<
695
+ typeof PluginCameraUpdateNavigationSettingsArgs
696
+ >