@roomle/web-sdk 2.60.0 → 2.61.0-alpha.2

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 (179) hide show
  1. package/lib/{TextGeometry-3e0a22a8.js → TextGeometry-0ef7f44a.js} +2 -2
  2. package/lib/{TextGeometry-3e0a22a8.js.map → TextGeometry-0ef7f44a.js.map} +1 -1
  3. package/lib/{TextGeometry-0604159d.nomodule.js → TextGeometry-2f8ecc7b.nomodule.js} +2 -2
  4. package/lib/{TextGeometry-0604159d.nomodule.js.map → TextGeometry-2f8ecc7b.nomodule.js.map} +1 -1
  5. package/lib/{banana-for-scale-3a114a0c.nomodule.js → banana-for-scale-b571d20d.nomodule.js} +2 -2
  6. package/lib/{banana-for-scale-3a114a0c.nomodule.js.map → banana-for-scale-b571d20d.nomodule.js.map} +1 -1
  7. package/lib/{banana-for-scale-68a45a69.js → banana-for-scale-d59baa83.js} +2 -2
  8. package/lib/{banana-for-scale-68a45a69.js.map → banana-for-scale-d59baa83.js.map} +1 -1
  9. package/lib/{budgeteer-measure-3b21e46f.js → budgeteer-measure-0b7be7aa.js} +2 -2
  10. package/lib/{budgeteer-measure-3b21e46f.js.map → budgeteer-measure-0b7be7aa.js.map} +1 -1
  11. package/lib/budgeteer-measure.nomodule.js +1 -1
  12. package/lib/{component-dimensioning-64dd804c.js → component-dimensioning-16d1e543.js} +2 -2
  13. package/lib/component-dimensioning-16d1e543.js.map +1 -0
  14. package/lib/{component-dimensioning-a8078114.nomodule.js → component-dimensioning-ddc57886.nomodule.js} +2 -2
  15. package/lib/component-dimensioning-ddc57886.nomodule.js.map +1 -0
  16. package/lib/{component-raycast-helper-4f91b663.js → component-raycast-helper-5fed3fea.js} +2 -2
  17. package/lib/component-raycast-helper-5fed3fea.js.map +1 -0
  18. package/lib/{component-raycast-helper-ac3b7072.nomodule.js → component-raycast-helper-a5a21a3d.nomodule.js} +2 -2
  19. package/lib/component-raycast-helper-a5a21a3d.nomodule.js.map +1 -0
  20. package/lib/{configurator-a9c1fe12.nomodule.js → configurator-064016b1.nomodule.js} +2 -2
  21. package/lib/configurator-064016b1.nomodule.js.map +1 -0
  22. package/lib/{configurator-c62d84e8.js → configurator-e05bf66c.js} +2 -2
  23. package/lib/configurator-e05bf66c.js.map +1 -0
  24. package/lib/configurator-main-13d8febe.js +2 -0
  25. package/lib/configurator-main-13d8febe.js.map +1 -0
  26. package/lib/configurator-main.nomodule.js +1 -1
  27. package/lib/{continuous-drawing-helper-7a08e3cf.nomodule.js → continuous-drawing-helper-25cbd8cf.nomodule.js} +2 -2
  28. package/lib/continuous-drawing-helper-25cbd8cf.nomodule.js.map +1 -0
  29. package/lib/{continuous-drawing-helper-3b11f9f9.js → continuous-drawing-helper-f6a6732d.js} +2 -2
  30. package/lib/continuous-drawing-helper-f6a6732d.js.map +1 -0
  31. package/lib/{default-light-setting-f4f47231.js → default-light-setting-337c0d14.js} +2 -2
  32. package/lib/default-light-setting-337c0d14.js.map +1 -0
  33. package/lib/{default-light-setting-01a91d0f.nomodule.js → default-light-setting-e2995f02.nomodule.js} +2 -2
  34. package/lib/default-light-setting-e2995f02.nomodule.js.map +1 -0
  35. package/lib/definitions/common-core/src/webgl/renderer/screen-space-shadow-map.d.ts +3 -2
  36. package/lib/{dimensioning-helper-b9457f63.js → dimensioning-helper-c2ddcae7.js} +2 -2
  37. package/lib/{dimensioning-helper-b9457f63.js.map → dimensioning-helper-c2ddcae7.js.map} +1 -1
  38. package/lib/{dimensioning-helper-3efe98dd.nomodule.js → dimensioning-helper-fdc33c50.nomodule.js} +2 -2
  39. package/lib/{dimensioning-helper-3efe98dd.nomodule.js.map → dimensioning-helper-fdc33c50.nomodule.js.map} +1 -1
  40. package/lib/{glb-viewer-1aee8147.js → glb-viewer-78325254.js} +2 -2
  41. package/lib/{glb-viewer-1aee8147.js.map → glb-viewer-78325254.js.map} +1 -1
  42. package/lib/{glb-viewer-c1c1106b.nomodule.js → glb-viewer-a98ce118.nomodule.js} +2 -2
  43. package/lib/{glb-viewer-c1c1106b.nomodule.js.map → glb-viewer-a98ce118.nomodule.js.map} +1 -1
  44. package/lib/glb-viewer-main-57ca8e11.js +2 -0
  45. package/lib/glb-viewer-main-57ca8e11.js.map +1 -0
  46. package/lib/glb-viewer-main.nomodule.js +1 -1
  47. package/lib/legacy/TextGeometry-24b7f0c2.legacy.js +2 -0
  48. package/lib/legacy/{TextGeometry-85fd8358.legacy.js.map → TextGeometry-24b7f0c2.legacy.js.map} +1 -1
  49. package/lib/legacy/{banana-for-scale-8fde3b6e.legacy.js → banana-for-scale-a0a27df5.legacy.js} +2 -2
  50. package/lib/legacy/{banana-for-scale-8fde3b6e.legacy.js.map → banana-for-scale-a0a27df5.legacy.js.map} +1 -1
  51. package/lib/legacy/budgeteer-measure.legacy.js +1 -1
  52. package/lib/legacy/{component-dimensioning-0c4f6279.legacy.js → component-dimensioning-40bc8413.legacy.js} +2 -2
  53. package/lib/legacy/component-dimensioning-40bc8413.legacy.js.map +1 -0
  54. package/lib/legacy/{component-raycast-helper-e634d9cc.legacy.js → component-raycast-helper-9b45b799.legacy.js} +2 -2
  55. package/lib/legacy/component-raycast-helper-9b45b799.legacy.js.map +1 -0
  56. package/lib/legacy/{configurator-5d8e9e4c.legacy.js → configurator-b328c30a.legacy.js} +2 -2
  57. package/lib/legacy/configurator-b328c30a.legacy.js.map +1 -0
  58. package/lib/legacy/configurator-main.legacy.js +1 -1
  59. package/lib/legacy/{continuous-drawing-helper-d7691e20.legacy.js → continuous-drawing-helper-8a3e0880.legacy.js} +2 -2
  60. package/lib/legacy/continuous-drawing-helper-8a3e0880.legacy.js.map +1 -0
  61. package/lib/legacy/{default-light-setting-80b8957f.legacy.js → default-light-setting-43d6679b.legacy.js} +2 -2
  62. package/lib/legacy/default-light-setting-43d6679b.legacy.js.map +1 -0
  63. package/lib/legacy/{dimensioning-helper-8d78ba0a.legacy.js → dimensioning-helper-4554b1e0.legacy.js} +2 -2
  64. package/lib/legacy/{dimensioning-helper-8d78ba0a.legacy.js.map → dimensioning-helper-4554b1e0.legacy.js.map} +1 -1
  65. package/lib/legacy/{glb-viewer-20b26df0.legacy.js → glb-viewer-ebd38c72.legacy.js} +2 -2
  66. package/lib/legacy/{glb-viewer-20b26df0.legacy.js.map → glb-viewer-ebd38c72.legacy.js.map} +1 -1
  67. package/lib/legacy/glb-viewer-main.legacy.js +1 -1
  68. package/lib/legacy/main-thread-to-worker-e67fead1.legacy.js +7 -0
  69. package/lib/legacy/{main-thread-to-worker-50cdf3d3.legacy.js.map → main-thread-to-worker-e67fead1.legacy.js.map} +1 -1
  70. package/lib/legacy/{material-viewer-83aa0d82.legacy.js → material-viewer-7103fd72.legacy.js} +2 -2
  71. package/lib/legacy/material-viewer-7103fd72.legacy.js.map +1 -0
  72. package/lib/legacy/material-viewer-main.legacy.js +1 -1
  73. package/lib/legacy/{planner-a0ef7d31.legacy.js → planner-be2a0965.legacy.js} +2 -2
  74. package/lib/legacy/{planner-a0ef7d31.legacy.js.map → planner-be2a0965.legacy.js.map} +1 -1
  75. package/lib/legacy/planner-main.legacy.js +1 -1
  76. package/lib/legacy/{roomle-configurator-7dc323ca.legacy.js → roomle-configurator-e774fe03.legacy.js} +2 -2
  77. package/lib/legacy/roomle-configurator-e774fe03.legacy.js.map +1 -0
  78. package/lib/legacy/roomle-dependency-injection-209a95bc.legacy.js +9 -0
  79. package/lib/legacy/{roomle-dependency-injection-ab58de3d.legacy.js.map → roomle-dependency-injection-209a95bc.legacy.js.map} +1 -1
  80. package/lib/legacy/roomle-sdk.legacy.js +1 -1
  81. package/lib/legacy/{scene-manager-079c4752.legacy.js → scene-manager-f6e7143c.legacy.js} +2 -2
  82. package/lib/legacy/{scene-manager-079c4752.legacy.js.map → scene-manager-f6e7143c.legacy.js.map} +1 -1
  83. package/lib/legacy/{script-loader-35fe01aa.legacy.js → script-loader-f6681cf0.legacy.js} +2 -2
  84. package/lib/legacy/script-loader-f6681cf0.legacy.js.map +1 -0
  85. package/lib/legacy/{stats-helper-40eeaca2.legacy.js → stats-helper-caa407ec.legacy.js} +2 -2
  86. package/lib/legacy/stats-helper-caa407ec.legacy.js.map +1 -0
  87. package/lib/legacy/{tools-core-ae90b05b.legacy.js → tools-core-dbdad735.legacy.js} +2 -2
  88. package/lib/legacy/tools-core-dbdad735.legacy.js.map +1 -0
  89. package/lib/{main-thread-to-worker-30982707.js → main-thread-to-worker-64a59f5b.js} +2 -2
  90. package/lib/{main-thread-to-worker-30982707.js.map → main-thread-to-worker-64a59f5b.js.map} +1 -1
  91. package/lib/main-thread-to-worker-bf37ccb6.nomodule.js +8 -0
  92. package/lib/{main-thread-to-worker-5609c757.nomodule.js.map → main-thread-to-worker-bf37ccb6.nomodule.js.map} +1 -1
  93. package/lib/{material-viewer-e70173ae.js → material-viewer-8c6656a9.js} +2 -2
  94. package/lib/material-viewer-8c6656a9.js.map +1 -0
  95. package/lib/{material-viewer-4d884001.nomodule.js → material-viewer-b09b4294.nomodule.js} +2 -2
  96. package/lib/material-viewer-b09b4294.nomodule.js.map +1 -0
  97. package/lib/material-viewer-main-5b97645d.js +2 -0
  98. package/lib/material-viewer-main-5b97645d.js.map +1 -0
  99. package/lib/material-viewer-main.nomodule.js +1 -1
  100. package/lib/{planner-7ec2696d.nomodule.js → planner-98212afe.nomodule.js} +2 -2
  101. package/lib/{planner-7ec2696d.nomodule.js.map → planner-98212afe.nomodule.js.map} +1 -1
  102. package/lib/{planner-2d7a7b1b.js → planner-e6b1fb60.js} +2 -2
  103. package/lib/{planner-2d7a7b1b.js.map → planner-e6b1fb60.js.map} +1 -1
  104. package/lib/planner-main-f0e4513f.js +2 -0
  105. package/lib/planner-main-f0e4513f.js.map +1 -0
  106. package/lib/planner-main.nomodule.js +1 -1
  107. package/lib/{roomle-configurator-42d4fecc.js → roomle-configurator-7b42df67.js} +2 -2
  108. package/lib/roomle-configurator-7b42df67.js.map +1 -0
  109. package/lib/{roomle-configurator-b01d2885.nomodule.js → roomle-configurator-d3491afb.nomodule.js} +2 -2
  110. package/lib/roomle-configurator-d3491afb.nomodule.js.map +1 -0
  111. package/lib/roomle-dependency-injection-60ebaf7e.nomodule.js +16 -0
  112. package/lib/{roomle-dependency-injection-2583f0dc.nomodule.js.map → roomle-dependency-injection-60ebaf7e.nomodule.js.map} +1 -1
  113. package/lib/roomle-dependency-injection-ee1a801f.js +16 -0
  114. package/lib/{roomle-dependency-injection-bf64a07e.js.map → roomle-dependency-injection-ee1a801f.js.map} +1 -1
  115. package/lib/{roomle-sdk-1ed375ca.js → roomle-sdk-9d596c91.js} +2 -2
  116. package/lib/roomle-sdk-9d596c91.js.map +1 -0
  117. package/lib/roomle-sdk.nomodule.js +1 -1
  118. package/lib/{scene-manager-45fc4ce6.nomodule.js → scene-manager-6dd0fdd1.nomodule.js} +2 -2
  119. package/lib/{scene-manager-45fc4ce6.nomodule.js.map → scene-manager-6dd0fdd1.nomodule.js.map} +1 -1
  120. package/lib/{scene-manager-d25d6ad2.js → scene-manager-ac75aaa1.js} +2 -2
  121. package/lib/{scene-manager-d25d6ad2.js.map → scene-manager-ac75aaa1.js.map} +1 -1
  122. package/lib/{script-loader-92e1532b.nomodule.js → script-loader-5f9a9d17.nomodule.js} +2 -2
  123. package/lib/script-loader-5f9a9d17.nomodule.js.map +1 -0
  124. package/lib/{script-loader-9059c8a6.js → script-loader-63343d0d.js} +2 -2
  125. package/lib/script-loader-63343d0d.js.map +1 -0
  126. package/lib/{stats-helper-62ea900d.js → stats-helper-50bfc81a.js} +2 -2
  127. package/lib/stats-helper-50bfc81a.js.map +1 -0
  128. package/lib/{stats-helper-dd07b86c.nomodule.js → stats-helper-98ed1a5d.nomodule.js} +2 -2
  129. package/lib/stats-helper-98ed1a5d.nomodule.js.map +1 -0
  130. package/lib/{tools-core-f5491293.nomodule.js → tools-core-36f69785.nomodule.js} +2 -2
  131. package/lib/tools-core-36f69785.nomodule.js.map +1 -0
  132. package/lib/{tools-core-02eb3a98.js → tools-core-b0a7804f.js} +2 -2
  133. package/lib/tools-core-b0a7804f.js.map +1 -0
  134. package/package.json +2 -2
  135. package/lib/component-dimensioning-64dd804c.js.map +0 -1
  136. package/lib/component-dimensioning-a8078114.nomodule.js.map +0 -1
  137. package/lib/component-raycast-helper-4f91b663.js.map +0 -1
  138. package/lib/component-raycast-helper-ac3b7072.nomodule.js.map +0 -1
  139. package/lib/configurator-a9c1fe12.nomodule.js.map +0 -1
  140. package/lib/configurator-c62d84e8.js.map +0 -1
  141. package/lib/configurator-main-ba699dda.js +0 -2
  142. package/lib/configurator-main-ba699dda.js.map +0 -1
  143. package/lib/continuous-drawing-helper-3b11f9f9.js.map +0 -1
  144. package/lib/continuous-drawing-helper-7a08e3cf.nomodule.js.map +0 -1
  145. package/lib/default-light-setting-01a91d0f.nomodule.js.map +0 -1
  146. package/lib/default-light-setting-f4f47231.js.map +0 -1
  147. package/lib/glb-viewer-main-a9bf8d50.js +0 -2
  148. package/lib/glb-viewer-main-a9bf8d50.js.map +0 -1
  149. package/lib/legacy/TextGeometry-85fd8358.legacy.js +0 -2
  150. package/lib/legacy/component-dimensioning-0c4f6279.legacy.js.map +0 -1
  151. package/lib/legacy/component-raycast-helper-e634d9cc.legacy.js.map +0 -1
  152. package/lib/legacy/configurator-5d8e9e4c.legacy.js.map +0 -1
  153. package/lib/legacy/continuous-drawing-helper-d7691e20.legacy.js.map +0 -1
  154. package/lib/legacy/default-light-setting-80b8957f.legacy.js.map +0 -1
  155. package/lib/legacy/main-thread-to-worker-50cdf3d3.legacy.js +0 -7
  156. package/lib/legacy/material-viewer-83aa0d82.legacy.js.map +0 -1
  157. package/lib/legacy/roomle-configurator-7dc323ca.legacy.js.map +0 -1
  158. package/lib/legacy/roomle-dependency-injection-ab58de3d.legacy.js +0 -9
  159. package/lib/legacy/script-loader-35fe01aa.legacy.js.map +0 -1
  160. package/lib/legacy/stats-helper-40eeaca2.legacy.js.map +0 -1
  161. package/lib/legacy/tools-core-ae90b05b.legacy.js.map +0 -1
  162. package/lib/main-thread-to-worker-5609c757.nomodule.js +0 -8
  163. package/lib/material-viewer-4d884001.nomodule.js.map +0 -1
  164. package/lib/material-viewer-e70173ae.js.map +0 -1
  165. package/lib/material-viewer-main-7c8974fa.js +0 -2
  166. package/lib/material-viewer-main-7c8974fa.js.map +0 -1
  167. package/lib/planner-main-d56b0156.js +0 -2
  168. package/lib/planner-main-d56b0156.js.map +0 -1
  169. package/lib/roomle-configurator-42d4fecc.js.map +0 -1
  170. package/lib/roomle-configurator-b01d2885.nomodule.js.map +0 -1
  171. package/lib/roomle-dependency-injection-2583f0dc.nomodule.js +0 -16
  172. package/lib/roomle-dependency-injection-bf64a07e.js +0 -16
  173. package/lib/roomle-sdk-1ed375ca.js.map +0 -1
  174. package/lib/script-loader-9059c8a6.js.map +0 -1
  175. package/lib/script-loader-92e1532b.nomodule.js.map +0 -1
  176. package/lib/stats-helper-62ea900d.js.map +0 -1
  177. package/lib/stats-helper-dd07b86c.nomodule.js.map +0 -1
  178. package/lib/tools-core-02eb3a98.js.map +0 -1
  179. package/lib/tools-core-f5491293.nomodule.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{S as ScriptLoader,M as Main}from"./script-loader-9059c8a6.js";import{_ as __decorate,i as inject,l as CANVAS_ID,p as DynamicLightSettingLoader,q as PREDEFINED_LIGHTSETTING,V as MaterialCreator,ao as setMaterial,ap as getMaterialShading,Z as getGUI,aq as addExistingTexture,Y as addTexture,ar as UiCallback,D as DependencyInjectionAssignment,L as Logger,am as InputManager,as as ConfiguratorMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-bf64a07e.js";import{S as SceneManager,B as BackgroundEnvironment,C as CameraControl3D,F as FloorEnvironment,T as TWEEN_FILE_NAME}from"./scene-manager-d25d6ad2.js";import{at as BoxGeometry,x as Mesh,C as Color,aa as Box3,a as Vector3,u as DoubleSide,a4 as FrontSide,aH as SphereGeometry,b3 as PlaneGeometry,a6 as Texture}from"./main-thread-to-worker-30982707.js";import"./query-params-helper-a271f9dc.js";class MaterialViewerSceneManager extends SceneManager{constructor(e,a){super(e,a,CANVAS_ID.RMV),this._sceneParams={type:"cube"},this._materialParams={color:"#ffffff",metallic:.5,alpha:0,alphaCutoff:0,doubleSided:!1},this._renderer.capabilities.maxTextures>8&&this.loadDynamicLightSetting(DynamicLightSettingLoader.createDynamicLightSettingSource(null,PREDEFINED_LIGHTSETTING.CAMERA)),this._initScene()}_initScene(){const e=new BoxGeometry(1,1,1,100,100,100),a=MaterialCreator.createMeshPhysicalMaterial({color:this._initData.colors.PRIMARY});this._setMaterial(a),this._mesh=new Mesh(e,this._material),this._mesh.castShadow=!0,this._mesh.position.setY(.5),this._scene.add(this._mesh);const{initialFloorMaterial:t}=this._initData;if(t?this.changeFloorMaterialById(t):this._environment=new BackgroundEnvironment(this._scene,null,new Color(16777215)),this._cameraControl instanceof CameraControl3D){const e=new Box3;e.setFromObject(this._mesh),this._cameraControl.updateAndReset(e.getSize(new Vector3),e.getCenter(new Vector3))}this.showGUI()}loadMaterialId(e){return new Promise(a=>{this._configuratorMeshGenerator.loadMaterial(e,1e3,1e3).then(e=>{this._setMaterial(e),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),a()})})}loadMaterial(e){return new Promise(a=>{e.__rapi_path__||(e.__rapi_path__="materials"),this._mesh.material=this._material,this._configuratorMeshGenerator.loadTextures(e,this._material,100,100).then(()=>{this._updateGUI(),this._requestRender()}),a()})}loadMaterialShading(e){return new Promise(a=>{let t={shading:e};this._setMaterial(setMaterial(this._material,t,this._initData.envMapIntensity)),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),a()})}_setMaterial(e){this._material=e,this._materialParams.alpha=e.opacity,this._materialParams.alphaCutoff=e.alphaTest,this._materialParams.color="#"+e.color.getHexString(),this._materialParams.doubleSided=e.side===DoubleSide,this._materialParams.metallic=1===e.metalness?1:e.reflectivity}getMaterialShading(){return getMaterialShading(this._material)}createCameraControl(e,a){this._cameraControl=new CameraControl3D(this._creator_,this._getInputManager(),new Vector3(-1,1,1))}_getInputManager(){return this._inputManager}sceneChanged(){}getBounds(){return this._mesh?(new Box3).setFromObject(this._mesh):null}_guiLoaded(){this._updateGUI()}_updateGUI(){let e=getGUI();e&&(this._guiGeometryFolder||(this._guiGeometryFolder=e.addFolder("Geometry"),this._guiGeometryFolder.add(this._sceneParams,"type",{Cube:"cube",Sphere:"sphere",PlaneVertical:"plane_vertical",PlaneHorizontal:"plane_horizontal"}).onChange(e=>{this._setGeometry()})),this._material&&(this._guiMaterialFolder&&e.removeFolder(this._guiMaterialFolder),this._guiMaterialFolder=e.addFolder("Material"),this._guiMaterialFolder.addColor(this._materialParams,"color").onChange(e=>{this._material.color=new Color(e),this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"metallic").min(0).max(1).step(.01).onChange(e=>{this._material.metalness=1===e?1:.5,this._material.reflectivity=e||.5,this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"roughness").min(0).max(1).step(.01).onChange(e=>{this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"transmission").min(0).max(1).step(.01).onChange(e=>{this._material.transmission=e,e>0&&(this._material.opacity=1,this._material.alphaTest=.5,this._material.depthWrite=!1,this._material.transparent=!0,this._material.metalness=0),this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alpha").min(0).max(1).step(.01).onChange(e=>{this._material.transparent=e<1,this._material.opacity=e,this._material.depthWrite=e>=1,this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alphaCutoff").min(0).max(1).step(.01).onChange(e=>{this._material.alphaTest=e||0,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"doubleSided").onChange(e=>{this._material.side=e?DoubleSide:FrontSide,this._shadingChanged()})),this._addGUIListener(e))}_shadingChanged(){this._roomleMaterialViewerUiCallback.onMaterialShadingChanged(getMaterialShading(this._material))}setGeometry(e){this._sceneParams.type=e,this._setGeometry()}_setGeometry(){let e;"cube"===this._sceneParams.type&&(e=new BoxGeometry(1,1,1,100,100,100)),"sphere"===this._sceneParams.type&&(e=new SphereGeometry(.5,100,100)),"plane_horizontal"===this._sceneParams.type&&(e=new PlaneGeometry(1,1),e.rotateX(-Math.PI/2)),"plane_vertical"===this._sceneParams.type&&(e=new PlaneGeometry(1,1)),this._mesh.geometry=e,this._renderEverything()}async changeFloorMaterialById(e){const a=await this._rapiAccess.getMaterial(e);return this._environment&&this._environment instanceof FloorEnvironment||(this._environment=new FloorEnvironment(this._scene,this._environment,!0)),new Promise((e,t)=>{this._environment.changeFloorMaterial(a,this._maxAnisotropy,this._initData.envMapIntensity).then(()=>{this._requestRender(),e()},t)})}async addTexture(e,a){const t=100/(0===e.mmWidth?1:e.mmWidth),i=100/(0===e.mmHeight?1:e.mmHeight);if(a){const r=new Image;r.src=a;const s=new Texture;s.image=r,r.onload=function(){s.needsUpdate=!0},addExistingTexture(s,e,this._material,this._maxAnisotropy,t,i,this._renderer.capabilities.maxTextures)}else await addTexture(e.image,e,this._material,this._maxAnisotropy,t,i,this._renderer.capabilities.maxTextures);this._requestRender()}removeTexture(e){"ORM"===e.mapping&&(this._material.aoMap=null,this._material.roughnessMap=null,this._material.metalnessMap=null),"RGB"!==e.mapping&&"RGBA"!==e.mapping||(this._material.map=null),"XYZ"===e.mapping&&(this._material.normalMap=null),this._material.needsUpdate=!0,this._requestRender()}clearCache(){this._configuratorMeshGenerator.clear()}}__decorate([inject],MaterialViewerSceneManager.prototype,"_inputManager",void 0),__decorate([inject],MaterialViewerSceneManager.prototype,"_configuratorMeshGenerator",void 0),__decorate([inject],MaterialViewerSceneManager.prototype,"_roomleMaterialViewerUiCallback",void 0),__decorate([inject],MaterialViewerSceneManager.prototype,"_rapiAccess",void 0);class RoomleMaterialViewer{constructor(e){this._creator_=e}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}getCameraOffset(){return this._sceneManager.getCameraOffset()}init(e){return this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):new Promise(this._initPromiseCallback.bind(this))}_initPromiseCallback(e,a){Promise.all([this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"})]).then(()=>{this._sceneManager=new MaterialViewerSceneManager(this._creator_,{left:0,top:1,right:1,bottom:0}),this._sceneManager.enableHD(),e()})}get callbacks(){return this._roomleMaterialViewerUiCallback}set callbacks(e){this._roomleMaterialViewerUiCallback=e}loadMaterialShading(e){return this._sceneManager.loadMaterialShading(e)}loadMaterial(e,a={}){return a.flushCache&&this._clearCaches(),this._sceneManager.loadMaterial(e)}loadMaterialId(e,a={}){return a.flushCache&&this._clearCaches(),this._sceneManager.loadMaterialId(e)}getMaterialShading(){return this._sceneManager.getMaterialShading()}loadSceneSetting(e){return this._sceneManager.loadSceneSettings(e)}setOverrides(e){e&&this._initData.setOverrides(e)}updateSize(){this._sceneManager.updateCamera()}getMain(){}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}showGUI(){this._sceneManager.showGUI()}async changeFloorMaterialById(e){return this._sceneManager.changeFloorMaterialById(e)}setGeometry(e){this._sceneManager.setGeometry(e)}async addTexture(e,a){return this._sceneManager.addTexture(e,a)}removeTexture(e){return this._sceneManager.removeTexture(e)}_clearCaches(){this._rapiAccess.cleanUp(),this._sceneManager.clearCache()}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getUnitFormatter(){return this._unitFormatter}}__decorate([inject],RoomleMaterialViewer.prototype,"_domHelper",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_scriptLoader",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_lifeCycleManager",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_roomleMaterialViewerUiCallback",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_initData",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_rapiAccess",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_unitFormatter",void 0);const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("input-manager",InputManager,1),new DependencyInjectionAssignment("configurator-mesh-generator",ConfiguratorMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("roomle-material-viewer-ui-callback",class extends UiCallback{constructor(e){super(e),this.onMaterialShadingChanged=e=>{}}},1)];class MaterialViewer extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._viewer=new RoomleMaterialViewer(this._context),window.RoomleMaterialViewer||(window.RoomleMaterialViewer=this._viewer)}getApi(){return this._viewer}getContextName(){return"material-viewer"}}export{MaterialViewer};
2
- //# sourceMappingURL=material-viewer-e70173ae.js.map
1
+ import{S as ScriptLoader,M as Main}from"./script-loader-63343d0d.js";import{_ as __decorate,i as inject,l as CANVAS_ID,p as DynamicLightSettingLoader,q as PREDEFINED_LIGHTSETTING,V as MaterialCreator,ao as setMaterial,ap as getMaterialShading,Z as getGUI,aq as addExistingTexture,Y as addTexture,ar as UiCallback,D as DependencyInjectionAssignment,L as Logger,am as InputManager,as as ConfiguratorMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-ee1a801f.js";import{S as SceneManager,B as BackgroundEnvironment,C as CameraControl3D,F as FloorEnvironment,T as TWEEN_FILE_NAME}from"./scene-manager-ac75aaa1.js";import{at as BoxGeometry,x as Mesh,C as Color,aa as Box3,a as Vector3,u as DoubleSide,a4 as FrontSide,aH as SphereGeometry,b3 as PlaneGeometry,a6 as Texture}from"./main-thread-to-worker-64a59f5b.js";import"./query-params-helper-a271f9dc.js";class MaterialViewerSceneManager extends SceneManager{constructor(e,a){super(e,a,CANVAS_ID.RMV),this._sceneParams={type:"cube"},this._materialParams={color:"#ffffff",metallic:.5,alpha:0,alphaCutoff:0,doubleSided:!1},this._renderer.capabilities.maxTextures>8&&this.loadDynamicLightSetting(DynamicLightSettingLoader.createDynamicLightSettingSource(null,PREDEFINED_LIGHTSETTING.CAMERA)),this._initScene()}_initScene(){const e=new BoxGeometry(1,1,1,100,100,100),a=MaterialCreator.createMeshPhysicalMaterial({color:this._initData.colors.PRIMARY});this._setMaterial(a),this._mesh=new Mesh(e,this._material),this._mesh.castShadow=!0,this._mesh.position.setY(.5),this._scene.add(this._mesh);const{initialFloorMaterial:t}=this._initData;if(t?this.changeFloorMaterialById(t):this._environment=new BackgroundEnvironment(this._scene,null,new Color(16777215)),this._cameraControl instanceof CameraControl3D){const e=new Box3;e.setFromObject(this._mesh),this._cameraControl.updateAndReset(e.getSize(new Vector3),e.getCenter(new Vector3))}this.showGUI()}loadMaterialId(e){return new Promise(a=>{this._configuratorMeshGenerator.loadMaterial(e,1e3,1e3).then(e=>{this._setMaterial(e),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),a()})})}loadMaterial(e){return new Promise(a=>{e.__rapi_path__||(e.__rapi_path__="materials"),this._mesh.material=this._material,this._configuratorMeshGenerator.loadTextures(e,this._material,100,100).then(()=>{this._updateGUI(),this._requestRender()}),a()})}loadMaterialShading(e){return new Promise(a=>{let t={shading:e};this._setMaterial(setMaterial(this._material,t,this._initData.envMapIntensity)),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),a()})}_setMaterial(e){this._material=e,this._materialParams.alpha=e.opacity,this._materialParams.alphaCutoff=e.alphaTest,this._materialParams.color="#"+e.color.getHexString(),this._materialParams.doubleSided=e.side===DoubleSide,this._materialParams.metallic=1===e.metalness?1:e.reflectivity}getMaterialShading(){return getMaterialShading(this._material)}createCameraControl(e,a){this._cameraControl=new CameraControl3D(this._creator_,this._getInputManager(),new Vector3(-1,1,1))}_getInputManager(){return this._inputManager}sceneChanged(){}getBounds(){return this._mesh?(new Box3).setFromObject(this._mesh):null}_guiLoaded(){this._updateGUI()}_updateGUI(){let e=getGUI();e&&(this._guiGeometryFolder||(this._guiGeometryFolder=e.addFolder("Geometry"),this._guiGeometryFolder.add(this._sceneParams,"type",{Cube:"cube",Sphere:"sphere",PlaneVertical:"plane_vertical",PlaneHorizontal:"plane_horizontal"}).onChange(e=>{this._setGeometry()})),this._material&&(this._guiMaterialFolder&&e.removeFolder(this._guiMaterialFolder),this._guiMaterialFolder=e.addFolder("Material"),this._guiMaterialFolder.addColor(this._materialParams,"color").onChange(e=>{this._material.color=new Color(e),this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"metallic").min(0).max(1).step(.01).onChange(e=>{this._material.metalness=1===e?1:.5,this._material.reflectivity=e||.5,this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"roughness").min(0).max(1).step(.01).onChange(e=>{this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"transmission").min(0).max(1).step(.01).onChange(e=>{this._material.transmission=e,e>0&&(this._material.opacity=1,this._material.alphaTest=.5,this._material.depthWrite=!1,this._material.transparent=!0,this._material.metalness=0),this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alpha").min(0).max(1).step(.01).onChange(e=>{this._material.transparent=e<1,this._material.opacity=e,this._material.depthWrite=e>=1,this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alphaCutoff").min(0).max(1).step(.01).onChange(e=>{this._material.alphaTest=e||0,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"doubleSided").onChange(e=>{this._material.side=e?DoubleSide:FrontSide,this._shadingChanged()})),this._addGUIListener(e))}_shadingChanged(){this._roomleMaterialViewerUiCallback.onMaterialShadingChanged(getMaterialShading(this._material))}setGeometry(e){this._sceneParams.type=e,this._setGeometry()}_setGeometry(){let e;"cube"===this._sceneParams.type&&(e=new BoxGeometry(1,1,1,100,100,100)),"sphere"===this._sceneParams.type&&(e=new SphereGeometry(.5,100,100)),"plane_horizontal"===this._sceneParams.type&&(e=new PlaneGeometry(1,1),e.rotateX(-Math.PI/2)),"plane_vertical"===this._sceneParams.type&&(e=new PlaneGeometry(1,1)),this._mesh.geometry=e,this._renderEverything()}async changeFloorMaterialById(e){const a=await this._rapiAccess.getMaterial(e);return this._environment&&this._environment instanceof FloorEnvironment||(this._environment=new FloorEnvironment(this._scene,this._environment,!0)),new Promise((e,t)=>{this._environment.changeFloorMaterial(a,this._maxAnisotropy,this._initData.envMapIntensity).then(()=>{this._requestRender(),e()},t)})}async addTexture(e,a){const t=100/(0===e.mmWidth?1:e.mmWidth),i=100/(0===e.mmHeight?1:e.mmHeight);if(a){const r=new Image;r.src=a;const s=new Texture;s.image=r,r.onload=function(){s.needsUpdate=!0},addExistingTexture(s,e,this._material,this._maxAnisotropy,t,i,this._renderer.capabilities.maxTextures)}else await addTexture(e.image,e,this._material,this._maxAnisotropy,t,i,this._renderer.capabilities.maxTextures);this._requestRender()}removeTexture(e){"ORM"===e.mapping&&(this._material.aoMap=null,this._material.roughnessMap=null,this._material.metalnessMap=null),"RGB"!==e.mapping&&"RGBA"!==e.mapping||(this._material.map=null),"XYZ"===e.mapping&&(this._material.normalMap=null),this._material.needsUpdate=!0,this._requestRender()}clearCache(){this._configuratorMeshGenerator.clear()}}__decorate([inject],MaterialViewerSceneManager.prototype,"_inputManager",void 0),__decorate([inject],MaterialViewerSceneManager.prototype,"_configuratorMeshGenerator",void 0),__decorate([inject],MaterialViewerSceneManager.prototype,"_roomleMaterialViewerUiCallback",void 0),__decorate([inject],MaterialViewerSceneManager.prototype,"_rapiAccess",void 0);class RoomleMaterialViewer{constructor(e){this._creator_=e}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}getCameraOffset(){return this._sceneManager.getCameraOffset()}init(e){return this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):new Promise(this._initPromiseCallback.bind(this))}_initPromiseCallback(e,a){Promise.all([this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"})]).then(()=>{this._sceneManager=new MaterialViewerSceneManager(this._creator_,{left:0,top:1,right:1,bottom:0}),this._sceneManager.enableHD(),e()})}get callbacks(){return this._roomleMaterialViewerUiCallback}set callbacks(e){this._roomleMaterialViewerUiCallback=e}loadMaterialShading(e){return this._sceneManager.loadMaterialShading(e)}loadMaterial(e,a={}){return a.flushCache&&this._clearCaches(),this._sceneManager.loadMaterial(e)}loadMaterialId(e,a={}){return a.flushCache&&this._clearCaches(),this._sceneManager.loadMaterialId(e)}getMaterialShading(){return this._sceneManager.getMaterialShading()}loadSceneSetting(e){return this._sceneManager.loadSceneSettings(e)}setOverrides(e){e&&this._initData.setOverrides(e)}updateSize(){this._sceneManager.updateCamera()}getMain(){}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}showGUI(){this._sceneManager.showGUI()}async changeFloorMaterialById(e){return this._sceneManager.changeFloorMaterialById(e)}setGeometry(e){this._sceneManager.setGeometry(e)}async addTexture(e,a){return this._sceneManager.addTexture(e,a)}removeTexture(e){return this._sceneManager.removeTexture(e)}_clearCaches(){this._rapiAccess.cleanUp(),this._sceneManager.clearCache()}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getUnitFormatter(){return this._unitFormatter}}__decorate([inject],RoomleMaterialViewer.prototype,"_domHelper",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_scriptLoader",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_lifeCycleManager",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_roomleMaterialViewerUiCallback",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_initData",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_rapiAccess",void 0),__decorate([inject],RoomleMaterialViewer.prototype,"_unitFormatter",void 0);const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("input-manager",InputManager,1),new DependencyInjectionAssignment("configurator-mesh-generator",ConfiguratorMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("roomle-material-viewer-ui-callback",class extends UiCallback{constructor(e){super(e),this.onMaterialShadingChanged=e=>{}}},1)];class MaterialViewer extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._viewer=new RoomleMaterialViewer(this._context),window.RoomleMaterialViewer||(window.RoomleMaterialViewer=this._viewer)}getApi(){return this._viewer}getContextName(){return"material-viewer"}}export{MaterialViewer};
2
+ //# sourceMappingURL=material-viewer-8c6656a9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material-viewer-8c6656a9.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- System.register(["./script-loader-92e1532b.nomodule.js","./roomle-dependency-injection-2583f0dc.nomodule.js","./scene-manager-45fc4ce6.nomodule.js","./main-thread-to-worker-5609c757.nomodule.js","./query-params-helper-c231e1b8.nomodule.js"],(function(e){var t,a,i,r,s,n,h,o,l,_,m,d,c,p,g,u,M,w,y,C,f,v,S,b,P,x,F,G,I,U,R,T,D,A,k;return{setters:[function(e){t=e.S,a=e.M},function(e){i=e._,r=e.i,s=e.l,n=e.p,h=e.q,o=e.V,l=e.ao,_=e.ap,m=e.Z,d=e.aq,c=e.Y,p=e.ar,g=e.D,u=e.L,M=e.am,w=e.as,y=e.R,C=e.b},function(e){f=e.S,v=e.B,S=e.C,b=e.F,P=e.T},function(e){x=e.at,F=e.x,G=e.C,I=e.aa,U=e.a,R=e.u,T=e.a4,D=e.aH,A=e.b3,k=e.a6},function(){}],execute:function(){class V extends f{constructor(e,t){super(e,t,s.RMV),this._sceneParams={type:"cube"},this._materialParams={color:"#ffffff",metallic:.5,alpha:0,alphaCutoff:0,doubleSided:!1},this._renderer.capabilities.maxTextures>8&&this.loadDynamicLightSetting(n.createDynamicLightSettingSource(null,h.CAMERA)),this._initScene()}_initScene(){const e=new x(1,1,1,100,100,100),t=o.createMeshPhysicalMaterial({color:this._initData.colors.PRIMARY});this._setMaterial(t),this._mesh=new F(e,this._material),this._mesh.castShadow=!0,this._mesh.position.setY(.5),this._scene.add(this._mesh);const{initialFloorMaterial:a}=this._initData;if(a?this.changeFloorMaterialById(a):this._environment=new v(this._scene,null,new G(16777215)),this._cameraControl instanceof S){const e=new I;e.setFromObject(this._mesh),this._cameraControl.updateAndReset(e.getSize(new U),e.getCenter(new U))}this.showGUI()}loadMaterialId(e){return new Promise(t=>{this._configuratorMeshGenerator.loadMaterial(e,1e3,1e3).then(e=>{this._setMaterial(e),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),t()})})}loadMaterial(e){return new Promise(t=>{e.__rapi_path__||(e.__rapi_path__="materials"),this._mesh.material=this._material,this._configuratorMeshGenerator.loadTextures(e,this._material,100,100).then(()=>{this._updateGUI(),this._requestRender()}),t()})}loadMaterialShading(e){return new Promise(t=>{let a={shading:e};this._setMaterial(l(this._material,a,this._initData.envMapIntensity)),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),t()})}_setMaterial(e){this._material=e,this._materialParams.alpha=e.opacity,this._materialParams.alphaCutoff=e.alphaTest,this._materialParams.color="#"+e.color.getHexString(),this._materialParams.doubleSided=e.side===R,this._materialParams.metallic=1===e.metalness?1:e.reflectivity}getMaterialShading(){return _(this._material)}createCameraControl(e,t){this._cameraControl=new S(this._creator_,this._getInputManager(),new U(-1,1,1))}_getInputManager(){return this._inputManager}sceneChanged(){}getBounds(){return this._mesh?(new I).setFromObject(this._mesh):null}_guiLoaded(){this._updateGUI()}_updateGUI(){let e=m();e&&(this._guiGeometryFolder||(this._guiGeometryFolder=e.addFolder("Geometry"),this._guiGeometryFolder.add(this._sceneParams,"type",{Cube:"cube",Sphere:"sphere",PlaneVertical:"plane_vertical",PlaneHorizontal:"plane_horizontal"}).onChange(e=>{this._setGeometry()})),this._material&&(this._guiMaterialFolder&&e.removeFolder(this._guiMaterialFolder),this._guiMaterialFolder=e.addFolder("Material"),this._guiMaterialFolder.addColor(this._materialParams,"color").onChange(e=>{this._material.color=new G(e),this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"metallic").min(0).max(1).step(.01).onChange(e=>{this._material.metalness=1===e?1:.5,this._material.reflectivity=e||.5,this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"roughness").min(0).max(1).step(.01).onChange(e=>{this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"transmission").min(0).max(1).step(.01).onChange(e=>{this._material.transmission=e,e>0&&(this._material.opacity=1,this._material.alphaTest=.5,this._material.depthWrite=!1,this._material.transparent=!0,this._material.metalness=0),this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alpha").min(0).max(1).step(.01).onChange(e=>{this._material.transparent=e<1,this._material.opacity=e,this._material.depthWrite=e>=1,this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alphaCutoff").min(0).max(1).step(.01).onChange(e=>{this._material.alphaTest=e||0,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"doubleSided").onChange(e=>{this._material.side=e?R:T,this._shadingChanged()})),this._addGUIListener(e))}_shadingChanged(){this._roomleMaterialViewerUiCallback.onMaterialShadingChanged(_(this._material))}setGeometry(e){this._sceneParams.type=e,this._setGeometry()}_setGeometry(){let e;"cube"===this._sceneParams.type&&(e=new x(1,1,1,100,100,100)),"sphere"===this._sceneParams.type&&(e=new D(.5,100,100)),"plane_horizontal"===this._sceneParams.type&&(e=new A(1,1),e.rotateX(-Math.PI/2)),"plane_vertical"===this._sceneParams.type&&(e=new A(1,1)),this._mesh.geometry=e,this._renderEverything()}async changeFloorMaterialById(e){const t=await this._rapiAccess.getMaterial(e);return this._environment&&this._environment instanceof b||(this._environment=new b(this._scene,this._environment,!0)),new Promise((e,a)=>{this._environment.changeFloorMaterial(t,this._maxAnisotropy,this._initData.envMapIntensity).then(()=>{this._requestRender(),e()},a)})}async addTexture(e,t){const a=100/(0===e.mmWidth?1:e.mmWidth),i=100/(0===e.mmHeight?1:e.mmHeight);if(t){const r=new Image;r.src=t;const s=new k;s.image=r,r.onload=function(){s.needsUpdate=!0},d(s,e,this._material,this._maxAnisotropy,a,i,this._renderer.capabilities.maxTextures)}else await c(e.image,e,this._material,this._maxAnisotropy,a,i,this._renderer.capabilities.maxTextures);this._requestRender()}removeTexture(e){"ORM"===e.mapping&&(this._material.aoMap=null,this._material.roughnessMap=null,this._material.metalnessMap=null),"RGB"!==e.mapping&&"RGBA"!==e.mapping||(this._material.map=null),"XYZ"===e.mapping&&(this._material.normalMap=null),this._material.needsUpdate=!0,this._requestRender()}clearCache(){this._configuratorMeshGenerator.clear()}}i([r],V.prototype,"_inputManager",void 0),i([r],V.prototype,"_configuratorMeshGenerator",void 0),i([r],V.prototype,"_roomleMaterialViewerUiCallback",void 0),i([r],V.prototype,"_rapiAccess",void 0);class j{constructor(e){this._creator_=e}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}getCameraOffset(){return this._sceneManager.getCameraOffset()}init(e){return this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):new Promise(this._initPromiseCallback.bind(this))}_initPromiseCallback(e,t){Promise.all([this._scriptLoader.fetch(P,{id:"tween-js"})]).then(()=>{this._sceneManager=new V(this._creator_,{left:0,top:1,right:1,bottom:0}),this._sceneManager.enableHD(),e()})}get callbacks(){return this._roomleMaterialViewerUiCallback}set callbacks(e){this._roomleMaterialViewerUiCallback=e}loadMaterialShading(e){return this._sceneManager.loadMaterialShading(e)}loadMaterial(e,t={}){return t.flushCache&&this._clearCaches(),this._sceneManager.loadMaterial(e)}loadMaterialId(e,t={}){return t.flushCache&&this._clearCaches(),this._sceneManager.loadMaterialId(e)}getMaterialShading(){return this._sceneManager.getMaterialShading()}loadSceneSetting(e){return this._sceneManager.loadSceneSettings(e)}setOverrides(e){e&&this._initData.setOverrides(e)}updateSize(){this._sceneManager.updateCamera()}getMain(){}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}showGUI(){this._sceneManager.showGUI()}async changeFloorMaterialById(e){return this._sceneManager.changeFloorMaterialById(e)}setGeometry(e){this._sceneManager.setGeometry(e)}async addTexture(e,t){return this._sceneManager.addTexture(e,t)}removeTexture(e){return this._sceneManager.removeTexture(e)}_clearCaches(){this._rapiAccess.cleanUp(),this._sceneManager.clearCache()}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getUnitFormatter(){return this._unitFormatter}}i([r],j.prototype,"_domHelper",void 0),i([r],j.prototype,"_scriptLoader",void 0),i([r],j.prototype,"_lifeCycleManager",void 0),i([r],j.prototype,"_roomleMaterialViewerUiCallback",void 0),i([r],j.prototype,"_initData",void 0),i([r],j.prototype,"_rapiAccess",void 0),i([r],j.prototype,"_unitFormatter",void 0);const q=[new g("script-loader",t),new g("logger",u),new g("input-manager",M,1),new g("configurator-mesh-generator",w),new g("rapi-access",y),new g("roomle-material-viewer-ui-callback",class extends p{constructor(e){super(e),this.onMaterialShadingChanged=e=>{}}},1)];e("MaterialViewer",class extends a{setupGlobals(){}setupDependencies(){C.setup(q),this.lookup("logger",this._context)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._viewer=new j(this._context),window.RoomleMaterialViewer||(window.RoomleMaterialViewer=this._viewer)}getApi(){return this._viewer}getContextName(){return"material-viewer"}})}}}));
2
- //# sourceMappingURL=material-viewer-4d884001.nomodule.js.map
1
+ System.register(["./script-loader-5f9a9d17.nomodule.js","./roomle-dependency-injection-60ebaf7e.nomodule.js","./scene-manager-6dd0fdd1.nomodule.js","./main-thread-to-worker-bf37ccb6.nomodule.js","./query-params-helper-c231e1b8.nomodule.js"],(function(e){var t,a,i,r,s,n,h,o,l,_,m,d,c,p,g,u,M,w,y,C,f,v,b,S,P,x,F,G,I,U,R,T,D,A,k;return{setters:[function(e){t=e.S,a=e.M},function(e){i=e._,r=e.i,s=e.l,n=e.p,h=e.q,o=e.V,l=e.ao,_=e.ap,m=e.Z,d=e.aq,c=e.Y,p=e.ar,g=e.D,u=e.L,M=e.am,w=e.as,y=e.R,C=e.b},function(e){f=e.S,v=e.B,b=e.C,S=e.F,P=e.T},function(e){x=e.at,F=e.x,G=e.C,I=e.aa,U=e.a,R=e.u,T=e.a4,D=e.aH,A=e.b3,k=e.a6},function(){}],execute:function(){class V extends f{constructor(e,t){super(e,t,s.RMV),this._sceneParams={type:"cube"},this._materialParams={color:"#ffffff",metallic:.5,alpha:0,alphaCutoff:0,doubleSided:!1},this._renderer.capabilities.maxTextures>8&&this.loadDynamicLightSetting(n.createDynamicLightSettingSource(null,h.CAMERA)),this._initScene()}_initScene(){const e=new x(1,1,1,100,100,100),t=o.createMeshPhysicalMaterial({color:this._initData.colors.PRIMARY});this._setMaterial(t),this._mesh=new F(e,this._material),this._mesh.castShadow=!0,this._mesh.position.setY(.5),this._scene.add(this._mesh);const{initialFloorMaterial:a}=this._initData;if(a?this.changeFloorMaterialById(a):this._environment=new v(this._scene,null,new G(16777215)),this._cameraControl instanceof b){const e=new I;e.setFromObject(this._mesh),this._cameraControl.updateAndReset(e.getSize(new U),e.getCenter(new U))}this.showGUI()}loadMaterialId(e){return new Promise(t=>{this._configuratorMeshGenerator.loadMaterial(e,1e3,1e3).then(e=>{this._setMaterial(e),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),t()})})}loadMaterial(e){return new Promise(t=>{e.__rapi_path__||(e.__rapi_path__="materials"),this._mesh.material=this._material,this._configuratorMeshGenerator.loadTextures(e,this._material,100,100).then(()=>{this._updateGUI(),this._requestRender()}),t()})}loadMaterialShading(e){return new Promise(t=>{let a={shading:e};this._setMaterial(l(this._material,a,this._initData.envMapIntensity)),this._mesh.material=this._material,this._updateGUI(),this._requestRender(),t()})}_setMaterial(e){this._material=e,this._materialParams.alpha=e.opacity,this._materialParams.alphaCutoff=e.alphaTest,this._materialParams.color="#"+e.color.getHexString(),this._materialParams.doubleSided=e.side===R,this._materialParams.metallic=1===e.metalness?1:e.reflectivity}getMaterialShading(){return _(this._material)}createCameraControl(e,t){this._cameraControl=new b(this._creator_,this._getInputManager(),new U(-1,1,1))}_getInputManager(){return this._inputManager}sceneChanged(){}getBounds(){return this._mesh?(new I).setFromObject(this._mesh):null}_guiLoaded(){this._updateGUI()}_updateGUI(){let e=m();e&&(this._guiGeometryFolder||(this._guiGeometryFolder=e.addFolder("Geometry"),this._guiGeometryFolder.add(this._sceneParams,"type",{Cube:"cube",Sphere:"sphere",PlaneVertical:"plane_vertical",PlaneHorizontal:"plane_horizontal"}).onChange(e=>{this._setGeometry()})),this._material&&(this._guiMaterialFolder&&e.removeFolder(this._guiMaterialFolder),this._guiMaterialFolder=e.addFolder("Material"),this._guiMaterialFolder.addColor(this._materialParams,"color").onChange(e=>{this._material.color=new G(e),this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"metallic").min(0).max(1).step(.01).onChange(e=>{this._material.metalness=1===e?1:.5,this._material.reflectivity=e||.5,this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"roughness").min(0).max(1).step(.01).onChange(e=>{this._shadingChanged()}),this._guiMaterialFolder.add(this._material,"transmission").min(0).max(1).step(.01).onChange(e=>{this._material.transmission=e,e>0&&(this._material.opacity=1,this._material.alphaTest=.5,this._material.depthWrite=!1,this._material.transparent=!0,this._material.metalness=0),this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alpha").min(0).max(1).step(.01).onChange(e=>{this._material.transparent=e<1,this._material.opacity=e,this._material.depthWrite=e>=1,this._mesh.castShadow=!this._material.transparent,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"alphaCutoff").min(0).max(1).step(.01).onChange(e=>{this._material.alphaTest=e||0,this._shadingChanged()}),this._guiMaterialFolder.add(this._materialParams,"doubleSided").onChange(e=>{this._material.side=e?R:T,this._shadingChanged()})),this._addGUIListener(e))}_shadingChanged(){this._roomleMaterialViewerUiCallback.onMaterialShadingChanged(_(this._material))}setGeometry(e){this._sceneParams.type=e,this._setGeometry()}_setGeometry(){let e;"cube"===this._sceneParams.type&&(e=new x(1,1,1,100,100,100)),"sphere"===this._sceneParams.type&&(e=new D(.5,100,100)),"plane_horizontal"===this._sceneParams.type&&(e=new A(1,1),e.rotateX(-Math.PI/2)),"plane_vertical"===this._sceneParams.type&&(e=new A(1,1)),this._mesh.geometry=e,this._renderEverything()}async changeFloorMaterialById(e){const t=await this._rapiAccess.getMaterial(e);return this._environment&&this._environment instanceof S||(this._environment=new S(this._scene,this._environment,!0)),new Promise((e,a)=>{this._environment.changeFloorMaterial(t,this._maxAnisotropy,this._initData.envMapIntensity).then(()=>{this._requestRender(),e()},a)})}async addTexture(e,t){const a=100/(0===e.mmWidth?1:e.mmWidth),i=100/(0===e.mmHeight?1:e.mmHeight);if(t){const r=new Image;r.src=t;const s=new k;s.image=r,r.onload=function(){s.needsUpdate=!0},d(s,e,this._material,this._maxAnisotropy,a,i,this._renderer.capabilities.maxTextures)}else await c(e.image,e,this._material,this._maxAnisotropy,a,i,this._renderer.capabilities.maxTextures);this._requestRender()}removeTexture(e){"ORM"===e.mapping&&(this._material.aoMap=null,this._material.roughnessMap=null,this._material.metalnessMap=null),"RGB"!==e.mapping&&"RGBA"!==e.mapping||(this._material.map=null),"XYZ"===e.mapping&&(this._material.normalMap=null),this._material.needsUpdate=!0,this._requestRender()}clearCache(){this._configuratorMeshGenerator.clear()}}i([r],V.prototype,"_inputManager",void 0),i([r],V.prototype,"_configuratorMeshGenerator",void 0),i([r],V.prototype,"_roomleMaterialViewerUiCallback",void 0),i([r],V.prototype,"_rapiAccess",void 0);class j{constructor(e){this._creator_=e}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}getCameraOffset(){return this._sceneManager.getCameraOffset()}init(e){return this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):new Promise(this._initPromiseCallback.bind(this))}_initPromiseCallback(e,t){Promise.all([this._scriptLoader.fetch(P,{id:"tween-js"})]).then(()=>{this._sceneManager=new V(this._creator_,{left:0,top:1,right:1,bottom:0}),this._sceneManager.enableHD(),e()})}get callbacks(){return this._roomleMaterialViewerUiCallback}set callbacks(e){this._roomleMaterialViewerUiCallback=e}loadMaterialShading(e){return this._sceneManager.loadMaterialShading(e)}loadMaterial(e,t={}){return t.flushCache&&this._clearCaches(),this._sceneManager.loadMaterial(e)}loadMaterialId(e,t={}){return t.flushCache&&this._clearCaches(),this._sceneManager.loadMaterialId(e)}getMaterialShading(){return this._sceneManager.getMaterialShading()}loadSceneSetting(e){return this._sceneManager.loadSceneSettings(e)}setOverrides(e){e&&this._initData.setOverrides(e)}updateSize(){this._sceneManager.updateCamera()}getMain(){}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}showGUI(){this._sceneManager.showGUI()}async changeFloorMaterialById(e){return this._sceneManager.changeFloorMaterialById(e)}setGeometry(e){this._sceneManager.setGeometry(e)}async addTexture(e,t){return this._sceneManager.addTexture(e,t)}removeTexture(e){return this._sceneManager.removeTexture(e)}_clearCaches(){this._rapiAccess.cleanUp(),this._sceneManager.clearCache()}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getUnitFormatter(){return this._unitFormatter}}i([r],j.prototype,"_domHelper",void 0),i([r],j.prototype,"_scriptLoader",void 0),i([r],j.prototype,"_lifeCycleManager",void 0),i([r],j.prototype,"_roomleMaterialViewerUiCallback",void 0),i([r],j.prototype,"_initData",void 0),i([r],j.prototype,"_rapiAccess",void 0),i([r],j.prototype,"_unitFormatter",void 0);const q=[new g("script-loader",t),new g("logger",u),new g("input-manager",M,1),new g("configurator-mesh-generator",w),new g("rapi-access",y),new g("roomle-material-viewer-ui-callback",class extends p{constructor(e){super(e),this.onMaterialShadingChanged=e=>{}}},1)];e("MaterialViewer",class extends a{setupGlobals(){}setupDependencies(){C.setup(q),this.lookup("logger",this._context)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._viewer=new j(this._context),window.RoomleMaterialViewer||(window.RoomleMaterialViewer=this._viewer)}getApi(){return this._viewer}getContextName(){return"material-viewer"}})}}}));
2
+ //# sourceMappingURL=material-viewer-b09b4294.nomodule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material-viewer-b09b4294.nomodule.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import{MaterialViewer}from"./material-viewer-8c6656a9.js";import"./script-loader-63343d0d.js";import"./query-params-helper-a271f9dc.js";import"./roomle-dependency-injection-ee1a801f.js";import"./main-thread-to-worker-64a59f5b.js";import"./scene-manager-ac75aaa1.js";(new MaterialViewer).boot();
2
+ //# sourceMappingURL=material-viewer-main-5b97645d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material-viewer-main-5b97645d.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- System.register(["./material-viewer-4d884001.nomodule.js","./script-loader-92e1532b.nomodule.js","./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-2583f0dc.nomodule.js","./main-thread-to-worker-5609c757.nomodule.js","./scene-manager-45fc4ce6.nomodule.js"],(function(){var e;return{setters:[function(n){e=n.MaterialViewer},function(){},function(){},function(){},function(){},function(){}],execute:function(){(new e).boot()}}}));
1
+ System.register(["./material-viewer-b09b4294.nomodule.js","./script-loader-5f9a9d17.nomodule.js","./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-60ebaf7e.nomodule.js","./main-thread-to-worker-bf37ccb6.nomodule.js","./scene-manager-6dd0fdd1.nomodule.js"],(function(){var e;return{setters:[function(n){e=n.MaterialViewer},function(){},function(){},function(){},function(){},function(){}],execute:function(){(new e).boot()}}}));
2
2
  //# sourceMappingURL=material-viewer-main.nomodule.js.map
@@ -1,2 +1,2 @@
1
- System.register(["./script-loader-92e1532b.nomodule.js","./roomle-dependency-injection-2583f0dc.nomodule.js","./scene-manager-45fc4ce6.nomodule.js","./main-thread-to-worker-5609c757.nomodule.js","./roomle-configurator-b01d2885.nomodule.js","./query-params-helper-c231e1b8.nomodule.js","./default-light-setting-01a91d0f.nomodule.js"],(function(e,t){var n,a,i,s,r,o,l,c,h,d,_,g,p,m,u,v,w,C,f,b,M,E,P,S,I,y,D,O,H,L,A,k,V,j,x,T,R,B,W,F,K,z,G,U,N,Z,q,X,J,Q,Y,$,ee,te,ne,ae,ie,se,re,oe,le,ce,he,de,_e,ge,pe,me,ue,ve,we,Ce,fe,be,Me;return{setters:[function(e){n=e.S,a=e.M},function(e){i=e.Z,s=e.E,r=e.W,o=e.F,l=e._,c=e.i,h=e.h,d=e.N,_=e.a8,g=e.e,p=e.a9,m=e.c,u=e.S,v=e.aa,w=e.ab,C=e.j,f=e.O,b=e.ac,M=e.ad,E=e.ae,P=e.af,S=e.k,I=e.V,y=e.ag,D=e.ah,O=e.ai,H=e.d,L=e.aj,A=e.r,k=e.ak,V=e.H,j=e.B,x=e.al,T=e.p,R=e.am,B=e.D,W=e.L,F=e.an,K=e.R,z=e.b},function(e){G=e.L,U=e.B,N=e.C,Z=e.b,q=e.c,X=e.T},function(e){J=e.a,Q=e.A,Y=e.C,$=e.D,ee=e.V,te=e.ab,ne=e.bu,ae=e.ak,ie=e.b3,se=e.f,re=e.x,oe=e.aB,le=e.aw,ce=e.aa,he=e.H,de=e.aT,_e=e.aY,ge=e.b8,pe=e.at,me=e.bK,ue=e.aH,ve=e.bL,we=e.K},function(e){Ce=e.S,fe=e.C,be=e.P,Me=e.R},function(){},function(){}],execute:function(){class Ee extends G{constructor(e,t){super(e,t),this._center=new J(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new Q(new Y(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new $(new Y(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 ee(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 J));const t=new te;e.getBoundingSphere(t);const n=t.radius,a=new J(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=i();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 Y(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 Y(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 Y(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))}}}}const Pe=e=>e instanceof r||e instanceof o;class Se{constructor(e){const{planElementViewModel:t,planElementViewModels:n,selectionMode:a,reason:i}=e;this.planElementViewModel=t,this.planElementViewModels=n,this.selectionMode=a,this.reason=i}}class Ie{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:s}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i,this.reason=s}}class ye extends Ce{constructor(e,t,n,a){super(e,t,n,a),this._isDrawingEnabled=!1,this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(0,()=>{2!==this._state?this._plannerSelectionHandler.cancelSelection("click_outside"):this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new Ie({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(2,({planElementViewModels:e})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(e)},this),this._plannerSelectionHandler.addEventListener(15,({selectionMode:e})=>{"multiselect"===e&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject)},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new Ie({planElementViewModel:e,reason:t}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new ne;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 ne;e.disableAll(),e.enable(3),e.enable(7),e.enable(6),e.enable(9),e.enable(2),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(9):this._raycastHelper.getLayers().disable(9)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(6):this._raycastHelper.getLayers().disable(6)}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.getObject(),{hasListener:!0,priority:1,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=ae(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=ae(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("double_click",t=>{var n;this._doubleClickElement(e,t.attachment.type,null===(n=t.attachment.intersection)||void 0===n?void 0:n.point)}),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)))}_createFloorMeshWithHandler(){const e=new ie(1e3,1e3,8,8),t=new se;t.visible=!1;const n=new re(e,t);return n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData=ae(n.userData,{hasListener:!0,priority:.9,roomleId:void 0}),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(h(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{this._isCurrentlyDrawing?this._clickOnPlane(h(e.attachment.intersection.point)):this._plannerSelectionHandler.cancelSelection("select_other")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=0){this._closeToPoint(e)?this.stopDrawing():this._toggleDrawing(null,e,t)}_closeToPoint(e){let t=!1;for(const n of this._planViewModel.getNodePlanObjectViewModels())this._close(n.getPlanElement().getCenter(),e)&&(t=!0);return t}_close(e,t){return Math.abs(e.x-t.x)<500&&Math.abs(e.y-t.y)<500&&Math.abs(e.z-t.z)<500}_clickElement(e){this._isCurrentlyDrawing||(this._debug&&e.getId(),2!==this._state?(this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof d||e instanceof r))return;let a;this._debug&&e.getId(),e instanceof r&&this._plannerSelectionHandler.cancelSelection("double_click_wall"),e instanceof d?a=e.getPlanElement().getCenter():n&&(a=h(new J(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){this._isCurrentlyDrawing||("multiselect"===this._plannerSelectionHandler.getSelectionMode()?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){Pe(this._hoveredObject)||Pe(e)?(this._hoveredObject=null,oe("default")):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new Ie({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),this.dispatchEvent(4,new Ie({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?oe("ew-resize"):1===this._state?oe("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?oe("move"):this._hoveredObject?oe("pointer"):3===this._state?oe(_?"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"):oe("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(e){this._plannerSelectionHandler.cancelSelection(e)}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this.dispatchEvent(8),le(v.DRAG).then(()=>{if(this._inputManager.isMouseUp())return this.setState(0),oe("pointer"),void this.dispatchEvent(12);this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(),this.dispatchEvent(9,new Ie({planElementViewModel:e}))}))}_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).getPlanElement())),n.moveObjectsBy(e,h(a))}else(e instanceof d||e instanceof r||this._planViewModel.cameraType===g.CAMERA_2D)&&(this._plannerSelectionHandler.check(e),t.y=p(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),h(t));this.dispatchEvent(10,new Ie({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(11,new Ie({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._roomlePlannerUiCallback.onDragElementEnd(),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){var t,n;const a=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new Ie({state:this._state,oldState:a})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===a&&(null===(n=this.planInteractionHandler)||void 0===n||n.reactivateAllSnappingActivity())}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 J(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new ce;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.getPlanElement()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new J);this.planInteractionHandler.rotateObjectsBy(i,t,h(r)),this._position.copy(new J(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof m||e instanceof u)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new Ie({}))}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.snapObjectsToWalls=!0}disableSnapping(){this.planInteractionHandler.snapObjectsToWalls=!1}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new he,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(13,this._endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){var t;e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(9),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),null===(t=this._continousDrawingHelper)||void 0===t||t.endDrawing()}startDrawing(){var e;this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(9),this.dispatchEvent(6),this._setStateAndCursor(3),null===(e=this._continousDrawingHelper)||void 0===e||e.update())}_toggleDrawing(e,t,n){this._isCurrentlyDrawing?this._endWallDrawing(e,t):this._startWallDrawing(e,t,n)}_endWallDrawing(e,t){if(this._isCurrentlyDrawing){if(this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle()&&this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle())this.planInteractionHandler.cancelDrawing();else{const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:a,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continousDrawingHelper.update());const{x:a,y:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.beginDrawing({x:a,y:i,z:0}),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continousDrawingHelper){const{default:e}=await t.import("./continuous-drawing-helper-7a08e3cf.nomodule.js");this._continousDrawingHelper=new e,this._continousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:a,z:0}),null===(t=this._continousDrawingHelper)||void 0===t||t.update(),this.dispatchEvent(5)}_createNode(e,t){if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:a,z:0}),this._raycastHelper.clear()}_getIntersectionPointWithScene(e){return this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}setKernelZoomFactor(e){var t;this._kernelZoomFactor=e,null===(t=this._continousDrawingHelper)||void 0===t||t.setKernelZoomFactor(e)}}l([c],ye.prototype,"_plannerSelectionHandler",void 0),l([c],ye.prototype,"_plannerKernelAccess",void 0),l([c],ye.prototype,"_roomlePlannerUiCallback",void 0);const De=(e,t,n,a)=>{const i=(new ce).setFromObject(e.getContainer()).getCenter(new J);return{runtimeId:e.getId(),position2d:w(C(i,t,n,a))}};class Oe extends re{constructor(){const e=Oe.SkyShader,t=new de({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:_e.clone(e.uniforms),side:ge,depthWrite:!1});super(new pe(1,1,1),t),this.isSky=!0}}Oe.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new J},up:{value:new J(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const He=async(e,t,n)=>{let a=[];const i=[],s=[];await Promise.all(e.map(async e=>{const n=f(e);if(n.catalogItemId?i.push(n.catalogItemId):n.configurationHash&&s.push(n.configurationHash),n.parts){const e=n.configurationHash||n.catalogItemId,a=await t.addUiDataAndPriceToPartList(n.parts,e);n.parts=a}n.data=null,a.push(n)}));const[r,o]=await Promise.all([n.getItems(i),n.getConfigurations(s)]),l=[],c=new Map;for(const e of r)c.set(e.id,e);for(const e of o)c.set(e.id,e),l.push(e.rootComponentId);const h=await n.getComponents(l),d=new Map;for(const e of h)d.set(e.id,e);for(const e of a){const t=e.catalogItemId||e.configurationHash,n=c.get(t)||null;if(n&&!n.label&&d.has(n.rootComponentId)){const e=d.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return a};class Le extends fe{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new b,this._configurableItemGuard=new b,this._planCompletelyLoadedGuard=new b,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 ye(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._roomleRenderer.switchToPlanner(M.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(13,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof u&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,()=>{this._cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),e instanceof r&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(11,async({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),h(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything();const a=this.getPlanObject(e.getId());let i;a&&(i=await He([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.CHANGED,i?i[0]:null)},this),this._plannerSceneEventHandler.addEventListener(12,()=>{this._cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(6,()=>{this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(5,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(7,()=>this._renderWithoutShadowsAndAO(),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()}planCleared(){}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new be(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new J),a=e.distanceTo(n),i=t.getSize(new J),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new J).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){const t={};if(e instanceof u&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof m&&(t.configurationRuntimeId=e.getConfigurationRuntimeId()),e instanceof r){const n=this._cameraControl.getKernelZoomFactor();t.wall=e.getWallDimension(n)}e instanceof o&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=(e=>{if(e instanceof u){const t=e.getPlanObject().getObjectType();return"door"!==t&&"window"!==t?"static":t}return e instanceof m?"configuration":e instanceof r?"wall":e instanceof o?"floor":"unknown"})(e);const a=(async()=>{const t={};if(e instanceof u&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof m){await e.isInitDone();const a=e.getConfigurationRuntimeId(),i=e.getPlanObject().getCatalogItemId();let s,r=i;if(r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a)),this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),i&&V(i)){const e=await this._rapiAccess.getItem(i);t.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);t.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const n=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(n);t.configuration=i,s=i.rootComponentId?i.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);t.component=e}t.configurationRuntimeId=a,n="configuration"}return t.planElementId=e.getId(),me(t)})();this.currentSelection=me(t),this._roomlePlannerUiCallback.onSelectionChange(me(this._plannerSceneEventHandler.getSelectionMode()),me(n),me(t),a,e),(e instanceof r||e instanceof d)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()),this._renderWithoutShadowsAndAO(),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._initData.legacyLight&&(this._lightSetting=new Ee(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),this._setEnvironment(new U(this._scene,this._environment,new Y(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){this._cameraControl instanceof N&&P(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&this._roomleRenderer.forceShadowUpdates(!0)}_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 N&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.disablePlannerEvents(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const{planElementId:t}=this._configuratorContext,n=this._getViewModel().getPlanObjectForId(t);n&&(this.setRootComponentId(n.getRootComponentRuntimeId()),this._cameraControl instanceof N&&this._cameraControl.setObjectRotation(n.getPlanElement().rotation));const a=null==n?void 0:n.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==a&&(this._configuratorContext.planObjectId=a),this._getViewModel().hideAllExcept(t),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this._roomleRenderer.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(a),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(a),this.updateEnvironment(this.getBounds(),!0);const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.startInteraction()}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t),this._onSelectionChange(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 N&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this._roomleRenderer.switchToPlanner(this._cameraControl instanceof N?M.Mode3D:M.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new J).clone();t.y=0,t.lengthSq()<.01&&(t=new J(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=S(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera(),setTimeout(()=>this._planCompletelyLoadedGuard.resolve(),0),this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide())}handlerSwitchedPlans(e,t){if(this._roomlePlannerUiCallback.onHandlerSwitchedPlans(),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 ie(1e3,1e3);e.rotateX(-Math.PI/2);let t=I.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),n=new re(e,t);n.name="Ground",n.position.y=-.01,n.userData.isFloor=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),this._planCompletelyLoadedGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait(),this._planCompletelyLoadedGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){var e;const t=this._getViewModel().getCorePlan();if(this._roomleRenderer){const n=S(t.getBounds());null===(e=this._roomleRenderer)||void 0===e||e.updateBounds(n)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this.updateEnvironment(this.getBounds(),!0),this._renderEverything()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{var e;this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),(null===(e=this._lightSetting)||void 0===e?void 0:e.needsBounds())&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}async addPlanObjectToScene(e){if(e){const t=e.getContainer();y(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),await e.isInitDone(),this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything();const n=this.getPlanObject(e.getId());let a;n&&(a=await He([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.ADDED,a?a[0]:null)}}removePlanObjectFromScene(e){(e instanceof r||e instanceof d)&&this._sendWallDimensions(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!0),this._renderEverything()}async planElementChanged(e,t){if(this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),!this._plannerSceneEventHandler.isDragIn()){const e=this.getPlanObject(t.getId());let n;e&&(n=await He([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.CHANGED,n?n[0]:null)}}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){if(!this._sky){this._sky=new Oe,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=D(4e5,0,.6);this._sky.material.uniforms.sunPosition.value.copy(e);let t=new re(new ue(2e4,16,8),new se({color:16777215}));t.name="Sunsphere",t.position.y=-7e5,t.visible=!1,t.position.set(e.x,-e.z,e.y)}this._lightSetting instanceof Ee&&this._lightSetting.updateSunPosition(.6,0)}switchTo2D(){var e;if(this._onCameraMove(),!(this._cameraControl instanceof Z)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(g.CAMERA_2D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(M.Mode2D),this._renderEverything(),this._changeCameraControl(new Z(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(g.CAMERA_2D),this._setCameraControlListeners(),this._setKernelZoomFactor(),this._onCameraMove()}}switchTo3D(){var e;this._onCameraMove(),this._cameraControl instanceof N||(this._getViewModel().setCameraType(g.CAMERA_3D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(M.Mode3D),this._renderEverything(),this._changeCameraControl(new N(this._creator_,this._getInputManager(),new J(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(g.CAMERA_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(){this._setKernelZoomFactor()}_setKernelZoomFactor(){var e,t;const n=this._cameraControl.getKernelZoomFactor();null===(e=this._getKernelAccess().planInteractionHandler)||void 0===e||e.setZoomFactor(n),null===(t=this._plannerSceneEventHandler)||void 0===t||t.setKernelZoomFactor(n)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof q?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 N&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof q)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>O(e.material,!1,!1)),this._getViewModel().setCameraType(g.CAMERA_FP),this._renderEverything();let e=new J(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new J)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new q(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(g.CAMERA_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 N&&(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 N&&(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 g.CAMERA_2D:this.switchTo2D();break;case g.CAMERA_3D:this.switchTo3D();break;case g.CAMERA_FP:this.switchToFirstPerson()}}_highlightPlanElement(e){var t;let n=new Set;e instanceof H&&this._cameraControl instanceof Z&&e&&e.getTopViewContainer()?n.add(e.getTopViewContainer()):e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>n.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t instanceof H&&this._cameraControl instanceof Z&&t&&t.getTopViewContainer()?n.add(t.getTopViewContainer()):t&&t.getObject()&&t.getObject().children&&t.getObject().children.forEach(e=>n.add(e))}),null===(t=this._roomleRenderer)||void 0===t||t.highlightObjects(Array.from(n))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}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){e||(e=this.getBounds()),e&&(this._cameraControl instanceof N&&this._cameraControl.updateToBounds(e,!1),this._cameraControl instanceof Z&&this._cameraControl.zoomToFitBounds(L(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight,1.1),!0),this._renderEverything())}_zoomToBounds(e,t=!0){const n=this.getBounds();this._cameraControl instanceof N&&(this._getViewModel().getPlanObjectCount()<=1?this._cameraControl.zoomToFitBounds(n,t):this._cameraControl.checkBoundsAndPlaceCamera(n,t)),this._cameraControl instanceof Z&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(n,e,t)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof Z&&this._cameraControl.zoomToFitBounds(e,!1,!0),this._cameraControl instanceof N&&this._cameraControl.zoomToFitBounds(e,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}getPlanObject(e){const t=this._getKernelAccess().planInteractionHandler,n=this._plannerKernelAccess.planModelViewHelper,a=t.getPlan();return n.getPlanObject(a,e)}cancelPlanElementSelection(e){this._plannerSceneEventHandler.cancelSelection(e),this._highlightPlanElement(null),this._requestRender()}async deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection("delete_object"),await this.deletePlanElementByIds(e)}async deletePlanElementByIds(e){for(const t of e){const e=this._getViewModel().getPlanObjectForId(t);if(e&&e.getObject()){const t=this.getPlanObject(e.getId());let n;t&&(n=await He([t],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.REMOVED,n?n[0]:null),this._getKernelAccess().planInteractionHandler.removeElement(e.getKernelObject())}}}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new ce;let a={x:0,y:0,z:0};if(this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(a=i.getPlanElement().getCenter(),t.push_back(i.getPlanElement()),n.expandByObject(i.getContainer()))}),t.size()>1){const e=n.getCenter(new J);a=h(e)}const i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,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()=>{var n,a;let i=this._calculateBoundingBoxOfAllMeshes(.1);null===(n=this._lightSetting)||void 0===n||n.removeFromScene(),this._cameraControl instanceof N&&this._getViewModel().setCameraType(g.CAMERA_2D);let s=await this._imageRenderer.prepareTopImage(this._scene,null,i,e);this._cameraControl instanceof N&&this._getViewModel().setCameraType(g.CAMERA_3D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(s)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a;let i;this._cameraControl instanceof N?i=this._cameraControl.getCamera().clone():(i=this.getPerspectiveOffsetCamera(),this._getViewModel().setCameraType(g.CAMERA_3D)),i.resetOffset();let s=this._calculateBoundingBoxOfAllMeshes();null===(n=this._lightSetting)||void 0===n||n.removeFromScene();const r=await this._imageRenderer.preparePerspectiveImage(this._scene,null,i,s,e);this._cameraControl instanceof Z&&this._getViewModel().setCameraType(g.CAMERA_2D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(r)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return A.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(),this._roomlePlannerUiCallback.onCameraIdle()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),!0}_updateNodeSize(){if(this._cameraControl instanceof Z){const e=1/this._cameraControl.getCamera().zoom;this._getViewModel().setNodeZoom(e)}}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=this._cameraControl.getCamera(),a=[],i={staticPlanObjectViewModels:this._getViewModel().getStaticPlanObjectViewModels(),configurablePlanObjectViewModels:this._getViewModel().getConfigurablePlanObjectViewModels(),constructionPlanObjectViewModels:this._getViewModel().getConstructionPlanObjectViewModels(),wallPlanObjectViewModels:this._getViewModel().getWallPlanObjectViewModels(),floorPlanObjectViewModels:this._getViewModel().getFloorPlanObjectViewModels(),nodePlanObjectViewModels:this._getViewModel().getNodePlanObjectViewModels()};for(const s of Object.values(i))for(const i of s)a.push(De(i,n,e,t));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(a)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:a}=this._domHelper.element,i=this._getViewModel().getWallPlanObjectViewModels(),s=this._cameraControl.getKernelZoomFactor();for(const e of i){const i=e.getWallDimension(s);if(i.length>0){const e=this._cameraControl.getCamera();i.fromPosition2d=C(i.fromPosition3d,e,n,a),i.toPosition2d=C(i.toPosition3d,e,n,a),i.fromWithoutPadding=C(i.fromWithoutPadding,e,n,a),i.toWithoutPadding=C(i.toWithoutPadding,e,n,a),i.textPosition2d=C(i.textPosition3d,e,n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(k(i))}if(this._initData.debug){const e=new ue(.1,32,16),t=new se({color:16711680}),n=new re(e,t);n.position.copy(i.fromPosition3d);const a=new re(e,t);a.position.copy(i.toPosition3d);const s=new re(e,new se({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}this._roomlePlannerUiCallback.onUpdateWallDimensions(t)}enableWallDrawing(){if(this._cameraControl instanceof Z){const e=L(this.getBounds(),this._domHelper.element.clientWidth,this._domHelper.element.clientHeight);this._cameraControl.zoomToFitBounds(e,!0)}this._drawingEnabled||(this._drawingEnabled=!0,this._scene.add(this._plannerSceneEventHandler.enableWallDrawing()))}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._scene.remove(this._plannerSceneEventHandler.cancelWallDrawing())}escapeDrawing(){this._plannerSceneEventHandler.stopDrawing()}_changeCameraControl(e){super._changeCameraControl(e)}setSceneEvents(e){var t,n;void 0!==e.construction&&(null===(t=this._plannerSceneEventHandler)||void 0===t||t.enableConstructionEvents(e.construction)),void 0!==e.objects&&(null===(n=this._plannerSceneEventHandler)||void 0===n||n.enableObjectEvents(e.objects))}startedDrawing(){this._plannerSceneEventHandler.startDrawing()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),"planner"===this._configuratorContext.baseContext&&this.enablePlannerEvents()}resetCameraPositionToStart(e=!0){this._cameraControl instanceof N&&super.resetCameraPositionToStart(e),this._cameraControl instanceof Z&&this._updateCamera()}async moveCamera(e){return this._cameraControl instanceof N?super.moveCamera(e):Promise.reject("Camera can only be moved in 3D")}_setInteriorOrExteriorWallMaterial(e,t){const n=this._getViewModel().getWallPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=e=>{a.setWallLeftMaterial(e,ve(e.leftMaterial,t))},s=e=>{a.setWallRightMaterial(e,ve(e.rightMaterial,t))},r=n.map(e=>e.getKernelObject()),o=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,l=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,c=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const t of r)t.wallType===o&&"interior"===e&&(i(t),s(t)),t.wallType===l&&("interior"===e?s(t):i(t)),t.wallType===c&&("exterior"===e?s(t):i(t))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("interior",e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("exterior",e)}changeFloorsMaterial(e){const t=this._getViewModel().getFloorPlanObjectViewModels();if(!t.length)return;const n=this._getKernelAccess().planInteractionHandler,a=t.map(e=>e.getKernelObject());for(const t of a)n.setFloorMaterial(t,ve(t.material,e))}getWallAngleDegrees(e){if(!(e instanceof r))return 0;const t=this._cameraControl.getCamera(),n=new ee(t.position.x,t.position.z),a=new ee(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),i=e.getKernelObject(),s=new ee(Math.sin(i.getAngle()),Math.cos(i.getAngle())),o=a.angle()-s.angle();return we.radToDeg(o)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0),n.moveElementTo(e.getPlanElement(),t),this._sendPlanObjectPositions()}}l([c],Le.prototype,"_rapiAccess",void 0),l([c],Le.prototype,"_plannerMeshGenerator",void 0),l([c],Le.prototype,"_plannerInputManager",void 0),l([c],Le.prototype,"_roomlePlannerUiCallback",void 0),l([c],Le.prototype,"_localStorageHelper",void 0),l([c],Le.prototype,"_unitFormatter",void 0);const Ae={left:0,top:1,right:1,bottom:0};class ke{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(e="unknown"){this._sceneManager.cancelPlanElementSelection(e)}init(e,t,n){return j.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)=>{const a=x(e);(a?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(n=>{const i=a?n.plan:n.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(i),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t(n)},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}resetCameraPosition(){this._sceneManager.resetCameraPositionToStart()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){Promise.all([this._scriptLoader.fetch(X,{id:"tween-js"})]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new Le(this._creator_,Ae,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=T.createDynamicLightSettingSource(t,n);i&&this.showStats(),this._sceneManager.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){j.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new Me(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)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-a9c1fe12.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-c1c1106b.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=h(new J(t.x,t.y,t.z)));const a=await(V(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=>V(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return await this._plannerKernelAccess.insertItems(n)}async insertItems(e){return await this._plannerKernelAccess.insertItems(e)}duplicateItems(e){return this._plannerKernelAccess.duplicateItems(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),t=f(e.objects);return He(t,this._plannerKernelAccess,this._rapiAccess)}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()}enableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode("multiselect"),this._configuratorContext.selectionMode="multiselect"}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),a=await this.insertItems([n]);if(1!==a.length)throw new Error("More than one object added, abort");return a[0]}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(),this._sceneManager.updateScene(),s}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const t of e){const e=this._sceneManager.getPlanObject(t.getId());let n;e&&(n=await He([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.REMOVED,n?n[0]:null),this._planInteractionHandler.removeElement(t)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}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}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}async saveCurrentPlanSnapshot(e){const t=await this.getPlanModelViewHelper(),n=this._planInteractionHandler.getPlan(),a=t.getPlanOverview(n),i={parentId:e||null,planObjects:[],combinedIds:[],plan:n.getPlanXML(!1,2)},s=a.objects,r=s.size();for(let e=0;e<r;e++){const t=s.get(e),n=t.configurationHash||t.catalogItemId,{center:a,dimensions:r,rotation:o}=t,l=JSON.stringify({center:a,dimensions:r,rotation:o});i.planObjects.push({combinedId:n,location:l})}const o=await this._rapiAccess.savePlanSnapshot(i),l=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotPerspectiveImage(o,n.value),i=await this._rapiAccess.savePlanSnapshotTopImage(o,a.value);e({...t,...i})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await l}catch(e){return console.error(e),o}}getPlanXmlFrom(e){return e?x(e.id)?e.plan:e.planObjects:null}async moveCamera(e){return this._sceneManager.moveCamera(e)}async createNewSerializedConfiguration(e){return Promise.resolve(this._plannerKernelAccess.createNewSerializedConfiguration(e))}changeInteriorWallsMaterial(e){this._sceneManager.changeInteriorWallsMaterial(e)}changeExteriorWallsMaterial(e){this._sceneManager.changeExteriorWallsMaterial(e)}changeFloorsMaterial(e){this._sceneManager.changeFloorsMaterial(e)}getWallAngleDegrees(e){return this._sceneManager.getWallAngleDegrees(e)}calcPartsPriceSum(e){return this._plannerKernelAccess.calcPartsPriceSum(e)}async swapObject(e,t){const n=e.getPosition(),a=e.getRotation();return await this._sceneManager.deletePlanElementByIds([e.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,n,a)}exportImageFromCamera(e="image"){this._sceneManager.exportImageFromCamera(e)}moveElementPosition(e,t){this._sceneManager.moveElementPosition(e,t)}async generateProductionServiceExport(e,t=""){try{return Promise.resolve(JSON.parse(this._plannerKernelAccess.kernelInstance.generateProductionServiceExport(e,t)))}catch(e){return console.error(e),Promise.reject("Could not create Blue Ocean MVP JSON")}}}l([c],ke.prototype,"_configuratorContext",void 0),l([c],ke.prototype,"_domHelper",void 0),l([c],ke.prototype,"_scriptLoader",void 0),l([c],ke.prototype,"_kernelAccessCallback",void 0),l([c],ke.prototype,"_plannerKernelAccess",void 0),l([c],ke.prototype,"_rapiAccess",void 0),l([c],ke.prototype,"_singlePromiseFactory",void 0),l([c],ke.prototype,"_roomlePlannerUiCallback",void 0),l([c],ke.prototype,"_lifeCycleManager",void 0),l([c],ke.prototype,"_dataSyncer",void 0),l([c],ke.prototype,"_initData",void 0),l([c],ke.prototype,"_globalInitData",void 0),l([c],ke.prototype,"_unitFormatter",void 0);const Ve=[new B("script-loader",n),new B("planner-input-manager",class extends R{_canDrag(e){return!0}},1),new B("logger",W),new B("planner-mesh-generator",F),new B("rapi-access",K),new B("planner-selection-handler",class extends s{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(e){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new Se({planElementViewModel:t,reason:e}))})}_checkStandard(e){this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new Se({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new Se({planElementViewModel:e})))}_checkMulti(e){if(!Pe(e)&&!this._selectedPlanElementViewModels.has(e.getId())){this._selectedPlanElementViewModels.set(e.getId(),e),e.select();const t=Array.from(this._selectedPlanElementViewModels).map(([e,t])=>t);this.dispatchEvent(2,new Se({planElementViewModels:t})),this.dispatchEvent(0,new Se({planElementViewModel:e}))}}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{Pe(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new Se({planElementViewModel:e})))})}setSelectionMode(e){"multiselect"===e&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(15,new Se({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 a{setupGlobals(){}setupDependencies(){z.setup(Ve),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 ke(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
- //# sourceMappingURL=planner-7ec2696d.nomodule.js.map
1
+ System.register(["./script-loader-5f9a9d17.nomodule.js","./roomle-dependency-injection-60ebaf7e.nomodule.js","./scene-manager-6dd0fdd1.nomodule.js","./main-thread-to-worker-bf37ccb6.nomodule.js","./roomle-configurator-d3491afb.nomodule.js","./query-params-helper-c231e1b8.nomodule.js","./default-light-setting-e2995f02.nomodule.js"],(function(e,t){var n,a,i,s,r,o,l,c,h,d,_,g,p,m,u,v,w,C,f,b,M,E,P,S,I,y,D,O,H,L,A,k,V,j,x,T,R,B,W,F,K,z,G,U,N,Z,q,X,J,Q,Y,$,ee,te,ne,ae,ie,se,re,oe,le,ce,he,de,_e,ge,pe,me,ue,ve,we,Ce,fe,be,Me;return{setters:[function(e){n=e.S,a=e.M},function(e){i=e.Z,s=e.E,r=e.W,o=e.F,l=e._,c=e.i,h=e.h,d=e.N,_=e.a8,g=e.e,p=e.a9,m=e.c,u=e.S,v=e.aa,w=e.ab,C=e.j,f=e.O,b=e.ac,M=e.ad,E=e.ae,P=e.af,S=e.k,I=e.V,y=e.ag,D=e.ah,O=e.ai,H=e.d,L=e.aj,A=e.r,k=e.ak,V=e.H,j=e.B,x=e.al,T=e.p,R=e.am,B=e.D,W=e.L,F=e.an,K=e.R,z=e.b},function(e){G=e.L,U=e.B,N=e.C,Z=e.b,q=e.c,X=e.T},function(e){J=e.a,Q=e.A,Y=e.C,$=e.D,ee=e.V,te=e.ab,ne=e.bt,ae=e.ak,ie=e.b3,se=e.f,re=e.x,oe=e.aB,le=e.aw,ce=e.aa,he=e.H,de=e.aT,_e=e.aY,ge=e.b8,pe=e.at,me=e.bJ,ue=e.aH,ve=e.bK,we=e.K},function(e){Ce=e.S,fe=e.C,be=e.P,Me=e.R},function(){},function(){}],execute:function(){class Ee extends G{constructor(e,t){super(e,t),this._center=new J(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new Q(new Y(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new $(new Y(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 ee(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 J));const t=new te;e.getBoundingSphere(t);const n=t.radius,a=new J(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=i();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 Y(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 Y(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 Y(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))}}}}const Pe=e=>e instanceof r||e instanceof o;class Se{constructor(e){const{planElementViewModel:t,planElementViewModels:n,selectionMode:a,reason:i}=e;this.planElementViewModel=t,this.planElementViewModels=n,this.selectionMode=a,this.reason=i}}class Ie{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:s}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i,this.reason=s}}class ye extends Ce{constructor(e,t,n,a){super(e,t,n,a),this._isDrawingEnabled=!1,this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(0,()=>{2!==this._state?this._plannerSelectionHandler.cancelSelection("click_outside"):this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new Ie({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(2,({planElementViewModels:e})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(e)},this),this._plannerSelectionHandler.addEventListener(15,({selectionMode:e})=>{"multiselect"===e&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject)},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new Ie({planElementViewModel:e,reason:t}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new ne;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 ne;e.disableAll(),e.enable(3),e.enable(7),e.enable(6),e.enable(9),e.enable(2),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(9):this._raycastHelper.getLayers().disable(9)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(6):this._raycastHelper.getLayers().disable(6)}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.getObject(),{hasListener:!0,priority:1,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=ae(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=ae(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("double_click",t=>{var n;this._doubleClickElement(e,t.attachment.type,null===(n=t.attachment.intersection)||void 0===n?void 0:n.point)}),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)))}_createFloorMeshWithHandler(){const e=new ie(1e3,1e3,8,8),t=new se;t.visible=!1;const n=new re(e,t);return n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData=ae(n.userData,{hasListener:!0,priority:.9,roomleId:void 0}),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(h(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{this._isCurrentlyDrawing?this._clickOnPlane(h(e.attachment.intersection.point)):this._plannerSelectionHandler.cancelSelection("select_other")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=0){this._closeToPoint(e)?this.stopDrawing():this._toggleDrawing(null,e,t)}_closeToPoint(e){let t=!1;for(const n of this._planViewModel.getNodePlanObjectViewModels())this._close(n.getPlanElement().getCenter(),e)&&(t=!0);return t}_close(e,t){return Math.abs(e.x-t.x)<500&&Math.abs(e.y-t.y)<500&&Math.abs(e.z-t.z)<500}_clickElement(e){this._isCurrentlyDrawing||(this._debug&&e.getId(),2!==this._state?(this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof d||e instanceof r))return;let a;this._debug&&e.getId(),e instanceof r&&this._plannerSelectionHandler.cancelSelection("double_click_wall"),e instanceof d?a=e.getPlanElement().getCenter():n&&(a=h(new J(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){this._isCurrentlyDrawing||("multiselect"===this._plannerSelectionHandler.getSelectionMode()?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){Pe(this._hoveredObject)||Pe(e)?(this._hoveredObject=null,oe("default")):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new Ie({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),this.dispatchEvent(4,new Ie({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?oe("ew-resize"):1===this._state?oe("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?oe("move"):this._hoveredObject?oe("pointer"):3===this._state?oe(_?"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"):oe("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(e){this._plannerSelectionHandler.cancelSelection(e)}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this.dispatchEvent(8),le(v.DRAG).then(()=>{if(this._inputManager.isMouseUp())return this.setState(0),oe("pointer"),void this.dispatchEvent(12);this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(),this.dispatchEvent(9,new Ie({planElementViewModel:e}))}))}_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).getPlanElement())),n.moveObjectsBy(e,h(a))}else(e instanceof d||e instanceof r||this._planViewModel.cameraType===g.CAMERA_2D)&&(this._plannerSelectionHandler.check(e),t.y=p(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),h(t));this.dispatchEvent(10,new Ie({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(11,new Ie({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._roomlePlannerUiCallback.onDragElementEnd(),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){var t,n;const a=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new Ie({state:this._state,oldState:a})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===a&&(null===(n=this.planInteractionHandler)||void 0===n||n.reactivateAllSnappingActivity())}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 J(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new ce;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.getPlanElement()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new J);this.planInteractionHandler.rotateObjectsBy(i,t,h(r)),this._position.copy(new J(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof m||e instanceof u)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new Ie({}))}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.snapObjectsToWalls=!0}disableSnapping(){this.planInteractionHandler.snapObjectsToWalls=!1}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new he,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(13,this._endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){var t;e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(9),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),null===(t=this._continousDrawingHelper)||void 0===t||t.endDrawing()}startDrawing(){var e;this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(9),this.dispatchEvent(6),this._setStateAndCursor(3),null===(e=this._continousDrawingHelper)||void 0===e||e.update())}_toggleDrawing(e,t,n){this._isCurrentlyDrawing?this._endWallDrawing(e,t):this._startWallDrawing(e,t,n)}_endWallDrawing(e,t){if(this._isCurrentlyDrawing){if(this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle()&&this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle())this.planInteractionHandler.cancelDrawing();else{const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:a,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continousDrawingHelper.update());const{x:a,y:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.beginDrawing({x:a,y:i,z:0}),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continousDrawingHelper){const{default:e}=await t.import("./continuous-drawing-helper-25cbd8cf.nomodule.js");this._continousDrawingHelper=new e,this._continousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:a,z:0}),null===(t=this._continousDrawingHelper)||void 0===t||t.update(),this.dispatchEvent(5)}_createNode(e,t){if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:a,z:0}),this._raycastHelper.clear()}_getIntersectionPointWithScene(e){return this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}setKernelZoomFactor(e){var t;this._kernelZoomFactor=e,null===(t=this._continousDrawingHelper)||void 0===t||t.setKernelZoomFactor(e)}}l([c],ye.prototype,"_plannerSelectionHandler",void 0),l([c],ye.prototype,"_plannerKernelAccess",void 0),l([c],ye.prototype,"_roomlePlannerUiCallback",void 0);const De=(e,t,n,a)=>{const i=(new ce).setFromObject(e.getContainer()).getCenter(new J);return{runtimeId:e.getId(),position2d:w(C(i,t,n,a))}};class Oe extends re{constructor(){const e=Oe.SkyShader,t=new de({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:_e.clone(e.uniforms),side:ge,depthWrite:!1});super(new pe(1,1,1),t),this.isSky=!0}}Oe.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new J},up:{value:new J(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const He=async(e,t,n)=>{let a=[];const i=[],s=[];await Promise.all(e.map(async e=>{const n=f(e);if(n.catalogItemId?i.push(n.catalogItemId):n.configurationHash&&s.push(n.configurationHash),n.parts){const e=n.configurationHash||n.catalogItemId,a=await t.addUiDataAndPriceToPartList(n.parts,e);n.parts=a}n.data=null,a.push(n)}));const[r,o]=await Promise.all([n.getItems(i),n.getConfigurations(s)]),l=[],c=new Map;for(const e of r)c.set(e.id,e);for(const e of o)c.set(e.id,e),l.push(e.rootComponentId);const h=await n.getComponents(l),d=new Map;for(const e of h)d.set(e.id,e);for(const e of a){const t=e.catalogItemId||e.configurationHash,n=c.get(t)||null;if(n&&!n.label&&d.has(n.rootComponentId)){const e=d.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return a};class Le extends fe{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new b,this._configurableItemGuard=new b,this._planCompletelyLoadedGuard=new b,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 ye(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._roomleRenderer.switchToPlanner(M.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(13,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof u&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,()=>{this._cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),e instanceof r&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(11,async({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),h(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything();const a=this.getPlanObject(e.getId());let i;a&&(i=await He([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.CHANGED,i?i[0]:null)},this),this._plannerSceneEventHandler.addEventListener(12,()=>{this._cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(6,()=>{this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(5,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(7,()=>this._renderWithoutShadowsAndAO(),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()}planCleared(){}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new be(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new J),a=e.distanceTo(n),i=t.getSize(new J),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new J).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){const t={};if(e instanceof u&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof m&&(t.configurationRuntimeId=e.getConfigurationRuntimeId()),e instanceof r){const n=this._cameraControl.getKernelZoomFactor();t.wall=e.getWallDimension(n)}e instanceof o&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=(e=>{if(e instanceof u){const t=e.getPlanObject().getObjectType();return"door"!==t&&"window"!==t?"static":t}return e instanceof m?"configuration":e instanceof r?"wall":e instanceof o?"floor":"unknown"})(e);const a=(async()=>{const t={};if(e instanceof u&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof m){await e.isInitDone();const a=e.getConfigurationRuntimeId(),i=e.getPlanObject().getCatalogItemId();let s,r=i;if(r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a)),this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),i&&V(i)){const e=await this._rapiAccess.getItem(i);t.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);t.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const n=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(n);t.configuration=i,s=i.rootComponentId?i.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);t.component=e}t.configurationRuntimeId=a,n="configuration"}return t.planElementId=e.getId(),me(t)})();this.currentSelection=me(t),this._roomlePlannerUiCallback.onSelectionChange(me(this._plannerSceneEventHandler.getSelectionMode()),me(n),me(t),a,e),(e instanceof r||e instanceof d)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()),this._renderWithoutShadowsAndAO(),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._initData.legacyLight&&(this._lightSetting=new Ee(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),this._setEnvironment(new U(this._scene,this._environment,new Y(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){this._cameraControl instanceof N&&P(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&this._roomleRenderer.forceShadowUpdates(!0)}_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 N&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.disablePlannerEvents(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const{planElementId:t}=this._configuratorContext,n=this._getViewModel().getPlanObjectForId(t);n&&(this.setRootComponentId(n.getRootComponentRuntimeId()),this._cameraControl instanceof N&&this._cameraControl.setObjectRotation(n.getPlanElement().rotation));const a=null==n?void 0:n.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==a&&(this._configuratorContext.planObjectId=a),this._getViewModel().hideAllExcept(t),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this._roomleRenderer.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(a),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(a),this.updateEnvironment(this.getBounds(),!0);const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.startInteraction()}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t),this._onSelectionChange(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 N&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this._roomleRenderer.switchToPlanner(this._cameraControl instanceof N?M.Mode3D:M.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new J).clone();t.y=0,t.lengthSq()<.01&&(t=new J(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=S(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera(),setTimeout(()=>this._planCompletelyLoadedGuard.resolve(),0),this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide())}handlerSwitchedPlans(e,t){if(this._roomlePlannerUiCallback.onHandlerSwitchedPlans(),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 ie(1e3,1e3);e.rotateX(-Math.PI/2);let t=I.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),n=new re(e,t);n.name="Ground",n.position.y=-.01,n.userData.isFloor=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),this._planCompletelyLoadedGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait(),this._planCompletelyLoadedGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){var e;const t=this._getViewModel().getCorePlan();if(this._roomleRenderer){const n=S(t.getBounds());null===(e=this._roomleRenderer)||void 0===e||e.updateBounds(n)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this.updateEnvironment(this.getBounds(),!0),this._renderEverything()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{var e;this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),(null===(e=this._lightSetting)||void 0===e?void 0:e.needsBounds())&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}async addPlanObjectToScene(e){if(e){const t=e.getContainer();y(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),await e.isInitDone(),this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything();const n=this.getPlanObject(e.getId());let a;n&&(a=await He([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.ADDED,a?a[0]:null)}}removePlanObjectFromScene(e){(e instanceof r||e instanceof d)&&this._sendWallDimensions(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!0),this._renderEverything()}async planElementChanged(e,t){if(this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),!this._plannerSceneEventHandler.isDragIn()){const e=this.getPlanObject(t.getId());let n;e&&(n=await He([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.CHANGED,n?n[0]:null)}}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){if(!this._sky){this._sky=new Oe,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=D(4e5,0,.6);this._sky.material.uniforms.sunPosition.value.copy(e);let t=new re(new ue(2e4,16,8),new se({color:16777215}));t.name="Sunsphere",t.position.y=-7e5,t.visible=!1,t.position.set(e.x,-e.z,e.y)}this._lightSetting instanceof Ee&&this._lightSetting.updateSunPosition(.6,0)}switchTo2D(){var e;if(this._onCameraMove(),!(this._cameraControl instanceof Z)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(g.CAMERA_2D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(M.Mode2D),this._renderEverything(),this._changeCameraControl(new Z(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(g.CAMERA_2D),this._setCameraControlListeners(),this._setKernelZoomFactor(),this._onCameraMove()}}switchTo3D(){var e;this._onCameraMove(),this._cameraControl instanceof N||(this._getViewModel().setCameraType(g.CAMERA_3D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(M.Mode3D),this._renderEverything(),this._changeCameraControl(new N(this._creator_,this._getInputManager(),new J(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(g.CAMERA_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(){this._setKernelZoomFactor()}_setKernelZoomFactor(){var e,t;const n=this._cameraControl.getKernelZoomFactor();null===(e=this._getKernelAccess().planInteractionHandler)||void 0===e||e.setZoomFactor(n),null===(t=this._plannerSceneEventHandler)||void 0===t||t.setKernelZoomFactor(n)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof q?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 N&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof q)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>O(e.material,!1,!1)),this._getViewModel().setCameraType(g.CAMERA_FP),this._renderEverything();let e=new J(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new J)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new q(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(g.CAMERA_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 N&&(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 N&&(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 g.CAMERA_2D:this.switchTo2D();break;case g.CAMERA_3D:this.switchTo3D();break;case g.CAMERA_FP:this.switchToFirstPerson()}}_highlightPlanElement(e){var t;let n=new Set;e instanceof H&&this._cameraControl instanceof Z&&e&&e.getTopViewContainer()?n.add(e.getTopViewContainer()):e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>n.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t instanceof H&&this._cameraControl instanceof Z&&t&&t.getTopViewContainer()?n.add(t.getTopViewContainer()):t&&t.getObject()&&t.getObject().children&&t.getObject().children.forEach(e=>n.add(e))}),null===(t=this._roomleRenderer)||void 0===t||t.highlightObjects(Array.from(n))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}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){e||(e=this.getBounds()),e&&(this._cameraControl instanceof N&&this._cameraControl.updateToBounds(e,!1),this._cameraControl instanceof Z&&this._cameraControl.zoomToFitBounds(L(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight,1.1),!0),this._renderEverything())}_zoomToBounds(e,t=!0){const n=this.getBounds();this._cameraControl instanceof N&&(this._getViewModel().getPlanObjectCount()<=1?this._cameraControl.zoomToFitBounds(n,t):this._cameraControl.checkBoundsAndPlaceCamera(n,t)),this._cameraControl instanceof Z&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(n,e,t)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof Z&&this._cameraControl.zoomToFitBounds(e,!1,!0),this._cameraControl instanceof N&&this._cameraControl.zoomToFitBounds(e,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}getPlanObject(e){const t=this._getKernelAccess().planInteractionHandler,n=this._plannerKernelAccess.planModelViewHelper,a=t.getPlan();return n.getPlanObject(a,e)}cancelPlanElementSelection(e){this._plannerSceneEventHandler.cancelSelection(e),this._highlightPlanElement(null),this._requestRender()}async deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection("delete_object"),await this.deletePlanElementByIds(e)}async deletePlanElementByIds(e){for(const t of e){const e=this._getViewModel().getPlanObjectForId(t);if(e&&e.getObject()){const t=this.getPlanObject(e.getId());let n;t&&(n=await He([t],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.REMOVED,n?n[0]:null),this._getKernelAccess().planInteractionHandler.removeElement(e.getKernelObject())}}}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new ce;let a={x:0,y:0,z:0};if(this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(a=i.getPlanElement().getCenter(),t.push_back(i.getPlanElement()),n.expandByObject(i.getContainer()))}),t.size()>1){const e=n.getCenter(new J);a=h(e)}const i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,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()=>{var n,a;let i=this._calculateBoundingBoxOfAllMeshes(.1);null===(n=this._lightSetting)||void 0===n||n.removeFromScene(),this._cameraControl instanceof N&&this._getViewModel().setCameraType(g.CAMERA_2D);let s=await this._imageRenderer.prepareTopImage(this._scene,null,i,e);this._cameraControl instanceof N&&this._getViewModel().setCameraType(g.CAMERA_3D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(s)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a;let i;this._cameraControl instanceof N?i=this._cameraControl.getCamera().clone():(i=this.getPerspectiveOffsetCamera(),this._getViewModel().setCameraType(g.CAMERA_3D)),i.resetOffset();let s=this._calculateBoundingBoxOfAllMeshes();null===(n=this._lightSetting)||void 0===n||n.removeFromScene();const r=await this._imageRenderer.preparePerspectiveImage(this._scene,null,i,s,e);this._cameraControl instanceof Z&&this._getViewModel().setCameraType(g.CAMERA_2D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(r)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return A.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(),this._roomlePlannerUiCallback.onCameraIdle()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),!0}_updateNodeSize(){if(this._cameraControl instanceof Z){const e=1/this._cameraControl.getCamera().zoom;this._getViewModel().setNodeZoom(e)}}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=this._cameraControl.getCamera(),a=[],i={staticPlanObjectViewModels:this._getViewModel().getStaticPlanObjectViewModels(),configurablePlanObjectViewModels:this._getViewModel().getConfigurablePlanObjectViewModels(),constructionPlanObjectViewModels:this._getViewModel().getConstructionPlanObjectViewModels(),wallPlanObjectViewModels:this._getViewModel().getWallPlanObjectViewModels(),floorPlanObjectViewModels:this._getViewModel().getFloorPlanObjectViewModels(),nodePlanObjectViewModels:this._getViewModel().getNodePlanObjectViewModels()};for(const s of Object.values(i))for(const i of s)a.push(De(i,n,e,t));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(a)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:a}=this._domHelper.element,i=this._getViewModel().getWallPlanObjectViewModels(),s=this._cameraControl.getKernelZoomFactor();for(const e of i){const i=e.getWallDimension(s);if(i.length>0){const e=this._cameraControl.getCamera();i.fromPosition2d=C(i.fromPosition3d,e,n,a),i.toPosition2d=C(i.toPosition3d,e,n,a),i.fromWithoutPadding=C(i.fromWithoutPadding,e,n,a),i.toWithoutPadding=C(i.toWithoutPadding,e,n,a),i.textPosition2d=C(i.textPosition3d,e,n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(k(i))}if(this._initData.debug){const e=new ue(.1,32,16),t=new se({color:16711680}),n=new re(e,t);n.position.copy(i.fromPosition3d);const a=new re(e,t);a.position.copy(i.toPosition3d);const s=new re(e,new se({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}this._roomlePlannerUiCallback.onUpdateWallDimensions(t)}enableWallDrawing(){if(this._cameraControl instanceof Z){const e=L(this.getBounds(),this._domHelper.element.clientWidth,this._domHelper.element.clientHeight);this._cameraControl.zoomToFitBounds(e,!0)}this._drawingEnabled||(this._drawingEnabled=!0,this._scene.add(this._plannerSceneEventHandler.enableWallDrawing()))}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._scene.remove(this._plannerSceneEventHandler.cancelWallDrawing())}escapeDrawing(){this._plannerSceneEventHandler.stopDrawing()}_changeCameraControl(e){super._changeCameraControl(e)}setSceneEvents(e){var t,n;void 0!==e.construction&&(null===(t=this._plannerSceneEventHandler)||void 0===t||t.enableConstructionEvents(e.construction)),void 0!==e.objects&&(null===(n=this._plannerSceneEventHandler)||void 0===n||n.enableObjectEvents(e.objects))}startedDrawing(){this._plannerSceneEventHandler.startDrawing()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),"planner"===this._configuratorContext.baseContext&&this.enablePlannerEvents()}resetCameraPositionToStart(e=!0){this._cameraControl instanceof N&&super.resetCameraPositionToStart(e),this._cameraControl instanceof Z&&this._updateCamera()}async moveCamera(e){return this._cameraControl instanceof N?super.moveCamera(e):Promise.reject("Camera can only be moved in 3D")}_setInteriorOrExteriorWallMaterial(e,t){const n=this._getViewModel().getWallPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=e=>{a.setWallLeftMaterial(e,ve(e.leftMaterial,t))},s=e=>{a.setWallRightMaterial(e,ve(e.rightMaterial,t))},r=n.map(e=>e.getKernelObject()),o=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,l=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,c=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const t of r)t.wallType===o&&"interior"===e&&(i(t),s(t)),t.wallType===l&&("interior"===e?s(t):i(t)),t.wallType===c&&("exterior"===e?s(t):i(t))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("interior",e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("exterior",e)}changeFloorsMaterial(e){const t=this._getViewModel().getFloorPlanObjectViewModels();if(!t.length)return;const n=this._getKernelAccess().planInteractionHandler,a=t.map(e=>e.getKernelObject());for(const t of a)n.setFloorMaterial(t,ve(t.material,e))}getWallAngleDegrees(e){if(!(e instanceof r))return 0;const t=this._cameraControl.getCamera(),n=new ee(t.position.x,t.position.z),a=new ee(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),i=e.getKernelObject(),s=new ee(Math.sin(i.getAngle()),Math.cos(i.getAngle())),o=a.angle()-s.angle();return we.radToDeg(o)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0),n.moveElementTo(e.getPlanElement(),t),this._sendPlanObjectPositions()}}l([c],Le.prototype,"_rapiAccess",void 0),l([c],Le.prototype,"_plannerMeshGenerator",void 0),l([c],Le.prototype,"_plannerInputManager",void 0),l([c],Le.prototype,"_roomlePlannerUiCallback",void 0),l([c],Le.prototype,"_localStorageHelper",void 0),l([c],Le.prototype,"_unitFormatter",void 0);const Ae={left:0,top:1,right:1,bottom:0};class ke{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(e="unknown"){this._sceneManager.cancelPlanElementSelection(e)}init(e,t,n){return j.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)=>{const a=x(e);(a?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(n=>{const i=a?n.plan:n.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(i),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t(n)},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}resetCameraPosition(){this._sceneManager.resetCameraPositionToStart()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){Promise.all([this._scriptLoader.fetch(X,{id:"tween-js"})]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new Le(this._creator_,Ae,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=T.createDynamicLightSettingSource(t,n);i&&this.showStats(),this._sceneManager.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){j.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new Me(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)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-064016b1.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-a98ce118.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=h(new J(t.x,t.y,t.z)));const a=await(V(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=>V(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return await this._plannerKernelAccess.insertItems(n)}async insertItems(e){return await this._plannerKernelAccess.insertItems(e)}duplicateItems(e){return this._plannerKernelAccess.duplicateItems(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),t=f(e.objects);return He(t,this._plannerKernelAccess,this._rapiAccess)}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()}enableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode("multiselect"),this._configuratorContext.selectionMode="multiselect"}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),a=await this.insertItems([n]);if(1!==a.length)throw new Error("More than one object added, abort");return a[0]}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(),this._sceneManager.updateScene(),s}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const t of e){const e=this._sceneManager.getPlanObject(t.getId());let n;e&&(n=await He([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(E.REMOVED,n?n[0]:null),this._planInteractionHandler.removeElement(t)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}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}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}async saveCurrentPlanSnapshot(e){const t=await this.getPlanModelViewHelper(),n=this._planInteractionHandler.getPlan(),a=t.getPlanOverview(n),i={parentId:e||null,planObjects:[],combinedIds:[],plan:n.getPlanXML(!1,2)},s=a.objects,r=s.size();for(let e=0;e<r;e++){const t=s.get(e),n=t.configurationHash||t.catalogItemId,{center:a,dimensions:r,rotation:o}=t,l=JSON.stringify({center:a,dimensions:r,rotation:o});i.planObjects.push({combinedId:n,location:l})}const o=await this._rapiAccess.savePlanSnapshot(i),l=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotPerspectiveImage(o,n.value),i=await this._rapiAccess.savePlanSnapshotTopImage(o,a.value);e({...t,...i})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await l}catch(e){return console.error(e),o}}getPlanXmlFrom(e){return e?x(e.id)?e.plan:e.planObjects:null}async moveCamera(e){return this._sceneManager.moveCamera(e)}async createNewSerializedConfiguration(e){return Promise.resolve(this._plannerKernelAccess.createNewSerializedConfiguration(e))}changeInteriorWallsMaterial(e){this._sceneManager.changeInteriorWallsMaterial(e)}changeExteriorWallsMaterial(e){this._sceneManager.changeExteriorWallsMaterial(e)}changeFloorsMaterial(e){this._sceneManager.changeFloorsMaterial(e)}getWallAngleDegrees(e){return this._sceneManager.getWallAngleDegrees(e)}calcPartsPriceSum(e){return this._plannerKernelAccess.calcPartsPriceSum(e)}async swapObject(e,t){const n=e.getPosition(),a=e.getRotation();return await this._sceneManager.deletePlanElementByIds([e.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,n,a)}exportImageFromCamera(e="image"){this._sceneManager.exportImageFromCamera(e)}moveElementPosition(e,t){this._sceneManager.moveElementPosition(e,t)}async generateProductionServiceExport(e,t=""){try{return Promise.resolve(JSON.parse(this._plannerKernelAccess.kernelInstance.generateProductionServiceExport(e,t)))}catch(e){return console.error(e),Promise.reject("Could not create Blue Ocean MVP JSON")}}}l([c],ke.prototype,"_configuratorContext",void 0),l([c],ke.prototype,"_domHelper",void 0),l([c],ke.prototype,"_scriptLoader",void 0),l([c],ke.prototype,"_kernelAccessCallback",void 0),l([c],ke.prototype,"_plannerKernelAccess",void 0),l([c],ke.prototype,"_rapiAccess",void 0),l([c],ke.prototype,"_singlePromiseFactory",void 0),l([c],ke.prototype,"_roomlePlannerUiCallback",void 0),l([c],ke.prototype,"_lifeCycleManager",void 0),l([c],ke.prototype,"_dataSyncer",void 0),l([c],ke.prototype,"_initData",void 0),l([c],ke.prototype,"_globalInitData",void 0),l([c],ke.prototype,"_unitFormatter",void 0);const Ve=[new B("script-loader",n),new B("planner-input-manager",class extends R{_canDrag(e){return!0}},1),new B("logger",W),new B("planner-mesh-generator",F),new B("rapi-access",K),new B("planner-selection-handler",class extends s{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(e){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new Se({planElementViewModel:t,reason:e}))})}_checkStandard(e){this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new Se({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new Se({planElementViewModel:e})))}_checkMulti(e){if(!Pe(e)&&!this._selectedPlanElementViewModels.has(e.getId())){this._selectedPlanElementViewModels.set(e.getId(),e),e.select();const t=Array.from(this._selectedPlanElementViewModels).map(([e,t])=>t);this.dispatchEvent(2,new Se({planElementViewModels:t})),this.dispatchEvent(0,new Se({planElementViewModel:e}))}}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{Pe(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new Se({planElementViewModel:e})))})}setSelectionMode(e){"multiselect"===e&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(15,new Se({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 a{setupGlobals(){}setupDependencies(){z.setup(Ve),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 ke(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
+ //# sourceMappingURL=planner-98212afe.nomodule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-7ec2696d.nomodule.js","sources":["../../node_modules/three/examples/jsm/objects/Sky.js"],"sourcesContent":["import {\n\tBackSide,\n\tBoxGeometry,\n\tMesh,\n\tShaderMaterial,\n\tUniformsUtils,\n\tVector3\n} from 'three';\n\n/**\n * Based on \"A Practical Analytic Model for Daylight\"\n * aka The Preetham Model, the de facto standard analytic skydome model\n * https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight\n *\n * First implemented by Simon Wallner\n * http://simonwallner.at/project/atmospheric-scattering/\n *\n * Improved by Martin Upitis\n * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR\n *\n * Three.js integration by zz85 http://twitter.com/blurspline\n*/\n\nclass Sky extends Mesh {\n\n\tconstructor() {\n\n\t\tconst shader = Sky.SkyShader;\n\n\t\tconst material = new ShaderMaterial( {\n\t\t\tname: 'SkyShader',\n\t\t\tfragmentShader: shader.fragmentShader,\n\t\t\tvertexShader: shader.vertexShader,\n\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\tside: BackSide,\n\t\t\tdepthWrite: false\n\t\t} );\n\n\t\tsuper( new BoxGeometry( 1, 1, 1 ), material );\n\n\t\tthis.isSky = true;\n\n\t}\n\n}\n\nSky.SkyShader = {\n\n\tuniforms: {\n\t\t'turbidity': { value: 2 },\n\t\t'rayleigh': { value: 1 },\n\t\t'mieCoefficient': { value: 0.005 },\n\t\t'mieDirectionalG': { value: 0.8 },\n\t\t'sunPosition': { value: new Vector3() },\n\t\t'up': { value: new Vector3( 0, 1, 0 ) }\n\t},\n\n\tvertexShader: /* glsl */`\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}`,\n\n\tfragmentShader: /* glsl */`\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}`\n\n};\n\nexport { Sky };\n"],"names":["Sky","Mesh","[object Object]","shader","SkyShader","material","ShaderMaterial","name","fragmentShader","vertexShader","uniforms","UniformsUtils","clone","side","BackSide","depthWrite","super","BoxGeometry","this","isSky","turbidity","value","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","Vector3","up"],"mappings":"+thBAuBA,MAAMA,WAAYC,GAEjBC,cAEC,MAAMC,EAASH,GAAII,UAEbC,EAAW,IAAIC,GAAgB,CACpCC,KAAM,YACNC,eAAgBL,EAAOK,eACvBC,aAAcN,EAAOM,aACrBC,SAAUC,GAAcC,MAAOT,EAAOO,UACtCG,KAAMC,GACNC,YAAY,IAGbC,MAAO,IAAIC,GAAa,EAAG,EAAG,GAAKZ,GAEnCa,KAAKC,OAAQ,GAMfnB,GAAII,UAAY,CAEfM,SAAU,CACTU,UAAa,CAAEC,MAAO,GACtBC,SAAY,CAAED,MAAO,GACrBE,eAAkB,CAAEF,MAAO,MAC3BG,gBAAmB,CAAEH,MAAO,IAC5BI,YAAe,CAAEJ,MAAO,IAAIK,GAC5BC,GAAM,CAAEN,MAAO,IAAIK,EAAS,EAAG,EAAG,KAGnCjB,aAAwB,6gFAwExBD,eAA0B"}
1
+ {"version":3,"file":"planner-98212afe.nomodule.js","sources":["../../node_modules/three/examples/jsm/objects/Sky.js"],"sourcesContent":["import {\n\tBackSide,\n\tBoxGeometry,\n\tMesh,\n\tShaderMaterial,\n\tUniformsUtils,\n\tVector3\n} from 'three';\n\n/**\n * Based on \"A Practical Analytic Model for Daylight\"\n * aka The Preetham Model, the de facto standard analytic skydome model\n * https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight\n *\n * First implemented by Simon Wallner\n * http://simonwallner.at/project/atmospheric-scattering/\n *\n * Improved by Martin Upitis\n * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR\n *\n * Three.js integration by zz85 http://twitter.com/blurspline\n*/\n\nclass Sky extends Mesh {\n\n\tconstructor() {\n\n\t\tconst shader = Sky.SkyShader;\n\n\t\tconst material = new ShaderMaterial( {\n\t\t\tname: 'SkyShader',\n\t\t\tfragmentShader: shader.fragmentShader,\n\t\t\tvertexShader: shader.vertexShader,\n\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\tside: BackSide,\n\t\t\tdepthWrite: false\n\t\t} );\n\n\t\tsuper( new BoxGeometry( 1, 1, 1 ), material );\n\n\t\tthis.isSky = true;\n\n\t}\n\n}\n\nSky.SkyShader = {\n\n\tuniforms: {\n\t\t'turbidity': { value: 2 },\n\t\t'rayleigh': { value: 1 },\n\t\t'mieCoefficient': { value: 0.005 },\n\t\t'mieDirectionalG': { value: 0.8 },\n\t\t'sunPosition': { value: new Vector3() },\n\t\t'up': { value: new Vector3( 0, 1, 0 ) }\n\t},\n\n\tvertexShader: /* glsl */`\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}`,\n\n\tfragmentShader: /* glsl */`\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}`\n\n};\n\nexport { Sky };\n"],"names":["Sky","Mesh","[object Object]","shader","SkyShader","material","ShaderMaterial","name","fragmentShader","vertexShader","uniforms","UniformsUtils","clone","side","BackSide","depthWrite","super","BoxGeometry","this","isSky","turbidity","value","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","Vector3","up"],"mappings":"+thBAuBA,MAAMA,WAAYC,GAEjBC,cAEC,MAAMC,EAASH,GAAII,UAEbC,EAAW,IAAIC,GAAgB,CACpCC,KAAM,YACNC,eAAgBL,EAAOK,eACvBC,aAAcN,EAAOM,aACrBC,SAAUC,GAAcC,MAAOT,EAAOO,UACtCG,KAAMC,GACNC,YAAY,IAGbC,MAAO,IAAIC,GAAa,EAAG,EAAG,GAAKZ,GAEnCa,KAAKC,OAAQ,GAMfnB,GAAII,UAAY,CAEfM,SAAU,CACTU,UAAa,CAAEC,MAAO,GACtBC,SAAY,CAAED,MAAO,GACrBE,eAAkB,CAAEF,MAAO,MAC3BG,gBAAmB,CAAEH,MAAO,IAC5BI,YAAe,CAAEJ,MAAO,IAAIK,GAC5BC,GAAM,CAAEN,MAAO,IAAIK,EAAS,EAAG,EAAG,KAGnCjB,aAAwB,6gFAwExBD,eAA0B"}