okgeometry-api 1.1.23 → 1.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/dist/Mesh.d.ts +52 -0
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +260 -0
- package/dist/Mesh.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/wasm-base64.d.ts +1 -1
- package/dist/wasm-base64.d.ts.map +1 -1
- package/dist/wasm-base64.js +1 -1
- package/dist/wasm-base64.js.map +1 -1
- package/dist/wasm-bindings.d.ts +40 -0
- package/dist/wasm-bindings.d.ts.map +1 -1
- package/dist/wasm-bindings.js +80 -0
- package/dist/wasm-bindings.js.map +1 -1
- package/package.json +1 -1
- package/src/Mesh.ts +872 -483
- package/src/NurbsCurve.ts +45 -45
- package/src/index.ts +4 -0
- package/src/wasm-base64.ts +1 -1
- package/src/wasm-bindings.d.ts +12 -0
- package/src/wasm-bindings.js +84 -0
package/src/NurbsCurve.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ensureInit } from "./engine.js";
|
|
2
2
|
import { Point } from "./Point.js";
|
|
3
|
-
import { Vec3 } from "./Vec3.js";
|
|
4
|
-
import { Plane } from "./Plane.js";
|
|
5
|
-
import { Mesh } from "./Mesh.js";
|
|
6
|
-
import { Polyline } from "./Polyline.js";
|
|
7
|
-
import type { Line } from "./Line.js";
|
|
8
|
-
import type { Arc } from "./Arc.js";
|
|
9
|
-
import type { RotationAxis } from "./types.js";
|
|
10
|
-
import * as wasm from "./wasm-bindings.js";
|
|
3
|
+
import { Vec3 } from "./Vec3.js";
|
|
4
|
+
import { Plane } from "./Plane.js";
|
|
5
|
+
import { Mesh } from "./Mesh.js";
|
|
6
|
+
import { Polyline } from "./Polyline.js";
|
|
7
|
+
import type { Line } from "./Line.js";
|
|
8
|
+
import type { Arc } from "./Arc.js";
|
|
9
|
+
import type { RotationAxis } from "./types.js";
|
|
10
|
+
import * as wasm from "./wasm-bindings.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Non-Uniform Rational B-Spline (NURBS) curve backed by WASM.
|
|
@@ -50,24 +50,24 @@ export class NurbsCurve {
|
|
|
50
50
|
* @param n - Number of points to generate
|
|
51
51
|
* @returns Array of n points along the curve
|
|
52
52
|
*/
|
|
53
|
-
sample(n: number): Point[] {
|
|
54
|
-
ensureInit();
|
|
55
|
-
const buf = wasm.sample_nurbs_curve(this._data, n);
|
|
56
|
-
const pts: Point[] = [];
|
|
57
|
-
for (let i = 0; i < buf.length; i += 3) {
|
|
58
|
-
pts.push(new Point(buf[i], buf[i + 1], buf[i + 2]));
|
|
59
|
-
}
|
|
60
|
-
return pts;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Check if this NURBS curve is closed.
|
|
65
|
-
* @param eps - Tolerance for comparing start and end points
|
|
66
|
-
* @returns True if the curve closes on itself
|
|
67
|
-
*/
|
|
68
|
-
isClosed(eps = 1e-10): boolean {
|
|
69
|
-
return this.pointAt(0).equals(this.pointAt(1), eps);
|
|
70
|
-
}
|
|
53
|
+
sample(n: number): Point[] {
|
|
54
|
+
ensureInit();
|
|
55
|
+
const buf = wasm.sample_nurbs_curve(this._data, n);
|
|
56
|
+
const pts: Point[] = [];
|
|
57
|
+
for (let i = 0; i < buf.length; i += 3) {
|
|
58
|
+
pts.push(new Point(buf[i], buf[i + 1], buf[i + 2]));
|
|
59
|
+
}
|
|
60
|
+
return pts;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Check if this NURBS curve is closed.
|
|
65
|
+
* @param eps - Tolerance for comparing start and end points
|
|
66
|
+
* @returns True if the curve closes on itself
|
|
67
|
+
*/
|
|
68
|
+
isClosed(eps = 1e-10): boolean {
|
|
69
|
+
return this.pointAt(0).equals(this.pointAt(1), eps);
|
|
70
|
+
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* Find intersection points with a plane.
|
|
@@ -162,25 +162,25 @@ export class NurbsCurve {
|
|
|
162
162
|
* @param samples - Number of sample points (default 64)
|
|
163
163
|
* @returns Offset polyline approximation
|
|
164
164
|
*/
|
|
165
|
-
offset(distance: number, normal?: Vec3, samples = 64): Polyline {
|
|
166
|
-
const pts = this.sample(samples);
|
|
167
|
-
const pl = new Polyline(pts);
|
|
168
|
-
return pl.offset(distance, normal);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Extrude this closed NURBS curve into a trusted solid suitable for booleans.
|
|
173
|
-
* @param direction - Extrusion direction and magnitude
|
|
174
|
-
* @param segments - Number of curve samples used for tessellation (default 64)
|
|
175
|
-
* @returns Closed mesh solid ready for boolean operations
|
|
176
|
-
*/
|
|
177
|
-
extrudeAsSolid(direction: Vec3, segments = 64): Mesh {
|
|
178
|
-
return Mesh.extrudeCurveAsSolid(this, direction, segments);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Decode a NurbsCurve from WASM flat buffer.
|
|
183
|
-
* @param data - Buffer in format [degree, num_cp, xyz..., w..., k...]
|
|
165
|
+
offset(distance: number, normal?: Vec3, samples = 64): Polyline {
|
|
166
|
+
const pts = this.sample(samples);
|
|
167
|
+
const pl = new Polyline(pts);
|
|
168
|
+
return pl.offset(distance, normal);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Extrude this closed NURBS curve into a trusted solid suitable for booleans.
|
|
173
|
+
* @param direction - Extrusion direction and magnitude
|
|
174
|
+
* @param segments - Number of curve samples used for tessellation (default 64)
|
|
175
|
+
* @returns Closed mesh solid ready for boolean operations
|
|
176
|
+
*/
|
|
177
|
+
extrudeAsSolid(direction: Vec3, segments = 64): Mesh {
|
|
178
|
+
return Mesh.extrudeCurveAsSolid(this, direction, segments);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Decode a NurbsCurve from WASM flat buffer.
|
|
183
|
+
* @param data - Buffer in format [degree, num_cp, xyz..., w..., k...]
|
|
184
184
|
* @returns New NurbsCurve instance
|
|
185
185
|
*/
|
|
186
186
|
static fromData(data: Float64Array | number[]): NurbsCurve {
|
package/src/index.ts
CHANGED