@arcgis/core 4.27.0-rc.3 → 4.27.0-rc.4

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.
Files changed (134) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0e65e00173b66c7fec2e.js → 09e677ca7532a281d262.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{89001ee8d3f69fa03cc1.js → 0f7ddb063ee0664f2fca.js} +1 -1
  4. package/assets/esri/core/workers/chunks/17ab08f60764244b2cf8.js +1 -0
  5. package/assets/esri/core/workers/chunks/{2446e336b1f7256d4fde.js → 2c587ed66e2586cccb8d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{00c7b9fb375c9a934158.js → 38c6452dc9cf18e8bca8.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{16db0bc87d87a7313dc4.js → 4806df402845c717c842.js} +1 -1
  8. package/assets/esri/core/workers/chunks/4884432d80e9af947449.js +1 -0
  9. package/assets/esri/core/workers/chunks/588cd91d08cec5207be1.js +1 -0
  10. package/assets/esri/core/workers/chunks/{83e3d104886b48f00397.js → 633c00c02a81397fc8df.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{efb96aefe979a0f5c632.js → 640e8ac3498be30c6614.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{33901eb1574e46abd9af.js → 6c213768715c52625855.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{5e6471dd2a08e66b47d0.js → 6e4940fe3bba014c921b.js} +57 -58
  14. package/assets/esri/core/workers/chunks/{3160af63b860b52db389.js → 6f724f75f85dc3989d60.js} +1 -1
  15. package/assets/esri/core/workers/chunks/8b05fb365336cc42fecc.js +1 -0
  16. package/assets/esri/core/workers/chunks/8eec6da5e862cc33ea2b.js +1 -0
  17. package/assets/esri/core/workers/chunks/90d8f297d9cb359e071d.js +1 -0
  18. package/assets/esri/core/workers/chunks/91785144901dfe56c5e2.js +1 -0
  19. package/assets/esri/core/workers/chunks/{471f6eba213412b82840.js → 927417abea79c955b216.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{adaa9d4239f4e905d011.js → 9d4bd73dd50400e9d328.js} +1 -1
  21. package/assets/esri/core/workers/chunks/a324cc07d486061d0d8e.js +1 -0
  22. package/assets/esri/core/workers/chunks/a40130579791293cefa2.js +1 -0
  23. package/assets/esri/core/workers/chunks/{50f910797c17c3028521.js → a49718c74053314ed741.js} +1 -1
  24. package/assets/esri/core/workers/chunks/ad2891985e0fe45aa8d2.js +1 -0
  25. package/assets/esri/core/workers/chunks/afcba35eea836aea98ca.js +1 -0
  26. package/assets/esri/core/workers/chunks/b3d2e397ea74ebef4423.js +1 -0
  27. package/assets/esri/core/workers/chunks/b5fb9da45cc9dee286f8.js +1 -0
  28. package/assets/esri/core/workers/chunks/b846d4215210aac9f6ef.js +1 -0
  29. package/assets/esri/core/workers/chunks/c7dc821db8c14fec24a7.js +1 -0
  30. package/assets/esri/core/workers/chunks/c9df9a0a4a45f9a53ce9.js +1 -0
  31. package/assets/esri/core/workers/chunks/{45a4041881e6235d73a2.js → d0a9711f48dfa5fee68a.js} +1 -1
  32. package/assets/esri/core/workers/chunks/e23ec4f867c4735eec20.js +1 -0
  33. package/assets/esri/core/workers/chunks/{ff42585e1b1d0c5497af.js → ea16230a0edfc9f756bd.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +1 -0
  35. package/assets/esri/themes/base/_View.scss +2 -5
  36. package/assets/esri/themes/base/widgets/_Feature.scss +12 -4
  37. package/assets/esri/themes/dark/main.css +1 -1
  38. package/assets/esri/themes/light/main.css +1 -1
  39. package/assets/esri/themes/light/view.css +1 -1
  40. package/chunks/DefaultMaterial.glsl.js +42 -42
  41. package/chunks/Terrain.glsl.js +7 -7
  42. package/copyright.txt +1 -1
  43. package/geometry/Mesh.js +1 -1
  44. package/geometry/support/meshUtils/bounds.js +1 -1
  45. package/geometry/support/meshUtils/georeference.js +1 -1
  46. package/interfaces.d.ts +3 -3
  47. package/kernel.js +1 -1
  48. package/layers/OrientedImageryLayer.js +1 -1
  49. package/layers/SceneLayer.js +1 -1
  50. package/layers/VideoLayer.js +1 -1
  51. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  52. package/layers/graphics/editingSupport.js +1 -1
  53. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  54. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  55. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  56. package/layers/graphics/sources/support/uploadAssets.js +1 -1
  57. package/layers/mixins/ArcGISImageService.js +1 -1
  58. package/layers/mixins/ImageryTileMixin.js +1 -1
  59. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  60. package/layers/orientedImagery/core/bestImageUtils.js +1 -1
  61. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  62. package/layers/orientedImagery/transformations/groundToImageUtils.js +1 -1
  63. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  64. package/layers/support/SubtypeSublayer.js +1 -1
  65. package/layers/support/capabilities.js +1 -1
  66. package/layers/support/layerUtils.js +1 -1
  67. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  68. package/layers/video/VideoCameraSensorModel.js +5 -0
  69. package/layers/video/VideoController.js +1 -1
  70. package/layers/video/videoUtils.js +1 -1
  71. package/package.json +1 -1
  72. package/portal/PortalItem.js +1 -1
  73. package/renderers/support/colorRampUtils.js +1 -1
  74. package/rest/support/meshFeatureSet.js +1 -1
  75. package/smartMapping/labels/bins.js +5 -0
  76. package/smartMapping/labels/clusters.js +1 -1
  77. package/smartMapping/labels/support/utils.js +5 -0
  78. package/smartMapping/support/binningUtils.js +1 -1
  79. package/support/revision.js +1 -1
  80. package/views/2d/layers/features/schemaUtils.js +1 -1
  81. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  82. package/views/3d/layers/I3SMeshView3D.js +1 -1
  83. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  84. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  85. package/views/3d/layers/SceneLayerWorker.js +1 -1
  86. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  87. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +5 -0
  88. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  89. package/views/3d/layers/i3s/I3SGeometryUtil.js +1 -1
  90. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  91. package/views/3d/terrain/TerrainRenderer.js +1 -1
  92. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +19 -20
  93. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  94. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +9 -9
  95. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  96. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  97. package/views/DOMContainer.js +1 -1
  98. package/views/PopupView.js +1 -1
  99. package/views/ui/DefaultUI.js +1 -1
  100. package/views/ui/UI.js +1 -1
  101. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  102. package/widgets/Editor/EditorViewModel.js +1 -1
  103. package/widgets/Editor/UpdateWorkflow.js +1 -1
  104. package/widgets/Editor/workflowUtils.js +1 -1
  105. package/widgets/Feature/support/featureUtils.js +1 -1
  106. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  107. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  108. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  109. package/widgets/OrientedImageryViewer.js +1 -1
  110. package/widgets/Popup.js +1 -1
  111. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  112. package/assets/esri/core/workers/chunks/013de5c2955801b329b3.js +0 -1
  113. package/assets/esri/core/workers/chunks/0618fb0058f39ecd363f.js +0 -1
  114. package/assets/esri/core/workers/chunks/07163dcbb871f927a580.js +0 -1
  115. package/assets/esri/core/workers/chunks/0e46687004392c493c06.js +0 -1
  116. package/assets/esri/core/workers/chunks/21328f3dd26abe84a10d.js +0 -1
  117. package/assets/esri/core/workers/chunks/2faa8f08f2fdaac3f4af.js +0 -1
  118. package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +0 -1
  119. package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +0 -1
  120. package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +0 -1
  121. package/assets/esri/core/workers/chunks/a6ddf80eb324c35076e1.js +0 -1
  122. package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +0 -1
  123. package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +0 -1
  124. package/assets/esri/core/workers/chunks/bf9e1fde9f6b2b4f10c0.js +0 -1
  125. package/assets/esri/core/workers/chunks/c96db6b7ce47bd343fdb.js +0 -1
  126. package/assets/esri/core/workers/chunks/cfa3b2b1e184681e9af4.js +0 -1
  127. package/assets/esri/core/workers/chunks/d95ca50ca7af4c222036.js +0 -1
  128. package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +0 -1
  129. package/assets/esri/core/workers/chunks/f720967ba8c5486a26a2.js +0 -1
  130. package/layers/orientedImagery/core/Affixes.js +0 -5
  131. package/layers/orientedImagery/core/CameraProperties.js +0 -5
  132. package/layers/orientedImagery/core/ImageProperties.js +0 -5
  133. package/layers/orientedImagery/core/ImageryTypes.js +0 -5
  134. package/layers/orientedImagery/core/imageryUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{assertIsSome as o}from"../../../../core/maybe.js";import{MIN_PRIORITY as n}from"../../../../core/MemCache.js";import{generateUUID as r}from"../../../../core/uuid.js";import{projectBoundingSphere as s}from"../../../../geometry/projection.js";import{k as a}from"../../../../chunks/sphere.js";import{loadImageAsync as i}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as l}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as u,TextureEncoding as d}from"./enums.js";import{CullFaceOptions as c}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as m}from"../../webgl-engine/materials/pbrUtils.js";class h{constructor(e,t,o,n,r){this._uid=e,this._indexSR=t,this._renderSR=o,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._memCache=n.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,r=n.spatialReference,a=this._indexSR,i=f(n,e.origin);s(i,r,i,a);return{type:"mesh",id:o,version:b(e),oid:t,mbs:i,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(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}}async loadNodeData(e,n){const r=e.id,s=this._id2Meta.get(r);if(null==s||"mesh-component"!==s.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,u=a.oid;if(null==l.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const d=l.components[s.componentIndex],{material:c,requiredTextures:m,textureData:h}=await p(d.material);if(null!=h)for(const t of h)null!=t&&s.textureData.set(t.id,t);const f={params:{material:c},type:"ArrayBufferView"},{vertexSpace:x,origin:g,transform:y}=l,w=[g.x,g.y,g.z??0],b={featureDataPosition:w,featureIds:[],geometries:[f]},I={attributeData:{},loadedAttributes:[]};i.projectionPromise||(o(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({localMatrix:y?.localMatrix,vertexSpace:x.toJSON(),origin:w,position:l.vertexAttributes.position,meshSR:l.spatialReference.toJSON(),indexSR:this._indexSR.toJSON()},n));const[N,S]=await i.projectionPromise;l.vertexAttributes.position=S;const{geometryBuffer:T,geometryDescriptor:_}=M(N,d.faces,l.vertexAttributes.normal,l.vertexAttributes.uv,l.vertexAttributes.color,u);return{geometryData:b,attributeDataInfo:I,geometryBuffer:T,geometryDescriptor:_,requiredTextures:m,textureData:h}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.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,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(l){r(l)}const a=s.memoryUsage,i={loadedMesh:s,projectionPromise:null,usedMemoryInBytes:a};this._memCache.put(t,i,a,n),e.loadMeshPromise=null,o(i)};return e.loadMeshPromise=new Promise(((e,t)=>o(e,t))),e.loadMeshPromise}return o}}function f(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let i=0;i<2;++i){const l=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[i]*n[2]-t.z;s=Math.max(l*l+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const i=r.x+o[a]*n[0]-t.x,l=r.y+o[e]*n[1]-t.y;s=Math.max(i*i+l*l,s)}return a([t.x,t.y,t.z],Math.sqrt(s))}async function p(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=y(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?c.None:c.Back,normalTextureId:await x(t.normalTexture,o,n,u.Normal),emissiveTextureId:r?await x(t.emissiveTexture,o,n,u.Emissive):-1,occlusionTextureId:r?await x(t.occlusionTexture,o,n,u.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await x(t.colorTexture,o,n,u.Color),metallicRoughnessTextureId:r?await x(t.metallicRoughnessTexture,o,n,u.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:m({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,emissiveFactor:r?e.toUnitRGBA(t.emissiveColor):null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function x(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,u=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const e=g(a);return n.push({id:s,usage:r,data:e,encoding:d.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:d.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof l)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=u){const e=new Image;e.src=u;const t=g(await i(e,e.src,!1,void 0));return n.push({id:s,usage:r,data:t,encoding:d.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:d.PNG}]}),s}return-1}function g(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),a}return e}function y(e){return e.hasOwnProperty("metallicRoughnessTexture")}function M(e,t,o,n,r,s){const a=1,i=t.length/3,l=3*i;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,x=0,g=0,y=0;u+=I,u+=I,d=u,u+=3*l*N,null!=o&&(c=!0,m=u,u+=3*l*N),null!=n&&(h=!0,f=u,u+=2*l*N),null!=r&&(p=!0,x=u,u+=4*l*S),g=u,u+=a*T,y=u,u+=2*a*I;const M=new ArrayBuffer(u),b=new Uint8Array(M);w(b,0,l),w(b,I,a);const _=new Float32Array(M,d),v=null!=o?new Float32Array(M,m):null,D=null!=n?new Float32Array(M,f):null,R=null!=r?new Uint8Array(M,x):null;for(let w=0;w<i;++w){const s=3*w;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,u=9*w+3*a;if(_[u]=e[l],_[u+1]=e[l+1],_[u+2]=e[l+2],null!=v&&(v[u]=o[l],v[u+1]=o[l+1],v[u+2]=o[l+2]),null!=D){const e=2*i,t=6*w+2*a;D[t]=n[e],D[t+1]=n[e+1]}if(null!=R){const e=4*i,t=12*w+4*a;R[t]=r[e],R[t+1]=r[e+1],R[t+2]=r[e+2],R[t+3]=r[e+3]}}}w(b,g,s),w(b,g+I,s/2**32),w(b,y,0),w(b,y+I,i-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function w(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function b(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return r();const o=t;let n="";for(const r of o)n+=r.makeHash();return n+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const I=4,N=4,S=1,T=8;export{h as I3SClientNodeLoader,M as createGeometryData};
5
+ import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{b as r}from"../../../../chunks/mat3.js";import{c as s}from"../../../../chunks/mat3f64.js";import{k as a}from"../../../../chunks/vec3.js";import{O as i}from"../../../../chunks/vec3f64.js";import{projectBoundingSphere as l}from"../../../../geometry/projection.js";import{k as d}from"../../../../chunks/sphere.js";import{ViewingMode as u}from"../../../ViewingMode.js";import{convertMeshMaterialToPBRMaterial as m}from"./I3SClientMaterialUtil.js";class c{constructor(e,t,o,n,r,s){this._uid=e,this._indexSR=t,this._renderSR=o,this._viewingMode=n,this._worker=s,this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._memCache=r.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,r=n.spatialReference,s=this._indexSR,a=h(n,e.origin);l(a,r,a,s);return{type:"mesh",id:o,version:y(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const o=this._id2Meta.get(t);if(null==o)throw new e(`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new e(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(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}}async loadNodeData(o,n){const l=o.id,d=this._id2Meta.get(l);if(null==d||"mesh-component"!==d.type)throw new e(`Failed to load client node data for node ${o.id} (unexpected node info)`);const c=d.meshNodeInfo,h=await this._getMeshData(c),p=h.loadedMesh,y=c.oid;if(null==p.components)throw new e(`Failed to load client node data for node ${o.id} (unexpected null reference)`);const M=p.components[d.componentIndex],{material:x,requiredTextures:g,textureData:_}=await m(M.material);if(null!=_)for(const e of _)null!=e&&d.textureData.set(e.id,e);const w={params:{material:x},type:"ArrayBufferView"},{vertexSpace:b,origin:N,transform:S}=p,D=[N.x,N.y,N.z??0],I={featureDataPosition:D,featureIds:[],geometries:[w]},v={attributeData:{},loadedAttributes:[]};h.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),h.projectionPromise=this._worker.project({positions:p.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:b.toJSON(),origin:D,inSpatialReference:p.spatialReference.toJSON(),outSpatialReference:this._indexSR.toJSON(),local:this._viewingMode===u.Local},n));const[j,A]=await h.projectionPromise,P=p.vertexAttributes.normal,R=null!=P&&null!=S&&(0!==S.rotationAngle||!a(S.scale,i));if(R&&!h.normalsTransformPromise){t(this._worker,"SceneLayerWorker is needed to transform mesh normals");const e=s();r(e,S.localMatrix),h.normalsTransformPromise=this._worker.transformNormals({normalMatrix:e,normals:P},n)}const[k,O]=R?await h.normalsTransformPromise:[P,P];p.vertexAttributes.position=A,p.vertexAttributes.normal=O;const{geometryBuffer:J,geometryDescriptor:C}=f(j,M.faces,k,p.vertexAttributes.uv,p.vertexAttributes.color,y);return{geometryData:I,attributeDataInfo:v,geometryBuffer:J,geometryDescriptor:C,requiredTextures:g,textureData:_}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(l){r(l)}const a=s.memoryUsage,i={loadedMesh:s,projectionPromise:null,normalsTransformPromise:null,usedMemoryInBytes:a};this._memCache.put(t,i,a,o),e.loadMeshPromise=null,n(i)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function h(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let i=0;i<2;++i){const l=r.x+o[a]*n[0]-t.x,d=r.y+o[e]*n[1]-t.y,u=r.z+o[i]*n[2]-t.z;s=Math.max(l*l+d*d+u*u,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const i=r.x+o[a]*n[0]-t.x,l=r.y+o[e]*n[1]-t.y;s=Math.max(i*i+l*l,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}function f(e,t,o,n,r,s){const a=1,i=t.length/3,l=3*i;let d=0,u=0,m=!1,c=0,h=!1,f=0,y=!1,w=0,b=0,N=0;d+=M,d+=M,u=d,d+=3*l*x,null!=o&&(m=!0,c=d,d+=3*l*x),null!=n&&(h=!0,f=d,d+=2*l*x),null!=r&&(y=!0,w=d,d+=4*l*g),b=d,d+=a*_,N=d,d+=2*a*M;const S=new ArrayBuffer(d),D=new Uint8Array(S);p(D,0,l),p(D,M,a);const I=new Float32Array(S,u),v=null!=o?new Float32Array(S,c):null,j=null!=n?new Float32Array(S,f):null,A=null!=r?new Uint8Array(S,w):null;for(let p=0;p<i;++p){const s=3*p;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,d=9*p+3*a;if(I[d]=e[l],I[d+1]=e[l+1],I[d+2]=e[l+2],null!=v&&(v[d]=o[l],v[d+1]=o[l+1],v[d+2]=o[l+2]),null!=j){const e=2*i,t=6*p+2*a;j[t]=n[e],j[t+1]=n[e+1]}if(null!=A){const e=4*i,t=12*p+4*a;A[t]=r[e],A[t+1]=r[e+1],A[t+2]=r[e+2],A[t+3]=r[e+3]}}}p(D,b,s),p(D,b+M,s/2**32),p(D,N,0),p(D,N+M,i-1);return{geometryBuffer:S,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:y,normal:m,uv0:h,uvRegion:!1,featureIndex:!0}}}function p(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function y(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const M=4,x=4,g=1,_=8;export{c as I3SClientNodeLoader,f as createGeometryData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{t,a as e}from"../../../../chunks/vec3.js";import{c as o}from"../../../../chunks/vec3f64.js";import{projectBuffer as r}from"../../../../geometry/projection.js";import{create as n,set as a,NEGATIVE_INFINITY as s,expandWithBuffer as m,ZERO as f}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";function c(o,r,n,a){const s=r.getComponentAabb(n,o,p),m=r.getObjectTransform(n);for(let f=0;f<8;++f)b[0]=1&f?s[0]:s[3],b[1]=2&f?s[1]:s[4],b[2]=4&f?s[2]:s[5],t(b,b,m.rotationScale),e(b,b,m.position),a[3*f]=b[0],a[3*f+1]=b[1],a[3*f+2]=b[2];return a}function i(t,e,o){const n=u(24);return u=>{let i=u.meta.featureExtents;if(null==i){i=new Float64Array(6*u.meta.featureIds.length),u.meta.featureExtents=i;for(let t=0;t<i.length;t+=6)i[t]=Number.POSITIVE_INFINITY}const l=new Float64Array(i.buffer,6*u.index*Float64Array.BYTES_PER_ELEMENT,6);return l[0]===Number.POSITIVE_INFINITY&&(c(u.index,o,u.meta.objectHandle,n),r(n,e,0,n,t,0,8)?(a(l,s),m(l,n,0,8)):a(l,f)),l}}function l(o,r,n,a){const s=r.getComponentAabb(n,o,p),m=r.getObjectTransform(n);a[0]=0,a[1]=0,a[2]=0;for(let f=0;f<8;++f)b[0]=1&f?s[0]:s[3],b[1]=2&f?s[1]:s[4],b[2]=s[5],t(b,b,m.rotationScale),e(b,b,m.position),a[0]+=b[0],a[1]+=b[1],a[2]+=b[2];return a[0]/=8,a[1]/=8,a[2]/=8,a}const p=n(),b=o();export{c as boundingBoxCornerPoints,l as boundingBoxTop,i as createGetFeatureExtent};
5
+ import{t,a as e}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{projectBuffer as o}from"../../../../geometry/projection.js";import{create as n,set as a,NEGATIVE_INFINITY as m,expandWithBuffer as s,ZERO as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as f}from"../../../../geometry/support/DoubleArray.js";function c(t,e,r){const n=f(24);return f=>{let c=f.meta.featureExtents;if(null==c){c=new Float64Array(6*f.meta.featureIds.length),f.meta.featureExtents=c;for(let t=0;t<c.length;t+=6)c[t]=Number.POSITIVE_INFINITY}const l=new Float64Array(c.buffer,6*f.index*Float64Array.BYTES_PER_ELEMENT,6);return l[0]===Number.POSITIVE_INFINITY&&(i(f.index,r,f.meta.objectHandle,n,0),o(n,e,0,n,t,0,8)?(a(l,m),s(l,n,0,8)):a(l,u)),l}}function i(r,o,n,a,m){const s=o.getComponentAabb(n,r,p),u=o.getObjectTransform(n);for(let f=0;f<8;++f)I[0]=1&f?s[0]:s[3],I[1]=2&f?s[1]:s[4],I[2]=4&f?s[2]:s[5],t(I,I,u.rotationScale),e(I,I,u.position),a[m++]=I[0],a[m++]=I[1],a[m++]=I[2];return a}const l=24,p=n(),I=r();export{l as BOUNDING_BOX_CORNERS_POINTS_STRIDE,i as boundingBoxCornerPoints,c as createGetFeatureExtent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import m from"../../../../core/ReactiveSet.js";import{watch as p,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as f,queryAllJSON as O}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as C,extractMesh as j}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as v,i3sPatchingEnabled as I,sceneLayerEditingEnabled as F}from"../../../../support/featureFlags.js";import{isTimeoutError as A}from"../../../../support/requestUtils.js";import L from"../FeatureLayerView3D.js";const E="esri.views.3d.layers.i3s.I3SOverrides";let w=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=S,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new m,this._geometryChangedObjectIds=new m,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(v()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(p((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new L({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(v()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return F()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(v()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=F()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new x(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s)}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=f(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(O(n,t,{signal:o}))})):[r(O(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=C(e,r.assetMaps);for(const i of r.features){const n=j(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger(E).warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:G,signal:e}));if(!h.ok&&A(h.error)){const e=this.layer.title;c.getLogger(E).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],c=[...o,...n,...d],l=a?[...o,...r??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,c.length);u<c.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=c.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],w.prototype,"view",void 0),e([y({constructOnly:!0})],w.prototype,"layer",void 0),e([y({readOnly:!0})],w.prototype,"is3DOFL",null),e([y()],w.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],w.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],w.prototype,"geometryOverrides",void 0),e([y()],w.prototype,"_clientGeometryCache",void 0),e([y()],w.prototype,"_associatedLayer",null),e([y()],w.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],w.prototype,"memoryController",void 0),e([y()],w.prototype,"_attributeChangedObjectIds",void 0),e([y()],w.prototype,"_geometryChangedObjectIds",void 0),e([y()],w.prototype,"hasGeometryChanges",null),e([y()],w.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],w.prototype,"_pendingFetchAbortController",void 0),e([y()],w.prototype,"_definitionExpression",null),e([y()],w.prototype,"updating",null),e([y()],w.prototype,"isEmpty",null),w=e([b(E)],w);class x{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=D.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=D.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=D.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===D.ACTIVE}}var D;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(D||(D={}));const G=1e4,S=5e4;export{w as I3SOverrides};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import m from"../../../../core/ReactiveSet.js";import{watch as p,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as f,queryAllJSON as O}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as C,extractMesh as j}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as v,i3sPatchingEnabled as I,sceneLayerEditingEnabled as F}from"../../../../support/featureFlags.js";import{isTimeoutError as A}from"../../../../support/requestUtils.js";import L from"../FeatureLayerView3D.js";const E="esri.views.3d.layers.i3s.I3SOverrides";let w=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=S,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new m,this._geometryChangedObjectIds=new m,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(v()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(p((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new L({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(v()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return F()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(v()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=F()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new x(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s)}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e,c.returnZ=s&&n.hasZ,c.returnM=s&&n.hasM;const h=f(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(O(n,t,{signal:o}))})):[r(O(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=C(e,r.assetMaps);for(const i of r.features){const n=j(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger(E).warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const h=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:G,signal:e}));if(!h.ok&&A(h.error)){const e=this.layer.title;c.getLogger(E).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(h.ok&&1===h.value.data?.edits?.length){const t=h.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],c=[...o,...n,...d],l=a?[...o,...r??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,c.length);u<c.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=c.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],w.prototype,"view",void 0),e([y({constructOnly:!0})],w.prototype,"layer",void 0),e([y({readOnly:!0})],w.prototype,"is3DOFL",null),e([y()],w.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],w.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],w.prototype,"geometryOverrides",void 0),e([y()],w.prototype,"_clientGeometryCache",void 0),e([y()],w.prototype,"_associatedLayer",null),e([y()],w.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],w.prototype,"memoryController",void 0),e([y()],w.prototype,"_attributeChangedObjectIds",void 0),e([y()],w.prototype,"_geometryChangedObjectIds",void 0),e([y()],w.prototype,"hasGeometryChanges",null),e([y()],w.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],w.prototype,"_pendingFetchAbortController",void 0),e([y()],w.prototype,"_definitionExpression",null),e([y()],w.prototype,"updating",null),e([y()],w.prototype,"isEmpty",null),w=e([b(E)],w);class x{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=D.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=D.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=D.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===D.ACTIVE}}var D;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(D||(D={}));const G=1e4,S=5e4;export{w as I3SOverrides};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{disposeMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I as a}from"../../../chunks/mat4f64.js";import{b as l,s as h,e as c}from"../../../chunks/vec3.js";import{Z as u,f as d,c as p}from"../../../chunks/vec3f64.js";import{Z as f}from"../../../chunks/vec4f64.js";import{create as _,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as g}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as b}from"../../ViewingMode.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as T}from"./LayerClass.js";import{OverlaySource as R}from"./Overlay.js";import{overlayRenderOccludedFlag as O}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as C}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as D}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{TileUpdate as S}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as q,compareTiles as A}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as w,ComponentIntersectionData as N}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as G}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as L}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as F}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as U}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as k}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as B}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as M,StoreResults as z}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as H}from"../webgl-engine/lib/Material.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as W}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Q,getVerticalOffsetTerrain as X}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as Z}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as K,intersectTriangles as J}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as $}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ee}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as te}from"../../webgl/enums.js";const re=7,ie=10,se=_();var ne;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(ne||(ne={}));let oe=class extends r{get _isGlobal(){return this._stage.viewingMode===b.Global}constructor(e){super(e),this.type=M.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new ee,this._passParameters=new I,this._rctx=null,this._renderDataPool=new s(C),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=ne.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=H.Occlude}initialize(){const e=[V.OPAQUE_TERRAIN,V.TRANSPARENT_TERRAIN,V.OCCLUDED_TERRAIN];this._stage.addRenderPlugin(e,this)}destroy(){this._stage.removeRenderPlugin(this),x()}get canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===ne.TransparentWithDraped||e===ne.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get needsLinearDepth(){return this._overlayRenderer.hasWater}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Q}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?O:H.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,S.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===S.TEXTURE_FADING?y.FADING:y.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const r of e.layerInfo[T.ELEVATION])r.pendingUpdates&=~S.GEOMETRY;e.resetPendingUpdate(S.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ie-re,r=Math.max(0,Math.floor((e.level-t)/re)*re);if(this._isGlobal&&0===r)return u;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=U.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=U.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=U.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=k(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,r,i){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==ne.Opaque)return;const s=ae,n=le;l(s,i,r),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,u=e.results.max,d=e.results.ground,p=e.options.store===z.MIN,f=!!e.results.ground.target,_=X(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=o.dist?o.dist:1/0;const R=h=>{const f=h.renderData;if(!f?.vao)return;const R=f.geometry;m(se,R.boundingBox);const O=f.localOrigin;null!=_&&(_.localOrigin=O,_.applyToAabb(se));const x=se;if(he[0]=r[0]-O[0],he[1]=r[1]-O[1],he[2]=r[2]-O[2],!K(x,he,n,b,T))return;const C=(e,t,r)=>{e.set(this.type,h,t,r,a),T=p&&null!=o.dist?o.dist:1/0},v=(n,a)=>{if(null!=a&&n>=0&&(e.options.backfacesTerrain||c(a,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,i,n))){if((null==d.dist||n<d.dist)&&C(d,n,a),e.options.isFiltered)return;e.options.store===z.ALL&&(null==y?(y=B(e.ray),C(y,n,a),e.results.all.push(y)):n<y.dist&&C(y,n,a)),(null==o.dist||n<o.dist)&&C(o,n,a),e.options.store!==z.MIN&&(null==u.dist||n>u.dist)&&C(u,n,a)}},D=ce;l(D,i,O);const P=R.indices,S=R.vertexAttributes,E=S.getField(Y.POSITION,g),q=new F(E.typedBuffer,3,!1,S.stride/4),A=R.indexCount/3;if(!_&&A>w){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new N(P,0,A,q)),e.intersectionData.intersectRay({r0:he,r1:D},v)}else J(he,D,0,A,P,q,null,_,v)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const i=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||i&&e.intersectsClippingArea)||null==_&&!e.intersectsRay(r,s,b,T)||f&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const r of t)null!=r.renderData?.textureReference&&e.queriesForTile(r);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===V.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&O))return null}else{const t=this.transparency===ne.Opaque?V.OPAQUE_TERRAIN:V.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case j.Color:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=e.bindParameters.ssr.enabled,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.active,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?G.Disabled:this._overlayRenderer.hasWater?G.EnabledWithWater:G.Enabled,this._updateTechnique(j.Color,e.bindParameters.slot===V.OCCLUDED_TERRAIN));case j.Shadow:case j.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Shadow,!1)):null;case j.Depth:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Depth,!1));case j.Normal:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Normal,!1));case j.ObjectAndLayerIdColor:return this.transparency===ne.Empty?null:this._updateTechnique(j.ObjectAndLayerIdColor,!1);case j.Highlight:return this.transparency!==ne.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Highlight,!1)):null}return null}render(e,t){const r=1===e.bindParameters.lighting.globalFactor;switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case j.Color:{const r=e.bindParameters.slot===V.OCCLUDED_TERRAIN?R.Occluded:R.ColorAndWater;this.transparency===ne.Opaque?this._renderMaterialPass(e,t,r):e.offscreenRenderingHelper.renderToTargets((()=>this._renderMaterialPass(e,t,r)),e.offscreenRenderingHelper.tmpColor,e.offscreenRenderingHelper.mainDepth,[0,0,0,0]);break}case j.Depth:case j.Normal:this._renderAuxiliaryPass(e,t,R.None);break;case j.Highlight:this.needsHighlight&&this._renderAuxiliaryPass(e,t,R.Highlight);break;case j.Shadow:case j.ShadowExcludeHighlight:this._castShadows&&r&&this._renderAuxiliaryPass(e,t,R.None);break;case j.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,r){const{rctx:i}=e;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,r)}_renderAuxiliaryPass(e,t,r){const i=e.rctx;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,r)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const r=this._tileRenderer;let i=null;if(null!=e){const r=t.toUnitRGBA(e);i=d(r[0]||0,r[1]||0,r[2]||0)}r.setBackground(i),this._allTiles.forAll((e=>r.updateTileTexture(e,y.FADING))),this._techniqueConfiguration.tileBlendInput=r.backgroundIsGrid?L.GridComposite:null!=r.backgroundColor?L.ColorComposite:L.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const r of e)q(this.renderOrder,r,t);e.sort(((e,t)=>A(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),r=e.renderData;if(!r){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const i=r.localOrigin;let s=this._patchGroups.get(i);s||(s=new Array,this._patchGroups.set(i,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new Z(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],te.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const i=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=W(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:i.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=r===R.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",u),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:u;this._techniqueConfiguration.tileBlendInput===L.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?te.LINES:te.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const h=this._patchGroups;for(const c of h.values()){const i=c[0].renderData.localOrigin;t.program.bindDraw(new Z(i),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of c){const i=a.renderData,h=i.textureReference;if(null!=h){if(!o){s.setUniform4fv("texOffsetAndScale",h.offsetAndScale),s.bindTexture("tex",h.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",h.opacities)}this._renderPatch(e,t,a,l,n,r),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,r,i,s,n){const o=r.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(D&&console.error("Rendered tile with no indices: ",r.lij," : ",o));const h=t.program;n===R.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,o.overlay),s&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.bindParameters.slot));const c=o.geometry.indexCount;e.rctx.bindVAO(a),h.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(i,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire($,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([n({constructOnly:!0})],oe.prototype,"_overlayRenderer",void 0),e([n({constructOnly:!0})],oe.prototype,"_stage",void 0),e([n({readOnly:!0})],oe.prototype,"_isGlobal",null),e([n({constructOnly:!0})],oe.prototype,"_allTiles",void 0),e([n({constructOnly:!0})],oe.prototype,"_ellipsoidRadius",void 0),e([n({value:!1})],oe.prototype,"renderingDisabled",null),e([n()],oe.prototype,"renderPatchBorders",null),e([n()],oe.prototype,"visualizeNormals",null),e([n()],oe.prototype,"cullBackFaces",null),e([n({value:v.FRONT_TO_BACK})],oe.prototype,"renderOrder",null),e([n()],oe.prototype,"wireframe",null),oe=e([o("esri.views.3d.terrain.TerrainRenderer")],oe);const ae=p(),le=p(),he=p(),ce=p();export{oe as TerrainRenderer,ne as TransparencyMode};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{disposeMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I as a}from"../../../chunks/mat4f64.js";import{b as l,s as h,e as c}from"../../../chunks/vec3.js";import{Z as u,f as d,c as p}from"../../../chunks/vec3f64.js";import{Z as f}from"../../../chunks/vec4f64.js";import{create as _,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as g}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as b}from"../../ViewingMode.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as T}from"./LayerClass.js";import{OverlaySource as R}from"./Overlay.js";import{overlayRenderOccludedFlag as O}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as C}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as D}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{TileUpdate as S}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as q,compareTiles as A}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as w,ComponentIntersectionData as N}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as G}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as L}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as F}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as U}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as k}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as B}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as M,StoreResults as z}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as H}from"../webgl-engine/lib/Material.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as W}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Q,getVerticalOffsetTerrain as X}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as Z}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as K,intersectTriangles as J}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as $}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ee}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as te}from"../../webgl/enums.js";const re=7,ie=10,se=_();var ne;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(ne||(ne={}));let oe=class extends r{get _isGlobal(){return this._stage.viewingMode===b.Global}constructor(e){super(e),this.type=M.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new ee,this._passParameters=new I,this._rctx=null,this._renderDataPool=new s(C),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=ne.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=H.Occlude}initialize(){const e=[V.OPAQUE_TERRAIN,V.TRANSPARENT_TERRAIN,V.OCCLUDED_TERRAIN];this._stage.addRenderPlugin(e,this)}destroy(){this._stage.removeRenderPlugin(this),x()}get canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===ne.TransparentWithDraped||e===ne.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get needsLinearDepth(){return this._overlayRenderer.hasWater}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Q}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?O:H.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,S.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===S.TEXTURE_FADING?y.FADING:y.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const r of e.layerInfo[T.ELEVATION])r.pendingUpdates&=~S.GEOMETRY;e.resetPendingUpdate(S.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ie-re,r=Math.max(0,Math.floor((e.level-t)/re)*re);if(this._isGlobal&&0===r)return u;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=U.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=U.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=U.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=k(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,r,i){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==ne.Opaque)return;const s=ae,n=le;l(s,i,r),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,u=e.results.max,d=e.results.ground,p=e.options.store===z.MIN,f=!!e.results.ground.target,_=X(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=o.dist?o.dist:1/0;const R=h=>{const f=h.renderData;if(!f?.vao)return;const R=f.geometry;m(se,R.boundingBox);const O=f.localOrigin;null!=_&&(_.localOrigin=O,_.applyToAabb(se));const x=se;if(he[0]=r[0]-O[0],he[1]=r[1]-O[1],he[2]=r[2]-O[2],!K(x,he,n,b,T))return;const C=(e,t,r)=>{e.set(this.type,h,t,r,a),T=p&&null!=o.dist?o.dist:1/0},v=(n,a)=>{if(null!=a&&n>=0&&(e.options.backfacesTerrain||c(a,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,i,n))){if((null==d.dist||n<d.dist)&&C(d,n,a),e.options.isFiltered)return;e.options.store===z.ALL&&(null==y?(y=B(e.ray),C(y,n,a),e.results.all.push(y)):n<y.dist&&C(y,n,a)),(null==o.dist||n<o.dist)&&C(o,n,a),e.options.store!==z.MIN&&(null==u.dist||n>u.dist)&&C(u,n,a)}},D=ce;l(D,i,O);const P=R.indices,S=R.vertexAttributes,E=S.getField(Y.POSITION,g),q=new F(E.typedBuffer,3,!1,S.stride/4),A=R.indexCount/3;if(!_&&A>w){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new N(P,0,A,q)),e.intersectionData.intersectRay({r0:he,r1:D},v)}else J(he,D,0,A,P,q,null,_,v)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const i=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||i&&e.intersectsClippingArea)||null==_&&!e.intersectsRay(r,s,b,T)||f&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const r of t)null!=r.renderData?.textureReference&&e.queriesForTile(r);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===V.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&O))return null}else{const t=this.transparency===ne.Opaque?V.OPAQUE_TERRAIN:V.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case j.Color:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=e.bindParameters.ssr.enabled,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.active,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?G.Disabled:this._overlayRenderer.hasWater?G.EnabledWithWater:G.Enabled,this._updateTechnique(j.Color,e.bindParameters.slot===V.OCCLUDED_TERRAIN));case j.Shadow:case j.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Shadow,!1)):null;case j.Depth:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Depth,!1));case j.Normal:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Normal,!1));case j.ObjectAndLayerIdColor:return this.transparency===ne.Empty?null:this._updateTechnique(j.ObjectAndLayerIdColor,!1);case j.Highlight:return this.transparency!==ne.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Highlight,!1)):null}return null}render(e,t){const r=1===e.bindParameters.lighting.globalFactor;switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case j.Color:{const r=e.bindParameters.slot===V.OCCLUDED_TERRAIN?R.Occluded:R.ColorAndWater;this.transparency===ne.Opaque?this._renderMaterialPass(e,t,r):e.offscreenRenderingHelper.renderToTargets((()=>this._renderMaterialPass(e,t,r)),e.offscreenRenderingHelper.tmpColor,e.offscreenRenderingHelper.mainDepth,[0,0,0,0]);break}case j.Depth:case j.Normal:this._renderAuxiliaryPass(e,t,R.ColorAndWater);break;case j.Highlight:this.needsHighlight&&this._renderAuxiliaryPass(e,t,R.Highlight);break;case j.Shadow:case j.ShadowExcludeHighlight:this._castShadows&&r&&this._renderAuxiliaryPass(e,t,R.None);break;case j.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,r){const{rctx:i}=e;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,r)}_renderAuxiliaryPass(e,t,r){const i=e.rctx;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,r)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const r=this._tileRenderer;let i=null;if(null!=e){const r=t.toUnitRGBA(e);i=d(r[0]||0,r[1]||0,r[2]||0)}r.setBackground(i),this._allTiles.forAll((e=>r.updateTileTexture(e,y.FADING))),this._techniqueConfiguration.tileBlendInput=r.backgroundIsGrid?L.GridComposite:null!=r.backgroundColor?L.ColorComposite:L.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const r of e)q(this.renderOrder,r,t);e.sort(((e,t)=>A(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),r=e.renderData;if(!r){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const i=r.localOrigin;let s=this._patchGroups.get(i);s||(s=new Array,this._patchGroups.set(i,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new Z(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],te.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const i=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=W(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:i.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=r===R.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",u),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:u;this._techniqueConfiguration.tileBlendInput===L.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?te.LINES:te.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const h=this._patchGroups;for(const c of h.values()){const i=c[0].renderData.localOrigin;t.program.bindDraw(new Z(i),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of c){const i=a.renderData,h=i.textureReference;if(null!=h){if(!o){s.setUniform4fv("texOffsetAndScale",h.offsetAndScale),s.bindTexture("tex",h.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",h.opacities)}this._renderPatch(e,t,a,l,n,r),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,r,i,s,n){const o=r.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(D&&console.error("Rendered tile with no indices: ",r.lij," : ",o));const h=t.program;n===R.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,o.overlay),s&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.bindParameters.slot));const c=o.geometry.indexCount;e.rctx.bindVAO(a),h.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(i,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire($,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([n({constructOnly:!0})],oe.prototype,"_overlayRenderer",void 0),e([n({constructOnly:!0})],oe.prototype,"_stage",void 0),e([n({readOnly:!0})],oe.prototype,"_isGlobal",null),e([n({constructOnly:!0})],oe.prototype,"_allTiles",void 0),e([n({constructOnly:!0})],oe.prototype,"_ellipsoidRadius",void 0),e([n({value:!1})],oe.prototype,"renderingDisabled",null),e([n()],oe.prototype,"renderPatchBorders",null),e([n()],oe.prototype,"visualizeNormals",null),e([n()],oe.prototype,"cullBackFaces",null),e([n({value:v.FRONT_TO_BACK})],oe.prototype,"renderOrder",null),e([n()],oe.prototype,"wireframe",null),oe=e([o("esri.views.3d.terrain.TerrainRenderer")],oe);const ae=p(),le=p(),he=p(),ce=p();export{oe as TerrainRenderer,ne as TransparencyMode};
@@ -2,31 +2,30 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as r}from"../ShaderOutput.js";import{SliceDraw as t}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as a,NormalType as s}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as l}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as n}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as c}from"../output/OutputDepth.glsl.js";import{OutputHighlight as u}from"../output/OutputHighlight.glsl.js";import{VisualVariables as m}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as f}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as g}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as x}from"../../../lib/basicInterfaces.js";function j(j,w){const{vertex:C,fragment:O}=j,b=w.hasModelTransformation;b&&C.uniforms.add(new h("model",(e=>e.modelTransformation??o)));const T=w.hasColorTexture&&w.alphaDiscardMode!==x.Opaque;switch(w.output){case r.Depth:case r.Shadow:case r.ShadowHighlight:case r.ShadowExcludeHighlight:case r.ObjectAndLayerIdColor:v(C,w),j.include(i,w),j.include(d,w),j.include(m,w),j.include(c,w),j.include(t,w),j.include(l,w),e(j),j.varyings.add("depth","float"),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
5
+ import{b as o}from"../../../../../../chunks/mat3.js";import{c as r}from"../../../../../../chunks/mat3f64.js";import{I as e}from"../../../../../../chunks/mat4f64.js";import{addNearFar as t}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as i}from"../ShaderOutput.js";import{SliceDraw as a}from"../Slice.glsl.js";import{Transform as s}from"../Transform.glsl.js";import{NormalAttribute as l,NormalType as d}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as n}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as m}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as c}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as u}from"../output/OutputDepth.glsl.js";import{OutputHighlight as p}from"../output/OutputHighlight.glsl.js";import{VisualVariables as v}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as f}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as h}from"../util/View.glsl.js";import{glsl as g}from"../../shaderModules/interfaces.js";import{Matrix3PassUniform as x}from"../../shaderModules/Matrix3PassUniform.js";import{Matrix4PassUniform as j}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as w}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as T}from"../../../lib/basicInterfaces.js";function b(b,C){const{vertex:O,fragment:y}=b,V=C.hasModelTransformation;if(V){const t=r();O.uniforms.add(new j("model",(o=>o.modelTransformation??e))),O.uniforms.add(new x("normalTransform",(r=>(o(t,r.modelTransformation??e),t))))}const A=C.hasColorTexture&&C.alphaDiscardMode!==T.Opaque;switch(C.output){case i.Depth:case i.Shadow:case i.ShadowHighlight:case i.ShadowExcludeHighlight:case i.ObjectAndLayerIdColor:h(O,C),b.include(s,C),b.include(m,C),b.include(v,C),b.include(u,C),b.include(a,C),b.include(n,C),t(b),b.varyings.add("depth","float"),A&&y.uniforms.add(new w("tex",(o=>o.texture))),O.code.add(g`
6
6
  void main(void) {
7
7
  vpos = calculateVPos();
8
- ${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
8
+ ${V?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
9
9
  vpos = subtractOrigin(vpos);
10
10
  vpos = addVerticalOffset(vpos, localOrigin);
11
11
  gl_Position = transformPositionWithDepth(proj, view, vpos, nearFar, depth);
12
12
  forwardTextureCoordinates();
13
13
  forwardObjectAndLayerIdColor();
14
14
  }
15
- `),j.include(p,w),O.code.add(f`
15
+ `),b.include(f,C),y.code.add(g`
16
16
  void main(void) {
17
17
  discardBySlice(vpos);
18
- ${T?f`
19
- vec4 texColor = texture(tex, ${w.hasColorTextureTransform?f`colorUV`:f`vuv0`});
18
+ ${A?g`
19
+ vec4 texColor = texture(tex, ${C.hasColorTextureTransform?g`colorUV`:g`vuv0`});
20
20
  discardOrAdjustAlpha(texColor);`:""}
21
- ${w.output===r.ObjectAndLayerIdColor?f`outputObjectAndLayerIdColor();`:f`outputDepth(depth);`}
21
+ ${C.output===i.ObjectAndLayerIdColor?g`outputObjectAndLayerIdColor();`:g`outputDepth(depth);`}
22
22
  }
23
- `);break;case r.Normal:{v(C,w),j.include(i,w),j.include(a,w),j.include(n,w),j.include(d,w),j.include(m,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),w.normalType===s.ScreenDerivative&&j.varyings.add("vPositionView","vec3");const o=w.normalType===s.Attribute||w.normalType===s.Compressed;C.code.add(f`
23
+ `);break;case i.Normal:{h(O,C),b.include(s,C),b.include(l,C),b.include(c,C),b.include(m,C),b.include(v,C),A&&y.uniforms.add(new w("tex",(o=>o.texture))),C.normalType===d.ScreenDerivative&&b.varyings.add("vPositionView","vec3");const o=C.normalType===d.Attribute||C.normalType===d.Compressed;O.code.add(g`
24
24
  void main(void) {
25
25
  vpos = calculateVPos();
26
- ${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
26
+ ${V?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
27
27
 
28
- ${o?f`
29
- vNormalWorld = dpNormalView(vvLocalNormal(normalModel()));`:f`
28
+ ${o?g`vNormalWorld = ${V?"normalize(normalTransform * dpNormal(vvLocalNormal(normalModel())))":"dpNormalView(vvLocalNormal(normalModel()))"};`:g`
30
29
  // Get vertex position in camera space for screen-space derivative normals
31
30
  vPositionView = (view * vec4(vpos, 1.0)).xyz;
32
31
  `}
@@ -35,35 +34,35 @@ import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}f
35
34
  gl_Position = transformPosition(proj, view, vpos);
36
35
  forwardTextureCoordinates();
37
36
  }
38
- `),j.include(t,w),j.include(p,w),O.code.add(f`
37
+ `),b.include(a,C),b.include(f,C),y.code.add(g`
39
38
  void main() {
40
39
  discardBySlice(vpos);
41
- ${T?f`
42
- vec4 texColor = texture(tex, ${w.hasColorTextureTransform?f`colorUV`:f`vuv0`});
40
+ ${A?g`
41
+ vec4 texColor = texture(tex, ${C.hasColorTextureTransform?g`colorUV`:g`vuv0`});
43
42
  discardOrAdjustAlpha(texColor);`:""}
44
43
 
45
- ${w.normalType===s.ScreenDerivative?f`vec3 normal = screenDerivativeNormal(vPositionView);`:f`
44
+ ${C.normalType===d.ScreenDerivative?g`vec3 normal = screenDerivativeNormal(vPositionView);`:g`
46
45
  vec3 normal = normalize(vNormalWorld);
47
46
  if (gl_FrontFacing == false){
48
47
  normal = -normal;
49
48
  }`}
50
49
  fragColor = vec4(0.5 + 0.5 * normal, 1.0);
51
50
  }
52
- `);break}case r.Highlight:v(C,w),j.include(i,w),j.include(d,w),j.include(m,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
51
+ `);break}case i.Highlight:h(O,C),b.include(s,C),b.include(m,C),b.include(v,C),A&&y.uniforms.add(new w("tex",(o=>o.texture))),O.code.add(g`
53
52
  void main(void) {
54
53
  vpos = calculateVPos();
55
- ${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
54
+ ${V?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
56
55
  vpos = subtractOrigin(vpos);
57
56
  vpos = addVerticalOffset(vpos, localOrigin);
58
57
  gl_Position = transformPosition(proj, view, vpos);
59
58
  forwardTextureCoordinates();
60
59
  }
61
- `),j.include(t,w),j.include(p,w),j.include(u,w),O.code.add(f`
60
+ `),b.include(a,C),b.include(f,C),b.include(p,C),y.code.add(g`
62
61
  void main() {
63
62
  discardBySlice(vpos);
64
- ${T?f`
65
- vec4 texColor = texture(tex, ${w.hasColorTextureTransform?f`colorUV`:f`vuv0`});
63
+ ${A?g`
64
+ vec4 texColor = texture(tex, ${C.hasColorTextureTransform?g`colorUV`:g`vuv0`});
66
65
  discardOrAdjustAlpha(texColor);`:""}
67
66
  outputHighlight();
68
67
  }
69
- `)}}export{j as DefaultMaterialAuxiliaryPasses};
68
+ `)}}export{b as DefaultMaterialAuxiliaryPasses};
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{I as e}from"../../../../../../chunks/mat4f64.js";import{c as a}from"../../../../../../chunks/vec3f64.js";import{RgbaFloatEncoding as s}from"../util/RgbaFloatEncoding.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{NoParameters as i,glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4sDrawUniform as d}from"../../shaderModules/Matrix4sDrawUniform.js";import{Matrix4sPassUniform as l}from"../../shaderModules/Matrix4sPassUniform.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";class p extends i{constructor(){super(...arguments),this.origin=a()}}class c extends p{}class h extends i{constructor(){super(...arguments),this.modelTransformation=e}}class v extends h{constructor(){super(...arguments),this.origin=a()}}function f(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new l("shadowMapMatrix",((e,a)=>a.shadowMap.getShadowMapMatrices(e.origin,e.modelTransformation)),4)),u(e))}function m(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new d("shadowMapMatrix",((e,a,s)=>a.shadowMap.getShadowMapMatrices(e.origin,s.modelTransformation)),4)),u(e))}function u(e){const a=e.fragment;a.include(s),a.uniforms.add(new n("shadowMapTex",((e,a)=>a.shadowMap.depthTexture)),new t("numCascades",((e,a)=>a.shadowMap.numCascades)),new o("cascadeDistances",((e,a)=>a.shadowMap.cascadeDistances))),a.code.add(r`int chooseCascade(float depth, out mat4 mat) {
5
+ import{I as e}from"../../../../../../chunks/mat4f64.js";import{c as a}from"../../../../../../chunks/vec3f64.js";import{RgbaFloatEncoding as s}from"../util/RgbaFloatEncoding.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{IntegerPassUniform as t}from"../../shaderModules/IntegerPassUniform.js";import{NoParameters as i,glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4sDrawUniform as d}from"../../shaderModules/Matrix4sDrawUniform.js";import{Matrix4sPassUniform as l}from"../../shaderModules/Matrix4sPassUniform.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";class p extends i{constructor(){super(...arguments),this.origin=a()}}class c extends p{}class h extends i{constructor(){super(...arguments),this.modelTransformation=e}}class v extends h{constructor(){super(...arguments),this.origin=a()}}function f(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new l("shadowMapMatrix",((e,a)=>a.shadowMap.getShadowMapMatrices(e.origin)),4)),x(e))}function u(e,a){a.receiveShadows&&(e.fragment.uniforms.add(new d("shadowMapMatrix",((e,a)=>a.shadowMap.getShadowMapMatrices(e.origin)),4)),x(e))}function x(e){const a=e.fragment;a.include(s),a.uniforms.add(new n("shadowMapTex",((e,a)=>a.shadowMap.depthTexture)),new t("numCascades",((e,a)=>a.shadowMap.numCascades)),new o("cascadeDistances",((e,a)=>a.shadowMap.cascadeDistances))),a.code.add(r`int chooseCascade(float depth, out mat4 mat) {
6
6
  vec4 distance = cascadeDistances;
7
7
  int i = depth < distance[1] ? 0 : depth < distance[2] ? 1 : depth < distance[3] ? 2 : 3;
8
8
  mat = i == 0 ? shadowMapMatrix[0] : i == 1 ? shadowMapMatrix[1] : i == 2 ? shadowMapMatrix[2] : shadowMapMatrix[3];
@@ -40,4 +40,4 @@ if (lvpos.z >= 1.0) { return 0.0; }
40
40
  if (lvpos.x < 0.0 || lvpos.x > 1.0 || lvpos.y < 0.0 || lvpos.y > 1.0) { return 0.0; }
41
41
  vec2 uv = cascadeCoordinates(i, lvpos);
42
42
  return filterShadow(uv, lvpos, float(textureSize(shadowMapTex, 0).x), shadowMapTex);
43
- }`)}export{m as ReadShadowMapDraw,c as ReadShadowMapDrawParameters,h as ReadShadowMapParameters,f as ReadShadowMapPass,v as ReadShadowMapPassParameters};
43
+ }`)}export{u as ReadShadowMapDraw,c as ReadShadowMapDrawParameters,h as ReadShadowMapParameters,f as ReadShadowMapPass,v as ReadShadowMapPassParameters};
@@ -2,26 +2,26 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{OverlayIndex as e}from"../../../../terrain/interfaces.js";import{ReadShadowMapPassParameters as o}from"../shading/ReadShadowMap.glsl.js";import{BackgroundGrid as r}from"./BackgroundGrid.glsl.js";import{overlay as t}from"./Overlay.glsl.js";import{TileBlendInput as s}from"./TileBlendInput.js";import{FloatPassUniform as c}from"../../shaderModules/FloatPassUniform.js";import{glsl as a}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as n}from"../../shaderModules/Texture2DPassUniform.js";import{Uniform as d}from"../../shaderModules/Uniform.js";class i extends o{constructor(){super(...arguments),this.overlayOpacity=1}}function l(o,r){o.vertex.uniforms.add(new v("overlayTexOffset"),new v("overlayTexScale")),o.fragment.uniforms.add(new c("overlayOpacity",(e=>e.overlayOpacity)),new n("ovColorTex",((o,r)=>0===r.overlays.length?null:r.overlays[e.INNER].getColorTexture(o.overlaySource)))),t(o,r)}function u(e,o){const{vertex:t,fragment:c,varyings:n}=e;n.add("vtc","vec2"),t.uniforms.add(new v("texOffsetAndScale")),c.uniforms.add(new m("tex")),c.uniforms.add(new x("textureOpacities"));const d=o.textureFadingEnabled&&!o.renderOccluded;d&&(t.uniforms.add(new v("nextTexOffsetAndScale")),n.add("nvtc","vec2"),c.uniforms.add(new m("texNext")),c.uniforms.add(new x("nextTexOpacities")),c.uniforms.add(new f("fadeFactor")));const i=o.tileBlendInput===s.ColorComposite,l=o.tileBlendInput===s.GridComposite;l&&c.include(r),i&&c.uniforms.add(new x("backgroundColor")),t.code.add(a`
5
+ import{OverlayIndex as e}from"../../../../terrain/interfaces.js";import{OverlaySource as r}from"../../../../terrain/Overlay.js";import{ReadShadowMapPassParameters as o}from"../shading/ReadShadowMap.glsl.js";import{BackgroundGrid as t}from"./BackgroundGrid.glsl.js";import{overlay as s}from"./Overlay.glsl.js";import{TileBlendInput as a}from"./TileBlendInput.js";import{FloatPassUniform as c}from"../../shaderModules/FloatPassUniform.js";import{glsl as n}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as i}from"../../shaderModules/Texture2DPassUniform.js";import{Uniform as d}from"../../shaderModules/Uniform.js";class l extends o{constructor(){super(...arguments),this.overlayOpacity=1,this.overlaySource=r.None}}function u(r,o){r.vertex.uniforms.add(new m("overlayTexOffset"),new m("overlayTexScale")),r.fragment.uniforms.add(new c("overlayOpacity",(e=>e.overlayOpacity)),new i("ovColorTex",((r,o)=>0===o.overlays.length?null:o.overlays[e.INNER].getColorTexture(r.overlaySource)))),s(r,o)}function f(e,r){const{vertex:o,fragment:s,varyings:c}=e;c.add("vtc","vec2"),o.uniforms.add(new m("texOffsetAndScale")),s.uniforms.add(new p("tex")),s.uniforms.add(new v("textureOpacities"));const i=r.textureFadingEnabled&&!r.renderOccluded;i&&(o.uniforms.add(new m("nextTexOffsetAndScale")),c.add("nvtc","vec2"),s.uniforms.add(new p("texNext")),s.uniforms.add(new v("nextTexOpacities")),s.uniforms.add(new x("fadeFactor")));const d=r.tileBlendInput===a.ColorComposite,l=r.tileBlendInput===a.GridComposite;l&&s.include(t),d&&s.uniforms.add(new v("backgroundColor")),o.code.add(n`
6
6
  void forwardTextureCoordinatesWithTransform(in vec2 uv) {
7
7
  vtc = uv * texOffsetAndScale.zw + texOffsetAndScale.xy;
8
- ${d?a`nvtc = uv * nextTexOffsetAndScale.zw + nextTexOffsetAndScale.xy;`:a``}
9
- }`),c.code.add(a`
8
+ ${i?n`nvtc = uv * nextTexOffsetAndScale.zw + nextTexOffsetAndScale.xy;`:n``}
9
+ }`),s.code.add(n`
10
10
  vec4 getColor(vec4 color, vec2 uv, vec3 opacities) {
11
- ${l||i?a`
11
+ ${l||d?n`
12
12
  if (opacities.y <= 0.0) {
13
13
  return color * opacities.z * opacities.x;
14
14
  }
15
- vec4 bg = vec4(${i?a`backgroundColor`:a`gridColor(uv)`} * opacities.y, opacities.y);
15
+ vec4 bg = vec4(${d?n`backgroundColor`:n`gridColor(uv)`} * opacities.y, opacities.y);
16
16
  vec4 layer = color * opacities.z;
17
- return (bg * (1.0 - layer.a) + layer) * opacities.x;`:a`return color;`}
18
- }`),d?c.code.add(a`vec4 getTileColor() {
17
+ return (bg * (1.0 - layer.a) + layer) * opacities.x;`:n`return color;`}
18
+ }`),i?s.code.add(n`vec4 getTileColor() {
19
19
  vec4 color = getColor(texture(tex, vtc), vtc, textureOpacities);
20
20
  if (fadeFactor >= 1.0) {
21
21
  return color;
22
22
  }
23
23
  vec4 nextColor = getColor(texture(texNext, nvtc), nvtc, nextTexOpacities);
24
24
  return mix(nextColor, color, fadeFactor);
25
- }`):c.code.add(a`vec4 getTileColor() {
25
+ }`):s.code.add(n`vec4 getTileColor() {
26
26
  return getColor(texture(tex, vtc), vtc, textureOpacities);
27
- }`)}class f extends d{constructor(e){super(e,"float")}}class x extends d{constructor(e){super(e,"vec3")}}class v extends d{constructor(e){super(e,"vec4")}}class m extends d{constructor(e){super(e,"sampler2D")}}export{x as Float3Uniform,l as OverlayTerrain,i as OverlayTerrainPassParameters,u as TerrainTexture,m as Texture2DUniform};
27
+ }`)}class x extends d{constructor(e){super(e,"float")}}class v extends d{constructor(e){super(e,"vec3")}}class m extends d{constructor(e){super(e,"vec4")}}class p extends d{constructor(e){super(e,"sampler2D")}}export{v as Float3Uniform,u as OverlayTerrain,l as OverlayTerrainPassParameters,f as TerrainTexture,p as Texture2DUniform};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{c as a}from"../../../../chunks/mat3f64.js";import{w as r,m as n,a as o,u as c}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f64.js";import{s as u,i as m,a as _,l,k as d,c as p,g as f,n as x,e as g,j as w}from"../../../../chunks/vec2.js";import{a as M}from"../../../../chunks/vec2f64.js";import{k as b,c as S,o as C,m as T,s as j}from"../../../../chunks/vec3.js";import{c as y}from"../../../../chunks/vec3f64.js";import{s as D,t as v}from"../../../../chunks/vec4.js";import{c as z}from"../../../../chunks/vec4f64.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{CascadeCamera as O}from"./CascadeCamera.js";import{applyTextureResizeModulo as R}from"./textureUtils.js";import{assert as U,logWithBase as F,verify as N,rayRay2D as k}from"./Util.js";import{TextureType as A,ClearBufferBit as L,TextureWrapMode as H,TextureSamplingMode as Q,RenderbufferFormat as V}from"../../../webgl/enums.js";import{FramebufferObject as I}from"../../../webgl/FramebufferObject.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as B}from"../../../webgl/Texture.js";import{TextureDescriptor as G}from"../../../webgl/TextureDescriptor.js";var X;!function(t){t[t.Highlight=0]="Highlight",t[t.Default=1]="Default"}(X||(X={}));class q{constructor(){this.camera=new O,this.lightMat=h()}}class W{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class J{get depthTexture(){return this._fbo?.colorTexture}get textureSize(){return this._textureSize}get numCascades(){return this._numCascades}get cascadeDistances(){return D(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}constructor(t,s){this._rctx=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureSize=0,this._numCascades=1,this.settings=new W,this._projectionView=h(),this._projectionViewInverse=h(),this._modelViewLight=h(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=z(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureSize=Math.min(has("esri-mobile")?2048:8192,this._rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._fbo=i(this._fbo),this._discardAllSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}getSnapshot(t){return this.enabled?this._snapshots[t]:null}get cascades(){for(let t=0;t<this._numCascades;++t)rt[t]=this._cascades[t];return rt.length=this._numCascades,rt}start(t,s,e,i,a){U(this.enabled),this._textureSize=this._computeTextureSize(t,a,i),this._ensureDepthTexture();const{near:r,far:n}=this._clampNearFar(e);this._computeCascadeDistances(n,r,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:c}=t;for(let h=0;h<this._numCascades;++h)this._constructCascade(h,c,o,s);this._lastOrigin=null,this.clear()}finish(t){U(this.enabled),this._rctx.bindFramebuffer(t)}getShadowMapMatrices(t,s){if(!this._lastOrigin||!b(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||y(),S(this._lastOrigin,t);for(let e=0;e<this._numCascades;++e){r(nt,this._cascades[e].lightMat,t),null!=s&&n(nt,nt,s);for(let t=0;t<16;++t)ot[16*e+t]=nt[t]}}return ot}takeCascadeSnapshotTo(t,s){U(this.enabled);const e=this._ensureSnapshot(s);this._bindFbo();const i=this._rctx,a=i.bindTexture(e,B.TEXTURE_UNIT_FOR_UPDATES);i.gl.copyTexSubImage2D(A.TEXTURE_2D,0,t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[2],t.camera.viewport[3]),i.bindTexture(a,B.TEXTURE_UNIT_FOR_UPDATES)}clear(){const t=this._rctx;this._bindFbo(),t.setClearColor(1,1,1,1),t.clearSafe(L.COLOR_BUFFER_BIT|L.DEPTH_BUFFER_BIT)}_computeTextureSize(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=Math.max(t.fullWidth,t.fullHeight)*i,r=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return Math.floor(Math.min(this._maxTextureSize,R((1===this.numCascades?1:2)*a*r)))}_ensureDepthTexture(){if(this._fbo?.width===this._textureSize)return;const t=new G(this._textureSize);t.wrapMode=H.CLAMP_TO_EDGE,t.samplingMode=Q.NEAREST,this._fbo?.dispose(),this._fbo=new I(this._rctx,t,new P(V.DEPTH_COMPONENT16,this._textureSize))}_ensureSnapshot(t){let s=this._snapshots[t];if(null!=s&&s.descriptor.width===this._textureSize)return s;this._discardSnapshot(t);const e=new G;return e.wrapMode=H.CLAMP_TO_EDGE,e.samplingMode=Q.NEAREST,e.width=this._textureSize,e.height=this._textureSize,s=new B(this._rctx,e),this._snapshots[t]=s,s}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardAllSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){const t=this._rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],c=-this._cascadeDistances[t+1],h=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),u=(s[10]*c+s[14])/Math.abs(s[11]*c+s[15]);U(h<u);for(let r=0;r<8;++r){D(Y,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?h:u,1);const t=Z[r];v(t,Y,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}C(at,Z[0]),a.camera.viewMatrix=r(K,this._modelViewLight,at);for(let r=0;r<8;++r)T(Z[r],Z[r],a.camera.viewMatrix);let m=Z[0][2],_=Z[0][2];for(let r=1;r<8;++r)m=Math.min(m,Z[r][2]),_=Math.max(_,Z[r][2]);m-=200,_+=200,a.camera.near=-_,a.camera.far=-m,jt(e,i,m,_,a.camera),n(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const l=this._textureSize/(1===this.numCascades?1:2);a.camera.viewport=[t%2==0?0:l,0===Math.floor(t/2)?0:l,l,l]}_setupMatrices(t,s){n(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===E.Global?t.eye:j(at,0,0,1);c(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_clampNearFar(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(F(t/e,4)),a);const r=(t-e)/this._numCascades,n=(t/e)**(1/this._numCascades);let o=e,c=e;for(let h=0;h<this._numCascades+1;++h)this._cascadeDistances[h]=s(o,c,this.settings.splitSchemeLambda),o*=n,c+=r}get gpuMemoryUsage(){return this._snapshots.reduce(((t,s)=>t+(s?.gpuMemoryUsage??0)),this._fbo?.gpuMemoryUsage??0)}get test(){return{cascades:this._cascades,textureSize:this._textureSize}}}const K=h(),Y=z(),Z=[];for(let yt=0;yt<8;++yt)Z.push(z());const $=M(),tt=M(),st=M(),et=M(),it=M(),at=y(),rt=[],nt=h(),ot=new Array(64),ct=M(),ht=M(),ut=[M(),M(),M(),M()],mt=M(),_t=M(),lt=M(),dt=M(),pt=M(),ft=M(),xt=M();function gt(t,s,e,i,a,r,n,o){u(ct,0,0);for(let u=0;u<4;++u)m(ct,ct,t[u]);_(ct,ct,.25),u(ht,0,0);for(let u=4;u<8;++u)m(ht,ht,t[u]);_(ht,ht,.25),l(ut[0],t[4],t[5],.5),l(ut[1],t[5],t[6],.5),l(ut[2],t[6],t[7],.5),l(ut[3],t[7],t[4],.5);let c=0,h=d(ut[0],ct);for(let u=1;u<4;++u){const t=d(ut[u],ct);t<h&&(h=t,c=u)}p(mt,ut[c],t[c+4]);const M=mt[0];let b,S;mt[0]=-mt[1],mt[1]=M,p(_t,ht,ct),f(_t,mt)<0&&x(mt,mt),l(mt,mt,_t,e),g(mt,mt),b=S=f(p(lt,t[0],ct),mt);for(let u=1;u<8;++u){const s=f(p(lt,t[u],ct),mt);s<b?b=s:s>S&&(S=s)}w(i,ct),_(lt,mt,b-s),m(i,i,lt);let C=-1,T=1,j=0,y=0;for(let u=0;u<8;++u){p(dt,t[u],i),g(dt,dt);const s=mt[0]*dt[1]-mt[1]*dt[0];s>0?s>C&&(C=s,j=u):s<T&&(T=s,y=u)}N(C>0,"leftArea"),N(T<0,"rightArea"),_(pt,mt,b),m(pt,pt,ct),_(ft,mt,S),m(ft,ft,ct),xt[0]=-mt[1],xt[1]=mt[0];const D=k(i,t[y],ft,m(lt,ft,xt),1,a),v=k(i,t[j],ft,lt,1,r),z=k(i,t[j],pt,m(lt,pt,xt),1,n),E=k(i,t[y],pt,lt,1,o);N(D,"rayRay"),N(v,"rayRay"),N(z,"rayRay"),N(E,"rayRay")}function wt(t,s){return 3*s+t}const Mt=M();function bt(t,s){return u(Mt,t[s],t[s+3]),Mt}const St=M(),Ct=a();function Tt(t,s,e,i,a){p(St,e,i),_(St,St,.5),Ct[0]=St[0],Ct[1]=St[1],Ct[2]=0,Ct[3]=St[1],Ct[4]=-St[0],Ct[5]=0,Ct[6]=St[0]*St[0]+St[1]*St[1],Ct[7]=St[0]*St[1]-St[1]*St[0],Ct[8]=1,Ct[wt(0,2)]=-f(bt(Ct,0),t),Ct[wt(1,2)]=-f(bt(Ct,1),t);let r=f(bt(Ct,0),e)+Ct[wt(0,2)],n=f(bt(Ct,1),e)+Ct[wt(1,2)],o=f(bt(Ct,0),i)+Ct[wt(0,2)],c=f(bt(Ct,1),i)+Ct[wt(1,2)];r=-(r+o)/(n+c),Ct[wt(0,0)]+=Ct[wt(1,0)]*r,Ct[wt(0,1)]+=Ct[wt(1,1)]*r,Ct[wt(0,2)]+=Ct[wt(1,2)]*r,r=1/(f(bt(Ct,0),e)+Ct[wt(0,2)]),n=1/(f(bt(Ct,1),e)+Ct[wt(1,2)]),Ct[wt(0,0)]*=r,Ct[wt(0,1)]*=r,Ct[wt(0,2)]*=r,Ct[wt(1,0)]*=n,Ct[wt(1,1)]*=n,Ct[wt(1,2)]*=n,Ct[wt(2,0)]=Ct[wt(1,0)],Ct[wt(2,1)]=Ct[wt(1,1)],Ct[wt(2,2)]=Ct[wt(1,2)],Ct[wt(1,2)]+=1,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=f(bt(Ct,1),e)+Ct[wt(1,2)],c=f(bt(Ct,2),e)+Ct[wt(2,2)],r=-.5*(r/n+o/c),Ct[wt(1,0)]+=Ct[wt(2,0)]*r,Ct[wt(1,1)]+=Ct[wt(2,1)]*r,Ct[wt(1,2)]+=Ct[wt(2,2)]*r,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=-n/r,Ct[wt(1,0)]*=o,Ct[wt(1,1)]*=o,Ct[wt(1,2)]*=o,a[0]=Ct[0],a[1]=Ct[1],a[2]=0,a[3]=Ct[2],a[4]=Ct[3],a[5]=Ct[4],a[6]=0,a[7]=Ct[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Ct[6],a[13]=Ct[7],a[14]=0,a[15]=Ct[8]}function jt(t,s,i,a,r){const n=1/Z[0][3],o=1/Z[4][3];U(n<o);let c=n+Math.sqrt(n*o);const h=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));c/=h,gt(Z,c,h,$,tt,st,et,it),Tt($,tt,et,it,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}export{J as ShadowMap,X as SnapshotSlot};
5
+ import has from"../../../../core/has.js";import{clamp as t,lerp as s,acosClamped as e}from"../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../core/maybe.js";import{c as a}from"../../../../chunks/mat3f64.js";import{w as r,m as n,a as o,u as c}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f64.js";import{s as u,i as m,a as _,l,k as d,c as p,g as f,n as x,e as g,j as w}from"../../../../chunks/vec2.js";import{a as M}from"../../../../chunks/vec2f64.js";import{k as b,c as S,o as C,m as T,s as j}from"../../../../chunks/vec3.js";import{c as y}from"../../../../chunks/vec3f64.js";import{s as D,t as v}from"../../../../chunks/vec4.js";import{c as z}from"../../../../chunks/vec4f64.js";import{ViewingMode as E}from"../../../ViewingMode.js";import{CascadeCamera as O}from"./CascadeCamera.js";import{applyTextureResizeModulo as R}from"./textureUtils.js";import{assert as U,logWithBase as F,verify as N,rayRay2D as k}from"./Util.js";import{TextureType as A,ClearBufferBit as L,TextureWrapMode as H,TextureSamplingMode as Q,RenderbufferFormat as V}from"../../../webgl/enums.js";import{FramebufferObject as I}from"../../../webgl/FramebufferObject.js";import{RenderbufferDescriptor as P}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as B}from"../../../webgl/Texture.js";import{TextureDescriptor as G}from"../../../webgl/TextureDescriptor.js";var X;!function(t){t[t.Highlight=0]="Highlight",t[t.Default=1]="Default"}(X||(X={}));class q{constructor(){this.camera=new O,this.lightMat=h()}}class W{constructor(){this.maxNumCascadesHighQuality=4,this.maxNumCascadesLowQuality=4,this.textureSizeModHighQuality=1.3,this.textureSizeModLowQuality=.9,this.splitSchemeLambda=0}}class J{get depthTexture(){return this._fbo?.colorTexture}get textureSize(){return this._textureSize}get numCascades(){return this._numCascades}get cascadeDistances(){return D(this._usedCascadeDistances,this._cascadeDistances[0],this._numCascades>1?this._cascadeDistances[1]:1/0,this._numCascades>2?this._cascadeDistances[2]:1/0,this._numCascades>3?this._cascadeDistances[3]:1/0)}constructor(t,s){this._rctx=t,this._viewingMode=s,this._enabled=!1,this._snapshots=new Array,this._textureSize=0,this._numCascades=1,this.settings=new W,this._projectionView=h(),this._projectionViewInverse=h(),this._modelViewLight=h(),this._cascadeDistances=[0,0,0,0,0],this._usedCascadeDistances=z(),this._cascades=[new q,new q,new q,new q],this._lastOrigin=null,this._maxTextureSize=Math.min(has("esri-mobile")?2048:8192,this._rctx.parameters.maxTextureSize)}dispose(){this.enabled=!1,this.disposeOffscreenBuffers()}disposeOffscreenBuffers(){this._fbo=i(this._fbo),this._discardAllSnapshots()}set maxCascades(s){this.settings.maxNumCascadesHighQuality=t(Math.floor(s),1,4)}get maxCascades(){return this.settings.maxNumCascadesHighQuality}set enabled(t){this._enabled=t,t||this.disposeOffscreenBuffers()}get enabled(){return this._enabled}get ready(){return this._enabled&&null!=this.depthTexture}getSnapshot(t){return this.enabled?this._snapshots[t]:null}get cascades(){for(let t=0;t<this._numCascades;++t)rt[t]=this._cascades[t];return rt.length=this._numCascades,rt}start(t,s,e,i,a){U(this.enabled),this._textureSize=this._computeTextureSize(t,a,i),this._ensureDepthTexture();const{near:r,far:n}=this._clampNearFar(e);this._computeCascadeDistances(n,r,i),this._setupMatrices(t,s);const{viewMatrix:o,projectionMatrix:c}=t;for(let h=0;h<this._numCascades;++h)this._constructCascade(h,c,o,s);this._lastOrigin=null,this.clear()}finish(t){U(this.enabled),this._rctx.bindFramebuffer(t)}getShadowMapMatrices(t){if(!this._lastOrigin||!b(t,this._lastOrigin)){this._lastOrigin=this._lastOrigin||y(),S(this._lastOrigin,t);for(let s=0;s<this._numCascades;++s){r(nt,this._cascades[s].lightMat,t);for(let t=0;t<16;++t)ot[16*s+t]=nt[t]}}return ot}takeCascadeSnapshotTo(t,s){U(this.enabled);const e=this._ensureSnapshot(s);this._bindFbo();const i=this._rctx,a=i.bindTexture(e,B.TEXTURE_UNIT_FOR_UPDATES);i.gl.copyTexSubImage2D(A.TEXTURE_2D,0,t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[0],t.camera.viewport[1],t.camera.viewport[2],t.camera.viewport[3]),i.bindTexture(a,B.TEXTURE_UNIT_FOR_UPDATES)}clear(){const t=this._rctx;this._bindFbo(),t.setClearColor(1,1,1,1),t.clearSafe(L.COLOR_BUFFER_BIT|L.DEPTH_BUFFER_BIT)}_computeTextureSize(t,s,e){const i=Math.min(window.devicePixelRatio,s)/t.pixelRatio,a=Math.max(t.fullWidth,t.fullHeight)*i,r=e?this.settings.textureSizeModHighQuality:this.settings.textureSizeModLowQuality;return Math.floor(Math.min(this._maxTextureSize,R((1===this.numCascades?1:2)*a*r)))}_ensureDepthTexture(){if(this._fbo?.width===this._textureSize)return;const t=new G(this._textureSize);t.wrapMode=H.CLAMP_TO_EDGE,t.samplingMode=Q.NEAREST,this._fbo?.dispose(),this._fbo=new I(this._rctx,t,new P(V.DEPTH_COMPONENT16,this._textureSize))}_ensureSnapshot(t){let s=this._snapshots[t];if(null!=s&&s.descriptor.width===this._textureSize)return s;this._discardSnapshot(t);const e=new G;return e.wrapMode=H.CLAMP_TO_EDGE,e.samplingMode=Q.NEAREST,e.width=this._textureSize,e.height=this._textureSize,s=new B(this._rctx,e),this._snapshots[t]=s,s}_discardSnapshot(t){this._snapshots[t]=i(this._snapshots[t])}_discardAllSnapshots(){for(let t=0;t<this._snapshots.length;++t)this._discardSnapshot(t);this._snapshots.length=0}_bindFbo(){const t=this._rctx;t.unbindTexture(this.depthTexture),t.bindFramebuffer(this._fbo)}_constructCascade(t,s,e,i){const a=this._cascades[t],o=-this._cascadeDistances[t],c=-this._cascadeDistances[t+1],h=(s[10]*o+s[14])/Math.abs(s[11]*o+s[15]),u=(s[10]*c+s[14])/Math.abs(s[11]*c+s[15]);U(h<u);for(let r=0;r<8;++r){D(Y,r%4==0||r%4==3?-1:1,r%4==0||r%4==1?-1:1,r<4?h:u,1);const t=Z[r];v(t,Y,this._projectionViewInverse),t[0]/=t[3],t[1]/=t[3],t[2]/=t[3]}C(at,Z[0]),a.camera.viewMatrix=r(K,this._modelViewLight,at);for(let r=0;r<8;++r)T(Z[r],Z[r],a.camera.viewMatrix);let m=Z[0][2],_=Z[0][2];for(let r=1;r<8;++r)m=Math.min(m,Z[r][2]),_=Math.max(_,Z[r][2]);m-=200,_+=200,a.camera.near=-_,a.camera.far=-m,jt(e,i,m,_,a.camera),n(a.lightMat,a.camera.projectionMatrix,a.camera.viewMatrix);const l=this._textureSize/(1===this.numCascades?1:2);a.camera.viewport=[t%2==0?0:l,0===Math.floor(t/2)?0:l,l,l]}_setupMatrices(t,s){n(this._projectionView,t.projectionMatrix,t.viewMatrix),o(this._projectionViewInverse,this._projectionView);const e=this._viewingMode===E.Global?t.eye:j(at,0,0,1);c(this._modelViewLight,[0,0,0],[-s[0],-s[1],-s[2]],e)}_clampNearFar(t){let{near:s,far:e}=t;return s<2&&(s=2),e<2&&(e=2),s>=e&&(s=2,e=4),{near:s,far:e}}_computeCascadeDistances(t,e,i){const a=i?this.settings.maxNumCascadesHighQuality:this.settings.maxNumCascadesLowQuality;this._numCascades=Math.min(1+Math.floor(F(t/e,4)),a);const r=(t-e)/this._numCascades,n=(t/e)**(1/this._numCascades);let o=e,c=e;for(let h=0;h<this._numCascades+1;++h)this._cascadeDistances[h]=s(o,c,this.settings.splitSchemeLambda),o*=n,c+=r}get gpuMemoryUsage(){return this._snapshots.reduce(((t,s)=>t+(s?.gpuMemoryUsage??0)),this._fbo?.gpuMemoryUsage??0)}get test(){return{cascades:this._cascades,textureSize:this._textureSize}}}const K=h(),Y=z(),Z=[];for(let yt=0;yt<8;++yt)Z.push(z());const $=M(),tt=M(),st=M(),et=M(),it=M(),at=y(),rt=[],nt=h(),ot=new Array(64),ct=M(),ht=M(),ut=[M(),M(),M(),M()],mt=M(),_t=M(),lt=M(),dt=M(),pt=M(),ft=M(),xt=M();function gt(t,s,e,i,a,r,n,o){u(ct,0,0);for(let u=0;u<4;++u)m(ct,ct,t[u]);_(ct,ct,.25),u(ht,0,0);for(let u=4;u<8;++u)m(ht,ht,t[u]);_(ht,ht,.25),l(ut[0],t[4],t[5],.5),l(ut[1],t[5],t[6],.5),l(ut[2],t[6],t[7],.5),l(ut[3],t[7],t[4],.5);let c=0,h=d(ut[0],ct);for(let u=1;u<4;++u){const t=d(ut[u],ct);t<h&&(h=t,c=u)}p(mt,ut[c],t[c+4]);const M=mt[0];let b,S;mt[0]=-mt[1],mt[1]=M,p(_t,ht,ct),f(_t,mt)<0&&x(mt,mt),l(mt,mt,_t,e),g(mt,mt),b=S=f(p(lt,t[0],ct),mt);for(let u=1;u<8;++u){const s=f(p(lt,t[u],ct),mt);s<b?b=s:s>S&&(S=s)}w(i,ct),_(lt,mt,b-s),m(i,i,lt);let C=-1,T=1,j=0,y=0;for(let u=0;u<8;++u){p(dt,t[u],i),g(dt,dt);const s=mt[0]*dt[1]-mt[1]*dt[0];s>0?s>C&&(C=s,j=u):s<T&&(T=s,y=u)}N(C>0,"leftArea"),N(T<0,"rightArea"),_(pt,mt,b),m(pt,pt,ct),_(ft,mt,S),m(ft,ft,ct),xt[0]=-mt[1],xt[1]=mt[0];const D=k(i,t[y],ft,m(lt,ft,xt),1,a),v=k(i,t[j],ft,lt,1,r),z=k(i,t[j],pt,m(lt,pt,xt),1,n),E=k(i,t[y],pt,lt,1,o);N(D,"rayRay"),N(v,"rayRay"),N(z,"rayRay"),N(E,"rayRay")}function wt(t,s){return 3*s+t}const Mt=M();function bt(t,s){return u(Mt,t[s],t[s+3]),Mt}const St=M(),Ct=a();function Tt(t,s,e,i,a){p(St,e,i),_(St,St,.5),Ct[0]=St[0],Ct[1]=St[1],Ct[2]=0,Ct[3]=St[1],Ct[4]=-St[0],Ct[5]=0,Ct[6]=St[0]*St[0]+St[1]*St[1],Ct[7]=St[0]*St[1]-St[1]*St[0],Ct[8]=1,Ct[wt(0,2)]=-f(bt(Ct,0),t),Ct[wt(1,2)]=-f(bt(Ct,1),t);let r=f(bt(Ct,0),e)+Ct[wt(0,2)],n=f(bt(Ct,1),e)+Ct[wt(1,2)],o=f(bt(Ct,0),i)+Ct[wt(0,2)],c=f(bt(Ct,1),i)+Ct[wt(1,2)];r=-(r+o)/(n+c),Ct[wt(0,0)]+=Ct[wt(1,0)]*r,Ct[wt(0,1)]+=Ct[wt(1,1)]*r,Ct[wt(0,2)]+=Ct[wt(1,2)]*r,r=1/(f(bt(Ct,0),e)+Ct[wt(0,2)]),n=1/(f(bt(Ct,1),e)+Ct[wt(1,2)]),Ct[wt(0,0)]*=r,Ct[wt(0,1)]*=r,Ct[wt(0,2)]*=r,Ct[wt(1,0)]*=n,Ct[wt(1,1)]*=n,Ct[wt(1,2)]*=n,Ct[wt(2,0)]=Ct[wt(1,0)],Ct[wt(2,1)]=Ct[wt(1,1)],Ct[wt(2,2)]=Ct[wt(1,2)],Ct[wt(1,2)]+=1,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=f(bt(Ct,1),e)+Ct[wt(1,2)],c=f(bt(Ct,2),e)+Ct[wt(2,2)],r=-.5*(r/n+o/c),Ct[wt(1,0)]+=Ct[wt(2,0)]*r,Ct[wt(1,1)]+=Ct[wt(2,1)]*r,Ct[wt(1,2)]+=Ct[wt(2,2)]*r,r=f(bt(Ct,1),s)+Ct[wt(1,2)],n=f(bt(Ct,2),s)+Ct[wt(2,2)],o=-n/r,Ct[wt(1,0)]*=o,Ct[wt(1,1)]*=o,Ct[wt(1,2)]*=o,a[0]=Ct[0],a[1]=Ct[1],a[2]=0,a[3]=Ct[2],a[4]=Ct[3],a[5]=Ct[4],a[6]=0,a[7]=Ct[5],a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=Ct[6],a[13]=Ct[7],a[14]=0,a[15]=Ct[8]}function jt(t,s,i,a,r){const n=1/Z[0][3],o=1/Z[4][3];U(n<o);let c=n+Math.sqrt(n*o);const h=Math.sin(e(t[2]*s[0]+t[6]*s[1]+t[10]*s[2]));c/=h,gt(Z,c,h,$,tt,st,et,it),Tt($,tt,et,it,r.projectionMatrix),r.projectionMatrix[10]=2/(i-a),r.projectionMatrix[14]=-(i+a)/(i-a)}export{J as ShadowMap,X as SnapshotSlot};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../chunks/mat4f64.js";import"../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../core/shaderLibrary/Offset.glsl.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../core/shaderLibrary/attributes/PositionAttribute.glsl.js";import"../core/shaderLibrary/attributes/SymbolColor.glsl.js";import"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../core/shaderLibrary/attributes/VerticalOffset.glsl.js";import"../core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import"../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import"../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../core/shaderLibrary/shading/MainLighting.glsl.js";import"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../core/shaderLibrary/shading/Normals.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/TextureTransformUV.glsl.js";import"../core/shaderLibrary/shading/VisualVariables.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderLibrary/util/AlphaDiscard.glsl.js";import"../core/shaderLibrary/util/MixExternalColor.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float3PassUniform.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/Matrix4PassUniform.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../lib/TransparencyPassType.js";import"../lib/VertexAttribute.js";export{b as build}from"../../../../chunks/DefaultMaterial.glsl.js";
5
+ import"../../../../chunks/mat3.js";import"../../../../chunks/mat3f64.js";import"../../../../chunks/mat4f64.js";import"../core/shaderLibrary/ForwardLinearDepth.glsl.js";import"../core/shaderLibrary/Offset.glsl.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../core/shaderLibrary/attributes/PositionAttribute.glsl.js";import"../core/shaderLibrary/attributes/SymbolColor.glsl.js";import"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../core/shaderLibrary/attributes/VerticalOffset.glsl.js";import"../core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js";import"../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import"../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../core/shaderLibrary/shading/MainLighting.glsl.js";import"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import"../core/shaderLibrary/shading/Normals.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/TextureTransformUV.glsl.js";import"../core/shaderLibrary/shading/VisualVariables.glsl.js";import"../core/shaderLibrary/util/AlphaCutoff.js";import"../core/shaderLibrary/util/AlphaDiscard.glsl.js";import"../core/shaderLibrary/util/MixExternalColor.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float3PassUniform.js";import"../core/shaderModules/Float4PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/Matrix3PassUniform.js";import"../core/shaderModules/Matrix4PassUniform.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DPassUniform.js";import"../lib/TransparencyPassType.js";import"../lib/VertexAttribute.js";export{b as build}from"../../../../chunks/DefaultMaterial.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import r from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as n}from"../core/maybe.js";import{watch as a,initial as d}from"../core/reactiveUtils.js";import{addFrameTask as h}from"../core/scheduling.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./overlay/ViewOverlay.js";const p=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return p[0]=s.left+(t?.pageXOffset??0),p[1]=s.top+(t?.pageYOffset??0),p}function f(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const v=16,g=750,_=512,w=2,C=i=>{let p=class extends i{constructor(...e){super(...e),this._freqInfo={freq:v,time:g},this._overlayRenderTaskHandle=null,this.height=0,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([a((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),a((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){this.addHandles([a((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),d),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui=o(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),o=t(e);if(o||"string"!=typeof e||r.getLogger(this).error("#container",`element with id '${e}' not found`),i===o)return;const l="dom-size";if(this.removeHandles(l),this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(f(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),f(this.userContent),this._set("userContent",null))),!o)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);o.classList.add("esri-view");const u=document.createElement("div");u.className="esri-view-user-storage",s(o,u),o.appendChild(u),this._set("userContent",u);const p=document.createElement("div");p.className="esri-view-root",o.insertBefore(p,o.firstChild),this._set("root",p);const m=document.createElement("div");m.className="esri-view-surface",m.setAttribute("role","application"),m.tabIndex=0,p.appendChild(m),this._set("surface",m);const y=new c;p.appendChild(y.surface),this._set("overlay",y),this.addHandles(a((()=>y.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=h({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=n(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this.addHandles(a((()=>this.size),(e=>{const[t,s]=e,i="esri-view-surface--inset-outline";t>=document.body.clientWidth||s>=document.body.clientHeight?m.classList.add(i):m.classList.remove(i)}),d),l),this._set("container",o),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(a((()=>this.root),(t=>{e.container=t?y(t):null}),d),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=v,e.time=g,this.addHandles([(()=>{const t=()=>{e.freq=v,e.time=g};return window.addEventListener("resize",t),{remove(){window.removeEventListener("resize",t)}}})(),h({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=v,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?v:Math.min(g,s.freq*w),!t&&s.freq>=_&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&m(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([l()],p.prototype,"container",null),e([l({readOnly:!0})],p.prototype,"focused",null),e([l({readOnly:!0})],p.prototype,"height",void 0),e([l({type:c})],p.prototype,"overlay",void 0),e([l({readOnly:!0})],p.prototype,"position",void 0),e([l({readOnly:!0})],p.prototype,"resizing",void 0),e([l({readOnly:!0})],p.prototype,"root",void 0),e([l({value:null,readOnly:!0})],p.prototype,"size",null),e([l({readOnly:!0})],p.prototype,"surface",void 0),e([l({readOnly:!0})],p.prototype,"suspended",void 0),e([l()],p.prototype,"ui",void 0),e([l({readOnly:!0})],p.prototype,"userContent",void 0),e([l({readOnly:!0})],p.prototype,"width",void 0),e([l()],p.prototype,"widthBreakpoint",void 0),p=e([u("esri.views.DOMContainer")],p),p};export{C as DOMContainer};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import r from"../core/Logger.js";import{destroyMaybe as o,removeMaybe as n}from"../core/maybe.js";import{watch as a,initial as h}from"../core/reactiveUtils.js";import{addFrameTask as d}from"../core/scheduling.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as u}from"../core/accessorSupport/decorators/subclass.js";import c from"./overlay/ViewOverlay.js";const p=[0,0];function f(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return p[0]=s.left+(t?.pageXOffset??0),p[1]=s.top+(t?.pageYOffset??0),p}function m(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function y(e){const t=document.createElement("div");return e.appendChild(t),t}const g=16,v=750,_=512,w=2,C=i=>{let p=class extends i{constructor(...e){super(...e),this._freqInfo={freq:g,time:v},this._overlayRenderTaskHandle=null,this.height=0,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([a((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),a((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){this.addHandles([a((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),h),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui=o(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),o=t(e);if(o||"string"!=typeof e||r.getLogger(this).error("#container",`element with id '${e}' not found`),i===o)return;if(this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(m(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),m(this.userContent),this._set("userContent",null))),!o)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);o.classList.add("esri-view");const h=document.createElement("div");h.className="esri-view-user-storage",s(o,h),o.appendChild(h),this._set("userContent",h);const l=document.createElement("div");l.className="esri-view-root",o.insertBefore(l,o.firstChild),this._set("root",l);const u=document.createElement("div");u.className="esri-view-surface",u.setAttribute("role","application"),u.tabIndex=0,l.appendChild(u),this._set("surface",u);const p=new c;l.appendChild(p.surface),this._set("overlay",p),this.addHandles(a((()=>p.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=d({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=n(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this._set("container",o),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(a((()=>this.root),(t=>{e.container=t?y(t):null}),h),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=g,e.time=v,this.addHandles([(()=>{const t=()=>{e.freq=g,e.time=v};return window.addEventListener("resize",t),{remove(){window.removeEventListener("resize",t)}}})(),d({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=g,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?g:Math.min(v,s.freq*w),!t&&s.freq>=_&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&f(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([l()],p.prototype,"container",null),e([l({readOnly:!0})],p.prototype,"focused",null),e([l({readOnly:!0})],p.prototype,"height",void 0),e([l({type:c})],p.prototype,"overlay",void 0),e([l({readOnly:!0})],p.prototype,"position",void 0),e([l({readOnly:!0})],p.prototype,"resizing",void 0),e([l({readOnly:!0})],p.prototype,"root",void 0),e([l({value:null,readOnly:!0})],p.prototype,"size",null),e([l({readOnly:!0})],p.prototype,"surface",void 0),e([l({readOnly:!0})],p.prototype,"suspended",void 0),e([l()],p.prototype,"ui",void 0),e([l({readOnly:!0})],p.prototype,"userContent",void 0),e([l({readOnly:!0})],p.prototype,"width",void 0),e([l()],p.prototype,"widthBreakpoint",void 0),p=e([u("esri.views.DOMContainer")],p),p};export{C as DOMContainer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as u,whenOnce as n}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s}))}),u),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),n((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),u=this._queryLayerPopupFeatures(i,s,p),n=u.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...n]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:u}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{createTask as p}from"../core/asyncUtils.js";import{deprecated as t}from"../core/deprecate.js";import i from"../core/Error.js";import s from"../core/Logger.js";import{eachAlwaysValues as o,throwIfAborted as r}from"../core/promiseUtils.js";import{watch as a,initial as n,whenOnce as u}from"../core/reactiveUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as h}from"./input/InputManager.js";function d(e){return null!=e&&"open"in e&&"declaredClass"in e}function y(e){return null!=e&&"declaredClass"in e&&"dockOptions"in e}const w=w=>{let m=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([a((()=>[this.ui,this.popup]),(([e,p],t)=>{const i="popup",s="manual";if(t){const[e,p]=t;e&&d(p)&&(p.view=null,y(p)&&e.remove(p,i))}e&&d(p)&&(p.view=this,y(p)&&e.add(p,{key:i,position:s,internal:!0}))}),n),this.on("click",(e=>{this.popup&&this.popupEnabled&&("mouse"!==e.pointerType||0===e.button)&&(!d(this.popup)&&"autoOpenEnabled"in this.popup&&!1===this.popup.autoOpenEnabled||(d(this.popup)?this.popup.viewModel.handleViewClick(e):e.async((async()=>{await this.setupPopup(),d(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(e)}))))}),h.WIDGET)]),u((()=>this.ready&&this.popupEnabled&&!this.updating)).then((()=>{import("../widgets/Popup.js")}))}destroy(){this.destroyed||this.closePopup()}async openPopup(e){d(this.popup)&&this.popup.open(e);try{if(await this.setupPopup(),!this.popup)return void s.getLogger(this).error(new i("view:null-popup","Popup is null and can't be opened"));this.popup.open(e)}catch{}}closePopup(){this._popupSetupTask?.abort(),d(this.popup)&&this.popup.close()}async fetchPopupFeatures(e,p){await this.when();const{location:t,queryArea:i,layerViewsAndGraphics:s,clientOnlyGraphics:r}=await this._prepareFetchPopupFeatures(e,p),a=Promise.resolve(r),n=this._queryLayerPopupFeatures(i,s,p),u=n.map((e=>e.promise));return{location:t,clientOnlyGraphics:r,allGraphicsPromise:o([a,...u]).then((e=>Array.from(new Set(e.flat())))),promisesPerLayerView:n}}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!d(this.popup))return this._popupSetupTask=p((async e=>{const{default:p}=await import("../widgets/Popup.js");if(r(e),!this.popup||d(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new p(t)})),this._popupSetupTask.promise}_queryLayerPopupFeatures(e,p,t){return p.map((({layerView:p,graphics:i})=>{const s={clientGraphics:i,event:null!=t?t.event:void 0,signal:null!=t?t.signal:void 0,defaultPopupTemplateEnabled:null!=t&&!!t.defaultPopupTemplateEnabled},o=p.fetchPopupFeatures(e,s);return{layerView:p,promise:o}}))}_isValidPopupGraphic(e,p){return e&&!!e.getEffectivePopupTemplate(null!=p&&p.defaultPopupTemplateEnabled)}async _prepareFetchPopupFeatures(e,p){const{clientGraphics:t,queryArea:i,location:s}=await this._popupHitTestGraphics(e,p),o=this._getFetchPopupLayerViews(),{layerViewsAndGraphics:r,clientOnlyGraphics:a}=this._graphicsPerFetchPopupLayerView(t,o);return{clientOnlyGraphics:a,layerViewsAndGraphics:r,queryArea:i,location:s}}async _popupHitTestGraphics(e,p){const t=await this.popupHitTest(e),i=t.results,s=t.mapPoint,o=i.filter((e=>"graphic"===e.type&&this._isValidPopupGraphic(e.graphic,p))),r=o.length?o[0].mapPoint:null;return{clientGraphics:o.map((e=>e.graphic)),queryArea:s,location:s||r}}_getFetchPopupLayerViews(){const e=[];return this.allLayerViews.forEach((p=>{this._isValidPopupLayerView(p)&&e.push(p)})),null!=this.graphicsView&&this._isValidPopupLayerView(this.graphicsView)&&e.push(this.graphicsView),e.reverse()}_isValidPopupLayerView(e){return null!=e&&(!("layer"in e)||!e.suspended)&&"fetchPopupFeatures"in e}_graphicsPerFetchPopupLayerView(e,p){const t=[],i=new Map,s=p.map((e=>{const p=[];return"layer"in e?i.set(e.layer,p):i.set(e.graphics,p),{layerView:e,graphics:p}}));for(const o of e){const e=i.get(o.layer)||i.get(o.sourceLayer)||null;e?e.push(o):t.push(o)}return{layerViewsAndGraphics:s,clientOnlyGraphics:t}}};return e([l({cast(e){return!e||d(e)||"object"==typeof e&&(e.open=e=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.open() will stop working when the popup isn't created",{replacement:"Use view.openPopup() instead.",version:"4.27"}),this.openPopup(e)),e.close=()=>(t(s.getLogger(this),"view.popup is no longer created by default. view.popup.close() will stop working when the popup isn't created",{replacement:"Use view.closePopup() instead.",version:"4.27"}),this.closePopup())),e}})],m.prototype,"popup",void 0),e([l()],m.prototype,"popupEnabled",void 0),m=e([c("esri.views.PopupView")],m),m};export{w as PopupView};