@arcgis/core 4.31.0-next.20240605 → 4.31.0-next.20240607

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 (98) hide show
  1. package/arcade/functions/centroid.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/04d84f7c9c5b5a6bdf47.js +1 -0
  4. package/assets/esri/core/workers/chunks/17e4d9be754e9ce2cec4.js +1 -0
  5. package/assets/esri/core/workers/chunks/1a64e0020d12c251ad4b.js +1 -0
  6. package/assets/esri/core/workers/chunks/{3ec2ed6b4d2f373ed0dc.js → 1ece003ccf1c03fb42d9.js} +1 -1
  7. package/assets/esri/core/workers/chunks/2ee7d91cc6c1ae7f3698.js +1 -0
  8. package/assets/esri/core/workers/chunks/423abec9211aa6ab6502.js +1 -0
  9. package/assets/esri/core/workers/chunks/493851fc4b07de3fe924.js +1 -0
  10. package/assets/esri/core/workers/chunks/66b835a5edfcdcf21c06.js +1 -0
  11. package/assets/esri/core/workers/chunks/{24a02d266749a77c8ae1.js → 7866b86ebe02adf5e874.js} +17 -17
  12. package/assets/esri/core/workers/chunks/{d1c4d0d53614055bc173.js → c406e673d2dd7e702af0.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{a5f467805178686b7240.js → c70683b7183458b338f8.js} +1 -1
  14. package/assets/esri/core/workers/chunks/fa5e171c8ce844363b6c.js +1 -0
  15. package/assets/esri/themes/base/widgets/_BuildingDisciplinesTree.scss +5 -138
  16. package/assets/esri/themes/base/widgets/_BuildingExplorer.scss +1 -9
  17. package/assets/esri/themes/base/widgets/_BuildingLevelPicker.scss +5 -39
  18. package/assets/esri/themes/base/widgets/_BuildingPhasePicker.scss +2 -17
  19. package/assets/esri/themes/base/widgets/_Editor.scss +8 -0
  20. package/assets/esri/themes/base/widgets/_Sketch.scss +8 -0
  21. package/assets/esri/themes/base/widgets/_SketchTooltipControls.scss +1 -0
  22. package/assets/esri/themes/base/widgets/_SnappingControls.scss +4 -0
  23. package/assets/esri/themes/dark/main.css +1 -1
  24. package/assets/esri/themes/light/main.css +1 -1
  25. package/assets/esri/themes/light/view.css +1 -1
  26. package/chunks/ColorMaterial.glsl.js +1 -1
  27. package/chunks/ComponentShader.glsl.js +1 -1
  28. package/chunks/CypherLexer.js +5 -0
  29. package/chunks/CypherListener.js +5 -0
  30. package/chunks/CypherParser.js +5 -0
  31. package/chunks/DefaultMaterial.glsl.js +1 -1
  32. package/chunks/HUDMaterial.glsl.js +32 -32
  33. package/chunks/ImageMaterial.glsl.js +1 -1
  34. package/chunks/LineMarker.glsl.js +1 -1
  35. package/chunks/NativeLine.glsl.js +1 -1
  36. package/chunks/OITCompositing.glsl.js +12 -9
  37. package/chunks/Pattern.glsl.js +1 -1
  38. package/chunks/RealisticTree.glsl.js +1 -1
  39. package/chunks/RibbonLine.glsl.js +1 -1
  40. package/chunks/ShadedColorMaterial.glsl.js +1 -1
  41. package/chunks/WaterSurface.glsl.js +1 -1
  42. package/chunks/antlr4.web.js +5 -0
  43. package/layers/LinkChartLayer.js +1 -1
  44. package/layers/knowledgeGraph/antlr/BindParamsListener.js +5 -0
  45. package/layers/knowledgeGraph/antlr/SimpleErrorListener.js +5 -0
  46. package/layers/knowledgeGraph/cypherUtils.js +5 -0
  47. package/layers/knowledgeGraph/supportUtils.js +1 -1
  48. package/layers/support/rasterFunctions/AspectFunction.js +1 -1
  49. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  50. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  51. package/layers/support/rasterFunctions/RemapFunction.js +1 -1
  52. package/layers/support/rasterFunctions/SlopeFunction.js +1 -1
  53. package/libs/linkchartlayout/LinkChartLayout.js +1 -1
  54. package/package.json +1 -1
  55. package/support/revision.js +1 -1
  56. package/views/2d/support/HighlightOptions.js +1 -1
  57. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  58. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  59. package/views/3d/support/HighlightOptions.js +1 -1
  60. package/views/3d/terrain/PatchRenderData.js +1 -1
  61. package/views/3d/terrain/Tile.js +1 -1
  62. package/views/3d/terrain/TileAgent.js +1 -1
  63. package/views/3d/terrain/TileRenderer.js +1 -1
  64. package/views/3d/terrain/terrainUtils.js +1 -1
  65. package/views/3d/terrain/tileUtils.js +1 -1
  66. package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
  67. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  68. package/views/3d/webgl-engine/core/shaderLibrary/util/AlphaCutoff.js +1 -1
  69. package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlphaBlend.glsl.js +1 -1
  70. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  71. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  72. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  73. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  74. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  75. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  76. package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +1 -1
  77. package/views/support/HighlightDefaults.js +5 -0
  78. package/views/support/HighlightOptions.js +5 -0
  79. package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesNode.js +1 -1
  80. package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
  81. package/widgets/BuildingExplorer/BuildingDisciplinesViewModel.js +1 -1
  82. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  83. package/widgets/BuildingExplorer/BuildingLevelPicker/Label.js +1 -1
  84. package/widgets/BuildingExplorer/BuildingLevelPicker/LevelItem.js +1 -1
  85. package/widgets/BuildingExplorer/BuildingLevelPicker/css.js +1 -1
  86. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  87. package/widgets/BuildingExplorer/BuildingPhasePicker/css.js +5 -0
  88. package/widgets/BuildingExplorer/support/LayerTreeNode.js +1 -1
  89. package/widgets/BuildingExplorer.js +1 -1
  90. package/widgets/support/legacyIcon.js +1 -1
  91. package/assets/esri/core/workers/chunks/3841ef7007eda2f3a7a4.js +0 -1
  92. package/assets/esri/core/workers/chunks/4ccf7a2b36e0b8b26736.js +0 -1
  93. package/assets/esri/core/workers/chunks/a111eb0ae78a9f5be981.js +0 -1
  94. package/assets/esri/core/workers/chunks/b57a5055b9956433dac2.js +0 -1
  95. package/assets/esri/core/workers/chunks/b9e4e2451108cad75bfd.js +0 -1
  96. package/assets/esri/core/workers/chunks/f9774ba48f3aa3b8fac4.js +0 -1
  97. package/assets/esri/core/workers/chunks/fa8b00135363c450de16.js +0 -1
  98. package/views/3d/webgl-engine/effects/highlight/HighlightDefaults.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.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import{numberMaxFloat32 as e}from"../../../core/mathUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{getPixelValueRange as o}from"../rasterFormats/pixelRangeUtils.js";import a from"./BaseRasterFunction.js";import{createRemapLUT as u,maxMapSizeGpu as r,lookupPixels as i,lookupBandValues as l,remap as p}from"./pixelUtils.js";import c from"./RemapFunctionArguments.js";let m=class extends a{constructor(){super(...arguments),this.functionName="Remap",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:e}=t;this.outputPixelType=this._getOutputPixelType(e),t.pixelType=this.outputPixelType,t.colormap=null,t.histograms=null,t.bandCount=1,t.attributeTable=null;const{statistics:s}=t,{allowUnmatched:n,outputValues:o,inputRanges:a,noDataRanges:i,isLastInputRangeInclusive:l}=this.functionArguments;if(null!=s&&s.length&&o?.length)if(n){const e=Math.min.apply(null,[...o,s[0].min]),n=Math.max.apply(null,[...o,s[0].max]);t.statistics=[{...s[0],min:e,max:n}]}else{let e=o[0],n=e;for(let t=0;t<o.length;t++)e=e>o[t]?o[t]:e,n=n>o[t]?n:o[t];t.statistics=[{...s[0],min:e,max:n}]}this.rasterInfo=t,this.lookup=n?null:u({srcPixelType:e,inputRanges:a,outputValues:o,noDataRanges:i,allowUnmatched:n,isLastInputRangeInclusive:l,outputPixelType:this.outputPixelType});return{success:!0,supportsGPU:(!o||o.length<=r)&&(!i||i.length<=r)}}_processPixels(t){const e=t.pixelBlocks?.[0];if(null==e)return null;const{lookup:s,outputPixelType:n}=this;if(s){const t=i(e,{lut:[s.lut],offset:s.offset,outputPixelType:n});return null!=t&&s.mask&&(t.mask=l(e.pixels[0],e.mask,s.mask,s.offset,"u8")),t}const{inputRanges:o,outputValues:a,noDataRanges:u,allowUnmatched:r,isLastInputRangeInclusive:c}=this.functionArguments;return p(e,{inputRanges:o,outputValues:a,noDataRanges:u,outputPixelType:n,allowUnmatched:r,isLastInputRangeInclusive:c})}_getWebGLParameters(){const{allowUnmatched:t,noDataRanges:s,isLastInputRangeInclusive:n}=this.functionArguments,a=new Float32Array(3*r),u=1e-5,i=this.functionArguments.inputRanges??[],l=this.functionArguments.outputValues??[],p=l.length;for(let o=0;o<r;o++)a[3*o]=i[2*o]??e-1,a[3*o+1]=i[2*o+1]??e,a[3*o+2]=l[o]??0,o<p&&(o>0&&(a[3*o]-=u),(o<p-1||!n)&&(a[3*o+1]-=u));const c=new Float32Array(2*r);c.fill(e),s?.length&&c.set(s);return{allowUnmatched:t,rangeMaps:a,noDataRanges:c,clampRange:o(this.outputPixelType)}}};t([s({json:{write:!0,name:"rasterFunction"}})],m.prototype,"functionName",void 0),t([s({type:c,json:{write:!0,name:"rasterFunctionArguments"}})],m.prototype,"functionArguments",void 0),t([s()],m.prototype,"rasterArgumentNames",void 0),t([s({json:{write:!0}})],m.prototype,"lookup",void 0),m=t([n("esri.layers.support.rasterFunctions.RemapFunction")],m);const g=m;export{g as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import{numberMaxFloat32 as s}from"../../../core/mathUtils.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{getPixelValueRange as o}from"../rasterFormats/pixelRangeUtils.js";import a from"./BaseRasterFunction.js";import{createRemapLUT as u,maxMapSizeGpu as r,lookupPixels as i,lookupBandValues as l,remap as p}from"./pixelUtils.js";import c from"./RemapFunctionArguments.js";let m=class extends a{constructor(){super(...arguments),this.functionName="Remap",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.lookup=null}_bindSourceRasters(){const t=this.sourceRasterInfos[0].clone(),{pixelType:s}=t;this.outputPixelType=this._getOutputPixelType(s),t.pixelType=this.outputPixelType,t.bandCount=1;const{statistics:e}=t;this._removeStatsHistColormapVAT(t);const{allowUnmatched:n,outputValues:o,inputRanges:a,noDataRanges:i,isLastInputRangeInclusive:l}=this.functionArguments;if(null!=e&&e.length&&o?.length)if(n){const s=Math.min.apply(null,[...o,e[0].min]),n=Math.max.apply(null,[...o,e[0].max]);t.statistics=[{...e[0],min:s,max:n}]}else{let s=o[0],n=s;for(let t=0;t<o.length;t++)s=s>o[t]?o[t]:s,n=n>o[t]?n:o[t];t.statistics=[{...e[0],min:s,max:n}]}this.rasterInfo=t,this.lookup=n?null:u({srcPixelType:s,inputRanges:a,outputValues:o,noDataRanges:i,allowUnmatched:n,isLastInputRangeInclusive:l,outputPixelType:this.outputPixelType});return{success:!0,supportsGPU:(!o||o.length<=r)&&(!i||i.length<=r)}}_processPixels(t){const s=t.pixelBlocks?.[0];if(null==s)return null;const{lookup:e,outputPixelType:n}=this;if(e){const t=i(s,{lut:[e.lut],offset:e.offset,outputPixelType:n});return null!=t&&e.mask&&(t.mask=l(s.pixels[0],s.mask,e.mask,e.offset,"u8")),t}const{inputRanges:o,outputValues:a,noDataRanges:u,allowUnmatched:r,isLastInputRangeInclusive:c}=this.functionArguments;return p(s,{inputRanges:o,outputValues:a,noDataRanges:u,outputPixelType:n,allowUnmatched:r,isLastInputRangeInclusive:c})}_getWebGLParameters(){const{allowUnmatched:t,noDataRanges:e,isLastInputRangeInclusive:n}=this.functionArguments,a=new Float32Array(3*r),u=1e-5,i=this.functionArguments.inputRanges??[],l=this.functionArguments.outputValues??[],p=l.length;for(let o=0;o<r;o++)a[3*o]=i[2*o]??s-1,a[3*o+1]=i[2*o+1]??s,a[3*o+2]=l[o]??0,o<p&&(o>0&&(a[3*o]-=u),(o<p-1||!n)&&(a[3*o+1]-=u));const c=new Float32Array(2*r);c.fill(s),e?.length&&c.set(e);return{allowUnmatched:t,rangeMaps:a,noDataRanges:c,clampRange:o(this.outputPixelType)}}};t([e({json:{write:!0,name:"rasterFunction"}})],m.prototype,"functionName",void 0),t([e({type:c,json:{write:!0,name:"rasterFunctionArguments"}})],m.prototype,"functionArguments",void 0),t([e()],m.prototype,"rasterArgumentNames",void 0),t([e({json:{write:!0}})],m.prototype,"lookup",void 0),m=t([n("esri.layers.support.rasterFunctions.RemapFunction")],m);const g=m;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./BaseRasterFunction.js";import o from"./SlopeFunctionArguments.js";import{slope as i,gcsFactor as n}from"./surfaceUtils.js";let p=class extends r{constructor(){super(...arguments),this.functionName="Slope",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const e=this.sourceRasterInfos[0].clone();return e.pixelType=this.outputPixelType,e.statistics="percent-rise"!==this.functionArguments.slopeType?[{min:0,max:90,avg:1,stddev:1}]:null,e.histograms=null,e.colormap=null,e.attributeTable=null,e.bandCount=1,this.rasterInfo=e,this.isGCS=e.spatialReference?.isGeographic??!1,{success:!0,supportsGPU:!0}}_processPixels(e){const t=e.pixelBlocks?.[0];if(null==t)return null;const{zFactor:s,slopeType:r,pixelSizePower:o,pixelSizeFactor:n}=this.functionArguments,{isGCS:p}=this,{extent:c,primaryPixelSizes:u}=e,a=u?.[0],l=a??(c?{x:c.width/t.width,y:c.height/t.height}:{x:1,y:1});return i(t,{zFactor:s,slopeType:r,pixelSizePower:o,pixelSizeFactor:n,isGCS:p,resolution:l})}_getWebGLParameters(){const{zFactor:e,slopeType:t,pixelSizeFactor:s,pixelSizePower:r}=this.functionArguments;return{zFactor:this.isGCS&&e>=1?e*n:e,slopeType:t,pixelSizeFactor:s??0,pixelSizePower:r??0}}};e([t({json:{write:!0,name:"rasterFunction"}})],p.prototype,"functionName",void 0),e([t({type:o,json:{write:!0,name:"rasterFunctionArguments"}})],p.prototype,"functionArguments",void 0),e([t()],p.prototype,"rasterArgumentNames",void 0),e([t({json:{write:!0}})],p.prototype,"isGCS",void 0),p=e([s("esri.layers.support.rasterFunctions.SlopeFunction")],p);const c=p;export{c as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import r from"./BaseRasterFunction.js";import o from"./SlopeFunctionArguments.js";import{slope as i,gcsFactor as n}from"./surfaceUtils.js";let p=class extends r{constructor(){super(...arguments),this.functionName="Slope",this.functionArguments=null,this.rasterArgumentNames=["raster"],this.isGCS=!1}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const e=this.sourceRasterInfos[0].clone();return e.pixelType=this.outputPixelType,this._removeStatsHistColormapVAT(e),e.statistics="percent-rise"!==this.functionArguments.slopeType?[{min:0,max:90,avg:1,stddev:1}]:null,e.bandCount=1,this.rasterInfo=e,this.isGCS=e.spatialReference?.isGeographic??!1,{success:!0,supportsGPU:!0}}_processPixels(e){const t=e.pixelBlocks?.[0];if(null==t)return null;const{zFactor:s,slopeType:r,pixelSizePower:o,pixelSizeFactor:n}=this.functionArguments,{isGCS:p}=this,{extent:c,primaryPixelSizes:u}=e,a=u?.[0],l=a??(c?{x:c.width/t.width,y:c.height/t.height}:{x:1,y:1});return i(t,{zFactor:s,slopeType:r,pixelSizePower:o,pixelSizeFactor:n,isGCS:p,resolution:l})}_getWebGLParameters(){const{zFactor:e,slopeType:t,pixelSizeFactor:s,pixelSizePower:r}=this.functionArguments;return{zFactor:this.isGCS&&e>=1?e*n:e,slopeType:t,pixelSizeFactor:s??0,pixelSizePower:r??0}}};e([t({json:{write:!0,name:"rasterFunction"}})],p.prototype,"functionName",void 0),e([t({type:o,json:{write:!0,name:"rasterFunctionArguments"}})],p.prototype,"functionArguments",void 0),e([t()],p.prototype,"rasterArgumentNames",void 0),e([t({json:{write:!0}})],p.prototype,"isGCS",void 0),p=e([s("esri.layers.support.rasterFunctions.SlopeFunction")],p);const c=p;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{getAssetUrl as t}from"../../assets.js";let e,r=null;function a(){return!!r}function n(){return e||(e=import("../../chunks/lclayout.js").then((t=>t.l)).then((({default:e})=>e({locateFile:e=>t(`esri/libs/linkchartlayout/${e}`)}))).then((t=>{s(t)})),e)}function s(t){r=t}var u,o;function l(t,e,a,n,s,u){const o=a.length,l=s.length,y=Float64Array.BYTES_PER_ELEMENT,i=Uint32Array.BYTES_PER_ELEMENT,c=Uint8Array.BYTES_PER_ELEMENT,E=16,f=E+o*(c+2*y)+l*(2*i),p=r._malloc(f);try{const c=p+E-p%E,f=c+o*y,A=f+o*y,_=A+l*i,P=_+l*i,b=()=>[r.HEAPF64.subarray(c>>3,(c>>3)+o),r.HEAPF64.subarray(f>>3,(f>>3)+o),r.HEAPU32.subarray(A>>2,(A>>2)+l),r.HEAPU32.subarray(_>>2,(_>>2)+l),r.HEAPU8.subarray(P,P+o)],[g,H,L,h,d]=b();g.set(a),H.set(n),L.set(s),h.set(u),d.set(e);let C=t(o,P,c,f,l,A,_),F=null,m=null;if(C){const t=r.getLayoutLinksTypes(),e=r.getLayoutLinksVerticesEndIndices(),a=r.getLayoutLinksVertices(),n=r.countLayoutLinksVertices();!l||t&&e?n&&!a?C=!1:(F={types:new Uint8Array(r.HEAPU8.subarray(t,t+l)),vertexEndIndex:new Uint32Array(r.HEAPU32.subarray(e>>2,(e>>2)+l)),vertices:new Float64Array(r.HEAPF64.subarray(a>>3,(a>>3)+2*n))},m=r.getAuxiliaryGraphicElements()):C=!1}const[R,T,U,B,v]=b();return a.set(R),n.set(T),s.set(U),u.set(B),e.set(v),{success:C,links:F,graphics:m}}finally{r._free(p),r.cleanupLayout()}}!function(t){t[t.None=0]="None",t[t.IsMovable=1]="IsMovable",t[t.IsGeographic=2]="IsGeographic",t[t.IsRoot=4]="IsRoot"}(u||(u={})),function(t){t[t.Regular=0]="Regular",t[t.Orthogonal=1]="Orthogonal",t[t.Curved=2]="Curved",t[t.Recursive=3]="Recursive"}(o||(o={}));const y=2,i=1,c=-1;var E,f,p,A,_,P,b,g,H;function L(t,e,a,n,s,u,o,l,y,i,c,E,f,p,A){const _=e.length,P=Float64Array.BYTES_PER_ELEMENT,b=Uint32Array.BYTES_PER_ELEMENT,g=16,H=g+t*(8*P)+_*(3*b),L=r._malloc(H);try{const H=L+g-L%g,h=H+t*P,d=h+t*P,C=d+t*P,F=C+t*P,m=F+t*P,R=m+t*P,T=R+t*P,U=T+t*P,B=U+_*b,v=B+_*b,N=()=>[r.HEAPF64.subarray(H>>3,(H>>3)+t),r.HEAPF64.subarray(h>>3,(h>>3)+t),r.HEAPF64.subarray(d>>3,(d>>3)+t),r.HEAPF64.subarray(C>>3,(C>>3)+t),r.HEAPF64.subarray(F>>3,(F>>3)+t),r.HEAPF64.subarray(m>>3,(m>>3)+t),r.HEAPF64.subarray(R>>3,(R>>3)+t),r.HEAPF64.subarray(T>>3,(T>>3)+t),r.HEAPU32.subarray(U>>2,(U>>2)+_),r.HEAPU32.subarray(B>>2,(B>>2)+_),r.HEAPU32.subarray(v>>2,(v>>2)+_)],[I,M,S,k,Y,w,G,x,z,D,V]=N();I.set(l),M.set(y),S.set(i),k.set(c),Y.set(E),w.set(f),G.set(p),x.set(A),z.set(e),D.set(a),V.set(n);const j=r.computeCentrality(t,_,U,B,v,s,u,o,H,h,d,C,F,m,R,T),[O,$,q,J,K,Q,W,X,Z,tt,et]=N();return l.set(O),y.set($),i.set(q),c.set(J),E.set(K),f.set(Q),p.set(W),A.set(X),e.set(Z),a.set(tt),n.set(et),j}finally{r._free(L)}}!function(t){function e(){return r.getMinIdealEdgeLength()}function a(t,e,a,n,s,u=y,o=i,E=c){return l(((t,e,a,n,s,l,y)=>r.applyForceDirectedLayout(t,e,a,n,s,l,y,u,o,E)),t,e,a,n,s)}t.getMinIdealEdgeLength=e,t.apply=a}(E||(E={})),function(t){function e(t,e,a,n,s,u=y,o=i,E=c){return l(((t,e,a,n,s,l,y)=>r.applyCommunityLayout(t,e,a,n,s,l,y,u,o,E)),t,e,a,n,s)}t.apply=e}(f||(f={})),function(t){function e(t,e,a,n,s){return l(r.applySimpleLayout,t,e,a,n,s)}t.apply=e}(p||(p={})),function(t){function e(t,e,a,n,s){return l(r.applyHierarchicalLayout,t,e,a,n,s)}t.apply=e}(A||(A={})),function(t){function e(t,e,a,n,s){return l(r.applyRadialTreeLayout,t,e,a,n,s)}t.apply=e}(_||(_={})),function(t){function e(t,e,a,n,s){return l(r.applySmartTreeLayout,t,e,a,n,s)}t.apply=e}(P||(P={})),function(t){function e(t,e,a,n,s,u,o,y,i){return l(((t,e,a,u,o,l,c)=>{if(n.length!==t)return!1;if(s.length!==t)return!1;if(y.length!==o)return!1;if(i.length!==o)return!1;const E=Float64Array.BYTES_PER_ELEMENT,f=16,p=r._malloc(f+t*E),A=r._malloc(f+t*E),_=r._malloc(f+o*E),P=r._malloc(f+o*E),b=p+f-p%f,g=A+f-A%f,H=_+f-_%f,L=P+f-P%f;try{return r.HEAPF64.subarray(b>>3,(b>>3)+t).set(n),r.HEAPF64.subarray(g>>3,(g>>3)+t).set(s),r.HEAPF64.subarray(H>>3,(H>>3)+o).set(y),r.HEAPF64.subarray(L>>3,(L>>3)+o).set(i),r.applyChronologicalLayout(t,e,a,u,b,g,o,l,c,H,L)}finally{r._free(p),r._free(A),r._free(_),r._free(P)}}),t,e,a,u,o)}t.apply=e}(b||(b={})),function(t){t[t.Undirected=0]="Undirected",t[t.Directed=1]="Directed",t[t.Reversed=2]="Reversed"}(g||(g={})),function(t){t[t.ByCC_Raw=0]="ByCC_Raw",t[t.ByCC_NormalizeGlobally=1]="ByCC_NormalizeGlobally",t[t.ByCC_NormalizeByCC=2]="ByCC_NormalizeByCC"}(H||(H={}));export{H as CentralityMode,b as LCChronologicalLayout,f as LCCommunityLayout,E as LCForceDirectedLayout,A as LCHierarchicalLayout,_ as LCRadialTreeLayout,p as LCSimpleLayout,P as LCSmartTreeLayout,o as LinkType,u as NodeFlag,g as RelationshipInterpretation,r as _lclib,L as computeCentrality,y as defaultBudgetTheoreticalSeconds,i as defaultIdealEdgeLengthMultiplier,c as defaultRepulsionRadiusMultiplier,a as isLoaded,n as load};
5
+ import{getAssetUrl as t}from"../../assets.js";let e,r=null;function a(){return!!r}function n(){return e||(e=import("../../chunks/lclayout.js").then((t=>t.l)).then((({default:e})=>e({locateFile:e=>t(`esri/libs/linkchartlayout/${e}`)}))).then((t=>{s(t)})),e)}function s(t){r=t}var u,o,l;function i(t,e,a,n,s,u){const o=a.length,l=s.length,i=Float64Array.BYTES_PER_ELEMENT,y=Uint32Array.BYTES_PER_ELEMENT,c=Uint8Array.BYTES_PER_ELEMENT,E=16,f=E+o*(c+2*i)+l*(2*y),p=r._malloc(f);try{const c=p+E-p%E,f=c+o*i,A=f+o*i,_=A+l*y,P=_+l*y,b=()=>[r.HEAPF64.subarray(c>>3,(c>>3)+o),r.HEAPF64.subarray(f>>3,(f>>3)+o),r.HEAPU32.subarray(A>>2,(A>>2)+l),r.HEAPU32.subarray(_>>2,(_>>2)+l),r.HEAPU8.subarray(P,P+o)],[g,L,h,H,d]=b();g.set(a),L.set(n),h.set(s),H.set(u),d.set(e);let C=t(o,P,c,f,l,A,_),F=null,m=null;if(C){const t=r.getLayoutLinksTypes(),e=r.getLayoutLinksVerticesEndIndices(),a=r.getLayoutLinksVertices(),n=r.countLayoutLinksVertices();!l||t&&e?n&&!a?C=!1:(F={types:new Uint8Array(r.HEAPU8.subarray(t,t+l)),vertexEndIndex:new Uint32Array(r.HEAPU32.subarray(e>>2,(e>>2)+l)),vertices:new Float64Array(r.HEAPF64.subarray(a>>3,(a>>3)+2*n))},m=r.getAuxiliaryGraphicElements()):C=!1}const[R,U,T,B,v]=b();return a.set(R),n.set(U),s.set(T),u.set(B),e.set(v),{success:C,links:F,graphics:m}}finally{r._free(p),r.cleanupLayout()}}!function(t){t[t.None=0]="None",t[t.IsMovable=1]="IsMovable",t[t.IsGeographic=2]="IsGeographic",t[t.IsRoot=4]="IsRoot"}(u||(u={})),function(t){t[t.Regular=0]="Regular",t[t.Orthogonal=1]="Orthogonal",t[t.Curved=2]="Curved",t[t.Recursive=3]="Recursive"}(o||(o={})),function(t){t[t.Right=0]="Right",t[t.Left=1]="Left",t[t.Up=2]="Up",t[t.Down=3]="Down"}(l||(l={}));const y=2,c=1,E=-1;var f,p,A,_,P,b,g,L,h;function H(t,e,a,n,s,u,o,l,i,y,c,E,f,p,A){const _=e.length,P=Float64Array.BYTES_PER_ELEMENT,b=Uint32Array.BYTES_PER_ELEMENT,g=16,L=g+t*(8*P)+_*(3*b),h=r._malloc(L);try{const L=h+g-h%g,H=L+t*P,d=H+t*P,C=d+t*P,F=C+t*P,m=F+t*P,R=m+t*P,U=R+t*P,T=U+t*P,B=T+_*b,v=B+_*b,N=()=>[r.HEAPF64.subarray(L>>3,(L>>3)+t),r.HEAPF64.subarray(H>>3,(H>>3)+t),r.HEAPF64.subarray(d>>3,(d>>3)+t),r.HEAPF64.subarray(C>>3,(C>>3)+t),r.HEAPF64.subarray(F>>3,(F>>3)+t),r.HEAPF64.subarray(m>>3,(m>>3)+t),r.HEAPF64.subarray(R>>3,(R>>3)+t),r.HEAPF64.subarray(U>>3,(U>>3)+t),r.HEAPU32.subarray(T>>2,(T>>2)+_),r.HEAPU32.subarray(B>>2,(B>>2)+_),r.HEAPU32.subarray(v>>2,(v>>2)+_)],[I,M,S,k,w,Y,D,G,x,z,V]=N();I.set(l),M.set(i),S.set(y),k.set(c),w.set(E),Y.set(f),D.set(p),G.set(A),x.set(e),z.set(a),V.set(n);const j=r.computeCentrality(t,_,T,B,v,s,u,o,L,H,d,C,F,m,R,U),[O,$,q,J,K,Q,W,X,Z,tt,et]=N();return l.set(O),i.set($),y.set(q),c.set(J),E.set(K),f.set(Q),p.set(W),A.set(X),e.set(Z),a.set(tt),n.set(et),j}finally{r._free(h)}}!function(t){function e(){return r.getMinIdealEdgeLength()}function a(t,e,a,n,s,u=y,o=c,l=E){return i(((t,e,a,n,s,i,y)=>r.applyForceDirectedLayout(t,e,a,n,s,i,y,u,o,l)),t,e,a,n,s)}t.getMinIdealEdgeLength=e,t.apply=a}(f||(f={})),function(t){function e(t,e,a,n,s,u=y,o=c,l=E){return i(((t,e,a,n,s,i,y)=>r.applyCommunityLayout(t,e,a,n,s,i,y,u,o,l)),t,e,a,n,s)}t.apply=e}(p||(p={})),function(t){function e(t,e,a,n,s){return i(r.applySimpleLayout,t,e,a,n,s)}t.apply=e}(A||(A={})),function(t){function e(t,e,a,n,s){return i(r.applyHierarchicalLayout,t,e,a,n,s)}t.apply=e}(_||(_={})),function(t){function e(t,e,a,n,s){return i(r.applyRadialTreeLayout,t,e,a,n,s)}t.apply=e}(P||(P={})),function(t){function e(t,e,a,n,s){return i(r.applySmartTreeLayout,t,e,a,n,s)}t.apply=e}(b||(b={})),function(t){function e(t,e,a,n,s,u,o,l,y){return i(((t,e,a,u,o,i,c)=>{if(n.length!==t)return!1;if(s.length!==t)return!1;if(l.length!==o)return!1;if(y.length!==o)return!1;const E=Float64Array.BYTES_PER_ELEMENT,f=16,p=r._malloc(f+t*E),A=r._malloc(f+t*E),_=r._malloc(f+o*E),P=r._malloc(f+o*E),b=p+f-p%f,g=A+f-A%f,L=_+f-_%f,h=P+f-P%f;try{return r.HEAPF64.subarray(b>>3,(b>>3)+t).set(n),r.HEAPF64.subarray(g>>3,(g>>3)+t).set(s),r.HEAPF64.subarray(L>>3,(L>>3)+o).set(l),r.HEAPF64.subarray(h>>3,(h>>3)+o).set(y),r.applyChronologicalLayout(t,e,a,u,b,g,o,i,c,L,h)}finally{r._free(p),r._free(A),r._free(_),r._free(P)}}),t,e,a,u,o)}t.apply=e}(g||(g={})),function(t){t[t.Undirected=0]="Undirected",t[t.Directed=1]="Directed",t[t.Reversed=2]="Reversed"}(L||(L={})),function(t){t[t.ByCC_Raw=0]="ByCC_Raw",t[t.ByCC_NormalizeGlobally=1]="ByCC_NormalizeGlobally",t[t.ByCC_NormalizeByCC=2]="ByCC_NormalizeByCC"}(h||(h={}));export{h as CentralityMode,l as Direction2D,g as LCChronologicalLayout,p as LCCommunityLayout,f as LCForceDirectedLayout,_ as LCHierarchicalLayout,P as LCRadialTreeLayout,A as LCSimpleLayout,b as LCSmartTreeLayout,o as LinkType,u as NodeFlag,L as RelationshipInterpretation,r as _lclib,H as computeCentrality,y as defaultBudgetTheoreticalSeconds,c as defaultIdealEdgeLengthMultiplier,E as defaultRepulsionRadiusMultiplier,a as isLoaded,n as load};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.31.0-next.20240605",
3
+ "version": "4.31.0-next.20240607",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const f="20240605",e="1f7048e43cea8f8f8de0f34323b9be757f25c86f";export{f as buildDate,e as commitHash};
5
+ const c="20240607",d="d301b1ac995ddfac8c397c98174ddadb696098c4";export{c as buildDate,d as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let l=class extends r{constructor(){super(...arguments),this.color=new t([0,255,255]),this.haloOpacity=1,this.fillOpacity=.25,this.multiHighlightEnabled=!1}equals(o){return this.color.equals(o.color)&&(this.haloColor||this.color).equals(o.haloColor||o.color)&&this.haloOpacity===o.haloOpacity&&this.fillOpacity===o.fillOpacity&&this.multiHighlightEnabled===o.multiHighlightEnabled}};o([i({type:t})],l.prototype,"color",void 0),o([i({type:t})],l.prototype,"haloColor",void 0),o([i()],l.prototype,"haloOpacity",void 0),o([i()],l.prototype,"fillOpacity",void 0),o([i()],l.prototype,"multiHighlightEnabled",void 0),l=o([s("esri.views.2d.support.HighlightOptions")],l);const p=l;export{p as default};
5
+ import{_ as s}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../support/HighlightOptions.js";let i=class extends r{constructor(){super(...arguments),this.multiHighlightEnabled=!1}equals(s){return super.equals(s)&&this.multiHighlightEnabled===s.multiHighlightEnabled}};s([t()],i.prototype,"multiHighlightEnabled",void 0),i=s([o("esri.views.2d.support.HighlightOptions")],i);const e=i;export{e as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import o from"../../../../core/Error.js";import{loadImageAsync as t}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as r}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as s,TextureEncoding as a}from"./enums.js";import{CullFaceOptions as l}from"../../webgl-engine/lib/basicInterfaces.js";import{downsampleImage as n}from"../../webgl-engine/lib/textureUtils.js";import{useSchematicPBR as i,defaultSchematicMRRFactors as u}from"../../webgl-engine/materials/pbrUtils.js";async function c(o){const t=[],r=[];if(null==o){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:t,textureData:r}}const a=d(o);"auto"===o.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');const n=i({normalTexture:o.normalTexture,emissiveTexture:a?o.emissiveTexture:null,emissiveFactor:a?e.toUnitRGB(o.emissiveColor):null,occlusionTexture:a?o.occlusionTexture:null,metallicRoughnessTexture:a?o.metallicRoughnessTexture:null,metallicFactor:a?o.metallic:null,roughnessFactor:a?o.roughness:null}),c=n?u[0]:a?o.metallic:0,g=n?u[1]:a?o.roughness:0;return{material:{alphaMode:"auto"===o.alphaMode?"blend":o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:o.doubleSided?l.None:l.Back,normalTextureId:await m(o.normalTexture,t,r,s.Normal),emissiveTextureId:a?await m(o.emissiveTexture,t,r,s.Emissive):-1,occlusionTextureId:a?await m(o.occlusionTexture,t,r,s.Occlusion):-1,emissiveFactor:a&&null!=o.emissiveColor?e.toUnitRGB(o.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=o.color?e.toUnitRGBA(o.color):[1,1,1,1],baseColorTextureId:await m(o.colorTexture,t,r,s.Color),metallicRoughnessTextureId:a?await m(o.metallicRoughnessTexture,t,r,s.MetallicRoughness):-1,metallicFactor:c,roughnessFactor:g},wrapTextures:!0,hasParametersFromSource:n},requiredTextures:t,textureData:r}}async function m(e,s,l,i){if(null==e)return-1;const u=l.length,c=e.data,m=e.url;if(null!=c){if(c instanceof HTMLImageElement||c instanceof HTMLCanvasElement){const e=n(c);return l.push({id:u,usage:i,data:e,encoding:a.PNG,downsampled:!1}),s.push({id:u,usage:i,encodings:[{name:void 0,encoding:a.PNG}]}),u}if(c instanceof HTMLVideoElement)return-1;if(c instanceof ImageData)throw new o("ImageData textures not supported yet for client side I3S nodes");if(c instanceof r)throw new o("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=m){const e=new Image;e.src=m;const o=await t(e,e.src,!1,void 0),r=n(o);return l.push({id:u,usage:i,data:r,encoding:a.PNG,downsampled:!1}),s.push({id:u,usage:i,encodings:[{name:void 0,encoding:a.PNG}]}),u}return-1}function d(e){return e.hasOwnProperty("metallicRoughnessTexture")}export{c as convertMeshMaterialToPBRMaterial};
5
+ import e from"../../../../Color.js";import o from"../../../../core/Error.js";import{loadImageAsync as t}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as r}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as s,TextureEncoding as a}from"./enums.js";import{alphaCutoff as l}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{CullFaceOptions as n}from"../../webgl-engine/lib/basicInterfaces.js";import{downsampleImage as i}from"../../webgl-engine/lib/textureUtils.js";import{useSchematicPBR as u,defaultSchematicMRRFactors as c}from"../../webgl-engine/materials/pbrUtils.js";async function m(o){const t=[],r=[];if(null==o){return{material:{alphaMode:"opaque",alphaCutoff:l,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:t,textureData:r}}const a=g(o);"auto"===o.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');const i=u({normalTexture:o.normalTexture,emissiveTexture:a?o.emissiveTexture:null,emissiveFactor:a?e.toUnitRGB(o.emissiveColor):null,occlusionTexture:a?o.occlusionTexture:null,metallicRoughnessTexture:a?o.metallicRoughnessTexture:null,metallicFactor:a?o.metallic:null,roughnessFactor:a?o.roughness:null}),m=i?c[0]:a?o.metallic:0,p=i?c[1]:a?o.roughness:0;return{material:{alphaMode:"auto"===o.alphaMode?"blend":o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:o.doubleSided?n.None:n.Back,normalTextureId:await d(o.normalTexture,t,r,s.Normal),emissiveTextureId:a?await d(o.emissiveTexture,t,r,s.Emissive):-1,occlusionTextureId:a?await d(o.occlusionTexture,t,r,s.Occlusion):-1,emissiveFactor:a&&null!=o.emissiveColor?e.toUnitRGB(o.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=o.color?e.toUnitRGBA(o.color):[1,1,1,1],baseColorTextureId:await d(o.colorTexture,t,r,s.Color),metallicRoughnessTextureId:a?await d(o.metallicRoughnessTexture,t,r,s.MetallicRoughness):-1,metallicFactor:m,roughnessFactor:p},wrapTextures:!0,hasParametersFromSource:i},requiredTextures:t,textureData:r}}async function d(e,s,l,n){if(null==e)return-1;const u=l.length,c=e.data,m=e.url;if(null!=c){if(c instanceof HTMLImageElement||c instanceof HTMLCanvasElement){const e=i(c);return l.push({id:u,usage:n,data:e,encoding:a.PNG,downsampled:!1}),s.push({id:u,usage:n,encodings:[{name:void 0,encoding:a.PNG}]}),u}if(c instanceof HTMLVideoElement)return-1;if(c instanceof ImageData)throw new o("ImageData textures not supported yet for client side I3S nodes");if(c instanceof r)throw new o("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=m){const e=new Image;e.src=m;const o=await t(e,e.src,!1,void 0),r=i(o);return l.push({id:u,usage:n,data:r,encoding:a.PNG,downsampled:!1}),s.push({id:u,usage:n,encodings:[{name:void 0,encoding:a.PNG}]}),u}return-1}function g(e){return e.hasOwnProperty("metallicRoughnessTexture")}export{m as convertMeshMaterialToPBRMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as o,TextureUsage as r}from"./enums.js";import{RenderTexture as a}from"../../webgl-engine/core/material/RenderTexture.js";import{defaultMaskAlphaCutoff as s}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as t}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as l,CullFaceOptions as n,AlphaDiscardMode as i}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as u}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBRI3S as c,useSchematicPBR as m,defaultSchematicMRRFactors as d,defaultAdvancedMRRFactors as g}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,o,a){const s=new Map,t=(e,o)=>{if(null==e)return-1;const r=s.get(e.id);if(r)return r.usage|=o,r.id;const a=s.size;return s.set(e.id,{id:a,usage:o}),a},l=o.pbrMetallicRoughness,i=l?.baseColorFactor,u=o.emissiveFactor,p=has("disable-feature:diffuse-rendering-i3s")||a?c({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}):m({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}),h=p?d[0]:l?.metallicFactor??g[0],x=p?d[1]:l?.roughnessFactor??g[1],F="mask"===o.alphaMode?r.Color|r.AlphaMask:r.Color,b={baseColorFactor:i?[i[0],i[1],i[2],i[3]]:[1,1,1,1],baseColorTextureId:t(l?.baseColorTexture,F),metallicRoughnessTextureId:t(l?.metallicRoughnessTexture,r.MetallicRoughness),metallicFactor:h,roughnessFactor:x},C={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:"front"===o.cullFace?n.Front:n.None,normalTextureId:t(o.normalTexture,r.Normal),emissiveTextureId:t(o.emissiveTexture,r.Emissive),occlusionTextureId:t(o.occlusionTexture,r.Occlusion),emissiveFactor:u?[u[0],u[1],u[2]]:[0,0,0],metallicRoughness:b,wrapTextures:!1,hasParametersFromSource:p},P=[];return s.forEach((({usage:o},r)=>{const a=null!=e&&e[r]&&e[r].formats,s=a?T(a.map((({name:e,format:o})=>({name:e,encoding:f[o]})))):[];P.push({id:r,usage:o,encodings:s})})),{material:C,textures:P}}function T(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const f={ktx2:o.KTX2,basis:o.Basis,dds:o.DDS_S3TC,png:o.PNG,jpg:o.JPG,"ktx-etc2":o.KTX_ETC2},x={[l.KTX2_ENCODING]:o.Basis,[l.BASIS_ENCODING]:o.Basis,[l.DDS_ENCODING]:o.DDS_S3TC,"image/png":o.PNG,"image/jpg":o.JPG,"image/jpeg":o.JPG,"image/ktx":o.KTX_ETC2};function F(o){const a=o?.materialDefinitions?Object.keys(o.materialDefinitions)[0]:null,s=o?.textureDefinitions?Object.keys(o.textureDefinitions)[0]:null,t=a?o.materialDefinitions?.[a]:null,l=s?o.textureDefinitions?.[s]:null,i=b();if(null!=t){const o=t.params;o.diffuse&&(i.metallicRoughness.baseColorFactor=[o.diffuse[0],o.diffuse[1],o.diffuse[2],1]),null!=o.doubleSided&&(i.doubleSided=o.doubleSided,i.cullFace=o.doubleSided?n.None:n.Back),"none"!==o.cullFace&&"front"!==o.cullFace&&"back"!==o.cullFace||(i.cullFace="none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:n.Front),o.transparency&&(i.metallicRoughness.baseColorFactor[3]=e(1-o.transparency,0,1)),(o.useVertexColorAlpha||i.metallicRoughness.baseColorFactor[3]<1)&&(i.alphaMode="blend")}const u=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(i.wrapTextures=!0);let o=r.Color;"rgba"===l.channels&&(i.alphaMode="blend",o|=r.AlphaMask);const a=l.images.length-1,s=l.images[a],t=e=>e?.split("/").pop(),n=Array.isArray(l.encoding)?T(l.encoding.map(((e,o)=>({name:t(s.href[o]),encoding:x[e]||0})))):[{name:t(s.href),encoding:x[l.encoding]||0}];u.push({id:e,usage:o,encodings:n}),i.metallicRoughness.baseColorTextureId=e}return{material:i,textures:u}}const b=()=>({alphaMode:"opaque",alphaCutoff:s,doubleSided:!0,cullFace:n.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,o,a,s){if(null==e?.data)return null;const t=e.data,l=s.renderingContext.parameters.maxMaxAnisotropy,n=l>1,i=a||!o.wrapTextures?P:S,c=N(e.encoding),m=e.usage&r.Color?"opaque"===o.alphaMode?3:4:3;return new u(t,{mipmap:n,maxAnisotropy:l,encoding:c,wrap:i,components:m,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},S={s:p.REPEAT,t:p.REPEAT};function M(o,l,n,u,c,m){const p=m.rendererTextureUsage,h=e=>w(u,n,e&p),T=l.metallicRoughness.baseColorFactor,f=e(l.metallicRoughness.baseColorFactor[3],0,1);o.baseColor=[T[0],T[1],T[2],f],o.hasParametersFromSource=!!l.hasParametersFromSource,o.usePBR=m.usePBR,o.mrrFactors=[l.metallicRoughness.metallicFactor,l.metallicRoughness.roughnessFactor,l.hasParametersFromSource?d[2]:g[2]],o.emissiveFactor=l.emissiveFactor,o.isIntegratedMesh=m.isIntegratedMesh,o.textureAlphaCutoff="mask"===l.alphaMode?l.alphaCutoff:s,o.alphaDiscardMode="opaque"===l.alphaMode?i.Opaque:"mask"===l.alphaMode?i.Mask:i.MaskBlend;const x=[],F=h(r.Color|r.AlphaMask);null!=F&&(o.baseColorTexture=new a(c,F),x.push(o.baseColorTexture.loadPromise));const b=h(r.MetallicRoughness);null!=b&&(o.metallicRoughnessTexture=new a(c,b),x.push(o.metallicRoughnessTexture.loadPromise));const C=h(r.Emissive);null!=C&&(o.emissionTexture=new a(c,C),x.push(o.emissionTexture.loadPromise));const P=h(r.Occlusion);null!=P&&(o.occlusionTexture=new a(c,P),x.push(o.occlusionTexture.loadPromise));const S=h(r.Normal);return null!=S&&(o.normalTexture=new a(c,S),x.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=l.doubleSided,o.commonMaterialParameters.cullFace=l.cullFace,o.ellipsoidMode=t(m.viewSpatialReference),Promise.all(x)}function R(e){const r=!!e.compressedTextureS3TC,a=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:o.Basis|o.KTX2,t=o.JPG|o.PNG,l=s|o.DDS_S3TC;return t|(r?l:0)|(a?s:0)}function D(e,o){if(null!=o)return e.find((e=>!!(e.encoding&o)))}function w(e,o,a){if(null==e||a===r.None)return null;for(let r=0;r<e.length;r++){const s=e[r];if(null!=s&&s.usage&a){const e=o[r];return null!=e?e.id:null}}return null}function N(e){switch(e){case o.KTX2:return l.KTX2_ENCODING;case o.Basis:return l.BASIS_ENCODING;case o.DDS_S3TC:return l.DDS_ENCODING;case o.PNG:return"image/png";case o.JPG:return"image/jpeg";case o.KTX_ETC2:return"image/ktx";default:return""}}export{M as configureMaterial,C as createTexture,b as defaultMaterial,h as getMaterialAndTextures,F as getMaterialAndTexturesFromShared,R as getSupportedEncodings,D as selectEncoding};
5
+ import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as o,TextureUsage as r}from"./enums.js";import{RenderTexture as a}from"../../webgl-engine/core/material/RenderTexture.js";import{alphaCutoff as s}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as t}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as l,CullFaceOptions as n,AlphaDiscardMode as i}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as u}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBRI3S as c,useSchematicPBR as m,defaultSchematicMRRFactors as d,defaultAdvancedMRRFactors as g}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,o,a){const s=new Map,t=(e,o)=>{if(null==e)return-1;const r=s.get(e.id);if(r)return r.usage|=o,r.id;const a=s.size;return s.set(e.id,{id:a,usage:o}),a},l=o.pbrMetallicRoughness,i=l?.baseColorFactor,u=o.emissiveFactor,p=has("disable-feature:diffuse-rendering-i3s")||a?c({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}):m({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}),h=p?d[0]:l?.metallicFactor??g[0],x=p?d[1]:l?.roughnessFactor??g[1],F="mask"===o.alphaMode?r.Color|r.AlphaMask:r.Color,b={baseColorFactor:i?[i[0],i[1],i[2],i[3]]:[1,1,1,1],baseColorTextureId:t(l?.baseColorTexture,F),metallicRoughnessTextureId:t(l?.metallicRoughnessTexture,r.MetallicRoughness),metallicFactor:h,roughnessFactor:x},C={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:"front"===o.cullFace?n.Front:n.None,normalTextureId:t(o.normalTexture,r.Normal),emissiveTextureId:t(o.emissiveTexture,r.Emissive),occlusionTextureId:t(o.occlusionTexture,r.Occlusion),emissiveFactor:u?[u[0],u[1],u[2]]:[0,0,0],metallicRoughness:b,wrapTextures:!1,hasParametersFromSource:p},P=[];return s.forEach((({usage:o},r)=>{const a=null!=e&&e[r]&&e[r].formats,s=a?T(a.map((({name:e,format:o})=>({name:e,encoding:f[o]})))):[];P.push({id:r,usage:o,encodings:s})})),{material:C,textures:P}}function T(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const f={ktx2:o.KTX2,basis:o.Basis,dds:o.DDS_S3TC,png:o.PNG,jpg:o.JPG,"ktx-etc2":o.KTX_ETC2},x={[l.KTX2_ENCODING]:o.Basis,[l.BASIS_ENCODING]:o.Basis,[l.DDS_ENCODING]:o.DDS_S3TC,"image/png":o.PNG,"image/jpg":o.JPG,"image/jpeg":o.JPG,"image/ktx":o.KTX_ETC2};function F(o){const a=o?.materialDefinitions?Object.keys(o.materialDefinitions)[0]:null,s=o?.textureDefinitions?Object.keys(o.textureDefinitions)[0]:null,t=a?o.materialDefinitions?.[a]:null,l=s?o.textureDefinitions?.[s]:null,i=b();if(null!=t){const o=t.params;o.diffuse&&(i.metallicRoughness.baseColorFactor=[o.diffuse[0],o.diffuse[1],o.diffuse[2],1]),null!=o.doubleSided&&(i.doubleSided=o.doubleSided,i.cullFace=o.doubleSided?n.None:n.Back),"none"!==o.cullFace&&"front"!==o.cullFace&&"back"!==o.cullFace||(i.cullFace="none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:n.Front),o.transparency&&(i.metallicRoughness.baseColorFactor[3]=e(1-o.transparency,0,1)),(o.useVertexColorAlpha||i.metallicRoughness.baseColorFactor[3]<1)&&(i.alphaMode="blend")}const u=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(i.wrapTextures=!0);let o=r.Color;"rgba"===l.channels&&(i.alphaMode="blend",o|=r.AlphaMask);const a=l.images.length-1,s=l.images[a],t=e=>e?.split("/").pop(),n=Array.isArray(l.encoding)?T(l.encoding.map(((e,o)=>({name:t(s.href[o]),encoding:x[e]||0})))):[{name:t(s.href),encoding:x[l.encoding]||0}];u.push({id:e,usage:o,encodings:n}),i.metallicRoughness.baseColorTextureId=e}return{material:i,textures:u}}const b=()=>({alphaMode:"opaque",alphaCutoff:s,doubleSided:!0,cullFace:n.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,o,a,s){if(null==e?.data)return null;const t=e.data,l=s.renderingContext.parameters.maxMaxAnisotropy,n=l>1,i=a||!o.wrapTextures?P:S,c=N(e.encoding),m=e.usage&r.Color?"opaque"===o.alphaMode?3:4:3;return new u(t,{mipmap:n,maxAnisotropy:l,encoding:c,wrap:i,components:m,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},S={s:p.REPEAT,t:p.REPEAT};function M(o,l,n,u,c,m){const p=m.rendererTextureUsage,h=e=>w(u,n,e&p),T=l.metallicRoughness.baseColorFactor,f=e(l.metallicRoughness.baseColorFactor[3],0,1);o.baseColor=[T[0],T[1],T[2],f],o.hasParametersFromSource=!!l.hasParametersFromSource,o.usePBR=m.usePBR,o.mrrFactors=[l.metallicRoughness.metallicFactor,l.metallicRoughness.roughnessFactor,l.hasParametersFromSource?d[2]:g[2]],o.emissiveFactor=l.emissiveFactor,o.isIntegratedMesh=m.isIntegratedMesh,o.textureAlphaCutoff="mask"===l.alphaMode?l.alphaCutoff:s,o.alphaDiscardMode="opaque"===l.alphaMode?i.Opaque:"mask"===l.alphaMode?i.Mask:i.MaskBlend;const x=[],F=h(r.Color|r.AlphaMask);null!=F&&(o.baseColorTexture=new a(c,F),x.push(o.baseColorTexture.loadPromise));const b=h(r.MetallicRoughness);null!=b&&(o.metallicRoughnessTexture=new a(c,b),x.push(o.metallicRoughnessTexture.loadPromise));const C=h(r.Emissive);null!=C&&(o.emissionTexture=new a(c,C),x.push(o.emissionTexture.loadPromise));const P=h(r.Occlusion);null!=P&&(o.occlusionTexture=new a(c,P),x.push(o.occlusionTexture.loadPromise));const S=h(r.Normal);return null!=S&&(o.normalTexture=new a(c,S),x.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=l.doubleSided,o.commonMaterialParameters.cullFace=l.cullFace,o.ellipsoidMode=t(m.viewSpatialReference),Promise.all(x)}function R(e){const r=!!e.compressedTextureS3TC,a=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:o.Basis|o.KTX2,t=o.JPG|o.PNG,l=s|o.DDS_S3TC;return t|(r?l:0)|(a?s:0)}function D(e,o){if(null!=o)return e.find((e=>!!(e.encoding&o)))}function w(e,o,a){if(null==e||a===r.None)return null;for(let r=0;r<e.length;r++){const s=e[r];if(null!=s&&s.usage&a){const e=o[r];return null!=e?e.id:null}}return null}function N(e){switch(e){case o.KTX2:return l.KTX2_ENCODING;case o.Basis:return l.BASIS_ENCODING;case o.DDS_S3TC:return l.DDS_ENCODING;case o.PNG:return"image/png";case o.JPG:return"image/jpeg";case o.KTX_ETC2:return"image/ktx";default:return""}}export{M as configureMaterial,C as createTexture,b as defaultMaterial,h as getMaterialAndTextures,F as getMaterialAndTexturesFromShared,R as getSupportedEncodings,D as selectEncoding};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{defaultColor as i,defaultHaloOpacity as p,defaultFillOpacity as c,defaultShadowOpacity as l,defaultShadowColor as a,defaultShadowDifference as h}from"../webgl-engine/effects/highlight/HighlightDefaults.js";let d=class extends r{constructor(){super(...arguments),this.color=i.clone(),this.haloColor=null,this.haloOpacity=p,this.fillOpacity=c,this.shadowOpacity=l,this.shadowColor=a.clone(),this.shadowDifference=h}};o([s({type:t})],d.prototype,"color",void 0),o([s({type:t})],d.prototype,"haloColor",void 0),o([s()],d.prototype,"haloOpacity",void 0),o([s()],d.prototype,"fillOpacity",void 0),o([s()],d.prototype,"shadowOpacity",void 0),o([s({type:t})],d.prototype,"shadowColor",void 0),o([s()],d.prototype,"shadowDifference",void 0),d=o([e("esri.views.3d.support.HighlightOptions")],d);const y=d;export{y as default};
5
+ import{_ as o}from"../../../chunks/tslib.es6.js";import s from"../../../Color.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as t}from"../../../core/accessorSupport/decorators/subclass.js";import{defaultShadowColor as e,defaultShadowOpacity as p,defaultShadowDifference as i}from"../../support/HighlightDefaults.js";import a from"../../support/HighlightOptions.js";let h=class extends a{constructor(){super(...arguments),this.shadowColor=e.clone(),this.shadowOpacity=p,this.shadowDifference=i}equals(o){return super.equals(o)&&this.shadowColor===o.shadowColor&&this.shadowOpacity===o.shadowOpacity&&this.shadowColor.equals(o.shadowColor)}};o([r({type:s})],h.prototype,"shadowColor",void 0),o([r()],h.prototype,"shadowOpacity",void 0),o([r()],h.prototype,"shadowDifference",void 0),h=o([t("esri.views.3d.support.HighlightOptions")],h);const c=h;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,F as s,H as o,f as a,n,m as l,z as g,G as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{LayerClass as y}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as S,oppositeEdge as C,neighborCornerIndices as D,v32s as b,lij2s as T}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.fadeDuration)),this.overlay=new R,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=S[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbors[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);B[t]=l,B[(t+1)%4]=n,B[(t+2)%4]=e,B[(t+3)%4]=a,$(B.some((t=>t?.isLoaded||t===e)));const g=B.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);B.forEach(((e,t)=>{e&&e?.level>g&&(B[t]=null)})),$(B.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=B[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)B[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&q)}get samplerDataChanged(){return!!(this._modifiedFlags&z)}get clippingAreaChanged(){return!!(this._modifiedFlags&J)}get wireframeChanged(){return!!(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=e&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[y.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[y.ELEVATION][g].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,y.ELEVATION);if(w(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=S.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const y=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(x.isLoaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.isLoaded)return $(!x.isLeaf),void $(0===v);const E=x.renderData;$(V(e,x,r)),$(v>=0);const S=2**v;if(v<0)return void $(!1);const C=e.renderData,D=C.geometry,j=C.localOrigin,A=D.getEdgeCount(y),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.isLoaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=w.getEdgeCount(P),G=A-1,B=F-1;$(G*S===B,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${B} (expected:${G*S})`);const W=e.extent,q=r===_.NORTH||r===_.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(y,x);$(0<=Y&&Y<S);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(y,O,j,0),D.getEdgeVertexPosition(y,I,j,A-1);const re=i(O,I),ie=Math.max(X,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===_.WEST?W[0]:W[2],p=q?r===_.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${ee}/${A}] and [${x.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${y}][${ee}/${n}] vs neighbor [${x.lij}].edge[${P}][${te}/${l}] ${b(O)} vs ${b(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(H,U);const _=l(k,H),S=1-_<.01||!1||e===x;if(!S){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${ee}/${A-1}) edge ${y} vs neighbor ${T(x.lij)} (${te}/${F-1}) nedge ${P} :${b(M)} vs ${b(U)} dot = ${_} : ${b(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",b(M)," => ",b(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",b(U)," => ",b(r))}$(S,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),H=h(),X=1,B=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,F as s,H as o,f as a,n,m as l,z as g,G as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{LayerClass as y}from"./LayerClass.js";import{NeighborIndex as _}from"./NeighborIndex.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as S,oppositeEdge as C,neighborCornerIndices as D,v32s as b,lij2s as T}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayerView as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.fadeDuration)),this.overlay=new R,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=S[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbors[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);B[t]=l,B[(t+1)%4]=n,B[(t+2)%4]=e,B[(t+3)%4]=a,$(B.some((t=>t?.isLoaded||t===e)));const g=B.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);B.forEach(((e,t)=>{e&&e?.level>g&&(B[t]=null)})),$(B.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=B[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)B[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return!!(this._modifiedFlags&q)}get samplerDataChanged(){return!!(this._modifiedFlags&z)}get clippingAreaChanged(){return!!(this._modifiedFlags&J)}get wireframeChanged(){return!!(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=e&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[y.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[y.ELEVATION][g].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,y.ELEVATION);if(w(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=S.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const y=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((r,y)=>{if(f[y])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(x.isLoaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.isLoaded)return $(!x.isLeaf),void $(0===v);const E=x.renderData;$(V(e,x,r)),$(v>=0);const S=2**v;if(v<0)return void $(!1);const C=e.renderData,D=C.geometry,j=C.localOrigin,A=D.getEdgeCount(y),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.isLoaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=w.getEdgeCount(P),G=A-1,B=F-1;$(G*S===B,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${B} (expected:${G*S})`);const W=e.extent,q=r===_.NORTH||r===_.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(y,x);$(0<=Y&&Y<S);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(y,O,j,0),D.getEdgeVertexPosition(y,I,j,A-1);const re=i(O,I),ie=Math.max(X,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===_.WEST?W[0]:W[2],p=q?r===_.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${ee}/${A}] and [${x.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${y}][${ee}/${n}] vs neighbor [${x.lij}].edge[${P}][${te}/${l}] ${b(O)} vs ${b(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(H,U);const _=l(k,H),S=1-_<.01||!1||e===x;if(!S){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${ee}/${A-1}) edge ${y} vs neighbor ${T(x.lij)} (${te}/${F-1}) nedge ${P} :${b(M)} vs ${b(U)} dot = ${_} : ${b(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(y,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",b(M)," => ",b(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",b(U)," => ",b(r))}$(S,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),H=h(),X=1,B=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,q as n,m as r,j as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{c as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{ElevationBounds as M}from"./ElevationBounds.js";import{ElevationTileAgent as T,isElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as A}from"./interfaces.js";import{LayerClasses as E,LayerClass as D}from"./LayerClass.js";import{MapTileAgent as I,isMapTileAgent as L}from"./MapTileAgent.js";import{NeighborIndex as x}from"./NeighborIndex.js";import{maxPatchTesselation as S}from"./TerrainConst.js";import{isVectorTile as O,isTileTexture as N,isRasterTile as b,isImageWithType as j}from"./TerrainData.js";import{weakAssert as U,getLayerWithExtentRange as C,isBlendableLayerView as B,oppositeCorner as P,internalAssert as R,enableTerrainInternalChecks as V,neighborEdgeIndices as w,oppositeEdge as G,neighborCornerIndices as W,isNorth as q,isSouth as F,isWest as H,isEast as k,enableWaterproofTests as X,almostEquals as Y,isWestCorner as z,isNorthCorner as J}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TileFrustumVisibility as Q}from"./TileFrustumVisibility.js";import{TilePerLayerInfo as K}from"./TilePerLayerInfo.js";import{TileUpdate as Z}from"./TileUpdate.js";import{fallsWithinLayer as ee}from"./tileUtils.js";const te=.1;class ie{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){re.prune(0),ae.prune(0),K.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[le.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??Q.INTERSECTS;this._frustumVisibility=t===Q.INSIDE?Q.INSIDE:t===Q.OUTSIDE?Q.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==Q.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[le.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of E){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=K.acquire(this._surface.upsampleInfoPool),r===D.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,S)}dispose(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach((e=>{e.forEach((e=>e.release())),e.length=0})),this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemory)}get _cachedMemory(){return this._ensureUsedMemory(),this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[D.MAP].reduce(((e,{data:t})=>e+(O(t)?t.usedMemoryPerReference:0)),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:t}of this.layerInfo[D.MAP])O(t)?this._vectorTileMemory+=t.usedMemoryPerReference:this._rasterTileMemory+=this._getTerrainDataMemory(t);const e=this._cpuImageMemorySize;for(const t of this.layerInfo[D.ELEVATION])this._usedMemory+=t.data?e:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===D.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===D.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return N(e)?e.texture.usedMemory:b(e)?e.memoryUsage:O(e)?e.usedMemoryPerReference:j(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[le.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return Z.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===Q.OUTSIDE))return Z.NONE;const h=this.level;s(fe,m(this._center[le.MIDDLE]),t);let u=n(fe),d=fe,c=m(this._center[le.MIDDLE]);s(_e,this._center[le.TOP],t);const g=n(_e);g<u&&(u=g,d=_e,c=this._center[le.TOP]),s(me,this._center[le.BOTTOM],t);const p=n(me);if(p<u&&(u=p,d=me,c=this._center[le.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return Z.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,M=()=>{if(h<e.maxLod)return this.elevationLevel=h,Z.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,Z.ELEVATION):Z.NONE},T=null!=i?i-h:1/0;if(T<=.5)return M();const v=r(this.up,fe),A=this._elevationBoundsMax-this._elevationBoundsMin,E=A/this.edgeLen;if(e.aboveGround&&v>0&&E<.001){if(v/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return Z.NONE}const D=null!=i?3-Math.min(T,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return M();if(h<7)return Z.SPLIT;a(ye,this.up,v),s(ye,ye,d);const I=n(ye);if(I<=this.radius*this.radius)return Z.SPLIT;a(ye,ye,this.radius/Math.sqrt(I)),o(ye,ye,c),s(ye,t,ye);const L=Math.min(1,(Math.abs(r(ye,this.up))+.5*A+this._curvatureHeight)/l(ye)),x=te/e.angledSplitBias,S=e.fovY*f*2;return L*(this._edgeLen/S*D)<x*e.relativeHeightLimit?Z.NONE:Z.SPLIT}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of E)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){this.renderData&&this.unrefMapData(),e.unloadTile(this);for(const t of E){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(ne(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(Z.GEOMETRY),this.resetPendingUpdate(Z.TEXTURE_NOFADING),this.resetPendingUpdate(Z.TEXTURE_FADING)}unloadMapData(){const e=this.layerInfo[D.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(ne(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(Z.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of E){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(Z.SPLIT)||e!==D.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===Z.SPLIT||e===Z.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=O(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(ye,m(this._center[le.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=O(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll((e=>e.dataMissing())),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case D.MAP:return this._updateTexture(t);case D.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===A.FADING?Z.TEXTURE_NOFADING:Z.TEXTURE_FADING),this.setPendingUpdate(e===A.FADING?Z.TEXTURE_FADING:Z.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(Z.GEOMETRY);for(const e of this.layerInfo[D.ELEVATION])e.pendingUpdates|=Z.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[D.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(ye,this.up,i),o(m(s[le.MIDDLE]),this.centerAtSeaLevel,ye),a(ye,this.up,e),o(s[le.TOP],this.centerAtSeaLevel,ye),a(ye,this.up,t),o(s[le.BOTTOM],this.centerAtSeaLevel,ye)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[D.ELEVATION][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,D.ELEVATION),o=C(a);if(!ee(this,o,!1))return;const l=oe;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[D.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new M),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(ne(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:K.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,A.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of E){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,A.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(B(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=C(o);if(r.loadingAgent?ee(this,l,!1)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(a=r.loadingAgent.update())):r.dispose():ee(this,l,!1)&&(r.loadingAgent=se(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===$&&this.setPendingUpdate(Z.GEOMETRY):(ne(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&this.updateRenderData(t,A.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(he(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?ue(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(P(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(R(!V||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return V&&(R(a<=o&&o<a+s),R(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;w.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(G(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),W.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(P(t),(e=>e.isLoaded));R(!s||ce(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=q(t)?-1:F(t)?1:0,s=H(t)?-1:k(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){X&&(R(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(q(e)&&t[3]+s>=i[3])return!1;if(F(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&H(e)&&t[0]-s<=i[0])&&!(!n&&k(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[le.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function se(e,t,i,s){const n=i===D.ELEVATION?ae.acquire():re.acquire();return n.init(e,t,i,s),n}function ne(e){e.dispose(),v(e)?ae.release(e):L(e)&&re.release(e)}const re=new i(I),ae=new i(T),oe=new M;var le;function he(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function ue(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function de(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return Y(e.extent[3],t.extent[1],s);case x.SOUTH:return Y(e.extent[1],t.extent[3],s);case x.EAST:return Y(e.extent[2],t.extent[0],s)||Y(e.extent[2],-t.extent[0],s);case x.WEST:return Y(e.extent[0],t.extent[2],s)||Y(e.extent[0],-t.extent[2],s)}}function ce(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ge(e,t,i):ge(t,e,P(i)))}function ge(e,t,i){R(e.level>=t.level);const s=z(i),n=J(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=Y(o[0],l[0],h)||e.surface.isGlobal&&Y(o[0],-l[0],h),d=Y(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return R(!1),!1;if(!u&&!d)return R(!1),!1;const c=u?pe(a[1],a[3],r[1],r[3],h):pe(a[0],a[2],r[0],r[2],h);return R(c),c}function pe(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(le||(le={}));const fe=u(),_e=u(),me=u(),ye=u();export{le as CenterPosition,ie as Tile,ce as isCornerNeighbor,de as isEdgeNeighbor,ue as lijEquals};
5
+ import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,q as n,m as r,j as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{c as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{ElevationBounds as M}from"./ElevationBounds.js";import{ElevationTileAgent as T,isElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as A}from"./interfaces.js";import{LayerClasses as E,LayerClass as D}from"./LayerClass.js";import{MapTileAgent as I,isMapTileAgent as L}from"./MapTileAgent.js";import{NeighborIndex as x}from"./NeighborIndex.js";import{maxPatchTesselation as S}from"./TerrainConst.js";import{isVectorTile as O,isTileTexture as N,isRasterTile as b,isImageWithType as j}from"./TerrainData.js";import{weakAssert as U,isBlendableLayerView as C,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as R,neighborEdgeIndices as V,oppositeEdge as w,neighborCornerIndices as G,isNorth as W,isSouth as q,isWest as F,isEast as H,enableWaterproofTests as k,almostEquals as X,isWestCorner as Y,isNorthCorner as z}from"./terrainUtils.js";import{tileAgentDone as J}from"./TileAgent.js";import{TileFrustumVisibility as $}from"./TileFrustumVisibility.js";import{TilePerLayerInfo as Q}from"./TilePerLayerInfo.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayerView as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}static prune(){ne.prune(0),re.prune(0),Q.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[oe.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??$.INTERSECTS;this._frustumVisibility=t===$.INSIDE?$.INSIDE:t===$.OUTSIDE?$.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==$.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[oe.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of E){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=Q.acquire(this._surface.upsampleInfoPool),r===D.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,S)}dispose(){U(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key),this.layerInfo.forEach((e=>{e.forEach((e=>e.release())),e.length=0})),this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemory)}get _cachedMemory(){return this._ensureUsedMemory(),this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[D.MAP].reduce(((e,{data:t})=>e+(O(t)?t.usedMemoryPerReference:0)),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:t}of this.layerInfo[D.MAP])O(t)?this._vectorTileMemory+=t.usedMemoryPerReference:this._rasterTileMemory+=this._getTerrainDataMemory(t);const e=this._cpuImageMemorySize;for(const t of this.layerInfo[D.ELEVATION])this._usedMemory+=t.data?e:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemory),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===D.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===D.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return N(e)?e.texture.usedMemory:b(e)?e.memoryUsage:O(e)?e.usedMemoryPerReference:j(e)||e instanceof HTMLImageElement?this._cpuImageMemorySize:0}updateScreenDepth(e){const t=this._center[oe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return K.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===$.OUTSIDE))return K.NONE;const h=this.level;s(pe,m(this._center[oe.MIDDLE]),t);let u=n(pe),d=pe,c=m(this._center[oe.MIDDLE]);s(fe,this._center[oe.TOP],t);const g=n(fe);g<u&&(u=g,d=fe,c=this._center[oe.TOP]),s(_e,this._center[oe.BOTTOM],t);const p=n(_e);if(p<u&&(u=p,d=_e,c=this._center[oe.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return K.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,M=()=>{if(h<e.maxLod)return this.elevationLevel=h,K.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,K.ELEVATION):K.NONE},T=null!=i?i-h:1/0;if(T<=.5)return M();const v=r(this.up,pe),A=this._elevationBoundsMax-this._elevationBoundsMin,E=A/this.edgeLen;if(e.aboveGround&&v>0&&E<.001){if(v/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return K.NONE}const D=null!=i?3-Math.min(T,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return M();if(h<7)return K.SPLIT;a(me,this.up,v),s(me,me,d);const I=n(me);if(I<=this.radius*this.radius)return K.SPLIT;a(me,me,this.radius/Math.sqrt(I)),o(me,me,c),s(me,t,me);const L=Math.min(1,(Math.abs(r(me,this.up))+.5*A+this._curvatureHeight)/l(me)),x=ee/e.angledSplitBias,S=e.fovY*f*2;return L*(this._edgeLen/S*D)<x*e.relativeHeightLimit?K.NONE:K.SPLIT}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of E)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){this.renderData&&this.unrefMapData(),e.unloadTile(this);for(const t of E){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==J&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING)}unloadMapData(){const e=this.layerInfo[D.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==J&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of E){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==J&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==D.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=O(n.data);return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(me,m(this._center[oe.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);U(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=O(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll((e=>e.dataMissing())),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case D.MAP:return this._updateTexture(t);case D.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===A.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===A.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[D.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[D.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(me,this.up,i),o(m(s[oe.MIDDLE]),this.centerAtSeaLevel,me),a(me,this.up,e),o(s[oe.TOP],this.centerAtSeaLevel,me),a(me,this.up,t),o(s[oe.BOTTOM],this.centerAtSeaLevel,me)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[D.ELEVATION][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,D.ELEVATION);if(!Z(this,a))return;const o=ae;let l=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;o.min=e.samplerData.data.minValue,o.max=e.samplerData.data.maxValue,o.hasNoDataValues=e.samplerData.data.hasNoDataValues,o.level=this.level,l=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[D.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],o),o.min!==1/0&&(o.level=i.level,l=!0))}l&&(null==i.elevationBounds&&(i.elevationBounds=new M),i.elevationBounds.copyFrom(o))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==J&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:Q.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,A.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===J&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of E){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==J&&(i.loadingAgent.setSuspension(t),i.loadingAgent===J&&this.updateRenderData(e,A.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==J&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=J,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(C(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n],a=this._surface.layerViewByIndex(n,t);let o=!1;if(r.loadingAgent?Z(this,a)?(r.loadingAgent!==J&&r.loadingAgent.setSuspension(s),r.loadingAgent!==J&&(o=r.loadingAgent.update())):r.dispose():Z(this,a)&&(r.loadingAgent=ie(this,n,t,s),o=r.loadingAgent.startLoading(),o?r.loadingAgent===J&&this.setPendingUpdate(K.GEOMETRY):(se(r.loadingAgent),r.loadingAgent=J)),r.loadingAgent===J&&this.updateRenderData(t,A.FADING),!this._hasBlendModes(e,i.length,t)&&o&&a.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,this.elevationLevelDelta-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?he(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===x.NORTH_EAST?1:e===x.NORTH_WEST?0:e===x.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===x.NORTH?[0,1]:e===x.NORTH_EAST?[1]:e===x.EAST?[1,3]:e===x.SOUTH_EAST?[3]:e===x.SOUTH?[2,3]:e===x.SOUTH_WEST?[2]:e===x.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!R||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return R&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));P(!s||de(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=W(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){k&&(P(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[oe.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ie(e,t,i,s){const n=i===D.ELEVATION?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),v(e)?re.release(e):L(e)&&ne.release(e)}const ne=new i(I),re=new i(T),ae=new M;var oe;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function he(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ue(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===x.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===x.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case x.NORTH:return X(e.extent[3],t.extent[1],s);case x.SOUTH:return X(e.extent[1],t.extent[3],s);case x.EAST:return X(e.extent[2],t.extent[0],s)||X(e.extent[2],-t.extent[0],s);case x.WEST:return X(e.extent[0],t.extent[2],s)||X(e.extent[0],-t.extent[2],s)}}function de(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ce(e,t,i):ce(t,e,B(i)))}function ce(e,t,i){P(e.level>=t.level);const s=Y(i),n=z(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=X(o[0],l[0],h)||e.surface.isGlobal&&X(o[0],-l[0],h),d=X(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return P(!1),!1;if(!u&&!d)return P(!1),!1;const c=u?ge(a[1],a[3],r[1],r[3],h):ge(a[0],a[2],r[0],r[2],h);return P(c),c}function ge(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(oe||(oe={}));const pe=u(),fe=u(),_e=u(),me=u();export{oe as CenterPosition,te as Tile,de as isCornerNeighbor,ue as isEdgeNeighbor,he as lijEquals};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../core/has.js";import{TextureUpdate as e}from"./interfaces.js";import{progressiveLoadingModulo as t}from"./TerrainConst.js";import{getLayerWithExtentRange as s}from"./terrainUtils.js";import{fallsWithinLayer as i}from"./tileUtils.js";class l{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(t,s){this._setUpsampleTile(t,s),this._tileRequested=null,t===this.tile?this.tile.updateRenderData(this._layerClass,e.FADING,s):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const e=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(e,l),r=s(a),{minLevel:n,maxLevel:h}=a.dataLevelRange,d=this._desiredMinLevelDelta,u=this._progressiveLevelModulo+d,o=this._scaleRangeEnabled?i:()=>!0;let _=this.tile;const p=_.level;let y;const f=this._tileLayerInfo.upsampleInfo,c=f?.tile?.level??-1,v=null!=f&&c-p>=d,q=r?.tilemapCache,I="vector-tile-3d"===a.type?a.schemaHelper:null;for(;_&&o(_,r,!1)&&_.level>=n;){const s=_.level,i=p-s,a=_.layerInfo[l][e];if(a.data&&i>=d){(!v||s>c)&&this._setUpsampleTile(_),a.dataInvalidated&&(y=_);break}const r=I?.getLevelRowColumn(_.lij)??_.lij;if("unavailable"!==q?.getAvailability(r[0],r[1],r[2])&&s<=h&&!a.data&&!a.dataMissing&&((!y||_.level===n||s%t==0||p-y.level<d)&&(y=_),i>=u))break;_=_.parent}if(null!=y&&p-y.level<d)if(f)y=null;else{const t=this._findAncestorWithData();if(null!=t){this._setUpsampleTile(t);y=t.layerInfo[l][e].dataInvalidated?t:null}}return y}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(t,s){this._tileLayerInfo.setUpsampleInfo(this.tile,t),this.tile.updateRenderData(this._layerClass,e.FADING,s)}get test(){}}class a extends l{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw r}get _progressiveLevelModulo(){throw r}dispose(){}}const r=new Error("Abstract method called on TileAgent"),n=new a;export{l as TileAgent,n as tileAgentDone};
5
+ import"../../../core/has.js";import{TextureUpdate as e}from"./interfaces.js";import{progressiveLoadingModulo as t}from"./TerrainConst.js";import{fallsWithinLayerView as s,getTileMapCache as i}from"./tileUtils.js";class l{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(t,s){this._setUpsampleTile(t,s),this._tileRequested=null,t===this.tile?this.tile.updateRenderData(this._layerClass,e.FADING,s):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const e=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(e,l),{minLevel:n,maxLevel:r}=a.dataLevelRange,h=this._desiredMinLevelDelta,d=this._progressiveLevelModulo+h,u=this._scaleRangeEnabled?s:()=>!0;let _=this.tile;const o=_.level;let p;const y=this._tileLayerInfo.upsampleInfo,f=y?.tile?.level??-1,c=null!=y&&f-o>=h,v=i(a),q="vector-tile-3d"===a.type?a.schemaHelper:null;for(;_&&u(_,a)&&_.level>=n;){const s=_.level,i=o-s,a=_.layerInfo[l][e];if(a.data&&i>=h){(!c||s>f)&&this._setUpsampleTile(_),a.dataInvalidated&&(p=_);break}const u=q?.getLevelRowColumn(_.lij)??_.lij;if("unavailable"!==v?.getAvailability(u[0],u[1],u[2])&&s<=r&&!a.data&&!a.dataMissing&&((!p||_.level===n||s%t==0||o-p.level<h)&&(p=_),i>=d))break;_=_.parent}if(null!=p&&o-p.level<h)if(y)p=null;else{const t=this._findAncestorWithData();if(null!=t){this._setUpsampleTile(t);p=t.layerInfo[l][e].dataInvalidated?t:null}}return p}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(t,s){this._tileLayerInfo.setUpsampleInfo(this.tile,t),this.tile.updateRenderData(this._layerClass,e.FADING,s)}get test(){}}class a extends l{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw n}get _progressiveLevelModulo(){throw n}dispose(){}}const n=new Error("Abstract method called on TileAgent"),r=new a;export{l as TileAgent,r as tileAgentDone};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as r,copy as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isBaseLayer as i,isGroupLayer as a}from"../../../layers/support/layerUtils.js";import{BlendLayersPassParameters as n}from"./BlendLayersTechnique.js";import{TextureUpdate as u}from"./interfaces.js";import{LayerClass as c}from"./LayerClass.js";import{NeighborIndex as l}from"./NeighborIndex.js";import{isImageWithType as p}from"./TerrainData.js";import{isBlendableLayerView as d,isVectorTileLayerView as h,isVectorTileRenderInfo as m,isImageryTileRenderInfo as f,isImageSourceRenderInfo as _,isTextureTileRenderInfo as T,isVectorTilePerLayerInfo as y}from"./terrainUtils.js";import{ActivationTime as b}from"./TextureFader.js";import{TextureReference as g}from"./TextureReference.js";import{TileCompositor as x}from"./TileCompositor.js";import{TileRenderInfo as I}from"./TileRenderInfo.js";import w from"./TileTexture.js";import{TileUpdate as A}from"./TileUpdate.js";import{blendModeFromString as P}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as k}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as O}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as E,TextureWrapMode as D,PixelFormat as M}from"../../webgl/enums.js";import{Texture as L}from"../../webgl/Texture.js";import{TextureDescriptor as R}from"../../webgl/TextureDescriptor.js";class j{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}class C{constructor(e,t,r,s){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._passParameters=new n,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new x(this._rctx,this._techniques),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._compositor=e(this._compositor),this._backgroundTexture=t(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,n=0,l=this.tileSize,p=!1,m=!1;const f=r.view.state.contentPixelRatio;let _=!1;F.clear(),q.length=0;const T=e.layerInfo[c.MAP];let y=0,b=null;for(;y<T.length;y++){const t=r.layerViewByIndex(y,c.MAP),u=t.layer.opacity,g=t.fullOpacity;if(m=m||i(t.layer),d(t)){let e="normal"!==t.layer.blendMode;if(a(t.layer.parent)){const r=t.layer.parent.uid;null!=r&&""!==r&&(e=U(t.layer.parent)||e)}e&&(_=e,p=!1)}if(0===u&&!_){T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING);continue}++n;const x=h(t),I=N(e,y,x);if(I){if(T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING),a(t.layer.parent)){const e=t.layer.parent.uid;null!=e&&""!==e&&B(t.layer.parent,y)}x?l=Math.max(l,this.tileSize*f):1===s&&1===g&&(t.isOpaque||this._dataToTexture(I)&&I.sourceLayerInfo.data.descriptor.isOpaque)&&(p=!0),++o,null===b&&(b=y)}}const g=l/this.tileSize,x=this._ensureBackgroundTexture(this.tileSize);0!==o&&null!==b?1===o&&!_&&this._useLayerTexture(e,b)||this._composeLayers(e,t,y-1,m,l,g,!p||_,F,_):G(e,n,x,t!==u.FADING)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._compositor.bind(e),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(this._backgroundTexture),this._compositor.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,c.MAP),s=i(r.layer),o=s?e.surface.baseOpacity:1,a=s?1:e.surface.baseOpacity,n=r.fullOpacity,l=N(e,t,!1);return!!this._dataToTexture(l)&&(e.renderData.setTextureReference(new g(l.sourceLayerInfo.data,u.FADING,l,o,a,n)),!0)}_composeLayers(e,t,r,s,a,n,u,l,p){this._compositor.ensureBuffer(a);const _=e.surface.baseOpacity;let T=!1,y=E.LINEAR_MIPMAP_LINEAR,b=!1,x=0;for(let g=r;g>=0;g--){const t=e.surface.layerViewByIndex(g,c.MAP),r=h(t),I=N(e,g,r),w=t.layer.opacity;if(!I||0===w&&!p)continue;const A=!i(t.layer)&&!T;A&&(T=!0);let O=!1;l.forEach((e=>{e.start===g&&(e.output=s?k.Composite:u&&A?this.backgroundIsGrid?k.GridComposite:k.ColorComposite:k.Composite,e.baseOpacity=A?_:1,q.push(e),this._compositor.openGroup(a),O=!0)}));const D=0===x,M=O?k.GroupBackgroundComposite:u&&D?this.backgroundIsGrid?k.GridComposite:k.ColorComposite:k.Composite,L=P[d(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=A&&!O&&_<1?_:1,this._passParameters.opacity=w,m(I)?b=this._compositor.drawVectorData(this._passParameters,M,a,L,I,n,this.tileSize,b):f(I)?(this._compositor.drawRasterData(this._passParameters,M,a,L,I),S(I)&&(y=E.NEAREST)):this._dataToTexture(I)&&(this._passParameters.texture=I.sourceLayerInfo.data.texture,this._passParameters.offset=I.offset,this._passParameters.scale=I.scale,this._compositor.drawImageData(this._passParameters,M,a,L));q.length>0&&q[q.length-1].end===g;){const e=q.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,a,P[e.blendMode])}x++}const I=e.renderData,w=p||T&&_<1,A=I.ensureTexture(a,w,(()=>this._buildTexture(a,w,y)));this._compositor.copyFBOToTexture(A),this._compositor.unbind(),I.setTextureReference(new g(A,t,H,T?1:_,0,1))}_dataToTexture(e){if(_(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data,!0),e.tile.setMemoryDirty()}return T(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=E.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new R;s.wrapMode=D.CLAMP_TO_EDGE,s.samplingMode=r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=M.RGB);const o=this._rctx;let i;if("number"==typeof e)s.width=s.height=e,i=this._buildTileTexture(s,e);else if(p(e))s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=M.RGB),i=this._buildTileTexture(s,e.element.width,e.element);else try{s.width=e.width,s.height=e.height,i=this._buildTileTexture(s,e.width,e)}catch(n){i=new w(O(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const a=o.bindTexture(i.texture,L.TEXTURE_UNIT_FOR_UPDATES);return i.generateMipmap(),o.bindTexture(a,L.TEXTURE_UNIT_FOR_UPDATES),i}_buildTileTexture(e,t,r){const s=`${t} ${e.pixelFormat}`,o=this._cache.pop(s);return o?(o.retain(),o.texture.setData(r),o):new w(new L(this._rctx,e,r),this._cache)}get test(){}}function N(e,t,o){v.layerIndex=t,v.vtlNeighborInfos.clear();const i=e.layerInfo[c.MAP][t];if(r(v.offset,0,0),v.tile=e,v.scale=1,v.sourceLod=e.lij,v.sourceLayerInfo=i,v.isVTLBackground=o,i.data)return o&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[c.MAP][t];if(!y(o)||i.data===o.data)return;const a=v.vtlNeighborInfos.pushNew();a.offset=z[s],a.sourceLod=r.lij,a.sourceLayerInfo=o})),v;const a=i.upsampleInfo,n=a?.tile?.layerInfo[c.MAP][t];return n?(v.tile=a.tile,s(v.offset,a.offset),v.scale=a.scale,v.sourceLod=a.tile.lij,v.sourceLayerInfo=n,v):o?v:null}function S(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function U(e){let t="normal"!==e.blendMode;return a(e.parent)&&(t=U(e.parent)||t),t}function B(e,t){a(e.parent)&&B(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=F.get(r);s?s.start=t:F.set(r,new j(t,t,e.blendMode,e.opacity,k.Composite,1))}}function G(e,t,r,s){const o=e.renderData,i=!s&&null!=o.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?b.Delayed:b.Immediate;o.setTextureReference(new g(r,u.FADING,H,e.surface.baseOpacity,0,1),i)}const F=new Map,q=new Array,v=new I,H={offset:[0,0],scale:1},z=new Array;z[l.NORTH]=[0,-1],z[l.NORTH_EAST]=[-1,-1],z[l.EAST]=[-1,0],z[l.SOUTH_EAST]=[-1,1],z[l.SOUTH]=[0,1],z[l.SOUTH_WEST]=[1,1],z[l.WEST]=[1,0],z[l.NORTH_WEST]=[1,-1];export{j as GroupInfo,C as TileRenderer};
5
+ import"../../../core/has.js";import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{set as r,copy as s}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{ZEROS as o}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isBaseLayer as i,isGroupLayer as a}from"../../../layers/support/layerUtils.js";import{BlendLayersPassParameters as n}from"./BlendLayersTechnique.js";import{TextureUpdate as u}from"./interfaces.js";import{LayerClass as c}from"./LayerClass.js";import{NeighborIndex as l}from"./NeighborIndex.js";import{isImageWithType as p}from"./TerrainData.js";import{isBlendableLayerView as d,isVectorTileLayerView as h,isVectorTileRenderInfo as m,isImageryTileRenderInfo as f,isImageSourceRenderInfo as _,isTextureTileRenderInfo as T,isVectorTilePerLayerInfo as y}from"./terrainUtils.js";import{ActivationTime as b}from"./TextureFader.js";import{TextureReference as g}from"./TextureReference.js";import{TileCompositor as x}from"./TileCompositor.js";import{TileRenderInfo as I}from"./TileRenderInfo.js";import w from"./TileTexture.js";import{TileUpdate as A}from"./TileUpdate.js";import{fallsWithinLayerView as P}from"./tileUtils.js";import{blendModeFromString as k}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BlendLayersOutput as O}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{createEmptyTexture as E}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as D,TextureWrapMode as M,PixelFormat as j}from"../../webgl/enums.js";import{Texture as L}from"../../webgl/Texture.js";import{TextureDescriptor as R}from"../../webgl/TextureDescriptor.js";class C{constructor(e,t,r,s,o,i){this.start=e,this.end=t,this.blendMode=r,this.opacity=s,this.output=o,this.baseOpacity=i}}class N{constructor(e,t,r,s){this._rctx=e,this.tileSize=t,this._techniques=r,this._cache=s,this._passParameters=new n,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._compositor=new x(this._rctx,this._techniques),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._compositor=e(this._compositor),this._backgroundTexture=t(this._backgroundTexture)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateHeading(e){this._compositor?.updateHeading(e)}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,n=0,l=this.tileSize,p=!1,m=!1;const f=r.view.state.contentPixelRatio;let _=!1;q.clear(),v.length=0;const T=e.layerInfo[c.MAP];let y=0,b=null;for(;y<T.length;y++){const t=r.layerViewByIndex(y,c.MAP),u=t.layer,g=!P(e,t),x=u.opacity,I=t.fullOpacity;if(m=m||i(u),d(t)){let e="normal"!==t.layer.blendMode;if(a(u.parent)){const t=u.parent.uid;null!=t&&""!==t&&(e=B(u.parent)||e)}e&&(_=e,p=!1)}if((g||0===x)&&!_){T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING);continue}++n;const w=h(t),k=U(e,y,w);if(k){if(T[y].pendingUpdates&=~(A.TEXTURE_NOFADING&A.TEXTURE_FADING),a(u.parent)){const e=u.parent.uid;null!=e&&""!==e&&G(u.parent,y)}w?l=Math.max(l,this.tileSize*f):1===s&&1===I&&(t.isOpaque||this._dataToTexture(k)&&k.sourceLayerInfo.data.descriptor.isOpaque)&&(p=!0),++o,null===b&&(b=y)}}const g=l/this.tileSize,x=this._ensureBackgroundTexture(this.tileSize);0!==o&&null!==b?1===o&&!_&&this._useLayerTexture(e,b)||this._composeLayers(e,t,y-1,m,l,g,!p||_,q,_):F(e,n,x,t!==u.FADING)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._compositor.bind(e),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._compositor.drawBackground(this._passParameters,null!=this.backgroundColor),this._compositor.copyFBOToTexture(this._backgroundTexture),this._compositor.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useLayerTexture(e,t){const r=e.surface.layerViewByIndex(t,c.MAP),s=i(r.layer),o=s?e.surface.baseOpacity:1,a=s?1:e.surface.baseOpacity,n=r.fullOpacity,l=U(e,t,!1);return!!this._dataToTexture(l)&&(e.renderData.setTextureReference(new g(l.sourceLayerInfo.data,u.FADING,l,o,a,n)),!0)}_composeLayers(e,t,r,s,a,n,u,l,p){this._compositor.ensureBuffer(a);const _=e.surface.baseOpacity;let T=!1,y=D.LINEAR_MIPMAP_LINEAR,b=!1,x=0;for(let g=r;g>=0;g--){const t=e.surface.layerViewByIndex(g,c.MAP),r=t.layer,I=h(t),w=U(e,g,I),A=r.opacity,E=!P(e,t);if(!w||(0===A||E)&&!p)continue;const M=!i(r)&&!T;M&&(T=!0);let j=!1;l.forEach((e=>{e.start===g&&(e.output=s?O.Composite:u&&M?this.backgroundIsGrid?O.GridComposite:O.ColorComposite:O.Composite,e.baseOpacity=M?_:1,v.push(e),this._compositor.openGroup(a),j=!0)}));const L=0===x,R=j?O.GroupBackgroundComposite:u&&L?this.backgroundIsGrid?O.GridComposite:O.ColorComposite:O.Composite,C=k[d(t)?t.layer.blendMode:"normal"];for(this._passParameters.baseOpacity=M&&!j&&_<1?_:1,this._passParameters.opacity=A,m(w)?b=this._compositor.drawVectorData(this._passParameters,R,a,C,w,n,this.tileSize,b):f(w)?(this._compositor.drawRasterData(this._passParameters,R,a,C,w),S(w)&&(y=D.NEAREST)):this._dataToTexture(w)&&(this._passParameters.texture=w.sourceLayerInfo.data.texture,this._passParameters.offset=w.offset,this._passParameters.scale=w.scale,this._compositor.drawImageData(this._passParameters,R,a,C));v.length>0&&v[v.length-1].end===g;){const e=v.pop();this._passParameters.baseOpacity=e.baseOpacity,this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1,this._compositor.drawGroup(this._passParameters,e.output,a,k[e.blendMode])}x++}const I=e.renderData,w=p||T&&_<1,A=I.ensureTexture(a,w,(()=>this._buildTexture(a,w,y)));this._compositor.copyFBOToTexture(A),this._compositor.unbind(),I.setTextureReference(new g(A,t,z,T?1:_,0,1))}_dataToTexture(e){if(_(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data,!0),e.tile.setMemoryDirty()}return T(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=D.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new R;s.wrapMode=M.CLAMP_TO_EDGE,s.samplingMode=r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=j.RGB);const o=this._rctx;let i;if("number"==typeof e)s.width=s.height=e,i=this._buildTileTexture(s,e);else if(p(e))s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=j.RGB),i=this._buildTileTexture(s,e.element.width,e.element);else try{s.width=e.width,s.height=e.height,i=this._buildTileTexture(s,e.width,e)}catch(n){i=new w(E(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const a=o.bindTexture(i.texture,L.TEXTURE_UNIT_FOR_UPDATES);return i.generateMipmap(),o.bindTexture(a,L.TEXTURE_UNIT_FOR_UPDATES),i}_buildTileTexture(e,t,r){const s=`${t} ${e.pixelFormat}`,o=this._cache.pop(s);return o?(o.retain(),o.texture.setData(r),o):new w(new L(this._rctx,e,r),this._cache)}get test(){}}function U(e,t,o){H.layerIndex=t,H.vtlNeighborInfos.clear();const i=e.layerInfo[c.MAP][t];if(r(H.offset,0,0),H.tile=e,H.scale=1,H.sourceLod=e.lij,H.sourceLayerInfo=i,H.isVTLBackground=o,i.data)return o&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const o=r.layerInfo[c.MAP][t];if(!y(o)||i.data===o.data)return;const a=H.vtlNeighborInfos.pushNew();a.offset=V[s],a.sourceLod=r.lij,a.sourceLayerInfo=o})),H;const a=i.upsampleInfo,n=a?.tile?.layerInfo[c.MAP][t];return n?(H.tile=a.tile,s(H.offset,a.offset),H.scale=a.scale,H.sourceLod=a.tile.lij,H.sourceLayerInfo=n,H):o?H:null}function S(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}function B(e){let t="normal"!==e.blendMode;return a(e.parent)&&(t=B(e.parent)||t),t}function G(e,t){a(e.parent)&&G(e.parent,t);const r=e.uid;if(null!=r&&""!==r){const s=q.get(r);s?s.start=t:q.set(r,new C(t,t,e.blendMode,e.opacity,O.Composite,1))}}function F(e,t,r,s){const o=e.renderData,i=!s&&null!=o.textureReference&&(e.surface.view.layerViewManager.updating||t>0)?b.Delayed:b.Immediate;o.setTextureReference(new g(r,u.FADING,z,e.surface.baseOpacity,0,1),i)}const q=new Map,v=new Array,H=new I,z={offset:[0,0],scale:1},V=new Array;V[l.NORTH]=[0,-1],V[l.NORTH_EAST]=[-1,-1],V[l.EAST]=[-1,0],V[l.SOUTH_EAST]=[-1,1],V[l.SOUTH]=[0,1],V[l.SOUTH_WEST]=[1,1],V[l.WEST]=[1,0],V[l.NORTH_WEST]=[1,-1];export{C as GroupInfo,N as TileRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import n from"../../../core/Collection.js";import{isCGCS2000 as t,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{ViewingMode as o}from"../../ViewingMode.js";import{NeighborIndex as i}from"./NeighborIndex.js";import{isRasterTile as l,isTileTexture as u,isImageWithType as f,isVectorTile as c}from"./TerrainData.js";import{t as a}from"../../../chunks/terrainUtilsPlanar.js";import{t as T}from"../../../chunks/terrainUtilsSpherical.js";const s={[o.Global]:T,[o.Local]:a};function S(n,t){n||console.warn("Terrain: "+t)}let E=!1,m=!1;function p(n){m=n,E=E||n}function H(n){E=n}function O(n,t){if(E&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function y(n){return I(n)?{fullExtent:n.fullExtent,minScale:n.layer.minScale,maxScale:n.layer.maxScale,tilemapCache:null}:n.layer}function _(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function I(n){return"imagery-tile-3d"===n?.type}function R(n){return"tile-3d"===n?.type}function d(n){return"vector-tile-3d"===n?.type}function N(n){return"wmts-3d"===n?.type}function U(n){return"elevation-3d"===n?.type}function W(n){return"elevation"===n?.type}function x(n){return"group"===n?.type}function A(n){return n&&(R(n)||N(n)||I(n)||d(n))}function h(n){return n&&(R(n)||I(n)||d(n)||N(n))}function L(n){return h(n)||U(n)}function g(n){return l(n?.sourceLayerInfo?.data)}function w(n){return v(n?.sourceLayerInfo)||!!n?.isVTLBackground}function C(n){return u(n?.sourceLayerInfo?.data)}function j(n){const t=n?.sourceLayerInfo?.data;return f(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function v(n){return c(n?.data)}function b(n){return null!=n&&"release"in n&&n.release(),null}function M(n){return n.fetchTile&&!1!==n.hasOverriddenFetchTile}function V(n,t,e,r,o){return s[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function k(n,t,e){let r=null,i=null;if("wmts"===n?.type){const o=F(n,t,e);r=o.tileInfo,i=o.fullExtent}else{i=_(n)?n.getCompatibleFullExtent(t):n.fullExtent;const l=e===o.Local;if(_(n))r=n.getCompatibleTileInfo(t,i,l);else if("vector-tile"===n?.type){r=l&&!D(t)||G.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const l="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=i&&null==V(r,i,t,e,l)?{tileInfo:r,fullExtent:i}:null}function F(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find((n=>null==V(n.tileInfo,n.fullExtent,e,o)));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function D(n){return n.isWGS84||n.isWebMercator||t(n)||!e(n)}const G={force512VTL:!1};function B(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function P(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function q(n,t,e=en){return Math.abs(n-t)<e}function z(n){return n===i.NORTH_EAST?i.SOUTH_WEST:n===i.NORTH_WEST?i.SOUTH_EAST:n===i.SOUTH_WEST?i.NORTH_EAST:i.NORTH_WEST}function J(n){return n===i.NORTH?i.SOUTH:n===i.EAST?i.WEST:n===i.SOUTH?i.NORTH:i.EAST}function K(n){return n===i.NORTH_WEST||n===i.SOUTH_WEST}function Q(n){return n===i.NORTH_WEST||n===i.NORTH_EAST}function X(n){return n===i.NORTH_WEST||n===i.WEST||n===i.SOUTH_WEST}function Y(n){return n===i.NORTH_EAST||n===i.EAST||n===i.SOUTH_EAST}function Z(n){return n===i.SOUTH_EAST||n===i.SOUTH||n===i.SOUTH_WEST}function $(n){return n===i.NORTH_EAST||n===i.NORTH||n===i.NORTH_WEST}const nn=[i.NORTH,i.EAST,i.SOUTH,i.WEST],tn=[i.NORTH_EAST,i.SOUTH_EAST,i.SOUTH_WEST,i.NORTH_WEST],en=1e-5;export{q as almostEquals,V as checkIfTileInfoSupportedForView,H as enableInternalTerrainChecks,E as enableTerrainInternalChecks,p as enableTerrainWaterproofChecks,m as enableWaterproofTests,en as eps,y as getLayerWithExtentRange,F as getTileInfoAndExtentFromWMTSLayer,k as getTiledLayerInfo,O as internalAssert,A as isBlendableLayerView,Y as isEast,W as isElevationLayer,U as isElevationLayerView,x as isGroupLayerView,j as isImageSourceRenderInfo,I as isImageryTileLayerView,g as isImageryTileRenderInfo,h as isMapTileLayerView,$ as isNorth,Q as isNorthCorner,_ as isProjectableRasterLayer,Z as isSouth,L as isSurfaceLayerView,C as isTextureTileRenderInfo,R as isTileLayerView,d as isVectorTileLayerView,v as isVectorTilePerLayerInfo,w as isVectorTileRenderInfo,N as isWMTSLayerView,X as isWest,K as isWestCorner,B as lij2s,tn as neighborCornerIndices,nn as neighborEdgeIndices,z as oppositeCorner,J as oppositeEdge,b as releaseTerrainData,G as test,M as useFetchTileForLayer,P as v32s,D as vtlAssumes256PixelSizeAsDefault,S as weakAssert};
5
+ import n from"../../../core/Collection.js";import{isCGCS2000 as t,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{ViewingMode as o}from"../../ViewingMode.js";import{NeighborIndex as i}from"./NeighborIndex.js";import{isRasterTile as u,isTileTexture as l,isImageWithType as f,isVectorTile as c}from"./TerrainData.js";import{t as T}from"../../../chunks/terrainUtilsPlanar.js";import{t as a}from"../../../chunks/terrainUtilsSpherical.js";const s={[o.Global]:a,[o.Local]:T};function S(n,t){n||console.warn("Terrain: "+t)}let E=!1,p=!1;function H(n){p=n,E=E||n}function O(n){E=n}function m(n,t){if(E&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function _(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function I(n){return"imagery-tile-3d"===n?.type}function y(n){return"tile-3d"===n?.type}function R(n){return"vector-tile-3d"===n?.type}function d(n){return"wmts-3d"===n?.type}function N(n){return"elevation-3d"===n?.type}function U(n){return"elevation"===n?.type}function W(n){return"group"===n?.type}function A(n){return n&&(y(n)||d(n)||I(n)||R(n))}function x(n){return n&&(y(n)||I(n)||R(n)||d(n))}function L(n){return x(n)||N(n)}function g(n){return u(n?.sourceLayerInfo?.data)}function h(n){return v(n?.sourceLayerInfo)||!!n?.isVTLBackground}function w(n){return l(n?.sourceLayerInfo?.data)}function j(n){const t=n?.sourceLayerInfo?.data;return f(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function v(n){return c(n?.data)}function C(n){return null!=n&&"release"in n&&n.release(),null}function b(n){return n.fetchTile&&!1!==n.hasOverriddenFetchTile}function M(n,t,e,r,o){return s[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function V(n,t,e){let r=null,i=null;if("wmts"===n?.type){const o=k(n,t,e);r=o.tileInfo,i=o.fullExtent}else{i=_(n)?n.getCompatibleFullExtent(t):n.fullExtent;const u=e===o.Local;if(_(n))r=n.getCompatibleTileInfo(t,i,u);else if("vector-tile"===n?.type){r=u&&!F(t)||D.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const u="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=i&&null==M(r,i,t,e,u)?{tileInfo:r,fullExtent:i}:null}function k(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find((n=>null==M(n.tileInfo,n.fullExtent,e,o)));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function F(n){return n.isWGS84||n.isWebMercator||t(n)||!e(n)}const D={force512VTL:!1};function G(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function B(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function P(n,t,e=tn){return Math.abs(n-t)<e}function q(n){return n===i.NORTH_EAST?i.SOUTH_WEST:n===i.NORTH_WEST?i.SOUTH_EAST:n===i.SOUTH_WEST?i.NORTH_EAST:i.NORTH_WEST}function z(n){return n===i.NORTH?i.SOUTH:n===i.EAST?i.WEST:n===i.SOUTH?i.NORTH:i.EAST}function J(n){return n===i.NORTH_WEST||n===i.SOUTH_WEST}function K(n){return n===i.NORTH_WEST||n===i.NORTH_EAST}function Q(n){return n===i.NORTH_WEST||n===i.WEST||n===i.SOUTH_WEST}function X(n){return n===i.NORTH_EAST||n===i.EAST||n===i.SOUTH_EAST}function Y(n){return n===i.SOUTH_EAST||n===i.SOUTH||n===i.SOUTH_WEST}function Z(n){return n===i.NORTH_EAST||n===i.NORTH||n===i.NORTH_WEST}const $=[i.NORTH,i.EAST,i.SOUTH,i.WEST],nn=[i.NORTH_EAST,i.SOUTH_EAST,i.SOUTH_WEST,i.NORTH_WEST],tn=1e-5;export{P as almostEquals,M as checkIfTileInfoSupportedForView,O as enableInternalTerrainChecks,E as enableTerrainInternalChecks,H as enableTerrainWaterproofChecks,p as enableWaterproofTests,tn as eps,k as getTileInfoAndExtentFromWMTSLayer,V as getTiledLayerInfo,m as internalAssert,A as isBlendableLayerView,X as isEast,U as isElevationLayer,N as isElevationLayerView,W as isGroupLayerView,j as isImageSourceRenderInfo,I as isImageryTileLayerView,g as isImageryTileRenderInfo,x as isMapTileLayerView,Z as isNorth,K as isNorthCorner,_ as isProjectableRasterLayer,Y as isSouth,L as isSurfaceLayerView,w as isTextureTileRenderInfo,y as isTileLayerView,R as isVectorTileLayerView,v as isVectorTilePerLayerInfo,h as isVectorTileRenderInfo,d as isWMTSLayerView,Q as isWest,J as isWestCorner,G as lij2s,nn as neighborCornerIndices,$ as neighborEdgeIndices,q as oppositeCorner,z as oppositeEdge,C as releaseTerrainData,D as test,b as useFetchTileForLayer,B as v32s,F as vtlAssumes256PixelSizeAsDefault,S as weakAssert};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../core/PooledArray.js";import{RenderOrder as e}from"./RenderOrder.js";class n{constructor(){this._queue=new t,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=void 0}reset(t=null){this._queue.clear(),null!=t&&this._queue.pushArray(t),this._last=void 0}skipSubtree(){this._last=void 0}next(){const t=this._last?.children;return t?.[0]&&this._queue.pushArray(t),this._last=this._queue.pop(),this._last}}class r{constructor(){this._q=new t}get done(){return 0===this._q.length}reset(t){if(this._q.clear(),null!=t){this._q.pushArray(t);for(let t=0;t<this._q.length;++t){const e=this._q.data[t];e.isLeaf||this._q.pushArray(e.children)}}}next(){return this._q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)i(t[n],e);else i(t,e)}function i(t,e){if(e(t),!t.isLeaf)for(const n of t.children)i(n,e)}function o(t,e,n){if(null==e?.fullExtent)return!1;const r=e.fullExtent,s=t.extent;if(n){if(s[0]<r.xmin||s[1]<r.ymin||s[2]>r.xmax||s[3]>r.ymax)return!1}else if(r.xmin>s[2]||r.ymin>s[3]||r.xmax<s[0]||r.ymax<s[1])return!1;const i=t.surface.tilingScheme.levels[t.level].scale,o=e.minScale;if(o>0&&i>1.00000001*o)return!1;const u=e.maxScale;return!(u>0&&i<.99999999*u)}function u(t,e){const n=t.lij,r=e.lij;return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]}function l(t,n,r=null){null==r||0===r.length?t===e.BACK_TO_FRONT?n.sort(c):n.sort(f):n.sort(((e,n)=>a(e,n,t,r)))}function c(t,e){const n=e.screenDepth-t.screenDepth;if(0!==n)return n;const r=t.lij,s=e.lij;return r[0]-s[0]||r[1]-s[1]||r[2]-s[2]}function f(t,e){const n=t.screenDepth-e.screenDepth;if(0!==n)return n;const r=t.lij,s=e.lij;return r[0]-s[0]||r[1]-s[1]||r[2]-s[2]}function h(t,e,n){const r=t.screenDepth,s=e.screenDepth;return r<s?-n:r>s?n:u(t,e)}function a(t,e,n,r){return _(t,r)===_(e,r)?h(t,e,n):t?n:-n}function _(t,e){for(const n of e)if(t.intersectsExtent(n))return!0;return!1}function p(t,e){const n=t.distanceToPOI-e.distanceToPOI;if(0!==n)return n;const r=t.lij,s=e.lij;return r[0]-s[0]||r[1]-s[1]||r[2]-s[2]}function d(t,e){const n=t.length;for(let r=0;r<n;++r){t.at(r).updateDistanceToPOI(e)}t.sort(p)}function m(t,e,n){let r=1,s=0,i=0;for(;t!==e;)if(r*=.5,s*=.5,i*=.5,1&t.lij[2]&&(s+=.5),1&t.lij[1]||(i+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,s,i,r)}function q(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function x(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,s=n?e:t,i=1<<s[0]-r[0];return Math.floor(s[1]/i)===r[1]&&Math.floor(s[2]/i)===r[2]}export{r as IteratorPostorder,n as IteratorPreorder,h as compareTiles,u as compareTilesByLij,a as compareTilesWithStencil,m as computeUpsampleInfo,o as fallsWithinLayer,q as hasLoadableSiblings,l as sortTiles,d as sortTilesByPOI,x as tilesAreRelated,s as traverseTilesPreorder};
5
+ import t from"../../../core/PooledArray.js";import{RenderOrder as e}from"./RenderOrder.js";import{isImageryTileLayerView as n}from"./terrainUtils.js";class r{constructor(){this._queue=new t,this.remove=()=>{}}get done(){return 0===this._queue.length&&(!this._last||this._last.isLeaf)}resetOne(t){this._queue.clear(),this._queue.push(t),this._last=void 0}reset(t=null){this._queue.clear(),null!=t&&this._queue.pushArray(t),this._last=void 0}skipSubtree(){this._last=void 0}next(){const t=this._last?.children;return t?.[0]&&this._queue.pushArray(t),this._last=this._queue.pop(),this._last}}class i{constructor(){this._q=new t}get done(){return 0===this._q.length}reset(t){if(this._q.clear(),null!=t){this._q.pushArray(t);for(let t=0;t<this._q.length;++t){const e=this._q.data[t];e.isLeaf||this._q.pushArray(e.children)}}}next(){return this._q.pop()}}function s(t,e){if(Array.isArray(t))for(let n=0;n<t.length;n++)l(t[n],e);else l(t,e)}function l(t,e){if(e(t),!t.isLeaf)for(const n of t.children)l(n,e)}function o(t,e){if(null==e)return!1;const n=u(e);if(null==n?.fullExtent)return!1;const r=n.fullExtent,i=t.extent;if(r.xmin>i[2]||r.ymin>i[3]||r.xmax<i[0]||r.ymax<i[1])return!1;const s=t.surface.tilingScheme.levels[t.level].scale,l=n.minScale;if(l>0&&s>1.00000001*l)return!1;const o=n.maxScale;return!(o>0&&s<.99999999*o)}function u(t){return n(t)?{fullExtent:t.fullExtent,minScale:t.layer.minScale,maxScale:t.layer.maxScale}:t.layer}function c(t){return n(t)||!("tilemapCache"in t.layer)?null:t.layer.tilemapCache}function a(t,e){const n=t.lij,r=e.lij;return n[0]-r[0]||n[1]-r[1]||n[2]-r[2]}function f(t,n,r=null){null==r||0===r.length?t===e.BACK_TO_FRONT?n.sort(h):n.sort(p):n.sort(((e,n)=>m(e,n,t,r)))}function h(t,e){const n=e.screenDepth-t.screenDepth;if(0!==n)return n;const r=t.lij,i=e.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function p(t,e){const n=t.screenDepth-e.screenDepth;if(0!==n)return n;const r=t.lij,i=e.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function _(t,e,n){const r=t.screenDepth,i=e.screenDepth;return r<i?-n:r>i?n:a(t,e)}function m(t,e,n,r){return d(t,r)===d(e,r)?_(t,e,n):t?n:-n}function d(t,e){for(const n of e)if(t.intersectsExtent(n))return!0;return!1}function q(t,e){const n=t.distanceToPOI-e.distanceToPOI;if(0!==n)return n;const r=t.lij,i=e.lij;return r[0]-i[0]||r[1]-i[1]||r[2]-i[2]}function x(t,e){const n=t.length;for(let r=0;r<n;++r){t.at(r).updateDistanceToPOI(e)}t.sort(q)}function y(t,e,n){let r=1,i=0,s=0;for(;t!==e;)if(r*=.5,i*=.5,s*=.5,1&t.lij[2]&&(i+=.5),1&t.lij[1]||(s+=.5),null==(t=t.parent))throw new Error("tile was not a descendant of upsampleTile");n.init(e,i,s,r)}function j(t){for(let e=0;e<t.length;e++){const n=t[e],r=n.parent;if(r)for(let t=0;t<4;t++){const e=r.children[t];if(e&&e!==n)return!0}}return!1}function g(t,e){if(!t||!e||t[0]===e[0])return!1;const n=t[0]<e[0],r=n?t:e,i=n?e:t,s=1<<i[0]-r[0];return Math.floor(i[1]/s)===r[1]&&Math.floor(i[2]/s)===r[2]}export{i as IteratorPostorder,r as IteratorPreorder,_ as compareTiles,a as compareTilesByLij,m as compareTilesWithStencil,y as computeUpsampleInfo,o as fallsWithinLayerView,c as getTileMapCache,j as hasLoadableSiblings,f as sortTiles,x as sortTilesByPOI,g as tilesAreRelated,s as traverseTilesPreorder};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as t}from"../../../../../core/mathUtils.js";import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{createUintArray as n}from"../../lib/triangleIntersectionUtils.js";class i{constructor(t,n){this.elementCount=t,this.model=n,this._elementIndexMap=null,this._bspNodes=[],this._generatedBVH=!1,this.localMode=n.localMode,this.planetCenterZ=n.planetCenterZ,this.geometryMinZ=n.geometryMinZ,this.planetCenter=e(0,0,this.planetCenterZ),this.maxBspNodeDepth=n.maxBspNodeDepth??8,this.minElementCountForBVH=n.minElementCountForBVH??15,this.minBspNodeElementCount=n.minBspNodeElementCount??5}get elementIndexMap(){return this._ensureBVH(),this._elementIndexMap}get _skipBVH(){return this.elementCount<this.minElementCountForBVH||this.geometryMinZ<.5*this.planetCenterZ}_ensureBVH(){this._generatedBVH||this._skipBVH||0===this._bspNodes.length&&this._generateBsp()}intersectRay(t,e,n){this.elementCount<1||(this._skipBVH?this._intersectRayWithoutBVH(n):this._intersectRayWithBVH(t,e,n))}_intersectRayWithoutBVH(t){this._intersectRange(0,this.elementCount)}_intersectRange(t,e){this.model.intersectRange(t,e)}_intersectRayWithBVH(t,e,n){this._ensureBVH(),n?this._intersectGeometryWithBVHVerticalRay(t):this._intersectGeometryWithBVHGeneralRay(t,e)}_intersectGeometryWithBVHVerticalRay(t){let e=t[0],n=t[1];if(!this.localMode){const{geometryMinZ:i,planetCenterZ:s}=this,h=(i-s)/(t[2]-s);e=t[0]*h,n=t[1]*h}const{_bspNodes:i}=this;let s=0;for(;s>=0;){const t=i[s],{d:h,dim:o,minIndexIndex:a,minMidIndexIndex:r,maxMidIndexIndex:c,maxIndexIndex:d,aabb2D:l}=t;if(e<l[0]||e>l[2]||n<l[1]||n>l[3])break;if(-1===o||-1===t.child0&&-1===t.child1){this._intersectRange(a,d);break}{this._intersectRange(r,c);const i=(0===o?e:n)-h;if(i<0){if(-1===t.child0){this._intersectRange(a,r);break}s=t.child0}else{if(!(i>0))break;if(-1===t.child1){this._intersectRange(c,d);break}s=t.child1}}}}_intersectGeometryWithBVHGeneralRay(e,n){let i=e[0],s=e[1],h=n[0],o=n[1];const{geometryMinZ:a}=this;if(!this.localMode){let t=0,r=1;const c=Math.min(.5*this.planetCenterZ,a),d=e[2],l=n[2];if(d<c&&l<c)return;if(d<c&&(t=(c-d)/(l-d)),l<c&&(r=(c-d)/(l-d)),t>r)return;const m=(1-t)*e[0]+t*n[0],x=(1-t)*e[1]+t*n[1],u=(1-t)*e[2]+t*n[2],M=(1-r)*e[0]+r*n[0],p=(1-r)*e[1]+r*n[1],f=(1-r)*e[2]+r*n[2],{planetCenterZ:_}=this,g=a-_,I=g/(u-_);i=m*I,s=x*I;const B=g/(f-_);h=M*B,o=p*B}const r=h-i,c=o-s,d=this._bspNodes,l=[0,0,1];let m=0;for(;m<l.length;){const e=l[m];let n=l[m+1],h=l[m+2];if(m+=3,n>h)continue;const o=d[e],{minIndexIndex:a,maxIndexIndex:x}=o,{child0:u,child1:M,minMidIndexIndex:p,maxMidIndexIndex:f,aabb2D:_,d:g,dim:I}=o;{const t=i+n*r,e=i+h*r,s=Math.min(t,e),o=Math.max(t,e),a=_[0],c=_[2];if(o<a||c<s)continue;if(s<a){const t=(a-i)/r;r>0?n=Math.max(n,t):h=Math.min(h,t)}if(c<o){const t=(c-i)/r;r>0?h=Math.min(h,t):n=Math.max(n,t)}}{const t=s+n*c,e=s+h*c,i=Math.min(t,e),o=Math.max(t,e),a=_[1],r=_[3];if(o<a||r<i)continue;if(i<a){const t=(a-s)/c;c>0?n=Math.max(n,t):h=Math.min(h,t)}if(r<o){const t=(r-s)/c;c>0?h=Math.min(h,t):n=Math.max(n,t)}}if(-1===u&&-1===M)this._intersectRange(a,x);else{const e=0===I?i:s,o=0===I?r:c,d=e+n*o,m=e+h*o,_=Math.min(d,m),B=Math.max(d,m),V=t((g-e)/o,0,1);a<p&&_<=g&&(-1!==u?(l.push(u),l.push(o>=0?n:Math.max(n,V)),l.push(o>=0?Math.min(h,V):h)):this._intersectRange(a,p)),this._intersectRange(p,f),f<x&&g<=B&&(-1!==M?(l.push(M),l.push(o>=0?Math.max(n,V):n),l.push(o>=0?h:Math.min(h,V))):this._intersectRange(f,x))}}}_generateBsp(){const{elementCount:t}=this;if(t<1)return;const e=n(t,t);this._elementIndexMap=e;for(let n=0;n<t;++n)e[n]=n;const i=this.model.getAabbs2D();let a=0;const d=this._bspNodes;d.length=0;const{localMode:l}=this;let m=!1;if(!l){const{planetCenterZ:t,geometryMinZ:e}=this;m=t>=0||e<.5*t}const x=[],u=(t,e,n,i,s)=>{x.push(t),x.push(e),x.push(n),x.push(i<0?-1:(s?0:1)+2*i)},{maxBspNodeDepth:M,minBspNodeElementCount:p}=this,f=(t,n,a,x,f)=>{const _=d.length;if(_>0&&(m||a>=M||n-t<p))return;const g=[0,0,0,0];r(g,t,n,e,i);const{d:I,dim:B}=l?s(g):h(g),{rangeMidStart:V,rangeMidEnd:b}=o(t,n,B,I,e,i),C=a===M-1,H=!C&&V>=t+p,R=!C&&n>=b+p;if(H||R||0===_){const e=new c(t,V,b,n,B,I,g);if(H&&u(t,V,a+1,_,!0),R&&u(b,n,a+1,_,!1),d.push(e),-1!==x){const t=d[x];f?t.child0=_:t.child1=_}}};for(u(0,t,0,-1,!1);a<x.length;){const t=x[a],e=x[a+1],n=x[a+2],i=x[a+3];a+=4;const s=i>>1;f(t,e,n,s,i-(s<<1)==0)}this._generatedBVH=!0}}function s(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,o;return i-e>=s-n?(o=.5*(e+i),h=0):(o=.5*(n+s),h=1),{d:o,dim:h}}function h(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,o;return i-e>=s-n?(h=0,o=.5*(e+i)):(h=1,o=.5*(n+s)),{dim:h,d:o}}function o(t,e,n,i,s,h){let o=t;{let t=e;for(;o<t;){const e=s[o];a(e,n,i,h)<0?++o:(--t,s[o]=s[t],s[t]=e)}}const r=o;let c=o,d=e;for(;c<d;){const t=s[d-1];a(t,n,i,h)>0?--d:(s[d-1]=s[c],s[c]=t,++c)}return{rangeMidStart:r,rangeMidEnd:d}}function a(t,e,n,i){const s=4*t,h=i[s+0+e];return i[s+2+e]<n?-1:h>n?1:0}function r(t,e,n,i,s){let h=1/0,o=1/0,a=-1/0,r=-1/0;for(let c=e;c<n;++c){const t=4*i[c];h=Math.min(h,s[t+0]),o=Math.min(o,s[t+1]),a=Math.max(a,s[t+2]),r=Math.max(r,s[t+3])}t[0]=h,t[1]=o,t[2]=a,t[3]=r}class c{constructor(t,e,n,i,s,h,o){this.minIndexIndex=t,this.minMidIndexIndex=e,this.maxMidIndexIndex=n,this.maxIndexIndex=i,this.dim=s,this.d=h,this.aabb2D=o,this.child0=-1,this.child1=-1}}export{i as ElevationAgnosticBVH};
5
+ import{clamp as t}from"../../../../../core/mathUtils.js";import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{createUintArray as n}from"../../lib/triangleIntersectionUtils.js";class i{constructor(t,n){this.elementCount=t,this.model=n,this._elementIndexMap=null,this._bspNodes=[],this._generatedBVH=!1,this.localMode=n.localMode,this.planetCenterZ=n.planetCenterZ,this.geometryMinZ=n.geometryMinZ,this.planetCenter=e(0,0,this.planetCenterZ),this.maxBspNodeDepth=n.maxBspNodeDepth??8,this.minElementCountForBVH=n.minElementCountForBVH??15,this.minBspNodeElementCount=n.minBspNodeElementCount??5}get elementIndexMap(){return this._ensureBVH(),this._elementIndexMap}get _skipBVH(){return this.elementCount<this.minElementCountForBVH||this.geometryMinZ<.5*this.planetCenterZ}_ensureBVH(){this._generatedBVH||this._skipBVH||0===this._bspNodes.length&&this._generateBsp()}intersectRay(t,e,n){this.elementCount<1||(this._skipBVH?this._intersectRayWithoutBVH(n):this._intersectRayWithBVH(t,e,n))}_intersectRayWithoutBVH(t){this._intersectRange(0,this.elementCount)}_intersectRange(t,e){this.model.intersectRange(t,e)}_intersectRayWithBVH(t,e,n){this._ensureBVH(),n?this._intersectGeometryWithBVHVerticalRay(t):this._intersectGeometryWithBVHGeneralRay(t,e)}_intersectGeometryWithBVHVerticalRay(t){let e=t[0],n=t[1];if(!this.localMode){const{geometryMinZ:i,planetCenterZ:s}=this,h=(i-s)/(t[2]-s);e=t[0]*h,n=t[1]*h}const{_bspNodes:i}=this;let s=0;for(;s>=0;){const t=i[s],{d:h,dim:a,minIndexIndex:o,minMidIndexIndex:r,maxMidIndexIndex:c,maxIndexIndex:m,aabb2D:l}=t;if(e<l[0]||e>l[2]||n<l[1]||n>l[3])break;if(-1===a||-1===t.child0&&-1===t.child1){this._intersectRange(o,m);break}{this._intersectRange(r,c);const i=(0===a?e:n)-h;if(i<0){if(-1===t.child0){this._intersectRange(o,r);break}s=t.child0}else{if(!(i>0))break;if(-1===t.child1){this._intersectRange(c,m);break}s=t.child1}}}}_intersectGeometryWithBVHGeneralRay(e,n){let i=e[0],s=e[1],h=n[0],a=n[1];const{geometryMinZ:o}=this;if(!this.localMode){let t=0,r=1;const c=Math.min(.5*this.planetCenterZ,o),m=e[2],l=n[2];if(m<c&&l<c)return;if(m<c&&(t=(c-m)/(l-m)),l<c&&(r=(c-m)/(l-m)),t>r)return;const d=(1-t)*e[0]+t*n[0],M=(1-t)*e[1]+t*n[1],x=(1-t)*e[2]+t*n[2],u=(1-r)*e[0]+r*n[0],p=(1-r)*e[1]+r*n[1],f=(1-r)*e[2]+r*n[2],{planetCenterZ:_}=this,g=o-_,I=g/(x-_);i=d*I,s=M*I;const B=g/(f-_);h=u*B,a=p*B}const r=h-i,c=a-s,m=this._bspNodes;let l=1;{const{aabb2D:t}=m[0],e=(t,e,n,i)=>{if(Math.abs(e)<1e-5*Math.max(i-n,1))return!1;const s=e>0,h=s?i:n,a=t+l*e;return(s?a<h:a>h)&&(l=Math.max((h-t)/e,l),!0)},n=()=>e(i,r,t[0],t[2]),h=()=>e(s,c,t[1],t[3]);Math.abs(r)>=Math.abs(c)?n()||h():h()||n()}const d=[0,0,l];let M=0;for(;M<d.length;){const e=d[M];let n=d[M+1],h=d[M+2];if(M+=3,n>h)continue;const a=m[e],{minIndexIndex:o,maxIndexIndex:x}=a,{child0:u,child1:p,minMidIndexIndex:f,maxMidIndexIndex:_,aabb2D:g,d:I,dim:B}=a;{const t=i+n*r,e=i+h*r,s=Math.min(t,e),a=Math.max(t,e),o=g[0],c=g[2];if(a<o||c<s)continue;if(s<o){const t=(o-i)/r;r>0?n=Math.max(n,t):h=Math.min(h,t)}if(c<a){const t=(c-i)/r;r>0?h=Math.min(h,t):n=Math.max(n,t)}}{const t=s+n*c,e=s+h*c,i=Math.min(t,e),a=Math.max(t,e),o=g[1],r=g[3];if(a<o||r<i)continue;if(i<o){const t=(o-s)/c;c>0?n=Math.max(n,t):h=Math.min(h,t)}if(r<a){const t=(r-s)/c;c>0?h=Math.min(h,t):n=Math.max(n,t)}}if(-1===u&&-1===p)this._intersectRange(o,x);else{const e=0===B?i:s,a=0===B?r:c,m=e+n*a,M=e+h*a,g=Math.min(m,M),b=Math.max(m,M),V=t((I-e)/a,0,l);o<f&&g<=I&&(-1!==u?(d.push(u),d.push(a>=0?n:Math.max(n,V)),d.push(a>=0?Math.min(h,V):h)):this._intersectRange(o,f)),this._intersectRange(f,_),_<x&&I<=b&&(-1!==p?(d.push(p),d.push(a>=0?Math.max(n,V):n),d.push(a>=0?h:Math.min(h,V))):this._intersectRange(_,x))}}}_generateBsp(){const{elementCount:t}=this;if(t<1)return;const e=n(t,t);this._elementIndexMap=e;for(let n=0;n<t;++n)e[n]=n;const i=this.model.getAabbs2D();let o=0;const m=this._bspNodes;m.length=0;const{localMode:l}=this;let d=!1;if(!l){const{planetCenterZ:t,geometryMinZ:e}=this;d=t>=0||e<.5*t}const M=[],x=(t,e,n,i,s)=>{M.push(t),M.push(e),M.push(n),M.push(i<0?-1:(s?0:1)+2*i)},{maxBspNodeDepth:u,minBspNodeElementCount:p}=this,f=(t,n,o,M,f)=>{const _=m.length;if(_>0&&(d||o>=u||n-t<p))return;const g=[0,0,0,0];r(g,t,n,e,i);const{d:I,dim:B}=l?s(g):h(g),{rangeMidStart:b,rangeMidEnd:V}=a(t,n,B,I,e,i),C=o===u-1,H=!C&&b>=t+p,R=!C&&n>=V+p;if(H||R||0===_){const e=new c(t,b,V,n,B,I,g);if(H&&x(t,b,o+1,_,!0),R&&x(V,n,o+1,_,!1),m.push(e),-1!==M){const t=m[M];f?t.child0=_:t.child1=_}}};for(x(0,t,0,-1,!1);o<M.length;){const t=M[o],e=M[o+1],n=M[o+2],i=M[o+3];o+=4;const s=i>>1;f(t,e,n,s,i-(s<<1)==0)}this._generatedBVH=!0}}function s(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,a;return i-e>=s-n?(a=.5*(e+i),h=0):(a=.5*(n+s),h=1),{d:a,dim:h}}function h(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,a;return i-e>=s-n?(h=0,a=.5*(e+i)):(h=1,a=.5*(n+s)),{dim:h,d:a}}function a(t,e,n,i,s,h){let a=t;{let t=e;for(;a<t;){const e=s[a];o(e,n,i,h)<0?++a:(--t,s[a]=s[t],s[t]=e)}}const r=a;let c=a,m=e;for(;c<m;){const t=s[m-1];o(t,n,i,h)>0?--m:(s[m-1]=s[c],s[c]=t,++c)}return{rangeMidStart:r,rangeMidEnd:m}}function o(t,e,n,i){const s=4*t,h=i[s+0+e];return i[s+2+e]<n?-1:h>n?1:0}function r(t,e,n,i,s){let h=1/0,a=1/0,o=-1/0,r=-1/0;for(let c=e;c<n;++c){const t=4*i[c];h=Math.min(h,s[t+0]),a=Math.min(a,s[t+1]),o=Math.max(o,s[t+2]),r=Math.max(r,s[t+3])}t[0]=h,t[1]=a,t[2]=o,t[3]=r}class c{constructor(t,e,n,i,s,h,a){this.minIndexIndex=t,this.minMidIndexIndex=e,this.maxMidIndexIndex=n,this.maxIndexIndex=i,this.dim=s,this.d=h,this.aabb2D=a,this.child0=-1,this.child1=-1}}export{i as ElevationAgnosticBVH};