cavi 0.1.1 → 0.1.2

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