@roomle/web-sdk 2.49.0 → 2.49.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-630cae80.nomodule.js → banana-for-scale-2ecaee40.nomodule.js} +2 -2
- package/lib/{banana-for-scale-630cae80.nomodule.js.map → banana-for-scale-2ecaee40.nomodule.js.map} +1 -1
- package/lib/{banana-for-scale-3494b2b7.js → banana-for-scale-8b6079e9.js} +2 -2
- package/lib/{banana-for-scale-3494b2b7.js.map → banana-for-scale-8b6079e9.js.map} +1 -1
- package/lib/{component-dimensioning-9be410df.nomodule.js → component-dimensioning-31a8ed20.nomodule.js} +2 -2
- package/lib/component-dimensioning-31a8ed20.nomodule.js.map +1 -0
- package/lib/{component-dimensioning-aff8fb19.js → component-dimensioning-79a89191.js} +2 -2
- package/lib/component-dimensioning-79a89191.js.map +1 -0
- package/lib/{component-raycast-helper-b0006a22.nomodule.js → component-raycast-helper-207c6814.nomodule.js} +2 -2
- package/lib/component-raycast-helper-207c6814.nomodule.js.map +1 -0
- package/lib/{component-raycast-helper-66a13b09.js → component-raycast-helper-49311c54.js} +2 -2
- package/lib/component-raycast-helper-49311c54.js.map +1 -0
- package/lib/{configurator-e7d3acc7.js → configurator-182231a9.js} +2 -2
- package/lib/configurator-182231a9.js.map +1 -0
- package/lib/{configurator-a6082e16.nomodule.js → configurator-d94eb4a1.nomodule.js} +2 -2
- package/lib/configurator-d94eb4a1.nomodule.js.map +1 -0
- package/lib/configurator-main-d548da78.js +2 -0
- package/lib/configurator-main-d548da78.js.map +1 -0
- package/lib/configurator-main.nomodule.js +1 -1
- package/lib/{continuous-drawing-helper-82c279d6.js → continuous-drawing-helper-1cf7ab68.js} +2 -2
- package/lib/continuous-drawing-helper-1cf7ab68.js.map +1 -0
- package/lib/{continuous-drawing-helper-10e6a713.nomodule.js → continuous-drawing-helper-69f0d4b9.nomodule.js} +2 -2
- package/lib/continuous-drawing-helper-69f0d4b9.nomodule.js.map +1 -0
- package/lib/{default-light-setting-1bddd22d.js → default-light-setting-0df3182d.js} +2 -2
- package/lib/default-light-setting-0df3182d.js.map +1 -0
- package/lib/{default-light-setting-f9c293e7.nomodule.js → default-light-setting-16ddc3a6.nomodule.js} +2 -2
- package/lib/default-light-setting-16ddc3a6.nomodule.js.map +1 -0
- package/lib/{dimensioning-helper-b5bcba13.nomodule.js → dimensioning-helper-4683c5b0.nomodule.js} +2 -2
- package/lib/{dimensioning-helper-b5bcba13.nomodule.js.map → dimensioning-helper-4683c5b0.nomodule.js.map} +1 -1
- package/lib/{dimensioning-helper-313da49f.js → dimensioning-helper-ce6bfc1a.js} +2 -2
- package/lib/{dimensioning-helper-313da49f.js.map → dimensioning-helper-ce6bfc1a.js.map} +1 -1
- package/lib/{glb-viewer-7e837ece.js → glb-viewer-164d0e63.js} +2 -2
- package/lib/{glb-viewer-7e837ece.js.map → glb-viewer-164d0e63.js.map} +1 -1
- package/lib/{glb-viewer-30d0cb88.nomodule.js → glb-viewer-d1b213e5.nomodule.js} +2 -2
- package/lib/{glb-viewer-30d0cb88.nomodule.js.map → glb-viewer-d1b213e5.nomodule.js.map} +1 -1
- package/lib/glb-viewer-main-6d2ca432.js +2 -0
- package/lib/glb-viewer-main-6d2ca432.js.map +1 -0
- package/lib/glb-viewer-main.nomodule.js +1 -1
- package/lib/legacy/{banana-for-scale-d8563084.legacy.js → banana-for-scale-2b6fc9db.legacy.js} +2 -2
- package/lib/legacy/{banana-for-scale-d8563084.legacy.js.map → banana-for-scale-2b6fc9db.legacy.js.map} +1 -1
- package/lib/legacy/{component-dimensioning-fee45704.legacy.js → component-dimensioning-8070bf6b.legacy.js} +2 -2
- package/lib/legacy/component-dimensioning-8070bf6b.legacy.js.map +1 -0
- package/lib/legacy/{component-raycast-helper-4a8fcbff.legacy.js → component-raycast-helper-eaba30f7.legacy.js} +2 -2
- package/lib/legacy/component-raycast-helper-eaba30f7.legacy.js.map +1 -0
- package/lib/legacy/{configurator-35596e9c.legacy.js → configurator-ad1d82fc.legacy.js} +2 -2
- package/lib/legacy/configurator-ad1d82fc.legacy.js.map +1 -0
- package/lib/legacy/configurator-main.legacy.js +1 -1
- package/lib/legacy/{continuous-drawing-helper-94374c51.legacy.js → continuous-drawing-helper-d1e6350b.legacy.js} +2 -2
- package/lib/legacy/continuous-drawing-helper-d1e6350b.legacy.js.map +1 -0
- package/lib/legacy/{default-light-setting-44ae7168.legacy.js → default-light-setting-7d9adb95.legacy.js} +2 -2
- package/lib/legacy/default-light-setting-7d9adb95.legacy.js.map +1 -0
- package/lib/legacy/{dimensioning-helper-52b2d970.legacy.js → dimensioning-helper-d7e0b04b.legacy.js} +2 -2
- package/lib/legacy/{dimensioning-helper-52b2d970.legacy.js.map → dimensioning-helper-d7e0b04b.legacy.js.map} +1 -1
- package/lib/legacy/{glb-viewer-ffa68ea5.legacy.js → glb-viewer-05a3d0a1.legacy.js} +2 -2
- package/lib/legacy/{glb-viewer-ffa68ea5.legacy.js.map → glb-viewer-05a3d0a1.legacy.js.map} +1 -1
- package/lib/legacy/glb-viewer-main.legacy.js +1 -1
- package/lib/legacy/{material-viewer-17e872f7.legacy.js → material-viewer-703558c1.legacy.js} +2 -2
- package/lib/legacy/material-viewer-703558c1.legacy.js.map +1 -0
- package/lib/legacy/material-viewer-main.legacy.js +1 -1
- package/lib/legacy/{pixotron-581948bd.legacy.js → pixotron-b60694dd.legacy.js} +2 -2
- package/lib/legacy/{pixotron-581948bd.legacy.js.map → pixotron-b60694dd.legacy.js.map} +1 -1
- package/lib/legacy/{planner-0ce61c4e.legacy.js → planner-c726ee53.legacy.js} +2 -2
- package/lib/legacy/{planner-0ce61c4e.legacy.js.map → planner-c726ee53.legacy.js.map} +1 -1
- package/lib/legacy/planner-main.legacy.js +1 -1
- package/lib/legacy/{roomle-configurator-863f369b.legacy.js → roomle-configurator-4f319c2e.legacy.js} +2 -2
- package/lib/legacy/{roomle-configurator-863f369b.legacy.js.map → roomle-configurator-4f319c2e.legacy.js.map} +1 -1
- package/lib/legacy/roomle-dependency-injection-b8a4a7f3.legacy.js +16 -0
- package/lib/legacy/{roomle-dependency-injection-3c6e7e0c.legacy.js.map → roomle-dependency-injection-b8a4a7f3.legacy.js.map} +1 -1
- package/lib/legacy/roomle-sdk.legacy.js +1 -1
- package/lib/legacy/{script-loader-708e2ce3.legacy.js → script-loader-5b832ac7.legacy.js} +2 -2
- package/lib/legacy/script-loader-5b832ac7.legacy.js.map +1 -0
- package/lib/legacy/static/{asset-loader.worker-5cacc1c1a2be88a6.js → asset-loader.worker-d8f85c01953acd85.js} +1 -1
- package/lib/{static/shaders-aab1a9168e9f3891.json → legacy/static/shaders-32c877bd71067eb5.json} +1 -1
- package/lib/legacy/{stats-helper-b82e8034.legacy.js → stats-helper-ac9962b4.legacy.js} +2 -2
- package/lib/legacy/{stats-helper-b82e8034.legacy.js.map → stats-helper-ac9962b4.legacy.js.map} +1 -1
- package/lib/legacy/{tools-core-49787559.legacy.js → tools-core-c6d575c9.legacy.js} +2 -2
- package/lib/legacy/tools-core-c6d575c9.legacy.js.map +1 -0
- package/lib/{material-viewer-b5d239ce.nomodule.js → material-viewer-9ff4f9e9.nomodule.js} +2 -2
- package/lib/material-viewer-9ff4f9e9.nomodule.js.map +1 -0
- package/lib/{material-viewer-3fd1d11d.js → material-viewer-b127c8c9.js} +2 -2
- package/lib/material-viewer-b127c8c9.js.map +1 -0
- package/lib/material-viewer-main-dcbbacf9.js +2 -0
- package/lib/material-viewer-main-dcbbacf9.js.map +1 -0
- package/lib/material-viewer-main.nomodule.js +1 -1
- package/lib/{pixotron-bcd1bd40.nomodule.js → pixotron-48835ed9.nomodule.js} +2 -2
- package/lib/{pixotron-bcd1bd40.nomodule.js.map → pixotron-48835ed9.nomodule.js.map} +1 -1
- package/lib/{pixotron-9cfcc41f.js → pixotron-b1119eb8.js} +2 -2
- package/lib/{pixotron-9cfcc41f.js.map → pixotron-b1119eb8.js.map} +1 -1
- package/lib/{planner-f6c307ca.js → planner-157713ae.js} +2 -2
- package/lib/{planner-f6c307ca.js.map → planner-157713ae.js.map} +1 -1
- package/lib/{planner-1e63d8f2.nomodule.js → planner-3459a34c.nomodule.js} +2 -2
- package/lib/{planner-1e63d8f2.nomodule.js.map → planner-3459a34c.nomodule.js.map} +1 -1
- package/lib/planner-main-918272bb.js +2 -0
- package/lib/planner-main-918272bb.js.map +1 -0
- package/lib/planner-main.nomodule.js +1 -1
- package/lib/{roomle-configurator-1071906a.js → roomle-configurator-c59e6b77.js} +2 -2
- package/lib/{roomle-configurator-1071906a.js.map → roomle-configurator-c59e6b77.js.map} +1 -1
- package/lib/{roomle-configurator-1a514c7b.nomodule.js → roomle-configurator-e3f2962f.nomodule.js} +2 -2
- package/lib/{roomle-configurator-1a514c7b.nomodule.js.map → roomle-configurator-e3f2962f.nomodule.js.map} +1 -1
- package/lib/roomle-dependency-injection-58fb9079.nomodule.js +16 -0
- package/lib/{roomle-dependency-injection-d13516f4.nomodule.js.map → roomle-dependency-injection-58fb9079.nomodule.js.map} +1 -1
- package/lib/roomle-dependency-injection-a073b368.js +16 -0
- package/lib/{roomle-dependency-injection-b50b25e7.js.map → roomle-dependency-injection-a073b368.js.map} +1 -1
- package/lib/{roomle-sdk-f35ff230.js → roomle-sdk-08b5bd91.js} +2 -2
- package/lib/roomle-sdk-08b5bd91.js.map +1 -0
- package/lib/roomle-sdk.nomodule.js +1 -1
- package/lib/{script-loader-a03cd80c.nomodule.js → script-loader-3d2ea0f9.nomodule.js} +2 -2
- package/lib/script-loader-3d2ea0f9.nomodule.js.map +1 -0
- package/lib/{script-loader-ebfec52a.js → script-loader-6849d83c.js} +2 -2
- package/lib/script-loader-6849d83c.js.map +1 -0
- package/lib/static/{asset-loader.worker-5cacc1c1a2be88a6.js → asset-loader.worker-d8f85c01953acd85.js} +1 -1
- package/lib/static/{asset-loader.worker-5cacc1c1a2be88a6.js.map → asset-loader.worker-d8f85c01953acd85.js.map} +1 -1
- package/lib/static/asset-loader.worker.js +1 -1
- package/lib/static/asset-loader.worker.js.map +1 -1
- package/lib/{legacy/static/shaders-aab1a9168e9f3891.json → static/shaders-32c877bd71067eb5.json} +1 -1
- package/lib/{stats-helper-ac74f51c.js → stats-helper-1604d54b.js} +2 -2
- package/lib/{stats-helper-ac74f51c.js.map → stats-helper-1604d54b.js.map} +1 -1
- package/lib/{stats-helper-f3059a47.nomodule.js → stats-helper-42ef6c36.nomodule.js} +2 -2
- package/lib/{stats-helper-f3059a47.nomodule.js.map → stats-helper-42ef6c36.nomodule.js.map} +1 -1
- package/lib/{tools-core-17918f3f.js → tools-core-45fd7826.js} +2 -2
- package/lib/tools-core-45fd7826.js.map +1 -0
- package/lib/{tools-core-c5f71863.nomodule.js → tools-core-912c41ec.nomodule.js} +2 -2
- package/lib/tools-core-912c41ec.nomodule.js.map +1 -0
- package/package.json +2 -2
- package/lib/component-dimensioning-9be410df.nomodule.js.map +0 -1
- package/lib/component-dimensioning-aff8fb19.js.map +0 -1
- package/lib/component-raycast-helper-66a13b09.js.map +0 -1
- package/lib/component-raycast-helper-b0006a22.nomodule.js.map +0 -1
- package/lib/configurator-a6082e16.nomodule.js.map +0 -1
- package/lib/configurator-e7d3acc7.js.map +0 -1
- package/lib/configurator-main-52fe922c.js +0 -2
- package/lib/configurator-main-52fe922c.js.map +0 -1
- package/lib/continuous-drawing-helper-10e6a713.nomodule.js.map +0 -1
- package/lib/continuous-drawing-helper-82c279d6.js.map +0 -1
- package/lib/default-light-setting-1bddd22d.js.map +0 -1
- package/lib/default-light-setting-f9c293e7.nomodule.js.map +0 -1
- package/lib/glb-viewer-main-84f95e7b.js +0 -2
- package/lib/glb-viewer-main-84f95e7b.js.map +0 -1
- package/lib/legacy/component-dimensioning-fee45704.legacy.js.map +0 -1
- package/lib/legacy/component-raycast-helper-4a8fcbff.legacy.js.map +0 -1
- package/lib/legacy/configurator-35596e9c.legacy.js.map +0 -1
- package/lib/legacy/continuous-drawing-helper-94374c51.legacy.js.map +0 -1
- package/lib/legacy/default-light-setting-44ae7168.legacy.js.map +0 -1
- package/lib/legacy/material-viewer-17e872f7.legacy.js.map +0 -1
- package/lib/legacy/roomle-dependency-injection-3c6e7e0c.legacy.js +0 -16
- package/lib/legacy/script-loader-708e2ce3.legacy.js.map +0 -1
- package/lib/legacy/tools-core-49787559.legacy.js.map +0 -1
- package/lib/material-viewer-3fd1d11d.js.map +0 -1
- package/lib/material-viewer-b5d239ce.nomodule.js.map +0 -1
- package/lib/material-viewer-main-7bd6e12b.js +0 -2
- package/lib/material-viewer-main-7bd6e12b.js.map +0 -1
- package/lib/planner-main-053fb716.js +0 -2
- package/lib/planner-main-053fb716.js.map +0 -1
- package/lib/roomle-dependency-injection-b50b25e7.js +0 -16
- package/lib/roomle-dependency-injection-d13516f4.nomodule.js +0 -16
- package/lib/roomle-sdk-f35ff230.js.map +0 -1
- package/lib/script-loader-a03cd80c.nomodule.js.map +0 -1
- package/lib/script-loader-ebfec52a.js.map +0 -1
- package/lib/tools-core-17918f3f.js.map +0 -1
- package/lib/tools-core-c5f71863.nomodule.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./query-params-helper-a271f9dc.js";import{l as getGUI,_ as __decorate,i as inject,h as convertToKernel,N as NodePlanElementViewModel,W as WallPlanElementViewModel,a6 as isSafari,a7 as convertToTHREE,c as ConfiguratorPlanObjectViewModel,S as StaticPlanObjectViewModel,a8 as threeVectorToTransferableXY,j as getScreenXY,V as AsyncGuard,a9 as hideWallsBasedOnCamera,k as kernelBoxToThreeBox,B as Benchmark,Y as fadeIn,f as PLAN_ELEMENT_CHANGE_TYPES,d as CAMERA_TYPE,aa as setWallTransparency,ab as getDrawingMinBounds,ac as wallDimensionToTransferable,G as isIdItemId,ad as GLTF_LOADER_FILE_NAME,ae as DRACO_LOADER_FILE_NAME,r as DynamicLightSettingLoader,M as convertCObject,af as InputManager,E as EventDispatcher,D as DependencyInjectionAssignment,L as Logger,ag as PlannerMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-b50b25e7.js";import{d as deepMerge,i as setCursor,m as copy}from"./main-thread-to-worker-811523e8.js";import{S as SceneEventHandler,C as ConfiguratorSceneManager,P as PlanViewModel,G as GLTF_EXPORTER_FILE_NAME,p as prepareTopImage,a as preparePerspectiveImage,g as getCameraTargetForBBox,R as RoomleConfigurator}from"./roomle-configurator-1071906a.js";import{L as LightSetting,B as BakedShadowEnvironment,b as BackgroundEnvironment,C as CameraControl3D,d as CameraControl2D,e as CameraControlFirstPerson,T as TWEEN_FILE_NAME,P as PIXOTRON_EFFETCS,c as PIXOTRON_FILE_NAME}from"./pixotron-9cfcc41f.js";import{S as ScriptLoader,M as Main}from"./script-loader-ebfec52a.js";import"./default-light-setting-1bddd22d.js";class PlannerLightSetting extends LightSetting{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,a=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=getGUI();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class SceneEventInfo{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i}}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():this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new SceneEventInfo({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new SceneEventInfo({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.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 THREE.PlaneBufferGeometry(1e3,1e3,8,8),t=new THREE.MeshBasicMaterial;t.visible=!1;const n=new THREE.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()}),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._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(),e instanceof NodePlanElementViewModel?a=e.getPlanElement().getCenter():n&&(a=convertToKernel(new THREE.Vector3(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){this._isCurrentlyDrawing||(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(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(8,new SceneEventInfo({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement())),n.moveObjectsBy(e,convertToKernel(a))}else(e instanceof NodePlanElementViewModel||e instanceof WallPlanElementViewModel)&&(t.y=convertToTHREE(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),convertToKernel(t));this.dispatchEvent(9,new SceneEventInfo({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(10,new SceneEventInfo({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){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 THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanElement()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(i,t,convertToKernel(r)),this._position.copy(new THREE.Vector3(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof ConfiguratorPlanObjectViewModel||e instanceof StaticPlanObjectViewModel)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(11,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 THREE.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-82c279d6.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);const createTransferableObjectPosition=(e,t,n,a)=>{const i=(new THREE.Box3).setFromObject(e.getContainer()).getCenter(new THREE.Vector3);return{runtimeId:e.getId(),position2d:threeVectorToTransferableXY(getScreenXY(i,t,n,a))}};class PlannerSceneManager extends ConfiguratorSceneManager{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new AsyncGuard,this._configurableItemGuard=new AsyncGuard,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new PlannerSceneEventHandler(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(11,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(3,({planElementViewModel:e})=>this._onPlanElementHoverOn(e),this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>this._onPlanElementHoverOff(e),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})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof WallPlanElementViewModel&&this._sendWallDimensions(),this._environment instanceof BakedShadowEnvironment&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof BakedShadowEnvironment&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),convertToKernel(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._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}_onPlanElementHoverOn(e){this._highlightPlanElement(e)}_onPlanElementHoverOff(e){this._highlightPlanElement(null)}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),a=e.distanceTo(n),i=t.getSize(new THREE.Vector3),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof StaticPlanObjectViewModel&&(t="static",n.item=e.getRapiItem(),n.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof ConfiguratorPlanObjectViewModel){t="configuration";const a=e.getConfigurationRuntimeId();n.configurationRuntimeId=a}e instanceof WallPlanElementViewModel&&(t="wall",n.wall=e.getWallDimension());const a=(async()=>{const n={};if(e instanceof StaticPlanObjectViewModel&&(n.item=e.getRapiItem(),n.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);n.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);n.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(t);n.configuration=i,s=i.rootComponentId?i.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);n.component=e}n.configurationRuntimeId=a,t="configuration"}return n.planElementId=e.getId(),copy(n)})();this.currentSelection=copy(n),this._roomlePlannerUiCallback.onSelectionChange(copy(this._plannerSceneEventHandler.getSelectionMode()),copy(t),copy(n),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._lightSetting=new PlannerLightSetting(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new BackgroundEnvironment(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new BakedShadowEnvironment(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof CameraControl3D&&(hideWallsBasedOnCamera(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),this._renderEverything())}_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._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.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)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=kernelBoxToThreeBox(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=kernelBoxToThreeBox(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),Benchmark.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();fadeIn(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.ADDED),e.isInitDone().then(()=>{this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything()})}}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(),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.REMOVED)}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.CHANGED)}exportGLB(e,t){this._scriptLoader.fetch(GLTF_EXPORTER_FILE_NAME,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof PlannerLightSetting&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){if(this._onCameraMove(),!(this._cameraControl instanceof CameraControl2D)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D),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(){this._onCameraMove(),this._cameraControl instanceof CameraControl3D||(this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D),this._renderEverything(),this._changeCameraControl(new CameraControl3D(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(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;const t=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(t),null===(e=this._plannerSceneEventHandler)||void 0===e||e.setKernelZoomFactor(t)}_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 THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new CameraControlFirstPerson(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_FP),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),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){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,a,i,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){e||(e=this.getBounds()),e&&(this._cameraControl instanceof CameraControl3D&&(e.expandByScalar(1.2),this._cameraControl.updateToBounds(e,!1)),this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(getDrawingMinBounds(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight),!0))}_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)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const a=this._getViewModel().getPlanObjectForId(e);a&&a.getObject()&&(t.push_back(a.getPlanElement()),n.expandByObject(a.getContainer()))});const a=n.getCenter(new THREE.Vector3),i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,convertToKernel(a))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let a=await prepareTopImage(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(a)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof CameraControl3D?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let a=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const i=await preparePerspectiveImage(this._scene,null,n,a,e);this._lightSetting.addToScene(),this._requestRender(),t(i)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),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=this._getViewModel().getStaticPlanObjectViewModels();for(const s of i)a.push(createTransferableObjectPosition(s,n,e,t));const s=this._getViewModel().getConfigurablePlanObjectViewModels();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();for(const e of i){const i=e.getWallDimension();if(i.length>0&&(i.fromPosition2d=getScreenXY(i.fromPosition3d,this._cameraControl.getCamera(),n,a),i.toPosition2d=getScreenXY(i.toPosition3d,this._cameraControl.getCamera(),n,a),i.textPosition2d=getScreenXY(i.textPosition3d,this._cameraControl.getCamera(),n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(wallDimensionToTransferable(i))),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(i.fromPosition3d);const a=new THREE.Mesh(e,t);a.position.copy(i.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}this._roomlePlannerUiCallback.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()}}__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(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return Benchmark.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(GLTF_LOADER_FILE_NAME,{id:"gltf-loader"}),n=this._scriptLoader.fetch(DRACO_LOADER_FILE_NAME,{id:"draco-loader"}),a=this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"}),i=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,a,i]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new PlannerSceneManager(this._creator_,OFFSET,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=DynamicLightSettingLoader.createDynamicLightSettingSource(t,n);i&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const a=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(PIXOTRON_EFFETCS.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(PIXOTRON_FILE_NAME,{id:"pi-js"}).then(a,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Benchmark.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new RoomleConfigurator(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);a&&this._configurator.notifyUiAboutNewLabel(a)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);import("./configurator-e7d3acc7.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-7e837ece.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=convertToKernel(new THREE.Vector3(t.x,t.y,t.z)));const a=await(isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){const t=e.map(e=>isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return await this._plannerKernelAccess.insertItems(n)}async insertItems(e){return await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],a=[],i=convertCObject(e.objects);await Promise.all(i.map(async e=>{const i=convertCObject(e);if(i.catalogItemId?n.push(i.catalogItemId):i.configurationHash&&a.push(i.configurationHash),i.parts){const e=i.configurationHash||i.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(i.parts,e);i.parts=t}i.data=null,t.push(i)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(a)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const c=await this._rapiAccess.getComponents(o),h=new Map;for(const e of c)h.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&h.has(n.rootComponentId)){const e=h.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return convertCObject(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),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}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}}__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,"_threeLoader",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);class PlannerSelectionHandlerEvent{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("planner-input-manager",class extends InputManager{_canDrag(e){return!0}},1),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("planner-selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));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(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];class Planner extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new RoomlePlanner(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}}export{Planner};
|
|
2
|
-
//# sourceMappingURL=planner-
|
|
1
|
+
import"./query-params-helper-a271f9dc.js";import{l as getGUI,_ as __decorate,i as inject,h as convertToKernel,N as NodePlanElementViewModel,W as WallPlanElementViewModel,a6 as isSafari,a7 as convertToTHREE,c as ConfiguratorPlanObjectViewModel,S as StaticPlanObjectViewModel,a8 as threeVectorToTransferableXY,j as getScreenXY,V as AsyncGuard,a9 as hideWallsBasedOnCamera,k as kernelBoxToThreeBox,B as Benchmark,Y as fadeIn,f as PLAN_ELEMENT_CHANGE_TYPES,d as CAMERA_TYPE,aa as setWallTransparency,ab as getDrawingMinBounds,ac as wallDimensionToTransferable,G as isIdItemId,ad as GLTF_LOADER_FILE_NAME,ae as DRACO_LOADER_FILE_NAME,r as DynamicLightSettingLoader,M as convertCObject,af as InputManager,E as EventDispatcher,D as DependencyInjectionAssignment,L as Logger,ag as PlannerMeshGenerator,R as RapiAccess,b as RoomleDependencyInjection}from"./roomle-dependency-injection-a073b368.js";import{d as deepMerge,i as setCursor,m as copy}from"./main-thread-to-worker-811523e8.js";import{S as SceneEventHandler,C as ConfiguratorSceneManager,P as PlanViewModel,G as GLTF_EXPORTER_FILE_NAME,p as prepareTopImage,a as preparePerspectiveImage,g as getCameraTargetForBBox,R as RoomleConfigurator}from"./roomle-configurator-c59e6b77.js";import{L as LightSetting,B as BakedShadowEnvironment,b as BackgroundEnvironment,C as CameraControl3D,d as CameraControl2D,e as CameraControlFirstPerson,T as TWEEN_FILE_NAME,P as PIXOTRON_EFFETCS,c as PIXOTRON_FILE_NAME}from"./pixotron-b1119eb8.js";import{S as ScriptLoader,M as Main}from"./script-loader-6849d83c.js";import"./default-light-setting-0df3182d.js";class PlannerLightSetting extends LightSetting{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,a=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);a.normalize(),a.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(a),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=getGUI();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class SceneEventInfo{constructor(e){const{planElementViewModel:t,resetCamera:n,state:a,oldState:i}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===a?0:a,this.oldState=void 0===i?0:i}}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():this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new SceneEventInfo({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new SceneEventInfo({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.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 THREE.PlaneBufferGeometry(1e3,1e3,8,8),t=new THREE.MeshBasicMaterial;t.visible=!1;const n=new THREE.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()}),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._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(),e instanceof NodePlanElementViewModel?a=e.getPlanElement().getCenter():n&&(a=convertToKernel(new THREE.Vector3(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,a):this._startWallDrawing(null,a,t)}_hoverOn(e){this._isCurrentlyDrawing||(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(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(8,new SceneEventInfo({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let a=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement())),n.moveObjectsBy(e,convertToKernel(a))}else(e instanceof NodePlanElementViewModel||e instanceof WallPlanElementViewModel)&&(t.y=convertToTHREE(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),convertToKernel(t));this.dispatchEvent(9,new SceneEventInfo({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(10,new SceneEventInfo({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,a=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),a.rotation-t)}}setState(e){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 THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const i=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,s=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(i.push_back(n.getPlanElement()),s.expandByObject(n.getContainer()))});const r=s.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(i,t,convertToKernel(r)),this._position.copy(new THREE.Vector3(n,a,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof ConfiguratorPlanObjectViewModel||e instanceof StaticPlanObjectViewModel)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(11,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 THREE.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-1cf7ab68.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);const createTransferableObjectPosition=(e,t,n,a)=>{const i=(new THREE.Box3).setFromObject(e.getContainer()).getCenter(new THREE.Vector3);return{runtimeId:e.getId(),position2d:threeVectorToTransferableXY(getScreenXY(i,t,n,a))}};class PlannerSceneManager extends ConfiguratorSceneManager{constructor(e,t,n,a){super(e,t,a),this._staticItemGuard=new AsyncGuard,this._configurableItemGuard=new AsyncGuard,this.currentSelection=null,this._stopRendering=!0,this._configuratorContext.baseContext="planner",this._roomlePlannerCallback=n,this._plannerMeshGenerator.maxAnisotropy=this._renderer.capabilities.getMaxAnisotropy(),this._plannerMeshGenerator.maxTextures=this._renderer.capabilities.maxTextures,this._plannerSceneEventHandler=new PlannerSceneEventHandler(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(11,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(3,({planElementViewModel:e})=>this._onPlanElementHoverOn(e),this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>this._onPlanElementHoverOff(e),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})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof WallPlanElementViewModel&&this._sendWallDimensions(),this._environment instanceof BakedShadowEnvironment&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof BakedShadowEnvironment&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),convertToKernel(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},this),this._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}_onPlanElementHoverOn(e){this._highlightPlanElement(e)}_onPlanElementHoverOff(e){this._highlightPlanElement(null)}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),a=e.distanceTo(n),i=t.getSize(new THREE.Vector3),s=Math.max(i.x,i.z)+3;if(a>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof StaticPlanObjectViewModel&&(t="static",n.item=e.getRapiItem(),n.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof ConfiguratorPlanObjectViewModel){t="configuration";const a=e.getConfigurationRuntimeId();n.configurationRuntimeId=a}e instanceof WallPlanElementViewModel&&(t="wall",n.wall=e.getWallDimension());const a=(async()=>{const n={};if(e instanceof StaticPlanObjectViewModel&&(n.item=e.getRapiItem(),n.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);n.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);n.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(a),i=await this._rapiAccess.saveConfiguration(t);n.configuration=i,s=i.rootComponentId?i.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);n.component=e}n.configurationRuntimeId=a,t="configuration"}return n.planElementId=e.getId(),copy(n)})();this.currentSelection=copy(n),this._roomlePlannerUiCallback.onSelectionChange(copy(this._plannerSceneEventHandler.getSelectionMode()),copy(t),copy(n),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._lightSetting=new PlannerLightSetting(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new BackgroundEnvironment(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new BakedShadowEnvironment(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof CameraControl3D&&(hideWallsBasedOnCamera(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),this._renderEverything())}_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._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.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)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof CameraControl3D&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,a)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},a)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=kernelBoxToThreeBox(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=kernelBoxToThreeBox(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),Benchmark.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,a,i,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();fadeIn(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.ADDED),e.isInitDone().then(()=>{this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything()})}}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(),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.REMOVED)}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(PLAN_ELEMENT_CHANGE_TYPES.CHANGED)}exportGLB(e,t){this._scriptLoader.fetch(GLTF_EXPORTER_FILE_NAME,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof PlannerLightSetting&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){if(this._onCameraMove(),!(this._cameraControl instanceof CameraControl2D)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_2D),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(){this._onCameraMove(),this._cameraControl instanceof CameraControl3D||(this._getViewModel().setCameraType(CAMERA_TYPE.CAMERA_3D),this._renderEverything(),this._changeCameraControl(new CameraControl3D(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(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;const t=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(t),null===(e=this._plannerSceneEventHandler)||void 0===e||e.setKernelZoomFactor(t)}_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 THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new CameraControlFirstPerson(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(CAMERA_TYPE.CAMERA_FP),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),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){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,a,i,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){e||(e=this.getBounds()),e&&(this._cameraControl instanceof CameraControl3D&&(e.expandByScalar(1.2),this._cameraControl.updateToBounds(e,!1)),this._cameraControl instanceof CameraControl2D&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(getDrawingMinBounds(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight),!0))}_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)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const a=this._getViewModel().getPlanObjectForId(e);a&&a.getObject()&&(t.push_back(a.getPlanElement()),n.expandByObject(a.getContainer()))});const a=n.getCenter(new THREE.Vector3),i=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(i,e,convertToKernel(a))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let a=await prepareTopImage(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(a)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof CameraControl3D?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let a=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const i=await preparePerspectiveImage(this._scene,null,n,a,e);this._lightSetting.addToScene(),this._requestRender(),t(i)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return getCameraTargetForBBox(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),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=this._getViewModel().getStaticPlanObjectViewModels();for(const s of i)a.push(createTransferableObjectPosition(s,n,e,t));const s=this._getViewModel().getConfigurablePlanObjectViewModels();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();for(const e of i){const i=e.getWallDimension();if(i.length>0&&(i.fromPosition2d=getScreenXY(i.fromPosition3d,this._cameraControl.getCamera(),n,a),i.toPosition2d=getScreenXY(i.toPosition3d,this._cameraControl.getCamera(),n,a),i.textPosition2d=getScreenXY(i.textPosition3d,this._cameraControl.getCamera(),n,a),i.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(i.length),t.push(wallDimensionToTransferable(i))),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(i.fromPosition3d);const a=new THREE.Mesh(e,t);a.position.copy(i.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(i.textPosition3d),this._scene.add(n),this._scene.add(a),this._scene.add(s)}}this._roomlePlannerUiCallback.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()}}__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(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return Benchmark.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(GLTF_LOADER_FILE_NAME,{id:"gltf-loader"}),n=this._scriptLoader.fetch(DRACO_LOADER_FILE_NAME,{id:"draco-loader"}),a=this._scriptLoader.fetch(TWEEN_FILE_NAME,{id:"tween-js"}),i=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,a,i]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:a,stats:i}=this._initData;this._sceneManager||(this._sceneManager=new PlannerSceneManager(this._creator_,OFFSET,this,a)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=DynamicLightSettingLoader.createDynamicLightSettingSource(t,n);i&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const a=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(PIXOTRON_EFFETCS.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(PIXOTRON_FILE_NAME,{id:"pi-js"}).then(a,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){Benchmark.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new RoomleConfigurator(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,a=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);a&&this._configurator.notifyUiAboutNewLabel(a)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);import("./configurator-182231a9.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-164d0e63.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=convertToKernel(new THREE.Vector3(t.x,t.y,t.z)));const a=await(isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),i=await this._plannerKernelAccess.addPlanObjectFromItem(a,t,n);return this._sceneManager.updateScene(),i}async insertItemList(e){const t=e.map(e=>isIdItemId(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),n=await Promise.all(t);return await this._plannerKernelAccess.insertItems(n)}async insertItems(e){return await this._plannerKernelAccess.insertItems(e)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],a=[],i=convertCObject(e.objects);await Promise.all(i.map(async e=>{const i=convertCObject(e);if(i.catalogItemId?n.push(i.catalogItemId):i.configurationHash&&a.push(i.configurationHash),i.parts){const e=i.configurationHash||i.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(i.parts,e);i.parts=t}i.data=null,t.push(i)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(a)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const c=await this._rapiAccess.getComponents(o),h=new Map;for(const e of c)h.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&h.has(n.rootComponentId)){const e=h.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return convertCObject(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),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}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}}__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,"_threeLoader",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);class PlannerSelectionHandlerEvent{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const INJECTABLES=[new DependencyInjectionAssignment("script-loader",ScriptLoader),new DependencyInjectionAssignment("planner-input-manager",class extends InputManager{_canDrag(e){return!0}},1),new DependencyInjectionAssignment("logger",Logger),new DependencyInjectionAssignment("planner-mesh-generator",PlannerMeshGenerator),new DependencyInjectionAssignment("rapi-access",RapiAccess),new DependencyInjectionAssignment("planner-selection-handler",class extends EventDispatcher{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));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(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new PlannerSelectionHandlerEvent({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new PlannerSelectionHandlerEvent({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];class Planner extends Main{setupGlobals(){}setupDependencies(){RoomleDependencyInjection.setup(INJECTABLES),this.lookup("logger",this._context),this.lookup("planner-kernel-access",this._context).init(0)}cleanUpGlobals(){throw new Error("Method not implemented.")}cleanUpDependencies(){throw new Error("Method not implemented.")}bootFinished(){this._planner=new RoomlePlanner(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}}export{Planner};
|
|
2
|
+
//# sourceMappingURL=planner-157713ae.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-
|
|
1
|
+
{"version":3,"file":"planner-157713ae.js","sources":["../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"0t7CAAe"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-d13516f4.nomodule.js","./main-thread-to-worker-1c4e6a69.nomodule.js","./roomle-configurator-1a514c7b.nomodule.js","./pixotron-bcd1bd40.nomodule.js","./script-loader-a03cd80c.nomodule.js","./default-light-setting-f9c293e7.nomodule.js"],(function(e,t){var n,i,a,s,r,o,l,h,c,d,_,g,p,m,u,w,E,C,v,f,b,S,M,P,I,H,y,D,L,k,O,A,V,T,R,j,x,B,F,W,G,K,U,z,N,q,Z,X,Q,Y,J,$,ee,te,ne,ie;return{setters:[function(){},function(e){n=e.l,i=e._,a=e.i,s=e.h,r=e.N,o=e.W,l=e.a6,h=e.a7,c=e.c,d=e.S,_=e.a8,g=e.j,p=e.V,m=e.a9,u=e.k,w=e.B,E=e.Y,C=e.f,v=e.d,f=e.aa,b=e.ab,S=e.ac,M=e.G,P=e.ad,I=e.ae,H=e.r,y=e.M,D=e.af,L=e.E,k=e.D,O=e.L,A=e.ag,V=e.R,T=e.b},function(e){R=e.d,j=e.i,x=e.m},function(e){B=e.S,F=e.C,W=e.P,G=e.G,K=e.p,U=e.a,z=e.g,N=e.R},function(e){q=e.L,Z=e.B,X=e.b,Q=e.C,Y=e.d,J=e.e,$=e.T,ee=e.P,te=e.c},function(e){ne=e.S,ie=e.M},function(){}],execute:function(){class ae extends q{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,i=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);i.normalize(),i.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(i),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=n();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class se{constructor(e){const{planElementViewModel:t,resetCamera:n,state:i,oldState:a}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===i?0:i,this.oldState=void 0===a?0:a}}class re extends B{constructor(e,t,n,i){super(e,t,n,i),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():this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new se({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new se({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.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=R(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=R(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 THREE.PlaneBufferGeometry(1e3,1e3,8,8),t=new THREE.MeshBasicMaterial;t.visible=!1;const n=new THREE.Mesh(e,t);return n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData=R(n.userData,{hasListener:!0,priority:.9,roomleId:void 0}),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(s(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{this._isCurrentlyDrawing?this._clickOnPlane(s(e.attachment.intersection.point)):this._plannerSelectionHandler.cancelSelection()}),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._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof r||e instanceof o))return;let i;this._debug&&e.getId(),e instanceof o&&this._plannerSelectionHandler.cancelSelection(),e instanceof r?i=e.getPlanElement().getCenter():n&&(i=s(new THREE.Vector3(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,i):this._startWallDrawing(null,i,t)}_hoverOn(e){this._isCurrentlyDrawing||(e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new se({planElementViewModel:e})),this._interaction(),this._setCursor())}_hoverOff(e){e.hoverOff(),this.dispatchEvent(4,new se({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?j("ew-resize"):1===this._state?j("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?j("move"):this._hoveredObject?j("pointer"):3===this._state?j(l?"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"):j("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(8,new se({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let i=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement())),n.moveObjectsBy(e,s(i))}else(e instanceof r||e instanceof o)&&(t.y=h(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),s(t));this.dispatchEvent(9,new se({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(10,new se({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,i=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),i.rotation-t)}}setState(e){var t,n;const i=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new se({state:this._state,oldState:i})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===i&&(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:i}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const a=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,r=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(a.push_back(n.getPlanElement()),r.expandByObject(n.getContainer()))});const o=r.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(a,t,s(o)),this._position.copy(new THREE.Vector3(n,i,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof c||e instanceof d)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(11,new se({}))}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 THREE.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:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:i,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continousDrawingHelper.update());const{x:i,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.beginDrawing({x:i,y:a,z:0}),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continousDrawingHelper){const{default:e}=await t.import("./continuous-drawing-helper-10e6a713.nomodule.js");this._continousDrawingHelper=new e,this._continousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing)return;const{x:n,y:i}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:i,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:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:i,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)}}i([a],re.prototype,"_plannerSelectionHandler",void 0),i([a],re.prototype,"_plannerKernelAccess",void 0);const oe=(e,t,n,i)=>{const a=(new THREE.Box3).setFromObject(e.getContainer()).getCenter(new THREE.Vector3);return{runtimeId:e.getId(),position2d:_(g(a,t,n,i))}};class le extends F{constructor(e,t,n,i){super(e,t,i),this._staticItemGuard=new p,this._configurableItemGuard=new p,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 re(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(11,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(3,({planElementViewModel:e})=>this._onPlanElementHoverOn(e),this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>this._onPlanElementHoverOff(e),this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof d&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof o&&this._sendWallDimensions(),this._environment instanceof Z&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof Z&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),s(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},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 W(this._creator_)),this._viewModel}_onPlanElementHoverOn(e){this._highlightPlanElement(e)}_onPlanElementHoverOff(e){this._highlightPlanElement(null)}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),i=e.distanceTo(n),a=t.getSize(new THREE.Vector3),s=Math.max(a.x,a.z)+3;if(i>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof d&&(t="static",n.item=e.getRapiItem(),n.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof c){t="configuration";const i=e.getConfigurationRuntimeId();n.configurationRuntimeId=i}e instanceof o&&(t="wall",n.wall=e.getWallDimension());const i=(async()=>{const n={};if(e instanceof d&&(n.item=e.getRapiItem(),n.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof c){await e.isInitDone();const i=e.getConfigurationRuntimeId(),a=e.getPlanObject().getCatalogItemId();let s,r=a;if(r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(i)),this._configuratorContext.planObjectId=i,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),a&&M(a)){const e=await this._rapiAccess.getItem(a);n.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);n.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(i),a=await this._rapiAccess.saveConfiguration(t);n.configuration=a,s=a.rootComponentId?a.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);n.component=e}n.configurationRuntimeId=i,t="configuration"}return n.planElementId=e.getId(),x(n)})();this.currentSelection=x(n),this._roomlePlannerUiCallback.onSelectionChange(x(this._plannerSceneEventHandler.getSelectionMode()),x(t),x(n),i,e),(e instanceof o||e instanceof r)&&(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._lightSetting=new ae(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new X(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new Z(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof Q&&(m(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),this._renderEverything())}_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 Q&&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._cameraControl instanceof Q&&this._cameraControl.setObjectRotation(n.getPlanElement().rotation);const i=null==n?void 0:n.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==i&&(this._configuratorContext.planObjectId=i),this._getViewModel().hideAllExcept(t),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(i),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(i),this.updateEnvironment(this.getBounds(),!0);const a=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==a||a.startInteraction()}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof Q&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,i)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},i)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=u(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=u(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),w.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,i,a,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();E(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(C.ADDED),e.isInitDone().then(()=>{this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything()})}}removePlanObjectFromScene(e){(e instanceof o||e instanceof r)&&this._sendWallDimensions(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged(C.REMOVED)}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(C.CHANGED)}exportGLB(e,t){this._scriptLoader.fetch(G,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof ae&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){if(this._onCameraMove(),!(this._cameraControl instanceof Y)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(v.CAMERA_2D),this._renderEverything(),this._changeCameraControl(new Y(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(v.CAMERA_2D),this._setCameraControlListeners(),this._setKernelZoomFactor(),this._onCameraMove()}}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof Q||(this._getViewModel().setCameraType(v.CAMERA_3D),this._renderEverything(),this._changeCameraControl(new Q(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(v.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;const t=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(t),null===(e=this._plannerSceneEventHandler)||void 0===e||e.setKernelZoomFactor(t)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof J?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 Q&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof J)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>f(e.material,!1,!1)),this._getViewModel().setCameraType(v.CAMERA_FP),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new J(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(v.CAMERA_FP),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof Q&&(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 Q&&(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 v.CAMERA_2D:this.switchTo2D();break;case v.CAMERA_3D:this.switchTo3D();break;case v.CAMERA_FP:this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,i,a,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){e||(e=this.getBounds()),e&&(this._cameraControl instanceof Q&&(e.expandByScalar(1.2),this._cameraControl.updateToBounds(e,!1)),this._cameraControl instanceof Y&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(b(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight),!0))}_zoomToBounds(e,t=!0){const n=this.getBounds();this._cameraControl instanceof Q&&(this._getViewModel().getPlanObjectCount()<=1?this._cameraControl.zoomToFitBounds(n,t):this._cameraControl.checkBoundsAndPlaceCamera(n,t)),this._cameraControl instanceof Y&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(n,e,t)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof Y&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(t.push_back(i.getPlanElement()),n.expandByObject(i.getContainer()))});const i=n.getCenter(new THREE.Vector3),a=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(a,e,s(i))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let i=await K(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(i)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof Q?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let i=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const a=await U(this._scene,null,n,i,e);this._lightSetting.addToScene(),this._requestRender(),t(a)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return z(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),!0}_updateNodeSize(){if(this._cameraControl instanceof Y){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(),i=[],a=this._getViewModel().getStaticPlanObjectViewModels();for(const s of a)i.push(oe(s,n,e,t));const s=this._getViewModel().getConfigurablePlanObjectViewModels();for(const a of s)i.push(oe(a,n,e,t));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(i)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:i}=this._domHelper.element,a=this._getViewModel().getWallPlanObjectViewModels();for(const e of a){const a=e.getWallDimension();if(a.length>0&&(a.fromPosition2d=g(a.fromPosition3d,this._cameraControl.getCamera(),n,i),a.toPosition2d=g(a.toPosition3d,this._cameraControl.getCamera(),n,i),a.textPosition2d=g(a.textPosition3d,this._cameraControl.getCamera(),n,i),a.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(a.length),t.push(S(a))),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(a.fromPosition3d);const i=new THREE.Mesh(e,t);i.position.copy(a.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(a.textPosition3d),this._scene.add(n),this._scene.add(i),this._scene.add(s)}}this._roomlePlannerUiCallback.onUpdateWallDimensions(t)}enableWallDrawing(){if(this._cameraControl instanceof Y){const e=b(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()}}i([a],le.prototype,"_rapiAccess",void 0),i([a],le.prototype,"_plannerMeshGenerator",void 0),i([a],le.prototype,"_plannerInputManager",void 0),i([a],le.prototype,"_roomlePlannerUiCallback",void 0),i([a],le.prototype,"_localStorageHelper",void 0),i([a],le.prototype,"_unitFormatter",void 0);const he={left:0,top:1,right:1,bottom:0};class ce{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return w.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(P,{id:"gltf-loader"}),n=this._scriptLoader.fetch(I,{id:"draco-loader"}),i=this._scriptLoader.fetch($,{id:"tween-js"}),a=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,i,a]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:i,stats:a}=this._initData;this._sceneManager||(this._sceneManager=new le(this._creator_,he,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=H.createDynamicLightSettingSource(t,n);a&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const i=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(ee.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(te,{id:"pi-js"}).then(i,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){w.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new N(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,i=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);i&&this._configurator.notifyUiAboutNewLabel(i)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-a6082e16.nomodule.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);t.import("./glb-viewer-30d0cb88.nomodule.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=s(new THREE.Vector3(t.x,t.y,t.z)));const i=await(M(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),a=await this._plannerKernelAccess.addPlanObjectFromItem(i,t,n);return this._sceneManager.updateScene(),a}async insertItemList(e){const t=e.map(e=>M(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)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],i=[],a=y(e.objects);await Promise.all(a.map(async e=>{const a=y(e);if(a.catalogItemId?n.push(a.catalogItemId):a.configurationHash&&i.push(a.configurationHash),a.parts){const e=a.configurationHash||a.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(a.parts,e);a.parts=t}a.data=null,t.push(a)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(i)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const h=await this._rapiAccess.getComponents(o),c=new Map;for(const e of h)c.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return y(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),i=await this.insertItems([n]);if(1!==i.length)throw new Error("More than one object added, abort");return i[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,i;const a=this._planInteractionHandler;a.startInteraction();const s=[];for(const t of e){const e=a.addNode(t.from),r=a.addNode(t.to),o=a.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&a.setWallHeight(o,t.props.height),void 0!==(null===(i=t.props)||void 0===i?void 0:i.thickness)&&a.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||a.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}}i([a],ce.prototype,"_domHelper",void 0),i([a],ce.prototype,"_scriptLoader",void 0),i([a],ce.prototype,"_kernelAccessCallback",void 0),i([a],ce.prototype,"_plannerKernelAccess",void 0),i([a],ce.prototype,"_rapiAccess",void 0),i([a],ce.prototype,"_singlePromiseFactory",void 0),i([a],ce.prototype,"_roomlePlannerUiCallback",void 0),i([a],ce.prototype,"_lifeCycleManager",void 0),i([a],ce.prototype,"_threeLoader",void 0),i([a],ce.prototype,"_dataSyncer",void 0),i([a],ce.prototype,"_initData",void 0),i([a],ce.prototype,"_globalInitData",void 0),i([a],ce.prototype,"_unitFormatter",void 0);class de{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const _e=[new k("script-loader",ne),new k("planner-input-manager",class extends D{_canDrag(e){return!0}},1),new k("logger",O),new k("planner-mesh-generator",A),new k("rapi-access",V),new k("planner-selection-handler",class extends L{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new de({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new de({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new de({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new de({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new de({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new de({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];e("Planner",class extends ie{setupGlobals(){}setupDependencies(){T.setup(_e),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 ce(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
|
|
2
|
-
//# sourceMappingURL=planner-
|
|
1
|
+
System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-58fb9079.nomodule.js","./main-thread-to-worker-1c4e6a69.nomodule.js","./roomle-configurator-e3f2962f.nomodule.js","./pixotron-48835ed9.nomodule.js","./script-loader-3d2ea0f9.nomodule.js","./default-light-setting-16ddc3a6.nomodule.js"],(function(e,t){var n,i,a,s,r,o,l,h,c,d,_,g,p,m,u,w,E,C,v,f,b,S,M,P,I,H,y,D,L,k,O,A,V,T,R,j,x,B,F,W,G,K,U,z,N,q,Z,X,Q,Y,J,$,ee,te,ne,ie;return{setters:[function(){},function(e){n=e.l,i=e._,a=e.i,s=e.h,r=e.N,o=e.W,l=e.a6,h=e.a7,c=e.c,d=e.S,_=e.a8,g=e.j,p=e.V,m=e.a9,u=e.k,w=e.B,E=e.Y,C=e.f,v=e.d,f=e.aa,b=e.ab,S=e.ac,M=e.G,P=e.ad,I=e.ae,H=e.r,y=e.M,D=e.af,L=e.E,k=e.D,O=e.L,A=e.ag,V=e.R,T=e.b},function(e){R=e.d,j=e.i,x=e.m},function(e){B=e.S,F=e.C,W=e.P,G=e.G,K=e.p,U=e.a,z=e.g,N=e.R},function(e){q=e.L,Z=e.B,X=e.b,Q=e.C,Y=e.d,J=e.e,$=e.T,ee=e.P,te=e.c},function(e){ne=e.S,ie=e.M},function(){}],execute:function(){class ae extends q{constructor(e,t){super(e,t),this._center=new THREE.Vector3(0,0,0),this._params={ambientLight:{color:"#ffffff"},hemiLight:{color:"#ffffff"},mainDirLight:{direction:{x:2,y:1,z:2},color:"#ffffff"}},this._ambientLight=new THREE.AmbientLight(new THREE.Color(this._params.ambientLight.color),.4),this._ambientLight.layers.set(1),this._mainDirLight=new THREE.DirectionalLight(new THREE.Color(this._params.mainDirLight.color),.5),this._mainDirLight.castShadow=!0,this._mainDirLight.shadow.camera.near=.5,this._mainDirLight.shadow.camera.far=100,this._mainDirLight.shadow.mapSize=new THREE.Vector2(1024,1024),this._mainDirLight.visible=!0,this.addToScene()}updateSunPosition(e,t){}addToScene(){this._scene.add(this._mainDirLight),this._scene.add(this._ambientLight),this._scene.add(this._mainDirLight.target)}removeFromScene(){this._scene.remove(this._mainDirLight),this._scene.remove(this._ambientLight),this._scene.remove(this._mainDirLight.target)}reload(){this.removeFromScene(),this.addToScene()}needsBounds(){return!0}updateBounds(e){this._center.copy(e.getCenter(new THREE.Vector3));const t=new THREE.Sphere;e.getBoundingSphere(t);const n=t.radius,i=new THREE.Vector3(this._params.mainDirLight.direction.x,this._params.mainDirLight.direction.y,this._params.mainDirLight.direction.z);i.normalize(),i.multiplyScalar(n),this._mainDirLight.position.copy(this._center),this._mainDirLight.position.add(i),this._mainDirLight.target.position.copy(this._center),this._mainDirLight.target.updateMatrixWorld(!0),this._mainDirLight.shadow.camera.top=n,this._mainDirLight.shadow.camera.bottom=-n,this._mainDirLight.shadow.camera.left=-n,this._mainDirLight.shadow.camera.right=n,this._mainDirLight.shadow.camera.near=.01,this._mainDirLight.shadow.camera.far=2*n,this._mainDirLight.shadow.camera.updateProjectionMatrix()}showGUI(){let e=n();if(e){if(this._ambientLight){let t=e.addFolder("Ambient Light");t.add(this._ambientLight,"visible"),t.add(this._ambientLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.ambientLight,"color").onChange(e=>this._ambientLight.color=new THREE.Color(e))}if(this._hemiLight){let t=e.addFolder("Hemi Light");t.add(this._hemiLight,"visible"),t.add(this._hemiLight,"intensity").min(0).max(5).step(.1),t.addColor(this._params.hemiLight,"color").onChange(e=>this._hemiLight.color=new THREE.Color(e))}if(this._mainDirLight){let t=e.addFolder("Main Directional Light");t.add(this._mainDirLight,"visible"),t.add(this._mainDirLight,"intensity").min(0).max(10).step(.1),t.add(this._mainDirLight,"castShadow"),t.addColor(this._params.mainDirLight,"color").onChange(e=>this._mainDirLight.color=new THREE.Color(e)),t.add(this._mainDirLight.position,"x").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"y").min(-10).max(50).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center)),t.add(this._mainDirLight.position,"z").min(-10).max(10).step(.1).onChange(()=>this._mainDirLight.lookAt(this._center))}}}}class se{constructor(e){const{planElementViewModel:t,resetCamera:n,state:i,oldState:a}=e;this.planElementViewModel=t,this.resetCamera=void 0===n||n,this.state=void 0===i?0:i,this.oldState=void 0===a?0:a}}class re extends B{constructor(e,t,n,i){super(e,t,n,i),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():this.resetState()},this),this._plannerSelectionHandler.addEventListener(0,({planElementViewModel:e})=>{this.dispatchEvent(0,new se({planElementViewModel:e}))},this),this._plannerSelectionHandler.addEventListener(1,({planElementViewModel:e})=>{1!==this._state&&this.setState(0),this.dispatchEvent(1,new se({planElementViewModel:e}))},this),this._inputManager.addEventListener(6,e=>this._move(e),this)}disable(){const e=new THREE.Layers;e.disableAll(),this._raycastHelper.setLayers(e),this._raycastHelper.disableEvents()}get planInteractionHandler(){var e;return null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler}enable(){const e=new THREE.Layers;e.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=R(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=R(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 THREE.PlaneBufferGeometry(1e3,1e3,8,8),t=new THREE.MeshBasicMaterial;t.visible=!1;const n=new THREE.Mesh(e,t);return n.name="2D raycaster floor mesh",n.rotation.set(-Math.PI/2,0,0),n.layers.enable(2),n.userData=R(n.userData,{hasListener:!0,priority:.9,roomleId:void 0}),n.addEventListener("double_click",e=>{this._doubleClickOnPlane(s(e.attachment.intersection.point),e.attachment.type)}),n.addEventListener("select",e=>{this._isCurrentlyDrawing?this._clickOnPlane(s(e.attachment.intersection.point)):this._plannerSelectionHandler.cancelSelection()}),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._setCursor()):this.resetState())}_doubleClickElement(e,t=0,n){if(!this._isDrawingEnabled||!(e instanceof r||e instanceof o))return;let i;this._debug&&e.getId(),e instanceof o&&this._plannerSelectionHandler.cancelSelection(),e instanceof r?i=e.getPlanElement().getCenter():n&&(i=s(new THREE.Vector3(n.x,0,n.z))),this._isCurrentlyDrawing?this._endWallDrawing(null,i):this._startWallDrawing(null,i,t)}_hoverOn(e){this._isCurrentlyDrawing||(e.hoverOn(),this._hoveredObject=e,this.dispatchEvent(3,new se({planElementViewModel:e})),this._interaction(),this._setCursor())}_hoverOff(e){e.hoverOff(),this.dispatchEvent(4,new se({planElementViewModel:e})),this._interaction(),this._hoveredObject=null,this._setCursor()}_setCursor(){2===this._state&&this._hasSelection()?j("ew-resize"):1===this._state?j("grabbing"):this._hoveredObject&&this._plannerSelectionHandler.isSelected(this._hoveredObject.getId())?j("move"):this._hoveredObject?j("pointer"):3===this._state?j(l?"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"):j("default")}setCamera(e){this._raycastHelper.setCamera(e)}setScene(e){this._raycastHelper.setScene(e)}getSelectedIds(){return this._plannerSelectionHandler.getSelectedIds()}setSelectionMode(e){this._plannerSelectionHandler.setSelectionMode(e)}setPlanViewModel(e){this._planViewModel=e}cancelSelection(){this._plannerSelectionHandler.cancelSelection()}_dragStart(e){((this._plannerSelectionHandler.isSelected(e.getId())||this._dragIn)&&0===this._state||this._isDrawingEnabled)&&(this._draggedObject=e,this.setState(1),this.dispatchEvent(8,new se({planElementViewModel:e})),this._setCursor())}_drag(e,t){if(!this._draggedObject||1!==this._state)return;const n=this.planInteractionHandler;if(this._plannerSelectionHandler.getSelectedIds().length>1){const e=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList;let i=t.sub(this._draggedObject.getPosition());this._plannerSelectionHandler.getSelectedIds().forEach(t=>e.push_back(this._planViewModel.getPlanObjectForId(t).getPlanElement())),n.moveObjectsBy(e,s(i))}else(e instanceof r||e instanceof o)&&(t.y=h(e.getPlanElement().getCenter()).y),n.moveElementTo(e.getPlanElement(),s(t));this.dispatchEvent(9,new se({planElementViewModel:e}))}_dragEnd(e,t){this._draggedObject&&(this._draggedObject=null,this.setState(0),this.dispatchEvent(10,new se({planElementViewModel:e})),this._dragIn&&this.setDragIn(!1),this._setCursor())}_rotate(e,t){if(this._plannerSelectionHandler.isSelected(e.getId())){const n=this.planInteractionHandler,i=e.getPlanObject();n.setObjectRotation(e.getPlanElement(),i.rotation-t)}}setState(e){var t,n;const i=this._state;this._state=e,this._setCursor(),this.dispatchEvent(2,new se({state:this._state,oldState:i})),this._position=null,2===this._state?null===(t=this.planInteractionHandler)||void 0===t||t.deactivateAllSnappingActivity():2===i&&(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:i}=e.positionRelative;this._position?t=1.4*e.positionRelative.x*Math.PI-1.4*this._position.x*Math.PI:this._position=new THREE.Vector3(e.positionRelative.x,e.positionRelative.y,0);const a=new this._plannerKernelAccess.kernelContainer.PlanObjectPtrList,r=new THREE.Box3;this.getSelectedIds().forEach(e=>{var t;const n=null===(t=this._planViewModel)||void 0===t?void 0:t.getPlanObjectForId(e);n&&n.getObject()&&(a.push_back(n.getPlanElement()),r.expandByObject(n.getContainer()))});const o=r.getCenter(new THREE.Vector3);this.planInteractionHandler.rotateObjectsBy(a,t,s(o)),this._position.copy(new THREE.Vector3(n,i,0))}}_hasSelection(){return this._plannerSelectionHandler.getSelectedIds().length>0}async selectPlanElement(e){(e instanceof c||e instanceof d)&&await e.isInitDone(),this._plannerSelectionHandler.check(e)}_interaction(e){this.dispatchEvent(11,new se({}))}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 THREE.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:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.endDrawing({x:n,y:i,z:0})}this.stopDrawing(!1)}}async _startWallDrawing(e,t,n){(e&&2===e.type||2===n)&&(await this._initMobileDrawing(),this._continousDrawingHelper.update());const{x:i,y:a}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.beginDrawing({x:i,y:a,z:0}),this.startDrawing()}async _initMobileDrawing(){if(this.planInteractionHandler.setDrawingType(0),this.planInteractionHandler.setSnapFeedbackWhileDrawing(!0),!this._continousDrawingHelper){const{default:e}=await t.import("./continuous-drawing-helper-69f0d4b9.nomodule.js");this._continousDrawingHelper=new e,this._continousDrawingHelper.init(this._drawingGroup,this.planInteractionHandler.getContinuousDrawingManager(),this._kernelZoomFactor)}}_drawWallOnMouseMove(e){var t;if(!this._isCurrentlyDrawing)return;const{x:n,y:i}=this._getIntersectionPointWithScene(e);this.planInteractionHandler.currentDrawingPosition({x:n,y:i,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:i}=t||this._getIntersectionPointWithScene(e);this.planInteractionHandler.forceNode({x:n,y:i,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)}}i([a],re.prototype,"_plannerSelectionHandler",void 0),i([a],re.prototype,"_plannerKernelAccess",void 0);const oe=(e,t,n,i)=>{const a=(new THREE.Box3).setFromObject(e.getContainer()).getCenter(new THREE.Vector3);return{runtimeId:e.getId(),position2d:_(g(a,t,n,i))}};class le extends F{constructor(e,t,n,i){super(e,t,i),this._staticItemGuard=new p,this._configurableItemGuard=new p,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 re(e,this._scene,this._cameraControl.getCamera(),this._getInputManager()),this._plannerSceneEventHandler.addEventListener(2,({state:e,oldState:t})=>{2===t&&e!==t&&this._roomlePlannerUiCallback.onRotationCancel(),2===e||1===e||3===e?(this._cameraControl.lock(),this._onCameraMove()):(this._cameraControl.unlock(),this._onCameraIdle())},this),this._plannerSceneEventHandler.addEventListener(11,()=>this._renderWithoutShadowsAndAO(),this),this._plannerSceneEventHandler.addEventListener(3,({planElementViewModel:e})=>this._onPlanElementHoverOn(e),this),this._plannerSceneEventHandler.addEventListener(4,({planElementViewModel:e})=>this._onPlanElementHoverOff(e),this),this._plannerSceneEventHandler.addEventListener(0,({planElementViewModel:e})=>{e instanceof d&&this._initData.debug&&e.getGLBUrl(),this._highlightPlanElement(e),this._onSelectionChange(e),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(1,({planElementViewModel:e})=>{this._highlightPlanElement(null),this._onSelectionCancel(e),this._roomlePlannerUiCallback.onSelectionCancel(),this._renderWithoutShadowsAndAO()},this),this._plannerSceneEventHandler.addEventListener(8,({planElementViewModel:e})=>{this._getKernelAccess().planInteractionHandler.startInteraction(),this._cameraControl.lock(),e instanceof o&&this._sendWallDimensions(),this._environment instanceof Z&&this._environment.removeFromScene(),this._requestRender(),this._dragStartBounds=this.getBounds()},this),this._plannerSceneEventHandler.addEventListener(9,({planElementViewModel:e})=>{this._cameraControl.checkNearFarDistance(e.getPosition()),this._requestRender()},this),this._plannerSceneEventHandler.addEventListener(10,({planElementViewModel:e})=>{const t=this._getKernelAccess().planInteractionHandler;t.endInteraction(),this._cameraControl.unlock(),this._environment instanceof Z&&this._environment.addToScene();const n=this._getDragPosition(e.getPosition());n&&t.moveElementTo(e.getPlanElement(),s(n)),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!1),this._renderEverything()},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 W(this._creator_)),this._viewModel}_onPlanElementHoverOn(e){this._highlightPlanElement(e)}_onPlanElementHoverOff(e){this._highlightPlanElement(null)}_getDragPosition(e){if(!this._plannerSceneEventHandler.isDragIn())return null;const t=this._dragStartBounds?this._dragStartBounds:this.getBounds(),n=t.getCenter(new THREE.Vector3),i=e.distanceTo(n),a=t.getSize(new THREE.Vector3),s=Math.max(a.x,a.z)+3;if(i>s){const t=(new THREE.Vector3).subVectors(e,n).normalize();return n.clone().add(t.multiplyScalar(s))}return null}_onSelectionChange(e){let t;const n={};if(e instanceof d&&(t="static",n.item=e.getRapiItem(),n.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof c){t="configuration";const i=e.getConfigurationRuntimeId();n.configurationRuntimeId=i}e instanceof o&&(t="wall",n.wall=e.getWallDimension());const i=(async()=>{const n={};if(e instanceof d&&(n.item=e.getRapiItem(),n.staticItemRuntimeId=e.getPlanElement().getId()),e instanceof c){await e.isInitDone();const i=e.getConfigurationRuntimeId(),a=e.getPlanObject().getCatalogItemId();let s,r=a;if(r||(r=this._getKernelAccess().kernelInstance.getHashOfConfiguration(i)),this._configuratorContext.planObjectId=i,this._configuratorContext.planElementId=e.getId(),this._configuratorContext.rootComponentId=e.getRootComponentRuntimeId(),a&&M(a)){const e=await this._rapiAccess.getItem(a);n.item=e,s=e.rootComponentId?e.rootComponentId:null}else try{const e=await this._rapiAccess.getConfiguration(r);n.configuration=e,s=e.rootComponentId?e.rootComponentId:null}catch(e){console.warn("Could not get RAPI configuration for kernel hash "+r+", saving configuration...");const t=await this._getKernelAccess().getConfigurationData(i),a=await this._rapiAccess.saveConfiguration(t);n.configuration=a,s=a.rootComponentId?a.rootComponentId:null}if(s){const e=await this._rapiAccess.getComponent(s);n.component=e}n.configurationRuntimeId=i,t="configuration"}return n.planElementId=e.getId(),x(n)})();this.currentSelection=x(n),this._roomlePlannerUiCallback.onSelectionChange(x(this._plannerSceneEventHandler.getSelectionMode()),x(t),x(n),i,e),(e instanceof o||e instanceof r)&&(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._lightSetting=new ae(this._scene,this._lightSetting),this._initData.moc?this._setEnvironment(new X(this._scene,this._environment,new THREE.Color(this._initData.colors.DEFAULT_BACKGROUND))):(this._addSky(),this._setEnvironment(new Z(this._scene,this._environment)))}onBeforeRender(){this._cameraControl instanceof Q&&(m(this._cameraControl.getCamera(),this._getViewModel().getWallPlanObjectViewModels()),this._renderEverything())}_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 Q&&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._cameraControl instanceof Q&&this._cameraControl.setObjectRotation(n.getPlanElement().rotation);const i=null==n?void 0:n.getConfigurationRuntimeId();this._configuratorContext.planObjectId!==i&&(this._configuratorContext.planObjectId=i),this._getViewModel().hideAllExcept(t),this.resetCamera(),this.disablePlannerEvents(),this.enableConfiguratorEvents(),this.updateScene(),this._getKernelAccess().updatePlanObjectDependencies(i),this._getKernelAccess().requestPartListAndUpdatePricesOfParts(),this._getKernelAccess().planObjectUpdated(i),this.updateEnvironment(this.getBounds(),!0);const a=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==a||a.startInteraction()}async selectPlanObject(e){if(this._plannerSceneEventHandler.getSelectedIds().includes(e))return;const t=this._getViewModel().getPlanObjectForId(e);await this._plannerSceneEventHandler.selectPlanElement(t)}backToPlanner(){var e;if(this._getViewModel().showAll(),"configurator"===this._configuratorContext.baseContext){const t=null===(e=this._plannerKernelAccess)||void 0===e?void 0:e.planInteractionHandler;null==t||t.endInteraction()}this._configuratorContext.baseContext="planner",this._cameraControl instanceof Q&&this._cameraControl.setObjectRotation(0),this.resetCamera(),this.enablePlannerEvents(),this.disableConfiguratorEvents(),this.updateScene()}resetCamera(){this._cameraControl.hasSavedState()?this.resetCameraToState():this.resetCameraPositionToStart()}resetCameraToState(){this._cameraControl.resetToState()}_getYRotationOfObject(e){let t=e.getWorldDirection(new THREE.Vector3).clone();t.y=0,t.lengthSq()<.01&&(t=new THREE.Vector3(0,1,0),t.applyQuaternion(e.quaternion),t.y=0),t.normalize();let n=Math.asin(t.x);return t.z<0&&(n=Math.PI-n),n<0&&(n+=2*Math.PI),n}loadStaticPlanObjects(){let e=new Map;this._getViewModel().getStaticPlanObjectViewModels().forEach(t=>{let n=t.getPlanObject();e.has(n.getCatalogItemId())?e.get(n.getCatalogItemId()).push(t):e.set(n.getCatalogItemId(),[t])}),this._rapiAccess.getItems(Array.from(e.keys())).then(t=>{let n=[];t.forEach(t=>{this._getKernelAccess().catalogItemLoaded(t),e.get(t.id).forEach(e=>{n.push(new Promise((n,i)=>{e.setRapiItem(t).then(()=>{this._requestRender(),n()},i)}))})}),Promise.all(n).then(()=>this._staticItemsLoaded())})}_staticItemsLoaded(){this._requestRender(),this._staticItemGuard.resolve(),this._roomlePlannerUiCallback.onItemsLoaded()}preload(e){this._planId=e;let t=this._localStorageHelper.getItem(this._planId,"rml_plans");t&&this._loadGLTF(t).then(e=>{this._preloadScene=e,this._preloadScene&&this._scene.add(this._preloadScene),this._requestRender()})}planXMLLoaded(e){this.endPlanConstruction(e);const t=e.getBounds(),n=u(t);this._updateBounds(n),this.loadStaticPlanObjects()}planCompletelyLoaded(e){this._stopRendering=!1,this._renderEverything(),this.resetCamera()}handlerSwitchedPlans(e,t){if(this._getViewModel().setReference(t),this._getKernelAccess().coupleReferences(this._getViewModel(),t),this._getViewModel().setPlannerSceneEventHandler(this._plannerSceneEventHandler),this._getViewModel().setGeometriesMergedListener(()=>{this._renderEverything()}),this._plannerSceneEventHandler.setPlanViewModel(this._getViewModel()),e&&this.clearScene(),!this._initData.moc){this._addSky();let e=new THREE.PlaneGeometry(1e3,1e3);e.rotateX(-Math.PI/2);let t=new THREE.MeshStandardMaterial({color:"#f0f0f0",roughness:1,metalness:0}),n=new THREE.Mesh(e,t);n.name="Ground",n.position.y=-.01,n.receiveShadow=!0,this._scene.add(n)}this.resetCamera(),this._setCeiling(),this._staticItemGuard.reset(),this._configurableItemGuard.reset(),Promise.all([this._staticItemGuard.wait(),this._configurableItemGuard.wait()]).then(this._itemsLoaded.bind(this))}_itemsLoaded(){const e=this._getViewModel().getCorePlan();if(this._pixotron){const t=u(e.getBounds());this._pixotron.getShadowPass().setShadowRecieverBBox(t)}this._roomlePlannerUiCallback.onCompletelyLoaded(),this._pixotronUtil&&this._getViewModel().materialQueue.finished(!0).then(()=>{this._pixotronUtil.unLockAdapter()}),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),w.end("loadingTime")}beginPlanConstruction(e){}addPlanMesh(e,t,n,i,a,s,r){}endPlanConstruction(e){this._renderLoopFunction=()=>{this._scene.add(this._getViewModel().getConstructionGroup()),this._scene.add(this._getViewModel().getCeilingGroup()),this._scene.add(this._getViewModel().getFloorGroup()),this._lightSetting.needsBounds()&&this._lightSetting.updateBounds(this._getViewModel().getBoundingBox()),this._scene.remove(this._preloadScene)}}addPlanObjectToScene(e){if(e){const t=e.getContainer();E(t),this._scene.add(t),this._plannerSceneEventHandler.isDragIn()&&(this._plannerSceneEventHandler.addComponentDragInHandler(e),this._requestRender()),this._roomlePlannerUiCallback.onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(C.ADDED),e.isInitDone().then(()=>{this._zoomToBounds(!1,!1),this.updateEnvironment(this.getBounds()),this._renderEverything()})}}removePlanObjectFromScene(e){(e instanceof o||e instanceof r)&&this._sendWallDimensions(),this._scene.remove(e.getContainer()),e.clear(),this.updateEnvironment(this.getBounds(),!0),this._zoomToBounds(!0),this._renderEverything(),this._roomlePlannerUiCallback.onPlanElementChanged(C.REMOVED)}planElementChanged(e,t){this._drawingEnabled&&this._sendWallDimensions(!1),this.updateEnvironment(this.getBounds(),!0),this._renderEverything(),this._onPlanChanged(),this._roomlePlannerUiCallback.onPlanElementChanged(C.CHANGED)}exportGLB(e,t){this._scriptLoader.fetch(G,{id:"gltf-exporter"}).then(()=>{let n=new THREE.GLTFExporter;e||(e=[],this._scene.children.forEach(t=>{this._isPartOfScene(t)&&e.push(t)})),n.parse(e,e=>{let n=t||"test";this._localStorageHelper.addItem(n,JSON.stringify(e),"rml_plans")},{binary:!1,embedImages:!0,forceIndices:!0})})}importGLB(e){this._loadGLB(e).then(e=>this._scene.add(e))}clearScene(){this._plannerMeshGenerator.clear(),this._getViewModel().sceneCleared(),super.clearScene()}_addSky(){this._sky=new THREE.Sky,this._sky.name="Sky",this._sky.scale.setScalar(45e4),this._scene.add(this._sky),this._sky.material.uniforms.turbidity.value=10,this._sky.material.uniforms.rayleigh.value=2,this._sky.material.uniforms.luminance.value=1,this._sky.material.uniforms.mieCoefficient.value=.005,this._sky.material.uniforms.mieDirectionalG.value=.8;let e=new THREE.Mesh(new THREE.SphereBufferGeometry(2e4,16,8),new THREE.MeshBasicMaterial({color:16777215}));e.name="Sunsphere",e.position.y=-7e5,e.visible=!1,this._scene.add(e);let t=-.2*Math.PI,n=2*Math.PI*-.25;e.position.x=4e5*Math.cos(n),e.position.y=4e5*Math.sin(n)*Math.sin(t),e.position.z=4e5*Math.sin(n)*Math.cos(t),e.visible=!0,this._sky.material.uniforms.sunPosition.value.copy(e.position),this._lightSetting instanceof ae&&this._lightSetting.updateSunPosition(.3,.25)}switchTo2D(){if(this._onCameraMove(),!(this._cameraControl instanceof Y)){for(const e of this._getViewModel().getWallPlanObjectViewModels())e.show();this._getViewModel().setCameraType(v.CAMERA_2D),this._renderEverything(),this._changeCameraControl(new Y(this._creator_,this._getInputManager(),null,this.getOrthographicOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(v.CAMERA_2D),this._setCameraControlListeners(),this._setKernelZoomFactor(),this._onCameraMove()}}switchTo3D(){this._onCameraMove(),this._cameraControl instanceof Q||(this._getViewModel().setCameraType(v.CAMERA_3D),this._renderEverything(),this._changeCameraControl(new Q(this._creator_,this._getInputManager(),new THREE.Vector3(0,10,0),this.getPerspectiveOffsetCamera())),this._updateCamera(),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(v.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;const t=this._cameraControl.getKernelZoomFactor();this._getKernelAccess().planInteractionHandler.setZoomFactor(t),null===(e=this._plannerSceneEventHandler)||void 0===e||e.setKernelZoomFactor(t)}_setCeiling(){this._getViewModel()&&(this._cameraControl instanceof J?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 Q&&this._cameraControl.resetToState()}switchToFirstPerson(){if(this._cameraControl instanceof J)return;this._plannerMeshGenerator.wallMeshes.forEach(e=>f(e.material,!1,!1)),this._getViewModel().setCameraType(v.CAMERA_FP),this._renderEverything();let e=new THREE.Vector3(0,0,0);this._getViewModel()&&(e=this._getViewModel().getBoundingBox().getCenter(new THREE.Vector3)),this._cameraControl&&this._cameraControl.cleanUp(),this._changeCameraControl(new J(this._creator_,this._getInputManager(),e,this.getPerspectiveOffsetCamera())),this._addCameraControlListener(),this._setCeiling(),this._roomlePlannerUiCallback.onCameraChanged(v.CAMERA_FP),this._setCameraControlListeners()}_onKeyDown(e){super._onKeyDown(e),this._initData.debug&&this._checkNumKey(e),e.key&&e.key.includes("Shift")&&this._cameraControl instanceof Q&&(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 Q&&(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 v.CAMERA_2D:this.switchTo2D();break;case v.CAMERA_3D:this.switchTo3D();break;case v.CAMERA_FP:this.switchToFirstPerson()}}_highlightPlanElement(e){let t=new Set;e&&e.getObject()&&e.getObject().children&&e.getObject().children.forEach(e=>t.add(e)),this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const n=this._getViewModel().getPlanObjectForId(e);n&&n.getObject()&&n.getObject().children&&n.getObject().children.forEach(e=>t.add(e))}),this._pixotron&&this._pixotron.highlightObjects(Array.from(t))}destroy(){super.destroy(),this._plannerMeshGenerator.removeMaterialLoadedListener(),this._getViewModel().removeGeometriesMergedListener()}getPixotronParams(){return{saoparams:{intensity:.5,occlusionWorldRadius:.6,smoothTransition:!0,samplesPerFrame:4,bias:.02,numSamples:100,accumulative:!1,falloff:2},shadowparams:{shadowMapResolution:1024,shadowRadius:3,shadowQuality:1,smoothTransition:!0,enableAccumulation:!0,shadowBiasMultiplier:.6,nearPlane:.01,farPlane:50,fov:110,side:THREE.FrontSide,numSamples:100},outlineparams:{highlightColor:new THREE.Color(this._initData.colors.SELECTION),edgeStrength:1,transparency:.9,edgeThickness:2}}}getBakedShadowParams(){return{enable:!0,shadowMapResolution:1024,smoothTransition:!0,numSamples:500,numSamplesPerFrame:4,bShadowMaterial:!0,falloff:1.8,darkness:.3,size:1.2,lightDirection:new THREE.Vector3(0,1,0),lightSolidAngle:40,yPosition:.006}}planObjectConfigurationLoaded(e,t,n){if(e&&e.extRef&&t&&t.extRef){let e=t.extRef.jsObject.getPlanObject().getConfigurationRuntimeId();e>0&&this._getViewModel().constructComponents(e)}}addMesh(e,t,n,i,a,s){}_updateBounds(e){e&&("planner"===this._configuratorContext.baseContext&&this._updateCamera(e),super._updateBounds(e))}_updateCamera(e){e||(e=this.getBounds()),e&&(this._cameraControl instanceof Q&&(e.expandByScalar(1.2),this._cameraControl.updateToBounds(e,!1)),this._cameraControl instanceof Y&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(b(e,this._domHelper.element.clientWidth,this._domHelper.element.clientHeight),!0))}_zoomToBounds(e,t=!0){const n=this.getBounds();this._cameraControl instanceof Q&&(this._getViewModel().getPlanObjectCount()<=1?this._cameraControl.zoomToFitBounds(n,t):this._cameraControl.checkBoundsAndPlaceCamera(n,t)),this._cameraControl instanceof Y&&!this._drawingEnabled&&this._cameraControl.zoomToFitBounds(n,e,t)}updateCameraOnDrawWalls(){const e=this.getBounds();this._cameraControl instanceof Y&&this._cameraControl.zoomToFitBounds(e,!1,!0)}getBounds(){return this._getViewModel()?this._getViewModel().getBoundingBox():null}cancelPlanElementSelection(){this._plannerSceneEventHandler.cancelSelection(),this._highlightPlanElement(null),this._requestRender()}deletePlanElementSelection(){const e=this._plannerSceneEventHandler.getSelectedIds();this.cancelPlanElementSelection(),e.forEach(e=>{const t=this._getViewModel().getPlanObjectForId(e);t&&t.getObject()&&this._getKernelAccess().planInteractionHandler.removeElement(t.getKernelObject())})}rotatePlanElementSelection(e){const t=new(this._getKernelAccess().kernelContainer.PlanObjectPtrList),n=new THREE.Box3;this._plannerSceneEventHandler.getSelectedIds().forEach(e=>{const i=this._getViewModel().getPlanObjectForId(e);i&&i.getObject()&&(t.push_back(i.getPlanElement()),n.expandByObject(i.getContainer()))});const i=n.getCenter(new THREE.Vector3),a=this._getKernelAccess().planInteractionHandler.groupObjects(t);this._getKernelAccess().planInteractionHandler.rotateGroupBy(a,e,s(i))}planBoundsChanged(){this.updateEnvironment(this.getBounds()),this._requestRender()}planElementRemoved(e){this._onPlanChanged(),this._renderEverything()}_onPlanChanged(){this._roomlePlannerUiCallback.onPlanChanged()}prepareTopImage(e={}){return new Promise(t=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n=this._calculateBoundingBoxOfAllMeshes(.1);this._lightSetting.removeFromScene();let i=await K(this._scene,null,n,e);this._lightSetting.addToScene(),this._requestRender(),t(i)})})}preparePerspectiveImage(e={}){return"configurator"===this._configuratorContext.baseContext?super.preparePerspectiveImage(e):new Promise((t,n)=>{this._getViewModel().materialQueue.finished(!0).then(async()=>{let n;n=this._cameraControl instanceof Q?this._cameraControl.getCamera().clone():this.getPerspectiveOffsetCamera();let i=this._calculateBoundingBoxOfAllMeshes();this._lightSetting.removeFromScene();const a=await U(this._scene,null,n,i,e);this._lightSetting.addToScene(),this._requestRender(),t(a)},n)})}_calculateBoundingBoxOfAllMeshes(e=0){const t=this.getBounds();return z(t,e)}enableRotation(){this._plannerSceneEventHandler.setState(2)}disableRotation(){this._plannerSceneEventHandler.resetState()}enableSnapping(){this._plannerSceneEventHandler.enableSnapping()}disableSnapping(){this._plannerSceneEventHandler.disableSnapping()}dragIn(e){this._plannerSceneEventHandler.setDragIn(!0,e)}getPlannerSceneEventHandler(){return this._plannerSceneEventHandler}disablePlannerEvents(){this._plannerSceneEventHandler.disable()}enablePlannerEvents(){this._plannerSceneEventHandler.enable()}_onCameraIdle(){return super._onCameraIdle()&&(this._sendWallDimensions(),this._sendPlanObjectPositions()),!0}_onCameraMove(){return super._onCameraMove()&&(this._roomlePlannerUiCallback.disableWallDimensions(),this._roomlePlannerUiCallback.cameraStartsMoving()),this._updateNodeSize(),!0}_updateNodeSize(){if(this._cameraControl instanceof Y){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(),i=[],a=this._getViewModel().getStaticPlanObjectViewModels();for(const s of a)i.push(oe(s,n,e,t));const s=this._getViewModel().getConfigurablePlanObjectViewModels();for(const a of s)i.push(oe(a,n,e,t));this._roomlePlannerUiCallback.onUpdatePlanObjectPositions(i)}_sendWallDimensions(e=!0){if(this._cameraControl.isLocked()&&e)return;const t=[],{clientWidth:n,clientHeight:i}=this._domHelper.element,a=this._getViewModel().getWallPlanObjectViewModels();for(const e of a){const a=e.getWallDimension();if(a.length>0&&(a.fromPosition2d=g(a.fromPosition3d,this._cameraControl.getCamera(),n,i),a.toPosition2d=g(a.toPosition3d,this._cameraControl.getCamera(),n,i),a.textPosition2d=g(a.textPosition3d,this._cameraControl.getCamera(),n,i),a.lengthFormatted=this._unitFormatter.formatMMValueToUnitString(a.length),t.push(S(a))),this._initData.debug){const e=new THREE.SphereGeometry(.1,32,16),t=new THREE.MeshBasicMaterial({color:16711680}),n=new THREE.Mesh(e,t);n.position.copy(a.fromPosition3d);const i=new THREE.Mesh(e,t);i.position.copy(a.toPosition3d);const s=new THREE.Mesh(e,new THREE.MeshBasicMaterial({color:65280}));s.position.copy(a.textPosition3d),this._scene.add(n),this._scene.add(i),this._scene.add(s)}}this._roomlePlannerUiCallback.onUpdateWallDimensions(t)}enableWallDrawing(){if(this._cameraControl instanceof Y){const e=b(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()}}i([a],le.prototype,"_rapiAccess",void 0),i([a],le.prototype,"_plannerMeshGenerator",void 0),i([a],le.prototype,"_plannerInputManager",void 0),i([a],le.prototype,"_roomlePlannerUiCallback",void 0),i([a],le.prototype,"_localStorageHelper",void 0),i([a],le.prototype,"_unitFormatter",void 0);const he={left:0,top:1,right:1,bottom:0};class ce{constructor(e){this._hscInstance=null,this._glbInstance=null,this._configurator=null,this._currentMode=1,this._creator_=e,this._kernelAccessCallback.addListener(this)}deleteSelection(){this._sceneManager.deletePlanElementSelection()}rotateSelection(e){this._sceneManager.rotatePlanElementSelection(e)}cancelSelection(){this._sceneManager.cancelPlanElementSelection()}init(e,t,n){return w.start("loadingTime"),this._domHelper.setDomElement(e),this._sceneManager?(this._lifeCycleManager.resume(),Promise.resolve()):(this._preloadPlanId=t,this.setOverrides(n),new Promise(this._initPromiseCallback.bind(this)))}loadPlanXml(e,t){return this.setOverrides(t),new Promise(n=>{this._plan=this._planInteractionHandler.loadPlanXML(e),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&(t.id?this._rapiAccess.trackView(t.id):this._rapiAccess.trackView("planXML")),n()})}loadPlan(e,t){return this.setOverrides(t),new Promise((t,n)=>{this._rapiAccess.getPlan(e).then(n=>{this._plan=this._planInteractionHandler.loadPlanXML(n.planObjects),this._sceneManager.planXMLLoaded(this._plan),this._roomlePlannerUiCallback.onTotalFloorAreaChanged(this._planInteractionHandler.getPlan().getTotalFloorArea()),this._currentMode=1,this._initData.moc&&this._rapiAccess.trackView(e),t()},n)})}setOverrides(e){e&&(this._initData.setOverrides(e),this._globalInitData.setOverrides(e))}switch2D(){this._sceneManager.switchTo2D()}switch3D(){this._sceneManager.switchTo3D()}switchToFirstPerson(){this._sceneManager.switchToFirstPerson()}exportGLB(){this._sceneManager.exportGLB()}importGLB(e){this._sceneManager.importGLB(e)}_initPromiseCallback(e,t){this._threeLoader.fetch().then(()=>{let t=this._scriptLoader.fetch(P,{id:"gltf-loader"}),n=this._scriptLoader.fetch(I,{id:"draco-loader"}),i=this._scriptLoader.fetch($,{id:"tween-js"}),a=this._scriptLoader.fetch("static/Sky-6621935ea8a523af.js",{id:"sky-js"});Promise.all([t,n,i,a]).then(()=>{this._kernelReadyCallback=e;const{dls:t,ls:n,mode:i,stats:a}=this._initData;this._sceneManager||(this._sceneManager=new le(this._creator_,he,this,i)),this._preloadPlanId&&this._sceneManager.preload(this._preloadPlanId);const s=H.createDynamicLightSettingSource(t,n);a&&this.showStats(),this.enableHD(s),this._planInteractionHandler&&this._kernelReadyCallback()})})}enableHD(e){return new Promise((t,n)=>{const i=()=>{this._sceneManager.enableHD(e),t()};this._threeLoader.fetch().then(()=>Promise.all(ee.map(e=>this._scriptLoader.fetch(e,{id:e})))).then(()=>{this._scriptLoader.fetch(te,{id:"pi-js"}).then(i,n)},n)})}isReady(){this._planInteractionHandler=this._plannerKernelAccess.planInteractionHandler,this._kernelReadyCallback&&this._kernelReadyCallback()}showBenchmarks(){w.showBenchmarks()}getConfiguratorApi(){return this._configurator||(this._configurator=new N(this._creator_),this._configurator.setOverrides(this._initData),this._configurator.initSceneManager(this._sceneManager)),this._configurator}startViewing(){this._sceneManager.startViewing()}startConfiguring(){var e,t;this._sceneManager.startConfiguring();const n=this._sceneManager.currentSelection,i=(null===(e=n.item)||void 0===e?void 0:e.id)||(null===(t=n.configuration)||void 0===t?void 0:t.id);i&&this._configurator.notifyUiAboutNewLabel(i)}async selectPlanObjectById(e){return this._sceneManager.selectPlanObject(e)}backToPlanner(){this._sceneManager.backToPlanner()}async switchToConfigurator(){const e=await this._singlePromiseFactory.create(3,"startHSC",e=>{if(this._hscInstance)return e(this._hscInstance);t.import("./configurator-d94eb4a1.nomodule.js").then(({Configurator:t})=>{const n=new t(this._creator_);n.boot({kernelInstance:this._planInteractionHandler.getConfiguratorKernel(),kernelContainer:this._plannerKernelAccess.kernelContainer}),n.getApi().setOverrides(this._initData),n.getApi().initSceneManager(this._sceneManager),n.getApi().init(this._domHelper.element).then(()=>{this._hscInstance=n,e(this._hscInstance)})})});return this._currentMode=0,this.cancelSelection(),e}async switchToViewer(){const e=await this._singlePromiseFactory.create(4,"startGLB",e=>{if(this._glbInstance)return e(this._glbInstance);t.import("./glb-viewer-d1b213e5.nomodule.js").then(t=>{const n=new t.GlbViewer(this._creator_);n.boot(),n.getApi().setOverrides(this._initData),n.getApi().init(this._domHelper.element).then(()=>{this._glbInstance=n,e(this._glbInstance)})})});return this._currentMode=2,this.cancelSelection(),e}switchToPlanner(e){e&&this.loadPlan(e),this._currentMode=1}updateSize(){this._sceneManager.updateCamera()}getMain(){}update(){this.updateSize(),this._glbInstance&&this._glbInstance.getApi().updateSize(),this._hscInstance&&this._hscInstance.getApi().updateSize()}get callbacks(){return this._roomlePlannerUiCallback}set callbacks(e){this._roomlePlannerUiCallback=e}showStats(){this._sceneManager.showStats()}onCloseHSC(){this._sceneManager.closeHSC(),this._hscInstance&&this._hscInstance.getApi().pauseKernelCallbacks()}back(){if(2===this._currentMode&&this._glbInstance&&this._glbInstance.getApi().clearScene(),0===this._currentMode&&this._hscInstance){const e=this._hscInstance.getApi();e.cancelSelection(),e.cancelDockings(),e.hideDimensions(),e.disableMultiselect(),this._sceneManager.updateScene()}this._currentMode=1}backTo(e){console.error("backTo in planner Needs to be implemented later")}getConfigurator(){return this._hscInstance}getCurrentSkin(){return this._rapiAccess.getCurrentSkin()}getRuntimeComponentIdOfRootComponent(e){return e?this._plannerKernelAccess.planInteractionHandler?this._plannerKernelAccess.planInteractionHandler.getConfiguratorKernel().getRootPlanComponentIdFromObjectId(e):(console.warn("Can not retrieve runtime id without planInteractionHandler"),0):(console.warn("Can not retrieve runtime id without planObjectId"),0)}resumeTest(e){this._domHelper.setDomElement(e),this._lifeCycleManager.resume()}pauseTest(){this._lifeCycleManager.pause()}syncCatalog(e){return this._dataSyncer.syncCatalog(e)}loadError(e){}getPlanInteractionHandler(){return Promise.resolve(this._planInteractionHandler)}getPlanModelViewHelper(){return Promise.resolve(this._plannerKernelAccess.planModelViewHelper)}async insertObject(e,t,n){if(!this._planInteractionHandler)throw new Error("no plan interaction handler");t&&(t=s(new THREE.Vector3(t.x,t.y,t.z)));const i=await(M(e)?this._rapiAccess.getItem(e):this._rapiAccess.getConfiguration(e)),a=await this._plannerKernelAccess.addPlanObjectFromItem(i,t,n);return this._sceneManager.updateScene(),a}async insertItemList(e){const t=e.map(e=>M(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)}getScene(){return this._sceneManager.getScene()}updateScene(){this._sceneManager.updateScene()}getCameraOffset(){return this._sceneManager.getCameraOffset()}setCameraOffset(e){this._sceneManager.setCameraOffset(e)}async getObjects(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);let t=[];const n=[],i=[],a=y(e.objects);await Promise.all(a.map(async e=>{const a=y(e);if(a.catalogItemId?n.push(a.catalogItemId):a.configurationHash&&i.push(a.configurationHash),a.parts){const e=a.configurationHash||a.catalogItemId,t=await this._plannerKernelAccess.addUiDataAndPriceToPartList(a.parts,e);a.parts=t}a.data=null,t.push(a)}));const[s,r]=await Promise.all([this._rapiAccess.getItems(n),this._rapiAccess.getConfigurations(i)]),o=[],l=new Map;for(const e of s)l.set(e.id,e);for(const e of r)l.set(e.id,e),o.push(e.rootComponentId);const h=await this._rapiAccess.getComponents(o),c=new Map;for(const e of h)c.set(e.id,e);for(const e of t){const t=e.catalogItemId||e.configurationHash,n=l.get(t)||null;if(n&&!n.label&&c.has(n.rootComponentId)){const e=c.get(n.rootComponentId);n.label=e.label}n&&!n.label&&(n.label=t),e.data=n}return t}async getPlanOverview(){const e=(await this.getPlanModelViewHelper()).getPlanOverview(this._plan);return y(e)}prepareTopImage(e={}){return this._sceneManager.prepareTopImage(e)}preparePerspectiveImage(e={}){return this._sceneManager.preparePerspectiveImage(e)}enableRotation(){this._sceneManager.enableRotation()}disableRotation(){this._sceneManager.disableRotation()}async dragInObject(e,t){this._sceneManager.dragIn(t);const n=await this._rapiAccess.getItem(e),i=await this.insertItems([n]);if(1!==i.length)throw new Error("More than one object added, abort");return i[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,i;const a=this._planInteractionHandler;a.startInteraction();const s=[];for(const t of e){const e=a.addNode(t.from),r=a.addNode(t.to),o=a.addWall(e,r);void 0!==(null===(n=t.props)||void 0===n?void 0:n.height)&&a.setWallHeight(o,t.props.height),void 0!==(null===(i=t.props)||void 0===i?void 0:i.thickness)&&a.setWallThickness(o,t.props.thickness),s.push(o)}return t.keepInteractionOpen||a.endInteraction(),this._sceneManager.updateCameraOnDrawWalls(),this._sceneManager.updateScene(),s}removeElements(e,t={}){const n=this._planInteractionHandler;n.startInteraction();for(const t of e)this._planInteractionHandler.removeElement(t);t.keepInteractionOpen||n.endInteraction()}hasWalls(){const e=this._planInteractionHandler,t=null==e?void 0:e.getPlan();return!(!t||t.getWallCount()<1)}enableWallDrawing(){this._sceneManager.enableWallDrawing()}disableWallDrawing(){this._sceneManager.disableWallDrawing()}getUnitFormatter(){return this._unitFormatter}get PlannerCoreTypes(){return this._plannerKernelAccess.kernelContainer}setSceneEvents(e){this._sceneManager.setSceneEvents(e)}}i([a],ce.prototype,"_domHelper",void 0),i([a],ce.prototype,"_scriptLoader",void 0),i([a],ce.prototype,"_kernelAccessCallback",void 0),i([a],ce.prototype,"_plannerKernelAccess",void 0),i([a],ce.prototype,"_rapiAccess",void 0),i([a],ce.prototype,"_singlePromiseFactory",void 0),i([a],ce.prototype,"_roomlePlannerUiCallback",void 0),i([a],ce.prototype,"_lifeCycleManager",void 0),i([a],ce.prototype,"_threeLoader",void 0),i([a],ce.prototype,"_dataSyncer",void 0),i([a],ce.prototype,"_initData",void 0),i([a],ce.prototype,"_globalInitData",void 0),i([a],ce.prototype,"_unitFormatter",void 0);class de{constructor(e){const{planElementViewModel:t}=e;this.planElementViewModel=t}}const _e=[new k("script-loader",ne),new k("planner-input-manager",class extends D{_canDrag(e){return!0}},1),new k("logger",O),new k("planner-mesh-generator",A),new k("rapi-access",V),new k("planner-selection-handler",class extends L{constructor(){super(...arguments),this._selectionMode="standard",this._selectedPlanElementViewModels=new Map}check(e){"standard"===this._selectionMode&&this._checkStandard(e),"multiselect"===this._selectionMode&&this._checkMulti(e)}cancelSelection(){0!==this._selectedPlanElementViewModels.size&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new de({planElementViewModel:e}))})}_checkStandard(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new de({planElementViewModel:e}));this._selectedPlanElementViewModels.size>0&&this._selectedPlanElementViewModels.forEach((e,t)=>{this._selectedPlanElementViewModels.delete(t),e.deselect(),this.dispatchEvent(1,new de({planElementViewModel:e}))}),this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new de({planElementViewModel:e}))}_checkMulti(e){if(this._selectedPlanElementViewModels.has(e.getId()))return this._selectedPlanElementViewModels.delete(e.getId()),e.deselect(),void this.dispatchEvent(1,new de({planElementViewModel:e}));this._selectedPlanElementViewModels.set(e.getId(),e),e.select(),this.dispatchEvent(0,new de({planElementViewModel:e}))}setSelectionMode(e){this._selectionMode=e}getSelectionMode(){return this._selectionMode}hasSelection(){return this._selectedPlanElementViewModels.size>0}getSelectedIds(){let e=[];return this._selectedPlanElementViewModels.forEach(t=>e.push(t.getId())),e}isSelected(e){return!!this._selectedPlanElementViewModels.get(e)}})];e("Planner",class extends ie{setupGlobals(){}setupDependencies(){T.setup(_e),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 ce(this._context),this._planner.getMain=()=>this,window.RoomlePlanner||(window.RoomlePlanner=this._planner)}getApi(){return this._planner}getContextName(){return"planner"}})}}}));
|
|
2
|
+
//# sourceMappingURL=planner-3459a34c.nomodule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-
|
|
1
|
+
{"version":3,"file":"planner-3459a34c.nomodule.js","sources":["../../node_modules/three/examples/js/objects/Sky.js"],"sourcesContent":["export default \"static/Sky-6621935ea8a523af.js\""],"names":[],"mappings":"y11CAAe"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./query-params-helper-a271f9dc.js";import"./roomle-dependency-injection-a073b368.js";import"./main-thread-to-worker-811523e8.js";import"./roomle-configurator-c59e6b77.js";import{Planner}from"./planner-157713ae.js";import"./pixotron-b1119eb8.js";import"./script-loader-6849d83c.js";import"./default-light-setting-0df3182d.js";(new Planner).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let o=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-o))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)});
|
|
2
|
+
//# sourceMappingURL=planner-main-918272bb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planner-main-918272bb.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-
|
|
1
|
+
System.register(["./query-params-helper-c231e1b8.nomodule.js","./roomle-dependency-injection-58fb9079.nomodule.js","./main-thread-to-worker-1c4e6a69.nomodule.js","./roomle-configurator-e3f2962f.nomodule.js","./planner-3459a34c.nomodule.js","./pixotron-48835ed9.nomodule.js","./script-loader-3d2ea0f9.nomodule.js","./default-light-setting-16ddc3a6.nomodule.js"],(function(){var e;return{setters:[function(){},function(){},function(){},function(){},function(n){e=n.Planner},function(){},function(){},function(){}],execute:function(){(new e).boot(),window.requestIdleCallback||(window.requestIdleCallback=e=>setTimeout(()=>{let n=Date.now();e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-n))})},1)),window.cancelIdleCallback||(window.cancelIdleCallback=window.cancelIdleCallback||function(e){clearTimeout(e)})}}}));
|
|
2
2
|
//# sourceMappingURL=planner-main.nomodule.js.map
|