@roomle/web-sdk 2.41.0-alpha.2 → 2.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/lib/{banana-for-scale-ae5b86f3.js → banana-for-scale-5ff6afa2.js} +2 -2
  2. package/lib/{banana-for-scale-ae5b86f3.js.map → banana-for-scale-5ff6afa2.js.map} +1 -1
  3. package/lib/{banana-for-scale-adac0bbc.nomodule.js → banana-for-scale-63b9dccb.nomodule.js} +2 -2
  4. package/lib/{banana-for-scale-adac0bbc.nomodule.js.map → banana-for-scale-63b9dccb.nomodule.js.map} +1 -1
  5. package/lib/{component-dimensioning-a3d0fd84.nomodule.js → component-dimensioning-6b29650e.nomodule.js} +2 -2
  6. package/lib/component-dimensioning-6b29650e.nomodule.js.map +1 -0
  7. package/lib/{component-dimensioning-c02017dc.js → component-dimensioning-86ee8104.js} +2 -2
  8. package/lib/component-dimensioning-86ee8104.js.map +1 -0
  9. package/lib/{component-raycast-helper-ab2376e7.nomodule.js → component-raycast-helper-5d22b992.nomodule.js} +2 -2
  10. package/lib/component-raycast-helper-5d22b992.nomodule.js.map +1 -0
  11. package/lib/{component-raycast-helper-fa1afd7d.js → component-raycast-helper-e9a05061.js} +2 -2
  12. package/lib/component-raycast-helper-e9a05061.js.map +1 -0
  13. package/lib/{configurator-9a219c6c.js → configurator-0499617b.js} +2 -2
  14. package/lib/configurator-0499617b.js.map +1 -0
  15. package/lib/{configurator-528af742.nomodule.js → configurator-3815d8dc.nomodule.js} +2 -2
  16. package/lib/configurator-3815d8dc.nomodule.js.map +1 -0
  17. package/lib/configurator-main-7bb5f0f6.js +2 -0
  18. package/lib/configurator-main-7bb5f0f6.js.map +1 -0
  19. package/lib/configurator-main.nomodule.js +1 -1
  20. package/lib/{default-light-setting-ee7cd0ac.nomodule.js → default-light-setting-86900b75.nomodule.js} +2 -2
  21. package/lib/default-light-setting-86900b75.nomodule.js.map +1 -0
  22. package/lib/{default-light-setting-4da6d23a.js → default-light-setting-a373e78e.js} +2 -2
  23. package/lib/default-light-setting-a373e78e.js.map +1 -0
  24. package/lib/{dimensioning-helper-131972e4.js → dimensioning-helper-7d14802f.js} +2 -2
  25. package/lib/{dimensioning-helper-131972e4.js.map → dimensioning-helper-7d14802f.js.map} +1 -1
  26. package/lib/{dimensioning-helper-4cb45f13.nomodule.js → dimensioning-helper-81e24b70.nomodule.js} +2 -2
  27. package/lib/{dimensioning-helper-4cb45f13.nomodule.js.map → dimensioning-helper-81e24b70.nomodule.js.map} +1 -1
  28. package/lib/{glb-viewer-ab95b772.nomodule.js → glb-viewer-2d08a55b.nomodule.js} +2 -2
  29. package/lib/{glb-viewer-ab95b772.nomodule.js.map → glb-viewer-2d08a55b.nomodule.js.map} +1 -1
  30. package/lib/{glb-viewer-70e9420a.js → glb-viewer-ca969b1b.js} +2 -2
  31. package/lib/{glb-viewer-70e9420a.js.map → glb-viewer-ca969b1b.js.map} +1 -1
  32. package/lib/glb-viewer-main-dc8a490a.js +2 -0
  33. package/lib/glb-viewer-main-dc8a490a.js.map +1 -0
  34. package/lib/glb-viewer-main.nomodule.js +1 -1
  35. package/lib/legacy/{banana-for-scale-4cba6922.legacy.js → banana-for-scale-3aaa2a02.legacy.js} +2 -2
  36. package/lib/legacy/{banana-for-scale-4cba6922.legacy.js.map → banana-for-scale-3aaa2a02.legacy.js.map} +1 -1
  37. package/lib/legacy/{component-dimensioning-bffb0f3b.legacy.js → component-dimensioning-86b32d3b.legacy.js} +2 -2
  38. package/lib/legacy/component-dimensioning-86b32d3b.legacy.js.map +1 -0
  39. package/lib/legacy/{component-raycast-helper-9f1b4f67.legacy.js → component-raycast-helper-69f2b444.legacy.js} +2 -2
  40. package/lib/legacy/component-raycast-helper-69f2b444.legacy.js.map +1 -0
  41. package/lib/legacy/{configurator-17f905eb.legacy.js → configurator-ab1c48da.legacy.js} +2 -2
  42. package/lib/legacy/configurator-ab1c48da.legacy.js.map +1 -0
  43. package/lib/legacy/configurator-main.legacy.js +1 -1
  44. package/lib/legacy/{default-light-setting-b4370cc1.legacy.js → default-light-setting-edbfae4a.legacy.js} +2 -2
  45. package/lib/legacy/default-light-setting-edbfae4a.legacy.js.map +1 -0
  46. package/lib/legacy/{dimensioning-helper-a4308bf5.legacy.js → dimensioning-helper-c78d3335.legacy.js} +2 -2
  47. package/lib/legacy/{dimensioning-helper-a4308bf5.legacy.js.map → dimensioning-helper-c78d3335.legacy.js.map} +1 -1
  48. package/lib/legacy/{glb-viewer-25726a33.legacy.js → glb-viewer-ac0f25b4.legacy.js} +2 -2
  49. package/lib/legacy/{glb-viewer-25726a33.legacy.js.map → glb-viewer-ac0f25b4.legacy.js.map} +1 -1
  50. package/lib/legacy/glb-viewer-main.legacy.js +1 -1
  51. package/lib/legacy/{material-viewer-2ae5c85f.legacy.js → material-viewer-ae767c51.legacy.js} +2 -2
  52. package/lib/legacy/material-viewer-ae767c51.legacy.js.map +1 -0
  53. package/lib/legacy/material-viewer-main.legacy.js +1 -1
  54. package/lib/legacy/{pixotron-084097ac.legacy.js → pixotron-77572ad9.legacy.js} +2 -2
  55. package/lib/legacy/{pixotron-084097ac.legacy.js.map → pixotron-77572ad9.legacy.js.map} +1 -1
  56. package/lib/legacy/{planner-ef79f503.legacy.js → planner-c9fae545.legacy.js} +2 -2
  57. package/lib/legacy/{planner-ef79f503.legacy.js.map → planner-c9fae545.legacy.js.map} +1 -1
  58. package/lib/legacy/planner-main.legacy.js +1 -1
  59. package/lib/legacy/{roomle-configurator-8d3e7c20.legacy.js → roomle-configurator-f6cddbe7.legacy.js} +2 -2
  60. package/lib/legacy/{roomle-configurator-8d3e7c20.legacy.js.map → roomle-configurator-f6cddbe7.legacy.js.map} +1 -1
  61. package/lib/legacy/{roomle-dependency-injection-f964807d.legacy.js → roomle-dependency-injection-85943177.legacy.js} +2 -2
  62. package/lib/legacy/{roomle-dependency-injection-f964807d.legacy.js.map → roomle-dependency-injection-85943177.legacy.js.map} +1 -1
  63. package/lib/legacy/roomle-sdk.legacy.js +1 -1
  64. package/lib/legacy/{script-loader-d596fefb.legacy.js → script-loader-cecb38a7.legacy.js} +2 -2
  65. package/lib/legacy/script-loader-cecb38a7.legacy.js.map +1 -0
  66. package/lib/legacy/static/ConfiguratorKernel-f0fd8475c9bb6ae3.wasm +0 -0
  67. package/lib/legacy/static/ConfiguratorKernelJs-733c537c978e8757.mem +0 -0
  68. package/lib/legacy/static/ConfiguratorKernelJs-94b662be35edd490.js +146 -0
  69. package/lib/legacy/static/RoomleCore-26406f45882636dc.wasm +0 -0
  70. package/lib/legacy/static/RoomleCoreJs-a667b9fb53d1da6d.js +154 -0
  71. package/lib/legacy/static/RoomleCoreJs-df5a3b5d84f74e48.mem +0 -0
  72. package/lib/legacy/static/RoomleToolsCore-03a0e982a9cbba05.wasm +0 -0
  73. package/lib/legacy/static/shaders-966e51d62bed1518.json +1 -0
  74. package/lib/legacy/{stats-helper-9898756b.legacy.js → stats-helper-47d4bb11.legacy.js} +2 -2
  75. package/lib/legacy/{stats-helper-9898756b.legacy.js.map → stats-helper-47d4bb11.legacy.js.map} +1 -1
  76. package/lib/legacy/{tools-core-becb0fa3.legacy.js → tools-core-89decd49.legacy.js} +2 -2
  77. package/lib/legacy/tools-core-89decd49.legacy.js.map +1 -0
  78. package/lib/{material-viewer-337773a9.nomodule.js → material-viewer-2299150f.nomodule.js} +2 -2
  79. package/lib/material-viewer-2299150f.nomodule.js.map +1 -0
  80. package/lib/{material-viewer-aad1c1fe.js → material-viewer-c37accb7.js} +2 -2
  81. package/lib/material-viewer-c37accb7.js.map +1 -0
  82. package/lib/material-viewer-main-1836fe13.js +2 -0
  83. package/lib/material-viewer-main-1836fe13.js.map +1 -0
  84. package/lib/material-viewer-main.nomodule.js +1 -1
  85. package/lib/{pixotron-710676a0.nomodule.js → pixotron-82119b18.nomodule.js} +2 -2
  86. package/lib/{pixotron-710676a0.nomodule.js.map → pixotron-82119b18.nomodule.js.map} +1 -1
  87. package/lib/{pixotron-636f369f.js → pixotron-9f139c75.js} +2 -2
  88. package/lib/{pixotron-636f369f.js.map → pixotron-9f139c75.js.map} +1 -1
  89. package/lib/{planner-40982a1a.js → planner-186d14e1.js} +2 -2
  90. package/lib/{planner-40982a1a.js.map → planner-186d14e1.js.map} +1 -1
  91. package/lib/{planner-8b93848e.nomodule.js → planner-81a22ec8.nomodule.js} +2 -2
  92. package/lib/{planner-8b93848e.nomodule.js.map → planner-81a22ec8.nomodule.js.map} +1 -1
  93. package/lib/planner-main-953e8696.js +2 -0
  94. package/lib/planner-main-953e8696.js.map +1 -0
  95. package/lib/planner-main.nomodule.js +1 -1
  96. package/lib/{roomle-configurator-bf767216.nomodule.js → roomle-configurator-60558432.nomodule.js} +2 -2
  97. package/lib/{roomle-configurator-bf767216.nomodule.js.map → roomle-configurator-60558432.nomodule.js.map} +1 -1
  98. package/lib/{roomle-configurator-b93f8e93.js → roomle-configurator-af533195.js} +2 -2
  99. package/lib/{roomle-configurator-b93f8e93.js.map → roomle-configurator-af533195.js.map} +1 -1
  100. package/lib/{roomle-dependency-injection-1916c1c5.js → roomle-dependency-injection-b9111746.js} +2 -2
  101. package/lib/{roomle-dependency-injection-1916c1c5.js.map → roomle-dependency-injection-b9111746.js.map} +1 -1
  102. package/lib/{roomle-dependency-injection-fd4ee18d.nomodule.js → roomle-dependency-injection-f6cc9c17.nomodule.js} +2 -2
  103. package/lib/{roomle-dependency-injection-fd4ee18d.nomodule.js.map → roomle-dependency-injection-f6cc9c17.nomodule.js.map} +1 -1
  104. package/lib/{roomle-sdk-0a2623a6.js → roomle-sdk-c950acdc.js} +2 -2
  105. package/lib/roomle-sdk-c950acdc.js.map +1 -0
  106. package/lib/roomle-sdk.nomodule.js +1 -1
  107. package/lib/{script-loader-ad588ab3.nomodule.js → script-loader-29c29641.nomodule.js} +2 -2
  108. package/lib/script-loader-29c29641.nomodule.js.map +1 -0
  109. package/lib/{script-loader-61e93b62.js → script-loader-3390ceca.js} +2 -2
  110. package/lib/script-loader-3390ceca.js.map +1 -0
  111. package/lib/static/ConfiguratorKernel-f0fd8475c9bb6ae3.wasm +0 -0
  112. package/lib/static/ConfiguratorKernelJs-733c537c978e8757.mem +0 -0
  113. package/lib/static/ConfiguratorKernelJs-94b662be35edd490.js +146 -0
  114. package/lib/static/RoomleCore-26406f45882636dc.wasm +0 -0
  115. package/lib/static/RoomleCoreJs-a667b9fb53d1da6d.js +154 -0
  116. package/lib/static/RoomleCoreJs-df5a3b5d84f74e48.mem +0 -0
  117. package/lib/static/RoomleToolsCore-03a0e982a9cbba05.wasm +0 -0
  118. package/lib/static/shaders-966e51d62bed1518.json +1 -0
  119. package/lib/{stats-helper-e36a7344.js → stats-helper-652ab243.js} +2 -2
  120. package/lib/{stats-helper-e36a7344.js.map → stats-helper-652ab243.js.map} +1 -1
  121. package/lib/{stats-helper-1d52f9e6.nomodule.js → stats-helper-66bdd451.nomodule.js} +2 -2
  122. package/lib/{stats-helper-1d52f9e6.nomodule.js.map → stats-helper-66bdd451.nomodule.js.map} +1 -1
  123. package/lib/{tools-core-6aafa419.nomodule.js → tools-core-786d3768.nomodule.js} +2 -2
  124. package/lib/tools-core-786d3768.nomodule.js.map +1 -0
  125. package/lib/{tools-core-234213f1.js → tools-core-7b6816a2.js} +2 -2
  126. package/lib/tools-core-7b6816a2.js.map +1 -0
  127. package/package.json +2 -2
  128. package/lib/component-dimensioning-a3d0fd84.nomodule.js.map +0 -1
  129. package/lib/component-dimensioning-c02017dc.js.map +0 -1
  130. package/lib/component-raycast-helper-ab2376e7.nomodule.js.map +0 -1
  131. package/lib/component-raycast-helper-fa1afd7d.js.map +0 -1
  132. package/lib/configurator-528af742.nomodule.js.map +0 -1
  133. package/lib/configurator-9a219c6c.js.map +0 -1
  134. package/lib/configurator-main-b3145ad1.js +0 -2
  135. package/lib/configurator-main-b3145ad1.js.map +0 -1
  136. package/lib/default-light-setting-4da6d23a.js.map +0 -1
  137. package/lib/default-light-setting-ee7cd0ac.nomodule.js.map +0 -1
  138. package/lib/glb-viewer-main-af7f8db5.js +0 -2
  139. package/lib/glb-viewer-main-af7f8db5.js.map +0 -1
  140. package/lib/legacy/component-dimensioning-bffb0f3b.legacy.js.map +0 -1
  141. package/lib/legacy/component-raycast-helper-9f1b4f67.legacy.js.map +0 -1
  142. package/lib/legacy/configurator-17f905eb.legacy.js.map +0 -1
  143. package/lib/legacy/default-light-setting-b4370cc1.legacy.js.map +0 -1
  144. package/lib/legacy/material-viewer-2ae5c85f.legacy.js.map +0 -1
  145. package/lib/legacy/script-loader-d596fefb.legacy.js.map +0 -1
  146. package/lib/legacy/static/ConfiguratorKernel-ae7e275bc715fd26.wasm +0 -0
  147. package/lib/legacy/static/ConfiguratorKernelJs-7c1047a033b225d4.js +0 -146
  148. package/lib/legacy/static/ConfiguratorKernelJs-d3e4f60672162604.mem +0 -0
  149. package/lib/legacy/static/RoomleCore-49461a0dcc73733f.wasm +0 -0
  150. package/lib/legacy/static/RoomleCoreJs-5893fc7ffafdc689.mem +0 -0
  151. package/lib/legacy/static/RoomleCoreJs-726cd014804a7c9c.js +0 -154
  152. package/lib/legacy/static/RoomleToolsCore-5d462fa29751217f.wasm +0 -0
  153. package/lib/legacy/static/shaders-f7602438ff124bbf.json +0 -1
  154. package/lib/legacy/tools-core-becb0fa3.legacy.js.map +0 -1
  155. package/lib/material-viewer-337773a9.nomodule.js.map +0 -1
  156. package/lib/material-viewer-aad1c1fe.js.map +0 -1
  157. package/lib/material-viewer-main-1e83e020.js +0 -2
  158. package/lib/material-viewer-main-1e83e020.js.map +0 -1
  159. package/lib/planner-main-b9d43968.js +0 -2
  160. package/lib/planner-main-b9d43968.js.map +0 -1
  161. package/lib/roomle-sdk-0a2623a6.js.map +0 -1
  162. package/lib/script-loader-61e93b62.js.map +0 -1
  163. package/lib/script-loader-ad588ab3.nomodule.js.map +0 -1
  164. package/lib/static/ConfiguratorKernel-ae7e275bc715fd26.wasm +0 -0
  165. package/lib/static/ConfiguratorKernelJs-7c1047a033b225d4.js +0 -146
  166. package/lib/static/ConfiguratorKernelJs-d3e4f60672162604.mem +0 -0
  167. package/lib/static/RoomleCore-49461a0dcc73733f.wasm +0 -0
  168. package/lib/static/RoomleCoreJs-5893fc7ffafdc689.mem +0 -0
  169. package/lib/static/RoomleCoreJs-726cd014804a7c9c.js +0 -154
  170. package/lib/static/RoomleToolsCore-5d462fa29751217f.wasm +0 -0
  171. package/lib/static/shaders-f7602438ff124bbf.json +0 -1
  172. package/lib/tools-core-234213f1.js.map +0 -1
  173. package/lib/tools-core-6aafa419.nomodule.js.map +0 -1
@@ -1,2 +1,2 @@
1
- System.register(["./roomle-dependency-injection-f964807d.legacy.js","./main-thread-to-worker-e2f2b9cb.legacy.js"],(function(t,e){var i,s,a,n,o,r,h,_,d,l,c,u,m,p,g,w,y,E,S,P,b,v,x,C;return{setters:[function(t){i=t._,s=t.i,a=t.E,n=t.t,o=t.H,r=t.J,h=t.K,_=t.M,d=t.j,l=t.N,c=t.O,u=t.Q,m=t.T,p=t.U,g=t.h,w=t.V,y=t.X,E=t.Y,S=t.p,P=t.n,b=t.r,v=t.Z},function(t){x=t.l,C=t.h}],execute:function(){t("T","static/Tween-d024b02fe34f25ab.js");const f=t("I",10);let R=t("a",(()=>{class t extends a{constructor(t,e,i){if(super(),this._tweenEnd=null,this._cameraStandingStill=!0,this._pitch=n(f),this._yaw=n(-30),this._distance=-1,this._locked=!1,this._inputListeners=[],this._lerpEnabled=!0,this._creator_=t,this._inputManager=e,this._initInputListener(),this._addInputListeners(),this._cameraPosition=new THREE.Vector3,this._targetPosition=new THREE.Vector3,i?this._cameraPosition.copy(i):this._cameraPosition=new THREE.Vector3(0,.5,3),this._initData.debug){const t=this.getDebugCameraPosition();t&&this._setCurrentCameraParameters(t)}let s=this._domHelper.getClientDimensions();this._width=s.x,this._height=s.y,this._dispatchCameraIdle=x(this._dispatchCameraIdle.bind(this),32)}getCamera(){return this._getCamera()}_addInputListeners(){this._inputListeners.forEach(t=>{this._inputManager.addEventListener(t.key,t.fun,this)})}_removeInputListeners(){this._inputListeners.forEach(t=>{this._inputManager.removeEventListener(t.key,t.fun)}),this._inputListeners=[]}cleanUp(){this._removeInputListeners()}animateCamera(t){let e=this._cameraPosition;if(!e||o(e,this.getCamera().position))return this._cameraStandingStill||(this._cameraStandingStill=!0,setTimeout(()=>this._dispatchCameraIdle(),16),this._initData.debug&&this.saveDebugCameraPosition()),!1;if(this._cameraStandingStill&&this.dispatchEvent(7,3),this._cameraStandingStill=!1,this._lerpEnabled&&!this._tweenEnd){let i=this.getCamera().position.clone();const s=Math.min(10*t,1);i.lerp(e,s),this.getCamera().position.copy(i)}else this.getCamera().position.copy(e);return!0}getDebugCameraPosition(){return JSON.parse(localStorage.getItem("debug_camera_position"))}saveDebugCameraPosition(){localStorage.setItem("debug_camera_position",JSON.stringify(this._getCurrentCameraParameters()))}_dispatchCameraIdle(){this.dispatchEvent(8,3)}_areEqual(t,e){return t.yaw.toFixed(5)===e.yaw.toFixed(5)&&t.pitch.toFixed(5)===e.pitch.toFixed(5)&&t.distance.toFixed(5)===e.distance.toFixed(5)&&t.targetX===e.targetX&&t.targetY===e.targetY&&t.targetZ===e.targetZ}_tweenCameraParameter(t,e,i=!1){return new Promise(s=>{if(e.yaw-t.yaw<=-Math.PI?t.yaw-=2*Math.PI:e.yaw-t.yaw>=Math.PI&&(t.yaw+=2*Math.PI),window.TWEEN){if(null!==this._tweenEnd&&this._tweenEnd.blockOtherTweens)return;this._tweenEnd=e,new TWEEN.Tween(t).to(e,400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{this.dispatchEvent(1,3),this._yaw=t.yaw,this._pitch=t.pitch,this._distance=t.distance,this._setCameraNear(),this._update(new THREE.Vector3(t.targetX,t.targetY,t.targetZ),i)}).onComplete(()=>{this.dispatchEvent(2,3),this._tweenEnd=null,s()}).start(),this.dispatchEvent(0,3)}})}_setCameraNear(){const t=this.getCamera();if(t instanceof THREE.PerspectiveCamera){const e=Math.max(.1,this._distance/6);t.near=e}}_getCurrentCameraParameters(){const t=this._targetPosition.clone();return{yaw:this._yaw,pitch:this._pitch,distance:this._distance,targetX:t.x,targetY:t.y,targetZ:t.z}}_setCurrentCameraParameters(t){this._yaw=t.yaw,this._pitch=t.pitch,this._distance=t.distance,this._targetPosition.copy(new THREE.Vector3(t.targetX,t.targetY,t.targetZ))}_rotateHorizontal(t){this._yaw-=t,this._yaw<-Math.PI?this._yaw+=2*Math.PI:this._yaw>Math.PI&&(this._yaw-=2*Math.PI)}_rotateVertical(t){this._pitch+=t,this._pitch<-Math.PI?this._pitch+=2*Math.PI:this._pitch>Math.PI&&(this._pitch-=2*Math.PI)}saveState(t){if(t||!this._stateSaved){let t=this._yaw,e=this._pitch,i=this._distance,s=this._targetPosition.clone();if(this._stateSaved={yaw:t,pitch:e,distance:i,targetX:s.x,targetY:s.y,targetZ:s.z,blockOtherTweens:!0},this._getCamera().fov){let t=this._getCamera();this._stateSaved.fov=t.fov,this._stateSaved.near=t.near,this._stateSaved.far=t.far}return this._stateSaved}return null}resetToState(){if(this._stateSaved){this._stateSaved.blockOtherTweens=!1;let t=this._targetPosition.clone();this._tweenCameraParameter({yaw:this._yaw,pitch:this._pitch,distance:this._distance,targetX:t.x,targetY:t.y,targetZ:t.z},this._stateSaved,!0)}this._stateSaved=null}setToState(t,e){this._tweenCameraParameter(t,e,!0)}hasSavedState(){return null!=this._stateSaved}lock(){this._locked=!0}unlock(){this._locked=!1}isLocked(){return this._locked}getTargetPosition(){return this._targetPosition}_saveYawAndPitch(){this._getCamera().userData.yaw=this._yaw,this._getCamera().userData.pitch=this._pitch}getInputPosition(t){const{x:e,y:i}=this._domHelper.getClientDimensions();return new THREE.Vector3(t.x/e*2-1,-t.y/i*2+1,.5)}addLightContainer(t){t.name="lights";const e=this._getCamera(),i=e.children.find(t=>"lights"===t.name);i&&e.remove(i),e.add(t)}checkNearFarDistance(t){if(!t)return;const e=this._cameraPosition.distanceTo(t),i=this._getCamera();i instanceof THREE.PerspectiveCamera&&e>i.far&&(i.far=e+1)}setBounds(t){this._boundingBox=t}}return i([s],t.prototype,"_domHelper",void 0),i([s],t.prototype,"_initData",void 0),t})());class T{constructor(t,e){this.minZoom=!1,this.maxZoom=!1,this.minZoom=t,this.maxZoom=e}}class M extends R{constructor(t,e,i,s){super(t,e,i),this._bounds=new THREE.Vector3,this._scale=1,this._state=0,this._zoomSpeed=Math.pow(.95,3),this.minDistance=0,this.maxDistance=5,this.minPolarAngle=n(0),this.maxPolarAngle=n(85),this._objectRotation=0,this.minAzimuthAngle=Number.NEGATIVE_INFINITY,this.maxAzimuthAngle=Number.POSITIVE_INFINITY,this._zoomDistance=.1,this._userInteraction=!1,this._currentZoomHash="",this._maxZoomedIn=!1,this._maxZoomedOut=!1,this._panningEnabled=!1,this._targetPositionIsPanned=!1,s?this._camera=s:this._initCamera(),this._targetPosition||(this._targetPosition=new THREE.Vector3(0,0,0),this._targetPositionIsPanned=!1);const{cameraRestriction:a,zoomDistance:o,minVerticalCameraAngle:r,maxVerticalCameraAngle:h,minHorizontalCameraAngle:_,maxHorizontalCameraAngle:d}=this._initData;if(o&&(this._zoomDistance=o/100),void 0!==r&&(this.minPolarAngle=n(r<0?r:-1*r)),void 0!==h&&(this.maxPolarAngle=n(h)),void 0!==_&&(this.minAzimuthAngle=n(_<0?_:-1*_)),void 0!==d&&(this.maxAzimuthAngle=n(d)),void 0!==a){let t=Math.abs(n(a));this.minAzimuthAngle=-t,this.maxAzimuthAngle=t,this.maxPolarAngle=Math.min(t,n(85))}this._update()}_getCamera(){return this._camera||this._initCamera(),this._camera}getCamera(){return super.getCamera()}_initCamera(){this._camera=new THREE.PerspectiveCamera,this._camera.fov=30,this._camera.aspect=this._width/this._height,this._camera.near=.1,this._camera.far=100,this._camera.updateProjectionMatrix(),this._camera.layers.set(3),this._camera.layers.enable(1),this._camera.layers.enable(2),this._camera.layers.enable(6),this._camera.layers.enable(5)}setObjectRotation(t){this._objectRotation=t}getObjectRotation(){return this._objectRotation}updateCamera(){let{x:t,y:e}=this._domHelper.getClientDimensions();this._camera.aspect=t/e,this._camera.updateProjectionMatrix()}animateCamera(t){if(!super.animateCamera(t))return!1;let e=this._targetPosition;return!!e&&(this.getCamera().lookAt(e),!0)}_initInputListener(){this._inputListeners.push({key:3,fun:()=>{this._state=1}}),this._inputListeners.push({key:6,fun:t=>{var e,i;1!==this._state||this._locked||(this._userInteraction=!0,!(void 0!==(null===(e=t.event)||void 0===e?void 0:e.shiftKey)&&(null===(i=t.event)||void 0===i?void 0:i.shiftKey))&&this._panningEnabled&&this.disablePanning(),this._move(new THREE.Vector2(t.position.x,t.position.y),t.type))}}),this._inputListeners.push({key:11,fun:t=>{1===this._state||this._locked||(this._userInteraction=!0,this._pan(new THREE.Vector2(t.position.x,t.position.y),t.type))}}),this._inputListeners.push({key:4,fun:t=>{1===this._state&&this.dispatchEvent(2,t.type),this._state=0,this._orbitPosition=null,this._lerpEnabled=!0}}),this._inputListeners.push({key:7,fun:({event:t})=>{this._maxZoomedIn||(t&&(t.preventDefault(),t.stopPropagation()),this.zoomIn())}}),this._inputListeners.push({key:8,fun:({event:t})=>{this._maxZoomedOut||(t&&(t.preventDefault(),t.stopPropagation()),this.zoomOut())}})}_panTargetPosition(t){const e=t.clone().sub(this._orbitPosition),i=this._domHelper.element,s=this._targetPosition.project(this._camera),a=Math.max(2,4*(1-this._distance/this.maxDistance));s.x=s.x-e.x/i.clientHeight*a,s.y=s.y+e.y/i.clientHeight*a,this._targetPositionIsPanned=!0,this._targetPosition.copy(s.unproject(this._camera))}_pan(t,e){this._lerpEnabled=!1,this._orbitPosition||(this._orbitPosition=new THREE.Vector2(t.x,t.y),this.dispatchEvent(0,e)),this._panTargetPosition(t),r(this._orbitPosition,t)||this.dispatchEvent(1,e),this._orbitPosition.copy(t),this._update()}_move(t,e){this._orbitPosition||(this._orbitPosition=new THREE.Vector2(t.x,t.y),this.dispatchEvent(0,e));const i=t.clone().sub(this._orbitPosition),s=this._domHelper.element;this._panningEnabled?this._panTargetPosition(t):(this._rotateHorizontal(2*Math.PI*i.x/s.clientWidth*1),this._rotateVertical(2*Math.PI*i.y/s.clientHeight*1)),r(this._orbitPosition,t)||this.dispatchEvent(1,e),this._orbitPosition.copy(t),this._update()}zoomToFitBounds(t){if(h(t,this._boundingBox)<0)return void this.setBounds(t);this.setBounds(t);const e=t.getSize(new THREE.Vector3);if(this._initData.debug||e.x+e.y+e.z===0)return;const i=this._getCurrentCameraParameters(),s=t.getCenter(new THREE.Vector3),a=this._setDistanceAndRangesBasedOnBounds(e);this._checkZoomDistance(t,a),this._tweenCameraParameter(i,{yaw:this._yaw,pitch:this._pitch,distance:a,targetX:s.x,targetY:s.y,targetZ:s.z},!1)}updateToBounds(t,e,i=!0,s){if(this.setBounds(t),this._initData.debug)return;const a=t.getCenter(new THREE.Vector3);s?(this._targetPosition=s.clone(),this._targetPositionIsPanned=!1):this._targetPositionIsPanned||(this._targetPosition=new THREE.Vector3(a.x,a.y,a.z));const n=this._getCurrentCameraParameters(),o=t.getSize(new THREE.Vector3);if(i){const i=this._setDistanceAndRangesBasedOnBounds(o);this._distance=i,this._checkZoomDistance(t,i),this._userInteraction?this._tweenCameraParameter(n,{yaw:this._yaw,pitch:this._pitch,distance:this._distance,targetX:this._targetPosition.x,targetY:this._targetPosition.y,targetZ:this._targetPosition.z},e):this._update()}else this._setDistanceAndRangesBasedOnBounds(o,!1);this._update()}_checkZoomDistance(t,e){const i=t.getBoundingSphere(new THREE.Sphere);e-i.radius<this._zoomDistance&&(console.warn("the initial camera position is closer than the zoomDistance param, zoomDistance is set to initial camera position."),this._zoomDistance=e-i.radius)}_setDistanceAndRangesBasedOnBounds(t,e=!0){const i=this._domHelper.getClientDimensions(),s=i.x,a=i.y,n=this._camera.offset?s-s*this._camera.offset.left-s*(1-this._camera.offset.right):s,o=this._camera.offset?a-a*this._camera.offset.bottom-a*(1-this._camera.offset.top):a;this._bounds.copy(t);const{cameraSpacing:r}=this._initData;t.addScalar(r/100),this.minDistance=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);const h=Math.max(t.x,t.y),{x:d,y:l}=this._getMargin(n,o),c=_(t.x+d,t.y+l,t.z,this._camera.fov,n,o);return this._distance<c&&e&&(this._distance=c),this.maxDistance=c+h,this.maxDistance<2&&(this.maxDistance=2),this._camera.far=5*this.maxDistance,this._setCameraNear(),c}_getMargin(t,e){let i=this._bounds.x/2,s=this._bounds.y/2;return t>1080&&(i+=this._bounds.x<.3?.2:0,i+=this._bounds.x*(t/1080-1)),e>1080&&(i+=this._bounds.y<.3?.2:0,s+=this._bounds.y*(e/1080-1)),{x:i,y:s}}reset(t,e,i,s,a=!0){const o=t.getSize(new THREE.Vector3);if(o){if(e)this._targetPosition.copy(e);else{const e=t.getCenter(new THREE.Vector3);this._targetPosition.copy(e)}const r=this._getCurrentCameraParameters();if(i||(i=-30),s||(s=f),i+=d(this._objectRotation),this._initData.debug)return this._distance=this._setDistanceAndRangesBasedOnBounds(o),this._update(this._targetPosition),void this._setDistanceAndRangesBasedOnBounds(o);const h=this._setDistanceAndRangesBasedOnBounds(o),_=n(s),l=n(i);let c=this._targetPosition.clone();a?this._tweenCameraParameter(r,{yaw:l,pitch:_,distance:h,targetX:c.x,targetY:c.y,targetZ:c.z},!0):(this._pitch=_,this._yaw=l,this._distance=h,this._update(this._targetPosition))}else console.warn("you cant reset without bounds!")}updateAndReset(t,e,i,s,a,o=!0){const r=new THREE.Vector3(-t.x/2,0,-t.z/2),h=new THREE.Vector3(t.x/2,t.y,t.z/2);if(this._boundingBox=new THREE.Box3(r,h),a&&t.addScalar(a),e?this._targetPosition.copy(e):(this._targetPosition=new THREE.Vector3(0,t.y/2,0),this._targetPositionIsPanned=!1),-1===this._distance){const e=this._setDistanceAndRangesBasedOnBounds(t);this._distance=Math.max(2,e)}const _=this._getCurrentCameraParameters();i||(i=-30),s||(s=f),i+=d(this._objectRotation),this._pitch=n(s),this._yaw=n(i),this._setDistanceAndRangesBasedOnBounds(t);let l=this._targetPosition.clone();o?this._tweenCameraParameter(_,{yaw:this._yaw,pitch:this._pitch,distance:this.maxDistance,targetX:l.x,targetY:l.y,targetZ:l.z},!0):this._update(this._targetPosition)}_update(t,e){this._initData.debug?this._pitch=Math.max(n(-89),Math.min(n(89),this._pitch)):(this._yaw=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this._yaw)),this._pitch=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._pitch))),this._saveYawAndPitch();const i=new THREE.Euler(-this._pitch,this._yaw,0,"ZYX"),s=(new THREE.Quaternion).setFromEuler(i),a=new THREE.Vector3(0,0,-1);a.applyQuaternion(s),this._distance*=this._scale,this._initData.debug||(this._distance=Math.min(this.maxDistance,this._distance)),t&&this._targetPosition.copy(t);const o=this._targetPosition.clone().sub(a.multiplyScalar(this._distance));if(this._initData.debug)this._cameraPosition.copy(o),this._zoomChanged(!1,!1);else if(e)this._cameraPosition.copy(o);else{const t=this._getCameraSphere(o);null!=this._boundingBox&&this._boundingBox.intersectsSphere(t)&&this._scale>=1?this._distance+=.1:null==this._boundingBox||this._boundingBox.intersectsSphere(t)?this._zoomChanged(!1,!0):(this._cameraPosition.copy(o),this._distance===this.maxDistance?this._zoomChanged(!0,!1):this._zoomChanged(!1,!1))}this._scale=1}_zoomChanged(t,e){let i=t+""+e;0===this._currentZoomHash.length||this._currentZoomHash!==i?(this.dispatchEvent(5,new T(t,e)),this._currentZoomHash=i):t||e||this.dispatchEvent(5,new T(t,e)),this._maxZoomedIn=e,this._maxZoomedOut=t}zoomTo(t,e,i,s,a,n){return this._tweenCameraParameter(this._getCurrentCameraParameters(),{yaw:s,pitch:a,distance:2.725*_(t.x,t.y,t.z,this._camera.fov,e,i),targetX:n.x,targetY:n.y,targetZ:n.z,blockOtherTweens:!0},!0)}_getCameraSphere(t){const e=Math.max(this._bounds.x,this._bounds.y),i=Math.max(e/10,this._zoomDistance);return new THREE.Sphere(t,i)}zoomIn(t){this._lerpEnabled=!0,this._scale*=t?Math.pow(.95,t):this._zoomSpeed,this._setCameraNear(),this._update(),this.dispatchEvent(3)}zoomOut(t){this._lerpEnabled=!0,this._scale/=t?Math.pow(.95,t):this._zoomSpeed,this._setCameraNear(),this._update(),this.dispatchEvent(4)}clear(){this._userInteraction=!1,this._initData.debug||(this._distance=-1,this._targetPosition=new THREE.Vector3(0,0,0),this._targetPositionIsPanned=!1)}async moveCamera(t){return this._tweenCameraParameter(this._getCurrentCameraParameters(),t,!0)}enablePanning(){this._lerpEnabled=!1,this._panningEnabled=!0}disablePanning(){this._lerpEnabled=!1,this._panningEnabled=!1}getKernelZoomFactor(){const t=this.maxDistance;return 1-this._distance/(t-2)+.2}}t("C",M);class A{constructor(t,e){this._scene=t,e&&e.removeFromScene()}needsBounds(){return!1}updateBounds(t){}getCameraContainer(){return this._cameraContainer||(this._cameraContainer=new THREE.Object3D),this._cameraContainer}}t("L",A);const H={enable:!0,shadowMapResolution:512,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.5,darkness:.2,size:1.6,lightSolidAngle:40,yPosition:0};class k extends class{constructor(t,e){this._scene=t,e&&(e.removeFromScene(),e.cleanUp())}updateCamera(t){}reload(){this.removeFromScene(),this.addToScene()}updateBounds(t,e){this._bounds=t}cleanUp(){this._scene=null}}{constructor(t,e){super(t,e),this._pixotronGuard=new l,this._enabled=!0,this._params=Object.assign(H,{lightDirection:new THREE.Vector3(0,1,.5),onComplete:this._addGroundShadows.bind(this),onProgress:this._progressCallback.bind(this)})}_progressCallback(t){}needsBounds(){return!0}needsCamera(){return!1}needsRotation(){return!1}setPixotron(t,e,i,s){t&&(this._pixotron=t,this._renderer=e,this._camera=i,this._shadowBaker||(this._shadowBaker=new window.PIXOTRON.PlaneShadowBakePass(Object.assign(this._params,s))),this._shadowBaker.enable?this._shadowBaker.startBake(this._renderer,this._scene,this._camera):this._shadowBaker.enable=!0,this._wasAAEnabled=this._pixotron.enableAA,this._pixotronGuard.resolve())}async _addGroundShadows(){await this._pixotronGuard.wait(),this._pixotron.needsUpdate=!0,this._shadowPlane=this._shadowBaker.getShadowPlane(),this._shadowPlane.name="Shadow plane",this._shadowPlane.receiveShadow=!1,0!==this._params.yPosition&&(this._shadowPlane.position.y=this._params.yPosition),this._shadowPlane.visible=!0,this.addToScene(),this._loadedCallback&&this._loadedCallback()}setLoadedCallback(t){this._loadedCallback=t}update(){const t=this._getNumberOfChildren();this._bake(),this._sceneChildren=t}updateBounds(t,e){const i=this._getNumberOfChildren();return!(c(this._bounds,t,1e-4)&&this._scene&&i===this._sceneChildren&&!e||(super.updateBounds(t),this._bake(),this._sceneChildren=i,0))}_bake(){this._pixotronGuard.wait().then(()=>{this._shadowPlane&&(this._shadowPlane.visible=!1),this._shadowBaker.startBake(this._renderer,this._scene,this._camera)})}_getNumberOfChildren(){let t=0;return this._scene.traverse(e=>{"Shadow plane"!==e.name&&t++}),t}addToScene(){this._scene&&this._shadowPlane&&this._enabled&&(this._shadowPlane.material.needsUpdate=!0,u(this._shadowPlane),this._scene.add(this._shadowPlane))}removeFromScene(){this._shadowPlane&&(this._scene.remove(this._shadowPlane),this._pixotron&&(this._pixotron.enableAA=this._wasAAEnabled))}enable(){this._enabled=!0,this.addToScene()}disable(){this._enabled=!1,this.removeFromScene()}showGUI(){}}t("B",k);class L{constructor(t){this._innerSize=1,this._outerSize=100,this._plane=new THREE.Object3D,this._plane.rotation.x=-Math.PI/2;const e=new THREE.MeshStandardMaterial;this._innerPlaneMesh=new THREE.Mesh,this._innerPlaneMesh.layers.set(2),this._innerPlaneMesh.material=e,this._innerPlaneMesh.receiveShadow=!0,this._outerPlaneMesh=new THREE.Mesh,this._outerPlaneMesh.layers.set(2),this._outerPlaneMesh.material=e,this._outerPlaneMesh.receiveShadow=!0,this._plane.add(this._innerPlaneMesh),this._plane.add(this._outerPlaneMesh),this._innerSize=1,this._outerSize=t,this._updatePlane(this._innerSize,this._outerSize)}getRootNode(){return this._plane}getInnerPlane(){return this._innerPlaneMesh}getOuterPlane(){return this._outerPlaneMesh}updateSize(t){this._innerSize=t,this._updatePlane(this._innerSize,this._outerSize)}_updatePlane(t,e){const i=new THREE.Shape;i.moveTo(-t/2,-t/2),i.lineTo(-t/2,t/2),i.lineTo(t/2,t/2),i.lineTo(t/2,-t/2),i.lineTo(-t/2,-t/2);const s=new THREE.Shape;s.moveTo(-e/2,-e/2),s.lineTo(-e/2,e/2),s.lineTo(e/2,e/2),s.lineTo(e/2,-e/2),s.lineTo(-e/2,-e/2);const a=new THREE.Path;a.moveTo(-t/2,-t/2),a.lineTo(-t/2,t/2),a.lineTo(t/2,t/2),a.lineTo(t/2,-t/2),a.lineTo(-t/2,-t/2),s.holes.push(a);const n=new THREE.ShapeBufferGeometry(i);this._innerPlaneMesh.geometry&&this._innerPlaneMesh.geometry.dispose(),this._innerPlaneMesh.geometry=n;const o=new THREE.ShapeBufferGeometry(s);this._outerPlaneMesh.geometry&&this._outerPlaneMesh.geometry.dispose(),this._outerPlaneMesh.geometry=o;const r=n.attributes.uv.clone();n.setAttribute("uv2",r);const h=n.attributes.uv2.array;for(let t=0;t<h.length;++t)h[t]+=.5}}let z=t("F",(()=>{class t extends k{constructor(t,e,i){super(t,e),this._longestSide=2,this._bakedShadowPlane=new L(100),this._fog=i||!1,this._textureLoader=new THREE.TextureLoader,this.addToScene()}needsBounds(){return!0}needsCamera(){return this._fog}needsRotation(){return!1}updateBounds(t){return super.updateBounds(t),this._longestSide=Math.max(t.x,t.z),this._update(),!0}updateCamera(t){this._cameraDistance=t.position.distanceTo(new THREE.Vector3(0,0,0)),this._update()}_update(){this._fog&&this._updateFog()}_updateFog(){let t=this._longestSide/2;this._scene.fog=new THREE.Fog(16185078,this._cameraDistance+t+3,this._cameraDistance+t+3+1),this._scene.background=new THREE.Color(16185078)}_updateFloor(){if(this._floorMaterial)this._bakedShadowPlane.getOuterPlane().material=this._floorMaterial,this._bakedShadowPlane.getInnerPlane().material=this._floorMaterial;else{let t=this._width/1e3,e=this._height/1e3;this._repeatable&&(this._floorTexture.wrapS=THREE.RepeatWrapping,this._floorTexture.wrapT=THREE.RepeatWrapping,this._floorTexture.repeat.set(100/t,100/e));let i=new THREE.MeshStandardMaterial({map:this._floorTexture,side:THREE.DoubleSide});this._bakedShadowPlane.getInnerPlane().material=i,this._bakedShadowPlane.getOuterPlane().material=i}}addToScene(){this._scene&&(this._shadowPlane&&(this._bakedShadowPlane.updateSize(this._shadowPlane.scale.x),this._bakedShadowPlane.getRootNode().position.copy(this._shadowPlane.position),this._bakedShadowPlane.getInnerPlane().material.aoMap=this._shadowPlane.material.aoMap),this._scene.add(this._bakedShadowPlane.getRootNode()))}removeFromScene(){this._scene.remove(this._bakedShadowPlane.getRootNode())}setFloorMaterial(t,e,i,s){return this._width=e,this._height=i,this._repeatable=s,this._floorPromise=new Promise((e,i)=>{this._textureLoader.load(t,t=>{this._floorTexture=t,e()},null,i)}),new Promise((t,e)=>{this._floorPromise.then(()=>{this._updateFloor(),this._update(),t()},e)})}changeFloorMaterial(t,e){this._floorPromise=new Promise((i,s)=>{this._floorMaterial=m(t,this._environmentLoader),this._rapiAccess.getTexturesOf(t).then(t=>{if(t.length>0){let a=[];t.forEach(t=>{a.push(p(this._dataSyncer.requestAsset(t.image,!0),t,this._floorMaterial,e,1,1))}),Promise.all(a).then(()=>{setTimeout(()=>i(),0)},s)}else setTimeout(()=>i(),0)})});let i=[this._floorPromise];return new Promise((t,e)=>{Promise.all(i).then(()=>{this._updateFloor(),this._update(),t()},e)})}showGUI(){this._floorMaterial?this._addGUI():this._floorPromise&&this._floorPromise.then(()=>this._addGUI())}_addGUI(){let t=g();if(!t)return;let e=t.addFolder("Floor");e.add(this._floorMaterial,"roughness").min(0).max(1).step(.01),e.add(this._floorMaterial,"reflectivity").min(0).max(1).step(.01),e.add(this._floorMaterial,"clearCoat").min(0).max(1).step(.01),e.add(this._floorMaterial,"clearCoatRoughness").min(0).max(1).step(.01),e.add(this._floorMaterial,"opacity").min(0).max(1).step(.01),e.add(this._floorMaterial,"metalness").min(0).max(1).step(.01),e.add(this._floorMaterial,"bumpScale").min(0).max(1).step(.01)}}return i([s],t.prototype,"_rapiAccess",void 0),i([s],t.prototype,"_dataSyncer",void 0),i([s],t.prototype,"_environmentLoader",void 0),t})());class I extends k{constructor(t,e,i,s,a){if(super(t,e),this._color=i,this._oldBackground=t.background,s&&a){this._canvas=s,this._style=document.createElement("style");let t='background-image: url("'+a+'"); background-size: cover;';this._style.innerText=".rml-scene-background {"+t+"}",this._canvas.appendChild(this._style)}}needsBounds(){return!0}needsCamera(){return!1}needsRotation(){return!1}addToScene(){super.addToScene(),this._scene&&this._color&&(this._scene.background=this._color),this._canvas&&this._canvas.classList&&(this._scene.background=null,this._canvas.classList.add("rml-scene-background"),this._pixotron&&(this._pixotron.enableAA=!1))}removeFromScene(){super.removeFromScene(),this._oldBackground&&(this._scene.background=this._oldBackground),this._canvas&&this._canvas.classList.remove("rml-scene-background")}}t("b",I);class D extends R{constructor(t,e,i,s){super(t,e,i),this._scale=1,this._cameraZoom=1,this._state=0,this._size=5,this._lastPosition=new THREE.Vector2,this._zoomPosition=new THREE.Vector3,this._lastZoom=0,this._zoomSpeed=Math.pow(.95,2),s?(this._camera=s,this._cameraPosition=(new THREE.Vector3).copy(this._camera.position)):this._initCamera(i||new THREE.Vector3(0,10,0))}_getCamera(){return this._camera||this._initCamera(new THREE.Vector3(0,10,0)),this._camera}_initCamera(t){let{x:e,y:i}=this._domHelper.getClientDimensions(),s=e/i*this._size,a=this._size;this._camera=new THREE.OrthographicCamera(s/-2,s/2,a/2,a/-2,1,1e3),this._camera.position.copy(t),this._cameraPosition=t,this._camera.lookAt(new THREE.Vector3(0,0,0))}updateCamera(){let{x:t,y:e}=this._domHelper.getClientDimensions(),i=t/e*this._size,s=this._size;this._camera.left=i/-2,this._camera.right=i/2,this._camera.top=s/2,this._camera.bottom=s/-2,this._camera.updateProjectionMatrix()}_initInputListener(){this._inputListeners.push({key:3,fun:t=>{this._locked||(this._state=1,this._lastPosition.set(t.positionRelative.x,t.positionRelative.y),this.dispatchEvent(0))}}),this._inputListeners.push({key:6,fun:t=>{1!==this._state||this._locked||(this._move(new THREE.Vector2(t.positionRelative.x,t.positionRelative.y),t.type),this.dispatchEvent(1))}}),this._inputListeners.push({key:4,fun:t=>{1===this._state&&this.dispatchEvent(2),this._state=0}}),this._inputListeners.push({key:7,fun:t=>{t.event&&(t.event.stopPropagation(),t.event.preventDefault()),this.dispatchEvent(3),this._scale/=this._zoomSpeed,this._zoomTo(t.positionRelative),this._update()}}),this._inputListeners.push({key:8,fun:t=>{t.event&&(t.event.stopPropagation(),t.event.preventDefault()),this.dispatchEvent(4),this._scale*=this._zoomSpeed,this._zoomTo(t.positionRelative),this._update()}})}_zoomTo(t){if(Date.now()-this._lastZoom>200){let e=new THREE.Vector3(t.x,t.y,0);e.unproject(this._camera),this._zoomPosition.copy(e)}this._lastZoom=Date.now()}_move(t,e){let i=new THREE.Vector3,s=new THREE.Vector3(this._lastPosition.x,this._lastPosition.y,0),a=new THREE.Vector3(t.x,t.y,0);s.unproject(this._camera),a.unproject(this._camera),i.subVectors(a,s),this._cameraPosition.x-=i.x*(2===e?1.1:1),this._cameraPosition.z-=i.z*(2===e?1.1:1),this._lastPosition.copy(t)}zoomToFitBounds(t,e,i){if(h(t,this._boundingBox)<0&&!i)return void this.setBounds(t);this.setBounds(t),t.expandByScalar(1.2);const s=t.getSize(new THREE.Vector3),a=t.getCenter(new THREE.Vector3),n=s.x/-2/this._camera.left,o=s.z/-2/this._camera.bottom,r=1/Math.max(n,o);(r<this._cameraZoom||e)&&(this._scale=r,this._cameraZoom=r,this._cameraPosition.x=a.x,this._cameraPosition.z=a.z)}_update(t){this._scale=Math.min(this._scale,5),this._scale=Math.max(this._scale,.2);let e=(new THREE.Vector3).subVectors(this._zoomPosition,this._cameraPosition).multiplyScalar((this._scale-this._cameraZoom)/this._scale);this._cameraPosition.x+=e.x,this._cameraPosition.z+=e.z,this._cameraZoom!==this._scale&&this.dispatchEvent(5,new T(.2===this._scale,5===this._scale)),this._cameraZoom=this._scale,this._camera.updateProjectionMatrix()}animateCamera(t){if(!super.animateCamera(t)&&Math.abs(this._cameraZoom-this._camera.zoom)<=.01)return!1;const e=Math.min(10*t,1);return this._camera.zoom=THREE.MathUtils.lerp(this._camera.zoom,this._cameraZoom,e),!0}getKernelZoomFactor(){return this._camera.zoom}}t("d",D);const B=Math.PI/4;class O extends R{constructor(t,e,i,s){super(t,e,i),this._state=0,this._rotationSpeed=1,this._keyMap=new Map,this.minPolarAngle=n(-60),this.maxPolarAngle=n(60),this._camera=s||new THREE.PerspectiveCamera,this._camera.fov=70,this._camera.aspect=this._width/this._height,this._camera.near=.1,this._camera.far=100,this._camera.updateProjectionMatrix(),this._camera.layers.set(3),this._camera.layers.enable(1),this._camera.layers.enable(2),this._camera.layers.enable(6),this._camera.layers.enable(5),i?this._camera.position.set(i.x,1.5,i.z):this._camera.position.set(0,1.5,0),this._cameraPosition=new THREE.Vector3,this._cameraPosition.copy(this._camera.position),this._cameraRotation=new THREE.Quaternion,this._pitch=0,this._yaw=0;let a=new THREE.Euler(-this._pitch,this._yaw,0,"ZYX");this._cameraRotation.setFromEuler(a),window.addEventListener("gamepadconnected",this._gamepadConnected.bind(this)),window.addEventListener("gamepaddisconnected",this._gamepadDisconnected.bind(this))}_gamepadConnected(t){this.startButtonPressListener()}_gamepadDisconnected(t){window.cancelAnimationFrame(this._listenerLoopAnimationFrame)}startButtonPressListener(){this._listenerLoopAnimationFrame=window.requestAnimationFrame(()=>{this.buttonPressListener()})}buttonPressListener(){let t=navigator.getGamepads()[0];this._checkRightStick(t),this._checkLeftStick(t),this._checkButtons(t),this._processKeyMap(this._keyMap,.001),this.startButtonPressListener()}_checkRightStick(t){let e=t.axes[2],i=t.axes[3];Math.abs(e)>.2&&(this._rotateHorizontal(.01*B*e),this._update(),this.dispatchEvent(1)),Math.abs(i)>.2&&(this._rotateVertical(.01*B*i),this._update(),this.dispatchEvent(1))}_checkLeftStick(t){let e=t.axes[0],i=t.axes[1];Math.abs(i)>.2?i<0?this._keyMap.set(87,!0):this._keyMap.set(83,!0):t.buttons&&t.buttons[12]&&t.buttons[12].pressed?this._keyMap.set(87,!0):t.buttons&&t.buttons[13]&&t.buttons[13].pressed?this._keyMap.set(83,!0):(this._keyMap.set(87,!1),this._keyMap.set(83,!1)),Math.abs(e)>.2?e<0?this._keyMap.set(65,!0):this._keyMap.set(68,!0):(this._keyMap.set(65,!1),this._keyMap.set(68,!1))}_checkButtons(t){t.buttons&&t.buttons[6]&&t.buttons[6].pressed?this._keyMap.set(16,!0):this._keyMap.set(16,!1),t.buttons&&t.buttons[14]&&t.buttons[14].pressed?(this._keyMap.set(37,!0),this.dispatchEvent(1)):this._keyMap.set(37,!1),t.buttons&&t.buttons[15]&&t.buttons[15].pressed?(this._keyMap.set(39,!0),this.dispatchEvent(1)):this._keyMap.set(39,!1)}animateCamera(t){let e=this._cameraPosition,i=this._cameraRotation,s=this.getCamera(),a=o(e,s.position),n=w(i,s.quaternion);if(!e||a&&n)return!1;let r=this.getCamera().position.clone(),h=Math.min(10*t,1);r.lerp(e,h),this.getCamera().position.copy(r);let _=this.getCamera().quaternion.clone(),d=Math.min(5*t,1);_.slerp(i,d),this.getCamera().setRotationFromQuaternion(_);let l=!1;return this._keyMap.forEach(t=>{t&&(l=!0)}),l&&this._processKeyMap(this._keyMap,t),!0}_getCamera(){return this._camera}_initInputListener(){window.addEventListener("keyup",this._onKeyChanged.bind(this),!1),window.addEventListener("keydown",this._onKeyChanged.bind(this),!1),this._inputListeners.push({key:3,fun:t=>{this._down(t)}}),this._inputListeners.push({key:6,fun:t=>{this._move(t)}}),this._inputListeners.push({key:4,fun:t=>{this._up(t)}})}_down(t){this._downPosition=t.position,this._position=t.position,this._state=1,2===t.type&&window.setTimeout(this._onLongDown.bind(this),350),2===t.type?this._rotationSpeed=.6:this._rotationSpeed=1}_move(t){this._position=t.position,1!==this._state||this._locked||this._orbit(new THREE.Vector2(t.position.x,t.position.y)),2!==this._state||this._locked||(this._orbit(new THREE.Vector2(t.position.x,t.position.y)),this._moveForward())}_up(t){1===this._state&&this.dispatchEvent(2),2===this._state&&this._keyMap.set(87,!1),this._state=0,this._orbitPosition=null}_onLongDown(){y(this._downPosition,this._position)<E&&1===this._state&&(this._state=2,this._orbit(new THREE.Vector2(this._position.x,this._position.y)),this._moveForward())}_update(t){let e=new THREE.Euler(-this._pitch,this._yaw,0,"ZYX");this._cameraRotation.setFromEuler(e)}updateCamera(){let{x:t,y:e}=this._domHelper.getClientDimensions();this._camera.aspect=t/e,this._camera.updateProjectionMatrix()}_onKeyChanged(t){this._keyMap.set(t.keyCode,"keydown"===t.type),this.dispatchEvent(6),this._processKeyMap(this._keyMap,.001)&&t.preventDefault()}_processKeyMap(t,e){e=Math.min(e,.1);let i=new THREE.Vector3(0,0,0),s=!1;return this._processUpDown(t,i,e),t.get(65)&&(i.x=-1*e),t.get(68)&&(i.x=1*e),t.get(37)&&(this._rotateHorizontal(-B*this._rotationSpeed*e),s=!0),t.get(39)&&(this._rotateHorizontal(B*this._rotationSpeed*e),s=!0),t.get(16)&&(i.x*=3,i.z*=3),!(0===i.x&&0===i.y&&0===i.z&&!s||(i.applyQuaternion(this.getCamera().quaternion),this._cameraPosition.add(new THREE.Vector3(i.x,0,i.z)),this._update(),0))}_processUpDown(t,e,i){(t.get(87)||t.get(38))&&(e.z=-1*i),(t.get(83)||t.get(40))&&(e.z=1*i)}_orbit(t){this._orbitPosition||(this._orbitPosition=new THREE.Vector2(t.x,t.y),this.dispatchEvent(0));let e=t.clone().sub(this._orbitPosition),i=this._domHelper.element instanceof Document?this._domHelper.element.body:this._domHelper.element;e.multiplyScalar(-1),this._rotateHorizontal(2*Math.PI*e.x/i.clientWidth*1),this._rotateVertical(2*Math.PI*e.y/i.clientHeight*1),r(this._orbitPosition,t)||this.dispatchEvent(1),this._orbitPosition.copy(t),this._update()}_moveForward(){this._keyMap.set(87,!0),this._processKeyMap(this._keyMap,.001)}_rotateVertical(t){let e=this._pitch+t;e>this.maxPolarAngle||e<this.minPolarAngle||(this._pitch=e,this._pitch<-Math.PI?this._pitch+=2*Math.PI:this._pitch>Math.PI&&(this._pitch-=2*Math.PI),this._saveYawAndPitch())}getKernelZoomFactor(){return this._camera.zoom}}t("e",O);let Q=(()=>{class t{parse(t,e,i,s){let a=JSON.parse(s);return a.environment?this.load(t,e,i,a):null}load(t,e,i,s){let a,n=s.environment;if(!n)return console.warn("No environment set in scene settings"),Promise.resolve(null);switch(n.type){case"color":a=new Promise(e=>e(new I(t,i,new THREE.Color(n.details.color))));break;case"image":a=new Promise(s=>s(new I(t,i,null,e,n.details.imageUrl)));break;case"floor":a=new Promise(e=>{this._rapiAccess.getMaterial(n.details.material).then(s=>{let a=void 0===n.details.fog||n.details.fog,o=new z(t,i,a);o.changeFloorMaterial(s).then(()=>{e(o)})})});break;case"baked_shadow":a=new Promise(s=>{n.details&&n.details.color?s(new I(t,i,new THREE.Color(n.details.color))):n.details&&n.details.imageUrl?s(new I(t,i,null,e,n.details.imageUrl)):s(new k(t,i))});break;default:console.warn("Could not load environment, return old environment"),a=new Promise(t=>t(i))}return a}}return i([s],t.prototype,"_rapiAccess",void 0),t})(),F=(()=>{class t extends A{constructor(t,e){super(t,e),this._lights=[]}needsBounds(){return!0}updateBounds(t){if(this._cameraLight){const e=this._cameraLight,i=new THREE.Vector3;t.getSize(i);const s=1.5*Math.max(Math.max(i.x,i.y),i.z);this._boundingSize=s,e.shadow.camera.top=s/2,e.shadow.camera.bottom=-s/2,e.shadow.camera.left=-s/2,e.shadow.camera.right=s/2,e.shadow.camera.updateProjectionMatrix()}}loadFromJSON(t){return new Promise(e=>{this._lights=this._dynamicLightSettingLoader.parse(t),this.addToScene(),e()})}loadFromObject(t){return new Promise(e=>{t.lights||e(),this._lights=this._dynamicLightSettingLoader.load(t),this._lights.forEach((t,e)=>{t.userData.movesWithCamera&&(this._cameraLight=t,this._lights.splice(e,1))}),this.addToScene(),e()})}loadFromURL(t){return new Promise((e,i)=>{fetch(new Request(t,{method:"GET"})).then(C).then(t=>this.loadFromObject(t).then(e,i))})}addToScene(){this._lights.forEach(t=>{this._scene.add(t)}),this._cameraLight&&this._scene.add(this._cameraLight)}update(t,e){if(!this._cameraLight)return;let i=new THREE.Vector3;t.getWorldDirection(i),i.multiplyScalar(-this._boundingSize);let s=e.clone().add(i);this._cameraLight.position.copy(s)}removeFromScene(){this._lights.forEach(t=>{this._scene.remove(t)}),this._cameraLight&&this._scene.remove(this._cameraLight)}reload(){this.removeFromScene(),this.addToScene()}showGUI(){let t=g();this._cameraLight&&this._addToGUI(t,this._cameraLight),this._lights.forEach(e=>{this._addToGUI(t,e)})}_addToGUI(t,e){t&&(e instanceof THREE.SpotLight&&this._addSpotLightToGUI(t,e),e instanceof THREE.AmbientLight&&this._addAmbientLightToGUI(t,e),e instanceof THREE.DirectionalLight&&this._addDirectionalLightToGUI(t,e),e instanceof THREE.RectAreaLight&&this._addRectAreaLightToGUI(t,e))}_addRectAreaLightToGUI(t,e){let i=t.addFolder(e.name),s={name:e.name,color:"#"+e.color.getHexString(),intensity:e.intensity*(e.width*e.height)};i.add(e,"visible"),i.add(s,"intensity").min(10).max(400).step(10).onChange(t=>{e.intensity=t/(e.width*e.height)}),i.add(e,"castShadow"),i.addColor(s,"color").onChange(t=>{e.color=new THREE.Color(t)}),i.add(e.position,"x").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"y").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"z").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))})}_addSpotLightToGUI(t,e){let i=t.addFolder(e.name),s={name:e.name,color:"#"+e.color.getHexString(),angle:180*e.angle/Math.PI};i.add(e,"visible"),i.add(e,"intensity").min(0).max(5).step(.1),i.add(e,"penumbra").min(0).max(1).step(.1),i.addColor(s,"color").onChange(t=>{e.color=new THREE.Color(t)}),i.add(s,"angle").min(10).max(180).step(1).onChange(t=>{e.angle=t*Math.PI/180}),i.add(e.position,"x").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"y").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"z").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))})}_addAmbientLightToGUI(t,e){let i={name:e.name,color:"#"+e.color.getHexString()},s=t.addFolder(e.name);s.add(e,"visible"),s.add(e,"intensity").min(0).max(5).step(.1),s.addColor(i,"color").onChange(t=>{e.color=new THREE.Color(t)})}_addDirectionalLightToGUI(t,e){let i=t.addFolder(e.name),s={name:e.name,color:"#"+e.color.getHexString()};i.add(e,"visible"),i.add(e,"intensity").min(0).max(5).step(.1),i.addColor(s,"color").onChange(t=>{e.color=new THREE.Color(t)}),i.add(e,"castShadow"),i.add(e.position,"x").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"y").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"z").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))})}}return i([s],t.prototype,"_dynamicLightSettingLoader",void 0),t})();class V{constructor(){this._settings=new window.PIXOTRON.QualitySettings(5),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!0,this._settings.useHDREnv=!0,this._settings.useGBuffer=!0,this._settings.ssr=!0,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!0},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class U{constructor(){this._settings=new window.PIXOTRON.QualitySettings(4),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!0,this._settings.useHDREnv=!0,this._settings.useGBuffer=!0,this._settings.ssr=!0,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!0},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class G{constructor(){this._settings=new window.PIXOTRON.QualitySettings(3),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!0,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!0},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class j{constructor(){this._settings=new window.PIXOTRON.QualitySettings(2),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!1,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!1},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class N{constructor(){this._settings=new window.PIXOTRON.QualitySettings(1),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!1,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!1,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!1},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class Z{constructor(){this._settings=new window.PIXOTRON.QualitySettings(0),this._settings.enableAA=!1,this._settings.useAreaLight=!1,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!1,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!1,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!1},this._settings.shadowQualitySettings={enabled:!1,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class W{constructor(t){this._sceneBoundingSphere=new THREE.Sphere,this._pixotron=t,this._initializeQualitySettings(),this._initializeQualityAdapters()}getPixotronInstance(t){const e={saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,bias:.02,accumulative:!1},shadowparams:{shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.05,nearPlane:.01,farPlane:50,fov:40,numSamples:100,side:THREE.FrontSide}};return t=t||e,new window.PIXOTRON.Pixotron(t)}showGUI(){let t=g();if(!t)return;let e=t.addFolder("Renderer");e.add(this._pixotron.getSAOPass(),"enabled"),this._pixotron.getSAOPass().smoothTransition&&e.add(this._pixotron.getSAOPass(),"smoothTransition"),e.add(this._pixotron.getSAOPass(),"occlusionWorldRadius").min(0).max(1).step(1e-4).onChange(t=>{this._adjustSaoRadius(t)}),e.add(this._pixotron.getSAOPass(),"intensity").min(.1).max(2).step(.05),e.add(this._pixotron.getSAOPass(),"bias").min(0).max(1).step(1e-4).onChange(t=>{this._adjustSaoBias(t)}),this._pixotron.getSAOPass().numSamples&&e.add(this._pixotron.getSAOPass(),"numSamples").min(10).max(3e3).step(10),void 0!==this._pixotron.getShadowPass().enabled&&e.add(this._pixotron.getShadowPass(),"enabled"),e.add(this._pixotron.getShadowPass(),"smoothTransition"),e.add(this._pixotron.getShadowPass(),"enableAccumulation"),e.add(this._pixotron.getShadowPass(),"shadowRadius").min(0).max(5).step(.1),e.add(this._pixotron.getShadowPass(),"shadowBiasMultiplier").min(0).max(3).step(.01),e.add(this._pixotron.getShadowPass(),"numSamples").min(10).max(3e3).step(10)}updateBounds(t){this._sceneBoundingSphere.copy(t);const e=.25*this._getMaxSaoRadius();this._adjustSaoRadius(e);const i=2*this._getMinSaoBias();this._adjustSaoBias(i)}_getSaoRadius(){return this._sceneBoundingSphere.radius}_adjustSaoRadius(t){const e=this._pixotron.getSAOPass(),i=this._getMinSaoRadius(),s=this._getMaxSaoRadius();e.occlusionWorldRadius=Math.min(Math.max(t,i),s)}_adjustSaoBias(t){const e=this._pixotron.getSAOPass(),i=this._getMinSaoBias(),s=this._getMaxSaoBias();e.bias=Math.min(Math.max(t,i),s)}_getMinSaoRadius(){return.001*this._getSaoRadius()}_getMaxSaoRadius(){return.6*this._getSaoRadius()}_getMinSaoBias(){return.001*this._getSaoRadius()}_getMaxSaoBias(){return.01*this._getSaoRadius()}updatePixelRatio(t){const e=new THREE.Vector2;t.getDrawingBufferSize(e),this._pixotron.setSize(Math.floor(e.width),Math.floor(e.height))}getHighPixelRatioQualitySetting(){return this._highPixelRatioQualitySetting.getSettings()}getLowestQualitySetting(){return this._lowQualitySetting.getSettings()}_initializeQualitySettings(){this._highestQualitySetting=new U,this._highPixelRatioQualitySetting=new V,this._highQualitySetting=new G,this._midQualitySetting=new j,this._lowQualitySetting=new N,this._lowestQualitySetting=new Z}_initializeQualityAdapters(){this._autoQualityAdapter=new window.PIXOTRON.AutoQualityAdapter(this._pixotron),this._autoQualityAdapter.addQuality(this._highestQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._highQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._midQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._lowQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._lowestQualitySetting.getSettings()),this._autoQualityAdapter.setDesiredFps(20),this._manualQualityAdapter=new window.PIXOTRON.ManualQualityAdapter(this._pixotron)}onAutoQualityChange(t){this._autoQualityAdapter.onQualityChange(t)}onManualQualityChange(t){this._manualQualityAdapter.onQualityChange(t)}getAutoAdapter(){return this._autoQualityAdapter}lockAdapter(){this._autoQualityAdapter.getCurrentQualitySetting().lock()}unLockAdapter(){this._autoQualityAdapter.getCurrentQualitySetting().unLock()}enablePixotronAutoQuality(){this._currentQualityAdapter||(this._currentQualityAdapter=this._autoQualityAdapter,this._pixotron.setQualityAdapter(this._autoQualityAdapter))}movingCameraStarts(){this._currentQualityAdapter&&(this._currentQualityAdapter=this._autoQualityAdapter,this._currentQualitySetting&&(this._manualQualityAdapter.setQualitySetting(this._currentQualitySetting),this._pixotron.setQualityAdapter(this._manualQualityAdapter)),this._pixotron.setQualityAdapter(this._autoQualityAdapter))}movingCameraStops(){this._currentQualityAdapter&&(this._currentQualitySetting=this._currentQualityAdapter.getCurrentQualitySetting(),this._currentQualityAdapter=this._manualQualityAdapter,this._pixotron.setQualityAdapter(this._manualQualityAdapter),this._manualQualityAdapter.setQualitySetting(this._highestQualitySetting.getSettings()))}}t("S",(()=>{class t{constructor(t,e,i,s="3D"){this._depthWriteMaterial=new THREE.MeshBasicMaterial({colorWrite:!1}),this._maxAnisotropy=1,this._clock=new THREE.Clock,this._delta=0,this._renderListener=null,this._stopRendering=!1,this._forceRender=!1,this._updateShadowsAndAO=!0,this._lastChange=Date.now(),this._running=!1,this._onAfterRender=()=>{},this._creator_=t,this._canvasID=i,this.createCameraControl(s,e),this._setupScene(e,!1),this._lifeCycleManager.addEventListener(this)}onBeforeRender(){}_changeCameraControl(t){this._cameraControl&&this._cameraControl.cleanUp(),t instanceof O&&(this._getInputManager().removeEventListener(7,this._renderListener),this._getInputManager().removeEventListener(8,this._renderListener)),this._cameraControl instanceof O&&(this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this)),(t instanceof D||t instanceof O)&&this._environment instanceof k&&this._environment.disable(),t instanceof M&&this._environment instanceof k&&this._environment.enable(),this._cameraControl=t,this.cameraControlChanged()}cameraControlChanged(){}_addCameraControlListener(){this._cameraControl.addEventListener(0,this._requestRender,this),this._cameraControl.addEventListener(1,this._requestRender,this),this._cameraControl.addEventListener(2,this._requestRender,this),this._cameraControl.addEventListener(6,this._requestRender,this)}_renderEverything(){this._pixotron&&(this._forceRender=!0,this._updateShadowsAndAO=!0),this._requestRender()}_renderWithoutShadowsAndAO(){this._pixotron&&(this._forceRender=!0,this._updateShadowsAndAO=!1),this._requestRender()}_requestRender(){if(!this._renderer||this._stopRendering)return;const t=()=>{var e;this._delta=this._clock.getDelta(),this._animateCamera(),this._cameraControl.getCamera().layers.mask=65535,null===(e=this._statsHelper)||void 0===e||e.updateRenderInfo(this._renderer.info),this._renderLoopFunction&&(this._renderLoopFunction(),this._renderLoopFunction=null),this.onBeforeRender(),this._pixotron&&(this._pixotron.autoShadowsClear=this._updateShadowsAndAO,this._pixotron.autoSAOClear=this._updateShadowsAndAO,this._forceRender&&(this._pixotron.needsUpdate=!0),this._pixotron.render(this._renderer,this._scene,this._cameraControl.getCamera(),this._renderTarget),this._forceRender=!1,this._updateShadowsAndAO=!0,this._pixotron.blit(),this._shouldRenderUi()&&this._renderUi()),this._onAfterRender(),window.TWEEN&&TWEEN.update(),this._lastChange+3e3<Date.now()||this._stopRendering?this._running=!1:(this._running=!0,requestAnimationFrame(t))};this._lastChange=Date.now(),this._running||this._stopRendering||(this._running=!0,requestAnimationFrame(t))}_shouldRenderUi(){return this._pluginSystem&&this._pluginSystem.needsUiScene()}_renderUi(){const t=this._scene.background?this._scene.background.clone():null;this._scene.overrideMaterial=this._depthWriteMaterial,this._scene.background=null,this._renderer.render(this._scene,this._cameraControl.getCamera()),this._scene.overrideMaterial=null;const e=this._renderer.autoClear;this._renderer.autoClear=!1,this._renderer.clearDepth(),this._renderer.render(this._uiScene,this._cameraControl.getCamera()),this._renderer.autoClear=e,this._scene.background=t}_animateCamera(){this._cameraControl&&(!this._cameraControl.animateCamera(this._delta)&&this.shouldClearShadowsAndAO()&&this._pixotron&&!this._forceRender?(this._pixotron.autoShadowsClear=!1,this._pixotron.autoSAOClear=!1):(this._lightSetting instanceof F&&this._cameraControl.getCamera()instanceof THREE.PerspectiveCamera&&this._lightSetting.update(this._cameraControl.getCamera(),this._cameraControl.getTargetPosition()),this._pixotron&&(this._pixotron.needsUpdate=!0))),this._environment&&this._environment.needsCamera()&&this._cameraControl instanceof M&&this._environment.updateCamera(this._cameraControl.getCamera())}shouldClearShadowsAndAO(){return!1}_setupScene(t,e){const{x:i,y:s}=this._domHelper.getClientDimensions();this._scene=new THREE.Scene,this._uiScene=new THREE.Scene,(e=e||!1)||(this._scene.background=new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND));const a={format:THREE.RGBAFormat,minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter},n=THREE.sRGBEncoding,o=Math.floor(i*window.devicePixelRatio),r=Math.floor(s*window.devicePixelRatio);this._renderTarget=new THREE.WebGLRenderTarget(o,r,a),this._renderTarget.texture.encoding=n,this._renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(i,s),this._renderer.outputEncoding=THREE.sRGBEncoding,this._renderer.autoClear=!1,this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=THREE.PCFSoftShadowMap,this._maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._renderer.domElement.classList.add(this._canvasID),this._domHelper.element.appendChild(this._renderer.domElement),this._getInputManager().addEvents(this._renderer.domElement),this._environmentLoader.setRendererAndScene(this._renderer,this._scene),this._environmentLoader.registerEnvironmentChangedCallback(()=>this._requestRender()),this._requestRender(),window.addEventListener("resize",this,!1),window.addEventListener("keydown",this,!1),window.addEventListener("keyup",this,!1),document.addEventListener("visibilitychange",this),this._pluginSystem.init(this._scene,this._uiScene,this._cameraControl.getCamera().position),this._addCameraControlListener(),this.sceneChanged()}_tabVisible(){this.updateCamera(!1)}updateCamera(t=!0){const{x:e,y:i}=this._domHelper.getClientDimensions();this._renderer.setSize(e,i);const s=this._renderer.getPixelRatio();if(this._renderTarget){const t=Math.floor(e*s),a=Math.floor(i*s);this._renderTarget.setSize(t,a)}if(this._pixotron)try{this._pixotron.setSize(e,i)}catch(t){console.warn(t)}this._cameraControl.updateCamera(),this._renderEverything()}_onWindowResize(){const t=this._getInputManager();t&&t.updateSize(),this.updateCamera(),this._requestRender()}_isPartOfScene(t){return"Object3D"===t.type||"Mesh"===t.type||"GLB"===t.type||"GLTF"===t.type||"Group"===t.type}cleanUp(){this._getInputManager().removeEventListener(7,this._renderListener),this._getInputManager().removeEventListener(8,this._renderListener),this._cameraControl&&this._cameraControl.cleanUp(),this._stopRendering=!0}clearScene(){let t=[];this._scene.children.forEach(e=>{this._isPartOfScene(e)&&t.push(e)}),t.forEach(t=>{S(t),this._scene.remove(t)}),this._renderer.renderLists.dispose()}enableHD(t){this._renderer.capabilities.maxTextures>8&&t&&this.loadDynamicLightSetting(t),this._pixotron=new window.PIXOTRON.Pixotron(this.getPixotronParams()),this._pixotron.enableAA=!1,this._pixotronUtil=new W(this._pixotron),this._initData.autoQuality&&this._enableAutoQuality(),this._environment instanceof k&&(this._environment.setPixotron(this._pixotron,this._renderer,this._cameraControl.getCamera(),this.getBakedShadowParams()),this._environment.setLoadedCallback(()=>setTimeout(()=>this._requestRender(),500))),this._requestRender()}_enableAutoQuality(){this._pixotronUtil.enablePixotronAutoQuality();const t=this._pixotronUtil.getAutoAdapter();this._pixotronUtil.onAutoQualityChange((e,i)=>{var s;null===(s=this._statsHelper)||void 0===s||s.updateQualityInfo(e);const a=this._pixotronUtil.getLowestQualitySetting();if(this._enableSSR(e.ssr),i&&e.getQuality()<i.getQuality()&&t.getAverageFps()<5&&t.setQualitySetting(a),this._renderer.getPixelRatio()>1&&!e.useDevicePixelRatio){this._renderer.setPixelRatio(1);const{x:t,y:e}=this._domHelper.getClientDimensions();try{this._pixotron.setSize(t,e)}catch(t){console.warn(t)}this._renderTarget&&this._renderTarget.setSize(t,e)}}),this._pixotronUtil.onManualQualityChange((t,e)=>{var i;null===(i=this._statsHelper)||void 0===i||i.updateQualityInfo(t),this._enableSSR(t.ssr)}),this._pixotronUtil.lockAdapter()}_enableSSR(t=!1){const e=void 0!==this._initData.ssr&&this._initData.ssr;this._pixotron.getSSRPass().enabled=!!e&&t}_loadGLTF(t,e,i,s,a,n,o){return new Promise((r,h)=>{this._staticItemLoader.loadGLTF(t,e,i,s,a,n,null,o).then(t=>{this._setCamera("GLTF",t),r(t)},h)})}_loadGLB(t,e,i,s,a,n,o,r){return new Promise((h,_)=>{this._staticItemLoader.loadGLB(t,e,i,s,a,n,o,r).then(t=>{this._setCamera("GLB",t),h(t)},_)})}_setCamera(t,e){if(!e)return void console.warn("could not set camera for gltf",e);const i=new THREE.Box3;i.setFromObject(e),"GLB"===t?this._cameraControl instanceof M&&this._cameraControl.updateToBounds(i,!1):"GLTF"===t&&(this._cameraControl instanceof M&&this._cameraControl.updateAndReset(i.getSize(new THREE.Vector3),i.getCenter(new THREE.Vector3),-15,70,5,!1),this._cameraControl instanceof D&&this._cameraControl.zoomToFitBounds(i,!0)),this.updateCamera()}async showGUI(){if(this._initData.disableDebugGUI)return;const t=document.createElement("style");t.innerText=".dg.main{position:absolute;z-index:100;top:0;left:0;}",document.head.appendChild(t),await this._scriptLoader.fetch("static/dat.gui.min-b5cbb61e5c62f0bf.js",{id:"dat-gui-js"});let e=g(!1);e&&(this._domHelper.element.appendChild(e.domElement),this._guiLoaded())}_guiLoaded(){let t=g();t&&(this._lightSetting&&this._lightSetting.showGUI(),this._pixotron&&this._pixotronUtil.showGUI(),this._environment&&this._environment.showGUI(),this._addGUIListener(t))}_addGUIListener(t){let e=t.__folders;Object.keys(e).forEach(t=>{let i=e[t];i.__folders&&Object.keys(i.__folders).forEach(t=>{let i=e[t];this._addGUIListener(i)}),i.__controllers&&i.__controllers.forEach(t=>{t.onFinishChange(()=>{this._guiParamChanged()})})})}_guiParamChanged(){this._renderEverything()}showStats(){e.import("./stats-helper-9898756b.legacy.js").then(t=>this._statsHelper=new t.default)}_onKeyDown(t){}_onKeyUp(t){}pause(){this._getInputManager().removeEvents(this._renderer.domElement),window.removeEventListener("resize",this,!1),window.removeEventListener("keydown",this,!1),window.removeEventListener("keyup",this,!1),document.removeEventListener("visibilitychange",this)}resume(){let t=this._domHelper.getClientDimensions(),e=t.x,i=t.y;if(this._renderTarget){const t=Math.floor(e*window.devicePixelRatio),s=Math.floor(i*window.devicePixelRatio);this._renderTarget.setSize(t,s)}this._renderer.domElement.classList.add(this._canvasID),this._domHelper.element.appendChild(this._renderer.domElement),this._getInputManager().addEvents(this._renderer.domElement),window.addEventListener("resize",this,!1),window.addEventListener("keydown",this,!1),window.addEventListener("keyup",this,!1),document.addEventListener("visibilitychange",this),this.updateCamera()}destroy(){this.pause(),this.cleanUp()}handleEvent(t){switch(t.type){case"resize":this._onWindowResize();break;case"keydown":if(t.target&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement))break;this._onKeyDown(t);break;case"keyup":if(t.target&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement))break;this._onKeyUp(t);break;case"visibilitychange":this._tabVisible()}}async loadSceneSettings(t){let e,i;return e=t.environment?new Promise(e=>{(new Q).load(this._scene,this._renderer.domElement,this._environment,t).then(t=>{this._setEnvironment(t),e()})}):Promise.resolve(),t.lights?(this._lightSetting=new F(this._scene,this._lightSetting),i=this._lightSetting.loadFromObject(t)):i=Promise.resolve(),new Promise((t,s)=>{Promise.all([e,i]).then(()=>{this._renderEverything(),t()},s)})}setBackgroundColor(t){this._setEnvironment(new I(this._scene,this._environment,new THREE.Color(t)))}setBackgroundImage(t){this._setEnvironment(new I(this._scene,this._environment,null,this._renderer.domElement,t))}setBakedShadow(t,e){this._setEnvironment(new I(this._scene,this._environment,new THREE.Color(t),this._renderer.domElement,e))}_setEnvironment(t){this._environment=t,this._environment instanceof k&&(this._pixotron&&this._environment.setPixotron(this._pixotron,this._renderer,this._cameraControl.getCamera()),this._environment.setLoadedCallback(()=>setTimeout(()=>this._renderEverything(),500))),this._renderEverything()}loadQualitySetting(t){this._pixotron&&(new v).set(this._pixotron,t)}async loadDynamicLightSetting(t){this._lightSetting=new F(this._scene,this._lightSetting);let e=!1;if(t.url)await this._lightSetting.loadFromURL(t.url),e=!0;else if(t.json)await this._lightSetting.loadFromJSON(t.json),e=!0;else if(t.object)await this._lightSetting.loadFromObject(t.object),e=!0;else if(t.ls){const i=P.createDynamicLightSettingSource(null,t.ls);await this._lightSetting.loadFromURL(i.url),e=!0}if(!e)throw new Error("No dynamic light setting source set");this._requestRender()}getScene(){return this._scene}updateScene(){this._updateBounds(this.getBounds()),this._renderEverything()}_updateBounds(t,e=!1){if(t){if(this.updateEnvironment(t,e),this._lightSetting&&this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(t),this._pixotronUtil){const e=new THREE.Sphere;t.getBoundingSphere(e),this._pixotronUtil.updateBounds(e)}this._requestRender(),this._pluginSystem.updateBounds(t)}}setCameraOffset(t){const e=this._cameraControl.getCamera(),i=e||e;(null==i?void 0:i.offset)?(i.offset=t,this._renderEverything()):console.warn("Cannot set offset, current camera does not support it")}getCameraOffset(){const t=this._cameraControl.getCamera(),e=t||t;return(null==e?void 0:e.offset)?JSON.parse(JSON.stringify(e.offset)):{left:0,top:0,right:1,bottom:1}}getOrthographicOffsetCamera(){const t=this.getCameraOffset(),e=this._domHelper.getClientDimensions();let i=e.x/e.y*5,s=b().createOrthographicCamera(i/-2,i/2,2.5,-2.5,1,1e3,t);return s.position.set(0,10,0),s.lookAt(new THREE.Vector3(0,0,0)),s}getPerspectiveOffsetCamera(){const t=this.getCameraOffset(),e=this._domHelper.getClientDimensions(),i=e.x,s=e.y;return b().createPerspectiveCamera(30,i/s,.1,20,t)}updateEnvironment(t,e=!1){if(t&&this._environment&&this._environment.needsBounds()){const i=t.getSize(new THREE.Vector3);i.x+i.y+i.z!==0&&this._environment.updateBounds(t.getSize(new THREE.Vector3),e)}}_onCameraIdle(){return!0}_onCameraMove(){return!0}}return i([s],t.prototype,"_domHelper",void 0),i([s],t.prototype,"_scriptLoader",void 0),i([s],t.prototype,"_lifeCycleManager",void 0),i([s],t.prototype,"_staticItemLoader",void 0),i([s],t.prototype,"_environmentLoader",void 0),i([s],t.prototype,"_initData",void 0),i([s],t.prototype,"_pluginSystem",void 0),t})()),t("c","static/pi.min-0272f873b3a4380a.js"),t("P",["static/CopyShader-cde53240fcc3e06e.js","static/EffectComposer-1e936e5d03ff43cc.js","static/RenderPass-bc5df3810a01b2c6.js","static/ShaderPass-31f36160e0ea282d.js","static/LuminosityHighPassShader-dd5826656142421d.js","static/OutlinePass-f4bcd337cdd89b8d.js","static/RectAreaLightUniformsLib-4b74882185efd473.js","static/GammaCorrectionShader-b3b56f244f0d1e0e.js"])}}}));
2
- //# sourceMappingURL=pixotron-084097ac.legacy.js.map
1
+ System.register(["./roomle-dependency-injection-85943177.legacy.js","./main-thread-to-worker-e2f2b9cb.legacy.js"],(function(t,e){var i,s,a,n,o,r,h,_,d,l,c,u,m,p,g,w,y,E,S,P,b,v,x,C;return{setters:[function(t){i=t._,s=t.i,a=t.E,n=t.t,o=t.H,r=t.J,h=t.K,_=t.M,d=t.j,l=t.N,c=t.O,u=t.Q,m=t.T,p=t.U,g=t.h,w=t.V,y=t.X,E=t.Y,S=t.p,P=t.n,b=t.r,v=t.Z},function(t){x=t.l,C=t.h}],execute:function(){t("T","static/Tween-d024b02fe34f25ab.js");const f=t("I",10);let R=t("a",(()=>{class t extends a{constructor(t,e,i){if(super(),this._tweenEnd=null,this._cameraStandingStill=!0,this._pitch=n(f),this._yaw=n(-30),this._distance=-1,this._locked=!1,this._inputListeners=[],this._lerpEnabled=!0,this._creator_=t,this._inputManager=e,this._initInputListener(),this._addInputListeners(),this._cameraPosition=new THREE.Vector3,this._targetPosition=new THREE.Vector3,i?this._cameraPosition.copy(i):this._cameraPosition=new THREE.Vector3(0,.5,3),this._initData.debug){const t=this.getDebugCameraPosition();t&&this._setCurrentCameraParameters(t)}let s=this._domHelper.getClientDimensions();this._width=s.x,this._height=s.y,this._dispatchCameraIdle=x(this._dispatchCameraIdle.bind(this),32)}getCamera(){return this._getCamera()}_addInputListeners(){this._inputListeners.forEach(t=>{this._inputManager.addEventListener(t.key,t.fun,this)})}_removeInputListeners(){this._inputListeners.forEach(t=>{this._inputManager.removeEventListener(t.key,t.fun)}),this._inputListeners=[]}cleanUp(){this._removeInputListeners()}animateCamera(t){let e=this._cameraPosition;if(!e||o(e,this.getCamera().position))return this._cameraStandingStill||(this._cameraStandingStill=!0,setTimeout(()=>this._dispatchCameraIdle(),16),this._initData.debug&&this.saveDebugCameraPosition()),!1;if(this._cameraStandingStill&&this.dispatchEvent(7,3),this._cameraStandingStill=!1,this._lerpEnabled&&!this._tweenEnd){let i=this.getCamera().position.clone();const s=Math.min(10*t,1);i.lerp(e,s),this.getCamera().position.copy(i)}else this.getCamera().position.copy(e);return!0}getDebugCameraPosition(){return JSON.parse(localStorage.getItem("debug_camera_position"))}saveDebugCameraPosition(){localStorage.setItem("debug_camera_position",JSON.stringify(this._getCurrentCameraParameters()))}_dispatchCameraIdle(){this.dispatchEvent(8,3)}_areEqual(t,e){return t.yaw.toFixed(5)===e.yaw.toFixed(5)&&t.pitch.toFixed(5)===e.pitch.toFixed(5)&&t.distance.toFixed(5)===e.distance.toFixed(5)&&t.targetX===e.targetX&&t.targetY===e.targetY&&t.targetZ===e.targetZ}_tweenCameraParameter(t,e,i=!1){return new Promise(s=>{if(e.yaw-t.yaw<=-Math.PI?t.yaw-=2*Math.PI:e.yaw-t.yaw>=Math.PI&&(t.yaw+=2*Math.PI),window.TWEEN){if(null!==this._tweenEnd&&this._tweenEnd.blockOtherTweens)return;this._tweenEnd=e,new TWEEN.Tween(t).to(e,400).easing(TWEEN.Easing.Sinusoidal.In).onUpdate(()=>{this.dispatchEvent(1,3),this._yaw=t.yaw,this._pitch=t.pitch,this._distance=t.distance,this._setCameraNear(),this._update(new THREE.Vector3(t.targetX,t.targetY,t.targetZ),i)}).onComplete(()=>{this.dispatchEvent(2,3),this._tweenEnd=null,s()}).start(),this.dispatchEvent(0,3)}})}_setCameraNear(){const t=this.getCamera();if(t instanceof THREE.PerspectiveCamera){const e=Math.max(.1,this._distance/6);t.near=e}}_getCurrentCameraParameters(){const t=this._targetPosition.clone();return{yaw:this._yaw,pitch:this._pitch,distance:this._distance,targetX:t.x,targetY:t.y,targetZ:t.z}}_setCurrentCameraParameters(t){this._yaw=t.yaw,this._pitch=t.pitch,this._distance=t.distance,this._targetPosition.copy(new THREE.Vector3(t.targetX,t.targetY,t.targetZ))}_rotateHorizontal(t){this._yaw-=t,this._yaw<-Math.PI?this._yaw+=2*Math.PI:this._yaw>Math.PI&&(this._yaw-=2*Math.PI)}_rotateVertical(t){this._pitch+=t,this._pitch<-Math.PI?this._pitch+=2*Math.PI:this._pitch>Math.PI&&(this._pitch-=2*Math.PI)}saveState(t){if(t||!this._stateSaved){let t=this._yaw,e=this._pitch,i=this._distance,s=this._targetPosition.clone();if(this._stateSaved={yaw:t,pitch:e,distance:i,targetX:s.x,targetY:s.y,targetZ:s.z,blockOtherTweens:!0},this._getCamera().fov){let t=this._getCamera();this._stateSaved.fov=t.fov,this._stateSaved.near=t.near,this._stateSaved.far=t.far}return this._stateSaved}return null}resetToState(){if(this._stateSaved){this._stateSaved.blockOtherTweens=!1;let t=this._targetPosition.clone();this._tweenCameraParameter({yaw:this._yaw,pitch:this._pitch,distance:this._distance,targetX:t.x,targetY:t.y,targetZ:t.z},this._stateSaved,!0)}this._stateSaved=null}setToState(t,e){this._tweenCameraParameter(t,e,!0)}hasSavedState(){return null!=this._stateSaved}lock(){this._locked=!0}unlock(){this._locked=!1}isLocked(){return this._locked}getTargetPosition(){return this._targetPosition}_saveYawAndPitch(){this._getCamera().userData.yaw=this._yaw,this._getCamera().userData.pitch=this._pitch}getInputPosition(t){const{x:e,y:i}=this._domHelper.getClientDimensions();return new THREE.Vector3(t.x/e*2-1,-t.y/i*2+1,.5)}addLightContainer(t){t.name="lights";const e=this._getCamera(),i=e.children.find(t=>"lights"===t.name);i&&e.remove(i),e.add(t)}checkNearFarDistance(t){if(!t)return;const e=this._cameraPosition.distanceTo(t),i=this._getCamera();i instanceof THREE.PerspectiveCamera&&e>i.far&&(i.far=e+1)}setBounds(t){this._boundingBox=t}}return i([s],t.prototype,"_domHelper",void 0),i([s],t.prototype,"_initData",void 0),t})());class T{constructor(t,e){this.minZoom=!1,this.maxZoom=!1,this.minZoom=t,this.maxZoom=e}}class M extends R{constructor(t,e,i,s){super(t,e,i),this._bounds=new THREE.Vector3,this._scale=1,this._state=0,this._zoomSpeed=Math.pow(.95,3),this.minDistance=0,this.maxDistance=5,this.minPolarAngle=n(0),this.maxPolarAngle=n(85),this._objectRotation=0,this.minAzimuthAngle=Number.NEGATIVE_INFINITY,this.maxAzimuthAngle=Number.POSITIVE_INFINITY,this._zoomDistance=.1,this._userInteraction=!1,this._currentZoomHash="",this._maxZoomedIn=!1,this._maxZoomedOut=!1,this._panningEnabled=!1,this._targetPositionIsPanned=!1,s?this._camera=s:this._initCamera(),this._targetPosition||(this._targetPosition=new THREE.Vector3(0,0,0),this._targetPositionIsPanned=!1);const{cameraRestriction:a,zoomDistance:o,minVerticalCameraAngle:r,maxVerticalCameraAngle:h,minHorizontalCameraAngle:_,maxHorizontalCameraAngle:d}=this._initData;if(o&&(this._zoomDistance=o/100),void 0!==r&&(this.minPolarAngle=n(r<0?r:-1*r)),void 0!==h&&(this.maxPolarAngle=n(h)),void 0!==_&&(this.minAzimuthAngle=n(_<0?_:-1*_)),void 0!==d&&(this.maxAzimuthAngle=n(d)),void 0!==a){let t=Math.abs(n(a));this.minAzimuthAngle=-t,this.maxAzimuthAngle=t,this.maxPolarAngle=Math.min(t,n(85))}this._update()}_getCamera(){return this._camera||this._initCamera(),this._camera}getCamera(){return super.getCamera()}_initCamera(){this._camera=new THREE.PerspectiveCamera,this._camera.fov=30,this._camera.aspect=this._width/this._height,this._camera.near=.1,this._camera.far=100,this._camera.updateProjectionMatrix(),this._camera.layers.set(3),this._camera.layers.enable(1),this._camera.layers.enable(2),this._camera.layers.enable(6),this._camera.layers.enable(5)}setObjectRotation(t){this._objectRotation=t}getObjectRotation(){return this._objectRotation}updateCamera(){let{x:t,y:e}=this._domHelper.getClientDimensions();this._camera.aspect=t/e,this._camera.updateProjectionMatrix()}animateCamera(t){if(!super.animateCamera(t))return!1;let e=this._targetPosition;return!!e&&(this.getCamera().lookAt(e),!0)}_initInputListener(){this._inputListeners.push({key:3,fun:()=>{this._state=1}}),this._inputListeners.push({key:6,fun:t=>{var e,i;1!==this._state||this._locked||(this._userInteraction=!0,!(void 0!==(null===(e=t.event)||void 0===e?void 0:e.shiftKey)&&(null===(i=t.event)||void 0===i?void 0:i.shiftKey))&&this._panningEnabled&&this.disablePanning(),this._move(new THREE.Vector2(t.position.x,t.position.y),t.type))}}),this._inputListeners.push({key:11,fun:t=>{1===this._state||this._locked||(this._userInteraction=!0,this._pan(new THREE.Vector2(t.position.x,t.position.y),t.type))}}),this._inputListeners.push({key:4,fun:t=>{1===this._state&&this.dispatchEvent(2,t.type),this._state=0,this._orbitPosition=null,this._lerpEnabled=!0}}),this._inputListeners.push({key:7,fun:({event:t})=>{this._maxZoomedIn||(t&&(t.preventDefault(),t.stopPropagation()),this.zoomIn())}}),this._inputListeners.push({key:8,fun:({event:t})=>{this._maxZoomedOut||(t&&(t.preventDefault(),t.stopPropagation()),this.zoomOut())}})}_panTargetPosition(t){const e=t.clone().sub(this._orbitPosition),i=this._domHelper.element,s=this._targetPosition.project(this._camera),a=Math.max(2,4*(1-this._distance/this.maxDistance));s.x=s.x-e.x/i.clientHeight*a,s.y=s.y+e.y/i.clientHeight*a,this._targetPositionIsPanned=!0,this._targetPosition.copy(s.unproject(this._camera))}_pan(t,e){this._lerpEnabled=!1,this._orbitPosition||(this._orbitPosition=new THREE.Vector2(t.x,t.y),this.dispatchEvent(0,e)),this._panTargetPosition(t),r(this._orbitPosition,t)||this.dispatchEvent(1,e),this._orbitPosition.copy(t),this._update()}_move(t,e){this._orbitPosition||(this._orbitPosition=new THREE.Vector2(t.x,t.y),this.dispatchEvent(0,e));const i=t.clone().sub(this._orbitPosition),s=this._domHelper.element;this._panningEnabled?this._panTargetPosition(t):(this._rotateHorizontal(2*Math.PI*i.x/s.clientWidth*1),this._rotateVertical(2*Math.PI*i.y/s.clientHeight*1)),r(this._orbitPosition,t)||this.dispatchEvent(1,e),this._orbitPosition.copy(t),this._update()}zoomToFitBounds(t){if(h(t,this._boundingBox)<0)return void this.setBounds(t);this.setBounds(t);const e=t.getSize(new THREE.Vector3);if(this._initData.debug||e.x+e.y+e.z===0)return;const i=this._getCurrentCameraParameters(),s=t.getCenter(new THREE.Vector3),a=this._setDistanceAndRangesBasedOnBounds(e);this._checkZoomDistance(t,a),this._tweenCameraParameter(i,{yaw:this._yaw,pitch:this._pitch,distance:a,targetX:s.x,targetY:s.y,targetZ:s.z},!1)}updateToBounds(t,e,i=!0,s){if(this.setBounds(t),this._initData.debug)return;const a=t.getCenter(new THREE.Vector3);s?(this._targetPosition=s.clone(),this._targetPositionIsPanned=!1):this._targetPositionIsPanned||(this._targetPosition=new THREE.Vector3(a.x,a.y,a.z));const n=this._getCurrentCameraParameters(),o=t.getSize(new THREE.Vector3);if(i){const i=this._setDistanceAndRangesBasedOnBounds(o);this._distance=i,this._checkZoomDistance(t,i),this._userInteraction?this._tweenCameraParameter(n,{yaw:this._yaw,pitch:this._pitch,distance:this._distance,targetX:this._targetPosition.x,targetY:this._targetPosition.y,targetZ:this._targetPosition.z},e):this._update()}else this._setDistanceAndRangesBasedOnBounds(o,!1);this._update()}_checkZoomDistance(t,e){const i=t.getBoundingSphere(new THREE.Sphere);e-i.radius<this._zoomDistance&&(console.warn("the initial camera position is closer than the zoomDistance param, zoomDistance is set to initial camera position."),this._zoomDistance=e-i.radius)}_setDistanceAndRangesBasedOnBounds(t,e=!0){const i=this._domHelper.getClientDimensions(),s=i.x,a=i.y,n=this._camera.offset?s-s*this._camera.offset.left-s*(1-this._camera.offset.right):s,o=this._camera.offset?a-a*this._camera.offset.bottom-a*(1-this._camera.offset.top):a;this._bounds.copy(t);const{cameraSpacing:r}=this._initData;t.addScalar(r/100),this.minDistance=Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z);const h=Math.max(t.x,t.y),{x:d,y:l}=this._getMargin(n,o),c=_(t.x+d,t.y+l,t.z,this._camera.fov,n,o);return this._distance<c&&e&&(this._distance=c),this.maxDistance=c+h,this.maxDistance<2&&(this.maxDistance=2),this._camera.far=5*this.maxDistance,this._setCameraNear(),c}_getMargin(t,e){let i=this._bounds.x/2,s=this._bounds.y/2;return t>1080&&(i+=this._bounds.x<.3?.2:0,i+=this._bounds.x*(t/1080-1)),e>1080&&(i+=this._bounds.y<.3?.2:0,s+=this._bounds.y*(e/1080-1)),{x:i,y:s}}reset(t,e,i,s,a=!0){const o=t.getSize(new THREE.Vector3);if(o){if(e)this._targetPosition.copy(e);else{const e=t.getCenter(new THREE.Vector3);this._targetPosition.copy(e)}const r=this._getCurrentCameraParameters();if(i||(i=-30),s||(s=f),i+=d(this._objectRotation),this._initData.debug)return this._distance=this._setDistanceAndRangesBasedOnBounds(o),this._update(this._targetPosition),void this._setDistanceAndRangesBasedOnBounds(o);const h=this._setDistanceAndRangesBasedOnBounds(o),_=n(s),l=n(i);let c=this._targetPosition.clone();a?this._tweenCameraParameter(r,{yaw:l,pitch:_,distance:h,targetX:c.x,targetY:c.y,targetZ:c.z},!0):(this._pitch=_,this._yaw=l,this._distance=h,this._update(this._targetPosition))}else console.warn("you cant reset without bounds!")}updateAndReset(t,e,i,s,a,o=!0){const r=new THREE.Vector3(-t.x/2,0,-t.z/2),h=new THREE.Vector3(t.x/2,t.y,t.z/2);if(this._boundingBox=new THREE.Box3(r,h),a&&t.addScalar(a),e?this._targetPosition.copy(e):(this._targetPosition=new THREE.Vector3(0,t.y/2,0),this._targetPositionIsPanned=!1),-1===this._distance){const e=this._setDistanceAndRangesBasedOnBounds(t);this._distance=Math.max(2,e)}const _=this._getCurrentCameraParameters();i||(i=-30),s||(s=f),i+=d(this._objectRotation),this._pitch=n(s),this._yaw=n(i),this._setDistanceAndRangesBasedOnBounds(t);let l=this._targetPosition.clone();o?this._tweenCameraParameter(_,{yaw:this._yaw,pitch:this._pitch,distance:this.maxDistance,targetX:l.x,targetY:l.y,targetZ:l.z},!0):this._update(this._targetPosition)}_update(t,e){this._initData.debug?this._pitch=Math.max(n(-89),Math.min(n(89),this._pitch)):(this._yaw=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,this._yaw)),this._pitch=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._pitch))),this._saveYawAndPitch();const i=new THREE.Euler(-this._pitch,this._yaw,0,"ZYX"),s=(new THREE.Quaternion).setFromEuler(i),a=new THREE.Vector3(0,0,-1);a.applyQuaternion(s),this._distance*=this._scale,this._initData.debug||(this._distance=Math.min(this.maxDistance,this._distance)),t&&this._targetPosition.copy(t);const o=this._targetPosition.clone().sub(a.multiplyScalar(this._distance));if(this._initData.debug)this._cameraPosition.copy(o),this._zoomChanged(!1,!1);else if(e)this._cameraPosition.copy(o);else{const t=this._getCameraSphere(o);null!=this._boundingBox&&this._boundingBox.intersectsSphere(t)&&this._scale>=1?this._distance+=.1:null==this._boundingBox||this._boundingBox.intersectsSphere(t)?this._zoomChanged(!1,!0):(this._cameraPosition.copy(o),this._distance===this.maxDistance?this._zoomChanged(!0,!1):this._zoomChanged(!1,!1))}this._scale=1}_zoomChanged(t,e){let i=t+""+e;0===this._currentZoomHash.length||this._currentZoomHash!==i?(this.dispatchEvent(5,new T(t,e)),this._currentZoomHash=i):t||e||this.dispatchEvent(5,new T(t,e)),this._maxZoomedIn=e,this._maxZoomedOut=t}zoomTo(t,e,i,s,a,n){return this._tweenCameraParameter(this._getCurrentCameraParameters(),{yaw:s,pitch:a,distance:2.725*_(t.x,t.y,t.z,this._camera.fov,e,i),targetX:n.x,targetY:n.y,targetZ:n.z,blockOtherTweens:!0},!0)}_getCameraSphere(t){const e=Math.max(this._bounds.x,this._bounds.y),i=Math.max(e/10,this._zoomDistance);return new THREE.Sphere(t,i)}zoomIn(t){this._lerpEnabled=!0,this._scale*=t?Math.pow(.95,t):this._zoomSpeed,this._setCameraNear(),this._update(),this.dispatchEvent(3)}zoomOut(t){this._lerpEnabled=!0,this._scale/=t?Math.pow(.95,t):this._zoomSpeed,this._setCameraNear(),this._update(),this.dispatchEvent(4)}clear(){this._userInteraction=!1,this._initData.debug||(this._distance=-1,this._targetPosition=new THREE.Vector3(0,0,0),this._targetPositionIsPanned=!1)}async moveCamera(t){return this._tweenCameraParameter(this._getCurrentCameraParameters(),t,!0)}enablePanning(){this._lerpEnabled=!1,this._panningEnabled=!0}disablePanning(){this._lerpEnabled=!1,this._panningEnabled=!1}getKernelZoomFactor(){const t=this.maxDistance;return 1-this._distance/(t-2)+.2}}t("C",M);class A{constructor(t,e){this._scene=t,e&&e.removeFromScene()}needsBounds(){return!1}updateBounds(t){}getCameraContainer(){return this._cameraContainer||(this._cameraContainer=new THREE.Object3D),this._cameraContainer}}t("L",A);const H={enable:!0,shadowMapResolution:512,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.5,darkness:.2,size:1.6,lightSolidAngle:40,yPosition:0};class k extends class{constructor(t,e){this._scene=t,e&&(e.removeFromScene(),e.cleanUp())}updateCamera(t){}reload(){this.removeFromScene(),this.addToScene()}updateBounds(t,e){this._bounds=t}cleanUp(){this._scene=null}}{constructor(t,e){super(t,e),this._pixotronGuard=new l,this._enabled=!0,this._params=Object.assign(H,{lightDirection:new THREE.Vector3(0,1,.5),onComplete:this._addGroundShadows.bind(this),onProgress:this._progressCallback.bind(this)})}_progressCallback(t){}needsBounds(){return!0}needsCamera(){return!1}needsRotation(){return!1}setPixotron(t,e,i,s){t&&(this._pixotron=t,this._renderer=e,this._camera=i,this._shadowBaker||(this._shadowBaker=new window.PIXOTRON.PlaneShadowBakePass(Object.assign(this._params,s))),this._shadowBaker.enable?this._shadowBaker.startBake(this._renderer,this._scene,this._camera):this._shadowBaker.enable=!0,this._wasAAEnabled=this._pixotron.enableAA,this._pixotronGuard.resolve())}async _addGroundShadows(){await this._pixotronGuard.wait(),this._pixotron.needsUpdate=!0,this._shadowPlane=this._shadowBaker.getShadowPlane(),this._shadowPlane.name="Shadow plane",this._shadowPlane.receiveShadow=!1,0!==this._params.yPosition&&(this._shadowPlane.position.y=this._params.yPosition),this._shadowPlane.visible=!0,this.addToScene(),this._loadedCallback&&this._loadedCallback()}setLoadedCallback(t){this._loadedCallback=t}update(){const t=this._getNumberOfChildren();this._bake(),this._sceneChildren=t}updateBounds(t,e){const i=this._getNumberOfChildren();return!(c(this._bounds,t,1e-4)&&this._scene&&i===this._sceneChildren&&!e||(super.updateBounds(t),this._bake(),this._sceneChildren=i,0))}_bake(){this._pixotronGuard.wait().then(()=>{this._shadowPlane&&(this._shadowPlane.visible=!1),this._shadowBaker.startBake(this._renderer,this._scene,this._camera)})}_getNumberOfChildren(){let t=0;return this._scene.traverse(e=>{"Shadow plane"!==e.name&&t++}),t}addToScene(){this._scene&&this._shadowPlane&&this._enabled&&(this._shadowPlane.material.needsUpdate=!0,u(this._shadowPlane),this._scene.add(this._shadowPlane))}removeFromScene(){this._shadowPlane&&(this._scene.remove(this._shadowPlane),this._pixotron&&(this._pixotron.enableAA=this._wasAAEnabled))}enable(){this._enabled=!0,this.addToScene()}disable(){this._enabled=!1,this.removeFromScene()}showGUI(){}}t("B",k);class L{constructor(t){this._innerSize=1,this._outerSize=100,this._plane=new THREE.Object3D,this._plane.rotation.x=-Math.PI/2;const e=new THREE.MeshStandardMaterial;this._innerPlaneMesh=new THREE.Mesh,this._innerPlaneMesh.layers.set(2),this._innerPlaneMesh.material=e,this._innerPlaneMesh.receiveShadow=!0,this._outerPlaneMesh=new THREE.Mesh,this._outerPlaneMesh.layers.set(2),this._outerPlaneMesh.material=e,this._outerPlaneMesh.receiveShadow=!0,this._plane.add(this._innerPlaneMesh),this._plane.add(this._outerPlaneMesh),this._innerSize=1,this._outerSize=t,this._updatePlane(this._innerSize,this._outerSize)}getRootNode(){return this._plane}getInnerPlane(){return this._innerPlaneMesh}getOuterPlane(){return this._outerPlaneMesh}updateSize(t){this._innerSize=t,this._updatePlane(this._innerSize,this._outerSize)}_updatePlane(t,e){const i=new THREE.Shape;i.moveTo(-t/2,-t/2),i.lineTo(-t/2,t/2),i.lineTo(t/2,t/2),i.lineTo(t/2,-t/2),i.lineTo(-t/2,-t/2);const s=new THREE.Shape;s.moveTo(-e/2,-e/2),s.lineTo(-e/2,e/2),s.lineTo(e/2,e/2),s.lineTo(e/2,-e/2),s.lineTo(-e/2,-e/2);const a=new THREE.Path;a.moveTo(-t/2,-t/2),a.lineTo(-t/2,t/2),a.lineTo(t/2,t/2),a.lineTo(t/2,-t/2),a.lineTo(-t/2,-t/2),s.holes.push(a);const n=new THREE.ShapeBufferGeometry(i);this._innerPlaneMesh.geometry&&this._innerPlaneMesh.geometry.dispose(),this._innerPlaneMesh.geometry=n;const o=new THREE.ShapeBufferGeometry(s);this._outerPlaneMesh.geometry&&this._outerPlaneMesh.geometry.dispose(),this._outerPlaneMesh.geometry=o;const r=n.attributes.uv.clone();n.setAttribute("uv2",r);const h=n.attributes.uv2.array;for(let t=0;t<h.length;++t)h[t]+=.5}}let z=t("F",(()=>{class t extends k{constructor(t,e,i){super(t,e),this._longestSide=2,this._bakedShadowPlane=new L(100),this._fog=i||!1,this._textureLoader=new THREE.TextureLoader,this.addToScene()}needsBounds(){return!0}needsCamera(){return this._fog}needsRotation(){return!1}updateBounds(t){return super.updateBounds(t),this._longestSide=Math.max(t.x,t.z),this._update(),!0}updateCamera(t){this._cameraDistance=t.position.distanceTo(new THREE.Vector3(0,0,0)),this._update()}_update(){this._fog&&this._updateFog()}_updateFog(){let t=this._longestSide/2;this._scene.fog=new THREE.Fog(16185078,this._cameraDistance+t+3,this._cameraDistance+t+3+1),this._scene.background=new THREE.Color(16185078)}_updateFloor(){if(this._floorMaterial)this._bakedShadowPlane.getOuterPlane().material=this._floorMaterial,this._bakedShadowPlane.getInnerPlane().material=this._floorMaterial;else{let t=this._width/1e3,e=this._height/1e3;this._repeatable&&(this._floorTexture.wrapS=THREE.RepeatWrapping,this._floorTexture.wrapT=THREE.RepeatWrapping,this._floorTexture.repeat.set(100/t,100/e));let i=new THREE.MeshStandardMaterial({map:this._floorTexture,side:THREE.DoubleSide});this._bakedShadowPlane.getInnerPlane().material=i,this._bakedShadowPlane.getOuterPlane().material=i}}addToScene(){this._scene&&(this._shadowPlane&&(this._bakedShadowPlane.updateSize(this._shadowPlane.scale.x),this._bakedShadowPlane.getRootNode().position.copy(this._shadowPlane.position),this._bakedShadowPlane.getInnerPlane().material.aoMap=this._shadowPlane.material.aoMap),this._scene.add(this._bakedShadowPlane.getRootNode()))}removeFromScene(){this._scene.remove(this._bakedShadowPlane.getRootNode())}setFloorMaterial(t,e,i,s){return this._width=e,this._height=i,this._repeatable=s,this._floorPromise=new Promise((e,i)=>{this._textureLoader.load(t,t=>{this._floorTexture=t,e()},null,i)}),new Promise((t,e)=>{this._floorPromise.then(()=>{this._updateFloor(),this._update(),t()},e)})}changeFloorMaterial(t,e){this._floorPromise=new Promise((i,s)=>{this._floorMaterial=m(t,this._environmentLoader),this._rapiAccess.getTexturesOf(t).then(t=>{if(t.length>0){let a=[];t.forEach(t=>{a.push(p(this._dataSyncer.requestAsset(t.image,!0),t,this._floorMaterial,e,1,1))}),Promise.all(a).then(()=>{setTimeout(()=>i(),0)},s)}else setTimeout(()=>i(),0)})});let i=[this._floorPromise];return new Promise((t,e)=>{Promise.all(i).then(()=>{this._updateFloor(),this._update(),t()},e)})}showGUI(){this._floorMaterial?this._addGUI():this._floorPromise&&this._floorPromise.then(()=>this._addGUI())}_addGUI(){let t=g();if(!t)return;let e=t.addFolder("Floor");e.add(this._floorMaterial,"roughness").min(0).max(1).step(.01),e.add(this._floorMaterial,"reflectivity").min(0).max(1).step(.01),e.add(this._floorMaterial,"clearCoat").min(0).max(1).step(.01),e.add(this._floorMaterial,"clearCoatRoughness").min(0).max(1).step(.01),e.add(this._floorMaterial,"opacity").min(0).max(1).step(.01),e.add(this._floorMaterial,"metalness").min(0).max(1).step(.01),e.add(this._floorMaterial,"bumpScale").min(0).max(1).step(.01)}}return i([s],t.prototype,"_rapiAccess",void 0),i([s],t.prototype,"_dataSyncer",void 0),i([s],t.prototype,"_environmentLoader",void 0),t})());class I extends k{constructor(t,e,i,s,a){if(super(t,e),this._color=i,this._oldBackground=t.background,s&&a){this._canvas=s,this._style=document.createElement("style");let t='background-image: url("'+a+'"); background-size: cover;';this._style.innerText=".rml-scene-background {"+t+"}",this._canvas.appendChild(this._style)}}needsBounds(){return!0}needsCamera(){return!1}needsRotation(){return!1}addToScene(){super.addToScene(),this._scene&&this._color&&(this._scene.background=this._color),this._canvas&&this._canvas.classList&&(this._scene.background=null,this._canvas.classList.add("rml-scene-background"),this._pixotron&&(this._pixotron.enableAA=!1))}removeFromScene(){super.removeFromScene(),this._oldBackground&&(this._scene.background=this._oldBackground),this._canvas&&this._canvas.classList.remove("rml-scene-background")}}t("b",I);class D extends R{constructor(t,e,i,s){super(t,e,i),this._scale=1,this._cameraZoom=1,this._state=0,this._size=5,this._lastPosition=new THREE.Vector2,this._zoomPosition=new THREE.Vector3,this._lastZoom=0,this._zoomSpeed=Math.pow(.95,2),s?(this._camera=s,this._cameraPosition=(new THREE.Vector3).copy(this._camera.position)):this._initCamera(i||new THREE.Vector3(0,10,0))}_getCamera(){return this._camera||this._initCamera(new THREE.Vector3(0,10,0)),this._camera}_initCamera(t){let{x:e,y:i}=this._domHelper.getClientDimensions(),s=e/i*this._size,a=this._size;this._camera=new THREE.OrthographicCamera(s/-2,s/2,a/2,a/-2,1,1e3),this._camera.position.copy(t),this._cameraPosition=t,this._camera.lookAt(new THREE.Vector3(0,0,0))}updateCamera(){let{x:t,y:e}=this._domHelper.getClientDimensions(),i=t/e*this._size,s=this._size;this._camera.left=i/-2,this._camera.right=i/2,this._camera.top=s/2,this._camera.bottom=s/-2,this._camera.updateProjectionMatrix()}_initInputListener(){this._inputListeners.push({key:3,fun:t=>{this._locked||(this._state=1,this._lastPosition.set(t.positionRelative.x,t.positionRelative.y),this.dispatchEvent(0))}}),this._inputListeners.push({key:6,fun:t=>{1!==this._state||this._locked||(this._move(new THREE.Vector2(t.positionRelative.x,t.positionRelative.y),t.type),this.dispatchEvent(1))}}),this._inputListeners.push({key:4,fun:t=>{1===this._state&&this.dispatchEvent(2),this._state=0}}),this._inputListeners.push({key:7,fun:t=>{t.event&&(t.event.stopPropagation(),t.event.preventDefault()),this.dispatchEvent(3),this._scale/=this._zoomSpeed,this._zoomTo(t.positionRelative),this._update()}}),this._inputListeners.push({key:8,fun:t=>{t.event&&(t.event.stopPropagation(),t.event.preventDefault()),this.dispatchEvent(4),this._scale*=this._zoomSpeed,this._zoomTo(t.positionRelative),this._update()}})}_zoomTo(t){if(Date.now()-this._lastZoom>200){let e=new THREE.Vector3(t.x,t.y,0);e.unproject(this._camera),this._zoomPosition.copy(e)}this._lastZoom=Date.now()}_move(t,e){let i=new THREE.Vector3,s=new THREE.Vector3(this._lastPosition.x,this._lastPosition.y,0),a=new THREE.Vector3(t.x,t.y,0);s.unproject(this._camera),a.unproject(this._camera),i.subVectors(a,s),this._cameraPosition.x-=i.x*(2===e?1.1:1),this._cameraPosition.z-=i.z*(2===e?1.1:1),this._lastPosition.copy(t)}zoomToFitBounds(t,e,i){if(h(t,this._boundingBox)<0&&!i)return void this.setBounds(t);this.setBounds(t),t.expandByScalar(1.2);const s=t.getSize(new THREE.Vector3),a=t.getCenter(new THREE.Vector3),n=s.x/-2/this._camera.left,o=s.z/-2/this._camera.bottom,r=1/Math.max(n,o);(r<this._cameraZoom||e)&&(this._scale=r,this._cameraZoom=r,this._cameraPosition.x=a.x,this._cameraPosition.z=a.z)}_update(t){this._scale=Math.min(this._scale,5),this._scale=Math.max(this._scale,.2);let e=(new THREE.Vector3).subVectors(this._zoomPosition,this._cameraPosition).multiplyScalar((this._scale-this._cameraZoom)/this._scale);this._cameraPosition.x+=e.x,this._cameraPosition.z+=e.z,this._cameraZoom!==this._scale&&this.dispatchEvent(5,new T(.2===this._scale,5===this._scale)),this._cameraZoom=this._scale,this._camera.updateProjectionMatrix()}animateCamera(t){if(!super.animateCamera(t)&&Math.abs(this._cameraZoom-this._camera.zoom)<=.01)return!1;const e=Math.min(10*t,1);return this._camera.zoom=THREE.MathUtils.lerp(this._camera.zoom,this._cameraZoom,e),!0}getKernelZoomFactor(){return this._camera.zoom}}t("d",D);const B=Math.PI/4;class O extends R{constructor(t,e,i,s){super(t,e,i),this._state=0,this._rotationSpeed=1,this._keyMap=new Map,this.minPolarAngle=n(-60),this.maxPolarAngle=n(60),this._camera=s||new THREE.PerspectiveCamera,this._camera.fov=70,this._camera.aspect=this._width/this._height,this._camera.near=.1,this._camera.far=100,this._camera.updateProjectionMatrix(),this._camera.layers.set(3),this._camera.layers.enable(1),this._camera.layers.enable(2),this._camera.layers.enable(6),this._camera.layers.enable(5),i?this._camera.position.set(i.x,1.5,i.z):this._camera.position.set(0,1.5,0),this._cameraPosition=new THREE.Vector3,this._cameraPosition.copy(this._camera.position),this._cameraRotation=new THREE.Quaternion,this._pitch=0,this._yaw=0;let a=new THREE.Euler(-this._pitch,this._yaw,0,"ZYX");this._cameraRotation.setFromEuler(a),window.addEventListener("gamepadconnected",this._gamepadConnected.bind(this)),window.addEventListener("gamepaddisconnected",this._gamepadDisconnected.bind(this))}_gamepadConnected(t){this.startButtonPressListener()}_gamepadDisconnected(t){window.cancelAnimationFrame(this._listenerLoopAnimationFrame)}startButtonPressListener(){this._listenerLoopAnimationFrame=window.requestAnimationFrame(()=>{this.buttonPressListener()})}buttonPressListener(){let t=navigator.getGamepads()[0];this._checkRightStick(t),this._checkLeftStick(t),this._checkButtons(t),this._processKeyMap(this._keyMap,.001),this.startButtonPressListener()}_checkRightStick(t){let e=t.axes[2],i=t.axes[3];Math.abs(e)>.2&&(this._rotateHorizontal(.01*B*e),this._update(),this.dispatchEvent(1)),Math.abs(i)>.2&&(this._rotateVertical(.01*B*i),this._update(),this.dispatchEvent(1))}_checkLeftStick(t){let e=t.axes[0],i=t.axes[1];Math.abs(i)>.2?i<0?this._keyMap.set(87,!0):this._keyMap.set(83,!0):t.buttons&&t.buttons[12]&&t.buttons[12].pressed?this._keyMap.set(87,!0):t.buttons&&t.buttons[13]&&t.buttons[13].pressed?this._keyMap.set(83,!0):(this._keyMap.set(87,!1),this._keyMap.set(83,!1)),Math.abs(e)>.2?e<0?this._keyMap.set(65,!0):this._keyMap.set(68,!0):(this._keyMap.set(65,!1),this._keyMap.set(68,!1))}_checkButtons(t){t.buttons&&t.buttons[6]&&t.buttons[6].pressed?this._keyMap.set(16,!0):this._keyMap.set(16,!1),t.buttons&&t.buttons[14]&&t.buttons[14].pressed?(this._keyMap.set(37,!0),this.dispatchEvent(1)):this._keyMap.set(37,!1),t.buttons&&t.buttons[15]&&t.buttons[15].pressed?(this._keyMap.set(39,!0),this.dispatchEvent(1)):this._keyMap.set(39,!1)}animateCamera(t){let e=this._cameraPosition,i=this._cameraRotation,s=this.getCamera(),a=o(e,s.position),n=w(i,s.quaternion);if(!e||a&&n)return!1;let r=this.getCamera().position.clone(),h=Math.min(10*t,1);r.lerp(e,h),this.getCamera().position.copy(r);let _=this.getCamera().quaternion.clone(),d=Math.min(5*t,1);_.slerp(i,d),this.getCamera().setRotationFromQuaternion(_);let l=!1;return this._keyMap.forEach(t=>{t&&(l=!0)}),l&&this._processKeyMap(this._keyMap,t),!0}_getCamera(){return this._camera}_initInputListener(){window.addEventListener("keyup",this._onKeyChanged.bind(this),!1),window.addEventListener("keydown",this._onKeyChanged.bind(this),!1),this._inputListeners.push({key:3,fun:t=>{this._down(t)}}),this._inputListeners.push({key:6,fun:t=>{this._move(t)}}),this._inputListeners.push({key:4,fun:t=>{this._up(t)}})}_down(t){this._downPosition=t.position,this._position=t.position,this._state=1,2===t.type&&window.setTimeout(this._onLongDown.bind(this),350),2===t.type?this._rotationSpeed=.6:this._rotationSpeed=1}_move(t){this._position=t.position,1!==this._state||this._locked||this._orbit(new THREE.Vector2(t.position.x,t.position.y)),2!==this._state||this._locked||(this._orbit(new THREE.Vector2(t.position.x,t.position.y)),this._moveForward())}_up(t){1===this._state&&this.dispatchEvent(2),2===this._state&&this._keyMap.set(87,!1),this._state=0,this._orbitPosition=null}_onLongDown(){y(this._downPosition,this._position)<E&&1===this._state&&(this._state=2,this._orbit(new THREE.Vector2(this._position.x,this._position.y)),this._moveForward())}_update(t){let e=new THREE.Euler(-this._pitch,this._yaw,0,"ZYX");this._cameraRotation.setFromEuler(e)}updateCamera(){let{x:t,y:e}=this._domHelper.getClientDimensions();this._camera.aspect=t/e,this._camera.updateProjectionMatrix()}_onKeyChanged(t){this._keyMap.set(t.keyCode,"keydown"===t.type),this.dispatchEvent(6),this._processKeyMap(this._keyMap,.001)&&t.preventDefault()}_processKeyMap(t,e){e=Math.min(e,.1);let i=new THREE.Vector3(0,0,0),s=!1;return this._processUpDown(t,i,e),t.get(65)&&(i.x=-1*e),t.get(68)&&(i.x=1*e),t.get(37)&&(this._rotateHorizontal(-B*this._rotationSpeed*e),s=!0),t.get(39)&&(this._rotateHorizontal(B*this._rotationSpeed*e),s=!0),t.get(16)&&(i.x*=3,i.z*=3),!(0===i.x&&0===i.y&&0===i.z&&!s||(i.applyQuaternion(this.getCamera().quaternion),this._cameraPosition.add(new THREE.Vector3(i.x,0,i.z)),this._update(),0))}_processUpDown(t,e,i){(t.get(87)||t.get(38))&&(e.z=-1*i),(t.get(83)||t.get(40))&&(e.z=1*i)}_orbit(t){this._orbitPosition||(this._orbitPosition=new THREE.Vector2(t.x,t.y),this.dispatchEvent(0));let e=t.clone().sub(this._orbitPosition),i=this._domHelper.element instanceof Document?this._domHelper.element.body:this._domHelper.element;e.multiplyScalar(-1),this._rotateHorizontal(2*Math.PI*e.x/i.clientWidth*1),this._rotateVertical(2*Math.PI*e.y/i.clientHeight*1),r(this._orbitPosition,t)||this.dispatchEvent(1),this._orbitPosition.copy(t),this._update()}_moveForward(){this._keyMap.set(87,!0),this._processKeyMap(this._keyMap,.001)}_rotateVertical(t){let e=this._pitch+t;e>this.maxPolarAngle||e<this.minPolarAngle||(this._pitch=e,this._pitch<-Math.PI?this._pitch+=2*Math.PI:this._pitch>Math.PI&&(this._pitch-=2*Math.PI),this._saveYawAndPitch())}getKernelZoomFactor(){return this._camera.zoom}}t("e",O);let Q=(()=>{class t{parse(t,e,i,s){let a=JSON.parse(s);return a.environment?this.load(t,e,i,a):null}load(t,e,i,s){let a,n=s.environment;if(!n)return console.warn("No environment set in scene settings"),Promise.resolve(null);switch(n.type){case"color":a=new Promise(e=>e(new I(t,i,new THREE.Color(n.details.color))));break;case"image":a=new Promise(s=>s(new I(t,i,null,e,n.details.imageUrl)));break;case"floor":a=new Promise(e=>{this._rapiAccess.getMaterial(n.details.material).then(s=>{let a=void 0===n.details.fog||n.details.fog,o=new z(t,i,a);o.changeFloorMaterial(s).then(()=>{e(o)})})});break;case"baked_shadow":a=new Promise(s=>{n.details&&n.details.color?s(new I(t,i,new THREE.Color(n.details.color))):n.details&&n.details.imageUrl?s(new I(t,i,null,e,n.details.imageUrl)):s(new k(t,i))});break;default:console.warn("Could not load environment, return old environment"),a=new Promise(t=>t(i))}return a}}return i([s],t.prototype,"_rapiAccess",void 0),t})(),F=(()=>{class t extends A{constructor(t,e){super(t,e),this._lights=[]}needsBounds(){return!0}updateBounds(t){if(this._cameraLight){const e=this._cameraLight,i=new THREE.Vector3;t.getSize(i);const s=1.5*Math.max(Math.max(i.x,i.y),i.z);this._boundingSize=s,e.shadow.camera.top=s/2,e.shadow.camera.bottom=-s/2,e.shadow.camera.left=-s/2,e.shadow.camera.right=s/2,e.shadow.camera.updateProjectionMatrix()}}loadFromJSON(t){return new Promise(e=>{this._lights=this._dynamicLightSettingLoader.parse(t),this.addToScene(),e()})}loadFromObject(t){return new Promise(e=>{t.lights||e(),this._lights=this._dynamicLightSettingLoader.load(t),this._lights.forEach((t,e)=>{t.userData.movesWithCamera&&(this._cameraLight=t,this._lights.splice(e,1))}),this.addToScene(),e()})}loadFromURL(t){return new Promise((e,i)=>{fetch(new Request(t,{method:"GET"})).then(C).then(t=>this.loadFromObject(t).then(e,i))})}addToScene(){this._lights.forEach(t=>{this._scene.add(t)}),this._cameraLight&&this._scene.add(this._cameraLight)}update(t,e){if(!this._cameraLight)return;let i=new THREE.Vector3;t.getWorldDirection(i),i.multiplyScalar(-this._boundingSize);let s=e.clone().add(i);this._cameraLight.position.copy(s)}removeFromScene(){this._lights.forEach(t=>{this._scene.remove(t)}),this._cameraLight&&this._scene.remove(this._cameraLight)}reload(){this.removeFromScene(),this.addToScene()}showGUI(){let t=g();this._cameraLight&&this._addToGUI(t,this._cameraLight),this._lights.forEach(e=>{this._addToGUI(t,e)})}_addToGUI(t,e){t&&(e instanceof THREE.SpotLight&&this._addSpotLightToGUI(t,e),e instanceof THREE.AmbientLight&&this._addAmbientLightToGUI(t,e),e instanceof THREE.DirectionalLight&&this._addDirectionalLightToGUI(t,e),e instanceof THREE.RectAreaLight&&this._addRectAreaLightToGUI(t,e))}_addRectAreaLightToGUI(t,e){let i=t.addFolder(e.name),s={name:e.name,color:"#"+e.color.getHexString(),intensity:e.intensity*(e.width*e.height)};i.add(e,"visible"),i.add(s,"intensity").min(10).max(400).step(10).onChange(t=>{e.intensity=t/(e.width*e.height)}),i.add(e,"castShadow"),i.addColor(s,"color").onChange(t=>{e.color=new THREE.Color(t)}),i.add(e.position,"x").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"y").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"z").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))})}_addSpotLightToGUI(t,e){let i=t.addFolder(e.name),s={name:e.name,color:"#"+e.color.getHexString(),angle:180*e.angle/Math.PI};i.add(e,"visible"),i.add(e,"intensity").min(0).max(5).step(.1),i.add(e,"penumbra").min(0).max(1).step(.1),i.addColor(s,"color").onChange(t=>{e.color=new THREE.Color(t)}),i.add(s,"angle").min(10).max(180).step(1).onChange(t=>{e.angle=t*Math.PI/180}),i.add(e.position,"x").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"y").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"z").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))})}_addAmbientLightToGUI(t,e){let i={name:e.name,color:"#"+e.color.getHexString()},s=t.addFolder(e.name);s.add(e,"visible"),s.add(e,"intensity").min(0).max(5).step(.1),s.addColor(i,"color").onChange(t=>{e.color=new THREE.Color(t)})}_addDirectionalLightToGUI(t,e){let i=t.addFolder(e.name),s={name:e.name,color:"#"+e.color.getHexString()};i.add(e,"visible"),i.add(e,"intensity").min(0).max(5).step(.1),i.addColor(s,"color").onChange(t=>{e.color=new THREE.Color(t)}),i.add(e,"castShadow"),i.add(e.position,"x").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"y").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))}),i.add(e.position,"z").min(-10).max(10).step(.1).onChange(()=>{e.lookAt(new THREE.Vector3(0,0,0))})}}return i([s],t.prototype,"_dynamicLightSettingLoader",void 0),t})();class V{constructor(){this._settings=new window.PIXOTRON.QualitySettings(5),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!0,this._settings.useHDREnv=!0,this._settings.useGBuffer=!0,this._settings.ssr=!0,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!0},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class U{constructor(){this._settings=new window.PIXOTRON.QualitySettings(4),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!0,this._settings.useHDREnv=!0,this._settings.useGBuffer=!0,this._settings.ssr=!0,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!0},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class G{constructor(){this._settings=new window.PIXOTRON.QualitySettings(3),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!0,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!0},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class j{constructor(){this._settings=new window.PIXOTRON.QualitySettings(2),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!1,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!1},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class N{constructor(){this._settings=new window.PIXOTRON.QualitySettings(1),this._settings.enableAA=!0,this._settings.useAreaLight=!0,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!1,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!1,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!1},this._settings.shadowQualitySettings={enabled:!0,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class Z{constructor(){this._settings=new window.PIXOTRON.QualitySettings(0),this._settings.enableAA=!1,this._settings.useAreaLight=!1,this._settings.useDevicePixelRatio=!1,this._settings.useHDREnv=!1,this._settings.useGBuffer=!0,this._settings.ssr=!1,this._settings.saoQualitySettings={enabled:!1,downscale:1,enabledOnMove:!0,useNormalWeights:!0,useAccumulative:!1,enableBlur:!1},this._settings.shadowQualitySettings={enabled:!1,downscale:1,enabledOnMove:!0}}getSettings(){return this._settings}}class W{constructor(t){this._sceneBoundingSphere=new THREE.Sphere,this._pixotron=t,this._initializeQualitySettings(),this._initializeQualityAdapters()}getPixotronInstance(t){const e={saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,bias:.02,accumulative:!1},shadowparams:{shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.05,nearPlane:.01,farPlane:50,fov:40,numSamples:100,side:THREE.FrontSide}};return t=t||e,new window.PIXOTRON.Pixotron(t)}showGUI(){let t=g();if(!t)return;let e=t.addFolder("Renderer");e.add(this._pixotron.getSAOPass(),"enabled"),this._pixotron.getSAOPass().smoothTransition&&e.add(this._pixotron.getSAOPass(),"smoothTransition"),e.add(this._pixotron.getSAOPass(),"occlusionWorldRadius").min(0).max(1).step(1e-4).onChange(t=>{this._adjustSaoRadius(t)}),e.add(this._pixotron.getSAOPass(),"intensity").min(.1).max(2).step(.05),e.add(this._pixotron.getSAOPass(),"bias").min(0).max(1).step(1e-4).onChange(t=>{this._adjustSaoBias(t)}),this._pixotron.getSAOPass().numSamples&&e.add(this._pixotron.getSAOPass(),"numSamples").min(10).max(3e3).step(10),void 0!==this._pixotron.getShadowPass().enabled&&e.add(this._pixotron.getShadowPass(),"enabled"),e.add(this._pixotron.getShadowPass(),"smoothTransition"),e.add(this._pixotron.getShadowPass(),"enableAccumulation"),e.add(this._pixotron.getShadowPass(),"shadowRadius").min(0).max(5).step(.1),e.add(this._pixotron.getShadowPass(),"shadowBiasMultiplier").min(0).max(3).step(.01),e.add(this._pixotron.getShadowPass(),"numSamples").min(10).max(3e3).step(10)}updateBounds(t){this._sceneBoundingSphere.copy(t);const e=.25*this._getMaxSaoRadius();this._adjustSaoRadius(e);const i=2*this._getMinSaoBias();this._adjustSaoBias(i)}_getSaoRadius(){return this._sceneBoundingSphere.radius}_adjustSaoRadius(t){const e=this._pixotron.getSAOPass(),i=this._getMinSaoRadius(),s=this._getMaxSaoRadius();e.occlusionWorldRadius=Math.min(Math.max(t,i),s)}_adjustSaoBias(t){const e=this._pixotron.getSAOPass(),i=this._getMinSaoBias(),s=this._getMaxSaoBias();e.bias=Math.min(Math.max(t,i),s)}_getMinSaoRadius(){return.001*this._getSaoRadius()}_getMaxSaoRadius(){return.6*this._getSaoRadius()}_getMinSaoBias(){return.001*this._getSaoRadius()}_getMaxSaoBias(){return.01*this._getSaoRadius()}updatePixelRatio(t){const e=new THREE.Vector2;t.getDrawingBufferSize(e),this._pixotron.setSize(Math.floor(e.width),Math.floor(e.height))}getHighPixelRatioQualitySetting(){return this._highPixelRatioQualitySetting.getSettings()}getLowestQualitySetting(){return this._lowQualitySetting.getSettings()}_initializeQualitySettings(){this._highestQualitySetting=new U,this._highPixelRatioQualitySetting=new V,this._highQualitySetting=new G,this._midQualitySetting=new j,this._lowQualitySetting=new N,this._lowestQualitySetting=new Z}_initializeQualityAdapters(){this._autoQualityAdapter=new window.PIXOTRON.AutoQualityAdapter(this._pixotron),this._autoQualityAdapter.addQuality(this._highestQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._highQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._midQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._lowQualitySetting.getSettings()),this._autoQualityAdapter.addQuality(this._lowestQualitySetting.getSettings()),this._autoQualityAdapter.setDesiredFps(20),this._manualQualityAdapter=new window.PIXOTRON.ManualQualityAdapter(this._pixotron)}onAutoQualityChange(t){this._autoQualityAdapter.onQualityChange(t)}onManualQualityChange(t){this._manualQualityAdapter.onQualityChange(t)}getAutoAdapter(){return this._autoQualityAdapter}lockAdapter(){this._autoQualityAdapter.getCurrentQualitySetting().lock()}unLockAdapter(){this._autoQualityAdapter.getCurrentQualitySetting().unLock()}enablePixotronAutoQuality(){this._currentQualityAdapter||(this._currentQualityAdapter=this._autoQualityAdapter,this._pixotron.setQualityAdapter(this._autoQualityAdapter))}movingCameraStarts(){this._currentQualityAdapter&&(this._currentQualityAdapter=this._autoQualityAdapter,this._currentQualitySetting&&(this._manualQualityAdapter.setQualitySetting(this._currentQualitySetting),this._pixotron.setQualityAdapter(this._manualQualityAdapter)),this._pixotron.setQualityAdapter(this._autoQualityAdapter))}movingCameraStops(){this._currentQualityAdapter&&(this._currentQualitySetting=this._currentQualityAdapter.getCurrentQualitySetting(),this._currentQualityAdapter=this._manualQualityAdapter,this._pixotron.setQualityAdapter(this._manualQualityAdapter),this._manualQualityAdapter.setQualitySetting(this._highestQualitySetting.getSettings()))}}t("S",(()=>{class t{constructor(t,e,i,s="3D"){this._depthWriteMaterial=new THREE.MeshBasicMaterial({colorWrite:!1}),this._maxAnisotropy=1,this._clock=new THREE.Clock,this._delta=0,this._renderListener=null,this._stopRendering=!1,this._forceRender=!1,this._updateShadowsAndAO=!0,this._lastChange=Date.now(),this._running=!1,this._onAfterRender=()=>{},this._creator_=t,this._canvasID=i,this.createCameraControl(s,e),this._setupScene(e,!1),this._lifeCycleManager.addEventListener(this)}onBeforeRender(){}_changeCameraControl(t){this._cameraControl&&this._cameraControl.cleanUp(),t instanceof O&&(this._getInputManager().removeEventListener(7,this._renderListener),this._getInputManager().removeEventListener(8,this._renderListener)),this._cameraControl instanceof O&&(this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this)),(t instanceof D||t instanceof O)&&this._environment instanceof k&&this._environment.disable(),t instanceof M&&this._environment instanceof k&&this._environment.enable(),this._cameraControl=t,this.cameraControlChanged()}cameraControlChanged(){}_addCameraControlListener(){this._cameraControl.addEventListener(0,this._requestRender,this),this._cameraControl.addEventListener(1,this._requestRender,this),this._cameraControl.addEventListener(2,this._requestRender,this),this._cameraControl.addEventListener(6,this._requestRender,this)}_renderEverything(){this._pixotron&&(this._forceRender=!0,this._updateShadowsAndAO=!0),this._requestRender()}_renderWithoutShadowsAndAO(){this._pixotron&&(this._forceRender=!0,this._updateShadowsAndAO=!1),this._requestRender()}_requestRender(){if(!this._renderer||this._stopRendering)return;const t=()=>{var e;this._delta=this._clock.getDelta(),this._animateCamera(),this._cameraControl.getCamera().layers.mask=65535,null===(e=this._statsHelper)||void 0===e||e.updateRenderInfo(this._renderer.info),this._renderLoopFunction&&(this._renderLoopFunction(),this._renderLoopFunction=null),this.onBeforeRender(),this._pixotron&&(this._pixotron.autoShadowsClear=this._updateShadowsAndAO,this._pixotron.autoSAOClear=this._updateShadowsAndAO,this._forceRender&&(this._pixotron.needsUpdate=!0),this._pixotron.render(this._renderer,this._scene,this._cameraControl.getCamera(),this._renderTarget),this._forceRender=!1,this._updateShadowsAndAO=!0,this._pixotron.blit(),this._shouldRenderUi()&&this._renderUi()),this._onAfterRender(),window.TWEEN&&TWEEN.update(),this._lastChange+3e3<Date.now()||this._stopRendering?this._running=!1:(this._running=!0,requestAnimationFrame(t))};this._lastChange=Date.now(),this._running||this._stopRendering||(this._running=!0,requestAnimationFrame(t))}_shouldRenderUi(){return this._pluginSystem&&this._pluginSystem.needsUiScene()}_renderUi(){const t=this._scene.background?this._scene.background.clone():null;this._scene.overrideMaterial=this._depthWriteMaterial,this._scene.background=null,this._renderer.render(this._scene,this._cameraControl.getCamera()),this._scene.overrideMaterial=null;const e=this._renderer.autoClear;this._renderer.autoClear=!1,this._renderer.clearDepth(),this._renderer.render(this._uiScene,this._cameraControl.getCamera()),this._renderer.autoClear=e,this._scene.background=t}_animateCamera(){this._cameraControl&&(!this._cameraControl.animateCamera(this._delta)&&this.shouldClearShadowsAndAO()&&this._pixotron&&!this._forceRender?(this._pixotron.autoShadowsClear=!1,this._pixotron.autoSAOClear=!1):(this._lightSetting instanceof F&&this._cameraControl.getCamera()instanceof THREE.PerspectiveCamera&&this._lightSetting.update(this._cameraControl.getCamera(),this._cameraControl.getTargetPosition()),this._pixotron&&(this._pixotron.needsUpdate=!0))),this._environment&&this._environment.needsCamera()&&this._cameraControl instanceof M&&this._environment.updateCamera(this._cameraControl.getCamera())}shouldClearShadowsAndAO(){return!1}_setupScene(t,e){const{x:i,y:s}=this._domHelper.getClientDimensions();this._scene=new THREE.Scene,this._uiScene=new THREE.Scene,(e=e||!1)||(this._scene.background=new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND));const a={format:THREE.RGBAFormat,minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter},n=THREE.sRGBEncoding,o=Math.floor(i*window.devicePixelRatio),r=Math.floor(s*window.devicePixelRatio);this._renderTarget=new THREE.WebGLRenderTarget(o,r,a),this._renderTarget.texture.encoding=n,this._renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(i,s),this._renderer.outputEncoding=THREE.sRGBEncoding,this._renderer.autoClear=!1,this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=THREE.PCFSoftShadowMap,this._maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._renderer.domElement.classList.add(this._canvasID),this._domHelper.element.appendChild(this._renderer.domElement),this._getInputManager().addEvents(this._renderer.domElement),this._environmentLoader.setRendererAndScene(this._renderer,this._scene),this._environmentLoader.registerEnvironmentChangedCallback(()=>this._requestRender()),this._requestRender(),window.addEventListener("resize",this,!1),window.addEventListener("keydown",this,!1),window.addEventListener("keyup",this,!1),document.addEventListener("visibilitychange",this),this._pluginSystem.init(this._scene,this._uiScene,this._cameraControl.getCamera().position),this._addCameraControlListener(),this.sceneChanged()}_tabVisible(){this.updateCamera(!1)}updateCamera(t=!0){const{x:e,y:i}=this._domHelper.getClientDimensions();this._renderer.setSize(e,i);const s=this._renderer.getPixelRatio();if(this._renderTarget){const t=Math.floor(e*s),a=Math.floor(i*s);this._renderTarget.setSize(t,a)}if(this._pixotron)try{this._pixotron.setSize(e,i)}catch(t){console.warn(t)}this._cameraControl.updateCamera(),this._renderEverything()}_onWindowResize(){const t=this._getInputManager();t&&t.updateSize(),this.updateCamera(),this._requestRender()}_isPartOfScene(t){return"Object3D"===t.type||"Mesh"===t.type||"GLB"===t.type||"GLTF"===t.type||"Group"===t.type}cleanUp(){this._getInputManager().removeEventListener(7,this._renderListener),this._getInputManager().removeEventListener(8,this._renderListener),this._cameraControl&&this._cameraControl.cleanUp(),this._stopRendering=!0}clearScene(){let t=[];this._scene.children.forEach(e=>{this._isPartOfScene(e)&&t.push(e)}),t.forEach(t=>{S(t),this._scene.remove(t)}),this._renderer.renderLists.dispose()}enableHD(t){this._renderer.capabilities.maxTextures>8&&t&&this.loadDynamicLightSetting(t),this._pixotron=new window.PIXOTRON.Pixotron(this.getPixotronParams()),this._pixotron.enableAA=!1,this._pixotronUtil=new W(this._pixotron),this._initData.autoQuality&&this._enableAutoQuality(),this._environment instanceof k&&(this._environment.setPixotron(this._pixotron,this._renderer,this._cameraControl.getCamera(),this.getBakedShadowParams()),this._environment.setLoadedCallback(()=>setTimeout(()=>this._requestRender(),500))),this._requestRender()}_enableAutoQuality(){this._pixotronUtil.enablePixotronAutoQuality();const t=this._pixotronUtil.getAutoAdapter();this._pixotronUtil.onAutoQualityChange((e,i)=>{var s;null===(s=this._statsHelper)||void 0===s||s.updateQualityInfo(e);const a=this._pixotronUtil.getLowestQualitySetting();if(this._enableSSR(e.ssr),i&&e.getQuality()<i.getQuality()&&t.getAverageFps()<5&&t.setQualitySetting(a),this._renderer.getPixelRatio()>1&&!e.useDevicePixelRatio){this._renderer.setPixelRatio(1);const{x:t,y:e}=this._domHelper.getClientDimensions();try{this._pixotron.setSize(t,e)}catch(t){console.warn(t)}this._renderTarget&&this._renderTarget.setSize(t,e)}}),this._pixotronUtil.onManualQualityChange((t,e)=>{var i;null===(i=this._statsHelper)||void 0===i||i.updateQualityInfo(t),this._enableSSR(t.ssr)}),this._pixotronUtil.lockAdapter()}_enableSSR(t=!1){const e=void 0!==this._initData.ssr&&this._initData.ssr;this._pixotron.getSSRPass().enabled=!!e&&t}_loadGLTF(t,e,i,s,a,n,o){return new Promise((r,h)=>{this._staticItemLoader.loadGLTF(t,e,i,s,a,n,null,o).then(t=>{this._setCamera("GLTF",t),r(t)},h)})}_loadGLB(t,e,i,s,a,n,o,r){return new Promise((h,_)=>{this._staticItemLoader.loadGLB(t,e,i,s,a,n,o,r).then(t=>{this._setCamera("GLB",t),h(t)},_)})}_setCamera(t,e){if(!e)return void console.warn("could not set camera for gltf",e);const i=new THREE.Box3;i.setFromObject(e),"GLB"===t?this._cameraControl instanceof M&&this._cameraControl.updateToBounds(i,!1):"GLTF"===t&&(this._cameraControl instanceof M&&this._cameraControl.updateAndReset(i.getSize(new THREE.Vector3),i.getCenter(new THREE.Vector3),-15,70,5,!1),this._cameraControl instanceof D&&this._cameraControl.zoomToFitBounds(i,!0)),this.updateCamera()}async showGUI(){if(this._initData.disableDebugGUI)return;const t=document.createElement("style");t.innerText=".dg.main{position:absolute;z-index:100;top:0;left:0;}",document.head.appendChild(t),await this._scriptLoader.fetch("static/dat.gui.min-b5cbb61e5c62f0bf.js",{id:"dat-gui-js"});let e=g(!1);e&&(this._domHelper.element.appendChild(e.domElement),this._guiLoaded())}_guiLoaded(){let t=g();t&&(this._lightSetting&&this._lightSetting.showGUI(),this._pixotron&&this._pixotronUtil.showGUI(),this._environment&&this._environment.showGUI(),this._addGUIListener(t))}_addGUIListener(t){let e=t.__folders;Object.keys(e).forEach(t=>{let i=e[t];i.__folders&&Object.keys(i.__folders).forEach(t=>{let i=e[t];this._addGUIListener(i)}),i.__controllers&&i.__controllers.forEach(t=>{t.onFinishChange(()=>{this._guiParamChanged()})})})}_guiParamChanged(){this._renderEverything()}showStats(){e.import("./stats-helper-47d4bb11.legacy.js").then(t=>this._statsHelper=new t.default)}_onKeyDown(t){}_onKeyUp(t){}pause(){this._getInputManager().removeEvents(this._renderer.domElement),window.removeEventListener("resize",this,!1),window.removeEventListener("keydown",this,!1),window.removeEventListener("keyup",this,!1),document.removeEventListener("visibilitychange",this)}resume(){let t=this._domHelper.getClientDimensions(),e=t.x,i=t.y;if(this._renderTarget){const t=Math.floor(e*window.devicePixelRatio),s=Math.floor(i*window.devicePixelRatio);this._renderTarget.setSize(t,s)}this._renderer.domElement.classList.add(this._canvasID),this._domHelper.element.appendChild(this._renderer.domElement),this._getInputManager().addEvents(this._renderer.domElement),window.addEventListener("resize",this,!1),window.addEventListener("keydown",this,!1),window.addEventListener("keyup",this,!1),document.addEventListener("visibilitychange",this),this.updateCamera()}destroy(){this.pause(),this.cleanUp()}handleEvent(t){switch(t.type){case"resize":this._onWindowResize();break;case"keydown":if(t.target&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement))break;this._onKeyDown(t);break;case"keyup":if(t.target&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement))break;this._onKeyUp(t);break;case"visibilitychange":this._tabVisible()}}async loadSceneSettings(t){let e,i;return e=t.environment?new Promise(e=>{(new Q).load(this._scene,this._renderer.domElement,this._environment,t).then(t=>{this._setEnvironment(t),e()})}):Promise.resolve(),t.lights?(this._lightSetting=new F(this._scene,this._lightSetting),i=this._lightSetting.loadFromObject(t)):i=Promise.resolve(),new Promise((t,s)=>{Promise.all([e,i]).then(()=>{this._renderEverything(),t()},s)})}setBackgroundColor(t){this._setEnvironment(new I(this._scene,this._environment,new THREE.Color(t)))}setBackgroundImage(t){this._setEnvironment(new I(this._scene,this._environment,null,this._renderer.domElement,t))}setBakedShadow(t,e){this._setEnvironment(new I(this._scene,this._environment,new THREE.Color(t),this._renderer.domElement,e))}_setEnvironment(t){this._environment=t,this._environment instanceof k&&(this._pixotron&&this._environment.setPixotron(this._pixotron,this._renderer,this._cameraControl.getCamera()),this._environment.setLoadedCallback(()=>setTimeout(()=>this._renderEverything(),500))),this._renderEverything()}loadQualitySetting(t){this._pixotron&&(new v).set(this._pixotron,t)}async loadDynamicLightSetting(t){this._lightSetting=new F(this._scene,this._lightSetting);let e=!1;if(t.url)await this._lightSetting.loadFromURL(t.url),e=!0;else if(t.json)await this._lightSetting.loadFromJSON(t.json),e=!0;else if(t.object)await this._lightSetting.loadFromObject(t.object),e=!0;else if(t.ls){const i=P.createDynamicLightSettingSource(null,t.ls);await this._lightSetting.loadFromURL(i.url),e=!0}if(!e)throw new Error("No dynamic light setting source set");this._requestRender()}getScene(){return this._scene}updateScene(){this._updateBounds(this.getBounds()),this._renderEverything()}_updateBounds(t,e=!1){if(t){if(this.updateEnvironment(t,e),this._lightSetting&&this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(t),this._pixotronUtil){const e=new THREE.Sphere;t.getBoundingSphere(e),this._pixotronUtil.updateBounds(e)}this._requestRender(),this._pluginSystem.updateBounds(t)}}setCameraOffset(t){const e=this._cameraControl.getCamera(),i=e||e;(null==i?void 0:i.offset)?(i.offset=t,this._renderEverything()):console.warn("Cannot set offset, current camera does not support it")}getCameraOffset(){const t=this._cameraControl.getCamera(),e=t||t;return(null==e?void 0:e.offset)?JSON.parse(JSON.stringify(e.offset)):{left:0,top:0,right:1,bottom:1}}getOrthographicOffsetCamera(){const t=this.getCameraOffset(),e=this._domHelper.getClientDimensions();let i=e.x/e.y*5,s=b().createOrthographicCamera(i/-2,i/2,2.5,-2.5,1,1e3,t);return s.position.set(0,10,0),s.lookAt(new THREE.Vector3(0,0,0)),s}getPerspectiveOffsetCamera(){const t=this.getCameraOffset(),e=this._domHelper.getClientDimensions(),i=e.x,s=e.y;return b().createPerspectiveCamera(30,i/s,.1,20,t)}updateEnvironment(t,e=!1){if(t&&this._environment&&this._environment.needsBounds()){const i=t.getSize(new THREE.Vector3);i.x+i.y+i.z!==0&&this._environment.updateBounds(t.getSize(new THREE.Vector3),e)}}_onCameraIdle(){return!0}_onCameraMove(){return!0}}return i([s],t.prototype,"_domHelper",void 0),i([s],t.prototype,"_scriptLoader",void 0),i([s],t.prototype,"_lifeCycleManager",void 0),i([s],t.prototype,"_staticItemLoader",void 0),i([s],t.prototype,"_environmentLoader",void 0),i([s],t.prototype,"_initData",void 0),i([s],t.prototype,"_pluginSystem",void 0),t})()),t("c","static/pi.min-0272f873b3a4380a.js"),t("P",["static/CopyShader-cde53240fcc3e06e.js","static/EffectComposer-1e936e5d03ff43cc.js","static/RenderPass-bc5df3810a01b2c6.js","static/ShaderPass-31f36160e0ea282d.js","static/LuminosityHighPassShader-dd5826656142421d.js","static/OutlinePass-f4bcd337cdd89b8d.js","static/RectAreaLightUniformsLib-4b74882185efd473.js","static/GammaCorrectionShader-b3b56f244f0d1e0e.js"])}}}));
2
+ //# sourceMappingURL=pixotron-77572ad9.legacy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pixotron-084097ac.legacy.js","sources":["../../../packages/three-build/src/Tween.js","../../../packages/three-build/src/dat.gui.min.js","../../../node_modules/pi/pi.min.js","../../../node_modules/pi/js/shaders/CopyShader.js","../../../node_modules/pi/js/postprocessing/EffectComposer.js","../../../node_modules/pi/js/postprocessing/RenderPass.js","../../../node_modules/pi/js/postprocessing/ShaderPass.js","../../../node_modules/pi/js/shaders/LuminosityHighPassShader.js","../../../node_modules/pi/js/postprocessing/OutlinePass.js","../../../node_modules/pi/js/lights/RectAreaLightUniformsLib.js","../../../node_modules/pi/js/shaders/GammaCorrectionShader.js"],"sourcesContent":["export default \"static/Tween-d024b02fe34f25ab.js\"","export default \"static/dat.gui.min-b5cbb61e5c62f0bf.js\"","export default \"static/pi.min-0272f873b3a4380a.js\"","export default \"static/CopyShader-cde53240fcc3e06e.js\"","export default \"static/EffectComposer-1e936e5d03ff43cc.js\"","export default \"static/RenderPass-bc5df3810a01b2c6.js\"","export default \"static/ShaderPass-31f36160e0ea282d.js\"","export default \"static/LuminosityHighPassShader-dd5826656142421d.js\"","export default \"static/OutlinePass-f4bcd337cdd89b8d.js\"","export default \"static/RectAreaLightUniformsLib-4b74882185efd473.js\"","export default \"static/GammaCorrectionShader-b3b56f244f0d1e0e.js\""],"names":[],"mappings":"yYAAe,o2pDCAA,+xKCAA,4CCAA,wCCAA,4CCAA,wCCAA,wCCAA,sDCAA,yCCAA,sDCAA"}
1
+ {"version":3,"file":"pixotron-77572ad9.legacy.js","sources":["../../../packages/three-build/src/Tween.js","../../../packages/three-build/src/dat.gui.min.js","../../../node_modules/pi/pi.min.js","../../../node_modules/pi/js/shaders/CopyShader.js","../../../node_modules/pi/js/postprocessing/EffectComposer.js","../../../node_modules/pi/js/postprocessing/RenderPass.js","../../../node_modules/pi/js/postprocessing/ShaderPass.js","../../../node_modules/pi/js/shaders/LuminosityHighPassShader.js","../../../node_modules/pi/js/postprocessing/OutlinePass.js","../../../node_modules/pi/js/lights/RectAreaLightUniformsLib.js","../../../node_modules/pi/js/shaders/GammaCorrectionShader.js"],"sourcesContent":["export default \"static/Tween-d024b02fe34f25ab.js\"","export default \"static/dat.gui.min-b5cbb61e5c62f0bf.js\"","export default \"static/pi.min-0272f873b3a4380a.js\"","export default \"static/CopyShader-cde53240fcc3e06e.js\"","export default \"static/EffectComposer-1e936e5d03ff43cc.js\"","export default \"static/RenderPass-bc5df3810a01b2c6.js\"","export default \"static/ShaderPass-31f36160e0ea282d.js\"","export default \"static/LuminosityHighPassShader-dd5826656142421d.js\"","export default \"static/OutlinePass-f4bcd337cdd89b8d.js\"","export default \"static/RectAreaLightUniformsLib-4b74882185efd473.js\"","export default \"static/GammaCorrectionShader-b3b56f244f0d1e0e.js\""],"names":[],"mappings":"yYAAe,o2pDCAA,+xKCAA,4CCAA,wCCAA,4CCAA,wCCAA,wCCAA,sDCAA,yCCAA,sDCAA"}
@@ -1,2 +1,2 @@
1
- System.register(["./query-params-helper-8c00a872.legacy.js","./roomle-dependency-injection-f964807d.legacy.js","./main-thread-to-worker-e2f2b9cb.legacy.js","./roomle-configurator-8d3e7c20.legacy.js","./pixotron-084097ac.legacy.js","./script-loader-d596fefb.legacy.js","./default-light-setting-b4370cc1.legacy.js"],(function(e,t){var n,i,a,s,r,o,l,h,c,d,_,g,p,m,u,C,w,E,v,f,S,b,M,I,P,y,H,L,D,k,O,T,V,R,A,x,j,B,F,W,G,K,U,z,q,N,X,Q,Z,J;return{setters:[function(){},function(e){n=e.h,i=e._,a=e.i,s=e.a0,r=e.f,o=e.N,l=e.S,h=e.W,c=e.c,d=e.a1,_=e.k,g=e.B,p=e.Q,m=e.a2,u=e.g,C=e.w,w=e.a3,E=e.a4,v=e.n,f=e.G,S=e.a5,b=e.E,M=e.D,I=e.L,P=e.a6,y=e.R,H=e.b},function(e){L=e.d,D=e.i,k=e.m},function(e){O=e.S,T=e.C,V=e.P,R=e.G,A=e.p,x=e.a,j=e.g,B=e.R},function(e){F=e.L,W=e.B,G=e.b,K=e.C,U=e.d,z=e.e,q=e.I,N=e.T,X=e.P,Q=e.c},function(e){Z=e.S,J=e.M},function(){}],execute:function(){class Y extends F{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,i=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);i.normalize(),i.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(i),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=n();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class ${constructor(e){const{planElementViewModel:t,resetCamera:n,state:i,oldState:a}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===i?0:i,this.oldState=void 0===a?0:a}}let ee=(()=>{class e extends O{constructor(e,t,n,i){super(e,t,n,i),this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(3,()=>{if(2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.cancelSelection()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new $({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{this.setState(0),this.dispatchEvent(1,new $({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.enable(3),e.enable(7),e.enable(6),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}disableWallEvents(){this._raycastHelper.getLayers().disable(9)}enableWallEvents(){this._raycastHelper.getLayers().enable(9)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_clickElement(e){if(!this._isCurrentlyDrawing){if(this._debug&&e.getId(),2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.check(e),this._setCursor()}}_hoverOn(e){this._isCurrentlyDrawing||(this._hoveredObject=e,this._setCursor())}_hoverOff(e){this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?D("ew-resize"):1===this._state?D("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?D("move"):this._hoveredObject?D("pointer"):3===this._state?D(s?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):D("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){this._plannerSelectionHandler.isSelected(e.getId())&&0===this._state&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(4,new $({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let i=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanObject())),n.moveObjectsBy(e,r(i))}else n.moveElementTo(e.getPlanElement(),r(t));this.dispatchEvent(5,new $({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(6,new $({planElementViewModel:e})),this._dragIn&&(this.cancelSelection(),this.setDragIn(!1)),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,i=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),i.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new $({state:this._state,oldState:t})),this._position=null,2===this._state&&this.planInteractionHandler.deactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:i}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const a=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(a.push_back(n.getPlanObject()),s.expandByObject(n.getContainer()))});const o=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(a,t,r(o)),this._position.copy(new THREE.Vector3(n,i,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}selectPlanElement(e){this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(0,new $({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.reactivateAllSnappingActivity(),this.isSnappingActive=!0}disableSnapping(){this.planInteractionHandler.deactivateAllSnappingActivity(),this.isSnappingActive=!1}enableWallDrawing(){this._inputManager.addEventListener(12,this._toggleDrawing,this),this._inputManager.addEventListener(5,this._createNode,this),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(14,this._startWallDrawing,this),this._inputManager.addEventListener(13,this._endWallDrawing,this)}cancelWallDrawing(){this._setStateAndCursor(0),this._inputManager.removeEventListener(12,this._toggleDrawing),this._inputManager.removeEventListener(5,this._createNode),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(14,this._startWallDrawing),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear()}escapeDrawing(){this.planInteractionHandler.endInteraction(),this.planInteractionHandler.cancelDrawing(),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(12)}_toggleDrawing(e){this._isCurrentlyDrawing?this._endWallDrawing():this._startWallDrawing(e)}_endWallDrawing(){this._isCurrentlyDrawing&&(this._isCurrentlyDrawing=!1,this.dispatchEvent(12),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this.planInteractionHandler.cancelDrawing(),this._setStateAndCursor(0))}_startWallDrawing(e){this._isCurrentlyDrawing=!0,2===e.type&&this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.startInteraction(),this._setStateAndCursor(3),this._getIntersectPointWithScene(e),this.planInteractionHandler.beginDrawing({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(11)}_drawWallOnMouseMove(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.currentDrawingPosition({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(10))}_createNode(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this._raycastHelper.clear(),this.planInteractionHandler.endInteraction())}_getIntersectPointWithScene(e){this._point=this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}}return i([a],e.prototype,"_plannerSelectionHandler",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),e})(),te=(()=>{class e extends T{constructor(e,t,n,i){super(e,t,i),this._staticItemGuard=new o,this._configurableItemGuard=new o,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new ee(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof l&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e)},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel()},this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof h&&this._sendWallDimensions(),this._environment instanceof W&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(5,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(6,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof W&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),r(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planCleared(){}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new V(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),i=e.distanceTo(n),a=t.getSize(new THREE.Vector3),s=Math.max(a.x,a.z)+3;if(i>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof l&&(t="static"),e instanceof c&&(t="configuration"),e instanceof h&&(t="wall",n.wall=e.getWallDimension()),e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const t=e.getConfigurationRuntimeId();n.configurationRuntimeId=t}const i=(async()=>{const n={};if(e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const i=e.getConfigurationRuntimeId(),a=e.getPlanObject().getCatalogItemId(),s=this._getKernelAccess().kernelInstance.getHashOfConfiguration(i);let r;if(this._configuratorContext.planObjectId=i,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),a&&C(a)){const e=await this._rapiAccess.getItem(a);n.item=e,r=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(s);n.configuration=e,r=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+s+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(i),a=await this._rapiAccess.saveConfiguration(t);n.configuration=a,r=a.rootComponentId?a.rootComponentId:null}if(r){const e=await this._rapiAccess.getComponent(r);n.component=e}n.configurationRuntimeId=i,t="configuration"}return k(n)})();this.currentSelection=k(n),this._roomlePlannerUiCallback.onSelectionChange(k(this._plannerSceneEventHandler.getSelectionMode()),k(t),this.currentSelection,i)}_onSelectionCancel(e){this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._lightSetting=new Y(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new G(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new W(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof K&&this._plannerMeshGenerator.wallMeshes.forEach(e=>d(this._cameraControl.getCamera(),e.material))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const t=this._plannerSceneEventHandler.getSelectedIds();if(1===t.length&&this._cameraControl instanceof K){const e=this._getViewModel().getPlanObjectForId(t[0]);this._cameraControl.setObjectRotation(e.getPlanElement().rotation)}const{planObjectId:n,planElementId:i}=this._configuratorContext;this._getViewModel().hideAllExcept(i),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(n),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(n),this.updateEnvironment(this.getBounds(),!0);const a=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==a||a.startInteraction()}selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,i)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},i)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=_(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=_(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),g.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,i,a,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();p(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.selectPlanElement(e),this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}setTimeout(()=>{this._zoomToBounds(!1)},0),this._renderEverything()}removePlanObjectFromScene(e){this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds()),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}exportGLB(e,t){this._scriptLoader.fetch(R,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof Y&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){this._onCameraMove(),this._cameraControl instanceof U||(this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("2D"),this._renderEverything(),this._changeCameraControl(new U(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("2D"),this._setCameraControlListeners())}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof K||(this._getViewModel().setCameraType("3D"),this._renderEverything(),this._changeCameraControl(new K(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("3D"),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){const e=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof z?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof K&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof z)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("FP"),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new z(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("FP"),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case"2D":this.switchTo2D();break;case"3D":this.switchTo3D();break;case"FP":this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,i,a,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){if(e||(e=this.getBounds()),e){if(this._cameraControl instanceof K){const t=e.getSize(new THREE.Vector3),n=Math.max(t.x,t.z),i=this._initData.moc?.5*n*-1:5,a=this._initData.moc?q:70;this._cameraControl.updateAndReset(t,e.getCenter(new THREE.Vector3),-15,a,i,!1)}this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(e,!0)}}_zoomToBounds(e){const t=this.getBounds();this._cameraControl instanceof K&&this._cameraControl.zoomToFitBounds(t),this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(t,e)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof U&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(t.push_back(i.getPlanObject()),n.expandByObject(i.getContainer()))});const i=n.getCenter(new THREE.Vector3),a=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(a,e,r(i))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let i=await A(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(i)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof K?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let i=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const a=await x(this._scene,null,n,i,e);this._lightSetting.addToScene(),this._requestRender(),t(a)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return j(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),!0}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=[];this._getViewModel().getStaticPlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._getViewModel().getConfigurablePlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._roomlePlannerUiCallback.enablePlanObjectPositions(n)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:i}=this._domHelper.element;this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{const a=e.getWallDimension();if(a.length>0&&(a.fromPosition2d=u(a.fromPosition3d,this._cameraControl.getCamera(),n,i),a.toPosition2d=u(a.toPosition3d,this._cameraControl.getCamera(),n,i),a.textPosition2d=u(a.textPosition3d,this._cameraControl.getCamera(),n,i),a.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(a.length),t.push(a)),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(a.fromPosition3d);const i=new THREE.Mesh(e,t);i.position.copy(a.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(a.textPosition3d),this._scene.add(n),this._scene.add(i),this._scene.add(s)}}),this._roomlePlannerUiCallback.enableWallDimensions(t)}enableWallDrawing(){this._drawingEnabled=!0,this._plannerSceneEventHandler.enableWallDrawing(),this._plannerSceneEventHandler.addEventListener(11,this.drawingStart,this),this._plannerSceneEventHandler.addEventListener(12,this.drawingEnd,this)}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._plannerSceneEventHandler.cancelWallDrawing(),this._plannerSceneEventHandler.removeEventListener(11,this.drawingStart),this._plannerSceneEventHandler.removeEventListener(12,this.drawingEnd)}escapeDrawing(){this._plannerSceneEventHandler.escapeDrawing()}drawingStart(){this._cameraControl.lock()}drawingEnd(){this._cameraControl.unlock()}_changeCameraControl(e){super._changeCameraControl(e),e instanceof U&&this._environment instanceof W&&this._plannerSceneEventHandler.enableWallEvents(),(e instanceof K||e instanceof z)&&this._environment instanceof W&&this._plannerSceneEventHandler.disableWallEvents()}}return i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_plannerMeshGenerator",void 0),i([a],e.prototype,"_plannerInputManager",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_localStorageHelper",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();const ne={left:0,top:1,right:1,bottom:0};let ie=(()=>{class e{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return g.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(w,{id:"gltf-loader"}),n=this._scriptLoader.fetch(E,{id:"draco-loader"}),i=this._scriptLoader.fetch(N,{id:"tween-js"}),a=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,i,a]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:i,stats:a}=this._initData;this._sceneManager||(this._sceneManager=new te(this._creator_,ne,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=v.createDynamicLightSettingSource(t,n);a&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const i=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(X.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(Q,{id:"pi-js"}).then(i,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){g.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new B(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,i=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);i&&this._configurator.notifyUiAboutNewLabel(i)}selectPlanObjectById(e){this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-17f905eb.legacy.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-25726a33.legacy.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=r(new THREE.Vector3(t.x,t.y,t.z)));const i=await(C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),a=await this._plannerKernelAccess.addPlanObjectFromItem(i,t,n);return this._sceneManager.updateScene(),a}async insertItemList(e){const t=e.map(e=>C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);await this._plannerKernelAccess.insertItems(n)}async insertItems(e){await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],i=[],a=f(e.objects);await Promise.all(a.map(async e=>{const a=f(e);if(a.catalogItemId?n.push(a.catalogItemId):a.configurationHash&&i.push(a.configurationHash),a.parts){const e=a.configurationHash||a.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(a.parts,e);a.parts=t}a.data=null,t.push(a)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(i)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const h=await this._rapiAccess.getComponents(o),c=new Map;for(const e of h)c.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return f(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e);this.insertItems([n])}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,i;const a=this._planInteractionHandler;a.startInteraction();const s=[];for(const t of e){const e=a.addNode(t.from),r=a.addNode(t.to),o=a.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&a.setWallHeight(o,t.props.height),void 0!==(null===(i=t.props)||void 0===i?void 0:i.thickness)&&a.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||a.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}}return i([a],e.prototype,"_domHelper",void 0),i([a],e.prototype,"_scriptLoader",void 0),i([a],e.prototype,"_kernelAccessCallback",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_singlePromiseFactory",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_lifeCycleManager",void 0),i([a],e.prototype,"_threeLoader",void 0),i([a],e.prototype,"_dataSyncer",void 0),i([a],e.prototype,"_initData",void 0),i([a],e.prototype,"_globalInitData",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();class ae{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const se=[new M("script-loader",Z),new M("planner-input-manager",class extends S{_canDrag(e){return!0}},1),new M("logger",I),new M("planner-mesh-generator",P),new M("rapi-access",y),new M("planner-selection-handler",class extends b{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];e("Planner",class extends J{setupGlobals(){}setupDependencies(){H.setup(se),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new ie(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
- //# sourceMappingURL=planner-ef79f503.legacy.js.map
1
+ System.register(["./query-params-helper-8c00a872.legacy.js","./roomle-dependency-injection-85943177.legacy.js","./main-thread-to-worker-e2f2b9cb.legacy.js","./roomle-configurator-f6cddbe7.legacy.js","./pixotron-77572ad9.legacy.js","./script-loader-cecb38a7.legacy.js","./default-light-setting-edbfae4a.legacy.js"],(function(e,t){var n,i,a,s,r,o,l,h,c,d,_,g,p,m,u,C,w,E,v,f,S,b,M,I,P,y,H,L,D,k,O,T,V,R,A,x,j,B,F,W,G,K,U,z,q,N,X,Q,Z,J;return{setters:[function(){},function(e){n=e.h,i=e._,a=e.i,s=e.a0,r=e.f,o=e.N,l=e.S,h=e.W,c=e.c,d=e.a1,_=e.k,g=e.B,p=e.Q,m=e.a2,u=e.g,C=e.w,w=e.a3,E=e.a4,v=e.n,f=e.G,S=e.a5,b=e.E,M=e.D,I=e.L,P=e.a6,y=e.R,H=e.b},function(e){L=e.d,D=e.i,k=e.m},function(e){O=e.S,T=e.C,V=e.P,R=e.G,A=e.p,x=e.a,j=e.g,B=e.R},function(e){F=e.L,W=e.B,G=e.b,K=e.C,U=e.d,z=e.e,q=e.I,N=e.T,X=e.P,Q=e.c},function(e){Z=e.S,J=e.M},function(){}],execute:function(){class Y extends F{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,i=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);i.normalize(),i.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(i),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=n();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class ${constructor(e){const{planElementViewModel:t,resetCamera:n,state:i,oldState:a}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===i?0:i,this.oldState=void 0===a?0:a}}let ee=(()=>{class e extends O{constructor(e,t,n,i){super(e,t,n,i),this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(3,()=>{if(2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.cancelSelection()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new $({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{this.setState(0),this.dispatchEvent(1,new $({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.enable(3),e.enable(7),e.enable(6),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}disableWallEvents(){this._raycastHelper.getLayers().disable(9)}enableWallEvents(){this._raycastHelper.getLayers().enable(9)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=L(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_clickElement(e){if(!this._isCurrentlyDrawing){if(this._debug&&e.getId(),2===this._state)return this.resetState(),void(this.isSnappingActive&&this.planInteractionHandler.reactivateAllSnappingActivity());this._plannerSelectionHandler.check(e),this._setCursor()}}_hoverOn(e){this._isCurrentlyDrawing||(this._hoveredObject=e,this._setCursor())}_hoverOff(e){this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?D("ew-resize"):1===this._state?D("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?D("move"):this._hoveredObject?D("pointer"):3===this._state?D(s?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):D("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){this._plannerSelectionHandler.isSelected(e.getId())&&0===this._state&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(4,new $({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let i=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanObject())),n.moveObjectsBy(e,r(i))}else n.moveElementTo(e.getPlanElement(),r(t));this.dispatchEvent(5,new $({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(6,new $({planElementViewModel:e})),this._dragIn&&(this.cancelSelection(),this.setDragIn(!1)),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,i=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),i.rotation-t)}}setState(e){const t=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new $({state:this._state,oldState:t})),this._position=null,2===this._state&&this.planInteractionHandler.deactivateAllSnappingActivity()}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:i}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const a=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(a.push_back(n.getPlanObject()),s.expandByObject(n.getContainer()))});const o=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(a,t,r(o)),this._position.copy(new THREE.Vector3(n,i,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}selectPlanElement(e){this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(0,new $({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.reactivateAllSnappingActivity(),this.isSnappingActive=!0}disableSnapping(){this.planInteractionHandler.deactivateAllSnappingActivity(),this.isSnappingActive=!1}enableWallDrawing(){this._inputManager.addEventListener(12,this._toggleDrawing,this),this._inputManager.addEventListener(5,this._createNode,this),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(14,this._startWallDrawing,this),this._inputManager.addEventListener(13,this._endWallDrawing,this)}cancelWallDrawing(){this._setStateAndCursor(0),this._inputManager.removeEventListener(12,this._toggleDrawing),this._inputManager.removeEventListener(5,this._createNode),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(14,this._startWallDrawing),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear()}escapeDrawing(){this.planInteractionHandler.endInteraction(),this.planInteractionHandler.cancelDrawing(),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(12)}_toggleDrawing(e){this._isCurrentlyDrawing?this._endWallDrawing():this._startWallDrawing(e)}_endWallDrawing(){this._isCurrentlyDrawing&&(this._isCurrentlyDrawing=!1,this.dispatchEvent(12),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this.planInteractionHandler.cancelDrawing(),this._setStateAndCursor(0))}_startWallDrawing(e){this._isCurrentlyDrawing=!0,2===e.type&&this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.startInteraction(),this._setStateAndCursor(3),this._getIntersectPointWithScene(e),this.planInteractionHandler.beginDrawing({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(11)}_drawWallOnMouseMove(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.currentDrawingPosition({x:this._point.x,y:this._point.y,z:this._point.z}),this.dispatchEvent(10))}_createNode(e){this._isCurrentlyDrawing&&(this._getIntersectPointWithScene(e),this.planInteractionHandler.forceNode({x:this._point.x,y:this._point.y,z:this._point.z}),this._raycastHelper.clear(),this.planInteractionHandler.endInteraction())}_getIntersectPointWithScene(e){this._point=this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}}return i([a],e.prototype,"_plannerSelectionHandler",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),e})(),te=(()=>{class e extends T{constructor(e,t,n,i){super(e,t,i),this._staticItemGuard=new o,this._configurableItemGuard=new o,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new ee(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof l&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e)},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel()},this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof h&&this._sendWallDimensions(),this._environment instanceof W&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(5,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(6,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof W&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),r(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planCleared(){}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new V(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),i=e.distanceTo(n),a=t.getSize(new THREE.Vector3),s=Math.max(a.x,a.z)+3;if(i>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof l&&(t="static"),e instanceof c&&(t="configuration"),e instanceof h&&(t="wall",n.wall=e.getWallDimension()),e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const t=e.getConfigurationRuntimeId();n.configurationRuntimeId=t}const i=(async()=>{const n={};if(e instanceof l&&(n.item=e.getRapiItem()),e instanceof c){const i=e.getConfigurationRuntimeId(),a=e.getPlanObject().getCatalogItemId(),s=this._getKernelAccess().kernelInstance.getHashOfConfiguration(i);let r;if(this._configuratorContext.planObjectId=i,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),a&&C(a)){const e=await this._rapiAccess.getItem(a);n.item=e,r=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(s);n.configuration=e,r=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+s+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(i),a=await this._rapiAccess.saveConfiguration(t);n.configuration=a,r=a.rootComponentId?a.rootComponentId:null}if(r){const e=await this._rapiAccess.getComponent(r);n.component=e}n.configurationRuntimeId=i,t="configuration"}return k(n)})();this.currentSelection=k(n),this._roomlePlannerUiCallback.onSelectionChange(k(this._plannerSceneEventHandler.getSelectionMode()),k(t),this.currentSelection,i)}_onSelectionCancel(e){this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._lightSetting=new Y(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new G(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new W(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof K&&this._plannerMeshGenerator.wallMeshes.forEach(e=>d(this._cameraControl.getCamera(),e.material))}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const t=this._plannerSceneEventHandler.getSelectedIds();if(1===t.length&&this._cameraControl instanceof K){const e=this._getViewModel().getPlanObjectForId(t[0]);this._cameraControl.setObjectRotation(e.getPlanElement().rotation)}const{planObjectId:n,planElementId:i}=this._configuratorContext;this._getViewModel().hideAllExcept(i),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(n),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(n),this.updateEnvironment(this.getBounds(),!0);const a=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==a||a.startInteraction()}selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof K&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,i)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},i)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=_(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=_(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),g.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,i,a,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();p(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.selectPlanElement(e),this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}setTimeout(()=>{this._zoomToBounds(!1)},0),this._renderEverything()}removePlanObjectFromScene(e){this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds()),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged()}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged()}exportGLB(e,t){this._scriptLoader.fetch(R,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof Y&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){this._onCameraMove(),this._cameraControl instanceof U||(this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("2D"),this._renderEverything(),this._changeCameraControl(new U(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("2D"),this._setCameraControlListeners())}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof K||(this._getViewModel().setCameraType("3D"),this._renderEverything(),this._changeCameraControl(new K(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("3D"),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){const e=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(e)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof z?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof K&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof z)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>m(e.material,!1,!1)),this._getViewModel().setCameraType("FP"),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new z(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged("FP"),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof K&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case"2D":this.switchTo2D();break;case"3D":this.switchTo3D();break;case"FP":this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,i,a,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){if(e||(e=this.getBounds()),e){if(this._cameraControl instanceof K){const t=e.getSize(new THREE.Vector3),n=Math.max(t.x,t.z),i=this._initData.moc?.5*n*-1:5,a=this._initData.moc?q:70;this._cameraControl.updateAndReset(t,e.getCenter(new THREE.Vector3),-15,a,i,!1)}this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(e,!0)}}_zoomToBounds(e){const t=this.getBounds();this._cameraControl instanceof K&&this._cameraControl.zoomToFitBounds(t),this._cameraControl instanceof U&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(t,e)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof U&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(t.push_back(i.getPlanObject()),n.expandByObject(i.getContainer()))});const i=n.getCenter(new THREE.Vector3),a=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(a,e,r(i))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let i=await A(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(i)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof K?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let i=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const a=await x(this._scene,null,n,i,e);this._lightSetting.addToScene(),this._requestRender(),t(a)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return j(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),!0}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=[];this._getViewModel().getStaticPlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._getViewModel().getConfigurablePlanObjectViewModels().forEach(i=>{const a=(new THREE.Box3).setFromObject(i.getContainer()).getCenter(new THREE.Vector3),s={planViewModel:i,position2d:u(a,this._cameraControl.getCamera(),e,t)};n.push(s)}),this._roomlePlannerUiCallback.enablePlanObjectPositions(n)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:i}=this._domHelper.element;this._getViewModel().getWallPlanObjectViewModels().forEach(e=>{const a=e.getWallDimension();if(a.length>0&&(a.fromPosition2d=u(a.fromPosition3d,this._cameraControl.getCamera(),n,i),a.toPosition2d=u(a.toPosition3d,this._cameraControl.getCamera(),n,i),a.textPosition2d=u(a.textPosition3d,this._cameraControl.getCamera(),n,i),a.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(a.length),t.push(a)),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(a.fromPosition3d);const i=new THREE.Mesh(e,t);i.position.copy(a.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(a.textPosition3d),this._scene.add(n),this._scene.add(i),this._scene.add(s)}}),this._roomlePlannerUiCallback.enableWallDimensions(t)}enableWallDrawing(){this._drawingEnabled=!0,this._plannerSceneEventHandler.enableWallDrawing(),this._plannerSceneEventHandler.addEventListener(11,this.drawingStart,this),this._plannerSceneEventHandler.addEventListener(12,this.drawingEnd,this)}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._plannerSceneEventHandler.cancelWallDrawing(),this._plannerSceneEventHandler.removeEventListener(11,this.drawingStart),this._plannerSceneEventHandler.removeEventListener(12,this.drawingEnd)}escapeDrawing(){this._plannerSceneEventHandler.escapeDrawing()}drawingStart(){this._cameraControl.lock()}drawingEnd(){this._cameraControl.unlock()}_changeCameraControl(e){super._changeCameraControl(e),e instanceof U&&this._environment instanceof W&&this._plannerSceneEventHandler.enableWallEvents(),(e instanceof K||e instanceof z)&&this._environment instanceof W&&this._plannerSceneEventHandler.disableWallEvents()}}return i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_plannerMeshGenerator",void 0),i([a],e.prototype,"_plannerInputManager",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_localStorageHelper",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();const ne={left:0,top:1,right:1,bottom:0};let ie=(()=>{class e{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return g.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(w,{id:"gltf-loader"}),n=this._scriptLoader.fetch(E,{id:"draco-loader"}),i=this._scriptLoader.fetch(N,{id:"tween-js"}),a=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,i,a]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:i,stats:a}=this._initData;this._sceneManager||(this._sceneManager=new te(this._creator_,ne,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=v.createDynamicLightSettingSource(t,n);a&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const i=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(X.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(Q,{id:"pi-js"}).then(i,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){g.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new B(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,i=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);i&&this._configurator.notifyUiAboutNewLabel(i)}selectPlanObjectById(e){this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-ab1c48da.legacy.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-ac0f25b4.legacy.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=r(new THREE.Vector3(t.x,t.y,t.z)));const i=await(C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),a=await this._plannerKernelAccess.addPlanObjectFromItem(i,t,n);return this._sceneManager.updateScene(),a}async insertItemList(e){const t=e.map(e=>C(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);await this._plannerKernelAccess.insertItems(n)}async insertItems(e){await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],i=[],a=f(e.objects);await Promise.all(a.map(async e=>{const a=f(e);if(a.catalogItemId?n.push(a.catalogItemId):a.configurationHash&&i.push(a.configurationHash),a.parts){const e=a.configurationHash||a.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(a.parts,e);a.parts=t}a.data=null,t.push(a)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(i)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const h=await this._rapiAccess.getComponents(o),c=new Map;for(const e of h)c.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return f(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e);this.insertItems([n])}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,i;const a=this._planInteractionHandler;a.startInteraction();const s=[];for(const t of e){const e=a.addNode(t.from),r=a.addNode(t.to),o=a.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&a.setWallHeight(o,t.props.height),void 0!==(null===(i=t.props)||void 0===i?void 0:i.thickness)&&a.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||a.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}}return i([a],e.prototype,"_domHelper",void 0),i([a],e.prototype,"_scriptLoader",void 0),i([a],e.prototype,"_kernelAccessCallback",void 0),i([a],e.prototype,"_plannerKernelAccess",void 0),i([a],e.prototype,"_rapiAccess",void 0),i([a],e.prototype,"_singlePromiseFactory",void 0),i([a],e.prototype,"_roomlePlannerUiCallback",void 0),i([a],e.prototype,"_lifeCycleManager",void 0),i([a],e.prototype,"_threeLoader",void 0),i([a],e.prototype,"_dataSyncer",void 0),i([a],e.prototype,"_initData",void 0),i([a],e.prototype,"_globalInitData",void 0),i([a],e.prototype,"_unitFormatter",void 0),e})();class ae{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const se=[new M("script-loader",Z),new M("planner-input-manager",class extends S{_canDrag(e){return!0}},1),new M("logger",I),new M("planner-mesh-generator",P),new M("rapi-access",y),new M("planner-selection-handler",class extends b{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),this.dispatchEvent(1,new ae({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),void this.dispatchEvent(1,new ae({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),this.dispatchEvent(0,new ae({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];e("Planner",class extends J{setupGlobals(){}setupDependencies(){H.setup(se),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new ie(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
2
+ //# sourceMappingURL=planner-c9fae545.legacy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-ef79f503.legacy.js","sources":["../../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"67sCAAe"}
1
+ {"version":3,"file":"planner-c9fae545.legacy.js","sources":["../../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"67sCAAe"}
@@ -1,2 +1,2 @@
1
- System.register(["./query-params-helper-8c00a872.legacy.js","./roomle-dependency-injection-f964807d.legacy.js","./main-thread-to-worker-e2f2b9cb.legacy.js","./roomle-configurator-8d3e7c20.legacy.js","./planner-ef79f503.legacy.js","./pixotron-084097ac.legacy.js","./script-loader-d596fefb.legacy.js","./default-light-setting-b4370cc1.legacy.js"],(function(){var e;return{setters:[function(){},function(){},function(){},function(){},function(n){e=n.Planner},function(){},function(){},function(){}],execute:function(){(new e).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let n=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-n))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)})}}}));
1
+ System.register(["./query-params-helper-8c00a872.legacy.js","./roomle-dependency-injection-85943177.legacy.js","./main-thread-to-worker-e2f2b9cb.legacy.js","./roomle-configurator-f6cddbe7.legacy.js","./planner-c9fae545.legacy.js","./pixotron-77572ad9.legacy.js","./script-loader-cecb38a7.legacy.js","./default-light-setting-edbfae4a.legacy.js"],(function(){var e;return{setters:[function(){},function(){},function(){},function(){},function(n){e=n.Planner},function(){},function(){},function(){}],execute:function(){(new e).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let n=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-n))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)})}}}));
2
2
  //# sourceMappingURL=planner-main.legacy.js.map