|
@@ -315,9 +315,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! three */ "three");
|
|
|
/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_2__);
|
|
|
-/* harmony import */ var _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @dimforge/rapier3d-compat */ "./node_modules/@dimforge/rapier3d-compat/rapier.es.js");
|
|
|
+/* harmony import */ var _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @dimforge/rapier3d-compat */ "./node_modules/@dimforge/rapier3d-compat/rapier.es.js");
|
|
|
/* harmony import */ var _RE_RogueEngine_rogue_rapier_Components_RapierBody_re__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @RE/RogueEngine/rogue-rapier/Components/RapierBody.re */ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/RapierBody.re.ts");
|
|
|
-/* harmony import */ var _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @RE/RogueEngine/rogue-rapier/Lib/RogueRapier */ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Lib/RogueRapier.ts");
|
|
|
+/* harmony import */ var _RE_RogueEngine_rogue_rapier_Components_RapierConfig_re__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @RE/RogueEngine/rogue-rapier/Components/RapierConfig.re */ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/RapierConfig.re.ts");
|
|
|
+/* harmony import */ var _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @RE/RogueEngine/rogue-rapier/Lib/RogueRapier */ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Lib/RogueRapier.ts");
|
|
|
var __defProp = Object.defineProperty;
|
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
@@ -336,6 +337,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__.Component {
|
|
|
constructor() {
|
|
|
super(...arguments);
|
|
@@ -345,9 +347,17 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
this.useCameraForward = true;
|
|
|
this.useObjectForward = false;
|
|
|
this.velocity = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 0, 0);
|
|
|
+ this.gravityAcceleration = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 0, 0);
|
|
|
this.drag = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(2e-3, 2e-3, 2e-3);
|
|
|
+ this.snapToGroundDistance = 1;
|
|
|
+ this.autostepMaxHeight = 0.7;
|
|
|
+ this.autostepMinWidth = 0.3;
|
|
|
+ this.autostepIncludeDynamicBodies = true;
|
|
|
+ this.gravityScale = 2;
|
|
|
+ this.minimumHeight = -10;
|
|
|
+ this.resetPosition = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 0, 0);
|
|
|
this.scaledVelocity = new three__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 0, 0);
|
|
|
- this.rapierScaledVelocity = new _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__["default"].Vector3(0, 0, 0);
|
|
|
+ this.rapierScaledVelocity = new _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_6__["default"].Vector3(0, 0, 0);
|
|
|
this.elapsed = 0;
|
|
|
this.thrust = false;
|
|
|
this.brake = false;
|
|
@@ -362,14 +372,17 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
start() {
|
|
|
this.cameraVectorCalculator = new _GetForwardVector__WEBPACK_IMPORTED_MODULE_0__["default"](rogue_engine__WEBPACK_IMPORTED_MODULE_1__.Runtime.camera);
|
|
|
this.objectVectorCalculator = new _GetForwardVector__WEBPACK_IMPORTED_MODULE_0__["default"](this.object3d);
|
|
|
+ this.config = rogue_engine__WEBPACK_IMPORTED_MODULE_1__.getComponent(_RE_RogueEngine_rogue_rapier_Components_RapierConfig_re__WEBPACK_IMPORTED_MODULE_4__["default"]);
|
|
|
}
|
|
|
beforeUpdate() {
|
|
|
- if (!_RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__["default"].initialized)
|
|
|
+ if (!_RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_5__["default"].initialized)
|
|
|
return;
|
|
|
!this.initialized && this.init();
|
|
|
}
|
|
|
init() {
|
|
|
- this.characterController = _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__["default"].world.createCharacterController(0.1);
|
|
|
+ this.characterController = _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_5__["default"].world.createCharacterController(0.1);
|
|
|
+ this.characterController.enableAutostep(this.autostepMaxHeight, this.autostepMinWidth, this.autostepIncludeDynamicBodies);
|
|
|
+ this.characterController.enableSnapToGround(this.snapToGroundDistance);
|
|
|
this.characterController.setCharacterMass(100);
|
|
|
this.characterController.setApplyImpulsesToDynamicBodies(true);
|
|
|
}
|
|
@@ -396,6 +409,8 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
if (this.strafeRight) {
|
|
|
this.moveRight(1 * this.speed);
|
|
|
}
|
|
|
+ this.gravityAcceleration.set(this.config.gravity.x, this.config.gravity.y, this.config.gravity.z);
|
|
|
+ this.velocity.add(this.gravityAcceleration.multiplyScalar(this.gravityScale * rogue_engine__WEBPACK_IMPORTED_MODULE_1__.Runtime.deltaTime));
|
|
|
const fixedStep = rogue_engine__WEBPACK_IMPORTED_MODULE_1__.Runtime.deltaTime;
|
|
|
const nextPosition = this.bodyComponent.body.translation();
|
|
|
const nextVelocity = this.convertRapierToThreeVec3(this.bodyComponent.body.linvel());
|
|
@@ -413,6 +428,11 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
nextPosition.x += characterMovement.x;
|
|
|
nextPosition.y += characterMovement.y;
|
|
|
nextPosition.z += characterMovement.z;
|
|
|
+ if (nextPosition.y < this.minimumHeight) {
|
|
|
+ nextPosition.x = this.resetPosition.x;
|
|
|
+ nextPosition.y = this.resetPosition.y;
|
|
|
+ nextPosition.z = this.resetPosition.z;
|
|
|
+ }
|
|
|
this.bodyComponent.body.setNextKinematicTranslation(nextPosition);
|
|
|
this.thrust = false;
|
|
|
this.brake = false;
|
|
@@ -503,6 +523,27 @@ __decorateClass([
|
|
|
__decorateClass([
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.vector3()
|
|
|
], RapierMovementController.prototype, "drag", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
+], RapierMovementController.prototype, "snapToGroundDistance", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
+], RapierMovementController.prototype, "autostepMaxHeight", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
+], RapierMovementController.prototype, "autostepMinWidth", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.checkbox()
|
|
|
+], RapierMovementController.prototype, "autostepIncludeDynamicBodies", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
+], RapierMovementController.prototype, "gravityScale", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
+], RapierMovementController.prototype, "minimumHeight", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.vector3()
|
|
|
+], RapierMovementController.prototype, "resetPosition", 2);
|
|
|
__decorateClass([
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.checkbox()
|
|
|
], RapierMovementController.prototype, "thrust", 2);
|