babylon-box3d 0.4.0 → 0.6.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/README.md CHANGED
@@ -3,28 +3,48 @@
3
3
  [Box3D](https://github.com/erincatto/box3d) physics for Babylon.js. Box3D is Erin Catto's 3D successor to Box2D v3:
4
4
  an MIT licensed rigid body engine with a soft step solver, continuous collision, cross platform determinism and
5
5
  SIMD. This extension ships the engine compiled to WebAssembly plus `Box3DPlugin`, an implementation of Babylon's
6
- physics v2 plugin interface, so it drops in wherever the Havok plugin is used.
6
+ physics v2 plugin interface. It supports most of the Physics V2 API, so scenes written for the Havok plugin generally
7
+ run on it unchanged; [What is covered](#what-is-covered) lists where it differs.
7
8
 
8
9
  ```ts
9
10
  import { Vector3 } from "@babylonjs/core/Maths/math.vector";
11
+ import "@babylonjs/core/Physics/joinedPhysicsEngineComponent"; // adds scene.enablePhysics
10
12
  import { Box3D, Box3DPlugin } from "babylon-box3d";
11
13
 
12
14
  const box3d = await Box3D();
13
15
  scene.enablePhysics(new Vector3(0, -9.81, 0), new Box3DPlugin(true, box3d));
14
16
  ```
15
17
 
16
- Script tags (Playground, plain HTML):
18
+ Script tags (Playground, plain HTML). A complete Playground scene is in
19
+ [the documentation page](docs/communityExtensions/box3dPhysics.md#playground):
17
20
 
18
21
  ```html
19
22
  <script src="https://cdn.babylonjs.com/babylon.js"></script>
20
23
  <script src="https://unpkg.com/babylon-box3d/lib/umd/box3d.umd.js"></script>
21
24
  <script src="https://unpkg.com/babylon-box3d/umd/babylon.box3d.min.js"></script>
22
25
  <script>
23
- const box3d = await Box3D();
24
- scene.enablePhysics(new BABYLON.Vector3(0, -9.81, 0), new BABYLONBOX3D.Box3DPlugin(true, box3d));
26
+ // a classic script cannot use await at the top level, so the setup runs in an async function
27
+ (async () => {
28
+ const box3d = await Box3D();
29
+ scene.enablePhysics(new BABYLON.Vector3(0, -9.81, 0), new BABYLONBOX3D.Box3DPlugin(true, box3d));
30
+ // create physics bodies from here on
31
+ })();
25
32
  </script>
26
33
  ```
27
34
 
35
+ ### Without npm or a build step
36
+
37
+ Like Havok's UMD build, this runs from plain files in a folder. Download these three and put them next to your page:
38
+
39
+ - [box3d.umd.js](https://unpkg.com/babylon-box3d@0.4.0/lib/umd/box3d.umd.js), the WebAssembly loader (global `Box3D`)
40
+ - [box3d.umd.wasm](https://unpkg.com/babylon-box3d@0.4.0/lib/umd/box3d.umd.wasm), the engine, found next to the loader
41
+ - [babylon.box3d.min.js](https://unpkg.com/babylon-box3d@0.4.0/umd/babylon.box3d.min.js), the plugin (global `BABYLONBOX3D`)
42
+
43
+ Then load them after `babylon.js` with the same three script tags as above, pointing at the local files. The folder
44
+ has to be opened through a web server rather than by double clicking the page: browsers refuse to load a `.wasm` from
45
+ `file://`, and Havok's wasm has the same limit. Any static server works, VS Code's Live Server or
46
+ `python -m http.server` in that folder among them; nothing runs on Node.
47
+
28
48
  The wasm is fetched next to the loader script. With a bundler pass `locateFile`, for example with vite:
29
49
 
30
50
  ```ts
@@ -84,6 +104,7 @@ Cross-Origin-Embedder-Policy: require-corp
84
104
 
85
105
  ```ts
86
106
  import { Vector3 } from "@babylonjs/core/Maths/math.vector";
107
+ import "@babylonjs/core/Physics/joinedPhysicsEngineComponent";
87
108
  import { LoadBox3D, Box3DPlugin } from "babylon-box3d";
88
109
 
89
110
  // "auto" uses the threaded build where the page allows it and the single threaded one everywhere else
@@ -99,7 +120,8 @@ it. `CanUseBox3DThreads()` reports whether this page can run them.
99
120
  Everything degrades rather than breaking. On a page that is not isolated, `threads: "auto"` loads the single threaded
100
121
  build, `workerCount` is clamped to 1 and the plugin says so once in the console. `threads: true` throws instead, for
101
122
  an app that would rather find out than quietly run on one thread. Isolation is a hosting decision: a static host that
102
- cannot add response headers (GitHub Pages, for one) can never run them, and the headers also block cross origin
123
+ cannot add response headers (GitHub Pages, for one) needs a service worker to add them, the way the hosted demo does
124
+ (`demo/public/coi-serviceworker.js`), and the headers also block cross origin
103
125
  resources that do not opt in with CORS or `Cross-Origin-Resource-Policy`, which is worth checking before turning them
104
126
  on for a whole site. `npm run demo` sets both headers, so the showcase runs threads with `?workers=4`.
105
127
 
@@ -231,6 +253,17 @@ Box3D extras on the plugin: `explode`, `createWheelJoint` (suspension, steering,
231
253
  `setShapeFilterGroup`, `setShapeRollingResistance`, `setAllowFastRotation`, `getStats`. `PhysicsCharacterController`
232
254
  is not supported yet, it depends on Havok internals.
233
255
 
256
+ **Beyond Babylon's API.** A simulation that drives the module directly, without Babylon, also has these raw exports
257
+ (typed in `lib/*/box3d.d.ts`, tested in `test/wasm.*.test.ts`):
258
+
259
+ | exports | what they do |
260
+ | --- | --- |
261
+ | `bx_Body_GetContacts`, `bx_BodyContactsPtr` | every touching manifold on a body as the body feels it: the shapes on both sides by index, the normal it is pushed along, friction and twist, and per point the position, separation, impulses, approach speed, and the triangle and material met on a mesh or height field |
262
+ | `bx_Body_SetShapeHull`, `bx_Body_TranslateShape`, `bx_Body_SetShapeFilter`, `bx_Body_RemoveShape`, `bx_Body_HasShape`, `bx_Body_GetShapeInfo` | per-shape handles: change one of a body's shapes and reset only its contacts, where `bx_Body_SetShape` rebuilds them all. A shape keeps its index for the body's lifetime, removed or not, and contact events (two floats appended) and ray hits (the last float) carry it |
263
+ | `bx_Body_SetShapeCrush`, `bx_Body_GetShapeCrush` | crushable contacts, see [Patches to Box3D](#patches-to-box3d) |
264
+ | `bx_World_CastShape`, `bx_World_OverlapShape`, `bx_OverlapsPtr` | a convex point cloud with a radius, from an origin given in doubles, cast along a translation or tested for overlap. The cast's fraction is where the surfaces touch: Box3D stops its own casts a linear slop short of that, and the shim moves the fraction on |
265
+ | `bx_Body_GetShapeGeometry`, `bx_GeometryPtr` | a shape's sphere, capsule or hull points, in the body's frame |
266
+
234
267
  Box3D creates shapes on bodies while Babylon creates shapes standalone, so a `PhysicsShape` is a description that
235
268
  is instantiated on every body it is set on. Changing its filter masks, material or density is applied to the live
236
269
  Box3D shapes in place; only geometry, children and the trigger flag rebuild them. Hull data is copied into Box3D's world database, mesh and height field
@@ -248,6 +281,7 @@ and mesh winding is flipped, exactly like the Havok plugin.
248
281
  | `wasm/box3d_shim.c` | C shim: flat, handle based API over box3d (`bx_*` functions) |
249
282
  | `wasm/build.mjs` | emcc build for `lib/esm`, `lib/umd` (global `Box3D`), `lib/node` and the threaded pair |
250
283
  | `lib/` | committed wasm builds and typings, `UPSTREAM_COMMIT` is the box3d commit |
284
+ | `wasm/patches/` | changes to Box3D itself, applied in name order to a copy of the box3d checkout at build time, see [Patches to Box3D](#patches-to-box3d) |
251
285
  | `lib/esm-threads`, `lib/node-threads` | the same module built with pthreads, see [Threads](#threads) |
252
286
  | `umd/` | plugin bundle for script tags (global `BABYLONBOX3D`), built by `npm run build:umd` |
253
287
  | `demo/` | vite showcase: `npm run demo`, then `http://localhost:5178/?demo=pyramid` |
@@ -255,6 +289,10 @@ and mesh winding is flipped, exactly like the Havok plugin.
255
289
  | `test/` | vitest unit tests with a mocked wasm module, tests against the real wasm, node smoke test, and `packaged.test.ts` over the built `dist` and every loader in `lib` |
256
290
  | `bench/` | Box3D vs Havok vs Oimo benchmark: `npm run bench` (node) or `demo/bench.html` (browser), results in `bench/results` |
257
291
 
292
+ The demo is published to GitHub Pages at https://pryme8.github.io/babylon-box3d/ by `.github/workflows/pages.yml`.
293
+ Pages cannot send the isolation headers threads need, so `demo/public/coi-serviceworker.js` adds them from a service
294
+ worker; that is only needed because of the host, and an app that controls its own headers does not want it.
295
+
258
296
  Demos: `pyramid` (Box3D's Large Pyramid benchmark, thin instances, `&rows=100` for 5050 boxes, click to explode),
259
297
  `ragdolls` (Erin's human ragdoll sliding down a chute), `car` (wheel joints, WASD), `destruction` (brick tower and
260
298
  wrecking ball), plus `stack`, `joints`, `terrain`, `compound` feature tests. Add `&ui=0` to hide the overlay.
@@ -319,6 +357,26 @@ threaded one in `lib/esm-threads` and `lib/node-threads`. Add `--no-threads` to
319
357
  shim. Both are wasm SIMD128; the threaded one adds `-pthread` and a pool of 8 workers, which is the cap the shim
320
358
  clamps `workerCount` to. `npm run bench -- --workers 4` runs the benchmark on it.
321
359
 
360
+ ## Patches to Box3D
361
+
362
+ The wasm is built from the box3d commit in `UPSTREAM_COMMIT` plus the patches in `wasm/patches`. `npm run build:wasm`
363
+ copies the checkout's `src` and `include` into `build/box3d-src` and applies the patches there, so the checkout itself
364
+ stays exactly upstream's commit, and a change to the patch set rebuilds every object.
365
+
366
+ | patch | what it changes |
367
+ | --- | --- |
368
+ | `0001-broad-phase-prunes-by-mask.patch` | A shape that moved queries the broad phase with its own mask bits instead of every category (unless it is in a positive group, which overrides masks). A body whose shapes are filtered against each other then skips its own subtree instead of visiting every sibling shape before rejecting it. Which pairs collide does not change. |
369
+ | `0002-continuous-per-body.patch` | `b3Body_EnableContinuous` and `b3Body_IsContinuousEnabled` (shim: `bx_Body_EnableContinuous`, `bx_Body_IsContinuousEnabled`): continuous collision switched for one body. The world's switch still applies. A body made of many small shapes is swept shape by shape whenever its smallest shape moves fast enough, which can cost more than the rest of the step. |
370
+ | `0003-crushable-contacts.patch` | `b3Shape_SetCrushLimit(shape, maxForce, plastic)`, `b3Shape_GetCrushLimit` and `b3Shape_IsCrushPlastic` (shim: `bx_Body_SetShapeCrush(body, i, maxForce, plastic)`, `bx_Body_GetShapeCrush`): each contact of a crushable shape pushes with at most `maxForce` newtons, the smaller of its two shapes' limits, shared between its points, so a body meeting something rigid decelerates over a distance instead of stopping within a step. A plastic contact gets no push-out and no restitution, so it keeps the overlap it reaches. Crushable contacts are routed to the scalar solver path, where each point's accumulated impulse is clamped; a point still apart pushes only for the part of the substep after the surfaces meet. Rigid contacts are untouched, bit for bit. The limit may change every step, and a shape turning crushable or rigid keeps its contacts. |
371
+
372
+ `test/wasm.patches.test.ts` covers 0001 and 0002, and `test/wasm.crush.test.ts` covers 0003. None has been offered upstream.
373
+
374
+ **Crush accuracy.** Against a constant limit the crush depth lands within 1.5% of the continuous answer at 480 Hz
375
+ with two substeps, and within 2% on a height field. What remains is Box3D's, not the patch's: its semi-implicit
376
+ integrator travels v·h/2 less under any constant force, and it makes contact points only within its 2 cm
377
+ speculative distance, so a body that covers more than that in a step (above 9.6 m/s at 480 Hz) can start up to
378
+ v·dt − 2 cm inside. Mesh and height field contacts also carry a 5 mm skin.
379
+
322
380
  ## License
323
381
 
324
382
  MIT. Box3D is MIT licensed by Erin Catto, see `LICENSE-box3d.txt`. The ragdoll data in the demo is ported from
@@ -224,7 +224,7 @@ var Box3DShapeSync;
224
224
  Box3DShapeSync[Box3DShapeSync["DENSITY"] = 4] = "DENSITY";
225
225
  })(Box3DShapeSync || (Box3DShapeSync = {}));
226
226
  const MOVE_STRIDE = 9;
227
- const CONTACT_STRIDE = 12;
227
+ const CONTACT_STRIDE = 14;
228
228
  const SENSOR_STRIDE = 5;
229
229
  const RAY_STRIDE = 11;
230
230
  /**
@@ -94,6 +94,36 @@ export interface Box3DExports {
94
94
  _bx_Body_IsAwake(body: number): number;
95
95
  _bx_Body_EnableSleep(body: number, flag: number): void;
96
96
  _bx_Body_SetBullet(body: number, flag: number): void;
97
+ /** Continuous collision for this body alone, on by default; the world's switch still applies. */
98
+ _bx_Body_EnableContinuous(body: number, flag: number): void;
99
+ _bx_Body_IsContinuousEnabled(body: number): number;
100
+ /**
101
+ * Crushable contacts for the body's shape `index`: each of its contacts pushes with at most `maxForce` newtons,
102
+ * and a plastic one (1) keeps its overlap instead of pushing out. A `maxForce` of zero or less makes it rigid.
103
+ */
104
+ _bx_Body_SetShapeCrush(body: number, index: number, maxForce: number, plastic: number): void;
105
+ /** scratch: [maxForce, plastic] for the body's shape `index`, zeros when it is rigid or there is no such shape. */
106
+ _bx_Body_GetShapeCrush(body: number, index: number): void;
107
+ /**
108
+ * Every touching contact manifold on the body, as the body feels it, written from `_bx_BodyContactsPtr`: 48 floats
109
+ * each, [shapeIndex, otherBody, otherShapeIndex, otherShapeDesc, normal xyz (the push on this body), friction impulse
110
+ * xyz on this body, twist impulse, pointCount], then 4 points of 9: [x, y, z, separation, normalImpulse (last
111
+ * substep), totalNormalImpulse (Box3D's, summed over every solver pass: nonzero means it carried load),
112
+ * normalVelocity, triangleIndex, material]. Returns the record count.
113
+ */
114
+ _bx_Body_GetContacts(body: number): number;
115
+ _bx_BodyContactsPtr(): number;
116
+ /** Per-shape handles: each changes one shape, resets only its contacts, and keeps every shape's index. */
117
+ /** Replaces shape `index` with the hull of `pointCount` points (xyz floats at `points`) in the body's frame; 1 if done. */
118
+ _bx_Body_SetShapeHull(body: number, index: number, points: number, pointCount: number): number;
119
+ /** Moves shape `index` (a hull, sphere or capsule) by (dx, dy, dz) in the body's frame; 1 if done. */
120
+ _bx_Body_TranslateShape(body: number, index: number, dx: number, dy: number, dz: number): number;
121
+ _bx_Body_SetShapeFilter(body: number, index: number, categoryBits: number, maskBits: number, groupIndex: number): void;
122
+ /** Removes shape `index`; the other shapes keep their indices. */
123
+ _bx_Body_RemoveShape(body: number, index: number): void;
124
+ _bx_Body_HasShape(body: number, index: number): number;
125
+ /** scratch: [kind (0 sphere, 1 capsule, 2 hull, -1 none), vertexCount, aabb min xyz, aabb max xyz] in the body's frame */
126
+ _bx_Body_GetShapeInfo(body: number, index: number): void;
97
127
  _bx_Body_AllowFastRotation(body: number, flag: number): void;
98
128
  _bx_Body_SetMotionLocks(body: number, lx: number, ly: number, lz: number, ax: number, ay: number, az: number): void;
99
129
  /** scratch: [minx, miny, minz, maxx, maxy, maxz] */
@@ -148,8 +178,9 @@ export interface Box3DExports {
148
178
  _bx_ShapeDesc_CreateHull(points: number, pointCount: number): number;
149
179
  /** vertices: vertexCount * 3 floats, indices: triangleCount * 3 int32 */
150
180
  _bx_ShapeDesc_CreateMesh(vertices: number, vertexCount: number, indices: number, triangleCount: number, sx: number, sy: number, sz: number, clockwise: number, weld: number): number;
151
- /** heights: countX * countZ floats indexed [z * countX + x], local offset (ox, oy, oz) */
152
- _bx_ShapeDesc_CreateHeightField(heights: number, countX: number, countZ: number, sx: number, sy: number, sz: number, clockwise: number, ox: number, oy: number, oz: number): number;
181
+ /** heights: countX * countZ floats indexed [z * countX + x]; materials: one byte a cell, (countX - 1) * (countZ - 1),
182
+ * or 0 for none; local offset (ox, oy, oz) */
183
+ _bx_ShapeDesc_CreateHeightField(heights: number, materials: number, countX: number, countZ: number, sx: number, sy: number, sz: number, clockwise: number, ox: number, oy: number, oz: number): number;
153
184
  _bx_ShapeDesc_CreateContainer(): number;
154
185
  _bx_ShapeDesc_AddChild(parent: number, child: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number, sx: number, sy: number, sz: number): void;
155
186
  _bx_ShapeDesc_RemoveChild(parent: number, index: number): void;
@@ -209,8 +240,19 @@ export interface Box3DExports {
209
240
 
210
241
  // queries
211
242
  _bx_RayHitsPtr(): number;
212
- /** Returns the hit count; hits are 11 floats each: [px, py, pz, nx, ny, nz, fraction, bodySlot, shapeDesc, triangleIndex, reserved] */
243
+ /** Returns the hit count; hits are 11 floats each: [px, py, pz, nx, ny, nz, fraction, bodySlot, shapeDesc, triangleIndex, shapeIndex] */
213
244
  _bx_World_CastRay(world: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, categoryBits: number, maskBits: number, ignoreBody: number, hitSensors: number, closestOnly: number): number;
245
+ /**
246
+ * Casts the hull of `count` points (xyz floats at `points`, relative to the origin) grown by `radius` along
247
+ * (dx, dy, dz). Hits are written as `_bx_World_CastRay` writes them, the fraction being where the surfaces touch.
248
+ */
249
+ _bx_World_CastShape(world: number, ox: number, oy: number, oz: number, points: number, count: number, radius: number, dx: number, dy: number, dz: number, categoryBits: number, maskBits: number, ignoreBody: number, closestOnly: number): number;
250
+ /** Every shape the hull of the points grown by `radius` overlaps, written from `_bx_OverlapsPtr` as [bodySlot, shapeIndex, shapeDesc]. */
251
+ _bx_World_OverlapShape(world: number, ox: number, oy: number, oz: number, points: number, count: number, radius: number, categoryBits: number, maskBits: number, ignoreBody: number): number;
252
+ _bx_OverlapsPtr(): number;
253
+ /** Shape `index`'s geometry in the body's frame, from `_bx_GeometryPtr`: sphere [c, r], capsule [c1, c2, r], or hull points. Returns the float count. */
254
+ _bx_Body_GetShapeGeometry(body: number, index: number): number;
255
+ _bx_GeometryPtr(): number;
214
256
  }
215
257
 
216
258
  export type Box3DModule = Box3DExports & Box3DHeap;
package/lib/esm/box3d.js CHANGED
@@ -1,2 +1,2 @@
1
- async function Box3D(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var programArgs=[];var thisProgram="./this.program";var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;class EmscriptenEH{}class EmscriptenSjLj extends EmscriptenEH{}var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.resizable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);HEAP64=new BigInt64Array(b)}function preRun(){var preRun=Module["preRun"];if(preRun){if(typeof preRun=="function")preRun=[preRun];onPreRuns.push(...preRun)}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){var postRun=Module["postRun"];if(postRun){if(typeof postRun=="function")postRun=[postRun];onPostRuns.push(...postRun)}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("box3d.wasm")}return new URL("box3d.wasm",import.meta.url).href}function getBinarySync(file){if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={env:wasmImports,wasi_snapshot_preview1:wasmImports};return imports}async function createWasm(){function receiveInstance(instance){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();var instantiateWasm=Module["instantiateWasm"];if(instantiateWasm){return new Promise(resolve=>{instantiateWasm(info,inst=>resolve(receiveInstance(inst)))})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var HEAP8;var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var onPreRuns=[];var noExitRuntime=true;var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);var HEAP64;function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>3]=BigInt(nsec);return 0}var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var HEAPU8;var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var printCharBuffers=[null,[],[]];var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(!curr||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var HEAPU32;var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};var HEAPF32;var HEAP32;{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["arguments"])programArgs=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var preInit=Module["preInit"];if(preInit){if(typeof preInit=="function")Module["preInit"]=preInit=[preInit];while(preInit.length>0){preInit.shift()()}}}var _free,_bx_Scratch,_bx_Alloc,_malloc,_bx_Free,_bx_GetVersion,_bx_GetRejectedSlotCount,_bx_GetMaxWorkers,_bx_CreateWorld,_bx_World_GetWorkerCount,_bx_DestroyWorld,_bx_ShapeDesc_Destroy,_bx_World_Step,_bx_World_SetGravity,_bx_World_SetMaximumLinearSpeed,_bx_World_GetMaximumLinearSpeed,_bx_World_EnableSleeping,_bx_World_EnableContinuous,_bx_World_SetContactTuning,_bx_World_Explode,_bx_World_GetAwakeBodyCount,_bx_World_GetJointEventCount,_bx_World_GetStats,_bx_MoveEventsPtr,_bx_ContactEventsPtr,_bx_SensorEventsPtr,_bx_World_GetMoveEvents,_bx_World_GetContactEvents,_bx_World_GetSensorEvents,_bx_CreateBody,_bx_DestroyBody,_bx_Body_SetType,_bx_Body_GetType,_bx_Body_SetTransform,_bx_Body_GetTransform,_bx_Body_SetTargetTransform,_bx_Body_SetLinearVelocity,_bx_Body_GetLinearVelocity,_bx_Body_SetAngularVelocity,_bx_Body_GetAngularVelocity,_bx_Body_SetLinearDamping,_bx_Body_GetLinearDamping,_bx_Body_SetAngularDamping,_bx_Body_GetAngularDamping,_bx_Body_SetGravityScale,_bx_Body_GetGravityScale,_bx_Body_ApplyForce,_bx_Body_ApplyForceToCenter,_bx_Body_ApplyTorque,_bx_Body_ApplyLinearImpulse,_bx_Body_ApplyLinearImpulseToCenter,_bx_Body_ApplyAngularImpulse,_bx_Body_SetAwake,_bx_Body_IsAwake,_bx_Body_EnableSleep,_bx_Body_SetBullet,_bx_Body_AllowFastRotation,_bx_Body_SetMotionLocks,_bx_Body_GetAABB,_bx_Body_ComputeShapeMassData,_bx_Body_GetMassData,_bx_Body_SetMassDataFull,_bx_Body_SetMassData,_bx_Body_GetMotionLocks,_bx_Body_ApplyMassFromShapes,_bx_Body_GetShapeCount,_bx_Body_SetEventFlags,_bx_Body_GetEventFlags,_bx_Body_EnableContactEvents,_bx_ShapeDesc_CreateSphere,_bx_ShapeDesc_CreateCapsule,_bx_ShapeDesc_CreateBox,_bx_ShapeDesc_CreateCylinder,_bx_ShapeDesc_CreateHull,_bx_ShapeDesc_CreateMesh,_bx_ShapeDesc_CreateHeightField,_bx_ShapeDesc_CreateContainer,_bx_ShapeDesc_AddChild,_bx_ShapeDesc_RemoveChild,_bx_ShapeDesc_GetChildCount,_bx_ShapeDesc_GetKind,_bx_ShapeDesc_SetMaterial,_bx_ShapeDesc_GetFriction,_bx_ShapeDesc_GetRestitution,_bx_ShapeDesc_SetDensity,_bx_ShapeDesc_GetDensity,_bx_ShapeDesc_SetFilter,_bx_ShapeDesc_GetCategoryBits,_bx_ShapeDesc_GetMaskBits,_bx_ShapeDesc_SetGroup,_bx_ShapeDesc_SetRollingResistance,_bx_ShapeDesc_SetSensor,_bx_ShapeDesc_IsSensor,_bx_ShapeDesc_GetAABB,_bx_GetShapeBuildCount,_bx_GetShapeDescCount,_bx_Body_SetShape,_bx_Body_SyncShapeDesc,_bx_Body_GetShapeDesc,_bx_ShapeDesc_BuildDebugGeometry,_bx_DebugPositionsPtr,_bx_DebugIndicesPtr,_bx_DebugIndexCount,_bx_CreateJoint,_bx_DestroyJoint,_bx_Joint_IsValid,_bx_Joint_SetCollideConnected,_bx_Joint_SetConstraintTuning,_bx_Joint_WakeBodies,_bx_Joint_EnableLimit,_bx_Joint_SetLimits,_bx_Joint_SetTwistLimits,_bx_Joint_EnableMotor,_bx_Joint_UpdateMotorFrame,_bx_Joint_SetSphericalMotor,_bx_Joint_SetSphericalTarget,_bx_Joint_SetMotorSpeed,_bx_Joint_SetMaxMotorForce,_bx_Joint_EnableSpring,_bx_Joint_SetSpring,_bx_Joint_SetTarget,_bx_Joint_GetPosition,_bx_ComputeAlignedFrameB,_bx_WheelJoint_SetSpinMotorSpeed,_bx_WheelJoint_SetMaxSpinTorque,_bx_WheelJoint_EnableSpinMotor,_bx_WheelJoint_SetTargetSteeringAngle,_bx_WheelJoint_SetSuspension,_bx_RayHitsPtr,_bx_World_CastRay,memory,__indirect_function_table,wasmMemory;function assignWasmExports(wasmExports){_free=Module["_free"]=wasmExports["free"];_bx_Scratch=Module["_bx_Scratch"]=wasmExports["bx_Scratch"];_bx_Alloc=Module["_bx_Alloc"]=wasmExports["bx_Alloc"];_malloc=Module["_malloc"]=wasmExports["malloc"];_bx_Free=Module["_bx_Free"]=wasmExports["bx_Free"];_bx_GetVersion=Module["_bx_GetVersion"]=wasmExports["bx_GetVersion"];_bx_GetRejectedSlotCount=Module["_bx_GetRejectedSlotCount"]=wasmExports["bx_GetRejectedSlotCount"];_bx_GetMaxWorkers=Module["_bx_GetMaxWorkers"]=wasmExports["bx_GetMaxWorkers"];_bx_CreateWorld=Module["_bx_CreateWorld"]=wasmExports["bx_CreateWorld"];_bx_World_GetWorkerCount=Module["_bx_World_GetWorkerCount"]=wasmExports["bx_World_GetWorkerCount"];_bx_DestroyWorld=Module["_bx_DestroyWorld"]=wasmExports["bx_DestroyWorld"];_bx_ShapeDesc_Destroy=Module["_bx_ShapeDesc_Destroy"]=wasmExports["bx_ShapeDesc_Destroy"];_bx_World_Step=Module["_bx_World_Step"]=wasmExports["bx_World_Step"];_bx_World_SetGravity=Module["_bx_World_SetGravity"]=wasmExports["bx_World_SetGravity"];_bx_World_SetMaximumLinearSpeed=Module["_bx_World_SetMaximumLinearSpeed"]=wasmExports["bx_World_SetMaximumLinearSpeed"];_bx_World_GetMaximumLinearSpeed=Module["_bx_World_GetMaximumLinearSpeed"]=wasmExports["bx_World_GetMaximumLinearSpeed"];_bx_World_EnableSleeping=Module["_bx_World_EnableSleeping"]=wasmExports["bx_World_EnableSleeping"];_bx_World_EnableContinuous=Module["_bx_World_EnableContinuous"]=wasmExports["bx_World_EnableContinuous"];_bx_World_SetContactTuning=Module["_bx_World_SetContactTuning"]=wasmExports["bx_World_SetContactTuning"];_bx_World_Explode=Module["_bx_World_Explode"]=wasmExports["bx_World_Explode"];_bx_World_GetAwakeBodyCount=Module["_bx_World_GetAwakeBodyCount"]=wasmExports["bx_World_GetAwakeBodyCount"];_bx_World_GetJointEventCount=Module["_bx_World_GetJointEventCount"]=wasmExports["bx_World_GetJointEventCount"];_bx_World_GetStats=Module["_bx_World_GetStats"]=wasmExports["bx_World_GetStats"];_bx_MoveEventsPtr=Module["_bx_MoveEventsPtr"]=wasmExports["bx_MoveEventsPtr"];_bx_ContactEventsPtr=Module["_bx_ContactEventsPtr"]=wasmExports["bx_ContactEventsPtr"];_bx_SensorEventsPtr=Module["_bx_SensorEventsPtr"]=wasmExports["bx_SensorEventsPtr"];_bx_World_GetMoveEvents=Module["_bx_World_GetMoveEvents"]=wasmExports["bx_World_GetMoveEvents"];_bx_World_GetContactEvents=Module["_bx_World_GetContactEvents"]=wasmExports["bx_World_GetContactEvents"];_bx_World_GetSensorEvents=Module["_bx_World_GetSensorEvents"]=wasmExports["bx_World_GetSensorEvents"];_bx_CreateBody=Module["_bx_CreateBody"]=wasmExports["bx_CreateBody"];_bx_DestroyBody=Module["_bx_DestroyBody"]=wasmExports["bx_DestroyBody"];_bx_Body_SetType=Module["_bx_Body_SetType"]=wasmExports["bx_Body_SetType"];_bx_Body_GetType=Module["_bx_Body_GetType"]=wasmExports["bx_Body_GetType"];_bx_Body_SetTransform=Module["_bx_Body_SetTransform"]=wasmExports["bx_Body_SetTransform"];_bx_Body_GetTransform=Module["_bx_Body_GetTransform"]=wasmExports["bx_Body_GetTransform"];_bx_Body_SetTargetTransform=Module["_bx_Body_SetTargetTransform"]=wasmExports["bx_Body_SetTargetTransform"];_bx_Body_SetLinearVelocity=Module["_bx_Body_SetLinearVelocity"]=wasmExports["bx_Body_SetLinearVelocity"];_bx_Body_GetLinearVelocity=Module["_bx_Body_GetLinearVelocity"]=wasmExports["bx_Body_GetLinearVelocity"];_bx_Body_SetAngularVelocity=Module["_bx_Body_SetAngularVelocity"]=wasmExports["bx_Body_SetAngularVelocity"];_bx_Body_GetAngularVelocity=Module["_bx_Body_GetAngularVelocity"]=wasmExports["bx_Body_GetAngularVelocity"];_bx_Body_SetLinearDamping=Module["_bx_Body_SetLinearDamping"]=wasmExports["bx_Body_SetLinearDamping"];_bx_Body_GetLinearDamping=Module["_bx_Body_GetLinearDamping"]=wasmExports["bx_Body_GetLinearDamping"];_bx_Body_SetAngularDamping=Module["_bx_Body_SetAngularDamping"]=wasmExports["bx_Body_SetAngularDamping"];_bx_Body_GetAngularDamping=Module["_bx_Body_GetAngularDamping"]=wasmExports["bx_Body_GetAngularDamping"];_bx_Body_SetGravityScale=Module["_bx_Body_SetGravityScale"]=wasmExports["bx_Body_SetGravityScale"];_bx_Body_GetGravityScale=Module["_bx_Body_GetGravityScale"]=wasmExports["bx_Body_GetGravityScale"];_bx_Body_ApplyForce=Module["_bx_Body_ApplyForce"]=wasmExports["bx_Body_ApplyForce"];_bx_Body_ApplyForceToCenter=Module["_bx_Body_ApplyForceToCenter"]=wasmExports["bx_Body_ApplyForceToCenter"];_bx_Body_ApplyTorque=Module["_bx_Body_ApplyTorque"]=wasmExports["bx_Body_ApplyTorque"];_bx_Body_ApplyLinearImpulse=Module["_bx_Body_ApplyLinearImpulse"]=wasmExports["bx_Body_ApplyLinearImpulse"];_bx_Body_ApplyLinearImpulseToCenter=Module["_bx_Body_ApplyLinearImpulseToCenter"]=wasmExports["bx_Body_ApplyLinearImpulseToCenter"];_bx_Body_ApplyAngularImpulse=Module["_bx_Body_ApplyAngularImpulse"]=wasmExports["bx_Body_ApplyAngularImpulse"];_bx_Body_SetAwake=Module["_bx_Body_SetAwake"]=wasmExports["bx_Body_SetAwake"];_bx_Body_IsAwake=Module["_bx_Body_IsAwake"]=wasmExports["bx_Body_IsAwake"];_bx_Body_EnableSleep=Module["_bx_Body_EnableSleep"]=wasmExports["bx_Body_EnableSleep"];_bx_Body_SetBullet=Module["_bx_Body_SetBullet"]=wasmExports["bx_Body_SetBullet"];_bx_Body_AllowFastRotation=Module["_bx_Body_AllowFastRotation"]=wasmExports["bx_Body_AllowFastRotation"];_bx_Body_SetMotionLocks=Module["_bx_Body_SetMotionLocks"]=wasmExports["bx_Body_SetMotionLocks"];_bx_Body_GetAABB=Module["_bx_Body_GetAABB"]=wasmExports["bx_Body_GetAABB"];_bx_Body_ComputeShapeMassData=Module["_bx_Body_ComputeShapeMassData"]=wasmExports["bx_Body_ComputeShapeMassData"];_bx_Body_GetMassData=Module["_bx_Body_GetMassData"]=wasmExports["bx_Body_GetMassData"];_bx_Body_SetMassDataFull=Module["_bx_Body_SetMassDataFull"]=wasmExports["bx_Body_SetMassDataFull"];_bx_Body_SetMassData=Module["_bx_Body_SetMassData"]=wasmExports["bx_Body_SetMassData"];_bx_Body_GetMotionLocks=Module["_bx_Body_GetMotionLocks"]=wasmExports["bx_Body_GetMotionLocks"];_bx_Body_ApplyMassFromShapes=Module["_bx_Body_ApplyMassFromShapes"]=wasmExports["bx_Body_ApplyMassFromShapes"];_bx_Body_GetShapeCount=Module["_bx_Body_GetShapeCount"]=wasmExports["bx_Body_GetShapeCount"];_bx_Body_SetEventFlags=Module["_bx_Body_SetEventFlags"]=wasmExports["bx_Body_SetEventFlags"];_bx_Body_GetEventFlags=Module["_bx_Body_GetEventFlags"]=wasmExports["bx_Body_GetEventFlags"];_bx_Body_EnableContactEvents=Module["_bx_Body_EnableContactEvents"]=wasmExports["bx_Body_EnableContactEvents"];_bx_ShapeDesc_CreateSphere=Module["_bx_ShapeDesc_CreateSphere"]=wasmExports["bx_ShapeDesc_CreateSphere"];_bx_ShapeDesc_CreateCapsule=Module["_bx_ShapeDesc_CreateCapsule"]=wasmExports["bx_ShapeDesc_CreateCapsule"];_bx_ShapeDesc_CreateBox=Module["_bx_ShapeDesc_CreateBox"]=wasmExports["bx_ShapeDesc_CreateBox"];_bx_ShapeDesc_CreateCylinder=Module["_bx_ShapeDesc_CreateCylinder"]=wasmExports["bx_ShapeDesc_CreateCylinder"];_bx_ShapeDesc_CreateHull=Module["_bx_ShapeDesc_CreateHull"]=wasmExports["bx_ShapeDesc_CreateHull"];_bx_ShapeDesc_CreateMesh=Module["_bx_ShapeDesc_CreateMesh"]=wasmExports["bx_ShapeDesc_CreateMesh"];_bx_ShapeDesc_CreateHeightField=Module["_bx_ShapeDesc_CreateHeightField"]=wasmExports["bx_ShapeDesc_CreateHeightField"];_bx_ShapeDesc_CreateContainer=Module["_bx_ShapeDesc_CreateContainer"]=wasmExports["bx_ShapeDesc_CreateContainer"];_bx_ShapeDesc_AddChild=Module["_bx_ShapeDesc_AddChild"]=wasmExports["bx_ShapeDesc_AddChild"];_bx_ShapeDesc_RemoveChild=Module["_bx_ShapeDesc_RemoveChild"]=wasmExports["bx_ShapeDesc_RemoveChild"];_bx_ShapeDesc_GetChildCount=Module["_bx_ShapeDesc_GetChildCount"]=wasmExports["bx_ShapeDesc_GetChildCount"];_bx_ShapeDesc_GetKind=Module["_bx_ShapeDesc_GetKind"]=wasmExports["bx_ShapeDesc_GetKind"];_bx_ShapeDesc_SetMaterial=Module["_bx_ShapeDesc_SetMaterial"]=wasmExports["bx_ShapeDesc_SetMaterial"];_bx_ShapeDesc_GetFriction=Module["_bx_ShapeDesc_GetFriction"]=wasmExports["bx_ShapeDesc_GetFriction"];_bx_ShapeDesc_GetRestitution=Module["_bx_ShapeDesc_GetRestitution"]=wasmExports["bx_ShapeDesc_GetRestitution"];_bx_ShapeDesc_SetDensity=Module["_bx_ShapeDesc_SetDensity"]=wasmExports["bx_ShapeDesc_SetDensity"];_bx_ShapeDesc_GetDensity=Module["_bx_ShapeDesc_GetDensity"]=wasmExports["bx_ShapeDesc_GetDensity"];_bx_ShapeDesc_SetFilter=Module["_bx_ShapeDesc_SetFilter"]=wasmExports["bx_ShapeDesc_SetFilter"];_bx_ShapeDesc_GetCategoryBits=Module["_bx_ShapeDesc_GetCategoryBits"]=wasmExports["bx_ShapeDesc_GetCategoryBits"];_bx_ShapeDesc_GetMaskBits=Module["_bx_ShapeDesc_GetMaskBits"]=wasmExports["bx_ShapeDesc_GetMaskBits"];_bx_ShapeDesc_SetGroup=Module["_bx_ShapeDesc_SetGroup"]=wasmExports["bx_ShapeDesc_SetGroup"];_bx_ShapeDesc_SetRollingResistance=Module["_bx_ShapeDesc_SetRollingResistance"]=wasmExports["bx_ShapeDesc_SetRollingResistance"];_bx_ShapeDesc_SetSensor=Module["_bx_ShapeDesc_SetSensor"]=wasmExports["bx_ShapeDesc_SetSensor"];_bx_ShapeDesc_IsSensor=Module["_bx_ShapeDesc_IsSensor"]=wasmExports["bx_ShapeDesc_IsSensor"];_bx_ShapeDesc_GetAABB=Module["_bx_ShapeDesc_GetAABB"]=wasmExports["bx_ShapeDesc_GetAABB"];_bx_GetShapeBuildCount=Module["_bx_GetShapeBuildCount"]=wasmExports["bx_GetShapeBuildCount"];_bx_GetShapeDescCount=Module["_bx_GetShapeDescCount"]=wasmExports["bx_GetShapeDescCount"];_bx_Body_SetShape=Module["_bx_Body_SetShape"]=wasmExports["bx_Body_SetShape"];_bx_Body_SyncShapeDesc=Module["_bx_Body_SyncShapeDesc"]=wasmExports["bx_Body_SyncShapeDesc"];_bx_Body_GetShapeDesc=Module["_bx_Body_GetShapeDesc"]=wasmExports["bx_Body_GetShapeDesc"];_bx_ShapeDesc_BuildDebugGeometry=Module["_bx_ShapeDesc_BuildDebugGeometry"]=wasmExports["bx_ShapeDesc_BuildDebugGeometry"];_bx_DebugPositionsPtr=Module["_bx_DebugPositionsPtr"]=wasmExports["bx_DebugPositionsPtr"];_bx_DebugIndicesPtr=Module["_bx_DebugIndicesPtr"]=wasmExports["bx_DebugIndicesPtr"];_bx_DebugIndexCount=Module["_bx_DebugIndexCount"]=wasmExports["bx_DebugIndexCount"];_bx_CreateJoint=Module["_bx_CreateJoint"]=wasmExports["bx_CreateJoint"];_bx_DestroyJoint=Module["_bx_DestroyJoint"]=wasmExports["bx_DestroyJoint"];_bx_Joint_IsValid=Module["_bx_Joint_IsValid"]=wasmExports["bx_Joint_IsValid"];_bx_Joint_SetCollideConnected=Module["_bx_Joint_SetCollideConnected"]=wasmExports["bx_Joint_SetCollideConnected"];_bx_Joint_SetConstraintTuning=Module["_bx_Joint_SetConstraintTuning"]=wasmExports["bx_Joint_SetConstraintTuning"];_bx_Joint_WakeBodies=Module["_bx_Joint_WakeBodies"]=wasmExports["bx_Joint_WakeBodies"];_bx_Joint_EnableLimit=Module["_bx_Joint_EnableLimit"]=wasmExports["bx_Joint_EnableLimit"];_bx_Joint_SetLimits=Module["_bx_Joint_SetLimits"]=wasmExports["bx_Joint_SetLimits"];_bx_Joint_SetTwistLimits=Module["_bx_Joint_SetTwistLimits"]=wasmExports["bx_Joint_SetTwistLimits"];_bx_Joint_EnableMotor=Module["_bx_Joint_EnableMotor"]=wasmExports["bx_Joint_EnableMotor"];_bx_Joint_UpdateMotorFrame=Module["_bx_Joint_UpdateMotorFrame"]=wasmExports["bx_Joint_UpdateMotorFrame"];_bx_Joint_SetSphericalMotor=Module["_bx_Joint_SetSphericalMotor"]=wasmExports["bx_Joint_SetSphericalMotor"];_bx_Joint_SetSphericalTarget=Module["_bx_Joint_SetSphericalTarget"]=wasmExports["bx_Joint_SetSphericalTarget"];_bx_Joint_SetMotorSpeed=Module["_bx_Joint_SetMotorSpeed"]=wasmExports["bx_Joint_SetMotorSpeed"];_bx_Joint_SetMaxMotorForce=Module["_bx_Joint_SetMaxMotorForce"]=wasmExports["bx_Joint_SetMaxMotorForce"];_bx_Joint_EnableSpring=Module["_bx_Joint_EnableSpring"]=wasmExports["bx_Joint_EnableSpring"];_bx_Joint_SetSpring=Module["_bx_Joint_SetSpring"]=wasmExports["bx_Joint_SetSpring"];_bx_Joint_SetTarget=Module["_bx_Joint_SetTarget"]=wasmExports["bx_Joint_SetTarget"];_bx_Joint_GetPosition=Module["_bx_Joint_GetPosition"]=wasmExports["bx_Joint_GetPosition"];_bx_ComputeAlignedFrameB=Module["_bx_ComputeAlignedFrameB"]=wasmExports["bx_ComputeAlignedFrameB"];_bx_WheelJoint_SetSpinMotorSpeed=Module["_bx_WheelJoint_SetSpinMotorSpeed"]=wasmExports["bx_WheelJoint_SetSpinMotorSpeed"];_bx_WheelJoint_SetMaxSpinTorque=Module["_bx_WheelJoint_SetMaxSpinTorque"]=wasmExports["bx_WheelJoint_SetMaxSpinTorque"];_bx_WheelJoint_EnableSpinMotor=Module["_bx_WheelJoint_EnableSpinMotor"]=wasmExports["bx_WheelJoint_EnableSpinMotor"];_bx_WheelJoint_SetTargetSteeringAngle=Module["_bx_WheelJoint_SetTargetSteeringAngle"]=wasmExports["bx_WheelJoint_SetTargetSteeringAngle"];_bx_WheelJoint_SetSuspension=Module["_bx_WheelJoint_SetSuspension"]=wasmExports["bx_WheelJoint_SetSuspension"];_bx_RayHitsPtr=Module["_bx_RayHitsPtr"]=wasmExports["bx_RayHitsPtr"];_bx_World_CastRay=Module["_bx_World_CastRay"]=wasmExports["bx_World_CastRay"];memory=wasmMemory=wasmExports["memory"];__indirect_function_table=wasmExports["__indirect_function_table"]}var wasmImports={clock_time_get:_clock_time_get,emscripten_get_now:_emscripten_get_now,emscripten_resize_heap:_emscripten_resize_heap,fd_write:_fd_write};async function run(){preRun();var setStatus=Module["setStatus"];if(setStatus){setStatus("Running...");await new Promise(resolve=>setTimeout(resolve,1));setTimeout(setStatus,1,"")}if(ABORT)return;initRuntime();Module["onRuntimeInitialized"]?.();postRun()}var wasmExports;wasmExports=await createWasm();await run();
1
+ async function Box3D(moduleArg={}){var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var programArgs=[];var thisProgram="./this.program";var _scriptName=import.meta.url;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;class EmscriptenEH{}class EmscriptenSjLj extends EmscriptenEH{}var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.resizable)return;var b=getMemoryBuffer();HEAP8=new Int8Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);HEAP64=new BigInt64Array(b)}function preRun(){var preRun=Module["preRun"];if(preRun){if(typeof preRun=="function")preRun=[preRun];onPreRuns.push(...preRun)}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["__wasm_call_ctors"]()}function postRun(){var postRun=Module["postRun"];if(postRun){if(typeof postRun=="function")postRun=[postRun];onPostRuns.push(...postRun)}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what=`Aborted(${what})`;err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);throw e}var wasmBinaryFile;function findWasmBinary(){if(Module["locateFile"]){return locateFile("box3d.wasm")}return new URL("box3d.wasm",import.meta.url).href}function getBinarySync(file){if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={env:wasmImports,wasi_snapshot_preview1:wasmImports};return imports}async function createWasm(){function receiveInstance(instance){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();var instantiateWasm=Module["instantiateWasm"];if(instantiateWasm){return new Promise(resolve=>{instantiateWasm(info,inst=>resolve(receiveInstance(inst)))})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var HEAP8;var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var onPreRuns=[];var noExitRuntime=true;var _emscripten_get_now=()=>performance.now();var _emscripten_date_now=()=>Date.now();var nowIsMonotonic=1;var checkWasiClock=clock_id=>clock_id>=0&&clock_id<=3;var INT53_MAX=9007199254740992;var INT53_MIN=-9007199254740992;var bigintToI53Checked=num=>num<INT53_MIN||num>INT53_MAX?NaN:Number(num);var HEAP64;function _clock_time_get(clk_id,ignored_precision,ptime){ignored_precision=bigintToI53Checked(ignored_precision);if(!checkWasiClock(clk_id)){return 28}var now;if(clk_id===0){now=_emscripten_date_now()}else if(nowIsMonotonic){now=_emscripten_get_now()}else{return 52}var nsec=Math.round(now*1e3*1e3);HEAP64[ptime>>3]=BigInt(nsec);return 0}var getHeapMax=()=>2147483648;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var HEAPU8;var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var printCharBuffers=[null,[],[]];var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(!curr||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var HEAPU32;var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};var HEAPF32;var HEAP32;{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["arguments"])programArgs=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];var preInit=Module["preInit"];if(preInit){if(typeof preInit=="function")Module["preInit"]=preInit=[preInit];while(preInit.length>0){preInit.shift()()}}}var _free,_bx_Scratch,_bx_Alloc,_malloc,_bx_Free,_bx_GetVersion,_bx_GetRejectedSlotCount,_bx_GetMaxWorkers,_bx_CreateWorld,_bx_World_GetWorkerCount,_bx_DestroyWorld,_bx_ShapeDesc_Destroy,_bx_World_Step,_bx_World_SetGravity,_bx_World_SetMaximumLinearSpeed,_bx_World_GetMaximumLinearSpeed,_bx_World_EnableSleeping,_bx_World_EnableContinuous,_bx_World_SetContactTuning,_bx_World_Explode,_bx_World_GetAwakeBodyCount,_bx_World_GetJointEventCount,_bx_World_GetStats,_bx_MoveEventsPtr,_bx_ContactEventsPtr,_bx_SensorEventsPtr,_bx_World_GetMoveEvents,_bx_World_GetContactEvents,_bx_World_GetSensorEvents,_bx_CreateBody,_bx_DestroyBody,_bx_Body_SetType,_bx_Body_GetType,_bx_Body_SetTransform,_bx_Body_GetTransform,_bx_Body_SetTargetTransform,_bx_Body_SetLinearVelocity,_bx_Body_GetLinearVelocity,_bx_Body_SetAngularVelocity,_bx_Body_GetAngularVelocity,_bx_Body_SetLinearDamping,_bx_Body_GetLinearDamping,_bx_Body_SetAngularDamping,_bx_Body_GetAngularDamping,_bx_Body_SetGravityScale,_bx_Body_GetGravityScale,_bx_Body_ApplyForce,_bx_Body_ApplyForceToCenter,_bx_Body_ApplyTorque,_bx_Body_ApplyLinearImpulse,_bx_Body_ApplyLinearImpulseToCenter,_bx_Body_ApplyAngularImpulse,_bx_Body_SetAwake,_bx_Body_IsAwake,_bx_Body_EnableSleep,_bx_Body_SetBullet,_bx_Body_EnableContinuous,_bx_Body_IsContinuousEnabled,_bx_Body_SetShapeCrush,_bx_Body_GetShapeCrush,_bx_BodyContactsPtr,_bx_Body_GetContacts,_bx_Body_AllowFastRotation,_bx_Body_SetMotionLocks,_bx_Body_GetAABB,_bx_Body_ComputeShapeMassData,_bx_Body_GetMassData,_bx_Body_SetMassDataFull,_bx_Body_SetMassData,_bx_Body_GetMotionLocks,_bx_Body_ApplyMassFromShapes,_bx_Body_GetShapeCount,_bx_Body_SetEventFlags,_bx_Body_GetEventFlags,_bx_Body_EnableContactEvents,_bx_ShapeDesc_CreateSphere,_bx_ShapeDesc_CreateCapsule,_bx_ShapeDesc_CreateBox,_bx_ShapeDesc_CreateCylinder,_bx_ShapeDesc_CreateHull,_bx_ShapeDesc_CreateMesh,_bx_ShapeDesc_CreateHeightField,_bx_ShapeDesc_CreateContainer,_bx_ShapeDesc_AddChild,_bx_ShapeDesc_RemoveChild,_bx_ShapeDesc_GetChildCount,_bx_ShapeDesc_GetKind,_bx_ShapeDesc_SetMaterial,_bx_ShapeDesc_GetFriction,_bx_ShapeDesc_GetRestitution,_bx_ShapeDesc_SetDensity,_bx_ShapeDesc_GetDensity,_bx_ShapeDesc_SetFilter,_bx_ShapeDesc_GetCategoryBits,_bx_ShapeDesc_GetMaskBits,_bx_ShapeDesc_SetGroup,_bx_ShapeDesc_SetRollingResistance,_bx_ShapeDesc_SetSensor,_bx_ShapeDesc_IsSensor,_bx_ShapeDesc_GetAABB,_bx_GetShapeBuildCount,_bx_GetShapeDescCount,_bx_Body_SetShape,_bx_Body_SetShapeHull,_bx_Body_TranslateShape,_bx_Body_SetShapeFilter,_bx_Body_RemoveShape,_bx_Body_HasShape,_bx_Body_GetShapeInfo,_bx_Body_SyncShapeDesc,_bx_Body_GetShapeDesc,_bx_ShapeDesc_BuildDebugGeometry,_bx_DebugPositionsPtr,_bx_DebugIndicesPtr,_bx_DebugIndexCount,_bx_CreateJoint,_bx_DestroyJoint,_bx_Joint_IsValid,_bx_Joint_SetCollideConnected,_bx_Joint_SetConstraintTuning,_bx_Joint_WakeBodies,_bx_Joint_EnableLimit,_bx_Joint_SetLimits,_bx_Joint_SetTwistLimits,_bx_Joint_EnableMotor,_bx_Joint_UpdateMotorFrame,_bx_Joint_SetSphericalMotor,_bx_Joint_SetSphericalTarget,_bx_Joint_SetMotorSpeed,_bx_Joint_SetMaxMotorForce,_bx_Joint_EnableSpring,_bx_Joint_SetSpring,_bx_Joint_SetTarget,_bx_Joint_GetPosition,_bx_ComputeAlignedFrameB,_bx_WheelJoint_SetSpinMotorSpeed,_bx_WheelJoint_SetMaxSpinTorque,_bx_WheelJoint_EnableSpinMotor,_bx_WheelJoint_SetTargetSteeringAngle,_bx_WheelJoint_SetSuspension,_bx_RayHitsPtr,_bx_World_CastRay,_bx_World_CastShape,_bx_OverlapsPtr,_bx_World_OverlapShape,_bx_GeometryPtr,_bx_Body_GetShapeGeometry,memory,__indirect_function_table,wasmMemory;function assignWasmExports(wasmExports){_free=Module["_free"]=wasmExports["free"];_bx_Scratch=Module["_bx_Scratch"]=wasmExports["bx_Scratch"];_bx_Alloc=Module["_bx_Alloc"]=wasmExports["bx_Alloc"];_malloc=Module["_malloc"]=wasmExports["malloc"];_bx_Free=Module["_bx_Free"]=wasmExports["bx_Free"];_bx_GetVersion=Module["_bx_GetVersion"]=wasmExports["bx_GetVersion"];_bx_GetRejectedSlotCount=Module["_bx_GetRejectedSlotCount"]=wasmExports["bx_GetRejectedSlotCount"];_bx_GetMaxWorkers=Module["_bx_GetMaxWorkers"]=wasmExports["bx_GetMaxWorkers"];_bx_CreateWorld=Module["_bx_CreateWorld"]=wasmExports["bx_CreateWorld"];_bx_World_GetWorkerCount=Module["_bx_World_GetWorkerCount"]=wasmExports["bx_World_GetWorkerCount"];_bx_DestroyWorld=Module["_bx_DestroyWorld"]=wasmExports["bx_DestroyWorld"];_bx_ShapeDesc_Destroy=Module["_bx_ShapeDesc_Destroy"]=wasmExports["bx_ShapeDesc_Destroy"];_bx_World_Step=Module["_bx_World_Step"]=wasmExports["bx_World_Step"];_bx_World_SetGravity=Module["_bx_World_SetGravity"]=wasmExports["bx_World_SetGravity"];_bx_World_SetMaximumLinearSpeed=Module["_bx_World_SetMaximumLinearSpeed"]=wasmExports["bx_World_SetMaximumLinearSpeed"];_bx_World_GetMaximumLinearSpeed=Module["_bx_World_GetMaximumLinearSpeed"]=wasmExports["bx_World_GetMaximumLinearSpeed"];_bx_World_EnableSleeping=Module["_bx_World_EnableSleeping"]=wasmExports["bx_World_EnableSleeping"];_bx_World_EnableContinuous=Module["_bx_World_EnableContinuous"]=wasmExports["bx_World_EnableContinuous"];_bx_World_SetContactTuning=Module["_bx_World_SetContactTuning"]=wasmExports["bx_World_SetContactTuning"];_bx_World_Explode=Module["_bx_World_Explode"]=wasmExports["bx_World_Explode"];_bx_World_GetAwakeBodyCount=Module["_bx_World_GetAwakeBodyCount"]=wasmExports["bx_World_GetAwakeBodyCount"];_bx_World_GetJointEventCount=Module["_bx_World_GetJointEventCount"]=wasmExports["bx_World_GetJointEventCount"];_bx_World_GetStats=Module["_bx_World_GetStats"]=wasmExports["bx_World_GetStats"];_bx_MoveEventsPtr=Module["_bx_MoveEventsPtr"]=wasmExports["bx_MoveEventsPtr"];_bx_ContactEventsPtr=Module["_bx_ContactEventsPtr"]=wasmExports["bx_ContactEventsPtr"];_bx_SensorEventsPtr=Module["_bx_SensorEventsPtr"]=wasmExports["bx_SensorEventsPtr"];_bx_World_GetMoveEvents=Module["_bx_World_GetMoveEvents"]=wasmExports["bx_World_GetMoveEvents"];_bx_World_GetContactEvents=Module["_bx_World_GetContactEvents"]=wasmExports["bx_World_GetContactEvents"];_bx_World_GetSensorEvents=Module["_bx_World_GetSensorEvents"]=wasmExports["bx_World_GetSensorEvents"];_bx_CreateBody=Module["_bx_CreateBody"]=wasmExports["bx_CreateBody"];_bx_DestroyBody=Module["_bx_DestroyBody"]=wasmExports["bx_DestroyBody"];_bx_Body_SetType=Module["_bx_Body_SetType"]=wasmExports["bx_Body_SetType"];_bx_Body_GetType=Module["_bx_Body_GetType"]=wasmExports["bx_Body_GetType"];_bx_Body_SetTransform=Module["_bx_Body_SetTransform"]=wasmExports["bx_Body_SetTransform"];_bx_Body_GetTransform=Module["_bx_Body_GetTransform"]=wasmExports["bx_Body_GetTransform"];_bx_Body_SetTargetTransform=Module["_bx_Body_SetTargetTransform"]=wasmExports["bx_Body_SetTargetTransform"];_bx_Body_SetLinearVelocity=Module["_bx_Body_SetLinearVelocity"]=wasmExports["bx_Body_SetLinearVelocity"];_bx_Body_GetLinearVelocity=Module["_bx_Body_GetLinearVelocity"]=wasmExports["bx_Body_GetLinearVelocity"];_bx_Body_SetAngularVelocity=Module["_bx_Body_SetAngularVelocity"]=wasmExports["bx_Body_SetAngularVelocity"];_bx_Body_GetAngularVelocity=Module["_bx_Body_GetAngularVelocity"]=wasmExports["bx_Body_GetAngularVelocity"];_bx_Body_SetLinearDamping=Module["_bx_Body_SetLinearDamping"]=wasmExports["bx_Body_SetLinearDamping"];_bx_Body_GetLinearDamping=Module["_bx_Body_GetLinearDamping"]=wasmExports["bx_Body_GetLinearDamping"];_bx_Body_SetAngularDamping=Module["_bx_Body_SetAngularDamping"]=wasmExports["bx_Body_SetAngularDamping"];_bx_Body_GetAngularDamping=Module["_bx_Body_GetAngularDamping"]=wasmExports["bx_Body_GetAngularDamping"];_bx_Body_SetGravityScale=Module["_bx_Body_SetGravityScale"]=wasmExports["bx_Body_SetGravityScale"];_bx_Body_GetGravityScale=Module["_bx_Body_GetGravityScale"]=wasmExports["bx_Body_GetGravityScale"];_bx_Body_ApplyForce=Module["_bx_Body_ApplyForce"]=wasmExports["bx_Body_ApplyForce"];_bx_Body_ApplyForceToCenter=Module["_bx_Body_ApplyForceToCenter"]=wasmExports["bx_Body_ApplyForceToCenter"];_bx_Body_ApplyTorque=Module["_bx_Body_ApplyTorque"]=wasmExports["bx_Body_ApplyTorque"];_bx_Body_ApplyLinearImpulse=Module["_bx_Body_ApplyLinearImpulse"]=wasmExports["bx_Body_ApplyLinearImpulse"];_bx_Body_ApplyLinearImpulseToCenter=Module["_bx_Body_ApplyLinearImpulseToCenter"]=wasmExports["bx_Body_ApplyLinearImpulseToCenter"];_bx_Body_ApplyAngularImpulse=Module["_bx_Body_ApplyAngularImpulse"]=wasmExports["bx_Body_ApplyAngularImpulse"];_bx_Body_SetAwake=Module["_bx_Body_SetAwake"]=wasmExports["bx_Body_SetAwake"];_bx_Body_IsAwake=Module["_bx_Body_IsAwake"]=wasmExports["bx_Body_IsAwake"];_bx_Body_EnableSleep=Module["_bx_Body_EnableSleep"]=wasmExports["bx_Body_EnableSleep"];_bx_Body_SetBullet=Module["_bx_Body_SetBullet"]=wasmExports["bx_Body_SetBullet"];_bx_Body_EnableContinuous=Module["_bx_Body_EnableContinuous"]=wasmExports["bx_Body_EnableContinuous"];_bx_Body_IsContinuousEnabled=Module["_bx_Body_IsContinuousEnabled"]=wasmExports["bx_Body_IsContinuousEnabled"];_bx_Body_SetShapeCrush=Module["_bx_Body_SetShapeCrush"]=wasmExports["bx_Body_SetShapeCrush"];_bx_Body_GetShapeCrush=Module["_bx_Body_GetShapeCrush"]=wasmExports["bx_Body_GetShapeCrush"];_bx_BodyContactsPtr=Module["_bx_BodyContactsPtr"]=wasmExports["bx_BodyContactsPtr"];_bx_Body_GetContacts=Module["_bx_Body_GetContacts"]=wasmExports["bx_Body_GetContacts"];_bx_Body_AllowFastRotation=Module["_bx_Body_AllowFastRotation"]=wasmExports["bx_Body_AllowFastRotation"];_bx_Body_SetMotionLocks=Module["_bx_Body_SetMotionLocks"]=wasmExports["bx_Body_SetMotionLocks"];_bx_Body_GetAABB=Module["_bx_Body_GetAABB"]=wasmExports["bx_Body_GetAABB"];_bx_Body_ComputeShapeMassData=Module["_bx_Body_ComputeShapeMassData"]=wasmExports["bx_Body_ComputeShapeMassData"];_bx_Body_GetMassData=Module["_bx_Body_GetMassData"]=wasmExports["bx_Body_GetMassData"];_bx_Body_SetMassDataFull=Module["_bx_Body_SetMassDataFull"]=wasmExports["bx_Body_SetMassDataFull"];_bx_Body_SetMassData=Module["_bx_Body_SetMassData"]=wasmExports["bx_Body_SetMassData"];_bx_Body_GetMotionLocks=Module["_bx_Body_GetMotionLocks"]=wasmExports["bx_Body_GetMotionLocks"];_bx_Body_ApplyMassFromShapes=Module["_bx_Body_ApplyMassFromShapes"]=wasmExports["bx_Body_ApplyMassFromShapes"];_bx_Body_GetShapeCount=Module["_bx_Body_GetShapeCount"]=wasmExports["bx_Body_GetShapeCount"];_bx_Body_SetEventFlags=Module["_bx_Body_SetEventFlags"]=wasmExports["bx_Body_SetEventFlags"];_bx_Body_GetEventFlags=Module["_bx_Body_GetEventFlags"]=wasmExports["bx_Body_GetEventFlags"];_bx_Body_EnableContactEvents=Module["_bx_Body_EnableContactEvents"]=wasmExports["bx_Body_EnableContactEvents"];_bx_ShapeDesc_CreateSphere=Module["_bx_ShapeDesc_CreateSphere"]=wasmExports["bx_ShapeDesc_CreateSphere"];_bx_ShapeDesc_CreateCapsule=Module["_bx_ShapeDesc_CreateCapsule"]=wasmExports["bx_ShapeDesc_CreateCapsule"];_bx_ShapeDesc_CreateBox=Module["_bx_ShapeDesc_CreateBox"]=wasmExports["bx_ShapeDesc_CreateBox"];_bx_ShapeDesc_CreateCylinder=Module["_bx_ShapeDesc_CreateCylinder"]=wasmExports["bx_ShapeDesc_CreateCylinder"];_bx_ShapeDesc_CreateHull=Module["_bx_ShapeDesc_CreateHull"]=wasmExports["bx_ShapeDesc_CreateHull"];_bx_ShapeDesc_CreateMesh=Module["_bx_ShapeDesc_CreateMesh"]=wasmExports["bx_ShapeDesc_CreateMesh"];_bx_ShapeDesc_CreateHeightField=Module["_bx_ShapeDesc_CreateHeightField"]=wasmExports["bx_ShapeDesc_CreateHeightField"];_bx_ShapeDesc_CreateContainer=Module["_bx_ShapeDesc_CreateContainer"]=wasmExports["bx_ShapeDesc_CreateContainer"];_bx_ShapeDesc_AddChild=Module["_bx_ShapeDesc_AddChild"]=wasmExports["bx_ShapeDesc_AddChild"];_bx_ShapeDesc_RemoveChild=Module["_bx_ShapeDesc_RemoveChild"]=wasmExports["bx_ShapeDesc_RemoveChild"];_bx_ShapeDesc_GetChildCount=Module["_bx_ShapeDesc_GetChildCount"]=wasmExports["bx_ShapeDesc_GetChildCount"];_bx_ShapeDesc_GetKind=Module["_bx_ShapeDesc_GetKind"]=wasmExports["bx_ShapeDesc_GetKind"];_bx_ShapeDesc_SetMaterial=Module["_bx_ShapeDesc_SetMaterial"]=wasmExports["bx_ShapeDesc_SetMaterial"];_bx_ShapeDesc_GetFriction=Module["_bx_ShapeDesc_GetFriction"]=wasmExports["bx_ShapeDesc_GetFriction"];_bx_ShapeDesc_GetRestitution=Module["_bx_ShapeDesc_GetRestitution"]=wasmExports["bx_ShapeDesc_GetRestitution"];_bx_ShapeDesc_SetDensity=Module["_bx_ShapeDesc_SetDensity"]=wasmExports["bx_ShapeDesc_SetDensity"];_bx_ShapeDesc_GetDensity=Module["_bx_ShapeDesc_GetDensity"]=wasmExports["bx_ShapeDesc_GetDensity"];_bx_ShapeDesc_SetFilter=Module["_bx_ShapeDesc_SetFilter"]=wasmExports["bx_ShapeDesc_SetFilter"];_bx_ShapeDesc_GetCategoryBits=Module["_bx_ShapeDesc_GetCategoryBits"]=wasmExports["bx_ShapeDesc_GetCategoryBits"];_bx_ShapeDesc_GetMaskBits=Module["_bx_ShapeDesc_GetMaskBits"]=wasmExports["bx_ShapeDesc_GetMaskBits"];_bx_ShapeDesc_SetGroup=Module["_bx_ShapeDesc_SetGroup"]=wasmExports["bx_ShapeDesc_SetGroup"];_bx_ShapeDesc_SetRollingResistance=Module["_bx_ShapeDesc_SetRollingResistance"]=wasmExports["bx_ShapeDesc_SetRollingResistance"];_bx_ShapeDesc_SetSensor=Module["_bx_ShapeDesc_SetSensor"]=wasmExports["bx_ShapeDesc_SetSensor"];_bx_ShapeDesc_IsSensor=Module["_bx_ShapeDesc_IsSensor"]=wasmExports["bx_ShapeDesc_IsSensor"];_bx_ShapeDesc_GetAABB=Module["_bx_ShapeDesc_GetAABB"]=wasmExports["bx_ShapeDesc_GetAABB"];_bx_GetShapeBuildCount=Module["_bx_GetShapeBuildCount"]=wasmExports["bx_GetShapeBuildCount"];_bx_GetShapeDescCount=Module["_bx_GetShapeDescCount"]=wasmExports["bx_GetShapeDescCount"];_bx_Body_SetShape=Module["_bx_Body_SetShape"]=wasmExports["bx_Body_SetShape"];_bx_Body_SetShapeHull=Module["_bx_Body_SetShapeHull"]=wasmExports["bx_Body_SetShapeHull"];_bx_Body_TranslateShape=Module["_bx_Body_TranslateShape"]=wasmExports["bx_Body_TranslateShape"];_bx_Body_SetShapeFilter=Module["_bx_Body_SetShapeFilter"]=wasmExports["bx_Body_SetShapeFilter"];_bx_Body_RemoveShape=Module["_bx_Body_RemoveShape"]=wasmExports["bx_Body_RemoveShape"];_bx_Body_HasShape=Module["_bx_Body_HasShape"]=wasmExports["bx_Body_HasShape"];_bx_Body_GetShapeInfo=Module["_bx_Body_GetShapeInfo"]=wasmExports["bx_Body_GetShapeInfo"];_bx_Body_SyncShapeDesc=Module["_bx_Body_SyncShapeDesc"]=wasmExports["bx_Body_SyncShapeDesc"];_bx_Body_GetShapeDesc=Module["_bx_Body_GetShapeDesc"]=wasmExports["bx_Body_GetShapeDesc"];_bx_ShapeDesc_BuildDebugGeometry=Module["_bx_ShapeDesc_BuildDebugGeometry"]=wasmExports["bx_ShapeDesc_BuildDebugGeometry"];_bx_DebugPositionsPtr=Module["_bx_DebugPositionsPtr"]=wasmExports["bx_DebugPositionsPtr"];_bx_DebugIndicesPtr=Module["_bx_DebugIndicesPtr"]=wasmExports["bx_DebugIndicesPtr"];_bx_DebugIndexCount=Module["_bx_DebugIndexCount"]=wasmExports["bx_DebugIndexCount"];_bx_CreateJoint=Module["_bx_CreateJoint"]=wasmExports["bx_CreateJoint"];_bx_DestroyJoint=Module["_bx_DestroyJoint"]=wasmExports["bx_DestroyJoint"];_bx_Joint_IsValid=Module["_bx_Joint_IsValid"]=wasmExports["bx_Joint_IsValid"];_bx_Joint_SetCollideConnected=Module["_bx_Joint_SetCollideConnected"]=wasmExports["bx_Joint_SetCollideConnected"];_bx_Joint_SetConstraintTuning=Module["_bx_Joint_SetConstraintTuning"]=wasmExports["bx_Joint_SetConstraintTuning"];_bx_Joint_WakeBodies=Module["_bx_Joint_WakeBodies"]=wasmExports["bx_Joint_WakeBodies"];_bx_Joint_EnableLimit=Module["_bx_Joint_EnableLimit"]=wasmExports["bx_Joint_EnableLimit"];_bx_Joint_SetLimits=Module["_bx_Joint_SetLimits"]=wasmExports["bx_Joint_SetLimits"];_bx_Joint_SetTwistLimits=Module["_bx_Joint_SetTwistLimits"]=wasmExports["bx_Joint_SetTwistLimits"];_bx_Joint_EnableMotor=Module["_bx_Joint_EnableMotor"]=wasmExports["bx_Joint_EnableMotor"];_bx_Joint_UpdateMotorFrame=Module["_bx_Joint_UpdateMotorFrame"]=wasmExports["bx_Joint_UpdateMotorFrame"];_bx_Joint_SetSphericalMotor=Module["_bx_Joint_SetSphericalMotor"]=wasmExports["bx_Joint_SetSphericalMotor"];_bx_Joint_SetSphericalTarget=Module["_bx_Joint_SetSphericalTarget"]=wasmExports["bx_Joint_SetSphericalTarget"];_bx_Joint_SetMotorSpeed=Module["_bx_Joint_SetMotorSpeed"]=wasmExports["bx_Joint_SetMotorSpeed"];_bx_Joint_SetMaxMotorForce=Module["_bx_Joint_SetMaxMotorForce"]=wasmExports["bx_Joint_SetMaxMotorForce"];_bx_Joint_EnableSpring=Module["_bx_Joint_EnableSpring"]=wasmExports["bx_Joint_EnableSpring"];_bx_Joint_SetSpring=Module["_bx_Joint_SetSpring"]=wasmExports["bx_Joint_SetSpring"];_bx_Joint_SetTarget=Module["_bx_Joint_SetTarget"]=wasmExports["bx_Joint_SetTarget"];_bx_Joint_GetPosition=Module["_bx_Joint_GetPosition"]=wasmExports["bx_Joint_GetPosition"];_bx_ComputeAlignedFrameB=Module["_bx_ComputeAlignedFrameB"]=wasmExports["bx_ComputeAlignedFrameB"];_bx_WheelJoint_SetSpinMotorSpeed=Module["_bx_WheelJoint_SetSpinMotorSpeed"]=wasmExports["bx_WheelJoint_SetSpinMotorSpeed"];_bx_WheelJoint_SetMaxSpinTorque=Module["_bx_WheelJoint_SetMaxSpinTorque"]=wasmExports["bx_WheelJoint_SetMaxSpinTorque"];_bx_WheelJoint_EnableSpinMotor=Module["_bx_WheelJoint_EnableSpinMotor"]=wasmExports["bx_WheelJoint_EnableSpinMotor"];_bx_WheelJoint_SetTargetSteeringAngle=Module["_bx_WheelJoint_SetTargetSteeringAngle"]=wasmExports["bx_WheelJoint_SetTargetSteeringAngle"];_bx_WheelJoint_SetSuspension=Module["_bx_WheelJoint_SetSuspension"]=wasmExports["bx_WheelJoint_SetSuspension"];_bx_RayHitsPtr=Module["_bx_RayHitsPtr"]=wasmExports["bx_RayHitsPtr"];_bx_World_CastRay=Module["_bx_World_CastRay"]=wasmExports["bx_World_CastRay"];_bx_World_CastShape=Module["_bx_World_CastShape"]=wasmExports["bx_World_CastShape"];_bx_OverlapsPtr=Module["_bx_OverlapsPtr"]=wasmExports["bx_OverlapsPtr"];_bx_World_OverlapShape=Module["_bx_World_OverlapShape"]=wasmExports["bx_World_OverlapShape"];_bx_GeometryPtr=Module["_bx_GeometryPtr"]=wasmExports["bx_GeometryPtr"];_bx_Body_GetShapeGeometry=Module["_bx_Body_GetShapeGeometry"]=wasmExports["bx_Body_GetShapeGeometry"];memory=wasmMemory=wasmExports["memory"];__indirect_function_table=wasmExports["__indirect_function_table"]}var wasmImports={clock_time_get:_clock_time_get,emscripten_get_now:_emscripten_get_now,emscripten_resize_heap:_emscripten_resize_heap,fd_write:_fd_write};async function run(){preRun();var setStatus=Module["setStatus"];if(setStatus){setStatus("Running...");await new Promise(resolve=>setTimeout(resolve,1));setTimeout(setStatus,1,"")}if(ABORT)return;initRuntime();Module["onRuntimeInitialized"]?.();postRun()}var wasmExports;wasmExports=await createWasm();await run();
2
2
  ;return Module}export default Box3D;
Binary file
@@ -94,6 +94,36 @@ export interface Box3DExports {
94
94
  _bx_Body_IsAwake(body: number): number;
95
95
  _bx_Body_EnableSleep(body: number, flag: number): void;
96
96
  _bx_Body_SetBullet(body: number, flag: number): void;
97
+ /** Continuous collision for this body alone, on by default; the world's switch still applies. */
98
+ _bx_Body_EnableContinuous(body: number, flag: number): void;
99
+ _bx_Body_IsContinuousEnabled(body: number): number;
100
+ /**
101
+ * Crushable contacts for the body's shape `index`: each of its contacts pushes with at most `maxForce` newtons,
102
+ * and a plastic one (1) keeps its overlap instead of pushing out. A `maxForce` of zero or less makes it rigid.
103
+ */
104
+ _bx_Body_SetShapeCrush(body: number, index: number, maxForce: number, plastic: number): void;
105
+ /** scratch: [maxForce, plastic] for the body's shape `index`, zeros when it is rigid or there is no such shape. */
106
+ _bx_Body_GetShapeCrush(body: number, index: number): void;
107
+ /**
108
+ * Every touching contact manifold on the body, as the body feels it, written from `_bx_BodyContactsPtr`: 48 floats
109
+ * each, [shapeIndex, otherBody, otherShapeIndex, otherShapeDesc, normal xyz (the push on this body), friction impulse
110
+ * xyz on this body, twist impulse, pointCount], then 4 points of 9: [x, y, z, separation, normalImpulse (last
111
+ * substep), totalNormalImpulse (Box3D's, summed over every solver pass: nonzero means it carried load),
112
+ * normalVelocity, triangleIndex, material]. Returns the record count.
113
+ */
114
+ _bx_Body_GetContacts(body: number): number;
115
+ _bx_BodyContactsPtr(): number;
116
+ /** Per-shape handles: each changes one shape, resets only its contacts, and keeps every shape's index. */
117
+ /** Replaces shape `index` with the hull of `pointCount` points (xyz floats at `points`) in the body's frame; 1 if done. */
118
+ _bx_Body_SetShapeHull(body: number, index: number, points: number, pointCount: number): number;
119
+ /** Moves shape `index` (a hull, sphere or capsule) by (dx, dy, dz) in the body's frame; 1 if done. */
120
+ _bx_Body_TranslateShape(body: number, index: number, dx: number, dy: number, dz: number): number;
121
+ _bx_Body_SetShapeFilter(body: number, index: number, categoryBits: number, maskBits: number, groupIndex: number): void;
122
+ /** Removes shape `index`; the other shapes keep their indices. */
123
+ _bx_Body_RemoveShape(body: number, index: number): void;
124
+ _bx_Body_HasShape(body: number, index: number): number;
125
+ /** scratch: [kind (0 sphere, 1 capsule, 2 hull, -1 none), vertexCount, aabb min xyz, aabb max xyz] in the body's frame */
126
+ _bx_Body_GetShapeInfo(body: number, index: number): void;
97
127
  _bx_Body_AllowFastRotation(body: number, flag: number): void;
98
128
  _bx_Body_SetMotionLocks(body: number, lx: number, ly: number, lz: number, ax: number, ay: number, az: number): void;
99
129
  /** scratch: [minx, miny, minz, maxx, maxy, maxz] */
@@ -148,8 +178,9 @@ export interface Box3DExports {
148
178
  _bx_ShapeDesc_CreateHull(points: number, pointCount: number): number;
149
179
  /** vertices: vertexCount * 3 floats, indices: triangleCount * 3 int32 */
150
180
  _bx_ShapeDesc_CreateMesh(vertices: number, vertexCount: number, indices: number, triangleCount: number, sx: number, sy: number, sz: number, clockwise: number, weld: number): number;
151
- /** heights: countX * countZ floats indexed [z * countX + x], local offset (ox, oy, oz) */
152
- _bx_ShapeDesc_CreateHeightField(heights: number, countX: number, countZ: number, sx: number, sy: number, sz: number, clockwise: number, ox: number, oy: number, oz: number): number;
181
+ /** heights: countX * countZ floats indexed [z * countX + x]; materials: one byte a cell, (countX - 1) * (countZ - 1),
182
+ * or 0 for none; local offset (ox, oy, oz) */
183
+ _bx_ShapeDesc_CreateHeightField(heights: number, materials: number, countX: number, countZ: number, sx: number, sy: number, sz: number, clockwise: number, ox: number, oy: number, oz: number): number;
153
184
  _bx_ShapeDesc_CreateContainer(): number;
154
185
  _bx_ShapeDesc_AddChild(parent: number, child: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number, sx: number, sy: number, sz: number): void;
155
186
  _bx_ShapeDesc_RemoveChild(parent: number, index: number): void;
@@ -209,8 +240,19 @@ export interface Box3DExports {
209
240
 
210
241
  // queries
211
242
  _bx_RayHitsPtr(): number;
212
- /** Returns the hit count; hits are 11 floats each: [px, py, pz, nx, ny, nz, fraction, bodySlot, shapeDesc, triangleIndex, reserved] */
243
+ /** Returns the hit count; hits are 11 floats each: [px, py, pz, nx, ny, nz, fraction, bodySlot, shapeDesc, triangleIndex, shapeIndex] */
213
244
  _bx_World_CastRay(world: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, categoryBits: number, maskBits: number, ignoreBody: number, hitSensors: number, closestOnly: number): number;
245
+ /**
246
+ * Casts the hull of `count` points (xyz floats at `points`, relative to the origin) grown by `radius` along
247
+ * (dx, dy, dz). Hits are written as `_bx_World_CastRay` writes them, the fraction being where the surfaces touch.
248
+ */
249
+ _bx_World_CastShape(world: number, ox: number, oy: number, oz: number, points: number, count: number, radius: number, dx: number, dy: number, dz: number, categoryBits: number, maskBits: number, ignoreBody: number, closestOnly: number): number;
250
+ /** Every shape the hull of the points grown by `radius` overlaps, written from `_bx_OverlapsPtr` as [bodySlot, shapeIndex, shapeDesc]. */
251
+ _bx_World_OverlapShape(world: number, ox: number, oy: number, oz: number, points: number, count: number, radius: number, categoryBits: number, maskBits: number, ignoreBody: number): number;
252
+ _bx_OverlapsPtr(): number;
253
+ /** Shape `index`'s geometry in the body's frame, from `_bx_GeometryPtr`: sphere [c, r], capsule [c1, c2, r], or hull points. Returns the float count. */
254
+ _bx_Body_GetShapeGeometry(body: number, index: number): number;
255
+ _bx_GeometryPtr(): number;
214
256
  }
215
257
 
216
258
  export type Box3DModule = Box3DExports & Box3DHeap;