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/RapierBodyWireframe.re.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"rogue-editor-user-scripts\"] = factory();\n\telse\n\t\troot[\"rogue-editor-user-scripts\"] = factory();\n})(self, function() {\nreturn ","import * as RE from 'rogue-engine';\r\nimport * as THREE from 'three';\r\n\r\nimport RapierCollider from '../Colliders/RapierCollider';\r\nimport RAPIER from '@dimforge/rapier3d-compat';\r\nimport RapierBody from '../RapierBody.re';\r\nimport RogueRapier from '@RE/RogueEngine/rogue-rapier/Lib/RogueRapier';\r\n\r\nexport default class RapierBodyWireframe extends RE.Component {\r\n static isEditorComponent = true;\r\n\r\n selectedObjects: THREE.Object3D[] = [];\r\n colliders: (RapierCollider | RapierBody)[] = [];\r\n\r\n lines = new THREE.LineSegments(\r\n new THREE.BufferGeometry(),\r\n new THREE.LineBasicMaterial({ color: new THREE.Color(\"#00FF00\") })\r\n );\r\n\r\n world: RAPIER.World;\r\n initializedPhysics = false;\r\n\r\n private handleOnComponentAdded = { stop: () => { } };\r\n private handleOnComponentRemoved = { stop: () => { } };\r\n\r\n private handleOnPlay = { stop: () => { } };\r\n\r\n private resetHandler = (component: RE.Component) => {\r\n component instanceof RapierCollider && this.setupImpostors();\r\n }\r\n\r\n async initPhysics() {\r\n await RAPIER.init();\r\n }\r\n\r\n start() {\r\n this.initializedPhysics = false;\r\n\r\n this.lines.geometry.computeBoundingSphere();\r\n this.lines.frustumCulled = false;\r\n\r\n this.initPhysics().then(() => {\r\n this.world = new RAPIER.World({x: 0, y: 0, z: 0});\r\n RogueRapier.world = this.world;\r\n this.initializedPhysics = true;\r\n });\r\n\r\n RE.App.currentScene.remove(this.lines);\r\n\r\n this.lines.userData.isEditorObject = true;\r\n RE.App.currentScene.add(this.lines);\r\n\r\n this.handleOnComponentAdded.stop();\r\n this.handleOnComponentRemoved.stop();\r\n this.handleOnPlay.stop();\r\n\r\n this.handleOnComponentAdded = RE.onComponentAdded(this.resetHandler);\r\n this.handleOnComponentRemoved = RE.onComponentRemoved(this.resetHandler);\r\n\r\n this.handleOnPlay = RE.Runtime.onPlay(() => {\r\n this.handleOnComponentAdded.stop();\r\n this.handleOnComponentRemoved.stop();\r\n });\r\n }\r\n\r\n resetComponents() {\r\n this.selectedObjects.forEach(selected => {\r\n if (!selected) return;\r\n selected.traverse(object => {\r\n const objComponents = RE.components[object.uuid];\r\n\r\n if (!objComponents) return;\r\n\r\n objComponents.forEach(component => {\r\n if (component instanceof RapierBody || component instanceof RapierCollider) {\r\n component.initialized = false;\r\n }\r\n });\r\n });\r\n });\r\n }\r\n\r\n afterUpdate() {\r\n this.lines.visible = false;\r\n if (!this.initializedPhysics) return;\r\n\r\n const selectedObjects = window[\"rogue-editor\"].Project.selectedObjects as THREE.Object3D[];\r\n\r\n if (!this.arraysAreEqual(selectedObjects, this.selectedObjects)) {\r\n this.selectedObjects = selectedObjects.slice(0);\r\n this.resetComponents();\r\n this.setupImpostors();\r\n }\r\n\r\n if (!this.world || (this.world && this.world.bodies.len() === 0)) {\r\n return;\r\n }\r\n\r\n this.updateImpostors();\r\n }\r\n\r\n private updateImpostors() {\r\n this.lines.visible = true;\r\n this.world.step();\r\n\r\n const flagForRemoval: (RapierCollider | RapierBody)[] = [];\r\n\r\n this.colliders.forEach(component => {\r\n if (component instanceof RapierCollider && component.object3d && component.bodyComponent) {\r\n if (!component.enabled) {\r\n component.initialized = false;\r\n flagForRemoval.push(component);\r\n return;\r\n }\r\n const pos = component.bodyComponent.object3d.position;\r\n const rot = component.bodyComponent.object3d.quaternion;\r\n component.body.setTranslation(new RAPIER.Vector3(pos.x, pos.y, pos.z), false);\r\n component.body.setRotation(new RAPIER.Quaternion(rot.x, rot.y, rot.z, rot.w), false);\r\n component.setColliderRot();\r\n component.setColliderPos();\r\n }\r\n });\r\n\r\n flagForRemoval.forEach(component => this.colliders.splice(this.colliders.indexOf(component), 1))\r\n\r\n let buffers = this.world.debugRender();\r\n\r\n this.lines.geometry.setAttribute(\r\n \"position\",\r\n new THREE.BufferAttribute(buffers.vertices, 3),\r\n );\r\n\r\n this.lines.geometry.setAttribute(\r\n \"color\",\r\n new THREE.BufferAttribute(buffers.colors, 4),\r\n );\r\n }\r\n\r\n private async cleanupImpostors() {\r\n RogueRapier.world && RogueRapier.world.bodies.forEach(body => RogueRapier.world.removeRigidBody(body));\r\n this.lines.visible = false;\r\n RE.App.currentScene.remove(this.lines);\r\n\r\n this.colliders = [];\r\n }\r\n\r\n private async setupImpostors() {\r\n await this.cleanupImpostors();\r\n\r\n this.selectedObjects.forEach(selected => {\r\n selected.traverse(object => {\r\n const objComponents = RE.components[object.uuid];\r\n\r\n if (!objComponents) return;\r\n\r\n objComponents.forEach(component => {\r\n if (component instanceof RapierBody) {\r\n component.init();\r\n this.colliders.push(component);\r\n }\r\n\r\n if (component instanceof RapierCollider) {\r\n const bodyComponent = component.getBodyComponent(component.object3d);\r\n\r\n if (bodyComponent) {\r\n bodyComponent.init();\r\n }\r\n\r\n component.init();\r\n // component.collider && \r\n // component.collider.setSensor(true);\r\n this.colliders.push(component);\r\n }\r\n });\r\n });\r\n });\r\n\r\n RE.App.currentScene.add(this.lines);\r\n }\r\n\r\n private arraysAreEqual(array1: any[], array2: any[]) {\r\n if (array1.length !== array2.length) return false;\r\n\r\n return array1.every((element, i) => {\r\n return array2[i] === element;\r\n });\r\n }\r\n\r\n onBeforeRemoved() {\r\n RE.App.currentScene.remove(this.lines);\r\n this.handleOnComponentAdded.stop();\r\n this.handleOnComponentRemoved.stop();\r\n this.handleOnPlay.stop();\r\n this.cleanupImpostors();\r\n }\r\n}\r\n\r\nRE.registerComponent(RapierBodyWireframe);\r\n"],"names":[],"sourceRoot":""}