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