@snaptrude/plugin-core 0.1.1 → 0.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @snaptrude/plugin-core
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4d959a4: Exposed new offset and copy APIs for tools
@@ -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} — Copy, offset, selection, and transform 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
+ /** Copy, offset, selection, and transform 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,oFAAoF;IACpF,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"}
@@ -0,0 +1,59 @@
1
+ import * as z from "zod";
2
+ import type { ComponentId } from "../../types";
3
+ /**
4
+ * Copy mode for `snaptrude.tools.copy`.
5
+ *
6
+ * | Value | Description |
7
+ * |---|---|
8
+ * | `"instance"` | Create instanced copies where possible |
9
+ * | `"unique"` | Create independent geometry copies |
10
+ */
11
+ export declare const PluginCopyMode: z.ZodEnum<{
12
+ instance: "instance";
13
+ unique: "unique";
14
+ }>;
15
+ export type PluginCopyMode = z.infer<typeof PluginCopyMode>;
16
+ /**
17
+ * Arguments for `snaptrude.tools.copy`.
18
+ *
19
+ * Creates one or more copies for each component in `componentIds`. Copy `i` is
20
+ * offset by `displacement * i`, where `i` starts at `1`. Source positions are
21
+ * preserved. In `"instance"` mode, a unique source mesh can be replaced by an
22
+ * instance at the same position so the source and copied objects remain in the
23
+ * same instance family. The created copy stack becomes the active editor
24
+ * selection, matching the native paste workflow.
25
+ *
26
+ * | Property | Type | Description |
27
+ * |---|---|---|
28
+ * | `componentIds` | `string[]` | Component IDs to copy |
29
+ * | `displacement` | {@linkcode PVec3} | Offset applied to each copy in Babylon units |
30
+ * | `count` | `number` | Number of copies per component. Defaults to `1` |
31
+ * | `copyMode` | {@linkcode PluginCopyMode} | `"instance"` or `"unique"`. Defaults to `"instance"` |
32
+ */
33
+ export declare const PluginCopyArgs: z.ZodObject<{
34
+ componentIds: z.ZodArray<z.ZodString>;
35
+ displacement: z.ZodObject<{
36
+ x: z.ZodNumber;
37
+ y: z.ZodNumber;
38
+ z: z.ZodNumber;
39
+ }, z.core.$strip>;
40
+ count: z.ZodOptional<z.ZodNumber>;
41
+ copyMode: z.ZodOptional<z.ZodEnum<{
42
+ instance: "instance";
43
+ unique: "unique";
44
+ }>>;
45
+ }, z.core.$strip>;
46
+ export type PluginCopyArgs = z.infer<typeof PluginCopyArgs>;
47
+ /**
48
+ * Result of `snaptrude.tools.copy`.
49
+ *
50
+ * Returned IDs are Snaptrude component IDs for the newly created copies, not
51
+ * Babylon mesh IDs.
52
+ */
53
+ export declare const PluginCopyResult: z.ZodObject<{
54
+ copiedIds: z.ZodArray<z.ZodString>;
55
+ }, z.core.$strip>;
56
+ export type PluginCopyResult = {
57
+ copiedIds: ComponentId[];
58
+ };
59
+ //# sourceMappingURL=copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../src/api/tools/copy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;EAAiC,CAAA;AAE5D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;iBAKzB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA;AAE3D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;iBAE3B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,WAAW,EAAE,CAAA;CACzB,CAAA"}
@@ -1,18 +1,29 @@
1
1
  import { PluginSelectionApi } from "./selection";
2
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";
3
6
  /**
4
7
  * Snaptrude editor tools for querying and manipulating scene components.
5
8
  *
6
9
  * - {@linkcode PluginToolsApi.selection} — Query the current user selection
7
10
  * - {@linkcode PluginToolsApi.transform} — Move and rotate components
11
+ * - {@linkcode PluginToolsApi.copy} — Copy components
12
+ * - {@linkcode PluginToolsApi.offset} — Offset or split component profiles
8
13
  */
9
14
  export declare abstract class PluginToolsApi {
10
15
  /** Query the current selection. See {@linkcode PluginSelectionApi}. */
11
16
  abstract selection: PluginSelectionApi;
12
17
  /** Move and rotate components. See {@linkcode PluginTransformApi}. */
13
18
  abstract transform: PluginTransformApi;
19
+ /** Copy components by ID. See {@linkcode PluginCopyArgs}. */
20
+ abstract copy(args: PluginCopyArgs): PluginApiReturn<PluginCopyResult>;
21
+ /** Offset or split a component profile. See {@linkcode PluginOffsetArgs}. */
22
+ abstract offset(args: PluginOffsetArgs): PluginApiReturn<PluginOffsetResult>;
14
23
  constructor();
15
24
  }
25
+ export * from "./copy";
26
+ export * from "./offset";
16
27
  export * from "./selection";
17
28
  export * from "./transform";
18
29
  //# 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,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEpE;;;;;;;GAOG;AACH,8BAAsB,cAAc;IAClC,uEAAuE;IACvE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,sEAAsE;IACtE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAE7C,6DAA6D;aAC7C,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAAC,gBAAgB,CAAC;IAE7E,6EAA6E;aAC7D,MAAM,CACpB,IAAI,EAAE,gBAAgB,GACrB,eAAe,CAAC,kBAAkB,CAAC;;CAGvC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
@@ -0,0 +1,43 @@
1
+ import * as z from "zod";
2
+ import type { ComponentId } from "../../types";
3
+ /**
4
+ * Arguments for `snaptrude.tools.offset`.
5
+ *
6
+ * Runs Snaptrude's offset/split operation on the top profile of a scene
7
+ * component. A positive distance offsets outward from the selected profile;
8
+ * a negative distance offsets inward. If `profilePickPoint` is omitted, the
9
+ * outer top profile is used. If `profilePickPoint` is provided, the nearest top
10
+ * contour profile to that point is used, matching the interactive offset tool's
11
+ * pick behavior.
12
+ *
13
+ * | Property | Type | Description |
14
+ * |---|---|---|
15
+ * | `componentId` | `string` | Component ID to offset |
16
+ * | `distance` | `number` | Signed offset distance in Snaptrude units |
17
+ * | `profilePickPoint` | {@linkcode PVec3} | Optional point used to choose a top contour profile |
18
+ */
19
+ export declare const PluginOffsetArgs: z.ZodObject<{
20
+ componentId: z.ZodString;
21
+ distance: z.ZodNumber;
22
+ profilePickPoint: z.ZodOptional<z.ZodObject<{
23
+ x: z.ZodNumber;
24
+ y: z.ZodNumber;
25
+ z: z.ZodNumber;
26
+ }, z.core.$strip>>;
27
+ }, z.core.$strip>;
28
+ export type PluginOffsetArgs = z.infer<typeof PluginOffsetArgs>;
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 declare const PluginOffsetResult: z.ZodObject<{
36
+ createdIds: z.ZodArray<z.ZodString>;
37
+ deletedIds: z.ZodArray<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export type PluginOffsetResult = {
40
+ createdIds: ComponentId[];
41
+ deletedIds: ComponentId[];
42
+ };
43
+ //# sourceMappingURL=offset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"offset.d.ts","sourceRoot":"","sources":["../../../src/api/tools/offset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAG9C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;iBAI3B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,UAAU,EAAE,WAAW,EAAE,CAAA;CAC1B,CAAA"}
package/dist/index.cjs CHANGED
@@ -39,6 +39,9 @@ __export(index_exports, {
39
39
  PVec3: () => PVec3,
40
40
  PluginApi: () => PluginApi,
41
41
  PluginArcApi: () => PluginArcApi,
42
+ PluginCopyArgs: () => PluginCopyArgs,
43
+ PluginCopyMode: () => PluginCopyMode,
44
+ PluginCopyResult: () => PluginCopyResult,
42
45
  PluginCoreApi: () => PluginCoreApi,
43
46
  PluginCurveApi: () => PluginCurveApi,
44
47
  PluginDepartmentApi: () => PluginDepartmentApi,
@@ -53,6 +56,8 @@ __export(index_exports, {
53
56
  PluginMassType: () => PluginMassType,
54
57
  PluginMathApi: () => PluginMathApi,
55
58
  PluginMoveArgs: () => PluginMoveArgs,
59
+ PluginOffsetArgs: () => PluginOffsetArgs,
60
+ PluginOffsetResult: () => PluginOffsetResult,
56
61
  PluginProfileApi: () => PluginProfileApi,
57
62
  PluginProfileFromLinePointsArgs: () => PluginProfileFromLinePointsArgs,
58
63
  PluginQuatApi: () => PluginQuatApi,
@@ -120,8 +125,8 @@ var PluginVec3Api = class {
120
125
  * // { x: 1, y: 2, z: 3 }
121
126
  * ```
122
127
  */
123
- new(x, y, z14) {
124
- return { x, y, z: z14 };
128
+ new(x, y, z16) {
129
+ return { x, y, z: z16 };
125
130
  }
126
131
  /**
127
132
  * Add two vectors component-wise.
@@ -299,8 +304,8 @@ var PluginQuatApi = class {
299
304
  * @param w - The W (scalar) component
300
305
  * @returns A new {@linkcode PQuat}
301
306
  */
302
- new(x, y, z14, w) {
303
- return { x, y, z: z14, w };
307
+ new(x, y, z16, w) {
308
+ return { x, y, z: z16, w };
304
309
  }
305
310
  /**
306
311
  * Create an identity quaternion representing no rotation.
@@ -344,13 +349,13 @@ var PluginQuatApi = class {
344
349
  * @param z - Rotation around Z axis in **radians**
345
350
  * @returns A new {@linkcode PQuat}
346
351
  */
347
- fromEuler(x, y, z14) {
352
+ fromEuler(x, y, z16) {
348
353
  const cx = Math.cos(x / 2);
349
354
  const sx = Math.sin(x / 2);
350
355
  const cy = Math.cos(y / 2);
351
356
  const sy = Math.sin(y / 2);
352
- const cz = Math.cos(z14 / 2);
353
- const sz = Math.sin(z14 / 2);
357
+ const cz = Math.cos(z16 / 2);
358
+ const sz = Math.sin(z16 / 2);
354
359
  return {
355
360
  x: sx * cy * cz + cx * sy * sz,
356
361
  y: cx * sy * cz - sx * cy * sz,
@@ -932,29 +937,54 @@ var PluginEntityApi = class {
932
937
  }
933
938
  };
934
939
 
935
- // src/api/tools/selection.ts
940
+ // src/api/tools/copy.ts
936
941
  var z11 = __toESM(require("zod"), 1);
942
+ var PluginCopyMode = z11.enum(["instance", "unique"]);
943
+ var PluginCopyArgs = z11.object({
944
+ componentIds: z11.array(z11.string()).min(1),
945
+ displacement: PVec3,
946
+ count: z11.number().int().positive().optional(),
947
+ copyMode: PluginCopyMode.optional()
948
+ });
949
+ var PluginCopyResult = z11.object({
950
+ copiedIds: z11.array(z11.string())
951
+ });
952
+
953
+ // src/api/tools/offset.ts
954
+ var z12 = __toESM(require("zod"), 1);
955
+ var PluginOffsetArgs = z12.object({
956
+ componentId: z12.string().min(1),
957
+ distance: z12.number(),
958
+ profilePickPoint: PVec3.optional()
959
+ });
960
+ var PluginOffsetResult = z12.object({
961
+ createdIds: z12.array(z12.string()),
962
+ deletedIds: z12.array(z12.string())
963
+ });
964
+
965
+ // src/api/tools/selection.ts
966
+ var z13 = __toESM(require("zod"), 1);
937
967
  var PluginSelectionApi = class {
938
968
  constructor() {
939
969
  }
940
970
  };
941
- var PluginSelectionGetResult = z11.object({
942
- selected: z11.array(z11.string())
971
+ var PluginSelectionGetResult = z13.object({
972
+ selected: z13.array(z13.string())
943
973
  });
944
974
 
945
975
  // src/api/tools/transform.ts
946
- var z12 = __toESM(require("zod"), 1);
976
+ var z14 = __toESM(require("zod"), 1);
947
977
  var PluginTransformApi = class {
948
978
  constructor() {
949
979
  }
950
980
  };
951
- var PluginMoveArgs = z12.object({
952
- componentIds: z12.array(z12.string()),
981
+ var PluginMoveArgs = z14.object({
982
+ componentIds: z14.array(z14.string()),
953
983
  displacement: PVec3
954
984
  });
955
- var PluginRotateArgs = z12.object({
956
- componentIds: z12.array(z12.string()),
957
- angle: z12.number(),
985
+ var PluginRotateArgs = z14.object({
986
+ componentIds: z14.array(z14.string()),
987
+ angle: z14.number(),
958
988
  axis: PVec3,
959
989
  pivot: PVec3
960
990
  });
@@ -966,12 +996,12 @@ var PluginToolsApi = class {
966
996
  };
967
997
 
968
998
  // src/api/units/index.ts
969
- var z13 = __toESM(require("zod"), 1);
999
+ var z15 = __toESM(require("zod"), 1);
970
1000
  var PluginUnitsApi = class {
971
1001
  constructor() {
972
1002
  }
973
1003
  };
974
- var PUnitType = z13.enum([
1004
+ var PUnitType = z15.enum([
975
1005
  "meters",
976
1006
  "feet-inches",
977
1007
  "inches",
@@ -980,21 +1010,21 @@ var PUnitType = z13.enum([
980
1010
  "kilometers",
981
1011
  "miles"
982
1012
  ]);
983
- var PluginUnitsConvertFromArgs = z13.object({
1013
+ var PluginUnitsConvertFromArgs = z15.object({
984
1014
  unit: PUnitType,
985
- value: z13.number(),
986
- degree: z13.number().int().min(1).max(3).optional()
1015
+ value: z15.number(),
1016
+ degree: z15.number().int().min(1).max(3).optional()
987
1017
  });
988
- var PluginUnitsConvertFromResult = z13.object({
989
- value: z13.number()
1018
+ var PluginUnitsConvertFromResult = z15.object({
1019
+ value: z15.number()
990
1020
  });
991
- var PluginUnitsConvertToArgs = z13.object({
1021
+ var PluginUnitsConvertToArgs = z15.object({
992
1022
  unit: PUnitType,
993
- value: z13.number(),
994
- degree: z13.number().int().min(1).max(3).optional()
1023
+ value: z15.number(),
1024
+ degree: z15.number().int().min(1).max(3).optional()
995
1025
  });
996
- var PluginUnitsConvertToResult = z13.object({
997
- value: z13.number()
1026
+ var PluginUnitsConvertToResult = z15.object({
1027
+ value: z15.number()
998
1028
  });
999
1029
 
1000
1030
  // src/api/index.ts
@@ -1013,6 +1043,9 @@ var PluginApi = class {
1013
1043
  PVec3,
1014
1044
  PluginApi,
1015
1045
  PluginArcApi,
1046
+ PluginCopyArgs,
1047
+ PluginCopyMode,
1048
+ PluginCopyResult,
1016
1049
  PluginCoreApi,
1017
1050
  PluginCurveApi,
1018
1051
  PluginDepartmentApi,
@@ -1027,6 +1060,8 @@ var PluginApi = class {
1027
1060
  PluginMassType,
1028
1061
  PluginMathApi,
1029
1062
  PluginMoveArgs,
1063
+ PluginOffsetArgs,
1064
+ PluginOffsetResult,
1030
1065
  PluginProfileApi,
1031
1066
  PluginProfileFromLinePointsArgs,
1032
1067
  PluginQuatApi,