UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 3.31 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import s from"../../core/Accessor.js";import t from"../../core/Collection.js";import{referenceSetter as i}from"../../core/collectionUtils.js";import r from"../../core/Logger.js";import{isAbortError as o}from"../../core/promiseUtils.js";import{watch as l,whenOnce as a}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/BuildingSceneLayer.js";import y from"../../layers/support/BuildingFilter.js";import h from"./BuildingDisciplinesViewModel.js";import c from"./BuildingLevel.js";import m from"./BuildingPhase.js";import{showFullModel as u}from"./support/buildingLayerUtils.js";import{setFilterOnLayers as f,getFilterBlockSolid as g,getFilterBlockXRay as j,generateFilterId as v}from"./support/filterUtils.js";import{createLoadLayersFunction as _}from"./support/layerUtils.js";let w=class extends s{constructor(e){super(e),this.view=null,this.state="disabled",this.level=new c,this.phase=new m,this.disciplines=new h,this._loadLayers=_(),this.layers=new t}initialize(){this.addHandles([this.layers.on("change",(()=>this._onLayersChange())),l((()=>({state:this.state,layers:this.layers,filter:this._filter})),(({state:e,layers:s,filter:t})=>{"ready"===e&&f(s,t)}),{initial:!0})]),this._onLayersChange()}destroy(){this.level.destroyed||this.level.destroy(),this.phase.destroyed||this.phase.destroy(),this.disciplines.destroyed||this.disciplines.destroy()}get isSupported(){return"3d"===this.view?.type}get layers(){return this._get("layers")}set layers(e){const s=e.filter((e=>e instanceof d));s.length!==e.length&&r.getLogger(this).error("Some layers are not BuildingSceneLayers but only BuildingSceneLayers can be passed to the widget."),this._set("layers",i(s,this._get("layers")))}get _filter(){const e=this.level.filterExpressions,s=this.phase.filterExpressions,t=[],i=g([e.solid,s.solid]);null!=i&&t.push(i);const r=j([e.xRay,s.xRay]);return null!=r&&t.push(r),0===t.length?null:new y({id:v(),name:"Building Explorer Filter",filterBlocks:t})}async _onLayersChange(){const e=this.layers;if(this.level.layers=e,this.phase.layers=e,this.disciplines.layers=e,0!==e.length){this._set("state","loading");try{await this._loadLayers(e),await Promise.all([a((()=>"ready"===this.level.state)),a((()=>"ready"===this.phase.state)),a((()=>"ready"===this.disciplines.state))]),e.forEach(u),this._set("state","ready")}catch(s){o(s)||this._set("state","failed")}}else this._set("state","disabled")}};e([p({value:null})],w.prototype,"view",void 0),e([p()],w.prototype,"isSupported",null),e([p({type:t,nonNullable:!0})],w.prototype,"layers",null),e([p({readOnly:!0})],w.prototype,"state",void 0),e([p({readOnly:!0,type:c})],w.prototype,"level",void 0),e([p({readOnly:!0,type:m})],w.prototype,"phase",void 0),e([p({readOnly:!0,type:h})],w.prototype,"disciplines",void 0),e([p()],w.prototype,"_filter",null),w=e([n("esri.widgets.BuildingExplorer.BuildingExplorerViewModel")],w);const L=w;export{L as default};