UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 2.84 kB
import{removeUnordered as e}from"../../../core/arrayUtils.js";import t from"../../../core/Handles.js";import{makeHandle as s}from"../../../core/handleUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,sync as n}from"../../../core/reactiveUtils.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{ObjectResourceCache as a}from"../layers/graphics/ObjectResourceCache.js";import{ClientType as o}from"./index.js";import{StreamTextureCollection as l}from"./StreamTextureCollection.js";import{getSettings as p,getLabelSettings as h}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{TextureWrapMode as S}from"../../webgl/enums.js";class u{constructor(e){this.textures=null,this.streamDataRequester=null,this._graphicsOwners=[],this._screenSizePerspectiveHandles=null,this.cimSymbolRasterizer=null,this._viewState=e.viewState,this._view=e.view,this._pointsOfInterest=e.pointsOfInterest,this.streamDataRequester=e.resourceController.createStreamDataRequester(o.SYMBOLOGY),this.objectResourceCache=new a(((t,s)=>e.resourceController.memoryController.newCache(t,s))),this.textures=new l(this.streamDataRequester,e.view._stage,{preMultiplyAlpha:!0,wrap:{s:S.CLAMP_TO_EDGE,t:S.CLAMP_TO_EDGE}},e.resourceController.scheduler);const t=c(this._view.spatialReference).radius;this.screenSizePerspectiveSettings=p(e.viewingMode,t),this.screenSizePerspectiveSettingsLabels=h(e.viewingMode,t)}destroy(){r(this.textures),this.textures=null,this.streamDataRequester=null}addGraphicsOwner(t){if(!t)return s();this._graphicsOwners.push(t);const r=i((()=>t.layer?.screenSizePerspectiveEnabled),(()=>this._updateScreenSizePerspectiveEnabled()));return this._updateScreenSizePerspectiveEnabled(),s((()=>{r.remove(),e(this._graphicsOwners,t),this._updateScreenSizePerspectiveEnabled()}))}_updateScreenSizePerspectiveEnabled(){const e=this._graphicsOwners.some((e=>!0===e.layer?.screenSizePerspectiveEnabled));if(e&&!this._screenSizePerspectiveHandles){this._screenSizePerspectiveHandles=new t;const e=()=>this._updateScreenSizePerspectiveSettings();this._screenSizePerspectiveHandles.add([i((()=>this._pointsOfInterest.centerOnSurfaceInfrequent.distance),e,n),this._viewState.events.on("camera-projection-changed",e)]),this._updateScreenSizePerspectiveSettings()}else e||(this._screenSizePerspectiveHandles=r(this._screenSizePerspectiveHandles))}_updateScreenSizePerspectiveSettings(){const e=this._pointsOfInterest;d.distance=e.centerOnSurfaceInfrequent.distance,d.fovY=this._viewState.camera.fovY,this.screenSizePerspectiveSettings.update(d),this.screenSizePerspectiveSettingsLabels.update(d),this._view._stage.renderView.requestRender()}get test(){return{screenSizePerspectiveHandles:this._screenSizePerspectiveHandles}}}const d={distance:0,fovY:0};export{u as SharedSymbolResources};