@arcgis/core 4.31.0-next.20240708 → 4.31.0-next.20240710

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 (239) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0975e54c50383375cc09.js → 14cf7411e8318a1bccb9.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{71852b8437ec66b9ef06.js → 2123ab24163a532ebc8d.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{c91b3800cf3891bf2d59.js → 252ff37bf5e12dae0b18.js} +1 -1
  5. package/assets/esri/core/workers/chunks/2799007b5f3f4a2e364c.js +51 -0
  6. package/assets/esri/core/workers/chunks/{ff5e6d823d512f87a527.js → 2dddb8a989b9c96572fe.js} +1 -1
  7. package/assets/esri/core/workers/chunks/34b5bab6239c7277f854.js +1 -0
  8. package/assets/esri/core/workers/chunks/543f9db420c99d429637.js +1 -0
  9. package/assets/esri/core/workers/chunks/{5089a12084a8a8fb93d8.js → 61e5179fb49866241128.js} +1 -1
  10. package/assets/esri/core/workers/chunks/632e3ba2b8a881df29a0.js +1 -0
  11. package/assets/esri/core/workers/chunks/63eb1cc923bb8dcb3cb3.js +1 -0
  12. package/assets/esri/core/workers/chunks/{380e2654bc7e07163df0.js → 725a0eae5248a933db05.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{1cc4a89c96a36d6b3d52.js → 7767559d56d16b644655.js} +1 -1
  14. package/assets/esri/core/workers/chunks/7baf288a07401f9e972d.js +1 -0
  15. package/assets/esri/core/workers/chunks/{43e83f4d827f59ff556a.js → 8087288f00dfdcc479b9.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{a5fbe1c95e49093e5af4.js → 8cce4b218568638e6e64.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{c7e2a97cb7bcd153bcef.js → 8e326def543268f8a08e.js} +1 -1
  18. package/assets/esri/core/workers/chunks/92cb45b18e151db007dc.js +1 -0
  19. package/assets/esri/core/workers/chunks/b2e8cc76381077b78d4c.js +1 -0
  20. package/assets/esri/core/workers/chunks/b6a8132708afcd988fa9.js +1 -0
  21. package/assets/esri/core/workers/chunks/{b4d850e82a8ae902d684.js → c44cc686774ff53c0a94.js} +1 -1
  22. package/assets/esri/core/workers/chunks/c52701477405c1fb2072.js +1 -0
  23. package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js → cfc2a1858a8bbb284979.js} +2 -2
  24. package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js.LICENSE.txt → cfc2a1858a8bbb284979.js.LICENSE.txt} +1 -1
  25. package/assets/esri/core/workers/chunks/d9863289c69d2550cd49.js +1 -0
  26. package/assets/esri/core/workers/chunks/e1f4df3a5b0b31521b3c.js +1 -0
  27. package/assets/esri/core/workers/chunks/ee72a006e25e94a4cd4a.js +1039 -0
  28. package/assets/esri/core/workers/chunks/{61505947371cebab9cbe.js → fdebfe55cd097714ec11.js} +1 -1
  29. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +13 -18
  30. package/assets/esri/themes/dark/main.css +1 -1
  31. package/assets/esri/themes/light/main.css +1 -1
  32. package/assets/esri/themes/light/view.css +1 -1
  33. package/chunks/AtmosphereCompositing.glsl.js +6 -9
  34. package/chunks/BlendLayers.glsl.js +1 -7
  35. package/chunks/BlendWeights.glsl.js +81 -86
  36. package/chunks/Blur.glsl.js +1 -3
  37. package/chunks/ChapmanAtmosphere.glsl.js +3 -8
  38. package/chunks/CheckerBoard.glsl.js +3 -9
  39. package/chunks/Clouds.glsl.js +21 -10
  40. package/chunks/CloudsComposition.glsl.js +3 -7
  41. package/chunks/ColorMaterial.glsl.js +3 -9
  42. package/chunks/ComponentShader.glsl.js +41 -75
  43. package/chunks/Compositing.glsl.js +5 -7
  44. package/chunks/DefaultMaterial.glsl.js +68 -73
  45. package/chunks/EdgeDetect.glsl.js +29 -39
  46. package/chunks/EdgeShader.glsl.js +37 -60
  47. package/chunks/Fog.glsl.js +4 -9
  48. package/chunks/HUDCompositing.glsl.js +1 -3
  49. package/chunks/HUDMaterial.glsl.js +11 -20
  50. package/chunks/Heatmap.glsl.js +3 -11
  51. package/chunks/HeatmapDensity.glsl.js +12 -15
  52. package/chunks/HighlightApply.glsl.js +130 -174
  53. package/chunks/HighlightDownsample.glsl.js +29 -32
  54. package/chunks/ImageMaterial.glsl.js +11 -21
  55. package/chunks/LaserlinePath.glsl.js +6 -10
  56. package/chunks/Laserlines.glsl.js +8 -20
  57. package/chunks/LineCallout.glsl.js +91 -108
  58. package/chunks/LineMarker.glsl.js +62 -53
  59. package/chunks/Magnifier.glsl.js +4 -9
  60. package/chunks/MeasurementArrow.glsl.js +9 -15
  61. package/chunks/NativeLine.glsl.js +8 -12
  62. package/chunks/NoiseTextureAtlas.glsl.js +89 -86
  63. package/chunks/OITCompositing.glsl.js +8 -12
  64. package/chunks/OverlayCompositing.glsl.js +2 -4
  65. package/chunks/Path.glsl.js +31 -55
  66. package/chunks/Pattern.glsl.js +16 -20
  67. package/chunks/PointRenderer.glsl.js +39 -48
  68. package/chunks/Precipitation.glsl.js +22 -39
  69. package/chunks/RasterColorizer.glsl.js +25 -33
  70. package/chunks/RealisticTree.glsl.js +53 -65
  71. package/chunks/RibbonLine.glsl.js +31 -36
  72. package/chunks/SSAO.glsl.js +7 -10
  73. package/chunks/SSAOBlur.glsl.js +10 -14
  74. package/chunks/ShadedColorMaterial.glsl.js +12 -15
  75. package/chunks/ShadowCastAccumulate.glsl.js +6 -8
  76. package/chunks/ShadowCastVisualize.glsl.js +12 -18
  77. package/chunks/ShadowHighlight.glsl.js +49 -51
  78. package/chunks/SimpleAtmosphere.glsl.js +4 -13
  79. package/chunks/SlicePlaneMaterial.glsl.js +3 -7
  80. package/chunks/Stars.glsl.js +3 -7
  81. package/chunks/Terrain.glsl.js +20 -61
  82. package/chunks/TextureOnly.glsl.js +2 -4
  83. package/chunks/Viewshed.glsl.js +20 -38
  84. package/chunks/WaterSurface.glsl.js +34 -60
  85. package/core/accessorSupport/tracking.js +1 -1
  86. package/core/workers/registry.js +1 -1
  87. package/geometry/Circle.js +1 -1
  88. package/geometry/Polygon.js +1 -1
  89. package/geometry/Polyline.js +1 -1
  90. package/geometry/support/geodesicUtils.js +1 -1
  91. package/interfaces.d.ts +34 -4
  92. package/layers/WCSLayer.js +1 -1
  93. package/layers/mixins/ArcGISImageService.js +1 -1
  94. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  95. package/layers/support/SubtypeSublayer.js +1 -1
  96. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  97. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  98. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  99. package/package.json +3 -3
  100. package/support/revision.js +1 -1
  101. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  102. package/views/2d/engine/flow/styles/Particles.js +1 -1
  103. package/views/2d/engine/flow/styles/Streamlines.js +1 -1
  104. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  105. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  106. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  107. package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
  108. package/views/2d/engine/webgl/DefaultVertexAttributeLayouts.js +1 -1
  109. package/views/2d/engine/webgl/Mesh2D.js +1 -1
  110. package/views/2d/engine/webgl/Overlay.js +1 -1
  111. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  112. package/views/2d/engine/webgl/Utils.js +1 -1
  113. package/views/2d/engine/webgl/VertexStream.js +1 -1
  114. package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
  115. package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
  116. package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
  117. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  118. package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
  119. package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
  120. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  121. package/views/2d/engine/webgl/shaderGraph/ShaderBuilder2D.js +1 -1
  122. package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
  123. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
  124. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
  125. package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
  126. package/views/2d/layers/support/DebugOverlay.js +1 -1
  127. package/views/2d/magnifier/MagnifierView2D.js +1 -1
  128. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  129. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  130. package/views/3d/environment/LocalAtmosphere.js +1 -1
  131. package/views/3d/environment/MarsAtmosphere.js +1 -1
  132. package/views/3d/environment/Precipitation.js +1 -1
  133. package/views/3d/environment/Stars.js +1 -1
  134. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  135. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  136. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  137. package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils.js +1 -1
  138. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  139. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  140. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  141. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  142. package/views/3d/layers/StreamLayerView3D.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  145. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +5 -0
  146. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +5 -0
  147. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +5 -0
  148. package/views/3d/layers/graphics/pipeline/PBFPointFeaturesView.js +5 -0
  149. package/views/3d/layers/graphics/pipeline/TestSymbol.js +5 -0
  150. package/views/3d/layers/graphics/pipeline/Tile.js +5 -0
  151. package/views/3d/layers/graphics/pipeline/Tile3DFetcher.js +5 -0
  152. package/views/3d/layers/graphics/pipeline/Tile3DProcessor.js +5 -0
  153. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  154. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  155. package/views/3d/layers/support/projectExtentUtils.js +1 -1
  156. package/views/3d/terrain/OverlayRenderer.js +1 -1
  157. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  158. package/views/3d/terrain/PatchRenderData.js +1 -1
  159. package/views/3d/terrain/TerrainRenderer.js +1 -1
  160. package/views/3d/terrain/TileCompositor.js +1 -1
  161. package/views/3d/webgl/ManagedFBObject.js +1 -1
  162. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  163. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  164. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  165. package/views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js +3 -5
  166. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
  167. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +29 -59
  168. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -12
  169. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
  170. package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +1 -1
  171. package/views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js +4 -7
  172. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  173. package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +6 -6
  174. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +4 -4
  175. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -4
  176. package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
  177. package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
  178. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  179. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  180. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  181. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  182. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  183. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  184. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  185. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
  186. package/views/3d/webgl-engine/effects/magnifier/MagnifierRenderNode.js +1 -1
  187. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  188. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  189. package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
  190. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  191. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  192. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  193. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  194. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  195. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  196. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  197. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  198. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  199. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  200. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  201. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  202. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  203. package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
  204. package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
  205. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
  206. package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +1 -1
  207. package/views/SceneView.js +1 -1
  208. package/views/draw/support/Box.js +1 -1
  209. package/views/interactive/tooltip/Tooltip.js +1 -1
  210. package/views/interactive/tooltip/fields/fields.js +1 -1
  211. package/views/webgl/RenderingContext.js +1 -1
  212. package/views/webgl/Util.js +1 -1
  213. package/views/webgl/VertexArrayObject.js +1 -1
  214. package/views/webgl/enums.js +1 -1
  215. package/views/webgl/heatmapTextureUtils.js +1 -1
  216. package/views/webgl/testDoublePrecisionArithmetic.js +1 -1
  217. package/views/webgl/testFloatBufferBlend.js +1 -1
  218. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  219. package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
  220. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  221. package/widgets/Feature/support/relatedFeatureUtils.js +1 -1
  222. package/widgets/FeatureForm.js +1 -1
  223. package/widgets/OrientedImageryViewer/constants.js +1 -1
  224. package/widgets/OrientedImageryViewer.js +1 -1
  225. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  226. package/widgets/UtilityNetworkTrace.js +1 -1
  227. package/widgets/support/TimezonePicker.js +1 -1
  228. package/assets/esri/core/workers/chunks/0cb2eb96ffb1dbed00eb.js +0 -1
  229. package/assets/esri/core/workers/chunks/0d6ed27fc9948f4ea061.js +0 -1
  230. package/assets/esri/core/workers/chunks/225b947ba4b2fcfd5630.js +0 -1
  231. package/assets/esri/core/workers/chunks/7c7c3068da3bf7467685.js +0 -1
  232. package/assets/esri/core/workers/chunks/812e18c65aa6e398c338.js +0 -1
  233. package/assets/esri/core/workers/chunks/85e5cdd723f68dec8c25.js +0 -1
  234. package/assets/esri/core/workers/chunks/a7e2ca5ede46395f0787.js +0 -1
  235. package/assets/esri/core/workers/chunks/aed0db145187d9eb52f2.js +0 -51
  236. package/assets/esri/core/workers/chunks/cf9a32a03b3d3b66effb.js +0 -1
  237. package/assets/esri/core/workers/chunks/d85c51abde781660b1f5.js +0 -1
  238. package/assets/esri/core/workers/chunks/e840e54455eb500b501d.js +0 -1098
  239. package/assets/esri/core/workers/chunks/fec53ce15ae52f8cb802.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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 V from"./TileOverlayData.js";import{fallsWithinLayerView as R}from"./tileUtils.js";import{VertexArrayObject as w}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 V,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.loaded){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.leaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=B(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==B(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=B(e,s[t]),n=B(e,s[(t+1)%4]),l=B(e,o);X[t]=l,X[(t+1)%4]=n,X[(t+2)%4]=e,X[(t+3)%4]=a,$(X.some((t=>t?.loaded||t===e)));const g=X.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);X.forEach(((e,t)=>{e&&e?.level>g&&(X[t]=null)})),$(X.some((t=>t?.loaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=X[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&&$(Z.some((r=>d[4*t+r]?.loaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)X[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&W)}get samplerDataChanged(){return!!(this._modifiedFlags&q)}get clippingAreaChanged(){return!!(this._modifiedFlags&z)}get wireframeChanged(){return!!(this._modifiedFlags&J)}get dirtyEdges(){return this._modifiedFlags>>K&15}get dirtyCorners(){return this._modifiedFlags>>Q&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Y&15}_markCornerDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Q|15<<K|15<<Y}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.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new w(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(R(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.loaded||!e.intersectsClippingArea||0===e.level)return void $(e?.loaded);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.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];$(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?.loaded)&&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.loaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return $(!x.leaf),void $(0===v);const E=x.renderData;$(e.isEdgeNeighbor(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),V=D.numVerticesPerSide-1,R=E.geometry;if(!R)return void $(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=R.getEdgeCount(P),G=A-1,X=F-1;$(G*S===X,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${G*S})`);const B=e.extent,W=r===_.NORTH||r===_.SOUTH,q=F-1,z=q>>v,J=A-1;if(z<1)return void $(1===J);$(z===J),$(t(z));const K=R.numVerticesPerSide-1;$(v>0||z===Math.max(K,V));const Q=e.getNeighborEdgeStartVertexIndex(y,x);$(0<=Q&&Q<S);const Y=Q*z;$(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,O,j,0),D.getEdgeVertexPosition(y,I,j,A-1);const te=i(O,I),re=Math.max(H,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,O,j,Z),R.getEdgeVertexPosition(P,I,w,ee);const i=t/z,f=W?B[0]+i*(B[2]-B[0]):r===_.WEST?B[0]:B[2],p=W?r===_.SOUTH?B[1]:B[3]:B[1]+i*(B[3]-B[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<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${A}] and [${x.lij}].edge${P}[${ee}/${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,Z),R.getEdgeVertexPosition(P,I,w,ee);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=R.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${P}][${ee}/${l}] ${b(O)} vs ${b(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,M,Z),R.getEdgeNormal(P,U,ee),n(k,M),n(L,U);const _=l(k,L),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)} (${Z}/${A-1}) edge ${y} vs neighbor ${T(x.lij)} (${ee}/${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,Z),R.getEdgeNormal(P,r,ee),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())}}Z+=1,ee+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),L=h(),H=1,X=[null,null,null,null];function B(e,t){return t?.loaded||t===e?t:null}const W=1,q=2,z=4,J=8,K=4,Q=8,Y=12,Z=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,B as neighborTileIfLoadedOrSelf,Z 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 V from"./TileOverlayData.js";import{fallsWithinLayerView as R}from"./tileUtils.js";import{VertexArrayObject as w}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 V,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.loaded){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.leaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.leaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=B(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==B(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=B(e,s[t]),n=B(e,s[(t+1)%4]),l=B(e,o);X[t]=l,X[(t+1)%4]=n,X[(t+2)%4]=e,X[(t+3)%4]=a,$(X.some((t=>t?.loaded||t===e)));const g=X.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);X.forEach(((e,t)=>{e&&e?.level>g&&(X[t]=null)})),$(X.some((t=>t?.loaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=X[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&&$(Z.some((r=>d[4*t+r]?.loaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)X[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&W)}get samplerDataChanged(){return!!(this._modifiedFlags&q)}get clippingAreaChanged(){return!!(this._modifiedFlags&z)}get wireframeChanged(){return!!(this._modifiedFlags&J)}get dirtyEdges(){return this._modifiedFlags>>K&15}get dirtyCorners(){return this._modifiedFlags>>Q&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Y&15}_markCornerDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Q|15<<K|15<<Y}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.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new w(e,N,new Map([["geometry",f(t.layout)]]),new Map([["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(R(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.loaded||!e.intersectsClippingArea||0===e.level)return void $(e?.loaded);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.loaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];$(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?.loaded)&&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.loaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[y]);const v=p-x.level;if(!x.loaded)return $(!x.leaf),void $(0===v);const E=x.renderData;$(e.isEdgeNeighbor(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),V=D.numVerticesPerSide-1,R=E.geometry;if(!R)return void $(!1);const w=E.localOrigin,N=this.geometryState.edgePeerNeighbors[y];if(N?.loaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=R.getEdgeCount(P),G=A-1,X=F-1;$(G*S===X,`Tile[${e.lij}]:e${y},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${G*S})`);const B=e.extent,W=r===_.NORTH||r===_.SOUTH,q=F-1,z=q>>v,J=A-1;if(z<1)return void $(1===J);$(z===J),$(t(z));const K=R.numVerticesPerSide-1;$(v>0||z===Math.max(K,V));const Q=e.getNeighborEdgeStartVertexIndex(y,x);$(0<=Q&&Q<S);const Y=Q*z;$(0<=Y&&Y<=q-z);let Z=0,ee=Y;D.getEdgeVertexPosition(y,O,j,0),D.getEdgeVertexPosition(y,M,j,A-1);const te=i(O,M),re=Math.max(H,1e-4*te);for(let t=0;t<=z;++t){D.getEdgeVertexPosition(y,O,j,Z),R.getEdgeVertexPosition(P,M,w,ee);const i=t/z,f=W?B[0]+i*(B[2]-B[0]):r===_.WEST?B[0]:B[2],p=W?r===_.SOUTH?B[1]:B[3]:B[1]+i*(B[3]-B[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,M),r=o(O)-c.radius,i=o(M)-c.radius,u=t<re;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Z}/${A}] and [${x.lij}].edge${P}[${ee}/${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(M);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(y,O,j,Z),R.getEdgeVertexPosition(P,M,w,ee);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,M,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${M} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(y),l=R.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${y}][${Z}/${n}] vs neighbor [${x.lij}].edge[${P}][${ee}/${l}] ${b(O)} vs ${b(M)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(y,I,Z),R.getEdgeNormal(P,U,ee),n(k,I),n(L,U);const _=l(k,L),S=1-_<.01||!1||e===x;if(!S){const t=h();g(t,I,U);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${Z}/${A-1}) edge ${y} vs neighbor ${T(x.lij)} (${ee}/${F-1}) nedge ${P} :${b(I)} 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,Z),R.getEdgeNormal(P,r,ee),d(I,t)||console.warn("Missing update in tile normal: ",b(I)," => ",b(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",b(U)," => ",b(r))}$(S,r())}}Z+=1,ee+=1}}))}}const O=h(),M=h(),I=h(),U=h(),k=h(),L=h(),H=1,X=[null,null,null,null];function B(e,t){return t?.loaded||t===e?t:null}const W=1,q=2,z=4,J=8,K=4,Q=8,Y=12,Z=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,B as neighborTileIfLoadedOrSelf,Z 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{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as d,s as h,m as u}from"../../../chunks/vec32.js";import{ZEROS as _,fromValues as f,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as R}from"./LayerClass.js";import{OverlayContent as x}from"./OverlayContent.js";import{overlayRenderOccludedFlag as P}from"./OverlayRenderer.js";import{PatchRenderData as v}from"./PatchRenderData.js";import{RenderOrder as w}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as A}from"./TileRenderer.js";import{TileUpdate as E}from"./TileUpdate.js";import{IteratorPreorder as C,sortTiles as N,compareTiles as j}from"./tileUtils.js";import{TransparencyMode as B}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as I,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as F}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as q,ConsumesDepth as M,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{TerrainTechnique as ne}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ae}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as oe}from"../../webgl/enums.js";const le=7,ce=10,de=m();let he=class extends q{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._tileSize=256,this._configuration=new ae,this._passParameters=new L,this._drawParameters=new se,this._renderDataPool=new s(v),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new C,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()],[$.TRANSPARENT_TERRAIN,()=>this._produces()],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?P:X.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?M:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return!!this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.updateTileTexture(e,E.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===E.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[R.ELEVATION])i.pendingUpdates&=~E.GEOMETRY;e.resetPendingUpdate(E.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ce-le,i=Math.max(0,Math.floor((e.level-t)/le)*le);if(this._isGlobal&&0===i)return _;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=V.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=V.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=V.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new A(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==B.Opaque)return;const s=ue,n=_e;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,_=e.options.store===W.MIN,f=!!e.results.ground.target,p=re(e.verticalOffset),g=e.tolerance;let m,T=_&&null!=a.dist?a.dist:1/0;const O=e.options,R=O.normalRequired||!O.backfacesTerrain,x=new J(!1,R),P=h=>{const f=h.renderData;if(!f?.vao)return;const P=f.geometry;b(de,P.boundingBox);const v=f.localOrigin;null!=p&&(p.localOrigin=v,p.applyToAabb(de));const w=de;if(fe[0]=i[0]-v[0],fe[1]=i[1]-v[1],fe[2]=i[2]-v[2],!K(w,fe,n,g,T))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),T=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!R||null!=d)&&n>=0&&(O.backfacesTerrain||u(d,s)<0)&&(O.invisibleTerrain||!O.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),O.isFiltered)return;O.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),O.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},A=pe;d(A,r,v);const{indices:E,indexCount:C}=P,N=P.vertexAttributes,j=N.getField(te.POSITION,y),B=new z(j.typedBuffer,3,N.stride/4),F=C/3;if(!p&&F>I){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new U(E,0,F,B)),e.intersectionData.intersectRay(fe,A,x,S)}else Z(fe,A,0,F,E,B,p,x,S)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==p&&!e.intersectsRay(i,s,g,T)||f&&this._useStencilForTile(e)?t.skipSubtree():P(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bindParameters.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bindParameters.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&P))return null}else{const t=this.transparency===B.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===B.Invisible)return null;switch(e.output){case F.Color:return this._configuration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._configuration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._configuration.receiveShadows=e.bindParameters.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._configuration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(F.Color,e.bindParameters.slot===$.OCCLUDED_TERRAIN);case F.Shadow:case F.ShadowExcludeHighlight:return this._castShadows?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Shadow,!1)):null;case F.ViewshedShadow:return this._inViewshed?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.ViewshedShadow,!1)):null;case F.Depth:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Depth,!1);case F.Normal:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Normal,!1);case F.ObjectAndLayerIdColor:return this._updateTechnique(F.ObjectAndLayerIdColor,!1);case F.Highlight:return this._overlayRenderer.hasHighlights&&0===e.bindParameters.highlightLevel?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case F.Color:{const i=e.bindParameters.slot===$.OCCLUDED_TERRAIN?x.Occluded:x.Color;this._renderMaterialPass(e,t,i);break}case F.Depth:case F.Normal:this._renderAuxiliaryPass(e,t,x.Color,this._visiblePatchesByOrigin);break;case F.Highlight:0===e.bindParameters.highlightLevel&&this._renderAuxiliaryPass(e,t,x.Highlight,this._visiblePatchesByOrigin);break;case F.Shadow:case F.ShadowExcludeHighlight:case F.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case F.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,x.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=f(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==w.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>j(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],oe.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===x.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",g));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?oe.LINES:oe.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;t.program.bindDraw(new se(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(ne,this._configuration,this._shaderTechnique),this._shaderTechnique}get test(){}};e([o({readOnly:!0})],he.prototype,"_isGlobal",null),e([o()],he.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],he.prototype,"renderingDisabled",null),e([o({value:!0})],he.prototype,"visible",null),e([o()],he.prototype,"renderPatchBorders",null),e([o()],he.prototype,"visualizeNormals",null),e([o()],he.prototype,"cullBackFaces",null),e([o({value:w.FRONT_TO_BACK})],he.prototype,"renderOrder",null),e([o()],he.prototype,"wireframe",null),he=e([l("esri.views.3d.terrain.TerrainRenderer")],he);const ue=p(),_e=p(),fe=p(),pe=p();export{he as TerrainRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as c}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as d,s as h,m as u}from"../../../chunks/vec32.js";import{ZEROS as _,fromValues as f,create as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as m,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as R}from"./LayerClass.js";import{OverlayContent as x}from"./OverlayContent.js";import{overlayRenderOccludedFlag as P}from"./OverlayRenderer.js";import{PatchRenderData as v}from"./PatchRenderData.js";import{RenderOrder as w}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as A}from"./TileRenderer.js";import{TileUpdate as E}from"./TileUpdate.js";import{IteratorPreorder as C,sortTiles as N,compareTiles as j}from"./tileUtils.js";import{TransparencyMode as B}from"./TransparencyMode.js";import{componentMinimalSizeForIntersectionData as I,ComponentIntersectionData as U}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as F}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as q,ConsumesDepth as M,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as z}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as V}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as Y}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as Q,StoreResults as W}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as X}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as K,intersectTriangles as Z,MeshIntersectionOptions as J}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as $}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as ee}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as te}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ie,getVerticalOffsetTerrain as re}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as se}from"../webgl-engine/materials/DrawParameters.js";import{TerrainTechnique as ne}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ae}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as oe}from"../../webgl/enums.js";const le=7,ce=10,de=m();let he=class extends q{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=Q.TERRAIN,this.isGround=!0,this._tileSize=256,this._configuration=new ae,this._passParameters=new L,this._drawParameters=new se,this._renderDataPool=new s(v),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new C,this._castShadows=!1,this._inViewshed=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=X.Occlude,this.produces=new Map([[$.OPAQUE_TERRAIN,()=>this._produces()],[$.TRANSPARENT_TERRAIN,()=>this._produces()],[$.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?P:X.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?M:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return!!this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._configuration.visualizeNormals}set visualizeNormals(e){this._configuration.visualizeNormals!==e&&(this._configuration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._configuration.backfaceCullingEnabled}set cullBackFaces(e){this._configuration.backfaceCullingEnabled!==e&&(this._configuration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ie}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._configuration.screenSizePerspective!==e&&(this._configuration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.updateTileTexture(e,E.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===E.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[R.ELEVATION])i.pendingUpdates&=~E.GEOMETRY;e.resetPendingUpdate(E.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ce-le,i=Math.max(0,Math.floor((e.level-t)/le)*le);if(this._isGlobal&&0===i)return _;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=V.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=V.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=V.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new A(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==B.Opaque)return;const s=ue,n=_e;d(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,_=e.options.store===W.MIN,f=!!e.results.ground.target,g=re(e.verticalOffset),p=e.tolerance;let m,T=_&&null!=a.dist?a.dist:1/0;const O=e.options,R=O.normalRequired||!O.backfacesTerrain,x=new J(!1,R),P=h=>{const f=h.renderData;if(!f?.vao)return;const P=f.geometry;b(de,P.boundingBox);const v=f.localOrigin;null!=g&&(g.localOrigin=v,g.applyToAabb(de));const w=de;if(fe[0]=i[0]-v[0],fe[1]=i[1]-v[1],fe[2]=i[2]-v[2],!K(w,fe,n,p,T))return;const D=(e,t,i)=>{e.set(this.type,h,t,i,c),T=_&&null!=a.dist?a.dist:1/0},S=(n,c,d)=>{if((!R||null!=d)&&n>=0&&(O.backfacesTerrain||u(d,s)<0)&&(O.invisibleTerrain||!O.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&D(l,n,d),O.isFiltered)return;O.store===W.ALL&&(null==m?(m=Y(e.ray),D(m,n,d),e.results.all.push(m)):n<m.dist&&D(m,n,d)),(null==a.dist||n<a.dist)&&D(a,n,d),O.store!==W.MIN&&(null==o.dist||n>o.dist)&&D(o,n,d)}},A=ge;d(A,r,v);const{indices:E,indexCount:C}=P,N=P.vertexAttributes,j=N.getField(te.POSITION,y),B=new z(j.typedBuffer,3,N.stride/4),F=C/3;if(!g&&F>I){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new U(E,0,F,B)),e.intersectionData.intersectRay(fe,A,x,S)}else Z(fe,A,0,F,E,B,g,x,S)},v=this._rootTiles;if(null!=v){(()=>{const t=this._tileIterator;t.reset(v);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,p,T)||f&&this._useStencilForTile(e)?t.skipSubtree():P(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0);const i=e.bindParameters.viewshedEnabled;if(this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),e.bindParameters.slot===$.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&P))return null}else{const t=this.transparency===B.Opaque?$.OPAQUE_TERRAIN:$.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===B.Invisible)return null;switch(e.output){case F.Color:return this._configuration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._configuration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._configuration.receiveShadows=e.bindParameters.shadowMap.ready,this._configuration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._configuration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(F.Color,e.bindParameters.slot===$.OCCLUDED_TERRAIN);case F.Shadow:case F.ShadowExcludeHighlight:return this._castShadows?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Shadow,!1)):null;case F.ViewshedShadow:return this._inViewshed?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.ViewshedShadow,!1)):null;case F.Depth:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Depth,!1);case F.Normal:return this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Normal,!1);case F.ObjectAndLayerIdColor:return this._updateTechnique(F.ObjectAndLayerIdColor,!1);case F.Highlight:return this._overlayRenderer.hasHighlights&&0===e.bindParameters.highlightLevel?(this._configuration.receiveShadows=this._configuration.receiveAmbientOcclusion=!1,this._updateTechnique(F.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case F.Color:{const i=e.bindParameters.slot===$.OCCLUDED_TERRAIN?x.Occluded:x.Color;this._renderMaterialPass(e,t,i);break}case F.Depth:case F.Normal:this._renderAuxiliaryPass(e,t,x.Color,this._visiblePatchesByOrigin);break;case F.Highlight:0===e.bindParameters.highlightLevel&&this._renderAuxiliaryPass(e,t,x.Highlight,this._visiblePatchesByOrigin);break;case F.Shadow:case F.ShadowExcludeHighlight:case F.ViewshedShadow:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case F.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,x.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=f(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._configuration.tileBlendInput=i.backgroundIsGrid?G.GridComposite:null!=i.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==w.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)N(this.renderOrder,i,t);e.sort(((e,t)=>j(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(e.bindParameters,this._passParameters,this._drawParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],oe.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._configuration.screenSizePerspective&&this.pointsOfInterest){const e=ee(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===x.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",_),n.setUniform4fv("texOffsetAndScale",p));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:_;this._configuration.tileBlendInput===G.ColorComposite&&n.setUniform3fv("backgroundColor",l);const c=this.wireframe?oe.LINES:oe.TRIANGLES;this._configuration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const d=this._visiblePatchesByOrigin;for(const h of d.values()){const r=h[0].renderData.localOrigin;this._drawParameters.origin=r,t.program.bindDraw(e.bindParameters,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const s of h){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._configuration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,c,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const d=a.geometry.indexCount;e.rctx.bindVAO(o),c.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,d,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._configuration.output=e,this._configuration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(ne,this._configuration,this._shaderTechnique),this._shaderTechnique}get test(){}};e([o({readOnly:!0})],he.prototype,"_isGlobal",null),e([o()],he.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],he.prototype,"renderingDisabled",null),e([o({value:!0})],he.prototype,"visible",null),e([o()],he.prototype,"renderPatchBorders",null),e([o()],he.prototype,"visualizeNormals",null),e([o()],he.prototype,"cullBackFaces",null),e([o({value:w.FRONT_TO_BACK})],he.prototype,"renderOrder",null),e([o()],he.prototype,"wireframe",null),he=e([l("esri.views.3d.terrain.TerrainRenderer")],he);const ue=g(),_e=g(),fe=g(),ge=g();export{he as TerrainRenderer};
@@ -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"../../../core/Logger.js";import{disposeMaybe as t,releaseMaybe as r}from"../../../core/maybe.js";import{ZEROS as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{RasterColorizerStretchType as s}from"../../2d/engine/imagery/enums.js";import{VectorTileRendererHelper3D as o}from"../../2d/engine/vectorTiles/VectorTileRendererHelper3D.js";import{BlendLayersTechniqueConfiguration as n,BlendLayersTechnique as a}from"./BlendLayersTechnique.js";import{LayerClass as l}from"./LayerClass.js";import{RasterColorizerTechniqueConfiguration as h,RasterColorizerTechnique as c}from"./RasterColorizerTechnique.js";import{MultiSizeFramebuffer as u}from"./support/MultiSizeFramebuffer.js";import{LayerBlendMode as d}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as _}from"../webgl-engine/core/shaderLibrary/terrain/BaseOpacityMode.js";import{BlendLayersOutput as f}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{PremultipliedAlphaSource as p}from"../webgl-engine/core/shaderLibrary/terrain/PremultipliedAlphaSource.js";import{B as b}from"../../../chunks/BlendLayers.glsl.js";import{BindParameters as g}from"../webgl-engine/lib/BindParameters.js";import{Pos2Tex as m}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as T}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as y,ClearBufferBit as x,TextureType as C}from"../../webgl/enums.js";import{Texture as B}from"../../webgl/Texture.js";import{vertexCount as q}from"../../webgl/Util.js";const O=()=>e.getLogger("esri.views.3d.terrain");class L{constructor(e,t){this._rctx=e,this._techniques=t,this._fbos=[],this._vectorTileHelper=new o,this._bindParameters=new g(null,null),this._blendLayersTechniqueConfig=new n,this._current=0,this._lastUsedIds=new Array,this._lastCreatedBufferId=0,this._onHoldIds=new Array,this._vaoQuad=T(this._rctx,m)}dispose(){this._fbos.forEach(t),this._fbos=null,this._vtFBO=t(this._vtFBO),this._vaoQuad=t(this._vaoQuad),this._vectorTileHelper=t(this._vectorTileHelper),this._backgroundTechnique=r(this._backgroundTechnique),this._applyOpacityTechnique=r(this._applyOpacityTechnique),this._blendLayersTechnique=r(this._blendLayersTechnique)}updateHeading(e){this._vectorTileHelper?.updateHeading(e)}_getBlendLayersTechnique(e,t,r,i=p.Off,s=b.BelowLayer){return this._blendLayersTechniqueConfig.output=t,this._blendLayersTechniqueConfig.blendMode=e,this._blendLayersTechniqueConfig.baseOpacityMode=r,this._blendLayersTechniqueConfig.premultipliedSource=i,this._blendLayersTechniqueConfig.background=s,this._blendLayersTechnique=this._techniques.releaseAndAcquire(a,this._blendLayersTechniqueConfig,this._blendLayersTechnique),this._blendLayersTechnique}drawBackground(e,t){const r=this._getBlendLayersTechnique(d.Normal,t?f.ColorComposite:f.GridComposite,_.NotRequired,p.Off,b.Only),i=this._rctx.bindTechnique(r,this._bindParameters,e);this._render(i)}_render(e){this._rctx.bindVAO(this._vaoQuad),e.assertCompatibleVertexAttributeLocations(this._vaoQuad),this._rctx.drawArrays(y.TRIANGLE_STRIP,0,q(this._vaoQuad,"geometry"))}drawGroup(e,t,r,i,s=p.On){t===f.Composite&&(e.fboTexture=this._fbos[this.getLastOnHoldId()].get(r).colorTexture),e.texture=this.currentFBO(r).colorTexture,this.closeGroup(r);const o=e.baseOpacity<1?_.Required:_.NotRequired,n=this._getBlendLayersTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawImageData(e,t,r,i,s=p.Off){if(null==e.texture)return;const o=e.baseOpacity<1?_.Required:_.NotRequired;e.fboTexture=t===f.GroupBackgroundComposite||i===d.Normal&&o===_.NotRequired&&s===p.Off?null:this.switch(r).colorTexture;const n=this._getBlendLayersTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawRasterData(e,t,r,i,s){const o=s.sourceLayerInfo.data;if(!o.source)return;if(s.tile.surface.layerViewByIndex(s.layerIndex,l.MAP).ensureSymbolizerParameters(o),!o.bind(this._rctx))return;const n=e.baseOpacity<1?_.Required:_.NotRequired;e.fboTexture=i===d.Normal&&n===_.NotRequired?null:this.switch(r).colorTexture;const a=this._getRasterColorizerTechnique(o,t,i,n);o.opacity=e.opacity;const h=o.getUniforms();h.scale=s.scale,h.offset=s.offset,h.backgroundColor=e.backgroundColor,h.fboTexture=e.fboTexture,h.baseOpacity=e.baseOpacity;const c=this._rctx.bindTechnique(a,null,h);this._render(c)}_getRasterColorizerTechnique(e,t,r,i){const o=e.symbolizerParameters,n=["stretch","lut","hillshade"].indexOf(o.type);return null==this._rasterColorizerConfig&&(this._rasterColorizerConfig=new h,this._rctx.gl.getExtension("WEBGL_color_buffer_float"),this._rctx.gl.getExtension("OES_texture_float")),this._rasterColorizerConfig.output=t,this._rasterColorizerConfig.blendMode=r,this._rasterColorizerConfig.baseOpacityMode=i,this._rasterColorizerConfig.colorizerType=n,this._rasterColorizerConfig.applyColormap=!!o.colormap,this._rasterColorizerConfig.requireBilinearWithNN=e.isBilinearWithStretchColorRamp,this._rasterColorizerConfig.stretchType=e.hasStretchTypeNone()?s.Noop:s.PerBand,this._rasterColorizerTechnique=this._techniques.releaseAndAcquire(c,this._rasterColorizerConfig,this._rasterColorizerTechnique),this._rasterColorizerTechnique}drawVectorData(e,t,r,s,o,n,a,h){const c=this._rctx,b=o.sourceLayerInfo.data,g=o.tile.surface.layerViewByIndex(o.layerIndex,l.MAP),m=e.baseOpacity<1?_.Required:_.NotRequired,T=m===_.Required||e.opacity<1||s!==d.Normal||t!==f.Composite,y=T?p.On:p.Off,C=this._getBlendLayersTechnique(s,t,m,y);c.setPipelineState(C.getPipeline());let B=null,q=null;T?(q=this.currentFBO(r),null==this._vtFBO&&(this._vtFBO=new u(this._rctx)),B=this._vtFBO.get(r),c.bindFramebuffer(B),this._clearCurrentFBO()):h&&c.clear(x.DEPTH_BUFFER_BIT);try{this._vectorTileHelper.renderBackground(c,o.sourceLod,g.painter,g.layer.styleRepository,g.schemaHelper,Math.round(1/o.scale),o.offset,a,n,g.contentZoom),b&&this._vectorTileHelper.renderContent(c,o.sourceLod,b,o.vtlNeighborInfos,g.painter,g.layer.styleRepository,g.schemaHelper,Math.round(1/o.scale),o.offset,a,n,g.contentZoom)}catch(L){O().warnOnce("A render call containing vector tiles did not resolve correctly.",L)}return null==B||(c.bindFramebuffer(q),e.texture=B.colorTexture,e.offset=i,e.scale=1,this.drawImageData(e,t,r,s,y),h)}copyFBOToTexture(e){const t=this._rctx,r=t.bindTexture(e.texture,B.TEXTURE_UNIT_FOR_UPDATES),i=e.descriptor;t.gl.copyTexImage2D(C.TEXTURE_2D,0,i.pixelFormat,0,0,i.width,i.height,0),e.generateMipmap(),t.bindTexture(r,B.TEXTURE_UNIT_FOR_UPDATES)}_clearCurrentFBO(){this._rctx.setStencilWriteMask(255),this._rctx.setClearColor(0,0,0,0),this._rctx.setClearDepth(1),this._rctx.setClearStencil(0),this._rctx.clear(x.COLOR_BUFFER_BIT|x.DEPTH_BUFFER_BIT|x.STENCIL_BUFFER_BIT)}_initFBO(e,t,r){this._rctx.bindFramebuffer(e),r&&(this._rctx.setViewport(0,0,t,t),this._clearCurrentFBO())}ensureBuffer(e){this._lastUsedIds.length=0,this._lastUsedIds.push(1),this._lastCreatedBufferId=1,this._onHoldIds.length=0,this.bind(e)}bind(e,t=0,r=!0){if(this._current=t,t>=this._fbos.length)for(let i=this._fbos.length;i<=t;i++)this._fbos.push(new u(this._rctx));this._initFBO(this._fbos[t].get(e),e,r)}_bindNextFreeBuffer(e){this._lastUsedIds.length>0?this.bind(e,this._lastUsedIds.pop()):(this._lastCreatedBufferId++,this.bind(e,this._lastCreatedBufferId))}openGroup(e){this._onHoldIds.push(this._current),this._bindNextFreeBuffer(e)}switch(e){const t=this.currentFBO(e),r=this._current;return this._bindNextFreeBuffer(e),this._lastUsedIds.push(r),t}getLastOnHoldId(){return this._onHoldIds[this._onHoldIds.length-1]}closeGroup(e){const t=this._current;this._bindNextFreeBuffer(e),this._lastUsedIds.push(t),this._lastUsedIds.push(this._onHoldIds.pop())}unbind(){this._rctx.bindFramebuffer(null)}currentFBO(e){return this._fbos[this._current].get(e)}}export{L as TileCompositor};
5
+ import e from"../../../core/Logger.js";import{disposeMaybe as t,releaseMaybe as r}from"../../../core/maybe.js";import{ZEROS as i}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{RasterColorizerStretchType as s}from"../../2d/engine/imagery/enums.js";import{VectorTileRendererHelper3D as o}from"../../2d/engine/vectorTiles/VectorTileRendererHelper3D.js";import{BlendLayersTechniqueConfiguration as n,BlendLayersTechnique as a}from"./BlendLayersTechnique.js";import{LayerClass as h}from"./LayerClass.js";import{RasterColorizerTechniqueConfiguration as l,RasterColorizerTechnique as c}from"./RasterColorizerTechnique.js";import{MultiSizeFramebuffer as u}from"./support/MultiSizeFramebuffer.js";import{LayerBlendMode as d}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as _}from"../webgl-engine/core/shaderLibrary/terrain/BaseOpacityMode.js";import{BlendLayersOutput as f}from"../webgl-engine/core/shaderLibrary/terrain/BlendLayersOutput.js";import{PremultipliedAlphaSource as p}from"../webgl-engine/core/shaderLibrary/terrain/PremultipliedAlphaSource.js";import{B as b}from"../../../chunks/BlendLayers.glsl.js";import{BindParameters as g}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as m,Layout as T}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as y,FramebufferBit as x,TextureType as C}from"../../webgl/enums.js";import{Texture as q}from"../../webgl/Texture.js";import{vertexCount as B}from"../../webgl/Util.js";const O=()=>e.getLogger("esri.views.3d.terrain");class L{constructor(e,t){this._rctx=e,this._techniques=t,this._fbos=[],this._vectorTileHelper=new o,this._bindParameters=new g(null,null),this._blendLayersTechniqueConfig=new n,this._current=0,this._lastUsedIds=new Array,this._lastCreatedBufferId=0,this._onHoldIds=new Array,this._vaoQuad=m(this._rctx,T.Pos2Tex)}dispose(){this._fbos.forEach(t),this._fbos=null,this._vtFBO=t(this._vtFBO),this._vaoQuad=t(this._vaoQuad),this._vectorTileHelper=t(this._vectorTileHelper),this._backgroundTechnique=r(this._backgroundTechnique),this._applyOpacityTechnique=r(this._applyOpacityTechnique),this._blendLayersTechnique=r(this._blendLayersTechnique)}updateHeading(e){this._vectorTileHelper?.updateHeading(e)}_getBlendLayersTechnique(e,t,r,i=p.Off,s=b.BelowLayer){return this._blendLayersTechniqueConfig.output=t,this._blendLayersTechniqueConfig.blendMode=e,this._blendLayersTechniqueConfig.baseOpacityMode=r,this._blendLayersTechniqueConfig.premultipliedSource=i,this._blendLayersTechniqueConfig.background=s,this._blendLayersTechnique=this._techniques.releaseAndAcquire(a,this._blendLayersTechniqueConfig,this._blendLayersTechnique),this._blendLayersTechnique}drawBackground(e,t){const r=this._getBlendLayersTechnique(d.Normal,t?f.ColorComposite:f.GridComposite,_.NotRequired,p.Off,b.Only),i=this._rctx.bindTechnique(r,this._bindParameters,e);this._render(i)}_render(e){this._rctx.bindVAO(this._vaoQuad),e.assertCompatibleVertexAttributeLocations(this._vaoQuad),this._rctx.drawArrays(y.TRIANGLE_STRIP,0,B(this._vaoQuad,"geometry"))}drawGroup(e,t,r,i,s=p.On){t===f.Composite&&(e.fboTexture=this._fbos[this.getLastOnHoldId()].get(r).colorTexture),e.texture=this.currentFBO(r).colorTexture,this.closeGroup(r);const o=e.baseOpacity<1?_.Required:_.NotRequired,n=this._getBlendLayersTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawImageData(e,t,r,i,s=p.Off){if(null==e.texture)return;const o=e.baseOpacity<1?_.Required:_.NotRequired;e.fboTexture=t===f.GroupBackgroundComposite||i===d.Normal&&o===_.NotRequired&&s===p.Off?null:this.switch(r).colorTexture;const n=this._getBlendLayersTechnique(i,t,o,s),a=this._rctx.bindTechnique(n,this._bindParameters,e);this._render(a)}drawRasterData(e,t,r,i,s){const o=s.sourceLayerInfo.data;if(!o.source)return;if(s.tile.surface.layerViewByIndex(s.layerIndex,h.MAP).ensureSymbolizerParameters(o),!o.bind(this._rctx))return;const n=e.baseOpacity<1?_.Required:_.NotRequired;e.fboTexture=i===d.Normal&&n===_.NotRequired?null:this.switch(r).colorTexture;const a=this._getRasterColorizerTechnique(o,t,i,n);o.opacity=e.opacity;const l=o.getUniforms();l.scale=s.scale,l.offset=s.offset,l.backgroundColor=e.backgroundColor,l.fboTexture=e.fboTexture,l.baseOpacity=e.baseOpacity;const c=this._rctx.bindTechnique(a,null,l);this._render(c)}_getRasterColorizerTechnique(e,t,r,i){const o=e.symbolizerParameters,n=["stretch","lut","hillshade"].indexOf(o.type);return null==this._rasterColorizerConfig&&(this._rasterColorizerConfig=new l,this._rctx.gl.getExtension("WEBGL_color_buffer_float"),this._rctx.gl.getExtension("OES_texture_float")),this._rasterColorizerConfig.output=t,this._rasterColorizerConfig.blendMode=r,this._rasterColorizerConfig.baseOpacityMode=i,this._rasterColorizerConfig.colorizerType=n,this._rasterColorizerConfig.applyColormap=!!o.colormap,this._rasterColorizerConfig.requireBilinearWithNN=e.isBilinearWithStretchColorRamp,this._rasterColorizerConfig.stretchType=e.hasStretchTypeNone()?s.Noop:s.PerBand,this._rasterColorizerTechnique=this._techniques.releaseAndAcquire(c,this._rasterColorizerConfig,this._rasterColorizerTechnique),this._rasterColorizerTechnique}drawVectorData(e,t,r,s,o,n,a,l){const c=this._rctx,b=o.sourceLayerInfo.data,g=o.tile.surface.layerViewByIndex(o.layerIndex,h.MAP),m=e.baseOpacity<1?_.Required:_.NotRequired,T=m===_.Required||e.opacity<1||s!==d.Normal||t!==f.Composite,y=T?p.On:p.Off,C=this._getBlendLayersTechnique(s,t,m,y);c.setPipelineState(C.getPipeline());let q=null,B=null;T?(B=this.currentFBO(r),null==this._vtFBO&&(this._vtFBO=new u(this._rctx)),q=this._vtFBO.get(r),c.bindFramebuffer(q),this._clearCurrentFBO()):l&&c.clear(x.DEPTH);try{this._vectorTileHelper.renderBackground(c,o.sourceLod,g.painter,g.layer.styleRepository,g.schemaHelper,Math.round(1/o.scale),o.offset,a,n,g.contentZoom),b&&this._vectorTileHelper.renderContent(c,o.sourceLod,b,o.vtlNeighborInfos,g.painter,g.layer.styleRepository,g.schemaHelper,Math.round(1/o.scale),o.offset,a,n,g.contentZoom)}catch(L){O().warnOnce("A render call containing vector tiles did not resolve correctly.",L)}return null==q||(c.bindFramebuffer(B),e.texture=q.colorTexture,e.offset=i,e.scale=1,this.drawImageData(e,t,r,s,y),l)}copyFBOToTexture(e){const t=this._rctx,r=t.bindTexture(e.texture,q.TEXTURE_UNIT_FOR_UPDATES),i=e.descriptor;t.gl.copyTexImage2D(C.TEXTURE_2D,0,i.pixelFormat,0,0,i.width,i.height,0),e.generateMipmap(),t.bindTexture(r,q.TEXTURE_UNIT_FOR_UPDATES)}_clearCurrentFBO(){this._rctx.setStencilWriteMask(255),this._rctx.setClearColor(0,0,0,0),this._rctx.setClearDepth(1),this._rctx.setClearStencil(0),this._rctx.clear(x.COLOR|x.DEPTH|x.STENCIL)}_initFBO(e,t,r){this._rctx.bindFramebuffer(e),r&&(this._rctx.setViewport(0,0,t,t),this._clearCurrentFBO())}ensureBuffer(e){this._lastUsedIds.length=0,this._lastUsedIds.push(1),this._lastCreatedBufferId=1,this._onHoldIds.length=0,this.bind(e)}bind(e,t=0,r=!0){if(this._current=t,t>=this._fbos.length)for(let i=this._fbos.length;i<=t;i++)this._fbos.push(new u(this._rctx));this._initFBO(this._fbos[t].get(e),e,r)}_bindNextFreeBuffer(e){this._lastUsedIds.length>0?this.bind(e,this._lastUsedIds.pop()):(this._lastCreatedBufferId++,this.bind(e,this._lastCreatedBufferId))}openGroup(e){this._onHoldIds.push(this._current),this._bindNextFreeBuffer(e)}switch(e){const t=this.currentFBO(e),r=this._current;return this._bindNextFreeBuffer(e),this._lastUsedIds.push(r),t}getLastOnHoldId(){return this._onHoldIds[this._onHoldIds.length-1]}closeGroup(e){const t=this._current;this._bindNextFreeBuffer(e),this._lastUsedIds.push(t),this._lastUsedIds.push(this._onHoldIds.pop())}unbind(){this._rctx.bindFramebuffer(null)}currentFBO(e){return this._fbos[this._current].get(e)}}export{L as TileCompositor};
@@ -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
- class e{constructor(e,t){this.key=e,this.free=t,this.incarnation=0,this._refCount=1}retain(e=1){this._refCount+=e}release(){return 0===this._refCount?(console.log(`Releasing already released FBO attachment in ${(new Error).stack}`),!0):(--this._refCount,0===this._refCount&&(this.free(),!0))}}var t;!function(e){e[e.FBO=0]="FBO",e[e.DEPTH=1]="DEPTH",e[e.COLOR=2]="COLOR"}(t||(t={}));export{t as AttachmentType,e as ManagedFBObject};
5
+ class e{constructor(e,t){this.key=e,this.free=t,this.incarnation=0,this._refCount=1}retain(e=1){this._refCount+=e}release(){return 0===this._refCount?(console.log(`Releasing already released FBO attachment "${this.name}" in ${(new Error).stack}`),!0):(--this._refCount,0===this._refCount&&(this.free(),!0))}}var t;!function(e){e[e.FBO=0]="FBO",e[e.DEPTH=1]="DEPTH",e[e.COLOR=2]="COLOR"}(t||(t={}));export{t as AttachmentType,e as ManagedFBObject};
@@ -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 e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isArray as o}from"../../../../../core/typedArrayUtil.js";import{a as n}from"../../../../../chunks/vec32.js";import{clone as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as s}from"../../../../../geometry/support/Indices.js";import{c as a}from"../../../../../chunks/vec3.js";import{c as l}from"../../../../../chunks/vec33.js";import{ViewingMode as c}from"../../../../ViewingMode.js";import{ColorMixModeEnum as m,encodeSymbolColor as f}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as p}from"../../../support/buffer/glUtil.js";import{newLayout as u}from"../../../support/buffer/InterleavedLayout.js";import d from"./ComponentData.js";import{ComponentObject as g}from"./ComponentObject.js";import{IntersectionGeometry as b}from"./IntersectionGeometry.js";import{Renderable as y}from"./Renderable.js";import{RenderGeometry as v}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as _}from"./SourceGeometry.js";import{UniformComponentParameters as j}from"./UniformComponentParameters.js";import{ComponentParametersVarying as M,ComponentParametersUniform as x,ComponentParameterSummary as w,ComponentMaterial as O}from"./Material/ComponentMaterial.js";import{attributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as D,updateVisibilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as S}from"../../lib/Util.js";import{VertexAttribute as E}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as V}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as L,PrimitiveType as N}from"../../../../webgl/enums.js";import{VertexArrayObject as U}from"../../../../webgl/VertexArrayObject.js";const T=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,o){this._renderManager=e,this._viewingMode=o,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._visible=new t,this._hidden=new t,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new B(e.rctx,2+(this._hasObjectAndLayerId?1:0))}destroy(){S(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=e.geometry,o=new d(this._componentBufferManager,s(t.componentOffsets)),n=this._createRenderable(e,o),i=new b(this._viewingMode,t.positionData,o),r=new g(e.transform,e.toMapSpace,e.obb.clone(),o,n,i);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount;return{visible:o,invisible:t.components.count-o}}setComponentData(e,t){const o=e,n=o.renderable.material,i=o.components,r=i.materialDataBuffer,s=i.materialDataIndices,a=new j,l=r.textureBuffer,c=new Uint8Array(4),p=new Uint32Array(c.buffer);let u=0,d=0,g=0,b=i.verticalOffsets,y=1/0,v=-1/0,C=!1,_=!1,O=0;for(let h=0;h<i.count;h++){t(h,a),u+=+(a.externalColor[3]<1),d+=+(a.externalColorMixMode===m.Replace&&1===a.externalColor[3]),g+=+a.castShadows,f(a.externalColor,a.externalColorMixMode,c),c[2]=254&c[2]|+a.castShadows,l.setData(s[h],0,c[0],c[1],c[2],c[3]),C||=h>0&&O!==p[0],O=p[0],_||=0!==a.elevationOffset,_&&null==b&&(b=new Array(h).fill(0)),null!=b&&(b[h]=a.elevationOffset),y=Math.min(y,a.elevationOffset),v=Math.max(v,a.elevationOffset),R(a.elevationOffset,c),l.setData(s[h],1,c[0],c[1],c[2],c[3]);const e=a.objectAndLayerIdColor;null!=e&&l.setData(s[h],2,e[0],e[1],e[2],e[3]),a.pickable!==D(i.pickability,h)&&(i.pickability=I(i.pickability,i.count,h,a.pickable))}i.verticalOffsets=_?b:null,o.offsetObb=_?h(o.obb,y,v,this._viewingMode,o.offsetObb??o.obb.clone()):null,C||_||this._hasObjectAndLayerId?(n.componentParameters=new M,n.componentParameters.castShadows=q(g,i.count),n.componentParameters.transparent=q(u,i.count),n.componentParameters.opaqueOverride=q(d,i.count),n.componentParameters.texture=l,l.updateTexture()):(n.componentParameters=new x,n.componentParameters.castShadows=a.castShadows?w.All:w.None,n.componentParameters.externalColor=a.externalColor,n.componentParameters.externalColorMixMode=a.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,o,n=!1){e.intersectionGeometry.getComponentAabb(t,o);const i=e,r=i.components.verticalOffsets;if(n||null==r)return o;const s=r[t];if(this._viewingMode===c.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=V(s);return a.localOrigin=i.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}expandRangeWithComponentObjectElevationRange(e,t,o,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const i=e,r=i.components,s=r.count,a=r.verticalOffsets,l=i.intersectionGeometry,m=this._viewingMode===c.Local,f=l.getComponentAabbs(),h=W;let p=1/0,u=-1/0;for(let c=0;c<s;c++){const e=6*c,r=a?.[c]??0;let s=1/0,l=-1/0;if(m)s=f[e+2]+r+t,l=f[e+5]+r+t;else{if(h[0]=f[e],h[1]=f[e+1],h[2]=f[e+2],h[3]=f[e+3],h[4]=f[e+4],h[5]=f[e+5],0!==r){const e=V(r);e.localOrigin=i.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+o;n.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-o)}n.expandElevationRangeValues(s,l),p=Math.min(p,s),u=Math.max(u,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=u}intersect(e,t,o,n,i,r,s){const a=e,{transform:l}=a,{position:c}=l;return null!=i&&(i.localOrigin=c),a.intersectionGeometry.intersect(t,o,n,i,a.components.verticalOffsets,l,r,s)}addEdges(e,t,o,n,i){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.components.offsets;return t.addComponentObject(r,a,s,l,o,n,i)}async extractEdgeInformation(e,t,o){const n=e,r=n.components.visibility;if(r.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:c}=n.intersectionGeometry,m=n.components.offsets,{EdgeInputBufferLayout:f}=await import("../../lib/edgeRendering/bufferLayouts.js"),h=f.createBuffer(c.length/3);l(h.position.typedBuffer,c,h.position.typedBufferStride,3),a(h.position,h.position,n.transform.rotationScale),this._setComponentIndices(h.componentIndex,s,m);const p=h.count,u=this._computeVisibilityIndices(s,r,m,p);return{origin:i(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:u,indicesLength:u.length,skipDeduplicate:!0,data:h,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let n=0;for(let i=0;i<o.length-1;i++){const r=o[i],s=o[i+1];for(let o=r;o<s;o++){const i=t?t[o]:o;e.set(i,n)}n++}}_computeVisibilityIndices(e,t,n,i){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=n[t]-n[e],!0)));const s=o(e)?new Array(r):2===e?.BYTES_PER_ELEMENT||i<=65536?new Uint16Array(r):new Uint32Array(r);let a=0;return t.forEachComponentRange(((t,o)=>{const i=n[t],r=n[o];for(let n=i;n<r;n++)s[a++]=e?e[n]:n;return!0})),s}addComponentHighlight(e,t,o){const n=e.components;let i=n.highlightCounts,r=n.highlightGroups;null!=i&&null!=r||(i=new Uint32Array(n.count+1),n.highlightCounts=i,r=new Array(n.count+1),n.highlightGroups=r),r[t]=o;0===i[t]++&&(n.highlightsDirty(),this._notifyDirty()),i[n.count]++}removeComponentHighlight(e,t){const o=e.components,n=o.highlightCounts;if(null==n)return void T().warn("Removing non-existing highlight.");const i=n[t];if(0===i)return void T().warn("Removing non-existing highlight.");const r=n[o.count];if(i>1)return n[t]=i-1,void(n[o.count]=r-1);n[t]=0,o.highlightsDirty(),this._notifyDirty(),1===r?(o.highlightCounts=null,o.highlightGroups=null):n[o.count]=r-1}clearHighlights(e){const t=e.components;null!=t.highlightCounts&&(t.highlightCounts=null,t.highlightGroups=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,n=e.geometry,i=n.vertices.layoutParameters,r=P.createVertex(o,L.STATIC_DRAW,n.vertices.data),s=n.indices?P.createIndex(o,L.STATIC_DRAW,n.indices):null,a=p(_(i)),l=new Uint16Array(n.vertices.count);for(let p=0;p<t.count;p++){const e=t.offsets[p],o=t.offsets[p+1],i=t.materialDataIndices[p];if(null!=n.indices)for(let t=e;t<o;t++){l[n.indices[t]]=i}else for(let t=e;t<o;t++)l[t]=i}const c=P.createVertex(o,L.STATIC_DRAW,l.buffer),m=new O(e.transform,e.toMapSpace),f=new U(o,A,{data:a,componentIndices:k},{data:r,componentIndices:c},s),h=new v(f,N.TRIANGLES,i,null!=s),u={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new y(m,h,u)}_notifyDirty(){this._renderManager.notifyDirty()}}const k=p(u().u16(E.COMPONENTINDEX));function q(e,t){return e===t?w.All:0===e?w.None:w.Some}const W=r();export{G as ComponentObjectCollection};
5
+ import has from"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isArray as o}from"../../../../../core/typedArrayUtil.js";import{a as n}from"../../../../../chunks/vec32.js";import{clone as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as s}from"../../../../../geometry/support/Indices.js";import{c as a}from"../../../../../chunks/vec3.js";import{c as l}from"../../../../../chunks/vec33.js";import{ViewingMode as c}from"../../../../ViewingMode.js";import{ColorMixModeEnum as m,encodeSymbolColor as f}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as p}from"../../../support/buffer/glUtil.js";import{newLayout as u}from"../../../support/buffer/InterleavedLayout.js";import d from"./ComponentData.js";import{ComponentObject as g}from"./ComponentObject.js";import{IntersectionGeometry as b}from"./IntersectionGeometry.js";import{Renderable as y}from"./Renderable.js";import{RenderGeometry as v}from"./RenderGeometry.js";import{RenderSubmitSystem as C}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as _}from"./SourceGeometry.js";import{UniformComponentParameters as M}from"./UniformComponentParameters.js";import{ComponentParametersVarying as j,ComponentParametersUniform as w,ComponentParameterSummary as x,ComponentMaterial as O}from"./Material/ComponentMaterial.js";import{attributeLocations as A}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as R}from"./Material/shader/ComponentData.glsl.js";import{getVisibility as D,updateVisibilityWithCount as I}from"../../lib/ComponentUtils.js";import{assert as S}from"../../lib/Util.js";import{VertexAttribute as E}from"../../lib/VertexAttribute.js";import{getVerticalOffsetI3S as V}from"../../lib/verticalOffsetUtils.js";import{BufferManager as B}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as P}from"../../../../webgl/BufferObject.js";import{Usage as L,PrimitiveType as N}from"../../../../webgl/enums.js";import{VertexArrayObject as U}from"../../../../webgl/VertexArrayObject.js";const T=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class G{constructor(e,o){this._renderManager=e,this._viewingMode=o,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._visible=new t,this._hidden=new t,this._renderSubmit=new C(this),this._renderManager.register(this._renderSubmit),this._hasObjectAndLayerId=has("enable-feature:objectAndLayerId-rendering"),this._componentBufferManager=new B(e.rctx,2+(this._hasObjectAndLayerId?1:0))}destroy(){S(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._visible.forAll((e=>e.destroy())),this._hidden.forAll((e=>e.destroy())),this._visible.clear(),this._hidden.clear()}createObject(e){const t=e.geometry,o=new d(this._componentBufferManager,s(t.componentOffsets)),n=this._createRenderable(e,o),i=new b(this._viewingMode,t.positionData,o),r=new g(e.transform,e.toMapSpace,e.obb.clone(),o,n,i);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const o=e;t!==o.visible&&(t?(this._hidden.removeUnordered(o),this._visible.push(o)):(this._visible.removeUnordered(o),this._hidden.push(o)),o.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll((e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center)))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const o=e.renderable.material;t(o),o.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const o=e;o.components.visibility.reset(t),o.components.visibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.components.visibility.forEachComponent(t)}getComponentCount(e){const t=e,o=t.components.visibility.componentCount;return{visible:o,invisible:t.components.count-o}}setComponentData(e,t){const o=e,n=o.renderable.material,i=o.components,r=i.materialDataBuffer,s=i.materialDataIndices,a=new M,l=r.textureBuffer,c=new Uint8Array(4),p=new Uint32Array(c.buffer);let u=0,d=0,g=0,b=i.verticalOffsets,y=1/0,v=-1/0,C=!1,_=!1,O=0;for(let h=0;h<i.count;h++){t(h,a),u+=+(a.externalColor[3]<1),d+=+(a.externalColorMixMode===m.Replace&&1===a.externalColor[3]),g+=+a.castShadows,f(a.externalColor,a.externalColorMixMode,c),c[2]=254&c[2]|+a.castShadows,l.setData(s[h],0,c[0],c[1],c[2],c[3]),C||=h>0&&O!==p[0],O=p[0],_||=0!==a.elevationOffset,_&&null==b&&(b=new Array(h).fill(0)),null!=b&&(b[h]=a.elevationOffset),y=Math.min(y,a.elevationOffset),v=Math.max(v,a.elevationOffset),R(a.elevationOffset,c),l.setData(s[h],1,c[0],c[1],c[2],c[3]);const e=a.objectAndLayerIdColor;null!=e&&l.setData(s[h],2,e[0],e[1],e[2],e[3]),a.pickable!==D(i.pickability,h)&&(i.pickability=I(i.pickability,i.count,h,a.pickable))}i.verticalOffsets=_?b:null,o.offsetObb=_?h(o.obb,y,v,this._viewingMode,o.offsetObb??o.obb.clone()):null,C||_||this._hasObjectAndLayerId?(n.componentParameters=new j,n.componentParameters.castShadows=q(g,i.count),n.componentParameters.transparent=q(u,i.count),n.componentParameters.opaqueOverride=q(d,i.count),n.componentParameters.texture=l,l.updateTexture()):(n.componentParameters=new w,n.componentParameters.castShadows=a.castShadows?x.All:x.None,n.componentParameters.externalColor=a.externalColor,n.componentParameters.externalColorMixMode=a.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,o,n=!1){e.intersectionGeometry.getComponentAabb(t,o);const i=e,r=i.components.verticalOffsets;if(n||null==r)return o;const s=r[t];if(this._viewingMode===c.Local||0===s)return o[2]+=s,o[5]+=s,o;const a=V(s);return a.localOrigin=i.transform.position,a.applyToAabb(o)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,o){return e.intersectionGeometry.getComponentPositions(t,o)}expandRangeWithComponentObjectElevationRange(e,t,o,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const i=e,r=i.components,s=r.count,a=r.verticalOffsets,l=i.intersectionGeometry,m=this._viewingMode===c.Local,f=l.getComponentAabbs(),h=W;let p=1/0,u=-1/0;for(let c=0;c<s;c++){const e=6*c,r=a?.[c]??0;let s=1/0,l=-1/0;if(m)s=f[e+2]+r+t,l=f[e+5]+r+t;else{if(h[0]=f[e],h[1]=f[e+1],h[2]=f[e+2],h[3]=f[e+3],h[4]=f[e+4],h[5]=f[e+5],0!==r){const e=V(r);e.localOrigin=i.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+o;n.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-o)}n.expandElevationRangeValues(s,l),p=Math.min(p,s),u=Math.max(u,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=u}intersect(e,t,o,n,i,r,s){const a=e,{transform:l}=a,{position:c}=l;return null!=i&&(i.localOrigin=c),a.intersectionGeometry.intersect(t,o,n,i,a.components.verticalOffsets,l,r,s)}addEdges(e,t,o,n,i){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.components.offsets;return t.addComponentObject(r,a,s,l,o,n,i)}async extractEdgeInformation(e,t,o){const n=e,r=n.components.visibility;if(r.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:c}=n.intersectionGeometry,m=n.components.offsets,{EdgeInputBufferLayout:f}=await import("../../lib/edgeRendering/bufferLayouts.js"),h=f.createBuffer(c.length/3);l(h.position.typedBuffer,c,h.position.typedBufferStride,3),a(h.position,h.position,n.transform.rotationScale),this._setComponentIndices(h.componentIndex,s,m);const p=h.count,u=this._computeVisibilityIndices(s,r,m,p);return{origin:i(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:u,indicesLength:u.length,skipDeduplicate:!0,data:h,writerSettings:{reducedPrecision:!1,variants:0}},o)}}_setComponentIndices(e,t,o){let n=0;for(let i=0;i<o.length-1;i++){const r=o[i],s=o[i+1];for(let o=r;o<s;o++){const i=t?t[o]:o;e.set(i,n)}n++}}_computeVisibilityIndices(e,t,n,i){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange(((e,t)=>(r+=n[t]-n[e],!0)));const s=o(e)?new Array(r):2===e?.BYTES_PER_ELEMENT||i<=65536?new Uint16Array(r):new Uint32Array(r);let a=0;return t.forEachComponentRange(((t,o)=>{const i=n[t],r=n[o];for(let n=i;n<r;n++)s[a++]=e?e[n]:n;return!0})),s}addComponentHighlight(e,t,o){const n=e.components;let i=n.highlightCounts,r=n.highlightGroups;null!=i&&null!=r||(i=new Uint32Array(n.count+1),n.highlightCounts=i,r=new Array(n.count+1),n.highlightGroups=r),r[t]=o;0===i[t]++&&(n.highlightsDirty(),this._notifyDirty()),i[n.count]++}removeComponentHighlight(e,t){const o=e.components,n=o.highlightCounts;if(null==n)return void T().warn("Removing non-existing highlight.");const i=n[t];if(0===i)return void T().warn("Removing non-existing highlight.");const r=n[o.count];if(i>1)return n[t]=i-1,void(n[o.count]=r-1);n[t]=0,o.highlightsDirty(),this._notifyDirty(),1===r?(o.highlightCounts=null,o.highlightGroups=null):n[o.count]=r-1}clearHighlights(e){const t=e.components;null!=t.highlightCounts&&(t.highlightCounts=null,t.highlightGroups=null,t.highlightsDirty(),this._notifyDirty())}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const o=this._renderManager.rctx,n=e.geometry,i=n.vertices.layoutParameters,r=P.createVertex(o,L.STATIC_DRAW,n.vertices.data),s=n.indices?P.createIndex(o,L.STATIC_DRAW,n.indices):null,a=p(_(i)),l=new Uint16Array(n.vertices.count);for(let p=0;p<t.count;p++){const e=t.offsets[p],o=t.offsets[p+1],i=t.materialDataIndices[p];if(null!=n.indices)for(let t=e;t<o;t++){l[n.indices[t]]=i}else for(let t=e;t<o;t++)l[t]=i}const c=P.createVertex(o,L.STATIC_DRAW,l.buffer),m=new O(e.transform,e.toMapSpace),f=new U(o,A,new Map([["data",a],["componentIndices",k]]),new Map([["data",r],["componentIndices",c]]),s),h=new v(f,N.TRIANGLES,i,null!=s),u={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new y(m,h,u)}_notifyDirty(){this._renderManager.notifyDirty()}}const k=p(u().u16(E.COMPONENTINDEX));function q(e,t){return e===t?x.All:0===e?x.None:x.Some}const W=r();export{G as ComponentObjectCollection};
@@ -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{ColorFormat as e,DepthFormat as t}from"../../webgl/formats.js";import{ManagedColorAttachment as r}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthAttachment as a}from"../../webgl/ManagedDepthAttachment.js";import c from"../../webgl/ManagedFBO.js";import{AttachmentType as i}from"../../webgl/ManagedFBObject.js";import{FBOPool as h}from"./FBOPool.js";import{PixelFormat as o,SizedPixelFormat as s,TextureWrapMode as n,PixelType as _,TextureSamplingMode as d,RenderbufferFormat as l,ColorAttachment as m}from"../../../webgl/enums.js";import{FramebufferObject as p}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as u}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as w}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as E}from"../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../webgl/TextureDescriptor.js";class f{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new h(e.newCache,"FBOCache"),this._depthCache=new h(e.newCache,"DepthAttachmentCache"),this._colorCache=new h(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback&&this.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===i.FBO&&e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("getTexture"in t?t.getTexture()?.usedMemory??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(r,a,i,h=e.RGBA){const o=b(h,r,a);let s=this._cache.pop(o);if(s){s.retain(),s.setName(i);const e=this.rctx.getBoundFramebufferObject();this.rctx.bindFramebuffer(s.fbo),this.rctx.setDrawBuffers([m.COLOR_ATTACHMENT0]),this.rctx.bindFramebuffer(e)}else s=new c(o,i,new p(this.rctx,{...O[h],width:r,height:a}),(e=>{e??=t.DEPTH_STENCIL_TEXTURE;const r=this._acquireDepth(e,s.fbo.width,s.fbo.height,`${s.name} depth`);return s.attachDepth(r),r.release(),s}),((t,c)=>{c??=e.RGBA;const i=this._acquireColor(c,r,a,`${s.name} color ${t}`);return s.attachColor(i,t),i.release(),s}),(()=>{this.debugCallback&&this.debugCallback(s.name,s.fbo),this._acquired.delete(s),s.detachAll(),this._cache.put(s)}));return this._trackHandle(s)}acquireDepth(e,t,r,a){return this._acquireDepth(e,t,r,a)}_acquireDepth(e,r,c,i){const h=b(e,r,c),o=this._depthCache.pop(h);if(o)return o.retain(),o.name=i,this._trackHandle(o);const s=e===t.DEPTH_STENCIL_TEXTURE?new a(h,new E(this.rctx,{...N[e],width:r,height:c}),(()=>{this._acquired.delete(s),this._depthCache.put(s)})):new a(h,new u(this.rctx,{...N[e],width:r,height:c}),(()=>{this._acquired.delete(s),this._depthCache.put(s)}));return s.name=i,this._trackHandle(s)}_acquireColor(e,t,a,c){const i=b(e,t,a),h=this._colorCache.pop(i);if(h)return h.retain(),h.name=c,this._trackHandle(h);const o=new r(i,new E(this.rctx,{...O[e],width:t,height:a}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return o.name=c,this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}const T=new c("default","default",null,(()=>T),(()=>T),(()=>{}));function b(e,t,r){return`${e}x${t}x${r}`}const A=new C;A.pixelFormat=o.RED,A.internalFormat=s.R8,A.wrapMode=n.CLAMP_TO_EDGE;const g=new C;g.pixelFormat=o.RG,g.internalFormat=s.RG8,g.wrapMode=n.CLAMP_TO_EDGE;const M=new C;M.internalFormat=s.RGBA4,M.dataType=_.UNSIGNED_SHORT_4_4_4_4,M.wrapMode=n.CLAMP_TO_EDGE;const R=new C;R.wrapMode=n.CLAMP_TO_EDGE;const F=new C;F.wrapMode=n.CLAMP_TO_EDGE,F.samplingMode=d.LINEAR_MIPMAP_LINEAR,F.hasMipmap=!0,F.maxAnisotropy=8;const D=new C;D.pixelFormat=o.RED,D.dataType=_.HALF_FLOAT,D.internalFormat=s.R16F,D.samplingMode=d.NEAREST;const x=new C;x.dataType=_.HALF_FLOAT,x.internalFormat=s.RGBA16F,x.samplingMode=d.NEAREST;const O={[e.RED]:A,[e.RG]:g,[e.RGBA4]:M,[e.RGBA]:R,[e.RGBA_MIPMAP]:F,[e.R16F]:D,[e.RGBA16F]:x},G=new C;G.pixelFormat=o.DEPTH_STENCIL,G.dataType=_.UNSIGNED_INT_24_8,G.samplingMode=d.NEAREST,G.wrapMode=n.CLAMP_TO_EDGE,G.internalFormat=o.DEPTH24_STENCIL8;const N={[t.DEPTH_STENCIL_TEXTURE]:G,[t.DEPTH16_BUFFER]:new w(l.DEPTH_COMPONENT16,4)};export{f as FBOCache,T as defaultWebGLFBO};
5
+ import{ColorFormat as e,DepthFormat as t}from"../../webgl/formats.js";import{ManagedColorAttachment as r}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthAttachment as a}from"../../webgl/ManagedDepthAttachment.js";import c from"../../webgl/ManagedFBO.js";import{AttachmentType as i}from"../../webgl/ManagedFBObject.js";import{FBOPool as h}from"./FBOPool.js";import{PixelFormat as o,SizedPixelFormat as s,TextureWrapMode as n,PixelType as _,TextureSamplingMode as d,RenderbufferFormat as l,ColorAttachment as m}from"../../../webgl/enums.js";import{FramebufferObject as p}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as u}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as w}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as E}from"../../../webgl/Texture.js";import{TextureDescriptor as C}from"../../../webgl/TextureDescriptor.js";class f{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new h(e.newCache,"FBOCache"),this._depthCache=new h(e.newCache,"DepthAttachmentCache"),this._colorCache=new h(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback&&this.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===i.FBO&&e(t.name,t.fbo)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("getTexture"in t?t.getTexture()?.usedMemory??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(r,a,i,h=e.RGBA){const o=b(h,r,a);let s=this._cache.pop(o);if(s){s.retain(),s.setName(i);const e=this.rctx.getBoundFramebufferObject();this.rctx.bindFramebuffer(s.fbo),this.rctx.setDrawBuffers([m.COLOR_ATTACHMENT0]),this.rctx.bindFramebuffer(e)}else s=new c(o,i,new p(this.rctx,{...O[h],width:r,height:a}),(e=>{e??=t.DEPTH_STENCIL_TEXTURE;const r=this._acquireDepth(e,s.fbo.width,s.fbo.height,`${s.name} depth`);return s.attachDepth(r),r.release(),s}),((t,c)=>{c??=e.RGBA;const i=this._acquireColor(c,r,a,`${s.name} color ${t}`);return s.attachColor(i,t),i.release(),s}),(()=>{this.debugCallback&&this.debugCallback(s.name,s.fbo),this._acquired.delete(s),s.detachAll(),this._cache.put(s)}));return this._trackHandle(s)}acquireDepth(e,t,r,a){return this._acquireDepth(e,t,r,a)}_acquireDepth(e,r,c,i){const h=b(e,r,c),o=this._depthCache.pop(h);if(o)return o.retain(),o.name=i,this._trackHandle(o);const s=e===t.DEPTH_STENCIL_TEXTURE?new a(h,new E(this.rctx,{...N[e],width:r,height:c}),(()=>{this._acquired.delete(s),this._depthCache.put(s)})):new a(h,new u(this.rctx,{...N[e],width:r,height:c}),(()=>{this._acquired.delete(s),this._depthCache.put(s)}));return s.name=i,this._trackHandle(s)}_acquireColor(e,t,a,c){const i=b(e,t,a),h=this._colorCache.pop(i);if(h)return h.retain(),h.name=c,this._trackHandle(h);const o=new r(i,new E(this.rctx,{...O[e],width:t,height:a}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return o.name=c,this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}const T=new c("default","default",null,(()=>T),(()=>T),(()=>{}));function b(e,t,r){return`${e}x${t}x${r}`}T.release=()=>!1;const A=new C;A.pixelFormat=o.RED,A.internalFormat=s.R8,A.wrapMode=n.CLAMP_TO_EDGE;const g=new C;g.pixelFormat=o.RG,g.internalFormat=s.RG8,g.wrapMode=n.CLAMP_TO_EDGE;const M=new C;M.internalFormat=s.RGBA4,M.dataType=_.UNSIGNED_SHORT_4_4_4_4,M.wrapMode=n.CLAMP_TO_EDGE;const R=new C;R.wrapMode=n.CLAMP_TO_EDGE;const F=new C;F.wrapMode=n.CLAMP_TO_EDGE,F.samplingMode=d.LINEAR_MIPMAP_LINEAR,F.hasMipmap=!0,F.maxAnisotropy=8;const D=new C;D.pixelFormat=o.RED,D.dataType=_.HALF_FLOAT,D.internalFormat=s.R16F,D.samplingMode=d.NEAREST;const x=new C;x.dataType=_.HALF_FLOAT,x.internalFormat=s.RGBA16F,x.samplingMode=d.NEAREST;const O={[e.RED]:A,[e.RG]:g,[e.RGBA4]:M,[e.RGBA]:R,[e.RGBA_MIPMAP]:F,[e.R16F]:D,[e.RGBA16F]:x},G=new C;G.pixelFormat=o.DEPTH_STENCIL,G.dataType=_.UNSIGNED_INT_24_8,G.samplingMode=d.NEAREST,G.wrapMode=n.CLAMP_TO_EDGE,G.internalFormat=o.DEPTH24_STENCIL8;const N={[t.DEPTH_STENCIL_TEXTURE]:G,[t.DEPTH16_BUFFER]:new w(l.DEPTH_COMPONENT16,4)};export{f as FBOCache,T as defaultWebGLFBO};
@@ -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"../../../../../core/PooledArray.js";import{RenderPassIdentifier as t}from"./AllRenderPasses.js";import{TransparencyPassType as r}from"../../lib/TransparencyPassType.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class n{constructor(t,r,i=s.FrontToBack){this._rctx=t,this._techniques=r,this._sorting=i,this._draws=new e({initialSize:32,allocator:e=>e||{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(e,t,r,i,s){const n=this._draws.pushNew();n.geometry=t,n.geometryRanges=r,n.material=e,n.depthSquaredHint=i,n.indexType=(t.indexed?t.vao.indexBuffer.indexType:null)??0,n.highlightGroup=s}prepare(e,t){return this._draws.map((r=>r.material.prepareTechnique(this._techniques,e,t,r.geometry.parameters)))}dispatch(e,i,s){const n=this._rctx;this._previouslyBoundDraw.clear();let a=null;const h=this._draws.length;for(let l=0;l<h;l++){const h=this._draws.data[l];if(e.identifier===t.Highlight){const{highlightGroup:e}=h;if(void 0!==e){if((i.highlightGroupMap.get(e)??0)!==i.highlightLevel)continue}}const p=s[l];p===a&&p.configuration.transparencyPassType===r.NONE||(n.bindTechnique(p,i,e),a=p);const{geometryRanges:c,indexType:d,geometry:u,material:g}=h;n.bindVAO(u.vao),this._previouslyBoundDraw.get(p)!==g&&(p.program.bindDraw(g,i,e),this._previouslyBoundDraw.set(p,g));const m=c.length,{primitiveType:y}=u;for(let e=0;e<m;e+=2){const t=c[e],r=c[e+1];if(0!==d){const e=o.get(d);n.drawElements(y,r,d,t*e)}else n.drawArrays(y,t,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const i=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==i?i:t.geometry.vao.byteSize-r.geometry.vao.byteSize}))}get count(){return this._draws.length}}const o=new Map;o.set(i.UNSIGNED_BYTE,1),o.set(i.UNSIGNED_SHORT,2),o.set(i.UNSIGNED_INT,4);export{n as RenderPass,s as RenderPassSorting};
5
+ import e from"../../../../../core/PooledArray.js";import{RenderPassIdentifier as t}from"./AllRenderPasses.js";import{TransparencyPassType as r}from"../../lib/TransparencyPassType.js";import{DataType as i}from"../../../../webgl/enums.js";var s;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(s||(s={}));class n{constructor(t,r,i=s.FrontToBack){this._rctx=t,this._techniques=r,this._sorting=i,this._draws=new e({initialSize:32,allocator:e=>e||{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._previouslyBoundDraw=new Map}submitDraw(e,t,r,i,s){const n=this._draws.pushNew();n.geometry=t,n.geometryRanges=r,n.material=e,n.depthSquaredHint=i,n.indexType=(t.indexed?t.vao.indexBuffer.indexType:null)??0,n.highlightGroup=s}prepare(e,t){return this._draws.map((r=>r.material.prepareTechnique(this._techniques,e,t,r.geometry.parameters)))}dispatch(e,i,s){const n=this._rctx;this._previouslyBoundDraw.clear();let a=null;const h=this._draws.length;for(let l=0;l<h;l++){const h=this._draws.data[l];if(e.identifier===t.Highlight){const{highlightGroup:e}=h;if(void 0!==e){if((i.highlightGroupMap.get(e)??0)!==i.highlightLevel)continue}}const p=s[l];p===a&&p.configuration.transparencyPassType===r.NONE||(n.bindTechnique(p,i,e),a=p);const{geometryRanges:c,indexType:d,geometry:u,material:g}=h;n.bindVAO(u.vao),this._previouslyBoundDraw.get(p)!==g&&(p.program.bindDraw(i,e,g),this._previouslyBoundDraw.set(p,g));const m=c.length,{primitiveType:y}=u;for(let e=0;e<m;e+=2){const t=c[e],r=c[e+1];if(0!==d){const e=o.get(d);n.drawElements(y,r,d,t*e)}else n.drawArrays(y,t,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===s.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const i=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==i?i:t.geometry.vao.byteSize-r.geometry.vao.byteSize}))}get count(){return this._draws.length}}const o=new Map;o.set(i.UNSIGNED_BYTE,1),o.set(i.UNSIGNED_SHORT,2),o.set(i.UNSIGNED_INT,4);export{n as RenderPass,s as RenderPassSorting};
@@ -2,9 +2,7 @@
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{glsl as i}from"../shaderModules/interfaces.js";import{VertexAttribute as e}from"../../lib/VertexAttribute.js";function o(o,t=!0){o.attributes.add(e.POSITION,"vec2"),t&&o.varyings.add("uv","vec2"),o.vertex.code.add(i`
6
- void main(void) {
5
+ import{glsl as t}from"../shaderModules/interfaces.js";import{VertexAttribute as e}from"../../lib/VertexAttribute.js";function i(i,o=!0){i.attributes.add(e.POSITION,"vec2"),o&&i.varyings.add("uv","vec2"),i.vertex.main.add(t`
7
6
  gl_Position = vec4(position, 0.0, 1.0);
8
- ${t?i`uv = position * 0.5 + vec2(0.5);`:""}
9
- }
10
- `)}export{o as ScreenSpacePass};
7
+ ${o?t`uv = position * 0.5 + vec2(0.5);`:""}
8
+ `)}export{i as ScreenSpacePass};
@@ -2,9 +2,9 @@
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{translate as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as i,g as a,f as l,s as o}from"../../../../../chunks/vec32.js";import{ZEROS as c,create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3DrawUniform as t}from"../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as n}from"../shaderModules/Float3PassUniform.js";import{NoParameters as f,glsl as d}from"../shaderModules/interfaces.js";class u extends f{constructor(e){super(),this.slicePlaneLocalOrigin=e}}function _(e,s){m(e,s,new n("slicePlaneOrigin",((e,i)=>H(s,e,i))),new n("slicePlaneBasis1",((e,i)=>I(s,e,i,i.slicePlane?.basis1))),new n("slicePlaneBasis2",((e,i)=>I(s,e,i,i.slicePlane?.basis2))))}function P(e,s){m(e,s,new t("slicePlaneOrigin",((e,i)=>H(s,e,i))),new t("slicePlaneBasis1",((e,i)=>I(s,e,i,i.slicePlane?.basis1))),new t("slicePlaneBasis2",((e,i)=>I(s,e,i,i.slicePlane?.basis2))))}function m(e,s,...i){if(!s.hasSlicePlane){const i=d`#define rejectBySlice(_pos_) false
5
+ import{translate as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as i,g as a,f as l,s as o}from"../../../../../chunks/vec32.js";import{ZEROS as c,create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3DrawUniform as t}from"../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as n}from"../shaderModules/Float3PassUniform.js";import{NoParameters as f,glsl as d}from"../shaderModules/interfaces.js";class u extends f{constructor(e){super(),this.slicePlaneLocalOrigin=e}}function _(e,s){h(e,s,new n("slicePlaneOrigin",((e,i)=>g(s,e,i))),new n("slicePlaneBasis1",((e,i)=>I(s,e,i,i.slicePlane?.basis1))),new n("slicePlaneBasis2",((e,i)=>I(s,e,i,i.slicePlane?.basis2))))}function P(e,s){h(e,s,new t("slicePlaneOrigin",((e,i)=>g(s,e,i))),new t("slicePlaneBasis1",((e,i)=>I(s,e,i,i.slicePlane?.basis1))),new t("slicePlaneBasis2",((e,i)=>I(s,e,i,i.slicePlane?.basis2))))}function h(e,s,...i){if(!s.hasSlicePlane){const i=d`#define rejectBySlice(_pos_) false
6
6
  #define discardBySlice(_pos_) {}
7
- #define highlightSlice(_color_, _pos_) (_color_)`;return s.hasSliceInVertexProgram&&e.vertex.code.add(i),void e.fragment.code.add(i)}s.hasSliceInVertexProgram&&e.vertex.uniforms.add(...i),e.fragment.uniforms.add(...i);const a=d`struct SliceFactors {
7
+ #define highlightSlice(_color_, _pos_) (_color_)`;return s.hasSliceInVertexProgram&&e.vertex.code.add(i),void e.fragment.code.add(i)}const a=d`struct SliceFactors {
8
8
  float front;
9
9
  float side0;
10
10
  float side1;
@@ -62,4 +62,4 @@ return mix(color, vec4(HIGHLIGHT_COLOR.rgb, color.a), highlightFactor * HIGHLIGH
62
62
  }`,o=s.hasSliceHighlight?d`
63
63
  ${l}
64
64
  #define highlightSlice(_color_, _pos_) (sliceEnabled() ? applySliceHighlight(_color_, _pos_) : (_color_))
65
- `:d`#define highlightSlice(_color_, _pos_) (_color_)`;s.hasSliceInVertexProgram&&e.vertex.code.add(a),e.fragment.code.add(a),e.fragment.code.add(o)}function h(e,s,i){return e.instancedDoublePrecision?o(b,i.camera.viewInverseTransposeMatrix[3],i.camera.viewInverseTransposeMatrix[7],i.camera.viewInverseTransposeMatrix[11]):s.slicePlaneLocalOrigin}function p(e,s){return null!=e?l(v,s.origin,e):s.origin}function g(s,i,a){return s.hasSliceTranslatedView?null!=i?e(S,a.camera.viewMatrix,i):a.camera.viewMatrix:null}function H(e,s,a){if(null==a.slicePlane)return c;const l=h(e,s,a),o=p(l,a.slicePlane),r=g(e,l,a);return null!=r?i(v,o,r):o}function I(e,s,o,r){if(null==r||null==o.slicePlane)return c;const t=h(e,s,o),n=p(t,o.slicePlane),f=g(e,t,o);return null!=f?(a(B,r,n),i(v,n,f),i(B,B,f),l(B,B,v)):r}const b=r(),v=r(),B=r(),S=s();export{P as SliceDraw,_ as SlicePass,u as SlicePlaneParameters};
65
+ `:d`#define highlightSlice(_color_, _pos_) (_color_)`;s.hasSliceInVertexProgram&&e.vertex.uniforms.add(...i).code.add(a),e.fragment.uniforms.add(...i).code.add(a),e.fragment.code.add(o)}function m(e,s,i){return e.instancedDoublePrecision?o(b,i.camera.viewInverseTransposeMatrix[3],i.camera.viewInverseTransposeMatrix[7],i.camera.viewInverseTransposeMatrix[11]):s.slicePlaneLocalOrigin}function p(e,s){return null!=e?l(B,s.origin,e):s.origin}function H(s,i,a){return s.hasSliceTranslatedView?null!=i?e(S,a.camera.viewMatrix,i):a.camera.viewMatrix:null}function g(e,s,a){if(null==a.slicePlane)return c;const l=m(e,s,a),o=p(l,a.slicePlane),r=H(e,l,a);return null!=r?i(B,o,r):o}function I(e,s,o,r){if(null==r||null==o.slicePlane)return c;const t=m(e,s,o),n=p(t,o.slicePlane),f=H(e,t,o);return null!=f?(a(v,r,n),i(B,n,f),i(v,v,f),l(v,v,B)):r}const b=r(),B=r(),v=r(),S=s();export{P as SliceDraw,_ as SlicePass,u as SlicePlaneParameters};
@@ -2,73 +2,43 @@
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{addNearFar as o}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as e}from"../ShaderOutput.js";import{SliceDraw as r}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as t,NormalType as a}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as s}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as l}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as n}from"../output/OutputDepth.glsl.js";import{OutputHighlight as c}from"../output/OutputHighlight.glsl.js";import{VisualVariables as u}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as m}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as f}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as g}from"../../../lib/basicInterfaces.js";function x(x,h){const{vertex:j,fragment:O}=x,w=h.hasColorTexture&&h.alphaDiscardMode!==g.Opaque;switch(h.output){case e.Depth:v(j,h),x.include(i,h),x.include(r,h),x.include(d,h),w&&O.uniforms.add(new f("tex",(o=>o.texture))),j.code.add(m`void main(void) {
6
- vpos = getVertexInLocalOriginSpace();
5
+ import{addNearFar as r}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as e}from"../ShaderOutput.js";import{SliceDraw as o}from"../Slice.glsl.js";import{Transform as t}from"../Transform.glsl.js";import{NormalAttribute as i,NormalType as a}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as s}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as l}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as d}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as n}from"../output/OutputDepth.glsl.js";import{OutputHighlight as c}from"../output/OutputHighlight.glsl.js";import{VisualVariables as u}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as m}from"../util/View.glsl.js";import{glsl as v}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as f}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as g}from"../../../lib/basicInterfaces.js";function x(x,h){const{vertex:j,fragment:O}=x,w=h.hasColorTexture&&h.alphaDiscardMode!==g.Opaque;switch(h.output){case e.Depth:m(j,h),x.include(t,h),x.include(o,h),x.include(l,h),w&&O.uniforms.add(new f("tex",(r=>r.texture))),j.main.add(v`vpos = getVertexInLocalOriginSpace();
7
6
  vpos = subtractOrigin(vpos);
8
7
  vpos = addVerticalOffset(vpos, localOrigin);
9
8
  gl_Position = transformPosition(proj, view, vpos);
10
- forwardTextureCoordinates();
11
- }`),x.include(p,h),O.code.add(m`
12
- void main(void) {
13
- discardBySlice(vpos);
14
- ${w?m`
15
- vec4 texColor = texture(tex, ${h.hasColorTextureTransform?m`colorUV`:m`vuv0`});
16
- discardOrAdjustAlpha(texColor);`:""}
17
- }
18
- `);break;case e.Shadow:case e.ShadowHighlight:case e.ShadowExcludeHighlight:case e.ViewshedShadow:case e.ObjectAndLayerIdColor:v(j,h),x.include(i,h),x.include(d,h),x.include(u,h),x.include(n,h),x.include(r,h),x.include(s,h),o(x),x.varyings.add("depth","float"),w&&O.uniforms.add(new f("tex",(o=>o.texture))),j.code.add(m`void main(void) {
19
- vpos = getVertexInLocalOriginSpace();
9
+ forwardTextureCoordinates();`),x.include(p,h),O.main.add(v`
10
+ discardBySlice(vpos);
11
+ ${w?v`vec4 texColor = texture(tex, ${h.hasColorTextureTransform?"colorUV":"vuv0"});
12
+ discardOrAdjustAlpha(texColor);`:""}`);break;case e.Shadow:case e.ShadowHighlight:case e.ShadowExcludeHighlight:case e.ViewshedShadow:case e.ObjectAndLayerIdColor:m(j,h),x.include(t,h),x.include(l,h),x.include(u,h),x.include(n,h),x.include(o,h),x.include(s,h),r(x),x.varyings.add("depth","float"),w&&O.uniforms.add(new f("tex",(r=>r.texture))),j.main.add(v`vpos = getVertexInLocalOriginSpace();
20
13
  vpos = subtractOrigin(vpos);
21
14
  vpos = addVerticalOffset(vpos, localOrigin);
22
15
  gl_Position = transformPositionWithDepth(proj, view, vpos, nearFar, depth);
23
16
  forwardTextureCoordinates();
24
- forwardObjectAndLayerIdColor();
25
- }`),x.include(p,h),O.code.add(m`
26
- void main(void) {
27
- discardBySlice(vpos);
28
- ${w?m`
29
- vec4 texColor = texture(tex, ${h.hasColorTextureTransform?m`colorUV`:m`vuv0`});
30
- discardOrAdjustAlpha(texColor);`:""}
31
- ${h.output===e.ObjectAndLayerIdColor?m`outputObjectAndLayerIdColor();`:m`outputDepth(depth);`}
32
- }
33
- `);break;case e.Normal:{v(j,h),x.include(i,h),x.include(t,h),x.include(l,h),x.include(d,h),x.include(u,h),w&&O.uniforms.add(new f("tex",(o=>o.texture))),h.normalType===a.ScreenDerivative&&x.varyings.add("vPositionView","vec3");const o=h.normalType===a.Attribute||h.normalType===a.Compressed;j.code.add(m`
34
- void main(void) {
35
- vpos = getVertexInLocalOriginSpace();
36
-
37
- ${o?m`vNormalWorld = dpNormalView(vvLocalNormal(normalModel()));`:m`
38
- // Get vertex position in camera space for screen-space derivative normals
39
- vPositionView = (view * vec4(vpos, 1.0)).xyz;
40
- `}
41
- vpos = subtractOrigin(vpos);
42
- vpos = addVerticalOffset(vpos, localOrigin);
43
- gl_Position = transformPosition(proj, view, vpos);
44
- forwardTextureCoordinates();
45
- }
46
- `),x.include(r,h),x.include(p,h),O.code.add(m`
47
- void main() {
48
- discardBySlice(vpos);
49
- ${w?m`
50
- vec4 texColor = texture(tex, ${h.hasColorTextureTransform?m`colorUV`:m`vuv0`});
51
- discardOrAdjustAlpha(texColor);`:""}
17
+ forwardObjectAndLayerIdColor();`),x.include(p,h),O.main.add(v`
18
+ discardBySlice(vpos);
19
+ ${w?v`vec4 texColor = texture(tex, ${h.hasColorTextureTransform?"colorUV":"vuv0"});
20
+ discardOrAdjustAlpha(texColor);`:""}
21
+ ${h.output===e.ObjectAndLayerIdColor?v`outputObjectAndLayerIdColor();`:v`outputDepth(depth);`}`);break;case e.Normal:{m(j,h),x.include(t,h),x.include(i,h),x.include(d,h),x.include(l,h),x.include(u,h),w&&O.uniforms.add(new f("tex",(r=>r.texture))),h.normalType===a.ScreenDerivative&&x.varyings.add("vPositionView","vec3");const r=h.normalType===a.Attribute||h.normalType===a.Compressed;j.main.add(v`
22
+ vpos = getVertexInLocalOriginSpace();
23
+ ${r?v`vNormalWorld = dpNormalView(vvLocalNormal(normalModel()));`:v`vPositionView = (view * vec4(vpos, 1.0)).xyz;`}
24
+ vpos = subtractOrigin(vpos);
25
+ vpos = addVerticalOffset(vpos, localOrigin);
26
+ gl_Position = transformPosition(proj, view, vpos);
27
+ forwardTextureCoordinates();`),x.include(o,h),x.include(p,h),O.main.add(v`
28
+ discardBySlice(vpos);
29
+ ${w?v`vec4 texColor = texture(tex, ${h.hasColorTextureTransform?"colorUV":"vuv0"});
30
+ discardOrAdjustAlpha(texColor);`:""}
52
31
 
53
- ${h.normalType===a.ScreenDerivative?m`vec3 normal = screenDerivativeNormal(vPositionView);`:m`
54
- vec3 normal = normalize(vNormalWorld);
55
- if (gl_FrontFacing == false){
56
- normal = -normal;
57
- }`}
58
- fragColor = vec4(0.5 + 0.5 * normal, 1.0);
59
- }
60
- `);break}case e.Highlight:v(j,h),x.include(i,h),x.include(d,h),x.include(u,h),w&&O.uniforms.add(new f("tex",(o=>o.texture))),j.code.add(m`void main(void) {
61
- vpos = getVertexInLocalOriginSpace();
32
+ ${h.normalType===a.ScreenDerivative?v`vec3 normal = screenDerivativeNormal(vPositionView);`:v`vec3 normal = normalize(vNormalWorld);
33
+ if (gl_FrontFacing == false){
34
+ normal = -normal;
35
+ }`}
36
+ fragColor = vec4(0.5 + 0.5 * normal, 1.0);`);break}case e.Highlight:m(j,h),x.include(t,h),x.include(l,h),x.include(u,h),w&&O.uniforms.add(new f("tex",(r=>r.texture))),j.main.add(v`vpos = getVertexInLocalOriginSpace();
62
37
  vpos = subtractOrigin(vpos);
63
38
  vpos = addVerticalOffset(vpos, localOrigin);
64
39
  gl_Position = transformPosition(proj, view, vpos);
65
- forwardTextureCoordinates();
66
- }`),x.include(r,h),x.include(p,h),x.include(c,h),O.code.add(m`
67
- void main() {
68
- discardBySlice(vpos);
69
- ${w?m`
70
- vec4 texColor = texture(tex, ${h.hasColorTextureTransform?m`colorUV`:m`vuv0`});
71
- discardOrAdjustAlpha(texColor);`:""}
72
- outputHighlight();
73
- }
74
- `)}}export{x as DefaultMaterialAuxiliaryPasses};
40
+ forwardTextureCoordinates();`),x.include(o,h),x.include(p,h),x.include(c,h),O.main.add(v`
41
+ discardBySlice(vpos);
42
+ ${w?v`vec4 texColor = texture(tex, ${h.hasColorTextureTransform?"colorUV":"vuv0"});
43
+ discardOrAdjustAlpha(texColor);`:""}
44
+ outputHighlight();`)}}export{x as DefaultMaterialAuxiliaryPasses};
@@ -2,8 +2,7 @@
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{AlignPixel as e}from"./AlignPixel.glsl.js";import{multipassTerrainTest as o}from"../shading/MultipassTerrainTest.glsl.js";import{glsl as t}from"../../shaderModules/interfaces.js";function i(i,r){const{vertex:s,fragment:p}=i;s.include(e),r.multipassEnabled&&i.varyings.add("depth","float"),s.code.add(t`
6
- void main(void) {
5
+ import{AlignPixel as e}from"./AlignPixel.glsl.js";import{multipassTerrainTest as o}from"../shading/MultipassTerrainTest.glsl.js";import{glsl as t}from"../../shaderModules/interfaces.js";function r(r,i){const{vertex:s,fragment:p}=r;s.include(e),i.multipassEnabled&&r.varyings.add("depth","float"),s.main.add(t`
7
6
  vec4 posProjCenter;
8
7
  if (dot(position, position) > 0.0) {
9
8
  // Render single point to center of the pixel to avoid subpixel filtering to affect the marker color
@@ -11,7 +10,7 @@ import{AlignPixel as e}from"./AlignPixel.glsl.js";import{multipassTerrainTest as
11
10
  vec4 posProj = projectPositionHUD(projectAux);
12
11
  posProjCenter = alignToPixelCenter(posProj, viewport.zw);
13
12
 
14
- ${r.multipassEnabled?"depth = projectAux.posView.z;":""}
13
+ ${i.multipassEnabled?t`depth = projectAux.posView.z;`:""}
15
14
  vec3 vpos = projectAux.posModel;
16
15
  if (rejectBySlice(vpos)) {
17
16
  // Project out of clip space
@@ -25,13 +24,8 @@ import{AlignPixel as e}from"./AlignPixel.glsl.js";import{multipassTerrainTest as
25
24
 
26
25
  gl_Position = posProjCenter;
27
26
  gl_PointSize = 1.0;
28
- }
29
- `),i.include(o,r),p.code.add(t`
30
- void main() {
27
+ `),r.include(o,i),p.main.add(t`
31
28
  fragColor = vec4(1);
32
- ${r.multipassEnabled?t`
33
- if(terrainDepthTest(depth)) {
34
- fragColor.g = 0.5;
35
- }`:""}
36
- }
37
- `)}export{i as HUDOcclusionPass};
29
+ ${i.multipassEnabled?t`if(terrainDepthTest(depth)) {
30
+ fragColor.g = 0.5;
31
+ }`:""}`)}export{r as HUDOcclusionPass};
@@ -2,21 +2,21 @@
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{alphaCutoff as e}from"../util/AlphaCutoff.js";import{RgbaFloatEncoding as t}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as o,addPixelRatio as i}from"../util/View.glsl.js";import{Float4PassUniform as r}from"../../shaderModules/Float4PassUniform.js";import{FloatPassUniform as l}from"../../shaderModules/FloatPassUniform.js";import{glsl as a}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as p}from"../../shaderModules/Texture2DPassUniform.js";import{computeLongestPattern as s,computeTextureSize as n}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as d}from"../../../shaders/ensureColor4.js";function c(t,o){t.constants.add("stippleAlphaColorDiscard","float",e),t.constants.add("stippleAlphaHighlightDiscard","float",.5),o.stippleEnabled?f(t,o):m(t)}function f(e,s){const n=!(s.draped&&s.stipplePreferContinuous),{vertex:c,fragment:f}=e;f.include(t),s.draped||(o(c,s),c.uniforms.add(new l("worldToScreenPerDistanceRatio",((e,t)=>1/t.camera.perScreenPixelRatio))),c.code.add(a`float computeWorldToScreenRatio(vec3 segmentCenter) {
5
+ import{RgbaFloatEncoding as e}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as t,addPixelRatio as o}from"../util/View.glsl.js";import{Float4PassUniform as i}from"../../shaderModules/Float4PassUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as l}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as a}from"../../shaderModules/Texture2DPassUniform.js";import{computeLongestPattern as p,computeTextureSize as n}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as s}from"../../../shaders/ensureColor4.js";function d(e,t){t.stippleEnabled?c(e,t):f(e)}function c(p,n){const d=!(n.draped&&n.stipplePreferContinuous),{vertex:c,fragment:f}=p;f.include(e),n.draped||(t(c,n),c.uniforms.add(new r("worldToScreenPerDistanceRatio",((e,t)=>1/t.camera.perScreenPixelRatio))),c.code.add(l`float computeWorldToScreenRatio(vec3 segmentCenter) {
6
6
  float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
7
7
  return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
8
- }`)),e.varyings.add("vStippleDistance","float"),e.varyings.add("vStippleDistanceLimits","vec2"),e.varyings.add("vStipplePatternStretch","float"),c.code.add(a`
8
+ }`)),p.varyings.add("vStippleDistance","float"),p.varyings.add("vStippleDistanceLimits","vec2"),p.varyings.add("vStipplePatternStretch","float"),c.code.add(l`
9
9
  float discretizeWorldToScreenRatio(float worldToScreenRatio) {
10
- float step = ${h};
10
+ float step = ${u};
11
11
 
12
12
  float discreteWorldToScreenRatio = log(worldToScreenRatio);
13
13
  discreteWorldToScreenRatio = ceil(discreteWorldToScreenRatio / step) * step;
14
14
  discreteWorldToScreenRatio = exp(discreteWorldToScreenRatio);
15
15
  return discreteWorldToScreenRatio;
16
16
  }
17
- `),c.code.add(a`vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {`),c.code.add(a`
18
- if (segmentLengthPseudoScreen >= ${n?"patternLength":"1e4"}) {
19
- `),i(c),c.code.add(a`float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
17
+ `),c.code.add(l`vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {`),c.code.add(l`
18
+ if (segmentLengthPseudoScreen >= ${d?"patternLength":"1e4"}) {
19
+ `),o(c),c.code.add(l`float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
20
20
  float flooredRepetitions = max(1.0, floor(repetitions + 0.5));
21
21
  float segmentLengthScreenRounded = flooredRepetitions * patternLength;
22
22
  float stretch = repetitions / flooredRepetitions;
@@ -24,7 +24,7 @@ vStipplePatternStretch = max(0.75, stretch);
24
24
  return vec2(0.0, segmentLengthScreenRounded);
25
25
  }
26
26
  return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
27
- }`),f.uniforms.add(new p("stipplePatternTexture",(e=>e.stippleTexture)),new l("stipplePatternSDFNormalizer",(e=>S(e.stipplePattern))),new l("stipplePatternPixelSizeInv",(e=>1/u(e)))),f.code.add(a`float getStippleSDF(out bool isClamped) {
27
+ }`),f.uniforms.add(new a("stipplePatternTexture",(e=>e.stippleTexture)),new r("stipplePatternSDFNormalizer",(e=>m(e.stipplePattern))),new r("stipplePatternPixelSizeInv",(e=>1/S(e)))),f.code.add(l`float getStippleSDF(out bool isClamped) {
28
28
  float stippleDistanceClamped = clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y);
29
29
  vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
30
30
  isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
@@ -43,8 +43,8 @@ bool isClamped;
43
43
  float stippleSDF = getStippleSDF(isClamped);
44
44
  float antiAliasedResult = clamp(stippleSDF * vLineWidth + 0.5, 0.0, 1.0);
45
45
  return isClamped ? floor(antiAliasedResult + 0.5) : antiAliasedResult;
46
- }`),s.stippleOffColorEnabled?(f.uniforms.add(new r("stippleOffColor",(e=>d(e.stippleOffColor)))),f.code.add(a`#define discardByStippleAlpha(stippleAlpha, threshold) {}
47
- #define blendStipple(color, stippleAlpha) mix(color, stippleOffColor, stippleAlpha)`)):f.code.add(a`#define discardByStippleAlpha(stippleAlpha, threshold) if (stippleAlpha < threshold) { discard; }
48
- #define blendStipple(color, stippleAlpha) vec4(color.rgb, color.a * stippleAlpha)`)}function m(e){e.fragment.code.add(a`float getStippleAlpha() { return 1.0; }
46
+ }`),n.stippleOffColorEnabled?(f.uniforms.add(new i("stippleOffColor",(e=>s(e.stippleOffColor)))),f.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) {}
47
+ #define blendStipple(color, stippleAlpha) mix(color, stippleOffColor, stippleAlpha)`)):f.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) if (stippleAlpha < threshold) { discard; }
48
+ #define blendStipple(color, stippleAlpha) vec4(color.rgb, color.a * stippleAlpha)`)}function f(e){e.fragment.code.add(l`float getStippleAlpha() { return 1.0; }
49
49
  #define discardByStippleAlpha(_stippleAlpha_, _threshold_) {}
50
- #define blendStipple(color, _stippleAlpha_) color`)}function S(e){return e?(Math.floor(.5*(s(e)-1))+.5)/e.pixelRatio:1}function u(e){const t=e.stipplePattern;return t?n(e.stipplePattern)/t.pixelRatio:1}const h=a.float(.4);export{c as LineStipple,u as computePixelSize};
50
+ #define blendStipple(color, _stippleAlpha_) color`)}function m(e){return e?(Math.floor(.5*(p(e)-1))+.5)/e.pixelRatio:1}function S(e){const t=e.stipplePattern;return t?n(e.stipplePattern)/t.pixelRatio:1}const u=l.float(.4);export{d as LineStipple,S as computePixelSize};