okgeometry-api 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/Arc.js +1 -1
  2. package/dist/Arc.js.map +1 -1
  3. package/dist/Circle.js +1 -1
  4. package/dist/Circle.js.map +1 -1
  5. package/dist/Line.js +1 -1
  6. package/dist/Line.js.map +1 -1
  7. package/dist/Mesh.d.ts +101 -4
  8. package/dist/Mesh.d.ts.map +1 -1
  9. package/dist/Mesh.js +103 -5
  10. package/dist/Mesh.js.map +1 -1
  11. package/dist/NurbsCurve.js +1 -1
  12. package/dist/NurbsCurve.js.map +1 -1
  13. package/dist/NurbsSurface.d.ts.map +1 -1
  14. package/dist/NurbsSurface.js +10 -7
  15. package/dist/NurbsSurface.js.map +1 -1
  16. package/dist/PolyCurve.js +1 -1
  17. package/dist/PolyCurve.js.map +1 -1
  18. package/dist/Polyline.js +1 -1
  19. package/dist/Polyline.js.map +1 -1
  20. package/dist/Ray.js +1 -1
  21. package/dist/Ray.js.map +1 -1
  22. package/dist/engine.d.ts.map +1 -1
  23. package/dist/engine.js +1 -3
  24. package/dist/engine.js.map +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/wasm-base64.d.ts +1 -1
  29. package/dist/wasm-base64.d.ts.map +1 -1
  30. package/dist/wasm-base64.js +1 -1
  31. package/dist/wasm-base64.js.map +1 -1
  32. package/package.json +7 -6
  33. package/src/Arc.ts +117 -117
  34. package/src/Circle.ts +153 -153
  35. package/src/Line.ts +144 -144
  36. package/src/Mesh.ts +671 -452
  37. package/src/NurbsCurve.ts +240 -240
  38. package/src/NurbsSurface.ts +249 -245
  39. package/src/PolyCurve.ts +306 -306
  40. package/src/Polyline.ts +153 -153
  41. package/src/Ray.ts +90 -90
  42. package/src/engine.ts +9 -11
  43. package/src/index.ts +6 -0
  44. package/src/wasm-base64.ts +1 -1
  45. package/wasm/README.md +0 -104
  46. package/wasm/okgeometrycore.d.ts +0 -754
  47. package/wasm/okgeometrycore.js +0 -2005
  48. package/wasm/okgeometrycore_bg.d.ts +0 -3
  49. package/wasm/okgeometrycore_bg.js +0 -1686
  50. package/wasm/okgeometrycore_bg.wasm +0 -0
  51. package/wasm/okgeometrycore_bg.wasm.d.ts +0 -100
  52. package/wasm/package.json +0 -19
@@ -1,1686 +0,0 @@
1
- /**
2
- * Get the length of an arc.
3
- * @param {number} radius
4
- * @param {number} start_angle
5
- * @param {number} end_angle
6
- * @returns {number}
7
- */
8
- export function arc_length(radius, start_angle, end_angle) {
9
- const ret = wasm.arc_length(radius, start_angle, end_angle);
10
- return ret;
11
- }
12
-
13
- /**
14
- * Evaluate a point on an arc at parameter t ∈ [0,1].
15
- * Returns [x, y, z].
16
- * @param {number} cx
17
- * @param {number} cy
18
- * @param {number} cz
19
- * @param {number} nx
20
- * @param {number} ny
21
- * @param {number} nz
22
- * @param {number} radius
23
- * @param {number} start_angle
24
- * @param {number} end_angle
25
- * @param {number} t
26
- * @returns {Float64Array}
27
- */
28
- export function arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, t) {
29
- const ret = wasm.arc_point_at(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, t);
30
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
31
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
32
- return v1;
33
- }
34
-
35
- /**
36
- * Chamfer corners of a polyline by cutting each corner with a straight segment.
37
- * Input: flat coords [x1,y1,z1, ...], distance from corner to cut.
38
- * Output: encoded polycurve segments [segment_count, type, ...data, ...]
39
- * type 0 = Line: [sx,sy,sz, ex,ey,ez]
40
- * @param {Float64Array} coords
41
- * @param {number} distance
42
- * @returns {Float64Array}
43
- */
44
- export function chamfer_polycurve(coords, distance) {
45
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
46
- const len0 = WASM_VECTOR_LEN;
47
- const ret = wasm.chamfer_polycurve(ptr0, len0, distance);
48
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
49
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
50
- return v2;
51
- }
52
-
53
- /**
54
- * Get the circumference of a circle.
55
- * @param {number} radius
56
- * @returns {number}
57
- */
58
- export function circle_length(radius) {
59
- const ret = wasm.circle_length(radius);
60
- return ret;
61
- }
62
-
63
- /**
64
- * Evaluate a point on a circle at parameter t ∈ [0,1].
65
- * Returns [x, y, z].
66
- * @param {number} cx
67
- * @param {number} cy
68
- * @param {number} cz
69
- * @param {number} nx
70
- * @param {number} ny
71
- * @param {number} nz
72
- * @param {number} radius
73
- * @param {number} t
74
- * @returns {Float64Array}
75
- */
76
- export function circle_point_at(cx, cy, cz, nx, ny, nz, radius, t) {
77
- const ret = wasm.circle_point_at(cx, cy, cz, nx, ny, nz, radius, t);
78
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
79
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
80
- return v1;
81
- }
82
-
83
- /**
84
- * Create an arc and return sampled points
85
- * @param {number} cx
86
- * @param {number} cy
87
- * @param {number} cz
88
- * @param {number} nx
89
- * @param {number} ny
90
- * @param {number} nz
91
- * @param {number} radius
92
- * @param {number} start_angle
93
- * @param {number} end_angle
94
- * @param {number} samples
95
- * @returns {Float64Array}
96
- */
97
- export function create_arc(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, samples) {
98
- const ret = wasm.create_arc(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, samples);
99
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
100
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
101
- return v1;
102
- }
103
-
104
- /**
105
- * Create a circle and return sampled points
106
- * @param {number} cx
107
- * @param {number} cy
108
- * @param {number} cz
109
- * @param {number} nx
110
- * @param {number} ny
111
- * @param {number} nz
112
- * @param {number} radius
113
- * @param {number} samples
114
- * @returns {Float64Array}
115
- */
116
- export function create_circle(cx, cy, cz, nx, ny, nz, radius, samples) {
117
- const ret = wasm.create_circle(cx, cy, cz, nx, ny, nz, radius, samples);
118
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
119
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
120
- return v1;
121
- }
122
-
123
- /**
124
- * Create a line segment and return sampled points
125
- * @param {number} x1
126
- * @param {number} y1
127
- * @param {number} z1
128
- * @param {number} x2
129
- * @param {number} y2
130
- * @param {number} z2
131
- * @param {number} samples
132
- * @returns {Float64Array}
133
- */
134
- export function create_line(x1, y1, z1, x2, y2, z2, samples) {
135
- const ret = wasm.create_line(x1, y1, z1, x2, y2, z2, samples);
136
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
137
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
138
- return v1;
139
- }
140
-
141
- /**
142
- * Create a polyline and return the points
143
- * @param {Float64Array} coords
144
- * @param {number} samples_per_segment
145
- * @returns {Float64Array}
146
- */
147
- export function create_polyline(coords, samples_per_segment) {
148
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
149
- const len0 = WASM_VECTOR_LEN;
150
- const ret = wasm.create_polyline(ptr0, len0, samples_per_segment);
151
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
152
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
153
- return v2;
154
- }
155
-
156
- /**
157
- * Serialize a curve to a list of points for Three.js rendering
158
- * Returns a flat array of coordinates: [x1, y1, z1, x2, y2, z2, ...]
159
- * @param {string} curve_type
160
- * @param {Float64Array} params
161
- * @param {number} samples
162
- * @returns {Float64Array}
163
- */
164
- export function curve_to_points(curve_type, params, samples) {
165
- const ptr0 = passStringToWasm0(curve_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
166
- const len0 = WASM_VECTOR_LEN;
167
- const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
168
- const len1 = WASM_VECTOR_LEN;
169
- const ret = wasm.curve_to_points(ptr0, len0, ptr1, len1, samples);
170
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
171
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
172
- return v3;
173
- }
174
-
175
- /**
176
- * Evaluate a NURBS curve at normalized parameter t in [0,1].
177
- * Returns [x, y, z].
178
- * @param {Float64Array} data
179
- * @param {number} t
180
- * @returns {Float64Array}
181
- */
182
- export function evaluate_nurbs_curve_at(data, t) {
183
- const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
184
- const len0 = WASM_VECTOR_LEN;
185
- const ret = wasm.evaluate_nurbs_curve_at(ptr0, len0, t);
186
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
187
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
188
- return v2;
189
- }
190
-
191
- /**
192
- * Extrude a circle and return mesh buffers
193
- * @param {number} cx
194
- * @param {number} cy
195
- * @param {number} cz
196
- * @param {number} nx
197
- * @param {number} ny
198
- * @param {number} nz
199
- * @param {number} radius
200
- * @param {number} dx
201
- * @param {number} dy
202
- * @param {number} dz
203
- * @param {number} segments
204
- * @param {boolean} with_caps
205
- * @returns {Float64Array}
206
- */
207
- export function extrude_circle(cx, cy, cz, nx, ny, nz, radius, dx, dy, dz, segments, with_caps) {
208
- const ret = wasm.extrude_circle(cx, cy, cz, nx, ny, nz, radius, dx, dy, dz, segments, with_caps);
209
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
210
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
211
- return v1;
212
- }
213
-
214
- /**
215
- * Extrude a line segment and return mesh buffers
216
- * @param {number} x1
217
- * @param {number} y1
218
- * @param {number} z1
219
- * @param {number} x2
220
- * @param {number} y2
221
- * @param {number} z2
222
- * @param {number} dx
223
- * @param {number} dy
224
- * @param {number} dz
225
- * @param {number} segments
226
- * @returns {Float64Array}
227
- */
228
- export function extrude_line(x1, y1, z1, x2, y2, z2, dx, dy, dz, segments) {
229
- const ret = wasm.extrude_line(x1, y1, z1, x2, y2, z2, dx, dy, dz, segments);
230
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
231
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
232
- return v1;
233
- }
234
-
235
- /**
236
- * Extrude a polyline and return mesh buffers.
237
- * Uses the polyline's actual vertices (no resampling) to preserve sharp corners.
238
- * @param {Float64Array} coords
239
- * @param {number} dx
240
- * @param {number} dy
241
- * @param {number} dz
242
- * @param {number} _segments
243
- * @param {boolean} with_caps
244
- * @returns {Float64Array}
245
- */
246
- export function extrude_polyline(coords, dx, dy, dz, _segments, with_caps) {
247
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
248
- const len0 = WASM_VECTOR_LEN;
249
- const ret = wasm.extrude_polyline(ptr0, len0, dx, dy, dz, _segments, with_caps);
250
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
251
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
252
- return v2;
253
- }
254
-
255
- /**
256
- * Fillet corners of a polyline with arcs of a given radius.
257
- * Input: flat coords [x1,y1,z1, ...], radius, plane normal (nx,ny,nz; 0,0,0 for auto).
258
- * Output: encoded polycurve segments [segment_count, type, ...data, type, ...data, ...]
259
- * type 0 = Line: [sx,sy,sz, ex,ey,ez]
260
- * type 1 = Arc: [cx,cy,cz, nx,ny,nz, radius, start_angle, end_angle]
261
- * @param {Float64Array} coords
262
- * @param {number} radius
263
- * @param {number} nx
264
- * @param {number} ny
265
- * @param {number} nz
266
- * @returns {Float64Array}
267
- */
268
- export function fillet_polycurve(coords, radius, nx, ny, nz) {
269
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
270
- const len0 = WASM_VECTOR_LEN;
271
- const ret = wasm.fillet_polycurve(ptr0, len0, radius, nx, ny, nz);
272
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
273
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
274
- return v2;
275
- }
276
-
277
- /**
278
- * Get the length of a line segment.
279
- * @param {number} x1
280
- * @param {number} y1
281
- * @param {number} z1
282
- * @param {number} x2
283
- * @param {number} y2
284
- * @param {number} z2
285
- * @returns {number}
286
- */
287
- export function line_length(x1, y1, z1, x2, y2, z2) {
288
- const ret = wasm.line_length(x1, y1, z1, x2, y2, z2);
289
- return ret;
290
- }
291
-
292
- /**
293
- * Offset a line segment perpendicular to line direction relative to reference normal.
294
- * Returns [startX,startY,startZ,endX,endY,endZ]
295
- * @param {number} x1
296
- * @param {number} y1
297
- * @param {number} z1
298
- * @param {number} x2
299
- * @param {number} y2
300
- * @param {number} z2
301
- * @param {number} distance
302
- * @param {number} nx
303
- * @param {number} ny
304
- * @param {number} nz
305
- * @returns {Float64Array}
306
- */
307
- export function line_offset(x1, y1, z1, x2, y2, z2, distance, nx, ny, nz) {
308
- const ret = wasm.line_offset(x1, y1, z1, x2, y2, z2, distance, nx, ny, nz);
309
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
310
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
311
- return v1;
312
- }
313
-
314
- /**
315
- * Evaluate a point on a line segment at parameter t ∈ [0,1].
316
- * Returns [x, y, z].
317
- * @param {number} x1
318
- * @param {number} y1
319
- * @param {number} z1
320
- * @param {number} x2
321
- * @param {number} y2
322
- * @param {number} z2
323
- * @param {number} t
324
- * @returns {Float64Array}
325
- */
326
- export function line_point_at(x1, y1, z1, x2, y2, z2, t) {
327
- const ret = wasm.line_point_at(x1, y1, z1, x2, y2, z2, t);
328
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
329
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
330
- return v1;
331
- }
332
-
333
- /**
334
- * Get the tangent direction of a line segment. Returns [x, y, z].
335
- * @param {number} x1
336
- * @param {number} y1
337
- * @param {number} z1
338
- * @param {number} x2
339
- * @param {number} y2
340
- * @param {number} z2
341
- * @returns {Float64Array}
342
- */
343
- export function line_tangent(x1, y1, z1, x2, y2, z2) {
344
- const ret = wasm.line_tangent(x1, y1, z1, x2, y2, z2);
345
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
346
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
347
- return v1;
348
- }
349
-
350
- /**
351
- * Loft between multiple circles
352
- *
353
- * # Parameters
354
- * * `circle_data` - Flat array of circle definitions [cx, cy, cz, nx, ny, nz, radius, ...]
355
- * * `segments` - Number of segments to sample along each curve
356
- * * `with_caps` - Whether to create end caps
357
- *
358
- * # Returns
359
- * Mesh buffers for the lofted surface
360
- * @param {Float64Array} circle_data
361
- * @param {number} segments
362
- * @param {boolean} with_caps
363
- * @returns {Float64Array}
364
- */
365
- export function loft_circles(circle_data, segments, with_caps) {
366
- const ptr0 = passArrayF64ToWasm0(circle_data, wasm.__wbindgen_malloc);
367
- const len0 = WASM_VECTOR_LEN;
368
- const ret = wasm.loft_circles(ptr0, len0, segments, with_caps);
369
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
370
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
371
- return v2;
372
- }
373
-
374
- /**
375
- * Loft a NURBS surface through multiple NURBS curves.
376
- * Input: [num_curves, degree_v, curve1_data..., curve2_data..., ...]
377
- * Each curve_data: [degree, num_pts, x,y,z,..., w0,w1,..., k0,k1,...]
378
- * Returns the NurbsSurface data (same format as tessellate input, without u_segs/v_segs).
379
- * @param {Float64Array} data
380
- * @returns {Float64Array}
381
- */
382
- export function loft_nurbs_surface(data) {
383
- const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
384
- const len0 = WASM_VECTOR_LEN;
385
- const ret = wasm.loft_nurbs_surface(ptr0, len0);
386
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
387
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
388
- return v2;
389
- }
390
-
391
- /**
392
- * Loft between multiple polylines
393
- *
394
- * # Parameters
395
- * * `polyline_data` - Flat array where each polyline is prefixed by its point count:
396
- * [count1, x1, y1, z1, x2, y2, z2, ..., count2, x1, y1, z1, ...]
397
- * * `_segments` - Ignored for polylines (kept for API compat). Points are used directly.
398
- * * `with_caps` - Whether to create end caps (fan triangulation from center)
399
- *
400
- * # Returns
401
- * Mesh buffers for the lofted surface
402
- * @param {Float64Array} polyline_data
403
- * @param {number} _segments
404
- * @param {boolean} with_caps
405
- * @returns {Float64Array}
406
- */
407
- export function loft_polylines(polyline_data, _segments, with_caps) {
408
- const ptr0 = passArrayF64ToWasm0(polyline_data, wasm.__wbindgen_malloc);
409
- const len0 = WASM_VECTOR_LEN;
410
- const ret = wasm.loft_polylines(ptr0, len0, _segments, with_caps);
411
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
412
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
413
- return v2;
414
- }
415
-
416
- /**
417
- * Make multiple NURBS curves compatible (same knot vectors, same CP count).
418
- * Input: [curve_count, curve1_data..., curve2_data..., ...]
419
- * Each curve: [degree, num_cp, cp_xyz..., weights..., knots...]
420
- * Output: same format with unified curves.
421
- * @param {Float64Array} curves_data
422
- * @returns {Float64Array}
423
- */
424
- export function make_nurbs_curves_compatible(curves_data) {
425
- const ptr0 = passArrayF64ToWasm0(curves_data, wasm.__wbindgen_malloc);
426
- const len0 = WASM_VECTOR_LEN;
427
- const ret = wasm.make_nurbs_curves_compatible(ptr0, len0);
428
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
429
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
430
- return v2;
431
- }
432
-
433
- /**
434
- * Apply a 4x4 transformation matrix to a mesh.
435
- * matrix: flat [m00,m01,m02,m03, m10,m11,..., m30,m31,m32,m33] (16 elements, row-major)
436
- * @param {number} vertex_count
437
- * @param {Float64Array} buffer
438
- * @param {Float64Array} matrix
439
- * @returns {Float64Array}
440
- */
441
- export function mesh_apply_matrix(vertex_count, buffer, matrix) {
442
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
443
- const len0 = WASM_VECTOR_LEN;
444
- const ptr1 = passArrayF64ToWasm0(matrix, wasm.__wbindgen_malloc);
445
- const len1 = WASM_VECTOR_LEN;
446
- const ret = wasm.mesh_apply_matrix(vertex_count, ptr0, len0, ptr1, len1);
447
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
448
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
449
- return v3;
450
- }
451
-
452
- /**
453
- * Perform boolean intersection on two meshes
454
- * @param {number} vertex_count_a
455
- * @param {Float64Array} buffer_a
456
- * @param {number} vertex_count_b
457
- * @param {Float64Array} buffer_b
458
- * @returns {Float64Array}
459
- */
460
- export function mesh_boolean_intersection(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
461
- const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
462
- const len0 = WASM_VECTOR_LEN;
463
- const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
464
- const len1 = WASM_VECTOR_LEN;
465
- const ret = wasm.mesh_boolean_intersection(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
466
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
467
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
468
- return v3;
469
- }
470
-
471
- /**
472
- * Perform boolean operation on two meshes
473
- *
474
- * # Parameters
475
- * * `vertex_count_a` - Number of vertices in mesh A
476
- * * `buffer_a` - Buffer for mesh A [vertices..., indices...]
477
- * * `vertex_count_b` - Number of vertices in mesh B
478
- * * `buffer_b` - Buffer for mesh B [vertices..., indices...]
479
- * * `operation` - Operation type: "union", "intersection", or "subtraction"
480
- *
481
- * # Returns
482
- * Result mesh buffer [vertices..., indices...]
483
- * @param {number} vertex_count_a
484
- * @param {Float64Array} buffer_a
485
- * @param {number} vertex_count_b
486
- * @param {Float64Array} buffer_b
487
- * @param {string} operation
488
- * @returns {Float64Array}
489
- */
490
- export function mesh_boolean_operation(vertex_count_a, buffer_a, vertex_count_b, buffer_b, operation) {
491
- const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
492
- const len0 = WASM_VECTOR_LEN;
493
- const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
494
- const len1 = WASM_VECTOR_LEN;
495
- const ptr2 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
496
- const len2 = WASM_VECTOR_LEN;
497
- const ret = wasm.mesh_boolean_operation(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1, ptr2, len2);
498
- var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
499
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
500
- return v4;
501
- }
502
-
503
- /**
504
- * Perform boolean subtraction on two meshes (A - B)
505
- * @param {number} vertex_count_a
506
- * @param {Float64Array} buffer_a
507
- * @param {number} vertex_count_b
508
- * @param {Float64Array} buffer_b
509
- * @returns {Float64Array}
510
- */
511
- export function mesh_boolean_subtraction(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
512
- const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
513
- const len0 = WASM_VECTOR_LEN;
514
- const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
515
- const len1 = WASM_VECTOR_LEN;
516
- const ret = wasm.mesh_boolean_subtraction(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
517
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
518
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
519
- return v3;
520
- }
521
-
522
- /**
523
- * Perform boolean union on two meshes
524
- * @param {number} vertex_count_a
525
- * @param {Float64Array} buffer_a
526
- * @param {number} vertex_count_b
527
- * @param {Float64Array} buffer_b
528
- * @returns {Float64Array}
529
- */
530
- export function mesh_boolean_union(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
531
- const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
532
- const len0 = WASM_VECTOR_LEN;
533
- const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
534
- const len1 = WASM_VECTOR_LEN;
535
- const ret = wasm.mesh_boolean_union(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
536
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
537
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
538
- return v3;
539
- }
540
-
541
- /**
542
- * Extract boundary (perimeter) edges from a mesh as polylines.
543
- * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
544
- * @param {number} vertex_count
545
- * @param {Float64Array} buffer
546
- * @returns {Float64Array}
547
- */
548
- export function mesh_boundary_polylines(vertex_count, buffer) {
549
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
550
- const len0 = WASM_VECTOR_LEN;
551
- const ret = wasm.mesh_boundary_polylines(vertex_count, ptr0, len0);
552
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
553
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
554
- return v2;
555
- }
556
-
557
- /**
558
- * Coplanar connected face groups.
559
- * Output format:
560
- * [groupCount, triCount, tri..., centroidX,centroidY,centroidZ, normalX,normalY,normalZ, ...]
561
- * @param {number} vertex_count
562
- * @param {Float64Array} buffer
563
- * @returns {Float64Array}
564
- */
565
- export function mesh_build_coplanar_connected_face_groups(vertex_count, buffer) {
566
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
567
- const len0 = WASM_VECTOR_LEN;
568
- const ret = wasm.mesh_build_coplanar_connected_face_groups(vertex_count, ptr0, len0);
569
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
570
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
571
- return v2;
572
- }
573
-
574
- /**
575
- * Chamfer all edges of a primitive mesh (flat bevel)
576
- *
577
- * # Arguments
578
- * * `mesh_type` - "box", "cylinder", or "prism"
579
- * * `params` - Parameters: [width,height,depth] for box, [radius,height,segments] for cylinder/prism
580
- * * `offset` - Chamfer offset distance
581
- *
582
- * # Returns
583
- * Result mesh buffer [vertexCount, vertices..., indices...]
584
- * @param {string} mesh_type
585
- * @param {Float64Array} params
586
- * @param {number} offset
587
- * @returns {Float64Array}
588
- */
589
- export function mesh_chamfer_all_edges(mesh_type, params, offset) {
590
- const ptr0 = passStringToWasm0(mesh_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
591
- const len0 = WASM_VECTOR_LEN;
592
- const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
593
- const len1 = WASM_VECTOR_LEN;
594
- const ret = wasm.mesh_chamfer_all_edges(ptr0, len0, ptr1, len1, offset);
595
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
596
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
597
- return v3;
598
- }
599
-
600
- /**
601
- * Compute planar curve normal from ordered points.
602
- * @param {Float64Array} coords
603
- * @param {boolean} closed
604
- * @returns {Float64Array}
605
- */
606
- export function mesh_compute_planar_curve_normal(coords, closed) {
607
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
608
- const len0 = WASM_VECTOR_LEN;
609
- const ret = wasm.mesh_compute_planar_curve_normal(ptr0, len0, closed);
610
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
611
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
612
- return v2;
613
- }
614
-
615
- /**
616
- * Odd/even mesh containment test.
617
- * @param {number} vertex_count
618
- * @param {Float64Array} buffer
619
- * @param {number} px
620
- * @param {number} py
621
- * @param {number} pz
622
- * @returns {boolean}
623
- */
624
- export function mesh_contains_point(vertex_count, buffer, px, py, pz) {
625
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
626
- const len0 = WASM_VECTOR_LEN;
627
- const ret = wasm.mesh_contains_point(vertex_count, ptr0, len0, px, py, pz);
628
- return ret !== 0;
629
- }
630
-
631
- /**
632
- * Create a box mesh and return buffers
633
- * Returns [vertices..., indices...]
634
- * @param {number} width
635
- * @param {number} height
636
- * @param {number} depth
637
- * @returns {Float64Array}
638
- */
639
- export function mesh_create_box(width, height, depth) {
640
- const ret = wasm.mesh_create_box(width, height, depth);
641
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
642
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
643
- return v1;
644
- }
645
-
646
- /**
647
- * Create a cone mesh and return buffers
648
- * @param {number} radius
649
- * @param {number} height
650
- * @param {number} segments
651
- * @returns {Float64Array}
652
- */
653
- export function mesh_create_cone(radius, height, segments) {
654
- const ret = wasm.mesh_create_cone(radius, height, segments);
655
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
656
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
657
- return v1;
658
- }
659
-
660
- /**
661
- * Create a cylinder mesh and return buffers
662
- * @param {number} radius
663
- * @param {number} height
664
- * @param {number} segments
665
- * @returns {Float64Array}
666
- */
667
- export function mesh_create_cylinder(radius, height, segments) {
668
- const ret = wasm.mesh_create_cylinder(radius, height, segments);
669
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
670
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
671
- return v1;
672
- }
673
-
674
- /**
675
- * Create a prism mesh and return buffers
676
- * @param {number} radius
677
- * @param {number} height
678
- * @param {number} sides
679
- * @returns {Float64Array}
680
- */
681
- export function mesh_create_prism(radius, height, sides) {
682
- const ret = wasm.mesh_create_prism(radius, height, sides);
683
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
684
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
685
- return v1;
686
- }
687
-
688
- /**
689
- * Create a sphere mesh and return buffers
690
- * @param {number} radius
691
- * @param {number} segments
692
- * @param {number} rings
693
- * @returns {Float64Array}
694
- */
695
- export function mesh_create_sphere(radius, segments, rings) {
696
- const ret = wasm.mesh_create_sphere(radius, segments, rings);
697
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
698
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
699
- return v1;
700
- }
701
-
702
- /**
703
- * Evaluate a point on a mesh surface at parametric coordinates (u, v).
704
- * Maps u ∈ [0,1] and v ∈ [0,1] to the mesh's AABB bounding box,
705
- * then casts a ray perpendicular to the best-fit projection plane.
706
- * Returns [x, y, z] of the intersection point, or [NaN, NaN, NaN] if no hit.
707
- * @param {number} vertex_count
708
- * @param {Float64Array} buffer
709
- * @param {number} u
710
- * @param {number} v
711
- * @returns {Float64Array}
712
- */
713
- export function mesh_evaluate(vertex_count, buffer, u, v) {
714
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
715
- const len0 = WASM_VECTOR_LEN;
716
- const ret = wasm.mesh_evaluate(vertex_count, ptr0, len0, u, v);
717
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
718
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
719
- return v2;
720
- }
721
-
722
- /**
723
- * Export a mesh to OBJ format
724
- * Takes mesh buffers as input (same format as mesh_to_buffers output)
725
- * Returns OBJ string
726
- * @param {number} vertex_count
727
- * @param {Float64Array} buffer
728
- * @returns {string}
729
- */
730
- export function mesh_export_obj(vertex_count, buffer) {
731
- let deferred2_0;
732
- let deferred2_1;
733
- try {
734
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
735
- const len0 = WASM_VECTOR_LEN;
736
- const ret = wasm.mesh_export_obj(vertex_count, ptr0, len0);
737
- deferred2_0 = ret[0];
738
- deferred2_1 = ret[1];
739
- return getStringFromWasm0(ret[0], ret[1]);
740
- } finally {
741
- wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
742
- }
743
- }
744
-
745
- /**
746
- * Push/pull a planar face set by moving its coplanar connected region.
747
- * @param {number} vertex_count
748
- * @param {Float64Array} buffer
749
- * @param {number} face_index
750
- * @param {number} distance
751
- * @returns {Float64Array}
752
- */
753
- export function mesh_extrude_face(vertex_count, buffer, face_index, distance) {
754
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
755
- const len0 = WASM_VECTOR_LEN;
756
- const ret = wasm.mesh_extrude_face(vertex_count, ptr0, len0, face_index, distance);
757
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
758
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
759
- return v2;
760
- }
761
-
762
- /**
763
- * Extrude planar curve profile by normal * height.
764
- * @param {Float64Array} coords
765
- * @param {number} nx
766
- * @param {number} ny
767
- * @param {number} nz
768
- * @param {number} height
769
- * @param {boolean} closed
770
- * @returns {Float64Array}
771
- */
772
- export function mesh_extrude_planar_curve(coords, nx, ny, nz, height, closed) {
773
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
774
- const len0 = WASM_VECTOR_LEN;
775
- const ret = wasm.mesh_extrude_planar_curve(ptr0, len0, nx, ny, nz, height, closed);
776
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
777
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
778
- return v2;
779
- }
780
-
781
- /**
782
- * Find the best matching coplanar connected face group by normal and optional near-point.
783
- * Output format: [centroidX, centroidY, centroidZ, normalX, normalY, normalZ] or [].
784
- * @param {number} vertex_count
785
- * @param {Float64Array} buffer
786
- * @param {number} nx
787
- * @param {number} ny
788
- * @param {number} nz
789
- * @param {number} near_x
790
- * @param {number} near_y
791
- * @param {number} near_z
792
- * @param {boolean} use_near_point
793
- * @returns {Float64Array}
794
- */
795
- export function mesh_find_face_group_by_normal(vertex_count, buffer, nx, ny, nz, near_x, near_y, near_z, use_near_point) {
796
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
797
- const len0 = WASM_VECTOR_LEN;
798
- 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);
799
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
800
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
801
- return v2;
802
- }
803
-
804
- /**
805
- * Find the coplanar connected face group containing triangle_index.
806
- * Output format: [centroidX, centroidY, centroidZ, normalX, normalY, normalZ] or [].
807
- * @param {number} vertex_count
808
- * @param {Float64Array} buffer
809
- * @param {number} triangle_index
810
- * @returns {Float64Array}
811
- */
812
- export function mesh_find_face_group_by_triangle_index(vertex_count, buffer, triangle_index) {
813
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
814
- const len0 = WASM_VECTOR_LEN;
815
- const ret = wasm.mesh_find_face_group_by_triangle_index(vertex_count, ptr0, len0, triangle_index);
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
- * Axis-aligned bounding box as [minX, minY, minZ, maxX, maxY, maxZ].
823
- * @param {number} vertex_count
824
- * @param {Float64Array} buffer
825
- * @returns {Float64Array}
826
- */
827
- export function mesh_get_bounds(vertex_count, buffer) {
828
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
829
- const len0 = WASM_VECTOR_LEN;
830
- const ret = wasm.mesh_get_bounds(vertex_count, ptr0, len0);
831
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
832
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
833
- return v2;
834
- }
835
-
836
- /**
837
- * Coplanar connected face-group centroid containing a given triangle face index.
838
- * Output format: [x, y, z] or [] when unavailable.
839
- * @param {number} vertex_count
840
- * @param {Float64Array} buffer
841
- * @param {number} face_index
842
- * @returns {Float64Array}
843
- */
844
- export function mesh_get_coplanar_face_group_centroid(vertex_count, buffer, face_index) {
845
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
846
- const len0 = WASM_VECTOR_LEN;
847
- const ret = wasm.mesh_get_coplanar_face_group_centroid(vertex_count, ptr0, len0, face_index);
848
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
849
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
850
- return v2;
851
- }
852
-
853
- /**
854
- * Edge-connected coplanar triangle indices as [count, i0, i1, ...].
855
- * @param {number} vertex_count
856
- * @param {Float64Array} buffer
857
- * @param {number} face_index
858
- * @returns {Float64Array}
859
- */
860
- export function mesh_get_coplanar_face_indices(vertex_count, buffer, face_index) {
861
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
862
- const len0 = WASM_VECTOR_LEN;
863
- const ret = wasm.mesh_get_coplanar_face_indices(vertex_count, ptr0, len0, face_index);
864
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
865
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
866
- return v2;
867
- }
868
-
869
- /**
870
- * Coplanar connected face region projected to a plane basis.
871
- * Output format:
872
- * [faceCount, faceIndex0, faceIndex1, ..., uMin, uMax, vMin, vMax]
873
- * @param {number} vertex_count
874
- * @param {Float64Array} buffer
875
- * @param {number} face_index
876
- * @param {number} ox
877
- * @param {number} oy
878
- * @param {number} oz
879
- * @param {number} ux
880
- * @param {number} uy
881
- * @param {number} uz
882
- * @param {number} vx
883
- * @param {number} vy
884
- * @param {number} vz
885
- * @param {number} margin_scale
886
- * @param {number} min_margin
887
- * @returns {Float64Array}
888
- */
889
- 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) {
890
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
891
- const len0 = WASM_VECTOR_LEN;
892
- 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);
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
- * Unique undirected triangle edges as [edgeCount, v0a, v0b, v1a, v1b, ...].
900
- * @param {number} vertex_count
901
- * @param {Float64Array} buffer
902
- * @returns {Float64Array}
903
- */
904
- export function mesh_get_edge_vertex_pairs(vertex_count, buffer) {
905
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
906
- const len0 = WASM_VECTOR_LEN;
907
- const ret = wasm.mesh_get_edge_vertex_pairs(vertex_count, ptr0, len0);
908
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
909
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
910
- return v2;
911
- }
912
-
913
- /**
914
- * Face area.
915
- * @param {number} vertex_count
916
- * @param {Float64Array} buffer
917
- * @param {number} face_index
918
- * @returns {number}
919
- */
920
- export function mesh_get_face_area(vertex_count, buffer, face_index) {
921
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
922
- const len0 = WASM_VECTOR_LEN;
923
- const ret = wasm.mesh_get_face_area(vertex_count, ptr0, len0, face_index);
924
- return ret;
925
- }
926
-
927
- /**
928
- * Face centroid as [x, y, z].
929
- * @param {number} vertex_count
930
- * @param {Float64Array} buffer
931
- * @param {number} face_index
932
- * @returns {Float64Array}
933
- */
934
- export function mesh_get_face_centroid(vertex_count, buffer, face_index) {
935
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
936
- const len0 = WASM_VECTOR_LEN;
937
- const ret = wasm.mesh_get_face_centroid(vertex_count, ptr0, len0, face_index);
938
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
939
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
940
- return v2;
941
- }
942
-
943
- /**
944
- * Face normal as [x, y, z].
945
- * @param {number} vertex_count
946
- * @param {Float64Array} buffer
947
- * @param {number} face_index
948
- * @returns {Float64Array}
949
- */
950
- export function mesh_get_face_normal(vertex_count, buffer, face_index) {
951
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
952
- const len0 = WASM_VECTOR_LEN;
953
- const ret = wasm.mesh_get_face_normal(vertex_count, ptr0, len0, face_index);
954
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
955
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
956
- return v2;
957
- }
958
-
959
- /**
960
- * Get mesh statistics
961
- * Returns [vertex_count, face_count, edge_count]
962
- * @param {number} vertex_count
963
- * @param {Float64Array} buffer
964
- * @returns {Float64Array}
965
- */
966
- export function mesh_get_stats(vertex_count, buffer) {
967
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
968
- const len0 = WASM_VECTOR_LEN;
969
- const ret = wasm.mesh_get_stats(vertex_count, ptr0, len0);
970
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
971
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
972
- return v2;
973
- }
974
-
975
- /**
976
- * Import OBJ data and return mesh buffers
977
- * @param {string} obj_data
978
- * @returns {Float64Array}
979
- */
980
- export function mesh_import_obj(obj_data) {
981
- const ptr0 = passStringToWasm0(obj_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
982
- const len0 = WASM_VECTOR_LEN;
983
- const ret = wasm.mesh_import_obj(ptr0, len0);
984
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
985
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
986
- return v2;
987
- }
988
-
989
- /**
990
- * Check if triangulated mesh is a closed volume (no welded boundary edges).
991
- * @param {number} vertex_count
992
- * @param {Float64Array} buffer
993
- * @returns {boolean}
994
- */
995
- export function mesh_is_closed_volume(vertex_count, buffer) {
996
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
997
- const len0 = WASM_VECTOR_LEN;
998
- const ret = wasm.mesh_is_closed_volume(vertex_count, ptr0, len0);
999
- return ret !== 0;
1000
- }
1001
-
1002
- /**
1003
- * Merge multiple mesh buffers while preserving per-mesh vertex order and index remapping.
1004
- * Input format: [mesh_count, len1, mesh1..., len2, mesh2..., ...]
1005
- * @param {Float64Array} mesh_data
1006
- * @returns {Float64Array}
1007
- */
1008
- export function mesh_merge(mesh_data) {
1009
- const ptr0 = passArrayF64ToWasm0(mesh_data, wasm.__wbindgen_malloc);
1010
- const len0 = WASM_VECTOR_LEN;
1011
- const ret = wasm.mesh_merge(ptr0, len0);
1012
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1013
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1014
- return v2;
1015
- }
1016
-
1017
- /**
1018
- * Intersect two meshes, returning intersection polyline points.
1019
- * Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
1020
- * @param {number} va_count
1021
- * @param {Float64Array} buffer_a
1022
- * @param {number} vb_count
1023
- * @param {Float64Array} buffer_b
1024
- * @returns {Float64Array}
1025
- */
1026
- export function mesh_mesh_intersect(va_count, buffer_a, vb_count, buffer_b) {
1027
- const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
1028
- const len0 = WASM_VECTOR_LEN;
1029
- const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
1030
- const len1 = WASM_VECTOR_LEN;
1031
- const ret = wasm.mesh_mesh_intersect(va_count, ptr0, len0, vb_count, ptr1, len1);
1032
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1033
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1034
- return v3;
1035
- }
1036
-
1037
- /**
1038
- * Create a planar patch mesh from boundary points using CDT.
1039
- * Correctly handles concave polygons (unlike fan triangulation).
1040
- * Input: flat coordinate array [x1,y1,z1, x2,y2,z2, ...]
1041
- * Output: mesh buffer [vertexCount, x1,y1,z1,..., i0,i1,i2, ...]
1042
- * @param {Float64Array} coords
1043
- * @returns {Float64Array}
1044
- */
1045
- export function mesh_patch_from_points(coords) {
1046
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1047
- const len0 = WASM_VECTOR_LEN;
1048
- const ret = wasm.mesh_patch_from_points(ptr0, len0);
1049
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1050
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1051
- return v2;
1052
- }
1053
-
1054
- /**
1055
- * Intersect a mesh with a plane, returning polyline points.
1056
- * Input: vertex_count, mesh_buffer..., nx, ny, nz, d
1057
- * Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
1058
- * @param {number} vertex_count
1059
- * @param {Float64Array} buffer
1060
- * @param {number} nx
1061
- * @param {number} ny
1062
- * @param {number} nz
1063
- * @param {number} d
1064
- * @returns {Float64Array}
1065
- */
1066
- export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
1067
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1068
- const len0 = WASM_VECTOR_LEN;
1069
- const ret = wasm.mesh_plane_intersect(vertex_count, ptr0, len0, nx, ny, nz, d);
1070
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1071
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1072
- return v2;
1073
- }
1074
-
1075
- /**
1076
- * Shift closed boolean cutter curve and adjust height.
1077
- * Returns [height, epsilon, pointCount, x,y,z,...]
1078
- * @param {Float64Array} coords
1079
- * @param {boolean} closed
1080
- * @param {number} nx
1081
- * @param {number} ny
1082
- * @param {number} nz
1083
- * @param {number} height
1084
- * @returns {Float64Array}
1085
- */
1086
- export function mesh_prepare_boolean_cutter_curve(coords, closed, nx, ny, nz, height) {
1087
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1088
- const len0 = WASM_VECTOR_LEN;
1089
- const ret = wasm.mesh_prepare_boolean_cutter_curve(ptr0, len0, closed, nx, ny, nz, height);
1090
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1091
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1092
- return v2;
1093
- }
1094
-
1095
- /**
1096
- * Raycast against mesh and return closest hit.
1097
- * Output: [] when no hit, otherwise [pointX,pointY,pointZ, normalX,normalY,normalZ, faceIndex, distance]
1098
- * @param {number} vertex_count
1099
- * @param {Float64Array} buffer
1100
- * @param {number} ox
1101
- * @param {number} oy
1102
- * @param {number} oz
1103
- * @param {number} dx
1104
- * @param {number} dy
1105
- * @param {number} dz
1106
- * @param {number} max_distance
1107
- * @returns {Float64Array}
1108
- */
1109
- export function mesh_raycast(vertex_count, buffer, ox, oy, oz, dx, dy, dz, max_distance) {
1110
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1111
- const len0 = WASM_VECTOR_LEN;
1112
- const ret = wasm.mesh_raycast(vertex_count, ptr0, len0, ox, oy, oz, dx, dy, dz, max_distance);
1113
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1114
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1115
- return v2;
1116
- }
1117
-
1118
- /**
1119
- * Raycast against mesh and return all hits sorted by distance.
1120
- * Output: [hitCount, (point, normal, faceIndex, distance)*]
1121
- * @param {number} vertex_count
1122
- * @param {Float64Array} buffer
1123
- * @param {number} ox
1124
- * @param {number} oy
1125
- * @param {number} oz
1126
- * @param {number} dx
1127
- * @param {number} dy
1128
- * @param {number} dz
1129
- * @param {number} max_distance
1130
- * @returns {Float64Array}
1131
- */
1132
- export function mesh_raycast_all(vertex_count, buffer, ox, oy, oz, dx, dy, dz, max_distance) {
1133
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1134
- const len0 = WASM_VECTOR_LEN;
1135
- const ret = wasm.mesh_raycast_all(vertex_count, ptr0, len0, ox, oy, oz, dx, dy, dz, max_distance);
1136
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1137
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1138
- return v2;
1139
- }
1140
-
1141
- /**
1142
- * Raycast against many meshes packed as:
1143
- * [meshCount, meshLen0, meshRaw0..., meshLen1, meshRaw1..., ...]
1144
- * Output: [hitCount, meshIndex, pointX,pointY,pointZ, normalX,normalY,normalZ, faceIndex, distance, ...]
1145
- * @param {Float64Array} mesh_data
1146
- * @param {number} ox
1147
- * @param {number} oy
1148
- * @param {number} oz
1149
- * @param {number} dx
1150
- * @param {number} dy
1151
- * @param {number} dz
1152
- * @param {number} max_distance
1153
- * @returns {Float64Array}
1154
- */
1155
- export function mesh_raycast_many(mesh_data, ox, oy, oz, dx, dy, dz, max_distance) {
1156
- const ptr0 = passArrayF64ToWasm0(mesh_data, wasm.__wbindgen_malloc);
1157
- const len0 = WASM_VECTOR_LEN;
1158
- const ret = wasm.mesh_raycast_many(ptr0, len0, ox, oy, oz, dx, dy, dz, max_distance);
1159
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1160
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1161
- return v2;
1162
- }
1163
-
1164
- /**
1165
- * Rotate a mesh around an arbitrary axis and return new buffers
1166
- * Axis is defined by (ax, ay, az), angle in radians
1167
- * @param {number} vertex_count
1168
- * @param {Float64Array} buffer
1169
- * @param {number} ax
1170
- * @param {number} ay
1171
- * @param {number} az
1172
- * @param {number} angle
1173
- * @returns {Float64Array}
1174
- */
1175
- export function mesh_rotate(vertex_count, buffer, ax, ay, az, angle) {
1176
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1177
- const len0 = WASM_VECTOR_LEN;
1178
- const ret = wasm.mesh_rotate(vertex_count, ptr0, len0, ax, ay, az, angle);
1179
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1180
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1181
- return v2;
1182
- }
1183
-
1184
- /**
1185
- * Scale a mesh non-uniformly and return new buffers
1186
- * @param {number} vertex_count
1187
- * @param {Float64Array} buffer
1188
- * @param {number} sx
1189
- * @param {number} sy
1190
- * @param {number} sz
1191
- * @returns {Float64Array}
1192
- */
1193
- export function mesh_scale(vertex_count, buffer, sx, sy, sz) {
1194
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1195
- const len0 = WASM_VECTOR_LEN;
1196
- const ret = wasm.mesh_scale(vertex_count, ptr0, len0, sx, sy, sz);
1197
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1198
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1199
- return v2;
1200
- }
1201
-
1202
- /**
1203
- * Translate a mesh by an offset vector and return new buffers
1204
- * @param {number} vertex_count
1205
- * @param {Float64Array} buffer
1206
- * @param {number} dx
1207
- * @param {number} dy
1208
- * @param {number} dz
1209
- * @returns {Float64Array}
1210
- */
1211
- export function mesh_translate(vertex_count, buffer, dx, dy, dz) {
1212
- const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
1213
- const len0 = WASM_VECTOR_LEN;
1214
- const ret = wasm.mesh_translate(vertex_count, ptr0, len0, dx, dy, dz);
1215
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1216
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1217
- return v2;
1218
- }
1219
-
1220
- /**
1221
- * Intersect two NURBS curves.
1222
- * Returns: [num_points, x,y,z, ...]
1223
- * @param {Float64Array} data_a
1224
- * @param {Float64Array} data_b
1225
- * @returns {Float64Array}
1226
- */
1227
- export function nurbs_curve_curve_intersect(data_a, data_b) {
1228
- const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
1229
- const len0 = WASM_VECTOR_LEN;
1230
- const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
1231
- const len1 = WASM_VECTOR_LEN;
1232
- const ret = wasm.nurbs_curve_curve_intersect(ptr0, len0, ptr1, len1);
1233
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1234
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1235
- return v3;
1236
- }
1237
-
1238
- /**
1239
- * Intersect a NURBS curve with a plane.
1240
- * Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
1241
- * Returns: [num_points, x,y,z, x,y,z, ...]
1242
- * @param {Float64Array} data
1243
- * @param {number} nx
1244
- * @param {number} ny
1245
- * @param {number} nz
1246
- * @param {number} d
1247
- * @returns {Float64Array}
1248
- */
1249
- export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
1250
- const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1251
- const len0 = WASM_VECTOR_LEN;
1252
- const ret = wasm.nurbs_curve_plane_intersect(ptr0, len0, nx, ny, nz, d);
1253
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1254
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1255
- return v2;
1256
- }
1257
-
1258
- /**
1259
- * Evaluate a NURBS surface at (u, v) parameters.
1260
- * Input format: same as tessellate but last 2 values are u, v instead of u_segs, v_segs
1261
- * Returns [x, y, z]
1262
- * @param {Float64Array} data
1263
- * @param {number} u
1264
- * @param {number} v
1265
- * @returns {Float64Array}
1266
- */
1267
- export function nurbs_surface_evaluate(data, u, v) {
1268
- const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1269
- const len0 = WASM_VECTOR_LEN;
1270
- const ret = wasm.nurbs_surface_evaluate(ptr0, len0, u, v);
1271
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1272
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1273
- return v2;
1274
- }
1275
-
1276
- /**
1277
- * Intersect a NURBS surface with a plane.
1278
- * Input: same surface format as tessellate_nurbs_surface, then plane (nx,ny,nz,d) appended.
1279
- * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
1280
- * @param {Float64Array} surface_data
1281
- * @param {number} nx
1282
- * @param {number} ny
1283
- * @param {number} nz
1284
- * @param {number} d
1285
- * @param {number} tess
1286
- * @returns {Float64Array}
1287
- */
1288
- export function nurbs_surface_plane_intersect(surface_data, nx, ny, nz, d, tess) {
1289
- const ptr0 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
1290
- const len0 = WASM_VECTOR_LEN;
1291
- const ret = wasm.nurbs_surface_plane_intersect(ptr0, len0, nx, ny, nz, d, tess);
1292
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1293
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1294
- return v2;
1295
- }
1296
-
1297
- /**
1298
- * Intersect two NURBS surfaces.
1299
- * Returns polyline buffer.
1300
- * @param {Float64Array} data_a
1301
- * @param {Float64Array} data_b
1302
- * @param {number} tess
1303
- * @returns {Float64Array}
1304
- */
1305
- export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
1306
- const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
1307
- const len0 = WASM_VECTOR_LEN;
1308
- const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
1309
- const len1 = WASM_VECTOR_LEN;
1310
- const ret = wasm.nurbs_surface_surface_intersect(ptr0, len0, ptr1, len1, tess);
1311
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1312
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1313
- return v3;
1314
- }
1315
-
1316
- /**
1317
- * Offset a polyline by a distance in a given plane.
1318
- * If nx=ny=nz=0, the plane normal is auto-detected.
1319
- * Returns flat [x1,y1,z1, x2,y2,z2, ...] of the offset polyline.
1320
- * @param {Float64Array} coords
1321
- * @param {number} distance
1322
- * @param {number} nx
1323
- * @param {number} ny
1324
- * @param {number} nz
1325
- * @returns {Float64Array}
1326
- */
1327
- export function offset_polyline_curve(coords, distance, nx, ny, nz) {
1328
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1329
- const len0 = WASM_VECTOR_LEN;
1330
- const ret = wasm.offset_polyline_curve(ptr0, len0, distance, nx, ny, nz);
1331
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1332
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1333
- return v2;
1334
- }
1335
-
1336
- /**
1337
- * Convert a polycurve (Line/Arc segments) to an exact NURBS curve.
1338
- * Input format: [segment_count, type1, ...data1..., type2, ...data2..., ...]
1339
- * type 0 = Line (6 floats: start_xyz, end_xyz)
1340
- * type 1 = Arc (9 floats: center_xyz, normal_xyz, radius, start_angle, end_angle)
1341
- * Output format: [degree, num_cp, cp_x1,y1,z1,..., w1,w2,..., k1,k2,...]
1342
- * @param {Float64Array} segment_data
1343
- * @returns {Float64Array}
1344
- */
1345
- export function polycurve_to_nurbs(segment_data) {
1346
- const ptr0 = passArrayF64ToWasm0(segment_data, wasm.__wbindgen_malloc);
1347
- const len0 = WASM_VECTOR_LEN;
1348
- const ret = wasm.polycurve_to_nurbs(ptr0, len0);
1349
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1350
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1351
- return v2;
1352
- }
1353
-
1354
- /**
1355
- * Get the total length of a polyline.
1356
- * Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
1357
- * @param {Float64Array} coords
1358
- * @returns {number}
1359
- */
1360
- export function polyline_length(coords) {
1361
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1362
- const len0 = WASM_VECTOR_LEN;
1363
- const ret = wasm.polyline_length(ptr0, len0);
1364
- return ret;
1365
- }
1366
-
1367
- /**
1368
- * Evaluate a point on a polyline at parameter t ∈ [0,1].
1369
- * Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
1370
- * Returns [x, y, z].
1371
- * @param {Float64Array} coords
1372
- * @param {number} t
1373
- * @returns {Float64Array}
1374
- */
1375
- export function polyline_point_at(coords, t) {
1376
- const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
1377
- const len0 = WASM_VECTOR_LEN;
1378
- const ret = wasm.polyline_point_at(ptr0, len0, t);
1379
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1380
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1381
- return v2;
1382
- }
1383
-
1384
- /**
1385
- * Find the closest point on a ray to a given point.
1386
- * Returns [x, y, z] of the closest point on the ray.
1387
- * @param {number} ox
1388
- * @param {number} oy
1389
- * @param {number} oz
1390
- * @param {number} dx
1391
- * @param {number} dy
1392
- * @param {number} dz
1393
- * @param {number} px
1394
- * @param {number} py
1395
- * @param {number} pz
1396
- * @returns {Float64Array}
1397
- */
1398
- export function ray_closest_point(ox, oy, oz, dx, dy, dz, px, py, pz) {
1399
- const ret = wasm.ray_closest_point(ox, oy, oz, dx, dy, dz, px, py, pz);
1400
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1401
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1402
- return v1;
1403
- }
1404
-
1405
- /**
1406
- * Find the parameter t for the closest point on a ray to a given point.
1407
- * The closest point is at: origin + t * direction
1408
- * Note: t can be negative if the closest point is "behind" the ray origin.
1409
- * @param {number} ox
1410
- * @param {number} oy
1411
- * @param {number} oz
1412
- * @param {number} dx
1413
- * @param {number} dy
1414
- * @param {number} dz
1415
- * @param {number} px
1416
- * @param {number} py
1417
- * @param {number} pz
1418
- * @returns {number}
1419
- */
1420
- export function ray_closest_point_parameter(ox, oy, oz, dx, dy, dz, px, py, pz) {
1421
- const ret = wasm.ray_closest_point_parameter(ox, oy, oz, dx, dy, dz, px, py, pz);
1422
- return ret;
1423
- }
1424
-
1425
- /**
1426
- * Compute the distance from a ray to a point.
1427
- * Ray is defined by origin (ox, oy, oz) and direction (dx, dy, dz).
1428
- * Direction should be normalized for accurate distance.
1429
- * Returns the perpendicular distance from the ray to the point.
1430
- * @param {number} ox
1431
- * @param {number} oy
1432
- * @param {number} oz
1433
- * @param {number} dx
1434
- * @param {number} dy
1435
- * @param {number} dz
1436
- * @param {number} px
1437
- * @param {number} py
1438
- * @param {number} pz
1439
- * @returns {number}
1440
- */
1441
- export function ray_distance_to_point(ox, oy, oz, dx, dy, dz, px, py, pz) {
1442
- const ret = wasm.ray_distance_to_point(ox, oy, oz, dx, dy, dz, px, py, pz);
1443
- return ret;
1444
- }
1445
-
1446
- /**
1447
- * Get a point along the ray at parameter t.
1448
- * Returns [x, y, z] = origin + t * direction
1449
- * @param {number} ox
1450
- * @param {number} oy
1451
- * @param {number} oz
1452
- * @param {number} dx
1453
- * @param {number} dy
1454
- * @param {number} dz
1455
- * @param {number} t
1456
- * @returns {Float64Array}
1457
- */
1458
- export function ray_point_at(ox, oy, oz, dx, dy, dz, t) {
1459
- const ret = wasm.ray_point_at(ox, oy, oz, dx, dy, dz, t);
1460
- var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1461
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1462
- return v1;
1463
- }
1464
-
1465
- /**
1466
- * Sample a NURBS curve.
1467
- * Input: degree, then flat control points [x,y,z,...], then flat weights, then flat knots
1468
- * Format: [degree, num_pts, x0,y0,z0, ..., w0,w1,..., k0,k1,...]
1469
- * @param {Float64Array} data
1470
- * @param {number} samples
1471
- * @returns {Float64Array}
1472
- */
1473
- export function sample_nurbs_curve(data, samples) {
1474
- const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1475
- const len0 = WASM_VECTOR_LEN;
1476
- const ret = wasm.sample_nurbs_curve(ptr0, len0, samples);
1477
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1478
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1479
- return v2;
1480
- }
1481
-
1482
- /**
1483
- * Sweep a profile curve along a path curve using exact curve evaluation.
1484
- * profile_data/path_data: encoded curve (see decode_curve)
1485
- * Returns mesh buffers.
1486
- * @param {Float64Array} profile_data
1487
- * @param {Float64Array} path_data
1488
- * @param {number} profile_segments
1489
- * @param {number} path_segments
1490
- * @param {boolean} with_caps
1491
- * @returns {Float64Array}
1492
- */
1493
- export function sweep_curves(profile_data, path_data, profile_segments, path_segments, with_caps) {
1494
- const ptr0 = passArrayF64ToWasm0(profile_data, wasm.__wbindgen_malloc);
1495
- const len0 = WASM_VECTOR_LEN;
1496
- const ptr1 = passArrayF64ToWasm0(path_data, wasm.__wbindgen_malloc);
1497
- const len1 = WASM_VECTOR_LEN;
1498
- const ret = wasm.sweep_curves(ptr0, len0, ptr1, len1, profile_segments, path_segments, with_caps);
1499
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1500
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1501
- return v3;
1502
- }
1503
-
1504
- /**
1505
- * Sweep a profile polyline along a path polyline.
1506
- * profile_coords: flat [x,y,z,...] for profile curve
1507
- * path_coords: flat [x,y,z,...] for path curve
1508
- * with_caps: whether to close the ends
1509
- * Returns mesh buffers.
1510
- * @param {Float64Array} profile_coords
1511
- * @param {Float64Array} path_coords
1512
- * @param {boolean} with_caps
1513
- * @returns {Float64Array}
1514
- */
1515
- export function sweep_polylines(profile_coords, path_coords, with_caps) {
1516
- const ptr0 = passArrayF64ToWasm0(profile_coords, wasm.__wbindgen_malloc);
1517
- const len0 = WASM_VECTOR_LEN;
1518
- const ptr1 = passArrayF64ToWasm0(path_coords, wasm.__wbindgen_malloc);
1519
- const len1 = WASM_VECTOR_LEN;
1520
- const ret = wasm.sweep_polylines(ptr0, len0, ptr1, len1, with_caps);
1521
- var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1522
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1523
- return v3;
1524
- }
1525
-
1526
- /**
1527
- * Tessellate a NURBS surface to a mesh buffer.
1528
- * Input format: [degree_u, degree_v, num_u, num_v, ...control_points(flat)..., ...weights(flat)..., ...knots_u..., ...knots_v..., u_segs, v_segs]
1529
- * @param {Float64Array} data
1530
- * @returns {Float64Array}
1531
- */
1532
- export function tessellate_nurbs_surface(data) {
1533
- const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
1534
- const len0 = WASM_VECTOR_LEN;
1535
- const ret = wasm.tessellate_nurbs_surface(ptr0, len0);
1536
- var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
1537
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
1538
- return v2;
1539
- }
1540
-
1541
- /**
1542
- * Simple test function to verify WASM is working
1543
- * @returns {string}
1544
- */
1545
- export function test_wasm() {
1546
- let deferred1_0;
1547
- let deferred1_1;
1548
- try {
1549
- const ret = wasm.test_wasm();
1550
- deferred1_0 = ret[0];
1551
- deferred1_1 = ret[1];
1552
- return getStringFromWasm0(ret[0], ret[1]);
1553
- } finally {
1554
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1555
- }
1556
- }
1557
-
1558
- /**
1559
- * Get version info
1560
- * @returns {string}
1561
- */
1562
- export function version() {
1563
- let deferred1_0;
1564
- let deferred1_1;
1565
- try {
1566
- const ret = wasm.version();
1567
- deferred1_0 = ret[0];
1568
- deferred1_1 = ret[1];
1569
- return getStringFromWasm0(ret[0], ret[1]);
1570
- } finally {
1571
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1572
- }
1573
- }
1574
- export function __wbindgen_init_externref_table() {
1575
- const table = wasm.__wbindgen_externrefs;
1576
- const offset = table.grow(4);
1577
- table.set(0, undefined);
1578
- table.set(offset + 0, undefined);
1579
- table.set(offset + 1, null);
1580
- table.set(offset + 2, true);
1581
- table.set(offset + 3, false);
1582
- }
1583
- function getArrayF64FromWasm0(ptr, len) {
1584
- ptr = ptr >>> 0;
1585
- return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1586
- }
1587
-
1588
- let cachedFloat64ArrayMemory0 = null;
1589
- function getFloat64ArrayMemory0() {
1590
- if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1591
- cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1592
- }
1593
- return cachedFloat64ArrayMemory0;
1594
- }
1595
-
1596
- function getStringFromWasm0(ptr, len) {
1597
- ptr = ptr >>> 0;
1598
- return decodeText(ptr, len);
1599
- }
1600
-
1601
- let cachedUint8ArrayMemory0 = null;
1602
- function getUint8ArrayMemory0() {
1603
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1604
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1605
- }
1606
- return cachedUint8ArrayMemory0;
1607
- }
1608
-
1609
- function passArrayF64ToWasm0(arg, malloc) {
1610
- const ptr = malloc(arg.length * 8, 8) >>> 0;
1611
- getFloat64ArrayMemory0().set(arg, ptr / 8);
1612
- WASM_VECTOR_LEN = arg.length;
1613
- return ptr;
1614
- }
1615
-
1616
- function passStringToWasm0(arg, malloc, realloc) {
1617
- if (realloc === undefined) {
1618
- const buf = cachedTextEncoder.encode(arg);
1619
- const ptr = malloc(buf.length, 1) >>> 0;
1620
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1621
- WASM_VECTOR_LEN = buf.length;
1622
- return ptr;
1623
- }
1624
-
1625
- let len = arg.length;
1626
- let ptr = malloc(len, 1) >>> 0;
1627
-
1628
- const mem = getUint8ArrayMemory0();
1629
-
1630
- let offset = 0;
1631
-
1632
- for (; offset < len; offset++) {
1633
- const code = arg.charCodeAt(offset);
1634
- if (code > 0x7F) break;
1635
- mem[ptr + offset] = code;
1636
- }
1637
- if (offset !== len) {
1638
- if (offset !== 0) {
1639
- arg = arg.slice(offset);
1640
- }
1641
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1642
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1643
- const ret = cachedTextEncoder.encodeInto(arg, view);
1644
-
1645
- offset += ret.written;
1646
- ptr = realloc(ptr, len, offset, 1) >>> 0;
1647
- }
1648
-
1649
- WASM_VECTOR_LEN = offset;
1650
- return ptr;
1651
- }
1652
-
1653
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1654
- cachedTextDecoder.decode();
1655
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
1656
- let numBytesDecoded = 0;
1657
- function decodeText(ptr, len) {
1658
- numBytesDecoded += len;
1659
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1660
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1661
- cachedTextDecoder.decode();
1662
- numBytesDecoded = len;
1663
- }
1664
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1665
- }
1666
-
1667
- const cachedTextEncoder = new TextEncoder();
1668
-
1669
- if (!('encodeInto' in cachedTextEncoder)) {
1670
- cachedTextEncoder.encodeInto = function (arg, view) {
1671
- const buf = cachedTextEncoder.encode(arg);
1672
- view.set(buf);
1673
- return {
1674
- read: arg.length,
1675
- written: buf.length
1676
- };
1677
- };
1678
- }
1679
-
1680
- let WASM_VECTOR_LEN = 0;
1681
-
1682
-
1683
- let wasm;
1684
- export function __wbg_set_wasm(val) {
1685
- wasm = val;
1686
- }