1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("rogue-engine"), require("three"));
- else if(typeof define === 'function' && define.amd)
- define(["rogue-engine", "three"], factory);
- else if(typeof exports === 'object')
- exports["rogue-engine-user-scripts"] = factory(require("rogue-engine"), require("three"));
- else
- root["rogue-engine-user-scripts"] = factory(root["rogue-engine"], root["three"]);
- })(self, function(__WEBPACK_EXTERNAL_MODULE_rogue_engine__, __WEBPACK_EXTERNAL_MODULE_three__) {
- return /******/ (() => { // webpackBootstrap
- /******/ "use strict";
- /******/ var __webpack_modules__ = ({
- /***/ "./Assets/Components/DungeonGenerator.re.ts":
- /*!**************************************************!*\
- !*** ./Assets/Components/DungeonGenerator.re.ts ***!
- \**************************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ DungeonGenerator)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- var __defProp = Object.defineProperty;
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
- class DungeonGenerator extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- awake() {
- }
- start() {
- }
- update() {
- }
- }
- __name(DungeonGenerator, "DungeonGenerator");
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(DungeonGenerator);
- /***/ }),
- /***/ "./Assets/Components/EnemyAI.re.ts":
- /*!*****************************************!*\
- !*** ./Assets/Components/EnemyAI.re.ts ***!
- \*****************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ EnemyAI)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- /* 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__);
- /* harmony import */ var _WorldFPSController_re__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorldFPSController.re */ "./Assets/Components/WorldFPSController.re.ts");
- 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 EnemyAI extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- constructor() {
- super(...arguments);
- this.movementSpeed = 0.3;
- this.attackDistance = 0.3;
- this.targetPosition = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
- }
- awake() {
- if (!this.target) {
- let gameLogic = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.getObjectByName("GameLogic");
- this.target = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.getObjectByName("Player") || new three__WEBPACK_IMPORTED_MODULE_1__.Object3D();
- this.targetPosition = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.getComponent(_WorldFPSController_re__WEBPACK_IMPORTED_MODULE_2__["default"], gameLogic)?.characterOffset.position || this.target.position;
- } else {
- this.targetPosition = this.target.position;
- }
- }
- start() {
- }
- update() {
- const deltaTime = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.deltaTime;
- this.object3d.lookAt(this.target.position);
- let movementVector = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 1);
- if (this.object3d.position.distanceTo(this.targetPosition) <= this.attackDistance) {
- movementVector.set(0, 0, 0);
- }
- movementVector.transformDirection(this.object3d.matrix).multiplyScalar(this.movementSpeed * deltaTime);
- this.object3d.position.x += movementVector.x;
- this.object3d.position.z += movementVector.z;
- }
- }
- __name(EnemyAI, "EnemyAI");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
- ], EnemyAI.prototype, "target", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], EnemyAI.prototype, "movementSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], EnemyAI.prototype, "attackDistance", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(EnemyAI);
- /***/ }),
- /***/ "./Assets/Components/FPSController.re.ts":
- /*!***********************************************!*\
- !*** ./Assets/Components/FPSController.re.ts ***!
- \***********************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ FPSController)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- /* 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;
- };
- const fwdDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, -1);
- const bwdDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 1);
- const leftDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(-1, 0, 0);
- const rightDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(1, 0, 0);
- class FPSController extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- constructor() {
- super(...arguments);
- this.rotSpeed = 1;
- this.minCameraRotY = -1.5708;
- this.maxCameraRotY = 1.5708;
- this.cameraHeight = 0.4;
- this.walkSpeed = 2;
- this.fwdSpeedMultiplier = 1.3;
- this.runSpeedMultiplier = 1.8;
- }
- awake() {
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.lock();
- this.camera = new three__WEBPACK_IMPORTED_MODULE_1__.PerspectiveCamera();
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.add(this.camera);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.activeCamera = this.camera.uuid;
- this.camera.position.copy(this.character.position);
- this.camera.position.y += this.cameraHeight;
- this.camera.rotation.copy(this.character.rotation);
- const appContainer = document.getElementById("rogue-app");
- if (!appContainer)
- return;
- appContainer.onmousedown = (e) => {
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.lock();
- };
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.onStop(() => {
- if (!appContainer)
- return;
- appContainer.onmousedown = null;
- });
- this.camera.rotation.order = "YXZ";
- this.character.rotation.order = "YXZ";
- this.camera.up.set(0, 1, 0);
- }
- update() {
- const deltaTime = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.deltaTime;
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.isMoving && document.pointerLockElement) {
- const mouseDeltaX = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementX * this.rotSpeed * deltaTime;
- const mouseDeltaY = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementY * this.rotSpeed * deltaTime;
- this.character.rotation.set(this.character.rotation.x, this.character.rotation.y - mouseDeltaX, this.character.rotation.z);
- this.camera.rotation.set(this.camera.rotation.x - mouseDeltaY, this.character.rotation.y, this.camera.rotation.z);
- this.camera.rotation.x = Math.max(this.minCameraRotY, Math.min(this.maxCameraRotY, this.camera.rotation.x));
- }
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Escape") && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.unlock();
- let actualSpeed = this.walkSpeed;
- let onlyFwd = true;
- const movementVector = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyDown("Space")) {
- }
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyW")) {
- movementVector.add(fwdDirection);
- } else if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyS")) {
- movementVector.add(bwdDirection);
- onlyFwd = false;
- }
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyA")) {
- movementVector.add(leftDirection);
- onlyFwd = false;
- } else if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyD")) {
- movementVector.add(rightDirection);
- onlyFwd = false;
- }
- if (onlyFwd) {
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("ShiftLeft")) {
- actualSpeed *= this.runSpeedMultiplier;
- } else {
- actualSpeed *= this.fwdSpeedMultiplier;
- }
- }
- movementVector.normalize();
- if (movementVector.length() > 0) {
- movementVector.copy(movementVector.transformDirection(this.character.matrix).multiplyScalar(actualSpeed * deltaTime));
- this.character.position.x += movementVector.x;
- this.character.position.z += movementVector.z;
- }
- this.camera.position.set(this.character.position.x, this.character.position.y + this.cameraHeight, this.character.position.z);
- }
- }
- __name(FPSController, "FPSController");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], FPSController.prototype, "rotSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num(-Math.PI / 2, 0)
- ], FPSController.prototype, "minCameraRotY", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num(0, Math.PI / 2)
- ], FPSController.prototype, "maxCameraRotY", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], FPSController.prototype, "cameraHeight", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], FPSController.prototype, "walkSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], FPSController.prototype, "fwdSpeedMultiplier", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], FPSController.prototype, "runSpeedMultiplier", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
- ], FPSController.prototype, "character", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(FPSController);
- /***/ }),
- /***/ "./Assets/Components/Flashlight.re.ts":
- /*!********************************************!*\
- !*** ./Assets/Components/Flashlight.re.ts ***!
- \********************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ Flashlight)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- var __defProp = Object.defineProperty;
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
- class Flashlight extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- awake() {
- }
- start() {
- this.object3d.getObjectByName("Spotlight")?.lookAt(this.object3d.position.x, this.object3d.position.y - 0.4, this.object3d.position.z - 1);
- }
- update() {
- }
- }
- __name(Flashlight, "Flashlight");
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(Flashlight);
- /***/ }),
- /***/ "./Assets/Components/MeshGrid.re.ts":
- /*!******************************************!*\
- !*** ./Assets/Components/MeshGrid.re.ts ***!
- \******************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ MeshGrid)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- 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 MeshGrid extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- constructor() {
- super(...arguments);
- this.allModels = [];
- }
- awake() {
- let x = 0;
- let z = 0;
- if (this.allModels.length > 0) {
- this.allModels.forEach((prefab) => {
- let model = prefab.instantiate(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene);
- model.position.set(x + 0.5 * x, 0, z + 0.5 * z);
- x++;
- if (x == 6) {
- x = 0;
- z++;
- }
- });
- }
- }
- start() {
- }
- update() {
- }
- }
- __name(MeshGrid, "MeshGrid");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.list.prefab()
- ], MeshGrid.prototype, "allModels", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(MeshGrid);
- /***/ }),
- /***/ "./Assets/Components/OrbitCamera.re.js":
- /*!*********************************************!*\
- !*** ./Assets/Components/OrbitCamera.re.js ***!
- \*********************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ OrbitCamera)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- /* 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 OrbitCamera extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- constructor() {
- super(...arguments);
- this.rotateStart = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
- this.rotateEnd = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
- this.rotateDelta = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2();
- this.enableRotate = true;
- this.rotateSpeed = 1;
- this.minAzimuthAngle = -Infinity;
- this.maxAzimuthAngle = Infinity;
- this.minPolarAngle = 0;
- this.maxPolarAngle = Math.PI;
- this.enableDolly = true;
- this.dollySpeed = 1;
- this.minDistance = 1;
- this.maxDistance = 50;
- this.scale = 1;
- this.EPS = 1e-6;
- this.twoPI = 2 * Math.PI;
- this.spherical = new three__WEBPACK_IMPORTED_MODULE_1__.Spherical();
- this.sphericalDelta = new three__WEBPACK_IMPORTED_MODULE_1__.Spherical();
- this.offset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
- this.rotateMouseButton = 2;
- this.quat = new three__WEBPACK_IMPORTED_MODULE_1__.Quaternion().setFromUnitVectors(new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 1, 0), new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 1, 0));
- this.quatInverse = this.quat.clone().invert();
- this.lastPosition = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
- this.lastQuaternion = new three__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
- this.initialOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
- }
- awake() {
- }
- start() {
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.rogueDOMContainer.addEventListener("contextmenu", (event) => {
- event.preventDefault();
- });
- this.quat = new three__WEBPACK_IMPORTED_MODULE_1__.Quaternion().setFromUnitVectors(this.object3d.up, new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 1, 0));
- this.quatInverse = this.quat.clone().invert();
- this.initialOffset.copy(this.object3d.position).sub(this.target.position);
- this.offset.copy(this.initialOffset);
- }
- update() {
- let normalizedScreenPosition = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2(0, 0);
- this.normalizeScreenInput(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse, normalizedScreenPosition);
- if (this.enableRotate && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.getButtonDown(this.rotateMouseButton)) {
- this.rotateStart.set(normalizedScreenPosition.x, normalizedScreenPosition.y);
- }
- if (this.enableRotate && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.getButtonPressed(this.rotateMouseButton)) {
- this.rotateEnd.set(normalizedScreenPosition.x, normalizedScreenPosition.y);
- this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
- this.rotateLeft(this.twoPI * this.rotateDelta.x);
- this.rotateUp(this.twoPI * -this.rotateDelta.y);
- this.rotateStart.copy(this.rotateEnd);
- }
- if (this.enableDolly && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.wheelY > 0) {
- this.dollyOut();
- }
- if (this.enableDolly && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.wheelY < 0) {
- this.dollyIn();
- }
- this.updateCamera();
- }
- rotateLeft(angle) {
- this.sphericalDelta.theta -= angle;
- }
- rotateUp(angle) {
- this.sphericalDelta.phi -= angle;
- }
- updateCamera() {
- this.offset.applyQuaternion(this.quat);
- this.spherical.setFromVector3(this.offset);
- this.spherical.theta += this.sphericalDelta.theta;
- this.spherical.phi += this.sphericalDelta.phi;
- let min = this.minAzimuthAngle;
- let max = this.maxAzimuthAngle;
- if (isFinite(min) && isFinite(max)) {
- if (min < -Math.PI) {
- min += this.twoPI;
- } else if (min > Math.PI) {
- min -= this.twoPI;
- }
- if (max < -Math.PI) {
- max += this.twoPI;
- } else if (max > Math.PI) {
- max -= this.twoPI;
- }
- if (min <= max) {
- this.spherical.theta = Math.max(min, Math.min(max, this.spherical.theta));
- } else {
- this.spherical.theta = this.spherical.theta > (min + max) / 2 ? Math.max(min, this.spherical.theta) : Math.min(max, this.spherical.theta);
- }
- }
- this.spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this.spherical.phi));
- this.spherical.makeSafe();
- this.spherical.radius *= this.scale;
- this.spherical.radius = Math.max(this.minDistance, Math.min(this.maxDistance, this.spherical.radius));
- this.offset.setFromSpherical(this.spherical);
- this.offset.applyQuaternion(this.quatInverse);
- this.object3d.position.copy(this.target.position).add(this.offset);
- this.object3d.lookAt(this.target.position);
- this.sphericalDelta.set(0, 0, 0);
- this.scale = 1;
- if (this.lastPosition.distanceToSquared(this.object3d.position) > this.EPS || 8 * (1 - this.lastQuaternion.dot(this.object3d.quaternion)) > this.EPS) {
- this.lastPosition.copy(this.object3d.position);
- this.lastQuaternion.copy(this.object3d.quaternion);
- }
- }
- dollyOut() {
- this.scale /= Math.pow(0.95, this.dollySpeed);
- }
- dollyIn() {
- this.scale *= Math.pow(0.95, this.dollySpeed);
- }
- normalizeScreenInput(browserVector, gameVector) {
- const bounds = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.rogueDOMContainer.getBoundingClientRect();
- gameVector.x = (browserVector.x - bounds.left) / bounds.width * 2 - 1;
- gameVector.y = -((browserVector.y - bounds.top) / bounds.height) * 2 + 1;
- }
- }
- __name(OrbitCamera, "OrbitCamera");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
- ], OrbitCamera.prototype, "target", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.checkbox()
- ], OrbitCamera.prototype, "enableRotate", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "rotateSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "minAzimuthAngle", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "maxAzimuthAngle", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "minPolarAngle", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "maxPolarAngle", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.checkbox()
- ], OrbitCamera.prototype, "enableDolly", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "dollySpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "minDistance", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "maxDistance", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.vector3()
- ], OrbitCamera.prototype, "offset", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], OrbitCamera.prototype, "rotateMouseButton", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(OrbitCamera);
- /***/ }),
- /***/ "./Assets/Components/RaycastReceiver.re.js":
- /*!*************************************************!*\
- !*** ./Assets/Components/RaycastReceiver.re.js ***!
- \*************************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ RaycastReceiver)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- var __defProp = Object.defineProperty;
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
- class RaycastReceiver extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- onMouseOver(intersect) {
- throw new Error("Abstract class: Please inherit from this class to use it's behavior");
- }
- onMouseOut() {
- throw new Error("Abstract class: Please inherit from this class to use it's behavior");
- }
- }
- __name(RaycastReceiver, "RaycastReceiver");
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(RaycastReceiver);
- /***/ }),
- /***/ "./Assets/Components/RaycastReporter.re.js":
- /*!*************************************************!*\
- !*** ./Assets/Components/RaycastReporter.re.js ***!
- \*************************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ RaycastReporter)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- /* 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__);
- /* harmony import */ var _RaycastReceiver_re__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RaycastReceiver.re */ "./Assets/Components/RaycastReceiver.re.js");
- 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 RaycastReporter extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- constructor() {
- super(...arguments);
- this.receiverClass = ["RaycastReceiver"];
- this.allHovered = [];
- }
- awake() {
- }
- start() {
- this.mouse = new three__WEBPACK_IMPORTED_MODULE_1__.Vector2(0, 0);
- this.raycaster = new three__WEBPACK_IMPORTED_MODULE_1__.Raycaster();
- this.updated = false;
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.touch.enabled = true;
- }
- normalizeScreenInput(browserVector, gameVector) {
- const bounds = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.rogueDOMContainer.getBoundingClientRect();
- gameVector.x = (browserVector.x - bounds.left) / bounds.width * 2 - 1;
- gameVector.y = -((browserVector.y - bounds.top) / bounds.height) * 2 + 1;
- }
- getMouseInput() {
- if (!rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.isMoving) {
- return;
- }
- this.normalizeScreenInput(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse, this.mouse);
- this.updated = true;
- }
- getTouchInput() {
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.touch.touches.length == 0) {
- return;
- }
- this.normalizeScreenInput(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.touch.touches[0], this.mouse);
- this.updated = true;
- }
- update() {
- this.updated = false;
- this.getMouseInput();
- this.getTouchInput();
- if (!this.updated) {
- return;
- }
- this.raycaster.setFromCamera(this.mouse, this.object3d);
- let intersects = this.raycaster.intersectObjects(rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.children);
- let listeningComponents = [];
- intersects.forEach((intersect) => {
- let object3d = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.getObjectByProperty("uuid", intersect.object.uuid);
- let component = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.getComponent(_RaycastReceiver_re__WEBPACK_IMPORTED_MODULE_2__["default"], object3d);
- while (component == null && object3d.parent != null) {
- object3d = object3d.parent;
- component = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.getComponent(_RaycastReceiver_re__WEBPACK_IMPORTED_MODULE_2__["default"], object3d);
- }
- if (component != null) {
- listeningComponents = listeningComponents.filter((dataThing) => {
- dataThing.component.object3d.uuid != component.object3d.uuid;
- });
- listeningComponents.push({ component, intersect });
- }
- });
- for (let i = 0; i < this.allHovered.length; i++) {
- let dataThing = this.allHovered[i];
- if (!listeningComponents.includes(dataThing)) {
- dataThing.component.onMouseOut();
- }
- }
- this.allHovered = [];
- for (let i = 0; i < listeningComponents.length; i++) {
- let dataThing = listeningComponents[i];
- this.allHovered.push(dataThing);
- if (dataThing.component.onMouseOver(dataThing.intersect) === false) {
- break;
- }
- }
- }
- }
- __name(RaycastReporter, "RaycastReporter");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.PropList("String")
- ], RaycastReporter.prototype, "receiverClass", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(RaycastReporter);
- /***/ }),
- /***/ "./Assets/Components/TileRaycastReceiver.re.js":
- /*!*****************************************************!*\
- !*** ./Assets/Components/TileRaycastReceiver.re.js ***!
- \*****************************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ TileRaycastReceiver)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- /* harmony import */ var _RaycastReceiver_re__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RaycastReceiver.re */ "./Assets/Components/RaycastReceiver.re.js");
- /* 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__);
- 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 TileRaycastReceiver extends _RaycastReceiver_re__WEBPACK_IMPORTED_MODULE_1__["default"] {
- constructor() {
- super(...arguments);
- this.tileSize = new three__WEBPACK_IMPORTED_MODULE_2__.Vector2(1, 1);
- this.isHovered = false;
- }
- onMouseOver(intersect) {
- this.isHovered = true;
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.rogueDOMContainer.style.cursor = "pointer";
- }
- onMouseOut() {
- if (this.isHovered) {
- this.isHovered = false;
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.rogueDOMContainer.style.cursor = "default";
- }
- }
- getPosition() {
- return this.object3d.position;
- }
- awake() {
- }
- start() {
- }
- update() {
- if (!this.isHovered) {
- return;
- }
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.getButtonDown(0) || rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.touch.touches.length == 1) {
- let target = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.getObjectByName("CameraTarget");
- if (!target) {
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Debug.logWarning("didn't find CameraTarget Object3D");
- return;
- }
- target.position.set(this.object3d.position.x, this.object3d.position.y, this.object3d.position.z);
- }
- }
- }
- __name(TileRaycastReceiver, "TileRaycastReceiver");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.vector2()
- ], TileRaycastReceiver.prototype, "tileSize", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(TileRaycastReceiver);
- /***/ }),
- /***/ "./Assets/Components/WorldFPSController.re.ts":
- /*!****************************************************!*\
- !*** ./Assets/Components/WorldFPSController.re.ts ***!
- \****************************************************/
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
- __webpack_require__.r(__webpack_exports__);
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
- /* harmony export */ "default": () => (/* binding */ WorldFPSController)
- /* harmony export */ });
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
- /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
- /* 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;
- };
- const fwdDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, -1);
- const bwdDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 1);
- const leftDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(-1, 0, 0);
- const rightDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(1, 0, 0);
- const upDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 1, 0);
- const downDirection = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, -1, 0);
- class WorldFPSController extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
- constructor() {
- super(...arguments);
- this.horizontalLookSpeed = 360;
- this.verticalLookSpeed = 180;
- this.minCameraRotY = -1.5708;
- this.maxCameraRotY = 1.5708;
- this.cameraHeight = 0.4;
- this.walkSpeed = 2;
- this.fwdSpeedMultiplier = 1.3;
- this.runSpeedMultiplier = 1.8;
- this.characterOffset = new three__WEBPACK_IMPORTED_MODULE_1__.Object3D();
- }
- awake() {
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.lock();
- this.characterOffset.position.copy(this.character.position);
- this.mainCamera.position.set(0, 0, 0);
- this.character.position.set(0, 0, 0);
- this.mainCamera.position.y += this.cameraHeight;
- this.mainCamera.rotation.copy(this.character.rotation);
- this.worldObjects.forEach((worldObject) => {
- worldObject.position.set(-this.characterOffset.position.x, -this.characterOffset.position.y, -this.characterOffset.position.z);
- });
- const appContainer = document.getElementById("rogue-app");
- if (!appContainer)
- return;
- appContainer.onmousedown = (e) => {
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.lock();
- };
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.onStop(() => {
- if (!appContainer)
- return;
- appContainer.onmousedown = null;
- });
- this.mainCamera.rotation.order = "YXZ";
- this.character.rotation.order = "YXZ";
- this.mainCamera.up.set(0, 1, 0);
- }
- update() {
- const deltaTime = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.deltaTime;
- const appContainer = document.getElementById("rogue-app");
- if (!appContainer)
- return;
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.isMoving && document.pointerLockElement) {
- console.log("movement Ratio", rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementX / appContainer.clientWidth, rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementY / appContainer.clientHeight);
- const mouseDeltaX = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementX / appContainer.clientWidth * this.horizontalLookSpeed * deltaTime;
- const mouseDeltaY = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.movementY / appContainer.clientHeight * this.verticalLookSpeed * deltaTime;
- this.character.rotation.set(this.character.rotation.x, this.character.rotation.y - mouseDeltaX, this.character.rotation.z);
- this.mainCamera.rotation.set(this.mainCamera.rotation.x - mouseDeltaY, this.character.rotation.y, this.mainCamera.rotation.z);
- this.mainCamera.rotation.x = Math.max(this.minCameraRotY, Math.min(this.maxCameraRotY, this.mainCamera.rotation.x));
- }
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Escape") && rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.mouse.unlock();
- let actualSpeed = this.walkSpeed;
- let onlyFwd = true;
- const movementVector = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3();
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("Space")) {
- movementVector.add(upDirection);
- }
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("ControlLeft")) {
- movementVector.add(downDirection);
- }
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyW")) {
- movementVector.add(fwdDirection);
- } else if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyS")) {
- movementVector.add(bwdDirection);
- onlyFwd = false;
- }
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyA")) {
- movementVector.add(leftDirection);
- onlyFwd = false;
- } else if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("KeyD")) {
- movementVector.add(rightDirection);
- onlyFwd = false;
- }
- if (onlyFwd) {
- if (rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Input.keyboard.getKeyPressed("ShiftLeft")) {
- actualSpeed *= this.runSpeedMultiplier;
- } else {
- actualSpeed *= this.fwdSpeedMultiplier;
- }
- }
- movementVector.normalize();
- if (movementVector.length() > 0) {
- movementVector.copy(movementVector.transformDirection(this.character.matrix).multiplyScalar(actualSpeed * deltaTime));
- this.characterOffset.position.x += movementVector.x;
- this.characterOffset.position.y += movementVector.y;
- this.characterOffset.position.z += movementVector.z;
- this.worldObjects.forEach((worldObject) => {
- worldObject.position.set(-this.characterOffset.position.x, -this.characterOffset.position.y, -this.characterOffset.position.z);
- });
- }
- this.characterOffsetPosition.set(this.characterOffset.position.x, this.characterOffset.position.y, this.characterOffset.position.z);
- this.characterRotatePosition.set(this.characterOffset.rotation.x, this.characterOffset.rotation.y, this.characterOffset.rotation.z);
- }
- }
- __name(WorldFPSController, "WorldFPSController");
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
- ], WorldFPSController.prototype, "mainCamera", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], WorldFPSController.prototype, "horizontalLookSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], WorldFPSController.prototype, "verticalLookSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num(-Math.PI / 2, 0)
- ], WorldFPSController.prototype, "minCameraRotY", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num(0, Math.PI / 2)
- ], WorldFPSController.prototype, "maxCameraRotY", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], WorldFPSController.prototype, "cameraHeight", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], WorldFPSController.prototype, "walkSpeed", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], WorldFPSController.prototype, "fwdSpeedMultiplier", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.num()
- ], WorldFPSController.prototype, "runSpeedMultiplier", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.object3d()
- ], WorldFPSController.prototype, "character", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.list.object3d()
- ], WorldFPSController.prototype, "worldObjects", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.vector3()
- ], WorldFPSController.prototype, "characterOffsetPosition", 2);
- __decorateClass([
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.props.vector3()
- ], WorldFPSController.prototype, "characterRotatePosition", 2);
- rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(WorldFPSController);
- /***/ }),
- /***/ "rogue-engine":
- /*!******************************************************************************************************************!*\
- !*** external {"commonjs":"rogue-engine","commonjs2":"rogue-engine","amd":"rogue-engine","root":"rogue-engine"} ***!
- \******************************************************************************************************************/
- /***/ ((module) => {
- module.exports = __WEBPACK_EXTERNAL_MODULE_rogue_engine__;
- /***/ }),
- /***/ "three":
- /*!**************************************************************************************!*\
- !*** external {"commonjs":"three","commonjs2":"three","amd":"three","root":"three"} ***!
- \**************************************************************************************/
- /***/ ((module) => {
- module.exports = __WEBPACK_EXTERNAL_MODULE_three__;
- /***/ })
- /******/ });
- /************************************************************************/
- /******/ // The module cache
- /******/ var __webpack_module_cache__ = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
- /******/ if (cachedModule !== undefined) {
- /******/ return cachedModule.exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = __webpack_module_cache__[moduleId] = {
- /******/ // no module.id needed
- /******/ // no module.loaded needed
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = __webpack_modules__;
- /******/
- /************************************************************************/
- /******/ /* webpack/runtime/chunk loaded */
- /******/ (() => {
- /******/ var deferred = [];
- /******/ __webpack_require__.O = (result, chunkIds, fn, priority) => {
- /******/ if(chunkIds) {
- /******/ priority = priority || 0;
- /******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];
- /******/ deferred[i] = [chunkIds, fn, priority];
- /******/ return;
- /******/ }
- /******/ var notFulfilled = Infinity;
- /******/ for (var i = 0; i < deferred.length; i++) {
- /******/ var [chunkIds, fn, priority] = deferred[i];
- /******/ var fulfilled = true;
- /******/ for (var j = 0; j < chunkIds.length; j++) {
- /******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {
- /******/ chunkIds.splice(j--, 1);
- /******/ } else {
- /******/ fulfilled = false;
- /******/ if(priority < notFulfilled) notFulfilled = priority;
- /******/ }
- /******/ }
- /******/ if(fulfilled) {
- /******/ deferred.splice(i--, 1)
- /******/ var r = fn();
- /******/ if (r !== undefined) result = r;
- /******/ }
- /******/ }
- /******/ return result;
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/compat get default export */
- /******/ (() => {
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = (module) => {
- /******/ var getter = module && module.__esModule ?
- /******/ () => (module['default']) :
- /******/ () => (module);
- /******/ __webpack_require__.d(getter, { a: getter });
- /******/ return getter;
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/define property getters */
- /******/ (() => {
- /******/ // define getter functions for harmony exports
- /******/ __webpack_require__.d = (exports, definition) => {
- /******/ for(var key in definition) {
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
- /******/ }
- /******/ }
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
- /******/ (() => {
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
- /******/ })();
- /******/
- /******/ /* webpack/runtime/make namespace object */
- /******/ (() => {
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = (exports) => {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/ })();
- /******/
- /******/ /* webpack/runtime/jsonp chunk loading */
- /******/ (() => {
- /******/ // no baseURI
- /******/
- /******/ // object to store loaded and loading chunks
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
- /******/ var installedChunks = {
- /******/ "rogue-engine-user-scripts": 0
- /******/ };
- /******/
- /******/ // no chunk on demand loading
- /******/
- /******/ // no prefetching
- /******/
- /******/ // no preloaded
- /******/
- /******/ // no HMR
- /******/
- /******/ // no HMR manifest
- /******/
- /******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);
- /******/
- /******/ // install a JSONP callback for chunk loading
- /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
- /******/ var [chunkIds, moreModules, runtime] = data;
- /******/ // add "moreModules" to the modules object,
- /******/ // then flag all "chunkIds" as loaded and fire callback
- /******/ var moduleId, chunkId, i = 0;
- /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
- /******/ for(moduleId in moreModules) {
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
- /******/ }
- /******/ }
- /******/ if(runtime) var result = runtime(__webpack_require__);
- /******/ }
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
- /******/ for(;i < chunkIds.length; i++) {
- /******/ chunkId = chunkIds[i];
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
- /******/ installedChunks[chunkId][0]();
- /******/ }
- /******/ installedChunks[chunkId] = 0;
- /******/ }
- /******/ return __webpack_require__.O(result);
- /******/ }
- /******/
- /******/ var chunkLoadingGlobal = self["webpackChunk_name_"] = self["webpackChunk_name_"] || [];
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
- /******/ })();
- /******/
- /************************************************************************/
- /******/
- /******/ // startup
- /******/ // Load entry module and return exports
- /******/ __webpack_require__("./Assets/Components/DungeonGenerator.re.ts");
- /******/ __webpack_require__("./Assets/Components/EnemyAI.re.ts");
- /******/ __webpack_require__("./Assets/Components/Flashlight.re.ts");
- /******/ __webpack_require__("./Assets/Components/FPSController.re.ts");
- /******/ __webpack_require__("./Assets/Components/MeshGrid.re.ts");
- /******/ __webpack_require__("./Assets/Components/OrbitCamera.re.js");
- /******/ // This entry module is referenced by other modules so it can't be inlined
- /******/ __webpack_require__("./Assets/Components/RaycastReceiver.re.js");
- /******/ __webpack_require__("./Assets/Components/RaycastReporter.re.js");
- /******/ __webpack_require__("./Assets/Components/TileRaycastReceiver.re.js");
- /******/ var __webpack_exports__ = __webpack_require__("./Assets/Components/WorldFPSController.re.ts");
- /******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
- /******/
- /******/ return __webpack_exports__;
- /******/ })()
- ;
- });
- //# sourceMappingURL=rogue-engine-user-scripts.js.map
|