okgeometry-api 0.2.16 → 0.2.17

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.
@@ -1,9 +1,1385 @@
1
1
  /* @ts-self-types="./okgeometrycore.d.ts" */
2
2
 
3
- import * as wasm from "./okgeometrycore_bg.wasm";
4
- import { __wbg_set_wasm } from "./okgeometrycore_bg.js";
5
- __wbg_set_wasm(wasm);
6
- wasm.__wbindgen_start();
7
- export {
8
- arc_length, arc_point_at, chamfer_polycurve, circle_length, circle_point_at, create_arc, create_circle, create_line, create_polyline, curve_to_points, evaluate_nurbs_curve_at, extrude_circle, extrude_line, extrude_polyline, fillet_polycurve, line_length, line_point_at, line_tangent, loft_circles, loft_nurbs_surface, loft_polylines, make_nurbs_curves_compatible, mesh_apply_matrix, mesh_boolean_intersection, mesh_boolean_operation, mesh_boolean_subtraction, mesh_boolean_union, mesh_boundary_polylines, mesh_chamfer_all_edges, mesh_create_box, mesh_create_cone, mesh_create_cylinder, mesh_create_prism, mesh_create_sphere, mesh_evaluate, mesh_export_obj, mesh_get_stats, mesh_import_obj, mesh_mesh_intersect, mesh_patch_from_points, mesh_plane_intersect, mesh_rotate, mesh_scale, mesh_translate, nurbs_curve_curve_intersect, nurbs_curve_plane_intersect, nurbs_surface_evaluate, nurbs_surface_plane_intersect, nurbs_surface_surface_intersect, offset_polyline_curve, polycurve_to_nurbs, polyline_length, polyline_point_at, ray_closest_point, ray_closest_point_parameter, ray_distance_to_point, ray_point_at, sample_nurbs_curve, sweep_curves, sweep_polylines, tessellate_nurbs_surface, test_wasm, version
9
- } from "./okgeometrycore_bg.js";
3
+ /**
4
+ * Get the length of an arc.
5
+ * @param {number} radius
6
+ * @param {number} start_angle
7
+ * @param {number} end_angle
8
+ * @returns {number}
9
+ */
10
+ export function arc_length(radius, start_angle, end_angle) {
11
+ const ret = wasm.arc_length(radius, start_angle, end_angle);
12
+ return ret;
13
+ }
14
+
15
+ /**
16
+ * Evaluate a point on an arc at parameter t ∈ [0,1].
17
+ * Returns [x, y, z].
18
+ * @param {number} cx
19
+ * @param {number} cy
20
+ * @param {number} cz
21
+ * @param {number} nx
22
+ * @param {number} ny
23
+ * @param {number} nz
24
+ * @param {number} radius
25
+ * @param {number} start_angle
26
+ * @param {number} end_angle
27
+ * @param {number} t
28
+ * @returns {Float64Array}
29
+ */
30
+ export function arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, t) {
31
+ const ret = wasm.arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, t);
32
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
33
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
34
+ return v1;
35
+ }
36
+
37
+ /**
38
+ * Chamfer corners of a polyline by cutting each corner with a straight segment.
39
+ * Input: flat coords [x1,y1,z1, ...], distance from corner to cut.
40
+ * Output: encoded polycurve segments [segment_count, type, ...data, ...]
41
+ * type 0 = Line: [sx,sy,sz, ex,ey,ez]
42
+ * @param {Float64Array} coords
43
+ * @param {number} distance
44
+ * @returns {Float64Array}
45
+ */
46
+ export function chamfer_polycurve(coords, distance) {
47
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
48
+ const len0 = WASM_VECTOR_LEN;
49
+ const ret = wasm.chamfer_polycurve(ptr0, len0, distance);
50
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
51
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
52
+ return v2;
53
+ }
54
+
55
+ /**
56
+ * Get the circumference of a circle.
57
+ * @param {number} radius
58
+ * @returns {number}
59
+ */
60
+ export function circle_length(radius) {
61
+ const ret = wasm.circle_length(radius);
62
+ return ret;
63
+ }
64
+
65
+ /**
66
+ * Evaluate a point on a circle at parameter t ∈ [0,1].
67
+ * Returns [x, y, z].
68
+ * @param {number} cx
69
+ * @param {number} cy
70
+ * @param {number} cz
71
+ * @param {number} nx
72
+ * @param {number} ny
73
+ * @param {number} nz
74
+ * @param {number} radius
75
+ * @param {number} t
76
+ * @returns {Float64Array}
77
+ */
78
+ export function circle_point_at(cx, cy, cz, nx, ny, nz, radius, t) {
79
+ const ret = wasm.circle_point_at(cx, cy, cz, nx, ny, nz, radius, t);
80
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
81
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
82
+ return v1;
83
+ }
84
+
85
+ /**
86
+ * Create an arc and return sampled points
87
+ * @param {number} cx
88
+ * @param {number} cy
89
+ * @param {number} cz
90
+ * @param {number} nx
91
+ * @param {number} ny
92
+ * @param {number} nz
93
+ * @param {number} radius
94
+ * @param {number} start_angle
95
+ * @param {number} end_angle
96
+ * @param {number} samples
97
+ * @returns {Float64Array}
98
+ */
99
+ export function create_arc(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, samples) {
100
+ const ret = wasm.create_arc(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, samples);
101
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
102
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
103
+ return v1;
104
+ }
105
+
106
+ /**
107
+ * Create a circle and return sampled points
108
+ * @param {number} cx
109
+ * @param {number} cy
110
+ * @param {number} cz
111
+ * @param {number} nx
112
+ * @param {number} ny
113
+ * @param {number} nz
114
+ * @param {number} radius
115
+ * @param {number} samples
116
+ * @returns {Float64Array}
117
+ */
118
+ export function create_circle(cx, cy, cz, nx, ny, nz, radius, samples) {
119
+ const ret = wasm.create_circle(cx, cy, cz, nx, ny, nz, radius, samples);
120
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
121
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
122
+ return v1;
123
+ }
124
+
125
+ /**
126
+ * Create a line segment and return sampled points
127
+ * @param {number} x1
128
+ * @param {number} y1
129
+ * @param {number} z1
130
+ * @param {number} x2
131
+ * @param {number} y2
132
+ * @param {number} z2
133
+ * @param {number} samples
134
+ * @returns {Float64Array}
135
+ */
136
+ export function create_line(x1, y1, z1, x2, y2, z2, samples) {
137
+ const ret = wasm.create_line(x1, y1, z1, x2, y2, z2, samples);
138
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
139
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
140
+ return v1;
141
+ }
142
+
143
+ /**
144
+ * Create a polyline and return the points
145
+ * @param {Float64Array} coords
146
+ * @param {number} samples_per_segment
147
+ * @returns {Float64Array}
148
+ */
149
+ export function create_polyline(coords, samples_per_segment) {
150
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
151
+ const len0 = WASM_VECTOR_LEN;
152
+ const ret = wasm.create_polyline(ptr0, len0, samples_per_segment);
153
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
154
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
155
+ return v2;
156
+ }
157
+
158
+ /**
159
+ * Serialize a curve to a list of points for Three.js rendering
160
+ * Returns a flat array of coordinates: [x1, y1, z1, x2, y2, z2, ...]
161
+ * @param {string} curve_type
162
+ * @param {Float64Array} params
163
+ * @param {number} samples
164
+ * @returns {Float64Array}
165
+ */
166
+ export function curve_to_points(curve_type, params, samples) {
167
+ const ptr0 = passStringToWasm0(curve_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
168
+ const len0 = WASM_VECTOR_LEN;
169
+ const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
170
+ const len1 = WASM_VECTOR_LEN;
171
+ const ret = wasm.curve_to_points(ptr0, len0, ptr1, len1, samples);
172
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
173
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
174
+ return v3;
175
+ }
176
+
177
+ /**
178
+ * Evaluate a NURBS curve at normalized parameter t in [0,1].
179
+ * Returns [x, y, z].
180
+ * @param {Float64Array} data
181
+ * @param {number} t
182
+ * @returns {Float64Array}
183
+ */
184
+ export function evaluate_nurbs_curve_at(data, t) {
185
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
186
+ const len0 = WASM_VECTOR_LEN;
187
+ const ret = wasm.evaluate_nurbs_curve_at(ptr0, len0, t);
188
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
189
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
190
+ return v2;
191
+ }
192
+
193
+ /**
194
+ * Extrude a circle and return mesh buffers
195
+ * @param {number} cx
196
+ * @param {number} cy
197
+ * @param {number} cz
198
+ * @param {number} nx
199
+ * @param {number} ny
200
+ * @param {number} nz
201
+ * @param {number} radius
202
+ * @param {number} dx
203
+ * @param {number} dy
204
+ * @param {number} dz
205
+ * @param {number} segments
206
+ * @param {boolean} with_caps
207
+ * @returns {Float64Array}
208
+ */
209
+ export function extrude_circle(cx, cy, cz, nx, ny, nz, radius, dx, dy, dz, segments, with_caps) {
210
+ const ret = wasm.extrude_circle(cx, cy, cz, nx, ny, nz, radius, dx, dy, dz, segments, with_caps);
211
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
212
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
213
+ return v1;
214
+ }
215
+
216
+ /**
217
+ * Extrude a line segment and return mesh buffers
218
+ * @param {number} x1
219
+ * @param {number} y1
220
+ * @param {number} z1
221
+ * @param {number} x2
222
+ * @param {number} y2
223
+ * @param {number} z2
224
+ * @param {number} dx
225
+ * @param {number} dy
226
+ * @param {number} dz
227
+ * @param {number} segments
228
+ * @returns {Float64Array}
229
+ */
230
+ export function extrude_line(x1, y1, z1, x2, y2, z2, dx, dy, dz, segments) {
231
+ const ret = wasm.extrude_line(x1, y1, z1, x2, y2, z2, dx, dy, dz, segments);
232
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
233
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
234
+ return v1;
235
+ }
236
+
237
+ /**
238
+ * Extrude a polyline and return mesh buffers.
239
+ * Uses the polyline's actual vertices (no resampling) to preserve sharp corners.
240
+ * @param {Float64Array} coords
241
+ * @param {number} dx
242
+ * @param {number} dy
243
+ * @param {number} dz
244
+ * @param {number} _segments
245
+ * @param {boolean} with_caps
246
+ * @returns {Float64Array}
247
+ */
248
+ export function extrude_polyline(coords, dx, dy, dz, _segments, with_caps) {
249
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
250
+ const len0 = WASM_VECTOR_LEN;
251
+ const ret = wasm.extrude_polyline(ptr0, len0, dx, dy, dz, _segments, with_caps);
252
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
253
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
254
+ return v2;
255
+ }
256
+
257
+ /**
258
+ * Fillet corners of a polyline with arcs of a given radius.
259
+ * Input: flat coords [x1,y1,z1, ...], radius, plane normal (nx,ny,nz; 0,0,0 for auto).
260
+ * Output: encoded polycurve segments [segment_count, type, ...data, type, ...data, ...]
261
+ * type 0 = Line: [sx,sy,sz, ex,ey,ez]
262
+ * type 1 = Arc: [cx,cy,cz, nx,ny,nz, radius, start_angle, end_angle]
263
+ * @param {Float64Array} coords
264
+ * @param {number} radius
265
+ * @param {number} nx
266
+ * @param {number} ny
267
+ * @param {number} nz
268
+ * @returns {Float64Array}
269
+ */
270
+ export function fillet_polycurve(coords, radius, nx, ny, nz) {
271
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ const ret = wasm.fillet_polycurve(ptr0, len0, radius, nx, ny, nz);
274
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
275
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
276
+ return v2;
277
+ }
278
+
279
+ /**
280
+ * Get the length of a line segment.
281
+ * @param {number} x1
282
+ * @param {number} y1
283
+ * @param {number} z1
284
+ * @param {number} x2
285
+ * @param {number} y2
286
+ * @param {number} z2
287
+ * @returns {number}
288
+ */
289
+ export function line_length(x1, y1, z1, x2, y2, z2) {
290
+ const ret = wasm.line_length(x1, y1, z1, x2, y2, z2);
291
+ return ret;
292
+ }
293
+
294
+ /**
295
+ * Evaluate a point on a line segment at parameter t ∈ [0,1].
296
+ * Returns [x, y, z].
297
+ * @param {number} x1
298
+ * @param {number} y1
299
+ * @param {number} z1
300
+ * @param {number} x2
301
+ * @param {number} y2
302
+ * @param {number} z2
303
+ * @param {number} t
304
+ * @returns {Float64Array}
305
+ */
306
+ export function line_point_at(x1, y1, z1, x2, y2, z2, t) {
307
+ const ret = wasm.line_point_at(x1, y1, z1, x2, y2, z2, t);
308
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
309
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
310
+ return v1;
311
+ }
312
+
313
+ /**
314
+ * Get the tangent direction of a line segment. Returns [x, y, z].
315
+ * @param {number} x1
316
+ * @param {number} y1
317
+ * @param {number} z1
318
+ * @param {number} x2
319
+ * @param {number} y2
320
+ * @param {number} z2
321
+ * @returns {Float64Array}
322
+ */
323
+ export function line_tangent(x1, y1, z1, x2, y2, z2) {
324
+ const ret = wasm.line_tangent(x1, y1, z1, x2, y2, z2);
325
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
326
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
327
+ return v1;
328
+ }
329
+
330
+ /**
331
+ * Loft between multiple circles
332
+ *
333
+ * # Parameters
334
+ * * `circle_data` - Flat array of circle definitions [cx, cy, cz, nx, ny, nz, radius, ...]
335
+ * * `segments` - Number of segments to sample along each curve
336
+ * * `with_caps` - Whether to create end caps
337
+ *
338
+ * # Returns
339
+ * Mesh buffers for the lofted surface
340
+ * @param {Float64Array} circle_data
341
+ * @param {number} segments
342
+ * @param {boolean} with_caps
343
+ * @returns {Float64Array}
344
+ */
345
+ export function loft_circles(circle_data, segments, with_caps) {
346
+ const ptr0 = passArrayF64ToWasm0(circle_data, wasm.__wbindgen_malloc);
347
+ const len0 = WASM_VECTOR_LEN;
348
+ const ret = wasm.loft_circles(ptr0, len0, segments, with_caps);
349
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
350
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
351
+ return v2;
352
+ }
353
+
354
+ /**
355
+ * Loft a NURBS surface through multiple NURBS curves.
356
+ * Input: [num_curves, degree_v, curve1_data..., curve2_data..., ...]
357
+ * Each curve_data: [degree, num_pts, x,y,z,..., w0,w1,..., k0,k1,...]
358
+ * Returns the NurbsSurface data (same format as tessellate input, without u_segs/v_segs).
359
+ * @param {Float64Array} data
360
+ * @returns {Float64Array}
361
+ */
362
+ export function loft_nurbs_surface(data) {
363
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
364
+ const len0 = WASM_VECTOR_LEN;
365
+ const ret = wasm.loft_nurbs_surface(ptr0, len0);
366
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
367
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
368
+ return v2;
369
+ }
370
+
371
+ /**
372
+ * Loft between multiple polylines
373
+ *
374
+ * # Parameters
375
+ * * `polyline_data` - Flat array where each polyline is prefixed by its point count:
376
+ * [count1, x1, y1, z1, x2, y2, z2, ..., count2, x1, y1, z1, ...]
377
+ * * `_segments` - Ignored for polylines (kept for API compat). Points are used directly.
378
+ * * `with_caps` - Whether to create end caps (fan triangulation from center)
379
+ *
380
+ * # Returns
381
+ * Mesh buffers for the lofted surface
382
+ * @param {Float64Array} polyline_data
383
+ * @param {number} _segments
384
+ * @param {boolean} with_caps
385
+ * @returns {Float64Array}
386
+ */
387
+ export function loft_polylines(polyline_data, _segments, with_caps) {
388
+ const ptr0 = passArrayF64ToWasm0(polyline_data, wasm.__wbindgen_malloc);
389
+ const len0 = WASM_VECTOR_LEN;
390
+ const ret = wasm.loft_polylines(ptr0, len0, _segments, with_caps);
391
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
392
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
393
+ return v2;
394
+ }
395
+
396
+ /**
397
+ * Make multiple NURBS curves compatible (same knot vectors, same CP count).
398
+ * Input: [curve_count, curve1_data..., curve2_data..., ...]
399
+ * Each curve: [degree, num_cp, cp_xyz..., weights..., knots...]
400
+ * Output: same format with unified curves.
401
+ * @param {Float64Array} curves_data
402
+ * @returns {Float64Array}
403
+ */
404
+ export function make_nurbs_curves_compatible(curves_data) {
405
+ const ptr0 = passArrayF64ToWasm0(curves_data, wasm.__wbindgen_malloc);
406
+ const len0 = WASM_VECTOR_LEN;
407
+ const ret = wasm.make_nurbs_curves_compatible(ptr0, len0);
408
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
409
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
410
+ return v2;
411
+ }
412
+
413
+ /**
414
+ * Apply a 4x4 transformation matrix to a mesh.
415
+ * matrix: flat [m00,m01,m02,m03, m10,m11,..., m30,m31,m32,m33] (16 elements, row-major)
416
+ * @param {number} vertex_count
417
+ * @param {Float64Array} buffer
418
+ * @param {Float64Array} matrix
419
+ * @returns {Float64Array}
420
+ */
421
+ export function mesh_apply_matrix(vertex_count, buffer, matrix) {
422
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
423
+ const len0 = WASM_VECTOR_LEN;
424
+ const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
425
+ const len1 = WASM_VECTOR_LEN;
426
+ const ret = wasm.mesh_apply_matrix(vertex_count, ptr0, len0, ptr1, len1);
427
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
428
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
429
+ return v3;
430
+ }
431
+
432
+ /**
433
+ * Perform boolean intersection on two meshes
434
+ * @param {number} vertex_count_a
435
+ * @param {Float64Array} buffer_a
436
+ * @param {number} vertex_count_b
437
+ * @param {Float64Array} buffer_b
438
+ * @returns {Float64Array}
439
+ */
440
+ export function mesh_boolean_intersection(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
441
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
442
+ const len0 = WASM_VECTOR_LEN;
443
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
444
+ const len1 = WASM_VECTOR_LEN;
445
+ const ret = wasm.mesh_boolean_intersection(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
446
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
447
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
448
+ return v3;
449
+ }
450
+
451
+ /**
452
+ * Perform boolean operation on two meshes
453
+ *
454
+ * # Parameters
455
+ * * `vertex_count_a` - Number of vertices in mesh A
456
+ * * `buffer_a` - Buffer for mesh A [vertices..., indices...]
457
+ * * `vertex_count_b` - Number of vertices in mesh B
458
+ * * `buffer_b` - Buffer for mesh B [vertices..., indices...]
459
+ * * `operation` - Operation type: "union", "intersection", or "subtraction"
460
+ *
461
+ * # Returns
462
+ * Result mesh buffer [vertices..., indices...]
463
+ * @param {number} vertex_count_a
464
+ * @param {Float64Array} buffer_a
465
+ * @param {number} vertex_count_b
466
+ * @param {Float64Array} buffer_b
467
+ * @param {string} operation
468
+ * @returns {Float64Array}
469
+ */
470
+ export function mesh_boolean_operation(vertex_count_a, buffer_a, vertex_count_b, buffer_b, operation) {
471
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
472
+ const len0 = WASM_VECTOR_LEN;
473
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
474
+ const len1 = WASM_VECTOR_LEN;
475
+ const ptr2 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
476
+ const len2 = WASM_VECTOR_LEN;
477
+ const ret = wasm.mesh_boolean_operation(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1, ptr2, len2);
478
+ var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
479
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
480
+ return v4;
481
+ }
482
+
483
+ /**
484
+ * Perform boolean subtraction on two meshes (A - B)
485
+ * @param {number} vertex_count_a
486
+ * @param {Float64Array} buffer_a
487
+ * @param {number} vertex_count_b
488
+ * @param {Float64Array} buffer_b
489
+ * @returns {Float64Array}
490
+ */
491
+ export function mesh_boolean_subtraction(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
492
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
493
+ const len0 = WASM_VECTOR_LEN;
494
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
495
+ const len1 = WASM_VECTOR_LEN;
496
+ const ret = wasm.mesh_boolean_subtraction(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
497
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
498
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
499
+ return v3;
500
+ }
501
+
502
+ /**
503
+ * Perform boolean union on two meshes
504
+ * @param {number} vertex_count_a
505
+ * @param {Float64Array} buffer_a
506
+ * @param {number} vertex_count_b
507
+ * @param {Float64Array} buffer_b
508
+ * @returns {Float64Array}
509
+ */
510
+ export function mesh_boolean_union(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
511
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
512
+ const len0 = WASM_VECTOR_LEN;
513
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
514
+ const len1 = WASM_VECTOR_LEN;
515
+ const ret = wasm.mesh_boolean_union(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
516
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
517
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
518
+ return v3;
519
+ }
520
+
521
+ /**
522
+ * Extract boundary (perimeter) edges from a mesh as polylines.
523
+ * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
524
+ * @param {number} vertex_count
525
+ * @param {Float64Array} buffer
526
+ * @returns {Float64Array}
527
+ */
528
+ export function mesh_boundary_polylines(vertex_count, buffer) {
529
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
530
+ const len0 = WASM_VECTOR_LEN;
531
+ const ret = wasm.mesh_boundary_polylines(vertex_count, ptr0, len0);
532
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
533
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
534
+ return v2;
535
+ }
536
+
537
+ /**
538
+ * Chamfer all edges of a primitive mesh (flat bevel)
539
+ *
540
+ * # Arguments
541
+ * * `mesh_type` - "box", "cylinder", or "prism"
542
+ * * `params` - Parameters: [width,height,depth] for box, [radius,height,segments] for cylinder/prism
543
+ * * `offset` - Chamfer offset distance
544
+ *
545
+ * # Returns
546
+ * Result mesh buffer [vertexCount, vertices..., indices...]
547
+ * @param {string} mesh_type
548
+ * @param {Float64Array} params
549
+ * @param {number} offset
550
+ * @returns {Float64Array}
551
+ */
552
+ export function mesh_chamfer_all_edges(mesh_type, params, offset) {
553
+ const ptr0 = passStringToWasm0(mesh_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
554
+ const len0 = WASM_VECTOR_LEN;
555
+ const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
556
+ const len1 = WASM_VECTOR_LEN;
557
+ const ret = wasm.mesh_chamfer_all_edges(ptr0, len0, ptr1, len1, offset);
558
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
559
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
560
+ return v3;
561
+ }
562
+
563
+ /**
564
+ * Create a box mesh and return buffers
565
+ * Returns [vertices..., indices...]
566
+ * @param {number} width
567
+ * @param {number} height
568
+ * @param {number} depth
569
+ * @returns {Float64Array}
570
+ */
571
+ export function mesh_create_box(width, height, depth) {
572
+ const ret = wasm.mesh_create_box(width, height, depth);
573
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
574
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
575
+ return v1;
576
+ }
577
+
578
+ /**
579
+ * Create a cone mesh and return buffers
580
+ * @param {number} radius
581
+ * @param {number} height
582
+ * @param {number} segments
583
+ * @returns {Float64Array}
584
+ */
585
+ export function mesh_create_cone(radius, height, segments) {
586
+ const ret = wasm.mesh_create_cone(radius, height, segments);
587
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
588
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
589
+ return v1;
590
+ }
591
+
592
+ /**
593
+ * Create a cylinder mesh and return buffers
594
+ * @param {number} radius
595
+ * @param {number} height
596
+ * @param {number} segments
597
+ * @returns {Float64Array}
598
+ */
599
+ export function mesh_create_cylinder(radius, height, segments) {
600
+ const ret = wasm.mesh_create_cylinder(radius, height, segments);
601
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
602
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
603
+ return v1;
604
+ }
605
+
606
+ /**
607
+ * Create a prism mesh and return buffers
608
+ * @param {number} radius
609
+ * @param {number} height
610
+ * @param {number} sides
611
+ * @returns {Float64Array}
612
+ */
613
+ export function mesh_create_prism(radius, height, sides) {
614
+ const ret = wasm.mesh_create_prism(radius, height, sides);
615
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
616
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
617
+ return v1;
618
+ }
619
+
620
+ /**
621
+ * Create a sphere mesh and return buffers
622
+ * @param {number} radius
623
+ * @param {number} segments
624
+ * @param {number} rings
625
+ * @returns {Float64Array}
626
+ */
627
+ export function mesh_create_sphere(radius, segments, rings) {
628
+ const ret = wasm.mesh_create_sphere(radius, segments, rings);
629
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
630
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
631
+ return v1;
632
+ }
633
+
634
+ /**
635
+ * Evaluate a point on a mesh surface at parametric coordinates (u, v).
636
+ * Maps u ∈ [0,1] and v ∈ [0,1] to the mesh's AABB bounding box,
637
+ * then casts a ray perpendicular to the best-fit projection plane.
638
+ * Returns [x, y, z] of the intersection point, or [NaN, NaN, NaN] if no hit.
639
+ * @param {number} vertex_count
640
+ * @param {Float64Array} buffer
641
+ * @param {number} u
642
+ * @param {number} v
643
+ * @returns {Float64Array}
644
+ */
645
+ export function mesh_evaluate(vertex_count, buffer, u, v) {
646
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
647
+ const len0 = WASM_VECTOR_LEN;
648
+ const ret = wasm.mesh_evaluate(vertex_count, ptr0, len0, u, v);
649
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
650
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
651
+ return v2;
652
+ }
653
+
654
+ /**
655
+ * Export a mesh to OBJ format
656
+ * Takes mesh buffers as input (same format as mesh_to_buffers output)
657
+ * Returns OBJ string
658
+ * @param {number} vertex_count
659
+ * @param {Float64Array} buffer
660
+ * @returns {string}
661
+ */
662
+ export function mesh_export_obj(vertex_count, buffer) {
663
+ let deferred2_0;
664
+ let deferred2_1;
665
+ try {
666
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
667
+ const len0 = WASM_VECTOR_LEN;
668
+ const ret = wasm.mesh_export_obj(vertex_count, ptr0, len0);
669
+ deferred2_0 = ret[0];
670
+ deferred2_1 = ret[1];
671
+ return getStringFromWasm0(ret[0], ret[1]);
672
+ } finally {
673
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
674
+ }
675
+ }
676
+
677
+ /**
678
+ * Get mesh statistics
679
+ * Returns [vertex_count, face_count, edge_count]
680
+ * @param {number} vertex_count
681
+ * @param {Float64Array} buffer
682
+ * @returns {Float64Array}
683
+ */
684
+ export function mesh_get_stats(vertex_count, buffer) {
685
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
686
+ const len0 = WASM_VECTOR_LEN;
687
+ const ret = wasm.mesh_get_stats(vertex_count, ptr0, len0);
688
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
689
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
690
+ return v2;
691
+ }
692
+
693
+ /**
694
+ * Import OBJ data and return mesh buffers
695
+ * @param {string} obj_data
696
+ * @returns {Float64Array}
697
+ */
698
+ export function mesh_import_obj(obj_data) {
699
+ const ptr0 = passStringToWasm0(obj_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
700
+ const len0 = WASM_VECTOR_LEN;
701
+ const ret = wasm.mesh_import_obj(ptr0, len0);
702
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
703
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
704
+ return v2;
705
+ }
706
+
707
+ /**
708
+ * Intersect two meshes, returning intersection polyline points.
709
+ * Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
710
+ * @param {number} va_count
711
+ * @param {Float64Array} buffer_a
712
+ * @param {number} vb_count
713
+ * @param {Float64Array} buffer_b
714
+ * @returns {Float64Array}
715
+ */
716
+ export function mesh_mesh_intersect(va_count, buffer_a, vb_count, buffer_b) {
717
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
718
+ const len0 = WASM_VECTOR_LEN;
719
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
720
+ const len1 = WASM_VECTOR_LEN;
721
+ const ret = wasm.mesh_mesh_intersect(va_count, ptr0, len0, vb_count, ptr1, len1);
722
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
723
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
724
+ return v3;
725
+ }
726
+
727
+ /**
728
+ * Create a planar patch mesh from boundary points using CDT.
729
+ * Correctly handles concave polygons (unlike fan triangulation).
730
+ * Input: flat coordinate array [x1,y1,z1, x2,y2,z2, ...]
731
+ * Output: mesh buffer [vertexCount, x1,y1,z1,..., i0,i1,i2, ...]
732
+ * @param {Float64Array} coords
733
+ * @returns {Float64Array}
734
+ */
735
+ export function mesh_patch_from_points(coords) {
736
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
737
+ const len0 = WASM_VECTOR_LEN;
738
+ const ret = wasm.mesh_patch_from_points(ptr0, len0);
739
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
740
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
741
+ return v2;
742
+ }
743
+
744
+ /**
745
+ * Intersect a mesh with a plane, returning polyline points.
746
+ * Input: vertex_count, mesh_buffer..., nx, ny, nz, d
747
+ * Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
748
+ * @param {number} vertex_count
749
+ * @param {Float64Array} buffer
750
+ * @param {number} nx
751
+ * @param {number} ny
752
+ * @param {number} nz
753
+ * @param {number} d
754
+ * @returns {Float64Array}
755
+ */
756
+ export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
757
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
758
+ const len0 = WASM_VECTOR_LEN;
759
+ const ret = wasm.mesh_plane_intersect(vertex_count, ptr0, len0, nx, ny, nz, d);
760
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
761
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
762
+ return v2;
763
+ }
764
+
765
+ /**
766
+ * Rotate a mesh around an arbitrary axis and return new buffers
767
+ * Axis is defined by (ax, ay, az), angle in radians
768
+ * @param {number} vertex_count
769
+ * @param {Float64Array} buffer
770
+ * @param {number} ax
771
+ * @param {number} ay
772
+ * @param {number} az
773
+ * @param {number} angle
774
+ * @returns {Float64Array}
775
+ */
776
+ export function mesh_rotate(vertex_count, buffer, ax, ay, az, angle) {
777
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
778
+ const len0 = WASM_VECTOR_LEN;
779
+ const ret = wasm.mesh_rotate(vertex_count, ptr0, len0, ax, ay, az, angle);
780
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
781
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
782
+ return v2;
783
+ }
784
+
785
+ /**
786
+ * Scale a mesh non-uniformly and return new buffers
787
+ * @param {number} vertex_count
788
+ * @param {Float64Array} buffer
789
+ * @param {number} sx
790
+ * @param {number} sy
791
+ * @param {number} sz
792
+ * @returns {Float64Array}
793
+ */
794
+ export function mesh_scale(vertex_count, buffer, sx, sy, sz) {
795
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
796
+ const len0 = WASM_VECTOR_LEN;
797
+ const ret = wasm.mesh_scale(vertex_count, ptr0, len0, sx, sy, sz);
798
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
799
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
800
+ return v2;
801
+ }
802
+
803
+ /**
804
+ * Translate a mesh by an offset vector and return new buffers
805
+ * @param {number} vertex_count
806
+ * @param {Float64Array} buffer
807
+ * @param {number} dx
808
+ * @param {number} dy
809
+ * @param {number} dz
810
+ * @returns {Float64Array}
811
+ */
812
+ export function mesh_translate(vertex_count, buffer, dx, dy, dz) {
813
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
814
+ const len0 = WASM_VECTOR_LEN;
815
+ const ret = wasm.mesh_translate(vertex_count, ptr0, len0, dx, dy, dz);
816
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
817
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
818
+ return v2;
819
+ }
820
+
821
+ /**
822
+ * Intersect two NURBS curves.
823
+ * Returns: [num_points, x,y,z, ...]
824
+ * @param {Float64Array} data_a
825
+ * @param {Float64Array} data_b
826
+ * @returns {Float64Array}
827
+ */
828
+ export function nurbs_curve_curve_intersect(data_a, data_b) {
829
+ const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
830
+ const len0 = WASM_VECTOR_LEN;
831
+ const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
832
+ const len1 = WASM_VECTOR_LEN;
833
+ const ret = wasm.nurbs_curve_curve_intersect(ptr0, len0, ptr1, len1);
834
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
835
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
836
+ return v3;
837
+ }
838
+
839
+ /**
840
+ * Intersect a NURBS curve with a plane.
841
+ * Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
842
+ * Returns: [num_points, x,y,z, x,y,z, ...]
843
+ * @param {Float64Array} data
844
+ * @param {number} nx
845
+ * @param {number} ny
846
+ * @param {number} nz
847
+ * @param {number} d
848
+ * @returns {Float64Array}
849
+ */
850
+ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
851
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
852
+ const len0 = WASM_VECTOR_LEN;
853
+ const ret = wasm.nurbs_curve_plane_intersect(ptr0, len0, nx, ny, nz, d);
854
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
855
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
856
+ return v2;
857
+ }
858
+
859
+ /**
860
+ * Evaluate a NURBS surface at (u, v) parameters.
861
+ * Input format: same as tessellate but last 2 values are u, v instead of u_segs, v_segs
862
+ * Returns [x, y, z]
863
+ * @param {Float64Array} data
864
+ * @param {number} u
865
+ * @param {number} v
866
+ * @returns {Float64Array}
867
+ */
868
+ export function nurbs_surface_evaluate(data, u, v) {
869
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
870
+ const len0 = WASM_VECTOR_LEN;
871
+ const ret = wasm.nurbs_surface_evaluate(ptr0, len0, u, v);
872
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
873
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
874
+ return v2;
875
+ }
876
+
877
+ /**
878
+ * Intersect a NURBS surface with a plane.
879
+ * Input: same surface format as tessellate_nurbs_surface, then plane (nx,ny,nz,d) appended.
880
+ * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
881
+ * @param {Float64Array} surface_data
882
+ * @param {number} nx
883
+ * @param {number} ny
884
+ * @param {number} nz
885
+ * @param {number} d
886
+ * @param {number} tess
887
+ * @returns {Float64Array}
888
+ */
889
+ export function nurbs_surface_plane_intersect(surface_data, nx, ny, nz, d, tess) {
890
+ const ptr0 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
891
+ const len0 = WASM_VECTOR_LEN;
892
+ const ret = wasm.nurbs_surface_plane_intersect(ptr0, len0, nx, ny, nz, d, tess);
893
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
894
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
895
+ return v2;
896
+ }
897
+
898
+ /**
899
+ * Intersect two NURBS surfaces.
900
+ * Returns polyline buffer.
901
+ * @param {Float64Array} data_a
902
+ * @param {Float64Array} data_b
903
+ * @param {number} tess
904
+ * @returns {Float64Array}
905
+ */
906
+ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
907
+ const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
908
+ const len0 = WASM_VECTOR_LEN;
909
+ const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
910
+ const len1 = WASM_VECTOR_LEN;
911
+ const ret = wasm.nurbs_surface_surface_intersect(ptr0, len0, ptr1, len1, tess);
912
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
913
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
914
+ return v3;
915
+ }
916
+
917
+ /**
918
+ * Offset a polyline by a distance in a given plane.
919
+ * If nx=ny=nz=0, the plane normal is auto-detected.
920
+ * Returns flat [x1,y1,z1, x2,y2,z2, ...] of the offset polyline.
921
+ * @param {Float64Array} coords
922
+ * @param {number} distance
923
+ * @param {number} nx
924
+ * @param {number} ny
925
+ * @param {number} nz
926
+ * @returns {Float64Array}
927
+ */
928
+ export function offset_polyline_curve(coords, distance, nx, ny, nz) {
929
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
930
+ const len0 = WASM_VECTOR_LEN;
931
+ const ret = wasm.offset_polyline_curve(ptr0, len0, distance, nx, ny, nz);
932
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
933
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
934
+ return v2;
935
+ }
936
+
937
+ /**
938
+ * Convert a polycurve (Line/Arc segments) to an exact NURBS curve.
939
+ * Input format: [segment_count, type1, ...data1..., type2, ...data2..., ...]
940
+ * type 0 = Line (6 floats: start_xyz, end_xyz)
941
+ * type 1 = Arc (9 floats: center_xyz, normal_xyz, radius, start_angle, end_angle)
942
+ * Output format: [degree, num_cp, cp_x1,y1,z1,..., w1,w2,..., k1,k2,...]
943
+ * @param {Float64Array} segment_data
944
+ * @returns {Float64Array}
945
+ */
946
+ export function polycurve_to_nurbs(segment_data) {
947
+ const ptr0 = passArrayF64ToWasm0(segment_data, wasm.__wbindgen_malloc);
948
+ const len0 = WASM_VECTOR_LEN;
949
+ const ret = wasm.polycurve_to_nurbs(ptr0, len0);
950
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
951
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
952
+ return v2;
953
+ }
954
+
955
+ /**
956
+ * Get the total length of a polyline.
957
+ * Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
958
+ * @param {Float64Array} coords
959
+ * @returns {number}
960
+ */
961
+ export function polyline_length(coords) {
962
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
963
+ const len0 = WASM_VECTOR_LEN;
964
+ const ret = wasm.polyline_length(ptr0, len0);
965
+ return ret;
966
+ }
967
+
968
+ /**
969
+ * Evaluate a point on a polyline at parameter t ∈ [0,1].
970
+ * Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
971
+ * Returns [x, y, z].
972
+ * @param {Float64Array} coords
973
+ * @param {number} t
974
+ * @returns {Float64Array}
975
+ */
976
+ export function polyline_point_at(coords, t) {
977
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
978
+ const len0 = WASM_VECTOR_LEN;
979
+ const ret = wasm.polyline_point_at(ptr0, len0, t);
980
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
981
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
982
+ return v2;
983
+ }
984
+
985
+ /**
986
+ * Find the closest point on a ray to a given point.
987
+ * Returns [x, y, z] of the closest point on the ray.
988
+ * @param {number} ox
989
+ * @param {number} oy
990
+ * @param {number} oz
991
+ * @param {number} dx
992
+ * @param {number} dy
993
+ * @param {number} dz
994
+ * @param {number} px
995
+ * @param {number} py
996
+ * @param {number} pz
997
+ * @returns {Float64Array}
998
+ */
999
+ export function ray_closest_point(ox, oy, oz, dx, dy, dz, px, py, pz) {
1000
+ const ret = wasm.ray_closest_point(ox, oy, oz, dx, dy, dz, px, py, pz);
1001
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1002
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1003
+ return v1;
1004
+ }
1005
+
1006
+ /**
1007
+ * Find the parameter t for the closest point on a ray to a given point.
1008
+ * The closest point is at: origin + t * direction
1009
+ * Note: t can be negative if the closest point is "behind" the ray origin.
1010
+ * @param {number} ox
1011
+ * @param {number} oy
1012
+ * @param {number} oz
1013
+ * @param {number} dx
1014
+ * @param {number} dy
1015
+ * @param {number} dz
1016
+ * @param {number} px
1017
+ * @param {number} py
1018
+ * @param {number} pz
1019
+ * @returns {number}
1020
+ */
1021
+ export function ray_closest_point_parameter(ox, oy, oz, dx, dy, dz, px, py, pz) {
1022
+ const ret = wasm.ray_closest_point_parameter(ox, oy, oz, dx, dy, dz, px, py, pz);
1023
+ return ret;
1024
+ }
1025
+
1026
+ /**
1027
+ * Compute the distance from a ray to a point.
1028
+ * Ray is defined by origin (ox, oy, oz) and direction (dx, dy, dz).
1029
+ * Direction should be normalized for accurate distance.
1030
+ * Returns the perpendicular distance from the ray to the point.
1031
+ * @param {number} ox
1032
+ * @param {number} oy
1033
+ * @param {number} oz
1034
+ * @param {number} dx
1035
+ * @param {number} dy
1036
+ * @param {number} dz
1037
+ * @param {number} px
1038
+ * @param {number} py
1039
+ * @param {number} pz
1040
+ * @returns {number}
1041
+ */
1042
+ export function ray_distance_to_point(ox, oy, oz, dx, dy, dz, px, py, pz) {
1043
+ const ret = wasm.ray_distance_to_point(ox, oy, oz, dx, dy, dz, px, py, pz);
1044
+ return ret;
1045
+ }
1046
+
1047
+ /**
1048
+ * Get a point along the ray at parameter t.
1049
+ * Returns [x, y, z] = origin + t * direction
1050
+ * @param {number} ox
1051
+ * @param {number} oy
1052
+ * @param {number} oz
1053
+ * @param {number} dx
1054
+ * @param {number} dy
1055
+ * @param {number} dz
1056
+ * @param {number} t
1057
+ * @returns {Float64Array}
1058
+ */
1059
+ export function ray_point_at(ox, oy, oz, dx, dy, dz, t) {
1060
+ const ret = wasm.ray_point_at(ox, oy, oz, dx, dy, dz, t);
1061
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1062
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1063
+ return v1;
1064
+ }
1065
+
1066
+ /**
1067
+ * Sample a NURBS curve.
1068
+ * Input: degree, then flat control points [x,y,z,...], then flat weights, then flat knots
1069
+ * Format: [degree, num_pts, x0,y0,z0, ..., w0,w1,..., k0,k1,...]
1070
+ * @param {Float64Array} data
1071
+ * @param {number} samples
1072
+ * @returns {Float64Array}
1073
+ */
1074
+ export function sample_nurbs_curve(data, samples) {
1075
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1076
+ const len0 = WASM_VECTOR_LEN;
1077
+ const ret = wasm.sample_nurbs_curve(ptr0, len0, samples);
1078
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1079
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1080
+ return v2;
1081
+ }
1082
+
1083
+ /**
1084
+ * Sweep a profile curve along a path curve using exact curve evaluation.
1085
+ * profile_data/path_data: encoded curve (see decode_curve)
1086
+ * Returns mesh buffers.
1087
+ * @param {Float64Array} profile_data
1088
+ * @param {Float64Array} path_data
1089
+ * @param {number} profile_segments
1090
+ * @param {number} path_segments
1091
+ * @param {boolean} with_caps
1092
+ * @returns {Float64Array}
1093
+ */
1094
+ export function sweep_curves(profile_data, path_data, profile_segments, path_segments, with_caps) {
1095
+ const ptr0 = passArrayF64ToWasm0(profile_data, wasm.__wbindgen_malloc);
1096
+ const len0 = WASM_VECTOR_LEN;
1097
+ const ptr1 = passArrayF64ToWasm0(path_data, wasm.__wbindgen_malloc);
1098
+ const len1 = WASM_VECTOR_LEN;
1099
+ const ret = wasm.sweep_curves(ptr0, len0, ptr1, len1, profile_segments, path_segments, with_caps);
1100
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1101
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1102
+ return v3;
1103
+ }
1104
+
1105
+ /**
1106
+ * Sweep a profile polyline along a path polyline.
1107
+ * profile_coords: flat [x,y,z,...] for profile curve
1108
+ * path_coords: flat [x,y,z,...] for path curve
1109
+ * with_caps: whether to close the ends
1110
+ * Returns mesh buffers.
1111
+ * @param {Float64Array} profile_coords
1112
+ * @param {Float64Array} path_coords
1113
+ * @param {boolean} with_caps
1114
+ * @returns {Float64Array}
1115
+ */
1116
+ export function sweep_polylines(profile_coords, path_coords, with_caps) {
1117
+ const ptr0 = passArrayF64ToWasm0(profile_coords, wasm.__wbindgen_malloc);
1118
+ const len0 = WASM_VECTOR_LEN;
1119
+ const ptr1 = passArrayF64ToWasm0(path_coords, wasm.__wbindgen_malloc);
1120
+ const len1 = WASM_VECTOR_LEN;
1121
+ const ret = wasm.sweep_polylines(ptr0, len0, ptr1, len1, with_caps);
1122
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1123
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1124
+ return v3;
1125
+ }
1126
+
1127
+ /**
1128
+ * Tessellate a NURBS surface to a mesh buffer.
1129
+ * Input format: [degree_u, degree_v, num_u, num_v, ...control_points(flat)..., ...weights(flat)..., ...knots_u..., ...knots_v..., u_segs, v_segs]
1130
+ * @param {Float64Array} data
1131
+ * @returns {Float64Array}
1132
+ */
1133
+ export function tessellate_nurbs_surface(data) {
1134
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1135
+ const len0 = WASM_VECTOR_LEN;
1136
+ const ret = wasm.tessellate_nurbs_surface(ptr0, len0);
1137
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1138
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1139
+ return v2;
1140
+ }
1141
+
1142
+ /**
1143
+ * Simple test function to verify WASM is working
1144
+ * @returns {string}
1145
+ */
1146
+ export function test_wasm() {
1147
+ let deferred1_0;
1148
+ let deferred1_1;
1149
+ try {
1150
+ const ret = wasm.test_wasm();
1151
+ deferred1_0 = ret[0];
1152
+ deferred1_1 = ret[1];
1153
+ return getStringFromWasm0(ret[0], ret[1]);
1154
+ } finally {
1155
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1156
+ }
1157
+ }
1158
+
1159
+ /**
1160
+ * Get version info
1161
+ * @returns {string}
1162
+ */
1163
+ export function version() {
1164
+ let deferred1_0;
1165
+ let deferred1_1;
1166
+ try {
1167
+ const ret = wasm.version();
1168
+ deferred1_0 = ret[0];
1169
+ deferred1_1 = ret[1];
1170
+ return getStringFromWasm0(ret[0], ret[1]);
1171
+ } finally {
1172
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1173
+ }
1174
+ }
1175
+
1176
+ function __wbg_get_imports() {
1177
+ const import0 = {
1178
+ __proto__: null,
1179
+ __wbindgen_init_externref_table: function() {
1180
+ const table = wasm.__wbindgen_externrefs;
1181
+ const offset = table.grow(4);
1182
+ table.set(0, undefined);
1183
+ table.set(offset + 0, undefined);
1184
+ table.set(offset + 1, null);
1185
+ table.set(offset + 2, true);
1186
+ table.set(offset + 3, false);
1187
+ },
1188
+ };
1189
+ return {
1190
+ __proto__: null,
1191
+ "./okgeometrycore_bg.js": import0,
1192
+ };
1193
+ }
1194
+
1195
+ function getArrayF64FromWasm0(ptr, len) {
1196
+ ptr = ptr >>> 0;
1197
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1198
+ }
1199
+
1200
+ let cachedFloat64ArrayMemory0 = null;
1201
+ function getFloat64ArrayMemory0() {
1202
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1203
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1204
+ }
1205
+ return cachedFloat64ArrayMemory0;
1206
+ }
1207
+
1208
+ function getStringFromWasm0(ptr, len) {
1209
+ ptr = ptr >>> 0;
1210
+ return decodeText(ptr, len);
1211
+ }
1212
+
1213
+ let cachedUint8ArrayMemory0 = null;
1214
+ function getUint8ArrayMemory0() {
1215
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1216
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1217
+ }
1218
+ return cachedUint8ArrayMemory0;
1219
+ }
1220
+
1221
+ function passArrayF64ToWasm0(arg, malloc) {
1222
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1223
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
1224
+ WASM_VECTOR_LEN = arg.length;
1225
+ return ptr;
1226
+ }
1227
+
1228
+ function passStringToWasm0(arg, malloc, realloc) {
1229
+ if (realloc === undefined) {
1230
+ const buf = cachedTextEncoder.encode(arg);
1231
+ const ptr = malloc(buf.length, 1) >>> 0;
1232
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1233
+ WASM_VECTOR_LEN = buf.length;
1234
+ return ptr;
1235
+ }
1236
+
1237
+ let len = arg.length;
1238
+ let ptr = malloc(len, 1) >>> 0;
1239
+
1240
+ const mem = getUint8ArrayMemory0();
1241
+
1242
+ let offset = 0;
1243
+
1244
+ for (; offset < len; offset++) {
1245
+ const code = arg.charCodeAt(offset);
1246
+ if (code > 0x7F) break;
1247
+ mem[ptr + offset] = code;
1248
+ }
1249
+ if (offset !== len) {
1250
+ if (offset !== 0) {
1251
+ arg = arg.slice(offset);
1252
+ }
1253
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1254
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1255
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1256
+
1257
+ offset += ret.written;
1258
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1259
+ }
1260
+
1261
+ WASM_VECTOR_LEN = offset;
1262
+ return ptr;
1263
+ }
1264
+
1265
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1266
+ cachedTextDecoder.decode();
1267
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1268
+ let numBytesDecoded = 0;
1269
+ function decodeText(ptr, len) {
1270
+ numBytesDecoded += len;
1271
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1272
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1273
+ cachedTextDecoder.decode();
1274
+ numBytesDecoded = len;
1275
+ }
1276
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1277
+ }
1278
+
1279
+ const cachedTextEncoder = new TextEncoder();
1280
+
1281
+ if (!('encodeInto' in cachedTextEncoder)) {
1282
+ cachedTextEncoder.encodeInto = function (arg, view) {
1283
+ const buf = cachedTextEncoder.encode(arg);
1284
+ view.set(buf);
1285
+ return {
1286
+ read: arg.length,
1287
+ written: buf.length
1288
+ };
1289
+ };
1290
+ }
1291
+
1292
+ let WASM_VECTOR_LEN = 0;
1293
+
1294
+ let wasmModule, wasm;
1295
+ function __wbg_finalize_init(instance, module) {
1296
+ wasm = instance.exports;
1297
+ wasmModule = module;
1298
+ cachedFloat64ArrayMemory0 = null;
1299
+ cachedUint8ArrayMemory0 = null;
1300
+ wasm.__wbindgen_start();
1301
+ return wasm;
1302
+ }
1303
+
1304
+ async function __wbg_load(module, imports) {
1305
+ if (typeof Response === 'function' && module instanceof Response) {
1306
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1307
+ try {
1308
+ return await WebAssembly.instantiateStreaming(module, imports);
1309
+ } catch (e) {
1310
+ const validResponse = module.ok && expectedResponseType(module.type);
1311
+
1312
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1313
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1314
+
1315
+ } else { throw e; }
1316
+ }
1317
+ }
1318
+
1319
+ const bytes = await module.arrayBuffer();
1320
+ return await WebAssembly.instantiate(bytes, imports);
1321
+ } else {
1322
+ const instance = await WebAssembly.instantiate(module, imports);
1323
+
1324
+ if (instance instanceof WebAssembly.Instance) {
1325
+ return { instance, module };
1326
+ } else {
1327
+ return instance;
1328
+ }
1329
+ }
1330
+
1331
+ function expectedResponseType(type) {
1332
+ switch (type) {
1333
+ case 'basic': case 'cors': case 'default': return true;
1334
+ }
1335
+ return false;
1336
+ }
1337
+ }
1338
+
1339
+ function initSync(module) {
1340
+ if (wasm !== undefined) return wasm;
1341
+
1342
+
1343
+ if (module !== undefined) {
1344
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1345
+ ({module} = module)
1346
+ } else {
1347
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1348
+ }
1349
+ }
1350
+
1351
+ const imports = __wbg_get_imports();
1352
+ if (!(module instanceof WebAssembly.Module)) {
1353
+ module = new WebAssembly.Module(module);
1354
+ }
1355
+ const instance = new WebAssembly.Instance(module, imports);
1356
+ return __wbg_finalize_init(instance, module);
1357
+ }
1358
+
1359
+ async function __wbg_init(module_or_path) {
1360
+ if (wasm !== undefined) return wasm;
1361
+
1362
+
1363
+ if (module_or_path !== undefined) {
1364
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1365
+ ({module_or_path} = module_or_path)
1366
+ } else {
1367
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1368
+ }
1369
+ }
1370
+
1371
+ if (module_or_path === undefined) {
1372
+ module_or_path = new URL('okgeometrycore_bg.wasm', import.meta.url);
1373
+ }
1374
+ const imports = __wbg_get_imports();
1375
+
1376
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1377
+ module_or_path = fetch(module_or_path);
1378
+ }
1379
+
1380
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1381
+
1382
+ return __wbg_finalize_init(instance, module);
1383
+ }
1384
+
1385
+ export { initSync, __wbg_init as default };