okgeometry-api 0.2.11 → 0.2.13

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 (74) hide show
  1. package/dist/Arc.d.ts +52 -2
  2. package/dist/Arc.d.ts.map +1 -1
  3. package/dist/Arc.js +50 -1
  4. package/dist/Arc.js.map +1 -1
  5. package/dist/BufferCodec.d.ts +118 -0
  6. package/dist/BufferCodec.d.ts.map +1 -0
  7. package/dist/BufferCodec.js +171 -0
  8. package/dist/BufferCodec.js.map +1 -0
  9. package/dist/Circle.d.ts +69 -4
  10. package/dist/Circle.d.ts.map +1 -1
  11. package/dist/Circle.js +77 -5
  12. package/dist/Circle.js.map +1 -1
  13. package/dist/Line.d.ts +53 -1
  14. package/dist/Line.d.ts.map +1 -1
  15. package/dist/Line.js +51 -0
  16. package/dist/Line.js.map +1 -1
  17. package/dist/Mesh.d.ts +167 -20
  18. package/dist/Mesh.d.ts.map +1 -1
  19. package/dist/Mesh.js +199 -72
  20. package/dist/Mesh.js.map +1 -1
  21. package/dist/NurbsCurve.d.ts +78 -8
  22. package/dist/NurbsCurve.d.ts.map +1 -1
  23. package/dist/NurbsCurve.js +76 -7
  24. package/dist/NurbsCurve.js.map +1 -1
  25. package/dist/NurbsSurface.d.ts +64 -14
  26. package/dist/NurbsSurface.d.ts.map +1 -1
  27. package/dist/NurbsSurface.js +65 -25
  28. package/dist/NurbsSurface.js.map +1 -1
  29. package/dist/Plane.d.ts +6 -1
  30. package/dist/Plane.d.ts.map +1 -1
  31. package/dist/Plane.js +29 -1
  32. package/dist/Plane.js.map +1 -1
  33. package/dist/Point.d.ts +65 -12
  34. package/dist/Point.d.ts.map +1 -1
  35. package/dist/Point.js +61 -2
  36. package/dist/Point.js.map +1 -1
  37. package/dist/PolyCurve.d.ts +4 -6
  38. package/dist/PolyCurve.d.ts.map +1 -1
  39. package/dist/PolyCurve.js +31 -16
  40. package/dist/PolyCurve.js.map +1 -1
  41. package/dist/Polygon.d.ts +35 -3
  42. package/dist/Polygon.d.ts.map +1 -1
  43. package/dist/Polygon.js +33 -2
  44. package/dist/Polygon.js.map +1 -1
  45. package/dist/Polyline.d.ts +54 -2
  46. package/dist/Polyline.d.ts.map +1 -1
  47. package/dist/Polyline.js +55 -13
  48. package/dist/Polyline.js.map +1 -1
  49. package/dist/Ray.d.ts +45 -0
  50. package/dist/Ray.d.ts.map +1 -0
  51. package/dist/Ray.js +68 -0
  52. package/dist/Ray.js.map +1 -0
  53. package/dist/Vec3.d.ts +76 -0
  54. package/dist/Vec3.d.ts.map +1 -1
  55. package/dist/Vec3.js +76 -0
  56. package/dist/Vec3.js.map +1 -1
  57. package/dist/engine.d.ts.map +1 -1
  58. package/dist/engine.js +3 -2
  59. package/dist/engine.js.map +1 -1
  60. package/dist/index.d.ts +6 -4
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +8 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/types.d.ts +67 -0
  65. package/dist/types.d.ts.map +1 -0
  66. package/dist/types.js +7 -0
  67. package/dist/types.js.map +1 -0
  68. package/dist/wasm-base64.d.ts +1 -1
  69. package/dist/wasm-base64.d.ts.map +1 -1
  70. package/dist/wasm-base64.js +1 -1
  71. package/dist/wasm-base64.js.map +1 -1
  72. package/package.json +1 -1
  73. package/wasm/okgeometrycore.d.ts +121 -0
  74. package/wasm/okgeometrycore_bg.wasm +0 -0
package/dist/Arc.d.ts CHANGED
@@ -2,20 +2,70 @@ import { Point } from "./Point.js";
2
2
  import { Vec3 } from "./Vec3.js";
3
3
  import { Polyline } from "./Polyline.js";
4
4
  import type { Plane } from "./Plane.js";
5
+ import type { RotationAxis } from "./types.js";
6
+ /**
7
+ * Immutable circular arc defined by center, radius, and angular span.
8
+ * Angles are in radians, measured counter-clockwise from the positive X axis
9
+ * in the plane defined by the normal.
10
+ */
5
11
  export declare class Arc {
6
12
  readonly center: Point;
7
13
  readonly radius: number;
8
14
  readonly startAngle: number;
9
15
  readonly endAngle: number;
10
16
  readonly normal: Vec3;
17
+ /**
18
+ * Create a new arc.
19
+ * @param center - Center point
20
+ * @param radius - Arc radius
21
+ * @param startAngle - Start angle in radians
22
+ * @param endAngle - End angle in radians
23
+ * @param normal - Normal vector defining the arc's plane (default Z axis)
24
+ */
11
25
  constructor(center: Point, radius: number, startAngle: number, endAngle: number, normal?: Vec3);
26
+ /**
27
+ * Evaluate a point on the arc at normalized parameter t.
28
+ * @param t - Parameter in [0, 1] (0 = start angle, 1 = end angle)
29
+ * @returns Point on arc at parameter t
30
+ */
12
31
  pointAt(t: number): Point;
32
+ /**
33
+ * Get the arc length.
34
+ * @returns Arc length = radius * angular span
35
+ */
13
36
  length(): number;
37
+ /**
38
+ * Translate this arc by an offset vector.
39
+ * @param offset - Translation vector
40
+ * @returns New translated arc
41
+ */
14
42
  translate(offset: Vec3): Arc;
15
- rotate(axis: Vec3 | import("./Line.js").Line, angle: number): Arc;
43
+ /**
44
+ * Rotate this arc around an axis.
45
+ * @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
46
+ * @param angle - Rotation angle in radians
47
+ * @returns New rotated arc
48
+ */
49
+ rotate(axis: RotationAxis, angle: number): Arc;
50
+ /**
51
+ * Offset this arc by changing its radius.
52
+ * @param distance - Distance to offset (positive = larger, negative = smaller)
53
+ * @returns New arc with adjusted radius
54
+ */
16
55
  offset(distance: number): Arc;
17
- /** Project onto plane. Returns a Polyline because a tilted arc projects to an elliptical arc. */
56
+ /**
57
+ * Project onto plane. Returns a Polyline because a tilted arc projects to an elliptical arc.
58
+ * @param plane - Target plane
59
+ * @param direction - Optional projection direction (default: perpendicular to plane)
60
+ * @param samples - Number of sample points for approximation (default 64)
61
+ * @returns Polyline approximating the projected arc
62
+ */
18
63
  projectOntoPlane(plane: Plane, direction?: Vec3, samples?: number): Polyline;
64
+ /**
65
+ * Sample the arc into evenly-spaced points.
66
+ * @param n - Number of points to generate
67
+ * @returns Array of n points along the arc
68
+ */
19
69
  sample(n: number): Point[];
20
70
  }
21
71
  //# sourceMappingURL=Arc.d.ts.map
package/dist/Arc.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Arc.d.ts","sourceRoot":"","sources":["../src/Arc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,qBAAa,GAAG;aAEI,MAAM,EAAE,KAAK;aACb,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,IAAI;gBAJZ,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,IAAa;IAGvC,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK;IAUzB,MAAM,IAAI,MAAM;IAKhB,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG;IAI5B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG;IAOjE,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG;IAI7B,iGAAiG;IACjG,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,SAAK,GAAG,QAAQ;IAMxE,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE;CAa3B"}
1
+ {"version":3,"file":"Arc.d.ts","sourceRoot":"","sources":["../src/Arc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C;;;;GAIG;AACH,qBAAa,GAAG;aAUI,MAAM,EAAE,KAAK;aACb,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,IAAI;IAb9B;;;;;;;OAOG;gBAEe,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,GAAE,IAAa;IAGvC;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK;IAUzB;;;OAGG;IACH,MAAM,IAAI,MAAM;IAKhB;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,GAAG;IAI5B;;;;;OAKG;IACH,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG;IAO9C;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG;IAI7B;;;;;;OAMG;IACH,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,SAAK,GAAG,QAAQ;IAMxE;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,EAAE;CAa3B"}
package/dist/Arc.js CHANGED
@@ -3,7 +3,20 @@ import { Point } from "./Point.js";
3
3
  import { Vec3 } from "./Vec3.js";
4
4
  import { Polyline } from "./Polyline.js";
5
5
  import * as wasm from "../wasm/okgeometrycore_bg.js";
6
+ /**
7
+ * Immutable circular arc defined by center, radius, and angular span.
8
+ * Angles are in radians, measured counter-clockwise from the positive X axis
9
+ * in the plane defined by the normal.
10
+ */
6
11
  export class Arc {
12
+ /**
13
+ * Create a new arc.
14
+ * @param center - Center point
15
+ * @param radius - Arc radius
16
+ * @param startAngle - Start angle in radians
17
+ * @param endAngle - End angle in radians
18
+ * @param normal - Normal vector defining the arc's plane (default Z axis)
19
+ */
7
20
  constructor(center, radius, startAngle, endAngle, normal = Vec3.Z) {
8
21
  this.center = center;
9
22
  this.radius = radius;
@@ -11,33 +24,69 @@ export class Arc {
11
24
  this.endAngle = endAngle;
12
25
  this.normal = normal;
13
26
  }
27
+ /**
28
+ * Evaluate a point on the arc at normalized parameter t.
29
+ * @param t - Parameter in [0, 1] (0 = start angle, 1 = end angle)
30
+ * @returns Point on arc at parameter t
31
+ */
14
32
  pointAt(t) {
15
33
  ensureInit();
16
34
  const r = wasm.arc_point_at(this.center.x, this.center.y, this.center.z, this.normal.x, this.normal.y, this.normal.z, this.radius, this.startAngle, this.endAngle, t);
17
35
  return new Point(r[0], r[1], r[2]);
18
36
  }
37
+ /**
38
+ * Get the arc length.
39
+ * @returns Arc length = radius * angular span
40
+ */
19
41
  length() {
20
42
  ensureInit();
21
43
  return wasm.arc_length(this.radius, this.startAngle, this.endAngle);
22
44
  }
45
+ /**
46
+ * Translate this arc by an offset vector.
47
+ * @param offset - Translation vector
48
+ * @returns New translated arc
49
+ */
23
50
  translate(offset) {
24
51
  return new Arc(this.center.add(offset), this.radius, this.startAngle, this.endAngle, this.normal);
25
52
  }
53
+ /**
54
+ * Rotate this arc around an axis.
55
+ * @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
56
+ * @param angle - Rotation angle in radians
57
+ * @returns New rotated arc
58
+ */
26
59
  rotate(axis, angle) {
27
60
  const n = this.normal;
28
61
  const dirAxis = 'start' in axis ? new Vec3(axis.end.x - axis.start.x, axis.end.y - axis.start.y, axis.end.z - axis.start.z) : axis;
29
62
  const rn = new Point(n.x, n.y, n.z).rotate(dirAxis, angle);
30
63
  return new Arc(this.center.rotate(axis, angle), this.radius, this.startAngle, this.endAngle, new Vec3(rn.x, rn.y, rn.z));
31
64
  }
65
+ /**
66
+ * Offset this arc by changing its radius.
67
+ * @param distance - Distance to offset (positive = larger, negative = smaller)
68
+ * @returns New arc with adjusted radius
69
+ */
32
70
  offset(distance) {
33
71
  return new Arc(this.center, this.radius + distance, this.startAngle, this.endAngle, this.normal);
34
72
  }
35
- /** Project onto plane. Returns a Polyline because a tilted arc projects to an elliptical arc. */
73
+ /**
74
+ * Project onto plane. Returns a Polyline because a tilted arc projects to an elliptical arc.
75
+ * @param plane - Target plane
76
+ * @param direction - Optional projection direction (default: perpendicular to plane)
77
+ * @param samples - Number of sample points for approximation (default 64)
78
+ * @returns Polyline approximating the projected arc
79
+ */
36
80
  projectOntoPlane(plane, direction, samples = 64) {
37
81
  const pts = this.sample(samples);
38
82
  const proj = (p) => direction ? plane.projectPointAlongDirection(p, direction) : plane.projectPoint(p);
39
83
  return new Polyline(pts.map(proj));
40
84
  }
85
+ /**
86
+ * Sample the arc into evenly-spaced points.
87
+ * @param n - Number of points to generate
88
+ * @returns Array of n points along the arc
89
+ */
41
90
  sample(n) {
42
91
  ensureInit();
43
92
  const buf = wasm.create_arc(this.center.x, this.center.y, this.center.z, this.normal.x, this.normal.y, this.normal.z, this.radius, this.startAngle, this.endAngle, n);
package/dist/Arc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Arc.js","sourceRoot":"","sources":["../src/Arc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AAErD,MAAM,OAAO,GAAG;IACd,YACkB,MAAa,EACb,MAAc,EACd,UAAkB,EAClB,QAAgB,EAChB,SAAe,IAAI,CAAC,CAAC;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1,z1, ..., i1,i2,i3, ...]`
8
+ * - Element 0: Number of vertices
9
+ * - Elements 1 to vertexCount*3: Vertex coordinates (xyz triplets)
10
+ * - Remaining elements: Triangle indices (groups of 3)
11
+ *
12
+ * ## Polyline Buffer (multi-polyline result)
13
+ * `[numPolylines, count1, x,y,z,..., count2, x,y,z,...]`
14
+ * - Element 0: Number of polylines
15
+ * - For each polyline: point count followed by xyz coordinates
16
+ *
17
+ * ## Intersection Points Buffer
18
+ * `[numPoints, x1,y1,z1, x2,y2,z2, ...]`
19
+ * - Element 0: Number of intersection points
20
+ * - Remaining: xyz triplets for each point
21
+ *
22
+ * ## Curve Encoding (for sweep/loft)
23
+ * See CurveTypeCode enum in types.ts for format details.
24
+ *
25
+ * ## NURBS Curve Data
26
+ * `[degree, numControlPoints, x1,y1,z1,..., w1,w2,..., k1,k2,...]`
27
+ *
28
+ * ## NURBS Surface Data
29
+ * `[degU, degV, numU, numV, cp_xyz..., weights..., knotsU..., knotsV...]`
30
+ *
31
+ * @module BufferCodec
32
+ */
33
+ import { Point } from "./Point.js";
34
+ import { Vec3 } from "./Vec3.js";
35
+ /**
36
+ * Convert array of Points to flat coordinate buffer.
37
+ * @param points - Array of Point objects
38
+ * @returns Float64Array with interleaved [x1,y1,z1, x2,y2,z2, ...]
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const pts = [new Point(0,0,0), new Point(1,2,3)];
43
+ * const coords = pointsToCoords(pts);
44
+ * // coords = Float64Array [0, 0, 0, 1, 2, 3]
45
+ * ```
46
+ */
47
+ export declare function pointsToCoords(points: Point[]): Float64Array;
48
+ /**
49
+ * Convert flat coordinate buffer to array of Points.
50
+ * @param coords - Float64Array with interleaved xyz coordinates
51
+ * @returns Array of Point objects
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const coords = new Float64Array([0, 0, 0, 1, 2, 3]);
56
+ * const pts = coordsToPoints(coords);
57
+ * // pts = [Point(0,0,0), Point(1,2,3)]
58
+ * ```
59
+ */
60
+ export declare function coordsToPoints(coords: Float64Array | number[]): Point[];
61
+ /**
62
+ * Read a single Point from buffer at specified offset.
63
+ * @param buf - Source buffer
64
+ * @param offset - Starting index in buffer
65
+ * @returns Tuple of [Point, newOffset] where newOffset = offset + 3
66
+ */
67
+ export declare function readPoint(buf: Float64Array, offset: number): [Point, number];
68
+ /**
69
+ * Read a single Vec3 from buffer at specified offset.
70
+ * @param buf - Source buffer
71
+ * @param offset - Starting index in buffer
72
+ * @returns Tuple of [Vec3, newOffset] where newOffset = offset + 3
73
+ */
74
+ export declare function readVec3(buf: Float64Array, offset: number): [Vec3, number];
75
+ /**
76
+ * Decode WASM result buffer as single Point.
77
+ * Common pattern for pointAt(), closestPoint() results.
78
+ * @param r - WASM result array (must have at least 3 elements)
79
+ * @returns Point from first 3 elements
80
+ */
81
+ export declare function decodePointResult(r: Float64Array): Point;
82
+ /**
83
+ * Decode WASM result buffer as single Vec3.
84
+ * Common pattern for tangent(), normal() results.
85
+ * @param r - WASM result array (must have at least 3 elements)
86
+ * @returns Vec3 from first 3 elements
87
+ */
88
+ export declare function decodeVec3Result(r: Float64Array): Vec3;
89
+ /**
90
+ * Parse WASM multi-polyline buffer into array of point arrays.
91
+ * Used by mesh intersection operations that return multiple polylines.
92
+ *
93
+ * Buffer format: [numPolylines, count1, x,y,z,..., count2, x,y,z,...]
94
+ *
95
+ * @param buf - WASM result buffer
96
+ * @returns Array of Point arrays, one per polyline
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * // Buffer: [2, 3, 0,0,0, 1,0,0, 1,1,0, 2, 5,5,5, 6,6,6]
101
+ * // = 2 polylines: first has 3 points, second has 2 points
102
+ * const polylines = parsePolylineBuffer(buf);
103
+ * // polylines[0] = [Point(0,0,0), Point(1,0,0), Point(1,1,0)]
104
+ * // polylines[1] = [Point(5,5,5), Point(6,6,6)]
105
+ * ```
106
+ */
107
+ export declare function parsePolylineBuffer(buf: Float64Array): Point[][];
108
+ /**
109
+ * Parse WASM intersection points buffer.
110
+ * Used by curve-curve and curve-plane intersection operations.
111
+ *
112
+ * Buffer format: [numPoints, x1,y1,z1, x2,y2,z2, ...]
113
+ *
114
+ * @param buf - WASM result buffer
115
+ * @returns Array of intersection Points
116
+ */
117
+ export declare function parseIntersectionPoints(buf: Float64Array): Point[];
118
+ //# sourceMappingURL=BufferCodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BufferCodec.d.ts","sourceRoot":"","sources":["../src/BufferCodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAQ5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE,CAOvE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAE1E;AAID;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,GAAG,KAAK,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAEtD;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,GAAG,KAAK,EAAE,EAAE,CAehE;AAID;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,YAAY,GAAG,KAAK,EAAE,CASlE"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Buffer encoding/decoding utilities for WASM communication.
3
+ *
4
+ * # WASM Buffer Formats
5
+ *
6
+ * ## Mesh Buffer
7
+ * `[vertexCount, x1,y1,z1, ..., i1,i2,i3, ...]`
8
+ * - Element 0: Number of vertices
9
+ * - Elements 1 to vertexCount*3: Vertex coordinates (xyz triplets)
10
+ * - Remaining elements: Triangle indices (groups of 3)
11
+ *
12
+ * ## Polyline Buffer (multi-polyline result)
13
+ * `[numPolylines, count1, x,y,z,..., count2, x,y,z,...]`
14
+ * - Element 0: Number of polylines
15
+ * - For each polyline: point count followed by xyz coordinates
16
+ *
17
+ * ## Intersection Points Buffer
18
+ * `[numPoints, x1,y1,z1, x2,y2,z2, ...]`
19
+ * - Element 0: Number of intersection points
20
+ * - Remaining: xyz triplets for each point
21
+ *
22
+ * ## Curve Encoding (for sweep/loft)
23
+ * See CurveTypeCode enum in types.ts for format details.
24
+ *
25
+ * ## NURBS Curve Data
26
+ * `[degree, numControlPoints, x1,y1,z1,..., w1,w2,..., k1,k2,...]`
27
+ *
28
+ * ## NURBS Surface Data
29
+ * `[degU, degV, numU, numV, cp_xyz..., weights..., knotsU..., knotsV...]`
30
+ *
31
+ * @module BufferCodec
32
+ */
33
+ import { Point } from "./Point.js";
34
+ import { Vec3 } from "./Vec3.js";
35
+ // ── Point Array Conversion ─────────────────────────────────────────
36
+ /**
37
+ * Convert array of Points to flat coordinate buffer.
38
+ * @param points - Array of Point objects
39
+ * @returns Float64Array with interleaved [x1,y1,z1, x2,y2,z2, ...]
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const pts = [new Point(0,0,0), new Point(1,2,3)];
44
+ * const coords = pointsToCoords(pts);
45
+ * // coords = Float64Array [0, 0, 0, 1, 2, 3]
46
+ * ```
47
+ */
48
+ export function pointsToCoords(points) {
49
+ const coords = new Float64Array(points.length * 3);
50
+ for (let i = 0; i < points.length; i++) {
51
+ coords[i * 3] = points[i].x;
52
+ coords[i * 3 + 1] = points[i].y;
53
+ coords[i * 3 + 2] = points[i].z;
54
+ }
55
+ return coords;
56
+ }
57
+ /**
58
+ * Convert flat coordinate buffer to array of Points.
59
+ * @param coords - Float64Array with interleaved xyz coordinates
60
+ * @returns Array of Point objects
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const coords = new Float64Array([0, 0, 0, 1, 2, 3]);
65
+ * const pts = coordsToPoints(coords);
66
+ * // pts = [Point(0,0,0), Point(1,2,3)]
67
+ * ```
68
+ */
69
+ export function coordsToPoints(coords) {
70
+ const data = coords instanceof Float64Array ? coords : new Float64Array(coords);
71
+ const pts = [];
72
+ for (let i = 0; i < data.length; i += 3) {
73
+ pts.push(new Point(data[i], data[i + 1], data[i + 2]));
74
+ }
75
+ return pts;
76
+ }
77
+ /**
78
+ * Read a single Point from buffer at specified offset.
79
+ * @param buf - Source buffer
80
+ * @param offset - Starting index in buffer
81
+ * @returns Tuple of [Point, newOffset] where newOffset = offset + 3
82
+ */
83
+ export function readPoint(buf, offset) {
84
+ return [new Point(buf[offset], buf[offset + 1], buf[offset + 2]), offset + 3];
85
+ }
86
+ /**
87
+ * Read a single Vec3 from buffer at specified offset.
88
+ * @param buf - Source buffer
89
+ * @param offset - Starting index in buffer
90
+ * @returns Tuple of [Vec3, newOffset] where newOffset = offset + 3
91
+ */
92
+ export function readVec3(buf, offset) {
93
+ return [new Vec3(buf[offset], buf[offset + 1], buf[offset + 2]), offset + 3];
94
+ }
95
+ // ── WASM Result Decoding ───────────────────────────────────────────
96
+ /**
97
+ * Decode WASM result buffer as single Point.
98
+ * Common pattern for pointAt(), closestPoint() results.
99
+ * @param r - WASM result array (must have at least 3 elements)
100
+ * @returns Point from first 3 elements
101
+ */
102
+ export function decodePointResult(r) {
103
+ return new Point(r[0], r[1], r[2]);
104
+ }
105
+ /**
106
+ * Decode WASM result buffer as single Vec3.
107
+ * Common pattern for tangent(), normal() results.
108
+ * @param r - WASM result array (must have at least 3 elements)
109
+ * @returns Vec3 from first 3 elements
110
+ */
111
+ export function decodeVec3Result(r) {
112
+ return new Vec3(r[0], r[1], r[2]);
113
+ }
114
+ // ── Polyline Buffer Format ─────────────────────────────────────────
115
+ /**
116
+ * Parse WASM multi-polyline buffer into array of point arrays.
117
+ * Used by mesh intersection operations that return multiple polylines.
118
+ *
119
+ * Buffer format: [numPolylines, count1, x,y,z,..., count2, x,y,z,...]
120
+ *
121
+ * @param buf - WASM result buffer
122
+ * @returns Array of Point arrays, one per polyline
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // Buffer: [2, 3, 0,0,0, 1,0,0, 1,1,0, 2, 5,5,5, 6,6,6]
127
+ * // = 2 polylines: first has 3 points, second has 2 points
128
+ * const polylines = parsePolylineBuffer(buf);
129
+ * // polylines[0] = [Point(0,0,0), Point(1,0,0), Point(1,1,0)]
130
+ * // polylines[1] = [Point(5,5,5), Point(6,6,6)]
131
+ * ```
132
+ */
133
+ export function parsePolylineBuffer(buf) {
134
+ if (buf.length === 0)
135
+ return [];
136
+ const numPolylines = buf[0];
137
+ const result = [];
138
+ let idx = 1;
139
+ for (let i = 0; i < numPolylines; i++) {
140
+ const count = buf[idx++];
141
+ const pts = [];
142
+ for (let j = 0; j < count; j++) {
143
+ pts.push(new Point(buf[idx], buf[idx + 1], buf[idx + 2]));
144
+ idx += 3;
145
+ }
146
+ result.push(pts);
147
+ }
148
+ return result;
149
+ }
150
+ // ── Intersection Result Format ─────────────────────────────────────
151
+ /**
152
+ * Parse WASM intersection points buffer.
153
+ * Used by curve-curve and curve-plane intersection operations.
154
+ *
155
+ * Buffer format: [numPoints, x1,y1,z1, x2,y2,z2, ...]
156
+ *
157
+ * @param buf - WASM result buffer
158
+ * @returns Array of intersection Points
159
+ */
160
+ export function parseIntersectionPoints(buf) {
161
+ if (buf.length === 0)
162
+ return [];
163
+ const numPts = buf[0];
164
+ const pts = [];
165
+ for (let i = 0; i < numPts; i++) {
166
+ const off = 1 + i * 3;
167
+ pts.push(new Point(buf[off], buf[off + 1], buf[off + 2]));
168
+ }
169
+ return pts;
170
+ }
171
+ //# sourceMappingURL=BufferCodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BufferCodec.js","sourceRoot":"","sources":["../src/BufferCodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,sEAAsE;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,MAA+B;IAC5D,MAAM,IAAI,GAAG,MAAM,YAAY,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAChF,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,M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AC,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/Circle.d.ts CHANGED
@@ -2,20 +2,85 @@ import { Point } from "./Point.js";
2
2
  import { Vec3 } from "./Vec3.js";
3
3
  import { Mesh } from "./Mesh.js";
4
4
  import { Polygon } from "./Polygon.js";
5
- import type { Plane } from "./Plane.js";
5
+ import { Plane } from "./Plane.js";
6
+ import type { RotationAxis } from "./types.js";
7
+ /**
8
+ * Immutable circle defined by center, radius, and normal.
9
+ * Supports evaluation, transformation, extrusion, and projection.
10
+ */
6
11
  export declare class Circle {
7
12
  readonly center: Point;
8
13
  readonly radius: number;
9
14
  readonly normal: Vec3;
10
- constructor(center: Point, radius: number, normal?: Vec3);
15
+ readonly uAxis?: Vec3 | undefined;
16
+ /**
17
+ * Create a new circle.
18
+ * @param center - Center point
19
+ * @param radius - Circle radius
20
+ * @param normal - Normal vector defining the circle's plane (default Z axis)
21
+ * @param uAxis - Optional reference direction defining where t=0 starts.
22
+ * Critical for sweep operations to maintain consistent profile orientation.
23
+ */
24
+ constructor(center: Point, radius: number, normal?: Vec3, uAxis?: Vec3 | undefined);
25
+ /**
26
+ * Create a Circle from a Plane, automatically using the plane's xAxis
27
+ * as the circle's uAxis for consistent orientation in sweep operations.
28
+ * @param plane - Plane defining circle's position and orientation
29
+ * @param radius - Circle radius
30
+ * @returns New Circle at plane origin with plane normal
31
+ */
32
+ static fromPlane(plane: Plane, radius: number): Circle;
33
+ /**
34
+ * Evaluate a point on the circle at normalized parameter t.
35
+ * @param t - Parameter in [0, 1] (0 and 1 are the same point for closed circle)
36
+ * @returns Point on circle at parameter t
37
+ */
11
38
  pointAt(t: number): Point;
39
+ /**
40
+ * Get the circumference of this circle.
41
+ * @returns 2 * PI * radius
42
+ */
12
43
  length(): number;
44
+ /**
45
+ * Sample the circle into evenly-spaced points.
46
+ * @param n - Number of points to generate
47
+ * @returns Array of n points around the circle
48
+ */
13
49
  sample(n: number): Point[];
50
+ /**
51
+ * Translate this circle by an offset vector.
52
+ * @param offset - Translation vector
53
+ * @returns New translated circle
54
+ */
14
55
  translate(offset: Vec3): Circle;
15
- rotate(axis: Vec3 | import("./Line.js").Line, angle: number): Circle;
56
+ /**
57
+ * Rotate this circle around an axis.
58
+ * @param axis - Rotation axis (Vec3 through origin, or Line for arbitrary axis)
59
+ * @param angle - Rotation angle in radians
60
+ * @returns New rotated circle
61
+ */
62
+ rotate(axis: RotationAxis, angle: number): Circle;
63
+ /**
64
+ * Offset this circle by changing its radius.
65
+ * @param distance - Distance to offset (positive = larger, negative = smaller)
66
+ * @returns New circle with adjusted radius
67
+ */
16
68
  offset(distance: number): Circle;
17
- /** Project onto plane. Returns a Polygon because a tilted circle projects to an ellipse. */
69
+ /**
70
+ * Project onto plane. Returns a Polygon because a tilted circle projects to an ellipse.
71
+ * @param plane - Target plane
72
+ * @param direction - Optional projection direction (default: perpendicular to plane)
73
+ * @param samples - Number of sample points for approximation (default 64)
74
+ * @returns Polygon approximating the projected circle
75
+ */
18
76
  projectOntoPlane(plane: Plane, direction?: Vec3, samples?: number): Polygon;
77
+ /**
78
+ * Extrude this circle along a direction vector to create a cylindrical mesh.
79
+ * @param direction - Extrusion direction and magnitude
80
+ * @param segments - Number of circumferential segments (default 16)
81
+ * @param caps - Whether to cap the ends (default true)
82
+ * @returns Mesh representing the extruded cylinder
83
+ */
19
84
  extrude(direction: Vec3, segments?: number, caps?: boolean): Mesh;
20
85
  }
21
86
  //# sourceMappingURL=Circle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Circle.d.ts","sourceRoot":"","sources":["../src/Circle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,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