babylon-box3d 0.6.1 → 0.8.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 +80 -5
- package/dist/box3dPlugin.d.ts +22 -0
- package/dist/box3dPlugin.d.ts.map +1 -1
- package/dist/box3dPlugin.js +33 -2
- package/dist/box3dPlugin.js.map +1 -1
- package/dist/loadBox3D.d.ts +7 -0
- package/dist/loadBox3D.d.ts.map +1 -1
- package/dist/loadBox3D.js +5 -4
- package/dist/loadBox3D.js.map +1 -1
- package/lib/esm/box3d.d.ts +54 -1
- package/lib/esm/box3d.js +1 -1
- package/lib/esm/box3d.wasm +0 -0
- package/lib/esm-f64/box3d.d.ts +320 -0
- package/lib/esm-f64/box3d.js +2 -0
- package/lib/esm-f64/box3d.wasm +0 -0
- package/lib/esm-f64-threads/box3d.d.ts +320 -0
- package/lib/esm-f64-threads/box3d.js +2 -0
- package/lib/esm-f64-threads/box3d.wasm +0 -0
- package/lib/esm-threads/box3d.d.ts +54 -1
- package/lib/esm-threads/box3d.js +1 -1
- package/lib/esm-threads/box3d.wasm +0 -0
- package/lib/node/box3d.d.ts +54 -1
- package/lib/node/box3d.mjs +1 -1
- package/lib/node/box3d.wasm +0 -0
- package/lib/node-f64/box3d.d.ts +320 -0
- package/lib/node-f64/box3d.mjs +2 -0
- package/lib/node-f64/box3d.wasm +0 -0
- package/lib/node-f64-threads/box3d.d.ts +320 -0
- package/lib/node-f64-threads/box3d.mjs +2 -0
- package/lib/node-f64-threads/box3d.wasm +0 -0
- package/lib/node-threads/box3d.d.ts +54 -1
- package/lib/node-threads/box3d.mjs +1 -1
- package/lib/node-threads/box3d.wasm +0 -0
- package/lib/umd/box3d.umd.js +1 -1
- package/lib/umd/box3d.umd.wasm +0 -0
- package/package.json +17 -1
- package/umd/babylon.box3d.js +76 -4
- package/umd/babylon.box3d.js.map +3 -3
- package/umd/babylon.box3d.min.js +2 -2
- package/umd/babylon.box3d.min.js.map +4 -4
- package/wasm/box3d_shim.c +526 -35
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the Box3D WebAssembly module used by the Babylon.js Box3DPlugin.
|
|
3
|
+
*
|
|
4
|
+
* The module exposes a flat, handle based C API (see src/box3d_shim.c). Bodies, shape descriptions and joints
|
|
5
|
+
* are integer slots. Vectors and quaternions are passed as individual floats. Functions that return more than one
|
|
6
|
+
* value write into the scratch buffer returned by `_bx_Scratch()` (64 floats), read it through `HEAPF32`.
|
|
7
|
+
*
|
|
8
|
+
* World positions cross in doubles: the entry points that take one take doubles, and those that give one back also
|
|
9
|
+
* write it as doubles, to `_bx_ScratchF64()` or to a double buffer beside their float records (read through
|
|
10
|
+
* `HEAPF64`). The `-f64` builds (BOX3D_DOUBLE_PRECISION) hold positions in doubles, so a body far from the origin moves
|
|
11
|
+
* as it does near it; the default builds hold floats, and their doubles are those floats widened.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface Box3DModuleOptions {
|
|
15
|
+
/** Resolves the location of box3d.wasm (and other runtime files). */
|
|
16
|
+
locateFile?: (file: string, prefix: string) => string;
|
|
17
|
+
/** Called with progress and error messages by the emscripten runtime. */
|
|
18
|
+
print?: (text: string) => void;
|
|
19
|
+
printErr?: (text: string) => void;
|
|
20
|
+
/** Supplies a pre-fetched wasm binary instead of fetching it. */
|
|
21
|
+
wasmBinary?: ArrayBuffer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Emscripten heap views. Do not cache them: they are replaced when the memory grows. */
|
|
25
|
+
export interface Box3DHeap {
|
|
26
|
+
HEAPF32: Float32Array;
|
|
27
|
+
HEAPF64: Float64Array;
|
|
28
|
+
HEAP32: Int32Array;
|
|
29
|
+
HEAPU32: Uint32Array;
|
|
30
|
+
HEAPU8: Uint8Array;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** All exported shim functions. Slots are integers, 0 is the null slot. */
|
|
34
|
+
export interface Box3DExports {
|
|
35
|
+
_malloc(bytes: number): number;
|
|
36
|
+
_free(ptr: number): void;
|
|
37
|
+
_bx_Scratch(): number;
|
|
38
|
+
/** 16 doubles: world positions given back, see `_bx_Body_GetTransform`. */
|
|
39
|
+
_bx_ScratchF64(): number;
|
|
40
|
+
/** 1 in an `-f64` build, which holds world positions in doubles. */
|
|
41
|
+
_bx_IsDoublePrecision(): number;
|
|
42
|
+
_bx_Alloc(bytes: number): number;
|
|
43
|
+
_bx_Free(ptr: number): void;
|
|
44
|
+
/** major * 10000 + minor * 100 + revision */
|
|
45
|
+
_bx_GetVersion(): number;
|
|
46
|
+
|
|
47
|
+
// world
|
|
48
|
+
/** Workers this build can put on a step, counting the calling thread: 1 unless this is the threaded module. */
|
|
49
|
+
_bx_GetMaxWorkers(): number;
|
|
50
|
+
/** workerCount counts the calling thread and is clamped to _bx_GetMaxWorkers(); box3d builds its threads here. */
|
|
51
|
+
_bx_CreateWorld(gx: number, gy: number, gz: number, workerCount: number): number;
|
|
52
|
+
_bx_World_GetWorkerCount(world: number): number;
|
|
53
|
+
_bx_DestroyWorld(world: number): void;
|
|
54
|
+
_bx_World_Step(world: number, dt: number, subSteps: number): void;
|
|
55
|
+
_bx_World_SetGravity(world: number, gx: number, gy: number, gz: number): void;
|
|
56
|
+
_bx_World_SetMaximumLinearSpeed(world: number, speed: number): void;
|
|
57
|
+
_bx_World_GetMaximumLinearSpeed(world: number): number;
|
|
58
|
+
_bx_World_EnableSleeping(world: number, flag: number): void;
|
|
59
|
+
_bx_World_EnableContinuous(world: number, flag: number): void;
|
|
60
|
+
_bx_World_SetContactTuning(world: number, hertz: number, dampingRatio: number, contactSpeed: number): void;
|
|
61
|
+
_bx_World_Explode(world: number, px: number, py: number, pz: number, radius: number, falloff: number, impulsePerArea: number): void;
|
|
62
|
+
_bx_World_GetAwakeBodyCount(world: number): number;
|
|
63
|
+
/** Joint force/torque threshold events from the last step (0 with the default thresholds). */
|
|
64
|
+
_bx_World_GetJointEventCount(world: number): number;
|
|
65
|
+
/** The most the world's step stack has held at once, in bytes. */
|
|
66
|
+
_bx_World_GetStackUsed(world: number): number;
|
|
67
|
+
/** scratch: [bodyCount, shapeCount, contactCount, jointCount, islandCount, stepMs, collideMs, solveMs] */
|
|
68
|
+
_bx_World_GetStats(world: number): void;
|
|
69
|
+
|
|
70
|
+
// events (records are copied into flat float buffers, see the shim for the strides)
|
|
71
|
+
_bx_MoveEventsPtr(): number;
|
|
72
|
+
_bx_ContactEventsPtr(): number;
|
|
73
|
+
_bx_SensorEventsPtr(): number;
|
|
74
|
+
_bx_World_GetMoveEvents(world: number): number;
|
|
75
|
+
_bx_World_GetContactEvents(world: number): number;
|
|
76
|
+
_bx_World_GetSensorEvents(world: number): number;
|
|
77
|
+
|
|
78
|
+
// bodies (type: 0 static, 1 kinematic, 2 dynamic)
|
|
79
|
+
_bx_CreateBody(world: number, type: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number, isAwake: number): number;
|
|
80
|
+
_bx_DestroyBody(body: number): void;
|
|
81
|
+
_bx_Body_SetType(body: number, type: number): void;
|
|
82
|
+
_bx_Body_GetType(body: number): number;
|
|
83
|
+
_bx_Body_SetTransform(body: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number): void;
|
|
84
|
+
/** scratch: [px, py, pz, qx, qy, qz, qw] as floats; scratchF64: [px, py, pz] as the build holds them */
|
|
85
|
+
_bx_Body_GetTransform(body: number): void;
|
|
86
|
+
_bx_Body_SetTargetTransform(body: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number, dt: number): void;
|
|
87
|
+
_bx_Body_SetLinearVelocity(body: number, x: number, y: number, z: number): void;
|
|
88
|
+
/** scratch: [x, y, z] */
|
|
89
|
+
_bx_Body_GetLinearVelocity(body: number): void;
|
|
90
|
+
_bx_Body_SetAngularVelocity(body: number, x: number, y: number, z: number): void;
|
|
91
|
+
/** scratch: [x, y, z] */
|
|
92
|
+
_bx_Body_GetAngularVelocity(body: number): void;
|
|
93
|
+
_bx_Body_SetLinearDamping(body: number, damping: number): void;
|
|
94
|
+
_bx_Body_GetLinearDamping(body: number): number;
|
|
95
|
+
_bx_Body_SetAngularDamping(body: number, damping: number): void;
|
|
96
|
+
_bx_Body_GetAngularDamping(body: number): number;
|
|
97
|
+
_bx_Body_SetGravityScale(body: number, scale: number): void;
|
|
98
|
+
_bx_Body_GetGravityScale(body: number): number;
|
|
99
|
+
_bx_Body_ApplyForce(body: number, fx: number, fy: number, fz: number, px: number, py: number, pz: number): void;
|
|
100
|
+
_bx_Body_ApplyForceToCenter(body: number, fx: number, fy: number, fz: number): void;
|
|
101
|
+
_bx_Body_ApplyTorque(body: number, x: number, y: number, z: number): void;
|
|
102
|
+
_bx_Body_ApplyLinearImpulse(body: number, ix: number, iy: number, iz: number, px: number, py: number, pz: number): void;
|
|
103
|
+
_bx_Body_ApplyLinearImpulseToCenter(body: number, ix: number, iy: number, iz: number): void;
|
|
104
|
+
_bx_Body_ApplyAngularImpulse(body: number, x: number, y: number, z: number): void;
|
|
105
|
+
_bx_Body_SetAwake(body: number, awake: number): void;
|
|
106
|
+
_bx_Body_IsAwake(body: number): number;
|
|
107
|
+
_bx_Body_EnableSleep(body: number, flag: number): void;
|
|
108
|
+
_bx_Body_SetBullet(body: number, flag: number): void;
|
|
109
|
+
/** Continuous collision for this body alone, on by default; the world's switch still applies. */
|
|
110
|
+
_bx_Body_EnableContinuous(body: number, flag: number): void;
|
|
111
|
+
_bx_Body_IsContinuousEnabled(body: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Crushable contacts for the body's shape `index`: each of its contacts pushes with at most `maxForce` newtons,
|
|
114
|
+
* and a plastic one (1) keeps its overlap instead of pushing out. A `maxForce` of zero or less makes it rigid.
|
|
115
|
+
*/
|
|
116
|
+
_bx_Body_SetShapeCrush(body: number, index: number, maxForce: number, plastic: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Clips the body's contacts with the plane (nx, ny, nz, d) (wasm/patches/0006), normalized: contact points where
|
|
119
|
+
* n.p + d > -2 * linearSlop, there or one separation toward the other shape, are dropped from its contacts with shapes whose category bits meet `mask`. `enabled` 0
|
|
120
|
+
* removes it. Wakes the body.
|
|
121
|
+
*/
|
|
122
|
+
_bx_Body_SetClipPlane(body: number, enabled: number, nx: number, ny: number, nz: number, d: number, mask: number): void;
|
|
123
|
+
/** scratchF64: [enabled, nx, ny, nz, d, mask] */
|
|
124
|
+
_bx_Body_GetClipPlane(body: number): void;
|
|
125
|
+
/** scratch: [maxForce, plastic] for the body's shape `index`, zeros when it is rigid or there is no such shape. */
|
|
126
|
+
_bx_Body_GetShapeCrush(body: number, index: number): void;
|
|
127
|
+
/**
|
|
128
|
+
* Every touching contact manifold on the body, as the body feels it, written from `_bx_BodyContactsPtr`: 48 floats
|
|
129
|
+
* each, [shapeIndex, otherBody, otherShapeIndex, otherShapeDesc, normal xyz (the push on this body), friction impulse
|
|
130
|
+
* xyz on this body, twist impulse, pointCount], then 4 points of 9: [x, y, z, separation, normalImpulse (last
|
|
131
|
+
* substep), totalNormalImpulse (Box3D's, summed over every solver pass: nonzero means it carried load),
|
|
132
|
+
* normalVelocity, triangleIndex, material]. Returns the record count.
|
|
133
|
+
*/
|
|
134
|
+
_bx_Body_GetContacts(body: number): number;
|
|
135
|
+
_bx_BodyContactsPtr(): number;
|
|
136
|
+
/** The points of the records `_bx_Body_GetContacts` wrote, as doubles: 12 a record, [x, y, z] for each of its 4. */
|
|
137
|
+
_bx_BodyContactPointsF64Ptr(): number;
|
|
138
|
+
/** Per-shape handles: each changes one shape, resets only its contacts, and keeps every shape's index. */
|
|
139
|
+
/** Replaces shape `index` with the hull of `pointCount` points (xyz floats at `points`) in the body's frame; 1 if done. */
|
|
140
|
+
_bx_Body_SetShapeHull(body: number, index: number, points: number, pointCount: number): number;
|
|
141
|
+
/** Moves shape `index` (a hull, sphere or capsule) by (dx, dy, dz) in the body's frame; 1 if done. */
|
|
142
|
+
_bx_Body_TranslateShape(body: number, index: number, dx: number, dy: number, dz: number): number;
|
|
143
|
+
_bx_Body_SetShapeFilter(body: number, index: number, categoryBits: number, maskBits: number, groupIndex: number): void;
|
|
144
|
+
/** Removes shape `index`; the other shapes keep their indices. */
|
|
145
|
+
_bx_Body_RemoveShape(body: number, index: number): void;
|
|
146
|
+
_bx_Body_HasShape(body: number, index: number): number;
|
|
147
|
+
/** scratch: [kind (0 sphere, 1 capsule, 2 hull, -1 none), vertexCount, aabb min xyz, aabb max xyz] in the body's frame */
|
|
148
|
+
_bx_Body_GetShapeInfo(body: number, index: number): void;
|
|
149
|
+
_bx_Body_AllowFastRotation(body: number, flag: number): void;
|
|
150
|
+
_bx_Body_SetMotionLocks(body: number, lx: number, ly: number, lz: number, ax: number, ay: number, az: number): void;
|
|
151
|
+
/** scratch: [minx, miny, minz, maxx, maxy, maxz] */
|
|
152
|
+
_bx_Body_GetAABB(body: number): void;
|
|
153
|
+
/** scratch: [mass, cx, cy, cz, ixx, iyy, izz, ixy, ixz, iyz] */
|
|
154
|
+
_bx_Body_GetMassData(body: number): void;
|
|
155
|
+
_bx_Body_SetMassData(body: number, mass: number, cx: number, cy: number, cz: number, ixx: number, iyy: number, izz: number): void;
|
|
156
|
+
/** Full symmetric inertia tensor about the center of mass. */
|
|
157
|
+
_bx_Body_SetMassDataFull(
|
|
158
|
+
body: number,
|
|
159
|
+
mass: number,
|
|
160
|
+
cx: number,
|
|
161
|
+
cy: number,
|
|
162
|
+
cz: number,
|
|
163
|
+
ixx: number,
|
|
164
|
+
iyy: number,
|
|
165
|
+
izz: number,
|
|
166
|
+
ixy: number,
|
|
167
|
+
ixz: number,
|
|
168
|
+
iyz: number
|
|
169
|
+
): void;
|
|
170
|
+
/** scratch: [lx, ly, lz, ax, ay, az], 1 where the motion is locked */
|
|
171
|
+
_bx_Body_GetMotionLocks(body: number): void;
|
|
172
|
+
/** Mass data the body's shapes would give it whatever its type (Box3D keeps mass 0 on static and kinematic bodies). */
|
|
173
|
+
_bx_Body_ComputeShapeMassData(body: number): void;
|
|
174
|
+
_bx_Body_ApplyMassFromShapes(body: number): void;
|
|
175
|
+
_bx_Body_GetShapeCount(body: number): number;
|
|
176
|
+
/**
|
|
177
|
+
* Gives the body a feature key (an integer from 1 to 2^44 - 1; 0 takes it off) and each of its shapes, now and when
|
|
178
|
+
* it is next shaped, (key << 20) | its index. New contacts are made, continuous collision sweeps and a closest
|
|
179
|
+
* cast's ties are broken in the order of these keys, so keyed statics pair the same whatever order they were made in.
|
|
180
|
+
*/
|
|
181
|
+
_bx_Body_SetFeatureKey(body: number, key: number): void;
|
|
182
|
+
_bx_Body_GetFeatureKey(body: number): number;
|
|
183
|
+
/** Shape `index`'s own feature key, as Box3D orders by it (exact up to 2^53). */
|
|
184
|
+
_bx_Body_GetShapeFeatureKey(body: number, index: number): number;
|
|
185
|
+
/** Begin/end touch events and hit events on the body's shapes, enabled separately. */
|
|
186
|
+
_bx_Body_SetEventFlags(body: number, contactEvents: number, hitEvents: number): void;
|
|
187
|
+
/** Bit 1: begin/end touch events, bit 2: hit events. */
|
|
188
|
+
_bx_Body_GetEventFlags(body: number): number;
|
|
189
|
+
/** Enables both begin/end touch and hit events. */
|
|
190
|
+
_bx_Body_EnableContactEvents(body: number, flag: number): void;
|
|
191
|
+
/** Replaces every shape on the body with an instance of the description (0 removes all shapes). */
|
|
192
|
+
_bx_Body_SetShape(body: number, desc: number): void;
|
|
193
|
+
/** Applies changed description properties (1 filter, 2 material, 4 density) to live shapes without rebuilding them. */
|
|
194
|
+
_bx_Body_SyncShapeDesc(body: number, desc: number, what: number): void;
|
|
195
|
+
/** Total number of box3d shapes the shim has created, to tell a rebuild from an in place update. */
|
|
196
|
+
_bx_GetShapeBuildCount(): number;
|
|
197
|
+
/** Live shape descriptions, including meshes baked for container children. */
|
|
198
|
+
_bx_GetShapeDescCount(): number;
|
|
199
|
+
/** Slot lookups the shim rejected (a handle used after it was destroyed, or a loader and a wasm from different builds). */
|
|
200
|
+
_bx_GetRejectedSlotCount(): number;
|
|
201
|
+
_bx_Body_GetShapeDesc(body: number): number;
|
|
202
|
+
|
|
203
|
+
// shape descriptions
|
|
204
|
+
_bx_ShapeDesc_CreateSphere(cx: number, cy: number, cz: number, radius: number): number;
|
|
205
|
+
_bx_ShapeDesc_CreateCapsule(ax: number, ay: number, az: number, bx: number, by: number, bz: number, radius: number): number;
|
|
206
|
+
_bx_ShapeDesc_CreateBox(hx: number, hy: number, hz: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number): number;
|
|
207
|
+
_bx_ShapeDesc_CreateCylinder(height: number, radius: number, sides: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number): number;
|
|
208
|
+
/** points: pointer to pointCount * 3 floats */
|
|
209
|
+
_bx_ShapeDesc_CreateHull(points: number, pointCount: number): number;
|
|
210
|
+
/** vertices: vertexCount * 3 floats, indices: triangleCount * 3 int32 */
|
|
211
|
+
_bx_ShapeDesc_CreateMesh(vertices: number, vertexCount: number, indices: number, triangleCount: number, sx: number, sy: number, sz: number, clockwise: number, weld: number): number;
|
|
212
|
+
/** heights: countX * countZ floats indexed [z * countX + x]; materials: one byte a cell, (countX - 1) * (countZ - 1),
|
|
213
|
+
* or 0 for none; local offset (ox, oy, oz) */
|
|
214
|
+
_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;
|
|
215
|
+
/**
|
|
216
|
+
* Where a mesh or height field description's data starts, and how many bytes it has (0 for any other description).
|
|
217
|
+
* Box3D keeps either as one block addressed by offsets, with no pointers in it, so the bytes can be copied to another
|
|
218
|
+
* instance of the same build (one with no world, on a worker) and made into a shape there with
|
|
219
|
+
* `_bx_ShapeDesc_CreateMeshFromBytes` or `_bx_ShapeDesc_CreateHeightFieldFromBytes`.
|
|
220
|
+
*/
|
|
221
|
+
_bx_ShapeDesc_GetGeometryBytes(desc: number): number;
|
|
222
|
+
_bx_ShapeDesc_GetGeometryByteCount(desc: number): number;
|
|
223
|
+
/** A mesh description from a copy of a mesh block put at `bytes`, with the description's scale. 0 if it is not one. */
|
|
224
|
+
_bx_ShapeDesc_CreateMeshFromBytes(bytes: number, byteCount: number, sx: number, sy: number, sz: number): number;
|
|
225
|
+
/** A height field description from a copy of a height field block put at `bytes`, with a local offset. 0 if it is not one. */
|
|
226
|
+
_bx_ShapeDesc_CreateHeightFieldFromBytes(bytes: number, byteCount: number, ox: number, oy: number, oz: number): number;
|
|
227
|
+
_bx_ShapeDesc_CreateContainer(): number;
|
|
228
|
+
_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;
|
|
229
|
+
_bx_ShapeDesc_RemoveChild(parent: number, index: number): void;
|
|
230
|
+
_bx_ShapeDesc_GetChildCount(desc: number): number;
|
|
231
|
+
_bx_ShapeDesc_GetKind(desc: number): number;
|
|
232
|
+
_bx_ShapeDesc_SetMaterial(desc: number, friction: number, restitution: number): void;
|
|
233
|
+
_bx_ShapeDesc_GetFriction(desc: number): number;
|
|
234
|
+
_bx_ShapeDesc_GetRestitution(desc: number): number;
|
|
235
|
+
_bx_ShapeDesc_SetDensity(desc: number, density: number): void;
|
|
236
|
+
_bx_ShapeDesc_GetDensity(desc: number): number;
|
|
237
|
+
_bx_ShapeDesc_SetFilter(desc: number, categoryBits: number, maskBits: number): void;
|
|
238
|
+
_bx_ShapeDesc_GetCategoryBits(desc: number): number;
|
|
239
|
+
_bx_ShapeDesc_GetMaskBits(desc: number): number;
|
|
240
|
+
_bx_ShapeDesc_SetGroup(desc: number, groupIndex: number): void;
|
|
241
|
+
_bx_ShapeDesc_SetRollingResistance(desc: number, value: number): void;
|
|
242
|
+
_bx_ShapeDesc_SetSensor(desc: number, flag: number): void;
|
|
243
|
+
_bx_ShapeDesc_IsSensor(desc: number): number;
|
|
244
|
+
/**
|
|
245
|
+
* 1 (the default): a static shape made from this description looks for its own pairs on the next step. 0: it never
|
|
246
|
+
* enters the broad phase's move buffer and waits for a moving shape to find it, which saves the step stack it would
|
|
247
|
+
* reserve and pairs a static made late on the same step as one made at the start. Off on a container, it is off for
|
|
248
|
+
* every shape made from its children.
|
|
249
|
+
*/
|
|
250
|
+
_bx_ShapeDesc_SetInvokeContactCreation(desc: number, flag: number): void;
|
|
251
|
+
_bx_ShapeDesc_GetInvokeContactCreation(desc: number): number;
|
|
252
|
+
/** scratch: [minx, miny, minz, maxx, maxy, maxz] */
|
|
253
|
+
_bx_ShapeDesc_GetAABB(desc: number): void;
|
|
254
|
+
_bx_ShapeDesc_Destroy(desc: number): void;
|
|
255
|
+
_bx_ShapeDesc_BuildDebugGeometry(desc: number): number;
|
|
256
|
+
_bx_DebugPositionsPtr(): number;
|
|
257
|
+
_bx_DebugIndicesPtr(): number;
|
|
258
|
+
_bx_DebugIndexCount(): number;
|
|
259
|
+
|
|
260
|
+
// joints (type: 0 weld, 1 spherical, 2 revolute, 3 prismatic, 4 distance, 5 filter, 6 wheel, 7 parallel)
|
|
261
|
+
/** Frames are read from scratch[0..13], type specific parameters from scratch[14..]. */
|
|
262
|
+
_bx_CreateJoint(world: number, type: number, bodyA: number, bodyB: number, collideConnected: number, param: number): number;
|
|
263
|
+
_bx_DestroyJoint(joint: number): void;
|
|
264
|
+
_bx_Joint_IsValid(joint: number): number;
|
|
265
|
+
_bx_Joint_SetCollideConnected(joint: number, flag: number): void;
|
|
266
|
+
_bx_Joint_SetConstraintTuning(joint: number, hertz: number, dampingRatio: number): void;
|
|
267
|
+
_bx_Joint_WakeBodies(joint: number): void;
|
|
268
|
+
_bx_Joint_EnableLimit(joint: number, flag: number): void;
|
|
269
|
+
_bx_Joint_SetLimits(joint: number, lower: number, upper: number): void;
|
|
270
|
+
_bx_Joint_SetTwistLimits(joint: number, enable: number, lower: number, upper: number): void;
|
|
271
|
+
_bx_Joint_EnableMotor(joint: number, flag: number): void;
|
|
272
|
+
_bx_Joint_SetMotorSpeed(joint: number, speed: number): void;
|
|
273
|
+
/** Spherical joints: target relative angular velocity in joint frame A, with a torque limit. */
|
|
274
|
+
_bx_Joint_SetSphericalMotor(joint: number, enable: number, x: number, y: number, z: number, maxTorque: number): void;
|
|
275
|
+
/** Re-converts a spherical motor target to world space, call once per step while the target is non-zero. */
|
|
276
|
+
_bx_Joint_UpdateMotorFrame(joint: number): void;
|
|
277
|
+
/** Spherical joints: target rotation of the spring, frame B relative to frame A. */
|
|
278
|
+
_bx_Joint_SetSphericalTarget(joint: number, qx: number, qy: number, qz: number, qw: number): void;
|
|
279
|
+
_bx_Joint_SetMaxMotorForce(joint: number, force: number): void;
|
|
280
|
+
_bx_Joint_EnableSpring(joint: number, flag: number): void;
|
|
281
|
+
_bx_Joint_SetSpring(joint: number, hertz: number, dampingRatio: number): void;
|
|
282
|
+
_bx_Joint_SetTarget(joint: number, target: number): void;
|
|
283
|
+
_bx_Joint_GetPosition(joint: number): number;
|
|
284
|
+
/** Reads frame A from scratch[0..6] and pivot B from scratch[7..9], writes the frame B rotation to scratch[10..13]. */
|
|
285
|
+
_bx_ComputeAlignedFrameB(bodyA: number, bodyB: number): void;
|
|
286
|
+
_bx_WheelJoint_SetSpinMotorSpeed(joint: number, speed: number): void;
|
|
287
|
+
_bx_WheelJoint_SetMaxSpinTorque(joint: number, torque: number): void;
|
|
288
|
+
_bx_WheelJoint_EnableSpinMotor(joint: number, flag: number): void;
|
|
289
|
+
_bx_WheelJoint_SetTargetSteeringAngle(joint: number, radians: number): void;
|
|
290
|
+
_bx_WheelJoint_SetSuspension(joint: number, hertz: number, dampingRatio: number): void;
|
|
291
|
+
|
|
292
|
+
// queries
|
|
293
|
+
_bx_RayHitsPtr(): number;
|
|
294
|
+
/** The hit points of the last ray or shape cast, as doubles: [x, y, z] a hit, beside `_bx_RayHitsPtr`'s records. */
|
|
295
|
+
_bx_RayHitPointsF64Ptr(): number;
|
|
296
|
+
/** Returns the hit count; hits are 11 floats each: [px, py, pz, nx, ny, nz, fraction, bodySlot, shapeDesc, triangleIndex, shapeIndex] */
|
|
297
|
+
_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;
|
|
298
|
+
/**
|
|
299
|
+
* Casts the hull of `count` points (xyz floats at `points`, relative to the origin) grown by `radius` along
|
|
300
|
+
* (dx, dy, dz). Hits are written as `_bx_World_CastRay` writes them, the fraction being where the surfaces touch.
|
|
301
|
+
*/
|
|
302
|
+
_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;
|
|
303
|
+
/** Every shape the hull of the points grown by `radius` overlaps, written from `_bx_OverlapsPtr` as [bodySlot, shapeIndex, shapeDesc]. */
|
|
304
|
+
_bx_World_OverlapShape(world: number, ox: number, oy: number, oz: number, points: number, count: number, radius: number, categoryBits: number, maskBits: number, ignoreBody: number): number;
|
|
305
|
+
_bx_OverlapsPtr(): number;
|
|
306
|
+
/** 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. */
|
|
307
|
+
_bx_Body_GetShapeGeometry(body: number, index: number): number;
|
|
308
|
+
_bx_GeometryPtr(): number;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export type Box3DModule = Box3DExports & Box3DHeap;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Instantiates the Box3D WebAssembly module.
|
|
315
|
+
* @param options emscripten module options, `locateFile` is needed when the wasm is not next to the script
|
|
316
|
+
* @returns the resolved module, pass it to `new Box3DPlugin(true, module)`
|
|
317
|
+
*/
|
|
318
|
+
declare function Box3D(options?: Box3DModuleOptions): Promise<Box3DModule>;
|
|
319
|
+
|
|
320
|
+
export default Box3D;
|
|
@@ -0,0 +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 ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&globalThis.name=="em-pthread";if(ENVIRONMENT_IS_NODE){const{createRequire}=await import("node:module");var require=createRequire(import.meta.url);var worker_threads=require("node:worker_threads");globalThis.Worker=worker_threads.Worker;ENVIRONMENT_IS_WORKER=!worker_threads.isMainThread;ENVIRONMENT_IS_PTHREAD=ENVIRONMENT_IS_WORKER&&worker_threads.workerData=="em-pthread"}var programArgs=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};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_NODE){var fs=require("node:fs");if(_scriptName.startsWith("file:")){scriptDirectory=require("node:path").dirname(require("node:url").fileURLToPath(_scriptName))+"/"}readBinary=filename=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename);return ret};readAsync=async(filename,binary=true)=>{filename=isFileURI(filename)?new URL(filename):filename;var ret=fs.readFileSync(filename,binary?undefined:"utf8");return ret};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}programArgs=process.argv.slice(2);quit_=(status,toThrow)=>{process.exitCode=status;throw toThrow}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}if(!ENVIRONMENT_IS_NODE){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 defaultPrint=console.log.bind(console);var defaultPrintErr=console.error.bind(console);if(ENVIRONMENT_IS_NODE){var utils=require("node:util");var stringify=a=>typeof a=="object"?utils.inspect(a):a;defaultPrint=(...args)=>fs.writeSync(1,args.map(stringify).join(" ")+"\n");defaultPrintErr=(...args)=>fs.writeSync(2,args.map(stringify).join(" ")+"\n")}var out=defaultPrint;var err=defaultPrintErr;var wasmBinary;var wasmModule;var ABORT=false;var EXITSTATUS;var isFileURI=filename=>filename.startsWith("file://");class EmscriptenEH{}class EmscriptenSjLj extends EmscriptenEH{}function growMemViews(){if(wasmMemory.buffer!=HEAP8.buffer){updateMemoryViews()}}if(ENVIRONMENT_IS_NODE&&ENVIRONMENT_IS_PTHREAD){globalThis.self=globalThis;var parentPort=worker_threads.parentPort;if(!globalThis.postMessage){parentPort.on("message",msg=>globalThis.onmessage?.({data:msg}));globalThis.postMessage=msg=>parentPort.postMessage(msg)}process.on("uncaughtException",err=>{postMessage({cmd:8,error:err});process.exit(1)})}var startWorker;if(ENVIRONMENT_IS_PTHREAD){var initializedJS=false;self.onunhandledrejection=e=>{throw e.reason||e};function handleMessage(e){try{var msgData=e.data;var cmd=msgData.cmd;if(cmd==1){let messageQueue=[];self.onmessage=e=>messageQueue.push(e);startWorker=()=>{postMessage({cmd:3});for(let msg of messageQueue){handleMessage(msg)}self.onmessage=handleMessage};for(const handler of msgData.handlers){if(!Module[handler]||Module[handler].proxy){Module[handler]=(...args)=>{postMessage({cmd:9,handler,args})};if(handler=="print")out=Module[handler];if(handler=="printErr")err=Module[handler]}}wasmMemory=msgData.wasmMemory;updateMemoryViews();wasmModule=msgData.wasmModule;createWasm();run();startWorker()}else if(cmd==2){establishStackSpace(msgData.pthread_ptr);__emscripten_thread_init(msgData.pthread_ptr,0,0,1,0,0);PThread.threadInitTLS();__emscripten_thread_mailbox_await(msgData.pthread_ptr);if(!initializedJS){initializedJS=true}try{invokeEntryPoint(msgData.start_routine,msgData.arg)}catch(ex){if(ex!="unwind"){throw ex}}}else if(cmd==4){if(initializedJS){checkMailbox()}}else if(cmd){err(`worker: received unknown command ${cmd}`);err(msgData)}}catch(ex){if(runtimeInitialized)__emscripten_thread_crashed();throw ex}}self.onmessage=handleMessage}var runtimeInitialized=false;function getMemoryBuffer(){return wasmMemory.buffer}function updateMemoryViews(){if(HEAP8?.buffer?.growable)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);Module["HEAPF64"]=HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b)}function initMemory(){if(ENVIRONMENT_IS_PTHREAD){return}{var INITIAL_MEMORY=33554432;wasmMemory=new WebAssembly.Memory({initial:INITIAL_MEMORY/65536,maximum:32768,shared:true})}updateMemoryViews()}function preRun(){var preRun=Module["preRun"];if(preRun){if(typeof preRun=="function")preRun=[preRun];onPreRuns.push(...preRun)}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;if(ENVIRONMENT_IS_PTHREAD)return;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&&!ENVIRONMENT_IS_NODE){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(){assignWasmImports();var imports={env:wasmImports,wasi_snapshot_preview1:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;registerTLSInit(wasmExports["_emscripten_tls_init"]);assignWasmExports(wasmExports);wasmModule=module;return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"],result["module"])}var info=getWasmImports();var instantiateWasm=Module["instantiateWasm"];if(instantiateWasm){return new Promise(resolve=>{instantiateWasm(info,(inst,mod)=>resolve(receiveInstance(inst,mod)))})}if(ENVIRONMENT_IS_PTHREAD){var instance=new WebAssembly.Instance(wasmModule,getWasmImports());return receiveInstance(instance,wasmModule)}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 terminateWorker=worker=>{worker.terminate();worker.onmessage=e=>{}};var cleanupThread=pthread_ptr=>{var worker=PThread.pthreads[pthread_ptr];PThread.returnWorkerToPool(worker)};var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var dependenciesPromise=null;var resolveRunDependencies=async()=>dependenciesPromise;var runDependencies=0;var dependenciesPromiseResolve=null;var removeRunDependency=id=>{runDependencies--;Module["monitorRunDependencies"]?.(runDependencies);if(!runDependencies){dependenciesPromiseResolve()}};var addRunDependency=id=>{if(!runDependencies){dependenciesPromise=new Promise(resolve=>dependenciesPromiseResolve=resolve)}runDependencies++;Module["monitorRunDependencies"]?.(runDependencies)};var spawnThread=threadParams=>{var worker=PThread.getNewWorker();if(!worker){return 6}PThread.pthreads[threadParams.pthread_ptr]=worker;worker.pthread_ptr=threadParams.pthread_ptr;var msg={cmd:2,start_routine:threadParams.startRoutine,arg:threadParams.arg,pthread_ptr:threadParams.pthread_ptr};worker.postMessage(msg,threadParams.transferList);return 0};var runtimeKeepaliveCounter=0;var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var stackSave=()=>_emscripten_stack_get_current();var stackRestore=val=>__emscripten_stack_restore(val);var stackAlloc=sz=>__emscripten_stack_alloc(sz);var HEAPF64;var HEAP64;var proxyToMainThread=(funcIndex,emAsmAddr,proxyMode,...callArgs)=>{var bufSize=8*callArgs.length*2;var sp=stackSave();var args=stackAlloc(bufSize);var b=args>>3;for(var arg of callArgs){if(typeof arg=="bigint"){(growMemViews(),HEAP64)[b++]=1n;(growMemViews(),HEAP64)[b++]=arg}else{(growMemViews(),HEAP64)[b++]=0n;(growMemViews(),HEAPF64)[b++]=arg}}var rtn=__emscripten_run_js_on_main_thread(funcIndex,emAsmAddr,bufSize,args,proxyMode);stackRestore(sp);return rtn};function _proc_exit(code){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(0,0,1,code);EXITSTATUS=code;if(!keepRuntimeAlive()){PThread.terminateAllThreads();Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))}function exitOnMainThread(returnCode){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(1,0,0,returnCode);_exit(returnCode)}var exitJS=(status,implicit)=>{EXITSTATUS=status;if(ENVIRONMENT_IS_PTHREAD){exitOnMainThread(status);throw"unwind"}_proc_exit(status)};var _exit=exitJS;var waitAsyncPolyfilled=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;var HEAP32;var PThread={unusedWorkers:[],tlsInitFunctions:[],pthreads:{},init(){if(!ENVIRONMENT_IS_PTHREAD){PThread.initMainThread()}},initMainThread(){var pthreadPoolSize=8;while(pthreadPoolSize--){PThread.allocateUnusedWorker()}addOnPreRun(async()=>{var pthreadPoolReady=PThread.loadWasmModuleToAllWorkers();addRunDependency("loading-workers");await pthreadPoolReady;removeRunDependency("loading-workers")})},terminateAllThreads:()=>{for(var worker of Object.values(PThread.pthreads)){terminateWorker(worker)}for(var worker of PThread.unusedWorkers){terminateWorker(worker)}PThread.unusedWorkers=[];PThread.pthreads={}},clearMailboxAwait:pthread_ptr=>{if(!waitAsyncPolyfilled){Atomics.notify((growMemViews(),HEAP32),pthread_ptr>>2)}},terminateRuntime:()=>{PThread.terminateAllThreads();var pthread_ptr=_pthread_self();___set_thread_state(0,0,0,1);PThread.clearMailboxAwait(pthread_ptr)},returnWorkerToPool:worker=>{var pthread_ptr=worker.pthread_ptr;delete PThread.pthreads[pthread_ptr];PThread.unusedWorkers.push(worker);worker.pthread_ptr=0;PThread.clearMailboxAwait(pthread_ptr);__emscripten_thread_free_data(pthread_ptr)},threadInitTLS(){PThread.tlsInitFunctions.forEach(f=>f())},loadWasmModuleToWorker:worker=>new Promise(onFinishedLoading=>{worker.onmessage=e=>{var d=e.data;var cmd=d.cmd;if(d.targetThread&&d.targetThread!=_pthread_self()){var targetWorker=PThread.pthreads[d.targetThread];targetWorker?.postMessage(d);return}if(d==="setimmediate"||d==="_si"){worker.postMessage(d);return}switch(cmd){case 4:checkMailbox();break;case 5:spawnThread(d);break;case 6:callUserCallback(()=>cleanupThread(d.thread));break;case 3:if(ENVIRONMENT_IS_NODE&&!worker.strongref){worker.unref()}onFinishedLoading(worker);break;case 8:worker.onerror(d.error);break;case 9:Module[d.handler](...d.args);break;default:if(cmd)err(`worker sent an unknown command ${cmd}`)}};worker.onerror=e=>{var message="worker sent an error!";err(`${message} ${e.filename}:${e.lineno}: ${e.message}`);throw e};if(ENVIRONMENT_IS_NODE){worker.on("message",data=>worker.onmessage({data}));worker.on("error",e=>worker.onerror(e))}var handlers=[];var knownHandlers=["onExit","onAbort","print","printErr"];for(var handler of knownHandlers){if(Module.propertyIsEnumerable(handler)){handlers.push(handler)}}worker.postMessage({cmd:1,handlers,wasmMemory,wasmModule})}),async loadWasmModuleToAllWorkers(){if(ENVIRONMENT_IS_PTHREAD){return}let pthreadPoolReady=Promise.all(PThread.unusedWorkers.map(PThread.loadWasmModuleToWorker));return pthreadPoolReady},allocateUnusedWorker(){var worker;worker=new Worker(new URL("box3d.mjs",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread"});PThread.unusedWorkers.push(worker);return worker},getNewWorker(){if(PThread.unusedWorkers.length==0){var newWorker=PThread.allocateUnusedWorker();PThread.loadWasmModuleToWorker(newWorker)}return PThread.unusedWorkers.pop()}};var onPostRuns=[];var HEAPU32;function establishStackSpace(pthread_ptr){var stackHigh=(growMemViews(),HEAPU32)[pthread_ptr+48>>2];var stackSize=(growMemViews(),HEAPU32)[pthread_ptr+52>>2];var stackLow=stackHigh-stackSize;_emscripten_stack_set_limits(stackHigh,stackLow);stackRestore(stackHigh)}var wasmTableMirror=[];var getWasmTableEntry=funcPtr=>{var func=wasmTableMirror[funcPtr];if(!func){wasmTableMirror[funcPtr]=func=wasmTable.get(funcPtr)}return func};var invokeEntryPoint=(ptr,arg)=>{runtimeKeepaliveCounter=0;noExitRuntime=0;var result=getWasmTableEntry(ptr)(arg);function finish(result){if(keepRuntimeAlive()){EXITSTATUS=result;return}__emscripten_thread_exit(result)}finish(result)};var noExitRuntime=true;var registerTLSInit=tlsInitFunc=>PThread.tlsInitFunctions.push(tlsInitFunc);var wasmMemory;function pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(2,0,1,pthread_ptr,attr,startRoutine,arg);return ___pthread_create_js(pthread_ptr,attr,startRoutine,arg)}var _emscripten_has_threading_support=()=>!!globalThis.SharedArrayBuffer;var ___pthread_create_js=(pthread_ptr,attr,startRoutine,arg)=>{if(!_emscripten_has_threading_support()){return 6}var transferList=[];var error=0;if(ENVIRONMENT_IS_PTHREAD&&(!transferList.length||error)){return pthreadCreateProxied(pthread_ptr,attr,startRoutine,arg)}if(error)return error;var threadParams={startRoutine,pthread_ptr,arg,transferList};if(ENVIRONMENT_IS_PTHREAD){threadParams.cmd=5;postMessage(threadParams,transferList);return 0}return spawnThread(threadParams)};var __emscripten_init_main_thread_js=tb=>{var can_block=!ENVIRONMENT_IS_WEB;__emscripten_thread_init(tb,!ENVIRONMENT_IS_WORKER,1,can_block,1048576,false);PThread.threadInitTLS()};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var maybeExit=()=>{if(!keepRuntimeAlive()){try{if(ENVIRONMENT_IS_PTHREAD){if(_pthread_self())__emscripten_thread_exit(EXITSTATUS);return}_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{return func()}catch(e){handleException(e)}finally{maybeExit()}};var __emscripten_thread_mailbox_await=pthread_ptr=>{if(!waitAsyncPolyfilled){var wait=Atomics.waitAsync((growMemViews(),HEAP32),pthread_ptr>>2,pthread_ptr);wait.value.then(checkMailbox);var waitingAsync=pthread_ptr+112;Atomics.store((growMemViews(),HEAP32),waitingAsync>>2,1)}};var checkMailbox=()=>{var pthread_ptr=_pthread_self();if(!pthread_ptr)return;callUserCallback(()=>{__emscripten_thread_mailbox_await(pthread_ptr);__emscripten_check_mailbox()})};var __emscripten_notify_mailbox_postmessage=(targetThread,currThreadId)=>{if(targetThread==currThreadId){setTimeout(checkMailbox)}else if(ENVIRONMENT_IS_PTHREAD){postMessage({targetThread,cmd:4})}else{var worker=PThread.pthreads[targetThread];if(!worker){return}worker.postMessage({cmd:4})}};var proxiedJSCallArgs=[];var __emscripten_receive_on_main_thread_js=(funcIndex,emAsmAddr,callingThread,bufSize,args,ctx,ctxArgs)=>{proxiedJSCallArgs.length=0;var b=args>>3;var end=args+bufSize>>3;while(b<end){var arg;if((growMemViews(),HEAP64)[b++]){arg=(growMemViews(),HEAP64)[b++]}else{arg=(growMemViews(),HEAPF64)[b++]}proxiedJSCallArgs.push(arg)}var func=proxiedFunctionTable[funcIndex];PThread.currentProxiedOperationCallerThread=callingThread;var rtn=func(...proxiedJSCallArgs);PThread.currentProxiedOperationCallerThread=0;if(ctx){rtn.then(rtn=>__emscripten_run_js_on_main_thread_done(ctx,ctxArgs,rtn));return}return rtn};var __emscripten_thread_cleanup=thread=>{if(!ENVIRONMENT_IS_PTHREAD)cleanupThread(thread);else postMessage({cmd:6,thread})};var __emscripten_thread_set_strongref=thread=>{if(ENVIRONMENT_IS_NODE){var worker=PThread.pthreads[thread];worker.ref();worker.strongref=1}};var _emscripten_get_now=()=>performance.timeOrigin+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);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);(growMemViews(),HEAP64)[ptime>>3]=BigInt(nsec);return 0}var _emscripten_check_blocking_allowed=()=>{};var runtimeKeepalivePush=()=>{runtimeKeepaliveCounter+=1};var _emscripten_exit_with_live_runtime=()=>{runtimeKeepalivePush();throw"unwind"};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=(growMemViews(),HEAPU8).length;requestedSize>>>=0;if(requestedSize<=oldSize){return false}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.buffer instanceof ArrayBuffer?heapOrArray.subarray(idx,endPtr):heapOrArray.slice(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)}};function _fd_write(fd,iov,iovcnt,pnum){if(ENVIRONMENT_IS_PTHREAD)return proxyToMainThread(3,0,1,fd,iov,iovcnt,pnum);var num=0;for(var i=0;i<iovcnt;i++){var ptr=(growMemViews(),HEAPU32)[iov>>2];var len=(growMemViews(),HEAPU32)[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,(growMemViews(),HEAPU8)[ptr+j])}num+=len}(growMemViews(),HEAPU32)[pnum>>2]=num;return 0}var HEAPF32;PThread.init();{initMemory();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 proxiedFunctionTable=[_proc_exit,exitOnMainThread,pthreadCreateProxied,_fd_write];var _free,_bx_Scratch,_bx_Alloc,_malloc,_bx_Free,_bx_GetVersion,_bx_ScratchF64,_bx_IsDoublePrecision,_bx_GetRejectedSlotCount,_bx_Body_SetClipPlane,_bx_Body_GetClipPlane,_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_GetStackUsed,_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_BodyContactPointsF64Ptr,_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_SetFeatureKey,_bx_Body_GetFeatureKey,_bx_Body_GetShapeFeatureKey,_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_GetGeometryBytes,_bx_ShapeDesc_GetGeometryByteCount,_bx_ShapeDesc_CreateMeshFromBytes,_bx_ShapeDesc_CreateHeightFieldFromBytes,_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_SetInvokeContactCreation,_bx_ShapeDesc_GetInvokeContactCreation,_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_RayHitPointsF64Ptr,_bx_World_CastRay,_bx_World_CastShape,_bx_OverlapsPtr,_bx_World_OverlapShape,_bx_GeometryPtr,_bx_Body_GetShapeGeometry,__emscripten_tls_init,_pthread_self,__emscripten_thread_init,___set_thread_state,__emscripten_thread_crashed,__emscripten_run_js_on_main_thread_done,__emscripten_run_js_on_main_thread,__emscripten_thread_free_data,__emscripten_thread_exit,__emscripten_check_mailbox,_emscripten_stack_set_limits,__emscripten_stack_restore,__emscripten_stack_alloc,_emscripten_stack_get_current,__indirect_function_table,wasmTable;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_ScratchF64=Module["_bx_ScratchF64"]=wasmExports["bx_ScratchF64"];_bx_IsDoublePrecision=Module["_bx_IsDoublePrecision"]=wasmExports["bx_IsDoublePrecision"];_bx_GetRejectedSlotCount=Module["_bx_GetRejectedSlotCount"]=wasmExports["bx_GetRejectedSlotCount"];_bx_Body_SetClipPlane=Module["_bx_Body_SetClipPlane"]=wasmExports["bx_Body_SetClipPlane"];_bx_Body_GetClipPlane=Module["_bx_Body_GetClipPlane"]=wasmExports["bx_Body_GetClipPlane"];_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_GetStackUsed=Module["_bx_World_GetStackUsed"]=wasmExports["bx_World_GetStackUsed"];_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_BodyContactPointsF64Ptr=Module["_bx_BodyContactPointsF64Ptr"]=wasmExports["bx_BodyContactPointsF64Ptr"];_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_SetFeatureKey=Module["_bx_Body_SetFeatureKey"]=wasmExports["bx_Body_SetFeatureKey"];_bx_Body_GetFeatureKey=Module["_bx_Body_GetFeatureKey"]=wasmExports["bx_Body_GetFeatureKey"];_bx_Body_GetShapeFeatureKey=Module["_bx_Body_GetShapeFeatureKey"]=wasmExports["bx_Body_GetShapeFeatureKey"];_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_GetGeometryBytes=Module["_bx_ShapeDesc_GetGeometryBytes"]=wasmExports["bx_ShapeDesc_GetGeometryBytes"];_bx_ShapeDesc_GetGeometryByteCount=Module["_bx_ShapeDesc_GetGeometryByteCount"]=wasmExports["bx_ShapeDesc_GetGeometryByteCount"];_bx_ShapeDesc_CreateMeshFromBytes=Module["_bx_ShapeDesc_CreateMeshFromBytes"]=wasmExports["bx_ShapeDesc_CreateMeshFromBytes"];_bx_ShapeDesc_CreateHeightFieldFromBytes=Module["_bx_ShapeDesc_CreateHeightFieldFromBytes"]=wasmExports["bx_ShapeDesc_CreateHeightFieldFromBytes"];_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_SetInvokeContactCreation=Module["_bx_ShapeDesc_SetInvokeContactCreation"]=wasmExports["bx_ShapeDesc_SetInvokeContactCreation"];_bx_ShapeDesc_GetInvokeContactCreation=Module["_bx_ShapeDesc_GetInvokeContactCreation"]=wasmExports["bx_ShapeDesc_GetInvokeContactCreation"];_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_RayHitPointsF64Ptr=Module["_bx_RayHitPointsF64Ptr"]=wasmExports["bx_RayHitPointsF64Ptr"];_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"];__emscripten_tls_init=wasmExports["_emscripten_tls_init"];_pthread_self=wasmExports["pthread_self"];__emscripten_thread_init=wasmExports["_emscripten_thread_init"];___set_thread_state=wasmExports["__set_thread_state"];__emscripten_thread_crashed=wasmExports["_emscripten_thread_crashed"];__emscripten_run_js_on_main_thread_done=wasmExports["_emscripten_run_js_on_main_thread_done"];__emscripten_run_js_on_main_thread=wasmExports["_emscripten_run_js_on_main_thread"];__emscripten_thread_free_data=wasmExports["_emscripten_thread_free_data"];__emscripten_thread_exit=wasmExports["_emscripten_thread_exit"];__emscripten_check_mailbox=wasmExports["_emscripten_check_mailbox"];_emscripten_stack_set_limits=wasmExports["emscripten_stack_set_limits"];__emscripten_stack_restore=wasmExports["_emscripten_stack_restore"];__emscripten_stack_alloc=wasmExports["_emscripten_stack_alloc"];_emscripten_stack_get_current=wasmExports["emscripten_stack_get_current"];__indirect_function_table=wasmTable=wasmExports["__indirect_function_table"]}var wasmImports;function assignWasmImports(){wasmImports={__pthread_create_js:___pthread_create_js,_emscripten_init_main_thread_js:__emscripten_init_main_thread_js,_emscripten_notify_mailbox_postmessage:__emscripten_notify_mailbox_postmessage,_emscripten_receive_on_main_thread_js:__emscripten_receive_on_main_thread_js,_emscripten_thread_cleanup:__emscripten_thread_cleanup,_emscripten_thread_mailbox_await:__emscripten_thread_mailbox_await,_emscripten_thread_set_strongref:__emscripten_thread_set_strongref,clock_time_get:_clock_time_get,emscripten_check_blocking_allowed:_emscripten_check_blocking_allowed,emscripten_exit_with_live_runtime:_emscripten_exit_with_live_runtime,emscripten_get_now:_emscripten_get_now,emscripten_resize_heap:_emscripten_resize_heap,exit:_exit,fd_write:_fd_write,memory:wasmMemory}}async function run(){if(ENVIRONMENT_IS_PTHREAD){initRuntime();return}preRun();if(runDependencies){await resolveRunDependencies()}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;if(!ENVIRONMENT_IS_PTHREAD){wasmExports=await createWasm();await run()}
|
|
2
|
+
;return Module}export default Box3D;var isPthread=globalThis.name=="em-pthread";var isNode=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(isNode)isPthread=(await import("node:worker_threads")).workerData==="em-pthread";isPthread&&Box3D();
|
|
Binary file
|
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* The module exposes a flat, handle based C API (see src/box3d_shim.c). Bodies, shape descriptions and joints
|
|
5
5
|
* are integer slots. Vectors and quaternions are passed as individual floats. Functions that return more than one
|
|
6
6
|
* value write into the scratch buffer returned by `_bx_Scratch()` (64 floats), read it through `HEAPF32`.
|
|
7
|
+
*
|
|
8
|
+
* World positions cross in doubles: the entry points that take one take doubles, and those that give one back also
|
|
9
|
+
* write it as doubles, to `_bx_ScratchF64()` or to a double buffer beside their float records (read through
|
|
10
|
+
* `HEAPF64`). The `-f64` builds (BOX3D_DOUBLE_PRECISION) hold positions in doubles, so a body far from the origin moves
|
|
11
|
+
* as it does near it; the default builds hold floats, and their doubles are those floats widened.
|
|
7
12
|
*/
|
|
8
13
|
|
|
9
14
|
export interface Box3DModuleOptions {
|
|
@@ -19,6 +24,7 @@ export interface Box3DModuleOptions {
|
|
|
19
24
|
/** Emscripten heap views. Do not cache them: they are replaced when the memory grows. */
|
|
20
25
|
export interface Box3DHeap {
|
|
21
26
|
HEAPF32: Float32Array;
|
|
27
|
+
HEAPF64: Float64Array;
|
|
22
28
|
HEAP32: Int32Array;
|
|
23
29
|
HEAPU32: Uint32Array;
|
|
24
30
|
HEAPU8: Uint8Array;
|
|
@@ -29,6 +35,10 @@ export interface Box3DExports {
|
|
|
29
35
|
_malloc(bytes: number): number;
|
|
30
36
|
_free(ptr: number): void;
|
|
31
37
|
_bx_Scratch(): number;
|
|
38
|
+
/** 16 doubles: world positions given back, see `_bx_Body_GetTransform`. */
|
|
39
|
+
_bx_ScratchF64(): number;
|
|
40
|
+
/** 1 in an `-f64` build, which holds world positions in doubles. */
|
|
41
|
+
_bx_IsDoublePrecision(): number;
|
|
32
42
|
_bx_Alloc(bytes: number): number;
|
|
33
43
|
_bx_Free(ptr: number): void;
|
|
34
44
|
/** major * 10000 + minor * 100 + revision */
|
|
@@ -52,6 +62,8 @@ export interface Box3DExports {
|
|
|
52
62
|
_bx_World_GetAwakeBodyCount(world: number): number;
|
|
53
63
|
/** Joint force/torque threshold events from the last step (0 with the default thresholds). */
|
|
54
64
|
_bx_World_GetJointEventCount(world: number): number;
|
|
65
|
+
/** The most the world's step stack has held at once, in bytes. */
|
|
66
|
+
_bx_World_GetStackUsed(world: number): number;
|
|
55
67
|
/** scratch: [bodyCount, shapeCount, contactCount, jointCount, islandCount, stepMs, collideMs, solveMs] */
|
|
56
68
|
_bx_World_GetStats(world: number): void;
|
|
57
69
|
|
|
@@ -69,7 +81,7 @@ export interface Box3DExports {
|
|
|
69
81
|
_bx_Body_SetType(body: number, type: number): void;
|
|
70
82
|
_bx_Body_GetType(body: number): number;
|
|
71
83
|
_bx_Body_SetTransform(body: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number): void;
|
|
72
|
-
/** scratch: [px, py, pz, qx, qy, qz, qw] */
|
|
84
|
+
/** scratch: [px, py, pz, qx, qy, qz, qw] as floats; scratchF64: [px, py, pz] as the build holds them */
|
|
73
85
|
_bx_Body_GetTransform(body: number): void;
|
|
74
86
|
_bx_Body_SetTargetTransform(body: number, px: number, py: number, pz: number, qx: number, qy: number, qz: number, qw: number, dt: number): void;
|
|
75
87
|
_bx_Body_SetLinearVelocity(body: number, x: number, y: number, z: number): void;
|
|
@@ -102,6 +114,14 @@ export interface Box3DExports {
|
|
|
102
114
|
* and a plastic one (1) keeps its overlap instead of pushing out. A `maxForce` of zero or less makes it rigid.
|
|
103
115
|
*/
|
|
104
116
|
_bx_Body_SetShapeCrush(body: number, index: number, maxForce: number, plastic: number): void;
|
|
117
|
+
/**
|
|
118
|
+
* Clips the body's contacts with the plane (nx, ny, nz, d) (wasm/patches/0006), normalized: contact points where
|
|
119
|
+
* n.p + d > -2 * linearSlop, there or one separation toward the other shape, are dropped from its contacts with shapes whose category bits meet `mask`. `enabled` 0
|
|
120
|
+
* removes it. Wakes the body.
|
|
121
|
+
*/
|
|
122
|
+
_bx_Body_SetClipPlane(body: number, enabled: number, nx: number, ny: number, nz: number, d: number, mask: number): void;
|
|
123
|
+
/** scratchF64: [enabled, nx, ny, nz, d, mask] */
|
|
124
|
+
_bx_Body_GetClipPlane(body: number): void;
|
|
105
125
|
/** scratch: [maxForce, plastic] for the body's shape `index`, zeros when it is rigid or there is no such shape. */
|
|
106
126
|
_bx_Body_GetShapeCrush(body: number, index: number): void;
|
|
107
127
|
/**
|
|
@@ -113,6 +133,8 @@ export interface Box3DExports {
|
|
|
113
133
|
*/
|
|
114
134
|
_bx_Body_GetContacts(body: number): number;
|
|
115
135
|
_bx_BodyContactsPtr(): number;
|
|
136
|
+
/** The points of the records `_bx_Body_GetContacts` wrote, as doubles: 12 a record, [x, y, z] for each of its 4. */
|
|
137
|
+
_bx_BodyContactPointsF64Ptr(): number;
|
|
116
138
|
/** Per-shape handles: each changes one shape, resets only its contacts, and keeps every shape's index. */
|
|
117
139
|
/** Replaces shape `index` with the hull of `pointCount` points (xyz floats at `points`) in the body's frame; 1 if done. */
|
|
118
140
|
_bx_Body_SetShapeHull(body: number, index: number, points: number, pointCount: number): number;
|
|
@@ -151,6 +173,15 @@ export interface Box3DExports {
|
|
|
151
173
|
_bx_Body_ComputeShapeMassData(body: number): void;
|
|
152
174
|
_bx_Body_ApplyMassFromShapes(body: number): void;
|
|
153
175
|
_bx_Body_GetShapeCount(body: number): number;
|
|
176
|
+
/**
|
|
177
|
+
* Gives the body a feature key (an integer from 1 to 2^44 - 1; 0 takes it off) and each of its shapes, now and when
|
|
178
|
+
* it is next shaped, (key << 20) | its index. New contacts are made, continuous collision sweeps and a closest
|
|
179
|
+
* cast's ties are broken in the order of these keys, so keyed statics pair the same whatever order they were made in.
|
|
180
|
+
*/
|
|
181
|
+
_bx_Body_SetFeatureKey(body: number, key: number): void;
|
|
182
|
+
_bx_Body_GetFeatureKey(body: number): number;
|
|
183
|
+
/** Shape `index`'s own feature key, as Box3D orders by it (exact up to 2^53). */
|
|
184
|
+
_bx_Body_GetShapeFeatureKey(body: number, index: number): number;
|
|
154
185
|
/** Begin/end touch events and hit events on the body's shapes, enabled separately. */
|
|
155
186
|
_bx_Body_SetEventFlags(body: number, contactEvents: number, hitEvents: number): void;
|
|
156
187
|
/** Bit 1: begin/end touch events, bit 2: hit events. */
|
|
@@ -181,6 +212,18 @@ export interface Box3DExports {
|
|
|
181
212
|
/** heights: countX * countZ floats indexed [z * countX + x]; materials: one byte a cell, (countX - 1) * (countZ - 1),
|
|
182
213
|
* or 0 for none; local offset (ox, oy, oz) */
|
|
183
214
|
_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;
|
|
215
|
+
/**
|
|
216
|
+
* Where a mesh or height field description's data starts, and how many bytes it has (0 for any other description).
|
|
217
|
+
* Box3D keeps either as one block addressed by offsets, with no pointers in it, so the bytes can be copied to another
|
|
218
|
+
* instance of the same build (one with no world, on a worker) and made into a shape there with
|
|
219
|
+
* `_bx_ShapeDesc_CreateMeshFromBytes` or `_bx_ShapeDesc_CreateHeightFieldFromBytes`.
|
|
220
|
+
*/
|
|
221
|
+
_bx_ShapeDesc_GetGeometryBytes(desc: number): number;
|
|
222
|
+
_bx_ShapeDesc_GetGeometryByteCount(desc: number): number;
|
|
223
|
+
/** A mesh description from a copy of a mesh block put at `bytes`, with the description's scale. 0 if it is not one. */
|
|
224
|
+
_bx_ShapeDesc_CreateMeshFromBytes(bytes: number, byteCount: number, sx: number, sy: number, sz: number): number;
|
|
225
|
+
/** A height field description from a copy of a height field block put at `bytes`, with a local offset. 0 if it is not one. */
|
|
226
|
+
_bx_ShapeDesc_CreateHeightFieldFromBytes(bytes: number, byteCount: number, ox: number, oy: number, oz: number): number;
|
|
184
227
|
_bx_ShapeDesc_CreateContainer(): number;
|
|
185
228
|
_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;
|
|
186
229
|
_bx_ShapeDesc_RemoveChild(parent: number, index: number): void;
|
|
@@ -198,6 +241,14 @@ export interface Box3DExports {
|
|
|
198
241
|
_bx_ShapeDesc_SetRollingResistance(desc: number, value: number): void;
|
|
199
242
|
_bx_ShapeDesc_SetSensor(desc: number, flag: number): void;
|
|
200
243
|
_bx_ShapeDesc_IsSensor(desc: number): number;
|
|
244
|
+
/**
|
|
245
|
+
* 1 (the default): a static shape made from this description looks for its own pairs on the next step. 0: it never
|
|
246
|
+
* enters the broad phase's move buffer and waits for a moving shape to find it, which saves the step stack it would
|
|
247
|
+
* reserve and pairs a static made late on the same step as one made at the start. Off on a container, it is off for
|
|
248
|
+
* every shape made from its children.
|
|
249
|
+
*/
|
|
250
|
+
_bx_ShapeDesc_SetInvokeContactCreation(desc: number, flag: number): void;
|
|
251
|
+
_bx_ShapeDesc_GetInvokeContactCreation(desc: number): number;
|
|
201
252
|
/** scratch: [minx, miny, minz, maxx, maxy, maxz] */
|
|
202
253
|
_bx_ShapeDesc_GetAABB(desc: number): void;
|
|
203
254
|
_bx_ShapeDesc_Destroy(desc: number): void;
|
|
@@ -240,6 +291,8 @@ export interface Box3DExports {
|
|
|
240
291
|
|
|
241
292
|
// queries
|
|
242
293
|
_bx_RayHitsPtr(): number;
|
|
294
|
+
/** The hit points of the last ray or shape cast, as doubles: [x, y, z] a hit, beside `_bx_RayHitsPtr`'s records. */
|
|
295
|
+
_bx_RayHitPointsF64Ptr(): number;
|
|
243
296
|
/** Returns the hit count; hits are 11 floats each: [px, py, pz, nx, ny, nz, fraction, bodySlot, shapeDesc, triangleIndex, shapeIndex] */
|
|
244
297
|
_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
298
|
/**
|