UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 6.65 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{filterInPlace as r}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{equalsShallow as i}from"../../../core/lang.js";import{floatEqualUlp as o}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as p,subclass as c}from"../../../core/accessorSupport/decorators.js";import{diff as h}from"../../../core/accessorSupport/diffUtils.js";import{projectBuffer as l}from"../../../geometry/projection/projectBuffer.js";import{fromBuffer as d,create as u}from"../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as m}from"../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as f}from"../../../layers/graphics/dehydratedPoint.js";import{RenderingInfo as y}from"../../../renderers/support/RenderingInfo.js";import g from"../../../symbols/PointSymbol3D.js";import{Graphics3DCore as b}from"./graphics/Graphics3DCore.js";import{Graphics3DScaleVisibility as _}from"./graphics/Graphics3DScaleVisibility.js";import{boundingBoxCornersPointsStride as v,boundingBoxCornerPoints as I}from"./i3s/I3SGeometryUtil.js";import{LimitGraphicsMap as w}from"../support/LimitGraphicsMap.js";import{hasLayerBasedScaleVisibility as G}from"../../support/layerViewUtils.js";class j{constructor(e,t){this.meta=e,this.index=t}}class C{constructor(e,t){this.graphic=e,this.geometry=t,this.components=[],this.overridesDirty=!1}}let M=class extends t{get updating(){return this._graphicsCore?.updating??!1}constructor(e){super(e),this.loadedGraphics=new w(5e4),this.slicePlaneEnabled=!1,this._renderingInfo=new y(null,new g),this._featuresMap=new Map}initialize(){const e=this.view.basemapTerrain;this._graphicsCore=new b({owner:this,layer:this.layer,preferredUpdatePolicy:0,elevationFeatureExpressionEnabled:!1,graphicSymbolSupported:!1,getRenderingInfoWithoutRenderer:!0,hasZ:!0,hasM:!1,componentFactories:{deconflictor:e=>this.view.deconflictor.addGraphicsOwner(e),labeler:(e,t)=>this.view.labeler.addGraphicsOwner(e,t,{emptySymbolLabelSupported:!0,elevationInfoOverride:{mode:"absolute-height",offset:0},disablePlacement:{logEntityDescription:"3D Object Scene Layer features"}}),scaleVisibility:G()?null:(t,r)=>new _({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:r,graphicsCore:t,basemapTerrain:e,layerScaleEnabled:!1})}}),this._graphicsCore.initializePromise.then(()=>this._graphicsCore.startCreateGraphics()).catch(()=>{}),this.addHandles(a(()=>this.layer.labelingInfo,(e,t)=>{h(e,t)&&this._graphicsCore.updateLabelingInfo()}))}destroy(){this._graphicsCore=s(this._graphicsCore),this.loadedGraphics=s(this.loadedGraphics),this.view=null}addNodeMeta(e,t){let r=0;const i=e.filteredIds,o=this.view.spatialReference,s=[];for(let a=0;a<e.featureIds.length;a++){const p=e.featureIds[a];let c=null==i;if(i&&r<i.length&&p===i[r]&&(c=!0,r++),!this._enabledForFeatureInNode(e,a))continue;const h=this._featuresMap.get(p);if(h){h.components.push(new j(e,a)),this._updateLabelPosition(p);continue}const l=t(a,e),d=f(0,0,0,o),u={objectId:p,uid:n(),attributes:l,visible:c,geometry:d},m=new C(u,d);m.components.push(new j(e,a)),this._featuresMap.set(p,m),this._updateLabelGeometry(p),s.push(u)}this.loadedGraphics.addMany(s)}updateLabelPositions(e){const t=this.view.renderCoordsHelper;this._forEachGraphic(e,(r,i,o)=>{const s=this._graphicsCore.getGraphics3DGraphicById(i.uid);null!=s&&this._updateLabelGeometry(e.featureIds[r])&&s.alignWithAbsoluteElevation(o.z??0,t,!1)})}setNodeMetaAttributes(e,t){const r=new Array;this._forEachGraphic(e,(o,s)=>{const a=t(o,e);i(s.attributes,a)||(s.attributes=a,r.push(s.uid))}),this._graphicsCore.updateLabelingInfo(r)}applyFilterChange(e){this._forEachFeature(e,(t,r,i)=>{if(!this._enabledForFeatureInNode(e,t)){const i=e.featureIds[t];switch(this._removeFeature(r,e,t)){case 2:this.loadedGraphics.removeManyByObjectId([i]);break;case 1:this._updateLabelPosition(i)}return}const o=r.graphic,s=o.visible;s!==i&&(o.visible=i,E.graphic=o,E.property="visible",E.oldValue=s,E.newValue=i,this._graphicsCore.graphicUpdateHandler(E),E.graphic=null)})}removeNodeMeta(e){const t=[];this._forEachGraphic(e,r=>{const i=e.featureIds[r],o=this._featuresMap.get(i);if(!o)return;switch(this._removeFeature(o,e,r)){case 1:this._updateLabelPosition(i);break;case 2:t.push(i)}}),this.loadedGraphics.removeManyByObjectId(t)}_removeFeature(e,t,i){const o=e.components.length;return r(e.components,e=>!(e.meta===t&&e.index===i)),0===e.components.length?(this._featuresMap.delete(t.featureIds[i]),2):o!==e.components.length?1:0}getRenderingInfo(){return this._renderingInfo}notifyGraphicGeometryChanged(){}notifyGraphicVisibilityChanged(){}_updateLabelPosition(e){const t=this._featuresMap.get(e);t&&this._updateLabelGeometry(e)&&(this.loadedGraphics.removeManyByObjectId([e]),this.loadedGraphics.addMany([t.graphic]))}_updateLabelGeometry(e){const t=this._featuresMap.get(e);if(!t)return!1;const r=t.geometry,i=this.view.spatialReference,s=this.view.renderCoordsHelper,a=r.x,n=r.y,p=r.z??0,c=t.components.length,h=m(c*v);let u=0;for(const{meta:o,index:l}of t.components)I(l,this.collection,o.objectHandle,h,u),u+=v;return l(h,s.spatialReference,0,h,i,0),d(h,F),r.x=(F[0]+F[3])/2,r.y=(F[1]+F[4])/2,r.z=F[5],!o(r.x,a)||!o(r.y,n)||!o(r.z,p)}_forEachGraphic(e,t){this._forEachFeature(e,(r,{graphic:i,geometry:o},s)=>{this._enabledForFeatureInNode(e,r)&&t(r,i,o,s)})}_forEachFeature(e,t){let r=0;for(let i=0;i<e.featureIds.length;i++){const o=this._featuresMap.get(e.featureIds[i]);let s=null==e.filteredIds;e.filteredIds?.[r]===e.featureIds[i]&&(s=!0,r++),o&&t(i,o,s)}}_enabledForFeatureInNode(e,t){return e.node.index<0||!this.overrides?.featureHasGeometryChanges(e.featureIds[t])}get updatePolicy(){return this._graphicsCore.effectiveUpdatePolicy}get usedMemory(){return this._graphicsCore.usedMemory}get unloadedMemoryEstimate(){return this._graphicsCore.unprocessedMemoryEstimate}get test(){}};e([p()],M.prototype,"view",void 0),e([p()],M.prototype,"layer",void 0),e([p()],M.prototype,"collection",void 0),e([p()],M.prototype,"loadedGraphics",void 0),e([p()],M.prototype,"overrides",void 0),e([p()],M.prototype,"layerViewUid",void 0),e([p()],M.prototype,"updating",null),e([p()],M.prototype,"slicePlaneEnabled",void 0),e([p()],M.prototype,"_graphicsCore",void 0),M=e([c("esri.views.3d.layers.I3SMeshViewLabeler")],M);const E={graphic:null,property:null,oldValue:null,newValue:null},F=u();export{M as default};