UNPKG

@dimforge/rapier3d

Version:

3-dimensional physics engine in Rust - official JS bindings.

1,306 lines (1,253 loc) 211 kB
let wasm; export function __wbg_set_wasm(val) { wasm = val; } 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)); } } const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 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)); } 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; } /** * @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 | 3} */ export const RawFeatureType = Object.freeze({ Vertex: 0, "0": "Vertex", Edge: 1, "1": "Edge", Face: 2, "2": "Face", Unknown: 3, "3": "Unknown", }); /** * @enum {0 | 1 | 2 | 3 | 4 | 5} */ export const RawJointAxis = Object.freeze({ LinX: 0, "0": "LinX", LinY: 1, "1": "LinY", LinZ: 2, "2": "LinZ", AngX: 3, "3": "AngX", AngY: 4, "4": "AngY", AngZ: 5, "5": "AngZ", }); /** * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6} */ 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", Spherical: 5, "5": "Spherical", Generic: 6, "6": "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 | 15 | 16 | 17 | 18} */ 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", ConvexPolyhedron: 9, "9": "ConvexPolyhedron", Cylinder: 10, "10": "Cylinder", Cone: 11, "11": "Cone", RoundCuboid: 12, "12": "RoundCuboid", RoundTriangle: 13, "13": "RoundTriangle", RoundCylinder: 14, "14": "RoundCylinder", RoundCone: 15, "15": "RoundCone", RoundConvexPolyhedron: 16, "16": "RoundConvexPolyhedron", HalfSpace: 17, "17": "HalfSpace", Voxels: 18, "18": "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; } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} rayOrig * @param {RawVector} rayDir * @param {number} maxToi * @param {boolean} solid * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate * @returns {RawRayColliderHit | undefined} */ castRay(narrow_phase, bodies, colliders, rayOrig, rayDir, maxToi, solid, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(rayOrig, RawVector); _assertClass(rayDir, RawVector); const ret = wasm.rawbroadphase_castRay(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid, filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); return ret === 0 ? undefined : RawRayColliderHit.__wrap(ret); } finally { heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} rayOrig * @param {RawVector} rayDir * @param {number} maxToi * @param {boolean} solid * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate * @returns {RawRayColliderIntersection | undefined} */ castRayAndGetNormal(narrow_phase, bodies, colliders, rayOrig, rayDir, maxToi, solid, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(rayOrig, RawVector); _assertClass(rayDir, RawVector); const ret = wasm.rawbroadphase_castRayAndGetNormal(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid, filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); return ret === 0 ? undefined : RawRayColliderIntersection.__wrap(ret); } finally { heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} rayOrig * @param {RawVector} rayDir * @param {number} maxToi * @param {boolean} solid * @param {Function} callback * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate */ intersectionsWithRay(narrow_phase, bodies, colliders, rayOrig, rayDir, maxToi, solid, callback, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(rayOrig, RawVector); _assertClass(rayDir, RawVector); wasm.rawbroadphase_intersectionsWithRay(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, rayOrig.__wbg_ptr, rayDir.__wbg_ptr, maxToi, solid, addBorrowedObject(callback), filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); } finally { heap[stack_pointer++] = undefined; heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} shapePos * @param {RawRotation} shapeRot * @param {RawShape} shape * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate * @returns {number | undefined} */ intersectionWithShape(narrow_phase, bodies, colliders, shapePos, shapeRot, shape, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(shapePos, RawVector); _assertClass(shapeRot, RawRotation); _assertClass(shape, RawShape); wasm.rawbroadphase_intersectionWithShape(retptr, this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, shapePos.__wbg_ptr, shapeRot.__wbg_ptr, shape.__wbg_ptr, filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); 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); heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} point * @param {boolean} solid * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate * @returns {RawPointColliderProjection | undefined} */ projectPoint(narrow_phase, bodies, colliders, point, solid, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(point, RawVector); const ret = wasm.rawbroadphase_projectPoint(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, point.__wbg_ptr, solid, filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); return ret === 0 ? undefined : RawPointColliderProjection.__wrap(ret); } finally { heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} point * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate * @returns {RawPointColliderProjection | undefined} */ projectPointAndGetFeature(narrow_phase, bodies, colliders, point, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(point, RawVector); const ret = wasm.rawbroadphase_projectPointAndGetFeature(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, point.__wbg_ptr, filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); return ret === 0 ? undefined : RawPointColliderProjection.__wrap(ret); } finally { heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} point * @param {Function} callback * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate */ intersectionsWithPoint(narrow_phase, bodies, colliders, point, callback, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(point, RawVector); wasm.rawbroadphase_intersectionsWithPoint(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, point.__wbg_ptr, addBorrowedObject(callback), filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); } finally { heap[stack_pointer++] = undefined; heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} shapePos * @param {RawRotation} shapeRot * @param {RawVector} shapeVel * @param {RawShape} shape * @param {number} target_distance * @param {number} maxToi * @param {boolean} stop_at_penetration * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate * @returns {RawColliderShapeCastHit | undefined} */ castShape(narrow_phase, bodies, colliders, shapePos, shapeRot, shapeVel, shape, target_distance, maxToi, stop_at_penetration, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(shapePos, RawVector); _assertClass(shapeRot, RawRotation); _assertClass(shapeVel, RawVector); _assertClass(shape, RawShape); const ret = wasm.rawbroadphase_castShape(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, shapePos.__wbg_ptr, shapeRot.__wbg_ptr, shapeVel.__wbg_ptr, shape.__wbg_ptr, target_distance, maxToi, stop_at_penetration, filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); return ret === 0 ? undefined : RawColliderShapeCastHit.__wrap(ret); } finally { heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} shapePos * @param {RawRotation} shapeRot * @param {RawShape} shape * @param {Function} callback * @param {number} filter_flags * @param {number | null | undefined} filter_groups * @param {number | null | undefined} filter_exclude_collider * @param {number | null | undefined} filter_exclude_rigid_body * @param {Function} filter_predicate */ intersectionsWithShape(narrow_phase, bodies, colliders, shapePos, shapeRot, shape, callback, filter_flags, filter_groups, filter_exclude_collider, filter_exclude_rigid_body, filter_predicate) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(shapePos, RawVector); _assertClass(shapeRot, RawRotation); _assertClass(shape, RawShape); wasm.rawbroadphase_intersectionsWithShape(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, shapePos.__wbg_ptr, shapeRot.__wbg_ptr, shape.__wbg_ptr, addBorrowedObject(callback), filter_flags, isLikeNone(filter_groups) ? 0x100000001 : (filter_groups) >>> 0, !isLikeNone(filter_exclude_collider), isLikeNone(filter_exclude_collider) ? 0 : filter_exclude_collider, !isLikeNone(filter_exclude_rigid_body), isLikeNone(filter_exclude_rigid_body) ? 0 : filter_exclude_rigid_body, addBorrowedObject(filter_predicate)); } finally { heap[stack_pointer++] = undefined; heap[stack_pointer++] = undefined; } } /** * @param {RawNarrowPhase} narrow_phase * @param {RawRigidBodySet} bodies * @param {RawColliderSet} colliders * @param {RawVector} aabbCenter * @param {RawVector} aabbHalfExtents * @param {Function} callback */ collidersWithAabbIntersectingAabb(narrow_phase, bodies, colliders, aabbCenter, aabbHalfExtents, callback) { try { _assertClass(narrow_phase, RawNarrowPhase); _assertClass(bodies, RawRigidBodySet); _assertClass(colliders, RawColliderSet); _assertClass(aabbCenter, RawVector); _assertClass(aabbHalfExtents, RawVector); wasm.rawbroadphase_collidersWithAabbIntersectingAabb(this.__wbg_ptr, narrow_phase.__wbg_ptr, bodies.__wbg_ptr, colliders.__wbg_ptr, aabbCenter.__wbg_ptr, aabbHalfExtents.__wbg_ptr, addBorrowedObject(callback)); } finally { heap[stack_pointer++] = undefined; } } } 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); } /** * The translation of this collider relative to its parent rigid-body. * * Returns the `None` if it doesn’t have a parent. * @param {number} handle * @returns {RawVector | undefined} */ coTranslationWrtParent(handle) { const ret = wasm.rawcolliderset_coTranslationWrtParent(this.__wbg_ptr, handle); return ret === 0 ? undefined : RawVector.__wrap(ret); } /** * The orientation of this collider relative to its parent rigid-body. * * Returns the `None` if it doesn’t have a parent. * @param {number} handle * @returns {RawRotation | undefined} */ coRotationWrtParent(handle) { const ret = wasm.rawcolliderset_coRotationWrtParent(this.__wbg_ptr, handle); return ret === 0 ? undefined : 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. * - `z`: the world-space position of the collider along the `z` 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 * @param {number} z */ coSetTranslation(handle, x, y, z) { wasm.rawcolliderset_coSetTranslation(this.__wbg_ptr, handle, x, y, z); } /** * @param {number} handle * @param {number} x * @param {number} y * @param {number} z */ coSetTranslationWrtParent(handle, x, y, z) { wasm.rawcolliderset_coSetTranslationWrtParent(this.__wbg_ptr, handle, x, y, z); } /** * Sets the rotation quaternion of this collider. * * This does nothing if a zero quaternion is provided. * * # Parameters * - `x`: the first vector component of the quaternion. * - `y`: the second vector component of the quaternion. * - `z`: the third vector component of the quaternion. * - `w`: the scalar component of the quaternion. * - `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 * @param {number} z * @param {number} w */ coSetRotation(handle, x, y, z, w) { wasm.rawcolliderset_coSetRotation(this.__wbg_ptr, handle, x, y, z, w); } /** * @param {number} handle * @param {number} x * @param {number} y * @param {number} z * @param {number} w */ coSetRotationWrtParent(handle, x, y, z, w) { wasm.rawcolliderset_coSetRotationWrtParent(this.__wbg_ptr, handle, x, y, z, w); } /** * 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 {number} iz * @param {boolean} filled */ coSetVoxel(handle, ix, iy, iz, filled) { wasm.rawcolliderset_coSetVoxel(this.__wbg_ptr, handle, ix, iy, iz, filled); } /** * @param {number} handle1 * @param {number} handle2 * @param {number} ix * @param {number} iy * @param {number} iz * @param {number} shift_x * @param {number} shift_y * @param {number} shift_z */ coPropagateVoxelChange(handle1, handle2, ix, iy, iz, shift_x, shift_y, shift_z) { wasm.rawcolliderset_coPropagateVoxelChange(this.__wbg_ptr, handle1, handle2, ix, iy, iz, shift_x, shift_y, shift_z); } /** * @param {number} handle1 * @param {number} handle2 * @param {number} shift_x * @param {number} shift_y * @param {number} shift_z */ coCombineVoxelStates(handle1, handle2, shift_x, shift_y, shift_z) { wasm.rawcolliderset_coCombineVoxelStates(this.__wbg_ptr, handle1, handle2, shift_x, shift_y, shift_z); } /** * 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; } /** * @param {number} handle * @returns {number | undefined} */ coHeightFieldFlags(handle) { const ret = wasm.rawcolliderset_coHeightFieldFlags(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 number of rows on this heightfield's height matrix, if it is one. * @param {number} handle * @returns {number | undefined} */ coHeightfieldNRows(handle) { const ret = wasm.rawcolliderset_coHeightfieldNRows(this.__wbg_ptr, handle); return ret === 0x100000001 ? undefined : ret; } /** * The number of columns on this heightfield's height matrix, if it is one. * @param {number} handle * @returns {number | undefined} */ coHeightfieldNCols(handle) { const ret = wasm.rawcolliderset_coHeightfieldNCols(this.__wbg_ptr, handle); return ret === 0x100000001 ? undefined : 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, soli