ballistics-engine 0.13.3 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +201 -0
- package/README.md +90 -573
- package/ballistics_engine.d.ts +99 -39
- package/ballistics_engine.js +7 -542
- package/ballistics_engine_bg.js +534 -0
- package/ballistics_engine_bg.wasm +0 -0
- package/package.json +18 -6
package/ballistics_engine.d.ts
CHANGED
|
@@ -1,49 +1,109 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Object-oriented calculator for programmatic use
|
|
5
6
|
* Provides a type-safe, fluent API alternative to the CLI interface
|
|
6
7
|
*/
|
|
7
8
|
export class Calculator {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* Add a downrange wind segment: `speed_mph` from `direction_deg`
|
|
13
|
+
* (wind-FROM: 0 = headwind, 90 = from the right) out to `until_yards`.
|
|
14
|
+
* Each segment applies from the previous boundary to `until_yards`; wind is
|
|
15
|
+
* zero beyond the last segment. When any segment is added it overrides the
|
|
16
|
+
* scalar `setWind` value. Repeatable.
|
|
17
|
+
*/
|
|
18
|
+
addWindSegment(speed_mph: number, direction_deg: number, until_yards: number): Calculator;
|
|
19
|
+
/**
|
|
20
|
+
* Calculate trajectory and return result as JavaScript object
|
|
21
|
+
* Returns: { range_yards, drop_inches, windage_inches, velocity_fps, energy_ftlb, time_sec }
|
|
22
|
+
*/
|
|
23
|
+
calculateTrajectory(range_yards: number): any;
|
|
24
|
+
/**
|
|
25
|
+
* Remove all downrange wind segments (reverts to the scalar `setWind`).
|
|
26
|
+
*/
|
|
27
|
+
clearWindSegments(): Calculator;
|
|
28
|
+
enableCoriolis(enabled: boolean, latitude?: number | null): Calculator;
|
|
29
|
+
enableSpinDrift(enabled: boolean, twist_rate?: number | null): Calculator;
|
|
30
|
+
/**
|
|
31
|
+
* Get full trajectory table as array of points
|
|
32
|
+
* Returns array of: [{ range_yards, drop_inches, windage_inches, velocity_fps, energy_ftlb, time_sec }, ...]
|
|
33
|
+
*/
|
|
34
|
+
getFullTrajectory(): any;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new calculator with default values
|
|
37
|
+
* Defaults: .308 Winchester 168gr at 2700 fps, standard atmosphere
|
|
38
|
+
*/
|
|
39
|
+
constructor();
|
|
40
|
+
setAltitude(altitude_ft: number): Calculator;
|
|
41
|
+
setBC(bc: number): Calculator;
|
|
42
|
+
setDiameter(diameter_inches: number): Calculator;
|
|
43
|
+
setDragModel(model: string): Calculator;
|
|
44
|
+
setHumidity(humidity: number): Calculator;
|
|
45
|
+
setMass(mass_grains: number): Calculator;
|
|
46
|
+
setMaxRange(range_yards: number): Calculator;
|
|
47
|
+
setPressure(pressure_inhg: number): Calculator;
|
|
48
|
+
setSightHeight(height_inches: number): Calculator;
|
|
49
|
+
setTemperature(temp_f: number): Calculator;
|
|
50
|
+
setVelocity(velocity_fps: number): Calculator;
|
|
51
|
+
setWind(speed_mph: number, direction_deg: number): Calculator;
|
|
52
|
+
setZeroRange(range_yards: number): Calculator;
|
|
40
53
|
}
|
|
54
|
+
|
|
41
55
|
export class WasmBallistics {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
free(): void;
|
|
57
|
+
[Symbol.dispose](): void;
|
|
58
|
+
/**
|
|
59
|
+
* Report whether a BC5D table is currently loaded.
|
|
60
|
+
*/
|
|
61
|
+
hasBc5dTable(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Report whether a custom drag table is currently loaded.
|
|
64
|
+
*/
|
|
65
|
+
hasDragTable(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Load a BC5D correction table from the raw bytes of a `bc5d_<caliber>.bin`
|
|
68
|
+
* file. The host (browser `fetch()` or Node `fs`/`fetch`) is responsible
|
|
69
|
+
* for retrieving the file — WASM has no filesystem or network — and passes
|
|
70
|
+
* the bytes here.
|
|
71
|
+
*
|
|
72
|
+
* Once loaded, any `trajectory` run that includes `--use-bc-segments` will
|
|
73
|
+
* apply velocity-dependent BC segments synthesized from this table. Load a
|
|
74
|
+
* table matching the bullet's caliber (e.g. `bc5d_308.bin` for a .308).
|
|
75
|
+
*
|
|
76
|
+
* Returns a short human-readable summary of the loaded table. Replaces any
|
|
77
|
+
* previously loaded table.
|
|
78
|
+
*/
|
|
79
|
+
loadBc5dTable(bytes: Uint8Array): string;
|
|
80
|
+
/**
|
|
81
|
+
* Load a custom Mach:Cd drag table (MBA-1328) — a measured or manufacturer-published
|
|
82
|
+
* drag curve (Hornady CDM data, a Lapua/Doppler-radar-derived deck, or your own) — from
|
|
83
|
+
* the raw bytes of a CSV file. The host (browser `fetch()` or Node `fs`/`fetch`) is
|
|
84
|
+
* responsible for retrieving the file — WASM has no filesystem or network — and passes
|
|
85
|
+
* the bytes here, mirroring [`Self::load_bc5d_table`].
|
|
86
|
+
*
|
|
87
|
+
* The bytes must be valid UTF-8 CSV text; parsing is delegated to
|
|
88
|
+
* [`crate::drag::DragTable::from_csv_str`] — the SAME parser native `--drag-table`
|
|
89
|
+
* uses — so the accepted format is identical: two columns `mach,cd` per line, blank
|
|
90
|
+
* lines and `#` comments ignored, a single leading textual header row tolerated, Mach
|
|
91
|
+
* strictly ascending with at least 2 points, Cd finite and > 0.
|
|
92
|
+
*
|
|
93
|
+
* Once loaded, EVERY subsequent `trajectory`, `zero`, `lead`, and `monte-carlo` run
|
|
94
|
+
* applies the table automatically — no `--use-*` gate flag is needed (unlike a loaded
|
|
95
|
+
* BC5D table, which only takes effect with `--use-bc-segments`). A loaded table is a
|
|
96
|
+
* full physical substitute for the G-model + BC (see `calculate_drag_coefficient`):
|
|
97
|
+
* `-b`/`--bc` may still be supplied but is ignored for drag once a table is active
|
|
98
|
+
* (matching the native `--drag-table` CLI semantics documented in CLI_USAGE.md).
|
|
99
|
+
*
|
|
100
|
+
* Returns a short human-readable summary of the loaded table (point count + Mach
|
|
101
|
+
* range). Replaces any previously loaded table.
|
|
102
|
+
*/
|
|
103
|
+
loadDragTable(bytes: Uint8Array): string;
|
|
104
|
+
constructor();
|
|
105
|
+
/**
|
|
106
|
+
* Run a command and return the output
|
|
107
|
+
*/
|
|
108
|
+
runCommand(command: string): string;
|
|
49
109
|
}
|
package/ballistics_engine.js
CHANGED
|
@@ -1,544 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./ballistics_engine.d.ts" */
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let cachedUint8ArrayMemory0 = null;
|
|
6
|
-
|
|
7
|
-
function getUint8ArrayMemory0() {
|
|
8
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
9
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
10
|
-
}
|
|
11
|
-
return cachedUint8ArrayMemory0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
15
|
-
|
|
16
|
-
cachedTextDecoder.decode();
|
|
17
|
-
|
|
18
|
-
function decodeText(ptr, len) {
|
|
19
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function getStringFromWasm0(ptr, len) {
|
|
23
|
-
ptr = ptr >>> 0;
|
|
24
|
-
return decodeText(ptr, len);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function addToExternrefTable0(obj) {
|
|
28
|
-
const idx = wasm.__externref_table_alloc();
|
|
29
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
30
|
-
return idx;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function handleError(f, args) {
|
|
34
|
-
try {
|
|
35
|
-
return f.apply(this, args);
|
|
36
|
-
} catch (e) {
|
|
37
|
-
const idx = addToExternrefTable0(e);
|
|
38
|
-
wasm.__wbindgen_exn_store(idx);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
43
|
-
ptr = ptr >>> 0;
|
|
44
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function isLikeNone(x) {
|
|
48
|
-
return x === undefined || x === null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let WASM_VECTOR_LEN = 0;
|
|
52
|
-
|
|
53
|
-
const cachedTextEncoder = new TextEncoder();
|
|
54
|
-
|
|
55
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
56
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
57
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
58
|
-
view.set(buf);
|
|
59
|
-
return {
|
|
60
|
-
read: arg.length,
|
|
61
|
-
written: buf.length
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
67
|
-
|
|
68
|
-
if (realloc === undefined) {
|
|
69
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
70
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
71
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
72
|
-
WASM_VECTOR_LEN = buf.length;
|
|
73
|
-
return ptr;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
let len = arg.length;
|
|
77
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
78
|
-
|
|
79
|
-
const mem = getUint8ArrayMemory0();
|
|
80
|
-
|
|
81
|
-
let offset = 0;
|
|
82
|
-
|
|
83
|
-
for (; offset < len; offset++) {
|
|
84
|
-
const code = arg.charCodeAt(offset);
|
|
85
|
-
if (code > 0x7F) break;
|
|
86
|
-
mem[ptr + offset] = code;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (offset !== len) {
|
|
90
|
-
if (offset !== 0) {
|
|
91
|
-
arg = arg.slice(offset);
|
|
92
|
-
}
|
|
93
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
94
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
95
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
96
|
-
|
|
97
|
-
offset += ret.written;
|
|
98
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
WASM_VECTOR_LEN = offset;
|
|
102
|
-
return ptr;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function takeFromExternrefTable0(idx) {
|
|
106
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
107
|
-
wasm.__externref_table_dealloc(idx);
|
|
108
|
-
return value;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const CalculatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
112
|
-
? { register: () => {}, unregister: () => {} }
|
|
113
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_calculator_free(ptr >>> 0, 1));
|
|
114
|
-
/**
|
|
115
|
-
* Object-oriented calculator for programmatic use
|
|
116
|
-
* Provides a type-safe, fluent API alternative to the CLI interface
|
|
117
|
-
*/
|
|
118
|
-
class Calculator {
|
|
119
|
-
|
|
120
|
-
static __wrap(ptr) {
|
|
121
|
-
ptr = ptr >>> 0;
|
|
122
|
-
const obj = Object.create(Calculator.prototype);
|
|
123
|
-
obj.__wbg_ptr = ptr;
|
|
124
|
-
CalculatorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
125
|
-
return obj;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
__destroy_into_raw() {
|
|
129
|
-
const ptr = this.__wbg_ptr;
|
|
130
|
-
this.__wbg_ptr = 0;
|
|
131
|
-
CalculatorFinalization.unregister(this);
|
|
132
|
-
return ptr;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
free() {
|
|
136
|
-
const ptr = this.__destroy_into_raw();
|
|
137
|
-
wasm.__wbg_calculator_free(ptr, 0);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @param {number} altitude_ft
|
|
141
|
-
* @returns {Calculator}
|
|
142
|
-
*/
|
|
143
|
-
setAltitude(altitude_ft) {
|
|
144
|
-
const ptr = this.__destroy_into_raw();
|
|
145
|
-
const ret = wasm.calculator_setAltitude(ptr, altitude_ft);
|
|
146
|
-
return Calculator.__wrap(ret);
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* @param {number} diameter_inches
|
|
150
|
-
* @returns {Calculator}
|
|
151
|
-
*/
|
|
152
|
-
setDiameter(diameter_inches) {
|
|
153
|
-
const ptr = this.__destroy_into_raw();
|
|
154
|
-
const ret = wasm.calculator_setDiameter(ptr, diameter_inches);
|
|
155
|
-
return Calculator.__wrap(ret);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* @param {number} humidity
|
|
159
|
-
* @returns {Calculator}
|
|
160
|
-
*/
|
|
161
|
-
setHumidity(humidity) {
|
|
162
|
-
const ptr = this.__destroy_into_raw();
|
|
163
|
-
const ret = wasm.calculator_setHumidity(ptr, humidity);
|
|
164
|
-
return Calculator.__wrap(ret);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* @param {number} pressure_inhg
|
|
168
|
-
* @returns {Calculator}
|
|
169
|
-
*/
|
|
170
|
-
setPressure(pressure_inhg) {
|
|
171
|
-
const ptr = this.__destroy_into_raw();
|
|
172
|
-
const ret = wasm.calculator_setPressure(ptr, pressure_inhg);
|
|
173
|
-
return Calculator.__wrap(ret);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* @param {number} velocity_fps
|
|
177
|
-
* @returns {Calculator}
|
|
178
|
-
*/
|
|
179
|
-
setVelocity(velocity_fps) {
|
|
180
|
-
const ptr = this.__destroy_into_raw();
|
|
181
|
-
const ret = wasm.calculator_setVelocity(ptr, velocity_fps);
|
|
182
|
-
return Calculator.__wrap(ret);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* @param {number} range_yards
|
|
186
|
-
* @returns {Calculator}
|
|
187
|
-
*/
|
|
188
|
-
setMaxRange(range_yards) {
|
|
189
|
-
const ptr = this.__destroy_into_raw();
|
|
190
|
-
const ret = wasm.calculator_setMaxRange(ptr, range_yards);
|
|
191
|
-
return Calculator.__wrap(ret);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* @param {string} model
|
|
195
|
-
* @returns {Calculator}
|
|
196
|
-
*/
|
|
197
|
-
setDragModel(model) {
|
|
198
|
-
const ptr = this.__destroy_into_raw();
|
|
199
|
-
const ptr0 = passStringToWasm0(model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
200
|
-
const len0 = WASM_VECTOR_LEN;
|
|
201
|
-
const ret = wasm.calculator_setDragModel(ptr, ptr0, len0);
|
|
202
|
-
return Calculator.__wrap(ret);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* @param {number} range_yards
|
|
206
|
-
* @returns {Calculator}
|
|
207
|
-
*/
|
|
208
|
-
setZeroRange(range_yards) {
|
|
209
|
-
const ptr = this.__destroy_into_raw();
|
|
210
|
-
const ret = wasm.calculator_setZeroRange(ptr, range_yards);
|
|
211
|
-
return Calculator.__wrap(ret);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* @param {number} temp_f
|
|
215
|
-
* @returns {Calculator}
|
|
216
|
-
*/
|
|
217
|
-
setTemperature(temp_f) {
|
|
218
|
-
const ptr = this.__destroy_into_raw();
|
|
219
|
-
const ret = wasm.calculator_setTemperature(ptr, temp_f);
|
|
220
|
-
return Calculator.__wrap(ret);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* @param {number} height_inches
|
|
224
|
-
* @returns {Calculator}
|
|
225
|
-
*/
|
|
226
|
-
setSightHeight(height_inches) {
|
|
227
|
-
const ptr = this.__destroy_into_raw();
|
|
228
|
-
const ret = wasm.calculator_setSightHeight(ptr, height_inches);
|
|
229
|
-
return Calculator.__wrap(ret);
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* @param {boolean} enabled
|
|
233
|
-
* @param {number | null} [latitude]
|
|
234
|
-
* @returns {Calculator}
|
|
235
|
-
*/
|
|
236
|
-
enableCoriolis(enabled, latitude) {
|
|
237
|
-
const ptr = this.__destroy_into_raw();
|
|
238
|
-
const ret = wasm.calculator_enableCoriolis(ptr, enabled, !isLikeNone(latitude), isLikeNone(latitude) ? 0 : latitude);
|
|
239
|
-
return Calculator.__wrap(ret);
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Get full trajectory table as array of points
|
|
243
|
-
* Returns array of: [{ range_yards, drop_inches, windage_inches, velocity_fps, energy_ftlb, time_sec }, ...]
|
|
244
|
-
* @returns {any}
|
|
245
|
-
*/
|
|
246
|
-
getFullTrajectory() {
|
|
247
|
-
const ret = wasm.calculator_getFullTrajectory(this.__wbg_ptr);
|
|
248
|
-
if (ret[2]) {
|
|
249
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
250
|
-
}
|
|
251
|
-
return takeFromExternrefTable0(ret[0]);
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Calculate trajectory and return result as JavaScript object
|
|
255
|
-
* Returns: { range_yards, drop_inches, windage_inches, velocity_fps, energy_ftlb, time_sec }
|
|
256
|
-
* @param {number} range_yards
|
|
257
|
-
* @returns {any}
|
|
258
|
-
*/
|
|
259
|
-
calculateTrajectory(range_yards) {
|
|
260
|
-
const ret = wasm.calculator_calculateTrajectory(this.__wbg_ptr, range_yards);
|
|
261
|
-
if (ret[2]) {
|
|
262
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
263
|
-
}
|
|
264
|
-
return takeFromExternrefTable0(ret[0]);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* @param {boolean} enabled
|
|
268
|
-
* @param {number | null} [twist_rate]
|
|
269
|
-
* @returns {Calculator}
|
|
270
|
-
*/
|
|
271
|
-
enableSpinDrift(enabled, twist_rate) {
|
|
272
|
-
const ptr = this.__destroy_into_raw();
|
|
273
|
-
const ret = wasm.calculator_enableSpinDrift(ptr, enabled, !isLikeNone(twist_rate), isLikeNone(twist_rate) ? 0 : twist_rate);
|
|
274
|
-
return Calculator.__wrap(ret);
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Create a new calculator with default values
|
|
278
|
-
* Defaults: .308 Winchester 168gr at 2700 fps, standard atmosphere
|
|
279
|
-
*/
|
|
280
|
-
constructor() {
|
|
281
|
-
const ret = wasm.calculator_new();
|
|
282
|
-
this.__wbg_ptr = ret >>> 0;
|
|
283
|
-
CalculatorFinalization.register(this, this.__wbg_ptr, this);
|
|
284
|
-
return this;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* @param {number} bc
|
|
288
|
-
* @returns {Calculator}
|
|
289
|
-
*/
|
|
290
|
-
setBC(bc) {
|
|
291
|
-
const ptr = this.__destroy_into_raw();
|
|
292
|
-
const ret = wasm.calculator_setBC(ptr, bc);
|
|
293
|
-
return Calculator.__wrap(ret);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* @param {number} mass_grains
|
|
297
|
-
* @returns {Calculator}
|
|
298
|
-
*/
|
|
299
|
-
setMass(mass_grains) {
|
|
300
|
-
const ptr = this.__destroy_into_raw();
|
|
301
|
-
const ret = wasm.calculator_setMass(ptr, mass_grains);
|
|
302
|
-
return Calculator.__wrap(ret);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* @param {number} speed_mph
|
|
306
|
-
* @param {number} direction_deg
|
|
307
|
-
* @returns {Calculator}
|
|
308
|
-
*/
|
|
309
|
-
setWind(speed_mph, direction_deg) {
|
|
310
|
-
const ptr = this.__destroy_into_raw();
|
|
311
|
-
const ret = wasm.calculator_setWind(ptr, speed_mph, direction_deg);
|
|
312
|
-
return Calculator.__wrap(ret);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
if (Symbol.dispose) Calculator.prototype[Symbol.dispose] = Calculator.prototype.free;
|
|
316
|
-
|
|
317
|
-
exports.Calculator = Calculator;
|
|
318
|
-
|
|
319
|
-
const WasmBallisticsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
320
|
-
? { register: () => {}, unregister: () => {} }
|
|
321
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_wasmballistics_free(ptr >>> 0, 1));
|
|
322
|
-
|
|
323
|
-
class WasmBallistics {
|
|
324
|
-
|
|
325
|
-
__destroy_into_raw() {
|
|
326
|
-
const ptr = this.__wbg_ptr;
|
|
327
|
-
this.__wbg_ptr = 0;
|
|
328
|
-
WasmBallisticsFinalization.unregister(this);
|
|
329
|
-
return ptr;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
free() {
|
|
333
|
-
const ptr = this.__destroy_into_raw();
|
|
334
|
-
wasm.__wbg_wasmballistics_free(ptr, 0);
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Run a command and return the output
|
|
338
|
-
* @param {string} command
|
|
339
|
-
* @returns {string}
|
|
340
|
-
*/
|
|
341
|
-
runCommand(command) {
|
|
342
|
-
let deferred3_0;
|
|
343
|
-
let deferred3_1;
|
|
344
|
-
try {
|
|
345
|
-
const ptr0 = passStringToWasm0(command, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
346
|
-
const len0 = WASM_VECTOR_LEN;
|
|
347
|
-
const ret = wasm.wasmballistics_runCommand(this.__wbg_ptr, ptr0, len0);
|
|
348
|
-
var ptr2 = ret[0];
|
|
349
|
-
var len2 = ret[1];
|
|
350
|
-
if (ret[3]) {
|
|
351
|
-
ptr2 = 0; len2 = 0;
|
|
352
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
353
|
-
}
|
|
354
|
-
deferred3_0 = ptr2;
|
|
355
|
-
deferred3_1 = len2;
|
|
356
|
-
return getStringFromWasm0(ptr2, len2);
|
|
357
|
-
} finally {
|
|
358
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
constructor() {
|
|
362
|
-
const ret = wasm.wasmballistics_new();
|
|
363
|
-
this.__wbg_ptr = ret >>> 0;
|
|
364
|
-
WasmBallisticsFinalization.register(this, this.__wbg_ptr, this);
|
|
365
|
-
return this;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
if (Symbol.dispose) WasmBallistics.prototype[Symbol.dispose] = WasmBallistics.prototype.free;
|
|
369
|
-
|
|
370
|
-
exports.WasmBallistics = WasmBallistics;
|
|
371
|
-
|
|
372
|
-
exports.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
|
|
373
|
-
const ret = typeof(arg0) === 'function';
|
|
374
|
-
return ret;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
exports.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
|
|
378
|
-
const val = arg0;
|
|
379
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
380
|
-
return ret;
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
exports.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
|
|
384
|
-
const ret = typeof(arg0) === 'string';
|
|
385
|
-
return ret;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
exports.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
|
|
389
|
-
const ret = arg0 === undefined;
|
|
390
|
-
return ret;
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
exports.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
|
|
394
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
exports.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
|
|
398
|
-
const ret = arg0.call(arg1, arg2);
|
|
399
|
-
return ret;
|
|
400
|
-
}, arguments) };
|
|
401
|
-
|
|
402
|
-
exports.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
|
|
403
|
-
const ret = arg0.call(arg1);
|
|
404
|
-
return ret;
|
|
405
|
-
}, arguments) };
|
|
406
|
-
|
|
407
|
-
exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
|
|
408
|
-
const ret = arg0.crypto;
|
|
409
|
-
return ret;
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
|
|
413
|
-
arg0.getRandomValues(arg1);
|
|
414
|
-
}, arguments) };
|
|
415
|
-
|
|
416
|
-
exports.__wbg_length_69bca3cb64fc8748 = function(arg0) {
|
|
417
|
-
const ret = arg0.length;
|
|
418
|
-
return ret;
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
|
|
422
|
-
const ret = arg0.msCrypto;
|
|
423
|
-
return ret;
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
exports.__wbg_new_1acc0b6eea89d040 = function() {
|
|
427
|
-
const ret = new Object();
|
|
428
|
-
return ret;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
exports.__wbg_new_e17d9f43105b08be = function() {
|
|
432
|
-
const ret = new Array();
|
|
433
|
-
return ret;
|
|
434
|
-
};
|
|
435
|
-
|
|
436
|
-
exports.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
|
|
437
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
438
|
-
return ret;
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
exports.__wbg_new_with_length_01aa0dc35aa13543 = function(arg0) {
|
|
442
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
443
|
-
return ret;
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
|
|
447
|
-
const ret = arg0.node;
|
|
448
|
-
return ret;
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
|
|
452
|
-
const ret = arg0.process;
|
|
453
|
-
return ret;
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
exports.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
|
|
457
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
458
|
-
};
|
|
459
|
-
|
|
460
|
-
exports.__wbg_push_df81a39d04db858c = function(arg0, arg1) {
|
|
461
|
-
const ret = arg0.push(arg1);
|
|
462
|
-
return ret;
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
|
|
466
|
-
arg0.randomFillSync(arg1);
|
|
467
|
-
}, arguments) };
|
|
468
|
-
|
|
469
|
-
exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
|
|
470
|
-
const ret = module.require;
|
|
471
|
-
return ret;
|
|
472
|
-
}, arguments) };
|
|
473
|
-
|
|
474
|
-
exports.__wbg_set_c2abbebe8b9ebee1 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
475
|
-
const ret = Reflect.set(arg0, arg1, arg2);
|
|
476
|
-
return ret;
|
|
477
|
-
}, arguments) };
|
|
478
|
-
|
|
479
|
-
exports.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
|
|
480
|
-
const ret = typeof global === 'undefined' ? null : global;
|
|
481
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
exports.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
|
|
485
|
-
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
486
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
exports.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
|
|
490
|
-
const ret = typeof self === 'undefined' ? null : self;
|
|
491
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
exports.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
|
|
495
|
-
const ret = typeof window === 'undefined' ? null : window;
|
|
496
|
-
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
exports.__wbg_subarray_480600f3d6a9f26c = function(arg0, arg1, arg2) {
|
|
500
|
-
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
501
|
-
return ret;
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
|
|
505
|
-
const ret = arg0.versions;
|
|
506
|
-
return ret;
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
510
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
511
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
512
|
-
return ret;
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
exports.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
|
|
516
|
-
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
517
|
-
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
518
|
-
return ret;
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
522
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
523
|
-
const ret = arg0;
|
|
524
|
-
return ret;
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
exports.__wbindgen_init_externref_table = function() {
|
|
528
|
-
const table = wasm.__wbindgen_externrefs;
|
|
529
|
-
const offset = table.grow(4);
|
|
530
|
-
table.set(0, undefined);
|
|
531
|
-
table.set(offset + 0, undefined);
|
|
532
|
-
table.set(offset + 1, null);
|
|
533
|
-
table.set(offset + 2, true);
|
|
534
|
-
table.set(offset + 3, false);
|
|
535
|
-
;
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
const wasmPath = `${__dirname}/ballistics_engine_bg.wasm`;
|
|
539
|
-
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
540
|
-
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
541
|
-
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
542
|
-
|
|
3
|
+
import * as wasm from "./ballistics_engine_bg.wasm";
|
|
4
|
+
import { __wbg_set_wasm } from "./ballistics_engine_bg.js";
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
543
6
|
wasm.__wbindgen_start();
|
|
544
|
-
|
|
7
|
+
export {
|
|
8
|
+
Calculator, WasmBallistics
|
|
9
|
+
} from "./ballistics_engine_bg.js";
|