UNPKG

@croquet/microverse-library

Version:

An npm package version of Microverse

1,141 lines (1,083 loc) 511 kB
"use strict"; (globalThis["webpackChunk_croquet_microverse"] = globalThis["webpackChunk_croquet_microverse"] || []).push([["vendors-node_modules_dimforge_rapier3d_rapier_js"],{ /***/ "./node_modules/@dimforge/rapier3d/coarena.js": /*!****************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/coarena.js ***! \****************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Coarena: () => (/* binding */ Coarena) /* harmony export */ }); class Coarena { constructor() { this.fconv = new Float64Array(1); this.uconv = new Uint32Array(this.fconv.buffer); this.data = new Array(); this.size = 0; } set(handle, data) { let i = this.index(handle); while (this.data.length <= i) { this.data.push(null); } if (this.data[i] == null) this.size += 1; this.data[i] = data; } len() { return this.size; } delete(handle) { let i = this.index(handle); if (i < this.data.length) { if (this.data[i] != null) this.size -= 1; this.data[i] = null; } } clear() { this.data = new Array(); } get(handle) { let i = this.index(handle); if (i < this.data.length) { return this.data[i]; } else { return null; } } forEach(f) { for (const elt of this.data) { if (elt != null) f(elt); } } getAll() { return this.data.filter((elt) => elt != null); } index(handle) { /// Extracts the index part of a handle (the lower 32 bits). /// This is done by first injecting the handle into an Float64Array /// which is itself injected into an Uint32Array (at construction time). /// The 0-th value of the Uint32Array will become the `number` integer /// representation of the lower 32 bits. /// Also `this.uconv[1]` then contains the generation number as a `number`, /// which we don’t really need. this.fconv[0] = handle; return this.uconv[0]; } } /***/ }), /***/ "./node_modules/@dimforge/rapier3d/control/character_controller.js": /*!*************************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/control/character_controller.js ***! \*************************************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CharacterCollision: () => (/* binding */ CharacterCollision), /* harmony export */ KinematicCharacterController: () => (/* binding */ KinematicCharacterController) /* harmony export */ }); /* harmony import */ var _raw__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../raw */ "./node_modules/@dimforge/rapier3d/rapier_wasm3d_bg.js"); /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../math */ "./node_modules/@dimforge/rapier3d/math.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_raw__WEBPACK_IMPORTED_MODULE_0__, _math__WEBPACK_IMPORTED_MODULE_1__]); ([_raw__WEBPACK_IMPORTED_MODULE_0__, _math__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__); /** * A collision between the character and an obstacle hit on its path. */ class CharacterCollision { } /** * A character controller for controlling kinematic bodies and parentless colliders by hitting * and sliding against obstacles. */ class KinematicCharacterController { constructor(offset, params, bodies, colliders, queries) { this.params = params; this.bodies = bodies; this.colliders = colliders; this.queries = queries; this.raw = new _raw__WEBPACK_IMPORTED_MODULE_0__.RawKinematicCharacterController(offset); this.rawCharacterCollision = new _raw__WEBPACK_IMPORTED_MODULE_0__.RawCharacterCollision(); this._applyImpulsesToDynamicBodies = false; this._characterMass = null; } /** @internal */ free() { if (!!this.raw) { this.raw.free(); this.rawCharacterCollision.free(); } this.raw = undefined; this.rawCharacterCollision = undefined; } /** * The direction that goes "up". Used to determine where the floor is, and the floor’s angle. */ up() { return this.raw.up(); } /** * Sets the direction that goes "up". Used to determine where the floor is, and the floor’s angle. */ setUp(vector) { let rawVect = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.intoRaw(vector); return this.raw.setUp(rawVect); rawVect.free(); } applyImpulsesToDynamicBodies() { return this._applyImpulsesToDynamicBodies; } setApplyImpulsesToDynamicBodies(enabled) { this._applyImpulsesToDynamicBodies = enabled; } /** * Returns the custom value of the character mass, if it was set by `this.setCharacterMass`. */ characterMass() { return this._characterMass; } /** * Set the mass of the character to be used for impulse resolution if `self.applyImpulsesToDynamicBodies` * is set to `true`. * * If no character mass is set explicitly (or if it is set to `null`) it is automatically assumed to be equal * to the mass of the rigid-body the character collider is attached to; or equal to 0 if the character collider * isn’t attached to any rigid-body. * * @param mass - The mass to set. */ setCharacterMass(mass) { this._characterMass = mass; } /** * A small gap to preserve between the character and its surroundings. * * This value should not be too large to avoid visual artifacts, but shouldn’t be too small * (must not be zero) to improve numerical stability of the character controller. */ offset() { return this.raw.offset(); } /** * Sets a small gap to preserve between the character and its surroundings. * * This value should not be too large to avoid visual artifacts, but shouldn’t be too small * (must not be zero) to improve numerical stability of the character controller. */ setOffset(value) { this.raw.setOffset(value); } /** * Is sliding against obstacles enabled? */ slideEnabled() { return this.raw.slideEnabled(); } /** * Enable or disable sliding against obstacles. */ setSlideEnabled(enabled) { this.raw.setSlideEnabled(enabled); } /** * The maximum step height a character can automatically step over. */ autostepMaxHeight() { return this.raw.autostepMaxHeight(); } /** * The minimum width of free space that must be available after stepping on a stair. */ autostepMinWidth() { return this.raw.autostepMinWidth(); } /** * Can the character automatically step over dynamic bodies too? */ autostepIncludesDynamicBodies() { return this.raw.autostepIncludesDynamicBodies(); } /** * Is automatically stepping over small objects enabled? */ autostepEnabled() { return this.raw.autostepEnabled(); } /** * Enabled automatically stepping over small objects. * * @param maxHeight - The maximum step height a character can automatically step over. * @param minWidth - The minimum width of free space that must be available after stepping on a stair. * @param includeDynamicBodies - Can the character automatically step over dynamic bodies too? */ enableAutostep(maxHeight, minWidth, includeDynamicBodies) { this.raw.enableAutostep(maxHeight, minWidth, includeDynamicBodies); } /** * Disable automatically stepping over small objects. */ disableAutostep() { return this.raw.disableAutostep(); } /** * The maximum angle (radians) between the floor’s normal and the `up` vector that the * character is able to climb. */ maxSlopeClimbAngle() { return this.raw.maxSlopeClimbAngle(); } /** * Sets the maximum angle (radians) between the floor’s normal and the `up` vector that the * character is able to climb. */ setMaxSlopeClimbAngle(angle) { this.raw.setMaxSlopeClimbAngle(angle); } /** * The minimum angle (radians) between the floor’s normal and the `up` vector before the * character starts to slide down automatically. */ minSlopeSlideAngle() { return this.raw.minSlopeSlideAngle(); } /** * Sets the minimum angle (radians) between the floor’s normal and the `up` vector before the * character starts to slide down automatically. */ setMinSlopeSlideAngle(angle) { this.raw.setMinSlopeSlideAngle(angle); } /** * If snap-to-ground is enabled, should the character be automatically snapped to the ground if * the distance between the ground and its feet are smaller than the specified threshold? */ snapToGroundDistance() { return this.raw.snapToGroundDistance(); } /** * Enables automatically snapping the character to the ground if the distance between * the ground and its feet are smaller than the specified threshold. */ enableSnapToGround(distance) { this.raw.enableSnapToGround(distance); } /** * Disables automatically snapping the character to the ground. */ disableSnapToGround() { this.raw.disableSnapToGround(); } /** * Is automatically snapping the character to the ground enabled? */ snapToGroundEnabled() { return this.raw.snapToGroundEnabled(); } /** * Computes the movement the given collider is able to execute after hitting and sliding on obstacles. * * @param collider - The collider to move. * @param desiredTranslation - The desired collider movement. * @param filterFlags - Flags for excluding whole subsets of colliders from the obstacles taken into account. * @param filterGroups - Groups for excluding colliders with incompatible collision groups from the obstacles * taken into account. * @param filterPredicate - Any collider for which this closure returns `false` will be excluded from the * obstacles taken into account. */ computeColliderMovement(collider, desiredTranslation, filterFlags, filterGroups, filterPredicate) { let rawTranslation = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.intoRaw(desiredTranslation); this.raw.computeColliderMovement(this.params.dt, this.bodies.raw, this.colliders.raw, this.queries.raw, collider.handle, rawTranslation, this._applyImpulsesToDynamicBodies, this._characterMass, filterFlags, filterGroups, this.colliders.castClosure(filterPredicate)); rawTranslation.free(); } /** * The movement computed by the last call to `this.computeColliderMovement`. */ computedMovement() { return _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(this.raw.computedMovement()); } /** * The result of ground detection computed by the last call to `this.computeColliderMovement`. */ computedGrounded() { return this.raw.computedGrounded(); } /** * The number of collisions against obstacles detected along the path of the last call * to `this.computeColliderMovement`. */ numComputedCollisions() { return this.raw.numComputedCollisions(); } /** * Returns the collision against one of the obstacles detected along the path of the last * call to `this.computeColliderMovement`. * * @param i - The i-th collision will be returned. * @param out - If this argument is set, it will be filled with the collision information. */ computedCollision(i, out) { if (!this.raw.computedCollision(i, this.rawCharacterCollision)) { return null; } else { let c = this.rawCharacterCollision; out = out !== null && out !== void 0 ? out : new CharacterCollision(); out.translationApplied = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(c.translationApplied()); out.translationRemaining = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(c.translationRemaining()); out.toi = c.toi(); out.witness1 = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(c.worldWitness1()); out.witness2 = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(c.worldWitness2()); out.normal1 = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(c.worldNormal1()); out.normal2 = _math__WEBPACK_IMPORTED_MODULE_1__.VectorOps.fromRaw(c.worldNormal2()); out.collider = this.colliders.get(c.handle()); return out; } } } __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/control/index.js": /*!**********************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/control/index.js ***! \**********************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CharacterCollision: () => (/* reexport safe */ _character_controller__WEBPACK_IMPORTED_MODULE_0__.CharacterCollision), /* harmony export */ KinematicCharacterController: () => (/* reexport safe */ _character_controller__WEBPACK_IMPORTED_MODULE_0__.KinematicCharacterController) /* harmony export */ }); /* harmony import */ var _character_controller__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./character_controller */ "./node_modules/@dimforge/rapier3d/control/character_controller.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_character_controller__WEBPACK_IMPORTED_MODULE_0__]); _character_controller__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0]; __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/ccd_solver.js": /*!****************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/ccd_solver.js ***! \****************************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CCDSolver: () => (/* binding */ CCDSolver) /* harmony export */ }); /* harmony import */ var _raw__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../raw */ "./node_modules/@dimforge/rapier3d/rapier_wasm3d_bg.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_raw__WEBPACK_IMPORTED_MODULE_0__]); _raw__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0]; /** * The CCD solver responsible for resolving Continuous Collision Detection. * * To avoid leaking WASM resources, this MUST be freed manually with `ccdSolver.free()` * once you are done using it. */ class CCDSolver { constructor(raw) { this.raw = raw || new _raw__WEBPACK_IMPORTED_MODULE_0__.RawCCDSolver(); } /** * Release the WASM memory occupied by this narrow-phase. */ free() { if (!!this.raw) { this.raw.free(); } this.raw = undefined; } } __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/coefficient_combine_rule.js": /*!******************************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/coefficient_combine_rule.js ***! \******************************************************************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CoefficientCombineRule: () => (/* binding */ CoefficientCombineRule) /* harmony export */ }); /** * A rule applied to combine coefficients. * * Use this when configuring the `ColliderDesc` to specify * how friction and restitution coefficient should be combined * in a contact. */ var CoefficientCombineRule; (function (CoefficientCombineRule) { CoefficientCombineRule[CoefficientCombineRule["Average"] = 0] = "Average"; CoefficientCombineRule[CoefficientCombineRule["Min"] = 1] = "Min"; CoefficientCombineRule[CoefficientCombineRule["Multiply"] = 2] = "Multiply"; CoefficientCombineRule[CoefficientCombineRule["Max"] = 3] = "Max"; })(CoefficientCombineRule || (CoefficientCombineRule = {})); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/impulse_joint.js": /*!*******************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/impulse_joint.js ***! \*******************************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ FixedImpulseJoint: () => (/* binding */ FixedImpulseJoint), /* harmony export */ ImpulseJoint: () => (/* binding */ ImpulseJoint), /* harmony export */ JointData: () => (/* binding */ JointData), /* harmony export */ JointType: () => (/* binding */ JointType), /* harmony export */ MotorModel: () => (/* binding */ MotorModel), /* harmony export */ PrismaticImpulseJoint: () => (/* binding */ PrismaticImpulseJoint), /* harmony export */ RevoluteImpulseJoint: () => (/* binding */ RevoluteImpulseJoint), /* harmony export */ SphericalImpulseJoint: () => (/* binding */ SphericalImpulseJoint), /* harmony export */ UnitImpulseJoint: () => (/* binding */ UnitImpulseJoint) /* harmony export */ }); /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../math */ "./node_modules/@dimforge/rapier3d/math.js"); /* harmony import */ var _raw__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../raw */ "./node_modules/@dimforge/rapier3d/rapier_wasm3d_bg.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_math__WEBPACK_IMPORTED_MODULE_0__, _raw__WEBPACK_IMPORTED_MODULE_1__]); ([_math__WEBPACK_IMPORTED_MODULE_0__, _raw__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__); /** * An enum grouping all possible types of joints: * * - `Revolute`: A revolute joint that removes all degrees of freedom between the affected * bodies except for the rotation along one axis. * - `Fixed`: A fixed joint that removes all relative degrees of freedom between the affected bodies. * - `Prismatic`: A prismatic joint that removes all degrees of freedom between the affected * bodies except for the translation along one axis. * - `Spherical`: (3D only) A spherical joint that removes all relative linear degrees of freedom between the affected bodies. */ var JointType; (function (JointType) { JointType[JointType["Revolute"] = 0] = "Revolute"; JointType[JointType["Fixed"] = 1] = "Fixed"; JointType[JointType["Prismatic"] = 2] = "Prismatic"; // #if DIM3 JointType[JointType["Spherical"] = 3] = "Spherical"; // #endif })(JointType || (JointType = {})); var MotorModel; (function (MotorModel) { MotorModel[MotorModel["AccelerationBased"] = 0] = "AccelerationBased"; MotorModel[MotorModel["ForceBased"] = 1] = "ForceBased"; })(MotorModel || (MotorModel = {})); class ImpulseJoint { constructor(rawSet, bodySet, handle) { this.rawSet = rawSet; this.bodySet = bodySet; this.handle = handle; } static newTyped(rawSet, bodySet, handle) { switch (rawSet.jointType(handle)) { case JointType.Revolute: return new RevoluteImpulseJoint(rawSet, bodySet, handle); case JointType.Prismatic: return new PrismaticImpulseJoint(rawSet, bodySet, handle); case JointType.Fixed: return new FixedImpulseJoint(rawSet, bodySet, handle); // #if DIM3 case JointType.Spherical: return new SphericalImpulseJoint(rawSet, bodySet, handle); // #endif default: return new ImpulseJoint(rawSet, bodySet, handle); } } /** @internal */ finalizeDeserialization(bodySet) { this.bodySet = bodySet; } /** * Checks if this joint is still valid (i.e. that it has * not been deleted from the joint set yet). */ isValid() { return this.rawSet.contains(this.handle); } /** * The first rigid-body this joint it attached to. */ body1() { return this.bodySet.get(this.rawSet.jointBodyHandle1(this.handle)); } /** * The second rigid-body this joint is attached to. */ body2() { return this.bodySet.get(this.rawSet.jointBodyHandle2(this.handle)); } /** * The type of this joint given as a string. */ type() { return this.rawSet.jointType(this.handle); } // #if DIM3 /** * The rotation quaternion that aligns this joint's first local axis to the `x` axis. */ frameX1() { return _math__WEBPACK_IMPORTED_MODULE_0__.RotationOps.fromRaw(this.rawSet.jointFrameX1(this.handle)); } // #endif // #if DIM3 /** * The rotation matrix that aligns this joint's second local axis to the `x` axis. */ frameX2() { return _math__WEBPACK_IMPORTED_MODULE_0__.RotationOps.fromRaw(this.rawSet.jointFrameX2(this.handle)); } // #endif /** * The position of the first anchor of this joint. * * The first anchor gives the position of the application point on the * local frame of the first rigid-body it is attached to. */ anchor1() { return _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.fromRaw(this.rawSet.jointAnchor1(this.handle)); } /** * The position of the second anchor of this joint. * * The second anchor gives the position of the application point on the * local frame of the second rigid-body it is attached to. */ anchor2() { return _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.fromRaw(this.rawSet.jointAnchor2(this.handle)); } /** * Sets the position of the first anchor of this joint. * * The first anchor gives the position of the application point on the * local frame of the first rigid-body it is attached to. */ setAnchor1(newPos) { const rawPoint = _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.intoRaw(newPos); this.rawSet.jointSetAnchor1(this.handle, rawPoint); rawPoint.free(); } /** * Sets the position of the second anchor of this joint. * * The second anchor gives the position of the application point on the * local frame of the second rigid-body it is attached to. */ setAnchor2(newPos) { const rawPoint = _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.intoRaw(newPos); this.rawSet.jointSetAnchor2(this.handle, rawPoint); rawPoint.free(); } /** * Controls whether contacts are computed between colliders attached * to the rigid-bodies linked by this joint. */ setContactsEnabled(enabled) { this.rawSet.jointSetContactsEnabled(this.handle, enabled); } /** * Indicates if contacts are enabled between colliders attached * to the rigid-bodies linked by this joint. */ contactsEnabled() { return this.rawSet.jointContactsEnabled(this.handle); } } class UnitImpulseJoint extends ImpulseJoint { /** * Are the limits enabled for this joint? */ limitsEnabled() { return this.rawSet.jointLimitsEnabled(this.handle, this.rawAxis()); } /** * The min limit of this joint. */ limitsMin() { return this.rawSet.jointLimitsMin(this.handle, this.rawAxis()); } /** * The max limit of this joint. */ limitsMax() { return this.rawSet.jointLimitsMax(this.handle, this.rawAxis()); } /** * Sets the limits of this joint. * * @param min - The minimum bound of this joint’s free coordinate. * @param max - The maximum bound of this joint’s free coordinate. */ setLimits(min, max) { this.rawSet.jointSetLimits(this.handle, this.rawAxis(), min, max); } configureMotorModel(model) { this.rawSet.jointConfigureMotorModel(this.handle, this.rawAxis(), model); } configureMotorVelocity(targetVel, factor) { this.rawSet.jointConfigureMotorVelocity(this.handle, this.rawAxis(), targetVel, factor); } configureMotorPosition(targetPos, stiffness, damping) { this.rawSet.jointConfigureMotorPosition(this.handle, this.rawAxis(), targetPos, stiffness, damping); } configureMotor(targetPos, targetVel, stiffness, damping) { this.rawSet.jointConfigureMotor(this.handle, this.rawAxis(), targetPos, targetVel, stiffness, damping); } } class FixedImpulseJoint extends ImpulseJoint { } class PrismaticImpulseJoint extends UnitImpulseJoint { rawAxis() { return _raw__WEBPACK_IMPORTED_MODULE_1__.RawJointAxis.X; } } class RevoluteImpulseJoint extends UnitImpulseJoint { rawAxis() { return _raw__WEBPACK_IMPORTED_MODULE_1__.RawJointAxis.AngX; } } // #if DIM3 class SphericalImpulseJoint extends ImpulseJoint { } // #endif class JointData { constructor() { } /** * Creates a new joint descriptor that builds a Fixed joint. * * A fixed joint removes all the degrees of freedom between the affected bodies, ensuring their * anchor and local frames coincide in world-space. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param frame1 - The reference orientation of the joint wrt. the first rigid-body. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param frame2 - The reference orientation of the joint wrt. the second rigid-body. */ static fixed(anchor1, frame1, anchor2, frame2) { let res = new JointData(); res.anchor1 = anchor1; res.anchor2 = anchor2; res.frame1 = frame1; res.frame2 = frame2; res.jointType = JointType.Fixed; return res; } // #if DIM3 /** * Create a new joint descriptor that builds spherical joints. * * A spherical joint allows three relative rotational degrees of freedom * by preventing any relative translation between the anchors of the * two attached rigid-bodies. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. */ static spherical(anchor1, anchor2) { let res = new JointData(); res.anchor1 = anchor1; res.anchor2 = anchor2; res.jointType = JointType.Spherical; return res; } /** * Creates a new joint descriptor that builds a Prismatic joint. * * A prismatic joint removes all the degrees of freedom between the * affected bodies, except for the translation along one axis. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param axis - Axis of the joint, expressed in the local-space of the rigid-bodies it is attached to. */ static prismatic(anchor1, anchor2, axis) { let res = new JointData(); res.anchor1 = anchor1; res.anchor2 = anchor2; res.axis = axis; res.jointType = JointType.Prismatic; return res; } /** * Create a new joint descriptor that builds Revolute joints. * * A revolute joint removes all degrees of freedom between the affected * bodies except for the rotation along one axis. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param axis - Axis of the joint, expressed in the local-space of the rigid-bodies it is attached to. */ static revolute(anchor1, anchor2, axis) { let res = new JointData(); res.anchor1 = anchor1; res.anchor2 = anchor2; res.axis = axis; res.jointType = JointType.Revolute; return res; } // #endif intoRaw() { let rawA1 = _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.intoRaw(this.anchor1); let rawA2 = _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.intoRaw(this.anchor2); let rawAx; let result; let limitsEnabled = false; let limitsMin = 0.0; let limitsMax = 0.0; switch (this.jointType) { case JointType.Fixed: let rawFra1 = _math__WEBPACK_IMPORTED_MODULE_0__.RotationOps.intoRaw(this.frame1); let rawFra2 = _math__WEBPACK_IMPORTED_MODULE_0__.RotationOps.intoRaw(this.frame2); result = _raw__WEBPACK_IMPORTED_MODULE_1__.RawGenericJoint.fixed(rawA1, rawFra1, rawA2, rawFra2); rawFra1.free(); rawFra2.free(); break; case JointType.Prismatic: rawAx = _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.intoRaw(this.axis); if (!!this.limitsEnabled) { limitsEnabled = true; limitsMin = this.limits[0]; limitsMax = this.limits[1]; } // #if DIM3 result = _raw__WEBPACK_IMPORTED_MODULE_1__.RawGenericJoint.prismatic(rawA1, rawA2, rawAx, limitsEnabled, limitsMin, limitsMax); // #endif rawAx.free(); break; // #if DIM3 case JointType.Spherical: result = _raw__WEBPACK_IMPORTED_MODULE_1__.RawGenericJoint.spherical(rawA1, rawA2); break; case JointType.Revolute: rawAx = _math__WEBPACK_IMPORTED_MODULE_0__.VectorOps.intoRaw(this.axis); result = _raw__WEBPACK_IMPORTED_MODULE_1__.RawGenericJoint.revolute(rawA1, rawA2, rawAx); rawAx.free(); break; // #endif } rawA1.free(); rawA2.free(); return result; } } __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/impulse_joint_set.js": /*!***********************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/impulse_joint_set.js ***! \***********************************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ImpulseJointSet: () => (/* binding */ ImpulseJointSet) /* harmony export */ }); /* harmony import */ var _raw__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../raw */ "./node_modules/@dimforge/rapier3d/rapier_wasm3d_bg.js"); /* harmony import */ var _coarena__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coarena */ "./node_modules/@dimforge/rapier3d/coarena.js"); /* harmony import */ var _impulse_joint__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./impulse_joint */ "./node_modules/@dimforge/rapier3d/dynamics/impulse_joint.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_raw__WEBPACK_IMPORTED_MODULE_0__, _impulse_joint__WEBPACK_IMPORTED_MODULE_2__]); ([_raw__WEBPACK_IMPORTED_MODULE_0__, _impulse_joint__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__); /** * A set of joints. * * To avoid leaking WASM resources, this MUST be freed manually with `jointSet.free()` * once you are done using it (and all the joints it created). */ class ImpulseJointSet { constructor(raw) { this.raw = raw || new _raw__WEBPACK_IMPORTED_MODULE_0__.RawImpulseJointSet(); this.map = new _coarena__WEBPACK_IMPORTED_MODULE_1__.Coarena(); // Initialize the map with the existing elements, if any. if (raw) { raw.forEachJointHandle((handle) => { this.map.set(handle, _impulse_joint__WEBPACK_IMPORTED_MODULE_2__.ImpulseJoint.newTyped(raw, null, handle)); }); } } /** * Release the WASM memory occupied by this joint set. */ free() { if (!!this.raw) { this.raw.free(); } this.raw = undefined; if (!!this.map) { this.map.clear(); } this.map = undefined; } /** @internal */ finalizeDeserialization(bodies) { this.map.forEach((joint) => joint.finalizeDeserialization(bodies)); } /** * Creates a new joint and return its integer handle. * * @param bodies - The set of rigid-bodies containing the bodies the joint is attached to. * @param desc - The joint's parameters. * @param parent1 - The handle of the first rigid-body this joint is attached to. * @param parent2 - The handle of the second rigid-body this joint is attached to. * @param wakeUp - Should the attached rigid-bodies be awakened? */ createJoint(bodies, desc, parent1, parent2, wakeUp) { const rawParams = desc.intoRaw(); const handle = this.raw.createJoint(rawParams, parent1, parent2, wakeUp); rawParams.free(); let joint = _impulse_joint__WEBPACK_IMPORTED_MODULE_2__.ImpulseJoint.newTyped(this.raw, bodies, handle); this.map.set(handle, joint); return joint; } /** * Remove a joint from this set. * * @param handle - The integer handle of the joint. * @param wakeUp - If `true`, the rigid-bodies attached by the removed joint will be woken-up automatically. */ remove(handle, wakeUp) { this.raw.remove(handle, wakeUp); this.unmap(handle); } /** * Calls the given closure with the integer handle of each impulse joint attached to this rigid-body. * * @param f - The closure called with the integer handle of each impulse joint attached to the rigid-body. */ forEachJointHandleAttachedToRigidBody(handle, f) { this.raw.forEachJointAttachedToRigidBody(handle, f); } /** * Internal function, do not call directly. * @param handle */ unmap(handle) { this.map.delete(handle); } /** * The number of joints on this set. */ len() { return this.map.len(); } /** * Does this set contain a joint with the given handle? * * @param handle - The joint handle to check. */ contains(handle) { return this.get(handle) != null; } /** * Gets the joint with the given handle. * * Returns `null` if no joint with the specified handle exists. * * @param handle - The integer handle of the joint to retrieve. */ get(handle) { return this.map.get(handle); } /** * Applies the given closure to each joint contained by this set. * * @param f - The closure to apply. */ forEach(f) { this.map.forEach(f); } /** * Gets all joints in the list. * * @returns joint list. */ getAll() { return this.map.getAll(); } } __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/index.js": /*!***********************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/index.js ***! \***********************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CCDSolver: () => (/* reexport safe */ _ccd_solver__WEBPACK_IMPORTED_MODULE_8__.CCDSolver), /* harmony export */ CoefficientCombineRule: () => (/* reexport safe */ _coefficient_combine_rule__WEBPACK_IMPORTED_MODULE_7__.CoefficientCombineRule), /* harmony export */ FixedImpulseJoint: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.FixedImpulseJoint), /* harmony export */ FixedMultibodyJoint: () => (/* reexport safe */ _multibody_joint__WEBPACK_IMPORTED_MODULE_5__.FixedMultibodyJoint), /* harmony export */ ImpulseJoint: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.ImpulseJoint), /* harmony export */ ImpulseJointSet: () => (/* reexport safe */ _impulse_joint_set__WEBPACK_IMPORTED_MODULE_4__.ImpulseJointSet), /* harmony export */ IntegrationParameters: () => (/* reexport safe */ _integration_parameters__WEBPACK_IMPORTED_MODULE_2__.IntegrationParameters), /* harmony export */ IslandManager: () => (/* reexport safe */ _island_manager__WEBPACK_IMPORTED_MODULE_9__.IslandManager), /* harmony export */ JointData: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.JointData), /* harmony export */ JointType: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.JointType), /* harmony export */ MotorModel: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.MotorModel), /* harmony export */ MultibodyJoint: () => (/* reexport safe */ _multibody_joint__WEBPACK_IMPORTED_MODULE_5__.MultibodyJoint), /* harmony export */ MultibodyJointSet: () => (/* reexport safe */ _multibody_joint_set__WEBPACK_IMPORTED_MODULE_6__.MultibodyJointSet), /* harmony export */ PrismaticImpulseJoint: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.PrismaticImpulseJoint), /* harmony export */ PrismaticMultibodyJoint: () => (/* reexport safe */ _multibody_joint__WEBPACK_IMPORTED_MODULE_5__.PrismaticMultibodyJoint), /* harmony export */ RevoluteImpulseJoint: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.RevoluteImpulseJoint), /* harmony export */ RevoluteMultibodyJoint: () => (/* reexport safe */ _multibody_joint__WEBPACK_IMPORTED_MODULE_5__.RevoluteMultibodyJoint), /* harmony export */ RigidBody: () => (/* reexport safe */ _rigid_body__WEBPACK_IMPORTED_MODULE_0__.RigidBody), /* harmony export */ RigidBodyDesc: () => (/* reexport safe */ _rigid_body__WEBPACK_IMPORTED_MODULE_0__.RigidBodyDesc), /* harmony export */ RigidBodySet: () => (/* reexport safe */ _rigid_body_set__WEBPACK_IMPORTED_MODULE_1__.RigidBodySet), /* harmony export */ RigidBodyType: () => (/* reexport safe */ _rigid_body__WEBPACK_IMPORTED_MODULE_0__.RigidBodyType), /* harmony export */ SphericalImpulseJoint: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.SphericalImpulseJoint), /* harmony export */ SphericalMultibodyJoint: () => (/* reexport safe */ _multibody_joint__WEBPACK_IMPORTED_MODULE_5__.SphericalMultibodyJoint), /* harmony export */ UnitImpulseJoint: () => (/* reexport safe */ _impulse_joint__WEBPACK_IMPORTED_MODULE_3__.UnitImpulseJoint), /* harmony export */ UnitMultibodyJoint: () => (/* reexport safe */ _multibody_joint__WEBPACK_IMPORTED_MODULE_5__.UnitMultibodyJoint) /* harmony export */ }); /* harmony import */ var _rigid_body__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rigid_body */ "./node_modules/@dimforge/rapier3d/dynamics/rigid_body.js"); /* harmony import */ var _rigid_body_set__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rigid_body_set */ "./node_modules/@dimforge/rapier3d/dynamics/rigid_body_set.js"); /* harmony import */ var _integration_parameters__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./integration_parameters */ "./node_modules/@dimforge/rapier3d/dynamics/integration_parameters.js"); /* harmony import */ var _impulse_joint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./impulse_joint */ "./node_modules/@dimforge/rapier3d/dynamics/impulse_joint.js"); /* harmony import */ var _impulse_joint_set__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./impulse_joint_set */ "./node_modules/@dimforge/rapier3d/dynamics/impulse_joint_set.js"); /* harmony import */ var _multibody_joint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multibody_joint */ "./node_modules/@dimforge/rapier3d/dynamics/multibody_joint.js"); /* harmony import */ var _multibody_joint_set__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./multibody_joint_set */ "./node_modules/@dimforge/rapier3d/dynamics/multibody_joint_set.js"); /* harmony import */ var _coefficient_combine_rule__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./coefficient_combine_rule */ "./node_modules/@dimforge/rapier3d/dynamics/coefficient_combine_rule.js"); /* harmony import */ var _ccd_solver__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ccd_solver */ "./node_modules/@dimforge/rapier3d/dynamics/ccd_solver.js"); /* harmony import */ var _island_manager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./island_manager */ "./node_modules/@dimforge/rapier3d/dynamics/island_manager.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_rigid_body__WEBPACK_IMPORTED_MODULE_0__, _rigid_body_set__WEBPACK_IMPORTED_MODULE_1__, _integration_parameters__WEBPACK_IMPORTED_MODULE_2__, _impulse_joint__WEBPACK_IMPORTED_MODULE_3__, _impulse_joint_set__WEBPACK_IMPORTED_MODULE_4__, _multibody_joint__WEBPACK_IMPORTED_MODULE_5__, _multibody_joint_set__WEBPACK_IMPORTED_MODULE_6__, _ccd_solver__WEBPACK_IMPORTED_MODULE_8__, _island_manager__WEBPACK_IMPORTED_MODULE_9__]); ([_rigid_body__WEBPACK_IMPORTED_MODULE_0__, _rigid_body_set__WEBPACK_IMPORTED_MODULE_1__, _integration_parameters__WEBPACK_IMPORTED_MODULE_2__, _impulse_joint__WEBPACK_IMPORTED_MODULE_3__, _impulse_joint_set__WEBPACK_IMPORTED_MODULE_4__, _multibody_joint__WEBPACK_IMPORTED_MODULE_5__, _multibody_joint_set__WEBPACK_IMPORTED_MODULE_6__, _ccd_solver__WEBPACK_IMPORTED_MODULE_8__, _island_manager__WEBPACK_IMPORTED_MODULE_9__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__); __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/integration_parameters.js": /*!****************************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/integration_parameters.js ***! \****************************************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ IntegrationParameters: () => (/* binding */ IntegrationParameters) /* harmony export */ }); /* harmony import */ var _raw__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../raw */ "./node_modules/@dimforge/rapier3d/rapier_wasm3d_bg.js"); var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_raw__WEBPACK_IMPORTED_MODULE_0__]); _raw__WEBPACK_IMPORTED_MODULE_0__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0]; class IntegrationParameters { constructor(raw) { this.raw = raw || new _raw__WEBPACK_IMPORTED_MODULE_0__.RawIntegrationParameters(); } /** * Free the WASM memory used by these integration parameters. */ free() { if (!!this.raw) { this.raw.free(); } this.raw = undefined; } /** * The timestep length (default: `1.0 / 60.0`) */ get dt() { return this.raw.dt; } /** * The Error Reduction Parameter in `[0, 1]` is the proportion of * the positional error to be corrected at each time step (default: `0.2`). */ get erp() { return this.raw.erp; } /** * Amount of penetration the engine wont attempt to correct (default: `0.001m`). */ get allowedLinearError() { return this.raw.allowedLinearError; } /** * The maximal distance separating two objects that will generate predictive contacts (default: `0.002`). */ get predictionDistance() { return this.raw.predictionDistance; } /** * Maximum number of iterations performed by the velocity constraints solver (default: `4`). */ get maxVelocityIterations() { return this.raw.maxVelocityIterations; } /** * Maximum number of friction iterations performed by the position-based constraints solver (default: `1`). */ get maxVelocityFrictionIterations() { return this.raw.maxVelocityFrictionIterations; } /** * Maximum number of stabilization iterations performed by the position-based constraints solver (default: `1`). */ get maxStabilizationIterations() { return this.raw.maxStabilizationIterations; } /** * Minimum number of dynamic bodies in each active island (default: `128`). */ get minIslandSize() { return this.raw.minIslandSize; } /** * Maximum number of substeps performed by the solver (default: `1`). */ get maxCcdSubsteps() { return this.raw.maxCcdSubsteps; } set dt(value) { this.raw.dt = value; } set erp(value) { this.raw.erp = value; } set allowedLinearError(value) { this.raw.allowedLinearError = value; } set predictionDistance(value) { this.raw.predictionDistance = value; } set maxVelocityIterations(value) { this.raw.maxVelocityIterations = value; } set maxVelocityFrictionIterations(value) { this.raw.maxVelocityFrictionIterations = value; } set maxStabilizationIterations(value) { this.raw.maxStabilizationIterations = value; } set minIslandSize(value) { this.raw.minIslandSize = value; } set maxCcdSubsteps(value) { this.raw.maxCcdSubsteps = value; } } __webpack_async_result__(); } catch(e) { __webpack_async_result__(e); } }); /***/ }), /***/ "./node_modules/@dimforge/rapier3d/dynamics/island_manager.js": /*!********************************************************************!*\ !*** ./node_modules/@dimforge/rapier3d/dynamics/island_manager.js ***! \********************************************************************/ /***/ ((module, __webpack_exports__, __webpack_require__) => { __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ IslandManager: () => (/* binding */ IslandManager) /* harmony expor