@roomle/web-sdk 2.60.0 → 2.61.0-alpha.1
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.
- package/lib/{banana-for-scale-3a114a0c.nomodule.js → banana-for-scale-1b8f041a.nomodule.js} +2 -2
- package/lib/{banana-for-scale-3a114a0c.nomodule.js.map → banana-for-scale-1b8f041a.nomodule.js.map} +1 -1
- package/lib/{banana-for-scale-68a45a69.js → banana-for-scale-411e5a4a.js} +2 -2
- package/lib/{banana-for-scale-68a45a69.js.map → banana-for-scale-411e5a4a.js.map} +1 -1
- package/lib/{component-dimensioning-a8078114.nomodule.js → component-dimensioning-a747c60d.nomodule.js} +2 -2
- package/lib/component-dimensioning-a747c60d.nomodule.js.map +1 -0
- package/lib/{component-dimensioning-64dd804c.js → component-dimensioning-be39c0b1.js} +2 -2
- package/lib/component-dimensioning-be39c0b1.js.map +1 -0
- package/lib/{component-raycast-helper-4f91b663.js → component-raycast-helper-c3888e4b.js} +2 -2
- package/lib/component-raycast-helper-c3888e4b.js.map +1 -0
- package/lib/{component-raycast-helper-ac3b7072.nomodule.js → component-raycast-helper-f110f8df.nomodule.js} +2 -2
- package/lib/component-raycast-helper-f110f8df.nomodule.js.map +1 -0
- package/lib/{configurator-c62d84e8.js → configurator-8a45d794.js} +2 -2
- package/lib/configurator-8a45d794.js.map +1 -0
- package/lib/{configurator-a9c1fe12.nomodule.js → configurator-ba8f2705.nomodule.js} +2 -2
- package/lib/configurator-ba8f2705.nomodule.js.map +1 -0
- package/lib/configurator-main-6b1a9963.js +2 -0
- package/lib/configurator-main-6b1a9963.js.map +1 -0
- package/lib/configurator-main.nomodule.js +1 -1
- package/lib/{continuous-drawing-helper-3b11f9f9.js → continuous-drawing-helper-8234d7be.js} +2 -2
- package/lib/continuous-drawing-helper-8234d7be.js.map +1 -0
- package/lib/{continuous-drawing-helper-7a08e3cf.nomodule.js → continuous-drawing-helper-c5fe700e.nomodule.js} +2 -2
- package/lib/continuous-drawing-helper-c5fe700e.nomodule.js.map +1 -0
- package/lib/{default-light-setting-01a91d0f.nomodule.js → default-light-setting-942df376.nomodule.js} +2 -2
- package/lib/default-light-setting-942df376.nomodule.js.map +1 -0
- package/lib/{default-light-setting-f4f47231.js → default-light-setting-d50d49f0.js} +2 -2
- package/lib/default-light-setting-d50d49f0.js.map +1 -0
- package/lib/definitions/common-core/src/webgl/renderer/screen-space-shadow-map.d.ts +1 -0
- package/lib/{dimensioning-helper-b9457f63.js → dimensioning-helper-1b1e1ca3.js} +2 -2
- package/lib/{dimensioning-helper-b9457f63.js.map → dimensioning-helper-1b1e1ca3.js.map} +1 -1
- package/lib/{dimensioning-helper-3efe98dd.nomodule.js → dimensioning-helper-9ef056d6.nomodule.js} +2 -2
- package/lib/{dimensioning-helper-3efe98dd.nomodule.js.map → dimensioning-helper-9ef056d6.nomodule.js.map} +1 -1
- package/lib/{glb-viewer-1aee8147.js → glb-viewer-8648293c.js} +2 -2
- package/lib/{glb-viewer-1aee8147.js.map → glb-viewer-8648293c.js.map} +1 -1
- package/lib/{glb-viewer-c1c1106b.nomodule.js → glb-viewer-d6255582.nomodule.js} +2 -2
- package/lib/{glb-viewer-c1c1106b.nomodule.js.map → glb-viewer-d6255582.nomodule.js.map} +1 -1
- package/lib/glb-viewer-main-92221a71.js +2 -0
- package/lib/glb-viewer-main-92221a71.js.map +1 -0
- package/lib/glb-viewer-main.nomodule.js +1 -1
- package/lib/legacy/{banana-for-scale-8fde3b6e.legacy.js → banana-for-scale-eb990d71.legacy.js} +2 -2
- package/lib/legacy/{banana-for-scale-8fde3b6e.legacy.js.map → banana-for-scale-eb990d71.legacy.js.map} +1 -1
- package/lib/legacy/{component-dimensioning-0c4f6279.legacy.js → component-dimensioning-5ddf8d0a.legacy.js} +2 -2
- package/lib/legacy/component-dimensioning-5ddf8d0a.legacy.js.map +1 -0
- package/lib/legacy/{component-raycast-helper-e634d9cc.legacy.js → component-raycast-helper-a2d37ac8.legacy.js} +2 -2
- package/lib/legacy/component-raycast-helper-a2d37ac8.legacy.js.map +1 -0
- package/lib/legacy/{configurator-5d8e9e4c.legacy.js → configurator-3ba95484.legacy.js} +2 -2
- package/lib/legacy/configurator-3ba95484.legacy.js.map +1 -0
- package/lib/legacy/configurator-main.legacy.js +1 -1
- package/lib/legacy/{continuous-drawing-helper-d7691e20.legacy.js → continuous-drawing-helper-e7b0526f.legacy.js} +2 -2
- package/lib/legacy/continuous-drawing-helper-e7b0526f.legacy.js.map +1 -0
- package/lib/legacy/{default-light-setting-80b8957f.legacy.js → default-light-setting-95addd85.legacy.js} +2 -2
- package/lib/legacy/default-light-setting-95addd85.legacy.js.map +1 -0
- package/lib/legacy/{dimensioning-helper-8d78ba0a.legacy.js → dimensioning-helper-2dbdb17d.legacy.js} +2 -2
- package/lib/legacy/{dimensioning-helper-8d78ba0a.legacy.js.map → dimensioning-helper-2dbdb17d.legacy.js.map} +1 -1
- package/lib/legacy/{glb-viewer-20b26df0.legacy.js → glb-viewer-6dee4f24.legacy.js} +2 -2
- package/lib/legacy/{glb-viewer-20b26df0.legacy.js.map → glb-viewer-6dee4f24.legacy.js.map} +1 -1
- package/lib/legacy/glb-viewer-main.legacy.js +1 -1
- package/lib/legacy/{material-viewer-83aa0d82.legacy.js → material-viewer-b6d87d4d.legacy.js} +2 -2
- package/lib/legacy/material-viewer-b6d87d4d.legacy.js.map +1 -0
- package/lib/legacy/material-viewer-main.legacy.js +1 -1
- package/lib/legacy/{planner-a0ef7d31.legacy.js → planner-16fc7895.legacy.js} +2 -2
- package/lib/legacy/{planner-a0ef7d31.legacy.js.map → planner-16fc7895.legacy.js.map} +1 -1
- package/lib/legacy/planner-main.legacy.js +1 -1
- package/lib/legacy/{roomle-configurator-7dc323ca.legacy.js → roomle-configurator-658bd821.legacy.js} +2 -2
- package/lib/legacy/roomle-configurator-658bd821.legacy.js.map +1 -0
- package/lib/legacy/roomle-dependency-injection-fe83f5a8.legacy.js +9 -0
- package/lib/legacy/{roomle-dependency-injection-ab58de3d.legacy.js.map → roomle-dependency-injection-fe83f5a8.legacy.js.map} +1 -1
- package/lib/legacy/roomle-sdk.legacy.js +1 -1
- package/lib/legacy/{scene-manager-079c4752.legacy.js → scene-manager-136db902.legacy.js} +2 -2
- package/lib/legacy/{scene-manager-079c4752.legacy.js.map → scene-manager-136db902.legacy.js.map} +1 -1
- package/lib/legacy/{script-loader-35fe01aa.legacy.js → script-loader-bed3087a.legacy.js} +2 -2
- package/lib/legacy/script-loader-bed3087a.legacy.js.map +1 -0
- package/lib/legacy/{stats-helper-40eeaca2.legacy.js → stats-helper-ff57364c.legacy.js} +2 -2
- package/lib/legacy/stats-helper-ff57364c.legacy.js.map +1 -0
- package/lib/legacy/{tools-core-ae90b05b.legacy.js → tools-core-3e70a4f3.legacy.js} +2 -2
- package/lib/legacy/tools-core-3e70a4f3.legacy.js.map +1 -0
- package/lib/{material-viewer-e70173ae.js → material-viewer-90d8260f.js} +2 -2
- package/lib/material-viewer-90d8260f.js.map +1 -0
- package/lib/{material-viewer-4d884001.nomodule.js → material-viewer-b5729235.nomodule.js} +2 -2
- package/lib/material-viewer-b5729235.nomodule.js.map +1 -0
- package/lib/material-viewer-main-d161abcc.js +2 -0
- package/lib/material-viewer-main-d161abcc.js.map +1 -0
- package/lib/material-viewer-main.nomodule.js +1 -1
- package/lib/{planner-7ec2696d.nomodule.js → planner-89c28a23.nomodule.js} +2 -2
- package/lib/{planner-7ec2696d.nomodule.js.map → planner-89c28a23.nomodule.js.map} +1 -1
- package/lib/{planner-2d7a7b1b.js → planner-9ebfcb2b.js} +2 -2
- package/lib/{planner-2d7a7b1b.js.map → planner-9ebfcb2b.js.map} +1 -1
- package/lib/planner-main-cd087802.js +2 -0
- package/lib/planner-main-cd087802.js.map +1 -0
- package/lib/planner-main.nomodule.js +1 -1
- package/lib/{roomle-configurator-42d4fecc.js → roomle-configurator-521e927f.js} +2 -2
- package/lib/roomle-configurator-521e927f.js.map +1 -0
- package/lib/{roomle-configurator-b01d2885.nomodule.js → roomle-configurator-683f0ae0.nomodule.js} +2 -2
- package/lib/roomle-configurator-683f0ae0.nomodule.js.map +1 -0
- package/lib/roomle-dependency-injection-390d51f2.js +16 -0
- package/lib/{roomle-dependency-injection-bf64a07e.js.map → roomle-dependency-injection-390d51f2.js.map} +1 -1
- package/lib/roomle-dependency-injection-f0a6e177.nomodule.js +16 -0
- package/lib/{roomle-dependency-injection-2583f0dc.nomodule.js.map → roomle-dependency-injection-f0a6e177.nomodule.js.map} +1 -1
- package/lib/{roomle-sdk-1ed375ca.js → roomle-sdk-597c482f.js} +2 -2
- package/lib/roomle-sdk-597c482f.js.map +1 -0
- package/lib/roomle-sdk.nomodule.js +1 -1
- package/lib/{scene-manager-45fc4ce6.nomodule.js → scene-manager-9ba0a160.nomodule.js} +2 -2
- package/lib/{scene-manager-45fc4ce6.nomodule.js.map → scene-manager-9ba0a160.nomodule.js.map} +1 -1
- package/lib/{scene-manager-d25d6ad2.js → scene-manager-f66599cf.js} +2 -2
- package/lib/{scene-manager-d25d6ad2.js.map → scene-manager-f66599cf.js.map} +1 -1
- package/lib/{script-loader-92e1532b.nomodule.js → script-loader-2d5e7ddb.nomodule.js} +2 -2
- package/lib/script-loader-2d5e7ddb.nomodule.js.map +1 -0
- package/lib/{script-loader-9059c8a6.js → script-loader-b4f54de0.js} +2 -2
- package/lib/script-loader-b4f54de0.js.map +1 -0
- package/lib/{stats-helper-dd07b86c.nomodule.js → stats-helper-7835a1cb.nomodule.js} +2 -2
- package/lib/stats-helper-7835a1cb.nomodule.js.map +1 -0
- package/lib/{stats-helper-62ea900d.js → stats-helper-f207bbc5.js} +2 -2
- package/lib/stats-helper-f207bbc5.js.map +1 -0
- package/lib/{tools-core-02eb3a98.js → tools-core-1798c674.js} +2 -2
- package/lib/tools-core-1798c674.js.map +1 -0
- package/lib/{tools-core-f5491293.nomodule.js → tools-core-30418d31.nomodule.js} +2 -2
- package/lib/tools-core-30418d31.nomodule.js.map +1 -0
- package/package.json +2 -2
- package/lib/component-dimensioning-64dd804c.js.map +0 -1
- package/lib/component-dimensioning-a8078114.nomodule.js.map +0 -1
- package/lib/component-raycast-helper-4f91b663.js.map +0 -1
- package/lib/component-raycast-helper-ac3b7072.nomodule.js.map +0 -1
- package/lib/configurator-a9c1fe12.nomodule.js.map +0 -1
- package/lib/configurator-c62d84e8.js.map +0 -1
- package/lib/configurator-main-ba699dda.js +0 -2
- package/lib/configurator-main-ba699dda.js.map +0 -1
- package/lib/continuous-drawing-helper-3b11f9f9.js.map +0 -1
- package/lib/continuous-drawing-helper-7a08e3cf.nomodule.js.map +0 -1
- package/lib/default-light-setting-01a91d0f.nomodule.js.map +0 -1
- package/lib/default-light-setting-f4f47231.js.map +0 -1
- package/lib/glb-viewer-main-a9bf8d50.js +0 -2
- package/lib/glb-viewer-main-a9bf8d50.js.map +0 -1
- package/lib/legacy/component-dimensioning-0c4f6279.legacy.js.map +0 -1
- package/lib/legacy/component-raycast-helper-e634d9cc.legacy.js.map +0 -1
- package/lib/legacy/configurator-5d8e9e4c.legacy.js.map +0 -1
- package/lib/legacy/continuous-drawing-helper-d7691e20.legacy.js.map +0 -1
- package/lib/legacy/default-light-setting-80b8957f.legacy.js.map +0 -1
- package/lib/legacy/material-viewer-83aa0d82.legacy.js.map +0 -1
- package/lib/legacy/roomle-configurator-7dc323ca.legacy.js.map +0 -1
- package/lib/legacy/roomle-dependency-injection-ab58de3d.legacy.js +0 -9
- package/lib/legacy/script-loader-35fe01aa.legacy.js.map +0 -1
- package/lib/legacy/stats-helper-40eeaca2.legacy.js.map +0 -1
- package/lib/legacy/tools-core-ae90b05b.legacy.js.map +0 -1
- package/lib/material-viewer-4d884001.nomodule.js.map +0 -1
- package/lib/material-viewer-e70173ae.js.map +0 -1
- package/lib/material-viewer-main-7c8974fa.js +0 -2
- package/lib/material-viewer-main-7c8974fa.js.map +0 -1
- package/lib/planner-main-d56b0156.js +0 -2
- package/lib/planner-main-d56b0156.js.map +0 -1
- package/lib/roomle-configurator-42d4fecc.js.map +0 -1
- package/lib/roomle-configurator-b01d2885.nomodule.js.map +0 -1
- package/lib/roomle-dependency-injection-2583f0dc.nomodule.js +0 -16
- package/lib/roomle-dependency-injection-bf64a07e.js +0 -16
- package/lib/roomle-sdk-1ed375ca.js.map +0 -1
- package/lib/script-loader-9059c8a6.js.map +0 -1
- package/lib/script-loader-92e1532b.nomodule.js.map +0 -1
- package/lib/stats-helper-62ea900d.js.map +0 -1
- package/lib/stats-helper-dd07b86c.nomodule.js.map +0 -1
- package/lib/tools-core-02eb3a98.js.map +0 -1
- package/lib/tools-core-f5491293.nomodule.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as ScriptLoader,M as Main}from"./script-loader-9059c8a6.js";import{Z as getGUI,E as EventDispatcher,W as WallPlanElementViewModel,F as FloorPlanElementViewModel,_ as __decorate,i as inject,h as convertToKernel,N as NodePlanElementViewModel,a8 as isSafari,e as CAMERA_TYPE,a9 as convertToTHREE,c as ConfiguratorPlanObjectViewModel,S as StaticPlanObjectViewModel,aa as INPUT_DELAY_TYPE,ab as threeVectorToTransferableXY,j as getScreenXY,O as convertCObject,ac as AsyncGuard,ad as RenderMode,ae as PLAN_ELEMENT_CHANGE_TYPES,af as hideWallsBasedOnCamera,k as kernelBoxToThreeBox,V as MaterialCreator,ag as fadeIn,ah as viewSpacePositionFromUV,ai as setWallTransparency,d as ConstructionPlanObjectViewModel,aj as getDrawingMinBounds,r as ImageRenderer,ak as wallDimensionToTransferable,H as isIdItemId,B as Benchmark,al as isPlanSnapshotId,p as DynamicLightSettingLoader,am as InputManager,D as DependencyInjectionAssignment,L as Logger,an as PlannerMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-bf64a07e.js";import{L as LightSetting,B as BackgroundEnvironment,C as CameraControl3D,b as CameraControl2D,c as CameraControlFirstPerson,T as TWEEN_FILE_NAME}from"./scene-manager-d25d6ad2.js";import{a as Vector3,A as AmbientLight,C as Color,D as DirectionalLight,V as Vector2,ab as Sphere,bu as Layers,ak as deepMerge,b3 as PlaneGeometry,f as MeshBasicMaterial,x as Mesh,aB as setCursor,aw as wait,aa as Box3,H as Group,aT as ShaderMaterial,aY as UniformsUtils,b8 as BackSide,at as BoxGeometry,bK as copy,aH as SphereGeometry,bL as applyMaterialToKernelMaterial,K as MathUtils}from"./main-thread-to-worker-30982707.js";import{S as SceneEventHandler,C as ConfiguratorSceneManager,P as PlanViewModel,R as RoomleConfigurator}from"./roomle-configurator-42d4fecc.js";import"./query-params-helper-a271f9dc.js";import"./default-light-setting-f4f47231.js";class PlannerLightSetting extends LightSetting{constructor(e,t){super(e,t),this._center=new 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 AmbientLight(new Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new DirectionalLight(new 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 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 Vector3));const t=new Sphere;e.getBoundingSphere(t);const n=t.radius,a=new Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=getGUI();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new 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 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 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))}}}}const isWallOrFloor=e=>e instanceof WallPlanElementViewModel||e instanceof FloorPlanElementViewModel;class PlannerSelectionHandlerEvent{constructor(e){const{planElementViewModel:t,planElementViewModels:n,selectionMode:a,reason:i}=e;this.planElementViewModel=t,this.planElementViewModels=n,this.selectionMode=a,this.reason=i}}class SceneEventInfo{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:s}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i,this.reason=s}}class PlannerSceneEventHandler extends SceneEventHandler{constructor(e,t,n,a){super(e,t,n,a),this._isDrawingEnabled=!1,this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(0,()=>{2!==this._state?this._plannerSelectionHandler.cancelSelection("click_outside"):this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new SceneEventInfo({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(2,({planElementViewModels:e})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(e)},this),this._plannerSelectionHandler.addEventListener(15,({selectionMode:e})=>{"multiselect"===e&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject)},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new SceneEventInfo({planElementViewModel:e,reason:t}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new 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 Layers;e.disableAll(),e.enable(3),e.enable(7),e.enable(6),e.enable(9),e.enable(2),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(9):this._raycastHelper.getLayers().disable(9)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(6):this._raycastHelper.getLayers().disable(6)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getObject(),{hasListener:!0,priority:1,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("double_click",t=>{var n;this._doubleClickElement(e,t.attachment.type,null===(n=t.attachment.intersection)||void 0===n?void 0:n.point)}),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_createFloorMeshWithHandler(){const e=new PlaneGeometry(1e3,1e3,8,8),t=new MeshBasicMaterial;t.visible=!1;const n=new Mesh(e,t);return n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData=deepMerge(n.userData,{hasListener:!0,priority:.9,roomleId:void 0}),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(convertToKernel(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{this._isCurrentlyDrawing?this._clickOnPlane(convertToKernel(e.attachment.intersection.point)):this._plannerSelectionHandler.cancelSelection("select_other")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=0){this._closeToPoint(e)?this.stopDrawing():this._toggleDrawing(null,e,t)}_closeToPoint(e){let t=!1;for(const n of this._planViewModel.getNodePlanObjectViewModels())this._close(n.getPlanElement().getCenter(),e)&&(t=!0);return t}_close(e,t){return Math.abs(e.x-t.x)<500&&Math.abs(e.y-t.y)<500&&Math.abs(e.z-t.z)<500}_clickElement(e){this._isCurrentlyDrawing||(this._debug&&e.getId(),2!==this._state?(this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof NodePlanElementViewModel||e instanceof WallPlanElementViewModel))return;let a;this._debug&&e.getId(),e instanceof WallPlanElementViewModel&&this._plannerSelectionHandler.cancelSelection("double_click_wall"),e instanceof NodePlanElementViewModel?a=e.getPlanElement().getCenter():n&&(a=convertToKernel(new Vector3(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){this._isCurrentlyDrawing||("multiselect"===this._plannerSelectionHandler.getSelectionMode()?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){isWallOrFloor(this._hoveredObject)||isWallOrFloor(e)?(this._hoveredObject=null,setCursor("default")):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new SceneEventInfo({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),this.dispatchEvent(4,new SceneEventInfo({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?setCursor("ew-resize"):1===this._state?setCursor("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?setCursor("move"):this._hoveredObject?setCursor("pointer"):3===this._state?setCursor(isSafari?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):setCursor("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(e){this._plannerSelectionHandler.cancelSelection(e)}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this.dispatchEvent(8),wait(INPUT_DELAY_TYPE.DRAG).then(()=>{if(this._inputManager.isMouseUp())return this.setState(0),setCursor("pointer"),void this.dispatchEvent(12);this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(),this.dispatchEvent(9,new SceneEventInfo({planElementViewModel:e}))}))}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement())),n.moveObjectsBy(e,convertToKernel(a))}else(e instanceof NodePlanElementViewModel||e instanceof WallPlanElementViewModel||this._planViewModel.cameraType===CAMERA_TYPE.CAMERA_2D)&&(this._plannerSelectionHandler.check(e),t.y=convertToTHREE(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),convertToKernel(t));this.dispatchEvent(10,new SceneEventInfo({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(11,new SceneEventInfo({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._roomlePlannerUiCallback.onDragElementEnd(),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){var t,n;const a=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new SceneEventInfo({state:this._state,oldState:a})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===a&&(null===(n=this.planInteractionHandler)||void 0===n||n.reactivateAllSnappingActivity())}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new Vector3(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanElement()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new Vector3);this.planInteractionHandler.rotateObjectsBy(i,t,convertToKernel(r)),this._position.copy(new Vector3(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof ConfiguratorPlanObjectViewModel||e instanceof StaticPlanObjectViewModel)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new SceneEventInfo({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.snapObjectsToWalls=!0}disableSnapping(){this.planInteractionHandler.snapObjectsToWalls=!1}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new Group,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(13,this._endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){var t;e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(9),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),null===(t=this._continousDrawingHelper)||void 0===t||t.endDrawing()}startDrawing(){var e;this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(9),this.dispatchEvent(6),this._setStateAndCursor(3),null===(e=this._continousDrawingHelper)||void 0===e||e.update())}_toggleDrawing(e,t,n){this._isCurrentlyDrawing?this._endWallDrawing(e,t):this._startWallDrawing(e,t,n)}_endWallDrawing(e,t){if(this._isCurrentlyDrawing){if(this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle()&&this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle())this.planInteractionHandler.cancelDrawing();else{const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:a,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continousDrawingHelper.update());const{x:a,y:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.beginDrawing({x:a,y:i,z:0}),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continousDrawingHelper){const{default:e}=await import("./continuous-drawing-helper-3b11f9f9.js");this._continousDrawingHelper=new e,this._continousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:a,z:0}),null===(t=this._continousDrawingHelper)||void 0===t||t.update(),this.dispatchEvent(5)}_createNode(e,t){if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:a,z:0}),this._raycastHelper.clear()}_getIntersectionPointWithScene(e){return this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}setKernelZoomFactor(e){var t;this._kernelZoomFactor=e,null===(t=this._continousDrawingHelper)||void 0===t||t.setKernelZoomFactor(e)}}__decorate([inject],PlannerSceneEventHandler.prototype,"_plannerSelectionHandler",void 0),__decorate([inject],PlannerSceneEventHandler.prototype,"_plannerKernelAccess",void 0),__decorate([inject],PlannerSceneEventHandler.prototype,"_roomlePlannerUiCallback",void 0);const createTransferableObjectPosition=(e,t,n,a)=>{const i=(new Box3).setFromObject(e.getContainer()).getCenter(new Vector3);return{runtimeId:e.getId(),position2d:threeVectorToTransferableXY(getScreenXY(i,t,n,a))}};class Sky extends Mesh{constructor(){const e=Sky.SkyShader,t=new ShaderMaterial({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:UniformsUtils.clone(e.uniforms),side:BackSide,depthWrite:!1});super(new BoxGeometry(1,1,1),t),this.isSky=!0}}Sky.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new Vector3},up:{value:new Vector3(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const mapToUiPlanObjects=async(e,t,n)=>{let a=[];const i=[],s=[];await Promise.all(e.map(async e=>{const n=convertCObject(e);if(n.catalogItemId?i.push(n.catalogItemId):n.configurationHash&&s.push(n.configurationHash),n.parts){const e=n.configurationHash||n.catalogItemId,a=await t.addUiDataAndPriceToPartList(n.parts,e);n.parts=a}n.data=null,a.push(n)}));const[r,o]=await Promise.all([n.getItems(i),n.getConfigurations(s)]),l=[],c=new Map;for(const e of r)c.set(e.id,e);for(const e of o)c.set(e.id,e),l.push(e.rootComponentId);const h=await n.getComponents(l),d=new Map;for(const e of h)d.set(e.id,e);for(const e of a){const t=e.catalogItemId||e.configurationHash,n=c.get(t)||null;if(n&&!n.label&&d.has(n.rootComponentId)){const e=d.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return a};class PlannerSceneManager extends ConfiguratorSceneManager{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new AsyncGuard,this._configurableItemGuard=new AsyncGuard,this._planCompletelyLoadedGuard=new AsyncGuard,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new PlannerSceneEventHandler(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._roomleRenderer.switchToPlanner(RenderMode.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(13,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof StaticPlanObjectViewModel&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,()=>{this._cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),e instanceof WallPlanElementViewModel&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(11,async({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),convertToKernel(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything();const a=this.getPlanObject(e.getId());let i;a&&(i=await mapToUiPlanObjects([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.CHANGED,i?i[0]:null)},this),this._plannerSceneEventHandler.addEventListener(12,()=>{this._cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(6,()=>{this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(5,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(7,()=>this._renderWithoutShadowsAndAO(),this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planCleared(){}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new PlanViewModel(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new Vector3),a=e.distanceTo(n),i=t.getSize(new Vector3),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){const t={};if(e instanceof StaticPlanObjectViewModel&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof ConfiguratorPlanObjectViewModel&&(t.configurationRuntimeId=e.getConfigurationRuntimeId()),e instanceof WallPlanElementViewModel){const n=this._cameraControl.getKernelZoomFactor();t.wall=e.getWallDimension(n)}e instanceof FloorPlanElementViewModel&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=(e=>{if(e instanceof StaticPlanObjectViewModel){const t=e.getPlanObject().getObjectType();return"door"!==t&&"window"!==t?"static":t}return e instanceof ConfiguratorPlanObjectViewModel?"configuration":e instanceof WallPlanElementViewModel?"wall":e instanceof FloorPlanElementViewModel?"floor":"unknown"})(e);const a=(async()=>{const t={};if(e instanceof StaticPlanObjectViewModel&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof ConfiguratorPlanObjectViewModel){await e.isInitDone();const a=e.getConfigurationRuntimeId(),i=e.getPlanObject().getCatalogItemId();let s,r=i;if(r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a)),this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),i&&isIdItemId(i)){const e=await this._rapiAccess.getItem(i);t.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);t.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const n=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(n);t.configuration=i,s=i.rootComponentId?i.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);t.component=e}t.configurationRuntimeId=a,n="configuration"}return t.planElementId=e.getId(),copy(t)})();this.currentSelection=copy(t),this._roomlePlannerUiCallback.onSelectionChange(copy(this._plannerSceneEventHandler.getSelectionMode()),copy(n),copy(t),a,e),(e instanceof WallPlanElementViewModel||e instanceof NodePlanElementViewModel)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()),this._renderWithoutShadowsAndAO(),this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._initData.legacyLight&&(this._lightSetting=new PlannerLightSetting(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),this._setEnvironment(new BackgroundEnvironment(this._scene,this._environment,new Color(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){this._cameraControl instanceof CameraControl3D&&hideWallsBasedOnCamera(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&this._roomleRenderer.forceShadowUpdates(!0)}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.disablePlannerEvents(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const{planElementId:t}=this._configuratorContext,n=this._getViewModel().getPlanObjectForId(t);n&&(this.setRootComponentId(n.getRootComponentRuntimeId()),this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(n.getPlanElement().rotation));const a=null==n?void 0:n.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==a&&(this._configuratorContext.planObjectId=a),this._getViewModel().hideAllExcept(t),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this._roomleRenderer.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(a),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(a),this.updateEnvironment(this.getBounds(),!0);const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.startInteraction()}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t),this._onSelectionChange(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this._roomleRenderer.switchToPlanner(this._cameraControl instanceof CameraControl3D?RenderMode.Mode3D:RenderMode.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=kernelBoxToThreeBox(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera(),setTimeout(()=>this._planCompletelyLoadedGuard.resolve(),0),this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide())}handlerSwitchedPlans(e,t){if(this._roomlePlannerUiCallback.onHandlerSwitchedPlans(),this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=MaterialCreator.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),n=new Mesh(e,t);n.name="Ground",n.position.y=-.01,n.userData.isFloor=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),this._planCompletelyLoadedGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait(),this._planCompletelyLoadedGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){var e;const t=this._getViewModel().getCorePlan();if(this._roomleRenderer){const n=kernelBoxToThreeBox(t.getBounds());null===(e=this._roomleRenderer)||void 0===e||e.updateBounds(n)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this.updateEnvironment(this.getBounds(),!0),this._renderEverything()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{var e;this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),(null===(e=this._lightSetting)||void 0===e?void 0:e.needsBounds())&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}async addPlanObjectToScene(e){if(e){const t=e.getContainer();fadeIn(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),await e.isInitDone(),this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything();const n=this.getPlanObject(e.getId());let a;n&&(a=await mapToUiPlanObjects([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.ADDED,a?a[0]:null)}}removePlanObjectFromScene(e){(e instanceof WallPlanElementViewModel||e instanceof NodePlanElementViewModel)&&this._sendWallDimensions(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!0),this._renderEverything()}async planElementChanged(e,t){if(this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),!this._plannerSceneEventHandler.isDragIn()){const e=this.getPlanObject(t.getId());let n;e&&(n=await mapToUiPlanObjects([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.CHANGED,n?n[0]:null)}}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){if(!this._sky){this._sky=new Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=viewSpacePositionFromUV(4e5,0,.6);this._sky.material.uniforms.sunPosition.value.copy(e);let t=new Mesh(new SphereGeometry(2e4,16,8),new MeshBasicMaterial({color:16777215}));t.name="Sunsphere",t.position.y=-7e5,t.visible=!1,t.position.set(e.x,-e.z,e.y)}this._lightSetting instanceof PlannerLightSetting&&this._lightSetting.updateSunPosition(.6,0)}switchTo2D(){var e;if(this._onCameraMove(),!(this._cameraControl instanceof CameraControl2D)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(RenderMode.Mode2D),this._renderEverything(),this._changeCameraControl(new CameraControl2D(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_2D),this._setCameraControlListeners(),this._setKernelZoomFactor(),this._onCameraMove()}}switchTo3D(){var e;this._onCameraMove(),this._cameraControl instanceof CameraControl3D||(this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(RenderMode.Mode3D),this._renderEverything(),this._changeCameraControl(new CameraControl3D(this._creator_,this._getInputManager(),new Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_3D),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){this._setKernelZoomFactor()}_setKernelZoomFactor(){var e,t;const n=this._cameraControl.getKernelZoomFactor();null===(e=this._getKernelAccess().planInteractionHandler)||void 0===e||e.setZoomFactor(n),null===(t=this._plannerSceneEventHandler)||void 0===t||t.setKernelZoomFactor(n)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof CameraControlFirstPerson?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof CameraControl3D&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof CameraControlFirstPerson)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparency(e.material,!1,!1)),this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_FP),this._renderEverything();let e=new Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new CameraControlFirstPerson(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_FP),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case CAMERA_TYPE.CAMERA_2D:this.switchTo2D();break;case CAMERA_TYPE.CAMERA_3D:this.switchTo3D();break;case CAMERA_TYPE.CAMERA_FP:this.switchToFirstPerson()}}_highlightPlanElement(e){var t;let n=new Set;e instanceof ConstructionPlanObjectViewModel&&this._cameraControl instanceof CameraControl2D&&e&&e.getTopViewContainer()?n.add(e.getTopViewContainer()):e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>n.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t instanceof ConstructionPlanObjectViewModel&&this._cameraControl instanceof CameraControl2D&&t&&t.getTopViewContainer()?n.add(t.getTopViewContainer()):t&&t.getObject()&&t.getObject().children&&t.getObject().children.forEach(e=>n.add(e))}),null===(t=this._roomleRenderer)||void 0===t||t.highlightObjects(Array.from(n))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,a,i,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){e||(e=this.getBounds()),e&&(this._cameraControl instanceof CameraControl3D&&this._cameraControl.updateToBounds(e,!1),this._cameraControl instanceof CameraControl2D&&this._cameraControl.zoomToFitBounds(getDrawingMinBounds(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight,1.1),!0),this._renderEverything())}_zoomToBounds(e,t=!0){const n=this.getBounds();this._cameraControl instanceof CameraControl3D&&(this._getViewModel().getPlanObjectCount()<=1?this._cameraControl.zoomToFitBounds(n,t):this._cameraControl.checkBoundsAndPlaceCamera(n,t)),this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(n,e,t)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof CameraControl2D&&this._cameraControl.zoomToFitBounds(e,!1,!0),this._cameraControl instanceof CameraControl3D&&this._cameraControl.zoomToFitBounds(e,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}getPlanObject(e){const t=this._getKernelAccess().planInteractionHandler,n=this._plannerKernelAccess.planModelViewHelper,a=t.getPlan();return n.getPlanObject(a,e)}cancelPlanElementSelection(e){this._plannerSceneEventHandler.cancelSelection(e),this._highlightPlanElement(null),this._requestRender()}async deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection("delete_object"),await this.deletePlanElementByIds(e)}async deletePlanElementByIds(e){for(const t of e){const e=this._getViewModel().getPlanObjectForId(t);if(e&&e.getObject()){const t=this.getPlanObject(e.getId());let n;t&&(n=await mapToUiPlanObjects([t],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.REMOVED,n?n[0]:null),this._getKernelAccess().planInteractionHandler.removeElement(e.getKernelObject())}}}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new Box3;let a={x:0,y:0,z:0};if(this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(a=i.getPlanElement().getCenter(),t.push_back(i.getPlanElement()),n.expandByObject(i.getContainer()))}),t.size()>1){const e=n.getCenter(new Vector3);a=convertToKernel(e)}const i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,a)}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a;let i=this._calculateBoundingBoxOfAllMeshes(.1);null===(n=this._lightSetting)||void 0===n||n.removeFromScene(),this._cameraControl instanceof CameraControl3D&&this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D);let s=await this._imageRenderer.prepareTopImage(this._scene,null,i,e);this._cameraControl instanceof CameraControl3D&&this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(s)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a;let i;this._cameraControl instanceof CameraControl3D?i=this._cameraControl.getCamera().clone():(i=this.getPerspectiveOffsetCamera(),this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D)),i.resetOffset();let s=this._calculateBoundingBoxOfAllMeshes();null===(n=this._lightSetting)||void 0===n||n.removeFromScene();const r=await this._imageRenderer.preparePerspectiveImage(this._scene,null,i,s,e);this._cameraControl instanceof CameraControl2D&&this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(r)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return ImageRenderer.getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions(),this._roomlePlannerUiCallback.onCameraIdle()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),!0}_updateNodeSize(){if(this._cameraControl instanceof CameraControl2D){const e=1/this._cameraControl.getCamera().zoom;this._getViewModel().setNodeZoom(e)}}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=this._cameraControl.getCamera(),a=[],i={staticPlanObjectViewModels:this._getViewModel().getStaticPlanObjectViewModels(),configurablePlanObjectViewModels:this._getViewModel().getConfigurablePlanObjectViewModels(),constructionPlanObjectViewModels:this._getViewModel().getConstructionPlanObjectViewModels(),wallPlanObjectViewModels:this._getViewModel().getWallPlanObjectViewModels(),floorPlanObjectViewModels:this._getViewModel().getFloorPlanObjectViewModels(),nodePlanObjectViewModels:this._getViewModel().getNodePlanObjectViewModels()};for(const s of Object.values(i))for(const i of s)a.push(createTransferableObjectPosition(i,n,e,t));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(a)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:a}=this._domHelper.element,i=this._getViewModel().getWallPlanObjectViewModels(),s=this._cameraControl.getKernelZoomFactor();for(const e of i){const i=e.getWallDimension(s);if(i.length>0){const e=this._cameraControl.getCamera();i.fromPosition2d=getScreenXY(i.fromPosition3d,e,n,a),i.toPosition2d=getScreenXY(i.toPosition3d,e,n,a),i.fromWithoutPadding=getScreenXY(i.fromWithoutPadding,e,n,a),i.toWithoutPadding=getScreenXY(i.toWithoutPadding,e,n,a),i.textPosition2d=getScreenXY(i.textPosition3d,e,n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(wallDimensionToTransferable(i))}if(this._initData.debug){const e=new SphereGeometry(.1,32,16),t=new MeshBasicMaterial({color:16711680}),n=new Mesh(e,t);n.position.copy(i.fromPosition3d);const a=new Mesh(e,t);a.position.copy(i.toPosition3d);const s=new Mesh(e,new MeshBasicMaterial({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}this._roomlePlannerUiCallback.onUpdateWallDimensions(t)}enableWallDrawing(){if(this._cameraControl instanceof CameraControl2D){const e=getDrawingMinBounds(this.getBounds(),this._domHelper.element.clientWidth,this._domHelper.element.clientHeight);this._cameraControl.zoomToFitBounds(e,!0)}this._drawingEnabled||(this._drawingEnabled=!0,this._scene.add(this._plannerSceneEventHandler.enableWallDrawing()))}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._scene.remove(this._plannerSceneEventHandler.cancelWallDrawing())}escapeDrawing(){this._plannerSceneEventHandler.stopDrawing()}_changeCameraControl(e){super._changeCameraControl(e)}setSceneEvents(e){var t,n;void 0!==e.construction&&(null===(t=this._plannerSceneEventHandler)||void 0===t||t.enableConstructionEvents(e.construction)),void 0!==e.objects&&(null===(n=this._plannerSceneEventHandler)||void 0===n||n.enableObjectEvents(e.objects))}startedDrawing(){this._plannerSceneEventHandler.startDrawing()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),"planner"===this._configuratorContext.baseContext&&this.enablePlannerEvents()}resetCameraPositionToStart(e=!0){this._cameraControl instanceof CameraControl3D&&super.resetCameraPositionToStart(e),this._cameraControl instanceof CameraControl2D&&this._updateCamera()}async moveCamera(e){return this._cameraControl instanceof CameraControl3D?super.moveCamera(e):Promise.reject("Camera can only be moved in 3D")}_setInteriorOrExteriorWallMaterial(e,t){const n=this._getViewModel().getWallPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=e=>{a.setWallLeftMaterial(e,applyMaterialToKernelMaterial(e.leftMaterial,t))},s=e=>{a.setWallRightMaterial(e,applyMaterialToKernelMaterial(e.rightMaterial,t))},r=n.map(e=>e.getKernelObject()),o=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,l=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,c=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const t of r)t.wallType===o&&"interior"===e&&(i(t),s(t)),t.wallType===l&&("interior"===e?s(t):i(t)),t.wallType===c&&("exterior"===e?s(t):i(t))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("interior",e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("exterior",e)}changeFloorsMaterial(e){const t=this._getViewModel().getFloorPlanObjectViewModels();if(!t.length)return;const n=this._getKernelAccess().planInteractionHandler,a=t.map(e=>e.getKernelObject());for(const t of a)n.setFloorMaterial(t,applyMaterialToKernelMaterial(t.material,e))}getWallAngleDegrees(e){if(!(e instanceof WallPlanElementViewModel))return 0;const t=this._cameraControl.getCamera(),n=new Vector2(t.position.x,t.position.z),a=new Vector2(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),i=e.getKernelObject(),s=new Vector2(Math.sin(i.getAngle()),Math.cos(i.getAngle())),r=a.angle()-s.angle();return MathUtils.radToDeg(r)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0),n.moveElementTo(e.getPlanElement(),t),this._sendPlanObjectPositions()}}__decorate([inject],PlannerSceneManager.prototype,"_rapiAccess",void 0),__decorate([inject],PlannerSceneManager.prototype,"_plannerMeshGenerator",void 0),__decorate([inject],PlannerSceneManager.prototype,"_plannerInputManager",void 0),__decorate([inject],PlannerSceneManager.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],PlannerSceneManager.prototype,"_localStorageHelper",void 0),__decorate([inject],PlannerSceneManager.prototype,"_unitFormatter",void 0);const OFFSET={left:0,top:1,right:1,bottom:0};class RoomlePlanner{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(e="unknown"){this._sceneManager.cancelPlanElementSelection(e)}init(e,t,n){return Benchmark.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{const a=isPlanSnapshotId(e);(a?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(n=>{const i=a?n.plan:n.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(i),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t(n)},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}resetCameraPosition(){this._sceneManager.resetCameraPositionToStart()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){Promise.all([this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"})]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new PlannerSceneManager(this._creator_,OFFSET,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=DynamicLightSettingLoader.createDynamicLightSettingSource(t,n);i&&this.showStats(),this._sceneManager.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Benchmark.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new RoomleConfigurator(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);a&&this._configurator.notifyUiAboutNewLabel(a)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);import("./configurator-c62d84e8.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);import("./glb-viewer-1aee8147.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=convertToKernel(new Vector3(t.x,t.y,t.z)));const a=await(isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){const t=e.map(e=>isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return await this._plannerKernelAccess.insertItems(n)}async insertItems(e){return await this._plannerKernelAccess.insertItems(e)}duplicateItems(e){return this._plannerKernelAccess.duplicateItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan),t=convertCObject(e.objects);return mapToUiPlanObjects(t,this._plannerKernelAccess,this._rapiAccess)}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return convertCObject(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}enableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode("multiselect"),this._configuratorContext.selectionMode="multiselect"}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),a=await this.insertItems([n]);if(1!==a.length)throw new Error("More than one object added, abort");return a[0]}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,a;const i=this._planInteractionHandler;i.startInteraction();const s=[];for(const t of e){const e=i.addNode(t.from),r=i.addNode(t.to),o=i.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&i.setWallHeight(o,t.props.height),void 0!==(null===(a=t.props)||void 0===a?void 0:a.thickness)&&i.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||i.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),s}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const t of e){const e=this._sceneManager.getPlanObject(t.getId());let n;e&&(n=await mapToUiPlanObjects([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.REMOVED,n?n[0]:null),this._planInteractionHandler.removeElement(t)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}async saveCurrentPlanSnapshot(e){const t=await this.getPlanModelViewHelper(),n=this._planInteractionHandler.getPlan(),a=t.getPlanOverview(n),i={parentId:e||null,planObjects:[],combinedIds:[],plan:n.getPlanXML(!1,2)},s=a.objects,r=s.size();for(let e=0;e<r;e++){const t=s.get(e),n=t.configurationHash||t.catalogItemId,{center:a,dimensions:r,rotation:o}=t,l=JSON.stringify({center:a,dimensions:r,rotation:o});i.planObjects.push({combinedId:n,location:l})}const o=await this._rapiAccess.savePlanSnapshot(i),l=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotPerspectiveImage(o,n.value),i=await this._rapiAccess.savePlanSnapshotTopImage(o,a.value);e({...t,...i})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await l}catch(e){return console.error(e),o}}getPlanXmlFrom(e){return e?isPlanSnapshotId(e.id)?e.plan:e.planObjects:null}async moveCamera(e){return this._sceneManager.moveCamera(e)}async createNewSerializedConfiguration(e){return Promise.resolve(this._plannerKernelAccess.createNewSerializedConfiguration(e))}changeInteriorWallsMaterial(e){this._sceneManager.changeInteriorWallsMaterial(e)}changeExteriorWallsMaterial(e){this._sceneManager.changeExteriorWallsMaterial(e)}changeFloorsMaterial(e){this._sceneManager.changeFloorsMaterial(e)}getWallAngleDegrees(e){return this._sceneManager.getWallAngleDegrees(e)}calcPartsPriceSum(e){return this._plannerKernelAccess.calcPartsPriceSum(e)}async swapObject(e,t){const n=e.getPosition(),a=e.getRotation();return await this._sceneManager.deletePlanElementByIds([e.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,n,a)}exportImageFromCamera(e="image"){this._sceneManager.exportImageFromCamera(e)}moveElementPosition(e,t){this._sceneManager.moveElementPosition(e,t)}async generateProductionServiceExport(e,t=""){try{return Promise.resolve(JSON.parse(this._plannerKernelAccess.kernelInstance.generateProductionServiceExport(e,t)))}catch(e){return console.error(e),Promise.reject("Could not create Blue Ocean MVP JSON")}}}__decorate([inject],RoomlePlanner.prototype,"_configuratorContext",void 0),__decorate([inject],RoomlePlanner.prototype,"_domHelper",void 0),__decorate([inject],RoomlePlanner.prototype,"_scriptLoader",void 0),__decorate([inject],RoomlePlanner.prototype,"_kernelAccessCallback",void 0),__decorate([inject],RoomlePlanner.prototype,"_plannerKernelAccess",void 0),__decorate([inject],RoomlePlanner.prototype,"_rapiAccess",void 0),__decorate([inject],RoomlePlanner.prototype,"_singlePromiseFactory",void 0),__decorate([inject],RoomlePlanner.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],RoomlePlanner.prototype,"_lifeCycleManager",void 0),__decorate([inject],RoomlePlanner.prototype,"_dataSyncer",void 0),__decorate([inject],RoomlePlanner.prototype,"_initData",void 0),__decorate([inject],RoomlePlanner.prototype,"_globalInitData",void 0),__decorate([inject],RoomlePlanner.prototype,"_unitFormatter",void 0);const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("planner-input-manager",class extends InputManager{_canDrag(e){return!0}},1),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("planner-selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(e){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:t,reason:e}))})}_checkStandard(e){this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e})))}_checkMulti(e){if(!isWallOrFloor(e)&&!this._selectedPlanElementViewModels.has(e.getId())){this._selectedPlanElementViewModels.set(e.getId(),e),e.select();const t=Array.from(this._selectedPlanElementViewModels).map(([e,t])=>t);this.dispatchEvent(2,new PlannerSelectionHandlerEvent({planElementViewModels:t})),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{isWallOrFloor(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e})))})}setSelectionMode(e){"multiselect"===e&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(15,new PlannerSelectionHandlerEvent({selectionMode:e}))}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];class Planner extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new RoomlePlanner(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}}export{Planner};
|
|
2
|
-
//# sourceMappingURL=planner-
|
|
1
|
+
import{S as ScriptLoader,M as Main}from"./script-loader-b4f54de0.js";import{Z as getGUI,E as EventDispatcher,W as WallPlanElementViewModel,F as FloorPlanElementViewModel,_ as __decorate,i as inject,h as convertToKernel,N as NodePlanElementViewModel,a8 as isSafari,e as CAMERA_TYPE,a9 as convertToTHREE,c as ConfiguratorPlanObjectViewModel,S as StaticPlanObjectViewModel,aa as INPUT_DELAY_TYPE,ab as threeVectorToTransferableXY,j as getScreenXY,O as convertCObject,ac as AsyncGuard,ad as RenderMode,ae as PLAN_ELEMENT_CHANGE_TYPES,af as hideWallsBasedOnCamera,k as kernelBoxToThreeBox,V as MaterialCreator,ag as fadeIn,ah as viewSpacePositionFromUV,ai as setWallTransparency,d as ConstructionPlanObjectViewModel,aj as getDrawingMinBounds,r as ImageRenderer,ak as wallDimensionToTransferable,H as isIdItemId,B as Benchmark,al as isPlanSnapshotId,p as DynamicLightSettingLoader,am as InputManager,D as DependencyInjectionAssignment,L as Logger,an as PlannerMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-390d51f2.js";import{L as LightSetting,B as BackgroundEnvironment,C as CameraControl3D,b as CameraControl2D,c as CameraControlFirstPerson,T as TWEEN_FILE_NAME}from"./scene-manager-f66599cf.js";import{a as Vector3,A as AmbientLight,C as Color,D as DirectionalLight,V as Vector2,ab as Sphere,bu as Layers,ak as deepMerge,b3 as PlaneGeometry,f as MeshBasicMaterial,x as Mesh,aB as setCursor,aw as wait,aa as Box3,H as Group,aT as ShaderMaterial,aY as UniformsUtils,b8 as BackSide,at as BoxGeometry,bK as copy,aH as SphereGeometry,bL as applyMaterialToKernelMaterial,K as MathUtils}from"./main-thread-to-worker-30982707.js";import{S as SceneEventHandler,C as ConfiguratorSceneManager,P as PlanViewModel,R as RoomleConfigurator}from"./roomle-configurator-521e927f.js";import"./query-params-helper-a271f9dc.js";import"./default-light-setting-d50d49f0.js";class PlannerLightSetting extends LightSetting{constructor(e,t){super(e,t),this._center=new 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 AmbientLight(new Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new DirectionalLight(new 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 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 Vector3));const t=new Sphere;e.getBoundingSphere(t);const n=t.radius,a=new Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=getGUI();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new 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 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 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))}}}}const isWallOrFloor=e=>e instanceof WallPlanElementViewModel||e instanceof FloorPlanElementViewModel;class PlannerSelectionHandlerEvent{constructor(e){const{planElementViewModel:t,planElementViewModels:n,selectionMode:a,reason:i}=e;this.planElementViewModel=t,this.planElementViewModels=n,this.selectionMode=a,this.reason=i}}class SceneEventInfo{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i,reason:s}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i,this.reason=s}}class PlannerSceneEventHandler extends SceneEventHandler{constructor(e,t,n,a){super(e,t,n,a),this._isDrawingEnabled=!1,this._isCurrentlyDrawing=!1,this._state=0,this._inputManager.addEventListener(4,()=>this._position=null,this),this._raycastHelper.setMode(0),this._raycastHelper.addEventListener(0,()=>{2!==this._state?this._plannerSelectionHandler.cancelSelection("click_outside"):this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new SceneEventInfo({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(2,({planElementViewModels:e})=>{this._roomlePlannerUiCallback.onMultiSelectionChange(e)},this),this._plannerSelectionHandler.addEventListener(15,({selectionMode:e})=>{"multiselect"===e&&this._hoveredObject&&this._hoverOnMultiSelect(this._hoveredObject)},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new SceneEventInfo({planElementViewModel:e,reason:t}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new 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 Layers;e.disableAll(),e.enable(3),e.enable(7),e.enable(6),e.enable(9),e.enable(2),this._raycastHelper.setLayers(e),this._raycastHelper.enableEvents()}enableConstructionEvents(e){e?this._raycastHelper.getLayers().enable(9):this._raycastHelper.getLayers().disable(9)}enableObjectEvents(e){e?this._raycastHelper.getLayers().enable(6):this._raycastHelper.getLayers().disable(6)}getSelectionMode(){return this._plannerSelectionHandler.getSelectionMode()}addPlanObjectHandlers(e,t){t||(t=e.getBoundingBox());const n={hasListener:!0,priority:1,roomleId:e.getId()};this._addPlanObjectHandlers(e,t,n)}addWallHandlers(e){this._addPlanElementHandlers(e,e.getObject(),{hasListener:!0,priority:1,roomleId:e.getId()})}addNodeHandlers(e){this._addPlanElementHandlers(e,e.getBoundingBox(),{hasListener:!0,priority:1,roomleId:e.getId()})}_addPlanObjectHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)),t.addEventListener("rotate",t=>this._rotate(e,t.attachment.rotation)))}_addPlanElementHandlers(e,t,n){t.userData.hasListener||(t.userData=deepMerge(t.userData,n),t.addEventListener("select",()=>this._clickElement(e)),t.addEventListener("double_click",t=>{var n;this._doubleClickElement(e,t.attachment.type,null===(n=t.attachment.intersection)||void 0===n?void 0:n.point)}),t.addEventListener("drag_start",()=>this._dragStart(e)),t.addEventListener("drag",t=>this._drag(e,t.attachment.position)),t.addEventListener("drag_end",t=>this._dragEnd(e,t.attachment.position)),t.addEventListener("hover_on",()=>this._hoverOn(e)),t.addEventListener("hover_off",()=>this._hoverOff(e)))}_createFloorMeshWithHandler(){const e=new PlaneGeometry(1e3,1e3,8,8),t=new MeshBasicMaterial;t.visible=!1;const n=new Mesh(e,t);return n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData=deepMerge(n.userData,{hasListener:!0,priority:.9,roomleId:void 0}),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(convertToKernel(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{this._isCurrentlyDrawing?this._clickOnPlane(convertToKernel(e.attachment.intersection.point)):this._plannerSelectionHandler.cancelSelection("select_other")}),n}_clickOnPlane(e){this._createNode(null,e)}_doubleClickOnPlane(e,t=0){this._closeToPoint(e)?this.stopDrawing():this._toggleDrawing(null,e,t)}_closeToPoint(e){let t=!1;for(const n of this._planViewModel.getNodePlanObjectViewModels())this._close(n.getPlanElement().getCenter(),e)&&(t=!0);return t}_close(e,t){return Math.abs(e.x-t.x)<500&&Math.abs(e.y-t.y)<500&&Math.abs(e.z-t.z)<500}_clickElement(e){this._isCurrentlyDrawing||(this._debug&&e.getId(),2!==this._state?(this._plannerSelectionHandler.check(e),this._roomlePlannerUiCallback.onClickElement(e),this._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof NodePlanElementViewModel||e instanceof WallPlanElementViewModel))return;let a;this._debug&&e.getId(),e instanceof WallPlanElementViewModel&&this._plannerSelectionHandler.cancelSelection("double_click_wall"),e instanceof NodePlanElementViewModel?a=e.getPlanElement().getCenter():n&&(a=convertToKernel(new Vector3(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){this._isCurrentlyDrawing||("multiselect"===this._plannerSelectionHandler.getSelectionMode()?this._hoverOnMultiSelect(e):this._hoverOnStandard(e))}_hoverOnMultiSelect(e){isWallOrFloor(this._hoveredObject)||isWallOrFloor(e)?(this._hoveredObject=null,setCursor("default")):this._hoverOnStandard(e)}_hoverOnStandard(e){e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new SceneEventInfo({planElementViewModel:e})),this._interaction(),this._setCursor()}_hoverOff(e){e.hoverOff(),this.dispatchEvent(4,new SceneEventInfo({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?setCursor("ew-resize"):1===this._state?setCursor("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?setCursor("move"):this._hoveredObject?setCursor("pointer"):3===this._state?setCursor(isSafari?"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 0 15, auto":"url('https://res.cloudinary.com/roomle/image/upload/v1664957371/pencil_j5vkhm.svg') 3 20, auto"):setCursor("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(e){this._plannerSelectionHandler.cancelSelection(e)}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this.dispatchEvent(8),wait(INPUT_DELAY_TYPE.DRAG).then(()=>{if(this._inputManager.isMouseUp())return this.setState(0),setCursor("pointer"),void this.dispatchEvent(12);this._draggedObject=e,this.setState(1),this._roomlePlannerUiCallback.onDragElementStart(),this.dispatchEvent(9,new SceneEventInfo({planElementViewModel:e}))}))}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement())),n.moveObjectsBy(e,convertToKernel(a))}else(e instanceof NodePlanElementViewModel||e instanceof WallPlanElementViewModel||this._planViewModel.cameraType===CAMERA_TYPE.CAMERA_2D)&&(this._plannerSelectionHandler.check(e),t.y=convertToTHREE(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),convertToKernel(t));this.dispatchEvent(10,new SceneEventInfo({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(11,new SceneEventInfo({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._roomlePlannerUiCallback.onDragElementEnd(),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){var t,n;const a=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new SceneEventInfo({state:this._state,oldState:a})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===a&&(null===(n=this.planInteractionHandler)||void 0===n||n.reactivateAllSnappingActivity())}resetState(){this.setState(0)}_move(e){if(3!==this._state&&2===this._state&&this._hasSelection()){this._setCursor();let t=Math.PI/180;const{x:n,y:a}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new Vector3(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanElement()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new Vector3);this.planInteractionHandler.rotateObjectsBy(i,t,convertToKernel(r)),this._position.copy(new Vector3(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof ConfiguratorPlanObjectViewModel||e instanceof StaticPlanObjectViewModel)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(13,new SceneEventInfo({}))}addComponentDragInHandler(e){if(!this._dragIn)return;const t=e.getBoundingBox();this._addPlanElementHandlers(e,t,{hasListener:!0,priority:1,roomleId:e.getId()}),this._raycastHelper.enableDragIn(t),this._dragStart(e)}enableSnapping(){this.planInteractionHandler.snapObjectsToWalls=!0}disableSnapping(){this.planInteractionHandler.snapObjectsToWalls=!1}enableWallDrawing(){return this._isDrawingEnabled=!0,this._drawingGroup=new Group,this._drawingGroup.name="Drawing",this._drawingGroup.add(this._createFloorMeshWithHandler()),this._inputManager.addEventListener(6,this._drawWallOnMouseMove,this),this._inputManager.addEventListener(13,this._endWallDrawing,this),this._drawingGroup}cancelWallDrawing(){return this._isDrawingEnabled=!1,this._setStateAndCursor(0),this._inputManager.removeEventListener(6,this._drawWallOnMouseMove),this._inputManager.removeEventListener(13,this._endWallDrawing),this._raycastHelper.clear(),this._drawingGroup}stopDrawing(e=!0){var t;e&&this.planInteractionHandler.cancelDrawing(),this._raycastHelper.getLayers().enable(9),this._isCurrentlyDrawing=!1,this._setStateAndCursor(0),this.dispatchEvent(7),null===(t=this._continousDrawingHelper)||void 0===t||t.endDrawing()}startDrawing(){var e;this._isCurrentlyDrawing||(this._isCurrentlyDrawing=!0,this._raycastHelper.getLayers().disable(9),this.dispatchEvent(6),this._setStateAndCursor(3),null===(e=this._continousDrawingHelper)||void 0===e||e.update())}_toggleDrawing(e,t,n){this._isCurrentlyDrawing?this._endWallDrawing(e,t):this._startWallDrawing(e,t,n)}_endWallDrawing(e,t){if(this._isCurrentlyDrawing){if(this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle()&&this.planInteractionHandler.getContinuousDrawingManager().shouldShowCircle())this.planInteractionHandler.cancelDrawing();else{const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:a,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continousDrawingHelper.update());const{x:a,y:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.beginDrawing({x:a,y:i,z:0}),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continousDrawingHelper){const{default:e}=await import("./continuous-drawing-helper-8234d7be.js");this._continousDrawingHelper=new e,this._continousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:a,z:0}),null===(t=this._continousDrawingHelper)||void 0===t||t.update(),this.dispatchEvent(5)}_createNode(e,t){if(!this._isCurrentlyDrawing)return;const{x:n,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:a,z:0}),this._raycastHelper.clear()}_getIntersectionPointWithScene(e){return this._raycastHelper.intersectMouseOnScene(e)}_setStateAndCursor(e){this.setState(e),this._setCursor()}setKernelZoomFactor(e){var t;this._kernelZoomFactor=e,null===(t=this._continousDrawingHelper)||void 0===t||t.setKernelZoomFactor(e)}}__decorate([inject],PlannerSceneEventHandler.prototype,"_plannerSelectionHandler",void 0),__decorate([inject],PlannerSceneEventHandler.prototype,"_plannerKernelAccess",void 0),__decorate([inject],PlannerSceneEventHandler.prototype,"_roomlePlannerUiCallback",void 0);const createTransferableObjectPosition=(e,t,n,a)=>{const i=(new Box3).setFromObject(e.getContainer()).getCenter(new Vector3);return{runtimeId:e.getId(),position2d:threeVectorToTransferableXY(getScreenXY(i,t,n,a))}};class Sky extends Mesh{constructor(){const e=Sky.SkyShader,t=new ShaderMaterial({name:"SkyShader",fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:UniformsUtils.clone(e.uniforms),side:BackSide,depthWrite:!1});super(new BoxGeometry(1,1,1),t),this.isSky=!0}}Sky.SkyShader={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new Vector3},up:{value:new Vector3(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}"};const mapToUiPlanObjects=async(e,t,n)=>{let a=[];const i=[],s=[];await Promise.all(e.map(async e=>{const n=convertCObject(e);if(n.catalogItemId?i.push(n.catalogItemId):n.configurationHash&&s.push(n.configurationHash),n.parts){const e=n.configurationHash||n.catalogItemId,a=await t.addUiDataAndPriceToPartList(n.parts,e);n.parts=a}n.data=null,a.push(n)}));const[r,o]=await Promise.all([n.getItems(i),n.getConfigurations(s)]),l=[],c=new Map;for(const e of r)c.set(e.id,e);for(const e of o)c.set(e.id,e),l.push(e.rootComponentId);const h=await n.getComponents(l),d=new Map;for(const e of h)d.set(e.id,e);for(const e of a){const t=e.catalogItemId||e.configurationHash,n=c.get(t)||null;if(n&&!n.label&&d.has(n.rootComponentId)){const e=d.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return a};class PlannerSceneManager extends ConfiguratorSceneManager{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new AsyncGuard,this._configurableItemGuard=new AsyncGuard,this._planCompletelyLoadedGuard=new AsyncGuard,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new PlannerSceneEventHandler(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._roomleRenderer.switchToPlanner(RenderMode.Mode3D),this._imageRenderer.switchToPlannerSettings(),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(13,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof StaticPlanObjectViewModel&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e,reason:t})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(t),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,()=>{this._cameraControl.lock()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),e instanceof WallPlanElementViewModel&&this._sendWallDimensions(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(11,async({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),convertToKernel(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything();const a=this.getPlanObject(e.getId());let i;a&&(i=await mapToUiPlanObjects([a],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.CHANGED,i?i[0]:null)},this),this._plannerSceneEventHandler.addEventListener(12,()=>{this._cameraControl.unlock()},this),this._plannerSceneEventHandler.addEventListener(6,()=>{this._setKernelZoomFactor(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(5,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(7,()=>this._renderWithoutShadowsAndAO(),this),this._getKernelAccess().addPlannerListener(this),this._plannerMeshGenerator.setMaterialLoadedListener(()=>{this._configurableItemGuard.resolve(),this._requestRender()}),window.onbeforeunload=this.clearScene.bind(this),this._renderListener=()=>{this._requestRender()},this._getInputManager().addEventListener(7,this._renderListener,this),this._getInputManager().addEventListener(8,this._renderListener,this),this.disableConfiguratorEvents(),this.enablePlannerEvents()}planCleared(){}planHistoryStateChanged(){this._sendWallDimensions()}_getViewModel(){return this._viewModel||(this._viewModel=new PlanViewModel(this._creator_)),this._viewModel}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new Vector3),a=e.distanceTo(n),i=t.getSize(new Vector3),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){const t={};if(e instanceof StaticPlanObjectViewModel&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof ConfiguratorPlanObjectViewModel&&(t.configurationRuntimeId=e.getConfigurationRuntimeId()),e instanceof WallPlanElementViewModel){const n=this._cameraControl.getKernelZoomFactor();t.wall=e.getWallDimension(n)}e instanceof FloorPlanElementViewModel&&(t.staticItemRuntimeId=e.getPlanElement().getId());let n=(e=>{if(e instanceof StaticPlanObjectViewModel){const t=e.getPlanObject().getObjectType();return"door"!==t&&"window"!==t?"static":t}return e instanceof ConfiguratorPlanObjectViewModel?"configuration":e instanceof WallPlanElementViewModel?"wall":e instanceof FloorPlanElementViewModel?"floor":"unknown"})(e);const a=(async()=>{const t={};if(e instanceof StaticPlanObjectViewModel&&(t.item=e.getRapiItem(),t.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof ConfiguratorPlanObjectViewModel){await e.isInitDone();const a=e.getConfigurationRuntimeId(),i=e.getPlanObject().getCatalogItemId();let s,r=i;if(r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(a)),this._configuratorContext.planObjectId=a,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),i&&isIdItemId(i)){const e=await this._rapiAccess.getItem(i);t.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);t.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const n=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(n);t.configuration=i,s=i.rootComponentId?i.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);t.component=e}t.configurationRuntimeId=a,n="configuration"}return t.planElementId=e.getId(),copy(t)})();this.currentSelection=copy(t),this._roomlePlannerUiCallback.onSelectionChange(copy(this._plannerSceneEventHandler.getSelectionMode()),copy(n),copy(t),a,e),(e instanceof WallPlanElementViewModel||e instanceof NodePlanElementViewModel)&&(this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.show()),this._updateNodeSize()),this._renderWithoutShadowsAndAO()}_onSelectionCancel(e){this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide()),this._renderWithoutShadowsAndAO(),this.resetConfiguratorContext(),this.currentSelection=null}resetConfiguratorContext(){this._configuratorContext.planObjectId=0,this._configuratorContext.planElementId=0,this._configuratorContext.rootComponentId=0,this._configuratorContext.dockingRootComponentId=0}_setupScene(e,t){super._setupScene(e,t,!0),this._initData.legacyLight&&(this._lightSetting=new PlannerLightSetting(this._scene,this._lightSetting)),this._initData.moc||this._addSky(),this._setEnvironment(new BackgroundEnvironment(this._scene,this._environment,new Color(this._initData.colors.DEFAULT_BACKGROUND)))}onBeforeRender(){this._cameraControl instanceof CameraControl3D&&hideWallsBasedOnCamera(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels())&&this._roomleRenderer.forceShadowUpdates(!0)}_getInputManager(){return this._plannerInputManager}createCameraControl(e,t){this.setMode(e)}startViewing(){this._configuratorContext.baseContext="glb-viewer";const e=this._plannerSceneEventHandler.getSelectedIds();if(1===e.length){const t=this._getViewModel().getPlanObjectForId(e[0]);this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(t.getPlanElement().rotation),this._getViewModel().hideAllExcept(t.getId())}this.resetCamera(),this.disablePlannerEvents(),this.updateEnvironment(this.getBounds(),!0)}startConfiguring(){var e;this._configuratorContext.baseContext="configurator";const{planElementId:t}=this._configuratorContext,n=this._getViewModel().getPlanObjectForId(t);n&&(this.setRootComponentId(n.getRootComponentRuntimeId()),this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(n.getPlanElement().rotation));const a=null==n?void 0:n.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==a&&(this._configuratorContext.planObjectId=a),this._getViewModel().hideAllExcept(t),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this._roomleRenderer.switchToConfigurator(),this._imageRenderer.switchToConfiguratorSettings(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(a),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(a),this.updateEnvironment(this.getBounds(),!0);const i=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==i||i.startInteraction()}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t),this._onSelectionChange(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this._roomleRenderer.switchToPlanner(this._cameraControl instanceof CameraControl3D?RenderMode.Mode3D:RenderMode.Mode2D),this._imageRenderer.switchToPlannerSettings(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=kernelBoxToThreeBox(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera(),setTimeout(()=>this._planCompletelyLoadedGuard.resolve(),0),this._getViewModel().getNodePlanObjectViewModels().forEach(e=>e.hide())}handlerSwitchedPlans(e,t){if(this._roomlePlannerUiCallback.onHandlerSwitchedPlans(),this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=MaterialCreator.createMeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0,depthWrite:!1}),n=new Mesh(e,t);n.name="Ground",n.position.y=-.01,n.userData.isFloor=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),this._planCompletelyLoadedGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait(),this._planCompletelyLoadedGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){var e;const t=this._getViewModel().getCorePlan();if(this._roomleRenderer){const n=kernelBoxToThreeBox(t.getBounds());null===(e=this._roomleRenderer)||void 0===e||e.updateBounds(n)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this.updateEnvironment(this.getBounds(),!0),this._renderEverything()}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{var e;this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),(null===(e=this._lightSetting)||void 0===e?void 0:e.needsBounds())&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}async addPlanObjectToScene(e){if(e){const t=e.getContainer();fadeIn(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),await e.isInitDone(),this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything();const n=this.getPlanObject(e.getId());let a;n&&(a=await mapToUiPlanObjects([n],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.ADDED,a?a[0]:null)}}removePlanObjectFromScene(e){(e instanceof WallPlanElementViewModel||e instanceof NodePlanElementViewModel)&&this._sendWallDimensions(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!0),this._renderEverything()}async planElementChanged(e,t){if(this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),!this._plannerSceneEventHandler.isDragIn()){const e=this.getPlanObject(t.getId());let n;e&&(n=await mapToUiPlanObjects([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.CHANGED,n?n[0]:null)}}exportGLB(e,t){}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){if(!this._sky){this._sky=new Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._sky.frustumCulled=!1,this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=viewSpacePositionFromUV(4e5,0,.6);this._sky.material.uniforms.sunPosition.value.copy(e);let t=new Mesh(new SphereGeometry(2e4,16,8),new MeshBasicMaterial({color:16777215}));t.name="Sunsphere",t.position.y=-7e5,t.visible=!1,t.position.set(e.x,-e.z,e.y)}this._lightSetting instanceof PlannerLightSetting&&this._lightSetting.updateSunPosition(.6,0)}switchTo2D(){var e;if(this._onCameraMove(),!(this._cameraControl instanceof CameraControl2D)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(RenderMode.Mode2D),this._renderEverything(),this._changeCameraControl(new CameraControl2D(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_2D),this._setCameraControlListeners(),this._setKernelZoomFactor(),this._onCameraMove()}}switchTo3D(){var e;this._onCameraMove(),this._cameraControl instanceof CameraControl3D||(this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D),null===(e=this._roomleRenderer)||void 0===e||e.switchToPlanner(RenderMode.Mode3D),this._renderEverything(),this._changeCameraControl(new CameraControl3D(this._creator_,this._getInputManager(),new Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_3D),this._setCameraControlListeners())}_setCameraControlListeners(){this._cameraControl.addEventListener(8,()=>{this._onCameraIdle()},this),this._cameraControl.addEventListener(1,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(3,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(4,()=>{this._onCameraMove()},this),this._cameraControl.addEventListener(5,()=>{this._onCameraZoomChange()},this)}_onCameraZoomChange(){this._setKernelZoomFactor()}_setKernelZoomFactor(){var e,t;const n=this._cameraControl.getKernelZoomFactor();null===(e=this._getKernelAccess().planInteractionHandler)||void 0===e||e.setZoomFactor(n),null===(t=this._plannerSceneEventHandler)||void 0===t||t.setKernelZoomFactor(n)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof CameraControlFirstPerson?this._getViewModel().getCeilingGroup().visible=!0:this._getViewModel().getCeilingGroup().visible=!1)}cameraControlChanged(){super.cameraControlChanged(),this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setCamera(this._cameraControl.getCamera())}sceneChanged(){this._plannerSceneEventHandler&&this._plannerSceneEventHandler.setScene(this._scene)}closeHSC(){this._requestRender(),this._cameraControl instanceof CameraControl3D&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof CameraControlFirstPerson)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>setWallTransparency(e.material,!1,!1)),this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_FP),this._renderEverything();let e=new Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new CameraControlFirstPerson(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_FP),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("multiselect"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.enablePanning(),e.preventDefault())}_checkNumKey(e){e.key&&"1"===e.key&&(this.switchTo2D(),e.preventDefault()),e.key&&"2"===e.key&&(this.switchTo3D(),e.preventDefault()),e.key&&"3"===e.key&&(this.switchToFirstPerson(),e.preventDefault())}_onKeyUp(e){super._onKeyDown(e),!e.key||"Meta"!==e.key&&"Control"!==e.key||(this._plannerSceneEventHandler.setSelectionMode("standard"),e.preventDefault()),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof CameraControl3D&&(this._cameraControl.disablePanning(),e.preventDefault()),!e.key||"Escape"!==e.key&&"Esc"!==e.key||this._drawingEnabled&&(this.escapeDrawing(),this._roomlePlannerUiCallback.onDrawCancel())}setMode(e){switch(e){case CAMERA_TYPE.CAMERA_2D:this.switchTo2D();break;case CAMERA_TYPE.CAMERA_3D:this.switchTo3D();break;case CAMERA_TYPE.CAMERA_FP:this.switchToFirstPerson()}}_highlightPlanElement(e){var t;let n=new Set;e instanceof ConstructionPlanObjectViewModel&&this._cameraControl instanceof CameraControl2D&&e&&e.getTopViewContainer()?n.add(e.getTopViewContainer()):e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>n.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t instanceof ConstructionPlanObjectViewModel&&this._cameraControl instanceof CameraControl2D&&t&&t.getTopViewContainer()?n.add(t.getTopViewContainer()):t&&t.getObject()&&t.getObject().children&&t.getObject().children.forEach(e=>n.add(e))}),null===(t=this._roomleRenderer)||void 0===t||t.highlightObjects(Array.from(n))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,a,i,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){e||(e=this.getBounds()),e&&(this._cameraControl instanceof CameraControl3D&&this._cameraControl.updateToBounds(e,!1),this._cameraControl instanceof CameraControl2D&&this._cameraControl.zoomToFitBounds(getDrawingMinBounds(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight,1.1),!0),this._renderEverything())}_zoomToBounds(e,t=!0){const n=this.getBounds();this._cameraControl instanceof CameraControl3D&&(this._getViewModel().getPlanObjectCount()<=1?this._cameraControl.zoomToFitBounds(n,t):this._cameraControl.checkBoundsAndPlaceCamera(n,t)),this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(n,e,t)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof CameraControl2D&&this._cameraControl.zoomToFitBounds(e,!1,!0),this._cameraControl instanceof CameraControl3D&&this._cameraControl.zoomToFitBounds(e,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}getPlanObject(e){const t=this._getKernelAccess().planInteractionHandler,n=this._plannerKernelAccess.planModelViewHelper,a=t.getPlan();return n.getPlanObject(a,e)}cancelPlanElementSelection(e){this._plannerSceneEventHandler.cancelSelection(e),this._highlightPlanElement(null),this._requestRender()}async deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection("delete_object"),await this.deletePlanElementByIds(e)}async deletePlanElementByIds(e){for(const t of e){const e=this._getViewModel().getPlanObjectForId(t);if(e&&e.getObject()){const t=this.getPlanObject(e.getId());let n;t&&(n=await mapToUiPlanObjects([t],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.REMOVED,n?n[0]:null),this._getKernelAccess().planInteractionHandler.removeElement(e.getKernelObject())}}}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new Box3;let a={x:0,y:0,z:0};if(this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(a=i.getPlanElement().getCenter(),t.push_back(i.getPlanElement()),n.expandByObject(i.getContainer()))}),t.size()>1){const e=n.getCenter(new Vector3);a=convertToKernel(e)}const i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,a)}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a;let i=this._calculateBoundingBoxOfAllMeshes(.1);null===(n=this._lightSetting)||void 0===n||n.removeFromScene(),this._cameraControl instanceof CameraControl3D&&this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D);let s=await this._imageRenderer.prepareTopImage(this._scene,null,i,e);this._cameraControl instanceof CameraControl3D&&this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(s)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{var n,a;let i;this._cameraControl instanceof CameraControl3D?i=this._cameraControl.getCamera().clone():(i=this.getPerspectiveOffsetCamera(),this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D)),i.resetOffset();let s=this._calculateBoundingBoxOfAllMeshes();null===(n=this._lightSetting)||void 0===n||n.removeFromScene();const r=await this._imageRenderer.preparePerspectiveImage(this._scene,null,i,s,e);this._cameraControl instanceof CameraControl2D&&this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D),null===(a=this._lightSetting)||void 0===a||a.addToScene(),this._requestRender(),t(r)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return ImageRenderer.getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions(),this._roomlePlannerUiCallback.onCameraIdle()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),!0}_updateNodeSize(){if(this._cameraControl instanceof CameraControl2D){const e=1/this._cameraControl.getCamera().zoom;this._getViewModel().setNodeZoom(e)}}_sendPlanObjectPositions(){if(this._cameraControl.isLocked())return;const{clientWidth:e,clientHeight:t}=this._domHelper.element,n=this._cameraControl.getCamera(),a=[],i={staticPlanObjectViewModels:this._getViewModel().getStaticPlanObjectViewModels(),configurablePlanObjectViewModels:this._getViewModel().getConfigurablePlanObjectViewModels(),constructionPlanObjectViewModels:this._getViewModel().getConstructionPlanObjectViewModels(),wallPlanObjectViewModels:this._getViewModel().getWallPlanObjectViewModels(),floorPlanObjectViewModels:this._getViewModel().getFloorPlanObjectViewModels(),nodePlanObjectViewModels:this._getViewModel().getNodePlanObjectViewModels()};for(const s of Object.values(i))for(const i of s)a.push(createTransferableObjectPosition(i,n,e,t));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(a)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:a}=this._domHelper.element,i=this._getViewModel().getWallPlanObjectViewModels(),s=this._cameraControl.getKernelZoomFactor();for(const e of i){const i=e.getWallDimension(s);if(i.length>0){const e=this._cameraControl.getCamera();i.fromPosition2d=getScreenXY(i.fromPosition3d,e,n,a),i.toPosition2d=getScreenXY(i.toPosition3d,e,n,a),i.fromWithoutPadding=getScreenXY(i.fromWithoutPadding,e,n,a),i.toWithoutPadding=getScreenXY(i.toWithoutPadding,e,n,a),i.textPosition2d=getScreenXY(i.textPosition3d,e,n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(wallDimensionToTransferable(i))}if(this._initData.debug){const e=new SphereGeometry(.1,32,16),t=new MeshBasicMaterial({color:16711680}),n=new Mesh(e,t);n.position.copy(i.fromPosition3d);const a=new Mesh(e,t);a.position.copy(i.toPosition3d);const s=new Mesh(e,new MeshBasicMaterial({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}this._roomlePlannerUiCallback.onUpdateWallDimensions(t)}enableWallDrawing(){if(this._cameraControl instanceof CameraControl2D){const e=getDrawingMinBounds(this.getBounds(),this._domHelper.element.clientWidth,this._domHelper.element.clientHeight);this._cameraControl.zoomToFitBounds(e,!0)}this._drawingEnabled||(this._drawingEnabled=!0,this._scene.add(this._plannerSceneEventHandler.enableWallDrawing()))}disableWallDrawing(){this._drawingEnabled=!1,this._cameraControl.unlock(),this._scene.remove(this._plannerSceneEventHandler.cancelWallDrawing())}escapeDrawing(){this._plannerSceneEventHandler.stopDrawing()}_changeCameraControl(e){super._changeCameraControl(e)}setSceneEvents(e){var t,n;void 0!==e.construction&&(null===(t=this._plannerSceneEventHandler)||void 0===t||t.enableConstructionEvents(e.construction)),void 0!==e.objects&&(null===(n=this._plannerSceneEventHandler)||void 0===n||n.enableObjectEvents(e.objects))}startedDrawing(){this._plannerSceneEventHandler.startDrawing()}stoppedDrawing(){this._plannerSceneEventHandler.stopDrawing()}disableEvents(){super.disableEvents(),this.disablePlannerEvents()}enableEvents(){super.enableEvents(),"planner"===this._configuratorContext.baseContext&&this.enablePlannerEvents()}resetCameraPositionToStart(e=!0){this._cameraControl instanceof CameraControl3D&&super.resetCameraPositionToStart(e),this._cameraControl instanceof CameraControl2D&&this._updateCamera()}async moveCamera(e){return this._cameraControl instanceof CameraControl3D?super.moveCamera(e):Promise.reject("Camera can only be moved in 3D")}_setInteriorOrExteriorWallMaterial(e,t){const n=this._getViewModel().getWallPlanObjectViewModels();if(!n.length)return;const a=this._getKernelAccess().planInteractionHandler,i=e=>{a.setWallLeftMaterial(e,applyMaterialToKernelMaterial(e.leftMaterial,t))},s=e=>{a.setWallRightMaterial(e,applyMaterialToKernelMaterial(e.rightMaterial,t))},r=n.map(e=>e.getKernelObject()),o=this._plannerKernelAccess.kernelContainer.WallType.InnerWall,l=this._plannerKernelAccess.kernelContainer.WallType.OuterWallLeft,c=this._plannerKernelAccess.kernelContainer.WallType.OuterWallRight;for(const t of r)t.wallType===o&&"interior"===e&&(i(t),s(t)),t.wallType===l&&("interior"===e?s(t):i(t)),t.wallType===c&&("exterior"===e?s(t):i(t))}changeInteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("interior",e)}changeExteriorWallsMaterial(e){this._setInteriorOrExteriorWallMaterial("exterior",e)}changeFloorsMaterial(e){const t=this._getViewModel().getFloorPlanObjectViewModels();if(!t.length)return;const n=this._getKernelAccess().planInteractionHandler,a=t.map(e=>e.getKernelObject());for(const t of a)n.setFloorMaterial(t,applyMaterialToKernelMaterial(t.material,e))}getWallAngleDegrees(e){if(!(e instanceof WallPlanElementViewModel))return 0;const t=this._cameraControl.getCamera(),n=new Vector2(t.position.x,t.position.z),a=new Vector2(e.getPosition().x,e.getPosition().z).clone().sub(n).normalize(),i=e.getKernelObject(),s=new Vector2(Math.sin(i.getAngle()),Math.cos(i.getAngle())),r=a.angle()-s.angle();return MathUtils.radToDeg(r)}moveElementPosition(e,t){const n=this._getKernelAccess().planInteractionHandler;n.setObjectFixedZ(e.getPlanElement(),!0),n.moveElementTo(e.getPlanElement(),t),this._sendPlanObjectPositions()}}__decorate([inject],PlannerSceneManager.prototype,"_rapiAccess",void 0),__decorate([inject],PlannerSceneManager.prototype,"_plannerMeshGenerator",void 0),__decorate([inject],PlannerSceneManager.prototype,"_plannerInputManager",void 0),__decorate([inject],PlannerSceneManager.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],PlannerSceneManager.prototype,"_localStorageHelper",void 0),__decorate([inject],PlannerSceneManager.prototype,"_unitFormatter",void 0);const OFFSET={left:0,top:1,right:1,bottom:0};class RoomlePlanner{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(e="unknown"){this._sceneManager.cancelPlanElementSelection(e)}init(e,t,n){return Benchmark.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{const a=isPlanSnapshotId(e);(a?this._rapiAccess.getPlanSnapshot(e):this._rapiAccess.getPlan(e)).then(n=>{const i=a?n.plan:n.planObjects;this._plan=this._planInteractionHandler.loadPlanXML(i),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t(n)},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}resetCameraPosition(){this._sceneManager.resetCameraPositionToStart()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){Promise.all([this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"})]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new PlannerSceneManager(this._creator_,OFFSET,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=DynamicLightSettingLoader.createDynamicLightSettingSource(t,n);i&&this.showStats(),this._sceneManager.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Benchmark.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new RoomleConfigurator(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);a&&this._configurator.notifyUiAboutNewLabel(a)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}showGUI(){this._sceneManager.showGUI()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);import("./configurator-8a45d794.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);import("./glb-viewer-8648293c.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=convertToKernel(new Vector3(t.x,t.y,t.z)));const a=await(isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){const t=e.map(e=>isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return await this._plannerKernelAccess.insertItems(n)}async insertItems(e){return await this._plannerKernelAccess.insertItems(e)}duplicateItems(e){return this._plannerKernelAccess.duplicateItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan),t=convertCObject(e.objects);return mapToUiPlanObjects(t,this._plannerKernelAccess,this._rapiAccess)}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return convertCObject(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}enableMultiselect(){this._sceneManager.getPlannerSceneEventHandler().setSelectionMode("multiselect"),this._configuratorContext.selectionMode="multiselect"}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),a=await this.insertItems([n]);if(1!==a.length)throw new Error("More than one object added, abort");return a[0]}enableSnapping(){this._sceneManager.enableSnapping()}disableSnapping(){this._sceneManager.disableSnapping()}async getPartlistOf(e){const t=this._plannerKernelAccess.kernelInstance.getHashOfConfiguration(e);if(!t){const e="Object has no partlist because it is not a configuration: "+t;return console.warn(e),Promise.reject(e)}const n=this._plannerKernelAccess.kernelInstance.getPartList(e);return await this._plannerKernelAccess.addUiDataAndPriceToPartList(n,t)}formatValueToUnitString(e,t){return this._unitFormatter.formatValueToUnitString(e,t)}drawWalls(e,t={}){var n,a;const i=this._planInteractionHandler;i.startInteraction();const s=[];for(const t of e){const e=i.addNode(t.from),r=i.addNode(t.to),o=i.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&i.setWallHeight(o,t.props.height),void 0!==(null===(a=t.props)||void 0===a?void 0:a.thickness)&&i.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||i.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),s}async removeElements(e,t={}){this._sceneManager.lockCamera();const n=this._planInteractionHandler;for(const t of e){const e=this._sceneManager.getPlanObject(t.getId());let n;e&&(n=await mapToUiPlanObjects([e],this._plannerKernelAccess,this._rapiAccess)),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.REMOVED,n?n[0]:null),this._planInteractionHandler.removeElement(t)}t.keepInteractionOpen||n.endInteraction(),this._sceneManager.unlockCamera()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}async saveCurrentPlanSnapshot(e){const t=await this.getPlanModelViewHelper(),n=this._planInteractionHandler.getPlan(),a=t.getPlanOverview(n),i={parentId:e||null,planObjects:[],combinedIds:[],plan:n.getPlanXML(!1,2)},s=a.objects,r=s.size();for(let e=0;e<r;e++){const t=s.get(e),n=t.configurationHash||t.catalogItemId,{center:a,dimensions:r,rotation:o}=t,l=JSON.stringify({center:a,dimensions:r,rotation:o});i.planObjects.push({combinedId:n,location:l})}const o=await this._rapiAccess.savePlanSnapshot(i),l=new Promise((e,t)=>{Promise.allSettled([this.preparePerspectiveImage(),this.prepareTopImage()]).then(async([n,a])=>{if("rejected"!==n.status&&"rejected"!==a.status)try{const t=await this._rapiAccess.savePlanSnapshotPerspectiveImage(o,n.value),i=await this._rapiAccess.savePlanSnapshotTopImage(o,a.value);e({...t,...i})}catch(e){t(e)}else t("Could not generate images of plan snapshot")})});try{return await l}catch(e){return console.error(e),o}}getPlanXmlFrom(e){return e?isPlanSnapshotId(e.id)?e.plan:e.planObjects:null}async moveCamera(e){return this._sceneManager.moveCamera(e)}async createNewSerializedConfiguration(e){return Promise.resolve(this._plannerKernelAccess.createNewSerializedConfiguration(e))}changeInteriorWallsMaterial(e){this._sceneManager.changeInteriorWallsMaterial(e)}changeExteriorWallsMaterial(e){this._sceneManager.changeExteriorWallsMaterial(e)}changeFloorsMaterial(e){this._sceneManager.changeFloorsMaterial(e)}getWallAngleDegrees(e){return this._sceneManager.getWallAngleDegrees(e)}calcPartsPriceSum(e){return this._plannerKernelAccess.calcPartsPriceSum(e)}async swapObject(e,t){const n=e.getPosition(),a=e.getRotation();return await this._sceneManager.deletePlanElementByIds([e.getPlanElement().getId()]),this.cancelSelection("swap_object"),await this.insertObject(t,n,a)}exportImageFromCamera(e="image"){this._sceneManager.exportImageFromCamera(e)}moveElementPosition(e,t){this._sceneManager.moveElementPosition(e,t)}async generateProductionServiceExport(e,t=""){try{return Promise.resolve(JSON.parse(this._plannerKernelAccess.kernelInstance.generateProductionServiceExport(e,t)))}catch(e){return console.error(e),Promise.reject("Could not create Blue Ocean MVP JSON")}}}__decorate([inject],RoomlePlanner.prototype,"_configuratorContext",void 0),__decorate([inject],RoomlePlanner.prototype,"_domHelper",void 0),__decorate([inject],RoomlePlanner.prototype,"_scriptLoader",void 0),__decorate([inject],RoomlePlanner.prototype,"_kernelAccessCallback",void 0),__decorate([inject],RoomlePlanner.prototype,"_plannerKernelAccess",void 0),__decorate([inject],RoomlePlanner.prototype,"_rapiAccess",void 0),__decorate([inject],RoomlePlanner.prototype,"_singlePromiseFactory",void 0),__decorate([inject],RoomlePlanner.prototype,"_roomlePlannerUiCallback",void 0),__decorate([inject],RoomlePlanner.prototype,"_lifeCycleManager",void 0),__decorate([inject],RoomlePlanner.prototype,"_dataSyncer",void 0),__decorate([inject],RoomlePlanner.prototype,"_initData",void 0),__decorate([inject],RoomlePlanner.prototype,"_globalInitData",void 0),__decorate([inject],RoomlePlanner.prototype,"_unitFormatter",void 0);const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("planner-input-manager",class extends InputManager{_canDrag(e){return!0}},1),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("planner-selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(e){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((t,n)=>{this._selectedPlanElementViewModels.delete(n),t.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:t,reason:e}))})}_checkStandard(e){this._selectedPlanElementViewModels.has(e.getId())||(this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e})))}_checkMulti(e){if(!isWallOrFloor(e)&&!this._selectedPlanElementViewModels.has(e.getId())){this._selectedPlanElementViewModels.set(e.getId(),e),e.select();const t=Array.from(this._selectedPlanElementViewModels).map(([e,t])=>t);this.dispatchEvent(2,new PlannerSelectionHandlerEvent({planElementViewModels:t})),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}}_deselectWallAndFloorElements(){this._selectedPlanElementViewModels.forEach((e,t)=>{isWallOrFloor(e)&&(this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e})))})}setSelectionMode(e){"multiselect"===e&&this._deselectWallAndFloorElements(),this._selectionMode=e,this.dispatchEvent(15,new PlannerSelectionHandlerEvent({selectionMode:e}))}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];class Planner extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new RoomlePlanner(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}}export{Planner};
|
|
2
|
+
//# sourceMappingURL=planner-9ebfcb2b.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-
|
|
1
|
+
{"version":3,"file":"planner-9ebfcb2b.js","sources":["../../node_modules/three/examples/jsm/objects/Sky.js"],"sourcesContent":["import {\n\tBackSide,\n\tBoxGeometry,\n\tMesh,\n\tShaderMaterial,\n\tUniformsUtils,\n\tVector3\n} from 'three';\n\n/**\n * Based on \"A Practical Analytic Model for Daylight\"\n * aka The Preetham Model, the de facto standard analytic skydome model\n * https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight\n *\n * First implemented by Simon Wallner\n * http://simonwallner.at/project/atmospheric-scattering/\n *\n * Improved by Martin Upitis\n * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR\n *\n * Three.js integration by zz85 http://twitter.com/blurspline\n*/\n\nclass Sky extends Mesh {\n\n\tconstructor() {\n\n\t\tconst shader = Sky.SkyShader;\n\n\t\tconst material = new ShaderMaterial( {\n\t\t\tname: 'SkyShader',\n\t\t\tfragmentShader: shader.fragmentShader,\n\t\t\tvertexShader: shader.vertexShader,\n\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\tside: BackSide,\n\t\t\tdepthWrite: false\n\t\t} );\n\n\t\tsuper( new BoxGeometry( 1, 1, 1 ), material );\n\n\t\tthis.isSky = true;\n\n\t}\n\n}\n\nSky.SkyShader = {\n\n\tuniforms: {\n\t\t'turbidity': { value: 2 },\n\t\t'rayleigh': { value: 1 },\n\t\t'mieCoefficient': { value: 0.005 },\n\t\t'mieDirectionalG': { value: 0.8 },\n\t\t'sunPosition': { value: new Vector3() },\n\t\t'up': { value: new Vector3( 0, 1, 0 ) }\n\t},\n\n\tvertexShader: /* glsl */`\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}`,\n\n\tfragmentShader: /* glsl */`\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\tconst vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPos );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <colorspace_fragment>\n\n\t\t}`\n\n};\n\nexport { Sky };\n"],"names":["Sky","Mesh","[object Object]","shader","SkyShader","material","ShaderMaterial","name","fragmentShader","vertexShader","uniforms","UniformsUtils","clone","side","BackSide","depthWrite","super","BoxGeometry","this","isSky","turbidity","value","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","Vector3","up"],"mappings":"m7kBAuBA,MAAMA,YAAYC,KAEjBC,cAEC,MAAMC,EAASH,IAAII,UAEbC,EAAW,IAAIC,eAAgB,CACpCC,KAAM,YACNC,eAAgBL,EAAOK,eACvBC,aAAcN,EAAOM,aACrBC,SAAUC,cAAcC,MAAOT,EAAOO,UACtCG,KAAMC,SACNC,YAAY,IAGbC,MAAO,IAAIC,YAAa,EAAG,EAAG,GAAKZ,GAEnCa,KAAKC,OAAQ,GAMfnB,IAAII,UAAY,CAEfM,SAAU,CACTU,UAAa,CAAEC,MAAO,GACtBC,SAAY,CAAED,MAAO,GACrBE,eAAkB,CAAEF,MAAO,MAC3BG,gBAAmB,CAAEH,MAAO,IAC5BI,YAAe,CAAEJ,MAAO,IAAIK,SAC5BC,GAAM,CAAEN,MAAO,IAAIK,QAAS,EAAG,EAAG,KAGnCjB,aAAwB,6gFAwExBD,eAA0B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Planner}from"./planner-9ebfcb2b.js";import"./script-loader-b4f54de0.js";import"./query-params-helper-a271f9dc.js";import"./roomle-dependency-injection-390d51f2.js";import"./main-thread-to-worker-30982707.js";import"./scene-manager-f66599cf.js";import"./roomle-configurator-521e927f.js";import"./default-light-setting-d50d49f0.js";(new Planner).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let a=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-a))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)});
|
|
2
|
+
//# sourceMappingURL=planner-main-cd087802.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-main-cd087802.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./planner-
|
|
1
|
+
System.register(["./planner-89c28a23.nomodule.js","./script-loader-2d5e7ddb.nomodule.js","./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-f0a6e177.nomodule.js","./main-thread-to-worker-5609c757.nomodule.js","./scene-manager-9ba0a160.nomodule.js","./roomle-configurator-683f0ae0.nomodule.js","./default-light-setting-942df376.nomodule.js"],(function(){var e;return{setters:[function(n){e=n.Planner},function(){},function(){},function(){},function(){},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.nomodule.js.map
|