You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
7.5 KiB
17 lines
7.5 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../../../chunks/tslib.es6 ../../../core/asyncUtils ../../../core/handleUtils ../../../core/Logger ../../../core/maybe ../../../core/promiseUtils ../../../core/reactiveUtils ../../../core/accessorSupport/decorators/property ../../../core/has ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../../geometry/Extent ../../../geometry/support/aaBoundingRect ./interfaces ./LayerView3D ./support/overlayImageUtils ./support/projectExtentUtils ../support/debugFlags ../terrain/interfaces ../webgl-engine/lib/ModelDirtyTypes ../webgl-engine/lib/RenderGeometry ../webgl-engine/lib/Texture ../webgl-engine/lib/UpdatePolicy ../webgl-engine/materials/ImageMaterial ../../layers/LayerView ../../layers/RefreshableLayerView ../../support/layerViewUtils ../../webgl/enums".split(" "), |
|
function(l,x,B,r,y,h,C,p,m,S,D,z,k,E,F,u,G,H,t,v,I,J,K,L,M,N,O,A){m=class extends N(F.LayerView3D(M)){constructor(){super(...arguments);this.drapeSourceType=E.DrapeSourceType.RasterImage;this.updatePolicy=K.UpdatePolicy.SYNC;this.maximumDataResolution=this.fullExtentInLocalViewSpatialReference=null;this._images=[];this._extents=[];this._overlays=[];this.updateWhenStationary=!0;this._drapeSourceRenderer=null;this.refreshDebounced=h.debounce(async a=>{this.destroyed||await this._doRefresh(a).catch(c=> |
|
{h.isAbortError(c)||r.getLogger(this).error(c)})},2E3)}get visibleAtCurrentScale(){const a=this.layer;return O.isInEffectiveScaleRange("effectiveScaleRange"in a?a.effectiveScaleRange:null,this.view.terrainScale)}initialize(){this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerGeometryDrapeSource(this);this.addHandles(B.makeHandle(()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)));this.addResolvingPromise(G.toViewIfLocal(this).then(a=>this._set("fullExtentInLocalViewSpatialReference", |
|
a)));this._updatingHandles.add(()=>this.suspended,()=>this._suspendedChangeHandler())}destroy(){this.clear()}setDrapingExtent(a,c){this._spatialReference=c;a.forEach((d,e)=>{this._overlays[e]=d;this._updateImageExtent(d,e)})}_updateImageExtent(a,c){const d=this._clippedExtent(a.extent,P);if(null!=d){var e=u.computeImageExportSize(a.extent,d,a.resolution);a=a.pixelRatio*this.view.state.pixelRatio;var {layer:b}=this;if("imageMaxWidth"in b&&null!=b.imageMaxWidth||"imageMaxHeight"in b&&null!=b.imageMaxHeight){var f= |
|
b.imageMaxWidth;b=b.imageMaxHeight;if(e.width>f){const g=f/e.width;e.height=Math.floor(e.height*g);e.width=f;a*=g}e.height>b&&(f=b/e.height,e.width=Math.floor(e.width*f),e.height=b,a*=f)}f=this._extents[c];f&&k.equals(f.extent,d)&&this._imageSizeEquals(d,f.imageSize,e)||(this._extents[c]={extent:k.create(d),imageSize:e,pixelRatio:a},this.suspended||this._fetch(c).catch(g=>{h.isAbortError(g)||r.getLogger(this).error(g)}))}}clear(){for(let a=0;a<this._images.length;a++)this._clearImage(a)}async doRefresh(){return this._doRefresh()}async _doRefresh(a){if(!this.suspended){var c= |
|
[];for(let d=0;d<this._extents.length;d++)this._extents[d]&&c.push(this._fetch(d,a));await Promise.allSettled(c)}}async processResult(a,c,d){if(c instanceof HTMLImageElement||c instanceof HTMLCanvasElement)a.image=c}findExtentInfoAt(a){for(const c of this._extents){const d=c.extent;if((new z(d[0],d[1],d[2],d[3],this._spatialReference)).contains(a))return c}return null}getFetchOptions(){}async redraw(a,c){await x.forEach(this._images,async(d,e)=>{d&&(await a(d,c),await this._createStageObjects(e,d.image, |
|
c))})}_imageSizeEquals(a,c,d){if(!this.maximumDataResolution)return!1;const e=k.width(a)/this.maximumDataResolution.x;a=k.height(a)/this.maximumDataResolution.y;a=Math.abs(a/c.height-a/d.height);const b=H.debugFlags.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return Math.abs(e/c.width-e/d.width)<=b&&a<=b}async _fetch(a,c){if(!this.suspended){var d=this._extents[a],e=d.extent;this._images[a]||(this._images[a]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null, |
|
pixelData:null,renderExtent:k.create(e)});var b=this._images[a];b.loadingAbortController=y.abortMaybe(b.loadingAbortController);var f=new z(e[0],e[1],e[2],e[3],this._spatialReference);if(0===f.width||0===f.height)this._clearImage(a);else{var g=new AbortController;b.loadingAbortController=g;h.onAbort(c,()=>g.abort());var q=g.signal,w=this._waitFetchReady(q).then(async()=>{const n={requestAsImageElement:!0,pixelRatio:this._overlays[a].pixelRatio,...this.getFetchOptions(),signal:q},{height:Q,width:R}= |
|
d.imageSize;return this.layer.fetchImage(f,R,Q,n)}).then(n=>{if(h.isAborted(q))throw r.getLogger(this).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),h.createAbortError();return this.processResult(b,n)}).then(()=>{k.copy(b.renderExtent,e)});b.loadingPromise=w;await this._updatingHandles.addPromise(w.then(async()=>{h.throwIfAborted(q);await this._createStageObjects(a,b.image,q)}).catch(n=>{n&&!h.isAbortError(n)&& |
|
r.getLogger(this).error(n);throw n;}).finally(()=>{w===b.loadingPromise&&(b.loadingPromise=null,b.loadingAbortController=null)}))}}}_clearImage(a){if(a=this._images[a]){null!=a.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([a.renderGeometry],v.DirtyOperation.UPDATE),a.renderGeometry=null);const c=this.view._stage,d=a.texture;d?.unload();c.remove(d);a.texture=null;c.remove(a.material);a.material=null;a.loadingAbortController=y.abortMaybe(a.loadingAbortController);a.loadingPromise=null; |
|
a.image=null;a.pixelData=null}}async _createStageObjects(a,c,d){const e=this.view._stage,b=this._images[a];var f=()=>{b.texture?.unload();e.remove(b.texture);b.texture=null;b.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([b.renderGeometry],v.DirtyOperation.UPDATE),b.renderGeometry=null)};if(c){const g=new J.Texture(c,{width:c.width,height:c.height,preMultiplyAlpha:!0,wrap:{s:A.TextureWrapMode.CLAMP_TO_EDGE,t:A.TextureWrapMode.CLAMP_TO_EDGE}});await x.result(this._images[a===t.OverlayIndex.INNER? |
|
t.OverlayIndex.OUTER:t.OverlayIndex.INNER].loadingPromise);h.throwIfAborted(d);f();await e.schedule(()=>g.load(e.renderView.renderingContext),d);e.add(g);b.texture=g;null==b.material?(b.material=new L.ImageMaterial({transparent:!0,textureId:g.id}),e.add(b.material)):b.material.setParameters({textureId:g.id});if(a===t.OverlayIndex.INNER)f=u.createGeometryForExtent(b.material,b.renderExtent);else{c=this._images[0].renderExtent;if(!c){f();return}f=u.createOuterImageGeometry(b.material,c,b.renderExtent)}b.renderGeometry= |
|
new I.RenderGeometry(f);b.renderGeometry.localOrigin=this._overlays[a].renderLocalOrigin;this._drapeSourceRenderer.addGeometries([b.renderGeometry],v.DirtyOperation.UPDATE)}else f(),e.remove(b.material),b.material=null}_clippedExtent(a,c){if("local"!==this.view.viewingMode)return k.copy(c,a);const d=this.view.basemapTerrain;return d.ready?k.intersection(a,d.extent,c):k.copy(c,a)}_suspendedChangeHandler(){this.suspended?this.clear():this.refreshDebounced()}async _waitFetchReady(a){await C.whenOnce(()=> |
|
this.view.stationary,a);h.throwIfAborted(a)}};l.__decorate([p.property()],m.prototype,"layer",void 0);l.__decorate([p.property()],m.prototype,"suspended",void 0);l.__decorate([p.property({readOnly:!0})],m.prototype,"fullExtentInLocalViewSpatialReference",void 0);l.__decorate([p.property({readOnly:!0})],m.prototype,"visibleAtCurrentScale",null);l.__decorate([p.property()],m.prototype,"updating",void 0);l=m=l.__decorate([D.subclass("esri.views.3d.layers.DynamicLayerView3D")],m);const P=k.create();return l}); |