UNPKG

@dimforge/rapier2d-compat

Version:

2-dimensional physics engine in Rust - official JS bindings. Compatibility package with inlined webassembly as base64.

1,576 lines (1,504 loc) 183 kB
let wasm; const heap = new Array(128).fill(undefined); heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } let heap_next = heap.length; function addHeapObject(obj) { if (heap_next === heap.length) heap.push(heap.length + 1); const idx = heap_next; heap_next = heap[idx]; heap[idx] = obj; return idx; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { wasm.__wbindgen_export_0(addHeapObject(e)); } } function isLikeNone(x) { return x === undefined || x === null; } let cachedDataViewMemory0 = null; function getDataViewMemory0() { if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { cachedDataViewMemory0 = new DataView(wasm.memory.buffer); } return cachedDataViewMemory0; } function dropObject(idx) { if (idx < 132) return; heap[idx] = heap_next; heap_next = idx; } function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret; } const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8ArrayMemory0; } function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0; return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } /** * @returns {string} */ export function version() { let deferred1_0; let deferred1_1; try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.version(retptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); deferred1_0 = r0; deferred1_1 = r1; return getStringFromWasm0(r0, r1); } finally { wasm.__wbindgen_add_to_stack_pointer(16); wasm.__wbindgen_export_1(deferred1_0, deferred1_1, 1); } } /** * @param {number} extra_bytes_count */ export function reserve_memory(extra_bytes_count) { wasm.reserve_memory(extra_bytes_count); } function _assertClass(instance, klass) { if (!(instance instanceof klass)) { throw new Error(`expected instance of ${klass.name}`); } } let stack_pointer = 128; function addBorrowedObject(obj) { if (stack_pointer == 1) throw new Error('out of js stack'); heap[--stack_pointer] = obj; return stack_pointer; } let cachedInt32ArrayMemory0 = null; function getInt32ArrayMemory0() { if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) { cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer); } return cachedInt32ArrayMemory0; } function getArrayI32FromWasm0(ptr, len) { ptr = ptr >>> 0; return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); } let cachedFloat32ArrayMemory0 = null; function getFloat32ArrayMemory0() { if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) { cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer); } return cachedFloat32ArrayMemory0; } function getArrayF32FromWasm0(ptr, len) { ptr = ptr >>> 0; return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); } let cachedUint32ArrayMemory0 = null; function getUint32ArrayMemory0() { if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) { cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer); } return cachedUint32ArrayMemory0; } function getArrayU32FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); } let WASM_VECTOR_LEN = 0; function passArray32ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 4, 4) >>> 0; getUint32ArrayMemory0().set(arg, ptr / 4); WASM_VECTOR_LEN = arg.length; return ptr; } function passArrayF32ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 4, 4) >>> 0; getFloat32ArrayMemory0().set(arg, ptr / 4); WASM_VECTOR_LEN = arg.length; return ptr; } /** * @enum {0 | 1 | 2} */ export const RawFeatureType = Object.freeze({ Vertex: 0, "0": "Vertex", Face: 1, "1": "Face", Unknown: 2, "2": "Unknown", }); /** * @enum {0 | 1 | 2} */ export const RawJointAxis = Object.freeze({ LinX: 0, "0": "LinX", LinY: 1, "1": "LinY", AngX: 2, "2": "AngX", }); /** * @enum {0 | 1 | 2 | 3 | 4 | 5} */ export const RawJointType = Object.freeze({ Revolute: 0, "0": "Revolute", Fixed: 1, "1": "Fixed", Prismatic: 2, "2": "Prismatic", Rope: 3, "3": "Rope", Spring: 4, "4": "Spring", Generic: 5, "5": "Generic", }); /** * @enum {0 | 1} */ export const RawMotorModel = Object.freeze({ AccelerationBased: 0, "0": "AccelerationBased", ForceBased: 1, "1": "ForceBased", }); /** * @enum {0 | 1 | 2 | 3} */ export const RawRigidBodyType = Object.freeze({ Dynamic: 0, "0": "Dynamic", Fixed: 1, "1": "Fixed", KinematicPositionBased: 2, "2": "KinematicPositionBased", KinematicVelocityBased: 3, "3": "KinematicVelocityBased", }); /** * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14} */ export const RawShapeType = Object.freeze({ Ball: 0, "0": "Ball", Cuboid: 1, "1": "Cuboid", Capsule: 2, "2": "Capsule", Segment: 3, "3": "Segment", Polyline: 4, "4": "Polyline", Triangle: 5, "5": "Triangle", TriMesh: 6, "6": "TriMesh", HeightField: 7, "7": "HeightField", Compound: 8, "8": "Compound", ConvexPolygon: 9, "9": "ConvexPolygon", RoundCuboid: 10, "10": "RoundCuboid", RoundTriangle: 11, "11": "RoundTriangle", RoundConvexPolygon: 12, "12": "RoundConvexPolygon", HalfSpace: 13, "13": "HalfSpace", Voxels: 14, "14": "Voxels", }); const RawBroadPhaseFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawbroadphase_free(ptr >>> 0, 1)); export class RawBroadPhase { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(RawBroadPhase.prototype); obj.__wbg_ptr = ptr; RawBroadPhaseFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawBroadPhaseFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawbroadphase_free(ptr, 0); } constructor() { const ret = wasm.rawbroadphase_new(); this.__wbg_ptr = ret >>> 0; RawBroadPhaseFinalization.register(this, this.__wbg_ptr, this); return this; } } const RawCCDSolverFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawccdsolver_free(ptr >>> 0, 1)); export class RawCCDSolver { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawCCDSolverFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawccdsolver_free(ptr, 0); } constructor() { const ret = wasm.rawccdsolver_new(); this.__wbg_ptr = ret >>> 0; RawCCDSolverFinalization.register(this, this.__wbg_ptr, this); return this; } } const RawCharacterCollisionFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawcharactercollision_free(ptr >>> 0, 1)); export class RawCharacterCollision { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawCharacterCollisionFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawcharactercollision_free(ptr, 0); } constructor() { const ret = wasm.rawcharactercollision_new(); this.__wbg_ptr = ret >>> 0; RawCharacterCollisionFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @returns {number} */ handle() { const ret = wasm.rawcharactercollision_handle(this.__wbg_ptr); return ret; } /** * @returns {RawVector} */ translationDeltaApplied() { const ret = wasm.rawcharactercollision_translationDeltaApplied(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ translationDeltaRemaining() { const ret = wasm.rawcharactercollision_translationDeltaRemaining(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {number} */ toi() { const ret = wasm.rawcharactercollision_toi(this.__wbg_ptr); return ret; } /** * @returns {RawVector} */ worldWitness1() { const ret = wasm.rawcharactercollision_worldWitness1(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ worldWitness2() { const ret = wasm.rawcharactercollision_worldWitness2(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ worldNormal1() { const ret = wasm.rawcharactercollision_worldNormal1(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ worldNormal2() { const ret = wasm.rawcharactercollision_worldNormal2(this.__wbg_ptr); return RawVector.__wrap(ret); } } const RawColliderSetFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawcolliderset_free(ptr >>> 0, 1)); export class RawColliderSet { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(RawColliderSet.prototype); obj.__wbg_ptr = ptr; RawColliderSetFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawColliderSetFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawcolliderset_free(ptr, 0); } /** * The world-space translation of this collider. * @param {number} handle * @returns {RawVector} */ coTranslation(handle) { const ret = wasm.rawcolliderset_coTranslation(this.__wbg_ptr, handle); return RawVector.__wrap(ret); } /** * The world-space orientation of this collider. * @param {number} handle * @returns {RawRotation} */ coRotation(handle) { const ret = wasm.rawcolliderset_coRotation(this.__wbg_ptr, handle); return RawRotation.__wrap(ret); } /** * Sets the translation of this collider. * * # Parameters * - `x`: the world-space position of the collider along the `x` axis. * - `y`: the world-space position of the collider along the `y` axis. * - `wakeUp`: forces the collider to wake-up so it is properly affected by forces if it * wasn't moving before modifying its position. * @param {number} handle * @param {number} x * @param {number} y */ coSetTranslation(handle, x, y) { wasm.rawcolliderset_coSetTranslation(this.__wbg_ptr, handle, x, y); } /** * @param {number} handle * @param {number} x * @param {number} y */ coSetTranslationWrtParent(handle, x, y) { wasm.rawcolliderset_coSetTranslationWrtParent(this.__wbg_ptr, handle, x, y); } /** * Sets the rotation angle of this collider. * * # Parameters * - `angle`: the rotation angle, in radians. * - `wakeUp`: forces the collider to wake-up so it is properly affected by forces if it * wasn't moving before modifying its position. * @param {number} handle * @param {number} angle */ coSetRotation(handle, angle) { wasm.rawcolliderset_coSetRotation(this.__wbg_ptr, handle, angle); } /** * @param {number} handle * @param {number} angle */ coSetRotationWrtParent(handle, angle) { wasm.rawcolliderset_coSetRotationWrtParent(this.__wbg_ptr, handle, angle); } /** * Is this collider a sensor? * @param {number} handle * @returns {boolean} */ coIsSensor(handle) { const ret = wasm.rawcolliderset_coIsSensor(this.__wbg_ptr, handle); return ret !== 0; } /** * The type of the shape of this collider. * @param {number} handle * @returns {RawShapeType} */ coShapeType(handle) { const ret = wasm.rawcolliderset_coShapeType(this.__wbg_ptr, handle); return ret; } /** * @param {number} handle * @returns {RawVector | undefined} */ coHalfspaceNormal(handle) { const ret = wasm.rawcolliderset_coHalfspaceNormal(this.__wbg_ptr, handle); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * The half-extents of this collider if it is has a cuboid shape. * @param {number} handle * @returns {RawVector | undefined} */ coHalfExtents(handle) { const ret = wasm.rawcolliderset_coHalfExtents(this.__wbg_ptr, handle); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * Set the half-extents of this collider if it has a cuboid shape. * @param {number} handle * @param {RawVector} newHalfExtents */ coSetHalfExtents(handle, newHalfExtents) { _assertClass(newHalfExtents, RawVector); wasm.rawcolliderset_coSetHalfExtents(this.__wbg_ptr, handle, newHalfExtents.__wbg_ptr); } /** * The radius of this collider if it is a ball, capsule, cylinder, or cone shape. * @param {number} handle * @returns {number | undefined} */ coRadius(handle) { const ret = wasm.rawcolliderset_coRadius(this.__wbg_ptr, handle); return ret === 0x100000001 ? undefined : ret; } /** * Set the radius of this collider if it is a ball, capsule, cylinder, or cone shape. * @param {number} handle * @param {number} newRadius */ coSetRadius(handle, newRadius) { wasm.rawcolliderset_coSetRadius(this.__wbg_ptr, handle, newRadius); } /** * The half height of this collider if it is a capsule, cylinder, or cone shape. * @param {number} handle * @returns {number | undefined} */ coHalfHeight(handle) { const ret = wasm.rawcolliderset_coHalfHeight(this.__wbg_ptr, handle); return ret === 0x100000001 ? undefined : ret; } /** * Set the half height of this collider if it is a capsule, cylinder, or cone shape. * @param {number} handle * @param {number} newHalfheight */ coSetHalfHeight(handle, newHalfheight) { wasm.rawcolliderset_coSetHalfHeight(this.__wbg_ptr, handle, newHalfheight); } /** * The radius of the round edges of this collider. * @param {number} handle * @returns {number | undefined} */ coRoundRadius(handle) { const ret = wasm.rawcolliderset_coRoundRadius(this.__wbg_ptr, handle); return ret === 0x100000001 ? undefined : ret; } /** * Set the radius of the round edges of this collider. * @param {number} handle * @param {number} newBorderRadius */ coSetRoundRadius(handle, newBorderRadius) { wasm.rawcolliderset_coSetRoundRadius(this.__wbg_ptr, handle, newBorderRadius); } /** * @param {number} handle * @returns {Int32Array | undefined} */ coVoxelData(handle) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.rawcolliderset_coVoxelData(retptr, this.__wbg_ptr, handle); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getArrayI32FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_1(r0, r1 * 4, 4); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number} handle * @returns {RawVector | undefined} */ coVoxelSize(handle) { const ret = wasm.rawcolliderset_coVoxelSize(this.__wbg_ptr, handle); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * @param {number} handle * @param {number} ix * @param {number} iy * @param {boolean} filled */ coSetVoxel(handle, ix, iy, filled) { wasm.rawcolliderset_coSetVoxel(this.__wbg_ptr, handle, ix, iy, filled); } /** * @param {number} handle1 * @param {number} handle2 * @param {number} ix * @param {number} iy * @param {number} shift_x * @param {number} shift_y */ coPropagateVoxelChange(handle1, handle2, ix, iy, shift_x, shift_y) { wasm.rawcolliderset_coPropagateVoxelChange(this.__wbg_ptr, handle1, handle2, ix, iy, shift_x, shift_y); } /** * @param {number} handle1 * @param {number} handle2 * @param {number} shift_x * @param {number} shift_y */ coCombineVoxelStates(handle1, handle2, shift_x, shift_y) { wasm.rawcolliderset_coCombineVoxelStates(this.__wbg_ptr, handle1, handle2, shift_x, shift_y); } /** * The vertices of this triangle mesh, polyline, convex polyhedron, segment, triangle or convex polyhedron, if it is one. * @param {number} handle * @returns {Float32Array | undefined} */ coVertices(handle) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.rawcolliderset_coVertices(retptr, this.__wbg_ptr, handle); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getArrayF32FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_1(r0, r1 * 4, 4); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * The indices of this triangle mesh, polyline, or convex polyhedron, if it is one. * @param {number} handle * @returns {Uint32Array | undefined} */ coIndices(handle) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.rawcolliderset_coIndices(retptr, this.__wbg_ptr, handle); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getArrayU32FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_1(r0, r1 * 4, 4); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number} handle * @returns {number | undefined} */ coTriMeshFlags(handle) { const ret = wasm.rawcolliderset_coTriMeshFlags(this.__wbg_ptr, handle); return ret === 0x100000001 ? undefined : ret; } /** * The height of this heightfield if it is one. * @param {number} handle * @returns {Float32Array | undefined} */ coHeightfieldHeights(handle) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.rawcolliderset_coHeightfieldHeights(retptr, this.__wbg_ptr, handle); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); let v1; if (r0 !== 0) { v1 = getArrayF32FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_1(r0, r1 * 4, 4); } return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * The scaling factor applied of this heightfield if it is one. * @param {number} handle * @returns {RawVector | undefined} */ coHeightfieldScale(handle) { const ret = wasm.rawcolliderset_coHeightfieldScale(this.__wbg_ptr, handle); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * The unique integer identifier of the collider this collider is attached to. * @param {number} handle * @returns {number | undefined} */ coParent(handle) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.rawcolliderset_coParent(retptr, this.__wbg_ptr, handle); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true); return r0 === 0 ? undefined : r2; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number} handle * @param {boolean} enabled */ coSetEnabled(handle, enabled) { wasm.rawcolliderset_coSetEnabled(this.__wbg_ptr, handle, enabled); } /** * @param {number} handle * @returns {boolean} */ coIsEnabled(handle) { const ret = wasm.rawcolliderset_coIsEnabled(this.__wbg_ptr, handle); return ret !== 0; } /** * @param {number} handle * @param {number} contact_skin */ coSetContactSkin(handle, contact_skin) { wasm.rawcolliderset_coSetContactSkin(this.__wbg_ptr, handle, contact_skin); } /** * @param {number} handle * @returns {number} */ coContactSkin(handle) { const ret = wasm.rawcolliderset_coContactSkin(this.__wbg_ptr, handle); return ret; } /** * The friction coefficient of this collider. * @param {number} handle * @returns {number} */ coFriction(handle) { const ret = wasm.rawcolliderset_coFriction(this.__wbg_ptr, handle); return ret; } /** * The restitution coefficient of this collider. * @param {number} handle * @returns {number} */ coRestitution(handle) { const ret = wasm.rawcolliderset_coRestitution(this.__wbg_ptr, handle); return ret; } /** * The density of this collider. * @param {number} handle * @returns {number} */ coDensity(handle) { const ret = wasm.rawcolliderset_coDensity(this.__wbg_ptr, handle); return ret; } /** * The mass of this collider. * @param {number} handle * @returns {number} */ coMass(handle) { const ret = wasm.rawcolliderset_coMass(this.__wbg_ptr, handle); return ret; } /** * The volume of this collider. * @param {number} handle * @returns {number} */ coVolume(handle) { const ret = wasm.rawcolliderset_coVolume(this.__wbg_ptr, handle); return ret; } /** * The collision groups of this collider. * @param {number} handle * @returns {number} */ coCollisionGroups(handle) { const ret = wasm.rawcolliderset_coCollisionGroups(this.__wbg_ptr, handle); return ret >>> 0; } /** * The solver groups of this collider. * @param {number} handle * @returns {number} */ coSolverGroups(handle) { const ret = wasm.rawcolliderset_coSolverGroups(this.__wbg_ptr, handle); return ret >>> 0; } /** * The physics hooks enabled for this collider. * @param {number} handle * @returns {number} */ coActiveHooks(handle) { const ret = wasm.rawcolliderset_coActiveHooks(this.__wbg_ptr, handle); return ret >>> 0; } /** * The collision types enabled for this collider. * @param {number} handle * @returns {number} */ coActiveCollisionTypes(handle) { const ret = wasm.rawcolliderset_coActiveCollisionTypes(this.__wbg_ptr, handle); return ret; } /** * The events enabled for this collider. * @param {number} handle * @returns {number} */ coActiveEvents(handle) { const ret = wasm.rawcolliderset_coActiveEvents(this.__wbg_ptr, handle); return ret >>> 0; } /** * The total force magnitude beyond which a contact force event can be emitted. * @param {number} handle * @returns {number} */ coContactForceEventThreshold(handle) { const ret = wasm.rawcolliderset_coContactForceEventThreshold(this.__wbg_ptr, handle); return ret; } /** * @param {number} handle * @param {RawVector} point * @returns {boolean} */ coContainsPoint(handle, point) { _assertClass(point, RawVector); const ret = wasm.rawcolliderset_coContainsPoint(this.__wbg_ptr, handle, point.__wbg_ptr); return ret !== 0; } /** * @param {number} handle * @param {RawVector} colliderVel * @param {RawShape} shape2 * @param {RawVector} shape2Pos * @param {RawRotation} shape2Rot * @param {RawVector} shape2Vel * @param {number} target_distance * @param {number} maxToi * @param {boolean} stop_at_penetration * @returns {RawShapeCastHit | undefined} */ coCastShape(handle, colliderVel, shape2, shape2Pos, shape2Rot, shape2Vel, target_distance, maxToi, stop_at_penetration) { _assertClass(colliderVel, RawVector); _assertClass(shape2, RawShape); _assertClass(shape2Pos, RawVector); _assertClass(shape2Rot, RawRotation); _assertClass(shape2Vel, RawVector); const ret = wasm.rawcolliderset_coCastShape(this.__wbg_ptr, handle, colliderVel.__wbg_ptr, shape2.__wbg_ptr, shape2Pos.__wbg_ptr, shape2Rot.__wbg_ptr, shape2Vel.__wbg_ptr, target_distance, maxToi, stop_at_penetration); return ret === 0 ? undefined : RawShapeCastHit.__wrap(ret); } /** * @param {number} handle * @param {RawVector} collider1Vel * @param {number} collider2handle * @param {RawVector} collider2Vel * @param {number} target_distance * @param {number} max_toi * @param {boolean} stop_at_penetration * @returns {RawColliderShapeCastHit | undefined} */ coCastCollider(handle, collider1Vel, collider2handle, collider2Vel, target_distance, max_toi, stop_at_penetration) { _assertClass(collider1Vel, RawVector); _assertClass(collider2Vel, RawVector); const ret = wasm.rawcolliderset_coCastCollider(this.__wbg_ptr, handle, collider1Vel.__wbg_ptr, collider2handle, collider2Vel.__wbg_ptr, target_distance, max_toi, stop_at_penetration); return ret === 0 ? undefined : RawColliderShapeCastHit.__wrap(ret); } /** * @param {number} handle * @param {RawShape} shape2 * @param {RawVector} shapePos2 * @param {RawRotation} shapeRot2 * @returns {boolean} */ coIntersectsShape(handle, shape2, shapePos2, shapeRot2) { _assertClass(shape2, RawShape); _assertClass(shapePos2, RawVector); _assertClass(shapeRot2, RawRotation); const ret = wasm.rawcolliderset_coIntersectsShape(this.__wbg_ptr, handle, shape2.__wbg_ptr, shapePos2.__wbg_ptr, shapeRot2.__wbg_ptr); return ret !== 0; } /** * @param {number} handle * @param {RawShape} shape2 * @param {RawVector} shapePos2 * @param {RawRotation} shapeRot2 * @param {number} prediction * @returns {RawShapeContact | undefined} */ coContactShape(handle, shape2, shapePos2, shapeRot2, prediction) { _assertClass(shape2, RawShape); _assertClass(shapePos2, RawVector); _assertClass(shapeRot2, RawRotation); const ret = wasm.rawcolliderset_coContactShape(this.__wbg_ptr, handle, shape2.__wbg_ptr, shapePos2.__wbg_ptr, shapeRot2.__wbg_ptr, prediction); return ret === 0 ? undefined : RawShapeContact.__wrap(ret); } /** * @param {number} handle * @param {number} collider2handle * @param {number} prediction * @returns {RawShapeContact | undefined} */ coContactCollider(handle, collider2handle, prediction) { const ret = wasm.rawcolliderset_coContactCollider(this.__wbg_ptr, handle, collider2handle, prediction); return ret === 0 ? undefined : RawShapeContact.__wrap(ret); } /** * @param {number} handle * @param {RawVector} point * @param {boolean} solid * @returns {RawPointProjection} */ coProjectPoint(handle, point, solid) { _assertClass(point, RawVector); const ret = wasm.rawcolliderset_coProjectPoint(this.__wbg_ptr, handle, point.__wbg_ptr, solid); return RawPointProjection.__wrap(ret); } /** * @param {number} handle * @param {RawVector} rayOrig * @param {RawVector} rayDir * @param {number} maxToi * @returns {boolean} */ coIntersectsRay(handle, rayOrig, rayDir, maxToi) { _assertClass(rayOrig, RawVector); _assertClass(rayDir, RawVector); const ret = wasm.rawcolliderset_coIntersectsRay(this.__wbg_ptr, handle, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi); return ret !== 0; } /** * @param {number} handle * @param {RawVector} rayOrig * @param {RawVector} rayDir * @param {number} maxToi * @param {boolean} solid * @returns {number} */ coCastRay(handle, rayOrig, rayDir, maxToi, solid) { _assertClass(rayOrig, RawVector); _assertClass(rayDir, RawVector); const ret = wasm.rawcolliderset_coCastRay(this.__wbg_ptr, handle, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid); return ret; } /** * @param {number} handle * @param {RawVector} rayOrig * @param {RawVector} rayDir * @param {number} maxToi * @param {boolean} solid * @returns {RawRayIntersection | undefined} */ coCastRayAndGetNormal(handle, rayOrig, rayDir, maxToi, solid) { _assertClass(rayOrig, RawVector); _assertClass(rayDir, RawVector); const ret = wasm.rawcolliderset_coCastRayAndGetNormal(this.__wbg_ptr, handle, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid); return ret === 0 ? undefined : RawRayIntersection.__wrap(ret); } /** * @param {number} handle * @param {boolean} is_sensor */ coSetSensor(handle, is_sensor) { wasm.rawcolliderset_coSetSensor(this.__wbg_ptr, handle, is_sensor); } /** * @param {number} handle * @param {number} restitution */ coSetRestitution(handle, restitution) { wasm.rawcolliderset_coSetRestitution(this.__wbg_ptr, handle, restitution); } /** * @param {number} handle * @param {number} friction */ coSetFriction(handle, friction) { wasm.rawcolliderset_coSetFriction(this.__wbg_ptr, handle, friction); } /** * @param {number} handle * @returns {number} */ coFrictionCombineRule(handle) { const ret = wasm.rawcolliderset_coFrictionCombineRule(this.__wbg_ptr, handle); return ret >>> 0; } /** * @param {number} handle * @param {number} rule */ coSetFrictionCombineRule(handle, rule) { wasm.rawcolliderset_coSetFrictionCombineRule(this.__wbg_ptr, handle, rule); } /** * @param {number} handle * @returns {number} */ coRestitutionCombineRule(handle) { const ret = wasm.rawcolliderset_coRestitutionCombineRule(this.__wbg_ptr, handle); return ret >>> 0; } /** * @param {number} handle * @param {number} rule */ coSetRestitutionCombineRule(handle, rule) { wasm.rawcolliderset_coSetRestitutionCombineRule(this.__wbg_ptr, handle, rule); } /** * @param {number} handle * @param {number} groups */ coSetCollisionGroups(handle, groups) { wasm.rawcolliderset_coSetCollisionGroups(this.__wbg_ptr, handle, groups); } /** * @param {number} handle * @param {number} groups */ coSetSolverGroups(handle, groups) { wasm.rawcolliderset_coSetSolverGroups(this.__wbg_ptr, handle, groups); } /** * @param {number} handle * @param {number} hooks */ coSetActiveHooks(handle, hooks) { wasm.rawcolliderset_coSetActiveHooks(this.__wbg_ptr, handle, hooks); } /** * @param {number} handle * @param {number} events */ coSetActiveEvents(handle, events) { wasm.rawcolliderset_coSetActiveEvents(this.__wbg_ptr, handle, events); } /** * @param {number} handle * @param {number} types */ coSetActiveCollisionTypes(handle, types) { wasm.rawcolliderset_coSetActiveCollisionTypes(this.__wbg_ptr, handle, types); } /** * @param {number} handle * @param {RawShape} shape */ coSetShape(handle, shape) { _assertClass(shape, RawShape); wasm.rawcolliderset_coSetShape(this.__wbg_ptr, handle, shape.__wbg_ptr); } /** * @param {number} handle * @param {number} threshold */ coSetContactForceEventThreshold(handle, threshold) { wasm.rawcolliderset_coSetContactForceEventThreshold(this.__wbg_ptr, handle, threshold); } /** * @param {number} handle * @param {number} density */ coSetDensity(handle, density) { wasm.rawcolliderset_coSetDensity(this.__wbg_ptr, handle, density); } /** * @param {number} handle * @param {number} mass */ coSetMass(handle, mass) { wasm.rawcolliderset_coSetMass(this.__wbg_ptr, handle, mass); } /** * @param {number} handle * @param {number} mass * @param {RawVector} centerOfMass * @param {number} principalAngularInertia */ coSetMassProperties(handle, mass, centerOfMass, principalAngularInertia) { _assertClass(centerOfMass, RawVector); wasm.rawcolliderset_coSetMassProperties(this.__wbg_ptr, handle, mass, centerOfMass.__wbg_ptr, principalAngularInertia); } constructor() { const ret = wasm.rawcolliderset_new(); this.__wbg_ptr = ret >>> 0; RawColliderSetFinalization.register(this, this.__wbg_ptr, this); return this; } /** * @returns {number} */ len() { const ret = wasm.rawcolliderset_len(this.__wbg_ptr); return ret >>> 0; } /** * @param {number} handle * @returns {boolean} */ contains(handle) { const ret = wasm.rawcolliderset_contains(this.__wbg_ptr, handle); return ret !== 0; } /** * @param {boolean} enabled * @param {RawShape} shape * @param {RawVector} translation * @param {RawRotation} rotation * @param {number} massPropsMode * @param {number} mass * @param {RawVector} centerOfMass * @param {number} principalAngularInertia * @param {number} density * @param {number} friction * @param {number} restitution * @param {number} frictionCombineRule * @param {number} restitutionCombineRule * @param {boolean} isSensor * @param {number} collisionGroups * @param {number} solverGroups * @param {number} activeCollisionTypes * @param {number} activeHooks * @param {number} activeEvents * @param {number} contactForceEventThreshold * @param {number} contactSkin * @param {boolean} hasParent * @param {number} parent * @param {RawRigidBodySet} bodies * @returns {number | undefined} */ createCollider(enabled, shape, translation, rotation, massPropsMode, mass, centerOfMass, principalAngularInertia, density, friction, restitution, frictionCombineRule, restitutionCombineRule, isSensor, collisionGroups, solverGroups, activeCollisionTypes, activeHooks, activeEvents, contactForceEventThreshold, contactSkin, hasParent, parent, bodies) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(shape, RawShape); _assertClass(translation, RawVector); _assertClass(rotation, RawRotation); _assertClass(centerOfMass, RawVector); _assertClass(bodies, RawRigidBodySet); wasm.rawcolliderset_createCollider(retptr, this.__wbg_ptr, enabled, shape.__wbg_ptr, translation.__wbg_ptr, rotation.__wbg_ptr, massPropsMode, mass, centerOfMass.__wbg_ptr, principalAngularInertia, density, friction, restitution, frictionCombineRule, restitutionCombineRule, isSensor, collisionGroups, solverGroups, activeCollisionTypes, activeHooks, activeEvents, contactForceEventThreshold, contactSkin, hasParent, parent, bodies.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r2 = getDataViewMemory0().getFloat64(retptr + 8 * 1, true); return r0 === 0 ? undefined : r2; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Removes a collider from this set and wake-up the rigid-body it is attached to. * @param {number} handle * @param {RawIslandManager} islands * @param {RawRigidBodySet} bodies * @param {boolean} wakeUp */ remove(handle, islands, bodies, wakeUp) { _assertClass(islands, RawIslandManager); _assertClass(bodies, RawRigidBodySet); wasm.rawcolliderset_remove(this.__wbg_ptr, handle, islands.__wbg_ptr, bodies.__wbg_ptr, wakeUp); } /** * Checks if a collider with the given integer handle exists. * @param {number} handle * @returns {boolean} */ isHandleValid(handle) { const ret = wasm.rawcolliderset_contains(this.__wbg_ptr, handle); return ret !== 0; } /** * Applies the given JavaScript function to the integer handle of each collider managed by this collider set. * * # Parameters * - `f(handle)`: the function to apply to the integer handle of each collider managed by this collider set. Called as `f(handle)`. * @param {Function} f */ forEachColliderHandle(f) { try { wasm.rawcolliderset_forEachColliderHandle(this.__wbg_ptr, addBorrowedObject(f)); } finally { heap[stack_pointer++] = undefined; } } } const RawColliderShapeCastHitFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawcollidershapecasthit_free(ptr >>> 0, 1)); export class RawColliderShapeCastHit { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(RawColliderShapeCastHit.prototype); obj.__wbg_ptr = ptr; RawColliderShapeCastHitFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawColliderShapeCastHitFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawcollidershapecasthit_free(ptr, 0); } /** * @returns {number} */ colliderHandle() { const ret = wasm.rawcollidershapecasthit_colliderHandle(this.__wbg_ptr); return ret; } /** * @returns {number} */ time_of_impact() { const ret = wasm.rawcollidershapecasthit_time_of_impact(this.__wbg_ptr); return ret; } /** * @returns {RawVector} */ witness1() { const ret = wasm.rawcollidershapecasthit_witness1(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ witness2() { const ret = wasm.rawcollidershapecasthit_witness2(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ normal1() { const ret = wasm.rawcollidershapecasthit_normal1(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ normal2() { const ret = wasm.rawcollidershapecasthit_normal2(this.__wbg_ptr); return RawVector.__wrap(ret); } } const RawContactForceEventFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawcontactforceevent_free(ptr >>> 0, 1)); export class RawContactForceEvent { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(RawContactForceEvent.prototype); obj.__wbg_ptr = ptr; RawContactForceEventFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawContactForceEventFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawcontactforceevent_free(ptr, 0); } /** * The first collider involved in the contact. * @returns {number} */ collider1() { const ret = wasm.rawcollidershapecasthit_colliderHandle(this.__wbg_ptr); return ret; } /** * The second collider involved in the contact. * @returns {number} */ collider2() { const ret = wasm.rawcontactforceevent_collider2(this.__wbg_ptr); return ret; } /** * The sum of all the forces between the two colliders. * @returns {RawVector} */ total_force() { const ret = wasm.rawcontactforceevent_total_force(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * The sum of the magnitudes of each force between the two colliders. * * Note that this is **not** the same as the magnitude of `self.total_force`. * Here we are summing the magnitude of all the forces, instead of taking * the magnitude of their sum. * @returns {number} */ total_force_magnitude() { const ret = wasm.rawcontactforceevent_total_force_magnitude(this.__wbg_ptr); return ret; } /** * The world-space (unit) direction of the force with strongest magnitude. * @returns {RawVector} */ max_force_direction() { const ret = wasm.rawcharactercollision_translationDeltaApplied(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * The magnitude of the largest force at a contact point of this contact pair. * @returns {number} */ max_force_magnitude() { const ret = wasm.rawcontactforceevent_max_force_magnitude(this.__wbg_ptr); return ret; } } const RawContactManifoldFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawcontactmanifold_free(ptr >>> 0, 1)); export class RawContactManifold { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(RawContactManifold.prototype); obj.__wbg_ptr = ptr; RawContactManifoldFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawContactManifoldFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawcontactmanifold_free(ptr, 0); } /** * @returns {RawVector} */ normal() { const ret = wasm.rawcontactmanifold_normal(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ local_n1() { const ret = wasm.rawcontactmanifold_local_n1(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {RawVector} */ local_n2() { const ret = wasm.rawcontactmanifold_local_n2(this.__wbg_ptr); return RawVector.__wrap(ret); } /** * @returns {number} */ subshape1() { const ret = wasm.rawcontactmanifold_subshape1(this.__wbg_ptr); return ret >>> 0; } /** * @returns {number} */ subshape2() { const ret = wasm.rawcontactmanifold_subshape2(this.__wbg_ptr); return ret >>> 0; } /** * @returns {number} */ num_contacts() { const ret = wasm.rawcontactmanifold_num_contacts(this.__wbg_ptr); return ret >>> 0; } /** * @param {number} i * @returns {RawVector | undefined} */ contact_local_p1(i) { const ret = wasm.rawcontactmanifold_contact_local_p1(this.__wbg_ptr, i); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * @param {number} i * @returns {RawVector | undefined} */ contact_local_p2(i) { const ret = wasm.rawcontactmanifold_contact_local_p2(this.__wbg_ptr, i); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * @param {number} i * @returns {number} */ contact_dist(i) { const ret = wasm.rawcontactmanifold_contact_dist(this.__wbg_ptr, i); return ret; } /** * @param {number} i * @returns {number} */ contact_fid1(i) { const ret = wasm.rawcontactmanifold_contact_fid1(this.__wbg_ptr, i); return ret >>> 0; } /** * @param {number} i * @returns {number} */ contact_fid2(i) { const ret = wasm.rawcontactmanifold_contact_fid2(this.__wbg_ptr, i); return ret >>> 0; } /** * @param {number} i * @returns {number} */ contact_impulse(i) { const ret = wasm.rawcontactmanifold_contact_impulse(this.__wbg_ptr, i); return ret; } /** * @param {number} i * @returns {number} */ contact_tangent_impulse(i) { const ret = wasm.rawcontactmanifold_contact_tangent_impulse(this.__wbg_ptr, i); return ret; } /** * @returns {number} */ num_solver_contacts() { const ret = wasm.rawcontactmanifold_num_solver_contacts(this.__wbg_ptr); return ret >>> 0; } /** * @param {number} i * @returns {RawVector | undefined} */ solver_contact_point(i) { const ret = wasm.rawcontactmanifold_solver_contact_point(this.__wbg_ptr, i); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * @param {number} i * @returns {number} */ solver_contact_dist(i) { const ret = wasm.rawcontactmanifold_solver_contact_dist(this.__wbg_ptr, i); return ret; } /** * @param {number} i * @returns {number} */ solver_contact_friction(i) { const ret = wasm.rawcontactmanifold_solver_contact_friction(this.__wbg_ptr, i); return ret; } /** * @param {number} i * @returns {number} */ solver_contact_restitution(i) { const ret = wasm.rawcontactmanifold_solver_contact_restitution(this.__wbg_ptr, i); return ret; } /** * @param {number} i * @returns {RawVector} */ solver_contact_tangent_velocity(i) { const ret = wasm.rawcontactmanifold_solver_contact_tangent_velocity(this.__wbg_ptr, i); return RawVector.__wrap(ret); } } const RawContactPairFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_rawcontactpair_free(ptr >>> 0, 1)); export class RawContactPair { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(RawContactPair.prototype); obj.__wbg_ptr = ptr; RawContactPairFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; RawContactPairFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rawcontactpair_free(ptr, 0); } /** * @returns {number} */ collider1() { const ret = wasm.rawcontactpair_collider1(this.__wbg_ptr); return ret; } /** * @returns {number} */ collider2() { const ret = wasm.rawcontactpair_collider2(this.__wbg_ptr); return ret; } /** * @returns {number} */ numContactManifolds() { const ret = wasm.rawcontactpair_numContactManifolds(this.__wbg_ptr); return ret >>> 0; } /** * @param {number} i * @returns {RawContactManifold | undefined} */ contactManifold(i) { const ret = wasm.rawcontactpair_contactManifold(this.__wbg_ptr, i); return ret === 0 ? undefined : RawContactManifold.__wrap(ret); } } const RawDebugRenderPipelineFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new Finalizatio