okgeometry-api 1.2.0 → 1.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.
Files changed (65) hide show
  1. package/dist/Line.d.ts +10 -1
  2. package/dist/Line.d.ts.map +1 -1
  3. package/dist/Line.js +11 -0
  4. package/dist/Line.js.map +1 -1
  5. package/dist/Mesh.d.ts +82 -9
  6. package/dist/Mesh.d.ts.map +1 -1
  7. package/dist/Mesh.js +329 -26
  8. package/dist/Mesh.js.map +1 -1
  9. package/dist/MeshSurface.d.ts +32 -0
  10. package/dist/MeshSurface.d.ts.map +1 -0
  11. package/dist/MeshSurface.js +51 -0
  12. package/dist/MeshSurface.js.map +1 -0
  13. package/dist/NurbsCurve.d.ts +24 -2
  14. package/dist/NurbsCurve.d.ts.map +1 -1
  15. package/dist/NurbsCurve.js +34 -2
  16. package/dist/NurbsCurve.js.map +1 -1
  17. package/dist/NurbsSurface.d.ts +9 -1
  18. package/dist/NurbsSurface.d.ts.map +1 -1
  19. package/dist/NurbsSurface.js +12 -3
  20. package/dist/NurbsSurface.js.map +1 -1
  21. package/dist/PolyCurve.d.ts +21 -3
  22. package/dist/PolyCurve.d.ts.map +1 -1
  23. package/dist/PolyCurve.js +82 -38
  24. package/dist/PolyCurve.js.map +1 -1
  25. package/dist/Polygon.d.ts +13 -2
  26. package/dist/Polygon.d.ts.map +1 -1
  27. package/dist/Polygon.js +21 -3
  28. package/dist/Polygon.js.map +1 -1
  29. package/dist/Polyline.d.ts +19 -2
  30. package/dist/Polyline.d.ts.map +1 -1
  31. package/dist/Polyline.js +38 -6
  32. package/dist/Polyline.js.map +1 -1
  33. package/dist/Surface.d.ts +17 -0
  34. package/dist/Surface.d.ts.map +1 -0
  35. package/dist/Surface.js +2 -0
  36. package/dist/Surface.js.map +1 -0
  37. package/dist/index.d.ts +4 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -0
  40. package/dist/index.js.map +1 -1
  41. package/dist/types.d.ts +13 -0
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/wasm-base64.d.ts +1 -1
  44. package/dist/wasm-base64.d.ts.map +1 -1
  45. package/dist/wasm-base64.js +1 -1
  46. package/dist/wasm-base64.js.map +1 -1
  47. package/dist/wasm-bindings.d.ts +65 -2
  48. package/dist/wasm-bindings.d.ts.map +1 -1
  49. package/dist/wasm-bindings.js +100 -2
  50. package/dist/wasm-bindings.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/Line.ts +38 -20
  53. package/src/Mesh.ts +538 -184
  54. package/src/MeshSurface.ts +72 -0
  55. package/src/NurbsCurve.ts +80 -26
  56. package/src/NurbsSurface.ts +28 -13
  57. package/src/PolyCurve.ts +157 -85
  58. package/src/Polygon.ts +34 -4
  59. package/src/Polyline.ts +74 -24
  60. package/src/Surface.ts +18 -0
  61. package/src/index.ts +5 -0
  62. package/src/types.ts +15 -0
  63. package/src/wasm-base64.ts +1 -1
  64. package/src/wasm-bindings.d.ts +43 -2
  65. package/src/wasm-bindings.js +105 -2
package/src/Line.ts CHANGED
@@ -1,10 +1,12 @@
1
- import { ensureInit } from "./engine.js";
2
- import { Point } from "./Point.js";
3
- import { Vec3 } from "./Vec3.js";
4
- import { Mesh } from "./Mesh.js";
5
- import type { Plane } from "./Plane.js";
6
- import type { RotationAxis } from "./types.js";
7
- import * as wasm from "./wasm-bindings.js";
1
+ import { ensureInit } from "./engine.js";
2
+ import { Point } from "./Point.js";
3
+ import { Vec3 } from "./Vec3.js";
4
+ import { Mesh } from "./Mesh.js";
5
+ import { PolyCurve } from "./PolyCurve.js";
6
+ import { Polyline } from "./Polyline.js";
7
+ import type { Plane } from "./Plane.js";
8
+ import type { CurveOffsetOptions, RotationAxis } from "./types.js";
9
+ import * as wasm from "./wasm-bindings.js";
8
10
 
9
11
  /**
10
12
  * Immutable line segment defined by start and end points.
@@ -100,24 +102,40 @@ export class Line {
100
102
  * @param normal - Reference normal for determining offset direction (default Z axis)
101
103
  * @returns New offset line
102
104
  */
103
- offset(distance: number, normal: Vec3 = Vec3.Z): Line {
104
- ensureInit();
105
- const r = wasm.line_offset(
106
- this.start.x, this.start.y, this.start.z,
107
- this.end.x, this.end.y, this.end.z,
105
+ offset(distance: number, normal: Vec3 = Vec3.Z): Line {
106
+ ensureInit();
107
+ const r = wasm.line_offset(
108
+ this.start.x, this.start.y, this.start.z,
109
+ this.end.x, this.end.y, this.end.z,
108
110
  distance,
109
111
  normal.x, normal.y, normal.z,
110
112
  );
111
113
  return new Line(
112
114
  new Point(r[0], r[1], r[2]),
113
- new Point(r[3], r[4], r[5]),
114
- );
115
- }
116
-
117
- /**
118
- * Project this line onto a plane.
119
- * @param plane - Target plane
120
- * @param direction - Optional projection direction (default: perpendicular to plane)
115
+ new Point(r[3], r[4], r[5]),
116
+ );
117
+ }
118
+
119
+ /**
120
+ * Thicken this line into a closed PolyCurve suitable for extrusion.
121
+ * When `bothSides` is false, the source line forms one side of the result.
122
+ * When true, the thickness is added on each side of the line.
123
+ *
124
+ * If `normal` is omitted, the kernel will infer a stable fallback plane.
125
+ */
126
+ thicken(
127
+ distance: number,
128
+ bothSides = false,
129
+ normal?: Vec3,
130
+ options: CurveOffsetOptions = {},
131
+ ): PolyCurve {
132
+ return new Polyline([this.start, this.end]).thicken(distance, bothSides, normal, options);
133
+ }
134
+
135
+ /**
136
+ * Project this line onto a plane.
137
+ * @param plane - Target plane
138
+ * @param direction - Optional projection direction (default: perpendicular to plane)
121
139
  * @returns New projected line
122
140
  */
123
141
  projectOntoPlane(plane: Plane, direction?: Vec3): Line {