okgeometry-api 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,1786 @@
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_offset, 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_build_coplanar_connected_face_groups, mesh_chamfer_all_edges, mesh_compute_planar_curve_normal, mesh_contains_point, mesh_create_box, mesh_create_cone, mesh_create_cylinder, mesh_create_prism, mesh_create_sphere, mesh_evaluate, mesh_export_obj, mesh_extrude_face, mesh_extrude_planar_curve, mesh_find_face_group_by_normal, mesh_find_face_group_by_triangle_index, mesh_get_bounds, mesh_get_coplanar_face_group_centroid, mesh_get_coplanar_face_indices, mesh_get_coplanar_face_region, mesh_get_edge_vertex_pairs, mesh_get_face_area, mesh_get_face_centroid, mesh_get_face_normal, mesh_get_stats, mesh_import_obj, mesh_is_closed_volume, mesh_merge, mesh_mesh_intersect, mesh_patch_from_points, mesh_plane_intersect, mesh_prepare_boolean_cutter_curve, mesh_raycast, mesh_raycast_all, mesh_raycast_many, 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
+ * Offset a line segment perpendicular to line direction relative to reference normal.
296
+ * Returns [startX,startY,startZ,endX,endY,endZ]
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} distance
304
+ * @param {number} nx
305
+ * @param {number} ny
306
+ * @param {number} nz
307
+ * @returns {Float64Array}
308
+ */
309
+ export function line_offset(x1, y1, z1, x2, y2, z2, distance, nx, ny, nz) {
310
+ const ret = wasm.line_offset(x1, y1, z1, x2, y2, z2, distance, nx, ny, nz);
311
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
312
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
313
+ return v1;
314
+ }
315
+
316
+ /**
317
+ * Evaluate a point on a line segment at parameter t ∈ [0,1].
318
+ * Returns [x, y, z].
319
+ * @param {number} x1
320
+ * @param {number} y1
321
+ * @param {number} z1
322
+ * @param {number} x2
323
+ * @param {number} y2
324
+ * @param {number} z2
325
+ * @param {number} t
326
+ * @returns {Float64Array}
327
+ */
328
+ export function line_point_at(x1, y1, z1, x2, y2, z2, t) {
329
+ const ret = wasm.line_point_at(x1, y1, z1, x2, y2, z2, t);
330
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
331
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
332
+ return v1;
333
+ }
334
+
335
+ /**
336
+ * Get the tangent direction of a line segment. Returns [x, y, z].
337
+ * @param {number} x1
338
+ * @param {number} y1
339
+ * @param {number} z1
340
+ * @param {number} x2
341
+ * @param {number} y2
342
+ * @param {number} z2
343
+ * @returns {Float64Array}
344
+ */
345
+ export function line_tangent(x1, y1, z1, x2, y2, z2) {
346
+ const ret = wasm.line_tangent(x1, y1, z1, x2, y2, z2);
347
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
348
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
349
+ return v1;
350
+ }
351
+
352
+ /**
353
+ * Loft between multiple circles
354
+ *
355
+ * # Parameters
356
+ * * `circle_data` - Flat array of circle definitions [cx, cy, cz, nx, ny, nz, radius, ...]
357
+ * * `segments` - Number of segments to sample along each curve
358
+ * * `with_caps` - Whether to create end caps
359
+ *
360
+ * # Returns
361
+ * Mesh buffers for the lofted surface
362
+ * @param {Float64Array} circle_data
363
+ * @param {number} segments
364
+ * @param {boolean} with_caps
365
+ * @returns {Float64Array}
366
+ */
367
+ export function loft_circles(circle_data, segments, with_caps) {
368
+ const ptr0 = passArrayF64ToWasm0(circle_data, wasm.__wbindgen_malloc);
369
+ const len0 = WASM_VECTOR_LEN;
370
+ const ret = wasm.loft_circles(ptr0, len0, segments, with_caps);
371
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
372
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
373
+ return v2;
374
+ }
375
+
376
+ /**
377
+ * Loft a NURBS surface through multiple NURBS curves.
378
+ * Input: [num_curves, degree_v, curve1_data..., curve2_data..., ...]
379
+ * Each curve_data: [degree, num_pts, x,y,z,..., w0,w1,..., k0,k1,...]
380
+ * Returns the NurbsSurface data (same format as tessellate input, without u_segs/v_segs).
381
+ * @param {Float64Array} data
382
+ * @returns {Float64Array}
383
+ */
384
+ export function loft_nurbs_surface(data) {
385
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
386
+ const len0 = WASM_VECTOR_LEN;
387
+ const ret = wasm.loft_nurbs_surface(ptr0, len0);
388
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
389
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
390
+ return v2;
391
+ }
392
+
393
+ /**
394
+ * Loft between multiple polylines
395
+ *
396
+ * # Parameters
397
+ * * `polyline_data` - Flat array where each polyline is prefixed by its point count:
398
+ * [count1, x1, y1, z1, x2, y2, z2, ..., count2, x1, y1, z1, ...]
399
+ * * `_segments` - Ignored for polylines (kept for API compat). Points are used directly.
400
+ * * `with_caps` - Whether to create end caps (fan triangulation from center)
401
+ *
402
+ * # Returns
403
+ * Mesh buffers for the lofted surface
404
+ * @param {Float64Array} polyline_data
405
+ * @param {number} _segments
406
+ * @param {boolean} with_caps
407
+ * @returns {Float64Array}
408
+ */
409
+ export function loft_polylines(polyline_data, _segments, with_caps) {
410
+ const ptr0 = passArrayF64ToWasm0(polyline_data, wasm.__wbindgen_malloc);
411
+ const len0 = WASM_VECTOR_LEN;
412
+ const ret = wasm.loft_polylines(ptr0, len0, _segments, with_caps);
413
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
414
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
415
+ return v2;
416
+ }
417
+
418
+ /**
419
+ * Make multiple NURBS curves compatible (same knot vectors, same CP count).
420
+ * Input: [curve_count, curve1_data..., curve2_data..., ...]
421
+ * Each curve: [degree, num_cp, cp_xyz..., weights..., knots...]
422
+ * Output: same format with unified curves.
423
+ * @param {Float64Array} curves_data
424
+ * @returns {Float64Array}
425
+ */
426
+ export function make_nurbs_curves_compatible(curves_data) {
427
+ const ptr0 = passArrayF64ToWasm0(curves_data, wasm.__wbindgen_malloc);
428
+ const len0 = WASM_VECTOR_LEN;
429
+ const ret = wasm.make_nurbs_curves_compatible(ptr0, len0);
430
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
431
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
432
+ return v2;
433
+ }
434
+
435
+ /**
436
+ * Apply a 4x4 transformation matrix to a mesh.
437
+ * matrix: flat [m00,m01,m02,m03, m10,m11,..., m30,m31,m32,m33] (16 elements, row-major)
438
+ * @param {number} vertex_count
439
+ * @param {Float64Array} buffer
440
+ * @param {Float64Array} matrix
441
+ * @returns {Float64Array}
442
+ */
443
+ export function mesh_apply_matrix(vertex_count, buffer, matrix) {
444
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
445
+ const len0 = WASM_VECTOR_LEN;
446
+ const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
447
+ const len1 = WASM_VECTOR_LEN;
448
+ const ret = wasm.mesh_apply_matrix(vertex_count, ptr0, len0, ptr1, len1);
449
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
450
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
451
+ return v3;
452
+ }
453
+
454
+ /**
455
+ * Perform boolean intersection on two meshes
456
+ * @param {number} vertex_count_a
457
+ * @param {Float64Array} buffer_a
458
+ * @param {number} vertex_count_b
459
+ * @param {Float64Array} buffer_b
460
+ * @returns {Float64Array}
461
+ */
462
+ export function mesh_boolean_intersection(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
463
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
464
+ const len0 = WASM_VECTOR_LEN;
465
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
466
+ const len1 = WASM_VECTOR_LEN;
467
+ const ret = wasm.mesh_boolean_intersection(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
468
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
469
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
470
+ return v3;
471
+ }
472
+
473
+ /**
474
+ * Perform boolean operation on two meshes
475
+ *
476
+ * # Parameters
477
+ * * `vertex_count_a` - Number of vertices in mesh A
478
+ * * `buffer_a` - Buffer for mesh A [vertices..., indices...]
479
+ * * `vertex_count_b` - Number of vertices in mesh B
480
+ * * `buffer_b` - Buffer for mesh B [vertices..., indices...]
481
+ * * `operation` - Operation type: "union", "intersection", or "subtraction"
482
+ *
483
+ * # Returns
484
+ * Result mesh buffer [vertices..., indices...]
485
+ * @param {number} vertex_count_a
486
+ * @param {Float64Array} buffer_a
487
+ * @param {number} vertex_count_b
488
+ * @param {Float64Array} buffer_b
489
+ * @param {string} operation
490
+ * @returns {Float64Array}
491
+ */
492
+ export function mesh_boolean_operation(vertex_count_a, buffer_a, vertex_count_b, buffer_b, operation) {
493
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
494
+ const len0 = WASM_VECTOR_LEN;
495
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
496
+ const len1 = WASM_VECTOR_LEN;
497
+ const ptr2 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
498
+ const len2 = WASM_VECTOR_LEN;
499
+ const ret = wasm.mesh_boolean_operation(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1, ptr2, len2);
500
+ var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
501
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
502
+ return v4;
503
+ }
504
+
505
+ /**
506
+ * Perform boolean subtraction on two meshes (A - B)
507
+ * @param {number} vertex_count_a
508
+ * @param {Float64Array} buffer_a
509
+ * @param {number} vertex_count_b
510
+ * @param {Float64Array} buffer_b
511
+ * @returns {Float64Array}
512
+ */
513
+ export function mesh_boolean_subtraction(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
514
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
515
+ const len0 = WASM_VECTOR_LEN;
516
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
517
+ const len1 = WASM_VECTOR_LEN;
518
+ const ret = wasm.mesh_boolean_subtraction(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
519
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
520
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
521
+ return v3;
522
+ }
523
+
524
+ /**
525
+ * Perform boolean union on two meshes
526
+ * @param {number} vertex_count_a
527
+ * @param {Float64Array} buffer_a
528
+ * @param {number} vertex_count_b
529
+ * @param {Float64Array} buffer_b
530
+ * @returns {Float64Array}
531
+ */
532
+ export function mesh_boolean_union(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
533
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
534
+ const len0 = WASM_VECTOR_LEN;
535
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
536
+ const len1 = WASM_VECTOR_LEN;
537
+ const ret = wasm.mesh_boolean_union(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
538
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
539
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
540
+ return v3;
541
+ }
542
+
543
+ /**
544
+ * Extract boundary (perimeter) edges from a mesh as polylines.
545
+ * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
546
+ * @param {number} vertex_count
547
+ * @param {Float64Array} buffer
548
+ * @returns {Float64Array}
549
+ */
550
+ export function mesh_boundary_polylines(vertex_count, buffer) {
551
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
552
+ const len0 = WASM_VECTOR_LEN;
553
+ const ret = wasm.mesh_boundary_polylines(vertex_count, ptr0, len0);
554
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
555
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
556
+ return v2;
557
+ }
558
+
559
+ /**
560
+ * Coplanar connected face groups.
561
+ * Output format:
562
+ * [groupCount, triCount, tri..., centroidX,centroidY,centroidZ, normalX,normalY,normalZ, ...]
563
+ * @param {number} vertex_count
564
+ * @param {Float64Array} buffer
565
+ * @returns {Float64Array}
566
+ */
567
+ export function mesh_build_coplanar_connected_face_groups(vertex_count, buffer) {
568
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
569
+ const len0 = WASM_VECTOR_LEN;
570
+ const ret = wasm.mesh_build_coplanar_connected_face_groups(vertex_count, ptr0, len0);
571
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
572
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
573
+ return v2;
574
+ }
575
+
576
+ /**
577
+ * Chamfer all edges of a primitive mesh (flat bevel)
578
+ *
579
+ * # Arguments
580
+ * * `mesh_type` - "box", "cylinder", or "prism"
581
+ * * `params` - Parameters: [width,height,depth] for box, [radius,height,segments] for cylinder/prism
582
+ * * `offset` - Chamfer offset distance
583
+ *
584
+ * # Returns
585
+ * Result mesh buffer [vertexCount, vertices..., indices...]
586
+ * @param {string} mesh_type
587
+ * @param {Float64Array} params
588
+ * @param {number} offset
589
+ * @returns {Float64Array}
590
+ */
591
+ export function mesh_chamfer_all_edges(mesh_type, params, offset) {
592
+ const ptr0 = passStringToWasm0(mesh_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
593
+ const len0 = WASM_VECTOR_LEN;
594
+ const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
595
+ const len1 = WASM_VECTOR_LEN;
596
+ const ret = wasm.mesh_chamfer_all_edges(ptr0, len0, ptr1, len1, offset);
597
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
598
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
599
+ return v3;
600
+ }
601
+
602
+ /**
603
+ * Compute planar curve normal from ordered points.
604
+ * @param {Float64Array} coords
605
+ * @param {boolean} closed
606
+ * @returns {Float64Array}
607
+ */
608
+ export function mesh_compute_planar_curve_normal(coords, closed) {
609
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
610
+ const len0 = WASM_VECTOR_LEN;
611
+ const ret = wasm.mesh_compute_planar_curve_normal(ptr0, len0, closed);
612
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
613
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
614
+ return v2;
615
+ }
616
+
617
+ /**
618
+ * Odd/even mesh containment test.
619
+ * @param {number} vertex_count
620
+ * @param {Float64Array} buffer
621
+ * @param {number} px
622
+ * @param {number} py
623
+ * @param {number} pz
624
+ * @returns {boolean}
625
+ */
626
+ export function mesh_contains_point(vertex_count, buffer, px, py, pz) {
627
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
628
+ const len0 = WASM_VECTOR_LEN;
629
+ const ret = wasm.mesh_contains_point(vertex_count, ptr0, len0, px, py, pz);
630
+ return ret !== 0;
631
+ }
632
+
633
+ /**
634
+ * Create a box mesh and return buffers
635
+ * Returns [vertices..., indices...]
636
+ * @param {number} width
637
+ * @param {number} height
638
+ * @param {number} depth
639
+ * @returns {Float64Array}
640
+ */
641
+ export function mesh_create_box(width, height, depth) {
642
+ const ret = wasm.mesh_create_box(width, height, depth);
643
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
644
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
645
+ return v1;
646
+ }
647
+
648
+ /**
649
+ * Create a cone mesh and return buffers
650
+ * @param {number} radius
651
+ * @param {number} height
652
+ * @param {number} segments
653
+ * @returns {Float64Array}
654
+ */
655
+ export function mesh_create_cone(radius, height, segments) {
656
+ const ret = wasm.mesh_create_cone(radius, height, segments);
657
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
658
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
659
+ return v1;
660
+ }
661
+
662
+ /**
663
+ * Create a cylinder mesh and return buffers
664
+ * @param {number} radius
665
+ * @param {number} height
666
+ * @param {number} segments
667
+ * @returns {Float64Array}
668
+ */
669
+ export function mesh_create_cylinder(radius, height, segments) {
670
+ const ret = wasm.mesh_create_cylinder(radius, height, segments);
671
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
672
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
673
+ return v1;
674
+ }
675
+
676
+ /**
677
+ * Create a prism mesh and return buffers
678
+ * @param {number} radius
679
+ * @param {number} height
680
+ * @param {number} sides
681
+ * @returns {Float64Array}
682
+ */
683
+ export function mesh_create_prism(radius, height, sides) {
684
+ const ret = wasm.mesh_create_prism(radius, height, sides);
685
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
686
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
687
+ return v1;
688
+ }
689
+
690
+ /**
691
+ * Create a sphere mesh and return buffers
692
+ * @param {number} radius
693
+ * @param {number} segments
694
+ * @param {number} rings
695
+ * @returns {Float64Array}
696
+ */
697
+ export function mesh_create_sphere(radius, segments, rings) {
698
+ const ret = wasm.mesh_create_sphere(radius, segments, rings);
699
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
700
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
701
+ return v1;
702
+ }
703
+
704
+ /**
705
+ * Evaluate a point on a mesh surface at parametric coordinates (u, v).
706
+ * Maps u ∈ [0,1] and v ∈ [0,1] to the mesh's AABB bounding box,
707
+ * then casts a ray perpendicular to the best-fit projection plane.
708
+ * Returns [x, y, z] of the intersection point, or [NaN, NaN, NaN] if no hit.
709
+ * @param {number} vertex_count
710
+ * @param {Float64Array} buffer
711
+ * @param {number} u
712
+ * @param {number} v
713
+ * @returns {Float64Array}
714
+ */
715
+ export function mesh_evaluate(vertex_count, buffer, u, v) {
716
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
717
+ const len0 = WASM_VECTOR_LEN;
718
+ const ret = wasm.mesh_evaluate(vertex_count, ptr0, len0, u, v);
719
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
720
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
721
+ return v2;
722
+ }
723
+
724
+ /**
725
+ * Export a mesh to OBJ format
726
+ * Takes mesh buffers as input (same format as mesh_to_buffers output)
727
+ * Returns OBJ string
728
+ * @param {number} vertex_count
729
+ * @param {Float64Array} buffer
730
+ * @returns {string}
731
+ */
732
+ export function mesh_export_obj(vertex_count, buffer) {
733
+ let deferred2_0;
734
+ let deferred2_1;
735
+ try {
736
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
737
+ const len0 = WASM_VECTOR_LEN;
738
+ const ret = wasm.mesh_export_obj(vertex_count, ptr0, len0);
739
+ deferred2_0 = ret[0];
740
+ deferred2_1 = ret[1];
741
+ return getStringFromWasm0(ret[0], ret[1]);
742
+ } finally {
743
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
744
+ }
745
+ }
746
+
747
+ /**
748
+ * Push/pull a planar face set by moving its coplanar connected region.
749
+ * @param {number} vertex_count
750
+ * @param {Float64Array} buffer
751
+ * @param {number} face_index
752
+ * @param {number} distance
753
+ * @returns {Float64Array}
754
+ */
755
+ export function mesh_extrude_face(vertex_count, buffer, face_index, distance) {
756
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
757
+ const len0 = WASM_VECTOR_LEN;
758
+ const ret = wasm.mesh_extrude_face(vertex_count, ptr0, len0, face_index, distance);
759
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
760
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
761
+ return v2;
762
+ }
763
+
764
+ /**
765
+ * Extrude planar curve profile by normal * height.
766
+ * @param {Float64Array} coords
767
+ * @param {number} nx
768
+ * @param {number} ny
769
+ * @param {number} nz
770
+ * @param {number} height
771
+ * @param {boolean} closed
772
+ * @returns {Float64Array}
773
+ */
774
+ export function mesh_extrude_planar_curve(coords, nx, ny, nz, height, closed) {
775
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
776
+ const len0 = WASM_VECTOR_LEN;
777
+ const ret = wasm.mesh_extrude_planar_curve(ptr0, len0, nx, ny, nz, height, closed);
778
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
779
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
780
+ return v2;
781
+ }
782
+
783
+ /**
784
+ * Find the best matching coplanar connected face group by normal and optional near-point.
785
+ * Output format: [centroidX, centroidY, centroidZ, normalX, normalY, normalZ] or [].
786
+ * @param {number} vertex_count
787
+ * @param {Float64Array} buffer
788
+ * @param {number} nx
789
+ * @param {number} ny
790
+ * @param {number} nz
791
+ * @param {number} near_x
792
+ * @param {number} near_y
793
+ * @param {number} near_z
794
+ * @param {boolean} use_near_point
795
+ * @returns {Float64Array}
796
+ */
797
+ export function mesh_find_face_group_by_normal(vertex_count, buffer, nx, ny, nz, near_x, near_y, near_z, use_near_point) {
798
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
799
+ const len0 = WASM_VECTOR_LEN;
800
+ const ret = wasm.mesh_find_face_group_by_normal(vertex_count, ptr0, len0, nx, ny, nz, near_x, near_y, near_z, use_near_point);
801
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
802
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
803
+ return v2;
804
+ }
805
+
806
+ /**
807
+ * Find the coplanar connected face group containing triangle_index.
808
+ * Output format: [centroidX, centroidY, centroidZ, normalX, normalY, normalZ] or [].
809
+ * @param {number} vertex_count
810
+ * @param {Float64Array} buffer
811
+ * @param {number} triangle_index
812
+ * @returns {Float64Array}
813
+ */
814
+ export function mesh_find_face_group_by_triangle_index(vertex_count, buffer, triangle_index) {
815
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
816
+ const len0 = WASM_VECTOR_LEN;
817
+ const ret = wasm.mesh_find_face_group_by_triangle_index(vertex_count, ptr0, len0, triangle_index);
818
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
819
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
820
+ return v2;
821
+ }
822
+
823
+ /**
824
+ * Axis-aligned bounding box as [minX, minY, minZ, maxX, maxY, maxZ].
825
+ * @param {number} vertex_count
826
+ * @param {Float64Array} buffer
827
+ * @returns {Float64Array}
828
+ */
829
+ export function mesh_get_bounds(vertex_count, buffer) {
830
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
831
+ const len0 = WASM_VECTOR_LEN;
832
+ const ret = wasm.mesh_get_bounds(vertex_count, ptr0, len0);
833
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
834
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
835
+ return v2;
836
+ }
837
+
838
+ /**
839
+ * Coplanar connected face-group centroid containing a given triangle face index.
840
+ * Output format: [x, y, z] or [] when unavailable.
841
+ * @param {number} vertex_count
842
+ * @param {Float64Array} buffer
843
+ * @param {number} face_index
844
+ * @returns {Float64Array}
845
+ */
846
+ export function mesh_get_coplanar_face_group_centroid(vertex_count, buffer, face_index) {
847
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
848
+ const len0 = WASM_VECTOR_LEN;
849
+ const ret = wasm.mesh_get_coplanar_face_group_centroid(vertex_count, ptr0, len0, face_index);
850
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
851
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
852
+ return v2;
853
+ }
854
+
855
+ /**
856
+ * Edge-connected coplanar triangle indices as [count, i0, i1, ...].
857
+ * @param {number} vertex_count
858
+ * @param {Float64Array} buffer
859
+ * @param {number} face_index
860
+ * @returns {Float64Array}
861
+ */
862
+ export function mesh_get_coplanar_face_indices(vertex_count, buffer, face_index) {
863
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
864
+ const len0 = WASM_VECTOR_LEN;
865
+ const ret = wasm.mesh_get_coplanar_face_indices(vertex_count, ptr0, len0, face_index);
866
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
867
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
868
+ return v2;
869
+ }
870
+
871
+ /**
872
+ * Coplanar connected face region projected to a plane basis.
873
+ * Output format:
874
+ * [faceCount, faceIndex0, faceIndex1, ..., uMin, uMax, vMin, vMax]
875
+ * @param {number} vertex_count
876
+ * @param {Float64Array} buffer
877
+ * @param {number} face_index
878
+ * @param {number} ox
879
+ * @param {number} oy
880
+ * @param {number} oz
881
+ * @param {number} ux
882
+ * @param {number} uy
883
+ * @param {number} uz
884
+ * @param {number} vx
885
+ * @param {number} vy
886
+ * @param {number} vz
887
+ * @param {number} margin_scale
888
+ * @param {number} min_margin
889
+ * @returns {Float64Array}
890
+ */
891
+ export function mesh_get_coplanar_face_region(vertex_count, buffer, face_index, ox, oy, oz, ux, uy, uz, vx, vy, vz, margin_scale, min_margin) {
892
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
893
+ const len0 = WASM_VECTOR_LEN;
894
+ const ret = wasm.mesh_get_coplanar_face_region(vertex_count, ptr0, len0, face_index, ox, oy, oz, ux, uy, uz, vx, vy, vz, margin_scale, min_margin);
895
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
896
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
897
+ return v2;
898
+ }
899
+
900
+ /**
901
+ * Unique undirected triangle edges as [edgeCount, v0a, v0b, v1a, v1b, ...].
902
+ * @param {number} vertex_count
903
+ * @param {Float64Array} buffer
904
+ * @returns {Float64Array}
905
+ */
906
+ export function mesh_get_edge_vertex_pairs(vertex_count, buffer) {
907
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
908
+ const len0 = WASM_VECTOR_LEN;
909
+ const ret = wasm.mesh_get_edge_vertex_pairs(vertex_count, ptr0, len0);
910
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
911
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
912
+ return v2;
913
+ }
914
+
915
+ /**
916
+ * Face area.
917
+ * @param {number} vertex_count
918
+ * @param {Float64Array} buffer
919
+ * @param {number} face_index
920
+ * @returns {number}
921
+ */
922
+ export function mesh_get_face_area(vertex_count, buffer, face_index) {
923
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
924
+ const len0 = WASM_VECTOR_LEN;
925
+ const ret = wasm.mesh_get_face_area(vertex_count, ptr0, len0, face_index);
926
+ return ret;
927
+ }
928
+
929
+ /**
930
+ * Face centroid as [x, y, z].
931
+ * @param {number} vertex_count
932
+ * @param {Float64Array} buffer
933
+ * @param {number} face_index
934
+ * @returns {Float64Array}
935
+ */
936
+ export function mesh_get_face_centroid(vertex_count, buffer, face_index) {
937
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
938
+ const len0 = WASM_VECTOR_LEN;
939
+ const ret = wasm.mesh_get_face_centroid(vertex_count, ptr0, len0, face_index);
940
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
941
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
942
+ return v2;
943
+ }
944
+
945
+ /**
946
+ * Face normal as [x, y, z].
947
+ * @param {number} vertex_count
948
+ * @param {Float64Array} buffer
949
+ * @param {number} face_index
950
+ * @returns {Float64Array}
951
+ */
952
+ export function mesh_get_face_normal(vertex_count, buffer, face_index) {
953
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
954
+ const len0 = WASM_VECTOR_LEN;
955
+ const ret = wasm.mesh_get_face_normal(vertex_count, ptr0, len0, face_index);
956
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
957
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
958
+ return v2;
959
+ }
960
+
961
+ /**
962
+ * Get mesh statistics
963
+ * Returns [vertex_count, face_count, edge_count]
964
+ * @param {number} vertex_count
965
+ * @param {Float64Array} buffer
966
+ * @returns {Float64Array}
967
+ */
968
+ export function mesh_get_stats(vertex_count, buffer) {
969
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
970
+ const len0 = WASM_VECTOR_LEN;
971
+ const ret = wasm.mesh_get_stats(vertex_count, ptr0, len0);
972
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
973
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
974
+ return v2;
975
+ }
976
+
977
+ /**
978
+ * Import OBJ data and return mesh buffers
979
+ * @param {string} obj_data
980
+ * @returns {Float64Array}
981
+ */
982
+ export function mesh_import_obj(obj_data) {
983
+ const ptr0 = passStringToWasm0(obj_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
984
+ const len0 = WASM_VECTOR_LEN;
985
+ const ret = wasm.mesh_import_obj(ptr0, len0);
986
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
987
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
988
+ return v2;
989
+ }
990
+
991
+ /**
992
+ * Check if triangulated mesh is a closed volume (no welded boundary edges).
993
+ * @param {number} vertex_count
994
+ * @param {Float64Array} buffer
995
+ * @returns {boolean}
996
+ */
997
+ export function mesh_is_closed_volume(vertex_count, buffer) {
998
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
999
+ const len0 = WASM_VECTOR_LEN;
1000
+ const ret = wasm.mesh_is_closed_volume(vertex_count, ptr0, len0);
1001
+ return ret !== 0;
1002
+ }
1003
+
1004
+ /**
1005
+ * Merge multiple mesh buffers while preserving per-mesh vertex order and index remapping.
1006
+ * Input format: [mesh_count, len1, mesh1..., len2, mesh2..., ...]
1007
+ * @param {Float64Array} mesh_data
1008
+ * @returns {Float64Array}
1009
+ */
1010
+ export function mesh_merge(mesh_data) {
1011
+ const ptr0 = passArrayF64ToWasm0(mesh_data, wasm.__wbindgen_malloc);
1012
+ const len0 = WASM_VECTOR_LEN;
1013
+ const ret = wasm.mesh_merge(ptr0, len0);
1014
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1015
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1016
+ return v2;
1017
+ }
1018
+
1019
+ /**
1020
+ * Intersect two meshes, returning intersection polyline points.
1021
+ * Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
1022
+ * @param {number} va_count
1023
+ * @param {Float64Array} buffer_a
1024
+ * @param {number} vb_count
1025
+ * @param {Float64Array} buffer_b
1026
+ * @returns {Float64Array}
1027
+ */
1028
+ export function mesh_mesh_intersect(va_count, buffer_a, vb_count, buffer_b) {
1029
+ const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
1030
+ const len0 = WASM_VECTOR_LEN;
1031
+ const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
1032
+ const len1 = WASM_VECTOR_LEN;
1033
+ const ret = wasm.mesh_mesh_intersect(va_count, ptr0, len0, vb_count, ptr1, len1);
1034
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1035
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1036
+ return v3;
1037
+ }
1038
+
1039
+ /**
1040
+ * Create a planar patch mesh from boundary points using CDT.
1041
+ * Correctly handles concave polygons (unlike fan triangulation).
1042
+ * Input: flat coordinate array [x1,y1,z1, x2,y2,z2, ...]
1043
+ * Output: mesh buffer [vertexCount, x1,y1,z1,..., i0,i1,i2, ...]
1044
+ * @param {Float64Array} coords
1045
+ * @returns {Float64Array}
1046
+ */
1047
+ export function mesh_patch_from_points(coords) {
1048
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1049
+ const len0 = WASM_VECTOR_LEN;
1050
+ const ret = wasm.mesh_patch_from_points(ptr0, len0);
1051
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1052
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1053
+ return v2;
1054
+ }
1055
+
1056
+ /**
1057
+ * Intersect a mesh with a plane, returning polyline points.
1058
+ * Input: vertex_count, mesh_buffer..., nx, ny, nz, d
1059
+ * Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
1060
+ * @param {number} vertex_count
1061
+ * @param {Float64Array} buffer
1062
+ * @param {number} nx
1063
+ * @param {number} ny
1064
+ * @param {number} nz
1065
+ * @param {number} d
1066
+ * @returns {Float64Array}
1067
+ */
1068
+ export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
1069
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1070
+ const len0 = WASM_VECTOR_LEN;
1071
+ const ret = wasm.mesh_plane_intersect(vertex_count, ptr0, len0, nx, ny, nz, d);
1072
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1073
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1074
+ return v2;
1075
+ }
1076
+
1077
+ /**
1078
+ * Shift closed boolean cutter curve and adjust height.
1079
+ * Returns [height, epsilon, pointCount, x,y,z,...]
1080
+ * @param {Float64Array} coords
1081
+ * @param {boolean} closed
1082
+ * @param {number} nx
1083
+ * @param {number} ny
1084
+ * @param {number} nz
1085
+ * @param {number} height
1086
+ * @returns {Float64Array}
1087
+ */
1088
+ export function mesh_prepare_boolean_cutter_curve(coords, closed, nx, ny, nz, height) {
1089
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1090
+ const len0 = WASM_VECTOR_LEN;
1091
+ const ret = wasm.mesh_prepare_boolean_cutter_curve(ptr0, len0, closed, nx, ny, nz, height);
1092
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1093
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1094
+ return v2;
1095
+ }
1096
+
1097
+ /**
1098
+ * Raycast against mesh and return closest hit.
1099
+ * Output: [] when no hit, otherwise [pointX,pointY,pointZ, normalX,normalY,normalZ, faceIndex, distance]
1100
+ * @param {number} vertex_count
1101
+ * @param {Float64Array} buffer
1102
+ * @param {number} ox
1103
+ * @param {number} oy
1104
+ * @param {number} oz
1105
+ * @param {number} dx
1106
+ * @param {number} dy
1107
+ * @param {number} dz
1108
+ * @param {number} max_distance
1109
+ * @returns {Float64Array}
1110
+ */
1111
+ export function mesh_raycast(vertex_count, buffer, ox, oy, oz, dx, dy, dz, max_distance) {
1112
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1113
+ const len0 = WASM_VECTOR_LEN;
1114
+ const ret = wasm.mesh_raycast(vertex_count, ptr0, len0, ox, oy, oz, dx, dy, dz, max_distance);
1115
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1116
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1117
+ return v2;
1118
+ }
1119
+
1120
+ /**
1121
+ * Raycast against mesh and return all hits sorted by distance.
1122
+ * Output: [hitCount, (point, normal, faceIndex, distance)*]
1123
+ * @param {number} vertex_count
1124
+ * @param {Float64Array} buffer
1125
+ * @param {number} ox
1126
+ * @param {number} oy
1127
+ * @param {number} oz
1128
+ * @param {number} dx
1129
+ * @param {number} dy
1130
+ * @param {number} dz
1131
+ * @param {number} max_distance
1132
+ * @returns {Float64Array}
1133
+ */
1134
+ export function mesh_raycast_all(vertex_count, buffer, ox, oy, oz, dx, dy, dz, max_distance) {
1135
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1136
+ const len0 = WASM_VECTOR_LEN;
1137
+ const ret = wasm.mesh_raycast_all(vertex_count, ptr0, len0, ox, oy, oz, dx, dy, dz, max_distance);
1138
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1139
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1140
+ return v2;
1141
+ }
1142
+
1143
+ /**
1144
+ * Raycast against many meshes packed as:
1145
+ * [meshCount, meshLen0, meshRaw0..., meshLen1, meshRaw1..., ...]
1146
+ * Output: [hitCount, meshIndex, pointX,pointY,pointZ, normalX,normalY,normalZ, faceIndex, distance, ...]
1147
+ * @param {Float64Array} mesh_data
1148
+ * @param {number} ox
1149
+ * @param {number} oy
1150
+ * @param {number} oz
1151
+ * @param {number} dx
1152
+ * @param {number} dy
1153
+ * @param {number} dz
1154
+ * @param {number} max_distance
1155
+ * @returns {Float64Array}
1156
+ */
1157
+ export function mesh_raycast_many(mesh_data, ox, oy, oz, dx, dy, dz, max_distance) {
1158
+ const ptr0 = passArrayF64ToWasm0(mesh_data, wasm.__wbindgen_malloc);
1159
+ const len0 = WASM_VECTOR_LEN;
1160
+ const ret = wasm.mesh_raycast_many(ptr0, len0, ox, oy, oz, dx, dy, dz, max_distance);
1161
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1162
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1163
+ return v2;
1164
+ }
1165
+
1166
+ /**
1167
+ * Rotate a mesh around an arbitrary axis and return new buffers
1168
+ * Axis is defined by (ax, ay, az), angle in radians
1169
+ * @param {number} vertex_count
1170
+ * @param {Float64Array} buffer
1171
+ * @param {number} ax
1172
+ * @param {number} ay
1173
+ * @param {number} az
1174
+ * @param {number} angle
1175
+ * @returns {Float64Array}
1176
+ */
1177
+ export function mesh_rotate(vertex_count, buffer, ax, ay, az, angle) {
1178
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1179
+ const len0 = WASM_VECTOR_LEN;
1180
+ const ret = wasm.mesh_rotate(vertex_count, ptr0, len0, ax, ay, az, angle);
1181
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1182
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1183
+ return v2;
1184
+ }
1185
+
1186
+ /**
1187
+ * Scale a mesh non-uniformly and return new buffers
1188
+ * @param {number} vertex_count
1189
+ * @param {Float64Array} buffer
1190
+ * @param {number} sx
1191
+ * @param {number} sy
1192
+ * @param {number} sz
1193
+ * @returns {Float64Array}
1194
+ */
1195
+ export function mesh_scale(vertex_count, buffer, sx, sy, sz) {
1196
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1197
+ const len0 = WASM_VECTOR_LEN;
1198
+ const ret = wasm.mesh_scale(vertex_count, ptr0, len0, sx, sy, sz);
1199
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1200
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1201
+ return v2;
1202
+ }
1203
+
1204
+ /**
1205
+ * Translate a mesh by an offset vector and return new buffers
1206
+ * @param {number} vertex_count
1207
+ * @param {Float64Array} buffer
1208
+ * @param {number} dx
1209
+ * @param {number} dy
1210
+ * @param {number} dz
1211
+ * @returns {Float64Array}
1212
+ */
1213
+ export function mesh_translate(vertex_count, buffer, dx, dy, dz) {
1214
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1215
+ const len0 = WASM_VECTOR_LEN;
1216
+ const ret = wasm.mesh_translate(vertex_count, ptr0, len0, dx, dy, dz);
1217
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1218
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1219
+ return v2;
1220
+ }
1221
+
1222
+ /**
1223
+ * Intersect two NURBS curves.
1224
+ * Returns: [num_points, x,y,z, ...]
1225
+ * @param {Float64Array} data_a
1226
+ * @param {Float64Array} data_b
1227
+ * @returns {Float64Array}
1228
+ */
1229
+ export function nurbs_curve_curve_intersect(data_a, data_b) {
1230
+ const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
1231
+ const len0 = WASM_VECTOR_LEN;
1232
+ const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
1233
+ const len1 = WASM_VECTOR_LEN;
1234
+ const ret = wasm.nurbs_curve_curve_intersect(ptr0, len0, ptr1, len1);
1235
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1236
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1237
+ return v3;
1238
+ }
1239
+
1240
+ /**
1241
+ * Intersect a NURBS curve with a plane.
1242
+ * Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
1243
+ * Returns: [num_points, x,y,z, x,y,z, ...]
1244
+ * @param {Float64Array} data
1245
+ * @param {number} nx
1246
+ * @param {number} ny
1247
+ * @param {number} nz
1248
+ * @param {number} d
1249
+ * @returns {Float64Array}
1250
+ */
1251
+ export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
1252
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1253
+ const len0 = WASM_VECTOR_LEN;
1254
+ const ret = wasm.nurbs_curve_plane_intersect(ptr0, len0, nx, ny, nz, d);
1255
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1256
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1257
+ return v2;
1258
+ }
1259
+
1260
+ /**
1261
+ * Evaluate a NURBS surface at (u, v) parameters.
1262
+ * Input format: same as tessellate but last 2 values are u, v instead of u_segs, v_segs
1263
+ * Returns [x, y, z]
1264
+ * @param {Float64Array} data
1265
+ * @param {number} u
1266
+ * @param {number} v
1267
+ * @returns {Float64Array}
1268
+ */
1269
+ export function nurbs_surface_evaluate(data, u, v) {
1270
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1271
+ const len0 = WASM_VECTOR_LEN;
1272
+ const ret = wasm.nurbs_surface_evaluate(ptr0, len0, u, v);
1273
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1274
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1275
+ return v2;
1276
+ }
1277
+
1278
+ /**
1279
+ * Intersect a NURBS surface with a plane.
1280
+ * Input: same surface format as tessellate_nurbs_surface, then plane (nx,ny,nz,d) appended.
1281
+ * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
1282
+ * @param {Float64Array} surface_data
1283
+ * @param {number} nx
1284
+ * @param {number} ny
1285
+ * @param {number} nz
1286
+ * @param {number} d
1287
+ * @param {number} tess
1288
+ * @returns {Float64Array}
1289
+ */
1290
+ export function nurbs_surface_plane_intersect(surface_data, nx, ny, nz, d, tess) {
1291
+ const ptr0 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
1292
+ const len0 = WASM_VECTOR_LEN;
1293
+ const ret = wasm.nurbs_surface_plane_intersect(ptr0, len0, nx, ny, nz, d, tess);
1294
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1295
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1296
+ return v2;
1297
+ }
1298
+
1299
+ /**
1300
+ * Intersect two NURBS surfaces.
1301
+ * Returns polyline buffer.
1302
+ * @param {Float64Array} data_a
1303
+ * @param {Float64Array} data_b
1304
+ * @param {number} tess
1305
+ * @returns {Float64Array}
1306
+ */
1307
+ export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
1308
+ const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
1309
+ const len0 = WASM_VECTOR_LEN;
1310
+ const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
1311
+ const len1 = WASM_VECTOR_LEN;
1312
+ const ret = wasm.nurbs_surface_surface_intersect(ptr0, len0, ptr1, len1, tess);
1313
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1314
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1315
+ return v3;
1316
+ }
1317
+
1318
+ /**
1319
+ * Offset a polyline by a distance in a given plane.
1320
+ * If nx=ny=nz=0, the plane normal is auto-detected.
1321
+ * Returns flat [x1,y1,z1, x2,y2,z2, ...] of the offset polyline.
1322
+ * @param {Float64Array} coords
1323
+ * @param {number} distance
1324
+ * @param {number} nx
1325
+ * @param {number} ny
1326
+ * @param {number} nz
1327
+ * @returns {Float64Array}
1328
+ */
1329
+ export function offset_polyline_curve(coords, distance, nx, ny, nz) {
1330
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1331
+ const len0 = WASM_VECTOR_LEN;
1332
+ const ret = wasm.offset_polyline_curve(ptr0, len0, distance, nx, ny, nz);
1333
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1334
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1335
+ return v2;
1336
+ }
1337
+
1338
+ /**
1339
+ * Convert a polycurve (Line/Arc segments) to an exact NURBS curve.
1340
+ * Input format: [segment_count, type1, ...data1..., type2, ...data2..., ...]
1341
+ * type 0 = Line (6 floats: start_xyz, end_xyz)
1342
+ * type 1 = Arc (9 floats: center_xyz, normal_xyz, radius, start_angle, end_angle)
1343
+ * Output format: [degree, num_cp, cp_x1,y1,z1,..., w1,w2,..., k1,k2,...]
1344
+ * @param {Float64Array} segment_data
1345
+ * @returns {Float64Array}
1346
+ */
1347
+ export function polycurve_to_nurbs(segment_data) {
1348
+ const ptr0 = passArrayF64ToWasm0(segment_data, wasm.__wbindgen_malloc);
1349
+ const len0 = WASM_VECTOR_LEN;
1350
+ const ret = wasm.polycurve_to_nurbs(ptr0, len0);
1351
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1352
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1353
+ return v2;
1354
+ }
1355
+
1356
+ /**
1357
+ * Get the total length of a polyline.
1358
+ * Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
1359
+ * @param {Float64Array} coords
1360
+ * @returns {number}
1361
+ */
1362
+ export function polyline_length(coords) {
1363
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1364
+ const len0 = WASM_VECTOR_LEN;
1365
+ const ret = wasm.polyline_length(ptr0, len0);
1366
+ return ret;
1367
+ }
1368
+
1369
+ /**
1370
+ * Evaluate a point on a polyline at parameter t ∈ [0,1].
1371
+ * Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
1372
+ * Returns [x, y, z].
1373
+ * @param {Float64Array} coords
1374
+ * @param {number} t
1375
+ * @returns {Float64Array}
1376
+ */
1377
+ export function polyline_point_at(coords, t) {
1378
+ const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1379
+ const len0 = WASM_VECTOR_LEN;
1380
+ const ret = wasm.polyline_point_at(ptr0, len0, t);
1381
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1382
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1383
+ return v2;
1384
+ }
1385
+
1386
+ /**
1387
+ * Find the closest point on a ray to a given point.
1388
+ * Returns [x, y, z] of the closest point on the ray.
1389
+ * @param {number} ox
1390
+ * @param {number} oy
1391
+ * @param {number} oz
1392
+ * @param {number} dx
1393
+ * @param {number} dy
1394
+ * @param {number} dz
1395
+ * @param {number} px
1396
+ * @param {number} py
1397
+ * @param {number} pz
1398
+ * @returns {Float64Array}
1399
+ */
1400
+ export function ray_closest_point(ox, oy, oz, dx, dy, dz, px, py, pz) {
1401
+ const ret = wasm.ray_closest_point(ox, oy, oz, dx, dy, dz, px, py, pz);
1402
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1403
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1404
+ return v1;
1405
+ }
1406
+
1407
+ /**
1408
+ * Find the parameter t for the closest point on a ray to a given point.
1409
+ * The closest point is at: origin + t * direction
1410
+ * Note: t can be negative if the closest point is "behind" the ray origin.
1411
+ * @param {number} ox
1412
+ * @param {number} oy
1413
+ * @param {number} oz
1414
+ * @param {number} dx
1415
+ * @param {number} dy
1416
+ * @param {number} dz
1417
+ * @param {number} px
1418
+ * @param {number} py
1419
+ * @param {number} pz
1420
+ * @returns {number}
1421
+ */
1422
+ export function ray_closest_point_parameter(ox, oy, oz, dx, dy, dz, px, py, pz) {
1423
+ const ret = wasm.ray_closest_point_parameter(ox, oy, oz, dx, dy, dz, px, py, pz);
1424
+ return ret;
1425
+ }
1426
+
1427
+ /**
1428
+ * Compute the distance from a ray to a point.
1429
+ * Ray is defined by origin (ox, oy, oz) and direction (dx, dy, dz).
1430
+ * Direction should be normalized for accurate distance.
1431
+ * Returns the perpendicular distance from the ray to the point.
1432
+ * @param {number} ox
1433
+ * @param {number} oy
1434
+ * @param {number} oz
1435
+ * @param {number} dx
1436
+ * @param {number} dy
1437
+ * @param {number} dz
1438
+ * @param {number} px
1439
+ * @param {number} py
1440
+ * @param {number} pz
1441
+ * @returns {number}
1442
+ */
1443
+ export function ray_distance_to_point(ox, oy, oz, dx, dy, dz, px, py, pz) {
1444
+ const ret = wasm.ray_distance_to_point(ox, oy, oz, dx, dy, dz, px, py, pz);
1445
+ return ret;
1446
+ }
1447
+
1448
+ /**
1449
+ * Get a point along the ray at parameter t.
1450
+ * Returns [x, y, z] = origin + t * direction
1451
+ * @param {number} ox
1452
+ * @param {number} oy
1453
+ * @param {number} oz
1454
+ * @param {number} dx
1455
+ * @param {number} dy
1456
+ * @param {number} dz
1457
+ * @param {number} t
1458
+ * @returns {Float64Array}
1459
+ */
1460
+ export function ray_point_at(ox, oy, oz, dx, dy, dz, t) {
1461
+ const ret = wasm.ray_point_at(ox, oy, oz, dx, dy, dz, t);
1462
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1463
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1464
+ return v1;
1465
+ }
1466
+
1467
+ /**
1468
+ * Sample a NURBS curve.
1469
+ * Input: degree, then flat control points [x,y,z,...], then flat weights, then flat knots
1470
+ * Format: [degree, num_pts, x0,y0,z0, ..., w0,w1,..., k0,k1,...]
1471
+ * @param {Float64Array} data
1472
+ * @param {number} samples
1473
+ * @returns {Float64Array}
1474
+ */
1475
+ export function sample_nurbs_curve(data, samples) {
1476
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1477
+ const len0 = WASM_VECTOR_LEN;
1478
+ const ret = wasm.sample_nurbs_curve(ptr0, len0, samples);
1479
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1480
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1481
+ return v2;
1482
+ }
1483
+
1484
+ /**
1485
+ * Sweep a profile curve along a path curve using exact curve evaluation.
1486
+ * profile_data/path_data: encoded curve (see decode_curve)
1487
+ * Returns mesh buffers.
1488
+ * @param {Float64Array} profile_data
1489
+ * @param {Float64Array} path_data
1490
+ * @param {number} profile_segments
1491
+ * @param {number} path_segments
1492
+ * @param {boolean} with_caps
1493
+ * @returns {Float64Array}
1494
+ */
1495
+ export function sweep_curves(profile_data, path_data, profile_segments, path_segments, with_caps) {
1496
+ const ptr0 = passArrayF64ToWasm0(profile_data, wasm.__wbindgen_malloc);
1497
+ const len0 = WASM_VECTOR_LEN;
1498
+ const ptr1 = passArrayF64ToWasm0(path_data, wasm.__wbindgen_malloc);
1499
+ const len1 = WASM_VECTOR_LEN;
1500
+ const ret = wasm.sweep_curves(ptr0, len0, ptr1, len1, profile_segments, path_segments, with_caps);
1501
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1502
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1503
+ return v3;
1504
+ }
1505
+
1506
+ /**
1507
+ * Sweep a profile polyline along a path polyline.
1508
+ * profile_coords: flat [x,y,z,...] for profile curve
1509
+ * path_coords: flat [x,y,z,...] for path curve
1510
+ * with_caps: whether to close the ends
1511
+ * Returns mesh buffers.
1512
+ * @param {Float64Array} profile_coords
1513
+ * @param {Float64Array} path_coords
1514
+ * @param {boolean} with_caps
1515
+ * @returns {Float64Array}
1516
+ */
1517
+ export function sweep_polylines(profile_coords, path_coords, with_caps) {
1518
+ const ptr0 = passArrayF64ToWasm0(profile_coords, wasm.__wbindgen_malloc);
1519
+ const len0 = WASM_VECTOR_LEN;
1520
+ const ptr1 = passArrayF64ToWasm0(path_coords, wasm.__wbindgen_malloc);
1521
+ const len1 = WASM_VECTOR_LEN;
1522
+ const ret = wasm.sweep_polylines(ptr0, len0, ptr1, len1, with_caps);
1523
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1524
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1525
+ return v3;
1526
+ }
1527
+
1528
+ /**
1529
+ * Tessellate a NURBS surface to a mesh buffer.
1530
+ * Input format: [degree_u, degree_v, num_u, num_v, ...control_points(flat)..., ...weights(flat)..., ...knots_u..., ...knots_v..., u_segs, v_segs]
1531
+ * @param {Float64Array} data
1532
+ * @returns {Float64Array}
1533
+ */
1534
+ export function tessellate_nurbs_surface(data) {
1535
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1536
+ const len0 = WASM_VECTOR_LEN;
1537
+ const ret = wasm.tessellate_nurbs_surface(ptr0, len0);
1538
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1539
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1540
+ return v2;
1541
+ }
1542
+
1543
+ /**
1544
+ * Simple test function to verify WASM is working
1545
+ * @returns {string}
1546
+ */
1547
+ export function test_wasm() {
1548
+ let deferred1_0;
1549
+ let deferred1_1;
1550
+ try {
1551
+ const ret = wasm.test_wasm();
1552
+ deferred1_0 = ret[0];
1553
+ deferred1_1 = ret[1];
1554
+ return getStringFromWasm0(ret[0], ret[1]);
1555
+ } finally {
1556
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1557
+ }
1558
+ }
1559
+
1560
+ /**
1561
+ * Get version info
1562
+ * @returns {string}
1563
+ */
1564
+ export function version() {
1565
+ let deferred1_0;
1566
+ let deferred1_1;
1567
+ try {
1568
+ const ret = wasm.version();
1569
+ deferred1_0 = ret[0];
1570
+ deferred1_1 = ret[1];
1571
+ return getStringFromWasm0(ret[0], ret[1]);
1572
+ } finally {
1573
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1574
+ }
1575
+ }
1576
+
1577
+ function __wbg_get_imports() {
1578
+ const import0 = {
1579
+ __proto__: null,
1580
+ __wbindgen_init_externref_table: function() {
1581
+ const table = wasm.__wbindgen_externrefs;
1582
+ const offset = table.grow(4);
1583
+ table.set(0, undefined);
1584
+ table.set(offset + 0, undefined);
1585
+ table.set(offset + 1, null);
1586
+ table.set(offset + 2, true);
1587
+ table.set(offset + 3, false);
1588
+ },
1589
+ };
1590
+ return {
1591
+ __proto__: null,
1592
+ "./okgeometrycore_bg.js": import0,
1593
+ };
1594
+ }
1595
+
1596
+ function getArrayF64FromWasm0(ptr, len) {
1597
+ ptr = ptr >>> 0;
1598
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1599
+ }
1600
+
1601
+ let cachedFloat64ArrayMemory0 = null;
1602
+ function getFloat64ArrayMemory0() {
1603
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1604
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1605
+ }
1606
+ return cachedFloat64ArrayMemory0;
1607
+ }
1608
+
1609
+ function getStringFromWasm0(ptr, len) {
1610
+ ptr = ptr >>> 0;
1611
+ return decodeText(ptr, len);
1612
+ }
1613
+
1614
+ let cachedUint8ArrayMemory0 = null;
1615
+ function getUint8ArrayMemory0() {
1616
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1617
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1618
+ }
1619
+ return cachedUint8ArrayMemory0;
1620
+ }
1621
+
1622
+ function passArrayF64ToWasm0(arg, malloc) {
1623
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1624
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
1625
+ WASM_VECTOR_LEN = arg.length;
1626
+ return ptr;
1627
+ }
1628
+
1629
+ function passStringToWasm0(arg, malloc, realloc) {
1630
+ if (realloc === undefined) {
1631
+ const buf = cachedTextEncoder.encode(arg);
1632
+ const ptr = malloc(buf.length, 1) >>> 0;
1633
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1634
+ WASM_VECTOR_LEN = buf.length;
1635
+ return ptr;
1636
+ }
1637
+
1638
+ let len = arg.length;
1639
+ let ptr = malloc(len, 1) >>> 0;
1640
+
1641
+ const mem = getUint8ArrayMemory0();
1642
+
1643
+ let offset = 0;
1644
+
1645
+ for (; offset < len; offset++) {
1646
+ const code = arg.charCodeAt(offset);
1647
+ if (code > 0x7F) break;
1648
+ mem[ptr + offset] = code;
1649
+ }
1650
+ if (offset !== len) {
1651
+ if (offset !== 0) {
1652
+ arg = arg.slice(offset);
1653
+ }
1654
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1655
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1656
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1657
+
1658
+ offset += ret.written;
1659
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1660
+ }
1661
+
1662
+ WASM_VECTOR_LEN = offset;
1663
+ return ptr;
1664
+ }
1665
+
1666
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1667
+ cachedTextDecoder.decode();
1668
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1669
+ let numBytesDecoded = 0;
1670
+ function decodeText(ptr, len) {
1671
+ numBytesDecoded += len;
1672
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1673
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1674
+ cachedTextDecoder.decode();
1675
+ numBytesDecoded = len;
1676
+ }
1677
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1678
+ }
1679
+
1680
+ const cachedTextEncoder = new TextEncoder();
1681
+
1682
+ if (!('encodeInto' in cachedTextEncoder)) {
1683
+ cachedTextEncoder.encodeInto = function (arg, view) {
1684
+ const buf = cachedTextEncoder.encode(arg);
1685
+ view.set(buf);
1686
+ return {
1687
+ read: arg.length,
1688
+ written: buf.length
1689
+ };
1690
+ };
1691
+ }
1692
+
1693
+ let WASM_VECTOR_LEN = 0;
1694
+
1695
+ let wasmModule, wasm;
1696
+ function __wbg_finalize_init(instance, module) {
1697
+ wasm = instance.exports;
1698
+ wasmModule = module;
1699
+ cachedFloat64ArrayMemory0 = null;
1700
+ cachedUint8ArrayMemory0 = null;
1701
+ wasm.__wbindgen_start();
1702
+ return wasm;
1703
+ }
1704
+
1705
+ async function __wbg_load(module, imports) {
1706
+ if (typeof Response === 'function' && module instanceof Response) {
1707
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1708
+ try {
1709
+ return await WebAssembly.instantiateStreaming(module, imports);
1710
+ } catch (e) {
1711
+ const validResponse = module.ok && expectedResponseType(module.type);
1712
+
1713
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1714
+ 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);
1715
+
1716
+ } else { throw e; }
1717
+ }
1718
+ }
1719
+
1720
+ const bytes = await module.arrayBuffer();
1721
+ return await WebAssembly.instantiate(bytes, imports);
1722
+ } else {
1723
+ const instance = await WebAssembly.instantiate(module, imports);
1724
+
1725
+ if (instance instanceof WebAssembly.Instance) {
1726
+ return { instance, module };
1727
+ } else {
1728
+ return instance;
1729
+ }
1730
+ }
1731
+
1732
+ function expectedResponseType(type) {
1733
+ switch (type) {
1734
+ case 'basic': case 'cors': case 'default': return true;
1735
+ }
1736
+ return false;
1737
+ }
1738
+ }
1739
+
1740
+ function initSync(module) {
1741
+ if (wasm !== undefined) return wasm;
1742
+
1743
+
1744
+ if (module !== undefined) {
1745
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1746
+ ({module} = module)
1747
+ } else {
1748
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1749
+ }
1750
+ }
1751
+
1752
+ const imports = __wbg_get_imports();
1753
+ if (!(module instanceof WebAssembly.Module)) {
1754
+ module = new WebAssembly.Module(module);
1755
+ }
1756
+ const instance = new WebAssembly.Instance(module, imports);
1757
+ return __wbg_finalize_init(instance, module);
1758
+ }
1759
+
1760
+ async function __wbg_init(module_or_path) {
1761
+ if (wasm !== undefined) return wasm;
1762
+
1763
+
1764
+ if (module_or_path !== undefined) {
1765
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1766
+ ({module_or_path} = module_or_path)
1767
+ } else {
1768
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1769
+ }
1770
+ }
1771
+
1772
+ if (module_or_path === undefined) {
1773
+ module_or_path = new URL('okgeometrycore_bg.wasm', import.meta.url);
1774
+ }
1775
+ const imports = __wbg_get_imports();
1776
+
1777
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1778
+ module_or_path = fetch(module_or_path);
1779
+ }
1780
+
1781
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1782
+
1783
+ return __wbg_finalize_init(instance, module);
1784
+ }
1785
+
1786
+ export { initSync, __wbg_init as default };