@snaptrude/plugin-core 0.0.4 → 0.0.6

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 (59) hide show
  1. package/dist/api/core/geom/arc.d.ts +50 -1
  2. package/dist/api/core/geom/arc.d.ts.map +1 -1
  3. package/dist/api/core/geom/curve.d.ts +26 -1
  4. package/dist/api/core/geom/curve.d.ts.map +1 -1
  5. package/dist/api/core/geom/index.d.ts +16 -0
  6. package/dist/api/core/geom/index.d.ts.map +1 -1
  7. package/dist/api/core/geom/line.d.ts +35 -1
  8. package/dist/api/core/geom/line.d.ts.map +1 -1
  9. package/dist/api/core/geom/profile.d.ts +66 -2
  10. package/dist/api/core/geom/profile.d.ts.map +1 -1
  11. package/dist/api/core/index.d.ts +8 -0
  12. package/dist/api/core/index.d.ts.map +1 -1
  13. package/dist/api/core/math/index.d.ts +8 -0
  14. package/dist/api/core/math/index.d.ts.map +1 -1
  15. package/dist/api/core/math/quat.d.ts +156 -15
  16. package/dist/api/core/math/quat.d.ts.map +1 -1
  17. package/dist/api/core/math/vec3.d.ts +131 -14
  18. package/dist/api/core/math/vec3.d.ts.map +1 -1
  19. package/dist/api/entity/index.d.ts +8 -0
  20. package/dist/api/entity/index.d.ts.map +1 -1
  21. package/dist/api/entity/space.d.ts +217 -4
  22. package/dist/api/entity/space.d.ts.map +1 -1
  23. package/dist/api/entity/story.d.ts +166 -0
  24. package/dist/api/entity/story.d.ts.map +1 -1
  25. package/dist/api/index.d.ts +14 -0
  26. package/dist/api/index.d.ts.map +1 -1
  27. package/dist/api/tools/index.d.ts +8 -0
  28. package/dist/api/tools/index.d.ts.map +1 -1
  29. package/dist/api/tools/selection.d.ts +37 -0
  30. package/dist/api/tools/selection.d.ts.map +1 -1
  31. package/dist/api/tools/transform.d.ts +82 -0
  32. package/dist/api/tools/transform.d.ts.map +1 -1
  33. package/dist/api/units/index.d.ts +72 -13
  34. package/dist/api/units/index.d.ts.map +1 -1
  35. package/dist/index.cjs +322 -36
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.js +321 -35
  38. package/dist/index.js.map +1 -1
  39. package/dist/types.d.ts +8 -1
  40. package/dist/types.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/api/core/geom/arc.ts +50 -1
  43. package/src/api/core/geom/curve.ts +26 -1
  44. package/src/api/core/geom/index.ts +16 -0
  45. package/src/api/core/geom/line.ts +35 -1
  46. package/src/api/core/geom/profile.ts +66 -2
  47. package/src/api/core/index.ts +8 -0
  48. package/src/api/core/math/index.ts +8 -0
  49. package/src/api/core/math/quat.ts +156 -15
  50. package/src/api/core/math/vec3.ts +131 -14
  51. package/src/api/entity/index.ts +8 -0
  52. package/src/api/entity/space.ts +218 -5
  53. package/src/api/entity/story.ts +166 -0
  54. package/src/api/index.ts +14 -0
  55. package/src/api/tools/index.ts +8 -0
  56. package/src/api/tools/selection.ts +37 -0
  57. package/src/api/tools/transform.ts +82 -0
  58. package/src/api/units/index.ts +72 -13
  59. package/src/types.ts +8 -1
@@ -1,10 +1,59 @@
1
1
  import * as z from "zod";
2
2
  import { PVec3 } from "../math/vec3";
3
+ /**
4
+ * Arc construction.
5
+ *
6
+ * A {@linkcode PArc} represents a circular arc in 3D space, defined by
7
+ * start/end points, a centre, and a rotation axis. Arcs can be wrapped
8
+ * as a {@linkcode PCurve} and combined into a {@linkcode PProfile}.
9
+ *
10
+ * Accessed via `snaptrude.core.geom.arc`.
11
+ */
3
12
  export declare abstract class PluginArcApi {
4
13
  constructor();
5
- /** Create a new PArc from start, end, centre and axis. */
14
+ /**
15
+ * Create a new arc from start, end, centre, and axis.
16
+ *
17
+ * The arc sweeps from {@linkcode startPoint} to {@linkcode endPoint}
18
+ * along the circle centred at {@linkcode centrePoint}, in the
19
+ * direction determined by the right-hand rule around {@linkcode axis}.
20
+ *
21
+ * @param startPoint - The start point as a {@linkcode PVec3}
22
+ * @param endPoint - The end point as a {@linkcode PVec3}
23
+ * @param centrePoint - The centre of the arc's circle as a {@linkcode PVec3}
24
+ * @param axis - The arc's rotation axis as a {@linkcode PVec3}
25
+ * (perpendicular to the arc's plane)
26
+ * @returns A new {@linkcode PArc}
27
+ *
28
+ * # Example
29
+ * ```ts
30
+ * const { vec3 } = snaptrude.core.math
31
+ * const { arc } = snaptrude.core.geom
32
+ *
33
+ * // Quarter-circle arc on the XZ plane
34
+ * const a = arc.new(
35
+ * vec3.new(1, 0, 0), // start
36
+ * vec3.new(0, 0, 1), // end
37
+ * vec3.new(0, 0, 0), // centre
38
+ * vec3.new(0, 1, 0), // Y-up axis
39
+ * )
40
+ * ```
41
+ */
6
42
  new(startPoint: PVec3, endPoint: PVec3, centrePoint: PVec3, axis: PVec3): PArc;
7
43
  }
44
+ /**
45
+ * A circular arc defined by start, end, centre, and axis.
46
+ *
47
+ * Discriminated by `curveType: "Arc"` within the {@linkcode PCurve} union.
48
+ *
49
+ * | Property | Type | Description |
50
+ * |---|---|---|
51
+ * | `curveType` | `"Arc"` | Discriminator tag |
52
+ * | `startPoint` | {@linkcode PVec3} | Start point of the arc |
53
+ * | `endPoint` | {@linkcode PVec3} | End point of the arc |
54
+ * | `centrePoint` | {@linkcode PVec3} | Centre of the arc's circle |
55
+ * | `axis` | {@linkcode PVec3} | Rotation axis (normal to the arc's plane) |
56
+ */
8
57
  export declare const PArc: z.ZodObject<{
9
58
  curveType: z.ZodLiteral<"Arc">;
10
59
  startPoint: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"arc.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/arc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC,8BAAsB,YAAY;;IAGhC,0DAA0D;IAC1D,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI;CAG/E;AAED,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;iBAMf,CAAA;AAEF,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA"}
1
+ {"version":3,"file":"arc.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/arc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC;;;;;;;;GAQG;AACH,8BAAsB,YAAY;;IAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,GAAG,IAAI;CAG/E;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;iBAMf,CAAA;AAEF,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAA"}
@@ -1,11 +1,36 @@
1
1
  import * as z from "zod";
2
2
  import { PLine } from "./line";
3
3
  import { PArc } from "./arc";
4
+ /**
5
+ * Unified curve wrapper — either a {@linkcode PLine} or a {@linkcode PArc}.
6
+ *
7
+ * Use this to build heterogeneous curve lists (mixing lines and arcs)
8
+ * when constructing a {@linkcode PProfile}.
9
+ *
10
+ * Accessed via `snaptrude.core.geom.curve`.
11
+ */
4
12
  export declare abstract class PluginCurveApi {
5
13
  constructor();
6
- /** Create a PCurve from a PLine or PArc. */
14
+ /**
15
+ * Wrap a {@linkcode PLine} or {@linkcode PArc} as a {@linkcode PCurve}.
16
+ *
17
+ * This is an identity operation — it simply returns the input unchanged.
18
+ * It exists for type-level clarity when building mixed curve lists.
19
+ *
20
+ * @param curve - A {@linkcode PLine} or {@linkcode PArc} to wrap
21
+ * @returns The same value typed as {@linkcode PCurve}
22
+ */
7
23
  new(curve: PLine | PArc): PCurve;
8
24
  }
25
+ /**
26
+ * A discriminated union of {@linkcode PLine} and {@linkcode PArc}.
27
+ *
28
+ * Discriminated on the `curveType` field:
29
+ * - `"Line"` → {@linkcode PLine}
30
+ * - `"Arc"` → {@linkcode PArc}
31
+ *
32
+ * Use `curve.curveType` to narrow the type in a switch or if-statement.
33
+ */
9
34
  export declare const PCurve: z.ZodDiscriminatedUnion<[z.ZodObject<{
10
35
  curveType: z.ZodLiteral<"Line">;
11
36
  startPoint: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/curve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAE5B,8BAAsB,cAAc;;IAGlC,4CAA4C;IAC5C,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM;CAGjC;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAmD,CAAA;AAEtE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA"}
1
+ {"version":3,"file":"curve.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/curve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAE5B;;;;;;;GAOG;AACH,8BAAsB,cAAc;;IAGlC;;;;;;;;OAQG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM;CAGjC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAmD,CAAA;AAEtE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAA"}
@@ -2,10 +2,26 @@ import { PluginLineApi } from "./line";
2
2
  import { PluginArcApi } from "./arc";
3
3
  import { PluginCurveApi } from "./curve";
4
4
  import { PluginProfileApi } from "./profile";
5
+ /**
6
+ * Geometry primitives for constructing 2D/3D shapes.
7
+ *
8
+ * Build geometry bottom-up: points ({@linkcode PVec3}) → lines/arcs → curves → profiles.
9
+ * Profiles can then be used with entity creation methods like
10
+ * {@linkcode PluginSpaceApi.createFromProfile}.
11
+ *
12
+ * - {@linkcode PluginGeomApi.line} — Line segment construction
13
+ * - {@linkcode PluginGeomApi.arc} — Arc construction
14
+ * - {@linkcode PluginGeomApi.curve} — Unified curve wrapper (line or arc)
15
+ * - {@linkcode PluginGeomApi.profile} — Closed loop of curves
16
+ */
5
17
  export declare abstract class PluginGeomApi {
18
+ /** Line segment construction. See {@linkcode PluginLineApi}. */
6
19
  abstract line: PluginLineApi;
20
+ /** Arc construction. See {@linkcode PluginArcApi}. */
7
21
  abstract arc: PluginArcApi;
22
+ /** Unified curve wrapper. See {@linkcode PluginCurveApi}. */
8
23
  abstract curve: PluginCurveApi;
24
+ /** Closed profile (loop of curves). See {@linkcode PluginProfileApi}. */
9
25
  abstract profile: PluginProfileApi;
10
26
  constructor();
11
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,8BAAsB,aAAa;IACjC,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,SAAgB,GAAG,EAAE,YAAY,CAAA;IACjC,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,SAAgB,OAAO,EAAE,gBAAgB,CAAA;;CAG1C;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C;;;;;;;;;;;GAWG;AACH,8BAAsB,aAAa;IACjC,gEAAgE;IAChE,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,sDAAsD;IACtD,SAAgB,GAAG,EAAE,YAAY,CAAA;IACjC,6DAA6D;IAC7D,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,yEAAyE;IACzE,SAAgB,OAAO,EAAE,gBAAgB,CAAA;;CAG1C;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
@@ -1,10 +1,44 @@
1
1
  import * as z from "zod";
2
2
  import { PVec3 } from "../math/vec3";
3
+ /**
4
+ * Line segment construction.
5
+ *
6
+ * A {@linkcode PLine} is the simplest curve primitive — a straight
7
+ * segment between two 3D points. Lines can be wrapped as a
8
+ * {@linkcode PCurve} and combined into a {@linkcode PProfile}.
9
+ *
10
+ * Accessed via `snaptrude.core.geom.line`.
11
+ */
3
12
  export declare abstract class PluginLineApi {
4
13
  constructor();
5
- /** Create a new PLine from start and end points. */
14
+ /**
15
+ * Create a new line segment between two points.
16
+ *
17
+ * @param startPoint - The start point as a {@linkcode PVec3}
18
+ * @param endPoint - The end point as a {@linkcode PVec3}
19
+ * @returns A new {@linkcode PLine}
20
+ *
21
+ * # Example
22
+ * ```ts
23
+ * const { vec3 } = snaptrude.core.math
24
+ * const { line } = snaptrude.core.geom
25
+ *
26
+ * const edge = line.new(vec3.new(0, 0, 0), vec3.new(5, 0, 0))
27
+ * ```
28
+ */
6
29
  new(startPoint: PVec3, endPoint: PVec3): PLine;
7
30
  }
31
+ /**
32
+ * A line segment defined by a start and end point.
33
+ *
34
+ * Discriminated by `curveType: "Line"` within the {@linkcode PCurve} union.
35
+ *
36
+ * | Property | Type | Description |
37
+ * |---|---|---|
38
+ * | `curveType` | `"Line"` | Discriminator tag |
39
+ * | `startPoint` | {@linkcode PVec3} | Start point of the segment |
40
+ * | `endPoint` | {@linkcode PVec3} | End point of the segment |
41
+ */
8
42
  export declare const PLine: z.ZodObject<{
9
43
  curveType: z.ZodLiteral<"Line">;
10
44
  startPoint: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC,8BAAsB,aAAa;;IAGjC,oDAAoD;IACpD,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK;CAG/C;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;iBAIhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAA"}
1
+ {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/line.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEpC;;;;;;;;GAQG;AACH,8BAAsB,aAAa;;IAGjC;;;;;;;;;;;;;;OAcG;IACH,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,GAAG,KAAK;CAG/C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;iBAIhB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,CAAA"}
@@ -1,13 +1,67 @@
1
1
  import * as z from "zod";
2
2
  import { PluginApiReturn } from "../../../types";
3
3
  import { PCurve } from "./curve";
4
+ /**
5
+ * Profile construction — a closed loop of {@linkcode PCurve}s.
6
+ *
7
+ * Profiles are the primary 2D shape primitive used for creating
8
+ * extruded entities like spaces. Build profiles either from an
9
+ * explicit list of curves or from a list of points (auto-connected
10
+ * with line segments).
11
+ *
12
+ * Accessed via `snaptrude.core.geom.profile`.
13
+ */
4
14
  export declare abstract class PluginProfileApi {
5
15
  constructor();
6
- /** Create a new PProfile from an array of PCurves. */
16
+ /**
17
+ * Create a profile from an ordered list of curves.
18
+ *
19
+ * The curves should form a closed loop — the end point of each curve
20
+ * should coincide with the start point of the next.
21
+ *
22
+ * @param curves - An ordered array of {@linkcode PCurve}s forming a closed loop
23
+ * @returns A new {@linkcode PProfile}
24
+ */
7
25
  new(curves: PCurve[]): PProfile;
8
- /** Create a PProfile from an array of points, connecting them with lines. */
26
+ /**
27
+ * Create a profile by connecting a list of points with line segments.
28
+ *
29
+ * The points are connected in order, with the last point automatically
30
+ * connected back to the first to close the loop.
31
+ *
32
+ * This is a **host API call** — it returns a `Promise`.
33
+ *
34
+ * @param args - An object containing:
35
+ * - {@linkcode PluginProfileFromLinePointsArgs.points args.points} — An ordered
36
+ * array of {@linkcode PVec3} forming the profile vertices
37
+ * @returns A {@linkcode PProfile} with line-segment curves connecting the points
38
+ *
39
+ * # Example
40
+ * ```ts
41
+ * const { vec3 } = snaptrude.core.math
42
+ *
43
+ * // Create an L-shaped profile
44
+ * const profile = await snaptrude.core.geom.profile.fromLinePoints({
45
+ * points: [
46
+ * vec3.new(0, 0, 0),
47
+ * vec3.new(10, 0, 0),
48
+ * vec3.new(10, 0, 5),
49
+ * vec3.new(5, 0, 5),
50
+ * vec3.new(5, 0, 10),
51
+ * vec3.new(0, 0, 10),
52
+ * ],
53
+ * })
54
+ * ```
55
+ */
9
56
  abstract fromLinePoints(args: PluginProfileFromLinePointsArgs): PluginApiReturn<PProfile>;
10
57
  }
58
+ /**
59
+ * Arguments for {@linkcode PluginProfileApi.fromLinePoints}.
60
+ *
61
+ * | Property | Type | Description |
62
+ * |---|---|---|
63
+ * | `points` | {@linkcode PVec3}`[]` | Ordered vertices of the profile |
64
+ */
11
65
  export declare const PluginProfileFromLinePointsArgs: z.ZodObject<{
12
66
  points: z.ZodArray<z.ZodObject<{
13
67
  x: z.ZodNumber;
@@ -16,6 +70,16 @@ export declare const PluginProfileFromLinePointsArgs: z.ZodObject<{
16
70
  }, z.core.$strip>>;
17
71
  }, z.core.$strip>;
18
72
  export type PluginProfileFromLinePointsArgs = z.infer<typeof PluginProfileFromLinePointsArgs>;
73
+ /**
74
+ * A closed profile composed of an ordered list of curves.
75
+ *
76
+ * Profiles are used as input to entity creation methods like
77
+ * {@linkcode PluginSpaceApi.createFromProfile}.
78
+ *
79
+ * | Property | Type | Description |
80
+ * |---|---|---|
81
+ * | `curves` | {@linkcode PCurve}`[]` | Ordered curves forming a closed loop |
82
+ */
19
83
  export declare const PProfile: z.ZodObject<{
20
84
  curves: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
21
85
  curveType: z.ZodLiteral<"Line">;
@@ -1 +1 @@
1
- {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../src/api/core/geom/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA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;;;;iBAEnB,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA"}
@@ -1,7 +1,15 @@
1
1
  import { PluginMathApi } from "./math";
2
2
  import { PluginGeomApi } from "./geom";
3
+ /**
4
+ * Core primitives used across the plugin API.
5
+ *
6
+ * - {@linkcode PluginCoreApi.math} — Vector and quaternion operations
7
+ * - {@linkcode PluginCoreApi.geom} — Geometry primitives (lines, arcs, curves, profiles)
8
+ */
3
9
  export declare abstract class PluginCoreApi {
10
+ /** Vector and quaternion math utilities. See {@linkcode PluginMathApi}. */
4
11
  abstract math: PluginMathApi;
12
+ /** Geometry primitives and constructors. See {@linkcode PluginGeomApi}. */
5
13
  abstract geom: PluginGeomApi;
6
14
  constructor();
7
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC,8BAAsB,aAAa;IACjC,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,SAAgB,IAAI,EAAE,aAAa,CAAA;;CAGpC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;GAKG;AACH,8BAAsB,aAAa;IACjC,2EAA2E;IAC3E,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,2EAA2E;IAC3E,SAAgB,IAAI,EAAE,aAAa,CAAA;;CAGpC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA"}
@@ -1,7 +1,15 @@
1
1
  import { PluginVec3Api } from "./vec3";
2
2
  import { PluginQuatApi } from "./quat";
3
+ /**
4
+ * Math primitives for 3D vector and quaternion operations.
5
+ *
6
+ * - {@linkcode PluginMathApi.vec3} — 3D vector creation and arithmetic
7
+ * - {@linkcode PluginMathApi.quat} — Quaternion creation and rotation operations
8
+ */
3
9
  export declare abstract class PluginMathApi {
10
+ /** 3D vector operations. See {@linkcode PluginVec3Api}. */
4
11
  abstract vec3: PluginVec3Api;
12
+ /** Quaternion operations. See {@linkcode PluginQuatApi}. */
5
13
  abstract quat: PluginQuatApi;
6
14
  constructor();
7
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/core/math/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC,8BAAsB,aAAa;IACjC,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,SAAgB,IAAI,EAAE,aAAa,CAAA;;CAGpC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/core/math/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;GAKG;AACH,8BAAsB,aAAa;IACjC,2DAA2D;IAC3D,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,4DAA4D;IAC5D,SAAgB,IAAI,EAAE,aAAa,CAAA;;CAGpC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA"}
@@ -1,41 +1,182 @@
1
1
  import * as z from "zod";
2
2
  import type { PVec3 } from "./vec3";
3
+ /**
4
+ * Quaternion operations for 3D rotations.
5
+ *
6
+ * Quaternions avoid gimbal lock and provide smooth interpolation
7
+ * compared to Euler angles. All methods are **pure** — they return
8
+ * new {@linkcode PQuat} values without mutating the inputs.
9
+ *
10
+ * Accessed via `snaptrude.core.math.quat`.
11
+ */
3
12
  export declare abstract class PluginQuatApi {
4
13
  constructor();
5
- /** Create a new PQuat. */
14
+ /**
15
+ * Create a new quaternion from raw components.
16
+ *
17
+ * For most use cases prefer {@linkcode PluginQuatApi.fromAxisAngle}
18
+ * or {@linkcode PluginQuatApi.fromEuler} instead.
19
+ *
20
+ * @param x - The X component
21
+ * @param y - The Y component
22
+ * @param z - The Z component
23
+ * @param w - The W (scalar) component
24
+ * @returns A new {@linkcode PQuat}
25
+ */
6
26
  new(x: number, y: number, z: number, w: number): PQuat;
7
- /** Create an identity quaternion (no rotation). */
27
+ /**
28
+ * Create an identity quaternion representing no rotation.
29
+ *
30
+ * @returns `{ x: 0, y: 0, z: 0, w: 1 }`
31
+ */
8
32
  identity(): PQuat;
9
- /** Create a quaternion from an axis and angle (radians). */
33
+ /**
34
+ * Create a quaternion from an axis and an angle.
35
+ *
36
+ * @param axis - The rotation axis as a {@linkcode PVec3} (will be normalized internally)
37
+ * @param angle - The rotation angle in **radians**
38
+ * @returns A new unit {@linkcode PQuat}, or identity if {@linkcode axis} has zero length
39
+ *
40
+ * # Example
41
+ * ```ts
42
+ * const { vec3, quat } = snaptrude.core.math
43
+ * // 90° rotation around the Y axis
44
+ * const rot = quat.fromAxisAngle(vec3.new(0, 1, 0), Math.PI / 2)
45
+ * ```
46
+ */
10
47
  fromAxisAngle(axis: PVec3, angle: number): PQuat;
11
- /** Create a quaternion from Euler angles (radians, XYZ order). */
48
+ /**
49
+ * Create a quaternion from Euler angles in **XYZ** rotation order.
50
+ *
51
+ * @param x - Rotation around X axis in **radians**
52
+ * @param y - Rotation around Y axis in **radians**
53
+ * @param z - Rotation around Z axis in **radians**
54
+ * @returns A new {@linkcode PQuat}
55
+ */
12
56
  fromEuler(x: number, y: number, z: number): PQuat;
13
- /** Multiply two quaternions (a * b). */
57
+ /**
58
+ * Multiply two quaternions, combining their rotations.
59
+ *
60
+ * Quaternion multiplication is **not commutative**: `a * b ≠ b * a`.
61
+ * The result applies rotation {@linkcode b} first, then {@linkcode a}.
62
+ *
63
+ * @param a - First quaternion (applied second)
64
+ * @param b - Second quaternion (applied first)
65
+ * @returns A new {@linkcode PQuat} representing the combined rotation
66
+ */
14
67
  multiply(a: PQuat, b: PQuat): PQuat;
15
- /** Conjugate of a quaternion. */
68
+ /**
69
+ * Compute the conjugate of a quaternion.
70
+ *
71
+ * For unit quaternions the conjugate equals the inverse.
72
+ *
73
+ * @param q - The quaternion
74
+ * @returns A new {@linkcode PQuat} with negated vector part `(-x, -y, -z, w)`
75
+ */
16
76
  conjugate(q: PQuat): PQuat;
17
- /** Length (magnitude) of a quaternion. */
77
+ /**
78
+ * Compute the length (magnitude) of a quaternion.
79
+ *
80
+ * @param q - The quaternion
81
+ * @returns The magnitude `√(x² + y² + z² + w²)`
82
+ */
18
83
  length(q: PQuat): number;
19
- /** Normalize a quaternion to unit length. Returns identity if length is 0. */
84
+ /**
85
+ * Normalize a quaternion to unit length.
86
+ *
87
+ * @param q - The quaternion to normalize
88
+ * @returns A new unit-length {@linkcode PQuat}, or identity if the input has zero length
89
+ */
20
90
  normalize(q: PQuat): PQuat;
21
- /** Inverse of a quaternion (conjugate / lengthSquared). */
91
+ /**
92
+ * Compute the inverse of a quaternion.
93
+ *
94
+ * The inverse satisfies `q * inverse(q) = identity`.
95
+ *
96
+ * @param q - The quaternion to invert
97
+ * @returns A new {@linkcode PQuat} that is the multiplicative inverse,
98
+ * or identity if the input has zero length
99
+ */
22
100
  inverse(q: PQuat): PQuat;
23
- /** Rotate a vector by a quaternion. */
101
+ /**
102
+ * Rotate a 3D vector by a quaternion.
103
+ *
104
+ * Computes `q * v * conjugate(q)` using the Hamilton product.
105
+ *
106
+ * @param q - The rotation quaternion (should be unit-length)
107
+ * @param v - The vector to rotate as a {@linkcode PVec3}
108
+ * @returns A new rotated {@linkcode PVec3}
109
+ *
110
+ * # Example
111
+ * ```ts
112
+ * const { vec3, quat } = snaptrude.core.math
113
+ * const rot = quat.fromAxisAngle(vec3.new(0, 1, 0), Math.PI / 2)
114
+ * const rotated = quat.rotateVec3(rot, vec3.new(1, 0, 0))
115
+ * // ≈ { x: 0, y: 0, z: -1 }
116
+ * ```
117
+ */
24
118
  rotateVec3(q: PQuat, v: PVec3): PVec3;
25
- /** Convert a quaternion to axis-angle representation. */
119
+ /**
120
+ * Convert a quaternion to axis-angle representation.
121
+ *
122
+ * @param q - The quaternion to convert
123
+ * @returns An object with:
124
+ * - `axis` — The rotation axis as a unit {@linkcode PVec3}
125
+ * (defaults to `(1, 0, 0)` when angle is zero)
126
+ * - `angle` — The rotation angle in **radians**
127
+ */
26
128
  toAxisAngle(q: PQuat): {
27
129
  axis: PVec3;
28
130
  angle: number;
29
131
  };
30
- /** Spherical linear interpolation between two quaternions. */
132
+ /**
133
+ * Spherical linear interpolation between two quaternions.
134
+ *
135
+ * Produces smooth constant-speed rotation between {@linkcode a} and {@linkcode b}.
136
+ *
137
+ * @param a - Start quaternion (returned when `t = 0`)
138
+ * @param b - End quaternion (returned when `t = 1`)
139
+ * @param t - Interpolation factor, typically in `[0, 1]`
140
+ * @returns A new interpolated {@linkcode PQuat}
141
+ */
31
142
  slerp(a: PQuat, b: PQuat, t: number): PQuat;
32
- /** Dot product of two quaternions. */
143
+ /**
144
+ * Compute the dot product of two quaternions.
145
+ *
146
+ * A value close to `1` or `-1` indicates similar orientations;
147
+ * a value close to `0` indicates maximally different orientations.
148
+ *
149
+ * @param a - First quaternion
150
+ * @param b - Second quaternion
151
+ * @returns The scalar dot product
152
+ */
33
153
  dot(a: PQuat, b: PQuat): number;
34
- /** Check if two quaternions are equal (exact). */
154
+ /**
155
+ * Check if two quaternions are exactly equal (strict equality per component).
156
+ *
157
+ * For floating-point comparisons, prefer {@linkcode PluginQuatApi.equalsApprox}.
158
+ *
159
+ * @param a - First quaternion
160
+ * @param b - Second quaternion
161
+ * @returns `true` if all components match exactly
162
+ */
35
163
  equals(a: PQuat, b: PQuat): boolean;
36
- /** Check if two quaternions are approximately equal within an epsilon. */
164
+ /**
165
+ * Check if two quaternions are approximately equal within a tolerance.
166
+ *
167
+ * @param a - First quaternion
168
+ * @param b - Second quaternion
169
+ * @param epsilon - Maximum allowed difference per component (default `1e-6`)
170
+ * @returns `true` if `|a[i] - b[i]| < epsilon` for all components
171
+ */
37
172
  equalsApprox(a: PQuat, b: PQuat, epsilon?: number): boolean;
38
173
  }
174
+ /**
175
+ * A quaternion with `x`, `y`, `z`, and `w` components.
176
+ *
177
+ * Used for representing 3D rotations without gimbal lock.
178
+ * Equivalent to `BABYLON.Quaternion`.
179
+ */
39
180
  export declare const PQuat: z.ZodObject<{
40
181
  x: z.ZodNumber;
41
182
  y: z.ZodNumber;
@@ -1 +1 @@
1
- {"version":3,"file":"quat.d.ts","sourceRoot":"","sources":["../../../../src/api/core/math/quat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,8BAAsB,aAAa;;IAGjC,0BAA0B;IAC1B,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK;IAItD,mDAAmD;IACnD,QAAQ,IAAI,KAAK;IAIjB,4DAA4D;IAC5D,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK;IAahD,kEAAkE;IAClE,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK;IAejD,wCAAwC;IACxC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,KAAK;IASnC,iCAAiC;IACjC,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