okgeometry-api 1.26.1 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/Arc.js +1 -1
  2. package/dist/Arc.js.map +1 -1
  3. package/dist/Brep.d.ts +18 -0
  4. package/dist/Brep.d.ts.map +1 -1
  5. package/dist/Brep.js +32 -1
  6. package/dist/Brep.js.map +1 -1
  7. package/dist/Circle.js +1 -1
  8. package/dist/Circle.js.map +1 -1
  9. package/dist/Line.js +1 -1
  10. package/dist/Line.js.map +1 -1
  11. package/dist/Mesh.d.ts +71 -0
  12. package/dist/Mesh.d.ts.map +1 -1
  13. package/dist/Mesh.js +264 -21
  14. package/dist/Mesh.js.map +1 -1
  15. package/dist/MeshSurface.js +1 -1
  16. package/dist/MeshSurface.js.map +1 -1
  17. package/dist/NurbsCurve.d.ts +6 -0
  18. package/dist/NurbsCurve.d.ts.map +1 -1
  19. package/dist/NurbsCurve.js +10 -1
  20. package/dist/NurbsCurve.js.map +1 -1
  21. package/dist/NurbsSurface.js +1 -1
  22. package/dist/NurbsSurface.js.map +1 -1
  23. package/dist/PolyCurve.d.ts +15 -0
  24. package/dist/PolyCurve.d.ts.map +1 -1
  25. package/dist/PolyCurve.js +31 -1
  26. package/dist/PolyCurve.js.map +1 -1
  27. package/dist/Polyline.d.ts +6 -0
  28. package/dist/Polyline.d.ts.map +1 -1
  29. package/dist/Polyline.js +12 -1
  30. package/dist/Polyline.js.map +1 -1
  31. package/dist/Ray.js +1 -1
  32. package/dist/Ray.js.map +1 -1
  33. package/dist/SculptSession.js +1 -1
  34. package/dist/SculptSession.js.map +1 -1
  35. package/dist/engine-threaded.d.ts +2 -0
  36. package/dist/engine-threaded.d.ts.map +1 -0
  37. package/dist/engine-threaded.js +33 -0
  38. package/dist/engine-threaded.js.map +1 -0
  39. package/dist/engine.d.ts +21 -0
  40. package/dist/engine.d.ts.map +1 -1
  41. package/dist/engine.js +42 -0
  42. package/dist/engine.js.map +1 -1
  43. package/dist/index.d.ts +2 -2
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/mesh-boolean.pool.d.ts +23 -1
  48. package/dist/mesh-boolean.pool.d.ts.map +1 -1
  49. package/dist/mesh-boolean.pool.js +97 -12
  50. package/dist/mesh-boolean.pool.js.map +1 -1
  51. package/dist/mesh-boolean.protocol.d.ts +21 -1
  52. package/dist/mesh-boolean.protocol.d.ts.map +1 -1
  53. package/dist/mesh-boolean.protocol.js.map +1 -1
  54. package/dist/mesh-boolean.worker.d.ts.map +1 -1
  55. package/dist/mesh-boolean.worker.js +94 -1
  56. package/dist/mesh-boolean.worker.js.map +1 -1
  57. package/dist/wasm-active.d.ts +20 -0
  58. package/dist/wasm-active.d.ts.map +1 -0
  59. package/dist/wasm-active.js +26 -0
  60. package/dist/wasm-active.js.map +1 -0
  61. package/dist/wasm-base64-threaded.d.ts +2 -0
  62. package/dist/wasm-base64-threaded.d.ts.map +1 -0
  63. package/dist/wasm-base64-threaded.js +3 -0
  64. package/dist/wasm-base64-threaded.js.map +1 -0
  65. package/dist/wasm-base64.d.ts +1 -1
  66. package/dist/wasm-base64.d.ts.map +1 -1
  67. package/dist/wasm-base64.js +1 -1
  68. package/dist/wasm-base64.js.map +1 -1
  69. package/dist/wasm-bindings-threaded.d.ts +2716 -0
  70. package/dist/wasm-bindings-threaded.d.ts.map +1 -0
  71. package/dist/wasm-bindings-threaded.js +5088 -0
  72. package/dist/wasm-bindings-threaded.js.map +1 -0
  73. package/dist/wasm-bindings.d.ts +182 -0
  74. package/dist/wasm-bindings.d.ts.map +1 -1
  75. package/dist/wasm-bindings.js +288 -0
  76. package/dist/wasm-bindings.js.map +1 -1
  77. package/dist/workerHelpers-threaded.d.ts +2 -0
  78. package/dist/workerHelpers-threaded.d.ts.map +1 -0
  79. package/dist/workerHelpers-threaded.js +100 -0
  80. package/dist/workerHelpers-threaded.js.map +1 -0
  81. package/package.json +10 -3
  82. package/src/Arc.ts +117 -117
  83. package/src/Brep.ts +45 -1
  84. package/src/Circle.ts +166 -166
  85. package/src/Line.ts +171 -171
  86. package/src/Mesh.ts +361 -45
  87. package/src/MeshSurface.ts +1 -1
  88. package/src/NurbsCurve.ts +671 -655
  89. package/src/NurbsSurface.ts +721 -721
  90. package/src/PolyCurve.ts +249 -203
  91. package/src/Polyline.ts +333 -316
  92. package/src/Ray.ts +90 -90
  93. package/src/SculptSession.ts +377 -377
  94. package/src/engine-threaded.ts +39 -0
  95. package/src/engine.ts +46 -0
  96. package/src/index.ts +3 -1
  97. package/src/mesh-boolean.pool.ts +208 -86
  98. package/src/mesh-boolean.protocol.ts +44 -1
  99. package/src/mesh-boolean.worker.ts +170 -56
  100. package/src/wasm-active.ts +31 -0
  101. package/src/wasm-base64-threaded.ts +2 -0
  102. package/src/wasm-base64.ts +1 -1
  103. package/src/wasm-bindings-threaded.d.ts +2027 -0
  104. package/src/wasm-bindings-threaded.js +5317 -0
  105. package/src/wasm-bindings.d.ts +142 -0
  106. package/src/wasm-bindings.js +307 -0
  107. package/src/workerHelpers-threaded.js +107 -0
@@ -2086,6 +2086,18 @@ export function mesh_boundary_edge_segments(vertex_count, buffer) {
2086
2086
  return v2;
2087
2087
  }
2088
2088
 
2089
+ /**
2090
+ * Handle variant of `mesh_boundary_edge_segments`.
2091
+ * @param {number} id
2092
+ * @returns {Float64Array}
2093
+ */
2094
+ export function mesh_boundary_edge_segments_h(id) {
2095
+ const ret = wasm.mesh_boundary_edge_segments_h(id);
2096
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2097
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2098
+ return v1;
2099
+ }
2100
+
2089
2101
  /**
2090
2102
  * Extract boundary (perimeter) edges from a mesh as polylines.
2091
2103
  * Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
@@ -2143,6 +2155,19 @@ export function mesh_build_render_buffers(vertex_count, buffer, crease_angle_deg
2143
2155
  return v2;
2144
2156
  }
2145
2157
 
2158
+ /**
2159
+ * Handle variant of `mesh_build_render_buffers`.
2160
+ * @param {number} id
2161
+ * @param {number} crease_angle_deg
2162
+ * @returns {Float32Array}
2163
+ */
2164
+ export function mesh_build_render_buffers_h(id, crease_angle_deg) {
2165
+ const ret = wasm.mesh_build_render_buffers_h(id, crease_angle_deg);
2166
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
2167
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2168
+ return v1;
2169
+ }
2170
+
2146
2171
  /**
2147
2172
  * Chamfer all edges of a primitive mesh (flat bevel)
2148
2173
  *
@@ -2489,6 +2514,18 @@ export function mesh_feature_edge_chains(vertex_count, buffer) {
2489
2514
  return v2;
2490
2515
  }
2491
2516
 
2517
+ /**
2518
+ * Handle variant of `mesh_feature_edge_chains`.
2519
+ * @param {number} id
2520
+ * @returns {Float64Array}
2521
+ */
2522
+ export function mesh_feature_edge_chains_h(id) {
2523
+ const ret = wasm.mesh_feature_edge_chains_h(id);
2524
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2525
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2526
+ return v1;
2527
+ }
2528
+
2492
2529
  /**
2493
2530
  * Find the best matching coplanar connected face group by normal and optional near-point.
2494
2531
  * Output format: [centroidX, centroidY, centroidZ, normalX, normalY, normalZ] or [].
@@ -2512,6 +2549,25 @@ export function mesh_find_face_group_by_normal(vertex_count, buffer, nx, ny, nz,
2512
2549
  return v2;
2513
2550
  }
2514
2551
 
2552
+ /**
2553
+ * Handle variant of `mesh_find_face_group_by_normal`.
2554
+ * @param {number} id
2555
+ * @param {number} nx
2556
+ * @param {number} ny
2557
+ * @param {number} nz
2558
+ * @param {number} near_x
2559
+ * @param {number} near_y
2560
+ * @param {number} near_z
2561
+ * @param {boolean} use_near_point
2562
+ * @returns {Float64Array}
2563
+ */
2564
+ export function mesh_find_face_group_by_normal_h(id, nx, ny, nz, near_x, near_y, near_z, use_near_point) {
2565
+ const ret = wasm.mesh_find_face_group_by_normal_h(id, nx, ny, nz, near_x, near_y, near_z, use_near_point);
2566
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2567
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2568
+ return v1;
2569
+ }
2570
+
2515
2571
  /**
2516
2572
  * Find the coplanar connected face group containing triangle_index.
2517
2573
  * Output format: [centroidX, centroidY, centroidZ, normalX, normalY, normalZ] or [].
@@ -2529,6 +2585,19 @@ export function mesh_find_face_group_by_triangle_index(vertex_count, buffer, tri
2529
2585
  return v2;
2530
2586
  }
2531
2587
 
2588
+ /**
2589
+ * Handle variant of `mesh_find_face_group_by_triangle_index`.
2590
+ * @param {number} id
2591
+ * @param {number} triangle_index
2592
+ * @returns {Float64Array}
2593
+ */
2594
+ export function mesh_find_face_group_by_triangle_index_h(id, triangle_index) {
2595
+ const ret = wasm.mesh_find_face_group_by_triangle_index_h(id, triangle_index);
2596
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2597
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2598
+ return v1;
2599
+ }
2600
+
2532
2601
  /**
2533
2602
  * Axis-aligned bounding box as [minX, minY, minZ, maxX, maxY, maxZ].
2534
2603
  * @param {number} vertex_count
@@ -2561,6 +2630,19 @@ export function mesh_get_coplanar_face_group_centroid(vertex_count, buffer, face
2561
2630
  return v2;
2562
2631
  }
2563
2632
 
2633
+ /**
2634
+ * Handle variant of `mesh_get_coplanar_face_group_centroid`.
2635
+ * @param {number} id
2636
+ * @param {number} face_index
2637
+ * @returns {Float64Array}
2638
+ */
2639
+ export function mesh_get_coplanar_face_group_centroid_h(id, face_index) {
2640
+ const ret = wasm.mesh_get_coplanar_face_group_centroid_h(id, face_index);
2641
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2642
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2643
+ return v1;
2644
+ }
2645
+
2564
2646
  /**
2565
2647
  * Edge-connected coplanar triangle indices as [count, i0, i1, ...].
2566
2648
  * @param {number} vertex_count
@@ -2577,6 +2659,19 @@ export function mesh_get_coplanar_face_indices(vertex_count, buffer, face_index)
2577
2659
  return v2;
2578
2660
  }
2579
2661
 
2662
+ /**
2663
+ * Handle variant of `mesh_get_coplanar_face_indices`.
2664
+ * @param {number} id
2665
+ * @param {number} face_index
2666
+ * @returns {Float64Array}
2667
+ */
2668
+ export function mesh_get_coplanar_face_indices_h(id, face_index) {
2669
+ const ret = wasm.mesh_get_coplanar_face_indices_h(id, face_index);
2670
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2671
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2672
+ return v1;
2673
+ }
2674
+
2580
2675
  /**
2581
2676
  * Coplanar connected face region projected to a plane basis.
2582
2677
  * Output format:
@@ -2621,6 +2716,18 @@ export function mesh_get_edge_vertex_pairs(vertex_count, buffer) {
2621
2716
  return v2;
2622
2717
  }
2623
2718
 
2719
+ /**
2720
+ * Handle variant of `mesh_get_edge_vertex_pairs`.
2721
+ * @param {number} id
2722
+ * @returns {Float64Array}
2723
+ */
2724
+ export function mesh_get_edge_vertex_pairs_h(id) {
2725
+ const ret = wasm.mesh_get_edge_vertex_pairs_h(id);
2726
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2727
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2728
+ return v1;
2729
+ }
2730
+
2624
2731
  /**
2625
2732
  * Face area.
2626
2733
  * @param {number} vertex_count
@@ -2659,6 +2766,19 @@ export function mesh_get_face_boundary_loops(vertex_count, buffer, face_index) {
2659
2766
  return v2;
2660
2767
  }
2661
2768
 
2769
+ /**
2770
+ * Handle variant of `mesh_get_face_boundary_loops`.
2771
+ * @param {number} id
2772
+ * @param {number} face_index
2773
+ * @returns {Float64Array}
2774
+ */
2775
+ export function mesh_get_face_boundary_loops_h(id, face_index) {
2776
+ const ret = wasm.mesh_get_face_boundary_loops_h(id, face_index);
2777
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2778
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2779
+ return v1;
2780
+ }
2781
+
2662
2782
  /**
2663
2783
  * Face centroid as [x, y, z].
2664
2784
  * @param {number} vertex_count
@@ -2712,6 +2832,20 @@ export function mesh_get_smooth_face_group(vertex_count, buffer, face_index, max
2712
2832
  return v2;
2713
2833
  }
2714
2834
 
2835
+ /**
2836
+ * Handle variant of `mesh_get_smooth_face_group`.
2837
+ * @param {number} id
2838
+ * @param {number} face_index
2839
+ * @param {number} max_angle_deg
2840
+ * @returns {Float64Array}
2841
+ */
2842
+ export function mesh_get_smooth_face_group_h(id, face_index, max_angle_deg) {
2843
+ const ret = wasm.mesh_get_smooth_face_group_h(id, face_index, max_angle_deg);
2844
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
2845
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
2846
+ return v1;
2847
+ }
2848
+
2715
2849
  /**
2716
2850
  * Get mesh statistics
2717
2851
  * Returns [vertex_count, face_count, edge_count]
@@ -3079,6 +3213,44 @@ export function mesh_raycast_all(vertex_count, buffer, ox, oy, oz, dx, dy, dz, m
3079
3213
  return v2;
3080
3214
  }
3081
3215
 
3216
+ /**
3217
+ * Handle variant of `mesh_raycast_all` — reuses the stored mesh's cached BVH.
3218
+ * @param {number} id
3219
+ * @param {number} ox
3220
+ * @param {number} oy
3221
+ * @param {number} oz
3222
+ * @param {number} dx
3223
+ * @param {number} dy
3224
+ * @param {number} dz
3225
+ * @param {number} max_distance
3226
+ * @returns {Float64Array}
3227
+ */
3228
+ export function mesh_raycast_all_h(id, ox, oy, oz, dx, dy, dz, max_distance) {
3229
+ const ret = wasm.mesh_raycast_all_h(id, ox, oy, oz, dx, dy, dz, max_distance);
3230
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3231
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3232
+ return v1;
3233
+ }
3234
+
3235
+ /**
3236
+ * Handle variant of `mesh_raycast` — reuses the stored mesh's cached BVH.
3237
+ * @param {number} id
3238
+ * @param {number} ox
3239
+ * @param {number} oy
3240
+ * @param {number} oz
3241
+ * @param {number} dx
3242
+ * @param {number} dy
3243
+ * @param {number} dz
3244
+ * @param {number} max_distance
3245
+ * @returns {Float64Array}
3246
+ */
3247
+ export function mesh_raycast_h(id, ox, oy, oz, dx, dy, dz, max_distance) {
3248
+ const ret = wasm.mesh_raycast_h(id, ox, oy, oz, dx, dy, dz, max_distance);
3249
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3250
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3251
+ return v1;
3252
+ }
3253
+
3082
3254
  /**
3083
3255
  * Raycast against many meshes packed as:
3084
3256
  * [meshCount, meshLen0, meshRaw0..., meshLen1, meshRaw1..., ...]
@@ -3144,6 +3316,18 @@ export function mesh_repair_diagnostics(vertex_count, buffer) {
3144
3316
  return v2;
3145
3317
  }
3146
3318
 
3319
+ /**
3320
+ * Handle variant of `mesh_repair_diagnostics`.
3321
+ * @param {number} id
3322
+ * @returns {Float64Array}
3323
+ */
3324
+ export function mesh_repair_diagnostics_h(id) {
3325
+ const ret = wasm.mesh_repair_diagnostics_h(id);
3326
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3327
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3328
+ return v1;
3329
+ }
3330
+
3147
3331
  /**
3148
3332
  * Rotate a mesh around an arbitrary axis and return new buffers
3149
3333
  * Axis is defined by (ax, ay, az), angle in radians
@@ -3316,6 +3500,47 @@ export function mesh_split_polyline(vertex_count, buffer, points, closed) {
3316
3500
  return v3;
3317
3501
  }
3318
3502
 
3503
+ /**
3504
+ * Store a mesh buffer `[vertexCount, x,y,z..., i0,i1,i2...]` WASM-side.
3505
+ * Returns a non-zero id, or 0 on invalid input.
3506
+ * @param {number} vertex_count
3507
+ * @param {Float64Array} buffer
3508
+ * @returns {number}
3509
+ */
3510
+ export function mesh_store(vertex_count, buffer) {
3511
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
3512
+ const len0 = WASM_VECTOR_LEN;
3513
+ const ret = wasm.mesh_store(vertex_count, ptr0, len0);
3514
+ return ret >>> 0;
3515
+ }
3516
+
3517
+ /**
3518
+ * Approximate bytes held by stored mesh raw buffers (diagnostics/tests).
3519
+ * Excludes lazy raycast caches.
3520
+ * @returns {number}
3521
+ */
3522
+ export function mesh_store_bytes() {
3523
+ const ret = wasm.mesh_store_bytes();
3524
+ return ret;
3525
+ }
3526
+
3527
+ /**
3528
+ * Number of stored meshes (diagnostics/tests).
3529
+ * @returns {number}
3530
+ */
3531
+ export function mesh_store_count() {
3532
+ const ret = wasm.mesh_store_count();
3533
+ return ret >>> 0;
3534
+ }
3535
+
3536
+ /**
3537
+ * Release a stored mesh and free its memory (idempotent).
3538
+ * @param {number} id
3539
+ */
3540
+ export function mesh_store_free(id) {
3541
+ wasm.mesh_store_free(id);
3542
+ }
3543
+
3319
3544
  /**
3320
3545
  * Trim an OPEN host surface by all closed cutter meshes in one WASM call.
3321
3546
  *
@@ -3385,6 +3610,34 @@ export function mesh_surface_split_plane(vertex_count, buffer, nx, ny, nz, d, op
3385
3610
  return v3;
3386
3611
  }
3387
3612
 
3613
+ /**
3614
+ * Thicken (solidify) a triangle mesh into a solid: open sheets gain boundary
3615
+ * walls, closed meshes become hollow shells. `bottom_offset`/`top_offset`
3616
+ * are signed displacements along the (angle-weighted) vertex normal;
3617
+ * centered = (-d/2, +d/2), up = (0, d), down = (-d, 0). `flags` bit 1 =
3618
+ * disable even thickness (miter compensation); bit 2 = skip the input
3619
+ * proximity weld (trusted indexed connectivity, e.g. kernel-produced
3620
+ * meshes). `miter_limit <= 0` uses the default (4.0). Returns the standard
3621
+ * mesh buffer
3622
+ * [vertexCount, positions..., indices...]; empty on failure (see
3623
+ * `geometry_last_error`).
3624
+ * @param {number} vertex_count
3625
+ * @param {Float64Array} buffer
3626
+ * @param {number} bottom_offset
3627
+ * @param {number} top_offset
3628
+ * @param {number} flags
3629
+ * @param {number} miter_limit
3630
+ * @returns {Float64Array}
3631
+ */
3632
+ export function mesh_thicken(vertex_count, buffer, bottom_offset, top_offset, flags, miter_limit) {
3633
+ const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
3634
+ const len0 = WASM_VECTOR_LEN;
3635
+ const ret = wasm.mesh_thicken(vertex_count, ptr0, len0, bottom_offset, top_offset, flags, miter_limit);
3636
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3637
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3638
+ return v2;
3639
+ }
3640
+
3388
3641
  /**
3389
3642
  * Return welded-edge topology metrics for a triangulated mesh buffer:
3390
3643
  * `[boundary_edges, non_manifold_edges]`.
@@ -4029,6 +4282,34 @@ export function nurbs_surface_tessellate_render(data, tolerance, max_segments_pe
4029
4282
  return v2;
4030
4283
  }
4031
4284
 
4285
+ /**
4286
+ * Thicken a NURBS surface into an exact watertight BREP solid: the shells are
4287
+ * exact parameterization-preserving offsets and the walls are exact ruled
4288
+ * surfaces between corresponding boundary curves. Handles closed directions
4289
+ * (seam edges) and degenerate boundaries (poles). `tolerance <= 0` uses the
4290
+ * offset default (1e-4). Returns the BREP JSON, or `{"error": ...}` on
4291
+ * failure.
4292
+ * @param {Float64Array} data
4293
+ * @param {number} bottom_offset
4294
+ * @param {number} top_offset
4295
+ * @param {number} tolerance
4296
+ * @returns {string}
4297
+ */
4298
+ export function nurbs_surface_thicken_brep(data, bottom_offset, top_offset, tolerance) {
4299
+ let deferred2_0;
4300
+ let deferred2_1;
4301
+ try {
4302
+ const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
4303
+ const len0 = WASM_VECTOR_LEN;
4304
+ const ret = wasm.nurbs_surface_thicken_brep(ptr0, len0, bottom_offset, top_offset, tolerance);
4305
+ deferred2_0 = ret[0];
4306
+ deferred2_1 = ret[1];
4307
+ return getStringFromWasm0(ret[0], ret[1]);
4308
+ } finally {
4309
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
4310
+ }
4311
+ }
4312
+
4032
4313
  /**
4033
4314
  * Offset a polycurve made of line and arc segments.
4034
4315
  * Input format: [segment_count, type, ...data, ...]
@@ -4583,6 +4864,32 @@ export function thicken_polycurve(segment_data, distance, both_sides, nx, ny, nz
4583
4864
  return v2;
4584
4865
  }
4585
4866
 
4867
+ /**
4868
+ * Thicken a polycurve into region boundary loops, supporting CLOSED inputs
4869
+ * (annulus semantics): open inputs return one closed ribbon loop; closed
4870
+ * inputs return the surviving offset loops on both sides (or source + one
4871
+ * side when `both_sides` is false). Segment data format matches
4872
+ * `thicken_polycurve`; output is a packed polycurve set
4873
+ * [curve_count, curve_len, curve_data..., ...]. Empty on failure (see
4874
+ * `geometry_last_error`).
4875
+ * @param {Float64Array} segment_data
4876
+ * @param {number} distance
4877
+ * @param {boolean} both_sides
4878
+ * @param {number} nx
4879
+ * @param {number} ny
4880
+ * @param {number} nz
4881
+ * @param {number} join_style_code
4882
+ * @returns {Float64Array}
4883
+ */
4884
+ export function thicken_polycurve_loops(segment_data, distance, both_sides, nx, ny, nz, join_style_code) {
4885
+ const ptr0 = passArrayF64ToWasm0(segment_data, wasm.__wbindgen_malloc);
4886
+ const len0 = WASM_VECTOR_LEN;
4887
+ const ret = wasm.thicken_polycurve_loops(ptr0, len0, distance, both_sides, nx, ny, nz, join_style_code);
4888
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
4889
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
4890
+ return v2;
4891
+ }
4892
+
4586
4893
  /**
4587
4894
  * Get version info
4588
4895
  * @returns {string}
@@ -0,0 +1,107 @@
1
+ /*
2
+ * Copyright 2022 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+
14
+ // Note: we use `wasm_bindgen_worker_`-prefixed message types to make sure
15
+ // we can handle bundling into other files, which might happen to have their
16
+ // own `postMessage`/`onmessage` communication channels.
17
+ //
18
+ // If we didn't take that into the account, we could send much simpler signals
19
+ // like just `0` or whatever, but the code would be less resilient.
20
+
21
+ function waitForMsgType(target, type) {
22
+ return new Promise(resolve => {
23
+ target.addEventListener('message', function onMsg({ data }) {
24
+ if (data?.type !== type) return;
25
+ target.removeEventListener('message', onMsg);
26
+ resolve(data);
27
+ });
28
+ });
29
+ }
30
+
31
+ waitForMsgType(self, 'wasm_bindgen_worker_init').then(async ({ init, receiver }) => {
32
+ // # Note 1
33
+ // Our JS should have been generated in
34
+ // `[out-dir]/snippets/wasm-bindgen-rayon-[hash]/workerHelpers.js`,
35
+ // resolve the main module via `../../..`.
36
+ //
37
+ // This might need updating if the generated structure changes on wasm-bindgen
38
+ // side ever in the future, but works well with bundlers today. The whole
39
+ // point of this crate, after all, is to abstract away unstable features
40
+ // and temporary bugs so that you don't need to deal with them in your code.
41
+ //
42
+ // # Note 2
43
+ // This could be a regular import, but then some bundlers complain about
44
+ // circular deps.
45
+ //
46
+ // Dynamic import could be cheap if this file was inlined into the parent,
47
+ // which would require us just using `../../..` in `new Worker` below,
48
+ // but that doesn't work because wasm-pack unconditionally adds
49
+ // "sideEffects":false (see below).
50
+ //
51
+ // OTOH, even though it can't be inlined, it should be still reasonably
52
+ // cheap since the requested file is already in cache (it was loaded by
53
+ // the main thread).
54
+ const pkg = await import('./wasm-bindings-threaded.js');
55
+ await pkg.default(init);
56
+ postMessage({ type: 'wasm_bindgen_worker_ready' });
57
+ pkg.wbg_rayon_start_worker(receiver);
58
+ });
59
+
60
+ // Note: this is never used, but necessary to prevent a bug in Firefox
61
+ // (https://bugzilla.mozilla.org/show_bug.cgi?id=1702191) where it collects
62
+ // Web Workers that have a shared WebAssembly memory with the main thread,
63
+ // but are not explicitly rooted via a `Worker` instance.
64
+ //
65
+ // By storing them in a variable, we can keep `Worker` objects around and
66
+ // prevent them from getting GC-d.
67
+ let _workers;
68
+
69
+ export async function startWorkers(module, memory, builder) {
70
+ if (builder.numThreads() === 0) {
71
+ throw new Error(`num_threads must be > 0.`);
72
+ }
73
+
74
+ const workerInit = {
75
+ type: 'wasm_bindgen_worker_init',
76
+ init: { module_or_path: module, memory },
77
+ receiver: builder.receiver()
78
+ };
79
+
80
+ _workers = await Promise.all(
81
+ Array.from({ length: builder.numThreads() }, async () => {
82
+ // Self-spawn into a new Worker.
83
+ //
84
+ // TODO: while `new URL('...', import.meta.url) becomes a semi-standard
85
+ // way to get asset URLs relative to the module across various bundlers
86
+ // and browser, ideally we should switch to `import.meta.resolve`
87
+ // once it becomes a standard.
88
+ //
89
+ // Note: we could use `../../..` as the URL here to inline workerHelpers.js
90
+ // into the parent entry instead of creating another split point -
91
+ // this would be preferable from optimization perspective -
92
+ // however, Webpack then eliminates all message handler code
93
+ // because wasm-pack produces "sideEffects":false in package.json
94
+ // unconditionally.
95
+ //
96
+ // The only way to work around that is to have side effect code
97
+ // in an entry point such as Worker file itself.
98
+ const worker = new Worker(new URL('./workerHelpers-threaded.js', import.meta.url), {
99
+ type: 'module'
100
+ });
101
+ worker.postMessage(workerInit);
102
+ await waitForMsgType(worker, 'wasm_bindgen_worker_ready');
103
+ return worker;
104
+ })
105
+ );
106
+ builder.build();
107
+ }