UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.42 kB
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Evented.js";import r from"../../../../core/Handles.js";import{destroyMaybe as s,isSome as a}from"../../../../core/maybe.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{ExtentSet as p}from"./ExtentSet.js";import{UpdatePolicy as d}from"../../webgl-engine/lib/UpdatePolicy.js";import{TaskPriority as c}from"../../../support/Scheduler.js";let l=class extends t{constructor(e){super(e),this._dirtyExtents=new p,this._globalDirty=!1,this._averageExtentUpdateSize=0,this._dirtyGraphicsSet=new Set,this._handles=new r,this._updateElevation=!1,this.graphicsCoreOwner=null,this.graphicsCore=null,this.events=new i}initialize(){const e=this.elevationProvider,t=this.graphicsCoreOwner.view.resourceController.scheduler;this._handles.add([e.on("elevation-change",(e=>this._elevationChanged(e))),n((()=>this.graphicsCoreOwner.suspended),(()=>this._suspendedChange())),t.registerTask(c.ELEVATION_ALIGNMENT,this)])}destroy(){this._dirtyGraphicsSet.clear(),this._handles=s(this._handles),this.graphicsCoreOwner=null,this.graphicsCore=null,this.queryGraphicUIDsInExtent=null,this.elevationProvider=null}clear(){this._dirtyGraphicsSet.clear(),this.notifyChange("updating")}_suspendedChange(){!0===this.graphicsCoreOwner.suspended?this._updateElevation=!1:!1===this.graphicsCoreOwner.suspended&&this._updateElevation&&(this._globalDirty=!0,this.notifyChange("updating"))}elevationInfoChange(){this._globalDirty=!0,this.notifyChange("updating")}get updating(){return this.running}get running(){return this._dirtyGraphicsSet.size>0||this._dirtyExtents&&!this._dirtyExtents.empty||this._globalDirty}get updatingRemaining(){return this._dirtyGraphicsSet.size+this._dirtyExtents.size*this._averageExtentUpdateSize}runTask(e){for(this._globalDirty&&(this._markAllGraphicsElevationDirty(),this._globalDirty=!1,e.madeProgress()),e.run((()=>this._dirtyExtents.merge(e)));this.running&&!e.done;)this._updateDirtyGraphics(e),this._updateDirtyExtents(e);this.notifyChange("updating")}_updateDirtyGraphics(e){const t=this.graphicsCoreOwner.view.renderCoordsHelper,i=this.graphicsCore.effectiveUpdatePolicy===d.ASYNC;for(const r of this._dirtyGraphicsSet.keys()){const s=this.graphicsCore.getGraphics3DGraphicById(r);if(this._dirtyGraphicsSet.delete(r),a(s)&&(s.alignWithElevation(this.elevationProvider,t,i),this.graphicsCoreOwner.view.deconflictor.setDirty(),e.madeProgress()),e.done)return}}_updateDirtyExtents(e){for(;!this._dirtyExtents.empty&&!e.done;){const t=this._dirtyExtents.pop(),i=this.elevationProvider.spatialReference;this.events.emit("invalidate-elevation",{extent:t,spatialReference:i});const r=this._dirtyGraphicsSet.size;this.queryGraphicUIDsInExtent(t,i,(e=>{const t=this.graphicsCore.getGraphics3DGraphicById(e);a(t)&&t.needsElevationUpdates()&&this._dirtyGraphicsSet.add(e)})),this._averageExtentUpdateSize=.1*(this._dirtyGraphicsSet.size-r)+.9*this._averageExtentUpdateSize,e.madeProgress()}}_markAllGraphicsElevationDirty(){this._dirtyExtents.clear(),this._dirtyGraphicsSet.clear(),this.graphicsCore.graphics3DGraphics.forEach(((e,t)=>this._dirtyGraphicsSet.add(t)))}_elevationChanged(e){if("scene"===e.context&&(!this.graphicsCore.layer.elevationInfo||"relative-to-scene"!==this.graphicsCore.layer.elevationInfo.mode))return;const{extent:t,spatialReference:i}=e;if(this.graphicsCoreOwner.suspended){if(!this._updateElevation){const e=this.graphicsCore.computedExtent;e&&t[2]>e.xmin&&t[0]<e.xmax&&t[3]>e.ymin&&t[1]<e.ymax&&(this._updateElevation=!0)}this.events.emit("invalidate-elevation",{extent:t,spatialReference:i})}else t[0]===-1/0?this._globalDirty=!0:this._dirtyExtents.add(t),this.notifyChange("updating")}};e([o()],l.prototype,"graphicsCoreOwner",void 0),e([o()],l.prototype,"graphicsCore",void 0),e([o()],l.prototype,"queryGraphicUIDsInExtent",void 0),e([o()],l.prototype,"elevationProvider",void 0),e([o({readOnly:!0})],l.prototype,"updating",null),e([o({readOnly:!0})],l.prototype,"updatingRemaining",null),l=e([h("esri.views.3d.layers.graphics.Graphics3DElevationAlignment")],l);const g=l;export{g as default};