UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 7.85 kB
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../Graphic.js";import i from"../../../../core/Collection.js";import{HandleOwner as r}from"../../../../core/HandleOwner.js";import{makeHandle as s}from"../../../../core/handleUtils.js";import{isSome as n,destroyMaybe as o,isNone as a}from"../../../../core/maybe.js";import{isAbortError as p}from"../../../../core/promiseUtils.js";import{watch as l,sync as c,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as y}from"../../../../core/accessorSupport/diffUtils.js";import g from"../../../../layers/Layer.js";import{hydrateGraphic as m}from"../../../../layers/graphics/hydratedFeatures.js";import{getRenderingInfo as f,getRenderingInfoAsync as b}from"../../../../renderers/support/renderingInfoUtils.js";import C from"../../../../rest/support/Query.js";import{DrapeSourceType as j}from"../interfaces.js";import{SUSPEND_RESUME_EXTENT_OPTIMISM as w}from"./constants.js";import{Graphics3DCore as S}from"./Graphics3DCore.js";import v from"./Graphics3DElevationAlignment.js";import V from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as E}from"./Graphics3DObjectStates.js";import G from"./Graphics3DScaleVisibility.js";import{enlargeExtent as O}from"./graphicUtils.js";import{Object3DState as x}from"../../webgl-engine/lib/basicInterfaces.js";import{UpdatePolicy as P}from"../../webgl-engine/lib/UpdatePolicy.js";let A=class extends r{constructor(t){super(t),this.type="graphics-3d",this.graphicsCore=null,this.drapeSourceType=j.Features,this.scaleVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this._suspendResumeExtent=null}initialize(){const{layer:t}=this,e="effectiveScaleRange"in t?t:null,i=this.scaleVisibilityEnabled&&n(e),r=new S({owner:this,layer:this.owner.layer,preferredUpdatePolicy:P.SYNC,graphicSymbolSupported:!0,componentFactories:{elevationAlignment:(t,e)=>new v({graphicsCoreOwner:this,graphicsCore:t,queryGraphicUIDsInExtent:e,elevationProvider:this.view.elevationProvider}),scaleVisibility:i?(t,i)=>new G({graphicsCoreOwner:this,layer:e,queryGraphicUIDsInExtent:i,graphicsCore:t,basemapTerrain:this.owner.view.basemapTerrain}):null,objectStates:t=>new E(t)}});if(this._set("graphicsCore",r),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new V({graphicsCoreOwner:this})),"fullOpacity"in this.owner){const t=this.owner;this.updatingHandles.add((()=>t.fullOpacity),(()=>this.graphicsCore.opacityChange()))}if("elevationInfo"in t){const e=t;this.updatingHandles.add((()=>e.elevationInfo),((t,e)=>{y(t,e)&&this.updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())}))}this._set("initializePromise",this._initializeAsync()),this.updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){try{await this.graphicsCore.initializePromise}catch(t){if(p(t))return;throw t}this.destroyed||(this.handles.add(l((()=>this.view.clippingArea),(()=>this._updateClippingExtent()),c)),this._updateClippingExtent(),this._setupSuspendResumeExtent(),this.graphicsCore.startCreateGraphics())}destroy(){this.handles.removeAll(),this.updatingHandles.removeAll(),this._set("frustumVisibility",o(this.frustumVisibility)),this._set("graphicsCore",o(this.graphicsCore))}get layer(){return this.owner.layer}get view(){return this.owner.view}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get objectStates(){return this.graphicsCore?.objectStates}get scaleVisibilitySuspended(){return!(!n(this.scaleVisibility)||!this.scaleVisibility.suspended)}get frustumVisibilitySuspended(){return n(this.frustumVisibility)&&this.frustumVisibility.suspended}get suspended(){return this.owner.suspended??!1}get updating(){return!!(this.graphicsCore?.updating||n(this.scaleVisibility)&&this.scaleVisibility.updating||n(this.frustumVisibility)&&this.frustumVisibility.updating||this.updatingHandles.updating)}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner.fullOpacity??1}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}notifyGraphicGeometryChanged(t){this.graphicsCore.notifyGraphicGeometryChanged(t)}notifyGraphicVisibilityChanged(t){this.graphicsCore.notifyGraphicVisibilityChanged(t)}getRenderingInfo(t,e,i){const r=f(t,{renderer:e,arcade:i});if(n(r)&&r.color){const t=r.color;t[0]=t[0]/255,t[1]=t[1]/255,t[2]=t[2]/255}return r}getRenderingInfoAsync(t,e,i,r){return b(t,{renderer:e,arcade:i,...r})}getHit(t){if(this.owner.loadedGraphics){const e=this.owner.loadedGraphics.find((e=>e.uid===t));if(e){const t=this.layer instanceof g?this.layer:null,i=m(e,t);return{type:"graphic",graphic:i,layer:i.layer}}}return null}whenGraphicBounds(t,e){return this.graphicsCore?this.graphicsCore.whenGraphicBounds(t,e):Promise.reject()}computeAttachmentOrigin(t,e){return this.graphicsCore?this.graphicsCore.computeAttachmentOrigin(t,e):null}getSymbolLayerSize(t,e){return this.graphicsCore?this.graphicsCore.getSymbolLayerSize(t,e):null}maskOccludee(t){const{set:e,handle:i}=this.objectStates.acquireSet(x.MaskOccludee,null);return this.objectStates.setUid(e,t.uid),i}highlight(t){if(t instanceof C)return _;if("number"==typeof t)return this.highlight([t]);if(t instanceof e)return this.highlight([t]);if(t instanceof i&&(t=t.toArray()),Array.isArray(t)&&t.length>0){if(t[0]instanceof e){const e=t.map((t=>t.uid)),{set:i,handle:r}=this.objectStates.acquireSet(x.Highlight,null);return this.objectStates.setUids(i,e),r}if("number"==typeof t[0]){const e=t,{set:i,handle:r}=this.objectStates.acquireSet(x.Highlight,null);return this.objectStates.setObjectIds(i,e),r}}return _}_setupSuspendResumeExtent(){const{scaleVisibility:t,frustumVisibility:e}=this;if(a(t)&&a(e))return;const i=({computedExtent:i,extentPadding:r})=>{this._suspendResumeExtent=O(i,this._suspendResumeExtent,w,r),n(t)&&t.setExtent(this._suspendResumeExtent),n(e)&&e.setExtent(this._suspendResumeExtent)};this.handles.add(l((()=>({computedExtent:this.graphicsCore?.computedExtent,extentPadding:this.graphicsCore?.extentPadding})),(t=>i(t)),h))}_updateClippingExtent(){const t=this.view.clippingArea;this.graphicsCore.setClippingExtent(t,this.view.spatialReference)&&this.graphicsCore.recreateAllGraphics()}};t([u()],A.prototype,"type",void 0),t([u({constructOnly:!0})],A.prototype,"owner",void 0),t([u()],A.prototype,"layer",null),t([u()],A.prototype,"view",null),t([u({constructOnly:!0})],A.prototype,"graphicsCore",void 0),t([u()],A.prototype,"scaleVisibility",null),t([u({constructOnly:!0})],A.prototype,"frustumVisibility",void 0),t([u()],A.prototype,"elevationAlignment",null),t([u()],A.prototype,"objectStates",null),t([u()],A.prototype,"scaleVisibilitySuspended",null),t([u({readOnly:!0})],A.prototype,"frustumVisibilitySuspended",null),t([u()],A.prototype,"suspended",null),t([u({readOnly:!0})],A.prototype,"updating",null),t([u()],A.prototype,"loadedGraphics",null),t([u()],A.prototype,"fullOpacity",null),t([u()],A.prototype,"slicePlaneEnabled",null),t([u()],A.prototype,"drapeSourceType",void 0),t([u()],A.prototype,"updatePolicy",null),t([u({constructOnly:!0})],A.prototype,"scaleVisibilityEnabled",void 0),t([u({constructOnly:!0})],A.prototype,"frustumVisibilityEnabled",void 0),t([u()],A.prototype,"initializePromise",void 0),A=t([d("esri.views.3d.layers.graphics.GraphicsProcessor")],A);const _=s();export{A as GraphicsProcessor};