@arcgis/core 4.33.0-next.20250409 → 4.33.0-next.20250411
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0c8f9ad2461323441372.js +1 -0
- package/assets/esri/core/workers/chunks/{f92d521ed3df3c9f737b.js → 26fcbe053194bd78fcc3.js} +1 -1
- package/assets/esri/core/workers/chunks/{1364744b15b327abd5a1.js → 37716880cef8155259f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{ccb289911e7445b17763.js → 3a84ee5d0434362286a6.js} +10 -10
- package/assets/esri/core/workers/chunks/4deeeceb784e4390441d.js +1 -0
- package/assets/esri/core/workers/chunks/5a991c8e0febb0cf9be1.js +1 -0
- package/assets/esri/core/workers/chunks/{4de3d692557120a4bbf7.js → 95379fdd6917c8a84c71.js} +1 -1
- package/assets/esri/core/workers/chunks/{b06e3ba73f353592c81d.js → b6361cec92003997bfe5.js} +1 -1
- package/assets/esri/core/workers/chunks/{b308bef7ff08e0e635b5.js → d8e6f8e22cda67ac70f9.js} +23 -23
- package/assets/esri/core/workers/chunks/{35ab75010817f1525e54.js → e6a97f9b6f7be8076f85.js} +1 -1
- package/assets/esri/core/workers/chunks/{3b2bda2e8c08f486de27.js → ed07bb41e1fd8043c88c.js} +1 -1
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BuildingDisciplinesTree.scss +0 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/BloomBlur.glsl.js +4 -6
- package/chunks/BloomComposition.glsl.js +12 -12
- package/chunks/Theme.js +1 -1
- package/chunks/bundle.js +5 -0
- package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
- package/interfaces.d.ts +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
- package/layers/support/rasterFunctions/RemapFunction.js +1 -1
- package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
- package/libs/parquet/loadParquetModule.js +5 -0
- package/libs/parquet/parquet.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/magnifier/MagnifierTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
- package/views/3d/layers/ElevationLayerView3D.js +1 -1
- package/views/3d/layers/ElevationLayerView3DModifications.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TextureFader.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/TileTexture.js +1 -1
- package/views/3d/webgl/formats.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomPresets.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RendererBase.js +5 -0
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/FocusAreas.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/textureUtils.js +1 -1
- package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesNode.js +1 -1
- package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Feature/FeatureMedia/xyChart.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Popup.js +1 -1
- package/assets/esri/core/workers/chunks/386ea90e87254b0282ec.js +0 -1
- package/assets/esri/core/workers/chunks/39bcfc9cd3a12a35316c.js +0 -1
- package/assets/esri/core/workers/chunks/ec83af4fb3bf59df7759.js +0 -1
- package/assets/esri/libs/parquet/pkg/arcgis_parquet_bg.wasm +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{identity as e,scale as t}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as a,create as i,ONES as
|
|
5
|
+
import{identity as e,scale as t}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as a,create as i,ONES as n}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as s}from"../../../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as l,size as d}from"../../../../../../geometry/support/aaBoundingBox.js";import{objectSymbolLayerPrimitiveBoundingBox as c,objectSymbolLayerSizeWithResourceSize as m}from"../../../../../../symbols/support/symbolLayerUtils3D.js";import{computeObjectScale as p}from"../../graphicUtils.js";import{readMapCoordinates as f,readObjectIds as u}from"../featureData/processingUtils.js";import{createPrimitiveGeometry as h}from"./primitiveObjectUtils.js";import{schematicMRRFactors as y}from"../../../../webgl-engine/materials/pbrUtils.js";class _{constructor(e){this._context=e,this.lodRendererId=null,this._loaded=!1,this._loadingPromise=null,this._primitive="cone",this._primitiveMaterialId=null}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}async _load(){const e=this._context.renderCommandContext,t={physicalBasedRenderingEnabled:!0,slicePlaneEnabled:!1,castShadows:!0,isPrimitive:!0,screenSizePerspectiveEnabled:!0},r={usePBR:t.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:y,ambient:n,diffuse:n,hasSlicePlane:t.slicePlaneEnabled,castShadows:t.castShadows,offsetTransparentBackfaces:!1,screenSizePerspective:{}};r.externalColor=o,r.isInstanced=!0;const a=await e.createMaterial({type:"default",parameters:r}),i=h(this._primitive,a);this.lodRendererId=await e.createLodRenderer(i),this._primitiveMaterialId=a,this._loaded=!0}async createAddCommand(e){const t=this._context,{renderCommandContext:r,mainThreadDelegate:i}=t;if(null==this.lodRendererId)throw new Error("expected lod renderer id to not be null");const{featureCount:n}=e;if(0===n)return r.createRenderCommandBuffer();const o=!0,s=l(c(this._primitive)),p=a(d(s)),h=a(m(p,{isPrimitive:o,width:100,depth:null,height:null})),y=new Float64Array(16*n),_=new Float64Array(16*n),x=f(e),C=await i.applyElevationAlignmentTo(x);for(let a=0;a<n;++a){const e=a,t=C[3*a+0],r=C[3*a+1],i=C[3*a+2],n=this._computeGlobalTransform(t,r,i,this._context.viewSpatialReference,g),o=this._computeLocalTransform(h,p,b);this._writeMatrixToTypedBuffer(y,e,o),this._writeMatrixToTypedBuffer(_,e,n)}const w=u(e),T=new Uint8Array(n);e.getVisibilityArray(T);const v={featureIds:new Uint32Array(w),visibility:T,localTransforms:y,globalTransforms:_};return r.addLodInstances(this.lodRendererId,e.id,v)}async createRemoveCommand(e){const{_context:t,lodRendererId:r}=this,a=t.renderCommandContext;return null==r?a.createRenderCommandBuffer():a.removeLodInstances(r,e)}async createUpdateVisibilityCommand(e){const{lodRendererId:t,_context:r}=this,a=r.renderCommandContext;if(null==t)return a.createRenderCommandBuffer();const i=new Uint8Array(e.featureCount);return e.getVisibilityArray(i),a.updateVisibility(t,e.id,i)}async createUpdateLayerOpacityCommand(e){const{_context:t}=this,r=t.renderCommandContext,a=this._primitiveMaterialId;return null==a?r.createRenderCommandBuffer():r.updateMaterial({type:"default",materialId:a,parameters:{opacity:e}})}async createUpdateElevationCommand(e){const{_context:t,lodRendererId:r}=this,{renderCommandContext:a,mainThreadDelegate:i}=t,{featureCount:n,id:o}=e;if(null==r||0===n)return a.createRenderCommandBuffer();const s=new Float64Array(16*n),l=f(e),d=await i.applyElevationAlignmentTo(l);for(let c=0;c<n;++c){const e=c,t=d[3*c+0],r=d[3*c+1],a=d[3*c+2],i=this._computeGlobalTransform(t,r,a,this._context.viewSpatialReference,g);this._writeMatrixToTypedBuffer(s,e,i)}return a.updateLodInstancesData(r,o,s)}_writeMatrixToTypedBuffer(e,t,r){let a=16*t;for(let i=0;i<16;i++)e[a++]=r[i]}_computeGlobalTransform(e,t,r,a,i){return x[0]=e,x[1]=t,x[2]=r,s(a,x,i,this._context.renderSpatialReference),i}_computeLocalTransform(t,r,a){return e(a),this._applyObjectScale(t,r,a),a}_applyObjectScale(e,r,a){const i=p(e,e,r,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||t(a,a,i)}}const x=i(),b=r(),g=r();export{_ as TestObjectSymbol};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{removeMaybe as e}from"../../../../../../core/maybe.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{namedAnchorToHUDMaterialAnchorPos as r}from"../../placementUtils.js";import{computeTileCenterRenderCoordinates as n,readObjectIds as i,readMapCoordinates as a,projectToRenderCoordinates as o}from"../featureData/processingUtils.js";import{inputAttributesToAttributesMap as l}from"./symbolizationUtils.js";import{createTextureInfo as s,defaultBoundingBox as d,requiresHalfTexelOffset as c}from"../../../../support/engineContent/sdfPrimitives.js";import{Attribute as m}from"../../../../webgl-engine/lib/Attribute.js";import{VertexAttribute as u}from"../../../../webgl-engine/lib/VertexAttribute.js";class f{constructor(e){this._context=e,this.materialId=null,this._loaded=!1,this._loadingPromise=null,this._iconTexture=null}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}destroy(){this._iconTexture=e(this._iconTexture)}async _load(){const e=this._context.renderCommandContext,t=await e.getOrCreateSharedTexture("circle-icon",(()=>s("circle")));this._iconTexture={remove:()=>e.releaseSharedTexture("circle-icon")};const n={anchorPosition:r.center,occlusionTest:!0,hasSlicePlane:!1,color:[1,0,0,1],outlineColor:[0,0,0,1],outlineSize:1,distanceFieldBoundingBox:d,textureId:t,textureIsSignedDistanceField:!0,sampleSignedDistanceFieldTexelCenter:c("circle")};this.materialId=await e.createMaterial({type:"hud",parameters:n}),await e.createDirectRenderer(this.materialId),this._loaded=!0}async createAddCommand(e){const{materialId:t,_context:r}=this,{renderCommandContext:i}=r;if(null==t)throw new Error("expected material not to be null");const a=await this._createGeometry(e);if(null==a)return i.createRenderCommandBuffer();const o=n(e,r);return i.addDirectRendererGeometry(e.id,a,o)}async _createGeometry(e){const{materialId:r,_context:n}=this,{mainThreadDelegate:s}=n,{featureCount:d}=e;if(0===d||null==r)return null;const c=i(e),f=a(e),y=await s.applyElevationAlignmentTo(f),
|
|
5
|
+
import{removeMaybe as e}from"../../../../../../core/maybe.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{namedAnchorToHUDMaterialAnchorPos as r}from"../../placementUtils.js";import{computeTileCenterRenderCoordinates as n,readObjectIds as i,readMapCoordinates as a,projectToRenderCoordinates as o}from"../featureData/processingUtils.js";import{inputAttributesToAttributesMap as l}from"./symbolizationUtils.js";import{createTextureInfo as s,defaultBoundingBox as d,requiresHalfTexelOffset as c}from"../../../../support/engineContent/sdfPrimitives.js";import{Attribute as m}from"../../../../webgl-engine/lib/Attribute.js";import{VertexAttribute as u}from"../../../../webgl-engine/lib/VertexAttribute.js";class f{constructor(e){this._context=e,this.materialId=null,this._loaded=!1,this._loadingPromise=null,this._iconTexture=null}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}destroy(){this._iconTexture=e(this._iconTexture)}async _load(){const e=this._context.renderCommandContext,t=await e.getOrCreateSharedTexture("circle-icon",(()=>s("circle")));this._iconTexture={remove:()=>e.releaseSharedTexture("circle-icon")};const n={anchorPosition:r.center,occlusionTest:!0,hasSlicePlane:!1,color:[1,0,0,1],outlineColor:[0,0,0,1],outlineSize:1,distanceFieldBoundingBox:d,textureId:t,textureIsSignedDistanceField:!0,sampleSignedDistanceFieldTexelCenter:c("circle")};this.materialId=await e.createMaterial({type:"hud",parameters:n}),await e.createDirectRenderer(this.materialId),this._loaded=!0}async createAddCommand(e){const{materialId:t,_context:r}=this,{renderCommandContext:i}=r;if(null==t)throw new Error("expected material not to be null");const a=await this._createGeometry(e);if(null==a)return i.createRenderCommandBuffer();const o=n(e,r);return i.addDirectRendererGeometry(e.id,a,o)}async _createGeometry(e){const{materialId:r,_context:n}=this,{mainThreadDelegate:s}=n,{featureCount:d}=e;if(0===d||null==r)return null;const c=i(e),f=a(e),y=await s.applyElevationAlignmentTo(f),C=o(y,n),h=new Float64Array([0,0,1]),x=new Float64Array([255,255,255,255]),w=new Float64Array([24,24]),p=new Float64Array([0,0,0,1]),_=new Float64Array([0,0]),A=new Float64Array([0]),g=new Uint32Array(d);for(let t=0;t<d;++t)g[t]=t;const b=new Uint32Array(d);for(let t=0;t<d;++t)b[t]=0;const I=new m(C,g,3,!0),T=new m(h,b,3,!0),R=new m(_,b,2,!0),F=new m(x,b,4,!0),U=new m(A,b,1,!0),j=new m(w,b,2,!0),D=new m(p,b,4,!0),O=[[u.POSITION,I],[u.NORMAL,T],[u.UV0,R],[u.COLOR,F],[u.ROTATION,U],[u.SIZE,j],[u.CENTEROFFSETANDDISTANCE,D]],S=new Uint8Array(d);e.getVisibilityArray(S);return{attributes:l(O),objectAndLayerIdColor:void 0,transformation:t(),materialId:r,objectIds:c,visibilities:S}}async createRemoveCommand(e){const{materialId:t,_context:r}=this,n=r.renderCommandContext;return null==t?n.createRenderCommandBuffer():n.removeDirectRendererGeometryBuffer(t,e)}async createUpdateVisibilityCommand(e){const{materialId:t,_context:r}=this,n=r.renderCommandContext;if(null==t)return n.createRenderCommandBuffer();const i=new Uint8Array(e.featureCount);return e.getVisibilityArray(i),n.updateVisibility(t,e.id,i)}async createUpdateLayerOpacityCommand(e){const{_context:t}=this;return t.renderCommandContext.createRenderCommandBuffer()}async createUpdateElevationCommand(e){const{materialId:t,_context:r}=this,{renderCommandContext:i}=r,{featureCount:a,id:o}=e;if(null==t||0===a)return i.createRenderCommandBuffer();const l=await this._createGeometry(e);if(null==l)return i.createRenderCommandBuffer();const s=n(e,r);return i.updateDirectRendererGeometry(o,l,s)}}export{f as TestSymbol};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{PipelineCommand as e}from"../PipelineCommand.js";import{readObjectIds as t}from"../featureData/processingUtils.js";import{TestObjectSymbol as n}from"./TestObjectSymbol.js";import{TestSymbol as a}from"./TestSymbol.js";class r{constructor(e){this._symbols=new Array,this._featureDataPartitioning=new Map,this._context=e}async load(){this._symbols[0]=new a(this._context),this._symbols[1]=new n(this._context)}async createAddCommand(t){const n=this._partition(t),a=await Promise.all(n.map((async({index:e,features:t})=>{const n=await this._provisionSymbol(e);return await(n?.createAddCommand(t))}))),r=this._context.renderCommandContext;return new e(r,r.mergeRenderCommandBuffers(a),[()=>{this._featureDataPartitioning.set(t.id,n)}])}async createRemoveCommand(t){const{_featureDataPartitioning:n,_context:a}=this,r=a.renderCommandContext,o=n.get(t);if(null==o)return new e(r,r.createRenderCommandBuffer(),[]);const s=await Promise.all(o.map((async({index:e,features:t})=>{const n=this._getLoadedSymbol(e);return await(n?.createRemoveCommand(t.id))})));return new e(r,r.mergeRenderCommandBuffers(s),[()=>{n.delete(t)}])}async createUpdateVisibilityCommand(t){const{_featureDataPartitioning:n,_context:a}=this,r=a.renderCommandContext,o=n.get(t.id);if(null==o)return new e(r,r.createRenderCommandBuffer(),[]);const s=await Promise.all(o.map((async({index:e,features:t})=>{const n=this._getLoadedSymbol(e);return await(n?.createUpdateVisibilityCommand(t))})));return new e(r,r.mergeRenderCommandBuffers(s),[])}async createUpdateElevationCommand(){const{_featureDataPartitioning:t,_context:n}=this,a=n.renderCommandContext,r=[];for(const e of t.values()){const t=e.map((async({index:e,features:t})=>{const n=this._getLoadedSymbol(e);return await(n?.createUpdateElevationCommand(t))}));r.push(...t)}const o=await Promise.all(r);return new e(a,a.mergeRenderCommandBuffers(o),[])}async _provisionSymbol(e){if(null==e)return null;const t=this._symbols[e];return t?(t.loaded||await t.load(),t):null}_getLoadedSymbol(e){if(null==e)return null;const t=this._symbols[e];return null!=t&&t.loaded?t:null}_partition(e){const n=t(e);if(null==n)throw new Error("unable to fetch objectIds");const{featureCount:a}=e,r=[[],[]];for(let t=0;t<a;++t){r[n[t]%2].push(t)}return r.map(((t,n)=>new o(n,e.subset(new Uint32Array(t))))).filter((e=>e.features.featureCount>0))}}class o{constructor(e,t){this.index=e,this.features=t}}export{r as UniqueValueFeatureRenderer};
|
|
5
|
+
import{PipelineCommand as e}from"../PipelineCommand.js";import{readObjectIds as t}from"../featureData/processingUtils.js";import{TestObjectSymbol as n}from"./TestObjectSymbol.js";import{TestSymbol as a}from"./TestSymbol.js";class r{constructor(e){this._symbols=new Array,this._featureDataPartitioning=new Map,this._context=e}async load(){this._symbols[0]=new a(this._context),this._symbols[1]=new n(this._context)}async createAddCommand(t){const n=this._partition(t),a=await Promise.all(n.map((async({index:e,features:t})=>{const n=await this._provisionSymbol(e);return await(n?.createAddCommand(t))}))),r=this._context.renderCommandContext;return new e(r,r.mergeRenderCommandBuffers(a),[()=>{this._featureDataPartitioning.set(t.id,n)}])}async createRemoveCommand(t){const{_featureDataPartitioning:n,_context:a}=this,r=a.renderCommandContext,o=n.get(t);if(null==o)return new e(r,r.createRenderCommandBuffer(),[]);const s=await Promise.all(o.map((async({index:e,features:t})=>{const n=this._getLoadedSymbol(e);return await(n?.createRemoveCommand(t.id))})));return new e(r,r.mergeRenderCommandBuffers(s),[()=>{n.delete(t)}])}async createUpdateVisibilityCommand(t){const{_featureDataPartitioning:n,_context:a}=this,r=a.renderCommandContext,o=n.get(t.id);if(null==o)return new e(r,r.createRenderCommandBuffer(),[]);const s=await Promise.all(o.map((async({index:e,features:t})=>{const n=this._getLoadedSymbol(e);return await(n?.createUpdateVisibilityCommand(t))})));return new e(r,r.mergeRenderCommandBuffers(s),[])}async createUpdateLayerOpacityCommand(t){const n=this._context.renderCommandContext,a=[];for(let e=0;e<this._symbols.length;++e){const n=this._symbols[e];null!=n&&n.loaded&&a.push(n.createUpdateLayerOpacityCommand(t))}const r=await Promise.all(a);return new e(n,n.mergeRenderCommandBuffers(r),[])}async createUpdateElevationCommand(){const{_featureDataPartitioning:t,_context:n}=this,a=n.renderCommandContext,r=[];for(const e of t.values()){const t=e.map((async({index:e,features:t})=>{const n=this._getLoadedSymbol(e);return await(n?.createUpdateElevationCommand(t))}));r.push(...t)}const o=await Promise.all(r);return new e(a,a.mergeRenderCommandBuffers(o),[])}async _provisionSymbol(e){if(null==e)return null;const t=this._symbols[e];return t?(t.loaded||await t.load(),t):null}_getLoadedSymbol(e){if(null==e)return null;const t=this._symbols[e];return null!=t&&t.loaded?t:null}_partition(e){const n=t(e);if(null==n)throw new Error("unable to fetch objectIds");const{featureCount:a}=e,r=[[],[]];for(let t=0;t<a;++t){r[n[t]%2].push(t)}return r.map(((t,n)=>new o(n,e.subset(new Uint32Array(t))))).filter((e=>e.features.featureCount>0))}}class o{constructor(e,t){this.index=e,this.features=t}}export{r as UniqueValueFeatureRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{estimateAttributesMemory as a,estimateFixedArrayMemory as s,estimateNumberMemory as o}from"../../../../core/memoryEstimations.js";import n from"../../../../core/Promise.js";import{initial as l,sync as p,watch as d}from"../../../../core/reactiveUtils.js";import{pt2px as u}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{projectPointToVector as _}from"../../../../geometry/projection/projectPointToVector.js";import{getContinuousIndexArray as g}from"../../../../geometry/support/Indices.js";import{getResolutionForScale as f}from"../../../../geometry/support/scaleUtils.js";import{getObjectId as R}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromPoint as F}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as b}from"../../../../layers/graphics/OptimizedFeature.js";import v from"../../../../layers/graphics/OptimizedGeometry.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{isNumericField as S}from"../../../../layers/support/fieldUtils.js";import{generateGradient as P}from"../../../../renderers/support/heatmapUtils.js";import{DrapeSourceType as j}from"../interfaces.js";import{DisplayFeatureLimit as T}from"../graphics/DisplayFeatureLimit.js";import{GraphicsCorePerformanceInfo as V}from"../graphics/GraphicsCorePerformanceInfo.js";import{FeatureVisibilityFilter as G}from"./FeatureVisibilityFilter.js";import{emptyHighlightHandle as x}from"./highlightUtils.js";import{drapedZ as I}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as A}from"../../webgl-engine/lib/ContentObjectType.js";import{DrapedHeatmapRenderer as N}from"../../webgl-engine/lib/DrapedHeatmapRenderer.js";import{Geometry as O}from"../../webgl-engine/lib/Geometry.js";import{DirtyOperation as U,DirtyState as H}from"../../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{UpdatePolicy as E}from"../../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as D}from"../../webgl-engine/lib/VertexAttribute.js";import{HeatmapDensityMaterial as C}from"../../webgl-engine/materials/HeatmapDensityMaterial.js";import{scaleBoundsPredicate as B,isScaleRangeActive as W}from"../../../support/layerViewUtils.js";import{PixelType as Z,PixelFormat as $}from"../../../webgl/enums.js";import{loadHeatmapTextureConfiguration as q,fallBackHeatmapConfiguration as z}from"../../../webgl/heatmapTextureUtils.js";const Y=112;let k=class extends n{constructor(e){super(e),this.type="heatmap",this.preferredUpdatePolicy=E.ASYNC,this.dataExtent=null,this.drapeSourceType=j.Features,this._renderGeometries=new Map,this._fieldTotal=0,this._drapeSourceRenderer=null,this._dataType=Z.HALF_FLOAT,this._pixelFormat=$.RGBA,this._updatingHandles=new y}initialize(){let e;try{e=q(this._renderView.renderingContext,i.getLogger(this))}catch(u){this.addResolvingPromise(Promise.reject(u)),e=z}const{dataType:t,samplingMode:a,pixelFormat:s,internalFormat:o}=e;this._featureStore=new w({geometryType:"esriGeometryPoint",hasZ:this.hasZ,hasM:this.hasM}),this._dataType=t,this._pixelFormat=s;const n=t!==Z.FLOAT;this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerDrapeSource(this,N,{...this._rendererParameters,dataType:t,samplingMode:a,pixelFormat:s,internalFormat:o}),this._material=new C({usesHalfFloats:n}),this._materialWithField=new C({usesHalfFloats:n,isAttributeDriven:!0}),this._filterVisibility=new G({context:{configuration:this.owner,featureStore:this.featureStore,getFeatureCount:()=>this._loadedPointGraphics.length,setAllFeaturesVisibility:e=>this._setAllFeaturesVisibility(e),clearFeaturesVisibility:()=>this._setAllFeaturesVisibility(!0),updateFeatureVisibilities:e=>this._updateFeatureVisibilities(e)}}),this._updatingHandles.addOnCollectionChange((()=>this._loadedPointGraphics),(e=>this._onLoadedFeaturesChange(e)),l),this._updatingHandles.addWhen((()=>this._materialParameters),(e=>this._forEachMaterial((t=>t.setParameters(e)))),l),this._updatingHandles.add((()=>this._rendererParameters),(e=>this._drapeSourceRenderer.set(e))),this._updatingHandles.add((()=>this._heatmapRendererField),(()=>{this._recreate()}),p),this._updatingHandles.add((()=>({fieldName:this._heatmapRendererFieldName,numeric:this._heatmapRendererFieldIsNumeric})),(({fieldName:e,numeric:t})=>{if(null!=e&&t){let t=0;this._featureStore.forEach((r=>t+=r.attributes[e]??0)),this._fieldTotal=t}else this._fieldTotal=this._featureStore.numFeatures}),l),this.addHandles([d((()=>({fieldName:this._heatmapRendererFieldName,field:this._heatmapRendererField})),(({fieldName:e,field:t})=>{e&&!t&&i.getLogger(this).warn(`Heatmap renderer field '${e}' for layer '${this.layer.title??this.layer.id}' not found`)})),d((()=>({field:this._heatmapRendererField,numeric:this._heatmapRendererFieldIsNumeric})),(({field:e,numeric:t})=>{null==e||t||i.getLogger(this).warn(`Heatmap renderer field '${e.name}' for layer '${this.layer.title??this.layer.id}' does not contain numeric values and cannot be used to drive the heatmap density`)})),r((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))])}destroy(){this._renderGeometries.clear(),this._material=null,this._materialWithField=null,this._featureStore.clear(),this._featureStore=null,this._updatingHandles.destroy()}get layer(){return this.owner.layer}get featureStore(){return this._featureStore}get updating(){return this._updatingHandles.updating||this.filterVisibility.updating}get updatingRemaining(){return 0}get suspendInfo(){return{}}get legendEnabled(){return!0}get filterVisibility(){return this._filterVisibility}get displayFeatureLimit(){const e=this.owner?.view?.quality??1,t=this.owner?.view?.qualitySettings,r=t?Math.ceil(t.heatmap.maxTotalNumberOfFeatures*e):0;return new T(r*6,r)}get hasZ(){return"hasZ"in this.layer&&this.layer.hasZ}get hasM(){return"hasM"in this.layer&&this.layer.hasM}get view(){return this.owner.view}get fullOpacity(){return this.owner.fullOpacity}get updatePolicy(){return this.owner.updatePolicy}get scaleVisibilitySuspended(){if(!this._isScaleRangeActive)return!1;const{minScale:e,maxScale:t}=this.layer.effectiveScaleRange,{scale:r}=this.view;return!B(r,e??0,t??0)}get usedMemory(){const e=this.usedMemoryPerFeature*this._featureStore.numFeatures,t=this._pixelFormat===$.RED?1:4,r=this._dataType===Z.FLOAT?4:2,i=Math.ceil((this._overlayRenderer?.overlays[0]?.resolution??0)*this._densityMapPixelRatio)??0;return i*i*t*r+e}get usedMemoryPerFeature(){const e=this._loadedPointGraphics.find((()=>!0));if(null==e)return 0;const t=a(e),r=6;return r*s([0,0,0],o)+r*s([0,0],o)+(this._heatmapRendererFieldIsNumeric?r*o:0)+t}get loadedFeatures(){return this._featureStore.numFeatures}get unprocessedMemoryEstimate(){return 0}get performanceInfo(){return new V(this._renderGeometries.size,this._visibleFeatures,0,0)}get renderer(){return this._heatmapRenderer}get _overlayRenderer(){return this.view.basemapTerrain.overlayManager.renderer}get _overlaySpatialReference(){return this._overlayRenderer.spatialReference}get _rendererParameters(){return{...this._radiusParameter,...this._densityParameters,...this._colorRampParameter,...this._pixelRatioParameter}}get _materialParameters(){return{...this._radiusParameter,...this._resolutionForScaleParameter}}get _densityParameters(){const e=this._heatmapRenderer;if(null==e)return null;const{minDensity:t,maxDensity:r}=e;return{minDensity:t,maxDensity:r,fieldTotal:this._fieldTotal}}get _radiusParameter(){const e=this._heatmapRenderer;return e?{searchRadius:u(this._clampSearchRadius(e.radius))}:null}get _resolutionForScaleParameter(){const e=this._heatmapRenderer;if(!e)return null;const{referenceScale:t}=e;return{resolutionForScale:0===t?0:f(t,this.view.spatialReference)}}get _colorRampParameter(){const e=this._heatmapRenderer;return e?{colorRampData:P(e.colorStops)}:null}get _pixelRatioParameter(){return{pixelRatio:this._densityMapPixelRatio}}get _densityMapPixelRatio(){return this.owner?.view?.qualitySettings.heatmap.pixelRatio??1}get _renderView(){return this.view.stage.renderView}get _featuresArePoints(){return"point"===this.layer.geometryType}get _loadedPointGraphics(){return this.owner.loadedGraphics}get _heatmapRenderer(){const e=this.layer.renderer;return"heatmap"===e?.type?e:null}get _heatmapRendererFieldName(){return this._heatmapRenderer?.field}get _heatmapRendererField(){const e=this._heatmapRendererFieldName;return null!=e?this.layer.fieldsIndex.get(e):null}get _heatmapRendererFieldIsNumeric(){const e=this._heatmapRendererField;return null!=e&&S(e)}get _isScaleRangeActive(){const{layer:e}=this;if(!("effectiveScaleRange"in e))return!1;const{minScale:t,maxScale:r}=e.effectiveScaleRange;return W(t,r)}get _visibleFeatures(){return Array.from(this._renderGeometries.values()).reduce(((e,{visible:t})=>e+(t?1:0)),0)}async whenGraphicBounds(){return null}computeAttachmentOrigin(){return null}highlight(){return x}maskOccludee(){return r()}setObjectIdVisibility(){}refreshFilter(){this.filterVisibility.reapply()}_onLoadedFeaturesChange(e){if(!this._featuresArePoints)return;const{objectIdField:r}=this.layer;this._featureStore.removeManyById(e.removed.map((e=>R(e,r)))),this._featureStore.addMany(e.added.map((e=>{const{attributes:t,centroid:i,geometry:a}=e,s=new b(F(new v,a),t,i?F(new v,i):null,R(e,r));return s.displayId=e.uid,s})));const i=e.added,a=e.removed;this._fieldTotal+=this._computeFieldTotalChange(i,a);const s=a.map((({uid:e})=>{const t=this._renderGeometries.get(e);return this._renderGeometries.delete(e),t})).filter(t),o=i.map((e=>{const t=this._pointGraphicToRenderGeometry(e);return this._renderGeometries.set(e.uid,t),t}));s.length>0&&this._drapeSourceRenderer.removeGeometries(s,U.REMOVE),o.length>0&&this._drapeSourceRenderer.addGeometries(o,U.ADD),(o.length>0||s.length>0)&&(this.filterVisibility.reapply(),this._renderView.requestRender())}_recreate(){if(!this._loadedPointGraphics)return;const e=this._loadedPointGraphics.toArray();this._onLoadedFeaturesChange({added:e,removed:e})}_pointGraphicToRenderGeometry(e){const t=this._heatmapRendererFieldName,r=null!=t?this._materialWithField:this._material,i=c();_(e.geometry,i,this._overlaySpatialReference),i[2]=I;const a=g(1),s=[[D.POSITION,new M(i,a,i.length)]],o=this._heatmapRendererFieldIsNumeric;null!=t&&s.push([D.FEATUREATTRIBUTE,new M([o?e.attributes[t]??0:0],a,1)]);const n=new L(new O(r,s,null,A.Point),{layerViewUid:this.owner.layerViewUid,graphicUid:e.uid});return n.visible=this.filterVisibility.defaultVisibility,n}_forEachMaterial(e){e(this._material),e(this._materialWithField)}_computeFieldTotalChange(e,t){if(null==this._heatmapRendererFieldName||!this._heatmapRendererFieldIsNumeric)return e.length-t.length;const r=this._heatmapRendererFieldName,i=(e,t)=>e+(t.attributes[r]??0);return e.reduce(i,0)-t.reduce(i,0)}_clampSearchRadius(e){return e>Y&&i.getLogger(this).warnOnce(`SceneView supports a maximum radius of ${Y} pt for HeatmapRenderer.`),Math.min(e,Y)}_updateFeatureVisibilities(e){const t=[];this._featureStore.forEach((({objectId:r,displayId:i})=>{const a=e(r),s=this._renderGeometries.get(i);s&&s.visible!==a&&(t.push(s),s.visible=a)})),this._drapeSourceRenderer.modifyGeometries(t,H.VISIBILITY)}_setAllFeaturesVisibility(e){const t=[];for(const r of this._renderGeometries.values())r.visible!==e&&(t.push(r),r.visible=e);this._drapeSourceRenderer.modifyGeometries(t,H.VISIBILITY)}get test(){}};e([m()],k.prototype,"type",void 0),e([m({constructOnly:!0})],k.prototype,"owner",void 0),e([m()],k.prototype,"layer",null),e([m()],k.prototype,"featureStore",null),e([m()],k.prototype,"updating",null),e([m()],k.prototype,"updatingRemaining",null),e([m()],k.prototype,"suspendInfo",null),e([m()],k.prototype,"legendEnabled",null),e([m()],k.prototype,"filterVisibility",null),e([m()],k.prototype,"displayFeatureLimit",null),e([m()],k.prototype,"preferredUpdatePolicy",void 0),e([m()],k.prototype,"hasZ",null),e([m()],k.prototype,"hasM",null),e([m()],k.prototype,"dataExtent",void 0),e([m()],k.prototype,"view",null),e([m()],k.prototype,"fullOpacity",null),e([m()],k.prototype,"updatePolicy",null),e([m()],k.prototype,"drapeSourceType",void 0),e([m()],k.prototype,"scaleVisibilitySuspended",null),e([m()],k.prototype,"renderer",null),e([m()],k.prototype,"_featureStore",void 0),e([m()],k.prototype,"_filterVisibility",void 0),e([m()],k.prototype,"_overlayRenderer",null),e([m()],k.prototype,"_overlaySpatialReference",null),e([m()],k.prototype,"_rendererParameters",null),e([m()],k.prototype,"_materialParameters",null),e([m()],k.prototype,"_densityParameters",null),e([m()],k.prototype,"_radiusParameter",null),e([m()],k.prototype,"_resolutionForScaleParameter",null),e([m()],k.prototype,"_colorRampParameter",null),e([m()],k.prototype,"_pixelRatioParameter",null),e([m()],k.prototype,"_densityMapPixelRatio",null),e([m()],k.prototype,"_renderGeometries",void 0),e([m()],k.prototype,"_material",void 0),e([m()],k.prototype,"_materialWithField",void 0),e([m()],k.prototype,"_renderView",null),e([m()],k.prototype,"_featuresArePoints",null),e([m()],k.prototype,"_loadedPointGraphics",null),e([m()],k.prototype,"_heatmapRenderer",null),e([m()],k.prototype,"_heatmapRendererFieldName",null),e([m()],k.prototype,"_heatmapRendererField",null),e([m()],k.prototype,"_heatmapRendererFieldIsNumeric",null),e([m()],k.prototype,"_fieldTotal",void 0),e([m()],k.prototype,"_drapeSourceRenderer",void 0),e([m()],k.prototype,"_isScaleRangeActive",null),k=e([h("esri.views.3d.layers.support.HeatmapFeatureProcessor")],k);export{k as HeatmapFeatureProcessor,Y as maxRadiusPt};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{estimateAttributesMemory as a,estimateFixedArrayMemory as s,estimateNumberMemory as o}from"../../../../core/memoryEstimations.js";import n from"../../../../core/Promise.js";import{initial as l,sync as p,watch as d}from"../../../../core/reactiveUtils.js";import{pt2px as u}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{projectPointToVector as _}from"../../../../geometry/projection/projectPointToVector.js";import{getContinuousIndexArray as g}from"../../../../geometry/support/Indices.js";import{getResolutionForScale as f}from"../../../../geometry/support/scaleUtils.js";import{getObjectId as R}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromPoint as F}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as b}from"../../../../layers/graphics/OptimizedFeature.js";import v from"../../../../layers/graphics/OptimizedGeometry.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{isNumericField as S}from"../../../../layers/support/fieldUtils.js";import{generateGradient as P}from"../../../../renderers/support/heatmapUtils.js";import{DrapeSourceType as j}from"../interfaces.js";import{DisplayFeatureLimit as T}from"../graphics/DisplayFeatureLimit.js";import{GraphicsCorePerformanceInfo as V}from"../graphics/GraphicsCorePerformanceInfo.js";import{FeatureVisibilityFilter as G}from"./FeatureVisibilityFilter.js";import{emptyHighlightHandle as x}from"./highlightUtils.js";import{drapedZ as I}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as A}from"../../webgl-engine/lib/ContentObjectType.js";import{DrapedHeatmapRenderer as N}from"../../webgl-engine/lib/DrapedHeatmapRenderer.js";import{Geometry as O}from"../../webgl-engine/lib/Geometry.js";import{DirtyOperation as U,DirtyState as H}from"../../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{UpdatePolicy as E}from"../../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as D}from"../../webgl-engine/lib/VertexAttribute.js";import{HeatmapDensityMaterial as C}from"../../webgl-engine/materials/HeatmapDensityMaterial.js";import{scaleBoundsPredicate as B,isScaleRangeActive as W}from"../../../support/layerViewUtils.js";import{PixelType as Z,PixelFormat as $}from"../../../webgl/enums.js";import{loadHeatmapTextureConfiguration as q,fallBackHeatmapConfiguration as z}from"../../../webgl/heatmapTextureUtils.js";const Y=112;let k=class extends n{constructor(e){super(e),this.type="heatmap",this.preferredUpdatePolicy=E.ASYNC,this.dataExtent=null,this.drapeSourceType=j.Features,this._renderGeometries=new Map,this._fieldTotal=0,this._drapeSourceRenderer=null,this._dataType=Z.HALF_FLOAT,this._pixelFormat=$.RGBA,this._updatingHandles=new y}initialize(){let e;try{e=q(this._renderView.renderingContext,i.getLogger(this))}catch(h){this.addResolvingPromise(Promise.reject(h)),e=z}const{dataType:t,samplingMode:a,pixelFormat:s,internalFormat:o}=e;this._featureStore=new w({geometryType:"esriGeometryPoint",hasZ:this.hasZ,hasM:this.hasM}),this._dataType=t,this._pixelFormat=s;const n=t!==Z.FLOAT,u=this.view.basemapTerrain.overlayManager,m={...this._rendererParameters,stage:this.view.stage,dataType:t,samplingMode:a,pixelFormat:s,internalFormat:o,rendererContext:u.renderer,drapeSource:this};this._drapeSourceRenderer=new N(m),u.registerDrapeSource(this,this._drapeSourceRenderer),this._material=new C({usesHalfFloats:n}),this._materialWithField=new C({usesHalfFloats:n,isAttributeDriven:!0}),this._filterVisibility=new G({context:{configuration:this.owner,featureStore:this.featureStore,getFeatureCount:()=>this._loadedPointGraphics.length,setAllFeaturesVisibility:e=>this._setAllFeaturesVisibility(e),clearFeaturesVisibility:()=>this._setAllFeaturesVisibility(!0),updateFeatureVisibilities:e=>this._updateFeatureVisibilities(e)}}),this._updatingHandles.addOnCollectionChange((()=>this._loadedPointGraphics),(e=>this._onLoadedFeaturesChange(e)),l),this._updatingHandles.addWhen((()=>this._materialParameters),(e=>this._forEachMaterial((t=>t.setParameters(e)))),l),this._updatingHandles.add((()=>this._rendererParameters),(e=>this._drapeSourceRenderer.set(e))),this._updatingHandles.add((()=>this._heatmapRendererField),(()=>{this._recreate()}),p),this._updatingHandles.add((()=>({fieldName:this._heatmapRendererFieldName,numeric:this._heatmapRendererFieldIsNumeric})),(({fieldName:e,numeric:t})=>{if(null!=e&&t){let t=0;this._featureStore.forEach((r=>t+=r.attributes[e]??0)),this._fieldTotal=t}else this._fieldTotal=this._featureStore.numFeatures}),l),this.addHandles([d((()=>({fieldName:this._heatmapRendererFieldName,field:this._heatmapRendererField})),(({fieldName:e,field:t})=>{e&&!t&&i.getLogger(this).warn(`Heatmap renderer field '${e}' for layer '${this.layer.title??this.layer.id}' not found`)})),d((()=>({field:this._heatmapRendererField,numeric:this._heatmapRendererFieldIsNumeric})),(({field:e,numeric:t})=>{null==e||t||i.getLogger(this).warn(`Heatmap renderer field '${e.name}' for layer '${this.layer.title??this.layer.id}' does not contain numeric values and cannot be used to drive the heatmap density`)})),r((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))])}destroy(){this._renderGeometries.clear(),this._material=null,this._materialWithField=null,this._featureStore.clear(),this._featureStore=null,this._updatingHandles.destroy()}get layer(){return this.owner.layer}get featureStore(){return this._featureStore}get updating(){return this._updatingHandles.updating||this.filterVisibility.updating}get updatingRemaining(){return 0}get suspendInfo(){return{}}get legendEnabled(){return!0}get filterVisibility(){return this._filterVisibility}get displayFeatureLimit(){const e=this.owner?.view?.quality??1,t=this.owner?.view?.qualitySettings,r=t?Math.ceil(t.heatmap.maxTotalNumberOfFeatures*e):0;return new T(r*6,r)}get hasZ(){return"hasZ"in this.layer&&this.layer.hasZ}get hasM(){return"hasM"in this.layer&&this.layer.hasM}get view(){return this.owner.view}get fullOpacity(){return this.owner.fullOpacity}get updatePolicy(){return this.owner.updatePolicy}get scaleVisibilitySuspended(){if(!this._isScaleRangeActive)return!1;const{minScale:e,maxScale:t}=this.layer.effectiveScaleRange,{scale:r}=this.view;return!B(r,e??0,t??0)}get usedMemory(){const e=this.usedMemoryPerFeature*this._featureStore.numFeatures,t=this._pixelFormat===$.RED?1:4,r=this._dataType===Z.FLOAT?4:2,i=Math.ceil((this._overlayRenderer?.overlays[0]?.resolution??0)*this._densityMapPixelRatio)??0;return i*i*t*r+e}get usedMemoryPerFeature(){const e=this._loadedPointGraphics.find((()=>!0));if(null==e)return 0;const t=a(e),r=6;return r*s([0,0,0],o)+r*s([0,0],o)+(this._heatmapRendererFieldIsNumeric?r*o:0)+t}get loadedFeatures(){return this._featureStore.numFeatures}get unprocessedMemoryEstimate(){return 0}get performanceInfo(){return new V(this._renderGeometries.size,this._visibleFeatures,0,0)}get renderer(){return this._heatmapRenderer}get _overlayRenderer(){return this.view.basemapTerrain.overlayManager.renderer}get _overlaySpatialReference(){return this._overlayRenderer.spatialReference}get _rendererParameters(){return{...this._radiusParameter,...this._densityParameters,...this._colorRampParameter,...this._pixelRatioParameter}}get _materialParameters(){return{...this._radiusParameter,...this._resolutionForScaleParameter}}get _densityParameters(){const e=this._heatmapRenderer;if(null==e)return null;const{minDensity:t,maxDensity:r}=e;return{minDensity:t,maxDensity:r,fieldTotal:this._fieldTotal}}get _radiusParameter(){const e=this._heatmapRenderer;return e?{searchRadius:u(this._clampSearchRadius(e.radius))}:null}get _resolutionForScaleParameter(){const e=this._heatmapRenderer;if(!e)return null;const{referenceScale:t}=e;return{resolutionForScale:0===t?0:f(t,this.view.spatialReference)}}get _colorRampParameter(){const e=this._heatmapRenderer;return e?{colorRampData:P(e.colorStops)}:null}get _pixelRatioParameter(){return{pixelRatio:this._densityMapPixelRatio}}get _densityMapPixelRatio(){return this.owner?.view?.qualitySettings.heatmap.pixelRatio??1}get _renderView(){return this.view.stage.renderView}get _featuresArePoints(){return"point"===this.layer.geometryType}get _loadedPointGraphics(){return this.owner.loadedGraphics}get _heatmapRenderer(){const e=this.layer.renderer;return"heatmap"===e?.type?e:null}get _heatmapRendererFieldName(){return this._heatmapRenderer?.field}get _heatmapRendererField(){const e=this._heatmapRendererFieldName;return null!=e?this.layer.fieldsIndex.get(e):null}get _heatmapRendererFieldIsNumeric(){const e=this._heatmapRendererField;return null!=e&&S(e)}get _isScaleRangeActive(){const{layer:e}=this;if(!("effectiveScaleRange"in e))return!1;const{minScale:t,maxScale:r}=e.effectiveScaleRange;return W(t,r)}get _visibleFeatures(){return Array.from(this._renderGeometries.values()).reduce(((e,{visible:t})=>e+(t?1:0)),0)}async whenGraphicBounds(){return null}computeAttachmentOrigin(){return null}highlight(){return x}maskOccludee(){return r()}setObjectIdVisibility(){}refreshFilter(){this.filterVisibility.reapply()}_onLoadedFeaturesChange(e){if(!this._featuresArePoints)return;const{objectIdField:r}=this.layer;this._featureStore.removeManyById(e.removed.map((e=>R(e,r)))),this._featureStore.addMany(e.added.map((e=>{const{attributes:t,centroid:i,geometry:a}=e,s=new b(F(new v,a),t,i?F(new v,i):null,R(e,r));return s.displayId=e.uid,s})));const i=e.added,a=e.removed;this._fieldTotal+=this._computeFieldTotalChange(i,a);const s=a.map((({uid:e})=>{const t=this._renderGeometries.get(e);return this._renderGeometries.delete(e),t})).filter(t),o=i.map((e=>{const t=this._pointGraphicToRenderGeometry(e);return this._renderGeometries.set(e.uid,t),t}));s.length>0&&this._drapeSourceRenderer.removeGeometries(s,U.REMOVE),o.length>0&&this._drapeSourceRenderer.addGeometries(o,U.ADD),(o.length>0||s.length>0)&&(this.filterVisibility.reapply(),this._renderView.requestRender())}_recreate(){if(!this._loadedPointGraphics)return;const e=this._loadedPointGraphics.toArray();this._onLoadedFeaturesChange({added:e,removed:e})}_pointGraphicToRenderGeometry(e){const t=this._heatmapRendererFieldName,r=null!=t?this._materialWithField:this._material,i=c();_(e.geometry,i,this._overlaySpatialReference),i[2]=I;const a=g(1),s=[[D.POSITION,new M(i,a,i.length)]],o=this._heatmapRendererFieldIsNumeric;null!=t&&s.push([D.FEATUREATTRIBUTE,new M([o?e.attributes[t]??0:0],a,1)]);const n=new L(new O(r,s,null,A.Point),{layerViewUid:this.owner.layerViewUid,graphicUid:e.uid});return n.visible=this.filterVisibility.defaultVisibility,n}_forEachMaterial(e){e(this._material),e(this._materialWithField)}_computeFieldTotalChange(e,t){if(null==this._heatmapRendererFieldName||!this._heatmapRendererFieldIsNumeric)return e.length-t.length;const r=this._heatmapRendererFieldName,i=(e,t)=>e+(t.attributes[r]??0);return e.reduce(i,0)-t.reduce(i,0)}_clampSearchRadius(e){return e>Y&&i.getLogger(this).warnOnce(`SceneView supports a maximum radius of ${Y} pt for HeatmapRenderer.`),Math.min(e,Y)}_updateFeatureVisibilities(e){const t=[];this._featureStore.forEach((({objectId:r,displayId:i})=>{const a=e(r),s=this._renderGeometries.get(i);s&&s.visible!==a&&(t.push(s),s.visible=a)})),this._drapeSourceRenderer.modifyGeometries(t,H.VISIBILITY)}_setAllFeaturesVisibility(e){const t=[];for(const r of this._renderGeometries.values())r.visible!==e&&(t.push(r),r.visible=e);this._drapeSourceRenderer.modifyGeometries(t,H.VISIBILITY)}get test(){}};e([m()],k.prototype,"type",void 0),e([m({constructOnly:!0})],k.prototype,"owner",void 0),e([m()],k.prototype,"layer",null),e([m()],k.prototype,"featureStore",null),e([m()],k.prototype,"updating",null),e([m()],k.prototype,"updatingRemaining",null),e([m()],k.prototype,"suspendInfo",null),e([m()],k.prototype,"legendEnabled",null),e([m()],k.prototype,"filterVisibility",null),e([m()],k.prototype,"displayFeatureLimit",null),e([m()],k.prototype,"preferredUpdatePolicy",void 0),e([m()],k.prototype,"hasZ",null),e([m()],k.prototype,"hasM",null),e([m()],k.prototype,"dataExtent",void 0),e([m()],k.prototype,"view",null),e([m()],k.prototype,"fullOpacity",null),e([m()],k.prototype,"updatePolicy",null),e([m()],k.prototype,"drapeSourceType",void 0),e([m()],k.prototype,"scaleVisibilitySuspended",null),e([m()],k.prototype,"renderer",null),e([m()],k.prototype,"_featureStore",void 0),e([m()],k.prototype,"_filterVisibility",void 0),e([m()],k.prototype,"_overlayRenderer",null),e([m()],k.prototype,"_overlaySpatialReference",null),e([m()],k.prototype,"_rendererParameters",null),e([m()],k.prototype,"_materialParameters",null),e([m()],k.prototype,"_densityParameters",null),e([m()],k.prototype,"_radiusParameter",null),e([m()],k.prototype,"_resolutionForScaleParameter",null),e([m()],k.prototype,"_colorRampParameter",null),e([m()],k.prototype,"_pixelRatioParameter",null),e([m()],k.prototype,"_densityMapPixelRatio",null),e([m()],k.prototype,"_renderGeometries",void 0),e([m()],k.prototype,"_material",void 0),e([m()],k.prototype,"_materialWithField",void 0),e([m()],k.prototype,"_renderView",null),e([m()],k.prototype,"_featuresArePoints",null),e([m()],k.prototype,"_loadedPointGraphics",null),e([m()],k.prototype,"_heatmapRenderer",null),e([m()],k.prototype,"_heatmapRendererFieldName",null),e([m()],k.prototype,"_heatmapRendererField",null),e([m()],k.prototype,"_heatmapRendererFieldIsNumeric",null),e([m()],k.prototype,"_fieldTotal",void 0),e([m()],k.prototype,"_drapeSourceRenderer",void 0),e([m()],k.prototype,"_isScaleRangeActive",null),k=e([h("esri.views.3d.layers.support.HeatmapFeatureProcessor")],k);export{k as HeatmapFeatureProcessor,Y as maxRadiusPt};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import i from"../../../core/Logger.js";import{MemCacheStorage as s,MemCache as r}from"../../../core/MemCache.js";import{addFrameTask as a}from"../../../core/scheduling.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isMemoryManagedView as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import i from"../../../core/Logger.js";import{MemCacheStorage as s,MemCache as r}from"../../../core/MemCache.js";import{addFrameTask as a}from"../../../core/scheduling.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isMemoryManagedView as d}from"./MemoryManagedView.js";function y(e){return new p({view:e})}const l=.1,u=1,n=1,m=.75,c=.6,_=1.3;let p=class extends t{constructor(e){super(e),this._quality=1,this._usedMemory=0,this._updating=!1,this._stableQuality=0,this._downscaleMemoryUsed=0,this._canFastRecover=!1,this._predictedMemory=0,this._cacheStorage=new s,this._warnMemoryUsage=null,this._numQualityChanges=0,this._maxMemory=750,this._additionalCacheMemory=0,this.addHandles(a({prepare:()=>this._updateMemory()}))}destroy(){this._cacheStorage.destroy()}get maxMemory(){return this._maxMemory}set maxMemory(e){null==e||e<=0||(this._stableQuality=0,this._canFastRecover=!1,this._maxMemory<e&&this._updateQuality(u),this._maxMemory=e)}get additionalCacheMemory(){return this._additionalCacheMemory}set additionalCacheMemory(e){null!=e&&(this._additionalCacheMemory=e)}get memoryFactor(){return this._quality}get updating(){return this._updating}get usedMemory(){return this._usedMemory}get usedCacheMemory(){return this._cacheStorage.size}newCache(e,t,i){return new r(e,this._cacheStorage,t,i)}resetStableQuality(){this._stableQuality=0}disableMemCache(){this.additionalCacheMemory=-4096}update(e=!0){if(this._predictedMemory<=0&&!this._updating)return;let t=this._layersUpdating();if(this._predictedMemory<c&&this._canFastRecover)this._downscaleMemoryUsed=0,this._stableQuality=0,this._canFastRecover=!1,this._updateQuality(u);else if(t){if(this._predictedMemory>1.1*n||this._usedMemory>n)if(this._stableQuality>0)this._downscaleMemoryUsed=0,this._updateQuality(this._stableQuality);else if(this._quality>l&&this._downscaleMemoryUsed<this._usedMemory){if(e&&this._compactAndUpdate())return;this._updateQuality(this._quality/_),this._downscaleMemoryUsed=this._usedMemory,this._canFastRecover=!1}}else if(this._downscaleMemoryUsed=0,this._usedMemory>n){if(e&&this._compactAndUpdate())return;this._stableQuality=0,this._canFastRecover=!1,t=this._updateQuality(this._quality/_),this._downscaleMemoryUsed=this._predictedMemory}else if(this._stableQuality!==this._quality)if(this._usedMemory<m&&this._quality<u){this._stableQuality=this._quality;const e=.05;t=this._updateQuality(this._quality+e)}else this._quality<1&&(this._canFastRecover=!0);this._updating=t}_compactAndUpdate(){let e=this.view.stage.compact();return e=this.view.basemapTerrain.overlayManager.renderer.compact()||e,e&&(this._updateMemory(),this.update(!1)),e}_updateQuality(e){return(e=Math.min(Math.max(e,l),u))!==this._quality&&(this._quality=e,++this._numQualityChanges,!0)}_layersUpdating(){return this.view.allLayerViews.some((e=>!!e.updating))}_updateMemory(){if(!this.view)return;this.view.stage?.renderer?.tick();const e=this.view.stage?.renderer?.usedMemory;let t=(this.view.basemapTerrain?.usedMemory??0)+(e?e.fbos+e.edges+e.plugins:0),s=0;this.view.allLayerViews&&this.view.allLayerViews.forEach((e=>{if(d(e)){const i=e.ignoresMemoryFactor?this._quality:1;t+=e.usedMemory*i,s+=e.unloadedMemory*i}}));const r=null==this._warnMemoryUsage||Math.round(10*t)!==Math.round(10*this._warnMemoryUsage),a=1048576*this.maxMemory;if(t>a&&r){this._warnMemoryUsage=t;const e=e=>(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})+" MB",r=Math.round(100*this._quality);i.getLogger(this).warn(`Memory Limit exceeded! Limit: ${e(a)} Current: ${e(t)} Projected: ${e(t+s)} Quality: ${r}%`)}this._usedMemory=t/a,this._predictedMemory=(t+s)/a;const o=a-t;this._cacheStorage.maxSize=Math.max(0,o+1048576*this.additionalCacheMemory)}get test(){}};e([o({constructOnly:!0})],p.prototype,"view",void 0),e([o()],p.prototype,"maxMemory",null),e([o()],p.prototype,"additionalCacheMemory",null),e([o({readOnly:!0})],p.prototype,"memoryFactor",null),e([o({readOnly:!0})],p.prototype,"updating",null),e([o({readOnly:!0})],p.prototype,"usedMemory",null),e([o({readOnly:!0})],p.prototype,"usedCacheMemory",null),e([o()],p.prototype,"_quality",void 0),e([o()],p.prototype,"_usedMemory",void 0),e([o()],p.prototype,"_updating",void 0),e([o()],p.prototype,"_stableQuality",void 0),e([o()],p.prototype,"_maxMemory",void 0),e([o()],p.prototype,"_additionalCacheMemory",void 0),p=e([h("esri.views.3d.support.MemoryController")],p);export{l as minQuality,y as newMemoryController};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import has from"../../../core/has.js";import{clamp as i,deg2rad as n}from"../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import{watch as o,sync as l}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{subtract as d}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{g as u,d as p,c as m,j as _}from"../../../chunks/vec32.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as g,b as f,g as v}from"../../../chunks/vec42.js";import{create as R,fromValues as O}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as x}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as w}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,width as D,copy as T,center as E,height as P,intersection as M,contains as b,intersects as j,offset as I}from"../../../geometry/support/aaBoundingRect.js";import{create as U,wrap as N}from"../../../geometry/support/ray.js";import{k as C,b as A,t as q}from"../../../chunks/sphere.js";import{angleAroundAxis as G}from"../../../geometry/support/vector.js";import{y2lat as V}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as F}from"../state/utils/viewUtils.js";import{debugFlags as L}from"../support/debugFlags.js";import{DebugPoint as B}from"../support/debugUtils.js";import{OverlayIndex as H}from"./interfaces.js";import{OverlayRenderer as k}from"./OverlayRenderer.js";import{RenderRequestType as Y}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as z}from"../webgl-engine/lib/Intersector.js";import{fromValues as W}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as X}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as K}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as Z}from"../webgl-engine/parts/renderUtils.js";import{TaskPriority as J,noBudget as Q}from"../../support/Scheduler.js";import{Yield as $}from"../../support/Yield.js";const ee=1.3,te=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let re,se=class extends t{constructor(e){super(e),this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096}initialize(){const e=this.view;this.renderer=new k({parent:this}),e.stage.renderer.plugins.add(this.renderer);const t=()=>this.requestRender();this._groundIntersector=z(this.view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([o((()=>this.renderer.hasHighlights),t),this.renderer.events.on("has-water",(()=>e.stage?.renderer.updateHasFlags())),this.renderer.events.on("content-changed",t),o((()=>e.state.camera.pixelRatio),t),o((()=>e.state.alignPixelEnabled),t),this.renderer.events.on("textures-disposed",(()=>this.surface.requestRender())),o((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),o((()=>[e.state?.pixelRatio,e.state?.contentPixelRatio]),(()=>this.setPlacementDirty()),l),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),e.resourceController.scheduler.registerTask(J.OVERLAY,this),e.stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(Q,e.camera,Y.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlays(Y.BACKGROUND,e)}))]),e.stage.renderer.overlay=this}destroy(){this.view?.stage&&(this.view.stage.renderer.plugins.remove(this.renderer),this.view.stage.renderer.overlay=null),re&&(re.hide(),re=null),this.renderer=a(this.renderer)}get spatialReference(){return this._spatialReference}set spatialReference(e){this._spatialReference=e,this.renderer.longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this.renderer.longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180))):this.renderer.disposeOverlays()}get running(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||L.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this.view.state.isGlobal}get worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?x(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return ee/this.view.resolutionScale}get _longitudeCyclical(){return this.renderer.longitudeCyclical}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get rendersOccludedDraped(){return this.renderer.rendersOccludedDraped}render(){if(this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays)return this._precompileShaders()?this._drawOverlays(Y.UPDATE):null}get hasOverlays(){return this.renderer.hasOverlays}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,X)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.requestRender()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this._updateOverlays(e,this.view.state.contentCamera,Y.UPDATE)}_updateOverlays(e,t,r){if(!this._spatialReference)return $;const s=this._computeOverlayResolution(t);this._computeOverlayExtents(t,s,le),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,le.stretch);const i=this._updateOverlay(H.INNER,le.inner,s,1*le.pixelRatioAdjustment,le.mapUnitsPerPixel),n=D(le.inner)/D(le.outer),a=this._updateOverlay(H.OUTER,le.outer,s,n*le.pixelRatioAdjustment,le.mapUnitsPerPixel);i!==ue.EXTENT&&a!==ue.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.updateOverlayParameters(r)),i===ue.NONE&&a===ue.NONE||this.requestRender(),this._placementDirty=!1,e.madeProgress()}_computeOverlayResolution(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s));return K(i,this._maxResolution)}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return ue.NONE;const n=this.renderer.overlays[e],a=n.mapUnitsPerPixel;if(n.mapUnitsPerPixel=i,n.pixelRatio=s,ie(t,n.extent)&&r===n.resolution)return a===i?ue.NONE:ue.RERENDER_ONLY;T(n.extent,t),n.resolution=r;const o=E(n.extent);return n.renderLocalOrigin=W(o[0],o[1],0,"OV_"+this._latestOriginId++),ue.EXTENT}updateOverlayParameters(e){this.surface.allTiles.forAll((e=>this.updateTileOverlayParameters(e))),this.surface.requestRender(e)}updateTileOverlayParameters(e){if(!e.renderData)return;const t=e.renderData.overlay;if(0===this.renderer.overlays.length)this._clearTileOverlayData(H.INNER,t),this._clearTileOverlayData(H.OUTER,t);else{const[r,s]=this.renderer.overlays,i=e.extent;this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,H.INNER,t),this._setTileOverlayData(i,H.OUTER,t)):(this._clearTileOverlayData(H.INNER,t),this._clearTileOverlayData(H.OUTER,t))}}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[H.INNER],s=this.renderer.overlays[H.OUTER],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=D(s),n=P(s);let a=e[0];if(this._longitudeCyclical){a=this._longitudeCyclical.minimalMonotonic(s[0],a);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);a>t&&(a=t-(e[2]-e[0]))}r.setScale(t,D(e)/i,P(e)/n),r.setOffset(t,(a-s[0])/i,(e[1]-s[1])/n)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}reloadShaders(){Z(),this.requestRender(),this.runTask(Q)}requestRender(e=Y.UPDATE){this.renderer.hasOverlays?(e===Y.UPDATE?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this._drawTexturesAnimateDirty=!0,this.view.stage.renderView.requestRender(e)):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s,i){const n=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,de,t,r);if(null==n)return!1;const a=n.origin,o=u(oe,n.origin,n.direction);this._groundIntersector.reset(a,o,e),this._groundIntersector.intersect([]),this.view.basemapTerrain.intersect(this._groundIntersector,null,a,o);const l=this._groundIntersector.results.min;return l.getIntersectionPoint(i)&&l.withinDistance(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const n=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=i(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),c=e.aboveGround;if("global"===this.view.viewingMode){const t=oe;C(A(q,x(this.view.spatialReference).radius+h),N(e.eye,e.viewForward),t),p(t,t,e.eye);const i=s.normalize(G(e.viewForward,t,e.viewRight))/e.fovY+.5,a=i<=0||i>=1?.5:n;r=c?a*i:i+a*(1-i)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),a=O(0,s,1,0),o=g(a,a,e.projectionMatrix)[1],l=i(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*n:1-(1-l)*n}return this._intersectGroundFromView(e,.5,r,o.distance,t)}_computeOverlayExtents(e,t,r){const s=this.view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=y();this._findHorizonBasedPointOfInterest(e,i)||m(i,s),L.OVERLAY_SHOW_CENTER?(null==re&&(re=new B(this.view.graphics,"red")),re.show(i,this._renderSR)):null!=re&&re.hide();const a=Math.max(.1,_(e.eye,i)),o=F(this.view.renderCoordsHelper,s,e.eye);this._overlaySREqualsRenderSR||w(i,this._renderSR,i,this._spatialReference);const l=this.surface.extent,h=!this._isSpherical&&this._spatialReference?.isGeographic,c=h&&this._spatialReference?1/x(this._spatialReference).metersPerDegree:1,u=this.view.state.contentPixelRatio,p=e.perScreenPixelRatio/u*a*c;r.mapUnitsPerPixel=p/this.worldToPCSRatio,r.stretch=this._overlayStretch;let g=t*p/2*r.stretch,R=!1,O=h?90:1/0;this._isSpherical&&l&&this._spatialReference&&(this._spatialReference.isWebMercator?(g/=Math.cos(V(i[1])),O=l[3]):(R=!0,g/=x(this._spatialReference).metersPerDegree,O=90),g>=O&&(g=O,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let S=1;R&&(S=1/Math.max(.2,Math.cos(Math.abs(n(i[1])))),g*S>180&&(S=180/g),r.mapUnitsPerPixel*=S);const E=Math.log(2)/12;g=Math.exp(Math.round(Math.log(g)/E)*E);const P=g*S,j=32,I=.5*t/(j*P),U=.5*t/(j*g);i[0]=Math.round(i[0]*I)/I,i[1]=Math.round(i[1]*U)/U;const N=r.inner;N[0]=i[0]-P,N[1]=i[1]-g,N[2]=i[0]+P,N[3]=i[1]+g,this._isSpherical&&this._shiftExtentToFitBounds(N,1/0,O);const C=r.outer;if(6*P>D(l))T(C,l);else{if(Math.PI/2-Math.abs(o-Math.PI/2)<=.25*Math.PI)C[0]=N[0]-P,C[1]=N[1]-g,C[2]=N[2]+P,C[3]=N[3]+g;else{w(e.eye,this._renderSR,oe,this._spatialReference),d(ae,i,oe);let t=-Math.atan2(ae[1],ae[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));f(ae,te[r],2*g),ae[0]*=S,ae[2]*=S,v(C,N,ae)}}if(this._isSpherical)C[0]=this._longitudeCyclical.clamp(C[0]),C[2]=this._longitudeCyclical.clamp(C[2]),C[1]=Math.max(C[1],-O),C[3]=Math.min(C[3],O);else{const e=M(N,l,he),t=M(C,l,ce);b(e,t)&&(C[2]=C[0],C[3]=C[1])}const A=Math.abs(N[2]-N[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,A),r.pixelRatioAdjustment=r.mapUnitsPerPixel/A}_precompileShaders(){return!!this.renderer.hasOverlays&&(this.renderer.precompileShaders(this.view.state),!0)}_drawOverlays(e,t=this.view.state){if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const r=this._drawTexturesDirty;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const s=this.renderer.computeValidity();this.renderer.releaseRenderTargets(),this.renderer.drawOverlays(t);return s!==this.renderer.computeValidity()&&this.updateOverlayParameters(Y.UPDATE),r?(this.surface.requestRender(e),e===Y.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(Y.BACKGROUND),this.renderer}_rectanglesOverlap(e,t){return null!=e&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):j(e,t))}_rectInsideRect(e,t){return null!=t&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:b(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),I(e,s,i)}get test(){}};function ie(e,t){const r=1e-5,s=L.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([h()],se.prototype,"_spatialReference",void 0),e([h({readOnly:!0})],se.prototype,"running",null),e([h()],se.prototype,"_placementDirty",void 0),e([h()],se.prototype,"_contentUpdated",void 0),e([h()],se.prototype,"_isSpherical",null),e([h()],se.prototype,"worldToPCSRatio",null),e([h()],se.prototype,"renderer",void 0),e([h({constructOnly:!0})],se.prototype,"view",void 0),e([h({constructOnly:!0})],se.prototype,"surface",void 0),e([h()],se.prototype,"suspended",null),e([h()],se.prototype,"updating",null),e([h({type:Boolean})],se.prototype,"rendersOccludedDraped",null),se=e([c("esri.views.3d.terrain.OverlayManager")],se);class ne{constructor(){this.inner=S(),this.outer=S(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=ee}}const ae=R(),oe=y(),le=new ne,he=S(),ce=S(),de=U();var ue;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(ue||(ue={}));export{se as OverlayManager};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import has from"../../../core/has.js";import{clamp as i,deg2rad as n}from"../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import{watch as o,sync as l}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{subtract as d}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{g as u,d as p,c as m,j as _}from"../../../chunks/vec32.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as y,b as f,g as v}from"../../../chunks/vec42.js";import{create as R,fromValues as O}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as w}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as x}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,width as D,copy as T,center as E,height as P,intersection as M,contains as b,intersects as j,offset as I}from"../../../geometry/support/aaBoundingRect.js";import{create as U,wrap as C}from"../../../geometry/support/ray.js";import{k as N,b as A,t as q}from"../../../chunks/sphere.js";import{angleAroundAxis as G}from"../../../geometry/support/vector.js";import{y2lat as V}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as F}from"../state/utils/viewUtils.js";import{debugFlags as L}from"../support/debugFlags.js";import{DebugPoint as B}from"../support/debugUtils.js";import{OverlayIndex as H}from"./interfaces.js";import{OverlayRenderer as k}from"./OverlayRenderer.js";import{RenderRequestType as Y}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as z}from"../webgl-engine/lib/Intersector.js";import{fromValues as W}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as X}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as K}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as Z}from"../webgl-engine/parts/renderUtils.js";import{TaskPriority as J,noBudget as Q}from"../../support/Scheduler.js";import{Yield as $}from"../../support/Yield.js";const ee=1.3,te=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let re,se=class extends t{constructor(e){super(e),this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096}initialize(){const e=this.view;this.renderer=new k({parent:this}),e.stage.renderer.plugins.add(this.renderer);const t=()=>this.requestRender();this._groundIntersector=z(this.view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([o((()=>this.renderer.hasHighlights),t),this.renderer.events.on("has-water",(()=>e.stage?.renderer.updateHasFlags())),this.renderer.events.on("content-changed",t),o((()=>e.state.camera.pixelRatio),t),o((()=>e.state.alignPixelEnabled),t),this.renderer.events.on("textures-disposed",(()=>this.surface.requestRender())),o((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),o((()=>[e.state?.pixelRatio,e.state?.contentPixelRatio]),(()=>this.setPlacementDirty()),l),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),e.resourceController.scheduler.registerTask(J.OVERLAY,this),e.stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(Q,e.camera,Y.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlays(Y.BACKGROUND,e)}))]),e.stage.renderer.overlay=this}destroy(){this.view?.stage&&(this.view.stage.renderer.plugins.remove(this.renderer),this.view.stage.renderer.overlay=null),re&&(re.hide(),re=null),this.renderer=a(this.renderer)}get spatialReference(){return this._spatialReference}set spatialReference(e){this._spatialReference=e,this.renderer.longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this.renderer.longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180))):this.renderer.disposeOverlays()}get running(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||L.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this.view.state.isGlobal}get worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?w(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return ee/this.view.resolutionScale}get _longitudeCyclical(){return this.renderer.longitudeCyclical}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get rendersOccludedDraped(){return this.renderer.rendersOccludedDraped}render(){if(this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays)return this._precompileShaders()?this._drawOverlays(Y.UPDATE):null}get hasOverlays(){return this.renderer.hasOverlays}registerDrapeSource(e,t){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources),this.renderer.registerDrapeSource(e,t),this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running")}registerGeometryDrapeSource(e){const t=new X({stage:this.view.stage,drapeSource:e,rendererContext:this.renderer});return this.registerDrapeSource(e,t),t}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.requestRender()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this._updateOverlays(e,this.view.state.contentCamera,Y.UPDATE)}_updateOverlays(e,t,r){if(!this._spatialReference)return $;const s=this._computeOverlayResolution(t);this._computeOverlayExtents(t,s,le),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,le.stretch);const i=this._updateOverlay(H.INNER,le.inner,s,1*le.pixelRatioAdjustment,le.mapUnitsPerPixel),n=D(le.inner)/D(le.outer),a=this._updateOverlay(H.OUTER,le.outer,s,n*le.pixelRatioAdjustment,le.mapUnitsPerPixel);i!==ue.EXTENT&&a!==ue.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.updateOverlayParameters(r)),i===ue.NONE&&a===ue.NONE||this.requestRender(),this._placementDirty=!1,e.madeProgress()}_computeOverlayResolution(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s));return K(i,this._maxResolution)}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return ue.NONE;const n=this.renderer.overlays[e],a=n.mapUnitsPerPixel;if(n.mapUnitsPerPixel=i,n.pixelRatio=s,ie(t,n.extent)&&r===n.resolution)return a===i?ue.NONE:ue.RERENDER_ONLY;T(n.extent,t),n.resolution=r;const o=E(n.extent);return n.renderLocalOrigin=W(o[0],o[1],0,"OV_"+this._latestOriginId++),ue.EXTENT}updateOverlayParameters(e){this.surface.allTiles.forAll((e=>this.updateTileOverlayParameters(e))),this.surface.requestRender(e)}updateTileOverlayParameters(e){if(!e.renderData)return;const t=e.renderData.overlay;if(0===this.renderer.overlays.length)this._clearTileOverlayData(H.INNER,t),this._clearTileOverlayData(H.OUTER,t);else{const[r,s]=this.renderer.overlays,i=e.extent;this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,H.INNER,t),this._setTileOverlayData(i,H.OUTER,t)):(this._clearTileOverlayData(H.INNER,t),this._clearTileOverlayData(H.OUTER,t))}}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[H.INNER],s=this.renderer.overlays[H.OUTER],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=D(s),n=P(s);let a=e[0];if(this._longitudeCyclical){a=this._longitudeCyclical.minimalMonotonic(s[0],a);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);a>t&&(a=t-(e[2]-e[0]))}r.setScale(t,D(e)/i,P(e)/n),r.setOffset(t,(a-s[0])/i,(e[1]-s[1])/n)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}reloadShaders(){Z(),this.requestRender(),this.runTask(Q)}requestRender(e=Y.UPDATE){this.renderer.hasOverlays?(e===Y.UPDATE?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this._drawTexturesAnimateDirty=!0,this.view.stage.renderView.requestRender(e)):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s,i){const n=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,de,t,r);if(null==n)return!1;const a=n.origin,o=u(oe,n.origin,n.direction);this._groundIntersector.reset(a,o,e),this._groundIntersector.intersect([]),this.view.basemapTerrain.intersect(this._groundIntersector,null,a,o);const l=this._groundIntersector.results.min;return l.getIntersectionPoint(i)&&l.withinDistance(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const n=.55,a=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=i(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:a+l,e.aboveGround?a-l:1/0),c=e.aboveGround;if("global"===this.view.viewingMode){const t=oe;N(A(q,w(this.view.spatialReference).radius+h),C(e.eye,e.viewForward),t),p(t,t,e.eye);const i=s.normalize(G(e.viewForward,t,e.viewRight))/e.fovY+.5,a=i<=0||i>=1?.5:n;r=c?a*i:i+a*(1-i)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),a=O(0,s,1,0),o=y(a,a,e.projectionMatrix)[1],l=i(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*n:1-(1-l)*n}return this._intersectGroundFromView(e,.5,r,o.distance,t)}_computeOverlayExtents(e,t,r){const s=this.view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=g();this._findHorizonBasedPointOfInterest(e,i)||m(i,s),L.OVERLAY_SHOW_CENTER?(null==re&&(re=new B(this.view.graphics,"red")),re.show(i,this._renderSR)):null!=re&&re.hide();const a=Math.max(.1,_(e.eye,i)),o=F(this.view.renderCoordsHelper,s,e.eye);this._overlaySREqualsRenderSR||x(i,this._renderSR,i,this._spatialReference);const l=this.surface.extent,h=!this._isSpherical&&this._spatialReference?.isGeographic,c=h&&this._spatialReference?1/w(this._spatialReference).metersPerDegree:1,u=this.view.state.contentPixelRatio,p=e.perScreenPixelRatio/u*a*c;r.mapUnitsPerPixel=p/this.worldToPCSRatio,r.stretch=this._overlayStretch;let y=t*p/2*r.stretch,R=!1,O=h?90:1/0;this._isSpherical&&l&&this._spatialReference&&(this._spatialReference.isWebMercator?(y/=Math.cos(V(i[1])),O=l[3]):(R=!0,y/=w(this._spatialReference).metersPerDegree,O=90),y>=O&&(y=O,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let S=1;R&&(S=1/Math.max(.2,Math.cos(Math.abs(n(i[1])))),y*S>180&&(S=180/y),r.mapUnitsPerPixel*=S);const E=Math.log(2)/12;y=Math.exp(Math.round(Math.log(y)/E)*E);const P=y*S,j=32,I=.5*t/(j*P),U=.5*t/(j*y);i[0]=Math.round(i[0]*I)/I,i[1]=Math.round(i[1]*U)/U;const C=r.inner;C[0]=i[0]-P,C[1]=i[1]-y,C[2]=i[0]+P,C[3]=i[1]+y,this._isSpherical&&this._shiftExtentToFitBounds(C,1/0,O);const N=r.outer;if(6*P>D(l))T(N,l);else{if(Math.PI/2-Math.abs(o-Math.PI/2)<=.25*Math.PI)N[0]=C[0]-P,N[1]=C[1]-y,N[2]=C[2]+P,N[3]=C[3]+y;else{x(e.eye,this._renderSR,oe,this._spatialReference),d(ae,i,oe);let t=-Math.atan2(ae[1],ae[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));f(ae,te[r],2*y),ae[0]*=S,ae[2]*=S,v(N,C,ae)}}if(this._isSpherical)N[0]=this._longitudeCyclical.clamp(N[0]),N[2]=this._longitudeCyclical.clamp(N[2]),N[1]=Math.max(N[1],-O),N[3]=Math.min(N[3],O);else{const e=M(C,l,he),t=M(N,l,ce);b(e,t)&&(N[2]=N[0],N[3]=N[1])}const A=Math.abs(C[2]-C[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,A),r.pixelRatioAdjustment=r.mapUnitsPerPixel/A}_precompileShaders(){return!!this.renderer.hasOverlays&&(this.renderer.precompileShaders(this.view.state),!0)}_drawOverlays(e,t=this.view.state){if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const r=this._drawTexturesDirty;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const s=this.renderer.computeValidity();this.renderer.releaseRenderTargets(),this.renderer.drawOverlays(t);return s!==this.renderer.computeValidity()&&this.updateOverlayParameters(Y.UPDATE),r?(this.surface.requestRender(e),e===Y.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(Y.BACKGROUND),this.renderer}_rectanglesOverlap(e,t){return null!=e&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):j(e,t))}_rectInsideRect(e,t){return null!=t&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:b(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),I(e,s,i)}get test(){}};function ie(e,t){const r=1e-5,s=L.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([h()],se.prototype,"_spatialReference",void 0),e([h({readOnly:!0})],se.prototype,"running",null),e([h()],se.prototype,"_placementDirty",void 0),e([h()],se.prototype,"_contentUpdated",void 0),e([h()],se.prototype,"_isSpherical",null),e([h()],se.prototype,"worldToPCSRatio",null),e([h()],se.prototype,"renderer",void 0),e([h({constructOnly:!0})],se.prototype,"view",void 0),e([h({constructOnly:!0})],se.prototype,"surface",void 0),e([h()],se.prototype,"suspended",null),e([h()],se.prototype,"updating",null),e([h({type:Boolean})],se.prototype,"rendersOccludedDraped",null),se=e([c("esri.views.3d.terrain.OverlayManager")],se);class ne{constructor(){this.inner=S(),this.outer=S(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=ee}}const ae=R(),oe=g(),le=new ne,he=S(),ce=S(),de=U();var ue;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(ue||(ue={}));export{se as OverlayManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import i from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as o,on as a,initial as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as u,fromTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{i as g}from"../../../chunks/vec32.js";import{ones as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DrapeTargetType as m,DrapeSourceType as f,DrapedRenderGroup as y}from"../layers/interfaces.js";import{debugFlags as R}from"../support/debugFlags.js";import{OverlayIndex as T}from"./interfaces.js";import{Overlay as b}from"./Overlay.js";import{OverlayContent as w}from"./OverlayContent.js";import{OverlayRenderTargets as x}from"./OverlayRenderTargets.js";import D from"../webgl/RenderCamera.js";import{ShaderOutput as v}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as C}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as E,renderHighlightBuffer as P}from"../webgl-engine/effects/highlight/Highlight.js";import{RenderRequestType as j}from"../webgl-engine/lib/basicInterfaces.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OITPass as I}from"../webgl-engine/lib/OITPass.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as N}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as F}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as V}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as H}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{Update as G}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as k}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as U}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as J}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends S{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new i,this._passParameters=new C,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new D,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[N.DRAPED_MATERIAL,e=>e!==v.Highlight||this.hasHighlights],[N.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,textures:i}=r.renderView;this._renderContext=new q(this._rctx,new F(t,e.state.viewingMode)),this.addHandles([n((()=>s.updating),(()=>this.events.emit("content-changed")),o),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),o),a((()=>e.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0)),n((()=>E(e.state.highlights)),(()=>this._sortedDrapeSourceRenderersDirty=!0),h),n((()=>e.state.highlights),(r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap,this._updateHighlights()}),h),e.resourceController.scheduler.registerTask(Y.STAGE,this)]),this._materials=new A(i,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed")));const{_bindParameters:l,_camera:d}=this;d.near=1,d.far=1e4,d.relativeElevation=null,l.slot=N.DRAPED_MATERIAL,l.mainDepth=null,l.camera=d,l.oitPass=I.NONE,l.updateLighting([new U(_())],0,0,G.Immediate)}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._passParameters.texture=s(this._passParameters.texture),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){this._pluginContext=e,this._techniques.precompile(z)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}_updateHighlights(){const e=this._view.state;this._renderers.forEach((r=>r.updateHighlights(e.highlightOrderMap)))}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===m.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new x(this._stage.renderer.fboCache),this._overlays=[new b,new b]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=s(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){return e===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(w.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges(this._view.state.highlightOrderMap)&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"))}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===k.SYNC))}get isEmpty(){return!R.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){const e=t(this._renderers,(({hasWater:e})=>e));return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se,++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.renderOccludedMask=e,r}renders(e){if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==w.Occluded&&e!==w.Highlight)return!0;if(!this._overlays)return!1;const r=this._overlays[T.INNER];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find((r=>r.content===e))?.output??v.Color,++this._techniques.precompiling;const s=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?O.Disabled:this.hasWater&&this.renders(w.WaterNormal)?O.EnabledWithWater:this._renderTargets?.getTexture(w.Color)?O.Enabled:O.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r&&this.parent.requestRender(j.BACKGROUND),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(t.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const e=t.output;this._renderContext.output=e,r.slot=e===v.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,e===v.Highlight&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null),t.content===w.Occluded&&(this._renderContext.renderOccludedMask=se),this._sortedRenderers.forAll((({drapeSource:e,renderer:r})=>{t.content===w.ColorNoRasterImage&&e.drapeSourceType===f.RasterImage||r.precompile(this._renderContext)})),this._renderContext.renderOccludedMask=L,r.highlightMixTexture=null}--this._techniques.precompiling}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)e.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=this._drawTarget(T.INNER,e),t=this._drawTarget(T.OUTER,e);(r||t)&&e.fbo.generateMipMap()}}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||n===v.Normal&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:l}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,l.slot=n===v.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,r.content===w.Occluded&&(h.renderOccludedMask=se),!this.renders(r.content))return h.renderOccludedMask=L,!1;const{resolution:d}=t,c=e===T.INNER,u=c?0:d;if(o.setViewport(u,0,d,d),this._bindTargetFBO(r),c)if(r.output!==v.Highlight)o.setClearColor(0,0,0,0),o.clear(K.COLOR);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==w.Occluded&&r.content!==w.Highlight){this._techniques.precompile(V,ie);const r=this._techniques.get(V,ie);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,re[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(r.output===v.Highlight){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),P(o,t,{width:s,height:s},l,(()=>this._renderAllGeometry(e,r)),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=L,!0}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll((({drapeSource:i,renderer:n})=>{if(r.content===w.ColorNoRasterImage&&i.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&r.output===v.Color&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(z);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}}))}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.bind(this._rctx,t,r)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}get _resolution(){return this._overlays?.[T.INNER].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),n=i>=0,o=s.renderGroup??(n?y.MapLayer:y.ViewLayer),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new ee(s,t,h))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],u(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),p(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new Z(e);i.samplingMode=J.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t)}get test(){}};e([d()],$.prototype,"hasHighlights",void 0),e([d()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([d({constructOnly:!0})],$.prototype,"parent",void 0),e([d({readOnly:!0})],$.prototype,"_techniques",null),e([d({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([d()],$.prototype,"isEmpty",null),e([d({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([c("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent,ie=new H;ie.hasAlpha=!0;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import i from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as o,on as a,initial as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as u,fromTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{i as g}from"../../../chunks/vec32.js";import{ones as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DrapeTargetType as m,DrapeSourceType as f,DrapedRenderGroup as y}from"../layers/interfaces.js";import{debugFlags as R}from"../support/debugFlags.js";import{OverlayIndex as T}from"./interfaces.js";import{Overlay as b}from"./Overlay.js";import{OverlayContent as w}from"./OverlayContent.js";import{OverlayRenderTargets as x}from"./OverlayRenderTargets.js";import v from"../webgl/RenderCamera.js";import{ShaderOutput as D}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as C}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as S}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as E,renderHighlightBuffer as P}from"../webgl-engine/effects/highlight/Highlight.js";import{RenderRequestType as j}from"../webgl-engine/lib/basicInterfaces.js";import{GLMaterialRepository as A}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as W}from"../webgl-engine/lib/Material.js";import{OITPass as I}from"../webgl-engine/lib/OITPass.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as N}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as F}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as V}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as H}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{Update as G}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as k}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as U}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as z}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as Y,noBudget as X}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as J}from"../../webgl/enums.js";import{Texture as Q}from"../../webgl/Texture.js";import{TextureDescriptor as Z}from"../../webgl/TextureDescriptor.js";let $=class extends S{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new i,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new v,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[N.DRAPED_MATERIAL,e=>e!==D.Highlight||this.hasHighlights],[N.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,textures:i}=r.renderView;this._renderContext=new q(this._rctx,new F(t,e.state.viewingMode)),this.addHandles([n((()=>s.updating),(()=>this.events.emit("content-changed")),o),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),o),a((()=>e.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0)),n((()=>E(e.state.highlights)),(()=>this._sortedDrapeSourceRenderersDirty=!0),h),n((()=>e.state.highlights),(r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap}),h),e.resourceController.scheduler.registerTask(Y.STAGE,this)]),this._materials=new A(i,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed")));const{_bindParameters:l,_camera:d}=this;d.near=1,d.far=1e4,d.relativeElevation=null,l.slot=N.DRAPED_MATERIAL,l.mainDepth=null,l.camera=d,l.oitPass=I.NONE,l.updateLighting([new U(_())],0,0,G.Immediate)}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._passParameters.texture=s(this._passParameters.texture),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){this._pluginContext=e,this._techniques.precompile(z)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating||e.canCompact))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===m.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new x(this._stage.renderer.fboCache),this._overlays=[new b,new b]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=s(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){return e===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(w.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges(this._view.state.highlightOrderMap)&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers());for(const t of this._renderers.values())t.compact(e),this.notifyChange("updating");s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"))}compact(){let e=!1;for(const r of this._renderers.values())e=r.compact(X)||e;return e&&this.notifyChange("updating"),e}hasHighlight(e){return t(this._renderers,(r=>r.hasHighlight(e)))}processSyncDrapeSources(){this._processDrapeSources(X,(e=>e.updatePolicy===k.SYNC))}get isEmpty(){return!R.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){const e=t(this._renderers,(({hasWater:e})=>e));return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=se,++this._techniques.precompiling;const r=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.renderOccludedMask=e,r}renders(e){if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==w.Occluded&&e!==w.Highlight)return!0;if(!this._overlays)return!1;const r=this._overlays[T.INNER];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._renderContext.output;this._renderContext.output=this._renderTargets?.targets.find((r=>r.content===e))?.output??D.Color,++this._techniques.precompiling;const s=this._sortedRenderers.some((({renderer:e})=>e.precompile(this._renderContext)));return--this._techniques.precompiling,this._renderContext.output=t,s}get mode(){return this.isEmpty?C.Disabled:this.hasWater&&this.renders(w.WaterNormal)?C.EnabledWithWater:this._renderTargets?.getTexture(w.Color)?C.Enabled:C.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r&&this.parent.requestRender(j.BACKGROUND),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(t.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const e=t.output;this._renderContext.output=e,r.slot=e===D.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,e===D.Highlight&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null),t.content===w.Occluded&&(this._renderContext.renderOccludedMask=se),this._sortedRenderers.forAll((({drapeSource:e,renderer:r})=>{t.content===w.ColorNoRasterImage&&e.drapeSourceType===f.RasterImage||r.precompile(this._renderContext)})),this._renderContext.renderOccludedMask=L,r.highlightMixTexture=null}--this._techniques.precompiling}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)e.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;for(const e of this._renderTargets.targets){if(e.content===w.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const r=this._drawTarget(T.INNER,e),t=this._drawTarget(T.OUTER,e);(r||t)&&e.fbo.generateMipMap()}}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n}=r;if(this.isEmpty||n===D.Normal&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:o,_camera:a,_renderContext:h,_bindParameters:l}=this;if(a.pixelRatio=t.pixelRatio*i,h.output=n,l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,l.slot=n===D.Normal?N.DRAPED_WATER:N.DRAPED_MATERIAL,r.content===w.Occluded&&(h.renderOccludedMask=se),!this.renders(r.content))return h.renderOccludedMask=L,!1;const{resolution:d}=t,c=e===T.INNER,u=c?0:d;if(o.setViewport(u,0,d,d),this._bindTargetFBO(r),c)if(r.output!==D.Highlight)o.setClearColor(0,0,0,0),o.clear(K.COLOR);else{const{gl:e}=o;e.clearBufferuiv(e.COLOR,0,[0,0,0,0])}if(R.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==w.Occluded&&r.content!==w.Highlight){this._techniques.precompile(V,ie);const r=this._techniques.get(V,ie);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,re[e]),o.bindTechnique(r,l,this._passParameters),o.screen.draw()}if(r.output===D.Highlight){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),P(o,t,{width:s,height:s},l,(()=>this._renderAllGeometry(e,r)),u)}else this._renderAllGeometry(e,r);return o.bindFramebuffer(null),h.renderOccludedMask=L,!0}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll((({drapeSource:i,renderer:n})=>{if(r.content===w.ColorNoRasterImage&&i.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&r.output===D.Color&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(z);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}}))}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.bind(this._rctx,t,r)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}get _resolution(){return this._overlays?.[T.INNER].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),n=i>=0,o=s.renderGroup??(n?y.MapLayer:y.ViewLayer),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new ee(s,t,h))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],u(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),p(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(g(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new Z(e);i.samplingMode=J.NEAREST,this._passParameters.texture=new Q(this._rctx,i,t)}get test(){}};e([d()],$.prototype,"hasHighlights",void 0),e([d()],$.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([d({constructOnly:!0})],$.prototype,"parent",void 0),e([d({readOnly:!0})],$.prototype,"_techniques",null),e([d({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([d()],$.prototype,"isEmpty",null),e([d({readOnly:!0})],$.prototype,"rendersOccludedDraped",null),$=e([c("esri.views.3d.terrain.OverlayRenderer")],$);class ee{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const re=[[1,.5,.5],[.5,.5,1]],te=-2,se=W.OccludeAndTransparent,ie=new H;ie.hasAlpha=!0;export{$ as OverlayRenderer,te as drapedZ,se as overlayRenderOccludedFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{j as i,F as s,H as o,d as a,n,f as l,a as d,G as g}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as x}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as v}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as E}from"./TerrainConst.js";import{enableTerrainInternalChecks as $,internalAssert as S,neighborEdgeIndices as C,oppositeEdge as D,neighborCornerIndices as b,v32s as T,lij2s as j}from"./terrainUtils.js";import{TextureFader as R,ActivationTime as A}from"./TextureFader.js";import{TextureReference as V}from"./TextureReference.js";import w from"./TileOverlayData.js";import{fallsWithinLayerView as N}from"./tileUtils.js";import{VertexArrayObject as F}from"../webgl-engine/lib/VertexArrayObject.js";import{vertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as G}from"../../webgl/BufferObject.js";import{PixelFormat as O}from"../../webgl/enums.js";class I{constructor(){this.geometry=new v,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new R((()=>this._tile.surface.fadeDuration)),this.overlay=new w,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),$&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)S(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=C[e];if(!t)return S(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(S(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}S(!t.leaf);let a=i;return t.forAllSubtreeOnSide(D(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(S(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(C[a],i),l=q(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==q(e,g),m=o[a]!==d;$&&n&&(S(e.level>=n.level),S(e.level-n.level<=E)),s[a]=n,(h||m)&&(o[a]=d,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);S(t(c)),S(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(b[t],i);r.cornerPeerNeighbors[t]=o;const a=q(e,s[t]),n=q(e,s[(t+1)%4]),l=q(e,o);W[t]=l,W[(t+1)%4]=n,W[(t+2)%4]=e,W[(t+3)%4]=a,S(W.some((t=>t?.loaded||t===e)));const d=W.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);W.forEach(((e,t)=>{e&&e?.level>d&&(W[t]=null)})),S(W.some((t=>t?.loaded||t===e)));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=W[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}$&&S(te.some((r=>g[4*t+r]?.loaded||g[4*t+r]===e)))}$&&S(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)W[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;$&&S(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?O.RGBA:O.RGB;return null!=this._texture&&(r===y.FADING&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new V(this._texture,y.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&z)}get samplerDataChanged(){return!!(this._modifiedFlags&J)}get clippingAreaChanged(){return!!(this._modifiedFlags&K)}get wireframeChanged(){return!!(this._modifiedFlags&Q)}get dirtyEdges(){return this._modifiedFlags>>Y&15}get dirtyCorners(){return this._modifiedFlags>>Z&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>ee&15}_markCornerDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Z|15<<Y|15<<ee}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new F(e,P,new Map([["geometry",f(t.layout)]]),new Map([["geometry",G.createVertex(e,i.STATIC_DRAW,t.buffer)]]),G.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[x.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[x.ELEVATION][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,x.ELEVATION);if(N(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!$)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void S(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;S(0===this.dirtyCorners),S(0===this.dirtyEdges),S(0===this.dirtyEdgeResolutions),S(!this.numVerticesPerSideChanged),S(!this.samplerDataChanged),S(!this.clippingAreaChanged),S(!this.wireframeChanged);const y=b.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];S(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void S(!t)}S(x.loaded||x.level===e.level),S(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return S(!x.leaf),void S(0===v);const E=x.renderData;S(e.isEdgeNeighbor(x,r)),S(v>=0);const $=2**v;if(v<0)return void S(!1);const C=e.renderData,D=C.geometry,b=C.localOrigin,R=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void S(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;S(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),S(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=R-1,O=P-1;S(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,W=r===_.NORTH||r===_.SOUTH,q=P-1,z=q>>v,J=R-1;if(z<1)return void S(1===J);S(z===J),S(t(z));const K=V.numVerticesPerSide-1;S(v>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);S(0<=Q&&Q<$);const Y=Q*z;S(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,M,b,0),D.getEdgeVertexPosition(y,U,b,R-1);const te=i(M,U),re=Math.max(B,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=t/z,f=W?I[0]+i*(I[2]-I[0]):r===_.WEST?I[0]:I[2],p=W?r===_.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(M,U),r=o(M)-c.radius,i=o(U)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${R}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(M),r=m(U);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,M,b,Z),V.getEdgeVertexPosition(F,U,w,ee);const i=h();d(i,M,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${o(i)} [${i}]`),d(i,U,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${U} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=V.getEdgeCount(P);S(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${F}][${ee}/${l}] ${T(M)} vs ${T(U)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,k,Z),V.getEdgeNormal(F,L,ee),n(H,k),n(X,L);const _=l(H,X),$=1-_<.01||!1||e===x;if(!$){const t=h();d(t,k,L);const r=()=>`Mismatch in tile edge normal ${j(e.lij)} (${Z}/${R-1}) edge ${y} vs neighbor ${j(x.lij)} (${ee}/${P-1}) nedge ${F} :${T(k)} vs ${T(L)} dot = ${_} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),g(k,t)||console.warn("Missing update in tile normal: ",T(k)," => ",T(t)),g(L,r)||console.warn("Missing update in neighbor normal: ",T(L)," => ",T(r))}S($,r())}}Z+=1,ee+=1}}))}}const M=h(),U=h(),k=h(),L=h(),H=h(),X=h(),B=1,W=[null,null,null,null];function q(e,t){return t?.loaded||t===e?t:null}const z=1,J=2,K=4,Q=8,Y=4,Z=8,ee=12,te=[0,1,2,3];export{A as ActivationTime,I as PatchRenderData,q as neighborTileIfLoadedOrSelf,te as zeroToFour};
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{j as s,F as o,H as a,d as n,n as l,f as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as m,clone as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{TextureUpdate as x}from"./interfaces.js";import{LayerClass as _}from"./LayerClass.js";import{NeighborIndex as v}from"./NeighborIndex.js";import{PatchGeometry as E}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as $}from"./TerrainConst.js";import{enableTerrainInternalChecks as S,internalAssert as C,neighborEdgeIndices as D,oppositeEdge as b,neighborCornerIndices as T,v32s as j,lij2s as R}from"./terrainUtils.js";import{TextureFader as A,ActivationTime as V}from"./TextureFader.js";import{TextureReference as w}from"./TextureReference.js";import N from"./TileOverlayData.js";import{fallsWithinLayerView as F}from"./tileUtils.js";import{VertexArrayObject as P}from"../webgl-engine/lib/VertexArrayObject.js";import{vertexAttributeLocations as G}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as O}from"../../webgl/BufferObject.js";import{PixelFormat as I}from"../../webgl/enums.js";class M{constructor(){this.geometry=new E,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureOpacity=1,this._textureRef=new A((()=>this._tile.surface.fadeDuration)),this.overlay=new N,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)C(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=D[e];if(!t)return C(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(C(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}C(!t.leaf);let a=i;return t.forAllSubtreeOnSide(b(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(C(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(D[a],i),l=z(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==z(e,g),m=o[a]!==d;S&&n&&(C(e.level>=n.level),C(e.level-n.level<=$)),s[a]=n,(h||m)&&(o[a]=d,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);C(t(c)),C(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(T[t],i);r.cornerPeerNeighbors[t]=o;const a=z(e,s[t]),n=z(e,s[(t+1)%4]),l=z(e,o);q[t]=l,q[(t+1)%4]=n,q[(t+2)%4]=e,q[(t+3)%4]=a,C(q.some((t=>t?.loaded||t===e)));const d=q.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);q.forEach(((e,t)=>{e&&e?.level>d&&(q[t]=null)})),C(q.some((t=>t?.loaded||t===e)));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=q[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&C(re.some((r=>g[4*t+r]?.loaded||g[4*t+r]===e)))}S&&C(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)q[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&C(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?I.RGBA:I.RGB;return null!=this._texture&&(r===x.FADING&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new w(this._texture,x.FADING,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&J)}get samplerDataChanged(){return!!(this._modifiedFlags&K)}get clippingAreaChanged(){return!!(this._modifiedFlags&Q)}get wireframeChanged(){return!!(this._modifiedFlags&Y)}get dirtyEdges(){return this._modifiedFlags>>Z&15}get dirtyCorners(){return this._modifiedFlags>>ee&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>te&15}_markCornerDirty(e){const t=1<<e<<ee;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<te;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<ee|15<<Z|15<<te}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new P(e,G,new Map([["geometry",p(t.layout)]]),new Map([["geometry",O.createVertex(e,i.STATIC_DRAW,t.buffer)]]),O.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=V.Immediate){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[_.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[_.ELEVATION][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,_.ELEVATION);if(F(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void C(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const i=D.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;C(0===this.dirtyCorners),C(0===this.dirtyEdges),C(0===this.dirtyEdgeResolutions),C(!this.numVerticesPerSideChanged),C(!this.samplerDataChanged),C(!this.clippingAreaChanged),C(!this.wireframeChanged);const y=T.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];C(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}D.forEach(((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void C(!t)}C(x.loaded||x.level===e.level),C(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return C(!x.leaf),void C(0===_);const E=x.renderData;C(e.isEdgeNeighbor(x,r)),C(_>=0);const $=2**_;if(_<0)return void C(!1);const S=e.renderData,D=S.geometry,b=S.localOrigin,T=D.getEdgeCount(y),A=D.numVerticesPerSide-1,V=E.geometry;if(!V)return void C(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;C(S.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),C(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const F=(y+2)%4,P=V.getEdgeCount(F),G=T-1,O=P-1;C(G*$===O,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${F},res=${O} (expected:${G*$})`);const I=e.extent,M=r===v.NORTH||r===v.SOUTH,q=P-1,z=q>>_,J=T-1;if(z<1)return void C(1===J);C(z===J),C(t(z));const K=V.numVerticesPerSide-1;C(_>0||z===Math.max(K,A));const Q=e.getNeighborEdgeStartVertexIndex(y,x);C(0<=Q&&Q<$);const Y=Q*z;C(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,U,b,0),D.getEdgeVertexPosition(y,k,b,T-1);const te=s(U,k),re=Math.max(W,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,U,b,Z),V.getEdgeVertexPosition(F,k,w,ee);const i=t/z,s=M?I[0]+i*(I[2]-I[0]):r===v.WEST?I[0]:I[2],p=M?r===v.SOUTH?I[1]:I[3]:I[1]+i*(I[3]-I[1]),_=e.surface.extent;if(null==_||c(_,s,p)){const t=o(U,k),r=a(U)-f.radius,i=a(k)-f.radius,c=t<re;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${T}] and [${x.lij}].edge${F}[${ee}/${P}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=m();n(o,S.localOrigin,E.localOrigin),a(o)>0&&console.warn(` localOrigins: ${S.localOrigin} vs ${E.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=u(U),r=u(k);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,U,b,Z),V.getEdgeVertexPosition(F,k,w,ee);const i=m();g(i,U,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${U} d=${a(i)} [${i}]`),g(i,k,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${k} d=${a(i)} [${i}]`)})();const l=D.getEdgeCount(y),d=V.getEdgeCount(P);C(c,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${l}] vs neighbor [${x.lij}].edge[${F}][${ee}/${d}] ${j(U)} vs ${j(k)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,L,Z),V.getEdgeNormal(F,H,ee),l(X,L),l(B,H);const v=d(X,B),$=1-v<.01||!1||e===x;if(!$){const t=m();g(t,L,H);const r=()=>`Mismatch in tile edge normal ${R(e.lij)} (${Z}/${T-1}) edge ${y} vs neighbor ${R(x.lij)} (${ee}/${P-1}) nedge ${F} :${j(L)} vs ${j(H)} dot = ${v} : ${j(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=m(),r=m();D.getEdgeNormal(y,t,Z),V.getEdgeNormal(F,r,ee),h(L,t)||console.warn("Missing update in tile normal: ",j(L)," => ",j(t)),h(H,r)||console.warn("Missing update in neighbor normal: ",j(H)," => ",j(r))}C($,r())}}Z+=1,ee+=1}}))}}const U=m(),k=m(),L=m(),H=m(),X=m(),B=m(),W=1,q=[null,null,null,null];function z(e,t){return t?.loaded||t===e?t:null}const J=1,K=2,Q=4,Y=8,Z=4,ee=8,te=12,re=[0,1,2,3];export{M as PatchRenderData,z as neighborTileIfLoadedOrSelf,re as zeroToFour};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{destroyMaybe as t}from"../../../core/maybe.js";import{TextureUpdate as e}from"./interfaces.js";class i{constructor(t){this._getFadeDuration=t,this._fadeStart=0,this._delayedTime=0}clear(){this._current=t(this._current),this._next=t(this._next),this._waiting=t(this._waiting),this._delayed=t(this._delayed)}get current(){if(null==this._current)return null;if(!this._isFadingEnabled){const
|
|
5
|
+
import{destroyMaybe as t}from"../../../core/maybe.js";import{TextureUpdate as e}from"./interfaces.js";class i{constructor(t){this._getFadeDuration=t,this._fadeStart=0,this._delayedTime=0}clear(){this._current=t(this._current),this._next=t(this._next),this._waiting=t(this._waiting),this._delayed=t(this._delayed)}get current(){if(null==this._current)return null;if(!this._isFadingEnabled){const e=this._delayed||this._waiting||this._next||this._current;e!==this._current&&(this._current=t(this._current),this.clear(),this._current=e)}let s=i.test.fadeMoment;if(this._delayed&&(s=s||performance.now(),s>=this._delayedTime&&(this._push(this._delayed,n.Immediate),this._delayed=null)),this._next){s=s||performance.now();const i=this._fadeDuration,n=null!=this._current&&this._next.texture===this._current.texture,r=this._next.type!==e.FADING,a=s-this._fadeStart>=i;(n||r||a)&&(t(this._current),this._current=this._next,this._next=this._waiting,this._waiting=null,this._fadeStart=this._alignFadeStart(s))}return this._current}get next(){return this._next}get fadeFactor(){if(null==this._next)return 1;const t=i.test.fadeMoment||performance.now(),e=Math.max(0,t-this._fadeStart),n=this._fadeDuration;return e>n?0:1-e/n}get isFading(){return null!=this._next||null!=this._delayed}push(e,i=n.Immediate){this._delayed=t(this._delayed),this._push(e,i)}_push(e,s){if(this._isFadingEnabled||this.clear(),null==this._current)return void(this._current=e);const r=i.test.fadeMoment||performance.now();return s!==n.Immediate?(this._delayed=e,void(this._delayedTime=r+s)):null==this._next?(this._next=e,void(this._fadeStart=this._alignFadeStart(r))):void(null!=e&&(t(this._waiting),this._waiting=e))}get _fadeDuration(){const t=this._getFadeDuration();return this._waiting?.5*t:t}_alignFadeStart(t){const e=this._getFadeDuration();return t+e-t%e}get _isFadingEnabled(){return this._getFadeDuration()>0}static{this.test={fadeMoment:0}}}var n;!function(t){t[t.Immediate=0]="Immediate",t[t.Delayed=5e3]="Delayed"}(n||(n={}));export{n as ActivationTime,i as TextureFader};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as r,copy as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as i}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as a,isGroupLayer as n,isReferenceLayer as
|
|
5
|
+
import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as r,copy as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as i}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isBaseLayer as a,isGroupLayer as n,isReferenceLayer as u}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as c}from"../support/flowUtils.js";import{BlendLayersPassParameters as l}from"./BlendLayersTechnique.js";import{TextureUpdate as p}from"./interfaces.js";import{LayerClass as d}from"./LayerClass.js";import{NeighborIndex as m}from"./NeighborIndex.js";import{isImageWithType as h}from"./TerrainData.js";import{isBlendableLayerView as f,isVectorTileLayerView as _,isVectorTileRenderInfo as T,isImageryTileRenderInfo as x,isImageSourceRenderInfo as y,isTextureTileRenderInfo as b,isVectorTilePerLayerInfo as g}from"./terrainUtils.js";import{ActivationTime as I}from"./TextureFader.js";import{TextureReference as w}from"./TextureReference.js";import{TileCompositor as A}from"./TileCompositor.js";import{TileRenderInfo as P}from"./TileRenderInfo.js";import{TileTexture as k,getCacheKey as E}from"./TileTexture.js";import{TileUpdate as O}from"./TileUpdate.js";import{fallsWithinLayerView as j}from"./tileUtils.js";import{blendModeFromString as M}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as C}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as L}from"../webgl-engine/lib/glUtil3D.js";import{isCompressible as R}from"../../support/TextureCompressionWorkerHandle.js";import{TextureSamplingMode as N,TextureWrapMode as D,PixelFormat as B}from"../../webgl/enums.js";import{Texture as U}from"../../webgl/Texture.js";import{TextureDescriptor as S}from"../../webgl/TextureDescriptor.js";class G{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}class F{constructor(e,t,r,s,o){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._compressionHandle=o,this._passParameters=new l,this._backgroundColor=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new A(this._rctx,this._techniques)}dispose(){this._compositor=e(this._compositor),this._backgroundTexture=t(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,i=0,l=this.tileSize,m=!1,h=!1;const T=r.view.state.contentPixelRatio;let x=!1;V.clear(),X.length=0;const y=e.layerInfo[d.MAP];let b=0,g=null;for(;b<y.length;b++){const t=r.layerViewByIndex(b,d.MAP),p=t.layer,I=!j(e,t),w=p.opacity,A=t.fullOpacity;if(h=h||a(p),c(t))continue;if(f(t)){let e="normal"!==t.layer.blendMode;if(n(p.parent)){const t=p.parent.uid;null!=t&&""!==t&&(e=q(p.parent)||e)}e&&(x=e,m=!1)}if((I||0===w)&&!x){y[b].pendingUpdates&=~(O.TEXTURE_NOFADING&O.TEXTURE_FADING);continue}++i;const P=_(t),k=H(e,b,P);if(k){if(y[b].pendingUpdates&=~(O.TEXTURE_NOFADING&O.TEXTURE_FADING),n(p.parent)){const e=p.parent.uid;null!=e&&""!==e&&z(p.parent,b)}P?l=Math.max(l,this.tileSize*T):1===s&&1===A&&(t.isOpaque||this._dataToTexture(k,u(p))&&k.sourceLayerInfo.data.descriptor.isOpaque)&&(m=!0),++o,null===g&&(g=b)}}const I=l/this.tileSize;0!==o&&null!==g?1===o&&!x&&this._useLayerTexture(e,g)||this._composeLayers(e,t,b-1,h,l,I,!m||x,V,x):this._useBackgroundTexture(e,i,t!==p.FADING)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundTexture&&this._drawBackgroundTexture(this._backgroundTexture))}_ensureBackgroundTexture(){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(this.tileSize,!1),this._drawBackgroundTexture(this._backgroundTexture)),this._backgroundTexture}_drawBackgroundTexture(e){this._compositor.bind(this.tileSize),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(e),this._compositor.unbind()}_useBackgroundTexture(e,t,r){const s=e.renderData,o=!r&&null!=s.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?I.Delayed:I.Immediate,i=this._ensureBackgroundTexture();s.setTextureReference(new w(i,p.FADING,J,e.surface.baseOpacity,0,1),o)}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,d.MAP),s=a(r.layer),o=s?e.surface.baseOpacity:1,n=s?1:e.surface.baseOpacity,c=r.fullOpacity,l=H(e,t,!1);return!!this._dataToTexture(l,u(r.layer))&&(e.renderData.setTextureReference(new w(l.sourceLayerInfo.data,p.FADING,i(l.offset[0],l.offset[1],l.scale,l.scale),o,n,c)),!0)}_composeLayers(e,t,r,s,i,n,c,l,p){this._compositor.ensureBuffer(i);const m=e.surface.baseOpacity;let h=!1,y=N.LINEAR_MIPMAP_LINEAR,b=!1,g=0;for(let w=r;w>=0;w--){const t=e.surface.layerViewByIndex(w,d.MAP),r=t.layer,I=_(t),A=H(e,w,I),P=r.opacity,k=!j(e,t);if(!A||(0===P||k)&&!p)continue;const E=!a(r)&&!h;E&&(h=!0);let O=!1;l.forEach((e=>{e.start===w&&(e.output=s?C.Composite:c&&E?this.backgroundIsGrid?C.GridComposite:C.ColorComposite:C.Composite,e.baseOpacity=E?m:1,X.push(e),this._compositor.openGroup(i),O=!0)}));const L=0===g,R=O?C.GroupBackgroundComposite:c&&L?this.backgroundIsGrid?C.GridComposite:C.ColorComposite:C.Composite,D=M[f(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=E&&!O&&m<1?m:1,this._passParameters.opacity=P,T(A)?b=this._compositor.drawVectorData(this._passParameters,R,i,D,A,n,this.tileSize,b):x(A)?(this._compositor.drawRasterData(this._passParameters,R,i,D,A),v(A)&&(y=N.NEAREST)):this._dataToTexture(A,u(r))&&(this._passParameters.texture=A.sourceLayerInfo.data.texture,this._passParameters.offset=A.offset,this._passParameters.scale=A.scale,this._compositor.drawImageData(this._passParameters,R,i,D));X.length>0&&X[X.length-1].end===w;){const e=X.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,i,M[e.blendMode])}g++}const I=e.renderData,A=p||h&&m<1,P=I.ensureTexture(i,A,t,(()=>this._buildTexture(i,A,y)));this._compositor.copyFBOToTexture(P),this._compositor.unbind(),I.setTextureReference(new w(P,t,J,h?1:m,0,1))}_dataToTexture(e,t){if(y(e)){const r=e.sourceLayerInfo,s=1===e.scale&&!t;r.data=this._buildTexture(r.data,!0,s,e.tile.onCompressionFinished),e.tile.setMemoryDirty()}return b(e)}_buildTexture(e,t,r=N.LINEAR_MIPMAP_LINEAR,s=()=>{}){if(null==e)return null;const o=new S;o.wrapMode=D.CLAMP_TO_EDGE,o.samplingMode="boolean"==typeof r?N.LINEAR_MIPMAP_LINEAR:r,o.maxAnisotropy=this._maxAnisotropy,o.preMultiplyAlpha=!0,o.flipped=!0,o.hasMipmap=!0,t||(o.pixelFormat=B.RGB);const i=this._rctx,a="boolean"==typeof r&&r;let n;if("number"==typeof e)o.width=o.height=e,n=this._buildTileTexture(o);else if(h(e))o.isOpaque=e.isOpaque,o.isOpaque&&(o.pixelFormat=B.RGB),o.width=e.element.width,o.height=e.element.height,n=this._buildTileTexture(o,a,s,e.element);else try{o.width=e.width,o.height=e.height,n=this._buildTileTexture(o,a,s,e)}catch(c){n=new k(L(i)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const u=i.bindTexture(n.texture,U.TEXTURE_UNIT_FOR_UPDATES);return n.generateMipmap(),i.bindTexture(u,U.TEXTURE_UNIT_FOR_UPDATES),n}_buildTileTexture(e,t=!1,r=()=>{},s){const o=this._cache.pop(E(e,!1))??this._cache.pop(E(e,!0));if(t&&=R(s),o)return o.retain(),t?o.texture.enableCompression(this._compressionHandle,r):o.texture.disableCompression(),o.texture.setData(s),o;e.compressionHandle=t?this._compressionHandle:null,e.compressionCallback=r;const i=new U(this._rctx,e,s);return new k(i,this._cache)}get test(){}}function H(e,t,o){W.layerIndex=t,W.vtlNeighborInfos.clear();const i=e.layerInfo[d.MAP][t];if(r(W.offset,0,0),W.tile=e,W.scale=1,W.sourceLod=e.lij,W.sourceLayerInfo=i,W.isVTLBackground=o,i.data)return o&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[d.MAP][t];if(!g(o)||i.data===o.data)return;const a=W.vtlNeighborInfos.pushNew();a.offset=K[s],a.sourceLod=r.lij,a.sourceLayerInfo=o})),W;const a=i.upsampleInfo,n=a?.tile?.layerInfo[d.MAP][t];return n&&a.tile?(W.tile=a.tile,s(W.offset,a.offset),W.scale=a.scale,W.sourceLod=a.tile.lij,W.sourceLayerInfo=n,W):o?W:null}function v(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function q(e){let t="normal"!==e.blendMode;return n(e.parent)&&(t=q(e.parent)||t),t}function z(e,t){n(e.parent)&&z(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=V.get(r);s?s.start=t:V.set(r,new G(t,t,e.blendMode,e.opacity,C.Composite,1))}}const V=new Map,X=new Array,W=new P,J=i(0,0,1,1),K=new Array;K[m.NORTH]=[0,-1],K[m.NORTH_EAST]=[-1,-1],K[m.EAST]=[-1,0],K[m.SOUTH_EAST]=[-1,1],K[m.SOUTH]=[0,1],K[m.SOUTH_WEST]=[1,1],K[m.WEST]=[1,0],K[m.NORTH_WEST]=[1,-1];export{G as GroupInfo,F as TileRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{ResourceType as t}from"../../webgl/enums.js";import{isCompressedFormat as e}from"../../webgl/textureUtils.js";class r{constructor(e,r){this._texture=e,this._cache=r,this.type="tile-texture",this._refCount=1,this._texture.descriptor.context.instanceCounter.increment(t.TileTexture,this)}retain(){++this._refCount}release(){--this._refCount,0===this._refCount&&(this._cache?(this._texture.isCompressing&&this._texture.abortCompression(),this._cache.put(i(this.descriptor),this)):this.dispose())}dispose(){this._texture.descriptor.context.instanceCounter.decrement(t.TileTexture,this),this._texture.dispose()}get texture(){return this._texture}generateMipmap(){this._texture.generateMipmap()}get descriptor(){return this._texture.descriptor}get cachedMemory(){return this._texture.usedMemory}}function i(t,r=e(t.internalFormat)){return`${t.width} ${t.pixelFormat} ${r}`}export{r as TileTexture,i as getCacheKey};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{SizedDepthFormat as R}from"../../webgl/enums.js";var
|
|
5
|
+
import{SizedDepthFormat as R}from"../../webgl/enums.js";var A;!function(R){R[R.R8=33321]="R8",R[R.R8UI=33330]="R8UI",R[R.RG8=33323]="RG8",R[R.RG8UI=33336]="RG8UI",R[R.RGBA4=32854]="RGBA4",R[R.RGBA8=32856]="RGBA8",R[R.RGBA8_MIPMAP=42843]="RGBA8_MIPMAP",R[R.R16F=33325]="R16F",R[R.RGBA16F=34842]="RGBA16F",R[R.RGBA16F_NEAREST=44570]="RGBA16F_NEAREST"}(A||(A={}));const G=R.DEPTH_COMPONENT16;export{A as ColorFormat,G as DepthRenderbuffer16f};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{signal as i}from"../../../core/signal.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as d}from"../state/helpers/SceneIntersectionHelper.js";import{TextureCollection as a}from"../support/TextureCollection.js";import{ChangeSet as h}from"./lib/ChangeSet.js";import{UpdatePolicy as c}from"./lib/UpdatePolicy.js";import{isWebGLLayer as y}from"./lib/WebGLLayer.js";import{Model as m}from"./parts/Model.js";import{RenderView as l}from"./parts/RenderView.js";import{TaskPriority as p,noBudget as u}from"../../support/Scheduler.js";import{Yield as _}from"../../support/Yield.js";let g=class extends t{constructor(e){super(e),this._model=new m,this._canCompact=i(!1),this._layers=new r,this._asyncChangeSet=new h,this._syncChangeSet=new h,this._layerSyncSet=new Set,this.textures=new a(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(p.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new l({stage:this})}destroy(){this.textures.destroy(),this.renderView.destroy()}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating||this.textures.updating}get renderView(){return this._renderView}get renderer(){return this.renderView.renderer}add(e){this._model.add(e),y(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null!=e&&!this.destroyed&&this._model.remove(e)&&(y(e)&&this._removeLayer(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView.requestRender())}forEachOfType(e,t){this._model.forEachOfType(e,t)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return _}compact(){return this._canCompact.value=!1,this.renderer.compact(u)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||r.updatePolicy===c.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.modify(i,s?u:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,u),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{e.done||this._layerSyncSet.has(r.id)||r.updatePolicy!==c.ASYNC||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((t=>{this._layerSyncSet.has(t.id)||t.updatePolicy===c.SYNC?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)}));for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,u),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,u),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||this._layers.push(e)}_removeLayer(e){this._commitLayer(e),null!=this._layers.removeUnordered(e)&&(this._model.dirtySet.getResidentRenderGeometries(e.id,this._syncChangeSet.removes),this.renderer.modify(this._syncChangeSet,u))}addRenderPlugin(e,t){const r=this.renderer.plugins.add(e,t),i=()=>{d(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(r))return r.then(i);i()}removeRenderPlugin(e){this.destroyed||(d(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get performanceInfo(){return this._model.getStats()}get test(){}};e([n({constructOnly:!0})],g.prototype,"view",void 0),e([n({constructOnly:!0})],g.prototype,"options",void 0),e([n({readOnly:!0})],g.prototype,"viewingMode",null),e([n({constructOnly:!0})],g.prototype,"container",void 0),e([n({readOnly:!0})],g.prototype,"updating",null),e([n({constructOnly:!0})],g.prototype,"_model",void 0),e([n()],g.prototype,"_renderView",void 0),e([n({readOnly:!0})],g.prototype,"renderer",null),e([n()],g.prototype,"textures",void 0),e([n({readOnly:!0})],g.prototype,"running",null),g=e([o("esri.views.3d.webgl-engine.Stage")],g);export{g as Stage};
|