okgeometry-api 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/wasm/README.md +102 -0
- package/wasm/okgeometrycore.d.ts +286 -0
- package/wasm/okgeometrycore.js +9 -0
- package/wasm/okgeometrycore_bg.d.ts +3 -0
- package/wasm/okgeometrycore_bg.js +941 -0
- package/wasm/okgeometrycore_bg.wasm +0 -0
- package/wasm/okgeometrycore_bg.wasm.d.ts +53 -0
- package/wasm/package.json +21 -0
|
@@ -0,0 +1,941 @@
|
|
|
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
|
+
* Get the circumference of a circle.
|
|
37
|
+
* @param {number} radius
|
|
38
|
+
* @returns {number}
|
|
39
|
+
*/
|
|
40
|
+
export function circle_length(radius) {
|
|
41
|
+
const ret = wasm.circle_length(radius);
|
|
42
|
+
return ret;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Evaluate a point on a circle at parameter t ∈ [0,1].
|
|
47
|
+
* Returns [x, y, z].
|
|
48
|
+
* @param {number} cx
|
|
49
|
+
* @param {number} cy
|
|
50
|
+
* @param {number} cz
|
|
51
|
+
* @param {number} nx
|
|
52
|
+
* @param {number} ny
|
|
53
|
+
* @param {number} nz
|
|
54
|
+
* @param {number} radius
|
|
55
|
+
* @param {number} t
|
|
56
|
+
* @returns {Float64Array}
|
|
57
|
+
*/
|
|
58
|
+
export function circle_point_at(cx, cy, cz, nx, ny, nz, radius, t) {
|
|
59
|
+
const ret = wasm.circle_point_at(cx, cy, cz, nx, ny, nz, radius, t);
|
|
60
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
61
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
62
|
+
return v1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Create an arc and return sampled points
|
|
67
|
+
* @param {number} cx
|
|
68
|
+
* @param {number} cy
|
|
69
|
+
* @param {number} cz
|
|
70
|
+
* @param {number} nx
|
|
71
|
+
* @param {number} ny
|
|
72
|
+
* @param {number} nz
|
|
73
|
+
* @param {number} radius
|
|
74
|
+
* @param {number} start_angle
|
|
75
|
+
* @param {number} end_angle
|
|
76
|
+
* @param {number} samples
|
|
77
|
+
* @returns {Float64Array}
|
|
78
|
+
*/
|
|
79
|
+
export function create_arc(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, samples) {
|
|
80
|
+
const ret = wasm.create_arc(cx, cy, cz, nx, ny, nz, radius, start_angle, end_angle, samples);
|
|
81
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
82
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
83
|
+
return v1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a circle and return sampled points
|
|
88
|
+
* @param {number} cx
|
|
89
|
+
* @param {number} cy
|
|
90
|
+
* @param {number} cz
|
|
91
|
+
* @param {number} nx
|
|
92
|
+
* @param {number} ny
|
|
93
|
+
* @param {number} nz
|
|
94
|
+
* @param {number} radius
|
|
95
|
+
* @param {number} samples
|
|
96
|
+
* @returns {Float64Array}
|
|
97
|
+
*/
|
|
98
|
+
export function create_circle(cx, cy, cz, nx, ny, nz, radius, samples) {
|
|
99
|
+
const ret = wasm.create_circle(cx, cy, cz, nx, ny, nz, radius, samples);
|
|
100
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
101
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
102
|
+
return v1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Create a line segment and return sampled points
|
|
107
|
+
* @param {number} x1
|
|
108
|
+
* @param {number} y1
|
|
109
|
+
* @param {number} z1
|
|
110
|
+
* @param {number} x2
|
|
111
|
+
* @param {number} y2
|
|
112
|
+
* @param {number} z2
|
|
113
|
+
* @param {number} samples
|
|
114
|
+
* @returns {Float64Array}
|
|
115
|
+
*/
|
|
116
|
+
export function create_line(x1, y1, z1, x2, y2, z2, samples) {
|
|
117
|
+
const ret = wasm.create_line(x1, y1, z1, x2, y2, z2, 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 polyline and return the points
|
|
125
|
+
* @param {Float64Array} coords
|
|
126
|
+
* @param {number} samples_per_segment
|
|
127
|
+
* @returns {Float64Array}
|
|
128
|
+
*/
|
|
129
|
+
export function create_polyline(coords, samples_per_segment) {
|
|
130
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
132
|
+
const ret = wasm.create_polyline(ptr0, len0, samples_per_segment);
|
|
133
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
134
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
135
|
+
return v2;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Serialize a curve to a list of points for Three.js rendering
|
|
140
|
+
* Returns a flat array of coordinates: [x1, y1, z1, x2, y2, z2, ...]
|
|
141
|
+
* @param {string} curve_type
|
|
142
|
+
* @param {Float64Array} params
|
|
143
|
+
* @param {number} samples
|
|
144
|
+
* @returns {Float64Array}
|
|
145
|
+
*/
|
|
146
|
+
export function curve_to_points(curve_type, params, samples) {
|
|
147
|
+
const ptr0 = passStringToWasm0(curve_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
149
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
150
|
+
const len1 = WASM_VECTOR_LEN;
|
|
151
|
+
const ret = wasm.curve_to_points(ptr0, len0, ptr1, len1, samples);
|
|
152
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
153
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
154
|
+
return v3;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Extrude a circle and return mesh buffers
|
|
159
|
+
* @param {number} cx
|
|
160
|
+
* @param {number} cy
|
|
161
|
+
* @param {number} cz
|
|
162
|
+
* @param {number} nx
|
|
163
|
+
* @param {number} ny
|
|
164
|
+
* @param {number} nz
|
|
165
|
+
* @param {number} radius
|
|
166
|
+
* @param {number} dx
|
|
167
|
+
* @param {number} dy
|
|
168
|
+
* @param {number} dz
|
|
169
|
+
* @param {number} segments
|
|
170
|
+
* @param {boolean} with_caps
|
|
171
|
+
* @returns {Float64Array}
|
|
172
|
+
*/
|
|
173
|
+
export function extrude_circle(cx, cy, cz, nx, ny, nz, radius, dx, dy, dz, segments, with_caps) {
|
|
174
|
+
const ret = wasm.extrude_circle(cx, cy, cz, nx, ny, nz, radius, dx, dy, dz, segments, with_caps);
|
|
175
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
176
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
177
|
+
return v1;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Extrude a line segment and return mesh buffers
|
|
182
|
+
* @param {number} x1
|
|
183
|
+
* @param {number} y1
|
|
184
|
+
* @param {number} z1
|
|
185
|
+
* @param {number} x2
|
|
186
|
+
* @param {number} y2
|
|
187
|
+
* @param {number} z2
|
|
188
|
+
* @param {number} dx
|
|
189
|
+
* @param {number} dy
|
|
190
|
+
* @param {number} dz
|
|
191
|
+
* @param {number} segments
|
|
192
|
+
* @returns {Float64Array}
|
|
193
|
+
*/
|
|
194
|
+
export function extrude_line(x1, y1, z1, x2, y2, z2, dx, dy, dz, segments) {
|
|
195
|
+
const ret = wasm.extrude_line(x1, y1, z1, x2, y2, z2, dx, dy, dz, segments);
|
|
196
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
197
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
198
|
+
return v1;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Extrude a polyline and return mesh buffers
|
|
203
|
+
* @param {Float64Array} coords
|
|
204
|
+
* @param {number} dx
|
|
205
|
+
* @param {number} dy
|
|
206
|
+
* @param {number} dz
|
|
207
|
+
* @param {number} segments
|
|
208
|
+
* @param {boolean} with_caps
|
|
209
|
+
* @returns {Float64Array}
|
|
210
|
+
*/
|
|
211
|
+
export function extrude_polyline(coords, dx, dy, dz, segments, with_caps) {
|
|
212
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
213
|
+
const len0 = WASM_VECTOR_LEN;
|
|
214
|
+
const ret = wasm.extrude_polyline(ptr0, len0, dx, dy, dz, segments, with_caps);
|
|
215
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
216
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
217
|
+
return v2;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get the length of a line segment.
|
|
222
|
+
* @param {number} x1
|
|
223
|
+
* @param {number} y1
|
|
224
|
+
* @param {number} z1
|
|
225
|
+
* @param {number} x2
|
|
226
|
+
* @param {number} y2
|
|
227
|
+
* @param {number} z2
|
|
228
|
+
* @returns {number}
|
|
229
|
+
*/
|
|
230
|
+
export function line_length(x1, y1, z1, x2, y2, z2) {
|
|
231
|
+
const ret = wasm.line_length(x1, y1, z1, x2, y2, z2);
|
|
232
|
+
return ret;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Evaluate a point on a line segment at parameter t ∈ [0,1].
|
|
237
|
+
* Returns [x, y, z].
|
|
238
|
+
* @param {number} x1
|
|
239
|
+
* @param {number} y1
|
|
240
|
+
* @param {number} z1
|
|
241
|
+
* @param {number} x2
|
|
242
|
+
* @param {number} y2
|
|
243
|
+
* @param {number} z2
|
|
244
|
+
* @param {number} t
|
|
245
|
+
* @returns {Float64Array}
|
|
246
|
+
*/
|
|
247
|
+
export function line_point_at(x1, y1, z1, x2, y2, z2, t) {
|
|
248
|
+
const ret = wasm.line_point_at(x1, y1, z1, x2, y2, z2, t);
|
|
249
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
250
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
251
|
+
return v1;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Get the tangent direction of a line segment. Returns [x, y, z].
|
|
256
|
+
* @param {number} x1
|
|
257
|
+
* @param {number} y1
|
|
258
|
+
* @param {number} z1
|
|
259
|
+
* @param {number} x2
|
|
260
|
+
* @param {number} y2
|
|
261
|
+
* @param {number} z2
|
|
262
|
+
* @returns {Float64Array}
|
|
263
|
+
*/
|
|
264
|
+
export function line_tangent(x1, y1, z1, x2, y2, z2) {
|
|
265
|
+
const ret = wasm.line_tangent(x1, y1, z1, x2, y2, z2);
|
|
266
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
267
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
268
|
+
return v1;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Loft between multiple circles
|
|
273
|
+
*
|
|
274
|
+
* # Parameters
|
|
275
|
+
* * `circle_data` - Flat array of circle definitions [cx, cy, cz, nx, ny, nz, radius, ...]
|
|
276
|
+
* * `segments` - Number of segments to sample along each curve
|
|
277
|
+
* * `with_caps` - Whether to create end caps
|
|
278
|
+
*
|
|
279
|
+
* # Returns
|
|
280
|
+
* Mesh buffers for the lofted surface
|
|
281
|
+
* @param {Float64Array} circle_data
|
|
282
|
+
* @param {number} segments
|
|
283
|
+
* @param {boolean} with_caps
|
|
284
|
+
* @returns {Float64Array}
|
|
285
|
+
*/
|
|
286
|
+
export function loft_circles(circle_data, segments, with_caps) {
|
|
287
|
+
const ptr0 = passArrayF64ToWasm0(circle_data, wasm.__wbindgen_malloc);
|
|
288
|
+
const len0 = WASM_VECTOR_LEN;
|
|
289
|
+
const ret = wasm.loft_circles(ptr0, len0, segments, with_caps);
|
|
290
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
291
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
292
|
+
return v2;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Loft between multiple polylines
|
|
297
|
+
*
|
|
298
|
+
* # Parameters
|
|
299
|
+
* * `polyline_data` - Flat array where each polyline is prefixed by its point count:
|
|
300
|
+
* [count1, x1, y1, z1, x2, y2, z2, ..., count2, x1, y1, z1, ...]
|
|
301
|
+
* * `segments` - Number of segments to sample along each curve
|
|
302
|
+
* * `with_caps` - Whether to create end caps
|
|
303
|
+
*
|
|
304
|
+
* # Returns
|
|
305
|
+
* Mesh buffers for the lofted surface
|
|
306
|
+
* @param {Float64Array} polyline_data
|
|
307
|
+
* @param {number} segments
|
|
308
|
+
* @param {boolean} with_caps
|
|
309
|
+
* @returns {Float64Array}
|
|
310
|
+
*/
|
|
311
|
+
export function loft_polylines(polyline_data, segments, with_caps) {
|
|
312
|
+
const ptr0 = passArrayF64ToWasm0(polyline_data, wasm.__wbindgen_malloc);
|
|
313
|
+
const len0 = WASM_VECTOR_LEN;
|
|
314
|
+
const ret = wasm.loft_polylines(ptr0, len0, segments, with_caps);
|
|
315
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
316
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
317
|
+
return v2;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Perform boolean intersection on two meshes
|
|
322
|
+
* @param {number} vertex_count_a
|
|
323
|
+
* @param {Float64Array} buffer_a
|
|
324
|
+
* @param {number} vertex_count_b
|
|
325
|
+
* @param {Float64Array} buffer_b
|
|
326
|
+
* @returns {Float64Array}
|
|
327
|
+
*/
|
|
328
|
+
export function mesh_boolean_intersection(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
|
|
329
|
+
const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
|
|
330
|
+
const len0 = WASM_VECTOR_LEN;
|
|
331
|
+
const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
|
|
332
|
+
const len1 = WASM_VECTOR_LEN;
|
|
333
|
+
const ret = wasm.mesh_boolean_intersection(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
|
|
334
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
335
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
336
|
+
return v3;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Perform boolean operation on two meshes
|
|
341
|
+
*
|
|
342
|
+
* # Parameters
|
|
343
|
+
* * `vertex_count_a` - Number of vertices in mesh A
|
|
344
|
+
* * `buffer_a` - Buffer for mesh A [vertices..., indices...]
|
|
345
|
+
* * `vertex_count_b` - Number of vertices in mesh B
|
|
346
|
+
* * `buffer_b` - Buffer for mesh B [vertices..., indices...]
|
|
347
|
+
* * `operation` - Operation type: "union", "intersection", or "subtraction"
|
|
348
|
+
*
|
|
349
|
+
* # Returns
|
|
350
|
+
* Result mesh buffer [vertices..., indices...]
|
|
351
|
+
* @param {number} vertex_count_a
|
|
352
|
+
* @param {Float64Array} buffer_a
|
|
353
|
+
* @param {number} vertex_count_b
|
|
354
|
+
* @param {Float64Array} buffer_b
|
|
355
|
+
* @param {string} operation
|
|
356
|
+
* @returns {Float64Array}
|
|
357
|
+
*/
|
|
358
|
+
export function mesh_boolean_operation(vertex_count_a, buffer_a, vertex_count_b, buffer_b, operation) {
|
|
359
|
+
const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
|
|
360
|
+
const len0 = WASM_VECTOR_LEN;
|
|
361
|
+
const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
|
|
362
|
+
const len1 = WASM_VECTOR_LEN;
|
|
363
|
+
const ptr2 = passStringToWasm0(operation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
364
|
+
const len2 = WASM_VECTOR_LEN;
|
|
365
|
+
const ret = wasm.mesh_boolean_operation(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1, ptr2, len2);
|
|
366
|
+
var v4 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
367
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
368
|
+
return v4;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Perform boolean subtraction on two meshes (A - B)
|
|
373
|
+
* @param {number} vertex_count_a
|
|
374
|
+
* @param {Float64Array} buffer_a
|
|
375
|
+
* @param {number} vertex_count_b
|
|
376
|
+
* @param {Float64Array} buffer_b
|
|
377
|
+
* @returns {Float64Array}
|
|
378
|
+
*/
|
|
379
|
+
export function mesh_boolean_subtraction(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
|
|
380
|
+
const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
|
|
381
|
+
const len0 = WASM_VECTOR_LEN;
|
|
382
|
+
const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
|
|
383
|
+
const len1 = WASM_VECTOR_LEN;
|
|
384
|
+
const ret = wasm.mesh_boolean_subtraction(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
|
|
385
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
386
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
387
|
+
return v3;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Perform boolean union on two meshes
|
|
392
|
+
* @param {number} vertex_count_a
|
|
393
|
+
* @param {Float64Array} buffer_a
|
|
394
|
+
* @param {number} vertex_count_b
|
|
395
|
+
* @param {Float64Array} buffer_b
|
|
396
|
+
* @returns {Float64Array}
|
|
397
|
+
*/
|
|
398
|
+
export function mesh_boolean_union(vertex_count_a, buffer_a, vertex_count_b, buffer_b) {
|
|
399
|
+
const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
|
|
400
|
+
const len0 = WASM_VECTOR_LEN;
|
|
401
|
+
const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
|
|
402
|
+
const len1 = WASM_VECTOR_LEN;
|
|
403
|
+
const ret = wasm.mesh_boolean_union(vertex_count_a, ptr0, len0, vertex_count_b, ptr1, len1);
|
|
404
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
405
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
406
|
+
return v3;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Chamfer all edges of a primitive mesh (flat bevel)
|
|
411
|
+
*
|
|
412
|
+
* # Arguments
|
|
413
|
+
* * `mesh_type` - "box", "cylinder", or "prism"
|
|
414
|
+
* * `params` - Parameters: [width,height,depth] for box, [radius,height,segments] for cylinder/prism
|
|
415
|
+
* * `offset` - Chamfer offset distance
|
|
416
|
+
*
|
|
417
|
+
* # Returns
|
|
418
|
+
* Result mesh buffer [vertexCount, vertices..., indices...]
|
|
419
|
+
* @param {string} mesh_type
|
|
420
|
+
* @param {Float64Array} params
|
|
421
|
+
* @param {number} offset
|
|
422
|
+
* @returns {Float64Array}
|
|
423
|
+
*/
|
|
424
|
+
export function mesh_chamfer_all_edges(mesh_type, params, offset) {
|
|
425
|
+
const ptr0 = passStringToWasm0(mesh_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
426
|
+
const len0 = WASM_VECTOR_LEN;
|
|
427
|
+
const ptr1 = passArrayF64ToWasm0(params, wasm.__wbindgen_malloc);
|
|
428
|
+
const len1 = WASM_VECTOR_LEN;
|
|
429
|
+
const ret = wasm.mesh_chamfer_all_edges(ptr0, len0, ptr1, len1, offset);
|
|
430
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
431
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
432
|
+
return v3;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Create a box mesh and return buffers
|
|
437
|
+
* Returns [vertices..., indices...]
|
|
438
|
+
* @param {number} width
|
|
439
|
+
* @param {number} height
|
|
440
|
+
* @param {number} depth
|
|
441
|
+
* @returns {Float64Array}
|
|
442
|
+
*/
|
|
443
|
+
export function mesh_create_box(width, height, depth) {
|
|
444
|
+
const ret = wasm.mesh_create_box(width, height, depth);
|
|
445
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
446
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
447
|
+
return v1;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Create a cone mesh and return buffers
|
|
452
|
+
* @param {number} radius
|
|
453
|
+
* @param {number} height
|
|
454
|
+
* @param {number} segments
|
|
455
|
+
* @returns {Float64Array}
|
|
456
|
+
*/
|
|
457
|
+
export function mesh_create_cone(radius, height, segments) {
|
|
458
|
+
const ret = wasm.mesh_create_cone(radius, height, segments);
|
|
459
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
460
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
461
|
+
return v1;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Create a cylinder mesh and return buffers
|
|
466
|
+
* @param {number} radius
|
|
467
|
+
* @param {number} height
|
|
468
|
+
* @param {number} segments
|
|
469
|
+
* @returns {Float64Array}
|
|
470
|
+
*/
|
|
471
|
+
export function mesh_create_cylinder(radius, height, segments) {
|
|
472
|
+
const ret = wasm.mesh_create_cylinder(radius, height, segments);
|
|
473
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
474
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
475
|
+
return v1;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Create a prism mesh and return buffers
|
|
480
|
+
* @param {number} radius
|
|
481
|
+
* @param {number} height
|
|
482
|
+
* @param {number} sides
|
|
483
|
+
* @returns {Float64Array}
|
|
484
|
+
*/
|
|
485
|
+
export function mesh_create_prism(radius, height, sides) {
|
|
486
|
+
const ret = wasm.mesh_create_prism(radius, height, sides);
|
|
487
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
488
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
489
|
+
return v1;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Create a sphere mesh and return buffers
|
|
494
|
+
* @param {number} radius
|
|
495
|
+
* @param {number} segments
|
|
496
|
+
* @param {number} rings
|
|
497
|
+
* @returns {Float64Array}
|
|
498
|
+
*/
|
|
499
|
+
export function mesh_create_sphere(radius, segments, rings) {
|
|
500
|
+
const ret = wasm.mesh_create_sphere(radius, segments, rings);
|
|
501
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
502
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
503
|
+
return v1;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Export a mesh to OBJ format
|
|
508
|
+
* Takes mesh buffers as input (same format as mesh_to_buffers output)
|
|
509
|
+
* Returns OBJ string
|
|
510
|
+
* @param {number} vertex_count
|
|
511
|
+
* @param {Float64Array} buffer
|
|
512
|
+
* @returns {string}
|
|
513
|
+
*/
|
|
514
|
+
export function mesh_export_obj(vertex_count, buffer) {
|
|
515
|
+
let deferred2_0;
|
|
516
|
+
let deferred2_1;
|
|
517
|
+
try {
|
|
518
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
519
|
+
const len0 = WASM_VECTOR_LEN;
|
|
520
|
+
const ret = wasm.mesh_export_obj(vertex_count, ptr0, len0);
|
|
521
|
+
deferred2_0 = ret[0];
|
|
522
|
+
deferred2_1 = ret[1];
|
|
523
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
524
|
+
} finally {
|
|
525
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Get mesh statistics
|
|
531
|
+
* Returns [vertex_count, face_count, edge_count]
|
|
532
|
+
* @param {number} vertex_count
|
|
533
|
+
* @param {Float64Array} buffer
|
|
534
|
+
* @returns {Float64Array}
|
|
535
|
+
*/
|
|
536
|
+
export function mesh_get_stats(vertex_count, buffer) {
|
|
537
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
538
|
+
const len0 = WASM_VECTOR_LEN;
|
|
539
|
+
const ret = wasm.mesh_get_stats(vertex_count, ptr0, len0);
|
|
540
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
541
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
542
|
+
return v2;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Import OBJ data and return mesh buffers
|
|
547
|
+
* @param {string} obj_data
|
|
548
|
+
* @returns {Float64Array}
|
|
549
|
+
*/
|
|
550
|
+
export function mesh_import_obj(obj_data) {
|
|
551
|
+
const ptr0 = passStringToWasm0(obj_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
552
|
+
const len0 = WASM_VECTOR_LEN;
|
|
553
|
+
const ret = wasm.mesh_import_obj(ptr0, len0);
|
|
554
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
555
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
556
|
+
return v2;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Intersect two meshes, returning intersection polyline points.
|
|
561
|
+
* Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
|
|
562
|
+
* @param {number} va_count
|
|
563
|
+
* @param {Float64Array} buffer_a
|
|
564
|
+
* @param {number} vb_count
|
|
565
|
+
* @param {Float64Array} buffer_b
|
|
566
|
+
* @returns {Float64Array}
|
|
567
|
+
*/
|
|
568
|
+
export function mesh_mesh_intersect(va_count, buffer_a, vb_count, buffer_b) {
|
|
569
|
+
const ptr0 = passArrayF64ToWasm0(buffer_a, wasm.__wbindgen_malloc);
|
|
570
|
+
const len0 = WASM_VECTOR_LEN;
|
|
571
|
+
const ptr1 = passArrayF64ToWasm0(buffer_b, wasm.__wbindgen_malloc);
|
|
572
|
+
const len1 = WASM_VECTOR_LEN;
|
|
573
|
+
const ret = wasm.mesh_mesh_intersect(va_count, ptr0, len0, vb_count, ptr1, len1);
|
|
574
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
575
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
576
|
+
return v3;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Intersect a mesh with a plane, returning polyline points.
|
|
581
|
+
* Input: vertex_count, mesh_buffer..., nx, ny, nz, d
|
|
582
|
+
* Returns: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
|
|
583
|
+
* @param {number} vertex_count
|
|
584
|
+
* @param {Float64Array} buffer
|
|
585
|
+
* @param {number} nx
|
|
586
|
+
* @param {number} ny
|
|
587
|
+
* @param {number} nz
|
|
588
|
+
* @param {number} d
|
|
589
|
+
* @returns {Float64Array}
|
|
590
|
+
*/
|
|
591
|
+
export function mesh_plane_intersect(vertex_count, buffer, nx, ny, nz, d) {
|
|
592
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
593
|
+
const len0 = WASM_VECTOR_LEN;
|
|
594
|
+
const ret = wasm.mesh_plane_intersect(vertex_count, ptr0, len0, nx, ny, nz, d);
|
|
595
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
596
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
597
|
+
return v2;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Rotate a mesh around an arbitrary axis and return new buffers
|
|
602
|
+
* Axis is defined by (ax, ay, az), angle in radians
|
|
603
|
+
* @param {number} vertex_count
|
|
604
|
+
* @param {Float64Array} buffer
|
|
605
|
+
* @param {number} ax
|
|
606
|
+
* @param {number} ay
|
|
607
|
+
* @param {number} az
|
|
608
|
+
* @param {number} angle
|
|
609
|
+
* @returns {Float64Array}
|
|
610
|
+
*/
|
|
611
|
+
export function mesh_rotate(vertex_count, buffer, ax, ay, az, angle) {
|
|
612
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
613
|
+
const len0 = WASM_VECTOR_LEN;
|
|
614
|
+
const ret = wasm.mesh_rotate(vertex_count, ptr0, len0, ax, ay, az, angle);
|
|
615
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
616
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
617
|
+
return v2;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Scale a mesh non-uniformly and return new buffers
|
|
622
|
+
* @param {number} vertex_count
|
|
623
|
+
* @param {Float64Array} buffer
|
|
624
|
+
* @param {number} sx
|
|
625
|
+
* @param {number} sy
|
|
626
|
+
* @param {number} sz
|
|
627
|
+
* @returns {Float64Array}
|
|
628
|
+
*/
|
|
629
|
+
export function mesh_scale(vertex_count, buffer, sx, sy, sz) {
|
|
630
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
631
|
+
const len0 = WASM_VECTOR_LEN;
|
|
632
|
+
const ret = wasm.mesh_scale(vertex_count, ptr0, len0, sx, sy, sz);
|
|
633
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
634
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
635
|
+
return v2;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Translate a mesh by an offset vector and return new buffers
|
|
640
|
+
* @param {number} vertex_count
|
|
641
|
+
* @param {Float64Array} buffer
|
|
642
|
+
* @param {number} dx
|
|
643
|
+
* @param {number} dy
|
|
644
|
+
* @param {number} dz
|
|
645
|
+
* @returns {Float64Array}
|
|
646
|
+
*/
|
|
647
|
+
export function mesh_translate(vertex_count, buffer, dx, dy, dz) {
|
|
648
|
+
const ptr0 = passArrayF64ToWasm0(buffer, wasm.__wbindgen_malloc);
|
|
649
|
+
const len0 = WASM_VECTOR_LEN;
|
|
650
|
+
const ret = wasm.mesh_translate(vertex_count, ptr0, len0, dx, dy, dz);
|
|
651
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
652
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
653
|
+
return v2;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Intersect two NURBS curves.
|
|
658
|
+
* Returns: [num_points, x,y,z, ...]
|
|
659
|
+
* @param {Float64Array} data_a
|
|
660
|
+
* @param {Float64Array} data_b
|
|
661
|
+
* @returns {Float64Array}
|
|
662
|
+
*/
|
|
663
|
+
export function nurbs_curve_curve_intersect(data_a, data_b) {
|
|
664
|
+
const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
|
|
665
|
+
const len0 = WASM_VECTOR_LEN;
|
|
666
|
+
const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
|
|
667
|
+
const len1 = WASM_VECTOR_LEN;
|
|
668
|
+
const ret = wasm.nurbs_curve_curve_intersect(ptr0, len0, ptr1, len1);
|
|
669
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
670
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
671
|
+
return v3;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Intersect a NURBS curve with a plane.
|
|
676
|
+
* Input: same curve format as sample_nurbs_curve + plane normal (nx,ny,nz) and d.
|
|
677
|
+
* Returns: [num_points, x,y,z, x,y,z, ...]
|
|
678
|
+
* @param {Float64Array} data
|
|
679
|
+
* @param {number} nx
|
|
680
|
+
* @param {number} ny
|
|
681
|
+
* @param {number} nz
|
|
682
|
+
* @param {number} d
|
|
683
|
+
* @returns {Float64Array}
|
|
684
|
+
*/
|
|
685
|
+
export function nurbs_curve_plane_intersect(data, nx, ny, nz, d) {
|
|
686
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
687
|
+
const len0 = WASM_VECTOR_LEN;
|
|
688
|
+
const ret = wasm.nurbs_curve_plane_intersect(ptr0, len0, nx, ny, nz, d);
|
|
689
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
690
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
691
|
+
return v2;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Intersect a NURBS surface with a plane.
|
|
696
|
+
* Input: same surface format as tessellate_nurbs_surface, then plane (nx,ny,nz,d) appended.
|
|
697
|
+
* Returns polyline buffer: [num_polylines, n1, x,y,z,..., n2, x,y,z,...]
|
|
698
|
+
* @param {Float64Array} surface_data
|
|
699
|
+
* @param {number} nx
|
|
700
|
+
* @param {number} ny
|
|
701
|
+
* @param {number} nz
|
|
702
|
+
* @param {number} d
|
|
703
|
+
* @param {number} tess
|
|
704
|
+
* @returns {Float64Array}
|
|
705
|
+
*/
|
|
706
|
+
export function nurbs_surface_plane_intersect(surface_data, nx, ny, nz, d, tess) {
|
|
707
|
+
const ptr0 = passArrayF64ToWasm0(surface_data, wasm.__wbindgen_malloc);
|
|
708
|
+
const len0 = WASM_VECTOR_LEN;
|
|
709
|
+
const ret = wasm.nurbs_surface_plane_intersect(ptr0, len0, nx, ny, nz, d, tess);
|
|
710
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
711
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
712
|
+
return v2;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Intersect two NURBS surfaces.
|
|
717
|
+
* Returns polyline buffer.
|
|
718
|
+
* @param {Float64Array} data_a
|
|
719
|
+
* @param {Float64Array} data_b
|
|
720
|
+
* @param {number} tess
|
|
721
|
+
* @returns {Float64Array}
|
|
722
|
+
*/
|
|
723
|
+
export function nurbs_surface_surface_intersect(data_a, data_b, tess) {
|
|
724
|
+
const ptr0 = passArrayF64ToWasm0(data_a, wasm.__wbindgen_malloc);
|
|
725
|
+
const len0 = WASM_VECTOR_LEN;
|
|
726
|
+
const ptr1 = passArrayF64ToWasm0(data_b, wasm.__wbindgen_malloc);
|
|
727
|
+
const len1 = WASM_VECTOR_LEN;
|
|
728
|
+
const ret = wasm.nurbs_surface_surface_intersect(ptr0, len0, ptr1, len1, tess);
|
|
729
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
730
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
731
|
+
return v3;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Get the total length of a polyline.
|
|
736
|
+
* Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
|
|
737
|
+
* @param {Float64Array} coords
|
|
738
|
+
* @returns {number}
|
|
739
|
+
*/
|
|
740
|
+
export function polyline_length(coords) {
|
|
741
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
742
|
+
const len0 = WASM_VECTOR_LEN;
|
|
743
|
+
const ret = wasm.polyline_length(ptr0, len0);
|
|
744
|
+
return ret;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Evaluate a point on a polyline at parameter t ∈ [0,1].
|
|
749
|
+
* Input: flat coords [x1,y1,z1, x2,y2,z2, ...]
|
|
750
|
+
* Returns [x, y, z].
|
|
751
|
+
* @param {Float64Array} coords
|
|
752
|
+
* @param {number} t
|
|
753
|
+
* @returns {Float64Array}
|
|
754
|
+
*/
|
|
755
|
+
export function polyline_point_at(coords, t) {
|
|
756
|
+
const ptr0 = passArrayF64ToWasm0(coords, wasm.__wbindgen_malloc);
|
|
757
|
+
const len0 = WASM_VECTOR_LEN;
|
|
758
|
+
const ret = wasm.polyline_point_at(ptr0, len0, t);
|
|
759
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
760
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
761
|
+
return v2;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Sample a NURBS curve.
|
|
766
|
+
* Input: degree, then flat control points [x,y,z,...], then flat weights, then flat knots
|
|
767
|
+
* Format: [degree, num_pts, x0,y0,z0, ..., w0,w1,..., k0,k1,...]
|
|
768
|
+
* @param {Float64Array} data
|
|
769
|
+
* @param {number} samples
|
|
770
|
+
* @returns {Float64Array}
|
|
771
|
+
*/
|
|
772
|
+
export function sample_nurbs_curve(data, samples) {
|
|
773
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
774
|
+
const len0 = WASM_VECTOR_LEN;
|
|
775
|
+
const ret = wasm.sample_nurbs_curve(ptr0, len0, samples);
|
|
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
|
+
* Tessellate a NURBS surface to a mesh buffer.
|
|
783
|
+
* Input format: [degree_u, degree_v, num_u, num_v, ...control_points(flat)..., ...weights(flat)..., ...knots_u..., ...knots_v..., u_segs, v_segs]
|
|
784
|
+
* @param {Float64Array} data
|
|
785
|
+
* @returns {Float64Array}
|
|
786
|
+
*/
|
|
787
|
+
export function tessellate_nurbs_surface(data) {
|
|
788
|
+
const ptr0 = passArrayF64ToWasm0(data, wasm.__wbindgen_malloc);
|
|
789
|
+
const len0 = WASM_VECTOR_LEN;
|
|
790
|
+
const ret = wasm.tessellate_nurbs_surface(ptr0, len0);
|
|
791
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
792
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
793
|
+
return v2;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Simple test function to verify WASM is working
|
|
798
|
+
* @returns {string}
|
|
799
|
+
*/
|
|
800
|
+
export function test_wasm() {
|
|
801
|
+
let deferred1_0;
|
|
802
|
+
let deferred1_1;
|
|
803
|
+
try {
|
|
804
|
+
const ret = wasm.test_wasm();
|
|
805
|
+
deferred1_0 = ret[0];
|
|
806
|
+
deferred1_1 = ret[1];
|
|
807
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
808
|
+
} finally {
|
|
809
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Get version info
|
|
815
|
+
* @returns {string}
|
|
816
|
+
*/
|
|
817
|
+
export function version() {
|
|
818
|
+
let deferred1_0;
|
|
819
|
+
let deferred1_1;
|
|
820
|
+
try {
|
|
821
|
+
const ret = wasm.version();
|
|
822
|
+
deferred1_0 = ret[0];
|
|
823
|
+
deferred1_1 = ret[1];
|
|
824
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
825
|
+
} finally {
|
|
826
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
export function __wbindgen_init_externref_table() {
|
|
830
|
+
const table = wasm.__wbindgen_externrefs;
|
|
831
|
+
const offset = table.grow(4);
|
|
832
|
+
table.set(0, undefined);
|
|
833
|
+
table.set(offset + 0, undefined);
|
|
834
|
+
table.set(offset + 1, null);
|
|
835
|
+
table.set(offset + 2, true);
|
|
836
|
+
table.set(offset + 3, false);
|
|
837
|
+
}
|
|
838
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
839
|
+
ptr = ptr >>> 0;
|
|
840
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
844
|
+
function getFloat64ArrayMemory0() {
|
|
845
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
846
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
847
|
+
}
|
|
848
|
+
return cachedFloat64ArrayMemory0;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
function getStringFromWasm0(ptr, len) {
|
|
852
|
+
ptr = ptr >>> 0;
|
|
853
|
+
return decodeText(ptr, len);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
let cachedUint8ArrayMemory0 = null;
|
|
857
|
+
function getUint8ArrayMemory0() {
|
|
858
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
859
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
860
|
+
}
|
|
861
|
+
return cachedUint8ArrayMemory0;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
865
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
866
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
867
|
+
WASM_VECTOR_LEN = arg.length;
|
|
868
|
+
return ptr;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
872
|
+
if (realloc === undefined) {
|
|
873
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
874
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
875
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
876
|
+
WASM_VECTOR_LEN = buf.length;
|
|
877
|
+
return ptr;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
let len = arg.length;
|
|
881
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
882
|
+
|
|
883
|
+
const mem = getUint8ArrayMemory0();
|
|
884
|
+
|
|
885
|
+
let offset = 0;
|
|
886
|
+
|
|
887
|
+
for (; offset < len; offset++) {
|
|
888
|
+
const code = arg.charCodeAt(offset);
|
|
889
|
+
if (code > 0x7F) break;
|
|
890
|
+
mem[ptr + offset] = code;
|
|
891
|
+
}
|
|
892
|
+
if (offset !== len) {
|
|
893
|
+
if (offset !== 0) {
|
|
894
|
+
arg = arg.slice(offset);
|
|
895
|
+
}
|
|
896
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
897
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
898
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
899
|
+
|
|
900
|
+
offset += ret.written;
|
|
901
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
WASM_VECTOR_LEN = offset;
|
|
905
|
+
return ptr;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
909
|
+
cachedTextDecoder.decode();
|
|
910
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
911
|
+
let numBytesDecoded = 0;
|
|
912
|
+
function decodeText(ptr, len) {
|
|
913
|
+
numBytesDecoded += len;
|
|
914
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
915
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
916
|
+
cachedTextDecoder.decode();
|
|
917
|
+
numBytesDecoded = len;
|
|
918
|
+
}
|
|
919
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
const cachedTextEncoder = new TextEncoder();
|
|
923
|
+
|
|
924
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
925
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
926
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
927
|
+
view.set(buf);
|
|
928
|
+
return {
|
|
929
|
+
read: arg.length,
|
|
930
|
+
written: buf.length
|
|
931
|
+
};
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
let WASM_VECTOR_LEN = 0;
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
let wasm;
|
|
939
|
+
export function __wbg_set_wasm(val) {
|
|
940
|
+
wasm = val;
|
|
941
|
+
}
|