rogue-editor-user-scripts.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. "use strict";
  2. (function webpackUniversalModuleDefinition(root, factory) {
  3. if(typeof exports === 'object' && typeof module === 'object')
  4. module.exports = factory();
  5. else if(typeof define === 'function' && define.amd)
  6. define([], factory);
  7. else if(typeof exports === 'object')
  8. exports["rogue-editor-user-scripts"] = factory();
  9. else
  10. root["rogue-editor-user-scripts"] = factory();
  11. })(self, function() {
  12. return (self["webpackChunk_name_"] = self["webpackChunk_name_"] || []).push([["rogue-editor-user-scripts"],{
  13. /***/ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/_Editor/RapierBodyWireframe.re.ts":
  14. /*!*****************************************************************************************************!*\
  15. !*** ./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/_Editor/RapierBodyWireframe.re.ts ***!
  16. \*****************************************************************************************************/
  17. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  18. __webpack_require__.r(__webpack_exports__);
  19. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  20. /* harmony export */ "default": () => (/* binding */ RapierBodyWireframe)
  21. /* harmony export */ });
  22. /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! rogue-engine */ "rogue-engine");
  23. /* harmony import */ var rogue_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(rogue_engine__WEBPACK_IMPORTED_MODULE_0__);
  24. /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ "three");
  25. /* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_1__);
  26. /* harmony import */ var _Colliders_RapierCollider__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Colliders/RapierCollider */ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierCollider.ts");
  27. /* harmony import */ var _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @dimforge/rapier3d-compat */ "./node_modules/@dimforge/rapier3d-compat/rapier.es.js");
  28. /* harmony import */ var _RapierBody_re__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../RapierBody.re */ "./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/RapierBody.re.ts");
  29. /* 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");
  30. var __defProp = Object.defineProperty;
  31. var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
  32. class RapierBodyWireframe extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
  33. constructor() {
  34. super(...arguments);
  35. this.selectedObjects = [];
  36. this.colliders = [];
  37. this.lines = new three__WEBPACK_IMPORTED_MODULE_1__.LineSegments(new three__WEBPACK_IMPORTED_MODULE_1__.BufferGeometry(), new three__WEBPACK_IMPORTED_MODULE_1__.LineBasicMaterial({ color: new three__WEBPACK_IMPORTED_MODULE_1__.Color("#00FF00") }));
  38. this.initializedPhysics = false;
  39. this.handleOnComponentAdded = { stop: () => {
  40. } };
  41. this.handleOnComponentRemoved = { stop: () => {
  42. } };
  43. this.handleOnPlay = { stop: () => {
  44. } };
  45. this.resetHandler = /* @__PURE__ */ __name((component) => {
  46. component instanceof _Colliders_RapierCollider__WEBPACK_IMPORTED_MODULE_2__["default"] && this.setupImpostors();
  47. }, "resetHandler");
  48. }
  49. async initPhysics() {
  50. await _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__["default"].init();
  51. }
  52. start() {
  53. this.initializedPhysics = false;
  54. this.lines.geometry.computeBoundingSphere();
  55. this.lines.frustumCulled = false;
  56. this.initPhysics().then(() => {
  57. this.world = new _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__["default"].World({ x: 0, y: 0, z: 0 });
  58. _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__["default"].world = this.world;
  59. this.initializedPhysics = true;
  60. });
  61. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.remove(this.lines);
  62. this.lines.userData.isEditorObject = true;
  63. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.add(this.lines);
  64. this.handleOnComponentAdded.stop();
  65. this.handleOnComponentRemoved.stop();
  66. this.handleOnPlay.stop();
  67. this.handleOnComponentAdded = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.onComponentAdded(this.resetHandler);
  68. this.handleOnComponentRemoved = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.onComponentRemoved(this.resetHandler);
  69. this.handleOnPlay = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.onPlay(() => {
  70. this.handleOnComponentAdded.stop();
  71. this.handleOnComponentRemoved.stop();
  72. });
  73. }
  74. resetComponents() {
  75. this.selectedObjects.forEach((selected) => {
  76. if (!selected)
  77. return;
  78. selected.traverse((object) => {
  79. const objComponents = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.components[object.uuid];
  80. if (!objComponents)
  81. return;
  82. objComponents.forEach((component) => {
  83. if (component instanceof _RapierBody_re__WEBPACK_IMPORTED_MODULE_3__["default"] || component instanceof _Colliders_RapierCollider__WEBPACK_IMPORTED_MODULE_2__["default"]) {
  84. component.initialized = false;
  85. }
  86. });
  87. });
  88. });
  89. }
  90. afterUpdate() {
  91. this.lines.visible = false;
  92. if (!this.initializedPhysics)
  93. return;
  94. const selectedObjects = window["rogue-editor"].Project.selectedObjects;
  95. if (!this.arraysAreEqual(selectedObjects, this.selectedObjects)) {
  96. this.selectedObjects = selectedObjects.slice(0);
  97. this.resetComponents();
  98. this.setupImpostors();
  99. }
  100. if (!this.world || this.world && this.world.bodies.len() === 0) {
  101. return;
  102. }
  103. this.updateImpostors();
  104. }
  105. updateImpostors() {
  106. this.lines.visible = true;
  107. this.world.step();
  108. const flagForRemoval = [];
  109. this.colliders.forEach((component) => {
  110. if (component instanceof _Colliders_RapierCollider__WEBPACK_IMPORTED_MODULE_2__["default"] && component.object3d && component.bodyComponent) {
  111. if (!component.enabled) {
  112. component.initialized = false;
  113. flagForRemoval.push(component);
  114. return;
  115. }
  116. const pos = component.bodyComponent.object3d.position;
  117. const rot = component.bodyComponent.object3d.quaternion;
  118. component.body.setTranslation(new _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__["default"].Vector3(pos.x, pos.y, pos.z), false);
  119. component.body.setRotation(new _dimforge_rapier3d_compat__WEBPACK_IMPORTED_MODULE_5__["default"].Quaternion(rot.x, rot.y, rot.z, rot.w), false);
  120. component.setColliderRot();
  121. component.setColliderPos();
  122. }
  123. });
  124. flagForRemoval.forEach((component) => this.colliders.splice(this.colliders.indexOf(component), 1));
  125. let buffers = this.world.debugRender();
  126. this.lines.geometry.setAttribute("position", new three__WEBPACK_IMPORTED_MODULE_1__.BufferAttribute(buffers.vertices, 3));
  127. this.lines.geometry.setAttribute("color", new three__WEBPACK_IMPORTED_MODULE_1__.BufferAttribute(buffers.colors, 4));
  128. }
  129. async cleanupImpostors() {
  130. _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__["default"].world && _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__["default"].world.bodies.forEach((body) => _RE_RogueEngine_rogue_rapier_Lib_RogueRapier__WEBPACK_IMPORTED_MODULE_4__["default"].world.removeRigidBody(body));
  131. this.lines.visible = false;
  132. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.remove(this.lines);
  133. this.colliders = [];
  134. }
  135. async setupImpostors() {
  136. await this.cleanupImpostors();
  137. this.selectedObjects.forEach((selected) => {
  138. selected.traverse((object) => {
  139. const objComponents = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.components[object.uuid];
  140. if (!objComponents)
  141. return;
  142. objComponents.forEach((component) => {
  143. if (component instanceof _RapierBody_re__WEBPACK_IMPORTED_MODULE_3__["default"]) {
  144. component.init();
  145. this.colliders.push(component);
  146. }
  147. if (component instanceof _Colliders_RapierCollider__WEBPACK_IMPORTED_MODULE_2__["default"]) {
  148. const bodyComponent = component.getBodyComponent(component.object3d);
  149. if (bodyComponent) {
  150. bodyComponent.init();
  151. }
  152. component.init();
  153. this.colliders.push(component);
  154. }
  155. });
  156. });
  157. });
  158. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.add(this.lines);
  159. }
  160. arraysAreEqual(array1, array2) {
  161. if (array1.length !== array2.length)
  162. return false;
  163. return array1.every((element, i) => {
  164. return array2[i] === element;
  165. });
  166. }
  167. onBeforeRemoved() {
  168. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.remove(this.lines);
  169. this.handleOnComponentAdded.stop();
  170. this.handleOnComponentRemoved.stop();
  171. this.handleOnPlay.stop();
  172. this.cleanupImpostors();
  173. }
  174. }
  175. __name(RapierBodyWireframe, "RapierBodyWireframe");
  176. RapierBodyWireframe.isEditorComponent = true;
  177. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(RapierBodyWireframe);
  178. /***/ })
  179. },
  180. /******/ __webpack_require__ => { // webpackRuntimeModules
  181. /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
  182. /******/ var __webpack_exports__ = (__webpack_exec__("./Assets/rogue_packages/EyeOfMidas/directional-light-shadow-fix/DirectionalLightShadowFixForMobileCamera.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/rapier-movement-controller/GetForwardVector.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/rapier-movement-controller/PlayerPawnInput.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/rapier-movement-controller/RapierMovementController.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/targeted-orbit-camera/TargetedOrbitCamera.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenCameraFlyover.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenCameraTruck.re copy.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenCameraTruck.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenConfig.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenPosition.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenRotation.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Components/TweenScale.re.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Lib/Easings.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/tween/Lib/Tween.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/_Editor/RapierBodyWireframe.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierBall.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierCapsule.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierCollider.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierCone.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierCuboid.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierCylinder.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/Colliders/RapierTrimesh.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/RapierBody.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Components/RapierConfig.re.ts"), __webpack_exec__("./Assets/rogue_packages/RogueEngine/rogue-rapier/Lib/RogueRapier.ts"));
  183. /******/ return __webpack_exports__;
  184. /******/ }
  185. ]);
  186. });
  187. //# sourceMappingURL=rogue-editor-user-scripts.js.map