rogue-editor-user-scripts.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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, () => {
  12. return (self["webpackChunkroguetemplateproject"] = self["webpackChunkroguetemplateproject"] || []).push([["rogue-editor-user-scripts"],{
  13. /***/ "./Assets/rogue_packages/BeardScript/rogue-cannon/Components/_Editor/CannonBodyWireframe.ts":
  14. /*!**************************************************************************************************!*\
  15. !*** ./Assets/rogue_packages/BeardScript/rogue-cannon/Components/_Editor/CannonBodyWireframe.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 */ CannonBodyWireframe)
  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 _Shapes_CannonBox_re__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shapes/CannonBox.re */ "./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonBox.re.ts");
  27. /* harmony import */ var _Shapes_CannonSphere_re__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shapes/CannonSphere.re */ "./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonSphere.re.ts");
  28. /* harmony import */ var _Shapes_CannonShape__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shapes/CannonShape */ "./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonShape.ts");
  29. /* harmony import */ var _Shapes_CannonCylinder_re__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shapes/CannonCylinder.re */ "./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonCylinder.re.ts");
  30. /* harmony import */ var _Shapes_CannonTrimesh_re__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shapes/CannonTrimesh.re */ "./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonTrimesh.re.ts");
  31. var __defProp = Object.defineProperty;
  32. var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
  33. class CannonBodyWireframe extends rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Component {
  34. constructor() {
  35. super(...arguments);
  36. this.selectedObjects = [];
  37. this.colliders = [];
  38. this.wireframeMaterial = new three__WEBPACK_IMPORTED_MODULE_1__.MeshStandardMaterial({ wireframe: true, emissive: new three__WEBPACK_IMPORTED_MODULE_1__.Color("#00FF00"), color: new three__WEBPACK_IMPORTED_MODULE_1__.Color("#000000") });
  39. this.handleOnComponentAdded = { stop: () => {
  40. } };
  41. this.handleOnComponentRemoved = { stop: () => {
  42. } };
  43. this.handleOnPlay = { stop: () => {
  44. } };
  45. this.resetHandler = /* @__PURE__ */ __name((component) => {
  46. component instanceof _Shapes_CannonShape__WEBPACK_IMPORTED_MODULE_4__["default"] && this.setupImpostors();
  47. }, "resetHandler");
  48. }
  49. start() {
  50. this.handleOnComponentAdded.stop();
  51. this.handleOnComponentRemoved.stop();
  52. this.handleOnPlay.stop();
  53. this.handleOnComponentAdded = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.onComponentAdded(this.resetHandler);
  54. this.handleOnComponentRemoved = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.onComponentRemoved(this.resetHandler);
  55. this.handleOnPlay = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.Runtime.onPlay(() => {
  56. this.handleOnComponentAdded.stop();
  57. this.handleOnComponentRemoved.stop();
  58. this.cleanupImpostors();
  59. });
  60. }
  61. afterUpdate() {
  62. const selectedObjects = window["rogue-editor"].Project.selectedObjects;
  63. if (!this.arraysAreEqual(selectedObjects, this.selectedObjects)) {
  64. this.selectedObjects = selectedObjects.slice(0);
  65. this.setupImpostors();
  66. }
  67. if (this.selectedObjects.length === 0)
  68. return;
  69. this.updateImpostors();
  70. }
  71. updateImpostors() {
  72. this.colliders.forEach((impostor) => {
  73. this.updateColliderMesh(impostor.userData.cannonShape, impostor);
  74. });
  75. }
  76. cleanupImpostors() {
  77. this.colliders.forEach((impostor) => {
  78. impostor.userData.cannonShape = null;
  79. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.remove(impostor);
  80. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.dispose(impostor);
  81. });
  82. this.colliders = [];
  83. }
  84. setupImpostors() {
  85. this.cleanupImpostors();
  86. this.selectedObjects.forEach((selected) => {
  87. selected.traverse((object) => {
  88. const objComponents = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.components[object.uuid];
  89. if (!objComponents)
  90. return;
  91. objComponents.forEach((component) => {
  92. if (!(component instanceof _Shapes_CannonShape__WEBPACK_IMPORTED_MODULE_4__["default"]))
  93. return;
  94. let impostor = rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.getObjectByName("EDITOR_OBJECT_BB_" + object.uuid);
  95. if (impostor)
  96. return;
  97. impostor = this.getColliderMesh(component);
  98. if (impostor) {
  99. impostor.name = "EDITOR_OBJECT_BB_" + object.uuid;
  100. impostor.userData.isEditorObject = true;
  101. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.App.currentScene.add(impostor);
  102. } else {
  103. return;
  104. }
  105. impostor.userData.cannonShape = component;
  106. this.colliders.push(impostor);
  107. });
  108. });
  109. });
  110. }
  111. arraysAreEqual(array1, array2) {
  112. if (array1.length !== array2.length)
  113. return false;
  114. return array1.every((element, i) => {
  115. return array2[i] === element;
  116. });
  117. }
  118. getColliderMesh(component) {
  119. if (component instanceof _Shapes_CannonBox_re__WEBPACK_IMPORTED_MODULE_2__["default"]) {
  120. return new three__WEBPACK_IMPORTED_MODULE_1__.Mesh(new three__WEBPACK_IMPORTED_MODULE_1__.BoxBufferGeometry(), this.wireframeMaterial);
  121. }
  122. if (component instanceof _Shapes_CannonCylinder_re__WEBPACK_IMPORTED_MODULE_5__["default"]) {
  123. const radiusTop = component.radiusTopOffset;
  124. const radiusBottom = component.radiusBottomOffset;
  125. const height = component.heightOffset;
  126. const mesh = new three__WEBPACK_IMPORTED_MODULE_1__.Mesh(new three__WEBPACK_IMPORTED_MODULE_1__.CylinderBufferGeometry(radiusTop, radiusBottom, height, component.segments), this.wireframeMaterial);
  127. return mesh;
  128. }
  129. if (component instanceof _Shapes_CannonSphere_re__WEBPACK_IMPORTED_MODULE_3__["default"]) {
  130. const scale = component.object3d.scale;
  131. const maxSide = Math.max(scale.x, scale.y, scale.z);
  132. const radius = component.radiusOffset * maxSide;
  133. const compensatedRadius = radius + radius * 0.01;
  134. const segments = 15;
  135. return new three__WEBPACK_IMPORTED_MODULE_1__.Mesh(new three__WEBPACK_IMPORTED_MODULE_1__.SphereBufferGeometry(compensatedRadius, segments, segments), this.wireframeMaterial);
  136. }
  137. if (component instanceof _Shapes_CannonTrimesh_re__WEBPACK_IMPORTED_MODULE_6__["default"]) {
  138. if (!component.shape)
  139. component.createShape();
  140. if (component.shape) {
  141. const geometry = new three__WEBPACK_IMPORTED_MODULE_1__.BufferGeometry();
  142. const mesh = new three__WEBPACK_IMPORTED_MODULE_1__.Mesh(geometry, this.wireframeMaterial);
  143. const points = [];
  144. for (let i = 0; i < component.shape.vertices.length; i += 3) {
  145. const point = new three__WEBPACK_IMPORTED_MODULE_1__.Vector3(component.shape.vertices[i], component.shape.vertices[i + 1], component.shape.vertices[i + 2]);
  146. points.push(point);
  147. }
  148. geometry.setFromPoints(points);
  149. return mesh;
  150. }
  151. }
  152. return;
  153. }
  154. updateColliderMesh(component, mesh) {
  155. if (component instanceof _Shapes_CannonBox_re__WEBPACK_IMPORTED_MODULE_2__["default"]) {
  156. component.object3d.getWorldScale(mesh.scale);
  157. mesh.scale.set(component.sizeOffset.x * mesh.scale.x, component.sizeOffset.y * mesh.scale.y, component.sizeOffset.z * mesh.scale.z);
  158. }
  159. if (component instanceof _Shapes_CannonCylinder_re__WEBPACK_IMPORTED_MODULE_5__["default"]) {
  160. const radiusTop = component.radiusTopOffset;
  161. const radiusBottom = component.radiusBottomOffset;
  162. const height = component.heightOffset;
  163. if (mesh.geometry instanceof three__WEBPACK_IMPORTED_MODULE_1__.CylinderBufferGeometry) {
  164. if (mesh.geometry.parameters.radiusTop !== radiusTop || mesh.geometry.parameters.radiusBottom !== radiusBottom || mesh.geometry.parameters.height !== height || mesh.geometry.parameters.radialSegments !== component.segments) {
  165. mesh.geometry.dispose();
  166. mesh.geometry = new three__WEBPACK_IMPORTED_MODULE_1__.CylinderBufferGeometry(radiusTop, radiusBottom, height, component.segments);
  167. }
  168. }
  169. component.object3d.getWorldScale(mesh.scale);
  170. }
  171. if (component instanceof _Shapes_CannonSphere_re__WEBPACK_IMPORTED_MODULE_3__["default"]) {
  172. const scale = component.object3d.scale;
  173. const maxSide = Math.max(scale.x, scale.y, scale.z);
  174. const radius = component.radiusOffset * maxSide;
  175. if (mesh.geometry instanceof three__WEBPACK_IMPORTED_MODULE_1__.SphereBufferGeometry) {
  176. if (mesh.geometry.parameters.radius !== radius) {
  177. let segments = 10 * radius;
  178. if (segments < 15)
  179. segments = 15;
  180. if (segments > 50)
  181. segments = 50;
  182. mesh.geometry.dispose();
  183. mesh.geometry = new three__WEBPACK_IMPORTED_MODULE_1__.SphereBufferGeometry(radius, segments, segments);
  184. }
  185. }
  186. }
  187. component.object3d.getWorldPosition(mesh.position);
  188. component.object3d.getWorldQuaternion(mesh.quaternion);
  189. }
  190. onBeforeRemoved() {
  191. this.handleOnComponentAdded.stop();
  192. this.handleOnComponentRemoved.stop();
  193. this.handleOnPlay.stop();
  194. this.cleanupImpostors();
  195. }
  196. }
  197. __name(CannonBodyWireframe, "CannonBodyWireframe");
  198. CannonBodyWireframe.isEditorComponent = true;
  199. rogue_engine__WEBPACK_IMPORTED_MODULE_0__.registerComponent(CannonBodyWireframe);
  200. /***/ })
  201. },
  202. /******/ __webpack_require__ => { // webpackRuntimeModules
  203. /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
  204. /******/ var __webpack_exports__ = (__webpack_exec__("./Assets/Components/BallRaycastReceiver.re.ts"), __webpack_exec__("./Assets/Components/CannonMovementController.re.ts"), __webpack_exec__("./Assets/Components/FloorCheckComponent.re.ts"), __webpack_exec__("./Assets/Components/FloorRaycastReceiver.re.ts"), __webpack_exec__("./Assets/Components/GameLogic.re.ts"), __webpack_exec__("./Assets/Components/MovementController.re.ts"), __webpack_exec__("./Assets/Components/RapierMovementController.re.ts"), __webpack_exec__("./Assets/Components/RaycastReceiver.re.ts"), __webpack_exec__("./Assets/Components/RaycastReporter.re.ts"), __webpack_exec__("./Assets/Library/GetForwardVector.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/_Editor/CannonBodyWireframe.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/CannonBody.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/CannonConfig.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Constraints/CannonConstraint.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Constraints/CannonDistanceConstraint.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Constraints/CannonHingeConstraint.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Constraints/CannonLockConstraint.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Constraints/CannonPointToPointConstraint.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Controllers/CannonSimpleCharacterController.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Controllers/CannonVehicleController.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Material/CannonContactMaterial.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Material/CannonMaterial.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Material/SetCannonMaterial.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Objects/CannonRaycastVehicle.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Objects/CannonSpring.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Objects/CannonWheel.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonBox.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonCylinder.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonShape.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonSphere.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Components/Shapes/CannonTrimesh.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/index.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-cannon/Lib/RogueCannon.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Colliders/RapierBall.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Colliders/RapierCapsule.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Colliders/RapierCollider.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Colliders/RapierCone.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Colliders/RapierCuboid.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Colliders/RapierCylinder.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/Jump.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/RapierBody.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Components/RapierConfig.re.ts"), __webpack_exec__("./Assets/rogue_packages/BeardScript/rogue-rapier-experimental/Lib/RogueRapier.ts"), __webpack_exec__("./Assets/rogue_packages/EyeOfMidas/targeted-orbit-camera/TargetedOrbitCamera.re.ts"));
  205. /******/ return __webpack_exports__;
  206. /******/ }
  207. ]);
  208. });
  209. //# sourceMappingURL=rogue-editor-user-scripts.js.map