cavi 0.1.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.
package/cavi.js ADDED
@@ -0,0 +1,1510 @@
1
+ /* @ts-self-types="./cavi.d.ts" */
2
+
3
+ export class Node {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(Node.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ NodeFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ NodeFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_node_free(ptr, 0);
20
+ }
21
+ /**
22
+ * @returns {boolean}
23
+ */
24
+ get fixed() {
25
+ const ret = wasm.__wbg_get_node_fixed(this.__wbg_ptr);
26
+ return ret !== 0;
27
+ }
28
+ /**
29
+ * @returns {Position}
30
+ */
31
+ get position() {
32
+ const ret = wasm.__wbg_get_node_position(this.__wbg_ptr);
33
+ return Position.__wrap(ret);
34
+ }
35
+ /**
36
+ * @returns {Point}
37
+ */
38
+ get velocity() {
39
+ const ret = wasm.__wbg_get_node_velocity(this.__wbg_ptr);
40
+ return Point.__wrap(ret);
41
+ }
42
+ /**
43
+ * Applies a force to the node (changes velocity)
44
+ * @param {number} fx
45
+ * @param {number} fy
46
+ */
47
+ apply_force(fx, fy) {
48
+ wasm.node_apply_force(this.__wbg_ptr, fx, fy);
49
+ }
50
+ /**
51
+ * Applies a force from a Point
52
+ * @param {Point} force
53
+ */
54
+ apply_force_point(force) {
55
+ _assertClass(force, Point);
56
+ var ptr0 = force.__destroy_into_raw();
57
+ wasm.node_apply_force_point(this.__wbg_ptr, ptr0);
58
+ }
59
+ /**
60
+ * Returns the squared distance to another node (faster)
61
+ * @param {Node} other
62
+ * @returns {number}
63
+ */
64
+ distance_squared_to(other) {
65
+ _assertClass(other, Node);
66
+ const ret = wasm.node_distance_squared_to(this.__wbg_ptr, other.__wbg_ptr);
67
+ return ret;
68
+ }
69
+ /**
70
+ * Returns the distance to another node
71
+ * @param {Node} other
72
+ * @returns {number}
73
+ */
74
+ distance_to(other) {
75
+ _assertClass(other, Node);
76
+ const ret = wasm.node_distance_to(this.__wbg_ptr, other.__wbg_ptr);
77
+ return ret;
78
+ }
79
+ /**
80
+ * Returns the fixed value (0.0 = movable, 1.0 = fixed)
81
+ * @returns {boolean}
82
+ */
83
+ get_fixed() {
84
+ const ret = wasm.node_get_fixed(this.__wbg_ptr);
85
+ return ret !== 0;
86
+ }
87
+ /**
88
+ * Returns the current position as a Point
89
+ * @returns {Point}
90
+ */
91
+ get_position() {
92
+ const ret = wasm.node_get_position(this.__wbg_ptr);
93
+ return Point.__wrap(ret);
94
+ }
95
+ /**
96
+ * Returns the speed (magnitude of velocity)
97
+ * @returns {number}
98
+ */
99
+ get_speed() {
100
+ const ret = wasm.node_get_speed(this.__wbg_ptr);
101
+ return ret;
102
+ }
103
+ /**
104
+ * Returns the velocity as a Point
105
+ * @returns {Point}
106
+ */
107
+ get_velocity() {
108
+ const ret = wasm.node_get_velocity(this.__wbg_ptr);
109
+ return Point.__wrap(ret);
110
+ }
111
+ /**
112
+ * Returns the velocity x component
113
+ * @returns {number}
114
+ */
115
+ get_velocity_x() {
116
+ const ret = wasm.node_get_velocity_x(this.__wbg_ptr);
117
+ return ret;
118
+ }
119
+ /**
120
+ * Returns the velocity y component
121
+ * @returns {number}
122
+ */
123
+ get_velocity_y() {
124
+ const ret = wasm.node_get_velocity_y(this.__wbg_ptr);
125
+ return ret;
126
+ }
127
+ /**
128
+ * Returns the current x position
129
+ * @returns {number}
130
+ */
131
+ get_x() {
132
+ const ret = wasm.node_get_x(this.__wbg_ptr);
133
+ return ret;
134
+ }
135
+ /**
136
+ * Returns the current y position
137
+ * @returns {number}
138
+ */
139
+ get_y() {
140
+ const ret = wasm.node_get_y(this.__wbg_ptr);
141
+ return ret;
142
+ }
143
+ /**
144
+ * Returns true if the node is fixed
145
+ * @returns {boolean}
146
+ */
147
+ is_fixed() {
148
+ const ret = wasm.node_get_fixed(this.__wbg_ptr);
149
+ return ret !== 0;
150
+ }
151
+ /**
152
+ * Returns true if the node is movable
153
+ * @returns {boolean}
154
+ */
155
+ is_movable() {
156
+ const ret = wasm.node_is_movable(this.__wbg_ptr);
157
+ return ret !== 0;
158
+ }
159
+ /**
160
+ * Makes the node fixed (immovable)
161
+ */
162
+ make_fixed() {
163
+ wasm.node_make_fixed(this.__wbg_ptr);
164
+ }
165
+ /**
166
+ * Makes the node movable
167
+ */
168
+ make_movable() {
169
+ wasm.node_make_movable(this.__wbg_ptr);
170
+ }
171
+ /**
172
+ * @param {Position} pos
173
+ * @param {Point} vel
174
+ * @param {boolean} fix
175
+ */
176
+ constructor(pos, vel, fix) {
177
+ _assertClass(pos, Position);
178
+ var ptr0 = pos.__destroy_into_raw();
179
+ _assertClass(vel, Point);
180
+ var ptr1 = vel.__destroy_into_raw();
181
+ const ret = wasm.node_new(ptr0, ptr1, fix);
182
+ this.__wbg_ptr = ret >>> 0;
183
+ NodeFinalization.register(this, this.__wbg_ptr, this);
184
+ return this;
185
+ }
186
+ /**
187
+ * Creates a fixed Node at the given position
188
+ * @param {number} x
189
+ * @param {number} y
190
+ * @returns {Node}
191
+ */
192
+ static new_fixed(x, y) {
193
+ const ret = wasm.node_new_fixed(x, y);
194
+ return Node.__wrap(ret);
195
+ }
196
+ /**
197
+ * Creates a Node with no initial velocity
198
+ * @param {number} x
199
+ * @param {number} y
200
+ * @param {boolean} fix
201
+ * @returns {Node}
202
+ */
203
+ static new_no_vel(x, y, fix) {
204
+ const ret = wasm.node_new_no_vel(x, y, fix);
205
+ return Node.__wrap(ret);
206
+ }
207
+ /**
208
+ * Converts to a string representation
209
+ * @returns {string}
210
+ */
211
+ print() {
212
+ let deferred1_0;
213
+ let deferred1_1;
214
+ try {
215
+ const ret = wasm.node_print(this.__wbg_ptr);
216
+ deferred1_0 = ret[0];
217
+ deferred1_1 = ret[1];
218
+ return getStringFromWasm0(ret[0], ret[1]);
219
+ } finally {
220
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
221
+ }
222
+ }
223
+ /**
224
+ * Resets the velocity to zero
225
+ */
226
+ reset_velocity() {
227
+ wasm.node_reset_velocity(this.__wbg_ptr);
228
+ }
229
+ /**
230
+ * Sets whether the node is fixed
231
+ * @param {boolean} fixed
232
+ */
233
+ set_fixed(fixed) {
234
+ wasm.node_set_fixed(this.__wbg_ptr, fixed);
235
+ }
236
+ /**
237
+ * Sets the current position
238
+ * @param {number} x
239
+ * @param {number} y
240
+ */
241
+ set_position(x, y) {
242
+ wasm.node_set_position(this.__wbg_ptr, x, y);
243
+ }
244
+ /**
245
+ * Sets the velocity
246
+ * @param {number} vx
247
+ * @param {number} vy
248
+ */
249
+ set_velocity(vx, vy) {
250
+ wasm.node_set_velocity(this.__wbg_ptr, vx, vy);
251
+ }
252
+ /**
253
+ * Moves the node by a delta amount
254
+ * @param {number} dx
255
+ * @param {number} dy
256
+ */
257
+ translate(dx, dy) {
258
+ wasm.node_translate(this.__wbg_ptr, dx, dy);
259
+ }
260
+ /**
261
+ * Updates the position based on velocity and acceleration
262
+ * @param {number} dt
263
+ * @param {number} friction
264
+ * @param {Point} acceleration
265
+ */
266
+ update_position(dt, friction, acceleration) {
267
+ _assertClass(acceleration, Point);
268
+ var ptr0 = acceleration.__destroy_into_raw();
269
+ wasm.node_update_position(this.__wbg_ptr, dt, friction, ptr0);
270
+ }
271
+ /**
272
+ * Updates position with custom acceleration
273
+ * @param {Point} acceleration
274
+ * @param {number} dt
275
+ * @param {number} friction
276
+ */
277
+ update_with_acceleration(acceleration, dt, friction) {
278
+ _assertClass(acceleration, Point);
279
+ var ptr0 = acceleration.__destroy_into_raw();
280
+ wasm.node_update_with_acceleration(this.__wbg_ptr, ptr0, dt, friction);
281
+ }
282
+ /**
283
+ * Creates a Node at origin with no velocity
284
+ * @returns {Node}
285
+ */
286
+ static zero() {
287
+ const ret = wasm.node_zero();
288
+ return Node.__wrap(ret);
289
+ }
290
+ /**
291
+ * @param {boolean} arg0
292
+ */
293
+ set fixed(arg0) {
294
+ wasm.__wbg_set_node_fixed(this.__wbg_ptr, arg0);
295
+ }
296
+ /**
297
+ * @param {Position} arg0
298
+ */
299
+ set position(arg0) {
300
+ _assertClass(arg0, Position);
301
+ var ptr0 = arg0.__destroy_into_raw();
302
+ wasm.__wbg_set_node_position(this.__wbg_ptr, ptr0);
303
+ }
304
+ /**
305
+ * @param {Point} arg0
306
+ */
307
+ set velocity(arg0) {
308
+ _assertClass(arg0, Point);
309
+ var ptr0 = arg0.__destroy_into_raw();
310
+ wasm.__wbg_set_node_velocity(this.__wbg_ptr, ptr0);
311
+ }
312
+ }
313
+ if (Symbol.dispose) Node.prototype[Symbol.dispose] = Node.prototype.free;
314
+
315
+ export class Point {
316
+ static __wrap(ptr) {
317
+ ptr = ptr >>> 0;
318
+ const obj = Object.create(Point.prototype);
319
+ obj.__wbg_ptr = ptr;
320
+ PointFinalization.register(obj, obj.__wbg_ptr, obj);
321
+ return obj;
322
+ }
323
+ __destroy_into_raw() {
324
+ const ptr = this.__wbg_ptr;
325
+ this.__wbg_ptr = 0;
326
+ PointFinalization.unregister(this);
327
+ return ptr;
328
+ }
329
+ free() {
330
+ const ptr = this.__destroy_into_raw();
331
+ wasm.__wbg_point_free(ptr, 0);
332
+ }
333
+ /**
334
+ * @returns {number}
335
+ */
336
+ get x() {
337
+ const ret = wasm.__wbg_get_point_x(this.__wbg_ptr);
338
+ return ret;
339
+ }
340
+ /**
341
+ * @returns {number}
342
+ */
343
+ get y() {
344
+ const ret = wasm.__wbg_get_point_y(this.__wbg_ptr);
345
+ return ret;
346
+ }
347
+ /**
348
+ * Returns the angle of this vector in radians
349
+ * @returns {number}
350
+ */
351
+ angle() {
352
+ const ret = wasm.point_angle(this.__wbg_ptr);
353
+ return ret;
354
+ }
355
+ /**
356
+ * Returns the angle to another point in radians
357
+ * @param {Point} other
358
+ * @returns {number}
359
+ */
360
+ angle_to(other) {
361
+ _assertClass(other, Point);
362
+ const ret = wasm.point_angle_to(this.__wbg_ptr, other.__wbg_ptr);
363
+ return ret;
364
+ }
365
+ /**
366
+ * Returns true if this point is approximately equal to another
367
+ * @param {Point} other
368
+ * @param {number} epsilon
369
+ * @returns {boolean}
370
+ */
371
+ approx_equal(other, epsilon) {
372
+ _assertClass(other, Point);
373
+ const ret = wasm.point_approx_equal(this.__wbg_ptr, other.__wbg_ptr, epsilon);
374
+ return ret !== 0;
375
+ }
376
+ /**
377
+ * Clamps the length of the vector to a maximum value
378
+ * @param {number} max_length
379
+ * @returns {Point}
380
+ */
381
+ clamped(max_length) {
382
+ const ret = wasm.point_clamped(this.__wbg_ptr, max_length);
383
+ return Point.__wrap(ret);
384
+ }
385
+ /**
386
+ * Returns the cross product (z component) with another point
387
+ * @param {Point} other
388
+ * @returns {number}
389
+ */
390
+ cross(other) {
391
+ _assertClass(other, Point);
392
+ const ret = wasm.point_cross(this.__wbg_ptr, other.__wbg_ptr);
393
+ return ret;
394
+ }
395
+ /**
396
+ * Returns the squared distance to another point (avoids sqrt)
397
+ * @param {Point} other
398
+ * @returns {number}
399
+ */
400
+ distance_squared_to(other) {
401
+ _assertClass(other, Point);
402
+ const ret = wasm.point_distance_squared_to(this.__wbg_ptr, other.__wbg_ptr);
403
+ return ret;
404
+ }
405
+ /**
406
+ * Returns the distance to another point
407
+ * @param {Point} other
408
+ * @returns {number}
409
+ */
410
+ distance_to(other) {
411
+ _assertClass(other, Point);
412
+ const ret = wasm.point_distance_to(this.__wbg_ptr, other.__wbg_ptr);
413
+ return ret;
414
+ }
415
+ /**
416
+ * Returns the dot product with another point
417
+ * @param {Point} other
418
+ * @returns {number}
419
+ */
420
+ dot(other) {
421
+ _assertClass(other, Point);
422
+ const ret = wasm.point_dot(this.__wbg_ptr, other.__wbg_ptr);
423
+ return ret;
424
+ }
425
+ /**
426
+ * Returns the length (magnitude) of the vector
427
+ * @returns {number}
428
+ */
429
+ length() {
430
+ const ret = wasm.point_length(this.__wbg_ptr);
431
+ return ret;
432
+ }
433
+ /**
434
+ * Returns the squared length (avoids sqrt for performance)
435
+ * @returns {number}
436
+ */
437
+ length_squared() {
438
+ const ret = wasm.point_length_squared(this.__wbg_ptr);
439
+ return ret;
440
+ }
441
+ /**
442
+ * Linear interpolation between this point and another
443
+ * @param {Point} other
444
+ * @param {number} t
445
+ * @returns {Point}
446
+ */
447
+ lerp(other, t) {
448
+ _assertClass(other, Point);
449
+ const ret = wasm.point_lerp(this.__wbg_ptr, other.__wbg_ptr, t);
450
+ return Point.__wrap(ret);
451
+ }
452
+ /**
453
+ * @param {number} x
454
+ * @param {number} y
455
+ */
456
+ constructor(x, y) {
457
+ const ret = wasm.point_new(x, y);
458
+ this.__wbg_ptr = ret >>> 0;
459
+ PointFinalization.register(this, this.__wbg_ptr, this);
460
+ return this;
461
+ }
462
+ /**
463
+ * Normalizes this point in place
464
+ */
465
+ normalize() {
466
+ wasm.point_normalize(this.__wbg_ptr);
467
+ }
468
+ /**
469
+ * Returns a normalized version of this point (unit vector)
470
+ * @returns {Point}
471
+ */
472
+ normalized() {
473
+ const ret = wasm.point_normalized(this.__wbg_ptr);
474
+ return Point.__wrap(ret);
475
+ }
476
+ /**
477
+ * Returns a point with both components set to 1
478
+ * @returns {Point}
479
+ */
480
+ static one() {
481
+ const ret = wasm.point_one();
482
+ return Point.__wrap(ret);
483
+ }
484
+ /**
485
+ * Returns a perpendicular vector (rotated 90 degrees CCW)
486
+ * @returns {Point}
487
+ */
488
+ perpendicular() {
489
+ const ret = wasm.point_perpendicular(this.__wbg_ptr);
490
+ return Point.__wrap(ret);
491
+ }
492
+ /**
493
+ * Reflects this vector across a normal vector
494
+ * @param {Point} normal
495
+ * @returns {Point}
496
+ */
497
+ reflect(normal) {
498
+ _assertClass(normal, Point);
499
+ const ret = wasm.point_reflect(this.__wbg_ptr, normal.__wbg_ptr);
500
+ return Point.__wrap(ret);
501
+ }
502
+ /**
503
+ * Rotates this point in place by the given angle (in radians)
504
+ * @param {number} angle
505
+ */
506
+ rotate(angle) {
507
+ wasm.point_rotate(this.__wbg_ptr, angle);
508
+ }
509
+ /**
510
+ * Returns a point rotated by the given angle (in radians)
511
+ * @param {number} angle
512
+ * @returns {Point}
513
+ */
514
+ rotated(angle) {
515
+ const ret = wasm.point_rotated(this.__wbg_ptr, angle);
516
+ return Point.__wrap(ret);
517
+ }
518
+ /**
519
+ * Returns a unit point in the X direction (1, 0)
520
+ * @returns {Point}
521
+ */
522
+ static unit_x() {
523
+ const ret = wasm.point_unit_x();
524
+ return Point.__wrap(ret);
525
+ }
526
+ /**
527
+ * Returns a unit point in the Y direction (0, 1)
528
+ * @returns {Point}
529
+ */
530
+ static unit_y() {
531
+ const ret = wasm.point_unit_y();
532
+ return Point.__wrap(ret);
533
+ }
534
+ /**
535
+ * Returns a zero point (0, 0)
536
+ * @returns {Point}
537
+ */
538
+ static zero() {
539
+ const ret = wasm.point_zero();
540
+ return Point.__wrap(ret);
541
+ }
542
+ /**
543
+ * @param {number} arg0
544
+ */
545
+ set x(arg0) {
546
+ wasm.__wbg_set_point_x(this.__wbg_ptr, arg0);
547
+ }
548
+ /**
549
+ * @param {number} arg0
550
+ */
551
+ set y(arg0) {
552
+ wasm.__wbg_set_point_y(this.__wbg_ptr, arg0);
553
+ }
554
+ }
555
+ if (Symbol.dispose) Point.prototype[Symbol.dispose] = Point.prototype.free;
556
+
557
+ export class Position {
558
+ static __wrap(ptr) {
559
+ ptr = ptr >>> 0;
560
+ const obj = Object.create(Position.prototype);
561
+ obj.__wbg_ptr = ptr;
562
+ PositionFinalization.register(obj, obj.__wbg_ptr, obj);
563
+ return obj;
564
+ }
565
+ __destroy_into_raw() {
566
+ const ptr = this.__wbg_ptr;
567
+ this.__wbg_ptr = 0;
568
+ PositionFinalization.unregister(this);
569
+ return ptr;
570
+ }
571
+ free() {
572
+ const ptr = this.__destroy_into_raw();
573
+ wasm.__wbg_position_free(ptr, 0);
574
+ }
575
+ /**
576
+ * @returns {Point}
577
+ */
578
+ get curr() {
579
+ const ret = wasm.__wbg_get_position_curr(this.__wbg_ptr);
580
+ return Point.__wrap(ret);
581
+ }
582
+ /**
583
+ * @returns {Point}
584
+ */
585
+ get old() {
586
+ const ret = wasm.__wbg_get_position_old(this.__wbg_ptr);
587
+ return Point.__wrap(ret);
588
+ }
589
+ /**
590
+ * Applies a constraint by moving the current position
591
+ * @param {Point} target
592
+ */
593
+ constrain(target) {
594
+ _assertClass(target, Point);
595
+ var ptr0 = target.__destroy_into_raw();
596
+ wasm.position_constrain(this.__wbg_ptr, ptr0);
597
+ }
598
+ /**
599
+ * Returns the distance between current and old positions
600
+ * @returns {number}
601
+ */
602
+ displacement() {
603
+ const ret = wasm.position_displacement(this.__wbg_ptr);
604
+ return ret;
605
+ }
606
+ /**
607
+ * Creates a Position from two Points
608
+ * @param {Point} curr
609
+ * @param {Point} old
610
+ * @returns {Position}
611
+ */
612
+ static from_points(curr, old) {
613
+ _assertClass(curr, Point);
614
+ var ptr0 = curr.__destroy_into_raw();
615
+ _assertClass(old, Point);
616
+ var ptr1 = old.__destroy_into_raw();
617
+ const ret = wasm.position_from_points(ptr0, ptr1);
618
+ return Position.__wrap(ret);
619
+ }
620
+ /**
621
+ * Returns the current position as a Point
622
+ * @returns {Point}
623
+ */
624
+ get_curr() {
625
+ const ret = wasm.position_get_curr(this.__wbg_ptr);
626
+ return Point.__wrap(ret);
627
+ }
628
+ /**
629
+ * Returns the current x coordinate
630
+ * @returns {number}
631
+ */
632
+ get_curr_x() {
633
+ const ret = wasm.position_get_curr_x(this.__wbg_ptr);
634
+ return ret;
635
+ }
636
+ /**
637
+ * Returns the current y coordinate
638
+ * @returns {number}
639
+ */
640
+ get_curr_y() {
641
+ const ret = wasm.position_get_curr_y(this.__wbg_ptr);
642
+ return ret;
643
+ }
644
+ /**
645
+ * Returns the old position as a Point
646
+ * @returns {Point}
647
+ */
648
+ get_old() {
649
+ const ret = wasm.position_get_old(this.__wbg_ptr);
650
+ return Point.__wrap(ret);
651
+ }
652
+ /**
653
+ * Returns the old x coordinate
654
+ * @returns {number}
655
+ */
656
+ get_old_x() {
657
+ const ret = wasm.position_get_old_x(this.__wbg_ptr);
658
+ return ret;
659
+ }
660
+ /**
661
+ * Returns the old y coordinate
662
+ * @returns {number}
663
+ */
664
+ get_old_y() {
665
+ const ret = wasm.position_get_old_y(this.__wbg_ptr);
666
+ return ret;
667
+ }
668
+ /**
669
+ * Integrates the position using Verlet integration
670
+ * new_pos = curr + (curr - old) * damping + acceleration * dt^2
671
+ * @param {Point} acceleration
672
+ * @param {number} dt
673
+ * @param {number} damping
674
+ */
675
+ integrate(acceleration, dt, damping) {
676
+ _assertClass(acceleration, Point);
677
+ var ptr0 = acceleration.__destroy_into_raw();
678
+ wasm.position_integrate(this.__wbg_ptr, ptr0, dt, damping);
679
+ }
680
+ /**
681
+ * @param {number} x
682
+ * @param {number} y
683
+ */
684
+ constructor(x, y) {
685
+ const ret = wasm.position_new(x, y);
686
+ this.__wbg_ptr = ret >>> 0;
687
+ PositionFinalization.register(this, this.__wbg_ptr, this);
688
+ return this;
689
+ }
690
+ /**
691
+ * Creates a Position with different current and old positions
692
+ * @param {number} curr_x
693
+ * @param {number} curr_y
694
+ * @param {number} old_x
695
+ * @param {number} old_y
696
+ * @returns {Position}
697
+ */
698
+ static new_with_old(curr_x, curr_y, old_x, old_y) {
699
+ const ret = wasm.position_new_with_old(curr_x, curr_y, old_x, old_y);
700
+ return Position.__wrap(ret);
701
+ }
702
+ /**
703
+ * Resets old position to match current (stops motion)
704
+ */
705
+ reset_velocity() {
706
+ wasm.position_reset_velocity(this.__wbg_ptr);
707
+ }
708
+ /**
709
+ * Sets the current position
710
+ * @param {number} x
711
+ * @param {number} y
712
+ */
713
+ set_curr(x, y) {
714
+ wasm.position_set_curr(this.__wbg_ptr, x, y);
715
+ }
716
+ /**
717
+ * Sets the current position from a Point
718
+ * @param {Point} point
719
+ */
720
+ set_curr_point(point) {
721
+ _assertClass(point, Point);
722
+ var ptr0 = point.__destroy_into_raw();
723
+ wasm.position_set_curr_point(this.__wbg_ptr, ptr0);
724
+ }
725
+ /**
726
+ * Sets the old position
727
+ * @param {number} x
728
+ * @param {number} y
729
+ */
730
+ set_old(x, y) {
731
+ wasm.position_set_old(this.__wbg_ptr, x, y);
732
+ }
733
+ /**
734
+ * Sets the old position from a Point
735
+ * @param {Point} point
736
+ */
737
+ set_old_point(point) {
738
+ _assertClass(point, Point);
739
+ var ptr0 = point.__destroy_into_raw();
740
+ wasm.position_set_old_point(this.__wbg_ptr, ptr0);
741
+ }
742
+ /**
743
+ * Returns the speed (magnitude of velocity)
744
+ * @returns {number}
745
+ */
746
+ speed() {
747
+ const ret = wasm.position_speed(this.__wbg_ptr);
748
+ return ret;
749
+ }
750
+ /**
751
+ * Updates the position: stores current as old, then sets new current
752
+ * @param {number} x
753
+ * @param {number} y
754
+ */
755
+ update(x, y) {
756
+ wasm.position_update(this.__wbg_ptr, x, y);
757
+ }
758
+ /**
759
+ * Updates the position from a Point
760
+ * @param {Point} point
761
+ */
762
+ update_point(point) {
763
+ _assertClass(point, Point);
764
+ var ptr0 = point.__destroy_into_raw();
765
+ wasm.position_update_point(this.__wbg_ptr, ptr0);
766
+ }
767
+ /**
768
+ * Returns the velocity (difference between current and old positions)
769
+ * @returns {Point}
770
+ */
771
+ velocity() {
772
+ const ret = wasm.position_velocity(this.__wbg_ptr);
773
+ return Point.__wrap(ret);
774
+ }
775
+ /**
776
+ * @param {Point} arg0
777
+ */
778
+ set curr(arg0) {
779
+ _assertClass(arg0, Point);
780
+ var ptr0 = arg0.__destroy_into_raw();
781
+ wasm.__wbg_set_position_curr(this.__wbg_ptr, ptr0);
782
+ }
783
+ /**
784
+ * @param {Point} arg0
785
+ */
786
+ set old(arg0) {
787
+ _assertClass(arg0, Point);
788
+ var ptr0 = arg0.__destroy_into_raw();
789
+ wasm.__wbg_set_position_old(this.__wbg_ptr, ptr0);
790
+ }
791
+ }
792
+ if (Symbol.dispose) Position.prototype[Symbol.dispose] = Position.prototype.free;
793
+
794
+ export class Wire {
795
+ static __wrap(ptr) {
796
+ ptr = ptr >>> 0;
797
+ const obj = Object.create(Wire.prototype);
798
+ obj.__wbg_ptr = ptr;
799
+ WireFinalization.register(obj, obj.__wbg_ptr, obj);
800
+ return obj;
801
+ }
802
+ __destroy_into_raw() {
803
+ const ptr = this.__wbg_ptr;
804
+ this.__wbg_ptr = 0;
805
+ WireFinalization.unregister(this);
806
+ return ptr;
807
+ }
808
+ free() {
809
+ const ptr = this.__destroy_into_raw();
810
+ wasm.__wbg_wire_free(ptr, 0);
811
+ }
812
+ /**
813
+ * @returns {number}
814
+ */
815
+ get iterations() {
816
+ const ret = wasm.__wbg_get_wire_iterations(this.__wbg_ptr);
817
+ return ret >>> 0;
818
+ }
819
+ /**
820
+ * @returns {number}
821
+ */
822
+ get link_target_distance() {
823
+ const ret = wasm.__wbg_get_wire_link_target_distance(this.__wbg_ptr);
824
+ return ret;
825
+ }
826
+ /**
827
+ * @returns {number}
828
+ */
829
+ get radius() {
830
+ const ret = wasm.__wbg_get_wire_radius(this.__wbg_ptr);
831
+ return ret;
832
+ }
833
+ /**
834
+ * @returns {number}
835
+ */
836
+ get render_type() {
837
+ const ret = wasm.__wbg_get_wire_render_type(this.__wbg_ptr);
838
+ return ret;
839
+ }
840
+ /**
841
+ * @param {number} arg0
842
+ */
843
+ set iterations(arg0) {
844
+ wasm.__wbg_set_wire_iterations(this.__wbg_ptr, arg0);
845
+ }
846
+ /**
847
+ * @param {number} arg0
848
+ */
849
+ set link_target_distance(arg0) {
850
+ wasm.__wbg_set_wire_link_target_distance(this.__wbg_ptr, arg0);
851
+ }
852
+ /**
853
+ * @param {number} arg0
854
+ */
855
+ set radius(arg0) {
856
+ wasm.__wbg_set_wire_radius(this.__wbg_ptr, arg0);
857
+ }
858
+ /**
859
+ * @param {number} arg0
860
+ */
861
+ set render_type(arg0) {
862
+ wasm.__wbg_set_wire_render_type(this.__wbg_ptr, arg0);
863
+ }
864
+ /**
865
+ * Checks collision with a point and adjusts nodes
866
+ * @param {Point} point
867
+ * @param {number} pointer_radius
868
+ */
869
+ check_collision(point, pointer_radius) {
870
+ _assertClass(point, Point);
871
+ wasm.wire_check_collision(this.__wbg_ptr, point.__wbg_ptr, pointer_radius);
872
+ }
873
+ /**
874
+ * Checks collision with mouse/pointer position
875
+ * @param {Point} mouse
876
+ * @param {number} mouse_radius
877
+ */
878
+ check_mouse_collision(mouse, mouse_radius) {
879
+ _assertClass(mouse, Point);
880
+ var ptr0 = mouse.__destroy_into_raw();
881
+ wasm.wire_check_mouse_collision(this.__wbg_ptr, ptr0, mouse_radius);
882
+ }
883
+ /**
884
+ * Checks for collisions between wire elements
885
+ * @param {number} response_coef
886
+ */
887
+ check_wire_elements_collisions(response_coef) {
888
+ wasm.wire_check_wire_elements_collisions(this.__wbg_ptr, response_coef);
889
+ }
890
+ /**
891
+ * Gets the end point of the wire
892
+ * @returns {Point}
893
+ */
894
+ get_end() {
895
+ const ret = wasm.wire_get_end(this.__wbg_ptr);
896
+ return Point.__wrap(ret);
897
+ }
898
+ /**
899
+ * Gets a specific node by index
900
+ * @param {number} index
901
+ * @returns {Node | undefined}
902
+ */
903
+ get_node(index) {
904
+ const ret = wasm.wire_get_node(this.__wbg_ptr, index);
905
+ return ret === 0 ? undefined : Node.__wrap(ret);
906
+ }
907
+ /**
908
+ * Gets the x coordinate of a node at the given index
909
+ * @param {number} index
910
+ * @returns {number}
911
+ */
912
+ get_node_x(index) {
913
+ const ret = wasm.wire_get_node_x(this.__wbg_ptr, index);
914
+ return ret;
915
+ }
916
+ /**
917
+ * Gets the y coordinate of a node at the given index
918
+ * @param {number} index
919
+ * @returns {number}
920
+ */
921
+ get_node_y(index) {
922
+ const ret = wasm.wire_get_node_y(this.__wbg_ptr, index);
923
+ return ret;
924
+ }
925
+ /**
926
+ * @returns {number}
927
+ */
928
+ get_radius() {
929
+ const ret = wasm.wire_get_radius(this.__wbg_ptr);
930
+ return ret;
931
+ }
932
+ /**
933
+ * Gets the render type (0 = segments, 1 = bezier)
934
+ * @returns {number}
935
+ */
936
+ get_render_type() {
937
+ const ret = wasm.wire_get_render_type(this.__wbg_ptr);
938
+ return ret;
939
+ }
940
+ /**
941
+ * Gets the start point of the wire
942
+ * @returns {Point}
943
+ */
944
+ get_start() {
945
+ const ret = wasm.wire_get_start(this.__wbg_ptr);
946
+ return Point.__wrap(ret);
947
+ }
948
+ /**
949
+ * Resets the iteration counter
950
+ */
951
+ invalidate() {
952
+ wasm.wire_invalidate(this.__wbg_ptr);
953
+ }
954
+ /**
955
+ * Returns the length of the wire (sum of all segment distances)
956
+ * @returns {number}
957
+ */
958
+ length() {
959
+ const ret = wasm.wire_length(this.__wbg_ptr);
960
+ return ret;
961
+ }
962
+ constructor() {
963
+ const ret = wasm.wire_new();
964
+ this.__wbg_ptr = ret >>> 0;
965
+ WireFinalization.register(this, this.__wbg_ptr, this);
966
+ return this;
967
+ }
968
+ /**
969
+ * Creates a wire between two points with specified radius
970
+ * @param {number} xs
971
+ * @param {number} ys
972
+ * @param {number} xe
973
+ * @param {number} ye
974
+ * @param {number} radius
975
+ * @returns {Wire}
976
+ */
977
+ static new_wire(xs, ys, xe, ye, radius) {
978
+ const ret = wasm.wire_new_wire(xs, ys, xe, ye, radius);
979
+ return Wire.__wrap(ret);
980
+ }
981
+ /**
982
+ * Creates a wire with specific node count and link target distance
983
+ * @param {number} xs
984
+ * @param {number} ys
985
+ * @param {number} xe
986
+ * @param {number} ye
987
+ * @param {number} node_count
988
+ * @param {number} link_target
989
+ * @param {number} radius
990
+ * @param {number} render_type
991
+ * @returns {Wire}
992
+ */
993
+ static new_with_count(xs, ys, xe, ye, node_count, link_target, radius, render_type) {
994
+ const ret = wasm.wire_new_with_count(xs, ys, xe, ye, node_count, link_target, radius, render_type);
995
+ return Wire.__wrap(ret);
996
+ }
997
+ /**
998
+ * Returns the number of nodes in the wire
999
+ * @returns {number}
1000
+ */
1001
+ node_count() {
1002
+ const ret = wasm.wire_node_count(this.__wbg_ptr);
1003
+ return ret >>> 0;
1004
+ }
1005
+ /**
1006
+ * @param {Point} start
1007
+ * @param {Point} end
1008
+ * @param {number} node_radius
1009
+ * @returns {number}
1010
+ */
1011
+ static optimal_length(start, end, node_radius) {
1012
+ _assertClass(start, Point);
1013
+ var ptr0 = start.__destroy_into_raw();
1014
+ _assertClass(end, Point);
1015
+ var ptr1 = end.__destroy_into_raw();
1016
+ const ret = wasm.wire_optimal_length(ptr0, ptr1, node_radius);
1017
+ return ret >>> 0;
1018
+ }
1019
+ /**
1020
+ * Sets the end point position (if it's fixed)
1021
+ * @param {number} x
1022
+ * @param {number} y
1023
+ */
1024
+ set_end(x, y) {
1025
+ wasm.wire_set_end(this.__wbg_ptr, x, y);
1026
+ }
1027
+ /**
1028
+ * Sets the number of nodes in the wire
1029
+ * Redistributes nodes evenly between start and end points
1030
+ * @param {number} new_count
1031
+ */
1032
+ set_node_count(new_count) {
1033
+ wasm.wire_set_node_count(this.__wbg_ptr, new_count);
1034
+ }
1035
+ /**
1036
+ * Sets the fixed state of a specific node
1037
+ * @param {number} node_idx
1038
+ * @param {boolean} fixed
1039
+ */
1040
+ set_node_fixed(node_idx, fixed) {
1041
+ wasm.wire_set_node_fixed(this.__wbg_ptr, node_idx, fixed);
1042
+ }
1043
+ /**
1044
+ * Sets the radius of the wire
1045
+ * @param {number} radius
1046
+ */
1047
+ set_radius(radius) {
1048
+ wasm.wire_set_radius(this.__wbg_ptr, radius);
1049
+ }
1050
+ /**
1051
+ * Sets the render type (0 = segments, 1 = bezier)
1052
+ * @param {number} render_type
1053
+ */
1054
+ set_render_type(render_type) {
1055
+ wasm.wire_set_render_type(this.__wbg_ptr, render_type);
1056
+ }
1057
+ /**
1058
+ * Sets the start point position (if it's fixed)
1059
+ * @param {number} x
1060
+ * @param {number} y
1061
+ */
1062
+ set_start(x, y) {
1063
+ wasm.wire_set_start(this.__wbg_ptr, x, y);
1064
+ }
1065
+ /**
1066
+ * Updates the wire physics simulation
1067
+ * @param {number} dt
1068
+ * @param {number} friction
1069
+ * @param {Point} acceleration
1070
+ */
1071
+ update(dt, friction, acceleration) {
1072
+ _assertClass(acceleration, Point);
1073
+ var ptr0 = acceleration.__destroy_into_raw();
1074
+ wasm.wire_update(this.__wbg_ptr, dt, friction, ptr0);
1075
+ }
1076
+ }
1077
+ if (Symbol.dispose) Wire.prototype[Symbol.dispose] = Wire.prototype.free;
1078
+
1079
+ export class World {
1080
+ __destroy_into_raw() {
1081
+ const ptr = this.__wbg_ptr;
1082
+ this.__wbg_ptr = 0;
1083
+ WorldFinalization.unregister(this);
1084
+ return ptr;
1085
+ }
1086
+ free() {
1087
+ const ptr = this.__destroy_into_raw();
1088
+ wasm.__wbg_world_free(ptr, 0);
1089
+ }
1090
+ /**
1091
+ * Adds a wire between two points with specified radius
1092
+ * @param {number} xs
1093
+ * @param {number} ys
1094
+ * @param {number} xe
1095
+ * @param {number} ye
1096
+ * @param {number} radius
1097
+ */
1098
+ add_wire(xs, ys, xe, ye, radius) {
1099
+ wasm.world_add_wire(this.__wbg_ptr, xs, ys, xe, ye, radius);
1100
+ }
1101
+ /**
1102
+ * Adds a default wire to the world
1103
+ */
1104
+ add_wire_debug() {
1105
+ wasm.world_add_wire_debug(this.__wbg_ptr);
1106
+ }
1107
+ /**
1108
+ * Adds a wire with specific node count and link target distance
1109
+ * @param {number} xs
1110
+ * @param {number} ys
1111
+ * @param {number} xe
1112
+ * @param {number} ye
1113
+ * @param {number} node_count
1114
+ * @param {number} link_target
1115
+ * @param {number} radius
1116
+ * @param {number} render_type
1117
+ */
1118
+ add_wire_with_count(xs, ys, xe, ye, node_count, link_target, radius, render_type) {
1119
+ wasm.world_add_wire_with_count(this.__wbg_ptr, xs, ys, xe, ye, node_count, link_target, radius, render_type);
1120
+ }
1121
+ /**
1122
+ * Gets the acceleration vector
1123
+ * @returns {Point}
1124
+ */
1125
+ get_acceleration() {
1126
+ const ret = wasm.world_get_acceleration(this.__wbg_ptr);
1127
+ return Point.__wrap(ret);
1128
+ }
1129
+ /**
1130
+ * Gets the friction coefficient
1131
+ * @returns {number}
1132
+ */
1133
+ get_friction() {
1134
+ const ret = wasm.world_get_friction(this.__wbg_ptr);
1135
+ return ret;
1136
+ }
1137
+ /**
1138
+ * Gets the mouse interaction radius
1139
+ * @returns {number}
1140
+ */
1141
+ get_mouse_radius() {
1142
+ const ret = wasm.world_get_mouse_radius(this.__wbg_ptr);
1143
+ return ret;
1144
+ }
1145
+ /**
1146
+ * Gets the pointer collision radius
1147
+ * @returns {number}
1148
+ */
1149
+ get_pointer_radius() {
1150
+ const ret = wasm.world_get_pointer_radius(this.__wbg_ptr);
1151
+ return ret;
1152
+ }
1153
+ /**
1154
+ * Gets the collision response coefficient
1155
+ * @returns {number}
1156
+ */
1157
+ get_response_coef() {
1158
+ const ret = wasm.world_get_response_coef(this.__wbg_ptr);
1159
+ return ret;
1160
+ }
1161
+ /**
1162
+ * Gets a specific wire by index
1163
+ * @param {number} index
1164
+ * @returns {Wire | undefined}
1165
+ */
1166
+ get_wire(index) {
1167
+ const ret = wasm.world_get_wire(this.__wbg_ptr, index);
1168
+ return ret === 0 ? undefined : Wire.__wrap(ret);
1169
+ }
1170
+ /**
1171
+ * Gets a node from a specific wire
1172
+ * @param {number} wire_idx
1173
+ * @param {number} node_idx
1174
+ * @returns {Node | undefined}
1175
+ */
1176
+ get_wire_node(wire_idx, node_idx) {
1177
+ const ret = wasm.world_get_wire_node(this.__wbg_ptr, wire_idx, node_idx);
1178
+ return ret === 0 ? undefined : Node.__wrap(ret);
1179
+ }
1180
+ /**
1181
+ * Gets the number of nodes in a specific wire
1182
+ * @param {number} wire_idx
1183
+ * @returns {number}
1184
+ */
1185
+ get_wire_node_count(wire_idx) {
1186
+ const ret = wasm.world_get_wire_node_count(this.__wbg_ptr, wire_idx);
1187
+ return ret >>> 0;
1188
+ }
1189
+ /**
1190
+ * Gets x coordinate of a node in a wire
1191
+ * @param {number} wire_idx
1192
+ * @param {number} node_idx
1193
+ * @returns {number}
1194
+ */
1195
+ get_wire_node_x(wire_idx, node_idx) {
1196
+ const ret = wasm.world_get_wire_node_x(this.__wbg_ptr, wire_idx, node_idx);
1197
+ return ret;
1198
+ }
1199
+ /**
1200
+ * Gets y coordinate of a node in a wire
1201
+ * @param {number} wire_idx
1202
+ * @param {number} node_idx
1203
+ * @returns {number}
1204
+ */
1205
+ get_wire_node_y(wire_idx, node_idx) {
1206
+ const ret = wasm.world_get_wire_node_y(this.__wbg_ptr, wire_idx, node_idx);
1207
+ return ret;
1208
+ }
1209
+ /**
1210
+ * @param {number} wire_idx
1211
+ * @returns {number}
1212
+ */
1213
+ get_wire_radius(wire_idx) {
1214
+ const ret = wasm.world_get_wire_radius(this.__wbg_ptr, wire_idx);
1215
+ return ret;
1216
+ }
1217
+ constructor() {
1218
+ const ret = wasm.world_new();
1219
+ this.__wbg_ptr = ret >>> 0;
1220
+ WorldFinalization.register(this, this.__wbg_ptr, this);
1221
+ return this;
1222
+ }
1223
+ /**
1224
+ * Sets the acceleration vector
1225
+ * @param {number} x
1226
+ * @param {number} y
1227
+ */
1228
+ set_acceleration(x, y) {
1229
+ wasm.world_set_acceleration(this.__wbg_ptr, x, y);
1230
+ }
1231
+ /**
1232
+ * Sets the friction coefficient
1233
+ * @param {number} friction
1234
+ */
1235
+ set_friction(friction) {
1236
+ wasm.world_set_friction(this.__wbg_ptr, friction);
1237
+ }
1238
+ /**
1239
+ * Sets the mouse position
1240
+ * @param {number} x
1241
+ * @param {number} y
1242
+ */
1243
+ set_mouse(x, y) {
1244
+ wasm.world_set_mouse(this.__wbg_ptr, x, y);
1245
+ }
1246
+ /**
1247
+ * Sets the mouse interaction radius
1248
+ * @param {number} radius
1249
+ */
1250
+ set_mouse_radius(radius) {
1251
+ wasm.world_set_mouse_radius(this.__wbg_ptr, radius);
1252
+ }
1253
+ /**
1254
+ * Sets the pointer collision radius
1255
+ * @param {number} radius
1256
+ */
1257
+ set_pointer_radius(radius) {
1258
+ wasm.world_set_pointer_radius(this.__wbg_ptr, radius);
1259
+ }
1260
+ /**
1261
+ * Sets the collision response coefficient
1262
+ * @param {number} coef
1263
+ */
1264
+ set_response_coef(coef) {
1265
+ wasm.world_set_response_coef(this.__wbg_ptr, coef);
1266
+ }
1267
+ /**
1268
+ * Sets the position of the last node (end) of a wire
1269
+ * @param {number} wire_idx
1270
+ * @param {number} x
1271
+ * @param {number} y
1272
+ */
1273
+ set_wire_end(wire_idx, x, y) {
1274
+ wasm.world_set_wire_end(this.__wbg_ptr, wire_idx, x, y);
1275
+ }
1276
+ /**
1277
+ * Sets the number of nodes in a specific wire
1278
+ * @param {number} wire_idx
1279
+ * @param {number} node_count
1280
+ */
1281
+ set_wire_node_count(wire_idx, node_count) {
1282
+ wasm.world_set_wire_node_count(this.__wbg_ptr, wire_idx, node_count);
1283
+ }
1284
+ /**
1285
+ * Sets the fixed state of a specific node in a wire
1286
+ * @param {number} wire_idx
1287
+ * @param {number} node_idx
1288
+ * @param {boolean} fixed
1289
+ */
1290
+ set_wire_node_fixed(wire_idx, node_idx, fixed) {
1291
+ wasm.world_set_wire_node_fixed(this.__wbg_ptr, wire_idx, node_idx, fixed);
1292
+ }
1293
+ /**
1294
+ * Sets the position of the first node (start) of a wire
1295
+ * @param {number} wire_idx
1296
+ * @param {number} x
1297
+ * @param {number} y
1298
+ */
1299
+ set_wire_start(wire_idx, x, y) {
1300
+ wasm.world_set_wire_start(this.__wbg_ptr, wire_idx, x, y);
1301
+ }
1302
+ /**
1303
+ * Updates all wires in the world
1304
+ */
1305
+ update() {
1306
+ wasm.world_update(this.__wbg_ptr);
1307
+ }
1308
+ /**
1309
+ * Returns the number of wires
1310
+ * @returns {number}
1311
+ */
1312
+ wire_count() {
1313
+ const ret = wasm.world_wire_count(this.__wbg_ptr);
1314
+ return ret >>> 0;
1315
+ }
1316
+ /**
1317
+ * Returns the length of the wire data buffer
1318
+ * @returns {number}
1319
+ */
1320
+ wire_data_len() {
1321
+ const ret = wasm.world_wire_data_len(this.__wbg_ptr);
1322
+ return ret >>> 0;
1323
+ }
1324
+ /**
1325
+ * Returns the pointer to the wire data buffer
1326
+ * Buffer format per wire: [node_count, radius, render_type, path_length, ...path_data]
1327
+ * @returns {number}
1328
+ */
1329
+ wire_data_ptr() {
1330
+ const ret = wasm.world_wire_data_ptr(this.__wbg_ptr);
1331
+ return ret >>> 0;
1332
+ }
1333
+ /**
1334
+ * Calculates the default node count for a wire based on distance and link target
1335
+ * @param {number} start_x
1336
+ * @param {number} start_y
1337
+ * @param {number} end_x
1338
+ * @param {number} end_y
1339
+ * @param {number} radius
1340
+ * @returns {number}
1341
+ */
1342
+ static wire_optimal_length(start_x, start_y, end_x, end_y, radius) {
1343
+ const ret = wasm.world_wire_optimal_length(start_x, start_y, end_x, end_y, radius);
1344
+ return ret >>> 0;
1345
+ }
1346
+ }
1347
+ if (Symbol.dispose) World.prototype[Symbol.dispose] = World.prototype.free;
1348
+
1349
+ function __wbg_get_imports() {
1350
+ const import0 = {
1351
+ __proto__: null,
1352
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
1353
+ throw new Error(getStringFromWasm0(arg0, arg1));
1354
+ },
1355
+ __wbindgen_init_externref_table: function() {
1356
+ const table = wasm.__wbindgen_externrefs;
1357
+ const offset = table.grow(4);
1358
+ table.set(0, undefined);
1359
+ table.set(offset + 0, undefined);
1360
+ table.set(offset + 1, null);
1361
+ table.set(offset + 2, true);
1362
+ table.set(offset + 3, false);
1363
+ },
1364
+ };
1365
+ return {
1366
+ __proto__: null,
1367
+ "./cavi_bg.js": import0,
1368
+ };
1369
+ }
1370
+
1371
+ const NodeFinalization = (typeof FinalizationRegistry === 'undefined')
1372
+ ? { register: () => {}, unregister: () => {} }
1373
+ : new FinalizationRegistry(ptr => wasm.__wbg_node_free(ptr >>> 0, 1));
1374
+ const PointFinalization = (typeof FinalizationRegistry === 'undefined')
1375
+ ? { register: () => {}, unregister: () => {} }
1376
+ : new FinalizationRegistry(ptr => wasm.__wbg_point_free(ptr >>> 0, 1));
1377
+ const PositionFinalization = (typeof FinalizationRegistry === 'undefined')
1378
+ ? { register: () => {}, unregister: () => {} }
1379
+ : new FinalizationRegistry(ptr => wasm.__wbg_position_free(ptr >>> 0, 1));
1380
+ const WireFinalization = (typeof FinalizationRegistry === 'undefined')
1381
+ ? { register: () => {}, unregister: () => {} }
1382
+ : new FinalizationRegistry(ptr => wasm.__wbg_wire_free(ptr >>> 0, 1));
1383
+ const WorldFinalization = (typeof FinalizationRegistry === 'undefined')
1384
+ ? { register: () => {}, unregister: () => {} }
1385
+ : new FinalizationRegistry(ptr => wasm.__wbg_world_free(ptr >>> 0, 1));
1386
+
1387
+ function _assertClass(instance, klass) {
1388
+ if (!(instance instanceof klass)) {
1389
+ throw new Error(`expected instance of ${klass.name}`);
1390
+ }
1391
+ }
1392
+
1393
+ function getStringFromWasm0(ptr, len) {
1394
+ ptr = ptr >>> 0;
1395
+ return decodeText(ptr, len);
1396
+ }
1397
+
1398
+ let cachedUint8ArrayMemory0 = null;
1399
+ function getUint8ArrayMemory0() {
1400
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1401
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1402
+ }
1403
+ return cachedUint8ArrayMemory0;
1404
+ }
1405
+
1406
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1407
+ cachedTextDecoder.decode();
1408
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1409
+ let numBytesDecoded = 0;
1410
+ function decodeText(ptr, len) {
1411
+ numBytesDecoded += len;
1412
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1413
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1414
+ cachedTextDecoder.decode();
1415
+ numBytesDecoded = len;
1416
+ }
1417
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1418
+ }
1419
+
1420
+ let wasmModule, wasm;
1421
+ function __wbg_finalize_init(instance, module) {
1422
+ wasm = instance.exports;
1423
+ wasmModule = module;
1424
+ cachedUint8ArrayMemory0 = null;
1425
+ wasm.__wbindgen_start();
1426
+ return wasm;
1427
+ }
1428
+
1429
+ async function __wbg_load(module, imports) {
1430
+ if (typeof Response === 'function' && module instanceof Response) {
1431
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1432
+ try {
1433
+ return await WebAssembly.instantiateStreaming(module, imports);
1434
+ } catch (e) {
1435
+ const validResponse = module.ok && expectedResponseType(module.type);
1436
+
1437
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1438
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1439
+
1440
+ } else { throw e; }
1441
+ }
1442
+ }
1443
+
1444
+ const bytes = await module.arrayBuffer();
1445
+ return await WebAssembly.instantiate(bytes, imports);
1446
+ } else {
1447
+ const instance = await WebAssembly.instantiate(module, imports);
1448
+
1449
+ if (instance instanceof WebAssembly.Instance) {
1450
+ return { instance, module };
1451
+ } else {
1452
+ return instance;
1453
+ }
1454
+ }
1455
+
1456
+ function expectedResponseType(type) {
1457
+ switch (type) {
1458
+ case 'basic': case 'cors': case 'default': return true;
1459
+ }
1460
+ return false;
1461
+ }
1462
+ }
1463
+
1464
+ function initSync(module) {
1465
+ if (wasm !== undefined) return wasm;
1466
+
1467
+
1468
+ if (module !== undefined) {
1469
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1470
+ ({module} = module)
1471
+ } else {
1472
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1473
+ }
1474
+ }
1475
+
1476
+ const imports = __wbg_get_imports();
1477
+ if (!(module instanceof WebAssembly.Module)) {
1478
+ module = new WebAssembly.Module(module);
1479
+ }
1480
+ const instance = new WebAssembly.Instance(module, imports);
1481
+ return __wbg_finalize_init(instance, module);
1482
+ }
1483
+
1484
+ async function __wbg_init(module_or_path) {
1485
+ if (wasm !== undefined) return wasm;
1486
+
1487
+
1488
+ if (module_or_path !== undefined) {
1489
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1490
+ ({module_or_path} = module_or_path)
1491
+ } else {
1492
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1493
+ }
1494
+ }
1495
+
1496
+ if (module_or_path === undefined) {
1497
+ module_or_path = new URL('cavi_bg.wasm', import.meta.url);
1498
+ }
1499
+ const imports = __wbg_get_imports();
1500
+
1501
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1502
+ module_or_path = fetch(module_or_path);
1503
+ }
1504
+
1505
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1506
+
1507
+ return __wbg_finalize_init(instance, module);
1508
+ }
1509
+
1510
+ export { initSync, __wbg_init as default };