|
@@ -127,12 +127,23 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ "three");
|
|
|
/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
var __defProp = Object.defineProperty;
|
|
|
+var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
|
+var __decorateClass = (decorators, target, key, kind) => {
|
|
|
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
|
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
|
+ if (decorator = decorators[i])
|
|
|
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
|
+ if (kind && result)
|
|
|
+ __defProp(target, key, result);
|
|
|
+ return result;
|
|
|
+};
|
|
|
|
|
|
|
|
|
class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
|
|
|
constructor() {
|
|
|
super(...arguments);
|
|
|
+ this.normalBias = 0.04;
|
|
|
this.initialOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
|
|
|
this.currentOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
|
|
|
}
|
|
@@ -146,20 +157,31 @@ class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMP
|
|
|
}
|
|
|
start() {
|
|
|
const directionalLight = this.getDirectionalLight();
|
|
|
- this.initialOffset.copy(directionalLight.position);
|
|
|
- this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
|
|
|
- this.updatePositions();
|
|
|
- directionalLight.target = this.getCamera();
|
|
|
+ if (this.target) {
|
|
|
+ this.initialOffset.copy(directionalLight.position);
|
|
|
+ this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
|
|
|
+ directionalLight.target = this.target;
|
|
|
+ } else {
|
|
|
+ this.initialOffset.copy(directionalLight.position);
|
|
|
+ this.initialOffset.sub(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0));
|
|
|
+ directionalLight.target = this.getCamera();
|
|
|
+ }
|
|
|
if (directionalLight.shadow) {
|
|
|
- directionalLight.shadow.normalBias = 0.04;
|
|
|
+ directionalLight.shadow.normalBias = this.normalBias;
|
|
|
}
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.log(`initial: ${this.initialOffset.x}, ${this.initialOffset.y}, ${this.initialOffset.z}`);
|
|
|
}
|
|
|
update() {
|
|
|
this.updatePositions();
|
|
|
}
|
|
|
updatePositions() {
|
|
|
const directionalLight = this.getDirectionalLight();
|
|
|
- this.currentOffset.copy(this.initialOffset).add(this.getCamera().position);
|
|
|
+ if (this.target) {
|
|
|
+ this.currentOffset.copy(this.target.position).add(this.initialOffset);
|
|
|
+ } else {
|
|
|
+ this.currentOffset.copy(this.getCamera().position).add(this.initialOffset);
|
|
|
+ }
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.log(`update: ${this.currentOffset.x}, ${this.currentOffset.y}, ${this.currentOffset.z}`);
|
|
|
directionalLight.position.set(this.currentOffset.x, this.currentOffset.y, this.currentOffset.z);
|
|
|
if (directionalLight.shadow) {
|
|
|
directionalLight.shadow.camera.position.set(this.currentOffset.x, this.currentOffset.y, this.currentOffset.z);
|
|
@@ -167,6 +189,12 @@ class DirectionalLightShadowFixForMobileCamera extends rogue_engine__WEBPACK_IMP
|
|
|
}
|
|
|
}
|
|
|
__name(DirectionalLightShadowFixForMobileCamera, "DirectionalLightShadowFixForMobileCamera");
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
|
|
|
+], DirectionalLightShadowFixForMobileCamera.prototype, "normalBias", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
|
|
|
+], DirectionalLightShadowFixForMobileCamera.prototype, "target", 2);
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(DirectionalLightShadowFixForMobileCamera);
|
|
|
|
|
|
|
|
@@ -289,6 +317,13 @@ class PlayerPawnInput extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Componen
|
|
|
this.movementController.rotateRight = true;
|
|
|
}
|
|
|
}
|
|
|
+ if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Space")) {
|
|
|
+ this.movementController.jump = true;
|
|
|
+ }
|
|
|
+ if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyUp("Space")) {
|
|
|
+ this.movementController.jump = false;
|
|
|
+ this.movementController.hasJumped = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
__name(PlayerPawnInput, "PlayerPawnInput");
|
|
@@ -354,6 +389,9 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
this.autostepMinWidth = 0.3;
|
|
|
this.autostepIncludeDynamicBodies = true;
|
|
|
this.gravityScale = 2;
|
|
|
+ this.jumpHeight = 5;
|
|
|
+ this.isFalling = false;
|
|
|
+ this.hasJumped = false;
|
|
|
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);
|
|
@@ -365,6 +403,7 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
this.strafeRight = false;
|
|
|
this.rotateLeft = false;
|
|
|
this.rotateRight = false;
|
|
|
+ this.jump = false;
|
|
|
}
|
|
|
awake() {
|
|
|
this.bodyComponent = rogue_engine__WEBPACK_IMPORTED_MODULE_1__.getComponent(_RE_RogueEngine_rogue_rapier_Components_RapierBody_re__WEBPACK_IMPORTED_MODULE_3__["default"], this.object3d);
|
|
@@ -409,9 +448,13 @@ 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;
|
|
|
+ if (this.jump && !this.isFalling && !this.hasJumped) {
|
|
|
+ this.velocity.y += this.jumpHeight * 1e3 * fixedStep;
|
|
|
+ this.hasJumped = true;
|
|
|
+ }
|
|
|
+ this.gravityAcceleration.set(this.config.gravity.x, this.config.gravity.y, this.config.gravity.z);
|
|
|
+ this.velocity.add(this.gravityAcceleration.multiplyScalar(this.gravityScale * fixedStep));
|
|
|
const nextPosition = this.bodyComponent.body.translation();
|
|
|
const nextVelocity = this.convertRapierToThreeVec3(this.bodyComponent.body.linvel());
|
|
|
nextVelocity.x *= 1 - this.drag.x;
|
|
@@ -425,6 +468,11 @@ class RapierMovementController extends rogue_engine__WEBPACK_IMPORTED_MODULE_1__
|
|
|
nextVelocity.z += this.velocity.z;
|
|
|
this.characterController.computeColliderMovement(this.bodyComponent.body.collider(0), nextVelocity.clone().multiplyScalar(fixedStep));
|
|
|
const characterMovement = this.characterController.computedMovement();
|
|
|
+ if (this.characterController.computedGrounded()) {
|
|
|
+ this.isFalling = false;
|
|
|
+ } else {
|
|
|
+ this.isFalling = true;
|
|
|
+ }
|
|
|
nextPosition.x += characterMovement.x;
|
|
|
nextPosition.y += characterMovement.y;
|
|
|
nextPosition.z += characterMovement.z;
|
|
@@ -538,6 +586,9 @@ __decorateClass([
|
|
|
__decorateClass([
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
], RapierMovementController.prototype, "gravityScale", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
+], RapierMovementController.prototype, "jumpHeight", 2);
|
|
|
__decorateClass([
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.num()
|
|
|
], RapierMovementController.prototype, "minimumHeight", 2);
|
|
@@ -562,6 +613,9 @@ __decorateClass([
|
|
|
__decorateClass([
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.checkbox()
|
|
|
], RapierMovementController.prototype, "rotateRight", 2);
|
|
|
+__decorateClass([
|
|
|
+ rogue_engine__WEBPACK_IMPORTED_MODULE_1__.props.checkbox()
|
|
|
+], RapierMovementController.prototype, "jump", 2);
|
|
|
rogue_engine__WEBPACK_IMPORTED_MODULE_1__.registerComponent(RapierMovementController);
|
|
|
|
|
|
|