@snaptrude/plugin-core 0.2.2 → 0.2.3

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.
@@ -5,7 +5,7 @@ import { PQuat } from "../core/math/quat"
5
5
  import { PProfile } from "../core/geom/profile"
6
6
 
7
7
  /**
8
- * Space (room/mass) management — create, query, and delete spaces.
8
+ * Space (room/mass) management — create, query, update, and delete spaces.
9
9
  *
10
10
  * A **space** is a 3D volume representing a room or mass in the
11
11
  * Snaptrude scene. Spaces live on a particular story and carry
@@ -99,6 +99,63 @@ export abstract class PluginSpaceApi {
99
99
  position,
100
100
  }: PluginSpaceCreateFromProfileArgs): PluginApiReturn<PluginSpaceCreateFromProfileResult>
101
101
 
102
+ /**
103
+ * Update a space's BRep and mesh geometry by extruding a 2D profile.
104
+ *
105
+ * The {@linkcode PluginSpaceUpdateGeometryFromProfileArgs.profile profile} is
106
+ * extruded upward (along the Y axis) by
107
+ * {@linkcode PluginSpaceUpdateGeometryFromProfileArgs.extrudeHeight extrudeHeight}
108
+ * and applied to the existing space. The space keeps the same `spaceId`,
109
+ * metadata, department, and transform; only its geometry is replaced.
110
+ *
111
+ * Profile points are interpreted in scene coordinates. Profiles returned by
112
+ * {@linkcode PluginSpaceApi.get} with `"profile"` can be passed back directly;
113
+ * `"planPoints"` can be used to construct line-only profiles in the same X/Z
114
+ * plan coordinate space.
115
+ *
116
+ * Use {@linkcode PluginProfileApi.fromLinePoints} to quickly build a profile
117
+ * from a list of points.
118
+ *
119
+ * @param args - An object containing:
120
+ * - {@linkcode PluginSpaceUpdateGeometryFromProfileArgs.spaceId args.spaceId} —
121
+ * The unique space ID to update
122
+ * - {@linkcode PluginSpaceUpdateGeometryFromProfileArgs.profile args.profile} —
123
+ * A closed {@linkcode PProfile} defining the new floor shape
124
+ * - {@linkcode PluginSpaceUpdateGeometryFromProfileArgs.extrudeHeight
125
+ * args.extrudeHeight} — New extrusion height in Babylon units
126
+ * @returns A {@linkcode PluginSpaceUpdateGeometryFromProfileResult} with the
127
+ * `spaceId` of the updated space
128
+ * @throws If the space does not exist, the component is not a space/mass, the
129
+ * height is not positive, or the profile cannot create valid geometry
130
+ *
131
+ * # Example
132
+ * ```ts
133
+ * const { vec3 } = snaptrude.core.math
134
+ *
135
+ * const profile = await snaptrude.core.geom.profile.fromLinePoints({
136
+ * points: [
137
+ * vec3.new(0, 0, 0),
138
+ * vec3.new(12, 0, 0),
139
+ * vec3.new(12, 0, 6),
140
+ * vec3.new(0, 0, 6),
141
+ * ],
142
+ * })
143
+ *
144
+ * const { spaceId } = await snaptrude.entity.space.updateGeometryFromProfile({
145
+ * spaceId: "some-space-id",
146
+ * profile,
147
+ * extrudeHeight: 4,
148
+ * })
149
+ * ```
150
+ */
151
+ public abstract updateGeometryFromProfile({
152
+ spaceId,
153
+ profile,
154
+ extrudeHeight,
155
+ }: PluginSpaceUpdateGeometryFromProfileArgs): PluginApiReturn<
156
+ PluginSpaceUpdateGeometryFromProfileResult
157
+ >
158
+
102
159
  /**
103
160
  * Get the IDs of all spaces in the current project.
104
161
  *
@@ -269,6 +326,40 @@ export type PluginSpaceCreateFromProfileResult = z.infer<
269
326
  typeof PluginSpaceCreateFromProfileResult
270
327
  >
271
328
 
329
+ /**
330
+ * Arguments for {@linkcode PluginSpaceApi.updateGeometryFromProfile}.
331
+ *
332
+ * | Property | Type | Description |
333
+ * |---|---|---|
334
+ * | `spaceId` | `string` | Space to update |
335
+ * | `profile` | {@linkcode PProfile} | Closed 2D profile defining the new floor shape |
336
+ * | `extrudeHeight` | `number` | New extrusion height in Babylon units |
337
+ */
338
+ export const PluginSpaceUpdateGeometryFromProfileArgs = z.object({
339
+ spaceId: z.string(),
340
+ profile: PProfile,
341
+ extrudeHeight: z.number(),
342
+ })
343
+
344
+ export type PluginSpaceUpdateGeometryFromProfileArgs = z.infer<
345
+ typeof PluginSpaceUpdateGeometryFromProfileArgs
346
+ >
347
+
348
+ /**
349
+ * Result of {@linkcode PluginSpaceApi.updateGeometryFromProfile}.
350
+ *
351
+ * | Property | Type | Description |
352
+ * |---|---|---|
353
+ * | `spaceId` | `string` | Unique ID of the updated space |
354
+ */
355
+ export const PluginSpaceUpdateGeometryFromProfileResult = z.object({
356
+ spaceId: z.string(),
357
+ })
358
+
359
+ export type PluginSpaceUpdateGeometryFromProfileResult = z.infer<
360
+ typeof PluginSpaceUpdateGeometryFromProfileResult
361
+ >
362
+
272
363
  /**
273
364
  * Available properties that can be queried on a space.
274
365
  *
@@ -306,6 +397,7 @@ export type PluginSpaceCreateFromProfileResult = z.infer<
306
397
  * | Value | Return Type | Description |
307
398
  * |---|---|---|
308
399
  * | `"planPoints"` | {@linkcode PVec3}`[]` | Bottom outer profile points in world space with `y = 0` (2D plan). No closing duplicate point. |
400
+ * | `"profile"` | {@linkcode PProfile} | Bottom outer profile in world space, preserving line/arc curve data. |
309
401
  */
310
402
  export const PluginSpaceGetProperty = z.enum([
311
403
  // Basic
@@ -331,6 +423,7 @@ export const PluginSpaceGetProperty = z.enum([
331
423
  "rotationQuaternion",
332
424
  // Derived from brep
333
425
  "planPoints",
426
+ "profile",
334
427
  ])
335
428
 
336
429
  /**
@@ -410,6 +503,7 @@ export const PluginSpaceGetResult = z
410
503
  rotationQuaternion: PQuat.nullable(),
411
504
  // Derived from brep
412
505
  planPoints: z.array(PVec3),
506
+ profile: PProfile,
413
507
  })
414
508
  .partial()
415
509