UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 13.5 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Graphic.js";import{XXH as i}from"../../../../arcade/functions/hash.js";import{neverReached as s}from"../../../../core/compilerUtils.js";import{HandleOwner as r}from"../../../../core/HandleOwner.js";import{destroyMaybe as n,isSome as a,isNone as o,unwrap as l}from"../../../../core/maybe.js";import{logOnError as p}from"../../../../core/promiseUtils.js";import{watch as u,initial as d,when as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as m}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as y}from"../../../../core/accessorSupport/diffUtils.js";import{canProject as g,project as b}from"../../../../geometry/support/webMercatorUtils.js";import{matchRandomRotationExpression as f}from"../../../../renderers/support/randomRotationExpression.js";import{getRenderingInfo as E,getRenderingInfoAsync as C}from"../../../../renderers/support/renderingInfoUtils.js";import x from"../../../../rest/support/Query.js";import{DrapeSourceType as v}from"../interfaces.js";import{SUSPEND_RESUME_EXTENT_OPTIMISM as w}from"./constants.js";import{Graphics3DCore as V}from"./Graphics3DCore.js";import j from"./Graphics3DElevationAlignment.js";import S from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as R}from"./Graphics3DObjectStates.js";import O from"./Graphics3DScaleVisibility.js";import{enlargeExtent as I}from"./graphicUtils.js";import{attributeLookup as G}from"../support/attributeUtils.js";import{FeatureVisibilityFilter as _}from"../support/FeatureVisibilityFilter.js";import{Object3DState as A}from"../../webgl-engine/lib/basicInterfaces.js";import{UpdatePolicy as P}from"../../webgl-engine/lib/UpdatePolicy.js";let U=class extends r{constructor(e){super(e),this.type="graphics-3d",this._randomRotationRenderers=null,this.elevationFeatureExpressionEnabled=!1,this.scaleVisibilityEnabled=!1,this.filterVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this.elevationAlignmentEnabled=!1,this.timeExtentEnabled=!1,this.setUidToIdOnAdd=!0,this.dataExtent=null,this.drapeSourceType=v.Features,this.preferredUpdatePolicy=P.ASYNC,this._suspendResumeExtent=null}initialize(){const e=this.owner,t=(this.filterVisibilityEnabled||this.timeExtentEnabled)&&"multipatch"!==e.layer.geometryType,i=new V({owner:this,layer:this.layer,preferredUpdatePolicy:this.preferredUpdatePolicy,elevationFeatureExpressionEnabled:this.elevationFeatureExpressionEnabled,graphicSymbolSupported:!1,hasZ:e.hasZ,hasM:e.hasM,setUidToIdOnAdd:this.setUidToIdOnAdd,componentFactories:{deconflictor:t=>e.view.deconflictor.addGraphicsOwner(t),labeler:(t,i)=>e.view.labeler.addGraphicsOwner(t,i),elevationAlignment:this.elevationAlignmentEnabled?(t,i)=>new j({graphicsCoreOwner:this,graphicsCore:t,queryGraphicUIDsInExtent:i,elevationProvider:e.view.elevationProvider}):null,scaleVisibility:this.scaleVisibilityEnabled?(t,i)=>new O({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:i,graphicsCore:t,basemapTerrain:e.view.basemapTerrain}):null,filterVisibility:t?t=>new _({context:{layerView:e,...t}}):null,objectStates:e=>new R(e)}});this._set("graphicsCore",i),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new S({graphicsCoreOwner:this})),this.elevationAlignment&&this.updatingHandles.add((()=>this.layer.elevationInfo),((e,t)=>{y(e,t)&&this.updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())})),this.updatingHandles.add((()=>this.layer.labelsVisible),(()=>this.graphicsCore.updateVisibilityInfo())),this.updatingHandles.add((()=>this.layer.labelingInfo),((e,t)=>{y(e,t)&&this.graphicsCore.updateLabelingInfo()})),this.updatingHandles.add((()=>this.preferredUpdatePolicy),(e=>this.graphicsCore.preferredUpdatePolicy=e)),this._set("initializePromise",this._initializeAsync()),this.updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){await p(this.graphicsCore.initializePromise);const e=this.owner;this.updatingHandles.add((()=>this.renderer),(e=>this.updatingHandles.addPromise(this.graphicsCore.rendererChange(e)))),this.updatingHandles.add((()=>e.fullOpacity),(()=>this.graphicsCore.opacityChange())),this._setupSuspendResumeExtent(),this.updateClippingExtent&&(this.updatingHandles.add((()=>e.view.clippingArea),(()=>this._updateClippingExtent())),this._updateClippingExtent()),this.graphicsCore.startCreateGraphics(),this.graphicsCore.labelsEnabled&&await p(this.graphicsCore.updateLabelingInfo())}destroy(){this.handles.removeAll(),this.updatingHandles.removeAll(),this._set("frustumVisibility",n(this.frustumVisibility)),this._set("graphicsCore",n(this.graphicsCore)),this._set("owner",null)}get layer(){return this.owner.layer}get renderer(){const{renderer:e,objectIdField:t}=this.layer;if(!e||!t||"heatmap"===e.type||!e.visualVariables)return e;const i=e.visualVariables.findIndex((e=>"rotation"===e.type&&null!=e.valueExpression&&f(e.valueExpression)===t&&(null==e.axis||"heading"===e.axis)&&"geographic"===e.rotationType));if(i<0)return e;const s=e.clone();return s.visualVariables.splice(i,1),this._randomRotationRenderers||(this._randomRotationRenderers=new WeakMap),this._randomRotationRenderers.set(s,t),s}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get filterVisibility(){return this.graphicsCore?.filterVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get objectStates(){return this.graphicsCore?.objectStates}get suspendResumeExtentMode(){return"suspendResumeExtentMode"in this.owner?this.owner.suspendResumeExtentMode:"computed"}get scaleVisibilitySuspended(){return a(this.scaleVisibility)&&this.scaleVisibility.suspended}get suspended(){return this.owner.suspended}get legendEnabled(){return o(this.frustumVisibility)||!this.frustumVisibility.suspended}get suspendInfo(){const e={};return this.scaleVisibilitySuspended&&(e.outsideScaleRange=!0),a(this.frustumVisibility)&&this.frustumVisibility.suspended&&(e.outsideOfView=!0),e}get updating(){return!!(this.graphicsCore?.updating||a(this.frustumVisibility)&&this.frustumVisibility.updating||this.updatingHandles?.updating)}get updatingRemaining(){return this.graphicsCore?.updatingRemaining??0}get featureStore(){return this.graphicsCore?.featureStore}get view(){return this.owner.view}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner?.fullOpacity}get filter(){return"filter"in this.owner?this.owner.filter:null}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}get featureSpatialReference(){return"featureSpatialReference"in this.owner?this.owner.featureSpatialReference:this.owner.view.spatialReference}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get symbolUpdateType(){return this.graphicsCore?.symbolUpdateType}get displayFeatureLimit(){const e=this.view.resourceController.memoryController.memoryFactor,t=this.graphicsCore?.displayFeatureLimit;if(1===e)return t;const i=Math.ceil(t.maximumNumberOfFeatures*e),s=Math.ceil(t.maximumTotalNumberOfFeatures*e),r=Math.ceil(t.minimumTotalNumberOfFeatures*e);return{...t,maximumNumberOfFeatures:i,maximumTotalNumberOfFeatures:s,minimumTotalNumberOfFeatures:r}}get usedMemory(){return this.graphicsCore?.usedMemory??0}get loadedFeatures(){return this.graphicsCore?.numberOfGraphics??0}get usedMemoryPerFeature(){return this.graphicsCore?.usedMemoryPerGraphic??0}get unprocessedMemoryEstimate(){return this.graphicsCore?.unprocessedMemoryEstimate??0}get performanceInfo(){return{core:this.graphicsCore.performanceInfo,elevationUpdating:this.elevationAlignment.updating,visibilityFrustum:o(this.frustumVisibility)||!this.frustumVisibility.suspended,visibilityScale:!this.scaleVisibilitySuspended}}maskOccludee(e){const{set:t,handle:i}=this.objectStates.acquireSet(A.MaskOccludee,null);return this.objectStates.setUid(t,e.uid),i}highlight(e,i){if(e instanceof x){const{set:t,handle:s}=this.objectStates.acquireSet(A.Highlight,i);return this.owner.queryObjectIds(e).then((e=>this.objectStates.setObjectIds(t,e))),s}if("number"==typeof e||"string"==typeof e)return this.highlight([e],i);if(e instanceof t)return this.highlight([e],i);if("toArray"in e&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof t){const t=e;if(null==G(this.layer.fieldsIndex,t[0].attributes,i)){const e=t.map((e=>e.uid)),{set:i,handle:s}=this.objectStates.acquireSet(A.Highlight,null);return this.objectStates.setUids(i,e),s}e=t.map((e=>G(this.layer.fieldsIndex,e.attributes,i)))}if("number"==typeof e[0]||"string"==typeof e[0]){const t=e,{set:s,handle:r}=this.objectStates.acquireSet(A.Highlight,i);return this.objectStates.setObjectIds(s,t),r}}return T}resetObjectStates(){this.objectStates.reset()}whenGraphicBounds(e,t){return this.graphicsCore?.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.graphicsCore?.computeAttachmentOrigin(e,t)}notifyGraphicGeometryChanged(e){this.graphicsCore.notifyGraphicGeometryChanged(e)}notifyGraphicVisibilityChanged(e){this.graphicsCore.notifyGraphicVisibilityChanged(e)}getRenderingInfo(e,t,s){const r=E(e,{renderer:t,arcade:s});if(a(r)&&r.color){const e=r.color;e[0]=e[0]/255,e[1]=e[1]/255,e[2]=e[2]/255}if(a(r)&&a(t)&&this._randomRotationRenderers?.has(t)){const s=this._randomRotationRenderers.get(t),n=e.attributes[s],a=new i(0);a.updateFloatArray([n]),a.updateUint8Array([173]),r.heading=8.381e-8*a.digest()}return r}getRenderingInfoAsync(e,t,i,s){return C(e,{renderer:t,arcade:i,...s})}getSymbolLayerSize(e,t){return this.graphicsCore?.getSymbolLayerSize(e,t)}setObjectIdVisibility(e,t){this.graphicsCore?.setObjectIdVisibility(e,t)}refreshFilter(){a(this.filterVisibility)&&this.filterVisibility.reapply()}getGraphics3DGraphicByObjectId(e){return this.graphicsCore?.getGraphics3DGraphicByObjectId(e)}_updateClippingExtent(){const e=this.owner.view.clippingArea;this.graphicsCore.setClippingExtent(e,this.owner.view.spatialReference)&&(this.updateClippingExtent(e)||this.graphicsCore.recreateAllGraphics())}_setupSuspendResumeExtent(){(this.frustumVisibility||this.scaleVisibility)&&this.handles.add(u((()=>this.suspendResumeExtentMode),(()=>{switch(this.handles.remove(M),this.suspendResumeExtentMode){case"computed":this.handles.add([u((()=>this.graphicsCore.computedExtent),(e=>this._updateSuspendResumeExtent(e)),d),u((()=>this.graphicsCore.extentPadding),(()=>this._updateSuspendResumeExtent(this.graphicsCore.computedExtent)))],M);break;case"data":this.handles.add([h((()=>this.dataExtent),(e=>this._updateSuspendResumeExtent(e)),d),u((()=>this.graphicsCore.extentPadding),(()=>this._updateSuspendResumeExtent(l(this.dataExtent))))],M);break;default:s(this.suspendResumeExtentMode)}}),d))}_updateSuspendResumeExtent(e){e?this._suspendResumeExtentChanged(this._extentToSuspendResumeRect(e,this._suspendResumeExtent)):this._suspendResumeExtentChanged(null)}_extentToSuspendResumeRect(e,t){const i=this.owner.view.spatialReference;if(!e.spatialReference.equals(i)){if(!g(e,i))return;e=b(e,i)}return I(e,t,w,this.graphicsCore.extentPadding)}_suspendResumeExtentChanged(e){a(this.frustumVisibility)&&this.frustumVisibility.setExtent(e),a(this.scaleVisibility)&&this.scaleVisibility.setExtent(e)}};e([c()],U.prototype,"type",void 0),e([c({constructOnly:!0})],U.prototype,"owner",void 0),e([c()],U.prototype,"layer",null),e([c()],U.prototype,"renderer",null),e([c({constructOnly:!0})],U.prototype,"updateClippingExtent",void 0),e([c({constructOnly:!0})],U.prototype,"elevationFeatureExpressionEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"graphicsCore",void 0),e([c({constructOnly:!0})],U.prototype,"scaleVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"filterVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"frustumVisibilityEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"elevationAlignmentEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"timeExtentEnabled",void 0),e([c({constructOnly:!0})],U.prototype,"setUidToIdOnAdd",void 0),e([c()],U.prototype,"scaleVisibility",null),e([c()],U.prototype,"filterVisibility",null),e([c()],U.prototype,"elevationAlignment",null),e([c({constructOnly:!0})],U.prototype,"frustumVisibility",void 0),e([c()],U.prototype,"objectStates",null),e([c()],U.prototype,"initializePromise",void 0),e([c()],U.prototype,"suspendResumeExtentMode",null),e([c()],U.prototype,"dataExtent",void 0),e([c()],U.prototype,"scaleVisibilitySuspended",null),e([c()],U.prototype,"suspended",null),e([c()],U.prototype,"legendEnabled",null),e([c()],U.prototype,"suspendInfo",null),e([c()],U.prototype,"updating",null),e([c()],U.prototype,"updatingRemaining",null),e([c()],U.prototype,"featureStore",null),e([c()],U.prototype,"view",null),e([c()],U.prototype,"loadedGraphics",null),e([c()],U.prototype,"fullOpacity",null),e([c()],U.prototype,"filter",null),e([c()],U.prototype,"slicePlaneEnabled",null),e([c()],U.prototype,"drapeSourceType",void 0),e([c()],U.prototype,"updatePolicy",null),e([c()],U.prototype,"preferredUpdatePolicy",void 0),e([c()],U.prototype,"displayFeatureLimit",null),U=e([m("esri.views.3d.layers.graphics.Graphics3DFeatureProcessor")],U);const F=U,M="suspendResumeExtentMode",T={remove(){},pause(){},resume(){}};export{F as default};