@roomle/web-sdk 2.40.0-alpha.8 → 2.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/lib/{banana-for-scale-02800438.nomodule.js → banana-for-scale-c621dcfe.nomodule.js} +2 -2
  2. package/lib/{banana-for-scale-02800438.nomodule.js.map → banana-for-scale-c621dcfe.nomodule.js.map} +1 -1
  3. package/lib/{banana-for-scale-ef041e93.js → banana-for-scale-ce67e362.js} +2 -2
  4. package/lib/{banana-for-scale-ef041e93.js.map → banana-for-scale-ce67e362.js.map} +1 -1
  5. package/lib/{component-dimensioning-ea9fa511.nomodule.js → component-dimensioning-14f19e11.nomodule.js} +2 -2
  6. package/lib/component-dimensioning-14f19e11.nomodule.js.map +1 -0
  7. package/lib/{component-dimensioning-eb3d847f.js → component-dimensioning-fb979ea7.js} +2 -2
  8. package/lib/component-dimensioning-fb979ea7.js.map +1 -0
  9. package/lib/{component-raycast-helper-04e54cc8.nomodule.js → component-raycast-helper-721352bc.nomodule.js} +2 -2
  10. package/lib/component-raycast-helper-721352bc.nomodule.js.map +1 -0
  11. package/lib/{component-raycast-helper-6e1e84fa.js → component-raycast-helper-d2abcbf9.js} +2 -2
  12. package/lib/component-raycast-helper-d2abcbf9.js.map +1 -0
  13. package/lib/{configurator-8db6c140.nomodule.js → configurator-7503e734.nomodule.js} +2 -2
  14. package/lib/configurator-7503e734.nomodule.js.map +1 -0
  15. package/lib/{configurator-e2883567.js → configurator-8ae6f5f3.js} +2 -2
  16. package/lib/configurator-8ae6f5f3.js.map +1 -0
  17. package/lib/configurator-main-12d65fa7.js +2 -0
  18. package/lib/configurator-main-12d65fa7.js.map +1 -0
  19. package/lib/configurator-main.nomodule.js +1 -1
  20. package/lib/{default-light-setting-ed48b5f9.js → default-light-setting-0ce92cb9.js} +2 -2
  21. package/lib/default-light-setting-0ce92cb9.js.map +1 -0
  22. package/lib/{default-light-setting-fac672cd.nomodule.js → default-light-setting-e50585c5.nomodule.js} +2 -2
  23. package/lib/default-light-setting-e50585c5.nomodule.js.map +1 -0
  24. package/lib/{dimensioning-helper-0c03548f.js → dimensioning-helper-2d4839c5.js} +2 -2
  25. package/lib/{dimensioning-helper-0c03548f.js.map → dimensioning-helper-2d4839c5.js.map} +1 -1
  26. package/lib/{dimensioning-helper-a395dff4.nomodule.js → dimensioning-helper-4c7422f4.nomodule.js} +2 -2
  27. package/lib/{dimensioning-helper-a395dff4.nomodule.js.map → dimensioning-helper-4c7422f4.nomodule.js.map} +1 -1
  28. package/lib/{glb-viewer-9dffa078.nomodule.js → glb-viewer-8535af71.nomodule.js} +2 -2
  29. package/lib/{glb-viewer-9dffa078.nomodule.js.map → glb-viewer-8535af71.nomodule.js.map} +1 -1
  30. package/lib/{glb-viewer-d09c0546.js → glb-viewer-eb8a2e36.js} +2 -2
  31. package/lib/{glb-viewer-d09c0546.js.map → glb-viewer-eb8a2e36.js.map} +1 -1
  32. package/lib/glb-viewer-main-7ad8db3a.js +2 -0
  33. package/lib/glb-viewer-main-7ad8db3a.js.map +1 -0
  34. package/lib/glb-viewer-main.nomodule.js +1 -1
  35. package/lib/legacy/{banana-for-scale-b66beaa4.legacy.js → banana-for-scale-d7cf7eac.legacy.js} +2 -2
  36. package/lib/legacy/{banana-for-scale-b66beaa4.legacy.js.map → banana-for-scale-d7cf7eac.legacy.js.map} +1 -1
  37. package/lib/legacy/{component-dimensioning-7b706bf6.legacy.js → component-dimensioning-789aca86.legacy.js} +2 -2
  38. package/lib/legacy/component-dimensioning-789aca86.legacy.js.map +1 -0
  39. package/lib/legacy/{component-raycast-helper-ea08448d.legacy.js → component-raycast-helper-806ded3e.legacy.js} +2 -2
  40. package/lib/legacy/component-raycast-helper-806ded3e.legacy.js.map +1 -0
  41. package/lib/legacy/{configurator-f126399f.legacy.js → configurator-6edf0fdb.legacy.js} +2 -2
  42. package/lib/legacy/configurator-6edf0fdb.legacy.js.map +1 -0
  43. package/lib/legacy/configurator-main.legacy.js +1 -1
  44. package/lib/legacy/{default-light-setting-66f11c31.legacy.js → default-light-setting-ccc032ee.legacy.js} +2 -2
  45. package/lib/legacy/default-light-setting-ccc032ee.legacy.js.map +1 -0
  46. package/lib/legacy/{dimensioning-helper-c63660d2.legacy.js → dimensioning-helper-6c0f6bc0.legacy.js} +2 -2
  47. package/lib/legacy/{dimensioning-helper-c63660d2.legacy.js.map → dimensioning-helper-6c0f6bc0.legacy.js.map} +1 -1
  48. package/lib/legacy/{glb-viewer-6c998954.legacy.js → glb-viewer-710dce16.legacy.js} +2 -2
  49. package/lib/legacy/{glb-viewer-6c998954.legacy.js.map → glb-viewer-710dce16.legacy.js.map} +1 -1
  50. package/lib/legacy/glb-viewer-main.legacy.js +1 -1
  51. package/lib/legacy/{material-viewer-5cd17210.legacy.js → material-viewer-df6e0f8b.legacy.js} +2 -2
  52. package/lib/legacy/material-viewer-df6e0f8b.legacy.js.map +1 -0
  53. package/lib/legacy/material-viewer-main.legacy.js +1 -1
  54. package/lib/legacy/{pixotron-10b5219f.legacy.js → pixotron-1d7bc380.legacy.js} +2 -2
  55. package/lib/legacy/{pixotron-10b5219f.legacy.js.map → pixotron-1d7bc380.legacy.js.map} +1 -1
  56. package/lib/legacy/{planner-ac7d0861.legacy.js → planner-4731aa02.legacy.js} +2 -2
  57. package/lib/legacy/{planner-ac7d0861.legacy.js.map → planner-4731aa02.legacy.js.map} +1 -1
  58. package/lib/legacy/planner-main.legacy.js +1 -1
  59. package/lib/legacy/{roomle-configurator-8120f2c6.legacy.js → roomle-configurator-ca286400.legacy.js} +2 -2
  60. package/lib/legacy/{roomle-configurator-8120f2c6.legacy.js.map → roomle-configurator-ca286400.legacy.js.map} +1 -1
  61. package/lib/legacy/{roomle-dependency-injection-807486a0.legacy.js → roomle-dependency-injection-06b92c13.legacy.js} +2 -2
  62. package/lib/legacy/{roomle-dependency-injection-807486a0.legacy.js.map → roomle-dependency-injection-06b92c13.legacy.js.map} +1 -1
  63. package/lib/legacy/roomle-sdk.legacy.js +1 -1
  64. package/lib/legacy/static/shaders-1e02a401be3330ee.json +1 -0
  65. package/lib/legacy/{stats-helper-50136601.legacy.js → stats-helper-7160871d.legacy.js} +2 -2
  66. package/lib/legacy/{stats-helper-50136601.legacy.js.map → stats-helper-7160871d.legacy.js.map} +1 -1
  67. package/lib/{material-viewer-2efb34f1.js → material-viewer-2d41fd5b.js} +2 -2
  68. package/lib/material-viewer-2d41fd5b.js.map +1 -0
  69. package/lib/{material-viewer-cc16fbe4.nomodule.js → material-viewer-b5dc2c23.nomodule.js} +2 -2
  70. package/lib/material-viewer-b5dc2c23.nomodule.js.map +1 -0
  71. package/lib/material-viewer-main-e665307d.js +2 -0
  72. package/lib/material-viewer-main-e665307d.js.map +1 -0
  73. package/lib/material-viewer-main.nomodule.js +1 -1
  74. package/lib/{pixotron-e27f0e7e.nomodule.js → pixotron-7b645940.nomodule.js} +2 -2
  75. package/lib/{pixotron-e27f0e7e.nomodule.js.map → pixotron-7b645940.nomodule.js.map} +1 -1
  76. package/lib/{pixotron-539457f5.js → pixotron-d48cdf07.js} +2 -2
  77. package/lib/{pixotron-539457f5.js.map → pixotron-d48cdf07.js.map} +1 -1
  78. package/lib/{planner-8f55a285.js → planner-31eff338.js} +2 -2
  79. package/lib/{planner-8f55a285.js.map → planner-31eff338.js.map} +1 -1
  80. package/lib/{planner-5cea6586.nomodule.js → planner-c461687e.nomodule.js} +2 -2
  81. package/lib/{planner-5cea6586.nomodule.js.map → planner-c461687e.nomodule.js.map} +1 -1
  82. package/lib/{planner-main-ced64a18.js → planner-main-36d2a4d1.js} +2 -2
  83. package/lib/planner-main-36d2a4d1.js.map +1 -0
  84. package/lib/planner-main.nomodule.js +1 -1
  85. package/lib/{roomle-configurator-b5eecec5.nomodule.js → roomle-configurator-442a410a.nomodule.js} +2 -2
  86. package/lib/{roomle-configurator-b5eecec5.nomodule.js.map → roomle-configurator-442a410a.nomodule.js.map} +1 -1
  87. package/lib/{roomle-configurator-48186109.js → roomle-configurator-729fec35.js} +2 -2
  88. package/lib/{roomle-configurator-48186109.js.map → roomle-configurator-729fec35.js.map} +1 -1
  89. package/lib/{roomle-dependency-injection-62c5e6bb.nomodule.js → roomle-dependency-injection-d856bd23.nomodule.js} +2 -2
  90. package/lib/{roomle-dependency-injection-62c5e6bb.nomodule.js.map → roomle-dependency-injection-d856bd23.nomodule.js.map} +1 -1
  91. package/lib/{roomle-dependency-injection-3b1d1ef6.js → roomle-dependency-injection-fe719e2d.js} +2 -2
  92. package/lib/{roomle-dependency-injection-3b1d1ef6.js.map → roomle-dependency-injection-fe719e2d.js.map} +1 -1
  93. package/lib/{roomle-sdk-b3956637.js → roomle-sdk-3895e33e.js} +2 -2
  94. package/lib/roomle-sdk-3895e33e.js.map +1 -0
  95. package/lib/roomle-sdk.nomodule.js +1 -1
  96. package/lib/static/shaders-1e02a401be3330ee.json +1 -0
  97. package/lib/{stats-helper-3c3e2d40.nomodule.js → stats-helper-2320382c.nomodule.js} +2 -2
  98. package/lib/{stats-helper-3c3e2d40.nomodule.js.map → stats-helper-2320382c.nomodule.js.map} +1 -1
  99. package/lib/{stats-helper-50d28af2.js → stats-helper-2f31fc65.js} +2 -2
  100. package/lib/{stats-helper-50d28af2.js.map → stats-helper-2f31fc65.js.map} +1 -1
  101. package/package.json +2 -2
  102. package/lib/component-dimensioning-ea9fa511.nomodule.js.map +0 -1
  103. package/lib/component-dimensioning-eb3d847f.js.map +0 -1
  104. package/lib/component-raycast-helper-04e54cc8.nomodule.js.map +0 -1
  105. package/lib/component-raycast-helper-6e1e84fa.js.map +0 -1
  106. package/lib/configurator-8db6c140.nomodule.js.map +0 -1
  107. package/lib/configurator-e2883567.js.map +0 -1
  108. package/lib/configurator-main-c387b63f.js +0 -2
  109. package/lib/configurator-main-c387b63f.js.map +0 -1
  110. package/lib/default-light-setting-ed48b5f9.js.map +0 -1
  111. package/lib/default-light-setting-fac672cd.nomodule.js.map +0 -1
  112. package/lib/glb-viewer-main-56e4825b.js +0 -2
  113. package/lib/glb-viewer-main-56e4825b.js.map +0 -1
  114. package/lib/legacy/component-dimensioning-7b706bf6.legacy.js.map +0 -1
  115. package/lib/legacy/component-raycast-helper-ea08448d.legacy.js.map +0 -1
  116. package/lib/legacy/configurator-f126399f.legacy.js.map +0 -1
  117. package/lib/legacy/default-light-setting-66f11c31.legacy.js.map +0 -1
  118. package/lib/legacy/material-viewer-5cd17210.legacy.js.map +0 -1
  119. package/lib/legacy/static/shaders-a7b6d4a2ed6b5e39.json +0 -1
  120. package/lib/material-viewer-2efb34f1.js.map +0 -1
  121. package/lib/material-viewer-cc16fbe4.nomodule.js.map +0 -1
  122. package/lib/material-viewer-main-ac6a4604.js +0 -2
  123. package/lib/material-viewer-main-ac6a4604.js.map +0 -1
  124. package/lib/planner-main-ced64a18.js.map +0 -1
  125. package/lib/roomle-sdk-b3956637.js.map +0 -1
  126. package/lib/static/shaders-a7b6d4a2ed6b5e39.json +0 -1
@@ -1,2 +1,2 @@
1
- import"./query-params-helper-a271f9dc.js";import{l as getGUI,_ as __decorate,i as inject,a0 as isSafari,G as convertToKernel,f as AsyncGuard,S as StaticPlanObjectViewModel,W as WallPlanElementViewModel,u as ConfiguratorPlanObjectViewModel,a1 as setWallTransparencyBasedOnCamera,x as kernelBoxToThreeBox,B as Benchmark,h as fadeIn,a2 as setWallTransparency,H as getScreenXY,U as isIdItemId,a3 as GLTF_LOADER_FILE_NAME,a4 as DRACO_LOADER_FILE_NAME,o as DynamicLightSettingLoader,Z as convertCObject,a5 as InputManager,E as EventDispatcher,D as DependencyInjectionAssignment,L as Logger,a6 as PlannerMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-3b1d1ef6.js";import{b as deepMerge,j as setCursor,m as copy}from"./main-thread-to-worker-0c7d537f.js";import{S as SceneEventHandler,C as ConfiguratorSceneManager,P as PlanViewModel,G as GLTF_EXPORTER_FILE_NAME,p as prepareTopImage,a as preparePerspectiveImage,g as getCameraTargetForBBox,R as RoomleConfigurator}from"./roomle-configurator-48186109.js";import{L as LightSetting,B as BakedShadowEnvironment,c as BackgroundEnvironment,C as CameraControl3D,e as CameraControl2D,f as CameraControlFirstPerson,I as INITIAL_PITCH,T as TWEEN_FILE_NAME,P as PIXOTRON_EFFETCS,d as PIXOTRON_FILE_NAME,S as ScriptLoader,M as Main}from"./pixotron-539457f5.js";import"./default-light-setting-ed48b5f9.js";class PlannerLightSetting extends LightSetting{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,a=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=getGUI();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class SceneEventInfo{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i}}let PlannerSceneEventHandler=(()=>{class e extends SceneEventHandler{constructor(e,t,n,a){super(e,t,n,a),this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(3,()=>{if(2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.cancelSelection()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new SceneEventInfo({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{this.setState(0),this.dispatchEvent(1,new SceneEventInfo({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.enable(3),e.enable(7),e.enable(6),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}disableWallEvents(){this._raycastHelper.getLayers().disable(9)}enableWallEvents(){this._raycastHelper.getLayers().enable(9)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_clickElement(e){if(!this._isCurrentlyDrawing){if(this._debug&&e.getId(),2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.check(e),this._setCursor()}}_hoverOn(e){this._isCurrentlyDrawing||(this._hoveredObject=e,this._setCursor())}_hoverOff(e){this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?setCursor("ew-resize"):1===this._state?setCursor("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?setCursor("move"):this._hoveredObject?setCursor("pointer"):3===this._state?setCursor(isSafari?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):setCursor("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){this._plannerSelectionHandler.isSelected(e.getId())&&0===this._state&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(4,new SceneEventInfo({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanObject())),n.moveObjectsBy(e,convertToKernel(a))}else n.moveElementTo(e.getPlanElement(),convertToKernel(t));this.dispatchEvent(5,new SceneEventInfo({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(6,new SceneEventInfo({planElementViewModel:e})),this._dragIn&&(this.cancelSelection(),this.setDragIn(!1)),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new SceneEventInfo({state:this._state,oldState:t})),this._position=null,2===this._state&&this.planInteractionHandler.deactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanObject()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(i,t,convertToKernel(r)),this._position.copy(new THREE.Vector3(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}selectPlanElement(e){this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(0,new SceneEventInfo({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.reactivateAllSnappingActivity(),this.isSnappingActive=!0}disableSnapping(){this.planInteractionHandler.deactivateAllSnappingActivity(),this.isSnappingActive=!1}enableWallDrawing(){this._inputManager.addEventListener(12,this._toggleDrawing,this),this._inputManager.addEventListener(5,this._createNode,this),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(14,this._startWallDrawing,this),this._inputManager.addEventListener(13,this._endWallDrawing,this)}cancelWallDrawing(){this._setStateAndCursor(0),this._inputManager.removeEventListener(12,this._toggleDrawing),this._inputManager.removeEventListener(5,this._createNode),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(14,this._startWallDrawing),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear()}escapeDrawing(){this.planInteractionHandler.endInteraction(),this.planInteractionHandler.cancelDrawing(),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(12)}_toggleDrawing(e){this._isCurrentlyDrawing?this._endWallDrawing():this._startWallDrawing(e)}_endWallDrawing(){this._isCurrentlyDrawing&&(this._isCurrentlyDrawing=!1,this.dispatchEvent(12),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this.planInteractionHandler.cancelDrawing(),this._setStateAndCursor(0))}_startWallDrawing(e){this._isCurrentlyDrawing=!0,2===e.type&&this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.startInteraction(),this._setStateAndCursor(3),this._getIntersectPointWithScene(e),this.planInteractionHandler.beginDrawing({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(11)}_drawWallOnMouseMove(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.currentDrawingPosition({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(10))}_createNode(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this._raycastHelper.clear(),this.planInteractionHandler.endInteraction())}_getIntersectPointWithScene(e){this._point=this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}}return __decorate([inject],e.prototype,"_plannerSelectionHandler",void 0),__decorate([inject],e.prototype,"_plannerKernelAccess",void 0),e})(),PlannerSceneManager=(()=>{class e extends ConfiguratorSceneManager{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new AsyncGuard,this._configurableItemGuard=new AsyncGuard,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new PlannerSceneEventHandler(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof StaticPlanObjectViewModel&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e)},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel()},this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof WallPlanElementViewModel&&this._sendWallDimensions(),this._environment instanceof BakedShadowEnvironment&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(5,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(6,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof BakedShadowEnvironment&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),convertToKernel(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new PlanViewModel(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),a=e.distanceTo(n),i=t.getSize(new THREE.Vector3),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof StaticPlanObjectViewModel&&(t="static"),e instanceof ConfiguratorPlanObjectViewModel&&(t="configuration"),e instanceof WallPlanElementViewModel&&(t="wall",n.wall=e.getWallDimension()),e instanceof StaticPlanObjectViewModel&&(n.item=e.getRapiItem()),e instanceof ConfiguratorPlanObjectViewModel){const t=e.getConfigurationRuntimeId();n.configurationRuntimeId=t}const a=(async()=>{const n={};if(e instanceof StaticPlanObjectViewModel&&(n.item=e.getRapiItem()),e instanceof ConfiguratorPlanObjectViewModel){const a=e.getConfigurationRuntimeId(),i=e.getPlanObject().getCatalogItemId(),s=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a);let r;if(this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),i&&isIdItemId(i)){const e=await this._rapiAccess.getItem(i);n.item=e,r=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(s);n.configuration=e,r=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+s+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(t);n.configuration=i,r=i.rootComponentId?i.rootComponentId:null}if(r){const e=await this._rapiAccess.getComponent(r);n.component=e}n.configurationRuntimeId=a,t="configuration"}return copy(n)})();this.currentSelection=copy(n),this._roomlePlannerUiCallback.onSelectionChange(copy(this._plannerSceneEventHandler.getSelectionMode()),copy(t),this.currentSelection,a)}_onSelectionCancel(e){this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._lightSetting=new PlannerLightSetting(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new BackgroundEnvironment(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new BakedShadowEnvironment(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof CameraControl3D&&this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparencyBasedOnCamera(this._cameraControl.getCamera(),e.material))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const t=this._plannerSceneEventHandler.getSelectedIds();if(1===t.length&&this._cameraControl instanceof CameraControl3D){const e=this._getViewModel().getPlanObjectForId(t[0]);this._cameraControl.setObjectRotation(e.getPlanElement().rotation)}const{planObjectId:n,planElementId:a}=this._configuratorContext;this._getViewModel().hideAllExcept(a),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(n),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(n),this.updateEnvironment(this.getBounds(),!0);const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.startInteraction()}selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=kernelBoxToThreeBox(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=kernelBoxToThreeBox(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),Benchmark.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();fadeIn(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.selectPlanElement(e),this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}setTimeout(()=>{this._zoomToBounds(!1)},0),this._renderEverything()}removePlanObjectFromScene(e){this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds()),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}exportGLB(e,t){this._scriptLoader.fetch(GLTF_EXPORTER_FILE_NAME,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof PlannerLightSetting&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){this._onCameraMove(),this._cameraControl instanceof CameraControl2D||(this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparency(e.material,!1,!1)),this._getViewModel().setCameraType("2D"),this._renderEverything(),this._changeCameraControl(new CameraControl2D(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("2D"),this._setCameraControlListeners())}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof CameraControl3D||(this._getViewModel().setCameraType("3D"),this._renderEverything(),this._changeCameraControl(new CameraControl3D(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("3D"),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){const e=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof CameraControlFirstPerson?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof CameraControl3D&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof CameraControlFirstPerson)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparency(e.material,!1,!1)),this._getViewModel().setCameraType("FP"),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new CameraControlFirstPerson(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("FP"),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case"2D":this.switchTo2D();break;case"3D":this.switchTo3D();break;case"FP":this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,a,i,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){if(e||(e=this.getBounds()),e){if(this._cameraControl instanceof CameraControl3D){const t=e.getSize(new THREE.Vector3),n=Math.max(t.x,t.z),a=this._initData.moc?.5*n*-1:5,i=this._initData.moc?INITIAL_PITCH:70;this._cameraControl.updateAndReset(t,e.getCenter(new THREE.Vector3),-15,i,a,!1)}this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(e,!0)}}_zoomToBounds(e){const t=this.getBounds();this._cameraControl instanceof CameraControl3D&&this._cameraControl.zoomToFitBounds(t),this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(t,e)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof CameraControl2D&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const a=this._getViewModel().getPlanObjectForId(e);a&&a.getObject()&&(t.push_back(a.getPlanObject()),n.expandByObject(a.getContainer()))});const a=n.getCenter(new THREE.Vector3),i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,convertToKernel(a))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let a=await prepareTopImage(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(a)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof CameraControl3D?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let a=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const i=await preparePerspectiveImage(this._scene,null,n,a,e);this._lightSetting.addToScene(),this._requestRender(),t(i)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),!0}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=[];this._getViewModel().getStaticPlanObjectViewModels().forEach(a=>{const i=(new THREE.Box3).setFromObject(a.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:a,position2d:getScreenXY(i,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._getViewModel().getConfigurablePlanObjectViewModels().forEach(a=>{const i=(new THREE.Box3).setFromObject(a.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:a,position2d:getScreenXY(i,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._roomlePlannerUiCallback.enablePlanObjectPositions(n)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:a}=this._domHelper.element;this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{const i=e.getWallDimension();if(i.length>0&&(i.fromPosition2d=getScreenXY(i.fromPosition3d,this._cameraControl.getCamera(),n,a),i.toPosition2d=getScreenXY(i.toPosition3d,this._cameraControl.getCamera(),n,a),i.textPosition2d=getScreenXY(i.textPosition3d,this._cameraControl.getCamera(),n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(i)),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(i.fromPosition3d);const a=new THREE.Mesh(e,t);a.position.copy(i.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}),this._roomlePlannerUiCallback.enableWallDimensions(t)}enableWallDrawing(){this._drawingEnabled=!0,this._plannerSceneEventHandler.enableWallDrawing(),this._plannerSceneEventHandler.addEventListener(11,this.drawingStart,this),this._plannerSceneEventHandler.addEventListener(12,this.drawingEnd,this)}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._plannerSceneEventHandler.cancelWallDrawing(),this._plannerSceneEventHandler.removeEventListener(11,this.drawingStart),this._plannerSceneEventHandler.removeEventListener(12,this.drawingEnd)}escapeDrawing(){this._plannerSceneEventHandler.escapeDrawing()}drawingStart(){this._cameraControl.lock()}drawingEnd(){this._cameraControl.unlock()}_changeCameraControl(e){super._changeCameraControl(e),e instanceof CameraControl2D&&this._environment instanceof BakedShadowEnvironment&&this._plannerSceneEventHandler.enableWallEvents(),(e instanceof CameraControl3D||e instanceof CameraControlFirstPerson)&&this._environment instanceof BakedShadowEnvironment&&this._plannerSceneEventHandler.disableWallEvents()}}return __decorate([inject],e.prototype,"_rapiAccess",void 0),__decorate([inject],e.prototype,"_plannerMeshGenerator",void 0),__decorate([inject],e.prototype,"_plannerInputManager",void 0),__decorate([inject],e.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],e.prototype,"_localStorageHelper",void 0),__decorate([inject],e.prototype,"_unitFormatter",void 0),e})();const OFFSET={left:0,top:1,right:1,bottom:0};let RoomlePlanner=(()=>{class e{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return Benchmark.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(GLTF_LOADER_FILE_NAME,{id:"gltf-loader"}),n=this._scriptLoader.fetch(DRACO_LOADER_FILE_NAME,{id:"draco-loader"}),a=this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"}),i=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,a,i]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new PlannerSceneManager(this._creator_,OFFSET,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=DynamicLightSettingLoader.createDynamicLightSettingSource(t,n);i&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const a=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(PIXOTRON_EFFETCS.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(PIXOTRON_FILE_NAME,{id:"pi-js"}).then(a,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Benchmark.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new RoomleConfigurator(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);a&&this._configurator.notifyUiAboutNewLabel(a)}selectPlanObjectById(e){this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);import("./configurator-e2883567.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);import("./glb-viewer-d09c0546.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=convertToKernel(new THREE.Vector3(t.x,t.y,t.z)));const a=await(isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){const t=e.map(e=>isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);await this._plannerKernelAccess.insertItems(n)}async insertItems(e){await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],a=[],i=convertCObject(e.objects);await Promise.all(i.map(async e=>{const i=convertCObject(e);if(i.catalogItemId?n.push(i.catalogItemId):i.configurationHash&&a.push(i.configurationHash),i.parts){const e=i.configurationHash||i.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(i.parts,e);i.parts=t}i.data=null,t.push(i)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(a)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const c=await this._rapiAccess.getComponents(o),h=new Map;for(const e of c)h.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&h.has(n.rootComponentId)){const e=h.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return convertCObject(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e);this.insertItems([n])}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,a;const i=this._planInteractionHandler;i.startInteraction();const s=[];for(const t of e){const e=i.addNode(t.from),r=i.addNode(t.to),o=i.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&i.setWallHeight(o,t.props.height),void 0!==(null===(a=t.props)||void 0===a?void 0:a.thickness)&&i.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||i.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}}return __decorate([inject],e.prototype,"_domHelper",void 0),__decorate([inject],e.prototype,"_scriptLoader",void 0),__decorate([inject],e.prototype,"_kernelAccessCallback",void 0),__decorate([inject],e.prototype,"_plannerKernelAccess",void 0),__decorate([inject],e.prototype,"_rapiAccess",void 0),__decorate([inject],e.prototype,"_singlePromiseFactory",void 0),__decorate([inject],e.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],e.prototype,"_lifeCycleManager",void 0),__decorate([inject],e.prototype,"_threeLoader",void 0),__decorate([inject],e.prototype,"_dataSyncer",void 0),__decorate([inject],e.prototype,"_initData",void 0),__decorate([inject],e.prototype,"_globalInitData",void 0),__decorate([inject],e.prototype,"_unitFormatter",void 0),e})();class PlannerSelectionHandlerEvent{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("planner-input-manager",class extends InputManager{_canDrag(e){return!0}},1),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("planner-selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];class Planner extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new RoomlePlanner(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}}export{Planner};
2
- //# sourceMappingURL=planner-8f55a285.js.map
1
+ import"./query-params-helper-a271f9dc.js";import{l as getGUI,_ as __decorate,i as inject,a0 as isSafari,G as convertToKernel,f as AsyncGuard,S as StaticPlanObjectViewModel,W as WallPlanElementViewModel,u as ConfiguratorPlanObjectViewModel,a1 as setWallTransparencyBasedOnCamera,x as kernelBoxToThreeBox,B as Benchmark,h as fadeIn,a2 as setWallTransparency,H as getScreenXY,U as isIdItemId,a3 as GLTF_LOADER_FILE_NAME,a4 as DRACO_LOADER_FILE_NAME,o as DynamicLightSettingLoader,Z as convertCObject,a5 as InputManager,E as EventDispatcher,D as DependencyInjectionAssignment,L as Logger,a6 as PlannerMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-fe719e2d.js";import{b as deepMerge,j as setCursor,m as copy}from"./main-thread-to-worker-0c7d537f.js";import{S as SceneEventHandler,C as ConfiguratorSceneManager,P as PlanViewModel,G as GLTF_EXPORTER_FILE_NAME,p as prepareTopImage,a as preparePerspectiveImage,g as getCameraTargetForBBox,R as RoomleConfigurator}from"./roomle-configurator-729fec35.js";import{L as LightSetting,B as BakedShadowEnvironment,c as BackgroundEnvironment,C as CameraControl3D,e as CameraControl2D,f as CameraControlFirstPerson,I as INITIAL_PITCH,T as TWEEN_FILE_NAME,P as PIXOTRON_EFFETCS,d as PIXOTRON_FILE_NAME,S as ScriptLoader,M as Main}from"./pixotron-d48cdf07.js";import"./default-light-setting-0ce92cb9.js";class PlannerLightSetting extends LightSetting{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,a=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=getGUI();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class SceneEventInfo{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i}}let PlannerSceneEventHandler=(()=>{class e extends SceneEventHandler{constructor(e,t,n,a){super(e,t,n,a),this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(3,()=>{if(2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.cancelSelection()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new SceneEventInfo({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{this.setState(0),this.dispatchEvent(1,new SceneEventInfo({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.enable(3),e.enable(7),e.enable(6),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}disableWallEvents(){this._raycastHelper.getLayers().disable(9)}enableWallEvents(){this._raycastHelper.getLayers().enable(9)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_clickElement(e){if(!this._isCurrentlyDrawing){if(this._debug&&e.getId(),2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.check(e),this._setCursor()}}_hoverOn(e){this._isCurrentlyDrawing||(this._hoveredObject=e,this._setCursor())}_hoverOff(e){this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?setCursor("ew-resize"):1===this._state?setCursor("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?setCursor("move"):this._hoveredObject?setCursor("pointer"):3===this._state?setCursor(isSafari?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):setCursor("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){this._plannerSelectionHandler.isSelected(e.getId())&&0===this._state&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(4,new SceneEventInfo({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanObject())),n.moveObjectsBy(e,convertToKernel(a))}else n.moveElementTo(e.getPlanElement(),convertToKernel(t));this.dispatchEvent(5,new SceneEventInfo({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(6,new SceneEventInfo({planElementViewModel:e})),this._dragIn&&(this.cancelSelection(),this.setDragIn(!1)),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new SceneEventInfo({state:this._state,oldState:t})),this._position=null,2===this._state&&this.planInteractionHandler.deactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanObject()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(i,t,convertToKernel(r)),this._position.copy(new THREE.Vector3(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}selectPlanElement(e){this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(0,new SceneEventInfo({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.reactivateAllSnappingActivity(),this.isSnappingActive=!0}disableSnapping(){this.planInteractionHandler.deactivateAllSnappingActivity(),this.isSnappingActive=!1}enableWallDrawing(){this._inputManager.addEventListener(12,this._toggleDrawing,this),this._inputManager.addEventListener(5,this._createNode,this),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(14,this._startWallDrawing,this),this._inputManager.addEventListener(13,this._endWallDrawing,this)}cancelWallDrawing(){this._setStateAndCursor(0),this._inputManager.removeEventListener(12,this._toggleDrawing),this._inputManager.removeEventListener(5,this._createNode),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(14,this._startWallDrawing),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear()}escapeDrawing(){this.planInteractionHandler.endInteraction(),this.planInteractionHandler.cancelDrawing(),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(12)}_toggleDrawing(e){this._isCurrentlyDrawing?this._endWallDrawing():this._startWallDrawing(e)}_endWallDrawing(){this._isCurrentlyDrawing&&(this._isCurrentlyDrawing=!1,this.dispatchEvent(12),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this.planInteractionHandler.cancelDrawing(),this._setStateAndCursor(0))}_startWallDrawing(e){this._isCurrentlyDrawing=!0,2===e.type&&this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.startInteraction(),this._setStateAndCursor(3),this._getIntersectPointWithScene(e),this.planInteractionHandler.beginDrawing({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(11)}_drawWallOnMouseMove(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.currentDrawingPosition({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(10))}_createNode(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this._raycastHelper.clear(),this.planInteractionHandler.endInteraction())}_getIntersectPointWithScene(e){this._point=this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}}return __decorate([inject],e.prototype,"_plannerSelectionHandler",void 0),__decorate([inject],e.prototype,"_plannerKernelAccess",void 0),e})(),PlannerSceneManager=(()=>{class e extends ConfiguratorSceneManager{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new AsyncGuard,this._configurableItemGuard=new AsyncGuard,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new PlannerSceneEventHandler(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof StaticPlanObjectViewModel&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e)},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel()},this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof WallPlanElementViewModel&&this._sendWallDimensions(),this._environment instanceof BakedShadowEnvironment&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(5,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(6,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof BakedShadowEnvironment&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),convertToKernel(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new PlanViewModel(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),a=e.distanceTo(n),i=t.getSize(new THREE.Vector3),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof StaticPlanObjectViewModel&&(t="static"),e instanceof ConfiguratorPlanObjectViewModel&&(t="configuration"),e instanceof WallPlanElementViewModel&&(t="wall",n.wall=e.getWallDimension()),e instanceof StaticPlanObjectViewModel&&(n.item=e.getRapiItem()),e instanceof ConfiguratorPlanObjectViewModel){const t=e.getConfigurationRuntimeId();n.configurationRuntimeId=t}const a=(async()=>{const n={};if(e instanceof StaticPlanObjectViewModel&&(n.item=e.getRapiItem()),e instanceof ConfiguratorPlanObjectViewModel){const a=e.getConfigurationRuntimeId(),i=e.getPlanObject().getCatalogItemId(),s=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a);let r;if(this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),i&&isIdItemId(i)){const e=await this._rapiAccess.getItem(i);n.item=e,r=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(s);n.configuration=e,r=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+s+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(t);n.configuration=i,r=i.rootComponentId?i.rootComponentId:null}if(r){const e=await this._rapiAccess.getComponent(r);n.component=e}n.configurationRuntimeId=a,t="configuration"}return copy(n)})();this.currentSelection=copy(n),this._roomlePlannerUiCallback.onSelectionChange(copy(this._plannerSceneEventHandler.getSelectionMode()),copy(t),this.currentSelection,a)}_onSelectionCancel(e){this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._lightSetting=new PlannerLightSetting(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new BackgroundEnvironment(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new BakedShadowEnvironment(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof CameraControl3D&&this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparencyBasedOnCamera(this._cameraControl.getCamera(),e.material))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const t=this._plannerSceneEventHandler.getSelectedIds();if(1===t.length&&this._cameraControl instanceof CameraControl3D){const e=this._getViewModel().getPlanObjectForId(t[0]);this._cameraControl.setObjectRotation(e.getPlanElement().rotation)}const{planObjectId:n,planElementId:a}=this._configuratorContext;this._getViewModel().hideAllExcept(a),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(n),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(n),this.updateEnvironment(this.getBounds(),!0);const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.startInteraction()}selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=kernelBoxToThreeBox(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=kernelBoxToThreeBox(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),Benchmark.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();fadeIn(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.selectPlanElement(e),this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}setTimeout(()=>{this._zoomToBounds(!1)},0),this._renderEverything()}removePlanObjectFromScene(e){this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds()),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}exportGLB(e,t){this._scriptLoader.fetch(GLTF_EXPORTER_FILE_NAME,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof PlannerLightSetting&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){this._onCameraMove(),this._cameraControl instanceof CameraControl2D||(this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparency(e.material,!1,!1)),this._getViewModel().setCameraType("2D"),this._renderEverything(),this._changeCameraControl(new CameraControl2D(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("2D"),this._setCameraControlListeners())}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof CameraControl3D||(this._getViewModel().setCameraType("3D"),this._renderEverything(),this._changeCameraControl(new CameraControl3D(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("3D"),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){const e=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof CameraControlFirstPerson?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof CameraControl3D&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof CameraControlFirstPerson)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparency(e.material,!1,!1)),this._getViewModel().setCameraType("FP"),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new CameraControlFirstPerson(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("FP"),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case"2D":this.switchTo2D();break;case"3D":this.switchTo3D();break;case"FP":this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,a,i,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){if(e||(e=this.getBounds()),e){if(this._cameraControl instanceof CameraControl3D){const t=e.getSize(new THREE.Vector3),n=Math.max(t.x,t.z),a=this._initData.moc?.5*n*-1:5,i=this._initData.moc?INITIAL_PITCH:70;this._cameraControl.updateAndReset(t,e.getCenter(new THREE.Vector3),-15,i,a,!1)}this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(e,!0)}}_zoomToBounds(e){const t=this.getBounds();this._cameraControl instanceof CameraControl3D&&this._cameraControl.zoomToFitBounds(t),this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(t,e)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof CameraControl2D&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const a=this._getViewModel().getPlanObjectForId(e);a&&a.getObject()&&(t.push_back(a.getPlanObject()),n.expandByObject(a.getContainer()))});const a=n.getCenter(new THREE.Vector3),i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,convertToKernel(a))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let a=await prepareTopImage(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(a)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof CameraControl3D?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let a=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const i=await preparePerspectiveImage(this._scene,null,n,a,e);this._lightSetting.addToScene(),this._requestRender(),t(i)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),!0}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=[];this._getViewModel().getStaticPlanObjectViewModels().forEach(a=>{const i=(new THREE.Box3).setFromObject(a.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:a,position2d:getScreenXY(i,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._getViewModel().getConfigurablePlanObjectViewModels().forEach(a=>{const i=(new THREE.Box3).setFromObject(a.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:a,position2d:getScreenXY(i,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._roomlePlannerUiCallback.enablePlanObjectPositions(n)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:a}=this._domHelper.element;this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{const i=e.getWallDimension();if(i.length>0&&(i.fromPosition2d=getScreenXY(i.fromPosition3d,this._cameraControl.getCamera(),n,a),i.toPosition2d=getScreenXY(i.toPosition3d,this._cameraControl.getCamera(),n,a),i.textPosition2d=getScreenXY(i.textPosition3d,this._cameraControl.getCamera(),n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(i)),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(i.fromPosition3d);const a=new THREE.Mesh(e,t);a.position.copy(i.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}),this._roomlePlannerUiCallback.enableWallDimensions(t)}enableWallDrawing(){this._drawingEnabled=!0,this._plannerSceneEventHandler.enableWallDrawing(),this._plannerSceneEventHandler.addEventListener(11,this.drawingStart,this),this._plannerSceneEventHandler.addEventListener(12,this.drawingEnd,this)}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._plannerSceneEventHandler.cancelWallDrawing(),this._plannerSceneEventHandler.removeEventListener(11,this.drawingStart),this._plannerSceneEventHandler.removeEventListener(12,this.drawingEnd)}escapeDrawing(){this._plannerSceneEventHandler.escapeDrawing()}drawingStart(){this._cameraControl.lock()}drawingEnd(){this._cameraControl.unlock()}_changeCameraControl(e){super._changeCameraControl(e),e instanceof CameraControl2D&&this._environment instanceof BakedShadowEnvironment&&this._plannerSceneEventHandler.enableWallEvents(),(e instanceof CameraControl3D||e instanceof CameraControlFirstPerson)&&this._environment instanceof BakedShadowEnvironment&&this._plannerSceneEventHandler.disableWallEvents()}}return __decorate([inject],e.prototype,"_rapiAccess",void 0),__decorate([inject],e.prototype,"_plannerMeshGenerator",void 0),__decorate([inject],e.prototype,"_plannerInputManager",void 0),__decorate([inject],e.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],e.prototype,"_localStorageHelper",void 0),__decorate([inject],e.prototype,"_unitFormatter",void 0),e})();const OFFSET={left:0,top:1,right:1,bottom:0};let RoomlePlanner=(()=>{class e{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return Benchmark.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(GLTF_LOADER_FILE_NAME,{id:"gltf-loader"}),n=this._scriptLoader.fetch(DRACO_LOADER_FILE_NAME,{id:"draco-loader"}),a=this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"}),i=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,a,i]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new PlannerSceneManager(this._creator_,OFFSET,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=DynamicLightSettingLoader.createDynamicLightSettingSource(t,n);i&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const a=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(PIXOTRON_EFFETCS.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(PIXOTRON_FILE_NAME,{id:"pi-js"}).then(a,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Benchmark.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new RoomleConfigurator(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);a&&this._configurator.notifyUiAboutNewLabel(a)}selectPlanObjectById(e){this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);import("./configurator-8ae6f5f3.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);import("./glb-viewer-eb8a2e36.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=convertToKernel(new THREE.Vector3(t.x,t.y,t.z)));const a=await(isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){const t=e.map(e=>isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);await this._plannerKernelAccess.insertItems(n)}async insertItems(e){await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],a=[],i=convertCObject(e.objects);await Promise.all(i.map(async e=>{const i=convertCObject(e);if(i.catalogItemId?n.push(i.catalogItemId):i.configurationHash&&a.push(i.configurationHash),i.parts){const e=i.configurationHash||i.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(i.parts,e);i.parts=t}i.data=null,t.push(i)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(a)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const c=await this._rapiAccess.getComponents(o),h=new Map;for(const e of c)h.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&h.has(n.rootComponentId)){const e=h.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return convertCObject(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e);this.insertItems([n])}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,a;const i=this._planInteractionHandler;i.startInteraction();const s=[];for(const t of e){const e=i.addNode(t.from),r=i.addNode(t.to),o=i.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&i.setWallHeight(o,t.props.height),void 0!==(null===(a=t.props)||void 0===a?void 0:a.thickness)&&i.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||i.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}}return __decorate([inject],e.prototype,"_domHelper",void 0),__decorate([inject],e.prototype,"_scriptLoader",void 0),__decorate([inject],e.prototype,"_kernelAccessCallback",void 0),__decorate([inject],e.prototype,"_plannerKernelAccess",void 0),__decorate([inject],e.prototype,"_rapiAccess",void 0),__decorate([inject],e.prototype,"_singlePromiseFactory",void 0),__decorate([inject],e.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],e.prototype,"_lifeCycleManager",void 0),__decorate([inject],e.prototype,"_threeLoader",void 0),__decorate([inject],e.prototype,"_dataSyncer",void 0),__decorate([inject],e.prototype,"_initData",void 0),__decorate([inject],e.prototype,"_globalInitData",void 0),__decorate([inject],e.prototype,"_unitFormatter",void 0),e})();class PlannerSelectionHandlerEvent{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("planner-input-manager",class extends InputManager{_canDrag(e){return!0}},1),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("planner-selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];class Planner extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new RoomlePlanner(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}}export{Planner};
2
+ //# sourceMappingURL=planner-31eff338.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-8f55a285.js","sources":["../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"+gxCAAe"}
1
+ {"version":3,"file":"planner-31eff338.js","sources":["../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"+gxCAAe"}
@@ -1,2 +1,2 @@
1
- System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-62c5e6bb.nomodule.js","./main-thread-to-worker-6c735cca.nomodule.js","./roomle-configurator-b5eecec5.nomodule.js","./pixotron-e27f0e7e.nomodule.js","./default-light-setting-fac672cd.nomodule.js"],(function(e,t){var n,i,a,s,r,o,l,h,c,d,_,g,p,m,u,C,w,E,v,f,S,b,M,I,P,H,y,L,D,k,O,T,V,R,A,x,j,B,F,W,G,K,U,z,q,N,X,Q,Z,J;return{setters:[function(){},function(e){n=e.l,i=e._,a=e.i,s=e.a0,r=e.G,o=e.f,l=e.S,h=e.W,c=e.u,d=e.a1,_=e.x,g=e.B,p=e.h,m=e.a2,u=e.H,C=e.U,w=e.a3,E=e.a4,v=e.o,f=e.Z,S=e.a5,b=e.E,M=e.D,I=e.L,P=e.a6,H=e.R,y=e.b},function(e){L=e.b,D=e.j,k=e.m},function(e){O=e.S,T=e.C,V=e.P,R=e.G,A=e.p,x=e.a,j=e.g,B=e.R},function(e){F=e.L,W=e.B,G=e.c,K=e.C,U=e.e,z=e.f,q=e.I,N=e.T,X=e.P,Q=e.d,Z=e.S,J=e.M},function(){}],execute:function(){class Y extends F{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,i=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);i.normalize(),i.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(i),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=n();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class ${constructor(e){const{planElementViewModel:t,resetCamera:n,state:i,oldState:a}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===i?0:i,this.oldState=void 0===a?0:a}}let ee=(()=>{class e extends O{constructor(e,t,n,i){super(e,t,n,i),this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(3,()=>{if(2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.cancelSelection()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new $({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{this.setState(0),this.dispatchEvent(1,new $({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.enable(3),e.enable(7),e.enable(6),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}disableWallEvents(){this._raycastHelper.getLayers().disable(9)}enableWallEvents(){this._raycastHelper.getLayers().enable(9)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_clickElement(e){if(!this._isCurrentlyDrawing){if(this._debug&&e.getId(),2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.check(e),this._setCursor()}}_hoverOn(e){this._isCurrentlyDrawing||(this._hoveredObject=e,this._setCursor())}_hoverOff(e){this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?D("ew-resize"):1===this._state?D("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?D("move"):this._hoveredObject?D("pointer"):3===this._state?D(s?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):D("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){this._plannerSelectionHandler.isSelected(e.getId())&&0===this._state&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(4,new $({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let i=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanObject())),n.moveObjectsBy(e,r(i))}else n.moveElementTo(e.getPlanElement(),r(t));this.dispatchEvent(5,new $({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(6,new $({planElementViewModel:e})),this._dragIn&&(this.cancelSelection(),this.setDragIn(!1)),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,i=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),i.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new $({state:this._state,oldState:t})),this._position=null,2===this._state&&this.planInteractionHandler.deactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:i}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const a=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(a.push_back(n.getPlanObject()),s.expandByObject(n.getContainer()))});const o=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(a,t,r(o)),this._position.copy(new THREE.Vector3(n,i,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}selectPlanElement(e){this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(0,new $({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.reactivateAllSnappingActivity(),this.isSnappingActive=!0}disableSnapping(){this.planInteractionHandler.deactivateAllSnappingActivity(),this.isSnappingActive=!1}enableWallDrawing(){this._inputManager.addEventListener(12,this._toggleDrawing,this),this._inputManager.addEventListener(5,this._createNode,this),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(14,this._startWallDrawing,this),this._inputManager.addEventListener(13,this._endWallDrawing,this)}cancelWallDrawing(){this._setStateAndCursor(0),this._inputManager.removeEventListener(12,this._toggleDrawing),this._inputManager.removeEventListener(5,this._createNode),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(14,this._startWallDrawing),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear()}escapeDrawing(){this.planInteractionHandler.endInteraction(),this.planInteractionHandler.cancelDrawing(),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(12)}_toggleDrawing(e){this._isCurrentlyDrawing?this._endWallDrawing():this._startWallDrawing(e)}_endWallDrawing(){this._isCurrentlyDrawing&&(this._isCurrentlyDrawing=!1,this.dispatchEvent(12),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this.planInteractionHandler.cancelDrawing(),this._setStateAndCursor(0))}_startWallDrawing(e){this._isCurrentlyDrawing=!0,2===e.type&&this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.startInteraction(),this._setStateAndCursor(3),this._getIntersectPointWithScene(e),this.planInteractionHandler.beginDrawing({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(11)}_drawWallOnMouseMove(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.currentDrawingPosition({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(10))}_createNode(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this._raycastHelper.clear(),this.planInteractionHandler.endInteraction())}_getIntersectPointWithScene(e){this._point=this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}}return i([a],e.prototype,"_plannerSelectionHandler",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),e})(),te=(()=>{class e extends T{constructor(e,t,n,i){super(e,t,i),this._staticItemGuard=new o,this._configurableItemGuard=new o,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new ee(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof l&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e)},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel()},this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof h&&this._sendWallDimensions(),this._environment instanceof W&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(5,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(6,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof W&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),r(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new V(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),i=e.distanceTo(n),a=t.getSize(new THREE.Vector3),s=Math.max(a.x,a.z)+3;if(i>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof l&&(t="static"),e instanceof c&&(t="configuration"),e instanceof h&&(t="wall",n.wall=e.getWallDimension()),e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const t=e.getConfigurationRuntimeId();n.configurationRuntimeId=t}const i=(async()=>{const n={};if(e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const i=e.getConfigurationRuntimeId(),a=e.getPlanObject().getCatalogItemId(),s=this._getKernelAccess().kernelInstance.getHashOfConfiguration(i);let r;if(this._configuratorContext.planObjectId=i,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),a&&C(a)){const e=await this._rapiAccess.getItem(a);n.item=e,r=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(s);n.configuration=e,r=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+s+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(i),a=await this._rapiAccess.saveConfiguration(t);n.configuration=a,r=a.rootComponentId?a.rootComponentId:null}if(r){const e=await this._rapiAccess.getComponent(r);n.component=e}n.configurationRuntimeId=i,t="configuration"}return k(n)})();this.currentSelection=k(n),this._roomlePlannerUiCallback.onSelectionChange(k(this._plannerSceneEventHandler.getSelectionMode()),k(t),this.currentSelection,i)}_onSelectionCancel(e){this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._lightSetting=new Y(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new G(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new W(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof K&&this._plannerMeshGenerator.wallMeshes.forEach(e=>d(this._cameraControl.getCamera(),e.material))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const t=this._plannerSceneEventHandler.getSelectedIds();if(1===t.length&&this._cameraControl instanceof K){const e=this._getViewModel().getPlanObjectForId(t[0]);this._cameraControl.setObjectRotation(e.getPlanElement().rotation)}const{planObjectId:n,planElementId:i}=this._configuratorContext;this._getViewModel().hideAllExcept(i),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(n),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(n),this.updateEnvironment(this.getBounds(),!0);const a=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==a||a.startInteraction()}selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,i)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},i)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=_(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=_(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),g.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,i,a,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();p(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.selectPlanElement(e),this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}setTimeout(()=>{this._zoomToBounds(!1)},0),this._renderEverything()}removePlanObjectFromScene(e){this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds()),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}exportGLB(e,t){this._scriptLoader.fetch(R,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof Y&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){this._onCameraMove(),this._cameraControl instanceof U||(this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("2D"),this._renderEverything(),this._changeCameraControl(new U(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("2D"),this._setCameraControlListeners())}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof K||(this._getViewModel().setCameraType("3D"),this._renderEverything(),this._changeCameraControl(new K(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("3D"),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){const e=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof z?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof K&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof z)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("FP"),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new z(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("FP"),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case"2D":this.switchTo2D();break;case"3D":this.switchTo3D();break;case"FP":this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,i,a,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){if(e||(e=this.getBounds()),e){if(this._cameraControl instanceof K){const t=e.getSize(new THREE.Vector3),n=Math.max(t.x,t.z),i=this._initData.moc?.5*n*-1:5,a=this._initData.moc?q:70;this._cameraControl.updateAndReset(t,e.getCenter(new THREE.Vector3),-15,a,i,!1)}this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(e,!0)}}_zoomToBounds(e){const t=this.getBounds();this._cameraControl instanceof K&&this._cameraControl.zoomToFitBounds(t),this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(t,e)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof U&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(t.push_back(i.getPlanObject()),n.expandByObject(i.getContainer()))});const i=n.getCenter(new THREE.Vector3),a=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(a,e,r(i))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let i=await A(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(i)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof K?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let i=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const a=await x(this._scene,null,n,i,e);this._lightSetting.addToScene(),this._requestRender(),t(a)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return j(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),!0}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=[];this._getViewModel().getStaticPlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._getViewModel().getConfigurablePlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._roomlePlannerUiCallback.enablePlanObjectPositions(n)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:i}=this._domHelper.element;this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{const a=e.getWallDimension();if(a.length>0&&(a.fromPosition2d=u(a.fromPosition3d,this._cameraControl.getCamera(),n,i),a.toPosition2d=u(a.toPosition3d,this._cameraControl.getCamera(),n,i),a.textPosition2d=u(a.textPosition3d,this._cameraControl.getCamera(),n,i),a.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(a.length),t.push(a)),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(a.fromPosition3d);const i=new THREE.Mesh(e,t);i.position.copy(a.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(a.textPosition3d),this._scene.add(n),this._scene.add(i),this._scene.add(s)}}),this._roomlePlannerUiCallback.enableWallDimensions(t)}enableWallDrawing(){this._drawingEnabled=!0,this._plannerSceneEventHandler.enableWallDrawing(),this._plannerSceneEventHandler.addEventListener(11,this.drawingStart,this),this._plannerSceneEventHandler.addEventListener(12,this.drawingEnd,this)}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._plannerSceneEventHandler.cancelWallDrawing(),this._plannerSceneEventHandler.removeEventListener(11,this.drawingStart),this._plannerSceneEventHandler.removeEventListener(12,this.drawingEnd)}escapeDrawing(){this._plannerSceneEventHandler.escapeDrawing()}drawingStart(){this._cameraControl.lock()}drawingEnd(){this._cameraControl.unlock()}_changeCameraControl(e){super._changeCameraControl(e),e instanceof U&&this._environment instanceof W&&this._plannerSceneEventHandler.enableWallEvents(),(e instanceof K||e instanceof z)&&this._environment instanceof W&&this._plannerSceneEventHandler.disableWallEvents()}}return i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_plannerMeshGenerator",void 0),i([a],e.prototype,"_plannerInputManager",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_localStorageHelper",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();const ne={left:0,top:1,right:1,bottom:0};let ie=(()=>{class e{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return g.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(w,{id:"gltf-loader"}),n=this._scriptLoader.fetch(E,{id:"draco-loader"}),i=this._scriptLoader.fetch(N,{id:"tween-js"}),a=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,i,a]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:i,stats:a}=this._initData;this._sceneManager||(this._sceneManager=new te(this._creator_,ne,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=v.createDynamicLightSettingSource(t,n);a&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const i=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(X.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(Q,{id:"pi-js"}).then(i,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){g.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new B(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,i=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);i&&this._configurator.notifyUiAboutNewLabel(i)}selectPlanObjectById(e){this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-8db6c140.nomodule.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);t.import("./glb-viewer-9dffa078.nomodule.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=r(new THREE.Vector3(t.x,t.y,t.z)));const i=await(C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),a=await this._plannerKernelAccess.addPlanObjectFromItem(i,t,n);return this._sceneManager.updateScene(),a}async insertItemList(e){const t=e.map(e=>C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);await this._plannerKernelAccess.insertItems(n)}async insertItems(e){await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],i=[],a=f(e.objects);await Promise.all(a.map(async e=>{const a=f(e);if(a.catalogItemId?n.push(a.catalogItemId):a.configurationHash&&i.push(a.configurationHash),a.parts){const e=a.configurationHash||a.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(a.parts,e);a.parts=t}a.data=null,t.push(a)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(i)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const h=await this._rapiAccess.getComponents(o),c=new Map;for(const e of h)c.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return f(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e);this.insertItems([n])}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,i;const a=this._planInteractionHandler;a.startInteraction();const s=[];for(const t of e){const e=a.addNode(t.from),r=a.addNode(t.to),o=a.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&a.setWallHeight(o,t.props.height),void 0!==(null===(i=t.props)||void 0===i?void 0:i.thickness)&&a.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||a.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}}return i([a],e.prototype,"_domHelper",void 0),i([a],e.prototype,"_scriptLoader",void 0),i([a],e.prototype,"_kernelAccessCallback",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_singlePromiseFactory",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_lifeCycleManager",void 0),i([a],e.prototype,"_threeLoader",void 0),i([a],e.prototype,"_dataSyncer",void 0),i([a],e.prototype,"_initData",void 0),i([a],e.prototype,"_globalInitData",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();class ae{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const se=[new M("script-loader",Z),new M("planner-input-manager",class extends S{_canDrag(e){return!0}},1),new M("logger",I),new M("planner-mesh-generator",P),new M("rapi-access",H),new M("planner-selection-handler",class extends b{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];e("Planner",class extends J{setupGlobals(){}setupDependencies(){y.setup(se),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new ie(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
- //# sourceMappingURL=planner-5cea6586.nomodule.js.map
1
+ System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-d856bd23.nomodule.js","./main-thread-to-worker-6c735cca.nomodule.js","./roomle-configurator-442a410a.nomodule.js","./pixotron-7b645940.nomodule.js","./default-light-setting-e50585c5.nomodule.js"],(function(e,t){var n,i,a,s,r,o,l,h,c,d,_,g,p,m,u,C,w,E,v,f,S,b,M,I,P,H,y,L,D,k,O,T,V,R,A,x,j,B,F,W,G,K,U,z,q,N,X,Q,Z,J;return{setters:[function(){},function(e){n=e.l,i=e._,a=e.i,s=e.a0,r=e.G,o=e.f,l=e.S,h=e.W,c=e.u,d=e.a1,_=e.x,g=e.B,p=e.h,m=e.a2,u=e.H,C=e.U,w=e.a3,E=e.a4,v=e.o,f=e.Z,S=e.a5,b=e.E,M=e.D,I=e.L,P=e.a6,H=e.R,y=e.b},function(e){L=e.b,D=e.j,k=e.m},function(e){O=e.S,T=e.C,V=e.P,R=e.G,A=e.p,x=e.a,j=e.g,B=e.R},function(e){F=e.L,W=e.B,G=e.c,K=e.C,U=e.e,z=e.f,q=e.I,N=e.T,X=e.P,Q=e.d,Z=e.S,J=e.M},function(){}],execute:function(){class Y extends F{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,i=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);i.normalize(),i.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(i),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=n();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class ${constructor(e){const{planElementViewModel:t,resetCamera:n,state:i,oldState:a}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===i?0:i,this.oldState=void 0===a?0:a}}let ee=(()=>{class e extends O{constructor(e,t,n,i){super(e,t,n,i),this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(3,()=>{if(2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.cancelSelection()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new $({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{this.setState(0),this.dispatchEvent(1,new $({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.enable(3),e.enable(7),e.enable(6),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}disableWallEvents(){this._raycastHelper.getLayers().disable(9)}enableWallEvents(){this._raycastHelper.getLayers().enable(9)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_clickElement(e){if(!this._isCurrentlyDrawing){if(this._debug&&e.getId(),2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.check(e),this._setCursor()}}_hoverOn(e){this._isCurrentlyDrawing||(this._hoveredObject=e,this._setCursor())}_hoverOff(e){this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?D("ew-resize"):1===this._state?D("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?D("move"):this._hoveredObject?D("pointer"):3===this._state?D(s?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):D("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){this._plannerSelectionHandler.isSelected(e.getId())&&0===this._state&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(4,new $({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let i=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanObject())),n.moveObjectsBy(e,r(i))}else n.moveElementTo(e.getPlanElement(),r(t));this.dispatchEvent(5,new $({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(6,new $({planElementViewModel:e})),this._dragIn&&(this.cancelSelection(),this.setDragIn(!1)),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,i=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),i.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new $({state:this._state,oldState:t})),this._position=null,2===this._state&&this.planInteractionHandler.deactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:i}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const a=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(a.push_back(n.getPlanObject()),s.expandByObject(n.getContainer()))});const o=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(a,t,r(o)),this._position.copy(new THREE.Vector3(n,i,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}selectPlanElement(e){this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(0,new $({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.reactivateAllSnappingActivity(),this.isSnappingActive=!0}disableSnapping(){this.planInteractionHandler.deactivateAllSnappingActivity(),this.isSnappingActive=!1}enableWallDrawing(){this._inputManager.addEventListener(12,this._toggleDrawing,this),this._inputManager.addEventListener(5,this._createNode,this),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(14,this._startWallDrawing,this),this._inputManager.addEventListener(13,this._endWallDrawing,this)}cancelWallDrawing(){this._setStateAndCursor(0),this._inputManager.removeEventListener(12,this._toggleDrawing),this._inputManager.removeEventListener(5,this._createNode),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(14,this._startWallDrawing),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear()}escapeDrawing(){this.planInteractionHandler.endInteraction(),this.planInteractionHandler.cancelDrawing(),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(12)}_toggleDrawing(e){this._isCurrentlyDrawing?this._endWallDrawing():this._startWallDrawing(e)}_endWallDrawing(){this._isCurrentlyDrawing&&(this._isCurrentlyDrawing=!1,this.dispatchEvent(12),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this.planInteractionHandler.cancelDrawing(),this._setStateAndCursor(0))}_startWallDrawing(e){this._isCurrentlyDrawing=!0,2===e.type&&this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.startInteraction(),this._setStateAndCursor(3),this._getIntersectPointWithScene(e),this.planInteractionHandler.beginDrawing({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(11)}_drawWallOnMouseMove(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.currentDrawingPosition({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(10))}_createNode(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this._raycastHelper.clear(),this.planInteractionHandler.endInteraction())}_getIntersectPointWithScene(e){this._point=this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}}return i([a],e.prototype,"_plannerSelectionHandler",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),e})(),te=(()=>{class e extends T{constructor(e,t,n,i){super(e,t,i),this._staticItemGuard=new o,this._configurableItemGuard=new o,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new ee(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof l&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e)},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel()},this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof h&&this._sendWallDimensions(),this._environment instanceof W&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(5,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(6,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof W&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),r(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new V(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),i=e.distanceTo(n),a=t.getSize(new THREE.Vector3),s=Math.max(a.x,a.z)+3;if(i>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof l&&(t="static"),e instanceof c&&(t="configuration"),e instanceof h&&(t="wall",n.wall=e.getWallDimension()),e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const t=e.getConfigurationRuntimeId();n.configurationRuntimeId=t}const i=(async()=>{const n={};if(e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const i=e.getConfigurationRuntimeId(),a=e.getPlanObject().getCatalogItemId(),s=this._getKernelAccess().kernelInstance.getHashOfConfiguration(i);let r;if(this._configuratorContext.planObjectId=i,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),a&&C(a)){const e=await this._rapiAccess.getItem(a);n.item=e,r=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(s);n.configuration=e,r=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+s+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(i),a=await this._rapiAccess.saveConfiguration(t);n.configuration=a,r=a.rootComponentId?a.rootComponentId:null}if(r){const e=await this._rapiAccess.getComponent(r);n.component=e}n.configurationRuntimeId=i,t="configuration"}return k(n)})();this.currentSelection=k(n),this._roomlePlannerUiCallback.onSelectionChange(k(this._plannerSceneEventHandler.getSelectionMode()),k(t),this.currentSelection,i)}_onSelectionCancel(e){this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._lightSetting=new Y(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new G(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new W(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof K&&this._plannerMeshGenerator.wallMeshes.forEach(e=>d(this._cameraControl.getCamera(),e.material))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const t=this._plannerSceneEventHandler.getSelectedIds();if(1===t.length&&this._cameraControl instanceof K){const e=this._getViewModel().getPlanObjectForId(t[0]);this._cameraControl.setObjectRotation(e.getPlanElement().rotation)}const{planObjectId:n,planElementId:i}=this._configuratorContext;this._getViewModel().hideAllExcept(i),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(n),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(n),this.updateEnvironment(this.getBounds(),!0);const a=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==a||a.startInteraction()}selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,i)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},i)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=_(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=_(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),g.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,i,a,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();p(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.selectPlanElement(e),this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}setTimeout(()=>{this._zoomToBounds(!1)},0),this._renderEverything()}removePlanObjectFromScene(e){this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds()),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}exportGLB(e,t){this._scriptLoader.fetch(R,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof Y&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){this._onCameraMove(),this._cameraControl instanceof U||(this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("2D"),this._renderEverything(),this._changeCameraControl(new U(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("2D"),this._setCameraControlListeners())}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof K||(this._getViewModel().setCameraType("3D"),this._renderEverything(),this._changeCameraControl(new K(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("3D"),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){const e=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof z?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof K&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof z)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("FP"),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new z(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("FP"),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case"2D":this.switchTo2D();break;case"3D":this.switchTo3D();break;case"FP":this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,i,a,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){if(e||(e=this.getBounds()),e){if(this._cameraControl instanceof K){const t=e.getSize(new THREE.Vector3),n=Math.max(t.x,t.z),i=this._initData.moc?.5*n*-1:5,a=this._initData.moc?q:70;this._cameraControl.updateAndReset(t,e.getCenter(new THREE.Vector3),-15,a,i,!1)}this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(e,!0)}}_zoomToBounds(e){const t=this.getBounds();this._cameraControl instanceof K&&this._cameraControl.zoomToFitBounds(t),this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(t,e)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof U&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(t.push_back(i.getPlanObject()),n.expandByObject(i.getContainer()))});const i=n.getCenter(new THREE.Vector3),a=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(a,e,r(i))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let i=await A(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(i)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof K?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let i=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const a=await x(this._scene,null,n,i,e);this._lightSetting.addToScene(),this._requestRender(),t(a)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return j(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),!0}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=[];this._getViewModel().getStaticPlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._getViewModel().getConfigurablePlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._roomlePlannerUiCallback.enablePlanObjectPositions(n)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:i}=this._domHelper.element;this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{const a=e.getWallDimension();if(a.length>0&&(a.fromPosition2d=u(a.fromPosition3d,this._cameraControl.getCamera(),n,i),a.toPosition2d=u(a.toPosition3d,this._cameraControl.getCamera(),n,i),a.textPosition2d=u(a.textPosition3d,this._cameraControl.getCamera(),n,i),a.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(a.length),t.push(a)),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(a.fromPosition3d);const i=new THREE.Mesh(e,t);i.position.copy(a.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(a.textPosition3d),this._scene.add(n),this._scene.add(i),this._scene.add(s)}}),this._roomlePlannerUiCallback.enableWallDimensions(t)}enableWallDrawing(){this._drawingEnabled=!0,this._plannerSceneEventHandler.enableWallDrawing(),this._plannerSceneEventHandler.addEventListener(11,this.drawingStart,this),this._plannerSceneEventHandler.addEventListener(12,this.drawingEnd,this)}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._plannerSceneEventHandler.cancelWallDrawing(),this._plannerSceneEventHandler.removeEventListener(11,this.drawingStart),this._plannerSceneEventHandler.removeEventListener(12,this.drawingEnd)}escapeDrawing(){this._plannerSceneEventHandler.escapeDrawing()}drawingStart(){this._cameraControl.lock()}drawingEnd(){this._cameraControl.unlock()}_changeCameraControl(e){super._changeCameraControl(e),e instanceof U&&this._environment instanceof W&&this._plannerSceneEventHandler.enableWallEvents(),(e instanceof K||e instanceof z)&&this._environment instanceof W&&this._plannerSceneEventHandler.disableWallEvents()}}return i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_plannerMeshGenerator",void 0),i([a],e.prototype,"_plannerInputManager",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_localStorageHelper",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();const ne={left:0,top:1,right:1,bottom:0};let ie=(()=>{class e{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return g.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(w,{id:"gltf-loader"}),n=this._scriptLoader.fetch(E,{id:"draco-loader"}),i=this._scriptLoader.fetch(N,{id:"tween-js"}),a=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,i,a]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:i,stats:a}=this._initData;this._sceneManager||(this._sceneManager=new te(this._creator_,ne,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=v.createDynamicLightSettingSource(t,n);a&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const i=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(X.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(Q,{id:"pi-js"}).then(i,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){g.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new B(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,i=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);i&&this._configurator.notifyUiAboutNewLabel(i)}selectPlanObjectById(e){this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-7503e734.nomodule.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);t.import("./glb-viewer-8535af71.nomodule.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=r(new THREE.Vector3(t.x,t.y,t.z)));const i=await(C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),a=await this._plannerKernelAccess.addPlanObjectFromItem(i,t,n);return this._sceneManager.updateScene(),a}async insertItemList(e){const t=e.map(e=>C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);await this._plannerKernelAccess.insertItems(n)}async insertItems(e){await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],i=[],a=f(e.objects);await Promise.all(a.map(async e=>{const a=f(e);if(a.catalogItemId?n.push(a.catalogItemId):a.configurationHash&&i.push(a.configurationHash),a.parts){const e=a.configurationHash||a.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(a.parts,e);a.parts=t}a.data=null,t.push(a)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(i)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const h=await this._rapiAccess.getComponents(o),c=new Map;for(const e of h)c.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return f(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e);this.insertItems([n])}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,i;const a=this._planInteractionHandler;a.startInteraction();const s=[];for(const t of e){const e=a.addNode(t.from),r=a.addNode(t.to),o=a.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&a.setWallHeight(o,t.props.height),void 0!==(null===(i=t.props)||void 0===i?void 0:i.thickness)&&a.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||a.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}}return i([a],e.prototype,"_domHelper",void 0),i([a],e.prototype,"_scriptLoader",void 0),i([a],e.prototype,"_kernelAccessCallback",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_singlePromiseFactory",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_lifeCycleManager",void 0),i([a],e.prototype,"_threeLoader",void 0),i([a],e.prototype,"_dataSyncer",void 0),i([a],e.prototype,"_initData",void 0),i([a],e.prototype,"_globalInitData",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();class ae{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const se=[new M("script-loader",Z),new M("planner-input-manager",class extends S{_canDrag(e){return!0}},1),new M("logger",I),new M("planner-mesh-generator",P),new M("rapi-access",H),new M("planner-selection-handler",class extends b{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];e("Planner",class extends J{setupGlobals(){}setupDependencies(){y.setup(se),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new ie(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
+ //# sourceMappingURL=planner-c461687e.nomodule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-5cea6586.nomodule.js","sources":["../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"w4sCAAe"}
1
+ {"version":3,"file":"planner-c461687e.nomodule.js","sources":["../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"w4sCAAe"}
@@ -1,2 +1,2 @@
1
- import"./query-params-helper-a271f9dc.js";import"./roomle-dependency-injection-3b1d1ef6.js";import"./main-thread-to-worker-0c7d537f.js";import"./roomle-configurator-48186109.js";import{Planner}from"./planner-8f55a285.js";import"./pixotron-539457f5.js";import"./default-light-setting-ed48b5f9.js";(new Planner).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let o=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)});
2
- //# sourceMappingURL=planner-main-ced64a18.js.map
1
+ import"./query-params-helper-a271f9dc.js";import"./roomle-dependency-injection-fe719e2d.js";import"./main-thread-to-worker-0c7d537f.js";import"./roomle-configurator-729fec35.js";import{Planner}from"./planner-31eff338.js";import"./pixotron-d48cdf07.js";import"./default-light-setting-0ce92cb9.js";(new Planner).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let o=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)});
2
+ //# sourceMappingURL=planner-main-36d2a4d1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner-main-36d2a4d1.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-62c5e6bb.nomodule.js","./main-thread-to-worker-6c735cca.nomodule.js","./roomle-configurator-b5eecec5.nomodule.js","./planner-5cea6586.nomodule.js","./pixotron-e27f0e7e.nomodule.js","./default-light-setting-fac672cd.nomodule.js"],(function(){var e;return{setters:[function(){},function(){},function(){},function(){},function(n){e=n.Planner},function(){},function(){}],execute:function(){(new e).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let n=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-n))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)})}}}));
1
+ System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-d856bd23.nomodule.js","./main-thread-to-worker-6c735cca.nomodule.js","./roomle-configurator-442a410a.nomodule.js","./planner-c461687e.nomodule.js","./pixotron-7b645940.nomodule.js","./default-light-setting-e50585c5.nomodule.js"],(function(){var e;return{setters:[function(){},function(){},function(){},function(){},function(n){e=n.Planner},function(){},function(){}],execute:function(){(new e).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let n=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-n))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)})}}}));
2
2
  //# sourceMappingURL=planner-main.nomodule.js.map