@snaptrude/plugin-core 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/api/entity/space.d.ts +153 -1
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/tools/copy.d.ts +59 -0
- package/dist/api/tools/copy.d.ts.map +1 -0
- package/dist/api/tools/index.d.ts +11 -4
- package/dist/api/tools/index.d.ts.map +1 -1
- package/dist/api/tools/offset.d.ts +43 -0
- package/dist/api/tools/offset.d.ts.map +1 -0
- package/dist/index.cjs +79 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +72 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/entity/space.ts +95 -1
- package/src/api/index.ts +2 -2
- package/src/api/tools/copy.ts +55 -0
- package/src/api/tools/index.ts +15 -4
- package/src/api/tools/offset.ts +43 -0
- package/dist/api/tools/material.d.ts +0 -51
- package/dist/api/tools/material.d.ts.map +0 -1
- package/src/api/tools/material.ts +0 -49
package/src/api/entity/space.ts
CHANGED
|
@@ -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
|
|
package/src/api/index.ts
CHANGED
|
@@ -10,13 +10,13 @@ import { PluginUnitsApi } from "./units"
|
|
|
10
10
|
*
|
|
11
11
|
* - {@linkcode PluginApi.core} — Math and geometry primitives
|
|
12
12
|
* - {@linkcode PluginApi.entity} — CRUD operations on Snaptrude entities (spaces, stories)
|
|
13
|
-
* - {@linkcode PluginApi.tools} —
|
|
13
|
+
* - {@linkcode PluginApi.tools} — Copy, offset, selection, and transform tools
|
|
14
14
|
* - {@linkcode PluginApi.units} — Unit conversion utilities
|
|
15
15
|
*/
|
|
16
16
|
export abstract class PluginApi {
|
|
17
17
|
/** Core math and geometry primitives. See {@linkcode PluginCoreApi}. */
|
|
18
18
|
public abstract core: PluginCoreApi
|
|
19
|
-
/**
|
|
19
|
+
/** Copy, offset, selection, and transform tools. See {@linkcode PluginToolsApi}. */
|
|
20
20
|
public abstract tools: PluginToolsApi
|
|
21
21
|
/** CRUD operations on Snaptrude entities. See {@linkcode PluginEntityApi}. */
|
|
22
22
|
public abstract entity: PluginEntityApi
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import type { ComponentId } from "../../types"
|
|
3
|
+
import { PVec3 } from "../core/math/vec3"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copy mode for `snaptrude.tools.copy`.
|
|
7
|
+
*
|
|
8
|
+
* | Value | Description |
|
|
9
|
+
* |---|---|
|
|
10
|
+
* | `"instance"` | Create instanced copies where possible |
|
|
11
|
+
* | `"unique"` | Create independent geometry copies |
|
|
12
|
+
*/
|
|
13
|
+
export const PluginCopyMode = z.enum(["instance", "unique"])
|
|
14
|
+
|
|
15
|
+
export type PluginCopyMode = z.infer<typeof PluginCopyMode>
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Arguments for `snaptrude.tools.copy`.
|
|
19
|
+
*
|
|
20
|
+
* Creates one or more copies for each component in `componentIds`. Copy `i` is
|
|
21
|
+
* offset by `displacement * i`, where `i` starts at `1`. Source positions are
|
|
22
|
+
* preserved. In `"instance"` mode, a unique source mesh can be replaced by an
|
|
23
|
+
* instance at the same position so the source and copied objects remain in the
|
|
24
|
+
* same instance family. The created copy stack becomes the active editor
|
|
25
|
+
* selection, matching the native paste workflow.
|
|
26
|
+
*
|
|
27
|
+
* | Property | Type | Description |
|
|
28
|
+
* |---|---|---|
|
|
29
|
+
* | `componentIds` | `string[]` | Component IDs to copy |
|
|
30
|
+
* | `displacement` | {@linkcode PVec3} | Offset applied to each copy in Babylon units |
|
|
31
|
+
* | `count` | `number` | Number of copies per component. Defaults to `1` |
|
|
32
|
+
* | `copyMode` | {@linkcode PluginCopyMode} | `"instance"` or `"unique"`. Defaults to `"instance"` |
|
|
33
|
+
*/
|
|
34
|
+
export const PluginCopyArgs = z.object({
|
|
35
|
+
componentIds: z.array(z.string()).min(1),
|
|
36
|
+
displacement: PVec3,
|
|
37
|
+
count: z.number().int().positive().optional(),
|
|
38
|
+
copyMode: PluginCopyMode.optional(),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export type PluginCopyArgs = z.infer<typeof PluginCopyArgs>
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Result of `snaptrude.tools.copy`.
|
|
45
|
+
*
|
|
46
|
+
* Returned IDs are Snaptrude component IDs for the newly created copies, not
|
|
47
|
+
* Babylon mesh IDs.
|
|
48
|
+
*/
|
|
49
|
+
export const PluginCopyResult = z.object({
|
|
50
|
+
copiedIds: z.array(z.string()),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
export type PluginCopyResult = {
|
|
54
|
+
copiedIds: ComponentId[]
|
|
55
|
+
}
|
package/src/api/tools/index.ts
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { PluginMaterialApi } from "./material"
|
|
2
1
|
import { PluginSelectionApi } from "./selection"
|
|
3
2
|
import { PluginTransformApi } from "./transform"
|
|
3
|
+
import type { PluginApiReturn } from "../../types"
|
|
4
|
+
import type { PluginCopyArgs, PluginCopyResult } from "./copy"
|
|
5
|
+
import type { PluginOffsetArgs, PluginOffsetResult } from "./offset"
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Snaptrude editor tools for querying and manipulating scene components.
|
|
7
9
|
*
|
|
8
10
|
* - {@linkcode PluginToolsApi.selection} — Query the current user selection
|
|
9
11
|
* - {@linkcode PluginToolsApi.transform} — Move and rotate components
|
|
12
|
+
* - {@linkcode PluginToolsApi.copy} — Copy components
|
|
13
|
+
* - {@linkcode PluginToolsApi.offset} — Offset or split component profiles
|
|
10
14
|
*/
|
|
11
15
|
export abstract class PluginToolsApi {
|
|
12
16
|
/** Query the current selection. See {@linkcode PluginSelectionApi}. */
|
|
13
17
|
public abstract selection: PluginSelectionApi
|
|
14
18
|
/** Move and rotate components. See {@linkcode PluginTransformApi}. */
|
|
15
19
|
public abstract transform: PluginTransformApi
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
|
|
21
|
+
/** Copy components by ID. See {@linkcode PluginCopyArgs}. */
|
|
22
|
+
public abstract copy(args: PluginCopyArgs): PluginApiReturn<PluginCopyResult>
|
|
23
|
+
|
|
24
|
+
/** Offset or split a component profile. See {@linkcode PluginOffsetArgs}. */
|
|
25
|
+
public abstract offset(
|
|
26
|
+
args: PluginOffsetArgs,
|
|
27
|
+
): PluginApiReturn<PluginOffsetResult>
|
|
18
28
|
|
|
19
29
|
constructor() {}
|
|
20
30
|
}
|
|
21
31
|
|
|
32
|
+
export * from "./copy"
|
|
33
|
+
export * from "./offset"
|
|
22
34
|
export * from "./selection"
|
|
23
35
|
export * from "./transform"
|
|
24
|
-
export * from "./material"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import type { ComponentId } from "../../types"
|
|
3
|
+
import { PVec3 } from "../core/math/vec3"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Arguments for `snaptrude.tools.offset`.
|
|
7
|
+
*
|
|
8
|
+
* Runs Snaptrude's offset/split operation on the top profile of a scene
|
|
9
|
+
* component. A positive distance offsets outward from the selected profile;
|
|
10
|
+
* a negative distance offsets inward. If `profilePickPoint` is omitted, the
|
|
11
|
+
* outer top profile is used. If `profilePickPoint` is provided, the nearest top
|
|
12
|
+
* contour profile to that point is used, matching the interactive offset tool's
|
|
13
|
+
* pick behavior.
|
|
14
|
+
*
|
|
15
|
+
* | Property | Type | Description |
|
|
16
|
+
* |---|---|---|
|
|
17
|
+
* | `componentId` | `string` | Component ID to offset |
|
|
18
|
+
* | `distance` | `number` | Signed offset distance in Snaptrude units |
|
|
19
|
+
* | `profilePickPoint` | {@linkcode PVec3} | Optional point used to choose a top contour profile |
|
|
20
|
+
*/
|
|
21
|
+
export const PluginOffsetArgs = z.object({
|
|
22
|
+
componentId: z.string().min(1),
|
|
23
|
+
distance: z.number(),
|
|
24
|
+
profilePickPoint: PVec3.optional(),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export type PluginOffsetArgs = z.infer<typeof PluginOffsetArgs>
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Result of `snaptrude.tools.offset`.
|
|
31
|
+
*
|
|
32
|
+
* `createdIds` are the components created by the offset operation. `deletedIds`
|
|
33
|
+
* are components removed by split-style offsets.
|
|
34
|
+
*/
|
|
35
|
+
export const PluginOffsetResult = z.object({
|
|
36
|
+
createdIds: z.array(z.string()),
|
|
37
|
+
deletedIds: z.array(z.string()),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export type PluginOffsetResult = {
|
|
41
|
+
createdIds: ComponentId[]
|
|
42
|
+
deletedIds: ComponentId[]
|
|
43
|
+
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
import { PluginApiReturn } from "../../types";
|
|
3
|
-
/**
|
|
4
|
-
* Apply materials to the current user selection in the Snaptrude editor or passed component ids if any.
|
|
5
|
-
*
|
|
6
|
-
* Accessed via `snaptrude.tools.material`.
|
|
7
|
-
*/
|
|
8
|
-
export declare abstract class PluginMaterialApi {
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
* Apply materials to the current user selection in the Snaptrude editor or passed component ids if any.
|
|
12
|
-
*
|
|
13
|
-
* @param args - An object containing:
|
|
14
|
-
* - {@linkcode PluginMaterialArgs.materialName args.materialName} — Material to apply
|
|
15
|
-
* - {@linkcode PluginMaterialArgs.componentIds args.componentIds} — Array of component
|
|
16
|
-
* ID strings to apply materials to if provided, if not provided, the current user selection will be used
|
|
17
|
-
*/
|
|
18
|
-
abstract apply({ materialName, componentIds, }: PluginMaterialArgs): PluginApiReturn<void>;
|
|
19
|
-
}
|
|
20
|
-
declare enum DEFAULT_MATERIALS {
|
|
21
|
-
GLASS = "glass",
|
|
22
|
-
WOOD = "wood",
|
|
23
|
-
METAL = "metal",
|
|
24
|
-
STONE = "stone",
|
|
25
|
-
TILES = "tiles",
|
|
26
|
-
CONCRETE = "concrete",
|
|
27
|
-
BRICK = "brick"
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Arguments for {@linkcode PluginMaterialApi.apply}.
|
|
31
|
-
*
|
|
32
|
-
* | Property | Type | Description |
|
|
33
|
-
* |---|---|---|
|
|
34
|
-
* | `materialName` | `DEFAULT_MATERIALS` | Material to apply |
|
|
35
|
-
* | `componentIds` | `string[]` | Component IDs to apply materials to if provided |
|
|
36
|
-
*/
|
|
37
|
-
export declare const PluginMaterialArgs: z.ZodObject<{
|
|
38
|
-
materialName: z.ZodEnum<{
|
|
39
|
-
glass: DEFAULT_MATERIALS.GLASS;
|
|
40
|
-
wood: DEFAULT_MATERIALS.WOOD;
|
|
41
|
-
metal: DEFAULT_MATERIALS.METAL;
|
|
42
|
-
stone: DEFAULT_MATERIALS.STONE;
|
|
43
|
-
tiles: DEFAULT_MATERIALS.TILES;
|
|
44
|
-
concrete: DEFAULT_MATERIALS.CONCRETE;
|
|
45
|
-
brick: DEFAULT_MATERIALS.BRICK;
|
|
46
|
-
}>;
|
|
47
|
-
componentIds: z.ZodArray<z.ZodString>;
|
|
48
|
-
}, z.core.$strip>;
|
|
49
|
-
export type PluginMaterialArgs = z.infer<typeof PluginMaterialArgs>;
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=material.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../../src/api/tools/material.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;GAIG;AACH,8BAAsB,iBAAiB;;IAGrC;;;;;;;OAOG;aACa,KAAK,CAAC,EACpB,YAAY,EACZ,YAAY,GACb,EAAE,kBAAkB,GAAG,eAAe,CAAC,IAAI,CAAC;CAC9C;AAED,aAAK,iBAAiB;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;iBAG7B,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as z from "zod"
|
|
2
|
-
import { PluginApiReturn } from "../../types"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Apply materials to the current user selection in the Snaptrude editor or passed component ids if any.
|
|
6
|
-
*
|
|
7
|
-
* Accessed via `snaptrude.tools.material`.
|
|
8
|
-
*/
|
|
9
|
-
export abstract class PluginMaterialApi {
|
|
10
|
-
constructor() {}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Apply materials to the current user selection in the Snaptrude editor or passed component ids if any.
|
|
14
|
-
*
|
|
15
|
-
* @param args - An object containing:
|
|
16
|
-
* - {@linkcode PluginMaterialArgs.materialName args.materialName} — Material to apply
|
|
17
|
-
* - {@linkcode PluginMaterialArgs.componentIds args.componentIds} — Array of component
|
|
18
|
-
* ID strings to apply materials to if provided, if not provided, the current user selection will be used
|
|
19
|
-
*/
|
|
20
|
-
public abstract apply({
|
|
21
|
-
materialName,
|
|
22
|
-
componentIds,
|
|
23
|
-
}: PluginMaterialArgs): PluginApiReturn<void>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
enum DEFAULT_MATERIALS {
|
|
27
|
-
GLASS = 'glass',
|
|
28
|
-
WOOD = 'wood',
|
|
29
|
-
METAL = 'metal',
|
|
30
|
-
STONE = 'stone',
|
|
31
|
-
TILES = 'tiles',
|
|
32
|
-
CONCRETE = 'concrete',
|
|
33
|
-
BRICK = 'brick',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Arguments for {@linkcode PluginMaterialApi.apply}.
|
|
38
|
-
*
|
|
39
|
-
* | Property | Type | Description |
|
|
40
|
-
* |---|---|---|
|
|
41
|
-
* | `materialName` | `DEFAULT_MATERIALS` | Material to apply |
|
|
42
|
-
* | `componentIds` | `string[]` | Component IDs to apply materials to if provided |
|
|
43
|
-
*/
|
|
44
|
-
export const PluginMaterialArgs = z.object({
|
|
45
|
-
materialName: z.enum(Object.values(DEFAULT_MATERIALS)),
|
|
46
|
-
componentIds: z.array(z.string()),
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
export type PluginMaterialArgs = z.infer<typeof PluginMaterialArgs>
|