architwin 1.0.9
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/README.md +530 -0
- package/bundle/LICENSE.md +17 -0
- package/bundle/css/core.css +21 -0
- package/bundle/css/late.css +22 -0
- package/bundle/css/showcase.css +406 -0
- package/bundle/css/unsupported_browser.css +1 -0
- package/bundle/cursors/grab.png +0 -0
- package/bundle/cursors/grabbing.png +0 -0
- package/bundle/cursors/rbe-default.png +0 -0
- package/bundle/cursors/rbe-finish-room.png +0 -0
- package/bundle/cursors/rbe-moving.png +0 -0
- package/bundle/cursors/rbe-place-door.png +0 -0
- package/bundle/cursors/rbe-place-node.png +0 -0
- package/bundle/cursors/rbe-place-opening.png +0 -0
- package/bundle/cursors/zoom-in.png +0 -0
- package/bundle/cursors/zoom-out.png +0 -0
- package/bundle/fonts/ibm-plex-sans-100.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-100.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-100italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-100italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-200.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-200.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-200italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-200italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-300.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-300.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-300italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-300italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-500.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-500.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-500italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-500italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-600.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-600.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-600italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-600italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-700.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-700.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-700italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-700italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-regular.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-regular.woff2 +0 -0
- package/bundle/fonts/mp-font.svg +2079 -0
- package/bundle/fonts/mp-font.woff +0 -0
- package/bundle/fonts/mp-font.woff2 +0 -0
- package/bundle/fonts/roboto-100.woff +0 -0
- package/bundle/fonts/roboto-100.woff2 +0 -0
- package/bundle/fonts/roboto-100italic.woff +0 -0
- package/bundle/fonts/roboto-100italic.woff2 +0 -0
- package/bundle/fonts/roboto-300.woff +0 -0
- package/bundle/fonts/roboto-300.woff2 +0 -0
- package/bundle/fonts/roboto-300italic.woff +0 -0
- package/bundle/fonts/roboto-300italic.woff2 +0 -0
- package/bundle/fonts/roboto-500.woff +0 -0
- package/bundle/fonts/roboto-500.woff2 +0 -0
- package/bundle/fonts/roboto-500italic.woff +0 -0
- package/bundle/fonts/roboto-500italic.woff2 +0 -0
- package/bundle/fonts/roboto-700.woff +0 -0
- package/bundle/fonts/roboto-700.woff2 +0 -0
- package/bundle/fonts/roboto-700italic.woff +0 -0
- package/bundle/fonts/roboto-700italic.woff2 +0 -0
- package/bundle/fonts/roboto-900.woff +0 -0
- package/bundle/fonts/roboto-900.woff2 +0 -0
- package/bundle/fonts/roboto-900italic.woff +0 -0
- package/bundle/fonts/roboto-900italic.woff2 +0 -0
- package/bundle/fonts/roboto-italic.woff +0 -0
- package/bundle/fonts/roboto-italic.woff2 +0 -0
- package/bundle/fonts/roboto-regular.woff +0 -0
- package/bundle/fonts/roboto-regular.woff2 +0 -0
- package/bundle/images/360_placement_pin_mask.png +0 -0
- package/bundle/images/Desktop-help-play-button.svg +1 -0
- package/bundle/images/Desktop-help-spacebar.png +0 -0
- package/bundle/images/MP-logo_H_lock-RGB_color-black.svg +24 -0
- package/bundle/images/NoteColor.png +0 -0
- package/bundle/images/chrome.png +0 -0
- package/bundle/images/edge.png +0 -0
- package/bundle/images/escape.png +0 -0
- package/bundle/images/exterior.png +0 -0
- package/bundle/images/exterior_hover.png +0 -0
- package/bundle/images/firefox.png +0 -0
- package/bundle/images/headset-quest-2.png +0 -0
- package/bundle/images/interior.png +0 -0
- package/bundle/images/interior_hover.png +0 -0
- package/bundle/images/login-screen-background.jpg +0 -0
- package/bundle/images/matterport-app-icon.svg +9 -0
- package/bundle/images/matterport-logo-light.svg +1 -0
- package/bundle/images/mattertag-disc-128-free.v1.png +0 -0
- package/bundle/images/mobile-help-play-button.svg +1 -0
- package/bundle/images/nav_help_360.png +0 -0
- package/bundle/images/nav_help_click_inside.png +0 -0
- package/bundle/images/nav_help_gesture_drag.png +0 -0
- package/bundle/images/nav_help_gesture_drag_two_finger.png +0 -0
- package/bundle/images/nav_help_gesture_pinch.png +0 -0
- package/bundle/images/nav_help_gesture_position.png +0 -0
- package/bundle/images/nav_help_gesture_position_two_finger.png +0 -0
- package/bundle/images/nav_help_gesture_tap.png +0 -0
- package/bundle/images/nav_help_inside_key.png +0 -0
- package/bundle/images/nav_help_keyboard_all.png +0 -0
- package/bundle/images/nav_help_keyboard_left_right.png +0 -0
- package/bundle/images/nav_help_keyboard_up_down.png +0 -0
- package/bundle/images/nav_help_mouse_click.png +0 -0
- package/bundle/images/nav_help_mouse_drag_left.png +0 -0
- package/bundle/images/nav_help_mouse_drag_right.png +0 -0
- package/bundle/images/nav_help_mouse_position_left.png +0 -0
- package/bundle/images/nav_help_mouse_position_right.png +0 -0
- package/bundle/images/nav_help_mouse_zoom.png +0 -0
- package/bundle/images/nav_help_tap_inside.png +0 -0
- package/bundle/images/nav_help_zoom_keys.png +0 -0
- package/bundle/images/objectColor.png +0 -0
- package/bundle/images/outlineBasic1024.png +0 -0
- package/bundle/images/outlineBasic2048.png +0 -0
- package/bundle/images/outlineBasic4096.png +0 -0
- package/bundle/images/outlineBasic512.png +0 -0
- package/bundle/images/outlineEnhanced1024.png +0 -0
- package/bundle/images/outlineEnhanced2048.png +0 -0
- package/bundle/images/outlineEnhanced4096.png +0 -0
- package/bundle/images/outlineEnhanced512.png +0 -0
- package/bundle/images/pinAnchor.png +0 -0
- package/bundle/images/pinIconDefault.png +0 -0
- package/bundle/images/safari.png +0 -0
- package/bundle/images/scope.svg +3 -0
- package/bundle/images/selected_sweep_glow.png +0 -0
- package/bundle/images/showcase-password-background.jpg +0 -0
- package/bundle/images/surface_grid_planar_256.png +0 -0
- package/bundle/images/tagColor.png +0 -0
- package/bundle/images/unsupported-browser.jpg +0 -0
- package/bundle/images/uv_grid_opengl.jpg +0 -0
- package/bundle/images/vert_arrows.png +0 -0
- package/bundle/js/136.js +18 -0
- package/bundle/js/136.js.LICENSE.txt +20 -0
- package/bundle/js/143.js +2 -0
- package/bundle/js/143.js.LICENSE.txt +20 -0
- package/bundle/js/145.js +2 -0
- package/bundle/js/145.js.LICENSE.txt +20 -0
- package/bundle/js/189.js +2 -0
- package/bundle/js/189.js.LICENSE.txt +20 -0
- package/bundle/js/217.js +2 -0
- package/bundle/js/217.js.LICENSE.txt +20 -0
- package/bundle/js/313.js +2 -0
- package/bundle/js/313.js.LICENSE.txt +20 -0
- package/bundle/js/316.js +2 -0
- package/bundle/js/316.js.LICENSE.txt +27 -0
- package/bundle/js/321.js +2 -0
- package/bundle/js/321.js.LICENSE.txt +20 -0
- package/bundle/js/324.js +2 -0
- package/bundle/js/324.js.LICENSE.txt +20 -0
- package/bundle/js/325.js +2 -0
- package/bundle/js/325.js.LICENSE.txt +20 -0
- package/bundle/js/330.js +2 -0
- package/bundle/js/330.js.LICENSE.txt +20 -0
- package/bundle/js/335.js +2 -0
- package/bundle/js/335.js.LICENSE.txt +20 -0
- package/bundle/js/376.js +2 -0
- package/bundle/js/376.js.LICENSE.txt +20 -0
- package/bundle/js/422.js +2 -0
- package/bundle/js/422.js.LICENSE.txt +22 -0
- package/bundle/js/493.js +2 -0
- package/bundle/js/493.js.LICENSE.txt +27 -0
- package/bundle/js/512.js +2 -0
- package/bundle/js/512.js.LICENSE.txt +20 -0
- package/bundle/js/519.js +2 -0
- package/bundle/js/519.js.LICENSE.txt +20 -0
- package/bundle/js/521.js +2 -0
- package/bundle/js/521.js.LICENSE.txt +20 -0
- package/bundle/js/525.js +2 -0
- package/bundle/js/525.js.LICENSE.txt +20 -0
- package/bundle/js/607.js +2 -0
- package/bundle/js/607.js.LICENSE.txt +27 -0
- package/bundle/js/644.js +2 -0
- package/bundle/js/644.js.LICENSE.txt +63 -0
- package/bundle/js/648.js +2 -0
- package/bundle/js/648.js.LICENSE.txt +20 -0
- package/bundle/js/66.js +2 -0
- package/bundle/js/66.js.LICENSE.txt +20 -0
- package/bundle/js/662.js +2 -0
- package/bundle/js/662.js.LICENSE.txt +20 -0
- package/bundle/js/668.js +2 -0
- package/bundle/js/668.js.LICENSE.txt +20 -0
- package/bundle/js/718.js +2 -0
- package/bundle/js/718.js.LICENSE.txt +20 -0
- package/bundle/js/764.js +2 -0
- package/bundle/js/764.js.LICENSE.txt +29 -0
- package/bundle/js/833.js +20 -0
- package/bundle/js/833.js.LICENSE.txt +20 -0
- package/bundle/js/858.js +2 -0
- package/bundle/js/858.js.LICENSE.txt +20 -0
- package/bundle/js/916.js +2 -0
- package/bundle/js/916.js.LICENSE.txt +20 -0
- package/bundle/js/924.js +2 -0
- package/bundle/js/924.js.LICENSE.txt +20 -0
- package/bundle/js/932.js +2 -0
- package/bundle/js/932.js.LICENSE.txt +20 -0
- package/bundle/js/948.js +2 -0
- package/bundle/js/948.js.LICENSE.txt +20 -0
- package/bundle/js/958.js +2 -0
- package/bundle/js/958.js.LICENSE.txt +20 -0
- package/bundle/js/JPEGDecoder.worker.worker.js.LICENSE.txt +29 -0
- package/bundle/js/JPEGEncoder.worker.worker.js.LICENSE.txt +29 -0
- package/bundle/js/PNGDecoder.worker.worker.js.LICENSE.txt +20 -0
- package/bundle/js/PNGEncoder.worker.worker.js.LICENSE.txt +20 -0
- package/bundle/js/browser-check.js +2 -0
- package/bundle/js/browser-check.js.LICENSE.txt +18 -0
- package/bundle/js/showcase.js +6 -0
- package/bundle/js/showcase.js.LICENSE.txt +144 -0
- package/bundle/locale/messages/strings_de.json +1 -0
- package/bundle/locale/messages/strings_es.json +1 -0
- package/bundle/locale/messages/strings_fr.json +1 -0
- package/bundle/locale/messages/strings_it.json +1 -0
- package/bundle/locale/messages/strings_ja.json +1 -0
- package/bundle/locale/messages/strings_ko.json +1 -0
- package/bundle/locale/messages/strings_nl.json +1 -0
- package/bundle/locale/messages/strings_pt.json +1 -0
- package/bundle/locale/messages/strings_ru.json +1 -0
- package/bundle/locale/messages/strings_zh-CN.json +1 -0
- package/bundle/locale/messages/strings_zh-TW.json +1 -0
- package/bundle/locale/strings.json +1 -0
- package/bundle/sdk/cursors/grab.png +0 -0
- package/bundle/sdk/cursors/grabbing.png +0 -0
- package/bundle/sdk/cursors/rbe-default.png +0 -0
- package/bundle/sdk/cursors/rbe-finish-room.png +0 -0
- package/bundle/sdk/cursors/rbe-moving.png +0 -0
- package/bundle/sdk/cursors/rbe-place-door.png +0 -0
- package/bundle/sdk/cursors/rbe-place-node.png +0 -0
- package/bundle/sdk/cursors/rbe-place-opening.png +0 -0
- package/bundle/sdk/cursors/zoom-in.png +0 -0
- package/bundle/sdk/cursors/zoom-out.png +0 -0
- package/bundle/sdk/sandbox.html +1 -0
- package/bundle/sdk/sdk-client.js +1 -0
- package/bundle/sdk/sdk-interface.js +1 -0
- package/bundle/sdk.d.ts +5312 -0
- package/bundle/showcase.html +114 -0
- package/bundle/terms/terms-de-DE.html +69 -0
- package/bundle/terms/terms-en-GB.html +62 -0
- package/bundle/terms/terms-en-US.html +62 -0
- package/bundle/terms/terms-es-MX.html +66 -0
- package/bundle/terms/terms-fr-FR.html +65 -0
- package/bundle/terms/terms-it-IT.html +65 -0
- package/bundle/terms/terms-ja-JP.html +64 -0
- package/bundle/terms/terms-ko-KR.html +65 -0
- package/bundle/terms/terms-nl-NL.html +65 -0
- package/bundle/terms/terms-pt-BR.html +75 -0
- package/bundle/terms/terms-ru-RU.html +72 -0
- package/bundle/terms/terms-zh-CN.html +65 -0
- package/bundle/terms/terms-zh-TW.html +84 -0
- package/bundle/vendors/three/0.146.0/libs/basis/README.md +32 -0
- package/bundle/vendors/three/0.146.0/libs/basis/basis_transcoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/basis/basis_transcoder.wasm +0 -0
- package/bundle/vendors/three/0.146.0/libs/basis/no-dynamic-execution.patch +11 -0
- package/bundle/vendors/three/0.146.0/libs/draco/README.md +32 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_decoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_decoder.wasm +0 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_encoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_wasm_wrapper.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_decoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_encoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_wasm_wrapper.js +1 -0
- package/bundle/vendors/three/0.146.0/three.cjs +2 -0
- package/bundle/vendors/three/0.146.0/three.cjs.LICENSE.txt +5 -0
- package/bundle/vendors/three/0.146.0/three.js +2 -0
- package/bundle/vendors/three/0.146.0/three.js.LICENSE.txt +5 -0
- package/bundle/vendors/three/0.146.0/three.min.js +2 -0
- package/bundle/vendors/three/0.146.0/three.min.js.LICENSE.txt +5 -0
- package/bundle/vendors/three/0.146.0/three.module.js +2 -0
- package/bundle/vendors/three/0.146.0/three.module.js.LICENSE.txt +5 -0
- package/bundle/version.txt +1 -0
- package/lib/architwin.d.ts +24 -0
- package/lib/architwin.min.js +1 -0
- package/lib/types.d.ts +123 -0
- package/lib/types.js +2 -0
- package/package.json +26 -0
- package/tsconfig.json +11 -0
package/bundle/js/321.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 321.js.LICENSE.txt */
|
|
2
|
+
(self.webpackChunkmp_webgl=self.webpackChunkmp_webgl||[]).push([[321],{92011:(e,t)=>{"use strict";var i=t.binary_mesh={};i.read=function(e,t){return e.readFields(i._readField,{chunk:[],quantized_chunk:[]},t)},i._readField=function(e,t,i){1===e?t.chunk.push(r.read(i,i.readVarint()+i.pos)):2===e&&t.quantized_chunk.push(l.read(i,i.readVarint()+i.pos))},i.write=function(e,t){if(e.chunk)for(var i=0;i<e.chunk.length;i++)t.writeMessage(1,r.write,e.chunk[i]);if(e.quantized_chunk)for(i=0;i<e.quantized_chunk.length;i++)t.writeMessage(2,l.write,e.quantized_chunk[i])};var s=t.vertices_simple={};s.read=function(e,t){return e.readFields(s._readField,{xyz:[],uv:[]},t)},s._readField=function(e,t,i){1===e?i.readPackedFloat(t.xyz):2===e&&i.readPackedFloat(t.uv)},s.write=function(e,t){e.xyz&&t.writePackedFloat(1,e.xyz),e.uv&&t.writePackedFloat(2,e.uv)};var o=t.faces_simple={};o.read=function(e,t){return e.readFields(o._readField,{faces:[]},t)},o._readField=function(e,t,i){1===e&&i.readPackedVarint(t.faces)},o.write=function(e,t){e.faces&&t.writePackedVarint(1,e.faces)};var r=t.chunk_simple={};r.read=function(e,t){return e.readFields(r._readField,{vertices:null,faces:null,chunk_name:"",material_name:""},t)},r._readField=function(e,t,i){1===e?t.vertices=s.read(i,i.readVarint()+i.pos):2===e?t.faces=o.read(i,i.readVarint()+i.pos):3===e?t.chunk_name=i.readString():4===e&&(t.material_name=i.readString())},r.write=function(e,t){e.vertices&&t.writeMessage(1,s.write,e.vertices),e.faces&&t.writeMessage(2,o.write,e.faces),e.chunk_name&&t.writeStringField(3,e.chunk_name),e.material_name&&t.writeStringField(4,e.material_name)};var n=t.vertices_quantized={};n.read=function(e,t){return e.readFields(n._readField,{quantization:0,translation:[],x:[],y:[],z:[]},t)},n._readField=function(e,t,i){1===e?t.quantization=i.readFloat():2===e?i.readPackedFloat(t.translation):3===e?i.readPackedSVarint(t.x):4===e?i.readPackedSVarint(t.y):5===e&&i.readPackedSVarint(t.z)},n.write=function(e,t){e.quantization&&t.writeFloatField(1,e.quantization),e.translation&&t.writePackedFloat(2,e.translation),e.x&&t.writePackedSVarint(3,e.x),e.y&&t.writePackedSVarint(4,e.y),e.z&&t.writePackedSVarint(5,e.z)};var a=t.uv_quantized={};a.read=function(e,t){return e.readFields(a._readField,{name:"",quantization:0,u:[],v:[]},t)},a._readField=function(e,t,i){1===e?t.name=i.readString():2===e?t.quantization=i.readFloat():3===e?i.readPackedSVarint(t.u):4===e&&i.readPackedSVarint(t.v)},a.write=function(e,t){e.name&&t.writeStringField(1,e.name),e.quantization&&t.writeFloatField(2,e.quantization),e.u&&t.writePackedSVarint(3,e.u),e.v&&t.writePackedSVarint(4,e.v)};var h=t.faces_compressed={};h.read=function(e,t){return e.readFields(h._readField,{faces:[]},t)},h._readField=function(e,t,i){1===e&&i.readPackedSVarint(t.faces)},h.write=function(e,t){e.faces&&t.writePackedSVarint(1,e.faces)};var l=t.chunk_quantized={};l.read=function(e,t){return e.readFields(l._readField,{chunk_name:"",material_name:"",vertices:null,uvs:[],faces:null},t)},l._readField=function(e,t,i){1===e?t.chunk_name=i.readString():2===e?t.material_name=i.readString():3===e?t.vertices=n.read(i,i.readVarint()+i.pos):4===e?t.uvs.push(a.read(i,i.readVarint()+i.pos)):5===e&&(t.faces=o.read(i,i.readVarint()+i.pos))},l.write=function(e,t){if(e.chunk_name&&t.writeStringField(1,e.chunk_name),e.material_name&&t.writeStringField(2,e.material_name),e.vertices&&t.writeMessage(3,n.write,e.vertices),e.uvs)for(var i=0;i<e.uvs.length;i++)t.writeMessage(4,a.write,e.uvs[i]);e.faces&&t.writeMessage(5,o.write,e.faces)}},17734:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>S});var s=i(97542),o=i(69170),r=i(54244),n=i(76532),a=i(53954),h=i(23254),l=i(92294),d=i(64773),c=i(18923),u=i(66563),m=i(14630),p=i(96154),g=i(5090),f=i(10699),y=i(23885),w=i(57053),v=i(99935),T=i(80626),M=i(24048),x=i(95882),b=i(5135);class D extends s.Y{constructor(){super(...arguments),this.name="mesh-quality",this.measurementModeData=null,this.updateMaxQuality=(()=>{let e,t,i;return({modeChange:s,criticalChange:o,interactionChange:r})=>{void 0!==o&&(t=o),void 0!==s&&(e=s),void 0!==r&&(i=r);const n=i===w.s.VrOrientOnly||i===w.s.VrWithController||i===w.s.VrWithTrackedController,a=this.modelMeshModule.stats().textureCount<=this.config.textureLODThreshold?Math.max(v.S.ULTRA,this.config.maxQuality):v.S.MEDIUM,h=Math.max(a,e===x.Ey.Panorama&&0===this.meshData.meshTextureOpacity.value?a:this.config.maxQuality);this.modelMeshModule.setTextureLimits(a,h);const l=this.viewmodeData.currentMode!==x.Ey.Dollhouse&&this.viewmodeData.currentMode!==x.Ey.Floorplan,d=this.viewmodeData.transition.active&&(0,x.Bw)(this.viewmodeData.transition.to);n||d||t&&l?this.modelMeshModule.setTextureStreamMode(T.l.NONE):this.modelMeshModule.setTextureStreamMode(this.config.textureLOD)}})()}async init(e,t){this.config=e,this.engine=t,[this.modelMeshModule,this.meshData,this.viewmodeData,this.sweepData,this.appData,this.interactionModeData]=await Promise.all([t.getModuleBySymbol(o.y.MODEL_MESH),t.market.waitForData(n._),t.market.waitForData(h.O),t.market.waitForData(a.Z),t.market.waitForData(r.pu),t.market.waitForData(b.Z)]),this.bindAppEventsToTextureQuality(),this.bindAppEventsToTextureVisibility(),this.updateMaxQuality({}),this.showcaseMeshDetailRules()}bindAppEventsToTextureQuality(){let e=0;this.bindings.push(this.meshData.onChanged((t=>{t.meshTextureOpacity.value!==e&&this.updateMaxQuality({}),e=t.meshTextureOpacity.value})),this.appData.onPhase((()=>{this.updateMaxQuality({})})),this.engine.subscribe(g.Z,(e=>{this.updateMaxQuality({criticalChange:!0,modeChange:e.toMode})})),this.engine.subscribe(f.Z,(e=>{this.updateMaxQuality({criticalChange:!1,modeChange:e.toMode})})),this.engine.subscribe(p.oR,(()=>{this.updateMaxQuality({criticalChange:!0})})),this.engine.subscribe(p.NR,(()=>{this.updateMaxQuality({criticalChange:!1})})),this.engine.subscribe(c.Z,(()=>{this.updateMaxQuality({criticalChange:!0})})),this.engine.subscribe(u.Z,(()=>{this.updateMaxQuality({criticalChange:!1})})),this.engine.subscribe(d.m,(e=>{this.updateMaxQuality({interactionChange:e.mode})})))}showcaseMeshDetailRules(){const{modelMeshModule:e,log:t}=this,i=()=>this.appData.phase>=this.appData.phases.PLAYING&&this.appData.phase!==this.appData.phases.ERROR,s=()=>this.viewmodeData.closestMode===x.Ey.Panorama,o=()=>{var e,t;return null!==(t=null===(e=this.measurementModeData)||void 0===e?void 0:e.isEditingOrCreating())&&void 0!==t&&t},r=()=>this.interactionModeData.isVR();function n(){const n=e.getMeshDetail();let a=n;a=!s()||s()&&o()?"max":"default",(!i()||r()&&s())&&(a="minimal"),n!==a&&(t.debug(`overrideMaxDetail from ${n} to ${a}`),e.setMeshOptions({overrideMaxDetail:a}))}this.bindings.push(this.appData.onPhase(n),this.viewmodeData.onChanged(n),this.meshData.meshTextureOpacity.onComplete(n),this.interactionModeData.onChanged(n)),this.engine.market.waitForData(l.X).then((e=>{this.bindings.push(e.onPhaseChanged(n)),this.measurementModeData=e})),n()}bindAppEventsToTextureVisibility(){this.bindings.push(this.engine.subscribe(g.Z,(e=>{this.updateRenderMode()})),this.engine.subscribe(m.Z,(e=>{const t=this.sweepData.isSweepUnaligned(e.toSweep);t!==this.sweepData.isSweepUnaligned(e.fromSweep)&&this.modelMeshModule.setRenderMode(t?M.k.PanoramaCube:M.k.PanoramaMesh)})))}updateRenderMode(){const e=this.viewmodeData.currentMode===x.Ey.Panorama||this.viewmodeData.transition.to===x.Ey.Panorama,t=e?M.k.PanoramaMesh:M.k.Mesh,i=e?y.Q9:y.w2;this.modelMeshModule.setRenderMode(t,i)}}const S=D},10059:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>p});var s=i(69170),o=i(89553),r=i(32597),n=i(41326),a=i(97542),h=i(6667),l=i(23254),d=i(95882),c=i(34029),u=i(53203),m=i(9037);class p extends a.Y{constructor(){super(...arguments),this.name="showcase-hotkeys",this.inputCommandMap={[h.M.PRESSED]:{[r.R.ONE]:()=>(this.viewmodeData.currentMode===d.Ey.Panorama&&(this.settings.setProperty(u.Lp,!1),this.currentView=0),this.switchToMode(n.BD.INSIDE)),[r.R.TWO]:()=>this.switchToMode(n.BD.DOLLHOUSE),[r.R.THREE]:()=>this.switchToMode(n.BD.FLOORPLAN),[r.R.ZERO]:()=>{const e=this.currentView++%this.meshViews.length;return this.meshViews[e]()}}},this.currentView=0,this.meshViews=[()=>(this.settings.setProperty(u.Lp,!1),this.switchToMode(n.BD.MESH)),()=>(this.settings.setProperty(u.Lp,!0),this.switchToMode(n.BD.MESH)),()=>(this.settings.setProperty(u.Lp,!0),this.switchToMode(n.BD.INSIDE)),()=>(this.settings.setProperty(u.Lp,!1),this.switchToMode(n.BD.INSIDE))]}async init(e,t){const i=await t.getModuleBySymbol(s.y.INPUT);[this.viewmodeData,this.settings,this.cameraData]=await Promise.all([t.market.waitForData(l.O),t.market.waitForData(c.e),t.market.waitForData(m.M)]),this.issueCommand=t.commandBinder.issueCommand.bind(t.commandBinder),i.registerHandler(o.e,(async e=>{this.inputCommandMap[e.state]&&this.inputCommandMap[e.state][e.key]&&await this.inputCommandMap[e.state][e.key]()}))}async switchToMode(e){const{currentMode:t}=this.viewmodeData;if(t!==d.Ey.Transition){const i=(0,d.Bw)(t)&&(e===n.BD.MESH||e===n.BD.INSIDE)?this.cameraData.pose.rotation:void 0;try{await this.issueCommand(new n._i(e,void 0,{rotation:i}))}catch(e){this.log.debug("Unable to switchToMode",e)}}}}},94292:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>B});var s=i(97542),o=i(69170),r=i(34029),n=i(59625),a=i(14715),h=i(64918),l=i(17788),d=i(97998),c=i(46391),u=i(17686),m=i(28361),p=i(5823);const g=new d.Z("mds-player-options-deserializer"),f={[p.Y6.LEFT]:u.kw.Left,[p.Y6.RIGHT]:u.kw.Right,[p.Y6.AUTO]:u.kw.Auto},y={[p.rq.BLACK]:m.z.black,[p.rq.GREY]:m.z.grey,[p.rq.WHITE]:m.z.white};class w{deserialize(e){var t;if(!e||!this.validate(e))return g.debug("Deserialized invalid options data from MDS",e),null;const i=(null===(t=e.publication)||void 0===t?void 0:t.options)||{},s=e.options||{},o=(null==s?void 0:s.tourPanDirection)?f[s.tourPanDirection]:u.kw.Auto,r={address:i.address,contact_email:i.contactEmail,contact_name:i.contactName,contact_phone:i.contactPhone,dollhouse:s.dollhouseEnabled,external_url:i.externalUrl,floor_plan:s.floorplanEnabled,floor_select:s.floorSelectEnabled,highlight_reel:s.highlightReelEnabled,labels:s.labelsEnabled,labels_dh:s.dollhouseLabelsEnabled,model_name:i.modelName,model_summary:i.modelSummary,presented_by:i.presentedBy,measurements:s.measurements!==p.XR.DISABLED,measurements_saved:s.measurements===p.XR.MEASUREANDVIEW,unit_type:s.unitType===p.nL.IMPERIAL?c.M.IMPERIAL:c.M.METRIC,background_color:(null==s?void 0:s.backgroundColor)?y[s.backgroundColor]:m.z.black,tour_buttons:s.tourButtonsEnabled,fast_transitions:s.tourFastTransitionsEnabled,transition_speed:s.tourTransitionSpeed,transition_time:s.tourTransitionTime,pan_speed:s.tourPanSpeed,dollhouse_pan_speed:s.tourDollhousePanSpeed,zoom_duration:s.tourZoomDuration,pan_angle:s.tourPanAngle,pan_direction:o,space_search:s.spaceSearchEnabled};return new n.af(r)}validate(e){if(!e)return!1;return["id","options","publication"].every((t=>t in e))}}var v=i(18448);const T=(0,v.S)(f),M=(0,v.S)(y);class x{serialize(e){const t={},i=e.options||{};if(void 0!==i.dollhouse&&(t.dollhouseOverride=i.dollhouse?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.floor_plan&&(t.floorplanOverride=i.floor_plan?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.floor_select&&(t.floorSelectOverride=i.floor_select?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.space_search&&(t.spaceSearchOverride=i.space_search?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.labels&&(t.labelsOverride=i.labels?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.labels_dh&&(t.dollhouseLabelsOverride=i.labels_dh?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.highlight_reel&&(t.highlightReelOverride=i.highlight_reel?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.background_color&&(t.backgroundColor={set:M[i.background_color]||p.rq.BLACK}),void 0!==i.unit_type){const e=i.unit_type===c.M.METRIC?p.nL.METRIC:p.nL.IMPERIAL;t.unitType={set:e}}if(void 0!==i.measurements||void 0!==i.measurements_saved){const e=i.measurements&&i.measurements_saved?p.XR.MEASUREANDVIEW:i.measurements?p.XR.MEASURE:p.XR.DISABLED;t.measurements={set:e}}void 0!==i.tour_buttons&&(t.tourButtonsOverride=i.tour_buttons?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.fast_transitions&&(t.tourFastTransitionsOverride=i.fast_transitions?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.pan_angle&&(t.tourPanAngle={set:i.pan_angle}),void 0!==i.pan_direction&&(t.tourPanDirection={set:T[i.pan_direction]}),void 0!==i.pan_speed&&(t.tourPanSpeed={set:i.pan_speed}),void 0!==i.transition_speed&&(t.tourTransitionSpeed={set:i.transition_speed}),void 0!==i.transition_time&&(t.tourTransitionTime={set:i.transition_time}),void 0!==i.zoom_duration&&(t.tourZoomDuration={set:i.zoom_duration}),void 0!==i.dollhouse_pan_speed&&(t.tourDollhousePanSpeed={set:i.dollhouse_pan_speed});const s={};return void 0!==i.presented_by&&(s.presentedByOverride=i.presented_by?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.contact_email&&(s.contactEmailOverride=i.contact_email?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.contact_name&&(s.contactNameOverride=i.contact_name?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.contact_phone&&(s.contactPhoneOverride=i.contact_phone?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.external_url&&(s.externalUrlOverride=i.external_url?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.model_name&&(s.modelNameOverride=i.model_name?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.model_summary&&(s.modelSummaryOverride=i.model_summary?p.J1.ENABLED:p.J1.DISABLED),void 0!==i.address&&(s.addressOverride=i.address?p.J1.ENABLED:p.J1.DISABLED),{options:t,publication:{options:s}}}}var b=i(64927);const D=new d.Z("mds-player-options-store");class S extends l.u{constructor(){super(...arguments),this.serializer=new x,this.deserializer=new w,this.prefetchKey="data.model.publication.options"}async read(e={}){const t={modelId:this.getViewId()};return this.query(b.GetModelOptions,t,e).then((e=>{var t;return this.deserializer.deserialize(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.model)}))}async update(e){const t=this.getViewId(),i=this.serializer.serialize(e);if(0===Object.keys(i).length)throw new Error("No data to update?");return this.mutate(b.PatchModel,{modelId:t,patch:i}).then((e=>{D.debug(e)}))}}var C=i(86090),P=i(2541),k=i(79728),O=i(90632),E=i(635),F=i(80742);class B extends s.Y{constructor(){super(...arguments),this.name="showcase-settings",this.updateTransitionType=(e,t,i)=>{const s=e.options.fast_transitions?h.n.FadeToBlack:h.n.Interpolate;t.hasProperty(a.gj)?t.setProperty(a.gj,s):i.registerSetting("player_options",a.gj,s)}}async init(e,t){const{baseModelId:i,readonly:s,baseUrl:a}=e;this.engine=t;const h=await t.market.waitForData(F.R);this.store=new S({context:h.mdsContext,readonly:s,baseUrl:a,viewId:i});const[l,d,c,u]=await Promise.all([t.getModuleBySymbol(o.y.SETTINGS),t.market.waitForData(r.e),t.getModuleBySymbol(o.y.STORAGE),this.store.read()]);this.playerOptionsData=u||new n.af,t.market.register(this,n.af,this.playerOptionsData);for(const e in n.gx){const t=n.gx[e],i=this.playerOptionsData.options[t];if(l.hasProperty(t)){const e=l.getProperty(t);l.updateSetting(t,i&&e),this.log.debug(`Updated player_options setting ${t} = ${i&&e}`)}else l.registerSetting("player_options",t,i),this.log.debug(`Registered player_options setting ${t} = ${i}`)}if(this.updateTransitionType(this.playerOptionsData,d,l),this.bindings.push(d.onPropertyChanged(n.gx.InstantTransitions,(()=>this.updateTransitionType(this.playerOptionsData,d,l)))),!s){this.bindings.push(c.onSave((()=>this.save()),{dataType:k.g.SETTINGS}));const e=await t.market.waitForData(O.Q);e.setRevertableType(k.g.SETTINGS),e.setPublishableType(k.g.SETTINGS),this.monitor=new C.u(this.playerOptionsData,{aggregationType:P.E.NextFrame},this.engine),this.monitor.onChanged((()=>this.engine.commandBinder.issueCommand(new E.VQ({dataTypes:[k.g.SETTINGS]}))))}}async save(){if(!this.store||!this.monitor)return void this.log.warn("Settings changes will NOT be saved");const e=this.monitor.getDiffRecord(),t=e.options;return t&&(t&&void 0===t.measurements&&void 0!==t.measurements_saved&&(t.measurements=this.playerOptionsData.options.measurements),t&&void 0!==t.measurements&&void 0===t.measurements_saved&&(t.measurements_saved=this.playerOptionsData.options.measurements_saved),void 0!==(null==t?void 0:t.floor_select)&&(t.floor_select=this.playerOptionsData.options.floor_select),void 0!==(null==t?void 0:t.labels_dh)&&(t.labels_dh=this.playerOptionsData.options.labels_dh),void 0===t.presented_by&&void 0===t.contact_email&&void 0===t.contact_name&&void 0===t.contact_phone&&void 0===t.external_url&&void 0===t.model_name&&void 0===t.model_summary&&void 0===t.address||(t.presented_by=this.playerOptionsData.options.presented_by,t.contact_email=this.playerOptionsData.options.contact_email,t.contact_name=this.playerOptionsData.options.contact_name,t.contact_phone=this.playerOptionsData.options.contact_phone,t.external_url=this.playerOptionsData.options.external_url,t.model_name=this.playerOptionsData.options.model_name,t.model_summary=this.playerOptionsData.options.model_summary,t.address=this.playerOptionsData.options.address)),this.monitor.clearDiffRecord(),this.store.update(e)}}},32170:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>x});var s=i(81396),o=i(97542),r=i(69170),n=i(53954),a=i(95882),h=i(55450),l=i(64918),d=i(63252),c=i(39880),u=i(34029),m=i(90197),p=i(59625),g=i(2569),f=i(46950),y=i(33324),w=i(40505),v=i(44237),T=i(28022),M=i(54244);class x extends o.Y{constructor(){super(...arguments),this.name="showcase-start",this.firstRenderPromise=new f.Q,this.flyInPromise=new f.Q,this.handleFlyIn=async(e,t,i)=>{this.renderer.startRender(!1);try{await this.doStandardStart(e,t,i,!0)}catch(e){this.log.error(e),this.renderer.startRender(!0)}}}async init(e,t){const[i,s]=await Promise.all([t.market.waitForData(u.e),t.getModuleBySymbol(r.y.CAMERA_START)]);[this.sweepData,this.sweepModule,this.cameraModule,this.renderer,this.appData]=await Promise.all([t.market.waitForData(n.Z),t.getModuleBySymbol(r.y.SWEEP_DATA),t.getModuleBySymbol(r.y.CAMERA),t.getModuleBySymbol(r.y.WEBGL_RENDERER),t.market.waitForData(M.pu)]);const o=i.tryGetProperty("quickstart",!1),a=s.getStartingPose();return(o?this.doQuickStart(a,t,l.n.Instant):this.doStandardStart(a,t,i,!1)).catch((e=>{this.log.error("Handling error during initial fly-in, attempting recover",{startingPose:a,error:e}),this.doQuickStart(a,t,l.n.FadeToBlack),this.renderBeforeStarting(t)})).finally((()=>this.flyInPromise.resolve())),this.bindings.push(t.commandBinder.addBinding(m.b,(async e=>{this.handleFlyIn(e.pose||s.getStartingPose(),t,i)})),t.commandBinder.addBinding(m.Q,(async e=>{this.fadeToStartLocation(s,t)})),t.subscribe(T.YB,(async()=>{this.appData.application!==M.Mx.WORKSHOP&&s.moveCameraOnViewChange&&this.fadeToStartLocation(s,t)}))),this.waitForFirstRender}fadeToStartLocation(e,t){const i=e.getStartingPose();this.doQuickStart(i,t,l.n.FadeToBlack)}get waitForFirstRender(){return this.firstRenderPromise.nativePromise()}get waitForFlyin(){return this.flyInPromise.nativePromise()}async doQuickStart(e,t,i){const s=this.sweepData.getStartSweep(e),o=s&&s.id,n=await t.getModuleBySymbol(r.y.VIEWMODE);return await n.switchToMode(e.mode,i,{sweepID:o,position:e.camera.position||s&&s.position,rotation:e.camera.rotation,zoom:-1!==e.camera.zoom?e.camera.zoom:void 0}),t.broadcast(new w.bN(!1)),e.mode!==a.Ey.Dollhouse&&e.mode!==a.Ey.Floorplan||e.floorVisibility&&await t.commandBinder.issueCommandWhenBound(new y.h9(e.floorVisibility.lastIndexOf(1),!0,0)),this.renderBeforeStarting(t)}async doStandardStart(e,t,i,o){var n;const[d]=await Promise.all([t.getModuleBySymbol(r.y.VIEWMODE)]);await t.getModuleBySymbol(r.y.SHOWCASE_SETTINGS);const u=0===i.getOverrideParam("dh",1)||!i.tryGetProperty(p.gx.Dollhouse,!0),m=0===i.getOverrideParam("fp",1)||!i.tryGetProperty(p.gx.FloorPlan,!0);e&&(e.mode===a.Ey.Dollhouse&&u||e.mode===a.Ey.Floorplan&&m||e.mode===a.Ey.Panorama&&!e.pano)&&(e=null);const f=!e||e&&(e.mode===a.Ey.Dollhouse||e.mode===a.Ey.Floorplan),T=!e||e&&!this.is360Pano(e)&&(0,a.Bw)(e.mode)&&!u,M=e?e.mode:a.Ey.Panorama,x=this.sweepData.getStartSweep(e),b=x&&x.id,D=this.sweepData.getFirstSweep();let S=D&&D.rotation;if((null===(n=null==e?void 0:e.camera)||void 0===n?void 0:n.rotation)&&!(0,v.mB)(e.camera.rotation)&&(S=e.camera.rotation),S&&M!==a.Ey.Floorplan&&(S=(0,g.Z)(S)),T){await t.getModuleBySymbol(r.y.MODEL_MESH);const i=d.getFlyinEndPose({sweepID:b,position:e?e.camera.position:void 0,rotation:S}),n=d.getFlyinStartPose(i,o?new s.Vector3(0,0,0):void 0);t.broadcast(new w.bN(!0));const u=b?this.sweepModule.activateSweep({sweepId:b}):Promise.resolve();await d.switchToMode(a.Ey.Dollhouse,l.n.Instant,n),await this.renderBeforeStarting(t),await(0,c.gw)(750),await this.cameraModule.moveTo({transitionType:l.n.Interpolate,pose:i}).nativePromise(),await u,t.broadcast(new w.bN(!1)),await d.switchToMode(M,l.n.Interpolate,{sweepID:b,rotation:S},h.DEFAULT_TRANSITION_TIME)}else await d.switchToMode(M,l.n.Instant,{sweepID:b,position:e?e.camera.position:void 0,rotation:S,zoom:e&&-1!==e.camera.zoom?e.camera.zoom:void 0}),f&&e&&(e.floorVisibility?await t.commandBinder.issueCommandWhenBound(new y.h9(e.floorVisibility.lastIndexOf(1),!0,0)):await t.commandBinder.issueCommandWhenBound(new y.Vw(null))),await this.renderBeforeStarting(t)}is360Pano(e){if(e.pano.uuid){const t=this.sweepData.getSweep(e.pano.uuid);if(t)return t.alignmentType!==d.z9.ALIGNED}else{const e=this.sweepData.getFirstSweep();if(void 0!==e)return e.alignmentType!==d.z9.ALIGNED}return!1}async renderBeforeStarting(e){await this.renderer.renderOnce(),await e.getModuleBySymbol(r.y.LOADING_GUI),this.renderer.startRender(!0),this.firstRenderPromise.resolve()}}},38319:(e,t,i)=>{"use strict";i.d(t,{hf:()=>r,lb:()=>o});var s=i(50575);const o=(e=200)=>({resizeDimensions:[{property:s.P.width,setDimension:e=>e.width,duration:e},{property:s.P.height,setDimension:e=>e.height,duration:e},{property:s.P.top,setDimension:()=>0,duration:e},{property:s.P.left,setDimension:()=>0,duration:e}]}),r=(e,t,i,o=200)=>{const r=[];return void 0!==e&&r.push({property:s.P.width,setDimension:t=>t.width+e,duration:o}),void 0!==t&&r.push({property:s.P.height,setDimension:e=>e.height+t,duration:o}),void 0!==i&&r.push({property:s.P.left,setDimension:()=>i,duration:o}),{resizeDimensions:r}}},86384:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>r});var s=i(97542),o=i(23254);class r extends s.Y{constructor(){super(...arguments),this.name="common-controls",this.otherControls=[],this.poseController=null}async init(e,t){this.cameraPoseProxy=e.cameraPoseProxy,this.modeControls={},t.market.waitForData(o.O).then((e=>this.viewmodeData=e)),this.cameraPoseProxy.newSession(this)}onAccessGranted(e){this.poseController=e,Object.values(this.modeControls).forEach((e=>e.controls.setController(this.poseController))),Object.values(this.otherControls).forEach((t=>t.onAccessGranted(e)))}onAccessRevoked(e){this.stop(),this.poseController=null,Object.values(this.modeControls).forEach((e=>e.controls.setController(this.poseController))),Object.values(this.otherControls).forEach((t=>t.onAccessRevoked(e)))}startRotateTransition(e,t,i=!0){return this.checkControlsForAction((s=>s.startRotateTransition(e,t,i)))}startZoomTransition(e,t,i=!0){return this.checkControlsForAction((s=>s.startZoomTransition(e,t,i)))}startTranslateTransition(e,t,i=!0){return this.checkControlsForAction((s=>s.startTranslateTransition(e,t,i)))}stop(){return this.checkControlsForAction((e=>(e.stop(),Promise.resolve())))}checkControlsForAction(e){if(this.viewmodeData&&null!==this.viewmodeData.currentMode){if(this.modeControls[this.viewmodeData.currentMode]){return e(this.modeControls[this.viewmodeData.currentMode].controls)}}return Promise.reject("checkControlsForAction() -> Current view mode is null")}addControls(e,t,i=!1){this.modeControls[e]&&!i||(t.setController(this.poseController),this.modeControls[e]={mode:e,controls:t})}register(e){this.poseController&&e.onAccessGranted(this.poseController),this.otherControls.push(e)}}},30445:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>G});var s=i(97542),o=i(69170),r=i(90304),n=i(12250),a=i(80592),h=i(89553),l=i(32597),d=i(6667),c=i(16782),u=i(5090),m=i(23254),p=i(95882),g=i(31362),f=i(69505),y=i(49827),w=i(2569),v=i(81396),T=i(18596),M=i(96955),x=i(76532),b=i(21646),D=i(41835),S=i(46950),C=i(64918);const P=1e3/60,k=89*f.Ue,O=.001*f.Ue,E=30*f.Ue,F=.25,B=Math.PI/1e3;var R=i(47047),A=i(59370);const I=b.Z.epsilon;class _ extends D.Z{constructor(e,t,i,s=!1){super(),this.cameraPoseProxy=e,this.cameraCheck=t,this.tempOrientation=new v.Quaternion,this.tempAxis=new v.Vector3,this.nextPosition=new v.Vector3,this.nextOrientation=new v.Quaternion,this.currentPose=new R.B(1),this.positionDelta=new v.Vector3,this.angularAccel=new v.Vector2,this.angularVelocity=new v.Vector2,this.linearAccel=new v.Vector2,this.linearVelocity=new v.Vector2,this.grabPlane=(new v.Plane).setFromNormalAndCoplanarPoint(r.f.UP,r.f.ZERO),this.grabPt=new v.Vector3,this.ndcPos=new v.Vector2,this.mousePan=!1,this.zoomAccel=0,this.zoomVelocity=0,this.zoomDir=new v.Vector3,this.focusPlane=new v.Plane,this.orbitPoint=new v.Vector3,this.orbitDistance=0,this.mouseOrbit=!1,this.aimTarget=new v.Vector3,this.currentPhiLowerLimit=O,this.currentPhiUpperLimit=k,this.poseController=null,this.castFromNdc=(()=>{const e=new v.Vector3,t=new v.Vector3(0,0,-1),i=new v.Ray(e,t),s=new v.Vector3;return()=>{(0,A.Kh)(this.grabCameraPose,e.set(this.ndcPos.x,this.ndcPos.y,-1),e),(0,A.Kh)(this.grabCameraPose,t.set(this.ndcPos.x,this.ndcPos.y,1),t),t.sub(e).normalize(),i.set(e,t);return i.intersectPlane(this.grabPlane,s)}})(),this.checkBounds=s,this._maxZoomDistance=Math.max(30,1.5*i.getSize(new v.Vector3).length()),this.transition={active:!1,startTime:0,elapsed:0,duration:0,angularVelocity:new v.Vector2,linearVelocity:new v.Vector2,zoomVelocity:0,easeOut:!1}}setController(e){return this.poseController=e,this}get maxZoomDistance(){return this._maxZoomDistance}setOrbitalAcceleration(e,t=!1){this.transition.active||(t&&this.haltVelocity(e,this.angularVelocity),this.angularAccel.x=void 0!==e.x?e.x:this.angularAccel.x,this.angularAccel.y=void 0!==e.y?e.y:this.angularAccel.y)}setPanAcceleration(e,t=!1){this.transition.active||(t&&this.haltVelocity(e,this.linearVelocity),this.linearAccel.x=void 0!==e.x?e.x:this.linearAccel.x,this.linearAccel.y=void 0!==e.y?e.y:this.linearAccel.y)}setNdcPos(e){this.ndcPos.copy(e)}setGrabPoint(e){this.grabPlane.setFromNormalAndCoplanarPoint(r.f.UP,e),this.grabCameraPose=this.cameraPoseProxy.pose.clone(),this.grabPt.copy(e),this.mousePan=!0}setOrbitPoint(e){this.orbitPoint.copy(e);const t=this.cameraPoseProxy.pose;this.orbitDistance=t.position.distanceTo(this.orbitPoint)/t.fovDistanceScale(),this.mouseOrbit=!0}unsetGrabPoint(){this.mousePan=!1}unsetOrbitPoint(){this.mouseOrbit=!1}setZoomAcceleration(e){this.transition.active||(this.zoomAccel=e)}setZoomDirection(e){this.transition.active||(this.zoomDir=e)}async setPhiLimits(e,t,i){this.currentPhiLowerLimit=e,this.currentPhiUpperLimit=t;const s=this.cameraPoseProxy.pose.phi(),o=(0,y.uZ)(0,this.currentPhiLowerLimit-s,this.currentPhiUpperLimit-s);Math.abs(o)>I&&i&&await this.orbit(new v.Vector2,!0)}haltVelocity(e,t){e.x&&t.x&&Math.sign(e.x)!==Math.sign(t.x)&&(t.x=0),e.y&&t.y&&Math.sign(e.y)!==Math.sign(t.y)&&(t.y=0)}startTransition(e,t,i,s,o){if(null===this.poseController)return S.Q.reject("Unable to start transition, since controller is unavailable.");const r=new S.Q;return this.transition.active=!0,this.transition.duration=e,this.transition.elapsed=0,this.transition.startTime=Date.now(),this.transition.deferred=r,this.transition.angularVelocity.copy(t),this.transition.linearVelocity.copy(i),this.transition.zoomVelocity=s,this.transition.easeOut=o,this.angularAccel.set(0,0),this.linearAccel.set(0,0),this.zoomAccel=0,this.angularVelocity.copy(t),this.linearVelocity.copy(i),this.zoomVelocity=s,this.poseController.beginExternalTransition(),this.setZoomDirection(this.cameraPoseProxy.pose.forward()),r.promise()}stopTransition(){this.transition.active&&(this.poseController&&this.poseController.endExternalTransition(),this.transition.active=!1),this.transition.deferred&&(this.transition.deferred.resolve(),this.transition.deferred=void 0)}updateTransition(e,t,i,s){let o=1,r=e/P;if(this.transition.elapsed+=e,this.transition.elapsed>=this.transition.duration){o=(this.transition.duration-(this.transition.elapsed-e))/e,r=1}t&&(this.angularVelocity.copy(this.transition.angularVelocity).multiplyScalar(o*r),this.orbit(this.angularVelocity)),i&&(this.linearVelocity.copy(this.transition.linearVelocity).multiplyScalar(o*r),this.pan(this.linearVelocity)),s&&(this.zoomVelocity=this.transition.zoomVelocity*o*r,this.zoom(this.zoomVelocity)),this.transition.elapsed>=this.transition.duration&&(this.stop(this.transition.easeOut),this.transition.active=!1)}updateDefault(e,t,i,s){const o=e/P;t&&(this.angularVelocity.addScaledVector(this.angularAccel,o),this.orbit(this.angularVelocity),this.angularVelocity.multiplyScalar(Math.pow(.92,o))),i&&(this.linearVelocity.addScaledVector(this.linearAccel,o),this.pan(this.linearVelocity),this.linearVelocity.multiplyScalar(Math.pow(.92,o))),s&&(this.zoomVelocity+=this.zoomAccel*o,this.zoom(this.zoomVelocity),this.zoomVelocity*=Math.pow(.84,o))}startRotateTransition(e,t,i){return t.x*=-1,this.startTransition(e,t.clone().multiplyScalar(P),new v.Vector2,0,i).nativePromise()}startTranslateTransition(e,t,i=!0){return this.startTransition(e,new v.Vector2,t.clone().multiplyScalar(P),0,i).nativePromise()}startZoomTransition(e,t,i){return this.startTransition(e,new v.Vector2(0,0),new v.Vector2(0,0),t,i).nativePromise()}update(e){const t=this.angularAccel.length()>I||this.angularVelocity.length()>I,i=this.linearAccel.length()>I||this.linearVelocity.length()>I||this.mousePan,s=Math.abs(this.zoomAccel)>I||Math.abs(this.zoomVelocity)>I;this.transition.active?this.updateTransition(e,t,i,s):this.updateDefault(e,t,i,s)}stopMomentum(){this.transition.active||(this.angularVelocity.set(0,0),this.linearVelocity.set(0,0),this.zoomVelocity=0)}stopAcceleration(){this.transition.active||(this.setOrbitalAcceleration({x:0,y:0}),this.setPanAcceleration({x:0,y:0}),this.setZoomAcceleration(0))}stop(e=!1){this.stopTransition(),this.stopAcceleration(),e||this.stopMomentum()}pan(e){if(!this.poseController)return;this.setupCurrentPose();const t=this.cameraPoseProxy.pose;if(this.mousePan){const e=this.castFromNdc();if(e){const t=e.sub(this.grabPt);this.nextPosition.copy(this.grabCameraPose.fovCorrectedPosition()).addScaledVector(t,-1),this.currentPose.position.copy(this.nextPosition),this.currentPose.applyPhiBasedFovSquish()}}else this.positionDelta.x=e.x,this.positionDelta.z=e.y,this.positionDelta.y=0,this.nextPosition.copy(t.fovCorrectedPosition()).add(this.positionDelta),this.currentPose.position.copy(this.nextPosition),this.currentPose.applyPhiBasedFovSquish();this.checkBounds&&this.cameraCheck(this.currentPose)&&this.poseController.updateCameraPose(this.currentPose)}orbit(e,t=!1){if(!this.poseController)return;this.setupCurrentPose();const i=this.cameraPoseProxy.pose,s=i.phi(),o=(0,y.uZ)(e.y,this.currentPhiLowerLimit-s,this.currentPhiUpperLimit-s),n=this.mouseOrbit?this.orbitDistance:i.fovCorrectedFocalDistance();this.aimTarget.copy(r.f.FORWARD).applyQuaternion(i.rotation),this.aimTarget.setLength(n),this.aimTarget.addVectors(i.fovCorrectedPosition(),this.aimTarget),this.tempAxis.copy(r.f.RIGHT),this.tempOrientation.setFromAxisAngle(this.tempAxis.applyQuaternion(i.rotation),-o),this.nextPosition.copy(i.fovCorrectedPosition()).sub(this.aimTarget).applyQuaternion(this.tempOrientation),this.nextOrientation.copy(i.rotation).premultiply(this.tempOrientation),this.tempOrientation.setFromAxisAngle(r.f.UP,e.x),this.nextPosition.applyQuaternion(this.tempOrientation),this.nextOrientation.premultiply(this.tempOrientation),this.nextPosition=this.nextPosition.add(this.aimTarget),this.nextOrientation.normalize(),this.currentPose.position.copy(this.nextPosition),this.currentPose.rotation.copy(this.nextOrientation),this.currentPose.focalDistance=n,this.currentPose.applyPhiBasedFovSquish();return Math.abs(n-F)<.01||!this.checkBounds||this.cameraCheck(this.currentPose)?t?this.poseController.moveTo({transitionType:C.n.Interpolate,pose:{position:this.currentPose.position.clone(),rotation:this.currentPose.rotation.clone()},transitionTime:500}).nativePromise():void this.poseController.updateCameraPose(this.currentPose):void 0}zoom(e){if(!this.poseController)return;this.setupCurrentPose();const t=this.cameraPoseProxy.pose;this.focusPlane.setFromNormalAndCoplanarPoint(r.f.UP,t.focalPoint());const i=this.maxZoomDistance-F,s=t.fovCorrectedFocalDistance(),o=(0,y.uZ)(e*i+s,F,this.maxZoomDistance)-s,n=this.zoomDir.clone().setLength(-o);this.nextPosition.copy(t.fovCorrectedPosition()).add(n);const a=r.f.FORWARD.clone().applyQuaternion(t.rotation),h=new v.Ray(this.nextPosition,a),l=new v.Vector3;h.intersectPlane(this.focusPlane,l)&&(this.currentPose.position.copy(this.nextPosition),this.currentPose.focalDistance=l.distanceTo(this.nextPosition),this.currentPose.resetProjMatrix(),this.currentPose.applyPhiBasedFovSquish(),this.checkBounds&&this.cameraCheck(this.currentPose)&&this.poseController.updateCameraPose(this.currentPose))}setupCurrentPose(){const e=this.cameraPoseProxy.pose;this.currentPose.copy(e),this.currentPose.unapplyPhiBasedFovSquish()}}class V{constructor(e,t,i){this.poseProxy=e,this.cameraCheck=t,this.raycaster=i,this.movingCamera=!1,this.smoothedTouch0=new v.Vector2,this.smoothedTouch1=new v.Vector2,this.origTouchAxis=new v.Vector2,this.origCenterPt=new v.Vector2,this.plane=new v.Plane(r.f.UP.clone(),0),this.originalPinchLength=0,this.pointersMoved=(()=>{const e=new v.Vector2,t=new v.Vector3,i=new v.Vector3,s=new v.Vector2,o=new v.Vector3,n=new R.B(1);return a=>{if(!this.poseController)return;n.copy(this.poseProxy.pose);this.smoothedTouch0.lerp(a[0].position,.2),this.smoothedTouch1.lerp(a[1].position,.2),s.copy(this.smoothedTouch1).sub(this.smoothedTouch0).normalize();const h=this.origTouchAxis.angle()-s.angle();t.copy(this.initialPose.fovCorrectedPosition());const l=new v.Vector3(-this.intersectionPt.x,0,-this.intersectionPt.z);t.add(l),t.applyAxisAngle(r.f.UP,h),l.negate(),t.add(l);const d=(new v.Quaternion).copy(this.initialPose.rotation),c=(new v.Quaternion).setFromAxisAngle(r.f.UP,h);d.premultiply(c);const u=this.smoothedTouch0.clone().lerp(this.smoothedTouch1,.5),m=new v.Vector3;if(i.copy(r.f.FORWARD).applyQuaternion(d),this.castFrom(u.x,i.y<-.01?u.y:this.origCenterPt.y,m),isNaN(m.x))return void(this.movingCamera=!1);m.x-=this.intersectionPt.x,m.z-=this.intersectionPt.z,m.negate(),m.applyAxisAngle(r.f.UP,h);const p=1-1/(e.subVectors(this.smoothedTouch0,this.smoothedTouch1).length()/this.originalPinchLength),g=t.add(m).lerp(this.intersectionPt,p).clone(),f=o.subVectors(g,this.intersectionPt).length();n.position.copy(g),n.rotation.copy(d),n.focalDistance=f,n.resetProjMatrix(),n.applyPhiBasedFovSquish(),this.cameraCheck(n)&&this.poseController&&this.poseController.updateCameraPose(n)}})(),this.initMove=(()=>{const e=new v.Vector2,t=new v.Ray,i=new v.Vector3;return s=>{const o=s[0].position,n=s[1].position;this.smoothedTouch0.copy(o),this.smoothedTouch1.copy(n),this.originalPinchLength=e.subVectors(o,n).length(),this.origTouchAxis.copy(n).sub(o).normalize(),this.origCenterPt.copy(o).lerp(n,.5);const{pose:a}=this.poseProxy;this.initialPose=a.clone();const h=new v.Vector3,l=new v.Vector3;(0,A.Kh)(this.initialPose,h.set(this.origCenterPt.x,this.origCenterPt.y,-1),h),(0,A.Kh)(this.initialPose,l.set(this.origCenterPt.x,this.origCenterPt.y,1),l),l.sub(h).normalize();const d=this.raycaster.picking.pick(h,l);d||(t.set(h,l),t.at(a.fovCorrectedFocalDistance(),i)),this.intersectionPt=d?d.point:i,this.plane.set(r.f.UP.clone(),0),this.plane.translate(new v.Vector3(0,this.intersectionPt.y,0))}})(),this.castFrom=(()=>{const e=new v.Ray,t=new v.Vector3,i=new v.Vector3;return(s,o,r)=>{(0,A.Kh)(this.initialPose,t.set(s,o,-1),t),(0,A.Kh)(this.initialPose,i.set(s,o,1),i),i.sub(t).normalize(),e.set(t,i),e.intersectPlane(this.plane,r)&&!r.equals(t)||(r.x=NaN),r.y=0}})()}rawPointerUpdate(e){const t=this.movingCamera;this.movingCamera=2===e.pointers.length&&!!this.poseController,this.movingCamera&&(t?this.pointersMoved(e.pointers):this.initMove(e.pointers))}onAccessGranted(e){this.poseController=e}onAccessRevoked(e){this.poseController=void 0,this.movingCamera=!1}}var L=i(19663);class N extends L.m{constructor(e){super(),this.payload=e,this.id="DOLLHOUSE_VERTICAL_LIMITS"}}var z,U=i(79727);!function(e){e[e.NONE=c.r.NONE]="NONE",e[e.ROTATE=c.r.PRIMARY]="ROTATE",e[e.PAN=c.r.SECONDARY]="PAN",e[e.ZOOM=c.r.MIDDLE]="ZOOM"}(z||(z={}));class G extends s.Y{constructor(){super(...arguments),this.name="dollhouse-controls",this.controlState=z.NONE,this.movementKeys=new v.Vector2,this.adjustedBounds=new v.Box3,this.didDrag=!1,this.resetControlState=()=>{this.controlState=z.NONE},this.convertDeltaToLocal=(()=>{const e=new v.Vector3,t=new v.Vector3;return i=>{const s=i.x||0,o=i.y||0,n=this.cameraPoseProxy.pose.phi()>(0,f.Id)(85)?r.f.UP:r.f.FORWARD,a=2*s*this.cameraPoseProxy.pose.fovCorrectedFocalDistance(),h=2*o*this.cameraPoseProxy.pose.fovCorrectedFocalDistance()/this.cameraPoseProxy.pose.aspect();return e.copy(r.f.RIGHT).applyQuaternion(this.cameraPoseProxy.pose.rotation).setY(0).setLength(a),t.copy(n).applyQuaternion(this.cameraPoseProxy.pose.rotation),e.add(t.setY(0).setLength(h)),e}})(),this.cameraCheck=(()=>{function e(e){return e.x>=1||e.x<=-1||e.y>=1||e.y<=-1||e.z<=-1||e.z>=1}const t=[];for(let e=0;e<8;e++)t.push(new v.Vector3);const i=new v.Matrix4,s=new v.Matrix4,o=new v.Box3;return n=>{const{focalDistance:a,projection:h,position:l,rotation:d}=n;if(a<F)return!1;if(!(0,w.cb)(l,d,h,this.adjustedBounds))return!1;(0,w.jB)(this.meshData.extendedBounds,t),i.compose(l,d,r.f.UNIT),i.invert(),s.copy(this.cameraPoseProxy.pose.projection.asThreeMatrix4()),o.makeEmpty();let c=!1;for(let e=0;e<8;e++)t[e].applyMatrix4(i),t[e].z=(0,y.uZ)(t[e].z,-T.oR.far,-T.oR.near),t[e].applyMatrix4(s),o.expandByPoint(t[e]);c=e(o.min)||e(o.max),o.min.clampScalar(-1,1),o.max.clampScalar(-1,1);return(o.max.x-o.min.x)*(o.max.y-o.min.y)>(c?.05:.01)}})()}async init(e,t){[this.viewmodeData,this.floorsViewData,this.meshData,this.commonControlsModule,this.inputIni,this.raycaster]=await Promise.all([t.market.waitForData(m.O),t.market.waitForData(U.c),t.market.waitForData(x._),t.getModuleBySymbol(o.y.CONTROLS_COMMON),t.getModuleBySymbol(o.y.INPUT),t.getModuleBySymbol(o.y.RAYCASTER)]),this.cameraPoseProxy=this.commonControlsModule.cameraPoseProxy,this.controls=new _(this.cameraPoseProxy,this.cameraCheck,this.meshData.extendedBounds,!0),this.bindings.push(t.subscribe(u.Z,(e=>{this.controls.stop(),this.resetControlState()})),t.commandBinder.addBinding(N,(async e=>this.controls.setPhiLimits(void 0!==e.phiLowerLimitDegrees?e.phiLowerLimitDegrees*f.Ue:O,void 0!==e.phiUpperLimitDegrees?e.phiUpperLimitDegrees*f.Ue:k,void 0!==e.noTransition?!e.noTransition:this.validateViewmode()))));const i=this.inputIni;this.setupBounds(),this.commonControlsModule.addControls(p.Ey.Dollhouse,this.controls);const s=await t.getModuleBySymbol(o.y.RAYCASTER);this.cameraTouchControls=new V(this.cameraPoseProxy,this.cameraCheck,s),this.commonControlsModule.register(this.cameraTouchControls),this.bindings.push(i.registerHandler(n.a,(e=>{this.validateViewmode()&&this.onScrollWheel(e)}))),this.bindings.push(i.registerHandler(a.E0,(e=>{this.validateViewmode()&&(this.didDrag=!1,this.onDragBegin(e.buttons,e.position))}))),this.bindings.push(i.registerHandler(a._R,(e=>{this.validateViewmode()&&(e.timeSinceLastMove<100&&this.didDrag&&(this.onDrag(e.delta,e.position),this.controls.update(P),this.controls.stopAcceleration()),this.onDragEnd(e.delta,e.buttons,e.position))}))),this.bindings.push(i.registerHandler(a._t,(e=>{this.validateViewmode()&&(this.didDrag=!0,this.onDrag(e.delta,e.position),this.controls.update(P),this.controls.stop())}))),this.bindings.push(i.registerHandler(M.h,(e=>{this.validateViewmode()&&this.cameraTouchControls.rawPointerUpdate(e)}))),this.bindings.push(i.registerHandler(h.e,(e=>{this.validateViewmode()&&e.state!==d.M.PRESSED&&this.onKey(e.key,e.state)})))}onUpdate(e){this.validateViewmode()&&this.controls.update(e)}onScrollWheel(e){if(0!==e.delta.y){const t=1/this.cameraPoseProxy.pose.fovCorrectedFocalDistance()*2,i=this.modelSize,{point:s,type:o}=this.computeFocusPoint(),r=s.clone().sub(this.cameraPoseProxy.pose.fovCorrectedPosition()).normalize(),n=this.cameraPoseProxy.pose.phi()>E&&r.y<0&&"focus"!==o?r:this.cameraPoseProxy.pose.forward();this.controls.setZoomAcceleration(.1*e.delta.y/(t*i*500)),this.controls.setZoomDirection(n),this.controls.update(P),this.controls.setZoomAcceleration(0)}}onDragBegin(e,t){if(this.controlState===z.NONE){const t=e;this.controlState=t}switch(this.controls.setPanAcceleration({x:0,y:0}),this.controls.stop(),this.controls.setNdcPos(t),this.controlState){case z.ROTATE:this.controls.setOrbitPoint(this.computeOrbitPoint());break;case z.PAN:this.controls.setGrabPoint(this.computeFocusPoint().point)}}onDrag(e,t){switch(this.controls.setNdcPos(t),this.controlState){case z.ROTATE:this.controls.setOrbitalAcceleration({x:-Math.PI*e.x,y:-Math.PI*e.y});break;case z.ZOOM:0!==e.y&&this.controls.setZoomAcceleration(-e.y)}}onDragEnd(e,t,i){t&this.controlState||(this.controlState=z.NONE,(0,g.tq)()&&this.controls.stop(),this.controls.unsetGrabPoint(),this.controls.unsetOrbitPoint(),this.controls.setNdcPos(i))}onKey(e,t){const i=t===d.M.DOWN;let s=!1;switch(e){case l.R.LEFTARROW:case l.R.J:this.controls.setOrbitalAcceleration({x:i?B:0},!0);break;case l.R.RIGHTARROW:case l.R.L:this.controls.setOrbitalAcceleration({x:i?-B:0},!0);break;case l.R.UPARROW:case l.R.I:this.controls.setOrbitalAcceleration({y:i?-B:0},!0);break;case l.R.DOWNARROW:case l.R.K:this.controls.setOrbitalAcceleration({y:i?B:0},!0);break;case l.R.W:this.movementKeys.y=i?1:0,s=!0;break;case l.R.S:this.movementKeys.y=i?-1:0,s=!0;break;case l.R.D:this.movementKeys.x=i?1:0,s=!0;break;case l.R.A:this.movementKeys.x=i?-1:0,s=!0}if(s){const e=this.convertDeltaToLocal(this.movementKeys).setLength(.02);this.controls.setPanAcceleration({x:e.x,y:e.z})}}validateViewmode(){return this.viewmodeData.currentMode===p.Ey.Dollhouse}computeFocusPoint(){const e=this.inputIni.getCurrentPointerRay(),t=this.raycaster.picking.pick(e.origin,e.direction);if(t)return{point:t.point.clone(),type:"mesh"};{const t=this.floorsViewData.getFloorMinPlane(),i=new v.Vector3,s=e.intersectPlane(t,i),o=i.distanceTo(this.cameraPoseProxy.pose.position),r=this.cameraPoseProxy.pose.fovCorrectedFocalDistance();if(s&&o<1.5*r)return{point:i,type:"ground"};{const t=this.cameraPoseProxy.pose.fovCorrectedFocalDistance(),i=new v.Vector3;return e.at(t,i),{point:i,type:"focus"}}}}computeOrbitPoint(){const e=this.cameraPoseProxy.pose,t=new v.Ray(e.position.clone(),e.forward().clone()),i=()=>{const e=this.floorsViewData.getFloorMinPlane(),i=new v.Vector3;if(!t.intersectPlane(e,i)){const e=new v.Vector3;this.floorsViewData.getFloorCentroid(e),t.closestPointToPoint(e,i),t.origin.distanceTo(i)<F&&t.at(F,i)}return i};if(e.autoOrtho)return i();{const e=this.raycaster.picking.pick(t.origin,t.direction);return e?e.point.clone():i()}}setupBounds(){function e(e,t){return Math.sign(e+t)===Math.sign(e)?e+t:0}this.modelSize=Math.max(this.meshData.extendedSize.length(),1),this.adjustedBounds.copy(this.meshData.extendedBounds);const t=-2;this.adjustedBounds.min.x=e(this.adjustedBounds.min.x,t),this.adjustedBounds.min.y=e(this.adjustedBounds.min.y,t),this.adjustedBounds.min.z=e(this.adjustedBounds.min.z,t),this.adjustedBounds.max.x=e(this.adjustedBounds.max.x,2),this.adjustedBounds.max.y=e(this.adjustedBounds.max.y,2),this.adjustedBounds.max.z=e(this.adjustedBounds.max.z,2);const i=new v.Vector3;this.adjustedBounds.getSize(i),this.adjustedBounds.setFromCenterAndSize(this.meshData.meshCenter,i)}}},88675:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>w});var s=i(81396),o=i(90304),r=i(41602),n=i(21646),a=i(44649);class h extends a.B{constructor(e,t,i,s,o=!1){super(e,t,i,s,o),this.cameraPoseProxy=e,this.angularAccel=0,this.angularVelocity=0,this.transition.angularVelocity=0}setRollAcceleration(e,t=!1){this.transition.active||(t&&e&&this.angularVelocity&&Math.sign(e)!==Math.sign(this.angularVelocity)&&(this.angularVelocity=0),this.angularAccel=e)}startRotateTransition(e,t,i){return this.startTransition(e,t.x*r.SI,new s.Vector2,0,i).nativePromise()}startTransition(e,t,i,s,o){return this.transition.angularVelocity=t,this.angularVelocity=t,this.angularAccel=0,super.startTransition(e,t,i,s,o)}update(e){super.update(e);(Math.abs(this.angularAccel)>n.Z.epsilon||Math.abs(this.angularVelocity)>n.Z.epsilon)&&(this.transition.active?this.updateAngularTransition(e):this.updateAngularDefault(e))}stopMomentum(){super.stopMomentum(),this.transition.active||(this.angularVelocity=0)}stopAcceleration(){super.stopAcceleration(),this.transition.active||this.setRollAcceleration(0)}updateAngularTransition(e){const t=this.getTransitionScale(e);this.angularVelocity=this.transition.angularVelocity*t,this.roll(this.angularVelocity)}updateAngularDefault(e){const t=e/r.SI;this.angularVelocity=this.angularVelocity+this.angularAccel*t,this.roll(this.angularVelocity),this.angularVelocity*=Math.pow(1-r.O8,t)}roll(e){var t;const i=this.cameraPoseProxy.pose;this.currentOrientation.setFromAxisAngle(o.f.FORWARD,e),this.currentOrientation.multiplyQuaternions(i.rotation,this.currentOrientation),this.currentOrientation.normalize(),this.checkBounds&&!this.insideBounds(i.position,this.currentOrientation,i.projection)||i.rotation.equals(this.currentOrientation)||null===(t=this.poseController)||void 0===t||t.updateCameraRotation(this.currentOrientation)}}var l=i(66445),d=i(10082),c=i(69170),u=i(32597),m=i(6667),p=i(95882),g=i(16782);const f=Math.PI/2/1e3;var y;!function(e){e[e.NONE=g.r.NONE]="NONE",e[e.PAN=g.r.PRIMARY]="PAN",e[e.ROTATE=g.r.SECONDARY]="ROTATE",e[e.ZOOM=g.r.MIDDLE]="ZOOM"}(y||(y={}));class w extends l.default{constructor(){super(...arguments),this.name="floorplan-controls"}async init(e,t){await super.init(e,t),t.getModuleBySymbol(c.y.INPUT).then((e=>{this.bindings.push(e.registerHandler(d.D,(e=>{this.validateViewmode()&&(this.controls.setRollAcceleration(e.rotateDelta),this.controls.update(r.SI),this.controls.stop())})),e.registerHandler(d.u,this.resetControlState))}))}createCameraControls(e,t){const i=this.commonControlsModule.cameraPoseProxy,s=t.defaultZoom.bind(t);this.controls=new h(i,s,e.extendedBounds,e.meshCenter,!0),this.commonControlsModule.addControls(p.Ey.Floorplan,this.controls)}onDrag(e){switch(super.onDrag(e),this.controlState){case y.ROTATE:this.controls.setRollAcceleration(e.x*Math.PI)}}onKey(e){super.onKey(e);const{key:t,state:i,modifiers:s}=e,o=i===m.M.DOWN;switch(t){case u.R.J:case u.R.LEFTARROW:this.controls.setRollAcceleration(o?f:0,!0);break;case u.R.L:case u.R.RIGHTARROW:this.controls.setRollAcceleration(o?-f:0,!0);break;case u.R.DOWNARROW:s.shiftKey||this.controls.setZoomAcceleration(o?r.Gu:0);break;case u.R.UPARROW:s.shiftKey||this.controls.setZoomAcceleration(o?-r.Gu:0)}}validateViewmode(){return this.viewmodeData.currentMode===p.Ey.Floorplan}}},45717:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>P});var s=i(97542),o=i(69170),r=i(2541),n=i(71954),a=i(64567),h=i(76957),l=i(79728),d=i(635),c=i(90632),u=i(8699),m=i(17788),p=i(97998),g=i(81396);class f{constructor(){this.list=[]}insort(e){const t=this.binarySearch(e);let i=t.index;if(!t.success)for(;this.compare(e,this.list[i])>=0&&i<this.list.length;)i++;for(let e=this.list.length;e>i;e--)this.list[e]=this.list[e-1];this.list[i]=e}removeIndex(e){if(e>this.list.length)throw Error("OrderList.removeIndex() -> Invalid index: "+e);this.list.splice(e,1)}getElement(e){if(e>=0&&e<this.list.length)return this.list[e];throw new Error("OrderList.getElement() -> Invalid index: "+e)}get length(){return this.list.length}find(e){const t=this.binarySearch(e);return t.success?t.index:-1}compare(e,t){return void 0===t?1:"number"==typeof e?e===t?0:e<t?-1:1:e.compare(t)}binarySearch(e){let t,i=0,s=this.list.length-1,o=-1,r=0;for(;i<=s;){if(o=Math.floor((i+s)/2),t=this.list[o],r=this.compare(e,t),0===r)return{success:!0,index:o};r<0?s=o-1:i=o+1}return{success:!1,index:o}}}var y=i(37262),w=i(75287),v=i(90304);class T extends w.T{constructor(e={}){super(),this.name="",this.center=new g.Vector3,this.boundingBox=new g.Box3,this.size=new g.Vector3,this.sweepHeights=new f,this.sweepFloorHeights=new f,this._groundPlane=new g.Plane,this._groundPt=new g.Vector3,this.medianSweepHeight=()=>this.sweepHeights.length>0?this.sweepHeights.getElement(Math.floor(this.sweepHeights.length/2)):this.center.y,this.minSweepFloorHeight=()=>this.sweepFloorHeights.length>0?this.sweepFloorHeights.getElement(0):this.boundingBox.min.y,Object.assign(this,e)}setBounds(e){this.boundingBox.copy(e),this.boundingBox.getSize(this.size),this.boundingBox.getCenter(this.center)}addSweep(e,t){this.sweepHeights.insort(e.y),this.sweepFloorHeights.insort(t.y)}get bottom(){return this.minSweepFloorHeight()}get groundPlane(){return this._groundPt.set(0,this.bottom,0),this._groundPlane.setFromNormalAndCoplanarPoint(v.f.UP,this._groundPt),this._groundPlane}get top(){return this.sweepFloorHeights.length>0?this.sweepFloorHeights.getElement(this.sweepFloorHeights.length-1):this.boundingBox.max.y}deepCopy(){return(0,y.p$)({id:this.id,meshGroup:this.meshGroup,index:this.index,name:this.name,center:this.center,boundingBox:this.boundingBox,size:this.size,medianSweepHeight:this.medianSweepHeight(),bottom:this.bottom})}}const M=new p.Z("mds-floor-deserializer");class x{deserialize(e){if(!e||!this.validate(e))return M.debug("Deserialized invalid floor data from MDS",e),null;const t=e.label||"",i=e.dimensions||{areaFloor:-1},{areaFloor:s}=i;return new T({id:e.id,index:e.sequence,meshGroup:e.meshId,name:t,areaFloor:s||-1})}validate(e){return["id","sequence","meshId"].every((t=>t in e))}}class b{serialize(e){return{label:e.name}}}class D extends m.u{constructor(){super(...arguments),this.deserializer=new x,this.prefetchKey="data.model.floors"}async read(e={}){const t={modelId:this.getViewId()};return this.query(u.GetFloors,t,e).then((e=>{var t,i;const s=null===(i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.model)||void 0===i?void 0:i.floors;if(!s||!Array.isArray(s))return null;return s.reduce(((e,t)=>{const i=this.deserializer.deserialize(t);return i&&(e[t.id]=i),e}),{})}))}async update(e,t){const i=this.getViewId(),s=(new b).serialize(t);if(!s)throw new Error("Could not update Floor");return this.mutate(u.PatchFloor,{modelId:i,floorId:e,data:s})}}var S=i(67238),C=i(80742);class P extends s.Y{constructor(){super(...arguments),this.name="floors"}async init(e,t){const{readonly:i,baseUrl:s,baseModelId:n}=e;this.engine=t;const{mdsContext:u}=await t.market.waitForData(C.R);this.store=new D({context:u,readonly:i,baseUrl:s,viewId:n});const[m]=await Promise.all([this.store.read()]);if(this.data=new h.i(m||{}),t.market.register(this,h.i,this.data),!1===i){const e=this.data.getCollection();this.monitor=new a.c(e,{aggregationType:r.E.NextFrame,shallow:!0},t),this.monitor.onChanged((()=>this.engine.commandBinder.issueCommand(new d.VQ({dataTypes:[l.g.FLOORS]}))));const[i]=await Promise.all([t.getModuleBySymbol(o.y.STORAGE)]);this.bindings.push(i.onSave((()=>this.save()),{dataType:l.g.FLOORS}));const s=await t.market.waitForData(c.Q);s.setRevertableType(l.g.FLOORS),s.setPublishableType(l.g.FLOORS)}}onUpdate(){}async save(){const e=this.monitor.getDiffRecord();this.monitor.clearDiffRecord();const t=[];for(const i of e){const e=i.index;if(!e)throw new S.H(`Invalid floor '${i.index}'`);i.action===n.KI.updated&&t.push(this.store.update(e,i.diff))}return Promise.all(t)}}},62226:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>se});var s=i(97542),o=i(69170),r=i(89553),n=i(23612),a=i(32597),h=i(6667),l=i(53954),d=i(23254),c=i(9037),u=i(76532),m=i(69739),p=i(66563),g=i(5090),f=i(85992),y=i(95882),w=i(2473),v=i(54244),T=i(10374),M=i(76957),x=i(49827),b=i(93411),D=i(53203);class S{constructor(e,t,i,s,o,r,n){this.getAngleModifier=e,this.floorsViewData=t,this.meshQuery=i,this.viewmodeData=s,this.raycasterData=o,this.meshData=r,this.touchDevice=n}activate(){}init(){}dispose(){}deactivate(){const{floorOpacity:e}=this.meshData.meshGroupVisuals;for(const t of this.meshData.meshGroups.floors.keys())e.set(t,0)}beforeRender(){const e=this.floorsViewData.nearestFloor,t=this.floorsViewData.transition.progress.active,i=!(!e||this.viewmodeData.isInside()),s=D.xx.FADE_OPAQUE;let o=s,r=s;const n=this.getAngleModifier(),a=this.floorsViewData.onlyShowActiveFloor.value?0:1;i&&(this.floorsViewData.floorSelectModeEnabled&&(this.viewmodeData.isDollhouse()||this.viewmodeData.isOrthographic())?(o=s*n*a*D.xx.FADE_IN_VALUE,r=o*D.xx.FADE_BELOW_MULT+D.xx.FADE_BELOW_START):(o=D.xx.FADE_ABOVE,r=D.xx.FADE_BELOW));const{floorOpacity:h}=this.meshData.meshGroupVisuals;for(const e of this.meshData.meshGroups.floors.keys()){const i=this.floorsViewData.floors.getFloorByMeshGroup(e);let n=s;const a=this.isBelowSelectedFloor(i)?r:o;let l=(0,x.uZ)(a+D.xx.FADE_IN_HOVER_BOOST_VALUE,0,1);this.floorsViewData.roomSelectModeActive&&(l=a),n=this.isHoveredFloor(null==i?void 0:i.id)&&!t&&a>0?l:a,n=this.isFloorTransitioningOut(i)?a:n;const d=this.isSelectedFloor(null==i?void 0:i.id)||this.isFloorTransitioningIn(i);if(n=d?s:n,n=this.clampForViewmodeTransitions(n),d)h.set(e,n);else{const t=h.get(e);if(void 0===t)h.set(e,n);else if(t!==n){let i=(0,b.t)(t,n,.2);Math.abs(n-i)<1e-4&&(i=n),h.set(e,i)}}}}render(){}clampForViewmodeTransitions(e){if(this.viewmodeData.currentMode===y.Ey.Transition){const{to:t}=this.viewmodeData.transition;if(t===y.Ey.Panorama)return Math.max(1-this.meshData.meshTextureOpacity.value,e)}return e}isHoveredFloor(e){if(void 0!==e&&this.raycasterData.hit&&(this.viewmodeData.isDollhouse()||this.viewmodeData.isOrthographic())&&!this.touchDevice&&this.floorsViewData.isNavigable(e)){const t=this.raycasterData.hit.object;return e===this.meshQuery.floorIdFromObject(t)}return!1}isSelectedFloor(e){const t=this.floorsViewData.nearestFloor;return!t||!(!e||t.id!==e)}isBelowSelectedFloor(e){const t=this.floorsViewData.nearestFloor;return!!(e&&t&&t.index>e.index)}isFloorTransitioningIn(e){return!(!e||!this.floorsViewData.transition.progress.active||this.floorsViewData.transition.to&&this.floorsViewData.transition.to!==e.id)}isFloorTransitioningOut(e){return!(!e||!this.floorsViewData.transition.progress.active||this.floorsViewData.transition.from&&this.floorsViewData.transition.from!==e.id&&this.floorsViewData.transition.to===e.id)}}var C=i(46950),P=i(56159),k=i(26256),O=i(64918),E=i(12039),F=i(81396),B=i(90304),R=i(67944),A=i(98169),I=i(81248),_=i(67238),V=i(35826),L=i(52498);class N{constructor(e,t,i,s,o,r,n,a,h){this.engine=e,this.floorsData=t,this.floorsViewData=i,this.sweepData=s,this.cameraData=o,this.cameraModule=r,this.viewmodeData=n,this.updateCurrentFloor=a,this.meshData=h,this.MOVE_TO_BLACK_TRANSITION_TIME=2e3,this.moveFloorUp=(e=!1,t)=>{const i=this.floorsViewData.currentFloorId,s=this.floorsViewData.getNavigableFloorIds(),o=i?s.indexOf(i):-1;let r=s[o+1];return void 0===r&&(r=this.viewmodeData.isInside()?s[s.length-1]:s[0]),this.moveToFloor(r,e,t)},this.moveFloorDown=(e=!1,t)=>{const i=this.floorsViewData.currentFloorId,s=this.floorsViewData.getNavigableFloorIds(),o=i?s.indexOf(i):s.length;let r=s[o-1];return void 0===r&&(r=this.viewmodeData.isInside()?s[0]:s[s.length-1]),this.moveToFloor(r,e,t)},this.moveToFloor=(e,t=!1,i,s)=>{const o=this.floorsViewData.currentFloorId,r=o===e,n=this.floorsViewData.totalFloors<2&&!e,a=e?this.floorsViewData.floors.getFloor(e):null;if(r||n||!this.floorsViewData.floorsEnabled)return this.updateCurrentFloor(e),C.Q.resolve();if(a&&!this.canMoveToFloor(a,t))return C.Q.reject(new _.H("Invalid floor ID"));this.engine.broadcast(new P.S(o,e)),void 0===i&&(i=L.cw);const h=new C.Q;let l;this.floorsViewData.transitionToFloor(o,e,i,h.nativePromise()),this.floorsViewData.commit();let d,c=s;if(this.viewmodeData.isInside()){const t=e=>e=>this.floorsViewData.isCurrentOrAllFloors(e.floorId),i=!!e?A.nK:t,o=[(0,A._T)(),(0,A._k)(),i(e)],r=[(0,I.l0)(s||this.cameraData.pose.position)],n=this.sweepData.sortByScore(o,r).shift();n&&(c=n.sweep.position,l=n.sweep.id)}else null!==e&&this.engine.commandBinder.issueCommand(new V.aK);d=t?Promise.resolve():this.getCameraTransition(e,i,l,c);const u=this,m=C.Q.all([h,d]);return this.engine.startGenerator((function*(){let e=Date.now();for(;u.floorsViewData.transition.progress.active;){yield new k.Jj;const t=Date.now(),i=t-e;u.floorsViewData.transition.progress.tick(i),u.floorsViewData.commit(),e=t}u.updateCurrentFloor(u.floorsViewData.transition.to),h.resolve()})),m}}moveToFloorIndex(e,t=!1,i,s){let o=null;if(e!==L.qE){const t=this.floorsViewData.floors.getFloorAtIndex(e);if(!t)return C.Q.reject(new _.H(`Invalid floor index ${e}`));o=t.id}return this.moveToFloor(o,t,i,s)}canMoveToFloor(e,t=!1){if(!e)return!1;const i=this.floorsViewData.transition.progress.active,s=this.cameraData.canTransition()||t,o=e.index<=this.floorsViewData.totalFloors-1,r=e.index>=-1;return!i&&s&&o&&r}getCameraTransition(e,t,i,s){if(this.viewmodeData.currentMode===y.Ey.Dollhouse||this.viewmodeData.currentMode===y.Ey.Floorplan){const i=this.getPoseForFloor(e,s);return this.cameraModule.moveTo({transitionType:O.n.Interpolate,pose:i.pose,focalDistance:i.focalDistance,transitionTime:t,autoOrtho:this.cameraData.pose.autoOrtho}).nativePromise()}return this.viewmodeData.isInside()&&i?this.engine.commandBinder.issueCommand(new E.ju({transition:O.n.MoveToBlack,sweep:i,transitionTime:this.MOVE_TO_BLACK_TRANSITION_TIME})):Promise.resolve()}getPoseForFloor(e,t){const i=this.cameraData.pose.fovCorrectedPosition(),s=this.cameraData.pose.rotation,o=e?this.floorsData.getFloor(e):null,r=o?o.medianSweepHeight():this.meshData.meshCenter.y,n=o?o.center:this.meshData.meshCenter;n.setY(r);const a=B.f.FORWARD.clone().applyQuaternion(s),h=i.clone();let l,d;if(t){const e=i.clone().addScaledVector(a,this.cameraData.pose.fovCorrectedFocalDistance()),s=(new F.Vector3).set(0,i.y,0),o=(new F.Vector3).set(0,e.y,0),n=s.distanceTo(o);h.setY(r+n);const c=e.clone().setY(t.y);d=c.distanceTo(h),this.viewmodeData.isDollhouse()&&(l=(0,R.n0)(h,c))}else{const e=(o?o.size.y:z)/2+z*-a.y;h.setY(r+e),d=h.distanceTo(n)}return{focalDistance:d,pose:{position:h,rotation:l}}}}const z=8;var U=i(79727),G=i(33324),j=i(23885),H=i(2569),Q=i(69505);class W{constructor(e,t,i){this.floorsViewData=e,this.viewmodeData=t,this.pose=i,this.vectors={lookDir:new F.Vector3,flattenedLookDir:new F.Vector3},this.getAngleModifier=this.getAngleModifier.bind(this)}update(){const e=this.getAngleModifier(),t=1===this.floorsViewData.totalFloors,i=!!this.floorsViewData.nearestFloor,s=!this.viewmodeData.isInside()&&!this.viewmodeData.transitionActive();this.floorsViewData.roomSelectModeActive=s&&(t||i&&e<1||this.viewmodeData.isFloorplan()),this.floorsViewData.floorSelectModeActive=s&&1===e&&!t,this.floorsViewData.showFloorSelection=!this.viewmodeData.transitionActive()&&(this.viewmodeData.isDollhouse()||this.viewmodeData.isFloorplan())&&i&&!t,this.floorsViewData.floorSelectable=this.floorsViewData.floorSelectModeEnabled&&(this.viewmodeData.isDollhouse()||this.viewmodeData.isOrthographic())}getAngleModifier(){const e=this.vectors.lookDir.copy(B.f.FORWARD).applyQuaternion(this.pose.rotation),t=this.vectors.flattenedLookDir.copy(e).setY(0),i=e.angleTo(t)*Q.MN,s=D.xx.FADE_IN_START_ANGLE,o=D.xx.FADE_IN_END_ANGLE,r=1-(0,H.dS)(i,s,o,0,1);return(0,j.FG)(r,0,1,1)}}var Z=i(31362),q=i(89570),$=i(72996),Y=i(26269),K=i(38987),J=i(34956),X=i(34029),ee=i(39642),te=i(10699),ie=i(59625);class se extends s.Y{constructor(){super(),this.name="floors-viewdata",this.onEndMoveToSweepMessage=e=>{const t=this.sweepData.getSweep(e.toSweep);t&&this.updateCurrentFloor(t.floorId)},this.onMoveToFloorIndexCommand=async e=>this.floorNavigation.moveToFloorIndex(e.floorIndex,e.suppressCameraMovement,e.transitionTime,e.focusPoint),this.onShowAllFloorsCommand=async e=>{const t="boolean"==typeof e.moveCamera&&!e.moveCamera;await this.engine.commandBinder.issueCommand(new G.Vw(null,t))},this.onEnableAllFloorsOptionCommand=async()=>{this.floorsViewData.showAllFloorsOption=!0,this.floorsViewData.commit()},this.onDisableAllFloorsOptionCommand=async()=>{this.floorsViewData.currentFloorIndex===L.qE&&await this.floorNavigation.moveToFloorIndex(0,!0),this.floorsViewData.showAllFloorsOption=!1,this.floorsViewData.commit()},this.applicationChanged=()=>{this.floorsViewData.updateViewData()},this.updateCurrentFloor=e=>{this.config.allowFloorChanges&&this.floorsViewData.currentFloorId!==e&&(this.floorsViewData.transitionToFloorInstant(e),this.engine.broadcast(new m.P(e,this.floorsViewData.getFloorName(e))))},this.updateFloorSelectMode=()=>{var e;null===(e=this.floorsSelectModeHelper)||void 0===e||e.update()},this.floorSelectFeatureEnabledCheck=()=>{const e=this.settingsData.tryGetProperty(ee.w,!0),t=this.settingsData.tryGetProperty(ie.gx.FloorSelect,!0),i=this.applicationData.application===v.Mx.WORKSHOP;this.toggleFloors(i||e&&t)},this.onMoveToFloorCommand=this.onMoveToFloorCommand.bind(this)}async init(e,t){var i,s,r;this.engine=t,this.config=e,[this.floorsData,this.settingsData,this.applicationData,this.sweepData,this.viewmodeData]=await Promise.all([t.market.waitForData(M.i),t.market.waitForData(X.e),t.market.waitForData(v.pu),t.market.waitForData(l.Z),t.market.waitForData(d.O)]);const n=await t.getModuleBySymbol(o.y.LOCALE),a={floorChangesEnabled:()=>this.config.allowFloorChanges,roomNavFeatureEnabled:()=>this.settingsData.tryGetProperty(ee.Q,!1)};if(this.floorsViewData=new U.c(this.floorsData,this.viewmodeData,this.sweepData,this.applicationData,n.t.bind(n),a),this.floorSelectFeatureEnabledCheck(),t.market.register(this,U.c,this.floorsViewData),[this.cameraData,this.input,this.raycasterData]=await Promise.all([t.market.waitForData(c.M),t.getModuleBySymbol(o.y.INPUT),t.market.waitForData(f.P)]),this.config.allowFloorChanges){const e=null===(i=this.config.startingFloorsVisibility)||void 0===i?void 0:i.lastIndexOf(1),t=null===(s=this.floorsData.getFloorAtIndex(e))||void 0===s?void 0:s.id,o=null===(r=this.sweepData.currentSweepObject)||void 0===r?void 0:r.floorId,n=o||t||null;(o||t)&&(this.log.debug(`Set initial floor to ${n} from current pose`),this.updateCurrentFloor(n))}const[h,m]=await Promise.all([t.getModuleBySymbol(o.y.CAMERA),t.market.waitForData(u._)]);this.floorNavigation=new N(t,this.floorsData,this.floorsViewData,this.sweepData,this.cameraData,h,this.viewmodeData,this.updateCurrentFloor,m),this.floorsSelectModeHelper=new W(this.floorsViewData,this.viewmodeData,this.cameraData.pose);const x=await t.getModuleBySymbol(o.y.MESH_QUERY),b=new S(this.floorsSelectModeHelper.getAngleModifier,this.floorsViewData,x,this.viewmodeData,this.raycasterData,m,(0,Z.Jm)());t.addComponent(this,b),this.settingsData.tryGetProperty(ee.Q,!1)&&this.config.allowFloorChanges&&this.registerFloorHoverCursorEffect(),this.bindings.push(this.registerKeys(),t.subscribe(T.bS,this.applicationChanged),this.floorsData.onChanged(this.floorsViewData.updateViewData),t.subscribe(p.Z,this.onEndMoveToSweepMessage),t.subscribe(g.Z,function(e,t,i){let s=!1;return o=>{const r=e.tryGetData(w.k);if(!r||r&&r.isTourActive())return;(0,y.Bw)(o.toMode)&&(s=null!==i.currentFloorId);const n=(0,y.Bw)(o.fromMode),a=o.toMode===y.Ey.Floorplan,h=o.toMode===y.Ey.Dollhouse;if(!n||!h&&!a)return;const l=s||a?i.currentFloorId:null;t(new G.Vw(l,!0,0))}}(t.market,t.commandBinder.issueCommand,this.floorsViewData)),t.commandBinder.addBinding(G.Vw,this.onMoveToFloorCommand),t.commandBinder.addBinding(G.h9,this.onMoveToFloorIndexCommand),t.commandBinder.addBinding(G.EU,this.onShowAllFloorsCommand),t.commandBinder.addBinding(G.LW,this.onEnableAllFloorsOptionCommand),t.commandBinder.addBinding(G.tR,this.onDisableAllFloorsOptionCommand),t.subscribe(te.Z,this.updateFloorSelectMode),this.cameraData.pose.onChanged(this.updateFloorSelectMode),this.floorsViewData.onChanged(this.updateFloorSelectMode),this.settingsData.onPropertyChanged(ee.w,this.floorSelectFeatureEnabledCheck),this.settingsData.onPropertyChanged(ie.gx.FloorSelect,this.floorSelectFeatureEnabledCheck),this.applicationData.onPropertyChanged("application",this.floorSelectFeatureEnabledCheck)),this.updateFloorSelectMode(),this.sweepData.currentSweepObject&&this.updateCurrentFloor(this.sweepData.currentSweepObject.floorId)}onUpdate(){}async onMoveToFloorCommand(e){return this.floorNavigation.moveToFloor(e.floorId,e.suppressCameraMovement,e.transitionTime,e.focusPoint).nativePromise()}toggleFloors(e){e||null===this.floorsViewData.currentFloorId||this.updateCurrentFloor(null),this.config.allowFloorChanges=e,this.updateFloorSelectMode()}registerKeys(){return this.input.registerHandler(r.e,(async e=>{if(!this.cameraData.canTransition())return;const t=e.modifiers.shiftKey;if(e.state===h.M.PRESSED)switch(e.key){case a.R.UPARROW:t&&this.floorNavigation.moveFloorUp();break;case a.R.DOWNARROW:t&&this.floorNavigation.moveFloorDown();break;case a.R.R:this.floorNavigation.moveFloorUp();break;case a.R.F:this.floorNavigation.moveFloorDown();break;case a.R.Y:this.floorNavigation.moveToFloor(null)}}))}registerFloorHoverCursorEffect(){const e=$.s.is((e=>Y.$4.isRoomMesh(e)&&e.raycastEnabled&&this.floorsViewData.floorSelectable)),t=new q.V(this.input.registerMeshHandler(n.z,e,(e=>{this.engine.commandBinder.issueCommand(new K.u(J.C.FINGER))})),this.input.registerMeshHandler(n.A,e,(e=>{this.engine.commandBinder.issueCommand(new K.u(J.C.DEFAULT))})));t.cancel();const i=(()=>{let e=!1;return()=>{const i=this.floorsViewData.floorSelectModeEnabled;i!==e&&(e=i,e?t.renew():(t.cancel(),this.engine.commandBinder.issueCommand(new K.u(J.C.DEFAULT))))}})();i(),this.bindings.push(this.viewmodeData.onChanged(i),this.floorsViewData.onFloorSelectModeChange(i),this.floorsViewData.makeFloorChangeSubscription(i),t)}}},82780:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>u});var s=i(97542),o=i(69170),r=i(67678),n=i(41927),a=i(89553),h=i(5135),l=i(57053),d=i(64773),c=i(31362);class u extends s.Y{constructor(){super(...arguments),this.name="interactionmode",this.onPointerButtonEvent=e=>{let t=this.data.source;switch(e.device){case n._.TOUCH:t=l.f.Touch;break;case n._.MOUSE:t=l.f.Mouse;break;case n._.PEN:t=l.f.Pen;break;case n._.GAMEPAD:this.renderer.xr.enabled&&this.renderer.xr.isPresenting&&(t=l.f.XRController);break;default:this.log.debug("source:",e.device,e)}this.updateSource(t)},this.onKeyEvent=()=>{this.updateSource(l.f.Key)}}async init(e,t){this.engine=t,this.data=new h.Z,this.mobileBrowser=(0,c.tq)();const i=await t.getModuleBySymbol(o.y.WEBGL_RENDERER);this.renderer=i.threeRenderer,this.updateMode(this.getInteractionMode(),this.data.mode),this.engine.market.register(this,h.Z,this.data),t.getModuleBySymbol(o.y.INPUT).then((e=>{this.bindings.push(e.registerHandler(r.er,this.onPointerButtonEvent),e.registerHandler(a.e,this.onKeyEvent))}))}onUpdate(e){const t=this.getInteractionMode();this.updateMode(t,this.data.mode)}getInteractionMode(){if(this.renderer.xr.enabled&&this.renderer.xr.isPresenting){const e=this.renderer.xr.getSession();if(null!==e&&e.inputSources.length>0)switch(e.inputSources[0].targetRayMode){case"gaze":case"screen":return l.s.VrOrientOnly;case"tracked-pointer":return l.s.VrWithTrackedController}return l.s.VrOrientOnly}return this.mobileBrowser?l.s.Mobile:l.s.Desktop}updateMode(e,t){e!==this.data.mode&&(this.data.updateMode(e),this.data.commit(),this.engine.broadcast(new d.m(this.data.mode,t)))}updateSource(e){e!==this.data.source&&(this.data.updateSource(e),this.data.commit(),this.engine.broadcast(new d.a(this.data.source)))}}},83977:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>h});var s=i(97542),o=i(69170),r=i(76957),n=i(76532),a=i(53954);class h extends s.Y{constructor(){super(...arguments),this.name="mesh-api-data-fixups"}async init(e,t){const{market:i}=t;[this.floorData,this.sweepData,this.meshData,this.meshQuery]=await Promise.all([i.waitForData(r.i),i.waitForData(a.Z),i.waitForData(n._),t.getModuleBySymbol(o.y.MESH_QUERY),t.getModuleBySymbol(o.y.MODEL_MESH)]),this.assignSweepToFloors(),this.assignBoundingBoxesToFloors(),this.assignMissingSweepFloors()}assignBoundingBoxesToFloors(){const e=this.meshData.meshGroups.floors;this.floorData.iterate(((t,i)=>{const s=e.get(t.meshGroup);s&&t.setBounds(s.boundingBox)})),this.floorData.commit()}assignMissingSweepFloors(){this.sweepData.getSweepList().forEach((e=>{var t;if(e.isUnplaced())return;let i;if(null===e.floorId||!this.floorData.hasFloor(e.floorId)){const s=this.meshQuery.floorIdFromObject(null===(t=this.meshQuery.nearestMeshInfo(e.position))||void 0===t?void 0:t.object);s&&this.floorData.hasFloor(s)&&(i=this.floorData.getFloor(s)),(null==i?void 0:i.id)&&i.id!==e.floorId&&(this.log.debug(`Setting ${e.alignmentType} sweep ${e.id} from floor ${e.floorId} to ${i.id}`),e.floorId=i.id,e.commit())}}))}assignSweepToFloors(){this.sweepData.getSweepList().forEach((e=>{var t;if(!e.isUnplaced()&&e.isAligned()){let i;if(e.floorId&&this.floorData.hasFloor(e.floorId))i=this.floorData.getFloor(e.floorId);else{const s=this.meshQuery.floorIdFromObject(null===(t=this.meshQuery.nearestMeshInfo(e.position))||void 0===t?void 0:t.object);s&&this.floorData.hasFloor(s)&&(i=this.floorData.getFloor(s))}i&&i.addSweep(e.position,e.floorPosition)}})),this.floorData.commit()}}},96782:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>d});var s=i(97542),o=i(69170),r=i(28269),n=i(76957);const a=(...e)=>function(t){return e.every((e=>e(t)))};var h=i(26269),l=i(81396);class d extends s.Y{constructor(){super(...arguments),this.name="mesh-query"}async init(e,t){const{market:i}=t;[this.raycaster,this.floorData,this.roomData]=await Promise.all([t.getModuleBySymbol(o.y.RAYCASTER),i.waitForData(n.i),i.waitForData(r.Z)])}nearestMeshInfoOnFloor(e,t){const i=a(h.$4.isRoomMesh,this.matchesFloorId(t));return this.raycaster.picking.nearest((new l.Vector3).set(e.x,e.y,e.z),i)}nearestMeshInfo(e){return this.raycaster.picking.nearest((new l.Vector3).set(e.x,e.y,e.z),h.$4.isRoomMesh)}inferMeshIdsFromPoint(e,t){const i=!e.roomId||!this.roomData.get(e.roomId),s=!e.floorId||!this.floorData.hasFloor(e.floorId);if(i||s){const o=s?h.$4.isRoomMesh:a(h.$4.isRoomMesh,this.matchesFloorId(e.floorId)),r=this.raycaster.picking.nearest((new l.Vector3).set(t.x,t.y,t.z),o),n=r&&this.roomIdFloorIdFromObject(r.object);if(n){const{roomId:t,floorId:o}=n;this.log.debug("data-fixup:",i?{roomId:t,prev:e.roomId}:"",s?{floorId:o,prev:e.floorId}:"",{data:e}),i&&(e.roomId=t),s&&(e.floorId=o)}else this.log.warn("Nearest Room/Floor not found for:",{point:t,data:e,invalidRoomId:i,invalidFloorId:s})}return e}roomIdFloorIdFromObject(e){if(!h.$4.hasMeshGroup(e))return;const t=this.floorData.getFloorByMeshGroup(e.meshGroup);if(void 0===t)return;const i=h.$4.hasMeshSubgroup(e)?this.roomData.getByMeshSubgroup(e.meshSubgroup):void 0;return{floorId:t.id,roomId:null==i?void 0:i.id}}floorIdFromObject(e){if(h.$4.hasMeshGroup(e)){const t=this.floorData.getFloorByMeshGroup(e.meshGroup);return null==t?void 0:t.id}}mdsRoomIdFromObject(e){if(!h.$4.hasMeshSubgroup(e)||!h.$4.hasMeshGroup(e))return;const t=this.roomData.getByMeshSubgroup(e.meshSubgroup);if(!t)return;const i=this.floorData.getFloorByMeshGroup(e.meshGroup);return t.floorId===(null==i?void 0:i.id)?t.id:void 0}mdsFloorIdFromObject(e){if(!h.$4.hasMeshGroup(e))return;const t=this.floorData.getFloorByMeshGroup(e.meshGroup);return t?t.id:void 0}matchesFloorId(e){return t=>{const i=this.roomIdFloorIdFromObject(t);return(null==i?void 0:i.floorId)===e}}}},70950:(e,t,i)=>{"use strict";i.d(t,{Z:()=>u});var s=i(67992),o=i(10385),r=i(15637),n=i(52498),a=i(97178),h=i(97998),l=i(98766),d=i(35895);const c=new h.Z("MeshTrimData");class u extends s.V{constructor(e,t){super(),this.maxTrimsPerFloor=a.t,this.maxAllFloorsTrims=a.t,this.numberOfTrims=0,this.meshTrimsByMeshGroup=new r.v,this.meshTrimsById=new r.v,this.onMeshGroupChangedCallbacks=new Set,this.onMeshTrimChangedCallbacks=new Set,this.updateMeshTrim=e=>{for(const t of this.onMeshTrimChangedCallbacks)t(e)},this.notifyMeshGroupChanges=e=>{for(const t of this.onMeshGroupChangedCallbacks)t(e)};for(const e of t){const t=new o.d;this.meshTrimsByMeshGroup.set(`${e}`,t)}1===t.length&&(this.singleFloorMeshGroup=t[0]),this.meshTrimsByMeshGroup.set(`${n.eh}`,new o.d);try{this.add(...Object.values(e))}catch(e){}}add(...e){const t=new Set;let i=!1;if(this.meshTrimsById.atomic((()=>{this.meshTrimsByMeshGroup.atomic((()=>{for(const s of e){void 0!==this.singleFloorMeshGroup&&(s.meshGroup=this.singleFloorMeshGroup);const e=s.meshGroup===n.eh,r=`${s.meshGroup}`;this.meshTrimsByMeshGroup.has(r)||this.meshTrimsByMeshGroup.set(r,new o.d);const a=this.meshTrimsByMeshGroup.get(r);a.length<(e?this.maxAllFloorsTrims:this.maxTrimsPerFloor)?(a.push(s),this.meshTrimsById.set(s.id,s),t.add(s.meshGroup),s.onChanged(this.updateMeshTrim)):(c.debugWarn("Trims exceed floor limit (trimId, meshGroup):",s.id,s.meshGroup),i=!0)}}))})),t.forEach((e=>{const t=this.meshTrimsByMeshGroup.get(`${e}`);this.sortList(t),this.reassignIndexes(t),this.notifyMeshGroupChanges(e)})),this.updateDerivedProperties(),i)throw new l.M("Exceeding max trims")}delete(...e){const t=new Set;this.meshTrimsByMeshGroup.atomic((()=>{for(const i of e){const e=this.meshTrimsByMeshGroup.get(`${i.meshGroup}`),s=e.indexOf(i);if(s>=0){e.splice(s,1)[0].enabled=!1,t.add(i.meshGroup),i.removeOnChanged(this.updateMeshTrim)}else c.error("Could not delete mesh trim:"+i.id)}})),t.forEach((e=>{const t=this.meshTrimsByMeshGroup.get(`${e}`);this.reassignIndexes(t),this.notifyMeshGroupChanges(e)})),this.meshTrimsById.atomic((()=>{e.forEach((e=>{this.meshTrimsById.delete(e.id)}))})),this.updateDerivedProperties()}updateDerivedProperties(){this.numberOfTrims=this.meshTrimsById.length,this.maxTrimsPerFloor=a.t-this.meshTrimsByMeshGroup.get(`${n.eh}`).length,this.maxAllFloorsTrims=a.t-this.getLongestTrimListLength(),this.commit()}onMeshGroupChanged(e){return(0,d.k1)((()=>this.onMeshGroupChangedCallbacks.add(e)),(()=>this.onMeshGroupChangedCallbacks.delete(e)))}onMeshTrimChanged(e){return(0,d.k1)((()=>this.onMeshTrimChangedCallbacks.add(e)),(()=>this.onMeshTrimChangedCallbacks.delete(e)))}getTrimById(e){return this.meshTrimsById.get(e)}getTrim(e,t){return this.meshTrimsByMeshGroup.has(`${e}`)?this.meshTrimsByMeshGroup.get(`${e}`).get(t):null}getTrimsForMeshGroup(e){return this.meshTrimsByMeshGroup.has(`${e}`)?this.meshTrimsByMeshGroup.get(`${e}`).values():[]}*activeTrimsForMeshGroup(e){if(this.meshTrimsByMeshGroup.has(`${e}`))for(const t of this.meshTrimsByMeshGroup.get(`${e}`))t.enabled&&(yield t);if(this.meshTrimsByMeshGroup.has(`${n.eh}`))for(const e of this.meshTrimsByMeshGroup.get(`${n.eh}`))e.enabled&&(yield e)}reassignIndexes(e){e.forEach(((e,t)=>{e.index=t}))}sortList(e){e.sort(((e,t)=>e.index-t.index))}getLongestTrimListLength(){let e=0;return this.meshTrimsByMeshGroup.keys.forEach((t=>{if(t===`${n.eh}`)return;const i=this.meshTrimsByMeshGroup.get(t);e=Math.max(i.length,e)})),e}}},98766:(e,t,i)=>{"use strict";i.d(t,{M:()=>o});var s=i(2224);class o extends s.y{constructor(e){super(e),this.name="TooManyTrimsError"}}},92256:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>V});var s=i(97542),o=i(2541),r=i(64567),n=i(71954),a=i(73698),h=i(50540),l=i(95912),d=i(38399),c=i(70950);class u{constructor(e){this.config=e}serialize(e){const{serializer:t}=this.config;if(!e||!t)return null;const i={};for(const s in e){const o=t.serialize(e[s]);o&&(i[s]=o)}return i}deserialize(e){const{deserializer:t}=this.config;if(!e||!t)return{};const i={};for(const s in e){const o=t.deserialize(e[s]);o&&(i[s]=o)}return i}}var m=i(3907),p=i(2569),g=i(9133),f=i(75287),y=i(39880),w=i(81396);const v=new w.Vector3;class T extends f.T{constructor(e,t,i,s,o,r,n=new Date,a=new Date,h,l,d,c){super(),this.position=e,this.scale=t,this.rotation=i,this.enabled=o,this.meshGroup=r,this.created=n,this.modified=a,this.discardContents=!0,this.activeInPanoMode=!0,this._rotationMatrix=new w.Matrix4,this._matrix=new w.Matrix4,this.id=h||`${this.meshGroup}`+(0,y.O1)(11),this.index=s,this.name=l,this.discardContents=void 0===d||d,this.activeInPanoMode=void 0===c||c}get sid(){return this.id}isPointTrimmed(e,t){return!!this.enabled&&(!(t&&!this.activeInPanoMode)&&(this.discardContents?this.isPointInside(e):!this.isPointInside(e)))}isPointInside(e){this._matrix.compose(this.position,this.rotation,this.scale),this._matrix.invert();const t=v.copy(e).applyMatrix4(this._matrix);return t.x<.5&&t.x>-.5&&t.y<.5&&t.y>-.5&&t.z<.5&&t.z>-.5}updateRotationMatrix(){const e=this.rotation,t=this.rotation.clone().set(e.x,e.y,e.z,-e.w);this._rotationMatrix.makeRotationFromQuaternion(t.normalize())}get rotationMatrix(){return this.updateRotationMatrix(),this._rotationMatrix}}var M=i(97998),x=i(29282);const b=new M.Z("JsonStoreMeshTrimDeserializer"),D=[{path:["position","x"],type:"number"},{path:["position","y"],type:"number"},{path:["position","z"],type:"number"},{path:["scale","x"],type:"number"},{path:["scale","y"],type:"number"},{path:["scale","z"],type:"number"},{path:["rotation","x"],type:"number"},{path:["rotation","y"],type:"number"},{path:["rotation","z"],type:"number"},{path:["rotation","w"],type:"number"},{path:["index"],type:"number"},{path:["enabled"],type:"boolean"},{path:["meshGroup"],type:"number"},{path:["id"],type:"string"},{path:["created"],type:"string"},{path:["modified"],type:"string"}];class S{constructor(){this.deserialize=e=>{if(!this.isValid(e))return b.debug("Unable to deserialize invalid mesh trim data",e),null;const{position:t,scale:i,rotation:s,index:o,enabled:r,meshGroup:n,created:a,modified:h,id:l,name:d,discardContents:c,activeInPanoMode:u}=e;return new T(p.ep.fromVisionVector(t),p.ep.fromVisionVector(i),p.ep.fromVisionQuaternion(s),o,r,n,(0,g.p)(a),(0,g.p)(h),l,d,c,u)}}isValid(e){if(!e||"object"!=typeof e)return!1;const t=e;return(0,x.r)(t.meshGroup)||(t.meshGroup=t.floorIndex),D.every((t=>this.hasRequiredField(e,t)))}hasRequiredField(e,t){try{return typeof t.path.reduce(((i,s)=>{if("object"==typeof i&&null!==i)return i[s];throw new Error(`data ${JSON.stringify(e)} must be addressable by ${t.path.join(".")} with a value of type ${t.type}`)}),e)===t.type}catch(e){return b.debug(e),!1}}}var C=i(59296);class P{serialize(e){if(!e)return null;const{position:t,scale:i,rotation:s,index:o,enabled:r,meshGroup:n,created:a,modified:h,id:l,name:d,discardContents:c,activeInPanoMode:u}=e;return{position:(0,C.m)(p.ep.toVisionVector(t)),scale:(0,C.m)(p.ep.toVisionVector(i)),rotation:(0,C.J5)(p.ep.toVisionQuaternion(s)),index:o,enabled:r,meshGroup:n,created:(0,g.U)(a),modified:(0,g.U)(h),id:l,name:d,discardContents:c,activeInPanoMode:u}}}class k extends m.MU{constructor(e,t,i){const s=new S,o=new P,r=new u({deserializer:s,serializer:o});super({queue:e,path:`${t}/api/v1/jsonstore/model/trims/${i}`,batchUpdate:!0,deserialize:e=>r.deserialize(e),serialize:e=>r.serialize(e)})}}var O=i(19663);class E extends O.m{constructor(e){super(),this.payload=e,this.id="CREATE_MESH_TRIM"}}class F extends O.m{constructor(e){super(),this.payload=e,this.id="DELETE_MESH_TRIM"}}class B extends O.m{constructor(e){super(),this.payload=e,this.id="MOVE_MESH_TRIM_ALL_FLOORS"}}var R=i(98766),A=i(52498),I=i(76532);const{TRIM:_}=d.Z.WORKSHOP;class V extends s.Y{constructor(){super(...arguments),this.name="trim-data",this.createMeshTrim=async e=>{try{this.data.add(e)}catch(e){if(e instanceof R.M){const e=_.MAX_TRIMS_ERROR_MESSAGE;this.engine.commandBinder.issueCommand(new h.I(e,{throttle:0,type:a.N.ERROR}))}}},this.deleteMeshTrim=async e=>{this.data.delete(e)},this.save=async()=>{const e=this.monitor.getDiffRecord();if(this.monitor.clearDiffRecord(),!e.length)return;const t={};for(const i of e)switch(i.action){case n.KI.added:case n.KI.updated:t[i.index]=this.data.getTrimById(i.index);break;case n.KI.removed:t[i.index]=null}try{await this.store.update(t)}catch(e){this.log.debug("error when writing to json storage"),this.log.debug(e);const t=_.UNABLE_TO_SAVE_CHANGES_ERROR_MESSAGE;this.engine.commandBinder.issueCommand(new h.I(t,{throttle:30,type:a.N.ERROR}))}},this.moveMeshTrimToAllFloors=async e=>{const t=e.enabled;this.deleteMeshTrim(e),e.meshGroup=A.eh,e.enabled=t,this.createMeshTrim(e)},this.onMeshTrimsChanged=(0,l.P)(this.save,1e3)}async init(e,t){this.engine=t,this.store=new k(e.queue,e.baseUrl,e.baseModelId);let i={};try{i=await this.store.read()||{}}catch(e){this.log.debug("error when reading from json storage"),this.log.debug(e)}const s=[...(await t.market.waitForData(I._)).meshGroups.floors.keys()].sort();this.data=new c.Z(i,s),this.monitor=new r.c(this.data.meshTrimsById,{aggregationType:o.E.Immediate}),t.market.register(this,c.Z,this.data),this.bindings.push(t.commandBinder.addBinding(E,this.createMeshTrim),t.commandBinder.addBinding(F,this.deleteMeshTrim),t.commandBinder.addBinding(B,this.moveMeshTrimToAllFloors)),this.monitor.onChanged(this.onMeshTrimsChanged)}}},17988:(e,t,i)=>{"use strict";i.d(t,{F:()=>n});var s=i(12529),o=i(81396),r=i(53203);class n extends o.Mesh{constructor(e){super(),this.roomMesh=e,this.excludeFromOctree=!0,this.layers.mask=e.layers.mask,this.name=`DepthPassRoomMesh:${e.meshGroup}-${e.meshSubgroup}`,this.renderOrder=s.z.ghostFloorDepthPrepass,this.visible=!1,this.roomMesh.onOpacityUpdate=e=>{this.visible=e<r.xx.FADE_OPAQUE},this.roomMesh.onBuild=()=>{this.geometry=this.roomMesh.geometry,this.material=this.roomMesh.material},this.roomMesh.onMaterialUpdate=()=>{this.material=this.roomMesh.material};let t=!0,i=!0;this.onBeforeRender=(e,s,o,r,n,a)=>{this.roomMesh.updateUniforms(n,a),t=n.colorWrite,i=n.depthWrite,n.colorWrite=!1,n.depthWrite=!0},this.onAfterRender=(e,s,o,r,n,a)=>{n.colorWrite=t,n.depthWrite=i}}}},1134:(e,t,i)=>{"use strict";i.d(t,{e:()=>r});var s=i(81396),o=i(35895);class r extends s.Object3D{constructor(){super(...arguments),this.boundingBox=new s.Box3,this.size=new s.Vector3,this.center=new s.Vector3,this._detail="default",this._chunks=[],this.onChunksLoaded=new Set}get detail(){return this._detail}get chunks(){return this._chunks}get visibleChunks(){return this._chunks}notifyOnChunksLoaded(e){return(0,o.k1)((()=>this.onChunksLoaded.add(e)),(()=>this.onChunksLoaded.delete(e)),!0)}dispose(){for(const e of this._chunks)e.dispose();this._chunks.length=0}overrideMaxDetail(e){}}},92324:(e,t,i)=>{"use strict";i.d(t,{s:()=>o});var s=i(67992);class o extends s.V{constructor(){super(),this.name="room-mesh-data",this.floors=new Set,this.rooms=new Set}}},14564:(e,t,i)=>{"use strict";i.d(t,{u:()=>n});var s,o,r=i(19663);!function(e){e.all="all",e.byMeshGroup="byMeshGroup",e.byMeshSubGroup="byMeshSubGroup"}(s||(s={})),function(e){e.explicit="explicit",e.random="random"}(o||(o={}));class n extends r.m{constructor(e,t){super(),this.id="SET_MESH_OVERLAY_COLOR",this.payload={selectBy:(null==t?void 0:t.style)||s.all,colorStyle:(null==e?void 0:e.style)||o.explicit,color:(null==e?void 0:e.color)||null,alpha:(null==e?void 0:e.alpha)||.5,index:null==t?void 0:t.index}}}n.selectBy=s,n.colorBy=o,n.COLOR_DIM={x:0,y:0,z:0,w:.3}},75810:(e,t,i)=>{"use strict";i.d(t,{I:()=>o});var s=i(19663);class o extends s.m{constructor(e){super(),this.id="TOGGLE_MESH_OVERLAY_COLOR",this.payload={enabled:e}}}},21270:(e,t,i)=>{"use strict";var s;i.d(t,{V:()=>s}),function(e){e[e.Min=0]="Min",e[e.Standard=1]="Standard",e[e.High=2]="High",e[e.Detail=3]="Detail"}(s||(s={}))},24048:(e,t,i)=>{"use strict";var s;i.d(t,{k:()=>s}),function(e){e.Mesh="mesh",e.PanoramaMesh="mesh.inside",e.PanoramaCube="cubemap.inside",e.Hidden="mesh.hidden"}(s||(s={}))},14052:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>Ie});var s=i(97542),o=i(69170),r=i(54244),n=i(90304),a=i(9037),h=i(26568),l=i(53954),d=i(70950),c=i(84366),u=i(23254),m=i(95882),p=i(23885),g=i(81396),f=i(33320);let y=!1;var w=i(51411),v=i(24048),T=i(80626),M=i(76532),x=i(97178);const b={meshTrimMatrices:[],meshTrimsDiscardContents:[],hasKeepVolume:!1};class D{constructor(e){this.floorUniforms={},this.sharedFloorUniforms={},this.isPanoMode=e}setMeshTrim(e){const{meshGroup:t,index:i,discardContents:s}=e,o=this.getEmptyCacheUniforms(),r=this.getFloorUniforms(t).meshTrimMatrices.slice();this.computeTrimMatrixFromTrim(e,r[i]),o.meshTrimMatrices=r,o.meshTrimsDiscardContents=this.setMeshTrimDiscardContents(t,i,s),this.setFloorUniforms(t,o)}updateMeshTrimArrays(e,t){const i=[],s=[];let o=!1;t.forEach((e=>{i.push(this.computeTrimMatrixFromTrim(e)),s.push(e.discardContents),o||(o=e.enabled&&!e.discardContents)})),this.setFloorUniforms(e,{meshTrimMatrices:i,meshTrimsDiscardContents:s,hasKeepVolume:o});"-1"==`${e}`?Object.keys(this.sharedFloorUniforms).forEach((e=>{this.updateSharedFloorUniforms(e)})):this.updateSharedFloorUniforms(e)}computeTrimMatrixFromTrim(e,t=new g.Matrix4){return e.enabled&&(!this.isPanoMode||this.isPanoMode&&e.activeInPanoMode)?(t.compose(e.position,e.rotation,e.scale),t.invert()):t.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),t}setMeshTrimDiscardContents(e,t,i){const s=this.getFloorUniforms(e).meshTrimsDiscardContents.slice();return s[t]=i,s}updateSharedFloorUniforms(e){const t=this.getFloorUniforms(e),i=this.getFloorUniforms(-1),s=new g.Matrix4;s.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const o=this.concatUniformArrays(i.meshTrimMatrices,t.meshTrimMatrices,s),r=this.concatUniformArrays(i.meshTrimsDiscardContents,t.meshTrimsDiscardContents,!0);this.setSharedFloorUniforms(e,{meshTrimMatrices:o,meshTrimsDiscardContents:r,hasKeepVolume:i.hasKeepVolume||t.hasKeepVolume})}concatUniformArrays(e,t,i){const s=e.concat(t).slice(0,x.t);for(let e=s.length;e<x.t;e++)s.push(i);return s}getFloorUniforms(e){return this.floorUniforms[`${e}`]||this.getEmptyCacheUniforms()}setFloorUniforms(e,t){this.floorUniforms[`${e}`]=t}getSharedFloorUniforms(e){return this.sharedFloorUniforms[`${e}`]||this.getEmptyCacheUniforms()}setSharedFloorUniforms(e,t){this.sharedFloorUniforms[`${e}`]=t}getEmptyCacheUniforms(){return Object.assign({},b)}}var S=i(39880),C=i(69984),P=i(97998),k=i(34029),O=i(18196),E=i(53203),F=i(22533),B=i(34742),R=i(12529),A=i(21270),I=i(93377);class _ extends I.b{constructor(e,t,i){const s={};for(const e of t)s[e]=!0;super({extensions:{derivatives:!0},fragmentShader:x.Z.modelChunk.fragmentShader,vertexShader:x.Z.modelChunk.vertexShader,uniforms:i,name:e,defines:s}),this.capabilities=t}}var V=i(75730),L=i(35895);function N(e,t){return null==t?t:t.isVector3||t.isVector4||t.isMatrix3||t.isMatrix4||t.isColor?null!=e?(e.copy(t),e):t.clone():t}let z,U=1;try{z=(0,V.k7)(0,0)}catch(e){}const G=5+x.t,j=[{key:B.h.PanoTextureTransition,enabled:function(e){return e.progress.value>0&&e.progress.value<1&&e.pano0Map.value!==e.pano1Map.value},dependsOn:[B.h.PanoTexture],uniformsUsed:["progress","pano0Map","pano1Map"]},{key:B.h.PanoTexture,enabled:function(e){return e.panoOpacity.value>0},dependsOn:[],uniformsUsed:["panoOpacity"]},{key:B.h.ColorOverlay,enabled:function(e){return null!==e.colorOverlay.value},dependsOn:[],uniformsUsed:["colorOverlay"]},{key:B.h.MeshPreviewSphere,enabled:function(e){return null!==e.meshPreviewCenter.value},dependsOn:[B.h.MeshTexture],uniformsUsed:[]},{key:B.h.MeshTexture,enabled:function(e){return e.meshOpacity.value>0&&e.map.value},dependsOn:[],uniformsUsed:["meshOpacity","map"]},{key:B.h.Wireframe,enabled:function(e){return!1},dependsOn:[],uniformsUsed:[]},{key:B.h.FlatShading,enabled:function(e){return!1},dependsOn:[],uniformsUsed:[]},{key:B.h.PanoOverlay,enabled:function(e){return!!e.overlay0Map.value},dependsOn:[B.h.PanoTexture],uniformsUsed:["overlay0Map"]},{key:B.h.PanoOverlayTransition,enabled:function(e){return!!(e.progress.value>0&&e.progress.value<1&&e.overlay0Map.value&&e.overlay1Map.value&&e.overlay0Map.value!==e.overlay1Map.value)},dependsOn:[B.h.PanoOverlay,B.h.PanoTexture,B.h.PanoTextureTransition],uniformsUsed:["progress","overlay0Map","overlay1Map"]},{key:B.h.MeshTrimVertex,enabled:function(e,{maxVaryings:t}){return t>G&&e.meshTrimMatrices.value.some((e=>!!e.elements[15]))},dependsOn:[B.h.MeshTexture],uniformsUsed:["meshTrimMatrices","meshTrimsDiscardContents"]},{key:B.h.MeshTrimPixel,enabled:function(e,{maxVaryings:t}){return t<=G&&e.meshTrimMatrices.value.some((e=>!!e.elements[15]))},dependsOn:[B.h.MeshTexture],uniformsUsed:["meshTrimMatrices","meshTrimsDiscardContents"]},{key:B.h.FloorTrimVertex,enabled:function(e){return!!(e.floorTrimHeight.value<1&&1===e.opacity.value)},dependsOn:[B.h.MeshTexture],uniformsUsed:["floorTrimHeight"]},{key:B.h.FloorTrimPixel,enabled:function(e){return!!(e.floorTrimHeight.value<1&&1===e.opacity.value)},dependsOn:[B.h.MeshTexture],uniformsUsed:["floorTrimHeight"]}],H=new Set(j.map((e=>e.uniformsUsed)).reduce(((e,t)=>e.concat(t)),[])),Q=new Set(["progress","panoOpacity","meshOpacity","pano0Map","pano0Position","pano0Matrix1","pano0Matrix2","pano1Map","pano1Position","pano1Matrix1","pano1Matrix2","overlay0Map","overlay0Matrix","overlay1Map","overlay1Matrix"]);class W{constructor(e,t,i,s,o="",r=!1){this.meshGroup=e,this.meshSubgroup=t,this.geometry=i,this.sharedState=s,this.textureName=o,this.id=U++,this.name="",this.lod=A.V.Standard,this.capabilityOverrides={},this.onMaterialUpdate=new Set,this.uniformCache=W.getUniformDefaults(),this.opacity=1,this.temp={m1:new g.Matrix4,m2:new g.Matrix4,quat:new g.Quaternion,m3:null},this.standardMaterial=this.getChunkMaterial(this.getCapabilities(),!1),this.updateRenderingMode(),r&&this.setMaterialsUniform(s.globalUniforms)}dispose(){this.geometry.dispose()}static getUniformDefaults(){const e={};for(const t in x.Z.modelChunk.uniforms){const i=g.UniformsUtils.clone(x.Z.modelChunk.uniforms[t]);for(const t in i)e[t]=i[t]}return e}set material(e){if(this._material!==e&&this.onMaterialUpdate)for(const t of this.onMaterialUpdate.values())t(e);this._material=e}get material(){return this._material}notifyOnMaterialUpdated(e){return(0,L.k1)((()=>this.onMaterialUpdate.add(e)),(()=>this.onMaterialUpdate.delete(e)),!0)}setMeshTexture(e){this.setMaterialsUniform({map:e})}getColorOverlay(){return this._colorOverlay}setColorOverlay(e){this._colorOverlay!==e&&(this.setMaterialsUniform({colorOverlay:e}),this._colorOverlay=e)}setMeshTextureOpacity(e){e!==this._meshTextureOpacity&&(this.setMaterialsUniform({meshOpacity:e,panoOpacity:1-e}),this._meshTextureOpacity=e)}setProgress(e){this._progress!==e&&(this.setMaterialsUniform({progress:e}),this._progress=e)}needsTransparent(){return this.opacity<E.xx.FADE_OPAQUE}setOpacity(e){this.opacity=e;const t=this.needsTransparent();return this.onOpacityUpdate&&this.onOpacityUpdate(e),t!==this._material.transparent}getOpacity(){return this.opacity}setTime(e){this.sharedState.renderingMode===F.S.Wireframe&&this.setMaterialsUniform({time:e})}setMeshPreviewSphere(e,t=.3){this.setMaterialsUniform({meshPreviewCenter:e,meshPreviewSize:t})}setWireframe(e){if(e){if(this.geometry.getIndex()){const e=this.geometry;e.boundsTree&&(e.boundsTree.geometry=this.geometry.clone()),this.geometry.copy(this.geometry.toNonIndexed())}(0,V.ko)(this.geometry)}this.overrideCapability(B.h.Wireframe,e)}setFlatShading(e){e&&this.geometry.computeVertexNormals(),this.overrideCapability(B.h.FlatShading,e)}getCapabilities(){const e=new Set;for(const t in this.capabilityOverrides)this.capabilityOverrides[t]&&e.add(t);for(const t of j)if(!e.has(t.key)&&t.enabled(this.uniformCache,this.sharedState)){e.add(t.key);for(const i of t.dependsOn)e.add(i)}return e}overrideCapability(e,t){this.capabilityOverrides[e]=t,this.updateMaterialCapabilities()}updateMaterialCapabilities(){const e=this.getCapabilities(),t=this.standardMaterial,i=this.needsTransparent();if((0,S.TH)(t.capabilities,e)&&i===t.transparent)return this._material;const s=this.getChunkMaterial(e,i);return this.standardMaterial=s,this.sharedState.renderingMode===F.S.Standard&&(this.material=s),this._material}getChunkMaterial(e,t){let i="chunkMaterial_";for(const t of j)i+=e.has(t.key)?"1":"0";const s=-1===this.meshGroup&&-1===this.meshSubgroup;i+=s?"f":t?"1":"0";const{chunkMaterials:o,side:r}=this.sharedState;if(!o[i]){const n=new _(i,e,this.getUniformsForCapabilities(e));s?(n.side=g.BackSide,n.transparent=!0,n.depthWrite=!1):(n.transparent=t,n.depthWrite=!t,n.side=r),o[i]=n}return o[i]}getUniformsForCapabilities(e){const t={};for(const i of e){const e=x.Z.modelChunk.uniforms[i];for(const i in e)t[i]=g.UniformsUtils.clone(this.uniformCache[i])}return t}setMaterialsUniform(e,t=!1){let i,s=!1;const o=this.uniformCache.meshPreviewCenter.value;for(const r in e){let n=!1;const a=e[r];if(n="meshPreviewCenter"!==r?n||H.has(r):n||null===o!=(null===a),!(r in this.uniformCache))throw new Error(`Uniform ${r} does not exist in Chunk`);const h=this.uniformCache[r];h.value!==a&&(h.value=N(h.value,a),"opacity"===r&&(i=a),t&&Q.has(r)&&(this.sharedState.globalUniforms[r]=N(this.sharedState.globalUniforms[r],a)),s=s||n)}return void 0!==i&&(s=this.setOpacity(i)||s),s&&this.updateMaterialCapabilities(),this._material}updateRenderingMode(){const{renderingMode:e,modeMaterials:t}=this.sharedState;e===F.S.Standard?this.material=this.standardMaterial:this.material=t.get(e)}setProjectedPano(e,t,i,s,o=!1){let r=1===e?"pano1Map":"pano0Map";const n={};n[r]=s||z,t&&(r=1===e?"pano1Position":"pano0Position",n[r]=t),i&&t&&(r=1===e?"pano1Matrix":"pano0Matrix",this.temp.m1.makeRotationFromQuaternion(this.temp.quat.copy(i).invert()),this.temp.m2.makeScale(-1,1,1),n[`${r}1`]=this.temp.m1,n[`${r}2`]=this.temp.m2),this.setMaterialsUniform(n,o)}setOverlayPano(e,t,i,s=!1){const o=`overlay${e}`,r={};if(t){this.temp.m3||(this.temp.m3=new g.Matrix4);const e=this.temp.m3.makeRotationFromQuaternion(t);r[o+"Matrix"]=e}r[o+"Map"]=i||z,this.setMaterialsUniform(r,s)}onBeforeDraw(e){if(this.sharedState.renderingMode===F.S.Standard){for(const t of Object.keys(e.uniforms))this.uniformCache[t]&&null!==this.uniformCache[t].value&&(e.uniforms[t].value=this.uniformCache[t].value);e.uniformsNeedUpdate=!0}}getSortKey(){var e,t,i;return null!==(i=null===(t=null===(e=this.uniformCache.map)||void 0===e?void 0:e.value)||void 0===t?void 0:t.id)&&void 0!==i?i:0}}const Z=new g.Vector3(0,0,0),q=new g.Vector3(100,100,100),$=new g.Vector3,Y=new g.Vector3,K=new g.Box3;class J extends g.Mesh{constructor(e){super(),this.bounds=new g.Box3,this.geometry=new g.BoxGeometry(1,1,1),this.geometry.computeBoundingBox(),this.geometry.computeBoundingSphere(),this.chunk=new W(-1,-1,this.geometry,e);const t=e=>{this.material=e};this.chunk.notifyOnMaterialUpdated(t),t(this.chunk.material),this.name="FallbackMesh",this.renderOrder=R.z.boundingSkybox,this.setFromCenterAndSize(Z,q),this.onBeforeRender=(e,t,i,s,o,r)=>{o instanceof g.RawShaderMaterial&&this.chunk.onBeforeDraw(o)}}setBounds(e){if(this.bounds.equals(e))return;this.bounds.copy(e);const t=e.getSize($);this.position.copy(e.getCenter(Y)),this.scale.set(t.x,t.y,t.z),this.updateMatrixWorld(!0)}setFromCenterAndSize(e,t=q){this.setBounds(K.setFromCenterAndSize(e,t))}}var X=i(14564),ee=i(75810),te=i(68191),ie=i(19663);class se extends ie.m{constructor(e,t,i){super(),this.id="SET_PANO_OVERLAY",this.payload={sweepId:e,texture:t,quaternion:i}}}const oe=new P.Z("modelrenderer");class re{constructor(e,t,i,s,o,r,n,a,h){this.scene=e,this.container=t,this.mesh=i,this.panoRenderer=s,this.meshData=o,this.sweepData=r,this.applicationData=n,this.chunkSharedState=a,this.renderOptions=h,this.chunkRenderingModeOverride=null,this.lastChunkRenderingModeOverride=null,this.fallbackMesh=new J(this.chunkSharedState),this.overlayColors=[],this.toolMeshColorEnabled=!1,this.TOOL_MESH_COLOR_OVERLAY=new g.Vector4(0,0,0,.3),this.overlayTextures=[{sweepId:void 0,texture:void 0,renderTarget:new g.WebGLCubeRenderTarget(2048,{format:g.RGBAFormat}),quaternion:new g.Quaternion},{sweepId:void 0,texture:void 0,renderTarget:new g.WebGLCubeRenderTarget(2048,{format:g.RGBAFormat}),quaternion:new g.Quaternion}],this.overlayEnabled=!1,this.bindings=[],this.updateFallbackMesh=(()=>{const e=new g.Box3;return()=>{if(this.sweepData.currentAlignedSweepObject&&this.viewmodeData.isInside()){const t=e.copy(this.meshData.extendedBounds).expandByScalar(.2);this.fallbackMesh.setBounds(t)}else this.cameraData&&this.fallbackMesh.setFromCenterAndSize(this.cameraData.pose.position)}})(),this.debugColorizeChunks=(()=>{let e=!1;return(t,i)=>{const s=new g.Vector4(1,1,1,0);e=!e,(e=>{for(const t of this.mesh.chunks){const o=i?100*t.id:100*t.meshSubgroup,r=e?(0,C.G1)(.5,o):s;t.setColorOverlay(r)}})(t||e)}})()}init(){}dispose(){}async activate(e){this.engine=e,[this.viewmodeData,this.settings,this.cameraData,this.renderer]=await Promise.all([e.market.waitForData(u.O),e.market.waitForData(k.e),e.market.waitForData(a.M),e.getModuleBySymbol(o.y.WEBGL_RENDERER)]),this.scene.add(this.container),this.scene.add(this.fallbackMesh),this.fallbackMesh.layers.mask=this.container.layers.mask,this.updateRenderState(),this.bindings.push(this.viewmodeData.onChanged(this.updateRenderState.bind(this)),this.sweepData.onChanged(this.updateRenderState.bind(this)),this.settings.onChanged(this.updateRenderState.bind(this)),e.commandBinder.addBinding(X.u,this.onMeshOverlayCommand.bind(this)),e.commandBinder.addBinding(ee.I,this.toggleMeshOverlayColor.bind(this)),e.commandBinder.addBinding(te.U,this.onSetChunkRenderStateCommand.bind(this)),e.commandBinder.addBinding(se,this.onPanoOverlayCommand.bind(this))),this.bindings.push(this.mesh.notifyOnChunksLoaded((e=>{for(const t of this.overlayColors)t(e)}))),this.renderOptions.colorizeRooms&&this.debugColorizeChunks(!0),this.renderOptions.colorizeChunks&&this.debugColorizeChunks(!0,!0),this.renderOptions.wireframe&&this.toggleWireframe(!0),this.setupDebugMenu(e)}deactivate(){for(const e of this.bindings)e.cancel();this.bindings=[],this.scene.remove(this.container),this.scene.remove(this.fallbackMesh),this.currentSweepId&&this.panoRenderer.freeTexture(this.currentSweepId),this.currentSweepId=null,this.targetSweepId=null}updateSweepRenderTarget(e,t,i,s){const o=this.panoRenderer.useTexture(t);if(o){let t=!0;for(const r of this.allChunks())r.setProjectedPano(e,i,s,o,t),t=!1}}*allChunks(){yield*this.mesh.chunks,yield this.fallbackMesh.chunk}updateExistingTexture(e,t,i,s){let o=!0;for(const r of this.allChunks())e===this.currentSweepId&&r.setProjectedPano(0,i,s,t,o),e===this.targetSweepId&&r.setProjectedPano(1,i,s,t,o),o=!1}render(){}beforeRender(){var e;const{floorOpacity:t}=this.meshData.meshGroupVisuals;for(const i of this.mesh.visibleChunks)i.setMaterialsUniform({meshOpacity:this.meshData.meshTextureOpacity.value,panoOpacity:1-this.meshData.meshTextureOpacity.value,opacity:null!==(e=t.get(i.meshGroup))&&void 0!==e?e:1,progress:this.sweepData.transition.progress.value});const i=(0,p.w2)(this.meshData.meshTextureOpacity.value,0,1,1);this.fallbackMesh.chunk.setMeshTextureOpacity(i),this.fallbackMesh.chunk.setProgress(this.sweepData.transition.progress.value),this.updateFallbackMesh()}updateChunkMaterialMode(e,t){const i=e?g.DoubleSide:g.FrontSide;this.chunkSharedState.side=i,this.chunkSharedState.renderingMode=t||F.S.Standard;for(const e of this.mesh.chunks)e.updateRenderingMode()}updateRenderState(){if(this.viewmodeData.currentMode!==this.lastViewmode||this.lastChunkRenderingModeOverride!==this.chunkRenderingModeOverride){this.lastChunkRenderingModeOverride=this.chunkRenderingModeOverride;const e=this.viewmodeData.isInside();this.updateChunkMaterialMode(e,this.chunkRenderingModeOverride),this.lastViewmode=this.viewmodeData.currentMode}if(this.viewmodeData.transition.active&&(0,m.Bw)(this.viewmodeData.transition.to)||this.viewmodeData.isInside()){const e=this.sweepData.currentSweep,t=this.sweepData.transition,i=t.active&&(this.applicationData.phase===r.nh.PLAYING||this.applicationData.phase===r.nh.STARTING),s=i?t.from:e,o=i?t.to:e,n=this.currentSweepId,a=this.targetSweepId;this.currentSweepId=s||null,this.targetSweepId=o||null,this.handleSweepChange(0,n,this.currentSweepId),this.handleSweepChange(1,a,this.targetSweepId)}if(this.overlayEnabled){const e=this.overlayTextures.find((e=>e.sweepId===this.currentSweepId)),t=this.overlayTextures.find((e=>e.sweepId===this.targetSweepId));let i=!0;for(const s of this.allChunks())s.setOverlayPano(0,e?e.quaternion:void 0,e?e.texture:void 0,i),s.setOverlayPano(1,t?t.quaternion:void 0,t?t.texture:void 0,i),i=!1}}handleSweepChange(e,t,i){if(t!==i&&(t&&this.panoRenderer.freeTexture(t),i)){const t=this.sweepData.getSweep(i);this.updateSweepRenderTarget(e,i,t.position,t.rotation)}}async onPanoOverlayCommand(e){this.overlayEnabled=!0;const t=t=>{const i=t.renderTarget;t.renderTarget.width=e.texture.image.width,t.renderTarget.height=e.texture.image.height,t.sweepId=e.sweepId,t.texture=i.texture,t.quaternion=e.quaternion,this.renderer.cwfRenderer.copyCubemap(e.texture,t.renderTarget)};let i=!1;for(const s of this.overlayTextures)i||s.sweepId!==e.sweepId||(t(s),i=!0);for(const e of this.overlayTextures)i||e.sweepId===this.targetSweepId||e.sweepId===this.currentSweepId||(t(e),i=!0);this.updateRenderState()}async onMeshOverlayCommand(e){let t=()=>!0;switch(e.selectBy){case X.u.selectBy.all:t=()=>!0,this.overlayColors.length=0;break;case X.u.selectBy.byMeshGroup:t=t=>t.meshGroup===e.index;break;case X.u.selectBy.byMeshSubGroup:t=t=>t.meshSubgroup===e.index}if(!t)return;let i="rand";e.colorStyle===X.u.colorBy.explicit&&(i=e.color?new g.Vector4(e.color.x,e.color.y,e.color.z,e.color.w):null);const s=s=>{for(const o of s)t(o)&&o.setColorOverlay("rand"===i?(0,C.G1)(e.alpha):i)};s([...this.allChunks()]),e.selectBy===X.u.selectBy.all&&null===i||this.overlayColors.push(s)}async toggleMeshOverlayColor({enabled:e}){if(e!==this.toolMeshColorEnabled)return this.toolMeshColorEnabled=e,this.onMeshOverlayCommand({color:e?this.TOOL_MESH_COLOR_OVERLAY:null,selectBy:X.u.selectBy.all,colorStyle:X.u.colorBy.explicit,alpha:.5})}async onSetChunkRenderStateCommand(e){this.chunkRenderingModeOverride=e.mode,this.updateRenderState()}toggleWireframe(e){for(const t of this.mesh.chunks)t.setWireframe(e)}async setupDebugMenu(e){const[t,i]=await Promise.all([e.market.waitForData(k.e),e.getModuleBySymbol(o.y.SETTINGS)]);i.registerButton("Mesh","Toggle visible",(()=>{this.container.visible=!this.container.visible})),i.registerButton("Mesh","Toggle UV debug",(()=>{const t=this.chunkRenderingModeOverride?null:F.S.UV;e.commandBinder.issueCommand(new te.U(t))})),i.registerButton("Mesh","Toggle depth",(()=>{const t=this.chunkRenderingModeOverride?null:F.S.Depth;e.commandBinder.issueCommand(new te.U(t))})),i.registerButton("Mesh","Toggle transparent",(()=>{const t=this.chunkRenderingModeOverride?null:F.S.Transparent;e.commandBinder.issueCommand(new te.U(t))})),i.registerButton("Mesh","Toggle wireframe",(()=>{const t=this.chunkRenderingModeOverride?null:F.S.Wireframe;e.commandBinder.issueCommand(new te.U(t))}));let s=!1;i.registerButton("Mesh","Toggle flat shading",(()=>{s=!s;for(const e of this.mesh.chunks)e.setFlatShading(s)})),i.registerButton("Mesh","Cycle all chunk materials",(()=>{this.debugCycleChunkMaterials()})),i.registerButton("Mesh","Highlight Rooms",this.debugColorizeChunks),i.registerButton("Mesh","Highlight Chunks",(()=>this.debugColorizeChunks(!0,!0))),t.onPropertyChanged(E.NR,(e=>{for(const t of this.mesh.chunks){const i=this.meshData.meshGroups.floors.get(t.meshGroup);i&&t.setMaterialsUniform({floorTrimHeight:1-e/100,floorHeightMin:i.boundingBox.min.y,floorHeightMax:i.boundingBox.max.y})}}));const r=(e,s,o,r,n)=>{i.registerSetting(e,s,o,!0,O.SettingPersistence.NONE,n),t.onPropertyChanged(s,r)};r("Wireframe",E.Lp,!1,this.toggleWireframe.bind(this));const n={[B.h.Wireframe]:{Wireframe:["thickness","wireframeOpacity","stroke","fillEnabled","fill","insideAltColor","dualStroke","secondThickness"],"Wireframe Dashes":["dashEnabled","dashLength","dashAnimate","dashOverlap"],"Wireframe Advanced":["squeeze","squeezeMin","squeezeMax"]}};for(const e in n){const t=x.Z.modelChunk.uniforms[e];for(const i in n[e])for(const s of n[e][i])r(i,s,t[s].value,(e=>{for(const t of this.mesh.chunks)t.setMaterialsUniform({[s]:e})}),t[s].range)}}async debugCycleChunkMaterials(){const e=[];for(const t in B.h)isNaN(Number(t))&&e.push(B.h[t]);const t=[];for(const e in F.S)isNaN(Number(e))&&t.push(F.S[e]);oe.info(`Available ChunkMaterialCapabilities: ${e}`);const i=[];for(let t=0;t<1<<e.length-1;t++){const s={};for(let i=e.length-1;i>=0;i--){s[e[i]]=Boolean(t&1<<i)}i.push(s)}oe.info(`There are ${i.length*t.length} options to test`);for(let e=0;e<t.length;e++){await this.engine.commandBinder.issueCommand(new te.U(e));for(const t of i){oe.info(`Testing ChunkRenderingMode.${F.S[e]} with capabilities: ${JSON.stringify(t,void 0,2)}`);const i=new g.Vector4(Math.random(),Math.random(),Math.random(),.5);for(const e of Object.keys(t))for(const s of this.mesh.chunks)s.setColorOverlay(i),s.setMeshPreviewSphere(new g.Vector3(0,0,0)),s.overrideCapability(e,t[e]);await(0,S.gw)(100)}await(0,S.gw)(100)}await this.engine.commandBinder.issueCommand(new te.U(null))}}var ne=i(53261),ae=i(26544);class he{constructor(e,t,i=128,s=128){this.slots=e,this.renderToTextureModule=t,this.width=i,this.height=s,this.sizeMultiplier=1/8,this.pixelBuffer=new Uint8Array(4),this.readBuffer=null,this.readPixelsAsync=Promise.resolve(this.pixelBuffer)}get renderTarget(){return this._renderTarget||(this._renderTarget=new g.WebGLRenderTarget(this.width,this.height,{type:g.UnsignedByteType,format:g.RGBAFormat,depthBuffer:!1,stencilBuffer:!1,generateMipmaps:!1,minFilter:g.NearestFilter,magFilter:g.NearestFilter})),this._renderTarget}pixels(){return this.pixelBuffer}renderAndReadAsync(e,t){this.beforeRender(),this.updateReadBufferSize(),this.readPixelsAsync=this.renderToTextureModule.renderAndReadAsync({mesh:e,camera:t,target:this.renderTarget,clear:!0},{x:0,y:0,width:this.width,height:this.height},{buffer:this.pixelBuffer}).then((e=>(this.pixelBuffer=e,this.pixelBuffer))),this.afterRender()}render(e,t,i=!1,s=!0){this.beforeRender();let{width:o,height:r}=this.renderToTextureModule.getRenderSize();o=Math.max(1,Math.floor(o*this.sizeMultiplier)),r=Math.max(1,Math.floor(r*this.sizeMultiplier)),o===this.renderTarget.width&&r===this.renderTarget.height||this.renderTarget.setSize(o,r),this.renderToTextureModule.render(this.renderTarget,e,t),i&&this.renderToScreen(),s&&this.afterRender()}renderToScreen(){this.renderToTextureModule.renderToScreen(this.renderTarget,!1)}readPixels(){this.updateReadBufferSize();const e=this.pixelBuffer;return this.pixelBuffer=this.renderToTextureModule.getRenderTargetData(this.renderTarget,e),this.pixelBuffer}updateReadBufferSize(){const e=this.renderTarget.width*this.renderTarget.height*4;this.pixelBuffer.length!==e&&(this.pixelBuffer=new Uint8Array(e))}beforeRender(){this.width===this.renderTarget.width&&this.height===this.renderTarget.height||this.renderTarget.setSize(this.width,this.height);for(const e of this.slots)for(const t of e.chunks)this.beforeRenderChunk(t,e)}afterRender(){for(const e of this.slots)for(const t of e.chunks)this.afterRenderChunk(t,e)}}class le extends he{constructor(){super(...arguments),this.prevColor=new WeakMap}beforeRenderChunk(e,t){this.prevColor.set(t,e.getColorOverlay()),e.setColorOverlay((0,ae.O7)(t.quality))}afterRenderChunk(e,t){var i;e.setColorOverlay(null!==(i=this.prevColor.get(t))&&void 0!==i?i:null)}}class de extends he{constructor(){super(...arguments),this.prevColor=new WeakMap}beforeRender(){this.maxValue=this.slots.reduce(((e,t)=>Math.max(e,t.screenCoverageScore)),1e-9),super.beforeRender()}beforeRenderChunk(e,t){const i=t.screenCoverageScore/this.maxValue,s=new g.Vector4(i,i,i,1);this.prevColor.set(t,e.getColorOverlay()),e.setColorOverlay(s)}afterRenderChunk(e,t){var i;e.setColorOverlay(null!==(i=this.prevColor.get(t))&&void 0!==i?i:null)}}var ce=i(99935),ue=i(83021);class me{constructor(e,t=A.V.Standard,i){this.textureName=e,this.lod=t,this.chunkedTexInfo=i,this.chunks=new Set,this.loading=!1,this.unloaded=!1,this.screenCoverage=0,this.screenCoverageScore=0,this.sightings=new ue.P(E.EJ.sightingMaxAge),i&&((0,ae.qT)().registerQualities(t,i.maxTextureSize,i.maxTexelSize,i.minScale),this.quality=(0,ae.qT)().min(t),this.targetQuality=this.quality),this.minQuality=(0,ae.qT)().min(t),this.maxQuality=this.minQuality}setTexture(e){const t=this.texture;if(this.texture=e,t&&t!==e&&t.dispose(),e)for(const t of this.chunks)t.setMeshTexture(e)}async getUrl(e){const t=(0,ae.qT)().get(e),{assetType:i,lod:s}=t;if(this.textureData){let e=this.textureName;if(!this.chunkedTexInfo){const t=this.textureName.match(/[_.]([0-9]{3})[_.]/);if(!t)throw new Error(`Could not parse texture index from texture name: ${this.textureName}`);e=t[1]}return(await this.textureData[i].get()).urlTemplate.replace("<folder>",`${s}`).replace("<texture>",e)}{const e=this.textureName.match(/^([a-f0-9]+(_10k|_50k)?)/);if(!e)throw new Error(`Unknown format for texture name: ${this.textureName}`);return`${e[0]}_texture_jpg_${i}/${this.textureName}`}}getEmbeddedTexture(){var e;const t=null===(e=this.chunks.entries().next())||void 0===e?void 0:e.value;return t?t[0].embeddedTexture:void 0}}class pe{constructor(e,t,i=.85){this.renderer=e,this.maxBudget=t,this.pctTotalMemory=i,this.lods=new Map,this.orders={},this.slotTexSizes=new Map}dispose(){this.slots.length=0,this.lods.clear()}update(e){this.updateBudget(void 0),this.updateTargetQualitiesFromBudget()}updateBudget(e){if(e){this.slots=e;const t=(0,ae.qT)();e.forEach((e=>{const i=this.lods.get(e.lod)||new Set;i.add(e),this.lods.set(e.lod,i),this.orders[e.lod]=t.order(e.lod)}))}if(this.shouldRestrictBudget()){const e=this.calcCurrentTexturesSize(),t=this.renderer.estimatedGPUMemoryAllocated()-e,i=this.maxBudget()-t;this.budget=i*this.pctTotalMemory}else this.budget=1/0;return this}updateTargetQualitiesFromBudget(){let e=0;for(const t of this.slots)this.updateBudgetSize(t),t.targetQuality=t.minQuality,e+=this.getBudgetSize(t,t.targetQuality);const t=(t,i)=>t.maxQuality<i||(e-=this.getBudgetSize(t,t.targetQuality),e+=this.getBudgetSize(t,i),!(e>this.budget)&&(t.targetQuality=i,!0));if(this.shouldRestrictBudget()){for(const e of this.slots)for(const i of this.orders[e.lod])if(!t(e,i))return}else for(const[e,i]of this.lods.entries())for(const s of this.orders[e])for(const e of i)if(!t(e,s))return}shouldRestrictBudget(){return this.maxBudget()!==1/0}getBudgetSize(e,t){if(!t)return 0;const i=(0,ae.qT)().get(t);let s=0;if(e){const i=(0,ae.qT)().min(e.lod);i!==t&&e.getEmbeddedTexture()&&(s=this.getBudgetSize(e,i));const o=e.textureName+t,r=this.slotTexSizes.get(o);if(r)return r+s}return(i?i.textureSize:4096)**2*4+s}updateBudgetSize(e){var t;const i=e.textureName+e.quality,s=null!==(t=e.texture)&&void 0!==t?t:e.getEmbeddedTexture();this.slotTexSizes.set(i,this.texSizeBytes(s))}calcCurrentTexturesSize(){return this.slots.reduce(((e,t)=>{var i;const s=t.getEmbeddedTexture(),o=null!==(i=t.texture)&&void 0!==i?i:s;return o===s?e+this.texSizeBytes(o):e+this.texSizeBytes(o)+this.texSizeBytes(s)}),0)}texSizeBytes(e){if(!e)return 0;if(e.mipmaps.length>0)return e.mipmaps.reduce(((e,t)=>e+t.data.length),0);let t=e.image.width*e.image.height*4,i=t/4;for(;i>=1;)t+=i,i/=4;return t}}var ge=i(67944),fe=i(49827),ye=i(60047),we=i(947);const ve=new P.Z("tex-lod");class Te{constructor(e,t,i,s,o,r,n,a,h){this.textureLOD=e,this.urls=t,this.modelObject=i,this.camera=s,this.renderer=o,this.renderToTextureModule=r,this.engine=n,this.chunkVisibilityChecker=a,this.rendererModule=h,this.name="texture-streaming",this.slots=[],this.textureNameToSlot={},this.chunkIdToSlot={},this._systemMin=ce.S.LOW,this._systemMax=ce.S.ULTRA,this.allowTextureDownload=()=>!0,this.concurrentLoadingTextures=1,this.concurrentDownloadingTiles=12,this.autoLoadTiles=!1,this.lastSortedAt=0,this.loadingTextures=0,this.downloadingTiles=0,this.totalTextures={},this.totalTiles=0,this.textureQualityRenderPass=new le(this.slots,this.renderToTextureModule),this.textureScoreRenderPass=new de(this.slots,this.renderToTextureModule),this.abortController=new AbortController,this._chunkSlotsSet=new Set}setModel(e,t,i,s){this.textureApiInfo=i,this.modelObject=e,this.slots.length=0,this.textureNameToSlot={},this.chunkIdToSlot={},this.addChunkSlots([...t]),this.textureBudgeter=new pe(this.rendererModule,s),this.textureBudgeter.updateBudget(this.slots),this.updateSystemQualityRanges(),this.chunkVisibilityChecker.notifyOnNewSighting(((e,t)=>{const i=this.addChunkSlots([e]);for(const e of i)e.sightings.push(t)}))}dispose(){this.slots.length=0,this.textureNameToSlot={},this.chunkIdToSlot={},this._chunkSlotsSet.clear(),this.textureBudgeter.dispose()}addChunkSlots(e){this._chunkSlotsSet.clear();let t=!1;for(const i of e){const e=i.textureName;let s=this.textureNameToSlot[e];s||(t=!0,s=new me(e,i.lod,i.textureLODInfo),i.embeddedTexture&&s.setTexture(i.embeddedTexture),this.textureApiInfo&&(s.textureData=this.textureApiInfo),this.textureNameToSlot[i.textureName]=s,this.slots.push(s)),s.chunks.has(i)||(t=!0,s.chunks.add(i),s.texture&&i.setMeshTexture(s.texture)),this._chunkSlotsSet.add(s),this.chunkIdToSlot[i.id]=s}return t&&this.textureBudgeter&&(this.textureBudgeter.updateBudget(this.slots),this.updateSystemQualityRanges()),this._chunkSlotsSet}removeChunks(e){for(const t of e){const e=this.chunkIdToSlot[t.id];if(e){if(e.chunks.delete(t),0===e.chunks.size){e.unloaded=!0,e.setTexture(null);const i=this.slots.indexOf(e);this.slots.splice(i,1),delete this.textureNameToSlot[t.textureName]}delete this.chunkIdToSlot[t.id]}else ve.error("Missing slot for chunk!")}}setQuality(e,t){this._systemMin=e,this._systemMax=t,this.updateSystemQualityRanges()}updateSystemQualityRanges(){const e=(0,ae.qT)();this.minQuality={},this.maxQuality={};for(const t of new Set([...this.slots.map((e=>e.lod))]).values())this.minQuality[t]=e.nearestQuality(t,this._systemMin),this.maxQuality[t]=e.nearestQuality(t,this._systemMax);for(const e of this.slots)e.minQuality=this.minQuality[e.lod],e.maxQuality=e.maxQuality?Math.min(this.maxQuality[e.lod],e.maxQuality):this.maxQuality[e.lod]}get textureCount(){return this.slots.length}loadAll(e){if(!this.slots[0]||!this.slots[0].textureName)return Promise.resolve([]);const t=(0,ae.qT)();if(!t.valid(e))return ve.warn(e,"not found in",t),Promise.resolve([]);const i=this.slots.map((t=>this.loadTexture(t,e,!1)));return Promise.all(i)}onWebGLContextLost(){this.abortController.abort();for(const e of this.slots)e.texture=null}onWebGLContextRestored(){this.abortController=new AbortController;for(const e of this.slots)this.loadTexture(e,e.quality)}async loadTexture(e,t,i=!0){var s,o;const r=(0,ae.qT)();r.valid(t)||ve.warn(t,"not found in",r);const n=r.get(t),a=(null===(s=e.chunkedTexInfo)||void 0===s?void 0:s.maxTextureSize)||n.assetSize,h=Math.min(a,n.textureSize);e.lastLoadedAt=performance.now();let l=e.texture;if(!l||t!==e.quality){if(l&&t<e.quality&&e.texture){const i=null===(o=e.chunks.values().next().value)||void 0===o?void 0:o.embeddedTexture;if(i&&i.image.width>=h&&i.mipmaps[0].data.length<=h*h*4)return e.quality=t,void e.setTexture(i);{const i=this.renderToTextureModule.resizeTexture(l,h);return Me(i,e),e.quality=t,void e.setTexture(i)}}e.loading=!0,this.loadingTextures++,this.totalTextures[h]=(this.totalTextures[h]||0)+1;try{const s=await e.getUrl(t);l=this.textureLOD!==T.l.NONE&&i?await this.loadTextureTiled(s,h,t,e,this.abortController.signal):await this.loadTextureSolid(s,h,t,this.abortController.signal),e.unloaded?l.dispose():(Me(l,e),e.setTexture(l))}catch(e){}finally{this.loadingTextures--,e.quality=t,e.loading=!1}}}async loadTextureTiled(e,t,i,s,o){var r;const n=this.renderer.initSizedTexture2D(t,{generateMipmaps:!1,minFilter:g.LinearFilter,magFilter:g.LinearFilter}),a=(0,ae.qT)(),h=(null===(r=s.chunkedTexInfo)||void 0===r?void 0:r.maxTextureSize)||a.get(i).assetSize,l=Math.min(h,a.get(i).textureSize),d=Math.min(l,a.get(i).tileSize),c=h/(l/d),u=async(t,i)=>{const s={};let r;c!==d&&(s.width=`${d}`),c!==h&&(s.crop=`${c},${c},x${t/l},y${i/l}`),this.downloadingTiles+=1,this.totalTiles+=1;const a=E.ZP.flipDownload;try{r=await this.urls.getImageBitmap(e,d,d,{priority:ne.ru.LOW,flipY:a,signal:o},s)}finally{this.downloadingTiles-=1}const u=t,m=E.ZP.flipUpload?l-i-d:i,p=new ye._("mesh/texture/upload-tiles",(()=>this.engine.after(we.A.End).then((()=>{if(o.aborted)throw new DOMException("Aborted","AbortError");n.flipY=a&&r instanceof HTMLImageElement,this.renderer.uploadTexture2D(r,n,u,m)}))),100);return(await this.engine.commandBinder.issueCommand(p)).promise.finally((()=>{var e,t;r&&(null===(t=(e=r).close)||void 0===t||t.call(e))}))},m=[];for(let e=0;e<l;e+=d)for(let t=0;t<l;t+=d)m.push(u(e,t));try{await Promise.all(m)}catch(e){throw n.dispose(),e}return n}async loadTextureSolid(e,t,i,s){var o,r;const n=this.renderer.initSizedTexture2D(t);let a=null;try{const t=(0,ae.qT)().get(i).textureSize,h=E.ZP.flipDownload;a=await this.urls.getImageBitmap(e,t,t,{priority:ne.ru.LOW,flipY:h,signal:s},{width:`${t}`}),n.flipY=h&&a instanceof HTMLImageElement,this.renderer.uploadTexture2D(a,n,0,0)}catch(e){throw n.dispose(),e}finally{a&&(null===(r=(o=a).close)||void 0===r||r.call(o))}return n}analyzeTextureScreenCoverageFromRaycasts(){const e=this.renderer.getSize().x,t=(new g.Vector3).copy(this.camera.position),i=(0,ae.qT)();for(const s of this.slots){s.screenCoverage=0,s.screenCoverageScore=0,s.maxQuality=s.minQuality;const o=s.sightings.getList(),r=s.sightings.index-1;for(let n=0;n<o.length;n++){const a=o[(r-n+o.length)%o.length];if(a.raycastAge<this.chunkVisibilityChecker.raycastCounter-E.ZP.sightingMaxAge)break;const h=t.distanceTo(a.point),l=(0,ge._U)(h,this.camera.projectionMatrix,e);let d=i.fromPixelSize(s.lod,l);d=Math.min(d,this.maxQuality[s.lod]),s.screenCoverageScore+=d,s.screenCoverage+=1,s.maxQuality=Math.max(d,s.maxQuality)}}this.slots.sort(((e,t)=>t.screenCoverageScore-e.screenCoverageScore)),this.textureBudgeter.updateTargetQualitiesFromBudget()}update(e){if(!this.camera||!this.autoLoadTiles||this.abortController.signal.aborted)return;this.textureBudgeter.update(e);const t=performance.now();this.textureLOD===T.l.RAYCAST&&this.scheduleRaycastTasks(t);let i=!1;for(let e=this.slots.length-1;e>=0;e--){const s=this.slots[e],o=(0,fe.uZ)(s.targetQuality,s.minQuality,s.maxQuality),r=t-s.lastLoadedAt<1e3;if(!s.loading&&s.quality>o){r?i=!0:this.loadTexture(s,o);break}}if(this.allowTextureDownload()&&!i){const e=(0,ae.qT)();for(const t of this.slots){if(this.loadingTextures>=this.concurrentLoadingTextures||this.downloadingTiles>=this.concurrentDownloadingTiles)break;const i=(0,fe.uZ)(t.targetQuality,t.minQuality,t.maxQuality);!t.loading&&t.quality<i&&this.loadTexture(t,e.moreDetailed(t.lod,t.quality))}}E.ZP.debugRttScores&&this.textureScoreRenderPass.render(this.modelObject,this.camera,!0,E.ZP.debugRttClear),E.ZP.debugRttQuality&&this.textureQualityRenderPass.render(this.modelObject,this.camera,!0,E.ZP.debugRttClear)}scheduleRaycastTasks(e){if(!this.analyzeTaskPromise&&e-this.lastSortedAt>200){const e=()=>{this.analyzeTextureScreenCoverageFromRaycasts(),this.lastSortedAt=performance.now()},t=async e=>{await e.promise,this.analyzeTaskPromise=null},i=new ye._("mesh/texture/analyze-screen-coverage",e,100);this.analyzeTaskPromise=this.engine.commandBinder.issueCommand(i).then(t)}}}function Me(e,t){e.addEventListener("dispose",(()=>{e===t.texture&&ve.warn("Streamed texture disposed while still in use")}))}var xe=i(92324),be=i(16769),De=i(7402),Se=i(64210);const Ce=Math.round(E.ZP.sightingMaxAge/60/5)||1;class Pe{constructor(e,t,i){this.scene=e,this.raycaster=t,this.raycastCounter=0,this.onNewSighting=new Set,this.poseSetAt=0,this.raycastRandomScreenLocation=(()=>{const e=new g.Vector3,t=new g.Vector3,i=new g.Vector3;return(s,o,r)=>{this.raycastCounter++;const n=(2-2*o)/s,a=-1+o,h=this.raycastCounter%(s*s),l=h%s,d=a+(h-l)/s*n,c=a+l*n+Math.random()*n,u=d+Math.random()*n;e.set(c,u,-1).unproject(this.camera),t.set(c,u,1).unproject(this.camera),i.subVectors(t,e).normalize();const m=this.raycaster.pick(e,i,be.Pv);if(m){if(m.face&&m.object instanceof De.g){const e=m.object.getChunk(m.face.materialIndex),t={point:m.point.clone(),raycastAge:this.raycastCounter};for(const i of this.onNewSighting.values())i(e,t)}r&&r(m)}}})(),this.camera=e.camera,i.pose.onChanged((()=>{this.poseSetAt=this.raycastCounter}))}update(){const e=E.ZP.debugLOD?(0,Se.e)(65280,this.scene):void 0,t=performance.now();for(let i=0;i<Ce&&performance.now()-t<.5&&this.raycastCounter<=this.poseSetAt+E.ZP.sightingMaxAge;i++)this.raycastRandomScreenLocation(5,.05,e)}notifyOnNewSighting(e){return(0,L.k1)((()=>this.onNewSighting.add(e)),(()=>this.onNewSighting.delete(e)),!0)}}var ke=i(92901),Oe=i(31362);const Ee=i.p+"images/uv_grid_opengl.jpg";var Fe=i(87926);class Be{constructor(){this.materials=new Map}get(e){let t=this.materials.get(e);return t||(t=Re[e](),this.materials.set(e,t)),t}}const Re={[F.S.Depth](){const e=g.UniformsUtils.clone(x.Z.depth.uniforms);return new g.RawShaderMaterial({fragmentShader:x.Z.depth.fragmentShader,vertexShader:x.Z.depth.vertexShader,uniforms:e,side:g.FrontSide,name:"materialDepth"})},[F.S.Transparent](){const e=g.UniformsUtils.clone(x.Z.modelOutside.uniforms);return e.opacity.value=.2,e.colorOverlay.value.set(1,1,1,1),new g.RawShaderMaterial({fragmentShader:x.Z.modelOutside.fragmentShader,vertexShader:x.Z.modelOutside.vertexShader,uniforms:e,side:g.FrontSide,transparent:!0,name:"materialTransparent"})},[F.S.Wireframe](){const e=g.UniformsUtils.clone(x.Z.modelOutside.uniforms);return e.opacity.value=.5,e.colorOverlay.value.set(1,1,1,1),new g.RawShaderMaterial({fragmentShader:x.Z.modelOutside.fragmentShader,vertexShader:x.Z.modelOutside.vertexShader,uniforms:e,side:g.FrontSide,transparent:!0,wireframe:!0,name:"materialWireframe"})},[F.S.UV]:()=>new g.MeshBasicMaterial({name:"uv-debug",map:(0,Fe.p)(Ee)})};class Ae{constructor(){this._side=g.FrontSide,this.renderingMode=F.S.Standard,this.chunkMaterials={},this.modeMaterials=new Be,this.globalUniforms={}}set side(e){this._side=e;for(const t in this.chunkMaterials){this.chunkMaterials[t].name.includes("f")||(this.chunkMaterials[t].side=e)}}get side(){return this._side}forEachChunkMaterial(e){const{chunkMaterials:t}=this;for(const i in t)e(t[i])}dispose(){const{chunkMaterials:e}=this;for(const t in e){const i=e[t];for(const e in i.uniforms)i.uniforms[e].value instanceof g.Texture&&i.uniforms[e].value.dispose();i.dispose(),delete e[t]}}}class Ie extends s.Y{constructor(){super(...arguments),this.name="model-mesh",this.chunkSharedState=new Ae,this.onMeshTrimGroupChanged=e=>{this.setTrimsForMeshGroup(e)},this.updateTrimVisibilityForViewmode=e=>{if(this.meshTrimUniforms&&e!==this.meshTrimUniforms.isPanoMode){this.meshTrimUniforms.isPanoMode=e;for(const e of this.meshTrimData.meshTrimsByMeshGroup.keys)this.setTrimsForMeshGroup(e)}},this.updateMeshTrim=e=>{this.meshTrimUniforms.setMeshTrim(e),this.setTrimsForMeshGroup(e.meshGroup)},this._renderMode=v.k.Hidden,this.meshTrimFilter=e=>{const t=e.object,i=e.point;let s=!1,o=!1;if(this.meshTrimData&&this.viewmodeData&&(0,be.Pv)(t)){for(const e of this.meshTrimData.activeTrimsForMeshGroup(t.meshGroup)){const t=e.isPointTrimmed(i,this.viewmodeData.isPano());if(e.discardContents){if(t)return!1}else s=s||!t,o=!0}if(o)return s}return!0}}async init(e,t){y||(g.Mesh.prototype.raycast=f.uL,g.BufferGeometry.prototype.computeBoundsTree=f.Xy,g.BufferGeometry.prototype.disposeBoundsTree=f.sn,y=!0),this.engine=t,this.market=t.market;const[s,n,d,p,T,M,x,b,D,S]=await Promise.all([t.getModuleBySymbol(o.y.WEBGL_RENDERER),t.getModuleBySymbol(o.y.RAYCASTER),t.getModuleBySymbol(o.y.MODEL_DATA),t.market.waitForData(h.T),t.getModuleBySymbol(o.y.INPUT),t.getModuleBySymbol(o.y.RENDER_TO_TEXTURE),t.market.waitForData(a.M),t.market.waitForData(u.O),t.market.waitForData(l.Z),t.getModuleBySymbol(o.y.SWEEP_PANO)]),C=await t.getModuleBySymbol(o.y.SETTINGS);this.appData=await t.market.waitForData(r.pu),this.sweepData=D,this.viewmodeData=b;const P=s.getScene(),k=d.getSignedUrls(),O=p.model,F=O.uuid,{chunkSharedState:B}=this,R=t.claimRenderLayer(this.name);this.panoRenderer=S.getRenderer();const A=this.roomMeshData=new xe.s;B.maxVaryings=s.maxVaryings,this.chunkVisibiltyChecker=new Pe(P,n.picking,x);const I=O.tileset&&C.tryGetProperty(E.iT,!1)&&!(0,Oe.Q0)()?await Promise.all([i.e(217),i.e(764),i.e(648),i.e(948),i.e(189),i.e(321)]).then(i.bind(i,12322)):await Promise.all([i.e(217),i.e(764),i.e(648),i.e(948),i.e(189),i.e(321)]).then(i.bind(i,30425));this.modelMesh=await I.createModelMesh({uuid:F,urls:k,renderLayer:R,engine:t,settings:E.ZP,modelData:p,roomMeshData:A,chunkSharedState:B,chunkFactory:(e,t,i,s)=>{const o=new W(e,t,i,B,s,!0);if(this.meshTrimUniforms){const t=this.meshTrimUniforms.getSharedFloorUniforms(e);o.setMaterialsUniform(t)}return o},chunkVisibilityChecker:this.chunkVisibiltyChecker,gltfConfig:e.gltfConfig}),this.engine.market.register(this,xe.s,A);let _=Promise.resolve();const V=this.modelMesh;this.setupMarketData(V.chunks,D);let L=e.startingMode;switch(null===L&&(L=this.viewmodeData.transition.active?this.viewmodeData.transition.to:this.viewmodeData.currentMode),L){case m.Ey.Dollhouse:case m.Ey.Floorplan:case m.Ey.Mesh:this.setRenderMode(v.k.Mesh);break;default:this.setRenderMode(v.k.PanoramaMesh)}this.modelTextureLoader=new Te(e.textureLOD,k,this.modelMesh,P.camera,s.cwfRenderer,M,t,this.chunkVisibiltyChecker,s),this.setTextureStreamMode(e.textureLOD),_=this.modelMesh.initTextureLoader(this.modelTextureLoader,p.model.textures),n.setupOctree(this.modelMesh.boundingBox),this.modelMesh.registerCollision(T),this.renderer=new re(P.scene,this.modelMesh,this.modelMesh,this.panoRenderer,this.meshData,this.sweepData,this.appData,B,e),await t.addComponent(this,this.renderer),await _,this.bindings.push(this.engine.subscribe(c.Z,(e=>{this.renderer.updateExistingTexture(e.sweepId,e.renderTarget.texture)}))),this.bindings.push(t.commandBinder.addBinding(w.n,this.setPreviewPosition.bind(this)),t.subscribe(ke.zq,(()=>{this.modelTextureLoader.onWebGLContextLost()})),t.subscribe(ke.Xq,(()=>{this.modelTextureLoader.onWebGLContextRestored()}))),await this.bindMeshTrimListeners(n)}dispose(e){super.dispose(e),this.modelMesh.dispose(),this.modelTextureLoader.dispose(),this.roomMeshData.floors.clear(),this.roomMeshData.rooms.clear()}onUpdate(e){this.modelMesh.onUpdate(),this.modelTextureLoader&&!E.ZP.debugPauseTexStream&&this.modelTextureLoader.update(e),this.chunkVisibiltyChecker&&this.chunkVisibiltyChecker.update(),this.meshData.meshTextureOpacity.active&&(this.meshData.meshTextureOpacity.updateProgress(this.viewmodeData.transition.progress),this.meshData.commit());const t=performance.now()/1e3;for(const e of this.modelMesh.chunks)e.setTime(t)}setupMarketData(e,t){var i;const s=new Map,o=new Map,r=new g.Box3;e.forEach((e=>{e.geometry.boundingBox&&r.union(e.geometry.boundingBox),s.set(e.meshGroup,(s.get(e.meshGroup)||[]).concat(e)),o.set(e.meshSubgroup,(o.get(e.meshSubgroup)||[]).concat(e))}));const a=r.clone(),h=new g.Box3;t.iterate((e=>{e.isUnplaced()||(h.setFromCenterAndSize(e.position,n.f.UNIT),a.union(h))}));const l=new M._(0,[...r.min.toArray(),...r.max.toArray()],[...a.min.toArray(),...a.max.toArray()]);for(const[e,t]of s.entries()){const s=new g.Box3;t.forEach((e=>{e.geometry.boundingBox&&s.union(e.geometry.boundingBox)})),l.meshGroups.floors.set(e,{meshGroup:e,boundingBox:s,parentMeshGroup:null});const r=[...new Set(t.map((e=>e.meshSubgroup)))].sort(((e,t)=>t-e));l.meshGroups.roomsByFloor.set(e,r);const n=l.meshGroups.rooms;for(const t of r){const s=new g.Box3;(o.get(t)||[]).forEach((e=>{e.geometry.boundingBox&&s.union(e.geometry.boundingBox)}));const r={meshGroup:t,boundingBox:s,parentMeshGroup:e},a=n.get(t);a?a.parentMeshGroup=Math.min(null!==(i=a.parentMeshGroup)&&void 0!==i?i:1/0,e):n.set(t,r)}l.meshGroupVisuals.floorOpacity.set(e,1)}this.meshData=l,this.market.register(this,M._,this.meshData)}async bindMeshTrimListeners(e){this.meshTrimData=await this.engine.market.waitForData(d.Z),this.meshTrimUniforms=new D(this.getRenderMode()===v.k.PanoramaMesh);const{meshTrimsByMeshGroup:t}=this.meshTrimData;this.bindings.push(this.meshTrimData.onMeshGroupChanged(this.onMeshTrimGroupChanged),this.meshTrimData.onMeshTrimChanged(this.updateMeshTrim)),t.keys.forEach((e=>{this.setTrimsForMeshGroup(e)})),this.setMaterialsUniforms(-1);const i=()=>{e.setIntersectionFilter(this.meshTrimData.meshTrimsById.values.some((e=>e.enabled))?this.meshTrimFilter:null)};this.bindings.push(this.meshTrimData.onMeshTrimChanged(i)),i()}setTrimsForMeshGroup(e){const t=this.meshTrimData.getTrimsForMeshGroup(e);this.meshTrimUniforms.updateMeshTrimArrays(e,t),this.setMaterialsUniforms(e)}setMaterialsUniforms(e){const t=`${e}`;if("-1"===t)this.modelMesh.chunks.forEach((e=>{const t=this.meshTrimUniforms.getSharedFloorUniforms(e.meshGroup);e.setMaterialsUniform(t)}));else{const i=this.meshTrimUniforms.getSharedFloorUniforms(e);this.modelMesh.chunks.forEach((e=>{`${e.meshGroup}`===t&&e.setMaterialsUniform(i)}))}}async setPreviewPosition(e){const t=e.enabled&&e.previewCirclePosition?e.previewCirclePosition:null,i=e.size?e.size:.3;for(const e of this.modelMesh.chunks)e.setMeshPreviewSphere(t,i)}stats(){const e={};return e.textureCount=this.modelTextureLoader.textureCount,e}getRenderMode(){return this._renderMode}setRenderMode(e,t=p.Q9){let i=1;switch(e){case v.k.Hidden:i=1,this.modelMesh.visible=!1;break;case v.k.Mesh:i=1,this.modelMesh.visible=!0;break;case v.k.PanoramaMesh:i=0,this.modelMesh.visible=!0;break;case v.k.PanoramaCube:i=0,this.modelMesh.visible=!1;break;default:throw new Error(`unknown mode ${e}!`)}const s=this.meshData.meshTextureOpacity;s.value===i&&s.easing===t||(this.meshData.meshTextureOpacity.modifyAnimation(this.meshData.meshTextureOpacity.value,i,100,t),this.updateTrimVisibilityForViewmode(0===i)),this.log.debug(`setRenderMode from ${this._renderMode} to ${e}`),this._renderMode=e}setMeshOptions(e){var t;const i=null!==(t=e.overrideMaxDetail)&&void 0!==t?t:this.modelMesh.detail;this.modelMesh.overrideMaxDetail(i)}getMeshDetail(){return this.modelMesh.detail}setTextureLimits(e,t){this.modelMesh.setTextureQuality(this.modelTextureLoader,e,t)}setTextureStreamMode(e){switch(e){case T.l.NONE:this.modelTextureLoader.autoLoadTiles=!1;break;case T.l.RAYCAST:this.modelTextureLoader.autoLoadTiles=!0}}}},30425:(e,t,i)=>{"use strict";i.r(t),i.d(t,{createModelMesh:()=>b});var s=i(82668),o=i(17878),r=i(2224);class n extends r.y{constructor(e){super(e),this.name="MeshCreationException"}}var a=i(81396),h=i(7402),l=i(48917),d=i(17988);class c extends a.Object3D{constructor(e,t=o.o.ALL){super(),this.renderLayer=t,this.roomMeshes=new l.Z((e=>e.meshSubgroup)),this.boundingBox=new a.Box3,this.size=new a.Vector3,this.center=new a.Vector3,this._chunks=[],this.built=!1,this.name=`FloorMesh:${e}`,this.meshGroup=e}dispose(){this.reset(),this.roomMeshes.clear()}reset(){for(const e of this.roomMeshes)e.dispose(),this.remove(e);this._chunks.length=0,this.built=!1}addChunk(e){const t=this.getOrCreateRoomMesh(e.meshSubgroup);this._chunks.push(e),t.addChunk(e)}build(){if(this.built)throw new Error("build() should only be called once");this.boundingBox.makeEmpty();for(const e of this.roomMeshes)this.add(e),this.boundingBox.union(e.boundingBox);this.center=this.boundingBox.getCenter(this.center),this.size=this.boundingBox.getSize(this.size),this.built=!0}get chunks(){return this._chunks}getOrCreateRoomMesh(e){let t=this.roomMeshes.get(e);if(!t){t=new h.g(this.meshGroup,e,this.renderLayer);const i=new d.F(t);this.roomMeshes.add(t),this.add(t),this.add(i)}return t}}var u=i(1134),m=i(26544),p=i(97998),g=i(3614),f=i(75730);const y=new p.Z("dam-loader");class w{constructor(e){this.chunkFactory=e,this.decoder=i(92011)}async load(e,t,i){y.time("download");const s=await t.getFile(e,{responseType:"arraybuffer",onProgress:i});return y.timeEnd("download"),this.parse(s)}parse(e){y.time("parse proto");const t=this.decoder.binary_mesh.read(new g(e));y.timeEnd("parse proto"),y.time("convert to webgl");const i=this.convertProtobufToSceneObject(t);return y.timeEnd("convert to webgl"),i}convertProtobufToSceneObject(e){if(0===e.chunk.length)return y.warn("No chunks in damfile..."),[];const t=new a.Matrix4;t.set(1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1);return e.chunk.map((e=>{const i=new a.BufferGeometry;i.setAttribute("position",new a.BufferAttribute(new Float32Array(e.vertices.xyz,0,3),3)),e.vertices.uv.length>0&&i.setAttribute("uv",new a.BufferAttribute(new Float32Array(e.vertices.uv,0,2),2)),i.setIndex(new a.BufferAttribute(new Uint32Array(e.faces.faces,0,1),1)),i.applyMatrix4(t),i.computeBoundingBox();const{group:s,subgroup:o}=(0,f.xc)(e.chunk_name);return this.chunkFactory(s,o,i,e.material_name)}))}}var v=i(21270),T=i(31362);const M=new p.Z("mesh");class x extends u.e{constructor(e,t,i=o.o.ALL){super(),this.renderLayer=i,this.floorMeshes=new l.Z((e=>e.meshGroup)),this.built=!1,this.uuid=e,this.name=`ModelMesh:${e}`,this.signedUrls=t,this.layers.mask=i.mask}dispose(){super.dispose(),this.floorMeshes.mapElements((e=>{e.dispose(),this.remove(e)})),this.floorMeshes.clear(),this.built=!1}reset(){this.floorMeshes.mapElements((e=>{e.reset(),this.remove(e)})),this._chunks.length=0,this.built=!1}async load(e){const{roomMeshData:t}=e;(0,T.Q0)()&&(e.chunks=[]);let i=e.chunks?e.chunks:await class{static async load(e,t,i,s,o=0){const r=new w(i),n=(t.meshUrls?t.meshUrls:[{suffix:"_50k",extension:"dam"},{suffix:"",extension:"dam"}])[o];if(!n)return Promise.reject("No suitable model file found...");const{url:a,suffix:h,extension:l}=n,d=a?await a.get():`${e}${h}.${l}`;return r.load(d,t,s).catch((()=>this.load(e,t,i,s,++o)))}}.load(this.uuid,this.signedUrls,e.chunkFactory,e.onProgress).catch((e=>{M.error(e);const t=e instanceof Error?e.message:"Failed to load model mesh";throw new n(t)}));if(0===i.length){M.warn("No geometry found for model, loading faux geometry, disabling outside view-mode");const t=new a.PlaneGeometry(5,5,1,1);t.rotateX(-Math.PI/2),t.computeBoundingBox();const s=e.chunkFactory(0,0,t);s.sharedState.forEachChunkMaterial((e=>e.visible=!1)),i=[s]}i.forEach((e=>{this.addChunk(e)})),this.build(t)}addChunk(e){const t=this.getOrCreateFloorMesh(e.meshGroup);this._chunks.push(e),t.addChunk(e)}build(e){var t,i;if(this.built)throw new Error("build() should only be called once");let s=0,o=0;for(const e of this.floorMeshes){this.add(e);for(const o of e.roomMeshes)o.build(),o.geometry.boundsTree||null===(i=(t=o.geometry).computeBoundsTree)||void 0===i||i.call(t),s++;e.build(),o++}M.debug(`FloorMeshes: ${o} RoomMeshes: ${s} Chunks: ${this._chunks.length}`),this.boundingBox.makeEmpty();for(const e of this.floorMeshes)this.boundingBox.union(e.boundingBox);this.size=this.boundingBox.getSize(this.size),this.center=this.boundingBox.getCenter(this.center),e.root=this,e.floors=new Set(this.floorMeshes),e.rooms=this.roomMeshes,e.commit(),this.built=!0}get roomMeshes(){const e=new Set;for(const t of this.floorMeshes)for(const i of t.roomMeshes)e.add(i);return e}setSide(e){for(const t of this.floorMeshes)for(const i of t.roomMeshes)this.setSideRecursively(i,e)}async initTextureLoader(e,t){e.setModel(this,this.chunks,t,(()=>1/0)),await e.loadAll((0,m.qT)().min(v.V.Standard))}registerCollision(e){e.registerMesh(this,!0);for(const t of this.roomMeshes)e.registerSnappingMeshGeometry(t.name,t.geometry,{meshGroup:t.meshGroup})}setTextureQuality(e,t,i){e.setQuality(t,i)}onUpdate(){}setSideRecursively(e,t){e instanceof a.Mesh&&e.material&&e.material instanceof a.MeshBasicMaterial&&(e.material.side=t);for(const i of e.children)this.setSideRecursively(i,t)}getOrCreateFloorMesh(e){let t=this.floorMeshes.get(e);return t||(t=new c(e,this.renderLayer),this.floorMeshes.add(t),this.add(t)),t}}async function b({uuid:e,urls:t,renderLayer:i,engine:o,roomMeshData:r,chunkFactory:n}){const a=new x(e,t,i);return await a.load({roomMeshData:r,chunkFactory:n,onProgress:e=>{o.broadcast(new s.Z(e.loaded,e.total))}}),a}},51524:(e,t,i)=>{"use strict";i.d(t,{t:()=>a});var s=i(59279),o=i(53261),r=i(31362),n=i(21270);const a={urlTemplateToken:"<file>",initialMaxLOD:n.V.Min,nonMeshMaxLOD:n.V.Standard,maxLOD:n.V.High,minLOD:n.V.Min,loadSiblings:!0,displayActiveTiles:!1,autoDisableRendererCulling:!0,optimizeRaycast:!1,stopAtEmptyTiles:!1,errorTarget:Number((0,s.eY)("errorTarget",(0,r.tq)()?6:4)),disableTileUpdates:!1,errorMultiplierRaycastOcclusion:.1,errorMultiplierHiddenFloors:.01,disposeModel:!1,limitMemoryUsage:(0,r.tq)(),allocatedMegsBeforeLimitingLod:350,lruMinExtraTiles:(0,r.tq)()?0:100,lruMaxTiles:800,lruUnloadPercent:.05,tileAssetRequestPriority:o.ru.MEDIUM,downloadQueueConcurrency:8,parseQueueConcurrency:10,snappingMaxLOD:n.V.Standard}},12322:(e,t,i)=>{"use strict";i.r(t),i.d(t,{createModelMesh:()=>te});var s=i(69170),o=i(9037),r=i(2032),n=i(90365),a=i(81396),h=i(56692),l=i(53203),d=i(26544),c=i(99935),u=i(82668),m=i(1134),p=i(7402),g=i(26269),f=i(97998),y=i(74815),w=i(51524),v=i(35895),T=i(17099),M=i(21270);class x extends T.Z{constructor(e,t,i,s){super(),this.urlSigner=e,this.modelUrls=t,this.onProgress=s,this.priorityCallback=i}add(e,t){return super.add(e,(async e=>{var i,s,o;if(null===(i=null==e?void 0:e.content)||void 0===i?void 0:i.uri){const i=e.content.uri;try{const r=null===(s=this.onProgress)||void 0===s?void 0:s.bind(this,e);if(e.content.uri=await this.urlSigner(i),(null===(o=e.extras)||void 0===o?void 0:o.level)===M.V.Min)return t(e).then((e=>r?function(e,t){if(e.ok&&e.body){const i=e.body.getReader(),s=e.headers.get("Content-Length");let o=s?+s:0,r=0!==o,n=0;const a=new ReadableStream({async start(e){for(;;){const{done:s,value:a}=await i.read();if(a&&(n+=a.byteLength,e.enqueue(a)),s&&(o=n,r=!0),null==t||t(new ProgressEvent("progress",{lengthComputable:r,loaded:n,total:o})),s){e.close();break}}}});e=new Response(a)}return e}(e,r):e));{const i=window.fetch;try{return window.fetch=async(e,t)=>{const i=await this.modelUrls.getFile(e,{responseType:"blob",priority:w.t.tileAssetRequestPriority,onProgress:r,signal:null==t?void 0:t.signal});return new Response(i)},t(e)}finally{window.fetch=i}}}finally{e.content.uri=i}}}))}}var b=i(75730);const D=new a.Vector3,S=(new a.Matrix4).set(1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1),C=S.clone().invert();function P(e,t){if(!1!==t(e)&&e.children)for(const i of e.children)P(i,t)}function k(e,t){const{box:i,boxTransformInverse:s}=function(e){let t=O.get(e);if(!t){const i=e.boundingVolume.box,s=new a.Box3,o=new a.Matrix4,r=new a.Vector3(i[3],i[4],i[5]),n=new a.Vector3(i[6],i[7],i[8]),h=new a.Vector3(i[9],i[10],i[11]),l=r.length(),d=n.length(),c=h.length();r.normalize(),n.normalize(),h.normalize(),0===l&&r.crossVectors(n,h),0===d&&n.crossVectors(r,h),0===c&&h.crossVectors(r,n),o.set(r.x,n.x,h.x,i[0],r.y,n.y,h.y,i[1],r.z,n.z,h.z,i[2],0,0,0,1).invert(),s.min.set(-l,-d,-c),s.max.set(l,d,c),t={box:s,boxTransformInverse:o},O.set(e,t)}return t}(t);return D.copy(e).applyMatrix4(S).applyMatrix4(s),i.containsPoint(D)}const O=new WeakMap;var E=i(17988);var F=i(82854),B=i(1217);class R{constructor(e){this.parser=e,this.name="CrossModelTextureCache"}static addToLoader(e){e.pluginCallbacks.unshift((e=>new R(e)))}loadTexture(e){var t;const i=this.parser,s=i.json,o=s.textures[e];let r=o.source;Object.keys(o.extensions).forEach((e=>r=r||o.extensions[e].source));const n=null===(t=s.images[r])||void 0===t?void 0:t.uri;if(void 0===n)return null;const a=A.get(n);if(a)return a;let h=i._invokeOne((t=>t===this?null:t.loadTexture&&t.loadTexture(e)));h||(h=i.loadTexture(e));const l=h.then((e=>{const t=()=>{A.delete(n),null==e||e.removeEventListener("dispose",t)};return null==e||e.addEventListener("dispose",t),e}));return A.set(n,l),l}}const A=new Map;var I=i(17878),_=i(27896);class V{constructor(e){this.parser=e,this.name="MTTR_three_mesh_bvh"}async loadMesh(e){const t=async(t,i)=>{var s,o;const r=this.parser.json.meshes[e].primitives[i];if(null===(s=r.extensions)||void 0===s?void 0:s.MTTR_three_mesh_bvh){const e=null===(o=r.extensions)||void 0===o?void 0:o.MTTR_three_mesh_bvh,i={roots:(await Promise.all(e.roots.map((e=>this.parser.loadAccessor(e))))).map((e=>{const t=e.array;return t.byteLength!==t.buffer.byteLength?t.slice().buffer:t.buffer})),index:new Uint8Array(0)};t.geometry.boundsTree=_.r.deserialize(i,t.geometry,{setIndex:!1})}},i=[],s=await this.loadMeshInternal(e);if(s)if("Group"===s.type){const e=s;i.push(...e.children.map(((e,i)=>t(e,i))))}else"Mesh"===s.type&&i.push(t(s,0));return await Promise.all(i),s}async loadMeshInternal(e){const t=this.parser,i=t,s=this.parser.json.meshes[e],o=s.primitives,r=[];for(let e=0,s=o.length;e<s;e++){const s=void 0===o[e].material?t.createDefaultMaterial(i.cache):t.getDependency("material",o[e].material);r.push(s)}return r.push(t.loadGeometries(o)),Promise.all(r).then((function(i){const r=i.slice(0,i.length-1),n=i[i.length-1],h=[];for(let i=0,a=n.length;i<a;i++){const a=n[i],l=o[i];let d;const c=r[i];if(l.mode!==L.TRIANGLES&&void 0!==l.mode)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+l.mode);d=new p.g(0,0,I.o.DEFAULT),d.geometry=a,d.material=c,d.name=t.createUniqueName(s.name||"mesh_"+e),N(d,s),t.assignFinalMaterial(d),h.push(d)}if(1===h.length)return h[0];const l=new a.Group;for(let e=0,t=h.length;e<t;e++)l.add(h[e]);return l}))}}const L={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123};function N(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}var z=i(72348);class U extends z.KTX2Loader{constructor(e,t,i){super(i),this.urlSigner=e,this.modelUrls=t,this.taskCache=new WeakMap}load(e,t,i,s){const o=new a.CompressedTexture([],0,0);return this.urlSigner(e).then((async e=>{const s=await this.modelUrls.getFile(e,{onProgress:i,responseType:"arraybuffer",priority:w.t.tileAssetRequestPriority});let r=this.taskCache.get(s);if(!r){r={promise:this._createTexture(s)},this.taskCache.set(s,r)}const n=await r.promise;o.copy(n),o.needsUpdate=!0,t(o)})).catch(s),o}preload(){this.init()}}let G,j;var H,Q=i(60047),W=i(46950),Z=i(95912);class q extends T.Z{constructor(){super(...arguments),this.prioritizeBy=H.FRUSTUM_ERROR_THRESH,this.priorityCallback=(e,t)=>{switch(this.prioritizeBy){case H.FRUSTUM_ERROR_THRESH:return this.sortBySelectors(e,t,[e=>Number(e.__inFrustum),e=>Number(e.__error<=w.t.errorTarget),e=>e.__error,e=>e.__distanceFromCamera]);default:return this.defaultPriorityCallback(e,t)}}}sortBySelectors(e,t,i){for(const s of i){const i=this.compareTile(e,t,s);if(null!==i)return i}return 0}compareTile(e,t,i){const s=i(e),o=i(t);return s===o?null:s>o?1:-1}defaultPriorityCallback(e,t){return e.__depth!==t.__depth?e.__depth>t.__depth?-1:1:e.__inFrustum!==t.__inFrustum?e.__inFrustum?1:-1:e.__used!==t.__used?e.__used?1:-1:e.__error!==t.__error?e.__error>t.__error?1:-1:e.__distanceFromCamera!==t.__distanceFromCamera?e.__distanceFromCamera>t.__distanceFromCamera?-1:1:0}}!function(e){e.DEFAULT="DEFAULT",e.FRUSTUM_ERROR_THRESH="FRUSTUM_ERROR_THRESH"}(H||(H={}));var $=i(28714);const Y=new f.Z("tiled-mesh"),K=3;class J{constructor(e,t,i,s,o,r,n){this.container=e,this.threeRenderer=t,this.chunkFactory=i,this.tilesetInfo=s,this.commandBinder=o,this.modelUrls=r,this.gltfConfig=n,this.name="MttrTileLoader",this.loadStats={startTimes:{start:0,tileset:0,lod0:0},timings:{tileset:"",lod0:""}},this.lodDeferreds=[],this.tileProgress=new WeakMap,this.onChunksLoaded=new Set,this.onChunksUnloaded=new Set,this.tileSetLoaded=!1,this.minimalLoaded=!1,this.minimalTileCount=0,this.signUrl=async e=>{if(e.startsWith("blob"))return e;return(await this.tilesetInfo.urlTemplate.get()).replace(w.t.urlTemplateToken,e)},this.onTileGltfDownloadProgress=(e,t)=>{this.tileProgress.set(e,t.lengthComputable?.5*t.loaded/t.total:0),this.checkLoadStatus()},this.checkLoadStatus=(()=>{const e=[];let t=!1,i=!1;return(0,Z.P)((()=>{t&&i||!this.tileSetLoaded||(0===e.length&&(e.push([],[]),this.tilesRenderer.traverse(((t,i,s)=>{var o;const r=null===(o=t.extras)||void 0===o?void 0:o.level;return 0!==r&&1!==r||e[r].push(t),!1}),null)),t||(t=this.notifyIfFullyLoaded(0,e,!0),t&&(this.tilesRenderer.update(),Y.debug("LOD0 fully downloaded, allow showing more lods"),this.minimalLoaded=!0,this.minimalTileCount=e[0].length,this.loadStats.timings.lod0=(performance.now()-this.loadStats.startTimes.lod0).toFixed(1)+"ms")),i||(i=this.notifyIfFullyLoaded(1,e,!1),i&&(e.length=0)))}),16)})()}async init(){this.loadStats.startTimes.start=performance.now();const e=await this.signUrl(this.tilesetInfo.rootFilename);this.tilesRenderer=new y.I(e),this.tilesRenderer.manager=$.U;const t=function(e,t,i,s,o){G||(G=new F.DRACOLoader(t),G.setDecoderPath(`${o.dracoDecoderPath}`),G.preload());const r=new B.GLTFLoader(t);return r.setDRACOLoader(G),r.register((e=>new V(e))),R.addToLoader(r),j||(j=new U(i,s,t),j.setTranscoderPath(o.basisTranscoderPath),j.detectSupport(e),j.preload()),r.setKTX2Loader(j),r}(this.threeRenderer,this.tilesRenderer.manager,this.signUrl,this.modelUrls,this.gltfConfig);this.configureTilesRenderer(this.tilesRenderer,t)}setCamera(e,t,i){this.tilesRenderer.setCamera(e),this.tilesRenderer.setResolution(e,t,i)}hasCamera(e){return this.tilesRenderer.hasCamera(e)}deleteCamera(e){return this.tilesRenderer.deleteCamera(e)}notifyOnChunksLoaded(e){return(0,v.k1)((()=>this.onChunksLoaded.add(e)),(()=>this.onChunksLoaded.delete(e)),!0)}notifyOnChunksUnloaded(e){return(0,v.k1)((()=>this.onChunksUnloaded.add(e)),(()=>this.onChunksUnloaded.delete(e)),!0)}notifyOnLodProgress(e,t){this.getLodDeferred(e).progress(t)}awaitLod(e){return this.getLodDeferred(e).nativePromise()}getLodDeferred(e){return this.lodDeferreds[e]||(this.lodDeferreds[e]=new W.Q)}update(){const{minimalLoaded:e,tilesRenderer:t}=this;e?(t.displayActiveTiles=w.t.displayActiveTiles,t.loadSiblings=w.t.loadSiblings,t.stopAtEmptyTiles=w.t.stopAtEmptyTiles,t.autoDisableRendererCulling=w.t.autoDisableRendererCulling,t.downloadQueue.maxJobs=w.t.downloadQueueConcurrency,t.parseQueue.maxJobs=w.t.parseQueueConcurrency):(t.loadSiblings=!0,t.downloadQueue.maxJobs=1/0,t.parseQueue.maxJobs=1/0),t.optimizeRaycast=w.t.optimizeRaycast,t.errorTarget=w.t.errorTarget,t.lruCache.maxSize=e?Math.max(w.t.lruMaxTiles,this.minimalTileCount):1/0,t.update(),t.lruCache.minSize=w.t.lruMinExtraTiles+t.lruCache.usedSet.size,t.lruCache.unloadPercent=w.t.lruUnloadPercent}getDownloadParseStatus(){return this.tilesRenderer.stats}configureTilesRenderer(e,t){const i=e.calculateError.bind(e);e.calculateError=e=>{i(e),this.adjustScreenSpaceError&&(e.__error=this.adjustScreenSpaceError(e.__error,e))},e.manager.addHandler(/\gltf$/,t),e.manager.addHandler(/\glb$/,t),e.errorTarget=w.t.errorTarget,e.loadSiblings=w.t.loadSiblings,e.stopAtEmptyTiles=w.t.stopAtEmptyTiles,e.displayActiveTiles=w.t.displayActiveTiles;const s=e.preprocessNode.bind(e);e.preprocessNode=function(e,t,i){return s(e,t,"")},this.configurePriorityQueues(),this.container.add(e.group);const o=(new a.Quaternion).setFromAxisAngle(new a.Vector3(-1,0,0),a.MathUtils.degToRad(90));this.container.quaternion.copy(o),this.container.updateMatrixWorld(!0),e.onLoadTileSet=this.onLoadTileset.bind(this),e.onLoadModel=this.onLoadModel.bind(this),e.onDisposeModel=this.onDisposeModel.bind(this);const r=e.setTileActive.bind(e);e.setTileActive=(e,t)=>{r(e,t),this.onTileActiveChange&&this.onTileActiveChange(e,t)};const n=e.setTileVisible.bind(e);e.setTileVisible=(e,t)=>{n(e,t),this.onTileVisibleChange&&this.onTileVisibleChange(e,t)};const h=e.tileInView.bind(e);e.tileInView=e=>{let t=h(e);return this.adjustTileInView&&(t=this.adjustTileInView(t,e)),t}}configurePriorityQueues(){const{tilesRenderer:e}=this;e.downloadQueue=new x(this.signUrl,this.modelUrls,e.downloadQueue.priorityCallback,this.onTileGltfDownloadProgress),e.parseQueue=new q;const t=e=>{this.commandBinder.issueCommand(new Q._("mesh/tiled/priorityQueue",e,100))};e.parseQueue.schedulingCallback=t,e.downloadQueue.schedulingCallback=t}async onLoadModel(e,t){const i=function(e,t,i){var s;const o=[],r=(null===(s=t.extras)||void 0===s?void 0:s.id)||""+e.id;return e.name=r,e.traverse((s=>{var n,h;if(s.matrixAutoUpdate=!1,s.updateMatrix(),s instanceof p.g){const l=new E.F(s);e.add(l);const{group:d,subgroup:c,chunkIndex:u}=(0,b.xc)(`${r}-${s.name}`),m=s.material,p=m.map;let g=null!==(n=null==p?void 0:p.name)&&void 0!==n?n:m.name;g=g.replace(".jpg",""),p&&(p.encoding=a.LinearEncoding);const f=i(d,c,s.geometry,g);f.textureLODInfo=function(e,t){if(t&&(null==t?void 0:t.maxTextureSize)&&(null==t?void 0:t.texelSize)&&(null==t?void 0:t.textureScale)&&t.textureScale>0){const i=t.textureScale;return{name:e,maxTexelSize:.001*t.texelSize,maxTextureSize:t.maxTextureSize,minTexelSize:1/i*t.texelSize*.001,minTextureSize:i*t.maxTextureSize,minScale:i}}return null}(g,t.extras)||void 0,f.lod=(null===(h=t.extras)||void 0===h?void 0:h.level)||0,f.chunkIndex=u,f.notifyOnMaterialUpdated((e=>{s.material=e}));const y={};y.map=p,s.buildWithTileChunk(f),s.material=f.setMaterialsUniform(y),f.name=s.name,f.embeddedTexture=y.map,o.push(f)}})),e.matrixWorld.copy(e.matrix),e.matrixWorld.premultiply(C),e.children.forEach((e=>e.updateMatrixWorld(!0))),o}(e,t,this.chunkFactory);for(const e of i)this.container.addChunk(e);for(const e of this.onChunksLoaded.values())e(i,t);this.onModelLoaded&&this.onModelLoaded(e,t),this.tileProgress.set(t,1),await new Promise((e=>setTimeout(e,0))),this.checkLoadStatus()}onDisposeModel(e,t){e.traverse((e=>{if((0,g.oR)(e)){const i=e.chunks;if(!i)return void Y.error("Missing chunks from RoomMesh");for(const e of i)this.container.removeChunk(e);for(const e of this.onChunksUnloaded.values())e(i,t)}})),this.onModelUnloaded&&this.onModelUnloaded(e,t),e.traverse((e=>{(0,g.oR)(e)&&e.reset()}))}onLoadTileset(e,t){var i;const s=!this.loadStats.startTimes.lod0;let o="";s&&(o=(performance.now()-this.loadStats.startTimes.start).toFixed(1),this.loadStats.timings.tileset=o+"ms");const r=null===(i=t.match(/[^/]*\.json/))||void 0===i?void 0:i[0];Y.debug(`Tileset ${r} load${s?`: ${o}ms`:""}`,e),s&&(this.loadStats.startTimes.lod0=performance.now()),this.tileSetLoaded=!0,this.onTilesetLoaded&&this.onTilesetLoaded(e,t),this.tilesRenderer.update()}notifyIfFullyLoaded(e,t,i){if(!t[e])return!1;const s=t[e],o=s.filter((e=>e.__loadingState!==K)),r=this.getLodDeferred(e);return i&&r.notify(s.reduce(((e,t)=>e+(this.tileProgress.get(t)||0)/s.length),0)),0===o.length&&r.resolve(),0===o.length}}class X extends m.e{constructor(e,t=I.o.ALL,i){super(),this.uuid=e,this.renderLayer=t,this.chunkSharedState=i,this.boundingBox=new a.Box3,this.size=new a.Vector3,this.center=new a.Vector3,this.tilesByChunkId=new Map,this.bindings=[],this.roomMeshesByTile=new Map,this.activeRoomMeshes=new Set,this.visibleRoomMeshes=new Set,this.activeTiles=new Set,this.tileActiveDescendantCounts=new WeakMap,this.maxLOD=w.t.maxLOD,this.isActiveRoomMeshFilter=e=>this.activeRoomMeshes.has(e),this.isActiveRoomMeshSnapFilter=e=>{var t,i,s;const o=null===(t=e.meta)||void 0===t?void 0:t.tile;if(o){const{snappingMaxLOD:e}=w.t,t=null!==(s=null===(i=o.extras)||void 0===i?void 0:i.level)&&void 0!==s?s:1/0;if(t===e&&(this.tileActiveDescendantCounts.get(o)||0)>0||t<=e&&this.activeTiles.has(o))return!0}return!1},this.layers.mask=t.mask,this.overriddenIsTileInView=this.overriddenIsTileInView.bind(this)}dispose(){super.dispose(),this.bindings.forEach((e=>e.cancel())),this.bindings=[]}async load(e,t,i,s,o,a,l,d,c,m){this.renderer=t,this.tilesetInfo=o,a.root=this,this.maxLOD=o.maxLOD,this.tileLoader=new J(this,t.threeRenderer,l,o,e.commandBinder,c,m),await this.tileLoader.init(),this.tileLoader.setCamera(i,s.width,s.height),this.bindings.push(e.subscribe(h.a,(e=>{this.tileLoader.setCamera(i,e.width,e.height)}))),this.tileLoader.onModelLoaded=(e,t)=>{let i=this.roomMeshesByTile.get(t);i||(i=[],this.roomMeshesByTile.set(t,i)),e.traverse((e=>{e.layers.mask=this.renderLayer.mask,(0,g.oR)(e)&&(a.rooms.add(e),i.push(e),this.inputIni&&this.registerMeshForCollision(this.inputIni,e,t))})),a.commit()},this.tileLoader.onModelUnloaded=(e,t)=>{e.traverse((e=>{e instanceof p.g&&(a.rooms.delete(e),this.inputIni&&this.unregisterMeshFromCollision(this.inputIni,e))})),a.commit(),this.tileLoader.onTileActiveChange(t,!1),this.tileLoader.onTileVisibleChange(t,!1),this.roomMeshesByTile.delete(t)},this.tileLoader.onTileActiveChange=(e,t)=>{var i;const s=t?"add":"delete";null===(i=this.roomMeshesByTile.get(e))||void 0===i||i.forEach((e=>{this.activeRoomMeshes[s](e)})),this.activeTiles[s](e);for(let i=e.parent;i;i=i.parent){const e=this.tileActiveDescendantCounts.get(i)||0;this.tileActiveDescendantCounts.set(i,e+(t?1:-1))}},this.tileLoader.onTileVisibleChange=(e,t)=>{var i;null===(i=this.roomMeshesByTile.get(e))||void 0===i||i.forEach((e=>{this.visibleRoomMeshes[t?"add":"delete"](e)}))},this.initTileLodAdjustments(this.tileLoader,d),this.tileLoader.notifyOnLodProgress(0,(t=>{e.broadcast(new u.Z(t,1))})),this.tileLoader.notifyOnChunksLoaded(((e,i)=>{var s;0===(null===(s=i.extras)||void 0===s?void 0:s.level)&&e.forEach((e=>{t.threeRenderer.initTexture(e.embeddedTexture)}))})),this.tileLoader.update(),this._detail="minimal",await this.tileLoader.awaitLod(w.t.initialMaxLOD),this._detail="default",this.tileLoader.tilesRenderer.getBounds(this.boundingBox),this.boundingBox.applyMatrix4(C),this.boundingBox.getSize(this.size),this.boundingBox.getCenter(this.center),e.broadcast(new r.em(n.Y.StreamingMesh)),e.broadcast(new r.em(n.Y.StreamingTexture))}initTextureLoader(e,t){return(0,d.qT)().limitStreamingBelow(this.tilesetInfo.maxLOD-1),e.autoLoadTiles=!1,e.setModel(this,this._chunks,t,(()=>w.t.limitMemoryUsage?w.t.allocatedMegsBeforeLimitingLod*2**20:1/0)),this.bindings.push(this.tileLoader.notifyOnChunksLoaded((t=>{e.addChunkSlots(t);for(const e of this.onChunksLoaded.values())e(t)})),this.tileLoader.notifyOnChunksUnloaded((t=>{e.removeChunks(t)}))),e.allowTextureDownload=()=>{const{downloading:e,parsing:t}=this.tileLoader.getDownloadParseStatus();return 0===e&&0===t},Promise.resolve()}initTileLodAdjustments(e,t){e.adjustTileInView=this.overriddenIsTileInView;const i=this.tilesByChunkId,s=new Map;let o=0;this.bindings.push(e.notifyOnChunksLoaded(((e,t)=>{for(const s of e)i.set(s.id,t)})),t.notifyOnNewSighting(((e,t)=>{o++;const r=i.get(e.id);if(r){for(let e=r.parent;e;e=e.parent)s.set(e,o);P(r,(e=>!(e!==r&&!k(t.point,e))&&(s.set(e,o),!0)))}})),this.tileLoader.notifyOnChunksUnloaded((e=>{for(const t of e)i.delete(t.id),t.dispose()}))),e.adjustScreenSpaceError=(e,t)=>{var i,r;if(1!==w.t.errorMultiplierRaycastOcclusion){(null!==(i=s.get(t))&&void 0!==i?i:-1/0)<o-l.EJ.sightingMaxAge&&(e*=w.t.errorMultiplierRaycastOcclusion)}if(1!==w.t.errorMultiplierHiddenFloors){(null===(r=this.roomMeshesByTile.get(t))||void 0===r?void 0:r.some((e=>e.chunks.some((e=>e.getOpacity()>l.xx.FADE_TILE_VISIBLE_THRESHOLD)))))||(e*=w.t.errorMultiplierHiddenFloors)}return ee(t)<w.t.minLOD&&(e=Math.max(e,w.t.errorTarget+1e-10)),e}}registerCollision(e){this.inputIni=e,this.tileLoader.tilesRenderer.forEachLoadedModel(((t,i)=>{t.traverse((t=>{(0,g.oR)(t)&&this.registerMeshForCollision(e,t,i)}))}))}addChunk(e){this._chunks.push(e)}removeChunk(e){const t=this._chunks.indexOf(e);this._chunks.splice(t,1)}onUpdate(){w.t.disableTileUpdates||(this.tileLoader.update(),this.checkDispose()),this.downgradeIfMemoryConstrained()}setTextureQuality(e,t,i){e.setQuality(c.S.LOW,i)}get visibleChunks(){const e=this.visibleRoomMeshes;return{*[Symbol.iterator](){for(const t of e)for(const e of t.chunks)yield e}}}registerMeshForCollision(e,t,i){e.registerMesh(t,!0,this.isActiveRoomMeshFilter),t.chunks[0].lod<=w.t.snappingMaxLOD&&e.registerSnappingMeshGeometry(t.name,t.geometry,{tile:i,meshGroup:t.meshGroup},this.isActiveRoomMeshSnapFilter)}unregisterMeshFromCollision(e,t){e.unregisterMesh(t),e.unregisterSnappingMeshGeometry(t.name)}overriddenIsTileInView(e,t){const i=ee(t.parent);if("minimal"===this._detail&&-1===i)return!0;let s=w.t.nonMeshMaxLOD;return"max"===this._detail&&(s=w.t.maxLOD),"minimal"===this._detail&&(s=w.t.initialMaxLOD),!(i>=s)&&e}overrideMaxDetail(e){if(e!==this._detail)switch(this._detail=e,this._detail){case"minimal":this.setMaxLOD(0);break;case"max":this.setMaxLOD(null);break;default:this.setMaxLOD(w.t.nonMeshMaxLOD)}}setMaxLOD(e){e=null!=e?e:this.maxLOD;const t=w.t.maxLOD;if(w.t.maxLOD=e,w.t.maxLOD!==t){const e=Math.min(w.t.maxLOD,this.maxLOD);(0,d.qT)().limitStreamingBelow(e-1)}}downgradeIfMemoryConstrained(){this.renderer.estimatedGPUMemoryAllocated()>2**20*(w.t.limitMemoryUsage?w.t.allocatedMegsBeforeLimitingLod:1/0)&&w.t.maxLOD>0&&this.setMaxLOD(w.t.maxLOD-1)}checkDispose(){if(w.t.disposeModel){const e=this.tileLoader.tilesRenderer,t=e;for(const e of t.cameras)t.deleteCamera(e);const i=.001,s=new a.OrthographicCamera(-i,i,i,-i,i,2*i);s.position.set(0,-1e4,0),s.rotation.setFromVector3(new a.Vector3(0,-1,0)),s.updateMatrix(),s.updateMatrixWorld(),this.tileLoader.setCamera(s,100,100),e.lruCache.minSize=0,e.lruCache.unloadPercent=1,e.lruCache.markAllUnused(),e.update(),e.dispose(),this.chunkSharedState.dispose(),w.t.disableTileUpdates=!0}}}function ee(e){for(var t;e;){const i=null===(t=e.extras)||void 0===t?void 0:t.level;if("number"==typeof i)return i;e=e.parent}return-1}async function te({uuid:e,engine:t,renderLayer:i,settings:r,modelData:n,roomMeshData:a,chunkFactory:h,chunkVisibilityChecker:l,chunkSharedState:d,urls:c,gltfConfig:u}){r.flipDownload=!1,r.flipUpload=!1;const[m,p]=await Promise.all([t.getModuleBySymbol(s.y.WEBGL_RENDERER),t.market.waitForData(o.M)]),g=new X(e,i,d);return await g.load(t,m,m.getCamera(),p,n.model.tileset,a,h,l,c,u),g}},26269:(e,t,i)=>{"use strict";i.d(t,{$4:()=>r,oR:()=>o});var s=i(7402);const o=e=>!!e&&e instanceof s.g,r={hasMeshGroup:e=>"object"==typeof e&&!!e&&"meshGroup"in e,hasMeshSubgroup:e=>"object"==typeof e&&!!e&&"meshSubgroup"in e,isRoomMesh:o,isVisibleRoomMesh:e=>o(e)&&e.raycastEnabled&&e.visible}},26544:(e,t,i)=>{"use strict";i.d(t,{O7:()=>g,qT:()=>m});var s=i(69984),o=i(81396),r=i(21270),n=i(99935),a=i(2569),h=i(53203);class l{constructor(){this._configs={},this._orders={},this._maxLod=-1/0,this._maxTs=1/0,this._streamAbove=0,this.resetOnNextRegisterOnce=!1,this.dynamic=!1}static encodeKey(e,t){return e-t}get maxLod(){return this._maxLod}get maxTexelSize(){return this._maxTs}limitStreamingBelow(e){this._streamAbove=e}order(e,t=!1){return t&&!this._orders[e]&&(this._orders[e]=[]),this._orders[e]}reset(){this._configs={},this._orders={},this.dynamic=!1,this._maxTs=1/0,this._maxLod=-1/0}get isDynamic(){return this.dynamic}valid(e){return e in this._configs}get(e){if(!this.valid(e))throw new Error("invalid quality level "+e);return this._configs[e]}max(e){return e<this._streamAbove?this.min(e):this.order(e)[this.order(e).length-1]}min(e){return this.order(e)[0]}fromPixelSize(e,t){const i=this.order(e),s=this.min(e);let o=this.max(e);for(let e=i.length-1;e>=0;e--)t>this.get(i[e]).texelSize&&i.indexOf(o)>i.indexOf(s)&&(o=i[e]);return o}moreDetailed(e,t){let i=this.min(e);const s=this.max(e),o=this.order(e),r=o.indexOf(t);return r+1===o.length?s:(-1!==r&&(i=Math.min(s,o[r+1%o.length])),i)}lessDetailed(e,t){const i=this.order(e),s=i.indexOf(t);let o=t;return-1!==s&&(o=i[Math.max(0,s-1)]),o}minSize(){return Object.values(this._configs).sort(d)[0]}maxSize(){const e=Object.values(this._configs).sort(d);return e[e.length-1]}nearestQuality(e,t){const i=this.order(e),s=this.max(e),o=(0,a.et)(t,1,4,0,i.length-1);return Math.min(s,i[Math.round(o)])}registerQualities(e,t,i,s,o="max"){this.dynamic=!0,this.resetOnNextRegisterOnce&&(this.reset(),this.resetOnNextRegisterOnce=!1);const r=this._configs,n=this.order(e,!0),a=t*s;for(let s=t,d=i;s>=a;s*=.5,d*=2){const i=l.encodeKey(e,d),a=r[i];(!a||a&&a.assetSize<t)&&(this._maxTs=Math.min(this._maxTs,d),this._maxLod=Math.max(this._maxLod,e),r[i]={key:i,lod:e,texelSize:d,textureSize:s,assetSize:t,assetType:o,tileSize:Math.min(s,h.ZP.textureTileSize)}),-1===n.indexOf(i)&&n.push(i)}n.sort(((e,t)=>r[t].texelSize-r[e].texelSize))}}function d(e,t){return e.textureSize>t.textureSize?1:-1}const c=new l;var u;(u=c).reset(),u.registerQualities(r.V.Standard,512,.048,.5,"low"),u.registerQualities(r.V.Standard,2048,.012,.5,"high"),u.dynamic=!1,u.resetOnNextRegisterOnce=!0;const m=()=>c;const p={[n.S.LOW]:new o.Vector4(1,0,0,.5),[n.S.MEDIUM]:new o.Vector4(1,1,0,.5),[n.S.HIGH]:new o.Vector4(0,1,0,.5),[n.S.ULTRA]:new o.Vector4(0,1,1,.5)};function g(e){return e in p?p[e]:(0,s.G1)(.5,e)}},64210:(e,t,i)=>{"use strict";i.d(t,{d:()=>l,e:()=>h});var s=i(81396);const o=i(53203).ZP.sightingMaxAge,r=new s.Color;let n,a=-1;const h=(e,t)=>{n||(n=new s.InstancedMesh(new s.SphereGeometry(.005,8,4),new s.MeshBasicMaterial,o),d(n));const i=new s.Matrix4;return({point:s,distance:h})=>{i.makeScale(h,h,h).setPosition(s),n.setMatrixAt(++a%o,i),n.instanceMatrix.needsUpdate=!0;for(let t=o;t--;)n.setColorAt((a-t+o)%o,r.set(e).multiplyScalar(1-t/o));n.instanceColor&&(n.instanceColor.needsUpdate=!0),n.parent||t.scene.add(n)}},l=()=>{var e;n&&(null===(e=n.parent)||void 0===e||e.remove(n),d(n))};function d(e){const t=(new s.Matrix4).makeScale(0,0,0);for(let i=0;i<o;i++)e.setMatrixAt(i,t)}},75730:(e,t,i)=>{"use strict";i.d(t,{k7:()=>n,ko:()=>r,xc:()=>o});var s=i(81396);function o(e){const t=e.match(/group([0-9]+)/),i=e.match(/sub([0-9]+)/),s=e.match(/type([0-9]+)/),o=e.match(/mirror([0-9]+)/),r=e.match(/window([0-9]+)/),n=e.match(/chunk([0-9]+)/),a=e.match(/_chunk([0-9]+)/),h=s?parseInt(s[1],10):o&&!isNaN(parseInt(o[1],10))?100:r&&!isNaN(parseInt(r[1],10))?101:0;return{group:t?parseInt(t[1],10):0,subgroup:i?parseInt(i[1],10):0,chunkIndex:n?parseInt(n[1],10):0,nodeIndex:a?parseInt(a[1],10):0,type:h}}function r(e,t=!1){let i=e.getAttribute("barycentric");if(i)return i;const o=(e.getIndex()||e.getAttribute("position")).count/3,r=[];for(let e=0;e<o;e++){const i=t?1:0;e%2==0?r.push(0,0,1,0,1,0,1,0,i):r.push(0,1,0,0,0,1,1,0,i)}const n=new Float32Array(r);return i=new s.BufferAttribute(n,3),e.setAttribute("barycentric",i),i}function n(e=16777215*Math.random(),t=1){const i=function(e,t,i,s=1){const o=document.createElement("canvas");o.width=t,o.height=i;const r=o.getContext("2d");return r.fillStyle=`rgba(${255*e.r|0},${255*e.g|0},${255*e.b|0}, ${255*s|0})`,r.fillRect(0,0,t,i),o}(new s.Color(e),1,1,t),o=new s.CubeTexture([i,i,i,i,i,i]);return o.format=s.RGBAFormat,o.needsUpdate=!0,o}},65111:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Cursor:()=>o.C,SetMouseCursorCommand:()=>r.u,default:()=>n});var s=i(97542),o=i(34956),r=i(38987);class n extends s.Y{constructor(){super(...arguments),this.name="mouse-cursor",this.activeCursor=null}async init(e,t){this.config=Object.assign({classPrefix:"cursor"},e),this.bindings.push(t.commandBinder.addBinding(r.u,(async e=>this.changeCursor(e.cursor))))}changeCursor(e){const{container:t,classPrefix:i}=this.config;e!==this.activeCursor&&(this.activeCursor&&t.classList.remove(`${i}-${this.activeCursor}`),e&&t.classList.add(`${i}-${e}`),this.activeCursor=e)}}},37611:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>Ee});var s=i(97542),o=i(34029),r=i(69170),n=i(9037),a=i(64918),h=i(65636),l=i(5135),d=i(12039),c=i(41753);class u extends c.f{constructor(e){super(e),this.name="NavigationException"}}const m={Locked:"Cannot move while navigation is locked",InsideOnly:"Cannot navigate between panos when not in Panorama mode",InvalidSweep:"Not at a valid sweep",InTransition:"Cannot move while in a transition",NoDestinationFound:"Cannot move in that direction",InvalidMode:"Cannot move to mode"};var p=i(86819),g=i(23612),f=i(72996),y=i(94046),w=i(81396),v=i(33324),T=i(16769),M=i(20043),x=i(35826),b=i(38987),D=i(34956),S=i(76631),C=i(39642);class P{constructor(e,t,i,s,o,r,n,a,h,l){this.canStartTransition=e,this.commandBinder=t,this.input=i,this.floorsViewData=s,this.navigation=o,this.sweepData=r,this.cameraModule=n,this.toolsData=a,this.settingsData=h,this.meshQuery=l,this.bindings=[],this.cancelTransition=!1,this.didSetCursor=!1,this.targetFloorId=null,this.targetHitPoint=new w.Vector3,this.toggleInput=e=>{this.bindings.forEach((t=>e?t.renew():t.cancel()))},this.onRoomClick=(e,t,i)=>{if(this.shouldIgnore())return!1;if(!this.canStartTransition())return!1;if(!i||!i.point)return!1;const s=this.meshQuery.floorIdFromObject(t);if(!s)return!1;if(!this.floorsViewData.isNavigable(s))return this.onBackgroundClick();if(this.cancelTransition)return!0;const o=this.floorsViewData.currentFloorId;return 1!==this.floorsViewData.totalFloors&&s!==o?(this.targetFloorId||(this.targetFloorId=s,this.targetHitPoint.copy(i.point)),!o&&(this.changeFloorIfNeeded(),!0)):this.floorsViewData.roomSelectModeActive||this.floorsViewData.floorSelectModeActive?(this.cancelTransition=!0,this.cameraModule.cancelTransition().then((()=>this.navigation.navigateToPanoNearIntersection(i))).then((()=>{this.cancelTransition=!1})),this.commandBinder.issueCommand(new b.u(D.C.DEFAULT)),!0):this.floorsViewData.floorSelectModeActive?(this.cancelTransition=!1,!1):(this.navigation.focus(i.point).then((()=>{this.cancelTransition||this.setFocusSweep(i),this.cancelTransition=!1})),!0)},this.onBackgroundClick=()=>!this.shouldIgnore()&&(!!this.canStartTransition()&&(!!this.floorsViewData.showAllFloorsOption&&(!this.targetFloorId&&(!!this.cancelTransition||(this.cancelTransition=!0,void this.cameraModule.cancelTransition().then((()=>this.commandBinder.issueCommand(new v.Vw(null,!1)))).then((()=>{this.cancelTransition=!1}))))))),this.onBackgroundHover=()=>{if(this.shouldIgnore())return!1;const{activeToolName:e}=this.toolsData;return null!==this.floorsViewData.currentFloorId&&e!==S.w1.LABELS&&e!==S.w1.ROOM_BOUNDS&&(this.didSetCursor=!0,this.commandBinder.issueCommand(new b.u(D.C.FINGER))),!1},this.onBackgroundUnhover=()=>(this.shouldIgnore()||this.didSetCursor&&(this.commandBinder.issueCommand(new b.u(D.C.DEFAULT)),this.didSetCursor=!1),!1),this.onFloorChange=()=>{this.shouldIgnore()||null===this.floorsViewData.currentFloorId&&this.commandBinder.issueCommand(new b.u(D.C.DEFAULT))},this.clearFloorChange=()=>{this.targetFloorId=null},this.changeFloorIfNeeded=async()=>{this.targetFloorId&&(await this.commandBinder.issueCommand(new v.Vw(this.targetFloorId,!1,void 0,this.targetHitPoint)),this.targetFloorId=null)},this.bindings.push(this.input.registerMeshHandler(p.R,f.s.is(T.Pv),this.onRoomClick,{default:!0}),this.input.registerUnfilteredHandler(p.R,this.clearFloorChange),this.input.registerHandler(p.R,this.changeFloorIfNeeded),this.input.registerMeshHandler(p.R,f.s.isType(y.i),this.onBackgroundClick,{default:!0}),this.input.registerMeshHandler(g.z,f.s.isType(y.i),this.onBackgroundHover),this.input.registerMeshHandler(g.A,f.s.isType(y.i),this.onBackgroundUnhover),this.floorsViewData.makeFloorChangeSubscription(this.onFloorChange))}async setFocusSweep(e){if(!this.canStartTransition())return;if(this.cancelTransition)return;const t=(0,M.bG)(this.sweepData,!1,e,this.meshQuery);t.length>0&&t[0].sweep&&await this.commandBinder.issueCommand(new x.aK(t[0].sweep.id))}shouldIgnore(){return!this.settingsData.tryGetProperty(C.Q,!1)}}var k=i(90304),O=i(32597),E=i(12250),F=i(89553),B=i(6667),R=i(82814),A=i(16782),I=i(97998);const _=new I.Z("nav-input");class V{constructor(e,t,i){this.navigation=e,this.inputIni=t,this.insideNav=[],this.insideVrNav=[],this.toggleInput=e=>{this.insideNav.forEach((t=>e?t.renew():t.cancel()))},this.toggleVrInput=e=>{this.insideVrNav.forEach((t=>e?t.renew():t.cancel()))},this.registerInsideClickHandlers=e=>[e.registerMeshHandler(p.R,f.s.is(T.Pv),((e,t,i)=>this.tryExecuteAction(((e,t)=>U(e)&&L(t)),((e,t)=>L(t)&&this.navigation.navigateTowardsIntersection(t)),e,i)),{default:!0}),e.registerMeshHandler(p.R,f.s.isType(y.i),((e,t,i)=>this.tryExecuteAction(((e,t)=>U(e)&&L(t)),((e,t)=>L(t)&&this.navigation.navigateTowardsIntersection(t)),e,i)),{default:!0})],this.registerVrClickHandlers=e=>[e.registerMeshHandler(p.R,f.s.isInstanceOf(R.S),((e,t,i)=>this.tryExecuteAction(((e,t)=>U(e)&&L(t)),((e,t)=>L(t)&&this.navigation.navigateToPanoNearIntersection(t)),e,i)),{default:!0})],this.registerWheelInput=e=>[e.registerHandler(E.a,(e=>this.tryExecuteAction((e=>!0),(e=>{if(e instanceof E.a){const t=new w.Vector3(0,0,Math.sign(e.delta.y));return!!this.navigation.navigateInLocalDirection(t)}return!1}),e)))],this.hotkeys=e=>[e.registerHandler(F.e,(e=>this.tryExecuteAction((e=>(N(e)||z(e))&&e.key in V.hotkeyDirections),(e=>{if(N(e)){this.continuousMovementHotkey=e.key;const t=V.hotkeyDirections[e.key];this.navigation.setContinuousNavigationLocalDirection(t)}else z(e)&&e.key===this.continuousMovementHotkey&&this.navigation.setContinuousNavigationLocalDirection();return!1}),e)))],this.tryExecuteAction=(e,t,i,s)=>{let o=!1;try{this.navigation.isNavigationInputAllowed()&&e(i,s)&&(o=t(i,s))}catch(e){if(!(e instanceof u))throw _.warn(e),e;_.debug(e)}return o},this.insideVrNav.push(...this.registerVrClickHandlers(this.inputIni)),this.insideNav.push(...this.registerInsideClickHandlers(this.inputIni),...this.hotkeys(this.inputIni)),i&&this.insideNav.push(...this.registerWheelInput(this.inputIni))}get bindings(){return[...this.insideNav,...this.insideVrNav]}}function L(e){return void 0!==e&&void 0!==e.point}function N(e){return e instanceof F.e&&e.state===B.M.DOWN}function z(e){return e instanceof F.e&&e.state===B.M.UP}function U(e){return e instanceof p.R&&e.button===A.M.PRIMARY}V.hotkeyDirections={[O.R.W]:k.f.FORWARD,[O.R.A]:k.f.LEFT,[O.R.S]:k.f.BACK,[O.R.D]:k.f.RIGHT,[O.R.UPARROW]:k.f.FORWARD,[O.R.DOWNARROW]:k.f.BACK};const G=new I.Z("nav-input");class j{constructor(e,t,i){this.navigation=e,this.input=t,this.settings=i,this.bindings=[],this.toggleInput=e=>{G.debug("toggling dollhouse input",e),this.bindings.forEach((t=>e?t.renew():t.cancel()))},this.bindings.push(...this.registerEnterPanoHandler())}registerEnterPanoHandler(){return[this.input.registerMeshHandler(p.R,f.s.isInstanceOf(R.S),((e,t,i)=>!this.settings.tryGetProperty(C.Q,!1)&&(!!this.navigation.isNavigationInputAllowed()&&(e.button===A.M.PRIMARY&&void 0!==i&&this.navigation.navigateToPanoNearIntersection(i)))),{default:!0})]}}var H=i(53954),Q=i(41326),W=i(23254),Z=i(95882),q=i(14715),$=i(79727),Y=i(91380),K=i(67944),J=i(40731);function X(e){if(e&&"object"==typeof e&&"min"in e&&"max"in e){const t=e;if((0,J.u)(t.min)&&(0,J.u)(t.max))return!0}return!1}var ee=i(88338);class te{constructor(e,t,i){this.canStartTransition=e,this.pose=t,this.cameraModule=i,this.focus=this.focus.bind(this),this.focusFloorplan=this.focusFloorplan.bind(this)}async focus(e,t){if(!this.canStartTransition())return;let i,s;X(e)?(s=e,i=s.getCenter(new w.Vector3)):(i=e,s=void 0);const{from:o,transition:r,mode:n}=null!=t?t:{};if(n===Z.Ey.Floorplan)return this.focusFloorplan(i);let{position:h,rotation:l,focalDistance:d}=this.pose;l=ie(l),o?(h=o,l=(0,K.n0)(h,i)):s?({focalDistance:d,rotation:l,position:h}=this.getPoseForBox({box:s,targetRotation:l})):h=(0,K.fd)(l,i,d);const c={pose:{position:h,rotation:l},transitionType:null!=r?r:a.n.Interpolate,focalDistance:d,transitionTime:ee.E.TRANSITION_TIME_DH};return this.cameraModule.moveTo(c).nativePromise()}focusFloorplan(e){const t=new w.Plane,i=new w.Vector3(0,0,1).applyQuaternion(this.pose.rotation);t.setFromNormalAndCoplanarPoint(i,e);const s=(0,K.Fe)(this.pose.position,this.pose.rotation,t);if(!s)return Promise.resolve();const o=(new w.Vector3).copy(e).sub(s),r=(new w.Vector3).copy(this.pose.position).add(o);return this.cameraModule.moveTo({transitionType:a.n.Interpolate,pose:{position:r}}).nativePromise()}getPoseForBox({box:e,targetRotation:t}){const i=t||this.pose.rotation;const s=this.pose.aspect(),o=e.getCenter(new w.Vector3),r={targetPosition:o,targetRotation:i.clone(),angleDown:undefined,box:e,fovY:2*Math.atan(1/this.pose.projection.elements[5]),aspectRatio:s},n=(0,K.YN)(r),a=o.distanceTo(n.position);return{position:n.position,rotation:n.rotation,focalDistance:a}}}const ie=(()=>{const e=Math.PI/180*-60,t=new w.Vector3,i=new w.Vector3(0,1,0),s=new w.Vector3(1,0,0);return o=>{t.set(0,0,-1).applyQuaternion(o);const r=t.angleTo(i),n=Math.abs(r-Math.PI);return r<.1||n<.1?(new w.Quaternion).setFromAxisAngle(s,e):o}})();var se=i(98169),oe=i(81248),re=i(69505),ne=i(2569),ae=i(59370),he=i(93642);const le=!0,de=8,ce=.1,ue=-25,me=500,pe=-2,ge=32,fe=32;class ye{constructor(e,t,i,s,o){this.cameraData=e,this.sweepData=t,this.viewmodeModule=i,this.picking=s,this.issueCommand=o,this.tryNavigateToPoint=async(e,t,i,s,o,r,n)=>{const h=n?n.slice():[],l=r?r.slice():[];if(h.push(se._T()),h.push(se._k()),l.push(this.scoreByLatitude(e,ge)),t===a.n.Interpolate&&(0,Z.Bw)(this.viewmodeModule.currentMode)&&this.sweepData.currentSweep){const t=this.sweepData.currentSweep,i=this.sweepData.getSweep(t),s=i.position.clone().sub(e).normalize();h.push(se.T3(i)),l.push(oe.o7(e,s))}h.push(this.withinLatitudeFilter(e)),h.push(this.notTooCloseFilter(e)),le||h.push(this.notTooFarFilter(e)),l.push(oe.Dv(e,pe));const c=this.sweepData.sortByScore(h,l),u=this.sweepData.currentSweepObject,m=new w.Vector3;let p=null,g=!1,f=null;const y=(0,Z.Bw)(this.viewmodeModule.currentMode),v=null!=o?o:15,T=y&&u?new Set(u.neighbours.filter((e=>this.sweepData.getSweep(e).position.distanceTo(u.position)<v)).concat([u.id])):new Set;for(const o of c)if(this.sweepCanSeeNote(e,o.sweep)){if(f=o.sweep,t===a.n.Interpolate||T.has(f.id)){m.copy(e).sub(f.position).normalize(),g=!0;const o=this.getSweepToPointRotation(f.position,e,s),r=this.cameraData.pose.projection.asThreeMatrix4(),{width:n,height:h}=this.cameraData,l=(0,ae.bD)(e,f.position,o,n,h,r);i&&i(l),p=y?this.issueCommand(new d.ju({transition:a.n.Interpolate,sweep:f.id,rotation:o})):this.viewmodeModule.switchToMode(Z.Ey.Panorama,t,{rotation:o,sweepID:f.id})}break}return!(!f||!g&&t===a.n.Interpolate)&&(p||(p=this.issueCommand(new d.ju({transition:t,transitionTime:me,sweep:f.id,rotation:this.getSweepToPointRotation(f.position,e,s)}))),p&&await p,!0)},this.getSweepToPointRotation=(e,t,i)=>{const s=(0,K.n0)(e,t);return i&&s.multiply(i),(0,ne.Z)(s)},this.sweepCanSeeNote=(()=>{const e=new w.Vector3;return(t,i)=>{e.copy(t).sub(i.position);const s=e.length();e.normalize();let o=this.picking.pick(i.position,e,T.Pv);return(!o||o.distance>s)&&(o=this.picking.pick(t,e.negate(),T.Pv)),!o||s<=o.distance}})(),this.notTooCloseFilter=e=>t=>Math.abs(t.position.x-e.x)>ce||Math.abs(t.position.z-e.z)>ce,this.notTooFarFilter=e=>t=>t.position.distanceTo(e)>de,this.withinLatitudeFilter=e=>t=>{const i=(new w.Vector3).copy(e).sub(t.position),s=-Math.atan(i.y/Math.sqrt(i.x*i.x+i.z*i.z)),o=(0,re.Id)(ue);return he.zf-o<s&&s<he.uQ+o},this.scoreByLatitude=(()=>{const e=new w.Vector3;return(t,i)=>s=>{e.copy(t).sub(s.position);const o=Math.abs(Math.atan(e.y/Math.sqrt(e.x*e.x+e.z*e.z)))/(Math.PI/2),r=Math.floor(20*o)/20;return i*(1-r)}})(),this.scoreByDirection=(()=>{const e=new w.Vector3,t=new w.Vector3;return(i,s,o)=>r=>{if(Math.abs(s.dot(k.f.UP))>.75)return 0;t.copy(s).normalize(),e.copy(i).sub(r.position).normalize();return-1*e.dot(t)*o}})(),this.scoreByFloor=(e,t)=>i=>i.floorId===e?t:0}async focusPin(e,t,i,s,o){const{anchorPosition:r,stemNormal:n,stemLength:a}=e,h=r.clone().add(n.clone().setLength(a)),l=[this.scoreByDirection(h,n,fe),this.scoreByFloor(e.floorId,32)];return this.focusPoint(h,t,i,s,o,l)}focus(e,t){var i;let s,o;return X(e)?(o=e,s=o.getCenter(new w.Vector3)):(s=e,o=void 0),this.focusPoint(s,null!==(i=null==t?void 0:t.transition)&&void 0!==i?i:a.n.Interpolate,void 0,void 0,void 0,(null==t?void 0:t.from)?[oe.Dv(null==t?void 0:t.from,100)]:[],[se.no(s,.25)])}async focusPoint(e,t,i,s,o,r,n){if(this.cameraData.canTransition()&&this.sweepData.canTransition()&&!await this.tryNavigateToPoint(e,t,i,s,o,r,n)){if(t!==a.n.Interpolate)return this.goToNearestSweep(e,t,i,s);try{await this.issueCommand(new Q._i(Q.BD.DOLLHOUSE,a.n.Interpolate))}catch(o){await this.goToNearestSweep(e,t,i,s)}await this.tryNavigateToPoint(e,t,i,s,o,r,n)||await this.goToNearestSweep(e,t,i,s)}}async goToNearestSweep(e,t,i,s){const o=e,r=this.sweepData.getClosestSweep(o,!0);if(!r)throw new Error("Cannot find sweep closest to Mattertag disc");const n=this.getSweepToPointRotation(r.position,o,s),h=this.cameraData.pose.projection.asThreeMatrix4(),{width:l,height:c}=this.cameraData,u=(0,ae.bD)(o,r.position,n,l,c,h);i&&i(u),await this.issueCommand(new d.ju({sweep:r.id,rotation:n,transition:t||a.n.Interpolate}))}}var we=i(26256),ve=i(75287);class Te extends ve.T{constructor(e=1,t=0){super(),this._slowdown=!0,this._initialSpeed=0,this._speed=0,this._acceleration=1,this._desiredAcceleration=1,this._jerk=1,this._maxSpeed=1,this._minSpeed=.05,this._startValue=0,this._value=0,this._endValue=e,this._delay=t}get active(){return this._active}get currentValue(){return this._value}get endValue(){return this._endValue}get speed(){return this._speed}get isSlowingDown(){return this._isSlowingDown}get maxSpeed(){return this._maxSpeed}get acceleration(){return this._acceleration}getProgressPercent(){return(this._value-this._startValue)/(this._endValue-this._startValue)}onComplete(e){return this._onComplete=e,this}setStartValue(e){return this._startValue=e,this}setCurrentValue(e){return this._value=e,this}setEndValue(e){return this._endValue=e,this}setInitialSpeed(e){return this._initialSpeed=e,this}setMaxSpeed(e){return this._maxSpeed=e,this}setDesiredAcceleration(e){return this._desiredAcceleration=e,this._jerk=3*Math.abs(this._desiredAcceleration-this._acceleration),this}activate(e){return this._active=e,this}setAccel(e){return this._acceleration=Math.abs(e),this}start(){this._active=!0,this._value=this._startValue,this._speed=this._initialSpeed}setSlowdown(e){return this._slowdown=e,this}tick(e){if(!this._active||e<=0)return;if(this._delay>0)return void(this._delay-=e);e>33&&(e=33);const t=.001*e,i=this._value,s=this._speed*t,o=(0,ne.r_)(i,this.endValue,s),r=this._endValue-i<=this.getSlowdownDistance(),n=this._slowdown&&r,a=n?this._minSpeed:this._maxSpeed,h=this.acceleration*t;this._speed=(0,ne.r_)(this._speed,a,h),this._isSlowingDown=n;const l=this._desiredAcceleration,d=this._jerk*t;return this._acceleration=(0,ne.r_)(this._acceleration,l,d),this._value=o,o===this.endValue?(this.activate(!1),this.commit(),void(this._onComplete&&this._onComplete())):void 0}getSlowdownDistance(){const e=this.speed,t=this._acceleration,i=e/(0===t?1e-5:t);return this.speed*i+.5*t*i*i}stop(e){this._active=!1,this._endValue=e,this.commit()}}var Me=i(46950),xe=i(74903),be=i(27641);const De=new I.Z("walk");class Se{constructor(e,t,i,s,o,r,n){this.cameraPose=e,this.sweepTransition=t,this.sweepControl=i,this.cameraControl=s,this.generators=o,this.navigation=r,this.active=!1,this.path=[],this.lastQueueTime=0,this.repeatedQueueDelayMS=150,this.positionTracker=(new Te).setAccel(15).setMaxSpeed(5),this.baseTransitionTime=h.ZP.camera.baseTransitionTime,this.baseTransitionSpeed=h.ZP.camera.transitionSpeed,n.onPropertyChanged(xe.baseTransitionSpeedKey,(e=>{this.baseTransitionTime=e}))}get isActive(){return this.active}get targetSweep(){return this.nextSweep}setContinuousMovementDirection(e){this.continuousMovementDirection=e,!this.active&&e&&this.navigation.navigateInLocalDirection(e)}stop(){this.path.length=0,this.cameraControl.endExternalTransition(),this.startingSweep=void 0,this.nextSweep=void 0,this.active=!1,this.generator&&(this.generators.stopGenerator(this.generator),this.generator=null)}appendNode(e,t){if(!this.canQueueSweeps(e))return Promise.resolve();if(!e)return Promise.resolve();if(this.path.push(e),this.lastQueueTime=Date.now(),!this.active){this.active=!0,this.startingSweep=t;const{generator:i,deferred:s}=this.createTransition();this.generators.startGenerator(i),this.generator=i,this.activePromise=s.nativePromise().then((()=>{this.activePromise=null})),this.positionTracker.setEndValue(this.getDistanceToSweep(e)),this.checkForSpeedIncrease(e)}return this.activePromise?this.activePromise:Promise.resolve()}canQueueSweeps(e){if(e&&this.path.indexOf(e)>=0)return!1;return!(this.path.length>=2)&&!(this.active&&Date.now()-this.lastQueueTime<this.repeatedQueueDelayMS)}attemptContinuousNavigation(){try{this.continuousMovementDirection&&this.navigation.navigateInLocalDirection(this.continuousMovementDirection)}catch(e){if(!(e instanceof u||e instanceof be.f))throw De.warn(e),e;De.debug(e)}}createTransition(){const e=this,t=new Me.Q;return{generator:function*(){let i=Date.now();e.cameraControl.beginExternalTransition();const s=(new w.Vector3).copy(e.cameraPose.position),o=new w.Vector3,r=new w.Vector3,n=e.positionTracker;for(n.setMaxSpeed(5).setAccel(15);e.path.length>0;){const t=e.nextSweep?e.nextSweep.id:e.startingSweep,a=e.path.shift();if(!a){e.nextSweep=void 0;break}e.nextSweep=a,s.copy(e.cameraPose.position);const h=s.distanceTo(a.position);for(n.setStartValue(0).setEndValue(h).setInitialSpeed(n.speed).activate(!0),r.subVectors(a.position,s),r.normalize(),yield new we.M8(e.sweepControl.activateSweepUnsafe({sweepId:a.id}).then((()=>{e.sweepControl.beginSweepTransition({sweepId:a.id,internalProgress:!1,prevSweepId:t})}))),n.start(),e.checkForSpeedIncrease(a);n.active;){const t=Date.now()-i,h=0===e.path.length;let l=!1,d=!1;if(!h){const t=e.path[0];l=n.endValue-n.currentValue+a.position.distanceTo(t.position)<n.getSlowdownDistance();const i=o.subVectors(t.position,a.position);i.normalize();r.dot(i)<.3&&(d=!0)}n.setSlowdown(h||l||d),n.tick(t);const c=n.getProgressPercent();e.cameraControl.updateCameraPosition(o.lerpVectors(s,a.position,c)),e.sweepTransition.progress.modifyAnimation(c,1,0),i=Date.now(),e.continuousMovementDirection&&e.canQueueSweeps()&&n.isSlowingDown&&e.attemptContinuousNavigation(),n.active&&(yield new we.Jj)}e.sweepControl.endSweepTransition({sweepId:a.id,prevSweepId:t})}t.resolve(),e.stop()},deferred:t}}getDistanceToSweep(e){return(this.nextSweep?this.nextSweep.position:this.cameraPose.position).distanceTo(e.position)}checkForSpeedIncrease(e){const t=this.positionTracker,i=this.getDistanceToSweep(e),s=t.endValue-t.currentValue,o=s+i-t.getSlowdownDistance();if(s+i>12){const e=this.baseTransitionTime,i=this.baseTransitionSpeed,s=.001*(e+Math.log2(1+o)*xe.TRANSITION_DISTANCE_MULTIPLIER*i)-t.maxSpeed/t.acceleration,r=o/s;s>0&&t.setMaxSpeed(r).setDesiredAcceleration(3*r)}else t.setMaxSpeed(5).setDesiredAcceleration(15)}}var Ce=i(59625);class Pe{constructor(e,t,i,s,o,r,n,a){this.engine=e,this.navigation=t,this.settingsData=i,this.cameraData=s,this.cameraModule=o,this.viewmodeData=r,this.floorsViewData=n,this.toolsData=a,this.defaultSize=(new w.Vector3).fromArray([3,3,3])}async enforceLabelEditorFriendlyViewmode(e){var t;let i=this.settingsData.tryGetProperty(C.Q,!1)&&this.viewmodeData.isDollhouse();this.toolsData.activeToolName!==S.w1.LABELS&&(i&=this.settingsData.tryGetProperty(Ce.gx.LabelsDollhouse,!0));let s=!0;if(await(null===(t=this.cameraData.transition.promise)||void 0===t?void 0:t.nativePromise()),!this.viewmodeData.isFloorplan()&&!i)try{await this.engine.commandBinder.issueCommand(new Q._i(Q.BD.FLOORPLAN,a.n.Interpolate))}catch(e){s=!1}return(e&&e!==this.floorsViewData.currentFloorId||null===this.floorsViewData.currentFloorId)&&await this.engine.commandBinder.issueCommand(new v.Vw(e||this.floorsViewData.getHighestVisibleFloorId())),s}async navigateToLabel(e){try{const t=await this.enforceLabelEditorFriendlyViewmode(e.floorId);return await this.navigation.focus((new w.Box3).setFromCenterAndSize(new w.Vector3(0,1,0).add(e.position),this.defaultSize)),t}catch(e){return!1}}}var ke=i(2032),Oe=i(90365);class Ee extends s.Y{constructor(){super(...arguments),this.name="navigation",this.navigationRules=[()=>!0],this.navigationEnabled=!0,this.inputOutside=[],this.addNavigationRule=e=>{-1===this.navigationRules.indexOf(e)&&this.navigationRules.push(e)},this.removeNavigationRule=e=>{const t=this.navigationRules.indexOf(e);-1!==t&&this.navigationRules.splice(t,1)},this.isNavigationInputAllowed=()=>{const e=this.navigationRules.reduce(((e,t)=>e&&t()),!0);return!(!this.navigationEnabled||!e)||(this.log.debug("Cannot move while navigation is locked",{blockedByRules:!e,blockedByCommand:!this.navigationEnabled}),!1)}}async init(e,t){const{market:i}=t;this.commandBinder=t.commandBinder,this.bindings.push(this.commandBinder.addBinding(d.ZK,(async()=>this.lockNavigation())),this.commandBinder.addBinding(d.Lp,(async()=>this.unlockNavigation())),this.commandBinder.addBinding(d.zs,(async e=>{const{focusPosition:t,transition:i,orientationAdjust:s,onSweepChosen:o,neighborDistanceThreshold:r}=e;return this.navigationPoint.focusPoint(t,i,o,s,r)})),this.commandBinder.addBinding(d.OR,(async e=>{const{pinPosition:t,transition:i,orientationAdjust:s,onSweepChosen:o,neighborDistanceThreshold:r}=e;return this.navigationPoint.focusPin(t,i,o,s,r)})),this.commandBinder.addBinding(d.ju,(e=>this.navigateToSweep(e.sweep,e.rotation,e.transition,e.transitionTime,e.transitionSpeedMultiplier))),this.commandBinder.addBinding(d.Cs,(async({position:e,floorId:t,viewmodeOnly:i})=>i?this.navigationLabel.enforceLabelEditorFriendlyViewmode():!(!e||!t)&&this.navigationLabel.navigateToLabel({position:e,floorId:t}))),this.commandBinder.addBinding(d.L4,(async e=>this.navigateToPose(e.pose)))),[this.settingsData,this.sweepData,this.sweepModule,this.viewmodeData,this.viewmodeModule,this.cameraData,this.cameraModule,this.interactionmodeData,this.meshQuery]=await Promise.all([i.waitForData(o.e),i.waitForData(H.Z),t.getModuleBySymbol(r.y.SWEEP_DATA),i.waitForData(W.O),t.getModuleBySymbol(r.y.VIEWMODE),i.waitForData(n.M),t.getModuleBySymbol(r.y.CAMERA),i.waitForData(l.Z),t.getModuleBySymbol(r.y.MESH_QUERY)]);const[s,a,h]=await Promise.all([t.getModuleBySymbol(r.y.RAYCASTER),i.waitForData(Y.t),i.waitForData($.c)]);this.navigationPoint=new ye(this.cameraData,this.sweepData,this.viewmodeModule,null==s?void 0:s.picking,t.commandBinder.issueCommand),this.navigationLabel=new Pe(t,this,this.settingsData,this.cameraData,this.cameraModule,this.viewmodeData,h,a);const c=await t.getModuleBySymbol(r.y.INPUT);this.inputOutside.push(new j(this,c,this.settingsData));const u=()=>this.isNavigationInputAllowed()&&this.viewmodeData.canStartTransition()&&!h.transitionActive&&this.sweepData.canTransition(),m=()=>u()&&(this.viewmodeData.isDollhouse()||this.viewmodeData.isFloorplan()||this.viewmodeData.isOrthographic());this.navigationOutside=new te(m,this.cameraData.pose,this.cameraModule),this.inputOutside.push(new P(m,t.commandBinder,c,h,this,this.sweepData,this.cameraModule,a,this.settingsData,this.meshQuery)),this.inputInside=new V(this,c,!!e.enableWheel),this.inputOutside.forEach((e=>this.bindings.push(...e.bindings))),this.bindings.push(...this.inputInside.bindings),this.updateInputBindings(),this.bindings.push(this.viewmodeData.makeModeChangeSubscription((()=>{this.viewmodeData.currentMode!==Z.Ey.Transition&&this.updateInputBindings()}))),this.navigationWalk=new Se(this.cameraData.pose,this.sweepData.transition,this.sweepModule,this.cameraModule,t,this,this.settingsData),t.broadcast(new ke.em(Oe.Y.Navigation))}updateInputBindings(){const e=this.interactionmodeData.isVR(),t=this.viewmodeData.isInside();this.inputInside.toggleInput(t&&!e),this.inputInside.toggleVrInput(t&&e),this.inputOutside.forEach((e=>e.toggleInput(!t)))}navigateInLocalDirection(e){const t=this.cameraData.pose.rotation;return this.navigateInDirection(e.clone().applyQuaternion(t))}setContinuousNavigationLocalDirection(e){this.navigationWalk.setContinuousMovementDirection(e)}navigateTowardsIntersection(e){try{this.navigateInDirection(e.point.clone().sub(this.cameraData.pose.position))}catch(e){return!1}return!0}navigateToPanoNearIntersection(e){const t=(0,M.bG)(this.sweepData,this.viewmodeData.isInside(),e,this.meshQuery),i=t.length>0?t[0].sweep:this.sweepData.getClosestSweep(e.point,!0),s=h.y4[this.interactionmodeData.mode];if(this.viewmodeData.isInside()&&i)return this.navigateToSweep(i.id,void 0,s),!0;if(this.viewmodeData.canSwitchViewMode(Z.Ey.Panorama)){const e=i?i.id:void 0;return this.commandBinder.issueCommand(new Q._i(Q.BD.INSIDE,s,{sweepID:e})),!0}return!1}navigateInDirection(e){if(!this.viewmodeData.isInside())throw new u(m.InsideOnly);if(!this.sweepData.currentSweep)throw new u(m.InvalidSweep);const t=h.y4[this.interactionmodeData.mode],i=(0,M.Tq)(this.sweepData,e,this.navigationWalk.isActive?.65:void 0,this.navigationWalk.isActive?this.navigationWalk.targetSweep:void 0);if(i.length>0&&i[0].sweep)return this.navigateToSweep(i[0].sweep.id,void 0,t);throw new u(m.NoDestinationFound)}async focus(e,t){if(!(t=Object.assign({mode:this.viewmodeData.currentMode,transition:a.n.Interpolate},t)).mode||!this.isNavigationInputAllowed())throw new u(m.Locked);try{switch(t.mode){case Z.Ey.Panorama:await this.navigationPoint.focus(e,t);break;case Z.Ey.Dollhouse:case Z.Ey.Floorplan:await this.viewmodeModule.switchToMode(t.mode,t.transition),await this.navigationOutside.focus(e,t);break;default:throw this.log.warn(`navigation.focus: ${t.mode} not implemented yet`),new u(m.InvalidMode)}}catch(i){throw this.log.debug("Unable to set focus",e,t,i),i}}lockNavigation(){this.navigationEnabled=!1,this.log.debug("Navigation input locked")}unlockNavigation(){this.navigationEnabled=!0,this.log.debug("Navigation input unlocked")}async navigateToSweep(e,t,i,s,o){const r=this.settingsData.tryGetProperty(q.gj,a.n.Interpolate);let n;void 0===i&&(i=r);const h=this.sweepData.currentSweep;if(i===a.n.Interpolate){const t=!h||this.sweepData.isSweepAligned(h),s=this.sweepData.isSweepAligned(e),o=h!==e,r=!t||!s,n=this.viewmodeData.isInside();o&&r&&n&&(i=a.n.FadeToBlack)}if(this.viewmodeData.isInside()){const r=void 0===t&&void 0===s&&void 0===o,h=this.cameraData.canTransition()&&this.sweepData.canTransition();if(i===a.n.Interpolate&&this.sweepData.currentSweep!==e&&r&&(h||this.navigationWalk.isActive)){const t=this.sweepData.getSweep(e);n=this.navigationWalk.appendNode(t,this.sweepData.currentSweep)}else{if(!h)return this.sweepData.currentSweep;n=this.sweepModule.moveToSweep({transitionType:i,sweepId:e,rotation:t,transitionTime:s,transitionSpeedMultiplier:o})}}else n=this.viewmodeModule.switchToMode(Z.Ey.Panorama,i,{sweepID:e,rotation:t});return await n,this.sweepData.currentSweep}navigateToPose(e){const t={2:Q.BD.DOLLHOUSE,3:Q.BD.FLOORPLAN},{sweepIndex:i,quaternion:s,mode:o}=e;let{panoId:r,position:n}=e;if(!r&&void 0!==i){const e=this.sweepData.getSweepByIndex(i);e&&(r=e.id)}if(r)this.commandBinder.issueCommand(new d.ju({sweep:r,rotation:s,transition:a.n.FadeToBlack}));else{if(!(o in t))throw new Error("Unknown navigation link pose: "+JSON.stringify(e));this.commandBinder.issueCommand(new Q._i(t[o],a.n.Interpolate,{rotation:s,position:n}))}}}},88338:(e,t,i)=>{"use strict";i.d(t,{E:()=>s});const s={longerTransitionMaxDist:10,TRANSITION_TIME_DH:650}},20043:(e,t,i)=>{"use strict";i.d(t,{Tq:()=>n,bG:()=>h});var s=i(98169),o=i(81248),r=i(88338);const n=(e,t,i,s,...o)=>a({sweepData:e,direction:t,directionFactor:i,sourceSweep:s,ignoreSweeps:o}),a=e=>{const{sweepData:t,direction:i,sourceSweep:r,ignoreSweeps:n,directionFactor:a}=e;if(!t.currentSweepObject)return[];const h=r||t.currentSweepObject,l=[s.ff(h),s._k(),s.vO(h),s.pI(h.position,i,a)];for(const e of n)l.push(s.ff(e));const d=[o.o7(h.position,i),o.TE(h.position)],c=t.getSweepNeighbours(h);return t.sortByScore(l,d,c)},h=(e,t,i,n)=>{const a=[s._k(),s._T()],h=[o.Dv(i.point)],l=e.currentSweepObject;t&&l&&a.push(s.ff(l),s.SF(l.position,r.E.longerTransitionMaxDist),s.vO(l)),i.face&&a.push(s.D5(i.point,i.face.normal));const d=n.floorIdFromObject(i.object);d&&h.push(o.Bv(d));const c=e.sortByScore(a,h);if(0===c.length){const t=e.getClosestSweep(i.point,!0);c.push({sweep:t,score:0})}return c}},44649:(e,t,i)=>{"use strict";i.d(t,{B:()=>c});var s=i(81396),o=i(31546),r=i(41602),n=i(21646),a=i(2569),h=i(67944),l=i(41835),d=i(46950);class c extends l.Z{constructor(e,t,i,n,a=!1){super(),this.cameraPoseProxy=e,this.getDefaultZoom=t,this.targetProjection=new o.M,this.currentOrientation=new s.Quaternion,this.currentPosition=new s.Vector3,this.positionDelta=new s.Vector3,this.linearAccel=new s.Vector2,this.linearVelocity=new s.Vector2,this.zoomAccel=0,this.zoomVelocity=0,this.scale=1,this.maxZoom=0,this.minZoom=r.Tm,this.poseController=null,this.checkBounds=a,this.bounds=i.clone(),this.boundsCenter=n.clone(),this.setupBounds(),this.transition={active:!1,startTime:0,elapsed:0,duration:0,linearVelocity:new s.Vector2,zoomVelocity:0,easeOut:!1}}setController(e){return this.poseController=e,this}start(){this.scale=1,this.maxZoom=this.getDefaultZoom()*r.Ct}setPanAcceleration(e,t=!1,i){if(!this.transition.active){t&&this.haltVelocity(e,this.linearVelocity);const s=this.cameraPoseProxy.pose,o=s.projection.elements[0],r=s.projection.elements[5];this.linearAccel.x=void 0!==e.x?e.x/o:this.linearAccel.x,this.linearAccel.y=void 0!==e.y?e.y/r:this.linearAccel.y,void 0!==i&&this.linearAccel.setLength(i)}}setZoomAcceleration(e){this.transition.active||(this.zoomAccel=e)}haltVelocity(e,t){e.x&&t.x&&Math.sign(e.x)!==Math.sign(t.x)&&(t.x=0),e.y&&t.y&&Math.sign(e.y)!==Math.sign(t.y)&&(t.y=0)}startRotateTransition(e,t,i){return Promise.resolve()}startTranslateTransition(e,t,i=!0){return this.startTransition(e,0,t.clone().multiplyScalar(r.SI),0,i).nativePromise()}startZoomTransition(e,t,i){return this.startTransition(e,0,new s.Vector2(0,0),t,i).nativePromise()}startTransition(e,t,i,s,o){const r=new d.Q;return this.poseController?(this.transition.active=!0,this.transition.duration=e,this.transition.elapsed=0,this.transition.startTime=Date.now(),this.transition.deferred=r,this.transition.linearVelocity.copy(i),this.transition.zoomVelocity=s,this.transition.easeOut=o,this.linearAccel.set(0,0),this.zoomAccel=0,this.linearVelocity.copy(i),this.zoomVelocity=s,this.poseController.beginExternalTransition(),r.promise()):r.resolve().promise()}stopTransition(){var e;this.transition.active&&(null===(e=this.poseController)||void 0===e||e.endExternalTransition(),this.transition.active=!1),this.transition.deferred&&(this.transition.deferred.resolve(),this.transition.deferred=void 0)}updateTransition(e,t,i){this.transition.elapsed+=e;const s=this.getTransitionScale(e);t&&(this.linearVelocity.copy(this.transition.linearVelocity).multiplyScalar(s),this.pan(this.linearVelocity)),i&&(this.zoomVelocity=this.transition.zoomVelocity*s,this.zoom(this.zoomVelocity)),this.transition.elapsed>=this.transition.duration&&(this.stop(this.transition.easeOut),this.transition.active=!1)}getTransitionScale(e){if(this.transition.elapsed>=this.transition.duration){return(this.transition.duration-(this.transition.elapsed-e))/e}return e/r.SI}updateDefault(e,t,i){const s=e/r.SI;t&&(this.linearVelocity.addScaledVector(this.linearAccel,s),this.pan(this.linearVelocity),this.linearVelocity.multiplyScalar(Math.pow(1-r.O8,s))),i&&(this.zoomVelocity=this.zoomVelocity+this.zoomAccel*s,this.zoom(this.zoomVelocity),this.zoomVelocity*=Math.pow(1-r.TD,s))}update(e){const t=this.linearAccel.length()>n.Z.epsilon||this.linearVelocity.length()>n.Z.epsilon,i=Math.abs(this.zoomAccel)>n.Z.epsilon||Math.abs(this.zoomVelocity)>n.Z.epsilon;this.transition.active?this.updateTransition(e,t,i):this.updateDefault(e,t,i)}stopMomentum(){this.transition.active||(this.linearVelocity.set(0,0),this.zoomVelocity=0)}stopAcceleration(){this.transition.active||(this.setPanAcceleration({x:0,y:0}),this.setZoomAcceleration(0))}stop(e=!1){this.stopTransition(),this.stopAcceleration(),e||this.stopMomentum()}pan(e){if(!this.poseController)return;const t=this.cameraPoseProxy.pose;this.positionDelta.x=e.x,this.positionDelta.y=e.y,this.positionDelta.z=0,this.positionDelta.applyQuaternion(t.rotation),this.currentPosition.copy(t.position).add(this.positionDelta),this.checkBounds&&!this.insideBounds(this.currentPosition,t.rotation,t.projection)||this.poseController.updateCameraPosition(this.currentPosition)}zoom(e){if(!this.poseController)return;const t=this.cameraPoseProxy.pose;this.targetProjection.copy(t.projection);const i=this.scale*(1-e);if(Math.abs(i-this.scale)>n.Z.epsilon){this.targetProjection.elements[0]*=i/this.scale,this.targetProjection.elements[5]*=i/this.scale;const s=(0,h.S3)(this.targetProjection);if(e<0&&s<=this.minZoom||e>0&&s>=this.maxZoom)return;if(this.checkBounds&&!this.insideBounds(t.position,t.rotation,this.targetProjection))return;this.scale=i,this.poseController.updateCameraProjection(this.targetProjection.clone())}}setupBounds(){this.bounds.min.x=this.adjustBound(this.bounds.min.x,2),this.bounds.min.y=this.adjustBound(this.bounds.min.y,2),this.bounds.min.z=this.adjustBound(this.bounds.min.z,2),this.bounds.max.x=this.adjustBound(this.bounds.max.x,-2),this.bounds.max.y=this.adjustBound(this.bounds.max.y,-2),this.bounds.max.z=this.adjustBound(this.bounds.max.z,-2),this.worldBounds=(new s.Box3).setFromCenterAndSize(this.boundsCenter,new s.Vector3(this.bounds.max.x-this.bounds.min.x,this.bounds.max.y-this.bounds.min.y,this.bounds.max.z-this.bounds.min.z))}insideBounds(e,t,i){return!!(0,a.cb)(e,t,i,this.worldBounds)}adjustBound(e,t){return Math.sign(e+t)===Math.sign(e)?e+t:0}}},66445:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>b});var s,o=i(97542),r=i(81396),n=i(44649),a=i(41602),h=i(23254),l=i(16782),d=i(32597),c=i(6667),u=i(95882),m=i(5090),p=i(10699),g=i(12250),f=i(80592),y=i(11442),w=i(89553),v=i(76532),T=i(2569),M=i(69170),x=i(9037);!function(e){e[e.NONE=l.r.NONE]="NONE",e[e.PAN=l.r.PRIMARY]="PAN",e[e.ROTATE=l.r.SECONDARY]="ROTATE",e[e.ZOOM=l.r.MIDDLE]="ZOOM"}(s||(s={}));class b extends o.Y{constructor(){super(...arguments),this.name="orthographic-controls",this.controlState=s.NONE,this.controlsEngaged=!1,this.movementKeys=new r.Vector2,this.resetControlState=()=>{this.controlState=s.NONE}}async init(e,t){const[i,s,o,r,n]=await Promise.all([t.market.waitForData(v._),t.getModuleBySymbol(M.y.CAMERA),t.getModuleBySymbol(M.y.CONTROLS_COMMON),t.market.waitForData(h.O),t.market.waitForData(x.M)]);this.meshData=i,this.cameraModule=s,this.viewmodeData=r,this.modelSize=Math.max(i.extendedSize.length(),1),this.commonControlsModule=o,this.createCameraControls(i,n),t.getModuleBySymbol(M.y.INPUT).then((e=>{this.bindings.push(e.registerHandler(g.a,(e=>{this.validateViewmode()&&this.onScrollWheel(e)}))),this.bindings.push(e.registerHandler(f.E0,(e=>{this.validateViewmode()&&this.onDragBegin(e.buttons)}))),this.bindings.push(e.registerHandler(f._t,(e=>{this.validateViewmode()&&(this.controlsEngaged=!0,this.onDrag(e.delta),this.controls.update(a.SI),this.controls.stop())}))),this.bindings.push(e.registerHandler(f._R,(e=>{this.validateViewmode()&&this.controlsEngaged&&(e.timeSinceLastMove<100&&(this.onDrag(e.delta),this.controls.update(a.SI),this.controls.stopAcceleration()),this.onDragEnd(e.delta,e.buttons),this.controlsEngaged=!1)}))),this.bindings.push(e.registerHandler(y.G,(e=>{this.validateViewmode()&&(this.controls.setZoomAcceleration(-e.pinchDelta*a.N4),this.controls.update(a.SI),this.controls.stop())}))),this.bindings.push(e.registerHandler(y.i,this.resetControlState)),this.bindings.push(e.registerHandler(w.e,(e=>{this.validateViewmode()&&e.state!==c.M.PRESSED&&this.onKey(e)})))})),this.bindings.push(t.subscribe(m.Z,(e=>{this.controls.stop(),this.resetControlState()}))),this.bindings.push(t.subscribe(p.Z,(e=>{this.validateViewmode()&&this.controls.start()})))}onUpdate(e){this.validateViewmode()&&this.controls.update(e)}createCameraControls(e,t){const i=this.commonControlsModule.cameraPoseProxy,s=t.defaultZoom.bind(t);this.controls=new n.B(i,s,e.extendedBounds,e.meshCenter,!0),this.commonControlsModule.addControls(u.Ey.Orthographic,this.controls)}onScrollWheel(e){if(0!==e.delta.y){const t=(0,T.et)(this.modelSize,1,1500,2,.125);this.controls.setZoomAcceleration(e.delta.y*a.jX/(t*a.mP)),this.controls.update(a.SI),this.controls.setZoomAcceleration(0)}}onDragBegin(e){if(this.controlState===s.NONE){const t=e;this.controlState=t}this.controls.stop()}onDrag(e){switch(this.controlState){case s.PAN:const t=e;this.controls.setPanAcceleration({x:-t.x,y:-t.y});break;case s.ZOOM:0!==e.y&&this.controls.setZoomAcceleration(-e.y)}}onDragEnd(e,t){t&this.controlState||(this.controlState=s.NONE)}onKey(e){const{key:t,state:i}=e,s=i===c.M.DOWN;let o=!1;switch(t){case d.R.A:this.movementKeys.x=s?-1:0,o=!0;break;case d.R.D:this.movementKeys.x=s?1:0,o=!0;break;case d.R.W:this.movementKeys.y=s?1:0,o=!0;break;case d.R.S:this.movementKeys.y=s?-1:0,o=!0;break;case d.R.K:this.controls.setZoomAcceleration(s?a.Gu:0);break;case d.R.I:this.controls.setZoomAcceleration(s?-a.Gu:0)}if(o){const e=this.movementKeys;this.controls.setPanAcceleration({x:e.x,y:e.y},!1,a.bC)}}validateViewmode(){return this.viewmodeData.currentMode===u.Ey.Orthographic}}},25814:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>C});var s=i(97542),o=i(69170),r=i(17878),n=i(81396),a=i(27115),h=i.n(a),l=i(92393),d=i.n(l),c=i(17965),u=i.n(c),m=i(14282),p=i.n(m),g=i(98419),f=i.n(g),y=i(20367),w=i.n(y);const v={circle_projection:new n.RawShaderMaterial({uniforms:{textureSampleScale:{value:5},panoTexture:{value:null},borderSize:{value:0},borderColor:{value:new n.Vector4(1,1,1,1)}},depthWrite:!1,depthTest:!0,side:n.DoubleSide,vertexShader:h(),fragmentShader:d()}),equirectangular:new n.RawShaderMaterial({uniforms:{cubemap:{value:null},yaw:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:u(),fragmentShader:p()}),compose:new n.RawShaderMaterial({uniforms:{mask:{value:null},bg:{value:null}},transparent:!0,vertexShader:f(),fragmentShader:w()})};var T=i(87928),M=i(41187);class x{constructor(e,t){this._renderer=e,this._renderTarget=t}get target(){return this._renderTarget}get width(){return this._renderTarget.width}get height(){return this._renderTarget.height}get bpp(){return 4}readRenderTargetData(e){const t=this._renderTarget.width,i=this._renderTarget.height;return e=e||new Uint8Array(t*i*4),this._renderer.readRenderTargetPixels(this._renderTarget,0,0,t,i,e),e}setSize(e,t){this._renderTarget.setSize(e,t)}dispose(){this._renderTarget.dispose()}}var b=i(947),D=i(56512);const S=new n.DataTexture(new Uint8Array([255,255,255,255]),1,1);S.needsUpdate=!0;class C extends s.Y{constructor(){super(...arguments),this.name="render-to-texture",this.circleProjectionPlane=new T.E((0,D.fc)(),v.circle_projection),this.equirectProjectionPlane=new T.E((0,D.fc)(),v.equirectangular),this.composePlane=new T.E((0,D.fc)(),v.compose),this.cachedSize=new n.Vector2,this.cachedViewport=new n.Vector4,this.cachedViewport2=new n.Vector4,this.debugRenderOffset=0}async init(e,t){this.engine=t;const i=await t.getModuleBySymbol(o.y.WEBGL_RENDERER);this.cwfRenderer=i.cwfRenderer,this.renderer=i.cwfRenderer.renderer,this.camera=new n.Camera,this.orthoCamera=new n.OrthographicCamera(-.5,.5,.5,-.5,0,1),this.camera.layers.mask=r.o.ALL.mask,this.scene=new n.Scene,this.scene.name="rtt",this.scene.matrixWorldAutoUpdate=!1,this.bindings.push(t.commandBinder.addBinding(M.oM,(async e=>new x(this.renderer,this.createRenderTarget2D(0))))),this.bindings.push(t.commandBinder.addBinding(M.sH,(async e=>{this.renderContext(e.renderTarget.target,e.context)}))),this.bindings.push(t.commandBinder.addBinding(M.vU,(async e=>{this.render(e.renderTarget.target,e.sceneObject,e.camera)}))),this.bindings.push(t.commandBinder.addBinding(M.fZ,(async e=>{this.renderEquirectangular(e.texture,e.renderTarget.target,e.heading)}))),this.bindings.push(t.commandBinder.addBinding(M.sp,(async e=>{this.render(e.renderTarget,e.sceneObject,e.camera)}))),this.bindings.push(t.commandBinder.addBinding(M.ep,(async e=>{this.compose(e.target1.target,e.target2.target,e.target2.target)})))}getRenderSize(){const e=this.renderer.getPixelRatio(),t=this.renderer.getSize(this.cachedSize);return t.width*=e,t.height*=e,t}onUpdate(){this.debugRenderOffset=0}createRenderTarget2D(e,t=e,i,s=!0){const o=new n.WebGLRenderTarget(e,t,i);return o.texture.generateMipmaps=s,o}clearRenderTarget2D(e){this.renderer.setRenderTarget(e),this.renderer.clear(),this.renderer.setRenderTarget(null)}disposeRenderTarget2D(e){e.texture.dispose(),e.depthTexture&&e.depthTexture.dispose(),e.dispose()}getRenderTargetData(e,t){const i=e.width,s=e.height;return t=t||new Uint8Array(i*s*4),this.renderer.readRenderTargetPixels(e,0,0,i,s,t),t}compose(e,t,i=S){const{uniforms:s}=this.composePlane.material;s.bg.value=this.isRenderTarget(t)?t.texture:t,s.mask.value=this.isRenderTarget(i)?i.texture:i,this.scene.add(this.composePlane),this.overrideRenderTarget(e,(()=>{this.renderer.render(this.scene,this.orthoCamera)})),this.scene.remove(this.composePlane),s.bg.value=null,s.mask.value=null}copyTexture(e,t){return this.compose(e,t)}resizeTexture(e,t){const i=new n.WebGLRenderTarget(t,t);return e.isCompressedTexture?i.texture.format=n.RGBAFormat:i.texture.format=e.format,i.texture.addEventListener("dispose",i.dispose.bind(i)),this.copyTexture(i,e),i.texture}renderToScreen(e,t=!0,i,s){(t?Promise.resolve():this.engine.after(b.A.Render)).then((()=>{const t=this.isRenderTarget(e)?e.width:e.image.width,o=this.isRenderTarget(e)?e.height:e.image.height,r=i?i.x:this.debugRenderOffset,n=i?i.y:60;this.renderer.getViewport(this.cachedViewport),this.renderer.setViewport(r,n,t,o),this.compose(null,e,s),this.renderer.setViewport(this.cachedViewport),i||(this.debugRenderOffset+=t+4)}))}isRenderTarget(e){return e.hasOwnProperty("texture")}renderContext(e,t){e.texture.image=t.canvas,e.texture.needsUpdate=!0}render(e,t,i,s){const o=t.parent;if(o&&this.scene.applyMatrix4(o.matrixWorld),this.scene.add(t),e.isWebGLCubeRenderTarget){const t=new n.CubeCamera(.01,1e3,e);i.getWorldPosition(t.position),i.getWorldQuaternion(t.quaternion),this.scene.add(t),this.scene.updateMatrixWorld(),t.layers.mask=s?s.mask:i.layers.mask,t.update(this.renderer,this.scene),this.scene.remove(t)}else{i.getWorldPosition(this.camera.position),i.getWorldQuaternion(this.camera.quaternion),this.camera.projectionMatrix.copy(i.projectionMatrix),this.camera.layers.mask=s?s.mask:i.layers.mask;const t=this.renderer.getSize(this.cachedSize),o=t.width/t.height,r=e.width/e.height,n=this.camera.projectionMatrix;o>r?n.elements[0]=n.elements[5]/r:n.elements[5]=n.elements[0]*r,this.overrideRenderTarget(e,(()=>{this.renderer.clear(),this.renderer.render(this.scene,this.camera)}))}return o&&(o.add(t),this.scene.matrixWorld.identity()),this.scene.remove(t),e}setScissors(e,t){if(e){if(!t)throw Error("Rect to restrict rendering to required when enabling scissors.");this.renderer.setScissorTest(!0),this.renderer.setScissor(t.x,t.y,t.width,t.height)}else{const e=this.renderer.getSize(this.cachedSize);this.renderer.setScissor(0,0,e.width,e.height),this.renderer.setScissorTest(!1)}}renderSphericalProjection(e,t,i,s,o){const r=v.circle_projection;r.uniforms.borderColor.value.copy(o||new n.Vector4(1,1,1,1)),r.uniforms.borderSize.value=s||0,r.uniforms.textureSampleScale.value=i||5,r.uniforms.panoTexture.value=e,this.scene.add(this.circleProjectionPlane),this.circleProjectionPlane.position.z=0,this.overrideRenderTarget(t,(()=>{this.renderer.render(this.scene,this.orthoCamera)})),this.scene.remove(this.circleProjectionPlane),r.uniforms.panoTexture.value=null}renderEquirectangular(e,t,i=0){const s=this.equirectProjectionPlane.material;s.uniforms.cubemap.value=e,s.uniforms.yaw.value=i,this.scene.add(this.equirectProjectionPlane),this.equirectProjectionPlane.position.z=0,this.overrideRenderTarget(t,(()=>{this.renderer.render(this.scene,this.orthoCamera)})),this.scene.remove(this.equirectProjectionPlane),s.uniforms.cubemap.value=null,s.uniforms.yaw.value=0}overrideRenderTarget(e,t){const i=this.renderTargetSwap(e);t(),this.renderTargetRestore(i)}renderTargetSwap(e){const t=this.renderer.xr.enabled,i=this.renderer.getRenderTarget(),s=this.renderer.getViewport(this.cachedViewport2);return this.renderer.xr.enabled=!1,this.renderer.setRenderTarget(e),{xr:t,rtt:i,viewport:s}}renderTargetRestore(e){this.renderer.xr.enabled=e.xr,this.renderer.setRenderTarget(e.rtt),this.renderer.setViewport(e.viewport)}renderAndReadAsync(e,t,i){const s=i.buffer;if(!this.renderer.capabilities.isWebGL2)return this.log.debug("renderAsync call webgl2, falling back to sync render/read"),this.render(e.target,e.mesh,e.camera),Promise.resolve(this.getRenderTargetData(e.target,s));const o=this.renderTargetSwap(e.target),r=this.renderer.getContext(),n=i.webglBuffer||r.createBuffer();if(!n)throw Error("Unable to create pack buffer");return r.bindBuffer(r.PIXEL_PACK_BUFFER,n),r.bufferData(r.PIXEL_PACK_BUFFER,s.byteLength,r.DYNAMIC_READ),e.clear&&this.renderer.clear(),this.renderer.render(e.mesh,e.camera),r.readPixels(t.x,t.y,t.width,t.height,r.RGBA,r.UNSIGNED_BYTE,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),this.renderTargetRestore(o),this.cwfRenderer.fence(r).then((()=>(r.bindBuffer(r.PIXEL_PACK_BUFFER,n),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,s),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i.webglBuffer||r.deleteBuffer(n),s)))}}},47183:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>f});var s=i(97542),o=i(28269),r=i(53954),n=i(23254),a=i(79992),h=i(86400),l=i(17788),d=i(97998);class c{constructor(e){this.tags=[],e&&Object.assign(this,e)}}const u=new d.Z("mds-floor-deserializer");class m{deserialize(e){var t,i,s,o;if(!e||!this.validate(e))return u.debug("Deserialized invalid room data from MDS",e),null;const r=e=>null!==e?e:void 0,n=e.dimensions||{height:null,width:null,depth:null,areaFloor:null},{height:a,width:h,depth:l,areaFloor:d}=n;return new c({id:e.id,meshSubgroup:e.meshId,floorId:null!==(i=null===(t=e.floor)||void 0===t?void 0:t.id)&&void 0!==i?i:"",height:r(a),width:r(h),depth:r(l),areaFloor:r(d),tags:null!==(o=null===(s=e.tags)||void 0===s?void 0:s.filter((e=>e)))&&void 0!==o?o:void 0})}validate(e){const t=["id","meshId"].every((t=>t in e)),i=e.floor&&e.floor.id&&"number"==typeof e.floor.meshId;return t&&!!i}}class p extends l.u{constructor(){super(...arguments),this.prefetchKey="data.model.rooms"}async read(e){const t=new m,i={modelId:this.getViewId()};return this.query(h.GetRooms,i,e).then((e=>{var i,s;const o=null===(s=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.model)||void 0===s?void 0:s.rooms;if(!o||!Array.isArray(o))return null;return o.reduce(((e,i)=>{const s=t.deserialize(i);return s&&(e[s.id]=s),e}),{})}))}}var g=i(80742);class f extends s.Y{constructor(){super(...arguments),this.name="room-data",this.visitedRooms={}}async init(e,t){const{baseModelId:i,baseUrl:s}=e,h=await t.market.waitForData(g.R);this.store=new p({context:h.mdsContext,baseUrl:s,readonly:!0,viewId:i});const l=await this.store.read();this.data=new o.Z(l||{}),t.market.register(this,o.Z,this.data);const d=await t.market.waitForData(n.O),c=this.data.roomCount,u=e=>{const i=d.closestMode;this.visitedRooms[e.id]||(this.visitedRooms[e.id]={visitCount:0}),this.visitedRooms[e.id].visitCount++;const s=this.visitedRooms[e.id].visitCount;t.broadcast(new a.D(e.id,e.meshSubgroup,i,s,c,""))},m=await t.market.waitForData(r.Z),f=m.makeSweepChangeSubscription((e=>{if(e){const t=m.getSweep(e);this.data.selected.value=t.roomId,this.data.commit()}})),y=this.data.selected.onChanged((e=>{if(null!==e){const t=this.data.get(e);t&&u(t)}}));this.bindings.push(f,y)}}},24886:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>l});var s=i(97542),o=i(97998);const r=[1/0,Array,ArrayBuffer,Boolean,DataView,Date,Error,EvalError,Float32Array,Float64Array,Function,Int8Array,Int16Array,Int32Array,JSON,Map,Math,NaN,Number,Object,Promise,Proxy,RangeError,ReferenceError,Reflect,RegExp,Set,String,SyntaxError,TypeError,URIError,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,WeakMap,WeakSet,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,escape,eval,isFinite,isNaN,parseFloat,parseInt,unescape,XMLHttpRequest,Headers,HTMLIFrameElement,Document,HTMLDocument,HTMLCanvasElement,DOMException];class n{constructor(e,t){this.originalSetFunc=e,this.originalClearFunc=t,this.disposed=!1,this.ids=new Set}setFunc(e,t){if(this.disposed)return-1;const i=this.originalSetFunc((()=>e()),t);return this.ids.add(i),i}clearFunc(e){this.disposed||this.ids.has(e)&&(this.ids.delete(e),this.originalClearFunc(e))}dispose(){if(!this.disposed){this.disposed=!0;for(const e of this.ids)this.originalClearFunc(e);this.ids.clear()}}}const a=function(e){return Object.freeze(e),Object.getOwnPropertyNames(e).forEach((function(t){const i=Object.getOwnPropertyDescriptor(e,t);(null==i?void 0:i.value)&&"object"==typeof i.value&&a(i.value)})),e};class h extends s.Y{constructor(){super(...arguments),this.overlayElement=null,this.name="SesModule",this.frozen=!1}freezeForStrict(){if(!this.frozen){for(const e of r)a(e);this.frozen=!0}}async init(e){await i.e(519).then(i.bind(i,6297)),globalThis.process&&(globalThis.process.on=()=>{}),this.overlayElement=e.overlayRoot}async makeSecureEnvironment(e,t,i){if(!this.overlayElement)return this.log.warn("Not creating a secure env due to missing overlay element"),null;if(t.startsWith("http")||t.startsWith("//")&&window.location.href.match(/^https?:/))try{const e=await fetch(t);t=await e.text()}catch(e){return this.log.warn("There was an error retrieving the plugin source."),null}let s=this.overlayElement.querySelector(`.${e}`);s&&this.overlayElement.removeChild(s),s=document.createElement("div"),s.classList.add("plugin-root-element"),s.classList.add(e),this.overlayElement.appendChild(s);const r=s.attachShadow({mode:"closed"}),a=new o.Z(`plugin ${e}`);Object.freeze(a);const h=new n(((e,t)=>window.setInterval(e,t)),(e=>window.clearInterval(e))),l=new n(((e,t)=>window.setTimeout(e,t)),(e=>window.clearTimeout(e))),d={log:(...e)=>a.info(...e),error:(...e)=>a.error(...e),info:(...e)=>a.info(...e),warn:(...e)=>a.warn(...e),time:e=>a.time(e),timeEnd:e=>a.timeEnd(e)};function c(e,t){return h.setFunc(e,t)}function u(e){return h.clearFunc(e)}function m(e,t){return l.setFunc(e,t)}function p(e){return l.clearFunc(e)}const g={setInterval:c,clearInterval:u,setTimeout:m,clearTimeout:p,console:d,window:{setInterval:c,clearInterval:u,setTimeout:m,clearTimeout:p,console:d,parent:{postMessage(e,t,i){"string"==typeof t?window.parent.postMessage(e,t,i):window.parent.postMessage(e,t)}}}},f=Object.assign(Object.assign({},g),{window:Object.assign(Object.assign({},g.window),{HTMLIFrameElement:HTMLIFrameElement,location:{},document:document,getComputedStyle:getComputedStyle.bind(globalThis),parent:window.parent}),XMLHttpRequest:XMLHttpRequest,HTMLIFrameElement:HTMLIFrameElement,Document:Document,HTMLDocument:HTMLDocument,HTMLCanvasElement:HTMLCanvasElement,DOMException:DOMException,Error:Error,Headers:Headers,document:document,navigator:{userAgent:navigator.userAgent},overlaySlot:()=>r}),y=new Compartment(i?g:f);y.evaluate(t,i?void 0:{__evadeImportExpressionTest__:!0,__evadeHtmlCommentTest__:!0});let w=!1;return{compartment:y,overlayElement:this.overlayElement,dispose:()=>{var e;w||(w=!0,null===(e=this.overlayElement)||void 0===e||e.removeChild(s),h.dispose(),l.dispose())}}}}const l=h},94046:(e,t,i)=>{"use strict";i.d(t,{i:()=>o});var s=i(81396);class o extends s.Mesh{}},89137:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>M});var s=i(97542),o=i(69170),r=i(81396),n=i(80218),a=i.n(n),h=i(46262),l=i.n(h);const d={sky:{uniforms:{topColor:{type:"v3",value:new r.Vector3(.094,.102,.11)},bottomColor:{type:"v3",value:new r.Vector3(.2,.216,.235)},radius:{type:"f",value:100}},vertexShader:a(),fragmentShader:l()}};class c extends r.RawShaderMaterial{constructor(e={}){super(Object.assign({fragmentShader:d.sky.fragmentShader,vertexShader:d.sky.vertexShader,uniforms:r.UniformsUtils.clone(d.sky.uniforms),name:"SkyboxMaterial"},e))}}var u=i(17878),m=i(94046),p=i(12529),g=i(18596);class f{constructor(e,t,i,s,o=u.o.ALL){this.scene=e,this.cameraData=t,this.addToRaycasting=i,this.removeFromRaycasting=s,this.renderLayer=o,this.bindings=[]}init(){const{visualMesh:e,colliderMesh:t}=this.setupSkysphere();this.skyVisual=e,this.material=this.skyVisual.material,this.skyCollider=t}dispose(){this.material.uniforms.pano0Map.value.dispose(),this.material.uniforms.pano1Map.value.dispose(),this.material.dispose(),this.skyVisual.geometry.dispose()}activate(e){this.scene.addChild(this.scene.ids.Root,this.skyVisual),this.skyVisual.updateMatrixWorld(!0),this.skyVisual.visible=!0,this.addToRaycasting(this.skyCollider,!1)}deactivate(e){for(const e of this.bindings)e.cancel();this.bindings=[],this.scene.removeChild(this.scene.ids.Root,this.skyVisual),this.scene.removeChild(this.scene.ids.CameraRig,this.skyCollider),this.removeFromRaycasting(this.skyCollider)}updateBackgroundColors(e,t){const i=new r.Color(e),s=new r.Color(t);this.material.uniforms.topColor.value.set(i.r,i.g,i.b),this.material.uniforms.bottomColor.value.set(s.r,s.g,s.b)}beforeRender(){this.skyVisual.position.copy(this.cameraData.pose.position),this.skyCollider.position.copy(this.cameraData.pose.position)}render(){}setupSkysphere(e){const t=new r.SphereGeometry(1e4,5,5);t.computeBoundingBox();const i=g.oR.far-10,s=new r.SphereGeometry(i,5,5);s.computeBoundingBox(),e||(e=new c({side:r.BackSide}));const o=new m.i(s,e);o.layers.mask=this.renderLayer.mask,o.name="Skysphere",o.renderOrder=p.z.boundingSkybox,o.updateMatrixWorld(!0),e.uniforms.radius.value=i,e.depthWrite=!1,e.depthTest=!1;return{visualMesh:o,colliderMesh:new m.i(t,new r.MeshBasicMaterial({opacity:0,depthWrite:!1,side:r.BackSide}))}}}var y=i(34029),w=i(28361),v=i(59625),T=i(9037);class M extends s.Y{constructor(){super(...arguments),this.name="skybox-module"}async init(e,t){const[i,s,r,n]=await Promise.all([t.getModuleBySymbol(o.y.WEBGL_RENDERER),t.market.waitForData(y.e),t.getModuleBySymbol(o.y.INPUT),t.market.waitForData(T.M)]),a=t.claimRenderLayer("skybox"),h=i.getScene();this.skybox=new f(h,n,r.registerMesh,r.unregisterMesh,a),t.addComponent(this,this.skybox);const l=s.tryGetProperty(v.gx.BackgroundColor,w.z.default);this.skybox.updateBackgroundColors(w.K[l].bgPrimary,w.K[l].bgSecondary),this.bindings.push(s.onPropertyChanged(v.gx.BackgroundColor,(e=>{this.skybox.updateBackgroundColors(w.K[e].bgPrimary,w.K[e].bgSecondary)})))}}},3907:(e,t,i)=>{"use strict";i.d(t,{MU:()=>a});var s,o=i(39880),r=i(44584);!function(e){e.GET="GET",e.POST="POST",e.PATCH="PATCH",e.PUT="PUT",e.DELETE="DELETE",e.OPTIONS="OPTIONS"}(s||(s={}));class n extends class{constructor(){this._options={responseType:"json"}}get options(){const e=this._options;return e.headers=(0,r.m)(this.url,this._options.headers||{}),e}}{constructor(e){super(),this.config=e,this.url=e.path}async read(){const{deserialize:e}=this.config;let t=null;return this.config.cachedData&&this.config.cachedData.data?t=this.config.cachedData.data:(t=await this.config.queue.get(this.config.path,this.options),this.config.cachedData&&(this.config.cachedData.data=t)),e(t)}clearCache(){this.config.cachedData&&(this.config.cachedData.data=null)}}class a extends n{constructor(e){super(e),this.config=e,this.acceptsPartial=!1,this.config.batchUpdate="batchUpdate"in this.config&&this.config.batchUpdate}async create(e){throw Error("Not implemented")}updateBatch(e,t){const{serialize:i}=this.config,o=[],r=[...new Set([...Object.keys(e),...Object.keys(t)])];for(const i of r){e[i]||t[i]||o.push(this.config.queue.delete(`${this.config.path}/${i}`,this.options))}const n=i(e,t),a=Object.assign(Object.assign({},this.options),{body:n});return o.push(this.config.queue.request(this.config.httpMethod||s.POST,this.config.path,a)),Promise.all(o)}updateInternal(e,t){const{serialize:i}=this.config,r=[],n=Object.assign({},this.options),a=Object.keys(e),h=Object.keys(t),l=(0,o.XN)(a.concat(h));for(const o in l){const a=l[o],h=e[a]||t[a];if(h){const e={};e[a]=h;const o={},l=t[a];l&&(o[a]=l);const d=i(e,o);n.body=d,r.push(this.config.queue.request(this.config.httpMethod||s.POST,this.config.path,n))}else r.push(this.config.queue.delete(`${this.config.path}/${a}`,this.options))}return Promise.all(r)}async update(e,t){this.clearCache(),await(this.config.batchUpdate?this.updateBatch(e,t||{}):this.updateInternal(e,t||{}))}async delete(e){throw Error("Not implemented")}}},81248:(e,t,i)=>{"use strict";i.d(t,{Bv:()=>u,Dv:()=>h,TE:()=>l,l0:()=>c,o7:()=>d});var s=i(81396);const o=-1,r=10,n=5,a=-5,h=(e,t=o)=>i=>e.distanceToSquared(i.position)*t,l=(e,t=o)=>i=>e.distanceTo(i.position)*t,d=(e,t,i=r)=>{const o=new s.Vector3;return s=>o.copy(s.position).sub(e).normalize().dot(t)*i},c=(e,t=o)=>i=>e.distanceToSquared(i.floorPosition)*t,u=(e,t=n,i=a)=>s=>e===s.floorId?t:i},84366:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(98010);class o extends s.v{constructor(e,t,i){super(),this.size=e,this.sweepId=t,this.renderTarget=i}}},71076:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>u});var s=i(97542),o=i(53954),r=i(21973),n=i(35826),a=i(23254),h=i(69739),l=i(79727),d=i(10374),c=i(96154);class u extends s.Y{constructor(){super(...arguments),this.name="sweep-viewdata",this.selectionEnabled=!0,this.nonPanoCurrentPuckVisible=!1,this.sweepMap={},this.sweepIdList=[],this.enableSweepSelection=async e=>{this.selectionEnabled=!0},this.disableSweepSelection=async e=>{this.selectionEnabled=!1},this.toggleCurrentPuck=async e=>{this.nonPanoCurrentPuckVisible=e.visible,this.updateVisibility(this.viewData.data.currentSweep)},this.onSweepSelectCommand=async e=>{this.selectionEnabled&&this.viewData.modifySelectAnimation(e.id,e.selected,e.duration)},this.onSweepHoverCommand=async e=>{this.viewData.modifySelectAnimation(e.id,e.hovered,e.duration)},this.updateVisibility=async e=>{if(this.viewmodeData.isInside()){if(e){const t=this.viewData.getSweep(e).neighbours;this.viewData.iterate((e=>{const i=this.viewData.getSweepVisibility(e)&&-1!==t.indexOf(e.id);this.viewData.setVisible(e.id,i)})),this.viewData.setVisible(e,!1)}}else this.viewData.iterate((e=>{this.viewData.setVisible(e.id,this.floorsViewData.isCurrentOrAllFloors(e.floorId))})),e&&this.viewData.setVisible(e,this.nonPanoCurrentPuckVisible)}}async init(e,t){this.data=await t.market.waitForData(o.Z),this.viewData=t.market.tryGetData(r.D)||new r.D(this.data),t.market.register(this,r.D,this.viewData),this.bindings.push(t.commandBinder.addBinding(n.iF,this.onSweepSelectCommand),t.commandBinder.addBinding(n.kR,this.onSweepHoverCommand),t.commandBinder.addBinding(n.zd,this.enableSweepSelection),t.commandBinder.addBinding(n.ZD,this.disableSweepSelection),t.commandBinder.addBinding(n.e9,this.toggleCurrentPuck),this.data.onChanged((()=>this.viewData.updateViewData())),t.msgBus.subscribe(c.sY,(()=>this.viewData.updateViewData()))),this.viewmodeData=await t.market.waitForData(a.O),this.floorsViewData=await t.market.waitForData(l.c),this.bindings.push(this.data.onPropertyChanged("currentSweep",this.updateVisibility),t.subscribe(h.P,(()=>this.updateVisibility(this.viewData.data.currentSweep))),t.subscribe(d.bS,(()=>this.updateVisibility(this.viewData.data.currentSweep))),this.viewmodeData.makeModeChangeSubscription((()=>this.updateVisibility(this.viewData.data.currentSweep)))),this.updateVisibility(this.viewData.data.currentSweep)}onUpdate(e){this.viewData.updateAnimations(e)}}},44756:(e,t,i)=>{"use strict";i.r(t),i.d(t,{AssetDockedMessage:()=>l.ro,AssetUndockedMessage:()=>l.A,CloseAndRemoveToolsCommand:()=>h.Ye,CloseCurrentToolCommand:()=>h.eS,CloseToolCommand:()=>h.CH,CollapseBottomPanelCommand:()=>h.qy,FullSizeEditorMessage:()=>l.Zi,OpenPreviousToolCommand:()=>h.cR,OpenToolCommand:()=>h.z2,PanelCollapseMessage:()=>l.U7,PanelTransitionEndMessage:()=>l.rh,RegisterToolsCommand:()=>h.MV,SetAppBarVisibleMessage:()=>l.bz,ToggleToolCommand:()=>h.tT,ToggleViewingControlsMessage:()=>l.ps,Tool:()=>b.U,ToolPalette:()=>n.$r,ToolPanelLayout:()=>n.wS,ToolToggleCollapseCommand:()=>h.Fg,Tools:()=>n.w1,ToolsData:()=>a.t,default:()=>D});var s=i(97542),o=i(69170),r=i(54244);var n=i(76631),a=i(91380);var h=i(89549),l=i(40964),d=i(92211),c=i(40505),u=i(25071),m=i(38319),p=i(50575),g=i(34029),f=i(92290),y=i(80008),w=i(38399),v=i(80361),T=i(19280),M=i(2367);class x extends s.Y{constructor(){super(...arguments),this.name="tools-module",this.activeToolDurationMap={},this.keyboardTimeout=0,this.bottomPanelHeight=0,this.sidePanelWidth=0,this.sidePanelLeft=0,this.closeAndRemoveTools=async e=>!(e&&!await this.deactivateCurrentTool())&&(this.toolsData.setActiveTool(null),this.toolsData.removeAllTools(),!0),this.onAssetDocked=()=>{this.toolsData.setAssetDocked(!0)},this.onAssetUndocked=()=>{this.toolsData.setAssetDocked(!1)},this.handleTextBoxFocus=e=>{window.clearTimeout(this.keyboardTimeout),e.focused?this.keyboardTimeout=window.setTimeout((()=>{document.documentElement.classList.add("keyboard-layout")}),500):document.documentElement.classList.remove("keyboard-layout")},this.onToggleModal=async e=>{this.toggleModal(e.modal,e.open)},this.closeModal=()=>{this.toolsData.openModal&&this.toggleModal(this.toolsData.openModal,!1)},this.allowToolOrViewChange=async()=>{var e;const t=this.toolsData.getActiveTool();if(!(null===(e=null==t?void 0:t.manager)||void 0===e?void 0:e.hasPendingEdits))return!0;if(await t.manager.hasPendingEdits()){const e={title:w.Z.TOOLS.UNSAVED_CHANGES_TITLE,message:w.Z.TOOLS.UNSAVED_CHANGES_MESSAGE,cancellable:!0,confirmPhraseKey:w.Z.TOOLS.UNSAVED_CHANGES_CONFIRM,cancelPhraseKey:w.Z.TOOLS.UNSAVED_CHANGES_CANCEL};return await this.engine.commandBinder.issueCommand(new f.EW(f.Rx.DISPLAY,e))===f.Uc.CLOSE}return!0},this.toggleTool=async({toolName:e,active:t})=>{if(this.toolInit)throw new Error("Current tool has not finished initializing!");t?await this.activateToolName(e,!1):await this.deactivateToolName(e)},this.openTool=async({toolName:e,softOpening:t})=>{await this.activateToolName(e,t)},this.closeTool=async({toolName:e})=>{await this.deactivateToolName(e)},this.closeCurrentTool=async()=>!!await this.deactivateCurrentTool()&&(this.toolsData.setActiveTool(null),!0),this.openPreviousTool=async()=>{this.toolsData.setSoftOpening(!1);const e=this.toolsData.previousToolName;if(null===e)return;const t=this.toolsData.getTool(e)||null;null!==t?await this.deactivateCurrentTool(t)&&(await this.activateTool(t),this.toolsData.setActiveTool(e)):this.log.error(`Tool not loaded: ${e}`)},this.updateLayoutSize=()=>{const{toolPanelLayout:e}=this.toolsData;let t=e;const i=this.isSidePanelLayout();switch(e){case n.wS.NORMAL:i||(t=n.wS.NARROW);break;case n.wS.SIDE_PANEL:i||(t=n.wS.BOTTOM_PANEL);break;case n.wS.NARROW:i&&(t=n.wS.NORMAL);break;case n.wS.BOTTOM_PANEL:i&&(t=n.wS.SIDE_PANEL)}this.toolsData.setToolPanelLayout(t)},this.handleToolCollapse=async e=>{e!==this.toolsData.toolCollapsed&&(this.toolsData.setToolCollapsed(e),e||this.toolsData.toolPanelLayout!==n.wS.BOTTOM_PANEL||this.closeModal(),this.engine.broadcast(new l.U7(e)))},this.handleBottomPanelCollapse=async e=>{if(this.toolsData.toolPanelLayout===n.wS.BOTTOM_PANEL)return this.handleToolCollapse(e.collapse)},this.adjustCanvasForPanelActual=async()=>{const{toolPanelLayout:e,toolCollapsed:t,assetDocked:i,openModal:s}=this.toolsData,{sidePanelWidth:o,bottomPanelHeight:r,sidePanelLeft:a}=this,h=this.toolsData.getActiveTool(),l=e===n.wS.SIDE_PANEL,d=h&&l&&!t,c=d&&!!(null==h?void 0:h.panelLeft),p=d?-u.LH:0,g=p!==o?p:void 0,f=c?u.LH:0,y=f!==a?f:void 0,w=e===n.wS.BOTTOM_PANEL&&!s&&i,v=-Math.floor(50*(this.containerData.size.height-55)/100),T=w?v:0,M=T!==r?T:void 0,x=0===g||0===M?0:500;this.resizeCanvas((0,m.hf)(g,M,y,x)),this.bottomPanelHeight=T,this.sidePanelWidth=p,this.sidePanelLeft=f},this.adjustCanvasForPanel=(0,v.D)(this.adjustCanvasForPanelActual,50),this.resizeCanvas=async e=>{this.engine.commandBinder.issueCommand(new p.M(e))}}async init(e,t){this.engine=t,await t.getModuleBySymbol(o.y.SHOWCASE_ANALYTICS),this.analytics=await t.getModuleBySymbol(o.y.ANALYTICS),[this.settingsData,this.appData,this.containerData]=await Promise.all([t.market.waitForData(g.e),t.market.waitForData(r.pu),t.market.waitForData(M.V)]),this.toolsData=new a.t,this.updateLayoutSize(),this.bindings.push(t.commandBinder.addBinding(h.tT,this.toggleTool),t.commandBinder.addBinding(h.cR,this.openPreviousTool),t.commandBinder.addBinding(h.z2,this.openTool),t.commandBinder.addBinding(h.CH,this.closeTool),t.commandBinder.addBinding(h.eS,this.closeCurrentTool),t.commandBinder.addBinding(d.Bz,this.onToggleModal),t.commandBinder.addBinding(d.rE,(async()=>this.closeModal())),t.commandBinder.addBinding(h.Fg,(async e=>{this.handleToolCollapse(e.collapse)})),t.commandBinder.addBinding(h.qy,this.handleBottomPanelCollapse),this.containerData.onPropertyChanged("size",this.updateLayoutSize),t.subscribe(l.ro,this.onAssetDocked),t.subscribe(l.A,this.onAssetUndocked),t.subscribe(c.SN,this.handleTextBoxFocus),this.toolsData.onToolPanelLayoutChanged(this.adjustCanvasForPanel),this.toolsData.onToolChanged(this.adjustCanvasForPanel),this.toolsData.onToolCollapsedChanged(this.adjustCanvasForPanel),this.toolsData.onAssetDockedChanged(this.adjustCanvasForPanel),t.commandBinder.addBinding(h.Ye,(({checkForEdits:e})=>this.closeAndRemoveTools(e))),t.commandBinder.addBinding(h.MV,(async({tools:e})=>this.registerTools(...e)))),t.commandBinder.issueCommand(new y.vM(this.allowToolOrViewChange)),t.market.register(this,a.t,this.toolsData)}dispose(e){super.dispose(e),this.closeAndRemoveTools(!1),e.market.unregister(this,a.t)}registerTools(...e){e.forEach((e=>{e.featureFlag&&this.bindings.push(this.settingsData.onPropertyChanged(e.featureFlag,(()=>this.updateEnabledTools())))})),this.toolsData.addTool(...e)}closePanel(){this.toolsData.setToolCollapsed(!1),this.toolsData.setToolPanelLayout(this.isSidePanelLayout()?n.wS.NORMAL:n.wS.NARROW)}openPanel(e){if(!e.panel)return void this.toolsData.setToolCollapsed(!!e.panelBar);const t=this.isSidePanelLayout();this.toolsData.setToolPanelLayout(t?n.wS.SIDE_PANEL:n.wS.BOTTOM_PANEL);const i=!t&&!this.toolsData.softOpening;this.toolsData.setToolCollapsed(i)}toggleModal(e,t){const{openModal:i,toolPanelLayout:s}=this.toolsData;if(t&&i===e||!t&&e!==i)return;const o=e.toLowerCase(),a=this.appData.application===r.Mx.WORKSHOP?"workshop_gui":"showcase_gui";this.analytics.track(a,{gui_action:`open_${o}`}),e&&this.analytics.track("modal_shown",{modal:e}),this.toolsData.setOpenModal(t?e:null),s===n.wS.BOTTOM_PANEL&&t!==!!i&&this.adjustCanvasForPanel(),this.engine.broadcast(new c.nV(e,t))}async activateTool(e){if(this.toolInit)throw new Error("Current tool has not finished initializing!");this.closeModal(),this.openPanel(e),e.manager&&(this.toolInit=e.manager.activate(),await this.toolInit,this.toolInit=null),this.startTrackingTool(e)}async deactivateCurrentTool(e,t=!0){const i=this.toolsData.getActiveTool();if(!i)return!0;if(await this.toolInit,t&&!await this.allowToolOrViewChange())return!1;i.manager&&await i.manager.deactivate(),this.closeModal();const s=this.toolsData.toolPanelLayout===n.wS.BOTTOM_PANEL||this.toolsData.toolPanelLayout===n.wS.NARROW||(null==e?void 0:e.panelLeft)===i.panelLeft;return!(e&&e.panel&&e.panel===i.panel&&s)&&this.closePanel(),this.stopTrackingTool(i),!0}async activateToolName(e,t){if(this.toolsData.activeToolName===e)return void this.toolsData.setSoftOpening(t);const i=this.toolsData.getTool(e)||null;null!==i?await this.deactivateCurrentTool(i)&&(this.toolsData.setSoftOpening(t),await this.activateTool(i),this.toolsData.setActiveTool(i.id)):this.log.error(`Tool not loaded: ${e}`)}async deactivateToolName(e,t){e===this.toolsData.activeToolName&&await this.deactivateCurrentTool(t)&&this.toolsData.setActiveTool(null)}startTrackingTool(e){this.activeToolDurationMap[e.analytic]=Date.now()}stopTrackingTool(e){const{analytic:t}=e;this.activeToolDurationMap[t]=Date.now()-this.activeToolDurationMap[t];const i={tool:`${t}_session_time`,duration:this.activeToolDurationMap[t]};this.analytics.track("tool_session_time",i)}updateEnabledTools(){const e=this.toolsData.toolsMap;e.atomic((()=>{for(const t of e)if(t.featureFlag){const e=this.settingsData.tryGetProperty(t.featureFlag,!1);t.enabled!==e&&(t.enabled=e,t.commit())}}))}isSidePanelLayout(){return!(0,T.p)(this.containerData.size)}}var b=i(50892);const D=x},8960:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>C});var s=i(59625),o=i(97542),r=i(69170),n=i(41326),a=i(55450),h=i(34029),l=i(95882),d=i(64918),c=i(76532),u=i(90304),m=i(81396),p=i(67944),g=i(53954),f=i(98169),y=i(81248),w=i(9037),v=i(12039),T=i(54244),M=i(10374),x=i(23254),b=i(55318),D=i(79727),S=i(22201);class C extends o.Y{constructor(){super(...arguments),this.name="viewmode-change",this.dhDisabled=()=>!1,this.fpDisabled=()=>!1}async init(e,t){this.engine=t,this.viewmodesModule=await t.getModuleBySymbol(r.y.VIEWMODE),this.bindings.push(t.subscribe(M.bS,(e=>this.setEnabledModes(e.application))),t.commandBinder.addBinding(n._i,this.onChangeViewmodeCommand.bind(this))),Promise.all([t.market.waitForData(T.pu),t.market.waitForData(h.e)]).then((([e,t])=>{this.settings=t,this.setEnabledModes(e.application)}))}async setEnabledModes(e){if(e===T.Mx.SHOWCASE){if(this.dhDisabled=()=>0===this.settings.getOverrideParam("dh",1)||!this.settings.tryGetProperty(s.gx.Dollhouse,!1),this.fpDisabled=()=>0===this.settings.getOverrideParam("fp",1)||!this.settings.tryGetProperty(s.gx.FloorPlan,!1),!this.previousApp)return;const e=(await this.engine.market.waitForData(x.O)).currentMode;if(e===l.Ey.Dollhouse&&this.dhDisabled()||e===l.Ey.Floorplan&&this.fpDisabled()){const e=(await this.engine.market.waitForData(b.O)).pose;if(e&&(0,l.Bw)(e.mode))this.goToInsideMode(d.n.Interpolate,{position:e.camera.position},e.mode);else{const e=(await this.engine.market.waitForData(w.M)).pose,t=(await this.engine.market.waitForData(g.Z)).getClosestSweep(e.position,!0),i=t?{position:t.position}:void 0;this.goToInsideMode(d.n.Interpolate,i,l.Ey.Panorama)}}}else e===T.Mx.WORKSHOP&&(this.dhDisabled=()=>!1,this.fpDisabled=()=>!1);this.previousApp=e}async onChangeViewmodeCommand(e){try{switch(e.mode){case n.BD.INSIDE:return this.goToInsideMode(e.transitionType,e.pose,l.Ey.Panorama);case n.BD.DOLLHOUSE:return this.goToDollhouse(e.transitionType,e.pose);case n.BD.FLOORPLAN:return this.goToFloorplan(e.transitionType,e.pose);case n.BD.ORTHOGRAPHIC:return this.goToOrthographic(e.transitionType,e.pose);case n.BD.MESH:return this.goToInsideMode(e.transitionType,e.pose,l.Ey.Mesh)}}catch(t){throw this.log.error(t),new S.x6(`Could not move to mode ${e.mode}`,t)}}async goToInsideMode(e=d.n.Interpolate,t={},i){const s=this.engine.market.tryGetData(g.Z);if(!s)throw new S.YR;if(!(0,l.Bw)(i))throw new S.YR;let o=t.sweepID||s.currentSweep;if(o||(o=await this.getLookAtSweep(s)),s.isSweepUnaligned(o)){const e=s.getFirstAlignedSweep();o=e?e.id:this.getFirstSweepId(s)}return(0,l.Bw)(this.viewmodesModule.currentMode)&&s.isSweepUnaligned(s.currentSweep)?this.engine.commandBinder.issueCommand(new v.ju({sweep:o,rotation:t.rotation,transition:d.n.FadeToBlack})):this.viewmodesModule.switchToMode(i,e,{sweepID:o,rotation:t.rotation},a.DEFAULT_TRANSITION_TIME)}async getLookAtSweep(e){const t=this.engine.market.tryGetData(w.M);if(!t)return this.getFirstSweepId(e);const i=this.engine.market.tryGetData(D.c),s=(null==i?void 0:i.getFloorMin())||this.getModelMinHeight(),o=new m.Plane(u.f.DOWN,s),r=(0,p.Fe)(t.pose.position,t.pose.rotation,o);if(!r)return this.getFirstSweepId(e);const n=[f._T(),f._k(),e=>!i||i.isCurrentOrAllFloors(e.floorId)],a=[y.l0(r)],h=e.sortByScore(n,a).shift();if(h)return h.sweep.id;const l=e.getClosestSweep(r,!0);return l?l.id:this.getFirstSweepId(e)}getFirstSweepId(e){const t=e.getFirstSweep();if(void 0===t)throw new Error("First enabled sweep not found");return t.id}getModelMinHeight(){return this.meshData||(this.meshData=this.engine.market.tryGetData(c._)),this.meshData?this.meshData.extendedBounds.min.y:0}async goToDollhouse(e=d.n.Interpolate,t={}){if(this.dhDisabled())throw new S.YR;return this.viewmodesModule.switchToMode(l.Ey.Dollhouse,e,t)}async goToFloorplan(e=d.n.Interpolate,t={}){if(this.fpDisabled())throw new S.YR;const i=await this.engine.getModuleBySymbol(r.y.CANVAS);return i&&await i.getTransitionPromise(),this.viewmodesModule.switchToMode(l.Ey.Floorplan,e,t)}async goToOrthographic(e=d.n.Interpolate,t={}){const i=await this.engine.getModuleBySymbol(r.y.CANVAS);return i&&await i.getTransitionPromise(),this.viewmodesModule.switchToMode(l.Ey.Orthographic,e,t)}}},92393:e=>{e.exports="precision highp float;precision highp int;uniform mat4 viewMatrix;uniform vec3 cameraPosition;uniform float borderSize;uniform float textureSampleScale;uniform samplerCube panoTexture;uniform vec4 borderColor;varying vec2 vUv;const vec4 transparent=vec4(0.,0.,0.,0.);const float PI=3.14159265359;const float HALF_PI=PI/2.;void main(){float fadeDist=0.1;float r=1.;vec2 uv=(vUv*2.)-vec2(1.,1.);float d=length(uv);float p=d*PI-HALF_PI;float y=sin(p);float h=cos(p)*textureSampleScale;vec3 sampleVec=vec3(uv.x*h,y,uv.y*h);vec4 panoColor=textureCube(panoTexture,sampleVec);panoColor.a=clamp(((1.-d)/d)/fadeDist,0.,1.);vec4 outColor=mix(panoColor,transparent,step(1.,d));float isBorder=max(sign(borderSize),0.)*step(1.-borderSize,d)*step(d,1.);gl_FragColor=mix(outColor,borderColor,isBorder);}"},27115:e=>{e.exports="precision highp float;precision highp int;uniform mat4 modelMatrix;uniform mat4 modelViewMatrix;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform mat3 normalMatrix;uniform vec3 cameraPosition;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec2 vUv;void main(){vUv=uv;vec4 projectedPosition=projectionMatrix*viewMatrix*modelMatrix*vec4(position,1.);gl_Position=projectedPosition;}"},20367:e=>{e.exports="precision highp float;precision highp int;uniform mat4 viewMatrix;uniform vec3 cameraPosition;uniform sampler2D bg;uniform sampler2D mask;varying vec2 vUv;void main(){vec4 existingColor=texture2D(bg,vUv);vec4 maskColor=texture2D(mask,vUv);gl_FragColor=vec4(existingColor.rgb*maskColor.rgb,maskColor.a);}"},98419:e=>{e.exports="precision highp float;precision highp int;uniform mat4 modelMatrix;uniform mat4 modelViewMatrix;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform mat3 normalMatrix;uniform vec3 cameraPosition;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*vec4(position,1.);}"},14282:e=>{e.exports="precision highp float;precision highp int;uniform mat4 viewMatrix;uniform vec3 cameraPosition;\n#define M_PI 3.14159265359\nuniform samplerCube cubemap;uniform float yaw;varying vec2 vUv;void main(){vec2 uv=vUv;float theta=uv.x*2.*M_PI+yaw;float phi=uv.y*M_PI;vec3 longitude=vec3(sin(theta),1.,-cos(theta));vec3 latitude=vec3(sin(phi),-cos(phi),sin(phi));vec3 dir=longitude*latitude;normalize(dir);gl_FragColor=vec4(textureCube(cubemap,dir).rgb,1.);}"},17965:e=>{e.exports="precision highp float;precision highp int;uniform mat4 modelMatrix;uniform mat4 modelViewMatrix;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform mat3 normalMatrix;uniform vec3 cameraPosition;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec2 vUv;void main(){vUv=vec2(1.-uv.x,uv.y);gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}"},46262:e=>{e.exports="precision highp float;precision highp int;uniform mat4 viewMatrix;uniform vec3 cameraPosition;uniform vec3 topColor;uniform vec3 bottomColor;uniform float radius;varying vec4 worldPosition;\n#define SRGB_TO_LINEAR(c)pow((c),vec3(2.2))\n#define LINEAR_TO_SRGB(c)pow((c),vec3(1./2.2))\n#define USE_DITHER \nfloat gradientNoise(in vec2 uv){const vec3 magic=vec3(0.06711056,0.00583715,52.9829189);return fract(magic.z*fract(dot(uv,magic.xy)));}void main(){float normalizedHeight=(worldPosition.y+radius)/(radius*2.);float ratio=smoothstep(0.,0.5,normalizedHeight);vec3 colorFromGradient=mix(SRGB_TO_LINEAR(bottomColor),SRGB_TO_LINEAR(topColor),ratio);vec3 color=LINEAR_TO_SRGB(colorFromGradient);\n#if defined (USE_DITHER)\ncolor+=(1./255.)*gradientNoise(gl_FragCoord.xy)-(0.5/255.);\n#endif\ngl_FragColor=vec4(color,1.);}"},80218:e=>{e.exports="precision highp float;precision highp int;uniform mat4 modelMatrix;uniform mat4 modelViewMatrix;uniform mat4 projectionMatrix;uniform mat4 viewMatrix;uniform mat3 normalMatrix;uniform vec3 cameraPosition;attribute vec3 position;attribute vec3 normal;attribute vec2 uv;varying vec4 worldPosition;void main(){worldPosition=modelMatrix*vec4(position,1.);gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.);}"}}]);
|