@snaptrude/plugin-core 0.1.1 → 0.1.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.
@@ -9,13 +9,13 @@ import { PluginUnitsApi } from "./units";
9
9
  *
10
10
  * - {@linkcode PluginApi.core} — Math and geometry primitives
11
11
  * - {@linkcode PluginApi.entity} — CRUD operations on Snaptrude entities (spaces, stories)
12
- * - {@linkcode PluginApi.tools} — Selection and transform tools
12
+ * - {@linkcode PluginApi.tools} — Selection, transform and material tools
13
13
  * - {@linkcode PluginApi.units} — Unit conversion utilities
14
14
  */
15
15
  export declare abstract class PluginApi {
16
16
  /** Core math and geometry primitives. See {@linkcode PluginCoreApi}. */
17
17
  abstract core: PluginCoreApi;
18
- /** Selection and transform tools. See {@linkcode PluginToolsApi}. */
18
+ /** Selection, transform and material tools. See {@linkcode PluginToolsApi}. */
19
19
  abstract tools: PluginToolsApi;
20
20
  /** CRUD operations on Snaptrude entities. See {@linkcode PluginEntityApi}. */
21
21
  abstract entity: PluginEntityApi;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;GASG;AACH,8BAAsB,SAAS;IAC7B,wEAAwE;IACxE,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,qEAAqE;IACrE,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,8EAA8E;IAC9E,SAAgB,MAAM,EAAE,eAAe,CAAA;IACvC,iEAAiE;IACjE,SAAgB,KAAK,EAAE,cAAc,CAAA;;CAGtC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;GASG;AACH,8BAAsB,SAAS;IAC7B,wEAAwE;IACxE,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,+EAA+E;IAC/E,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,8EAA8E;IAC9E,SAAgB,MAAM,EAAE,eAAe,CAAA;IACvC,iEAAiE;IACjE,SAAgB,KAAK,EAAE,cAAc,CAAA;;CAGtC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { PluginMaterialApi } from "./material";
1
2
  import { PluginSelectionApi } from "./selection";
2
3
  import { PluginTransformApi } from "./transform";
3
4
  /**
@@ -11,8 +12,11 @@ export declare abstract class PluginToolsApi {
11
12
  abstract selection: PluginSelectionApi;
12
13
  /** Move and rotate components. See {@linkcode PluginTransformApi}. */
13
14
  abstract transform: PluginTransformApi;
15
+ /** Apply materials to the current user selection in the Snaptrude editor or passed component ids if any. See {@linkcode PluginMaterialApi}. */
16
+ abstract material: PluginMaterialApi;
14
17
  constructor();
15
18
  }
16
19
  export * from "./selection";
17
20
  export * from "./transform";
21
+ export * from "./material";
18
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;GAKG;AACH,8BAAsB,cAAc;IAClC,uEAAuE;IACvE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,sEAAsE;IACtE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;;CAG9C;AAED,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD;;;;;GAKG;AACH,8BAAsB,cAAc;IAClC,uEAAuE;IACvE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,sEAAsE;IACtE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,+IAA+I;IAC/I,SAAgB,QAAQ,EAAE,iBAAiB,CAAA;;CAG5C;AAED,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,51 @@
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
@@ -0,0 +1 @@
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"}
package/dist/index.cjs CHANGED
@@ -51,6 +51,8 @@ __export(index_exports, {
51
51
  PluginGeomApi: () => PluginGeomApi,
52
52
  PluginLineApi: () => PluginLineApi,
53
53
  PluginMassType: () => PluginMassType,
54
+ PluginMaterialApi: () => PluginMaterialApi,
55
+ PluginMaterialArgs: () => PluginMaterialArgs,
54
56
  PluginMathApi: () => PluginMathApi,
55
57
  PluginMoveArgs: () => PluginMoveArgs,
56
58
  PluginProfileApi: () => PluginProfileApi,
@@ -120,8 +122,8 @@ var PluginVec3Api = class {
120
122
  * // { x: 1, y: 2, z: 3 }
121
123
  * ```
122
124
  */
123
- new(x, y, z14) {
124
- return { x, y, z: z14 };
125
+ new(x, y, z15) {
126
+ return { x, y, z: z15 };
125
127
  }
126
128
  /**
127
129
  * Add two vectors component-wise.
@@ -299,8 +301,8 @@ var PluginQuatApi = class {
299
301
  * @param w - The W (scalar) component
300
302
  * @returns A new {@linkcode PQuat}
301
303
  */
302
- new(x, y, z14, w) {
303
- return { x, y, z: z14, w };
304
+ new(x, y, z15, w) {
305
+ return { x, y, z: z15, w };
304
306
  }
305
307
  /**
306
308
  * Create an identity quaternion representing no rotation.
@@ -344,13 +346,13 @@ var PluginQuatApi = class {
344
346
  * @param z - Rotation around Z axis in **radians**
345
347
  * @returns A new {@linkcode PQuat}
346
348
  */
347
- fromEuler(x, y, z14) {
349
+ fromEuler(x, y, z15) {
348
350
  const cx = Math.cos(x / 2);
349
351
  const sx = Math.sin(x / 2);
350
352
  const cy = Math.cos(y / 2);
351
353
  const sy = Math.sin(y / 2);
352
- const cz = Math.cos(z14 / 2);
353
- const sz = Math.sin(z14 / 2);
354
+ const cz = Math.cos(z15 / 2);
355
+ const sz = Math.sin(z15 / 2);
354
356
  return {
355
357
  x: sx * cy * cz + cx * sy * sz,
356
358
  y: cx * sy * cz - sx * cy * sz,
@@ -959,6 +961,27 @@ var PluginRotateArgs = z12.object({
959
961
  pivot: PVec3
960
962
  });
961
963
 
964
+ // src/api/tools/material.ts
965
+ var z13 = __toESM(require("zod"), 1);
966
+ var PluginMaterialApi = class {
967
+ constructor() {
968
+ }
969
+ };
970
+ var DEFAULT_MATERIALS = /* @__PURE__ */ ((DEFAULT_MATERIALS2) => {
971
+ DEFAULT_MATERIALS2["GLASS"] = "glass";
972
+ DEFAULT_MATERIALS2["WOOD"] = "wood";
973
+ DEFAULT_MATERIALS2["METAL"] = "metal";
974
+ DEFAULT_MATERIALS2["STONE"] = "stone";
975
+ DEFAULT_MATERIALS2["TILES"] = "tiles";
976
+ DEFAULT_MATERIALS2["CONCRETE"] = "concrete";
977
+ DEFAULT_MATERIALS2["BRICK"] = "brick";
978
+ return DEFAULT_MATERIALS2;
979
+ })(DEFAULT_MATERIALS || {});
980
+ var PluginMaterialArgs = z13.object({
981
+ materialName: z13.enum(Object.values(DEFAULT_MATERIALS)),
982
+ componentIds: z13.array(z13.string())
983
+ });
984
+
962
985
  // src/api/tools/index.ts
963
986
  var PluginToolsApi = class {
964
987
  constructor() {
@@ -966,12 +989,12 @@ var PluginToolsApi = class {
966
989
  };
967
990
 
968
991
  // src/api/units/index.ts
969
- var z13 = __toESM(require("zod"), 1);
992
+ var z14 = __toESM(require("zod"), 1);
970
993
  var PluginUnitsApi = class {
971
994
  constructor() {
972
995
  }
973
996
  };
974
- var PUnitType = z13.enum([
997
+ var PUnitType = z14.enum([
975
998
  "meters",
976
999
  "feet-inches",
977
1000
  "inches",
@@ -980,21 +1003,21 @@ var PUnitType = z13.enum([
980
1003
  "kilometers",
981
1004
  "miles"
982
1005
  ]);
983
- var PluginUnitsConvertFromArgs = z13.object({
1006
+ var PluginUnitsConvertFromArgs = z14.object({
984
1007
  unit: PUnitType,
985
- value: z13.number(),
986
- degree: z13.number().int().min(1).max(3).optional()
1008
+ value: z14.number(),
1009
+ degree: z14.number().int().min(1).max(3).optional()
987
1010
  });
988
- var PluginUnitsConvertFromResult = z13.object({
989
- value: z13.number()
1011
+ var PluginUnitsConvertFromResult = z14.object({
1012
+ value: z14.number()
990
1013
  });
991
- var PluginUnitsConvertToArgs = z13.object({
1014
+ var PluginUnitsConvertToArgs = z14.object({
992
1015
  unit: PUnitType,
993
- value: z13.number(),
994
- degree: z13.number().int().min(1).max(3).optional()
1016
+ value: z14.number(),
1017
+ degree: z14.number().int().min(1).max(3).optional()
995
1018
  });
996
- var PluginUnitsConvertToResult = z13.object({
997
- value: z13.number()
1019
+ var PluginUnitsConvertToResult = z14.object({
1020
+ value: z14.number()
998
1021
  });
999
1022
 
1000
1023
  // src/api/index.ts
@@ -1025,6 +1048,8 @@ var PluginApi = class {
1025
1048
  PluginGeomApi,
1026
1049
  PluginLineApi,
1027
1050
  PluginMassType,
1051
+ PluginMaterialApi,
1052
+ PluginMaterialArgs,
1028
1053
  PluginMathApi,
1029
1054
  PluginMoveArgs,
1030
1055
  PluginProfileApi,