@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.99 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Collection.js";import{handlesGroup as s}from"../../../core/handleUtils.js";import i from"../../../core/Logger.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{abortMaybe as n}from"../../../core/maybe.js";import{isAbortError as l,allSettledValues as a,throwIfAborted as u,createResolver as p}from"../../../core/promiseUtils.js";import{watch as h,syncAndInitial as c}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import"../../../layers/buildingSublayers/BuildingGroupSublayer.js";import{isQuery as g,isGraphic as f}from"../../../support/guards.js";import m from"./BuildingComponentSublayerView3D.js";import{BuildingSublayerView3DMixin as w}from"./BuildingSublayerView3D.js";import{LayerView3D as b}from"./LayerView3D.js";import{parseFilterMode as V}from"./i3s/BuildingFilterUtil.js";import{checkSpatialReference as j}from"./i3s/I3SUtil.js";import{emptyHighlightHandle as C,normalizeHighlightTargetExceptQuery as _}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as S}from"./support/LayerViewPerformanceInfo.js";import{updatingProgress as v}from"../support/updatingProperties.js";import B from"../../layers/BuildingSceneLayerView.js";import{isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";const F=w(r);let M=class extends(b(B)){constructor(e){super(e),this.type="building-scene-3d",this.sublayerViews=new t,this._abortController=new AbortController,this._loadingComponents=0,this._pendingWhenSublayerViews=new Map,this.ignoresMemoryFactor=!1}get filterExpression(){const e=this.layer.activeFilterId,r=null!=e?this.layer.filters.find((r=>r.id===e)):null,t=null!=r?r.filterBlocks?.find((e=>"solid"===e.filterMode.type)):null;return t?t.filterExpression:null}get filterExpressions(){const e=this.layer.activeFilterId,r=null!=e?this.layer.filters.find((r=>r.id===e)):null;return r?.filterBlocks?r.filterBlocks.toArray().map((e=>[e.filterExpression??"",V(e)])):[]}get updatingProgressValue(){const e=this.sublayerViews,r=this._loadingComponents+(e?e.length:0);return e.reduce(((e,r)=>e+r.updatingProgress),0)/r}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){return this._loadingComponents>0||this.sublayerViews&&this.sublayerViews.some((e=>e.updating))}initialize(){j(this.layer.spatialReference,this.view.spatialReference,this.view.viewingMode),this._initializeSubLayerViews(this.layer.sublayers,this)}destroy(){this.sublayerViews&&(this.sublayerViews.forEach((e=>e.destroy())),this.sublayerViews=null),this._abortController=n(this._abortController)}_initializeSubLayerViews(e,r){const t=this,s=this.view;e.forEach((e=>{if(!e.isEmpty)if("building-group"===e.type){const t=new F({sublayer:e,view:s,parent:r});this._initializeSubLayerViews(e.sublayers,t)}else"mesh"===e.geometryType&&(this._loadingComponents++,e.load({signal:this._abortController.signal}).then((()=>{const i=new m({sublayer:e,layerView:t,view:s,parent:r});this.sublayerViews.push(i);const o=this._pendingWhenSublayerViews.get(e);if(o){for(const e of o)e.resolve(i);this._pendingWhenSublayerViews.delete(e)}this.addHandles([h((()=>i.updating),(()=>this.notifyChange("updating")),c),h((()=>i.updatingProgress),(()=>this.notifyChange("updatingProgressValue")),c)])})).catch((r=>{l(r)||i.getLogger(this).error(`Error while creating view for sublayer ${e.id}\nLayer: ${this.layer.url}\n`,r)})).then((()=>{this._loadingComponents--,this.notifyChange("updating"),this.notifyChange("updatingProgressValue")})))}))}getGraphicFromIntersectorTarget(e){for(const r of this.sublayerViews.items)if(r.sublayer.uid===e.sublayerUid)return r.getGraphicFromIntersectorTarget(e);return null}async fetchPopupFeaturesFromGraphics(e,r){if(0===e.length)return[];const t=P(e,(e=>e.sourceLayer)),s=[];for(const[o,n]of t){const e=this._findComponent(o);null!=e&&s.push(e.fetchPopupFeaturesFromGraphics(n,r))}const i=await a(s);return u(r),i.flat()}whenGraphicBounds(e){const r=this._findComponent(e.sourceLayer);return null==r?Promise.reject():r.whenGraphicBounds(e)}getAABBFromIntersectorTarget(e){for(const r of this.sublayerViews.items)if(r.sublayer.uid===e.sublayerUid)return r.getAABBFromIntersectorTarget(e);return null}async whenSublayerView(e){const r=this._findComponent(e);if(null!=r)return r;const t=this._pendingWhenSublayerViews.get(e),s=p();return t?t.push(s):this._pendingWhenSublayerViews.set(e,[s]),s.promise}_findComponent(e){return this.sublayerViews.find((r=>e===r.sublayer))}highlight(e,r){if(g(e))return C;const t=_(e);if(0===t.length)return C;if(f(t[0])){const e=t,i=new Map;for(const r of e)o(i,r.sourceLayer,(()=>[])).push(r);const n=[];return this.sublayerViews.forEach((e=>{const t=i.get(e.sublayer);t&&n.push(e.highlight(t,r))})),s(n)}return C}get usedMemory(){return this.sublayerViews.reduce(((e,r)=>e+r.usedMemory),0)}get unloadedMemory(){return this.sublayerViews.reduce(((e,r)=>e+r.unloadedMemory),0)}get performanceInfo(){return new S(this.usedMemory)}};function P(e,r){const t=new Map,s=e.length;for(let i=0;i<s;i++){const s=e[i],o=r(s,i,e),n=t.get(o);n?n.push(s):t.set(o,[s])}return t}e([y()],M.prototype,"sublayerViews",void 0),e([y({readOnly:!0})],M.prototype,"filterExpression",null),e([y({readOnly:!0})],M.prototype,"filterExpressions",null),e([y(v)],M.prototype,"updatingProgress",void 0),e([y({readOnly:!0,dependsOn:[]})],M.prototype,"updatingProgressValue",null),e([y({readOnly:!0})],M.prototype,"visibleAtCurrentScale",null),M=e([d("esri.views.3d.layers.BuildingSceneLayerView3D")],M);const E=M;export{E as default};