@arcgis/core 4.33.0-next.20250317 → 4.33.0-next.20250319
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/0b7331613f91a3258352.js +1 -0
- package/assets/esri/core/workers/chunks/2219d970ece5676ca6ee.js +1 -0
- package/assets/esri/core/workers/chunks/3fc18638f8799b85001d.js +1 -0
- package/assets/esri/core/workers/chunks/630a9afdf0523c27ddb6.js +1 -0
- package/assets/esri/core/workers/chunks/657ae4a0461d45044b28.js +1 -0
- package/assets/esri/core/workers/chunks/{23aa7254fffe67e3f1bc.js → 6a97bdd46715fc12e1b4.js} +239 -160
- package/assets/esri/core/workers/chunks/8063e35dacf8f99471d8.js +1 -0
- package/assets/esri/core/workers/chunks/8e20ec4e8e2cfc582fe7.js +319 -0
- package/assets/esri/core/workers/chunks/c528a2ca3b1b73df5a5d.js +1 -0
- package/assets/esri/core/workers/chunks/d787474e78360c925fd9.js +1 -0
- package/assets/esri/core/workers/chunks/{7ded83eb64eff069b761.js → d8b903b4147b090576f2.js} +1 -1
- package/assets/esri/core/workers/chunks/e4290719c8afc2a4ee8c.js +1 -0
- package/assets/esri/core/workers/chunks/e5e1f8ac53c70427a60b.js +1 -0
- package/assets/esri/core/workers/chunks/fc9758006a7135c7d9c3.js +1 -0
- package/assets/esri/core/workers/chunks/fef46b841e8369b30227.js +1 -0
- package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
- package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationLayers.scss +20 -0
- 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/HUDMaterial.glsl.js +80 -75
- package/chunks/RibbonLine.glsl.js +37 -37
- package/chunks/ShadowCastAccumulate.glsl.js +5 -21
- package/chunks/ShadowHighlight.glsl.js +8 -30
- package/chunks/Terrain.glsl.js +33 -34
- package/copyright.txt +29 -0
- package/core/has.js +1 -1
- package/core/typedArrayUtil.js +1 -1
- package/geometry/support/HalfFloatArray.js +5 -0
- package/geometry/support/buffer/BufferView.js +1 -1
- package/geometry/support/buffer/types.js +1 -1
- package/geometry/support/densifyUtils.js +1 -1
- package/interfaces.d.ts +18 -40
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/package.json +2 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
- package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
- package/views/2d/layers/graphics/densificationConstants.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.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/pipeline/rendering/LodRenderer.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/support/buffer/glUtil.js +1 -1
- package/views/3d/terrain/PatchGeometry.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/TerrainAttributes.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js +2 -9
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +4 -3
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +125 -40
- package/views/3d/webgl-engine/lib/AttributeArray.js +1 -1
- package/views/3d/webgl-engine/lib/DefaultVertexAttributeLocations.js +1 -1
- package/views/3d/webgl-engine/lib/DefaultVertexBufferLayouts.js +1 -1
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/VertexAttribute.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
- package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ReadShadowMapConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/widgets/Editor/AddAssociationWorkflow.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
- package/widgets/Features/FeaturesDrillIn.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/Print/TemplateOptions.js +1 -1
- package/widgets/support/LabeledSwitch.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/048121d433aa9175348c.js +0 -1
- package/assets/esri/core/workers/chunks/0f4a2bdf5bb2f4303b7f.js +0 -1
- package/assets/esri/core/workers/chunks/147e412de9972da16a1d.js +0 -1
- package/assets/esri/core/workers/chunks/1545bd7d6ac7800c71b6.js +0 -1
- package/assets/esri/core/workers/chunks/2b21152c7e2d9c170ed7.js +0 -1
- package/assets/esri/core/workers/chunks/385dd6466fd967ce3ae9.js +0 -1
- package/assets/esri/core/workers/chunks/8d636075e5aa053940fc.js +0 -1
- package/assets/esri/core/workers/chunks/c43c273725b1a33712ec.js +0 -314
- package/assets/esri/core/workers/chunks/c8cd9a3175f516624842.js +0 -1
- package/assets/esri/core/workers/chunks/d630e64463687090db92.js +0 -1
- package/assets/esri/core/workers/chunks/dd6f18bbab50be139d20.js +0 -1
- package/assets/esri/core/workers/chunks/de6864e120243cf0bee8.js +0 -1
|
@@ -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 has from"../../../../../../core/has.js";import{throwIfAborted as r}from"../../../../../../core/promiseUtils.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import"../../../../../../core/Error.js";import{subclass as s}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{VertexAttribute as n}from"../../../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as t}from"../../../../webgl-engine/lib/lodRendering/LodRenderer.js";import{LodComponentRenderGeometry as o,LodComponentResources as i,LodLevelResources as a,LodResources as d}from"../../../../webgl-engine/lib/lodRendering/LodResources.js";let l=class{constructor(e){this._optionalFields=new Array,this._instanceGroupToIndices=new Map,this._instanceIndexToFeatureId=new Map,this._disposeResourceHandles=new Array,this._lodRendererResources=null,this._numFeatures=0,this.layerUid=e.layerUid,this.view=e.view,this.sharedResources=this.view.sharedSymbolResources,this.scheduler=this.view.resourceController.scheduler}get numFeatures(){return this._numFeatures}get usedMemory(){const e=this._lodRendererResources?.lodRenderer,r=e?.symbol;return(r?.computeUsedMemory()??0)+16*this._instanceIndexToFeatureId.size}destroy(){this._disposeResourceHandles.forEach((e=>e()))}async doLoad(e,s,t){has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(n.
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{throwIfAborted as r}from"../../../../../../core/promiseUtils.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import"../../../../../../core/Error.js";import{subclass as s}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{VertexAttribute as n}from"../../../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as t}from"../../../../webgl-engine/lib/lodRendering/LodRenderer.js";import{LodComponentRenderGeometry as o,LodComponentResources as i,LodLevelResources as a,LodResources as d}from"../../../../webgl-engine/lib/lodRendering/LodResources.js";let l=class{constructor(e){this._optionalFields=new Array,this._instanceGroupToIndices=new Map,this._instanceIndexToFeatureId=new Map,this._disposeResourceHandles=new Array,this._lodRendererResources=null,this._numFeatures=0,this.layerUid=e.layerUid,this.view=e.view,this.sharedResources=this.view.sharedSymbolResources,this.scheduler=this.view.resourceController.scheduler}get numFeatures(){return this._numFeatures}get usedMemory(){const e=this._lodRendererResources?.lodRenderer,r=e?.symbol;return(r?.computeUsedMemory()??0)+16*this._instanceIndexToFeatureId.size}destroy(){this._disposeResourceHandles.forEach((e=>e()))}async doLoad(e,s,t){has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(n.OLIDCOLOR);const o=c((e=>s(e)),e),i=this.view.stage,a=o.getMaterials();i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const d=o.getTextures();i.addMany(d),this._addDisposeResource((()=>{d.forEach((e=>e.unload())),i.removeMany(d)})),await Promise.all(d.map((e=>this.view.stage.schedule((()=>e.load(i.renderView.renderingContext)),t)))),r(t);const l=await this._createLodRenderer(o,t);this._lodRendererResources={lodRenderer:l,materials:a,textures:d}}addInstances(e,r){const s=this._lodRendererResources;if(null==s)return;const n=s.lodRenderer;if(null==n)return;const{featureIds:t,localTransforms:o,globalTransforms:i,visibility:a}=r,d=new Array,l=n.instanceData,c=t.length,u=this._instanceIndexToFeatureId;for(let h=0;h<c;++h){const e=t[h],r=l.addInstance(),s=l.view,n=16*h;s.localTransform.copyFromTypedBuffer(r,o,n),s.globalTransform.copyFromTypedBuffer(r,i,n),l.updateModelTransform(r),l.setVisible(r,Boolean(a[h])),d.push(r),u.set(r,e)}this._instanceGroupToIndices.set(e,d),this._numFeatures+=c}removeInstances(e){const r=this._instanceGroupToIndices.get(e);if(null==r)return;const s=this._lodRendererResources;if(null==s)return;const n=s.lodRenderer.instanceData,t=this._instanceIndexToFeatureId;for(const o of r)n.removeInstance(o),t.delete(o);this._numFeatures-=r.length,this._instanceGroupToIndices.delete(e)}updateVisibility(e,r){const s=this._instanceGroupToIndices.get(e);if(null==s)return;const n=this._lodRendererResources;if(null==n)return;const t=s.length;if(t!==r.length)throw new Error("Unexpected mismatch instance count and visibility flag buffer length.");const o=n.lodRenderer.instanceData;for(let i=0;i<t;++i)o.setVisible(s[i],Boolean(r[i]))}updateGlobalTransforms(e,r){const s=this._instanceGroupToIndices.get(e);if(null==s)return;const n=this._lodRendererResources;if(null==n)return;const t=s.length;if(16*t!==r.length)throw new Error("Unexpected mismatch instance count and visibility flag buffer length.");const o=n.lodRenderer.instanceData,i=o.view;for(let a=0;a<t;++a){const e=s[a],n=16*a;i.globalTransform.copyFromTypedBuffer(e,r,n),o.updateModelTransform(e)}}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createLodRenderer(e,r){const s=this.view.stage,n={layerUid:this.layerUid,graphicUid:e=>this._instanceIndexToFeatureId.get(e)??-1,notifyGraphicGeometryChanged:e=>1,notifyGraphicVisibilityChanged:e=>1},o=new t({symbol:e,optionalFields:this._optionalFields,metadata:n,shaderTransformation:null},this.scheduler);return o.slicePlaneEnabled=!1,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,r),o}};function c(e,r){const s=r.levels.map((r=>{const s=r.components.map((r=>{const s=e(r.materialId);if(!u(s))throw new Error("LodRenderer only supports DefaultMaterial");const n=new o(s,r.renderGeometryBuffer.data,r.renderGeometryBuffer.elementCount,r.boundingInfo);return new i(n)}));return new a(s,r.minScreenSpaceRadius)}));return new d(s)}function u(e){return null!=e&&"materialType"in e&&"default"===e.materialType}l=e([s("esri.views.3d.layers.graphics.pipeline.rendering.LodRenderer")],l);export{l as LodRenderer,u as isDefaultMaterial};
|
|
@@ -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 e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as r}from"../../../../core/MemCache.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{p as a}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{isRelativeVertexSpace as
|
|
5
|
+
import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as r}from"../../../../core/MemCache.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{p as a}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{isRelativeVertexSpace as c}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{l as u}from"../../../../chunks/sphere.js";import{CachedMeshData as m}from"./CachedMeshData.js";import{convertMeshMaterialToPBRMaterial as h}from"./I3SClientMaterialUtil.js";class f{constructor(e,t,r,o){this._uid=e,this._worker=o,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._memCache=r.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const r=`mesh${t}`,o=e.extent,n=o.spatialReference,s=this._indexSR,i=x(o,e.origin);d(i,n,i,s);return{type:"mesh",id:r,version:w(e),oid:t,mbs:i,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,r){if(null!=this.getMeshNodeIndex(r.oid))throw new e(`I3SClientNodeLoader: client side mesh for feature oid=${r.oid} already exists`);r.nodeIndex=t,this._id2Meta.set(r.id,r),this._oid2Meta.set(r.oid,r)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}getMeshNodeInfo(e){const t=this._oid2Meta.values();for(const r of t)if("mesh"===r.type&&r.id===e)return r;return null}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const r=this._id2Meta.get(t);if(null==r)throw new e(`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(r.type){case"mesh":return this._loadMeshNodeJSON(r);case"mesh-component":return p(r);default:throw new e(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,r=(await this._getMeshData(e)).loadedMesh;if(null==r.components||0===r.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const o=[],n=r.components;for(let s=0;s<n.length;++s){const r=`${t}-component${s}`,n={type:"mesh-component",id:r,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(r),o.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:o}}updateNodeIndex(e,t,r){const o=this._id2Meta.get(e);o&&"mesh"===o.type&&(o.nodeIndex=r)}async loadNodeData(r,n){const s=this._id2Meta.get(r);if(null==s||"mesh-component"!==s.type)throw new e(`Failed to load client node data for node ${r} (unexpected node info)`);const i=s.meshNodeInfo,a=await this._getMeshData(i),l=a.loadedMesh,d=i.oid;if(null==l.components)throw new e(`Failed to load client node data for node ${r} (unexpected null reference)`);const c=l.components[s.componentIndex],{material:u,requiredTextures:m,textureData:f}=await h(c.material);if(null!=f)for(const e of f)null!=e&&s.textureData.set(e.id,e);const p={params:{material:u},type:"ArrayBufferView"},{vertexSpace:x,origin:M,transform:w}=l,S=[M.x,M.y,M.z??0];a.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),a.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:w?.localMatrix,vertexSpace:x.toJSON(),origin:S,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON()},n));const{projected:b,original:_,projectedOrigin:N}=await a.projectionPromise;l.vertexAttributes.position=_;const{transformed:v,original:D}=await y(c,a,this._worker,n);l.vertexAttributes.normal=D,o(n);const{geometryBuffer:R,geometryDescriptor:j}=g(b,c.faces,v,l.vertexAttributes.uv,l.vertexAttributes.color,d);return{geometryData:{featureDataPosition:N,featureIds:[],geometries:[p]},attributeDataInfo:{attributeData:{},loadedAttributes:[]},geometryBuffer:R,geometryDescriptor:j,requiredTextures:m,textureData:f,normalReferenceFrame:this._vertexSR.isGeographic?"east-north-up":"vertex-reference-frame"}}async loadAttributes(e,t,r){const o=e.numFeatures,n={};for(const{field:{name:s}}of t)n[s]=new Array(o);return n}async loadTextures(e,t,r){const o=e.id,n=this._id2Meta.get(o);if(null==n||"mesh-component"!==n.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const i of t)s.push(n.textureData.get(i.id)||null);return s}async _getMeshData(e){const t=e.version,o=this._memCache.get(t);if(null==o){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const o=async(o,n)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(a){n(a)}const i=new m(s);this._memCache.put(t,i,r),e.loadMeshPromise=null,o(i)};return e.loadMeshPromise=new Promise(((e,t)=>o(e,t))),e.loadMeshPromise}return o}}async function p(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}function x(e,t){const{spatialReference:r}=e,o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],s=r.isGeographic?r.metersPerUnit:1,i=e.center;let a=0;if(e.hasZ)for(let l=0;l<2;++l)for(let e=0;e<2;++e)for(let r=0;r<2;++r){const d=(i.x+o[l]*n[0]-t.x)*s,c=(i.y+o[e]*n[1]-t.y)*s,u=i.z+o[r]*n[2]-t.z;a=Math.max(d*d+c*c+u*u,a)}else for(let l=0;l<2;++l)for(let e=0;e<2;++e){const r=(i.x+o[l]*n[0]-t.x)*s,d=(i.y+o[e]*n[1]-t.y)*s;a=Math.max(r*r+d*d,a)}return u([t.x,t.y,t.z],Math.sqrt(a))}async function y(e,r,o,n){const{transform:d,vertexAttributes:c}=r.loadedMesh,u="source"===e.shading?c.normal:null;if(!(null!=u&&null!=d&&(0!==d.rotationAngle||!a(d.scale,l))))return{transformed:u,original:c.normal};if(!r.normalsTransformPromise){t(o,"SceneLayerWorker is needed to transform mesh normals");const e=i();s(e,d.localMatrix),r.normalsTransformPromise=o.transformNormals({normalMatrix:e,normals:u},n)}return r.normalsTransformPromise}function g(e,t,r,o,n,s){const i=1,a=(t?.length??0)/3,l=3*a;let d=0,c=0,u=!1,m=0,h=!1,f=0,p=!1,x=0,y=0,g=0;d+=S,d+=S,c=d,d+=3*l*b,null!=r&&(u=!0,m=d,d+=3*l*b),null!=o&&(h=!0,f=d,d+=2*l*b),null!=n&&(p=!0,x=d,d+=4*l*_),y=d,d+=i*N,g=d,d+=2*i*S;const w=new ArrayBuffer(d),v=new Uint8Array(w);M(v,0,l),M(v,S,i);const D=new Float32Array(w,c),R=null!=r?new Float32Array(w,m):null,j=null!=o?new Float32Array(w,f):null,I=null!=n?new Uint8Array(w,x):null;for(let M=0;M<a;++M){const s=3*M;for(let i=0;i<3;++i){const a=t[s+i],l=3*a,d=9*M+3*i;if(D[d]=e[l],D[d+1]=e[l+1],D[d+2]=e[l+2],R&&(R[d]=r[l],R[d+1]=r[l+1],R[d+2]=r[l+2]),j){const e=2*a,t=6*M+2*i;j[t]=o[e],j[t+1]=o[e+1]}if(I){const e=4*a,t=12*M+4*i;I[t]=n[e],I[t+1]=n[e+1],I[t+2]=n[e+2],I[t+3]=n[e+3]}}}M(v,y,s),M(v,y+S,s/2**32),M(v,g,0),M(v,g+S,a-1);return{geometryBuffer:w,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:u,uv0:h,uvRegion:!1,featureIndex:!0}}}function M(e,t,r){e[t]=255&r,e[t+1]=255&r>>8,e[t+2]=255&r>>16,e[t+3]=255&r>>24}function w(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const r=t;let o="";for(const n of r)o+=n.makeHash();return o+JSON.stringify(e.transform?.toJSON()??"")+(c(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):"")+JSON.stringify(e.spatialReference)}const S=4,b=4,_=1,N=8;export{f as I3SClientNodeLoader,x as createSphereFromExtent,b as sizeOfFloat32,S as sizeOfInt32,N as sizeOfUInt64,_ as sizeOfUInt8,y as transformNormals};
|
|
@@ -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{BufferViewVec2f16 as e,BufferViewVec2f as t,BufferViewVec2f64 as i,BufferViewVec3f as s,BufferViewVec3f64 as r,BufferViewVec4f as n,BufferViewVec4f64 as h,BufferViewMat3f as d,BufferViewMat3f64 as u,BufferViewMat4f as f,BufferViewMat4f64 as o,BufferViewVec4u8 as l,BufferViewFloat as p,BufferViewFloat64 as c,BufferViewUint8 as a,BufferViewUint16 as _,BufferViewInt8 as y,BufferViewVec2i8 as F,BufferViewVec2i16 as m,BufferViewVec2u8 as b,BufferViewVec4u16 as g,BufferViewUint32 as w,BufferViewVec3u8 as v,BufferViewVec2u16 as E,BufferViewVec3u16 as M,BufferViewVec2u32 as T,BufferViewVec3u32 as A,BufferViewVec4u32 as B,BufferViewVec3i8 as U,BufferViewVec4i8 as C,BufferViewInt16 as L,BufferViewVec3i16 as j,BufferViewVec4i16 as x,BufferViewInt32 as z,BufferViewVec2i32 as $,BufferViewVec3i32 as V,BufferViewVec4i32 as k}from"../../../../geometry/support/buffer/BufferView.js";import{elementTypeSize as q}from"../../../../geometry/support/buffer/types.js";import{assert as D}from"../../webgl-engine/lib/Util.js";class G{constructor(e,t){this.layout=e,this.buffer="number"==typeof t?new ArrayBuffer(t*e.stride):t;for(const i of e.fields.keys()){const t=e.fields.get(i);this[i]=new t.constructor(this.buffer,t.offset,this.stride)}}get stride(){return this.layout.stride}get count(){return this.buffer.byteLength/this.stride}get byteLength(){return this.buffer.byteLength}getField(e,t){const i=this[e];return i&&i.elementCount===t.ElementCount&&i.elementType===t.ElementType?i:null}slice(e,t){return new G(this.layout,this.buffer.slice(e*this.stride,t*this.stride))}copyFrom(e,t=0,i=0,s=e.count){const r=this.stride;if(r%4==0){const n=new Uint32Array(e.buffer,t*r,s*r/4);new Uint32Array(this.buffer,i*r,s*r/4).set(n)}else{const n=new Uint8Array(e.buffer,t*r,s*r);new Uint8Array(this.buffer,i*r,s*r).set(n)}return this}get cachedMemory(){return this.byteLength}dispose(){}}class H{constructor(e){this._stride=0,this._fields=new Map,e&&(this._stride=e.stride,e.fields.forEach((e=>this._fields.set(e[0],{...e[1],constructor:O(e[1].constructor)}))))}freeze(){return this}vec2f16(t,i){return this._appendField(t,e,i),this}vec2f(e,i){return this._appendField(e,t,i),this}vec2f64(e,t){return this._appendField(e,i,t),this}vec3f(e,t){return this._appendField(e,s,t),this}vec3f64(e,t){return this._appendField(e,r,t),this}vec4f(e,t){return this._appendField(e,n,t),this}vec4f64(e,t){return this._appendField(e,h,t),this}mat3f(e,t){return this._appendField(e,d,t),this}mat3f64(e,t){return this._appendField(e,u,t),this}mat4f(e,t){return this._appendField(e,f,t),this}mat4f64(e,t){return this._appendField(e,o,t),this}vec4u8(e,t){return this._appendField(e,l,t),this}f32(e,t){return this._appendField(e,p,t),this}f64(e,t){return this._appendField(e,c,t),this}u8(e,t){return this._appendField(e,a,t),this}u16(e,t){return this._appendField(e,_,t),this}i8(e,t){return this._appendField(e,y,t),this}vec2i8(e,t){return this._appendField(e,F,t),this}vec2i16(e,t){return this._appendField(e,m,t),this}vec2u8(e,t){return this._appendField(e,b,t),this}vec4u16(e,t){return this._appendField(e,g,t),this}u32(e,t){return this._appendField(e,w,t),this}_appendField(e,t,i){if(this._fields.has(e))return void D(!1,`${e} already added to vertex buffer layout`);const s=t.ElementCount*q(t.ElementType),r=this._stride;this._fields.set(e,{constructor:t,size:s,offset:r,optional:i}),this._alignFields()}_alignFields(){let e=0,t=1;this._fields.forEach((i=>{const s=q(i.constructor.ElementType);e=Math.floor((e+s-1)/s)*s,i.offset=e,e+=i.size,t=Math.max(t,s)})),e=Math.floor((e+t-1)/t)*t,this._stride=e}createBuffer(e){return new G(this,e)}createView(e){return new G(this,e)}clone(){const e=new H;return e._stride=this._stride,e._fields=new Map,this._fields.forEach(((t,i)=>e._fields.set(i,t))),e.BufferType=this.BufferType,e}get stride(){return this._stride}get fields(){return this._fields}}function I(){return new H}class J{constructor(e){this.fields=new Array,e.fields.forEach(((e,t)=>{const i={...e,constructor:N(e.constructor)};this.fields.push([t,i])})),this.stride=e.stride}}const K=[p,t,s,n,d,f,c,i,r,h,u,o,a,b,v,l,_,E,M,g,w,T,A,B,y,F,U,C,L,m,j,x,z,$,V,k];function N(e){return`${e.ElementType}_${e.ElementCount}`}function O(e){return P.get(e)}const P=new Map;K.forEach((e=>P.set(N(e),e)));export{G as InterleavedBuffer,H as InterleavedLayout,J as PackedLayout,I as newLayout};
|
|
@@ -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{DataType as e}from"../../../webgl/enums.js";import{VertexElementDescriptor as r}from"../../../webgl/VertexElementDescriptor.js";function t(e,t=0){const n=e.stride;return Array.from(e.fields.keys()).map((s=>{const i=e.fields.get(s),
|
|
5
|
+
import{DataType as e}from"../../../webgl/enums.js";import{VertexElementDescriptor as r}from"../../../webgl/VertexElementDescriptor.js";function t(e,t=0){const n=e.stride;return Array.from(e.fields.keys()).map((s=>{const i=e.fields.get(s),f=i.constructor.ElementCount,u=o(i.constructor.ElementType),c=i.offset,m=i.optional?.glNormalized??!1;return new r(s,f,u,c,n,m,t)}))}function o(e){const r=n[e];if(r)return r;throw new Error("BufferType not supported in WebGL")}const n={u8:e.UNSIGNED_BYTE,u16:e.UNSIGNED_SHORT,u32:e.UNSIGNED_INT,i8:e.BYTE,i16:e.SHORT,i32:e.INT,f16:e.HALF_FLOAT,f32:e.FLOAT};export{t as glLayout};
|
|
@@ -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{releaseMaybe as t}from"../../../core/maybe.js";import{g as e}from"../../../chunks/vec32.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{internalAssert as i}from"./terrainUtils.js";import{decompressNormal as r,compressNormal as n}from"../webgl-engine/lib/Normals.js";class
|
|
5
|
+
import{releaseMaybe as t}from"../../../core/maybe.js";import{g as e}from"../../../chunks/vec32.js";import{empty as s}from"../../../geometry/support/aaBoundingBox.js";import{internalAssert as i}from"./terrainUtils.js";import{decompressNormal as r,compressNormal as n}from"../webgl-engine/lib/Normals.js";class d{constructor(){this.indices=null,this.indexCount=0,this.edgeIndicesStartIndex=0,this.poleIndicesStartIndex=0,this.vertexAttributes=null,this.edgeVerticesStartIndex=0,this.poleVerticesStartIndex=0,this.maxEdgeVertexCount=0,this.boundingBox=s(),this.numVerticesPerSide=0,this.minu=0,this.minv=0,this.maxu=1,this.maxv=1,this.outerEdgesOffsetAndLength=[0,0,0,0,0,0,0,0]}release(){this.vertexAttributes=t(this.vertexAttributes),this.indices=null}reset(){this.indices=null,this.vertexAttributes=null,s(this.boundingBox),this.numVerticesPerSide=0}getEdgeFirstVertexIndex(t){return this.outerEdgesOffsetAndLength[2*t]}getEdgeCount(t){return this.outerEdgesOffsetAndLength[2*t+1]}getEdgeVertexIndex(t,e){return this.getEdgeAttributeIndex(t,e)}getEdgeVertexPosition(t,s,i,r){this._getEdgeVertexRaw(this.getEdgeAttributeIndex(t,r),s),e(s,s,i)}getEdgeNormal(t,e,s){const{typedBuffer:i,typedBufferStride:n}=this.vertexAttributes.normalCompressed;r(e,i,this.getEdgeAttributeIndex(t,s),n)}setEdgeNormalFromValues(t,e,s,i,r){this._setNormal(this.getEdgeAttributeIndex(t,e),s,i,r)}setEdgeVertexFromValuesRawPositionUV(t,e,s,i,r,n,d){const o=this.getEdgeAttributeIndex(t,e);this.vertexAttributes.position.setValues(o,s,i,r),this._setUV(o,n,d)}setEdgeVertexFromValuesRawPositionUVNormal(t,e,s,i,r,n,d,o,u,g){const h=this.getEdgeAttributeIndex(t,e);this.vertexAttributes.position.setValues(h,s,i,r),this._setUV(h,n,d),this._setNormal(h,o,u,g)}_getEdgeVertexRaw(t,e){this.vertexAttributes.position.getVec(t,e)}_setNormal(t,e,s,i){const{typedBuffer:r,typedBufferStride:d}=this.vertexAttributes.normalCompressed;n(r,t,e,s,i,d)}_setUV(t,e,s){this.vertexAttributes.uv0.setValues(t,e,s)}getEdgeAttributeIndex(t,e){return i(0<=e&&e<this.getEdgeCount(t)),this.getEdgeFirstVertexIndex(t)+e}}export{d as PatchGeometry};
|
|
@@ -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{isPowerOfTwo as e,clamp as t}from"../../../core/mathUtils.js";import{empty as n}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as o}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as s}from"./ElevationData.js";import{PatchType as r}from"./interfaces.js";import{NeighborIndex as i}from"./NeighborIndex.js";import{encodeUVInBuffer as a}from"./PatchGeometry.js";import{PatchGeometryLUT as c}from"./PatchGeometryLUT.js";import{neighborTileIfLoadedOrSelf as l,zeroToFour as u}from"./PatchRenderData.js";import{internalAssert as d,enableTerrainInternalChecks as f,neighborEdgeIndices as m,almostEquals as g}from"./terrainUtils.js";import{isCornerNeighbor as p}from"./Tile.js";import{compareTilesByLij as x}from"./tileUtils.js";import{compressNormal as h}from"../webgl-engine/lib/Normals.js";const M=65536;function S(e,t){const{tile:o,geometry:s,geometryState:i}=e,{extentInRadians:a,surface:c}=o,{isWebMercator:l,renderer:u}=c,{numVerticesPerSide:d,wireframe:f}=i,m=d-1,g=(d-2)**2,p=l&&(t===r.HAS_SOUTH_POLE||t===r.HAS_BOTH_POLES),x=l&&(t===r.HAS_NORTH_POLE||t===r.HAS_BOTH_POLES),h=((p?1:0)+(x?1:0))*pe*d,M=fe(i),S=g+h+4*M,B=u.tileGeometryCache.acquire(S);s.numVerticesPerSide=d,s.vertexAttributes=B,s.maxEdgeVertexCount=M;const{boundingBox:I}=s;n(I);const V=O(e);re.update(m,a,V),v(e),s.poleVerticesStartIndex=g;const L=y(e,p,x);s.edgeVerticesStartIndex=g+h,X(e),b(e),W(s,L,f),e.intersectionData=null}function y(e,t,n){const{tile:o,localOrigin:s,geometry:r}=e,{extent:i,ellipsoid:c}=o,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=r,m=u-1,g=s[0],p=s[1],x=s[2],M=c.radius,S=i[1],y=i[3],v=[];let B=f;const I=(e,t)=>{const n=t*u;de(-g,-p,e*M-x,l),v.push(new oe(1===e,n,1===e?0:2,B,pe));const o=P(-1===e?S:y,M),s=e*Math.PI/2-o,r=.99*(1===e?1:-1),i=M+0,{position:c,uv0:f}=d,{typedBuffer:I,typedBufferStride:V}=d.normalCompressed;for(let u=1;u<=pe;++u){const e=o+s*(u/pe),t=Math.cos(e),n=Math.sin(e);for(let o=0;o<=m;o++){const e=o/m,s=re.sinLonLUT[o],u=re.cosLonLUT[o]*t,d=s*t,M=n,S=u*i-g,y=d*i-p,v=M*i-x;de(S,y,v,l),c.setValues(B,S,y,v),a(f,B,e,r),h(I,B,u,d,M,V),++B}}};return t&&I(-1,0),n&&I(1,m),v}function v(e){const{tile:t}=e;if(!t.intersectsClippingArea)return;const{geometry:n,geometryState:o,localOrigin:r}=e,{numVerticesPerSide:i,samplerData:c}=o,l=i-2,u=i-1,{vertexAttributes:d,boundingBox:f}=n,m=d.position,g=d.uv0,{typedBuffer:p,typedBufferStride:x}=d.normalCompressed,{extent:M}=t,S=M[0],y=M[2],v=M[1],B=M[3],I=t.ellipsoid.radius,V=r[0],b=r[1],L=r[2],C=m.typedBuffer,P=m.typedBufferStride,A=1/u;let E=0;if(1<=l){const e=A,t=v*(1-e)+B*e,n=re.sinLatLUT[1],o=re.cosLatLUT[1];for(let r=1;r<=l;r++){const i=r*A,l=S*(1-i)+y*i,u=re.sinLonLUT[r],d=re.cosLonLUT[r],m=I+s(l,t,c),p=m*d*o-V,x=m*u*o-b,h=m*n-L;de(p,x,h,f);const M=(r-1)*P;C[M]=p,C[M+1]=x,C[M+2]=h,a(g,r-1,i,e)}}for(let O=1;O<=l;O++){const e=O*A,t=v*(1-e)+B*e,n=re.sinLatLUT[O],o=re.cosLatLUT[O],r=O+1,i=r*A,d=v*(1-i)+B*i,m=re.sinLatLUT[r],M=re.cosLatLUT[r],T=re.sinLonLUT[0],D=re.cosLonLUT[0],R=I+s(S,t,c);let U=D*o*R-V,N=T*o*R-b,w=n*R-L;const j=E*P;let F=C[j],H=C[j+1],q=C[j+2];for(let B=1;B<=l;B++){const e=B*A,r=S*(1-e)+y*e,T=re.sinLonLUT[B],D=re.cosLonLUT[B];let R=0,j=0,_=0;if(B<l){const e=(E+1)*P;R=C[e],j=C[e+1],_=C[e+2]}else{const e=re.sinLonLUT[u],r=re.cosLonLUT[u],i=I+s(y,t,c);R=r*o*i-V,j=e*o*i-b,_=n*i-L}const W=U,G=N,k=w;U=F,N=H,w=q,F=R,H=j,q=_;const z=R-W,J=j-G,K=_-k;let Q=0,X=0,Y=0;if(O>1){const e=(E-l)*P;Q=C[e],X=C[e+1],Y=C[e+2]}else{const e=re.sinLatLUT[0],t=re.cosLatLUT[0],n=I+s(r,v,c);Q=D*t*n-V,X=T*t*n-b,Y=e*n-L}const Z=I+s(r,d,c),$=D*M*Z-V,ee=T*M*Z-b,te=m*Z-L;if(O<l){const t=E+l,n=t*P;C[n]=$,C[n+1]=ee,C[n+2]=te,de($,ee,te,f),a(g,t,e,i)}const ne=Q-$,oe=X-ee,se=Y-te;let ie=D*o,ae=T*o,ce=n;ce*ce<.999&&(ie=K*oe-J*se,ae=z*se-K*ne,ce=J*ne-z*oe);const le=1/Math.sqrt(ie*ie+ae*ae+ce*ce);h(p,E,ie*le,ae*le,ce*le,x),++E}}}function B(e){e.tile.intersectsClippingArea&&(b(e),te(e),e.intersectionData=null)}function I(e){e.tile.intersectsClippingArea&&(Y(e),b(e),te(e),ne(e),e.intersectionData=null)}function V(e){e.tile.intersectsClippingArea&&(C(e),L(e,!0),te(e),e.intersectionData=null)}function b(e){e.tile.intersectsClippingArea&&(C(e),L(e))}function L(t,n=!1){const{geometry:o,geometryState:r,tile:i,localOrigin:c}=t,{level:u,extent:p,extentInRadians:h,ellipsoid:M}=i,S=M.radius,y=h[0],v=h[2],B=h[1],I=h[3],{samplerData:V}=r,b=p[0],L=p[2],C=p[1],P=p[3],A=O(t),{boundingBox:E,vertexAttributes:T}=o,D=c[0],R=c[1],U=c[2],N=T.position,w=N.typedBuffer,j=N.typedBufferStride,F=T.uv0;for(let O=0;O<4;++O){const c=1===O||3===O,h=r.edgeResolutions[O];d(e(h));const M=h+1,T=l(i,r.edgePeerNeighbors[O]);if(ce(i,T,O)){Z(t,O,T);continue}const N=null!=T;d(!N||T.level===i.level),d(!N||x(i,T)<=0);const H=T?.renderData,q=H?.geometryState;if(f){const e=i.surface;if(!T&&e&&!e.updatingRootTiles){const t=m[O],n=i.findNeighborTile(t,(e=>e.loaded||e.leaf||e.level===i.level));n?n.intersectsClippingArea&&(d(!n.loaded),d(!n.leaf),d(n.level===u)):d(null==e?.rootTiles||!i.shouldHaveNeighbor(t))}}const _=1===O?p[2]:p[0],W=T?.extent,G=W&&c?1===O?W[0]:W[2]:_,k=0===O?p[3]:p[1],z=1===O?1:0,J=0===O?1:0,K=1===O?v:y,Q=0===O?I:B,X=Math.sin(K),Y=Math.cos(K),$=Math.sin(Q),ee=Math.cos(Q),te=q?.samplerData,ne=N?(e,t,n)=>.5*(s(e,t,V)+s(n,t,te)):(e,t,n)=>s(e,t,V),oe=o.outerEdgesOffsetAndLength[2*O+0],se=n&&M>3?M-3:1,re=null!=V&&V.some((e=>null!=e)),ie=null!=te&&te.some((e=>null!=e)),ae=re||ie,le=1/h,ue=oe;d(!W||g(W[2]-W[0],p[2]-p[0]));(()=>{const e=1===O?-1:3===O?1:0,t=0===O?-1:2===O?1:0,n=(p[2]-p[0])*le,r=e*n,i=t*n,l=c?e*((v-y)*le):0,u=c?0:t*le,d=J,f=c?K+l:K,m=c?Math.sin(f):X,g=c?Math.cos(f):Y,x=c?K-l:K,h=c?Math.sin(x):X,B=c?Math.cos(x):Y,I=c?Q:A(d+u),T=c?$:Math.sin(I),H=c?ee:Math.cos(I),q=c?Q:A(d-u),W=c?$:Math.sin(q),Z=c?ee:Math.cos(q);let oe=0,re=0,ie=0;{const e=0*le,t=c?_:b*(1-e)+L*e,n=c?G:t,o=c?C*(1-e)+P*e:k,s=c?K:y*(1-e)+v*e,r=c?X:Math.sin(s),i=c?Y:Math.cos(s),a=c?A(e):Q,l=c?Math.sin(a):$,u=c?Math.cos(a):ee,d=S+ne(t,o,n);oe=i*u*d,re=r*u*d,ie=l*d}let ce=0,fe=0,me=0;{const e=1*le,t=c?_:b*(1-e)+L*e,n=c?G:t,o=c?C*(1-e)+P*e:k,s=c?K:y*(1-e)+v*e,r=c?X:Math.sin(s),i=c?Y:Math.cos(s),a=c?A(e):Q,l=c?Math.sin(a):$,u=c?Math.cos(a):ee,d=S+ne(t,o,n);ce=i*u*d,fe=r*u*d,me=l*d}for(let p=1;p<M-1;p+=se){let e=0,t=0,n=0;{const o=(p+1)*le,s=c?_:b*(1-o)+L*o,r=c?G:s,i=c?C*(1-o)+P*o:k,a=c?K:y*(1-o)+v*o,l=c?X:Math.sin(a),u=c?Y:Math.cos(a),d=c?A(o):Q,f=c?Math.sin(d):$,m=c?Math.cos(d):ee,g=S+ne(s,i,r);e=u*m*g,t=l*m*g,n=f*g}const l=e,u=t,d=n,f=ce,x=fe,M=me;ce=l,fe=u,me=d;{const e=ue+p,t=e*j,n=f-D,o=x-R,s=M-U;w[t]=n,w[t+1]=o,w[t+2]=s,de(n,o,s,E);const r=p*le;a(F,e,c?z:r,c?r:J)}const I=oe,q=re,se=ie;oe=f,re=x,ie=M;const ge=f,pe=x,xe=M,he=1/Math.sqrt(ge*ge+pe*pe+xe*xe),Me=xe*he;let Se=0,ye=0,ve=0;if(ae&&Me*Me<.999){let e=0,t=0,n=0;{const o=0===O?-1:1;e=o*(l-I),t=o*(u-q),n=o*(d-se)}{const o=p*le,a=c?_:b*(1-o)+L*o,l=c?G:a,u=c?C*(1-o)+P*o:k,d=c?K:y*(1-o)+v*o,f=c?X:Math.sin(d),x=c?Y:Math.cos(d),M=c?A(o):Q,I=c?Math.sin(M):$,E=c?Math.cos(M):ee;let D=ge,R=pe,U=xe;if(N){const e=S+s(l-r,u-i,te),t=c?E:Z;D=(c?B:x)*t*e,R=(c?h:f)*t*e,U=(c?I:W)*e}{const o=S+s(a+r,u+i,V),l=c?E:H,d=(c?g:x)*l*o,p=(c?m:f)*l*o,h=(c?I:T)*o;N||(D=2*ge-d,R=2*pe-p,U=2*xe-h);const M=3===O?-1:1,y=M*(D-d),v=M*(R-p),B=M*(U-h);Se=n*v-t*B,ye=e*B-n*y,ve=t*y-e*v;const b=1/Math.sqrt(Se*Se+ye*ye+ve*ve);Se*=b,ye*=b,ve*=b}}}else Se=ge*he,ye=pe*he,ve=xe*he;o.setEdgeNormalFromValues(O,p,Se,ye,ve)}})()}}function C(e){$(e)}function P(e,t){return Math.PI/2-2*Math.atan(Math.exp(-e/t))}function A(e,t,n,o){return P(e*(1-o)+t*o,n)}function E(e,t,n){return e*(1-n)+t*n}function O(e){const{tile:t}=e;if(t.surface.isWebMercator){const e=t.extent,n=t.ellipsoid.radius;return t=>A(e[1],e[3],n,t)}const n=t.extentInRadians;return e=>E(n[1],n[3],e)}function T(e,t){const{tile:o,geometryState:s,geometry:r}=e,{extent:i,surface:a}=o,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,p=null!=g?Math.max(0,(g[0]-l)/d):0,x=null!=g?Math.max(0,(g[1]-u)/f):0,h=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,S=(m-2)**2,y=fe(s),v=S+4*y,B=a.renderer.tileGeometryCache.acquire(v),{boundingBox:I}=r;n(I),r.numVerticesPerSide=m,r.vertexAttributes=B,r.maxEdgeVertexCount=y,r.minu=p,r.minv=x,r.maxu=h,r.maxv=M,D(e),r.edgeVerticesStartIndex=S,X(e),w(e),W(r,[],c),e.intersectionData=null}function D(e){const n=e.tile;if(!n.intersectsClippingArea)return;const{geometry:o,geometryState:r,localOrigin:i}=e,{samplerData:c,clippingArea:l,numVerticesPerSide:u}=r,{surface:d,extent:f,ellipsoid:m}=n,{isWebMercatorOnPlateCarree:g}=d,p=null!=l?l:ie,x=f[0],M=f[1],S=f[2],y=f[3],v=Math.max(x,p[0]),B=Math.min(S,p[2]),I=Math.max(M,p[1]),V=Math.min(y,p[3]),b=m.radius,L=n.horizontalScale,C=u-1,P=u-2,{minu:A,minv:E,maxu:O,maxv:T,boundingBox:D,vertexAttributes:R}=o,U=R.position,N=R.uv0,{typedBuffer:w,typedBufferStride:j}=R.normalCompressed,F=i[0],H=i[1],q=i[2],_=U.typedBuffer,W=U.typedBufferStride;let G=0;const k=t(M,I,V),z=g?(Math.PI/2-2*Math.atan(Math.exp(-k/b)))*b:k*L,J=1/C,K=t(M*(1-J)+y*J,I,V);let Q=z,X=g?(Math.PI/2-2*Math.atan(Math.exp(-K/b)))*b:K*L;for(let Y=1;Y<=P;Y++){const e=Y/C,n=t(M*(1-e)+y*e,I,V),o=t(e,E,T),r=X,i=(Y-1)/C,l=t(M*(1-i)+y*i,I,V),u=Q,d=(Y+1)/C,f=t(M*(1-d)+y*d,I,V),m=g?(Math.PI/2-2*Math.atan(Math.exp(-f/b)))*b:f*L,p=t(d,E,T);Q=X,X=m;const R=t(x,v,B);let U=R*L,k=s(R,n,c);const z=1/C,J=t(z,A,O),K=t(x*(1-J)+S*J,v,B);let Z=J,$=K,ee=K*L,te=s(K,n,c);if(1===Y){const e=ee-F,n=Q-H,s=te-q,r=0*W;_[r]=e,_[r+1]=n,_[r+2]=s,de(e,n,s,D);const i=t(z,A,O);a(N,G,i,o)}for(let g=1;g<=P;g++){const e=ee,i=te,d=(g+1)/C,M=t(d,A,O),y=t(x*(1-d)+S*d,v,B),I=$;$=y;{const e=G+1,t=e*W;if(1===Y||g===P){const i=y*L,l=s(y,n,c);if(1===Y&&g<P){const n=i-F,s=r-H,c=l-q;_[t]=n,_[t+1]=s,_[t+2]=c,de(n,s,c,D),a(N,e,M,o)}ee=i,te=l}else ee=_[t]+F,te=_[t+2]+q}const V=ee,b=te,E=U,T=k;U=e,k=i;const R=(G-P)*W,z=1===Y?s(I,l,c):_[R+2]+q,J=s(I,f,c);if(Y<P){const t=G+P,n=t*W,o=e-F,s=m-H,r=J-q;_[n]=o,_[n+1]=s,_[n+2]=r,de(o,s,r,D);const i=Z;Z=M,a(N,t,i,p)}{const e=V-E,t=u-m,n=t*(b-T),o=e*(z-J),s=-t*e,r=n*n+o*o+s*s;if(0===r)h(w,G,0,0,1,j);else{const e=1/Math.sqrt(r);h(w,G,n*e,o*e,s*e,j)}}++G}}}function R(e,t){e.tile.intersectsClippingArea&&(F(e),j(e,!0),te(e),e.intersectionData=null)}function U(e,t){e.tile.intersectsClippingArea&&(Y(e),w(e),te(e),ne(e),e.intersectionData=null)}function N(e,t){e.tile.intersectsClippingArea&&(w(e),te(e),e.intersectionData=null)}function w(e,t){e.tile.intersectsClippingArea&&(F(e),j(e,!1))}function j(n,o){const{geometry:r,geometryState:i,localOrigin:a}=n,c=n.tile,{surface:u,extent:g}=c,{clippingArea:p,samplerData:h}=i,M=null!=p?p:ie,S=g[0],y=g[2],v=g[1],B=g[3],I=[B>M[3],y>M[2],v<M[1],S<M[0]],V=c.horizontalScale,b=_(u.isWebMercatorOnPlateCarree,c.ellipsoid.radius,V),{minu:L,minv:C,maxu:P,maxv:A,boundingBox:E}=r,O=Math.max(S,M[0]),T=Math.min(y,M[2]),D=Math.max(v,M[1]),R=Math.min(B,M[3]),U=a[0],N=a[1],w=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,g=i.edgeResolutions[j];d(e(g));const p=g+1,M=I[j],F=l(c,i.edgePeerNeighbors[j]);if(!M&&ce(c,F,j)){Z(n,j,F);continue}const H=null!=F&&!M,q=F?.renderData,_=q?.geometryState;if(f&&(d(!H||F.level===c.level),d(!H||x(c,F)<=0),c&&!F&&!u.updatingRootTiles)){const e=m[j],t=c.findNeighborTile(e,(e=>e.loaded||e.leaf||e.level===c.level));u.updatingRootTiles||(t?t.intersectsClippingArea&&(d(!t.loaded),d(!t.leaf),d(t.level===c.level)):d(null==u?.rootTiles||!c.shouldHaveNeighbor(e)))}const W=t(1===j?y:S,O,T),G=t(0===j?B:v,D,R),k=_?.samplerData,z=o&&p>3?p-3:1,J=t(1===j?1:0,L,P),K=t(0===j?1:0,C,A),Q=H?(e,t)=>.5*(s(e,t,k)+s(e,t,h)):(e,t)=>s(e,t,h),X=(y-S)/g,Y=a?1===j?X:-X:0,$=a?0:0===j?X:-X,ee=-Y,te=-$;let ne=0,oe=0,se=0;{const e=0/g,n=a?W:t(S*(1-e)+y*e,O,T),o=a?t(v*(1-e)+B*e,D,R):G,s=Q(n,o);ne=n*V,oe=b(o),se=s}let re=0,ie=0,ae=0;{const e=1/g,n=a?W:t(S*(1-e)+y*e,O,T),o=a?t(v*(1-e)+B*e,D,R):G,s=Q(n,o);re=n*V,ie=b(o),ae=s}for(let e=1;e<p-1;e+=z){const n=e/g,o=re,i=ie,c=ae;{const s=a?J:t(n,L,P),l=a?t(n,C,A):K,u=o-U,d=i-N,f=c-w;de(o,d,f,E),r.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,s,l)}{const n=(e+1)/g,o=a?W:t(S*(1-n)+y*n,O,T),s=a?t(v*(1-n)+B*n,D,R):G,r=Q(o,s);re=o*V,ie=b(s),ae=r}const l=re,u=ae,d=ne,f=oe,m=se;ne=o,oe=i,se=c;let p=0,x=0,M=0;if(a){const e=ie-i,r=u-c,a=f-i,l=m-c,d=t(v*(1-n)+B*n,D,R),g=W+ee,S=g*V-o,y=s(g,d,h)-c,I=3===j?-1:1;if(p=I*(-a+e)*y,x=I*S*(-l+r),M=-I*S*(-a+e),H){const t=W+Y,n=t*V-o;p=(-a+e)*(y-(s(t,d,k)-c)),x=(S-n)*(-l+r),M=-(S-n)*(-a+e)}}else{const e=l-o,r=u-c,a=d-o,f=m-c,g=t(S*(1-n)+y*n,O,T),v=G+te,B=s(g,v,h)-c,I=b(v)-i,V=2===j?-1:1;if(p=V*I*(-f+r),x=V*(-a+e)*B,M=-V*I*(-a+e),H){const t=g,n=G+$,o=b(n)-i;p=(-I+o)*(-f+r),x=(-a+e)*(-B+(s(t,n,k)-c)),M=-(-I+o)*(-a+e)}}const I=1/Math.sqrt(p*p+x*x+M*M);r.setEdgeNormalFromValues(j,e,p*I,x*I,M*I)}}}function F(e,t){$(e)}function H(e,t){return(Math.PI/2-2*Math.atan(Math.exp(-e/t)))*t}function q(e,t){return e*t}function _(e,t,n){return e?e=>H(e,t):e=>q(e,n)}function W(e,t,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=e,i=o-1,a=s.count,c=2*(o-3)*(o-3),l=4*(i+r-3),d=u.reduce(((t,n)=>t+(i+e.getEdgeCount(n)-3)),0),f=t.reduce(((e,t)=>e+i*(2*(t.latitudeResolution-1)+1)),0),m=3*(n?2:1),g=(c+l+f)*m,p=a>=M?new Uint32Array(g):new Uint16Array(g);for(let u=0;u<g;++u)p[u]=0;e.indices=p,e.indexCount=(c+d+f)*m,e.poleIndicesStartIndex=c*m,e.edgeIndicesStartIndex=(c+f)*m,n?(J(e),K(e,t),Q(e)):(G(e),k(e,t),z(e))}function G(e){const{numVerticesPerSide:t,indices:n,vertexAttributes:o}=e,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=t-2,c=t-3,l=0,u=t-3;let d=0;for(let f=0;f<c;++f){const e=f*a;for(let t=l;t<u;++t){const o=e+t,s=o+1,c=s+a,l=c-1;me(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function k(e,t){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=e,r=n-1;let i=s;for(const a of t){const t=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=e.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let e=0;e<a.latitudeResolution;++e){const f=0===e?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+t]=u+1,o[i+s]=r,e<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function z(e){const{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:o}=e,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ue[a];let o=0,c=0;const l=e.getEdgeCount(a),u=n.count;d(u===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,p=e.getEdgeFirstVertexIndex(a),x=1,h=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const e=h+c*M,n=p+o*x,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const S=f?n+x:e+M;t[i]=e,t[i+m]=n,t[i+g]=S,i+=3}}e.indexCount=i}function J(e){const{indices:t,numVerticesPerSide:n,vertexAttributes:o}=e,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const e=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=e+o,m=f+1,g=m+a;me(f,m,g,g-1,i,r)?(ge(t,c,n,s,u),c+=6,ge(t,c,u,d,n)):(ge(t,c,n,s,d),c+=6,ge(t,c,d,u,s)),c+=6}}}function K(e,t){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=e,r=o-1;let i=s;for(const a of t){const t=a.connectedOuterEdgeOffset;let s=e.getEdgeVertexIndex(t,0),c=1;for(let e=0;e<a.latitudeResolution;++e){const t=0===e?a.rowOffset:s+o;for(let o=0;o<r;o++)ge(n,i,s,s+1,t+o),i+=6,e<a.latitudeResolution-1&&(ge(n,i,s+1,t+o+1,t+o),i+=6),s+=c;s=t,c=1}}}function Q(e){const{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:o}=e,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ue[a];let o=0,c=0;const l=e.getEdgeCount(a),u=n.count;d(u===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,p=e.getEdgeFirstVertexIndex(a),x=1,h=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const e=h+c*M,n=p+o*x,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const S=f?n+x:e+M;t[i]=e,t[i+m]=n,t[i+m+1]=n,t[i+g]=S,t[i+g+1]=S,t[i+5]=e,i+=6}}e.indexCount=i}function X(e){const{geometry:t,geometryState:n}=e,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=t,i=s-2;let a=r;for(let c=0;c<4;++c){{const e=0===c||2===c,t=(0===c?i-1:0)*i+(1===c?i-1:0),n=(e?0:1)*i+(e?1:0),o=ue[c];o.vertex0Index=t,o.stride=n,o.count=i}{const e=o[c]+1;t.outerEdgesOffsetAndLength[2*c+0]=a,t.outerEdgesOffsetAndLength[2*c+1]=e,a+=e}}}function Y(e){X(e),e.geometryState.wireframe?Q(e.geometry):z(e.geometry)}function Z(n,o,s){const{geometryState:r,geometry:i,tile:c,localOrigin:l}=n,u=1===o||3===o,f=r.edgeResolutions[o];d(e(f));const m=f+1,{boundingBox:g,minu:p,minv:x,maxu:h,maxv:M,vertexAttributes:S}=i,y=t(1===o?1:0,p,h),v=t(0===o?1:0,x,M),B=s.renderData,I=B.geometryState,V=B.geometry,b=(o+2)%4,L=V.getEdgeCount(b),C=c.getNeighborEdgeStartVertexIndex(o,s)*f,P=f*2**(c.level-s.level);d(I.edgeResolutions[b]===P),d(L-1===P);const A=B.localOrigin[0]-l[0],E=B.localOrigin[1]-l[1],O=B.localOrigin[2]-l[2],T=i.getEdgeFirstVertexIndex(o),D=S.position,R=D.typedBuffer,U=D.typedBufferStride,N=S.normalCompressed,w=N.typedBuffer,j=N.typedBufferStride,F=S.uv0,H=V.vertexAttributes,q=V.getEdgeFirstVertexIndex(b),_=H.position.typedBuffer,W=H.position.typedBufferStride,G=H.normalCompressed.typedBuffer,k=H.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const n=T+e,o=q+(C+e),s=n*U,r=o*W,i=_[r]+A,c=_[r+1]+E,l=_[r+2]+O;R[s]=i,R[s+1]=c,R[s+2]=l,de(i,c,l,g);const d=n*j,m=o*k;w[d]=G[m],w[d+1]=G[m+1];const S=e/f,B=u?y:t(S,p,h),I=u?t(S,x,M):v;a(F,n,B,I)}}function $(e){const{geometry:n,geometryState:o,localOrigin:r}=e,{clippingArea:i,samplerData:c}=o,{minu:l,minv:u,maxu:f,maxv:m,boundingBox:g,vertexAttributes:p}=n,h=e.tile,{surface:M,ellipsoid:S,extent:y,extentInRadians:v,horizontalScale:B}=h,I="local"===M.view?.viewingMode,V=S.radius;let b=0,L=0,C=0;const P=(e,t,n)=>{const o=v[0===t?1:3],s=v[0===e?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=V+n;b=c*r*l,L=a*r*l,C=i*l},A=I?(()=>{const e=i,n=null!=e&&(y[3]>e[3]||y[2]>e[2]||y[1]<e[1]||y[0]<e[0]),o=_(M.isWebMercatorOnPlateCarree,V,B);return(s,r,i)=>{const a=0===s?y[0]:y[2],c=0===r?y[1]:y[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;b=l*B,L=o(u),C=d}})():P;let E=0,T=0,D=0,R=0,U=0,N=0,w=0,j=0,F=0;const H=I&&M.isWebMercatorOnPlateCarree,q=(e,t,n,o,s)=>{let r=0,i=0,a=0;if(I){const e=t*B,s=H?(Math.PI/2-2*Math.atan(Math.exp(-n/V)))*V:n*B;r=e-b,i=s-L,a=o-C}else{const s=O(e),c=e.tile,l=c.extent,u=c.extentInRadians,d=(t-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),p=Math.cos(g),x=Math.sin(g),h=Math.sin(m),M=Math.cos(m),S=V+o;r=M*p*S-b,i=h*p*S-L,a=x*S-C}switch(s){case 0:w+=r,j+=i,F+=a;break;case 1:R-=r,U-=i,N-=a;break;case 2:w-=r,j-=i,F-=a;break;case 3:R+=r,U+=i,N+=a}},W=i??ie,G=y[0],k=y[2],z=y[1],J=y[3],K=[J>W[3],k>W[2],z<W[1],G<W[0]],Q=Math.max(G,W[0]),X=Math.min(k,W[2]),Y=Math.max(z,W[1]),Z=Math.min(J,W[3]),$=e=>Math.max(W[0],Math.min(W[2],e)),te=e=>Math.max(W[1],Math.min(W[3],e)),ne=e=>{const t=o.cornerNeighborCornerTiles;E=0,T=0,D=1,R=0,U=0,N=0,w=0,j=0,F=0;let n=1/0;for(let o=0;o<4;++o){const s=t[4*e+o];n=Math.min(n,s?.level??1/0)}for(let o=0;o<4;++o){const s=t[4*e+o];ae[o]=s?.level===n?s:null}let r=1,i=0;for(let o=0;o<4;++o){const e=ae[o];e&&(r=Math.max(r,e?.renderData.geometryState.numVerticesPerSide),i=e.extent[2]-e.extent[0])}const a=i,c=r;d(c>1);const l=a/c;for(let o=0;o<4;++o){const e=ae[(o+3)%4],t=ae[o%4];if(!e&&!t)continue;const n=0===o?1:1===o?2:2===o?3:0,r=0===o?2:1===o?3:2===o?0:1;if(e&&t){const i=se[o][0]*l,a=se[o][1]*l,c=e.extent,u=$(c[0===n||1===n?2:0]+i),d=te(c[0===n||3===n?3:1]+a),f=t.extent,m=$(f[0===r||1===r?2:0]+i),g=te(f[0===r||3===r?3:1]+a),p=e.renderData,x=t.renderData,h=s(u,d,p.geometryState.samplerData),M=s(m,g,x.geometryState.samplerData);q(p,u,d,.5*(h+M),o)}else{const i=e??t,a=e?n:r,c=i.extent,u=se[o],d=$(c[0===a||1===a?2:0]+u[0]*l),f=te(c[0===a||3===a?3:1]+u[1]*l),m=i.renderData,g=s(d,f,m.geometryState.samplerData);q(m,d,f,g,o)}}if(!I){const e=Math.sqrt(b*b+L*L+C*C);E=b/e,T=L/e,D=C/e}if(I||D*D<.999){const e=Math.sqrt(R*R+U*U+N*N);R/=e,U/=e,N/=e;const t=Math.sqrt(w*w+j*j+F*F);w/=t,j/=t,F/=t,E=N*j-U*F,T=R*F-N*w,D=U*w-R*j;const n=1/Math.sqrt(E*E+T*T+D*D);E*=n,T*=n,D*=n}},oe=o.cornerNeighborCornerTiles;for(let O=0;O<4;++O){const e=O,i=(O+1)%4,M=0===O||1===O?1:0,S=0===O||3===O?1:0,y=t(M,l,f),v=t(S,u,m),B=n.getEdgeFirstVertexIndex(e),I=n.getEdgeCount(e),V=0===O||3===O?I-1:0,P=n.getEdgeFirstVertexIndex(i),R=n.getEdgeCount(i),U=0===O||1===O?R-1:0;let N=-1;for(let t=0;t<4;++t){const e=oe[4*O+t],n=oe[4*O+N];e&&(-1===N||x(n,e)>0)&&(N=t)}const w=N,j=oe[4*O+w];if(j!==h){const e=h.level-j.level,t=2**e,n=[j.lij[0]+e,j.lij[1]*t,j.lij[2]*t],s=[n[1]+t===h.lij[1],0===O&&(1===w||0===w&&j!==oe[4*O+3])||1===O&&(0===w||1===w&&j!==oe[4*O+2]),n[1]===h.lij[1]+1,2===O&&(3===w||2===w&&j!==oe[4*O+1])||3===O&&(2===w||3===w&&j!==oe[4*O+0])],i=s.reduce(((e,t)=>e+(t?1:0)),0);d(1===i||2===i);let c=-1,l=-1;const u=j.renderData;if(1===i){const e=s.findIndex((e=>e));d(0<=e&&e<=3),c=(e+2)%4;const t=o.edgeResolutions[e];l=h.getNeighborEdgeStartVertexIndex(e,j)*t+t*(0===e&&0===O||1===e&&0===O||2===e&&1===O||3===e&&3===O?1:0)}else{d(s[1]||s[3]),c=s[1]?3:1;const e=u.geometryState.edgeResolutions[c];l=0===O||3===O?0:e}const f=u.geometry;{const e=B+V,t=P+U,n=f.getEdgeFirstVertexIndex(c)+l,o=f.vertexAttributes,s=u.localOrigin;{const i=o.position,a=i.typedBuffer,c=n*i.typedBufferStride,l=a[c]+s[0]-r[0],u=a[c+1]+s[1]-r[1],d=a[c+2]+s[2]-r[2];de(l,u,d,g);const f=p.position,m=f.typedBuffer;{const t=e*f.typedBufferStride;m[t]=l,m[t+1]=u,m[t+2]=d}{const e=t*f.typedBufferStride;m[e]=l,m[e+1]=u,m[e+2]=d}}const i=p.uv0;a(i,e,y,v),a(i,t,y,v);{const s=o.normalCompressed.typedBuffer,r=n*o.normalCompressed.typedBufferStride,i=p.normalCompressed,a=i.typedBuffer;{const t=e*i.typedBufferStride;a[t]=s[r],a[t+1]=s[r+1]}{const e=t*i.typedBufferStride;a[e]=s[r],a[e+1]=s[r+1]}}}}else{const o=K[e],a=K[i];let l;if(o||a){const e=t(G*(1-M)+k*M,Q,X),n=t(z*(1-S)+J*S,Y,Z);l=s(e,n,c)}else l=ee(oe,O);A(M,S,l),ne(O);const u=b-r[0],d=L-r[1],f=C-r[2];de(u,d,f,g),n.setEdgeVertexFromValuesRawPositionUVNormal(e,V,u,d,f,y,v,E,T,D),n.setEdgeVertexFromValuesRawPositionUVNormal(i,U,u,d,f,y,v,E,T,D)}}for(let t=0;t<4;++t)ae[t]=null}function ee(e,t){const n=4*t,o=u.reduce(((t,o)=>Math.min(t,e[n+o]?.level??1/0)),1/0);f&&(d(!e[n+0]||!e[n+2]||p(e[n+0],e[n+2],i.SOUTH_WEST)),d(!e[n+1]||!e[n+3]||p(e[n+1],e[n+3],i.NORTH_WEST)));let r=0,a=0;for(let i=0;i<4;++i){const t=e[n+i];if(t&&t.level===o){const e=0===i||1===i,n=0===i||3===i,o=t.extent,c=o[e?0:2],l=o[n?1:3],u=t.renderData?.geometryState?.samplerData;a+=s(c,l,u),r++}}const c=r?a/r:0;return d(null!=c),c}function te(e){const{vao:t,geometry:n}=e,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;t.vertexBuffers.get("geometry").setSubData(r,s,s,r.length)}function ne(e){const{vao:t,geometry:n}=e,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;t.indexBuffer.setSubData(o,r,r,s)}class oe{constructor(e,t,n,o,s){this.isNorth=e,this.connectedRowOffset=t,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const se=[[0,1],[1,0],[0,-1],[-1,0]],re=new c,ie=o(-1/0,-1/0,1/0,1/0),ae=[null,null,null,null];function ce(e,t,n){if(!t)return!1;const o=x(e,t);return o>0||0===o&&n>=2}class le{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(e){return d(0<=e&&e<this.count),this.vertex0Index+this.stride*e}}const ue=[new le,new le,new le,new le];function de(e,t,n,o){e<o[0]?o[0]=e:e>o[3]&&(o[3]=e),t<o[1]?o[1]=t:t>o[4]&&(o[4]=t),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function fe(e){const{edgeResolutions:t,numVerticesPerSide:n}=e,o=1+Math.max(...t);return Math.max(n,o)}function me(e,t,n,o,s,r){const i=e*s,a=r[i],c=r[i+1],l=r[i+2],u=t*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,p=r[g],x=r[g+1],h=r[g+2],M=o*s,S=r[M],y=r[M+1],v=r[M+2];return(d-S)*(d-S)+(f-y)*(f-y)+(m-v)*(m-v)>(a-p)*(a-p)+(c-x)*(c-x)+(l-h)*(l-h)}function ge(e,t,n,o,s){e[t]=n,e[t+1]=o,e[t+2]=o,e[t+3]=s,e[t+4]=s,e[t+5]=n}const pe=6;export{T as createPlanarGlobePatch,S as createSphericalGlobePatch,V as updateCornerSpherical,R as updateCornersPlanar,U as updateEdgeElevationsAndResolutionsPlanar,I as updateEdgeElevationsAndResolutionsSpherical,N as updateEdgesAndCornersPlanar,B as updateEdgesAndCornersSpherical};
|
|
5
|
+
import{isPowerOfTwo as e,clamp as t}from"../../../core/mathUtils.js";import{empty as n}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as o}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as s}from"./ElevationData.js";import{PatchType as r}from"./interfaces.js";import{NeighborIndex as i}from"./NeighborIndex.js";import{PatchGeometryLUT as a}from"./PatchGeometryLUT.js";import{neighborTileIfLoadedOrSelf as c,zeroToFour as l}from"./PatchRenderData.js";import{internalAssert as u,enableTerrainInternalChecks as d,neighborEdgeIndices as f,almostEquals as m}from"./terrainUtils.js";import{isCornerNeighbor as g}from"./Tile.js";import{compareTilesByLij as p}from"./tileUtils.js";import{compressNormal as x}from"../webgl-engine/lib/Normals.js";const h=65536;function M(e,t){const{tile:o,geometry:s,geometryState:i}=e,{extentInRadians:a,surface:c}=o,{isWebMercator:l,renderer:u}=c,{numVerticesPerSide:d,wireframe:f}=i,m=d-1,g=(d-2)**2,p=l&&(t===r.HAS_SOUTH_POLE||t===r.HAS_BOTH_POLES),x=l&&(t===r.HAS_NORTH_POLE||t===r.HAS_BOTH_POLES),h=((p?1:0)+(x?1:0))*ge*d,M=de(i),v=g+h+4*M,V=u.tileGeometryCache.acquire(v);s.numVerticesPerSide=d,s.vertexAttributes=V,s.maxEdgeVertexCount=M;const{boundingBox:B}=s;n(B);const b=E(e);se.update(m,a,b),y(e),s.poleVerticesStartIndex=g;const L=S(e,p,x);s.edgeVerticesStartIndex=g+h,Q(e),I(e),_(s,L,f),e.intersectionData=null}function S(e,t,n){const{tile:o,localOrigin:s,geometry:r}=e,{extent:i,ellipsoid:a}=o,{boundingBox:c,numVerticesPerSide:l,vertexAttributes:u,poleVerticesStartIndex:d}=r,f=l-1,m=s[0],g=s[1],p=s[2],h=a.radius,M=i[1],S=i[3],y=[];let v=d;const V=(e,t)=>{const n=t*l;ue(-m,-g,e*h-p,c),y.push(new ne(1===e,n,1===e?0:2,v,ge));const o=C(-1===e?M:S,h),s=e*Math.PI/2-o,r=.99*(1===e?1:-1),i=h+0,{position:a,uv0:d}=u,{typedBuffer:V,typedBufferStride:B}=u.normalCompressed;for(let l=1;l<=ge;++l){const e=o+s*(l/ge),t=Math.cos(e),n=Math.sin(e);for(let o=0;o<=f;o++){const e=o/f,s=se.sinLonLUT[o],l=se.cosLonLUT[o]*t,u=s*t,h=n,M=l*i-m,S=u*i-g,y=h*i-p;ue(M,S,y,c),a.setValues(v,M,S,y),d.setValues(v,e,r),x(V,v,l,u,h,B),++v}}};return t&&V(-1,0),n&&V(1,f),y}function y(e){const{tile:t}=e;if(!t.intersectsClippingArea)return;const{geometry:n,geometryState:o,localOrigin:r}=e,{numVerticesPerSide:i,samplerData:a}=o,c=i-2,l=i-1,{vertexAttributes:u,boundingBox:d}=n,{position:f,uv0:m}=u,{typedBuffer:g,typedBufferStride:p}=u.normalCompressed,{extent:h}=t,M=h[0],S=h[2],y=h[1],v=h[3],V=t.ellipsoid.radius,B=r[0],I=r[1],b=r[2],L=f.typedBuffer,C=f.typedBufferStride,A=1/l;let P=0;if(1<=c){const e=A,t=y*(1-e)+v*e,n=se.sinLatLUT[1],o=se.cosLatLUT[1];for(let r=1;r<=c;r++){const i=r*A,c=M*(1-i)+S*i,l=se.sinLonLUT[r],u=se.cosLonLUT[r],f=V+s(c,t,a),g=f*u*o-B,p=f*l*o-I,x=f*n-b;ue(g,p,x,d);const h=(r-1)*C;L[h]=g,L[h+1]=p,L[h+2]=x,m.setValues(r-1,i,e)}}for(let E=1;E<=c;E++){const e=E*A,t=y*(1-e)+v*e,n=se.sinLatLUT[E],o=se.cosLatLUT[E],r=E+1,i=r*A,u=y*(1-i)+v*i,f=se.sinLatLUT[r],h=se.cosLatLUT[r],O=se.sinLonLUT[0],T=se.cosLonLUT[0],D=V+s(M,t,a);let R=T*o*D-B,U=O*o*D-I,N=n*D-b;const w=P*C;let j=L[w],F=L[w+1],H=L[w+2];for(let v=1;v<=c;v++){const e=v*A,r=M*(1-e)+S*e,O=se.sinLonLUT[v],T=se.cosLonLUT[v];let D=0,w=0,q=0;if(v<c){const e=(P+1)*C;D=L[e],w=L[e+1],q=L[e+2]}else{const e=se.sinLonLUT[l],r=se.cosLonLUT[l],i=V+s(S,t,a);D=r*o*i-B,w=e*o*i-I,q=n*i-b}const _=R,W=U,k=N;R=j,U=F,N=H,j=D,F=w,H=q;const z=D-_,G=w-W,J=q-k;let K=0,Q=0,X=0;if(E>1){const e=(P-c)*C;K=L[e],Q=L[e+1],X=L[e+2]}else{const e=se.sinLatLUT[0],t=se.cosLatLUT[0],n=V+s(r,y,a);K=T*t*n-B,Q=O*t*n-I,X=e*n-b}const Y=V+s(r,u,a),Z=T*h*Y-B,$=O*h*Y-I,ee=f*Y-b;if(E<c){const t=P+c,n=t*C;L[n]=Z,L[n+1]=$,L[n+2]=ee,ue(Z,$,ee,d),m.setValues(t,e,i)}const te=K-Z,ne=Q-$,oe=X-ee;let re=T*o,ie=O*o,ae=n;ae*ae<.999&&(re=J*ne-G*oe,ie=z*oe-J*te,ae=G*te-z*ne);const ce=1/Math.sqrt(re*re+ie*ie+ae*ae);x(g,P,re*ce,ie*ce,ae*ce,p),++P}}}function v(e){e.tile.intersectsClippingArea&&(I(e),ee(e),e.intersectionData=null)}function V(e){e.tile.intersectsClippingArea&&(X(e),I(e),ee(e),te(e),e.intersectionData=null)}function B(e){e.tile.intersectsClippingArea&&(L(e),b(e,!0),ee(e),e.intersectionData=null)}function I(e){e.tile.intersectsClippingArea&&(L(e),b(e))}function b(t,n=!1){const{geometry:o,geometryState:r,tile:i,localOrigin:a}=t,{level:l,extent:g,extentInRadians:x,ellipsoid:h}=i,M=h.radius,S=x[0],y=x[2],v=x[1],V=x[3],{samplerData:B}=r,I=g[0],b=g[2],L=g[1],C=g[3],A=E(t),{boundingBox:P,vertexAttributes:O}=o,T=a[0],D=a[1],R=a[2],{position:U,uv0:N}=O,w=U.typedBuffer,j=U.typedBufferStride;for(let E=0;E<4;++E){const a=1===E||3===E,x=r.edgeResolutions[E];u(e(x));const h=x+1,O=c(i,r.edgePeerNeighbors[E]);if(ae(i,O,E)){Y(t,E,O);continue}const U=null!=O;u(!U||O.level===i.level),u(!U||p(i,O)<=0);const F=O?.renderData,H=F?.geometryState;if(d){const e=i.surface;if(!O&&e&&!e.updatingRootTiles){const t=f[E],n=i.findNeighborTile(t,(e=>e.loaded||e.leaf||e.level===i.level));n?n.intersectsClippingArea&&(u(!n.loaded),u(!n.leaf),u(n.level===l)):u(null==e?.rootTiles||!i.shouldHaveNeighbor(t))}}const q=1===E?g[2]:g[0],_=O?.extent,W=_&&a?1===E?_[0]:_[2]:q,k=0===E?g[3]:g[1],z=1===E?1:0,G=0===E?1:0,J=1===E?y:S,K=0===E?V:v,Q=Math.sin(J),X=Math.cos(J),Z=Math.sin(K),$=Math.cos(K),ee=H?.samplerData,te=U?(e,t,n)=>.5*(s(e,t,B)+s(n,t,ee)):(e,t,n)=>s(e,t,B),ne=o.outerEdgesOffsetAndLength[2*E+0],oe=n&&h>3?h-3:1,se=null!=B&&B.some((e=>null!=e)),re=null!=ee&&ee.some((e=>null!=e)),ie=se||re,ce=1/x,le=ne;u(!_||m(_[2]-_[0],g[2]-g[0]));(()=>{const e=1===E?-1:3===E?1:0,t=0===E?-1:2===E?1:0,n=(g[2]-g[0])*ce,r=e*n,i=t*n,c=a?e*((y-S)*ce):0,l=a?0:t*ce,u=G,d=a?J+c:J,f=a?Math.sin(d):Q,m=a?Math.cos(d):X,p=a?J-c:J,x=a?Math.sin(p):Q,v=a?Math.cos(p):X,V=a?K:A(u+l),O=a?Z:Math.sin(V),F=a?$:Math.cos(V),H=a?K:A(u-l),_=a?Z:Math.sin(H),Y=a?$:Math.cos(H);let ne=0,se=0,re=0;{const e=0*ce,t=a?q:I*(1-e)+b*e,n=a?W:t,o=a?L*(1-e)+C*e:k,s=a?J:S*(1-e)+y*e,r=a?Q:Math.sin(s),i=a?X:Math.cos(s),c=a?A(e):K,l=a?Math.sin(c):Z,u=a?Math.cos(c):$,d=M+te(t,o,n);ne=i*u*d,se=r*u*d,re=l*d}let ae=0,de=0,fe=0;{const e=1*ce,t=a?q:I*(1-e)+b*e,n=a?W:t,o=a?L*(1-e)+C*e:k,s=a?J:S*(1-e)+y*e,r=a?Q:Math.sin(s),i=a?X:Math.cos(s),c=a?A(e):K,l=a?Math.sin(c):Z,u=a?Math.cos(c):$,d=M+te(t,o,n);ae=i*u*d,de=r*u*d,fe=l*d}for(let g=1;g<h-1;g+=oe){let e=0,t=0,n=0;{const o=(g+1)*ce,s=a?q:I*(1-o)+b*o,r=a?W:s,i=a?L*(1-o)+C*o:k,c=a?J:S*(1-o)+y*o,l=a?Q:Math.sin(c),u=a?X:Math.cos(c),d=a?A(o):K,f=a?Math.sin(d):Z,m=a?Math.cos(d):$,p=M+te(s,i,r);e=u*m*p,t=l*m*p,n=f*p}const c=e,l=t,u=n,d=ae,p=de,h=fe;ae=c,de=l,fe=u;{const e=le+g,t=e*j,n=d-T,o=p-D,s=h-R;w[t]=n,w[t+1]=o,w[t+2]=s,ue(n,o,s,P);const r=g*ce,i=a?z:r,c=a?r:G;N.setValues(e,i,c)}const V=ne,H=se,oe=re;ne=d,se=p,re=h;const me=d,ge=p,pe=h,xe=1/Math.sqrt(me*me+ge*ge+pe*pe),he=pe*xe;let Me=0,Se=0,ye=0;if(ie&&he*he<.999){let e=0,t=0,n=0;{const o=0===E?-1:1;e=o*(c-V),t=o*(l-H),n=o*(u-oe)}{const o=g*ce,c=a?q:I*(1-o)+b*o,l=a?W:c,u=a?L*(1-o)+C*o:k,d=a?J:S*(1-o)+y*o,p=a?Q:Math.sin(d),h=a?X:Math.cos(d),V=a?A(o):K,P=a?Math.sin(V):Z,T=a?Math.cos(V):$;let D=me,R=ge,N=pe;if(U){const e=M+s(l-r,u-i,ee),t=a?T:Y;D=(a?v:h)*t*e,R=(a?x:p)*t*e,N=(a?P:_)*e}{const o=M+s(c+r,u+i,B),l=a?T:F,d=(a?m:h)*l*o,g=(a?f:p)*l*o,x=(a?P:O)*o;U||(D=2*me-d,R=2*ge-g,N=2*pe-x);const S=3===E?-1:1,y=S*(D-d),v=S*(R-g),V=S*(N-x);Me=n*v-t*V,Se=e*V-n*y,ye=t*y-e*v;const I=1/Math.sqrt(Me*Me+Se*Se+ye*ye);Me*=I,Se*=I,ye*=I}}}else Me=me*xe,Se=ge*xe,ye=pe*xe;o.setEdgeNormalFromValues(E,g,Me,Se,ye)}})()}}function L(e){Z(e)}function C(e,t){return Math.PI/2-2*Math.atan(Math.exp(-e/t))}function A(e,t,n,o){return C(e*(1-o)+t*o,n)}function P(e,t,n){return e*(1-n)+t*n}function E(e){const{tile:t}=e;if(t.surface.isWebMercator){const e=t.extent,n=t.ellipsoid.radius;return t=>A(e[1],e[3],n,t)}const n=t.extentInRadians;return e=>P(n[1],n[3],e)}function O(e,t){const{tile:o,geometryState:s,geometry:r}=e,{extent:i,surface:a}=o,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,p=null!=g?Math.max(0,(g[0]-l)/d):0,x=null!=g?Math.max(0,(g[1]-u)/f):0,h=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,S=(m-2)**2,y=de(s),v=S+4*y,V=a.renderer.tileGeometryCache.acquire(v),{boundingBox:B}=r;n(B),r.numVerticesPerSide=m,r.vertexAttributes=V,r.maxEdgeVertexCount=y,r.minu=p,r.minv=x,r.maxu=h,r.maxv=M,T(e),r.edgeVerticesStartIndex=S,Q(e),N(e),_(r,[],c),e.intersectionData=null}function T(e){const n=e.tile;if(!n.intersectsClippingArea)return;const{geometry:o,geometryState:r,localOrigin:i}=e,{samplerData:a,clippingArea:c,numVerticesPerSide:l}=r,{surface:u,extent:d,ellipsoid:f}=n,{isWebMercatorOnPlateCarree:m}=u,g=null!=c?c:re,p=d[0],h=d[1],M=d[2],S=d[3],y=Math.max(p,g[0]),v=Math.min(M,g[2]),V=Math.max(h,g[1]),B=Math.min(S,g[3]),I=f.radius,b=n.horizontalScale,L=l-1,C=l-2,{minu:A,minv:P,maxu:E,maxv:O,boundingBox:T,vertexAttributes:D}=o,{position:R,uv0:U}=D,{typedBuffer:N,typedBufferStride:w}=D.normalCompressed,j=i[0],F=i[1],H=i[2],q=R.typedBuffer,_=R.typedBufferStride;let W=0;const k=t(h,V,B),z=m?(Math.PI/2-2*Math.atan(Math.exp(-k/I)))*I:k*b,G=1/L,J=t(h*(1-G)+S*G,V,B);let K=z,Q=m?(Math.PI/2-2*Math.atan(Math.exp(-J/I)))*I:J*b;for(let X=1;X<=C;X++){const e=X/L,n=t(h*(1-e)+S*e,V,B),o=t(e,P,O),r=Q,i=(X-1)/L,c=t(h*(1-i)+S*i,V,B),l=K,u=(X+1)/L,d=t(h*(1-u)+S*u,V,B),f=m?(Math.PI/2-2*Math.atan(Math.exp(-d/I)))*I:d*b,g=t(u,P,O);K=Q,Q=f;const D=t(p,y,v);let R=D*b,k=s(D,n,a);const z=1/L,G=t(z,A,E),J=t(p*(1-G)+M*G,y,v);let Y=G,Z=J,$=J*b,ee=s(J,n,a);if(1===X){const e=$-j,n=K-F,s=ee-H,r=0*_;q[r]=e,q[r+1]=n,q[r+2]=s,ue(e,n,s,T);const i=t(z,A,E);U.setValues(W,i,o)}for(let m=1;m<=C;m++){const e=$,i=ee,u=(m+1)/L,h=t(u,A,E),S=t(p*(1-u)+M*u,y,v),V=Z;Z=S;{const e=W+1,t=e*_;if(1===X||m===C){const i=S*b,c=s(S,n,a);if(1===X&&m<C){const n=i-j,s=r-F,a=c-H;q[t]=n,q[t+1]=s,q[t+2]=a,ue(n,s,a,T),U.setValues(e,h,o)}$=i,ee=c}else $=q[t]+j,ee=q[t+2]+H}const B=$,I=ee,P=R,O=k;R=e,k=i;const D=(W-C)*_,z=1===X?s(V,c,a):q[D+2]+H,G=s(V,d,a);if(X<C){const t=W+C,n=t*_,o=e-j,s=f-F,r=G-H;q[n]=o,q[n+1]=s,q[n+2]=r,ue(o,s,r,T);const i=Y;Y=h,U.setValues(t,i,g)}{const e=B-P,t=l-f,n=t*(I-O),o=e*(z-G),s=-t*e,r=n*n+o*o+s*s;if(0===r)x(N,W,0,0,1,w);else{const e=1/Math.sqrt(r);x(N,W,n*e,o*e,s*e,w)}}++W}}}function D(e,t){e.tile.intersectsClippingArea&&(j(e),w(e,!0),ee(e),e.intersectionData=null)}function R(e,t){e.tile.intersectsClippingArea&&(X(e),N(e),ee(e),te(e),e.intersectionData=null)}function U(e,t){e.tile.intersectsClippingArea&&(N(e),ee(e),e.intersectionData=null)}function N(e,t){e.tile.intersectsClippingArea&&(j(e),w(e,!1))}function w(n,o){const{geometry:r,geometryState:i,localOrigin:a}=n,l=n.tile,{surface:m,extent:g}=l,{clippingArea:x,samplerData:h}=i,M=null!=x?x:re,S=g[0],y=g[2],v=g[1],V=g[3],B=[V>M[3],y>M[2],v<M[1],S<M[0]],I=l.horizontalScale,b=q(m.isWebMercatorOnPlateCarree,l.ellipsoid.radius,I),{minu:L,minv:C,maxu:A,maxv:P,boundingBox:E}=r,O=Math.max(S,M[0]),T=Math.min(y,M[2]),D=Math.max(v,M[1]),R=Math.min(V,M[3]),U=a[0],N=a[1],w=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,g=i.edgeResolutions[j];u(e(g));const x=g+1,M=B[j],F=c(l,i.edgePeerNeighbors[j]);if(!M&&ae(l,F,j)){Y(n,j,F);continue}const H=null!=F&&!M,q=F?.renderData,_=q?.geometryState;if(d&&(u(!H||F.level===l.level),u(!H||p(l,F)<=0),l&&!F&&!m.updatingRootTiles)){const e=f[j],t=l.findNeighborTile(e,(e=>e.loaded||e.leaf||e.level===l.level));m.updatingRootTiles||(t?t.intersectsClippingArea&&(u(!t.loaded),u(!t.leaf),u(t.level===l.level)):u(null==m?.rootTiles||!l.shouldHaveNeighbor(e)))}const W=t(1===j?y:S,O,T),k=t(0===j?V:v,D,R),z=_?.samplerData,G=o&&x>3?x-3:1,J=t(1===j?1:0,L,A),K=t(0===j?1:0,C,P),Q=H?(e,t)=>.5*(s(e,t,z)+s(e,t,h)):(e,t)=>s(e,t,h),X=(y-S)/g,Z=a?1===j?X:-X:0,$=a?0:0===j?X:-X,ee=-Z,te=-$;let ne=0,oe=0,se=0;{const e=0/g,n=a?W:t(S*(1-e)+y*e,O,T),o=a?t(v*(1-e)+V*e,D,R):k,s=Q(n,o);ne=n*I,oe=b(o),se=s}let re=0,ie=0,ce=0;{const e=1/g,n=a?W:t(S*(1-e)+y*e,O,T),o=a?t(v*(1-e)+V*e,D,R):k,s=Q(n,o);re=n*I,ie=b(o),ce=s}for(let e=1;e<x-1;e+=G){const n=e/g,o=re,i=ie,c=ce;{const s=a?J:t(n,L,A),l=a?t(n,C,P):K,u=o-U,d=i-N,f=c-w;ue(o,d,f,E),r.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,s,l)}{const n=(e+1)/g,o=a?W:t(S*(1-n)+y*n,O,T),s=a?t(v*(1-n)+V*n,D,R):k,r=Q(o,s);re=o*I,ie=b(s),ce=r}const l=re,u=ce,d=ne,f=oe,m=se;ne=o,oe=i,se=c;let p=0,x=0,M=0;if(a){const e=ie-i,r=u-c,a=f-i,l=m-c,d=t(v*(1-n)+V*n,D,R),g=W+ee,S=g*I-o,y=s(g,d,h)-c,B=3===j?-1:1;if(p=B*(-a+e)*y,x=B*S*(-l+r),M=-B*S*(-a+e),H){const t=W+Z,n=t*I-o;p=(-a+e)*(y-(s(t,d,z)-c)),x=(S-n)*(-l+r),M=-(S-n)*(-a+e)}}else{const e=l-o,r=u-c,a=d-o,f=m-c,g=t(S*(1-n)+y*n,O,T),v=k+te,V=s(g,v,h)-c,B=b(v)-i,I=2===j?-1:1;if(p=I*B*(-f+r),x=I*(-a+e)*V,M=-I*B*(-a+e),H){const t=g,n=k+$,o=b(n)-i;p=(-B+o)*(-f+r),x=(-a+e)*(-V+(s(t,n,z)-c)),M=-(-B+o)*(-a+e)}}const B=1/Math.sqrt(p*p+x*x+M*M);r.setEdgeNormalFromValues(j,e,p*B,x*B,M*B)}}}function j(e,t){Z(e)}function F(e,t){return(Math.PI/2-2*Math.atan(Math.exp(-e/t)))*t}function H(e,t){return e*t}function q(e,t,n){return e?e=>F(e,t):e=>H(e,n)}function _(e,t,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=e,i=o-1,a=s.count,c=2*(o-3)*(o-3),u=4*(i+r-3),d=l.reduce(((t,n)=>t+(i+e.getEdgeCount(n)-3)),0),f=t.reduce(((e,t)=>e+i*(2*(t.latitudeResolution-1)+1)),0),m=3*(n?2:1),g=(c+u+f)*m,p=a>=h?new Uint32Array(g):new Uint16Array(g);for(let l=0;l<g;++l)p[l]=0;e.indices=p,e.indexCount=(c+d+f)*m,e.poleIndicesStartIndex=c*m,e.edgeIndicesStartIndex=(c+f)*m,n?(G(e),J(e,t),K(e)):(W(e),k(e,t),z(e))}function W(e){const{numVerticesPerSide:t,indices:n,vertexAttributes:o}=e,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=t-2,c=t-3,l=0,u=t-3;let d=0;for(let f=0;f<c;++f){const e=f*a;for(let t=l;t<u;++t){const o=e+t,s=o+1,c=s+a,l=c-1;fe(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function k(e,t){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=e,r=n-1;let i=s;for(const a of t){const t=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=e.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let e=0;e<a.latitudeResolution;++e){const f=0===e?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+t]=u+1,o[i+s]=r,e<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function z(e){const{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:o}=e,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=le[a];let o=0,c=0;const l=e.getEdgeCount(a),d=n.count;u(d===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,p=e.getEdgeFirstVertexIndex(a),x=1,h=n.vertex0Index,M=n.stride;for(;o<l-1||c<d-1;){const e=h+c*M,n=p+o*x,a=o<l-1,u=c<d-1,f=a&&(!u||(a?0+s*(o+.5)/(l-1):0)<=(u?1+r*(c+.5)/(d-1):0));f?++o:++c;const S=f?n+x:e+M;t[i]=e,t[i+m]=n,t[i+g]=S,i+=3}}e.indexCount=i}function G(e){const{indices:t,numVerticesPerSide:n,vertexAttributes:o}=e,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const e=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=e+o,m=f+1,g=m+a;fe(f,m,g,g-1,i,r)?(me(t,c,n,s,u),c+=6,me(t,c,u,d,n)):(me(t,c,n,s,d),c+=6,me(t,c,d,u,s)),c+=6}}}function J(e,t){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=e,r=o-1;let i=s;for(const a of t){const t=a.connectedOuterEdgeOffset;let s=e.getEdgeVertexIndex(t,0),c=1;for(let e=0;e<a.latitudeResolution;++e){const t=0===e?a.rowOffset:s+o;for(let o=0;o<r;o++)me(n,i,s,s+1,t+o),i+=6,e<a.latitudeResolution-1&&(me(n,i,s+1,t+o+1,t+o),i+=6),s+=c;s=t,c=1}}}function K(e){const{indices:t,numVerticesPerSide:n,edgeIndicesStartIndex:o}=e,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=le[a];let o=0,c=0;const l=e.getEdgeCount(a),d=n.count;u(d===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,p=e.getEdgeFirstVertexIndex(a),x=1,h=n.vertex0Index,M=n.stride;for(;o<l-1||c<d-1;){const e=h+c*M,n=p+o*x,a=o<l-1,u=c<d-1,f=a&&(!u||(a?0+s*(o+.5)/(l-1):0)<=(u?1+r*(c+.5)/(d-1):0));f?++o:++c;const S=f?n+x:e+M;t[i]=e,t[i+m]=n,t[i+m+1]=n,t[i+g]=S,t[i+g+1]=S,t[i+5]=e,i+=6}}e.indexCount=i}function Q(e){const{geometry:t,geometryState:n}=e,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=t,i=s-2;let a=r;for(let c=0;c<4;++c){{const e=0===c||2===c,t=(0===c?i-1:0)*i+(1===c?i-1:0),n=(e?0:1)*i+(e?1:0),o=le[c];o.vertex0Index=t,o.stride=n,o.count=i}{const e=o[c]+1;t.outerEdgesOffsetAndLength[2*c+0]=a,t.outerEdgesOffsetAndLength[2*c+1]=e,a+=e}}}function X(e){Q(e),e.geometryState.wireframe?K(e.geometry):z(e.geometry)}function Y(n,o,s){const{geometryState:r,geometry:i,tile:a,localOrigin:c}=n,l=1===o||3===o,d=r.edgeResolutions[o];u(e(d));const f=d+1,{boundingBox:m,minu:g,minv:p,maxu:x,maxv:h,vertexAttributes:M}=i,S=t(1===o?1:0,g,x),y=t(0===o?1:0,p,h),v=s.renderData,V=v.geometryState,B=v.geometry,I=(o+2)%4,b=B.getEdgeCount(I),L=a.getNeighborEdgeStartVertexIndex(o,s)*d,C=d*2**(a.level-s.level);u(V.edgeResolutions[I]===C),u(b-1===C);const A=v.localOrigin[0]-c[0],P=v.localOrigin[1]-c[1],E=v.localOrigin[2]-c[2],O=i.getEdgeFirstVertexIndex(o),{position:T,uv0:D}=M,R=T.typedBuffer,U=T.typedBufferStride,N=M.normalCompressed,w=N.typedBuffer,j=N.typedBufferStride,F=B.vertexAttributes,H=B.getEdgeFirstVertexIndex(I),q=F.position.typedBuffer,_=F.position.typedBufferStride,W=F.normalCompressed.typedBuffer,k=F.normalCompressed.typedBufferStride;for(let e=1;e<f-1;++e){const n=O+e,o=H+(L+e),s=n*U,r=o*_,i=q[r]+A,a=q[r+1]+P,c=q[r+2]+E;R[s]=i,R[s+1]=a,R[s+2]=c,ue(i,a,c,m);const u=n*j,f=o*k;w[u]=W[f],w[u+1]=W[f+1];const M=e/d,v=l?S:t(M,g,x),V=l?t(M,p,h):y;D.setValues(n,v,V)}}function Z(e){const{geometry:n,geometryState:o,localOrigin:r}=e,{clippingArea:i,samplerData:a}=o,{minu:c,minv:l,maxu:d,maxv:f,boundingBox:m,vertexAttributes:g}=n,x=e.tile,{surface:h,ellipsoid:M,extent:S,extentInRadians:y,horizontalScale:v}=x,V="local"===h.view?.viewingMode,B=M.radius;let I=0,b=0,L=0;const C=(e,t,n)=>{const o=y[0===t?1:3],s=y[0===e?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=B+n;I=c*r*l,b=a*r*l,L=i*l},A=V?(()=>{const e=i,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=q(h.isWebMercatorOnPlateCarree,B,v);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;I=l*v,b=o(u),L=d}})():C;let P=0,O=0,T=0,D=0,R=0,U=0,N=0,w=0,j=0;const F=V&&h.isWebMercatorOnPlateCarree,H=(e,t,n,o,s)=>{let r=0,i=0,a=0;if(V){const e=t*v,s=F?(Math.PI/2-2*Math.atan(Math.exp(-n/B)))*B:n*v;r=e-I,i=s-b,a=o-L}else{const s=E(e),c=e.tile,l=c.extent,u=c.extentInRadians,d=(t-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),p=Math.cos(g),x=Math.sin(g),h=Math.sin(m),M=Math.cos(m),S=B+o;r=M*p*S-I,i=h*p*S-b,a=x*S-L}switch(s){case 0:N+=r,w+=i,j+=a;break;case 1:D-=r,R-=i,U-=a;break;case 2:N-=r,w-=i,j-=a;break;case 3:D+=r,R+=i,U+=a}},_=i??re,W=S[0],k=S[2],z=S[1],G=S[3],J=[G>_[3],k>_[2],z<_[1],W<_[0]],K=Math.max(W,_[0]),Q=Math.min(k,_[2]),X=Math.max(z,_[1]),Y=Math.min(G,_[3]),Z=e=>Math.max(_[0],Math.min(_[2],e)),ee=e=>Math.max(_[1],Math.min(_[3],e)),te=e=>{const t=o.cornerNeighborCornerTiles;P=0,O=0,T=1,D=0,R=0,U=0,N=0,w=0,j=0;let n=1/0;for(let o=0;o<4;++o){const s=t[4*e+o];n=Math.min(n,s?.level??1/0)}for(let o=0;o<4;++o){const s=t[4*e+o];ie[o]=s?.level===n?s:null}let r=1,i=0;for(let o=0;o<4;++o){const e=ie[o];e&&(r=Math.max(r,e?.renderData.geometryState.numVerticesPerSide),i=e.extent[2]-e.extent[0])}const a=i,c=r;u(c>1);const l=a/c;for(let o=0;o<4;++o){const e=ie[(o+3)%4],t=ie[o%4];if(!e&&!t)continue;const n=0===o?1:1===o?2:2===o?3:0,r=0===o?2:1===o?3:2===o?0:1;if(e&&t){const i=oe[o][0]*l,a=oe[o][1]*l,c=e.extent,u=Z(c[0===n||1===n?2:0]+i),d=ee(c[0===n||3===n?3:1]+a),f=t.extent,m=Z(f[0===r||1===r?2:0]+i),g=ee(f[0===r||3===r?3:1]+a),p=e.renderData,x=t.renderData,h=s(u,d,p.geometryState.samplerData),M=s(m,g,x.geometryState.samplerData);H(p,u,d,.5*(h+M),o)}else{const i=e??t,a=e?n:r,c=i.extent,u=oe[o],d=Z(c[0===a||1===a?2:0]+u[0]*l),f=ee(c[0===a||3===a?3:1]+u[1]*l),m=i.renderData,g=s(d,f,m.geometryState.samplerData);H(m,d,f,g,o)}}if(!V){const e=Math.sqrt(I*I+b*b+L*L);P=I/e,O=b/e,T=L/e}if(V||T*T<.999){const e=Math.sqrt(D*D+R*R+U*U);D/=e,R/=e,U/=e;const t=Math.sqrt(N*N+w*w+j*j);N/=t,w/=t,j/=t,P=U*w-R*j,O=D*j-U*N,T=R*N-D*w;const n=1/Math.sqrt(P*P+O*O+T*T);P*=n,O*=n,T*=n}},ne=o.cornerNeighborCornerTiles;for(let E=0;E<4;++E){const e=E,i=(E+1)%4,h=0===E||1===E?1:0,M=0===E||3===E?1:0,S=t(h,c,d),y=t(M,l,f),v=n.getEdgeFirstVertexIndex(e),V=n.getEdgeCount(e),B=0===E||3===E?V-1:0,C=n.getEdgeFirstVertexIndex(i),D=n.getEdgeCount(i),R=0===E||1===E?D-1:0;let U=-1;for(let t=0;t<4;++t){const e=ne[4*E+t],n=ne[4*E+U];e&&(-1===U||p(n,e)>0)&&(U=t)}const N=U,w=ne[4*E+N];if(w!==x){const e=x.level-w.level,t=2**e,n=[w.lij[0]+e,w.lij[1]*t,w.lij[2]*t],s=[n[1]+t===x.lij[1],0===E&&(1===N||0===N&&w!==ne[4*E+3])||1===E&&(0===N||1===N&&w!==ne[4*E+2]),n[1]===x.lij[1]+1,2===E&&(3===N||2===N&&w!==ne[4*E+1])||3===E&&(2===N||3===N&&w!==ne[4*E+0])],i=s.reduce(((e,t)=>e+(t?1:0)),0);u(1===i||2===i);let a=-1,c=-1;const l=w.renderData;if(1===i){const e=s.findIndex((e=>e));u(0<=e&&e<=3),a=(e+2)%4;const t=o.edgeResolutions[e];c=x.getNeighborEdgeStartVertexIndex(e,w)*t+t*(0===e&&0===E||1===e&&0===E||2===e&&1===E||3===e&&3===E?1:0)}else{u(s[1]||s[3]),a=s[1]?3:1;const e=l.geometryState.edgeResolutions[a];c=0===E||3===E?0:e}const d=l.geometry;{const e=v+B,t=C+R,n=d.getEdgeFirstVertexIndex(a)+c,o=d.vertexAttributes,s=l.localOrigin,i=o.position,u=i.typedBuffer,f=n*i.typedBufferStride,p=u[f]+s[0]-r[0],x=u[f+1]+s[1]-r[1],h=u[f+2]+s[2]-r[2];ue(p,x,h,m);const M=g.position,V=M.typedBuffer,I=e*M.typedBufferStride;V[I]=p,V[I+1]=x,V[I+2]=h;const b=t*M.typedBufferStride;V[b]=p,V[b+1]=x,V[b+2]=h;const L=g.uv0;L.setValues(e,S,y),L.setValues(t,S,y);{const s=o.normalCompressed.typedBuffer,r=n*o.normalCompressed.typedBufferStride,i=g.normalCompressed,a=i.typedBuffer;{const t=e*i.typedBufferStride;a[t]=s[r],a[t+1]=s[r+1]}{const e=t*i.typedBufferStride;a[e]=s[r],a[e+1]=s[r+1]}}}}else{const o=J[e],c=J[i];let l;if(o||c){const e=t(W*(1-h)+k*h,K,Q),n=t(z*(1-M)+G*M,X,Y);l=s(e,n,a)}else l=$(ne,E);A(h,M,l),te(E);const u=I-r[0],d=b-r[1],f=L-r[2];ue(u,d,f,m),n.setEdgeVertexFromValuesRawPositionUVNormal(e,B,u,d,f,S,y,P,O,T),n.setEdgeVertexFromValuesRawPositionUVNormal(i,R,u,d,f,S,y,P,O,T)}}for(let t=0;t<4;++t)ie[t]=null}function $(e,t){const n=4*t,o=l.reduce(((t,o)=>Math.min(t,e[n+o]?.level??1/0)),1/0);d&&(u(!e[n+0]||!e[n+2]||g(e[n+0],e[n+2],i.SOUTH_WEST)),u(!e[n+1]||!e[n+3]||g(e[n+1],e[n+3],i.NORTH_WEST)));let r=0,a=0;for(let i=0;i<4;++i){const t=e[n+i];if(t&&t.level===o){const e=0===i||1===i,n=0===i||3===i,o=t.extent,c=o[e?0:2],l=o[n?1:3],u=t.renderData?.geometryState?.samplerData;a+=s(c,l,u),r++}}const c=r?a/r:0;return u(null!=c),c}function ee(e){const{vao:t,geometry:n}=e,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;t.vertexBuffers.get("geometry").setSubData(r,s,s,r.length)}function te(e){const{vao:t,geometry:n}=e,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;t.indexBuffer.setSubData(o,r,r,s)}class ne{constructor(e,t,n,o,s){this.isNorth=e,this.connectedRowOffset=t,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const oe=[[0,1],[1,0],[0,-1],[-1,0]],se=new a,re=o(-1/0,-1/0,1/0,1/0),ie=[null,null,null,null];function ae(e,t,n){if(!t)return!1;const o=p(e,t);return o>0||0===o&&n>=2}class ce{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(e){return u(0<=e&&e<this.count),this.vertex0Index+this.stride*e}}const le=[new ce,new ce,new ce,new ce];function ue(e,t,n,o){e<o[0]?o[0]=e:e>o[3]&&(o[3]=e),t<o[1]?o[1]=t:t>o[4]&&(o[4]=t),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function de(e){const{edgeResolutions:t,numVerticesPerSide:n}=e,o=1+Math.max(...t);return Math.max(n,o)}function fe(e,t,n,o,s,r){const i=e*s,a=r[i],c=r[i+1],l=r[i+2],u=t*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,p=r[g],x=r[g+1],h=r[g+2],M=o*s,S=r[M],y=r[M+1],v=r[M+2];return(d-S)*(d-S)+(f-y)*(f-y)+(m-v)*(m-v)>(a-p)*(a-p)+(c-x)*(c-x)+(l-h)*(l-h)}function me(e,t,n,o,s){e[t]=n,e[t+1]=o,e[t+2]=o,e[t+3]=s,e[t+4]=s,e[t+5]=n}const ge=6;export{O as createPlanarGlobePatch,M as createSphericalGlobePatch,B as updateCornerSpherical,D as updateCornersPlanar,R as updateEdgeElevationsAndResolutionsPlanar,V as updateEdgeElevationsAndResolutionsSpherical,U as updateEdgesAndCornersPlanar,v as updateEdgesAndCornersSpherical};
|
|
@@ -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{newLayout as e}from"../support/buffer/InterleavedLayout.js";import{VertexAttribute as r}from"../webgl-engine/lib/VertexAttribute.js";const t=e().vec3f(r.POSITION).
|
|
5
|
+
import{newLayout as e}from"../support/buffer/InterleavedLayout.js";import{VertexAttribute as r}from"../webgl-engine/lib/VertexAttribute.js";const t=e().vec3f(r.POSITION).vec2f16(r.UV0).vec2i16(r.NORMALCOMPRESSED,{glNormalized:!0});export{t as terrainAttributesLayout};
|
|
@@ -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"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{MemCachePool as h}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as u,isAbortError as c,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as m,sync as f,initial as y}from"../../../core/reactiveUtils.js";import{property as T}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{i as E,c as S}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as C}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as L}from"../../../geometry/ellipsoidUtils.js";import b from"../../../geometry/SpatialReference.js";import{getProjector as P}from"../../../geometry/projection/projectors.js";import{projectPointToVector as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as D}from"../../../geometry/projection/projectVectorToVector.js";import{create as x,equals as U,intersection as R,intersectsSphere as j,empty as A,expand as I}from"../../../geometry/support/aaBoundingRect.js";import{create as B,copy as V}from"../../../geometry/support/frustum.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{e as O,a as G,c as N}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as q}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as F}from"../../../layers/support/layerUtils.js";import{debugFlags as W}from"../support/debugFlags.js";import{ElevationRange as $}from"../support/ElevationRange.js";import{ElevationUpdateEvent as H}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as Q}from"../support/extentUtils.js";import{ClientType as z}from"../support/index.js";import{updatingProgress as X}from"../support/updatingProperties.js";import{ElevationBounds as Y}from"./ElevationBounds.js";import{ElevationData as K,sampleElevation as J}from"./ElevationData.js";import{create as Z}from"./ExtentHelper.js";import{TextureUpdate as ee}from"./interfaces.js";import{LayerClass as te,LayerClasses as ie}from"./LayerClass.js";import{OverlayManager as re}from"./OverlayManager.js";import{PlanarPatch as se}from"./PlanarPatch.js";import{RenderOrder as ae}from"./RenderOrder.js";import{ScaleRangeQueries as ne}from"./ScaleRangeQueries.js";import{SphericalPatch as le}from"./SphericalPatch.js";import{SplitLimits as oe}from"./SplitLimits.js";import{maxRootTiles as he,tooManyRootTilesAfterChangeError as de,tooManyRootTilesForLayerError as pe,maxTileNeighborLevelDelta as ue,maxMemoryLodBias as ce}from"./TerrainConst.js";import{TerrainRenderer as ge}from"./TerrainRenderer.js";import _e from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as me,isVectorTileLayerView as fe,neighborEdgeIndices as ye,internalAssert as Te,oppositeEdge as ve,isSurfaceLayerView as Ee,isGroupLayerView as Se,isMapTileLayerView as we,isBlendableLayerView as Ce,isElevationLayerView as Le,releaseTerrainData as be,enableTerrainInternalChecks as Pe,neighborCornerIndices as Me,oppositeCorner as De,enableWaterproofTests as xe,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as Re}from"./terrainUtils.js";import{Tile as je,lijEquals as Ae}from"./Tile.js";import{printAllocations as Ie}from"./TilePerLayerInfo.js";import{TileUpdate as Be}from"./TileUpdate.js";import{IteratorPreorder as Ve,IteratorPostorder as ke,compareTilesByLij as Oe,hasLoadableSiblings as Ge,sortTilesByPOI as Ne}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{TransparencyMode as Fe}from"./TransparencyMode.js";import{UpsampleInfo as We}from"./UpsampleInfo.js";import{isCompositeBlendMode as $e,blendModeFromString as He}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Qe}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as ze}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as Xe}from"../../support/RenderState.js";import{ImmediateTask as Ye,TaskPriority as Ke,noBudget as Je}from"../../support/Scheduler.js";import{Yield as Ze}from"../../support/Yield.js";var et;let tt=class extends(a.EventedMixin(i)){static{et=this}get allTiles(){return this._allTiles}constructor(e){super(e),this._scaleRangeQueries=new ne,this._iteratorPool=new d(Ve,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new ke,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new _e,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=w(),this._eyePosSurfaceSR=w(),this._splitLimits=new oe,this._frustum=B(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new C,this._frameTask=Ye,this._allTiles=new p,this._upsampleInfoPool=new d(We),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=x(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=b.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new Y(1/0,-1/0),this.rootTileElevationBounds=new Y(1/0,-1/0),this._projectorCache=new Map,this._radiusModifier=Math.cos(Math.PI/16/16),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1;const t=e.view;this.overlayManager=new re({...e,surface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?le:se,this._ellipsoid=L(t.spatialReference),this._renderer=new ge(this.overlayManager.renderer,t.stage,this._allTiles,this._ellipsoid.radius,t.resourceController.memoryController)}initialize(){const e=this.view,t=e.resourceController,i=t.memoryController;this._tileCache=new h(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new q(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),_((()=>this.renderer.visible),(e=>this.suspended=!e)),_((()=>this.heading),(e=>{this._renderer.updateHeading(e),this._updateTileTextures(ee.FADING)})),_((()=>({heading:e.camera?.heading,state:e.state?.mode})),(({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(t===Xe.IDLE||Math.min(r,360-r)>=30)&&(this.heading=i)}))],"overlayManager"),this.addHandles([_((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ee.UNFADED:ee.IMMEDIATE)}),m),_((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ee.UNFADED:ee.IMMEDIATE)),m),_((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),f),_((()=>this.snapLevel),(()=>this._viewChanged=!0),f),_((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),_((()=>W.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&W.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=o(this._treeDebugger))}),y),_((()=>this._renderer?.texturesBeingCompressed),((e,t)=>{t&&e<t&&(this.setMemoryDirty(),this._allTiles.forAll((e=>e.setMemoryDirty()))),0===e&&e!==t&&this.requestRender()}))]);const{spatialReference:a}=e;this._extentHelper=Z(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new qe({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(z.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(z.BASEMAP);const d=t.scheduler;this._frameTask=d.registerTask(Ke.TERRAIN_SURFACE,this),this.addHandles([_((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),y),_((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),_((()=>this.extent),(()=>this._updateRootTiles()),y),e.on("resize",(()=>this._viewChangeUpdate())),_((()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),m),_((()=>e.qualitySettings?.fadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),y),_((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Qe.Simplified:Qe.Disabled),y),_((()=>e.qualitySettings?.tiledSurface.elevationLevelDelta),(()=>this._updateAllTileGeometries())),_((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",o(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",o(this.overlayManager)),this._tileCache=o(this._tileCache),je.prune(),this._treeDebugger=o(this._treeDebugger),this._renderer.destroy(),this._iteratorPool=o(this._iteratorPool),this._upsampleMapCache=o(this._upsampleMapCache),this._elevationQueryCache=o(this._elevationQueryCache),this._set("view",null),this._extentHelper=o(this._extentHelper),this._upsampleInfoPool=o(this._upsampleInfoPool),Ie()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=x(),r=Q(t,i,e)?i:null,s=this._get("extent");return U(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=R(this.groundExtent,this._userClippingExtent,x()),t=this._get("extent");return U(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.renderer.texturesBeingCompressed)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===Fe.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[te.ELEVATION].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=P(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const l=E(rt,e,t,i);a(l,0,l,0);return ot(s,l[0],l[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[te.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,ot(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!M(e,rt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(rt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;rt[0]>t[2]&&(i+=1),rt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=P(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureProjector(t);if(null==i)return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;O(e,st);const r=G(st);i(r,0,r,0);const s=new $,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!j(i.extent,st))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return new $(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*this._radiusModifier;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!M(e,G(st),this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;st[3]=t;let i=null;const r=e=>{if(e&&j(e.extent,st)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?Fe.Invisible:Fe.InvisibleWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?Fe.Opaque:Fe.Transparent;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;me(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??b.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&k(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(et._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=at;let s=t.rootTilesInExtent(e,i,5*he);if(null!=this._rootTiles){if(s.length>he)return void n.getLogger(this).warn(de);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,Ae);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>Ae(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(n.getLogger(this).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map((e=>this._newRootTile(e))));U(i,this._rootTilesExtent)||(this._rootTilesExtent=x(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.loaded&&e.intersectsClippingArea));e.sort(Oe),e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Oe);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Be.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Be.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Be.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ge(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Be.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new Y(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new Y(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=V(this._splitLimits.frustum??B(),t.frustum):this._splitLimits.frustum=null,V(this._frustum,e.frustum),S(this._eyePosRenderSR,t.eye),D(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._layerViews[te.MAP].some(fe)&&e.setPendingUpdate(Be.TEXTURE_FADING),this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Be.TEXTURE_FADING)?Be.TEXTURE_FADING:!!e.resetPendingUpdate(Be.TEXTURE_NOFADING)&&Be.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=nt.extent;A(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>I(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),nt.spatialReference=this.spatialReference,this.emit("elevation-change",nt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Pe&&this._checkTileInvariant(),!e.hasProgressed)return Ze}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(me(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(me(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(Be.MERGE)){me(!t.hasPendingUpdate(Be.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)me(e.leaf||e.hasPendingUpdate(Be.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ue;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ue} (edge[${i}])`),me(r,`tile level delta [${t.level}] vs [${e.level}] > ${ue}`))}me(t.level-e.level<=ue,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ue,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ye[i],s);if(null!=a){if(t.leaf&&t.level>=ue){let i=a;for(;t.level-i.level<ue;)i=i.parent;const s=[r,t.lij[1]>>ue,t.lij[2]>>ue];if(!Ae(s,i.lij)){const r=e.get(i);me(!r.has(t),"Cannot already have neighbor"),r.add(t)}}me(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),me(t.level-a.level<=ue,`Tile level delta [${t.level}] vs [${a.level}] > ${ue}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);me(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ht(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(Be.MERGE),o=l?Be.MERGE:e.shouldSplit(r,s,i),h=o===Be.SPLIT;e.leaf?dt(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(Be.SPLIT),e.leaf||e.setPendingUpdate(Be.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(Be.MERGE),e.leaf&&e.setPendingUpdate(Be.SPLIT)):(e.resetPendingUpdate(Be.SPLIT)&&e.updateAgentSuspension(),o===Be.ELEVATION&&e.updateAgents(te.ELEVATION),e.leaf||(e.setPendingUpdate(Be.MERGE),e.resetPendingUpdate(Be.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Te(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.loaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Oe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Te(r.loaded),Te(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Me[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),(e=>e.loaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(ve(ye[t]),(t=>!(!t.loaded||!t.intersectsClippingArea)&&(Te(e.has(t)||Oe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Pe&&xe&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(Be.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(Be.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(Be.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(Be.SPLIT)){let t=!0;const i=s.level;if(i>=ue){const e=e=>e.leaf||i-e.level<ue;for(let r=0;r<4;++r){const a=s.findNeighborTile(ye[r],e);null!=a&&i-a.level===ue&&(t=!1,Pe&&(Te(a.leaf),Te(a.hasPendingUpdate(Be.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(Be.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Be.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(ze.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?ut(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(et._tileMemcacheKey,e)}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){me(e.leaf,"Tile that is already split should not be split again!"),me(e.rendered,"Tile marked to split is not rendered"),ut(e);const t=e.createChildren();this._allTiles.pushArray(t),e.updateAgentSuspension(),me(e.rendered,"parent should be rendered"),t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach((e=>dt(e,e.hasPendingUpdate(Be.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){lt.spatialReference=this.spatialReference,lt.extent=e.extent,lt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",lt)}createTile(e,t,i,r){me(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Be.SPLIT),s}get _shortBatches(){return this.view.state.mode!==Xe.IDLE}_mergeTile(e){me(!e.hasPendingUpdate(Be.SPLIT),"_mergeTile sanity check"),me(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),me(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),dt(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=Je){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),Ee(e)||Se(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Se(e)){const i=this._layerClassFromLayerView(e),s=this._getLayerIdxByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(we(t)&&!F(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ce(e)||Se(e))&&$e(He[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Le(e)?te.ELEVATION:te.MAP}_registerTiledLayerView(e){const t=[];if((Ce(e)||Se(e))&&t.push(_((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ee.UNFADED)}))),!Se(e)){const i=this._layerClassFromLayerView(e);t.push(_((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(_((()=>e.fullOpacity),(()=>this._updateTileTextures(ee.UNFADED)))),t.push(_((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Ee(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===te.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ie){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===te.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(te.MAP),e===ee.IMMEDIATE?this.renderer.updateTileTexture(t,Be.TEXTURE_NOFADING):t.updateRenderData(te.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=ze.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||fe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,u(r),c(t)||this._dataMissing(e,i,s),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=t===te.ELEVATION;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():we(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!g(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{c(i)||(n.getLogger(this).error(`Tile ${e.lij.toString()} layer ${te.ELEVATION}/${t.uid} error ${i}`),this._dataMissing(e,te.ELEVATION,t),this.requestUpdate())};return t.fetchTile(e.lij,i).then((e=>this._frameTask.schedule((()=>r(e)))),s).finally((()=>--this._asyncWorkItems))}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[te.ELEVATION].get(t.uid);if(null==r)return void n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",te.ELEVATION,e.lij.toString());const s=new K(e.lij,e.extent,i);e.dataArrived(r,te.ELEVATION,s);const a=[e],l=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,l),e.computeElevationBounds()}0===l&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{be(s),g(i)||(console.error(`Tile ${e.lij.toString()} layer ${te.MAP}/${t.uid} error ${r}`),this._dataMissing(e,te.MAP,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{this.requestUpdate(),g(i)?be(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));return t.fetchTile(e.lij,i).then(a,n).finally((()=>--this._asyncWorkItems))}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(te.MAP,t.uid);if(null==r)return be(i),void n.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,te.MAP,i)}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i){const r=this._getLayerIdxByUID(t,i.uid);null!=r?e.dataMissing(r,t):n.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!xe)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){Re(e)}};e([T()],tt.prototype,"_renderer",void 0),e([T({constructOnly:!0})],tt.prototype,"_scaleRangeQueries",void 0),e([T({constructOnly:!0})],tt.prototype,"view",void 0),e([T({constructOnly:!0})],tt.prototype,"overlayManager",void 0),e([T()],tt.prototype,"_hasPendingUpdates",void 0),e([T()],tt.prototype,"_asyncWorkItems",void 0),e([T()],tt.prototype,"_allTilesDirty",void 0),e([T()],tt.prototype,"_allTilesSorted",void 0),e([T()],tt.prototype,"_viewChanged",void 0),e([T({type:Number})],tt.prototype,"heading",void 0),e([T()],tt.prototype,"_splitLimits",void 0),e([T({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([T()],tt.prototype,"_frameTask",void 0),e([T({readOnly:!0})],tt.prototype,"snapLevel",null),e([T({readOnly:!0})],tt.prototype,"lodSnappingEnabled",null),e([T()],tt.prototype,"_userClippingExtent",null),e([T()],tt.prototype,"_rootTilesExtent",void 0),e([T({readOnly:!0})],tt.prototype,"extent",null),e([T({readOnly:!0})],tt.prototype,"groundExtent",null),e([T({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([T({readOnly:!0})],tt.prototype,"updating",null),e([T({readOnly:!0})],tt.prototype,"running",null),e([T(X)],tt.prototype,"updatingProgress",void 0),e([T({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([T()],tt.prototype,"_maxNumUpdating",void 0),e([T()],tt.prototype,"baseOpacity",null),e([T()],tt.prototype,"hasCompositeBlendMode",void 0),e([T({readOnly:!0})],tt.prototype,"viewingMode",null),e([T()],tt.prototype,"maxTextureScale",void 0),e([T({readOnly:!0})],tt.prototype,"ready",null),e([T({value:ae.FRONT_TO_BACK})],tt.prototype,"renderOrder",null),e([T({readOnly:!0})],tt.prototype,"rootTiles",null),e([T()],tt.prototype,"_rootTiles",void 0),e([T({readOnly:!0})],tt.prototype,"spatialReference",null),e([T({type:t})],tt.prototype,"backgroundColor",null),e([T({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([T({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([T({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([T({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([T()],tt.prototype,"wireframe",null),e([T({value:!1})],tt.prototype,"suspended",null),e([T()],tt.prototype,"fadeDuration",null),e([T()],tt.prototype,"visibleElevationBounds",void 0),e([T()],tt.prototype,"rootTileElevationBounds",void 0),e([T()],tt.prototype,"_layerViewsDirty",void 0),e([T()],tt.prototype,"renderPatchBorders",null),e([T()],tt.prototype,"visualizeNormals",null),e([T()],tt.prototype,"renderingDisabled",null),tt=et=e([v("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt,rt=w(),st=N(),at=x();new p;const nt=new H("ground"),lt={spatialReference:null,extent:null,scale:0};function ot(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return J(t,i,s)}return null}class ht{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function dt(e,t){!e.leaf||e.level<ue||gt(e,(e=>{t&&pt(e);const i=ct(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=ct(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function pt(e){if(e.hasPendingUpdate(Be.SPLIT))return;let t=e.parent;for(;t?.resetPendingUpdate(Be.MERGE);)t=t.parent;e.resetPendingUpdate(Be.MERGE),e.leaf&&e.setPendingUpdate(Be.SPLIT),e.level<ue||gt(e,(e=>{pt(e)}))}function ut(e){e.level<ue||gt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,ct(t));)t=t.parent}}))}function ct(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function gt(e,t){if(e.level<ue)return;const i=e.level-ue,r=e.lij[1]>>ue,s=e.lij[2]>>ue,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ye[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{it as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{MemCachePool as h}from"../../../core/MemCachePool.js";import d from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as u,isAbortError as c,isAborted as g}from"../../../core/promiseUtils.js";import{watch as _,syncAndInitial as m,sync as f,initial as y}from"../../../core/reactiveUtils.js";import{property as T}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{i as E,c as S}from"../../../chunks/vec32.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as C}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as L}from"../../../geometry/ellipsoidUtils.js";import b from"../../../geometry/SpatialReference.js";import{getProjector as P}from"../../../geometry/projection/projectors.js";import{projectPointToVector as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as D}from"../../../geometry/projection/projectVectorToVector.js";import{create as x,equals as U,intersection as R,intersectsSphere as j,empty as A,expand as I}from"../../../geometry/support/aaBoundingRect.js";import{create as B,copy as V}from"../../../geometry/support/frustum.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{e as O,a as G,c as N}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as q}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as F}from"../../../layers/support/layerUtils.js";import{debugFlags as W}from"../support/debugFlags.js";import{ElevationRange as $}from"../support/ElevationRange.js";import{ElevationUpdateEvent as H}from"../support/ElevationUpdateEvent.js";import{toBoundingRect as Q}from"../support/extentUtils.js";import{ClientType as z}from"../support/index.js";import{updatingProgress as X}from"../support/updatingProperties.js";import{ElevationBounds as Y}from"./ElevationBounds.js";import{ElevationData as K,sampleElevation as J}from"./ElevationData.js";import{create as Z}from"./ExtentHelper.js";import{TextureUpdate as ee}from"./interfaces.js";import{LayerClass as te,LayerClasses as ie}from"./LayerClass.js";import{OverlayManager as re}from"./OverlayManager.js";import{PlanarPatch as se}from"./PlanarPatch.js";import{RenderOrder as ae}from"./RenderOrder.js";import{ScaleRangeQueries as ne}from"./ScaleRangeQueries.js";import{SphericalPatch as le}from"./SphericalPatch.js";import{SplitLimits as oe}from"./SplitLimits.js";import{maxRootTiles as he,tooManyRootTilesAfterChangeError as de,tooManyRootTilesForLayerError as pe,maxTileNeighborLevelDelta as ue,maxMemoryLodBias as ce}from"./TerrainConst.js";import{TerrainRenderer as ge}from"./TerrainRenderer.js";import _e from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as me,isVectorTileLayerView as fe,neighborEdgeIndices as ye,internalAssert as Te,oppositeEdge as ve,isSurfaceLayerView as Ee,isGroupLayerView as Se,isMapTileLayerView as we,isBlendableLayerView as Ce,isElevationLayerView as Le,releaseTerrainData as be,enableTerrainInternalChecks as Pe,neighborCornerIndices as Me,oppositeCorner as De,enableWaterproofTests as xe,enableInternalTerrainChecks as Ue,enableTerrainWaterproofChecks as Re}from"./terrainUtils.js";import{Tile as je,lijEquals as Ae}from"./Tile.js";import{printAllocations as Ie}from"./TilePerLayerInfo.js";import{TileUpdate as Be}from"./TileUpdate.js";import{IteratorPreorder as Ve,IteratorPostorder as ke,compareTilesByLij as Oe,hasLoadableSiblings as Ge,sortTilesByPOI as Ne}from"./tileUtils.js";import{TilingSchemeLogic as qe}from"./TilingSchemeLogic.js";import{TransparencyMode as Fe}from"./TransparencyMode.js";import{UpsampleInfo as We}from"./UpsampleInfo.js";import{isCompositeBlendMode as $e,blendModeFromString as He}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as Qe}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as ze}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as Xe}from"../../support/RenderState.js";import{ImmediateTask as Ye,TaskPriority as Ke,noBudget as Je}from"../../support/Scheduler.js";import{Yield as Ze}from"../../support/Yield.js";var et;let tt=class extends(a.EventedMixin(i)){static{et=this}get allTiles(){return this._allTiles}constructor(e){super(e),this._scaleRangeQueries=new ne,this._iteratorPool=new d(Ve,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new ke,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new _e,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=w(),this._eyePosSurfaceSR=w(),this._splitLimits=new oe,this._frustum=B(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new C,this._frameTask=Ye,this._allTiles=new p,this._upsampleInfoPool=new d(We),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=x(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=b.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new Y(1/0,-1/0),this.rootTileElevationBounds=new Y(1/0,-1/0),this._projectorCache=new Map,this._radiusModifier=Math.cos(Math.PI/16/16),this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1;const t=e.view;this.overlayManager=new re({...e,surface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?le:se,this._ellipsoid=L(t.spatialReference),this._renderer=new ge(this.overlayManager.renderer,t.stage,this._allTiles,this._ellipsoid.radius,t.resourceController.memoryController)}initialize(){const e=this.view,t=e.resourceController,i=t.memoryController;this._tileCache=new h(((e,t)=>i.newCache(e,t)),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new q(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([_((()=>r.renderer.isEmpty),(()=>this._evaluateTransparency())),_((()=>this.renderer.visible),(e=>this.suspended=!e)),_((()=>this.heading),(e=>{this._renderer.updateHeading(e),this._updateTileTextures(ee.FADING)})),_((()=>({heading:e.camera?.heading,state:e.state?.mode})),(({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(t===Xe.IDLE||Math.min(r,360-r)>=30)&&(this.heading=i)}))],"overlayManager"),this.addHandles([_((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ee.UNFADED:ee.IMMEDIATE)}),m),_((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ee.UNFADED:ee.IMMEDIATE)),m),_((()=>this.backgroundColor),((e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))}),f),_((()=>this.snapLevel),(()=>this._viewChanged=!0),f),_((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),_((()=>W.TERRAIN_TILE_TREE_SHOW_TILES),(t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&W.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))})):t||(this._treeDebugger=o(this._treeDebugger))}),y),_((()=>this._renderer?.texturesBeingCompressed),((e,t)=>{t&&e<t&&(this.setMemoryDirty(),this._allTiles.forAll((e=>e.setMemoryDirty())),this.requestRender())}),f)]);const{spatialReference:a}=e;this._extentHelper=Z(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new qe({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(z.ELEVATION),this._mapDataRequester=t.createStreamDataRequester(z.BASEMAP);const d=t.scheduler;this._frameTask=d.registerTask(Ke.TERRAIN_SURFACE,this),this.addHandles([_((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),y),_((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),_((()=>this.extent),(()=>this._updateRootTiles()),y),e.on("resize",(()=>this._viewChangeUpdate())),_((()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),m),_((()=>e.qualitySettings?.fadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),y),_((()=>e.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?Qe.Simplified:Qe.Disabled),y),_((()=>e.qualitySettings?.tiledSurface.elevationLevelDelta),(()=>this._updateAllTileGeometries())),_((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(e.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",o(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",o(this.overlayManager)),this._tileCache=o(this._tileCache),je.prune(),this._treeDebugger=o(this._treeDebugger),this._renderer.destroy(),this._iteratorPool=o(this._iteratorPool),this._upsampleMapCache=o(this._upsampleMapCache),this._elevationQueryCache=o(this._elevationQueryCache),this._set("view",null),this._extentHelper=o(this._extentHelper),this._upsampleInfoPool=o(this._upsampleInfoPool),Ie()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(null==t||null==e)return null;const i=x(),r=Q(t,i,e)?i:null,s=this._get("extent");return U(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=R(this.groundExtent,this._userClippingExtent,x()),t=this._get("extent");return U(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.renderer.texturesBeingCompressed)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=this._rootTiles}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===Fe.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length)return null;if(0===s[0].layerInfo[te.ELEVATION].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=P(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const l=E(rt,e,t,i);a(l,0,l,0);return ot(s,l[0],l[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[te.ELEVATION].length:0;if(r?.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,ot(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!M(e,rt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(rt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;rt[0]>t[2]&&(i+=1),rt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=P(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){const i=this._ensureProjector(t);if(null==i)return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;O(e,st);const r=G(st);i(r,0,r,0);const s=new $,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!j(i.extent,st))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return new $(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max)}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*this._radiusModifier;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!M(e,G(st),this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;st[3]=t;let i=null;const r=e=>{if(e&&j(e.extent,st)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?Fe.Invisible:Fe.InvisibleWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?Fe.Opaque:Fe.Transparent;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;me(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??b.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&k(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(et._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=at;let s=t.rootTilesInExtent(e,i,5*he);if(null!=this._rootTiles){if(s.length>he)return void n.getLogger(this).warn(de);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,Ae);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>Ae(t,e.lij)))>-1)||(this._purgeTile(e),!1)));t.added.forEach((t=>e.push(this._newRootTile(t)))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>he&&(n.getLogger(this).warn(pe),s=t.rootTilesInExtent(e,i,he)),this._setRootTiles(s.map((e=>this._newRootTile(e))));U(i,this._rootTilesExtent)||(this._rootTilesExtent=x(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.loaded&&e.intersectsClippingArea));e.sort(Oe),e.forEach((e=>this._renderer.updateTileGeometryState(e))),e.forEach((e=>e.renderData.updateNeighborData())),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Oe);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Be.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Be.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Be.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ge(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Be.GEOMETRY)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new Y(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach((({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new Y(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=V(this._splitLimits.frustum??B(),t.frustum):this._splitLimits.frustum=null,V(this._frustum,e.frustum),S(this._eyePosRenderSR,t.eye),D(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor((e=>{this._layerViews[te.MAP].some(fe)&&e.setPendingUpdate(Be.TEXTURE_FADING),this._pendingTilesToUpdate.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Be.TEXTURE_FADING)?Be.TEXTURE_FADING:!!e.resetPendingUpdate(Be.TEXTURE_NOFADING)&&Be.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=nt.extent;A(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>I(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),nt.spatialReference=this.spatialReference,this.emit("elevation-change",nt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Pe&&this._checkTileInvariant(),!e.hasProgressed)return Ze}_checkTileInvariant(){const e=new Map;this._allTiles.forAll((t=>e.set(t,new Set))),this._allTiles.forAll((t=>{if(me(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce(((t,i)=>t+(e(i)?0:1)),0);if(me(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(Be.MERGE)){me(!t.hasPendingUpdate(Be.SPLIT),"Tile can be both split and merge at the same time");for(const e of t.children)me(e.leaf||e.hasPendingUpdate(Be.MERGE),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ue;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ue} (edge[${i}])`),me(r,`tile level delta [${t.level}] vs [${e.level}] > ${ue}`))}me(t.level-e.level<=ue,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ue,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ye[i],s);if(null!=a){if(t.leaf&&t.level>=ue){let i=a;for(;t.level-i.level<ue;)i=i.parent;const s=[r,t.lij[1]>>ue,t.lij[2]>>ue];if(!Ae(s,i.lij)){const r=e.get(i);me(!r.has(t),"Cannot already have neighbor"),r.add(t)}}me(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),me(t.level-a.level<=ue,`Tile level delta [${t.level}] vs [${a.level}] > ${ue}`)}}})),this._allTiles.forAll((t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);me(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)}))}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new ht(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll((e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0}));const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=null!=n&&n.hasPendingUpdate(Be.MERGE),o=l?Be.MERGE:e.shouldSplit(r,s,i),h=o===Be.SPLIT;e.leaf?dt(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(Be.SPLIT),e.leaf||e.setPendingUpdate(Be.MERGE),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(Be.MERGE),e.leaf&&e.setPendingUpdate(Be.SPLIT)):(e.resetPendingUpdate(Be.SPLIT)&&e.updateAgentSuspension(),o===Be.ELEVATION&&e.updateAgents(te.ELEVATION),e.leaf||(e.setPendingUpdate(Be.MERGE),e.resetPendingUpdate(Be.SPLIT)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Ne(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Te(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter((e=>e.loaded&&e.intersectsClippingArea));if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Oe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Te(r.loaded),Te(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Me[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),(e=>e.loaded)))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(ve(ye[t]),(t=>!(!t.loaded||!t.intersectsClippingArea)&&(Te(e.has(t)||Oe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Pe&&xe&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some((s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(Be.MERGE)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(Be.MERGE);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(Be.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(Be.SPLIT)){let t=!0;const i=s.level;if(i>=ue){const e=e=>e.leaf||i-e.level<ue;for(let r=0;r<4;++r){const a=s.findNeighborTile(ye[r],e);null!=a&&i-a.level===ue&&(t=!1,Pe&&(Te(a.leaf),Te(a.hasPendingUpdate(Be.SPLIT))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(Be.SPLIT)}return e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Be.GEOMETRY)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done))),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(ze.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*ce}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?ut(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(et._tileMemcacheKey,e)}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){me(e.leaf,"Tile that is already split should not be split again!"),me(e.rendered,"Tile marked to split is not rendered"),ut(e);const t=e.createChildren();this._allTiles.pushArray(t),e.updateAgentSuspension(),me(e.rendered,"parent should be rendered"),t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach((e=>dt(e,e.hasPendingUpdate(Be.SPLIT)))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){lt.spatialReference=this.spatialReference,lt.extent=e.extent,lt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",lt)}createTile(e,t,i,r){me(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Be.SPLIT),s}get _shortBatches(){return this.view.state.mode!==Xe.IDLE}_mergeTile(e){me(!e.hasPendingUpdate(Be.SPLIT),"_mergeTile sanity check"),me(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),me(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),dt(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=Je){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),Ee(e)||Se(e))if(this._basemapLayerViewHandles.has(e.uid)&&!Se(e)){const i=this._layerClassFromLayerView(e),s=this._getLayerIdxByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach(((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)})),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(we(t)&&!F(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ce(e)||Se(e))&&$e(He[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Le(e)?te.ELEVATION:te.MAP}_registerTiledLayerView(e){const t=[];if((Ce(e)||Se(e))&&t.push(_((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ee.UNFADED)}))),!Se(e)){const i=this._layerClassFromLayerView(e);t.push(_((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(_((()=>e.fullOpacity),(()=>this._updateTileTextures(ee.UNFADED)))),t.push(_((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Ee(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===te.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ie){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===te.ELEVATION&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll((t=>{t.updateAgents(te.MAP),e===ee.IMMEDIATE?this.renderer.updateTileTexture(t,Be.TEXTURE_NOFADING):t.updateRenderData(te.MAP,e)})),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll((i=>i.removeLayerAgent(e,t))),this._allTiles.forAll((i=>i.invalidateLayerData(e,t)))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=ze.UPDATE){this.renderer.setNeedsRender(e)}requestUpdate(){1==++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||fe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,u(r),c(t)||this._dataMissing(e,i,s),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=t===te.ELEVATION;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():we(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!g(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{c(i)||(n.getLogger(this).error(`Tile ${e.lij.toString()} layer ${te.ELEVATION}/${t.uid} error ${i}`),this._dataMissing(e,te.ELEVATION,t),this.requestUpdate())};return t.fetchTile(e.lij,i).then((e=>this._frameTask.schedule((()=>r(e)))),s).finally((()=>--this._asyncWorkItems))}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[te.ELEVATION].get(t.uid);if(null==r)return void n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",te.ELEVATION,e.lij.toString());const s=new K(e.lij,e.extent,i);e.dataArrived(r,te.ELEVATION,s);const a=[e],l=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,l),e.computeElevationBounds()}0===l&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{be(s),g(i)||(console.error(`Tile ${e.lij.toString()} layer ${te.MAP}/${t.uid} error ${r}`),this._dataMissing(e,te.MAP,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{this.requestUpdate(),g(i)?be(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));return t.fetchTile(e.lij,i).then(a,n).finally((()=>--this._asyncWorkItems))}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(te.MAP,t.uid);if(null==r)return be(i),void n.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,te.MAP,i)}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i){const r=this._getLayerIdxByUID(t,i.uid);null!=r?e.dataMissing(r,t):n.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll((t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))})),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!xe)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Ue(e)}enableWaterproofnessChecks(e){Re(e)}};e([T()],tt.prototype,"_renderer",void 0),e([T({constructOnly:!0})],tt.prototype,"_scaleRangeQueries",void 0),e([T({constructOnly:!0})],tt.prototype,"view",void 0),e([T({constructOnly:!0})],tt.prototype,"overlayManager",void 0),e([T()],tt.prototype,"_hasPendingUpdates",void 0),e([T()],tt.prototype,"_asyncWorkItems",void 0),e([T()],tt.prototype,"_allTilesDirty",void 0),e([T()],tt.prototype,"_allTilesSorted",void 0),e([T()],tt.prototype,"_viewChanged",void 0),e([T({type:Number})],tt.prototype,"heading",void 0),e([T()],tt.prototype,"_splitLimits",void 0),e([T({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([T()],tt.prototype,"_frameTask",void 0),e([T({readOnly:!0})],tt.prototype,"snapLevel",null),e([T({readOnly:!0})],tt.prototype,"lodSnappingEnabled",null),e([T()],tt.prototype,"_userClippingExtent",null),e([T()],tt.prototype,"_rootTilesExtent",void 0),e([T({readOnly:!0})],tt.prototype,"extent",null),e([T({readOnly:!0})],tt.prototype,"groundExtent",null),e([T({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([T({readOnly:!0})],tt.prototype,"updating",null),e([T({readOnly:!0})],tt.prototype,"running",null),e([T(X)],tt.prototype,"updatingProgress",void 0),e([T({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([T()],tt.prototype,"_maxNumUpdating",void 0),e([T()],tt.prototype,"baseOpacity",null),e([T()],tt.prototype,"hasCompositeBlendMode",void 0),e([T({readOnly:!0})],tt.prototype,"viewingMode",null),e([T()],tt.prototype,"maxTextureScale",void 0),e([T({readOnly:!0})],tt.prototype,"ready",null),e([T({value:ae.FRONT_TO_BACK})],tt.prototype,"renderOrder",null),e([T({readOnly:!0})],tt.prototype,"rootTiles",null),e([T()],tt.prototype,"_rootTiles",void 0),e([T({readOnly:!0})],tt.prototype,"spatialReference",null),e([T({type:t})],tt.prototype,"backgroundColor",null),e([T({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([T({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([T({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([T({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([T()],tt.prototype,"wireframe",null),e([T({value:!1})],tt.prototype,"suspended",null),e([T()],tt.prototype,"fadeDuration",null),e([T()],tt.prototype,"visibleElevationBounds",void 0),e([T()],tt.prototype,"rootTileElevationBounds",void 0),e([T()],tt.prototype,"_layerViewsDirty",void 0),e([T()],tt.prototype,"renderPatchBorders",null),e([T()],tt.prototype,"visualizeNormals",null),e([T()],tt.prototype,"renderingDisabled",null),tt=et=e([v("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt,rt=w(),st=N(),at=x();new p;const nt=new H("ground"),lt={spatialReference:null,extent:null,scale:0};function ot(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return J(t,i,s)}return null}class ht{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function dt(e,t){!e.leaf||e.level<ue||gt(e,(e=>{t&&pt(e);const i=ct(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=ct(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}}))}function pt(e){if(e.hasPendingUpdate(Be.SPLIT))return;let t=e.parent;for(;t?.resetPendingUpdate(Be.MERGE);)t=t.parent;e.resetPendingUpdate(Be.MERGE),e.leaf&&e.setPendingUpdate(Be.SPLIT),e.level<ue||gt(e,(e=>{pt(e)}))}function ut(e){e.level<ue||gt(e,(e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,ct(t));)t=t.parent}}))}function ct(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function gt(e,t){if(e.level<ue)return;const i=e.level-ue,r=e.lij[1]>>ue,s=e.lij[2]>>ue,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ye[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}export{it as default};
|
|
@@ -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 e from"../../../../core/Error.js";import{ColorFormat as t,DepthFormat as r}from"../../webgl/formats.js";import{ManagedColorAttachment as a}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthAttachment as o}from"../../webgl/ManagedDepthAttachment.js";import
|
|
5
|
+
import e from"../../../../core/Error.js";import{ColorFormat as t,DepthFormat as r}from"../../webgl/formats.js";import{ManagedColorAttachment as a}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthAttachment as o}from"../../webgl/ManagedDepthAttachment.js";import n from"../../webgl/ManagedFBO.js";import{AttachmentType as i}from"../../webgl/ManagedFBObject.js";import{FBOPool as c}from"./FBOPool.js";import{PixelFormat as h,SizedPixelFormat as s,TextureWrapMode as m,TextureSamplingMode as _,PixelType as d,RenderbufferFormat as l,ColorAttachment0 as p}from"../../../webgl/enums.js";import{FramebufferObject as u}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as E}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as f}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as w}from"../../../webgl/Texture.js";import{TextureDescriptor as T}from"../../../webgl/TextureDescriptor.js";class C{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new c(e.newCache,"FBOCache"),this._depthCache=new c(e.newCache,"DepthAttachmentCache"),this._colorCache=new c(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback?.()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===i.FBO&&e(t.name,t.fbo,t.numberOfColorAttachments)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("getTexture"in t?t.getTexture()?.usedMemory??0:t.cachedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(a,o,i,c=t.RGBA){const h=A(c,a,o);let s=this._cache.pop(h);if(s){s.retain(),s.setName(i);const t=this.rctx.getBoundFramebufferObject();if(this.rctx.bindFramebuffer(s.fbo),this.rctx.setDrawBuffers([p]),!s.fbo)throw new e("attempt to use a not existing framebuffer");this.rctx.unbindTexture(s.fbo.colorTexture),this.rctx.bindFramebuffer(t)}else s=new n(h,i,new u(this.rctx,{...L[c],width:a,height:o}),(e=>{e??=r.DEPTH_STENCIL_TEXTURE;const t=this._acquireDepth(e,s.fbo.width,s.fbo.height,`${s.name} depth`);return s.attachDepth(t),t.release(),s}),((e,r,n)=>{r??=t.RGBA;const i=this._acquireColor(r,a,o,n??`${s.name} color ${e}`);return this.rctx.unbindTexture(i.attachment),s.attachColor(i,e),i.release(),s}),(()=>{this.debugCallback?.(s.name,s.fbo,s.numberOfColorAttachments),s.fbo?.invalidateAttachments([p],!0),this._acquired.delete(s),s.detachAll(),this._cache.put(s)}));return this._trackHandle(s)}acquireDepth(e,t,r,a){return this._acquireDepth(e,t,r,a)}_acquireDepth(e,t,a,n){const i=R(e,t,a),c=this._depthCache.pop(i);if(c)return c.retain(),c.name=n,this._trackHandle(c);const h=e===r.DEPTH_STENCIL_TEXTURE?new o(i,new w(this.rctx,{...y[e],width:t,height:a}),(()=>{this._acquired.delete(h),this._depthCache.put(h)})):new o(i,new E(this.rctx,{...y[e],width:t,height:a}),(()=>{this._acquired.delete(h),this._depthCache.put(h)}));return h.name=n,this._trackHandle(h)}_acquireColor(e,t,r,o){const n=A(e,t,r),i=this._colorCache.pop(n);if(i)return i.retain(),i.name=o,this._trackHandle(i);const c=new a(n,new w(this.rctx,{...L[e],width:t,height:r}),(()=>{this._acquired.delete(c),this._colorCache.put(c)}));return c.name=o,this._trackHandle(c)}_trackHandle(e){return this._acquired.add(e),e}}const b=new n("default","default",null,(()=>b),(()=>b),(()=>{}));function A(e,t,r){return`C${e}x${t}x${r}`}function R(e,t,r){return`D${e}x${t}x${r}`}b.release=()=>!1;const M=new T;M.pixelFormat=h.RED,M.internalFormat=s.R8,M.wrapMode=m.CLAMP_TO_EDGE;const g=new T;g.pixelFormat=h.RED_INTEGER,g.internalFormat=s.R8UI,g.wrapMode=m.CLAMP_TO_EDGE,g.samplingMode=_.NEAREST;const F=new T;F.pixelFormat=h.RG,F.internalFormat=s.RG8,F.wrapMode=m.CLAMP_TO_EDGE;const x=new T;x.pixelFormat=h.RG_INTEGER,x.internalFormat=s.RG8UI,x.wrapMode=m.CLAMP_TO_EDGE,x.samplingMode=_.NEAREST;const D=new T;D.internalFormat=s.RGBA4,D.dataType=d.UNSIGNED_SHORT_4_4_4_4,D.wrapMode=m.CLAMP_TO_EDGE;const G=new T;G.wrapMode=m.CLAMP_TO_EDGE;const N=new T;N.wrapMode=m.CLAMP_TO_EDGE,N.samplingMode=_.LINEAR_MIPMAP_LINEAR,N.hasMipmap=!0,N.maxAnisotropy=8;const O=new T;O.pixelFormat=h.RED,O.dataType=d.HALF_FLOAT,O.internalFormat=s.R16F,O.samplingMode=_.NEAREST;const P=new T;P.dataType=d.HALF_FLOAT,P.internalFormat=s.RGBA16F,P.samplingMode=_.NEAREST;const L={[t.RED]:M,[t.R8UI]:g,[t.RG]:F,[t.RG8UI]:x,[t.RGBA4]:D,[t.RGBA]:G,[t.RGBA_MIPMAP]:N,[t.R16F]:O,[t.RGBA16F]:P},I=new T;I.pixelFormat=h.DEPTH_STENCIL,I.dataType=d.UNSIGNED_INT_24_8,I.samplingMode=_.NEAREST,I.wrapMode=m.CLAMP_TO_EDGE,I.internalFormat=h.DEPTH24_STENCIL8;const y={[r.DEPTH_STENCIL_TEXTURE]:I,[r.DEPTH16_BUFFER]:new f(l.DEPTH_COMPONENT16,4)};export{C as FBOCache,b as defaultWebGLFBO};
|
|
@@ -2,7 +2,7 @@
|
|
|
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{ShaderOutput as o}from"../ShaderOutput.js";import{glsl as r}from"../../shaderModules/glsl.js";import{VertexAttribute as d}from"../../../lib/VertexAttribute.js";function e(e,t){if(t.output!==o.ObjectAndLayerIdColor)return e.vertex.code.add(r`void forwardObjectAndLayerIdColor() {}`),void e.fragment.code.add(r`void outputObjectAndLayerIdColor() {}`);const a=t.objectAndLayerIdColorInstanced;e.varyings.add("objectAndLayerIdColorVarying","vec4"),e.attributes.add(a?d.INSTANCEOBJECTANDLAYERIDCOLOR:d.
|
|
5
|
+
import{ShaderOutput as o}from"../ShaderOutput.js";import{glsl as r}from"../../shaderModules/glsl.js";import{VertexAttribute as d}from"../../../lib/VertexAttribute.js";function e(e,t){if(t.output!==o.ObjectAndLayerIdColor)return e.vertex.code.add(r`void forwardObjectAndLayerIdColor() {}`),void e.fragment.code.add(r`void outputObjectAndLayerIdColor() {}`);const a=t.objectAndLayerIdColorInstanced;e.varyings.add("objectAndLayerIdColorVarying","vec4"),e.attributes.add(a?d.INSTANCEOBJECTANDLAYERIDCOLOR:d.OLIDCOLOR,"vec4"),e.vertex.code.add(r`
|
|
6
6
|
void forwardObjectAndLayerIdColor() {
|
|
7
7
|
objectAndLayerIdColorVarying = ${a?"instanceObjectAndLayerIdColor":"objectAndLayerIdColor"} * 0.003921568627451;
|
|
8
8
|
}`),e.fragment.code.add(r`void outputObjectAndLayerIdColor() {
|
package/views/3d/webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js
CHANGED
|
@@ -2,14 +2,7 @@
|
|
|
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{neverReached as e}from"../../../../../../core/compilerUtils.js";import{glsl as
|
|
6
|
-
vuv0 = uv0;
|
|
7
|
-
}`);case d.Compressed:return o.attributes.add(t.UV0,"vec2"),o.varyings.add("vuv0","vec2"),void o.vertex.code.add(r`vec2 getUV0() {
|
|
8
|
-
return uv0 / 16384.0;
|
|
9
|
-
}
|
|
10
|
-
void forwardTextureCoordinates() {
|
|
11
|
-
vuv0 = getUV0();
|
|
12
|
-
}`);case d.Atlas:return o.attributes.add(t.UV0,"vec2"),o.varyings.add("vuv0","vec2"),o.attributes.add(t.UVREGION,"vec4"),o.varyings.add("vuvRegion","vec4"),void o.vertex.code.add(r`void forwardTextureCoordinates() {
|
|
5
|
+
import{neverReached as e}from"../../../../../../core/compilerUtils.js";import{glsl as t}from"../../shaderModules/glsl.js";import{VertexAttribute as r}from"../../../lib/VertexAttribute.js";var o;function d(d,a){switch(a.textureCoordinateType){case o.Default:return d.attributes.add(r.UV0,"vec2"),d.varyings.add("vuv0","vec2"),void d.vertex.code.add(t`void forwardTextureCoordinates() { vuv0 = uv0; }`);case o.Atlas:return d.attributes.add(r.UV0,"vec2"),d.attributes.add(r.UVREGION,"vec4"),d.varyings.add("vuv0","vec2"),d.varyings.add("vuvRegion","vec4"),void d.vertex.code.add(t`void forwardTextureCoordinates() {
|
|
13
6
|
vuv0 = uv0;
|
|
14
7
|
vuvRegion = uvRegion;
|
|
15
|
-
}`);default:e(
|
|
8
|
+
}`);default:e(a.textureCoordinateType);case o.None:return void d.vertex.code.add(t`void forwardTextureCoordinates() {}`);case o.COUNT:return}}!function(e){e[e.None=0]="None",e[e.Default=1]="Default",e[e.Atlas=2]="Atlas",e[e.COUNT=3]="COUNT"}(o||(o={}));export{d as TextureCoordinateAttribute,o as TextureCoordinateType};
|