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

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 (159) 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/3375de864347a847393d.js +1042 -0
  8. package/assets/esri/core/workers/chunks/543f9db420c99d429637.js +1 -0
  9. package/assets/esri/core/workers/chunks/{812e18c65aa6e398c338.js → 5b6c89dc41067d81c952.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{5089a12084a8a8fb93d8.js → 61e5179fb49866241128.js} +1 -1
  11. package/assets/esri/core/workers/chunks/632e3ba2b8a881df29a0.js +1 -0
  12. package/assets/esri/core/workers/chunks/{1cc4a89c96a36d6b3d52.js → 7767559d56d16b644655.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{43e83f4d827f59ff556a.js → 8087288f00dfdcc479b9.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{a5fbe1c95e49093e5af4.js → 8cce4b218568638e6e64.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{c7e2a97cb7bcd153bcef.js → 8e326def543268f8a08e.js} +1 -1
  16. package/assets/esri/core/workers/chunks/92cb45b18e151db007dc.js +1 -0
  17. package/assets/esri/core/workers/chunks/b2e8cc76381077b78d4c.js +1 -0
  18. package/assets/esri/core/workers/chunks/b6a8132708afcd988fa9.js +1 -0
  19. package/assets/esri/core/workers/chunks/{b4d850e82a8ae902d684.js → c44cc686774ff53c0a94.js} +1 -1
  20. package/assets/esri/core/workers/chunks/c52701477405c1fb2072.js +1 -0
  21. package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js → cfc2a1858a8bbb284979.js} +2 -2
  22. package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js.LICENSE.txt → cfc2a1858a8bbb284979.js.LICENSE.txt} +1 -1
  23. package/assets/esri/core/workers/chunks/d9863289c69d2550cd49.js +1 -0
  24. package/assets/esri/core/workers/chunks/e1f4df3a5b0b31521b3c.js +1 -0
  25. package/assets/esri/core/workers/chunks/{61505947371cebab9cbe.js → fdebfe55cd097714ec11.js} +1 -1
  26. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +13 -18
  27. package/assets/esri/themes/dark/main.css +1 -1
  28. package/assets/esri/themes/light/main.css +1 -1
  29. package/assets/esri/themes/light/view.css +1 -1
  30. package/chunks/AtmosphereCompositing.glsl.js +6 -9
  31. package/chunks/BlendLayers.glsl.js +1 -7
  32. package/chunks/BlendWeights.glsl.js +45 -51
  33. package/chunks/Blur.glsl.js +1 -3
  34. package/chunks/ChapmanAtmosphere.glsl.js +3 -8
  35. package/chunks/CheckerBoard.glsl.js +3 -9
  36. package/chunks/Clouds.glsl.js +21 -10
  37. package/chunks/CloudsComposition.glsl.js +3 -7
  38. package/chunks/ColorMaterial.glsl.js +3 -9
  39. package/chunks/ComponentShader.glsl.js +35 -50
  40. package/chunks/Compositing.glsl.js +5 -7
  41. package/chunks/DefaultMaterial.glsl.js +68 -73
  42. package/chunks/EdgeDetect.glsl.js +5 -10
  43. package/chunks/EdgeShader.glsl.js +37 -60
  44. package/chunks/Fog.glsl.js +4 -9
  45. package/chunks/HUDCompositing.glsl.js +1 -3
  46. package/chunks/HUDMaterial.glsl.js +8 -14
  47. package/chunks/Heatmap.glsl.js +4 -7
  48. package/chunks/HeatmapDensity.glsl.js +5 -11
  49. package/chunks/HighlightApply.glsl.js +133 -152
  50. package/chunks/HighlightDownsample.glsl.js +29 -32
  51. package/chunks/ImageMaterial.glsl.js +11 -21
  52. package/chunks/LaserlinePath.glsl.js +4 -9
  53. package/chunks/LineCallout.glsl.js +91 -108
  54. package/chunks/LineMarker.glsl.js +2 -8
  55. package/chunks/Magnifier.glsl.js +4 -9
  56. package/chunks/MeasurementArrow.glsl.js +9 -15
  57. package/chunks/NativeLine.glsl.js +8 -12
  58. package/chunks/NoiseTextureAtlas.glsl.js +89 -86
  59. package/chunks/OITCompositing.glsl.js +2 -3
  60. package/chunks/OverlayCompositing.glsl.js +2 -4
  61. package/chunks/Path.glsl.js +31 -55
  62. package/chunks/Pattern.glsl.js +16 -20
  63. package/chunks/PointRenderer.glsl.js +39 -48
  64. package/chunks/Precipitation.glsl.js +15 -27
  65. package/chunks/RasterColorizer.glsl.js +25 -33
  66. package/chunks/RealisticTree.glsl.js +53 -65
  67. package/chunks/SSAO.glsl.js +7 -10
  68. package/chunks/SSAOBlur.glsl.js +10 -14
  69. package/chunks/ShadedColorMaterial.glsl.js +12 -15
  70. package/chunks/ShadowCastAccumulate.glsl.js +2 -4
  71. package/chunks/ShadowCastVisualize.glsl.js +12 -19
  72. package/chunks/ShadowHighlight.glsl.js +46 -50
  73. package/chunks/SimpleAtmosphere.glsl.js +4 -13
  74. package/chunks/SlicePlaneMaterial.glsl.js +3 -7
  75. package/chunks/Stars.glsl.js +3 -7
  76. package/chunks/Terrain.glsl.js +20 -61
  77. package/chunks/TextureOnly.glsl.js +2 -4
  78. package/chunks/Viewshed.glsl.js +20 -38
  79. package/chunks/WaterSurface.glsl.js +34 -60
  80. package/core/workers/registry.js +1 -1
  81. package/interfaces.d.ts +34 -4
  82. package/layers/WCSLayer.js +1 -1
  83. package/layers/support/SubtypeSublayer.js +1 -1
  84. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  85. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  86. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  87. package/package.json +3 -3
  88. package/support/revision.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/ShaderBuilder2D.js +1 -1
  90. package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
  91. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
  92. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
  93. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  94. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  95. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  96. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  97. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  98. package/views/3d/layers/StreamLayerView3D.js +1 -1
  99. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  100. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  101. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +5 -0
  102. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +5 -0
  103. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +5 -0
  104. package/views/3d/layers/graphics/pipeline/PBFPointFeaturesView.js +5 -0
  105. package/views/3d/layers/graphics/pipeline/TestSymbol.js +5 -0
  106. package/views/3d/layers/graphics/pipeline/Tile.js +5 -0
  107. package/views/3d/layers/graphics/pipeline/Tile3DFetcher.js +5 -0
  108. package/views/3d/layers/graphics/pipeline/Tile3DProcessor.js +5 -0
  109. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  110. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  111. package/views/3d/layers/support/projectExtentUtils.js +1 -1
  112. package/views/3d/terrain/OverlayRenderer.js +1 -1
  113. package/views/3d/terrain/TerrainRenderer.js +1 -1
  114. package/views/3d/terrain/TileCompositor.js +1 -1
  115. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  116. package/views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js +3 -5
  117. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
  118. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +29 -59
  119. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -12
  120. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
  121. package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +6 -6
  122. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +2 -2
  123. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -4
  124. package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
  125. package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
  126. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  127. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  128. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  129. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  130. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  131. package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
  132. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  133. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  134. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  135. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  136. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  137. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  138. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  139. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  140. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  141. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  142. package/views/SceneView.js +1 -1
  143. package/views/webgl/RenderingContext.js +1 -1
  144. package/views/webgl/enums.js +1 -1
  145. package/views/webgl/heatmapTextureUtils.js +1 -1
  146. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  147. package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
  148. package/widgets/FeatureForm.js +1 -1
  149. package/widgets/OrientedImageryViewer/constants.js +1 -1
  150. package/widgets/OrientedImageryViewer.js +1 -1
  151. package/assets/esri/core/workers/chunks/0cb2eb96ffb1dbed00eb.js +0 -1
  152. package/assets/esri/core/workers/chunks/0d6ed27fc9948f4ea061.js +0 -1
  153. package/assets/esri/core/workers/chunks/225b947ba4b2fcfd5630.js +0 -1
  154. package/assets/esri/core/workers/chunks/7c7c3068da3bf7467685.js +0 -1
  155. package/assets/esri/core/workers/chunks/85e5cdd723f68dec8c25.js +0 -1
  156. package/assets/esri/core/workers/chunks/aed0db145187d9eb52f2.js +0 -51
  157. package/assets/esri/core/workers/chunks/cf9a32a03b3d3b66effb.js +0 -1
  158. package/assets/esri/core/workers/chunks/e840e54455eb500b501d.js +0 -1098
  159. 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{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as W}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as I}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as F}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as L}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as V}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as U}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as k}from"../webgl-engine/lib/TransparencyPassType.js";import{Update as H}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as B}from"../webgl-engine/lighting/Lightsources.js";import{O as z}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{ClearBufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends E{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new z,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[F.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[F.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new q(this._rctx,new L(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new W(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=F.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=k.NONE,this._bindParameters.updateLighting([new B(g(1,1,1))],0,0,H.Immediate),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,V)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=ie;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?F.DRAPED_WATER:F.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=ie),!this.renders(r.content))return this._renderContext.renderOccludedMask=I,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(K.COLOR_BUFFER_BIT));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,te[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(Y);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=I,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo?.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new re(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const a=new U;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],ee.prototype,"_techniques",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),e([c({readOnly:!0})],ee.prototype,"rendersOccludedDraped",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=A.OccludeAndTransparent;export{ee as OverlayRenderer,se as drapedZ,ie as overlayRenderOccludedFlag};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as a}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as h,on as d}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{ortho as p,fromTranslation as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{s as _}from"../../../chunks/vec32.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as f,DrapeSourceType as R,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayContent as v}from"./OverlayContent.js";import{OverlayRenderTargets as D}from"./OverlayRenderTargets.js";import S from"../webgl/RenderCamera.js";import{ShaderOutput as C}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as P}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as O}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as E}from"../webgl-engine/effects/RenderPlugin.js";import{GLMaterialRepository as W}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as M}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as A}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as q,defaultRenderOccludedMask as L}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as I}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as V}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as F}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as N}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as H}from"../webgl-engine/lib/TransparencyPassType.js";import{Update as U}from"../webgl-engine/lib/Update.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as z}from"../webgl-engine/lighting/Lightsources.js";import{O as B}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{FramebufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends E{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new B,this.hasHighlights=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new O,this._materials=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new S,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.produces=new Map([[I.DRAPED_MATERIAL,e=>e!==C.Highlight||this.hasHighlights],[I.DRAPED_WATER,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextures:t,stippleTextures:s,markerTextures:i}=r;this._techniques=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextures:s,markerTextures:i,waterTextures:t}),this._renderContext=new q(this._rctx,new V(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),h),n((()=>this.spatialReference),(e=>this._localOriginFactory=new M(e)),h),d((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materials=new W(r.textures,this._techniques,(()=>{this.notifyChange("rendersOccludedDraped"),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=I.DRAPED_MATERIAL,this._bindParameters.mainDepth=null,this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=H.NONE,this._bindParameters.updateLighting([new z(g(1,1,1))],0,0,U.Immediate),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._techniques=a(this._techniques),this.disposeOverlays()}get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materials(){return this._materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}renderNode(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),this._sortedRenderers.map((e=>e.drapeSource.layer)).filter((e=>!!e))}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,F)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(){this._renderTargets?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&l(e,(e=>e.drapeTargetType===f.WithoutRasterImage))}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===R.Features)),this._hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===R.RasterImage))):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new D(this.view._stage.renderer.fboCache),this._overlays=[new x,new x]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets=i(this._renderTargets),this.events.emit("textures-disposed")}getTexture(e){if(null!=e)return e===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource?this._renderTargets?.getTexture(v.Color):this._renderTargets?.getTexture(e)}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this.notifyChange("rendersOccludedDraped"),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccludedDraped(){const e=this._renderContext.renderOccludedMask;this._renderContext.renderOccludedMask=ie;const r=this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)));return this._renderContext.renderOccludedMask=e,r}renders(e){return b.OVERLAY_DRAW_DEBUG_TEXTURE&&e!==v.Occluded||this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext)))}get mode(){return this.isEmpty?P.Disabled:this._renderTargets?.getTexture(v.WaterNormal)?P.EnabledWithWater:this._renderTargets?.getTexture(v.Color)?P.Enabled:P.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawOverlays(e){if(this._overlays&&this._renderTargets){for(const e of this._overlays)this.longitudeCyclical?e.setupGeometryViewsCyclical(this.longitudeCyclical):e.setupGeometryViewsDirect();for(const r of this._renderTargets.targets){if(r.content===v.ColorNoRasterImage&&!this._needsColorWithoutRasterImage)continue;const t=this._drawTarget(w.INNER,r,e),s=this._drawTarget(w.OUTER,r,e);(t||s)&&r.fbo.generateMipMap()}}}_drawTarget(e,r,t){const s=this._overlays[e],i=s.canvasGeometries;if(0===i.numViews)return!1;const{alignPixelEnabled:a,contentPixelRatio:o}=t;this._screenToWorldRatio=o*s.mapUnitsPerPixel/this._bindParameters.overlayStretch;const n=r.output;if(this.isEmpty||n===C.Highlight&&!this.hasHighlights||n===C.Normal&&!this.hasWater||!s.hasSomeSizedView())return!1;const h=this._rctx;if(this._camera.pixelRatio=s.pixelRatio*o,this._renderContext.output=n,this._bindParameters.alignPixelEnabled=a,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=n===C.Normal?I.DRAPED_WATER:I.DRAPED_MATERIAL,r.content===v.Occluded&&(this._renderContext.renderOccludedMask=ie),!this.renders(r.content))return this._renderContext.renderOccludedMask=L,!1;const d=s.resolution;this._rctx.setViewport(e===w.INNER?0:d,0,d,d);const l=2*s.resolution,c=s.resolution,u=r.fbo;u.bind(h,l,c),e===w.INNER&&(h.setClearColor(0,0,0,0),h.clear(K.COLOR));if(b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.content!==v.Occluded)for(let p=0;p<i.numViews;p++)this._setViewParameters(i.extents[p],s),this._ensureDebugPatternResources(s.resolution,te[e]),this._rctx.bindTechnique(this._debugTextureTechnique,this._renderContext.bindParameters,this._passParameters),this._rctx.screen.draw();return this._sortedRenderers.forAll((({drapeSource:t,renderer:a})=>{if(r.content===v.ColorNoRasterImage&&t.drapeSourceType===R.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&n===C.Color?this.bindTemporaryFramebuffer(l,c):null;for(let e=0;e<i.numViews;e++)this._setViewParameters(i.extents[e],s),a.render(this._renderContext);if(d){u.bind(h,l,c),this._overlayParameters.texture=d.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const r=this.pluginContext.techniques.acquire(Y);this._rctx.bindTechnique(r,this._renderContext.bindParameters,this._overlayParameters),this._rctx.screen.draw(),r.release(),d.release()}})),h.bindFramebuffer(null),this._renderContext.renderOccludedMask=L,!0}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(e,r,"overlay tmp");return t.rctx.unbindTexture(s.fbo?.colorTexture),t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(K.COLOR),s}async reloadShaders(){await this._techniques.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:a}of this._sortedRenderers)i=a.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers,r=e.length;this._renderers.forEach(((t,s)=>{const i=e.indexOf(s.layer),a=i>=0,o=s.renderGroup??(a?T.MapLayer:T.ViewLayer),n=r*o+(a?i:0);this._sortedRenderers.push(new re(s,t,n))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=Math.floor(r/10),a=Math.floor(o/10);i<2||a<2||10*i>e-20||10*a>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&a?1&r^1&o?0:255:1&i^1&a?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const a=new k;a.hasAlpha=!0,this._debugTextureTechnique=this._techniques.acquire(N,a)}get test(){}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c()],ee.prototype,"_techniques",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),e([c({readOnly:!0})],ee.prototype,"rendersOccludedDraped",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=A.OccludeAndTransparent;export{ee as OverlayRenderer,se as drapedZ,ie as overlayRenderOccludedFlag};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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 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 y}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as T,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=y(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(T.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,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,y=m===_.Required||e.opacity<1||s!==d.Normal||t!==f.Composite,T=y?p.On:p.Off,C=this._getBlendLayersTechnique(s,t,m,T);c.setPipelineState(C.getPipeline());let q=null,B=null;y?(B=this.currentFBO(r),null==this._vtFBO&&(this._vtFBO=new u(this._rctx)),q=this._vtFBO.get(r),c.bindFramebuffer(q),this._clearCurrentFBO()):h&&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,T),h)}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
- 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,7 +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{ReadDepth as e}from"../output/ReadDepth.glsl.js";import{Float2PassUniform as o}from"../../shaderModules/Float2PassUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as a}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as i}from"../../shaderModules/Texture2DPassUniform.js";function d(d,n){const c=d.fragment;c.include(e),c.uniforms.add(new o("nearFar",((e,o)=>o.camera.nearFar))),c.uniforms.add(new i("depthMap",((e,o)=>o.depth?.attachment))),c.uniforms.add(new a("proj",((e,o)=>o.camera.projectionMatrix))),c.uniforms.add(new t("invResolutionHeight",((e,o)=>1/o.camera.height))),c.uniforms.add(new a("reprojectionMatrix",((e,o)=>o.ssr.reprojectionMatrix))),c.code.add(r`
5
+ import{ReadDepth as e}from"../output/ReadDepth.glsl.js";import{Float2PassUniform as o}from"../../shaderModules/Float2PassUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{glsl as r}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as a}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as i}from"../../shaderModules/Texture2DPassUniform.js";function d(d,n){const c=d.fragment;c.include(e),c.uniforms.add(new o("nearFar",((e,o)=>o.camera.nearFar)),new i("depthMap",((e,o)=>o.depth?.attachment)),new a("proj",((e,o)=>o.camera.projectionMatrix)),new t("invResolutionHeight",((e,o)=>1/o.camera.height)),new a("reprojectionMatrix",((e,o)=>o.ssr.reprojectionMatrix))).code.add(r`
6
6
  vec2 reprojectionCoordinate(vec3 projectionCoordinate)
7
7
  {
8
8
  vec4 zw = proj * vec4(0.0, 0.0, -projectionCoordinate.z, 1.0);
@@ -2,14 +2,14 @@
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{IDENTITY as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{TextureCoordinateAttributeType as e}from"../attributes/TextureCoordinateAttribute.glsl.js";import{glsl as o}from"../../shaderModules/interfaces.js";import{Matrix3PassUniform as a}from"../../shaderModules/Matrix3PassUniform.js";function t(e,t){t.hasColorTextureTransform?(e.vertex.uniforms.add(new a("colorTextureTransformMatrix",(e=>e.colorTextureTransformMatrix??r))),e.varyings.add("colorUV","vec2"),e.vertex.code.add(o`void forwardColorUV(){
5
+ import{IDENTITY as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{TextureCoordinateAttributeType as e}from"../attributes/TextureCoordinateAttribute.glsl.js";import{glsl as o}from"../../shaderModules/interfaces.js";import{Matrix3PassUniform as a}from"../../shaderModules/Matrix3PassUniform.js";function s(e,s){s.hasColorTextureTransform?(e.varyings.add("colorUV","vec2"),e.vertex.uniforms.add(new a("colorTextureTransformMatrix",(e=>e.colorTextureTransformMatrix??r))).code.add(o`void forwardColorUV(){
6
6
  colorUV = (colorTextureTransformMatrix * vec3(vuv0, 1.0)).xy;
7
- }`)):e.vertex.code.add(o`void forwardColorUV(){}`)}function s(t,s){s.hasNormalTextureTransform&&s.textureCoordinateType!==e.None?(t.vertex.uniforms.add(new a("normalTextureTransformMatrix",(e=>e.normalTextureTransformMatrix??r))),t.varyings.add("normalUV","vec2"),t.vertex.code.add(o`void forwardNormalUV(){
7
+ }`)):e.vertex.code.add(o`void forwardColorUV(){}`)}function i(s,i){i.hasNormalTextureTransform&&i.textureCoordinateType!==e.None?(s.varyings.add("normalUV","vec2"),s.vertex.uniforms.add(new a("normalTextureTransformMatrix",(e=>e.normalTextureTransformMatrix??r))).code.add(o`void forwardNormalUV(){
8
8
  normalUV = (normalTextureTransformMatrix * vec3(vuv0, 1.0)).xy;
9
- }`)):t.vertex.code.add(o`void forwardNormalUV(){}`)}function i(t,s){s.hasEmissionTextureTransform&&s.textureCoordinateType!==e.None?(t.vertex.uniforms.add(new a("emissiveTextureTransformMatrix",(e=>e.emissiveTextureTransformMatrix??r))),t.varyings.add("emissiveUV","vec2"),t.vertex.code.add(o`void forwardEmissiveUV(){
9
+ }`)):s.vertex.code.add(o`void forwardNormalUV(){}`)}function t(s,i){i.hasEmissionTextureTransform&&i.textureCoordinateType!==e.None?(s.varyings.add("emissiveUV","vec2"),s.vertex.uniforms.add(new a("emissiveTextureTransformMatrix",(e=>e.emissiveTextureTransformMatrix??r))).code.add(o`void forwardEmissiveUV(){
10
10
  emissiveUV = (emissiveTextureTransformMatrix * vec3(vuv0, 1.0)).xy;
11
- }`)):t.vertex.code.add(o`void forwardEmissiveUV(){}`)}function d(t,s){s.hasOcclusionTextureTransform&&s.textureCoordinateType!==e.None?(t.vertex.uniforms.add(new a("occlusionTextureTransformMatrix",(e=>e.occlusionTextureTransformMatrix??r))),t.varyings.add("occlusionUV","vec2"),t.vertex.code.add(o`void forwardOcclusionUV(){
11
+ }`)):s.vertex.code.add(o`void forwardEmissiveUV(){}`)}function d(s,i){i.hasOcclusionTextureTransform&&i.textureCoordinateType!==e.None?(s.varyings.add("occlusionUV","vec2"),s.vertex.uniforms.add(new a("occlusionTextureTransformMatrix",(e=>e.occlusionTextureTransformMatrix??r))).code.add(o`void forwardOcclusionUV(){
12
12
  occlusionUV = (occlusionTextureTransformMatrix * vec3(vuv0, 1.0)).xy;
13
- }`)):t.vertex.code.add(o`void forwardOcclusionUV(){}`)}function n(t,s){s.hasMetallicRoughnessTextureTransform&&s.textureCoordinateType!==e.None?(t.vertex.uniforms.add(new a("metallicRoughnessTextureTransformMatrix",(e=>e.metallicRoughnessTextureTransformMatrix??r))),t.varyings.add("metallicRoughnessUV","vec2"),t.vertex.code.add(o`void forwardMetallicRoughnessUV(){
13
+ }`)):s.vertex.code.add(o`void forwardOcclusionUV(){}`)}function n(s,i){i.hasMetallicRoughnessTextureTransform&&i.textureCoordinateType!==e.None?(s.varyings.add("metallicRoughnessUV","vec2"),s.vertex.uniforms.add(new a("metallicRoughnessTextureTransformMatrix",(e=>e.metallicRoughnessTextureTransformMatrix??r))).code.add(o`void forwardMetallicRoughnessUV(){
14
14
  metallicRoughnessUV = (metallicRoughnessTextureTransformMatrix * vec3(vuv0, 1.0)).xy;
15
- }`)):t.vertex.code.add(o`void forwardMetallicRoughnessUV(){}`)}export{t as colorTextureUV,i as emissiveTextureUV,n as metallicRoughnessTextureUV,s as normalTextureUV,d as occlusionTextureUV};
15
+ }`)):s.vertex.code.add(o`void forwardMetallicRoughnessUV(){}`)}export{s as colorTextureUV,t as emissiveTextureUV,n as metallicRoughnessTextureUV,i as normalTextureUV,d as occlusionTextureUV};
@@ -2,7 +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{FoamColor as e}from"./FoamRendering.glsl.js";import{Gamma as o}from"./Gamma.glsl.js";import{PhysicallyBasedRenderingWater as r}from"./PhysicallyBasedRendering.glsl.js";import{distanceFadeStart as t,distanceFadeEnd as i}from"./ScreenSpaceConstants.js";import{ScreenSpaceReflections as a}from"./ScreenSpaceReflections.glsl.js";import{CloudsParallaxShading as l}from"../util/CloudsParallaxShading.glsl.js";import{FloatPassUniform as n}from"../../shaderModules/FloatPassUniform.js";import{glsl as d}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as c}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as s}from"../../shaderModules/Texture2DPassUniform.js";function f(f,m){f.include(r,m),f.include(o),f.include(e),m.hasCloudsReflections&&f.include(l,m),m.hasScreenSpaceReflections&&f.include(a,m);const v=f.fragment;v.constants.add("fresnelSky","vec3",[.02,1,15]).add("fresnelMaterial","vec2",[.02,.1]).add("roughness","float",.015).add("foamIntensityExternal","float",1.7).add("ssrIntensity","float",.65).add("ssrHeightFadeStart","float",t).add("ssrHeightFadeEnd","float",i).add("waterDiffusion","float",.92).add("waterSeaColorMod","float",.8).add("correctionViewingPowerFactor","float",.4).add("skyZenitColor","vec3",[.52,.68,.9]).add("skyColor","vec3",[.67,.79,.9]).add("cloudFresnelModifier","vec2",[1.2,.01]),v.code.add(d`PBRShadingWater shadingInfo;
5
+ import{FoamColor as e}from"./FoamRendering.glsl.js";import{Gamma as o}from"./Gamma.glsl.js";import{PhysicallyBasedRenderingWater as r}from"./PhysicallyBasedRendering.glsl.js";import{distanceFadeStart as t,distanceFadeEnd as i}from"./ScreenSpaceConstants.js";import{ScreenSpaceReflections as a}from"./ScreenSpaceReflections.glsl.js";import{CloudsParallaxShading as l}from"../util/CloudsParallaxShading.glsl.js";import{FloatPassUniform as n}from"../../shaderModules/FloatPassUniform.js";import{glsl as d}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as c}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as s}from"../../shaderModules/Texture2DPassUniform.js";function f(f,m){f.include(r,m),f.include(o),f.include(e),m.hasCloudsReflections&&f.include(l),m.hasScreenSpaceReflections&&f.include(a,m);const v=f.fragment;v.constants.add("fresnelSky","vec3",[.02,1,15]).add("fresnelMaterial","vec2",[.02,.1]).add("roughness","float",.015).add("foamIntensityExternal","float",1.7).add("ssrIntensity","float",.65).add("ssrHeightFadeStart","float",t).add("ssrHeightFadeEnd","float",i).add("waterDiffusion","float",.92).add("waterSeaColorMod","float",.8).add("correctionViewingPowerFactor","float",.4).add("skyZenitColor","vec3",[.52,.68,.9]).add("skyColor","vec3",[.67,.79,.9]).add("cloudFresnelModifier","vec2",[1.2,.01]),v.code.add(d`PBRShadingWater shadingInfo;
6
6
  vec3 getSkyGradientColor(in float cosTheta, in vec3 horizon, in vec3 zenit) {
7
7
  float exponent = pow((1.0 - cosTheta), fresnelSky[2]);
8
8
  return mix(zenit, horizon, exponent);
@@ -44,7 +44,7 @@ vec3 reflectedWorld = normalize(reflect(-v, normalCorrectedClouds));`),m.hasClou
44
44
  cloudsColor.a = 1.0 - cloudsColor.a;
45
45
  cloudsColor = pow(cloudsColor, vec4(GAMMA));
46
46
  cloudsColor *= clamp(fresnelModifier.y * cloudFresnelModifier[0] - cloudFresnelModifier[1], 0.0, 1.0) * clamp((1.0 - totalFadeInOut), 0.0, 1.0);`),m.hasScreenSpaceReflections?(v.uniforms.add(new c("view",((e,o)=>o.camera.viewMatrix)),new s("lastFrameColorTexture",((e,o)=>o.ssr.lastFrameColor?.getTexture())),new n("fadeFactorSSR",((e,o)=>o.ssr.fadeFactor))),v.code.add(d`vec3 viewDir = normalize(viewPosition);
47
- vec4 viewNormalVectorCoordinate = view *vec4(n, 0.0);
47
+ vec4 viewNormalVectorCoordinate = view * vec4(n, 0.0);
48
48
  vec3 viewNormal = normalize(viewNormalVectorCoordinate.xyz);
49
49
  vec4 viewUp = view * vec4(localUp, 0.0);
50
50
  vec3 viewNormalCorrectedSSR = mix(viewUp.xyz, viewNormal, correctionViewingFactor);
@@ -2,8 +2,6 @@
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{ZEROS as s}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{Float2PassUniform as e}from"../../shaderModules/Float2PassUniform.js";import{FloatPassUniform as o}from"../../shaderModules/FloatPassUniform.js";import{NoParameters as t,glsl as r}from"../../shaderModules/interfaces.js";import{VertexAttribute as i}from"../../../lib/VertexAttribute.js";class a extends t{constructor(){super(...arguments),this.scale=1,this.offset=s}}function d(s){s.attributes.add(i.POSITION,"vec2"),s.attributes.add(i.UV0,"vec2"),s.varyings.add("uv","vec2"),s.varyings.add("vuv","vec2"),s.vertex.uniforms.add(new o("scale",(s=>s.scale)),new e("offset",(s=>s.offset))).code.add(r`void main(void) {
6
- gl_Position = vec4(position, 0.0, 1.0);
5
+ import{ZEROS as s}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{Float2PassUniform as e}from"../../shaderModules/Float2PassUniform.js";import{FloatPassUniform as t}from"../../shaderModules/FloatPassUniform.js";import{NoParameters as o,glsl as r}from"../../shaderModules/interfaces.js";import{VertexAttribute as a}from"../../../lib/VertexAttribute.js";class i extends o{constructor(){super(...arguments),this.scale=1,this.offset=s}}function f(s){s.attributes.add(a.POSITION,"vec2"),s.attributes.add(a.UV0,"vec2"),s.varyings.add("uv","vec2"),s.varyings.add("vuv","vec2"),s.vertex.uniforms.add(new t("scale",(s=>s.scale)),new e("offset",(s=>s.offset))),s.vertex.main.add(r`gl_Position = vec4(position, 0.0, 1.0);
7
6
  uv = uv0 * scale + offset;
8
- vuv = uv0;
9
- }`)}export{d as TileComposite,a as TileCompositePassParameters};
7
+ vuv = uv0;`)}export{f as TileComposite,i as TileCompositePassParameters};
@@ -2,7 +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{translate as r,invertOrIdentity as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{zeros as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{CameraSpace as t}from"./CameraSpace.glsl.js";import{NoParameters as a,glsl as c}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as s}from"../../shaderModules/Matrix4PassUniform.js";class m extends a{constructor(){super(...arguments),this.localOrigin=i()}}function n(i){i.include(t),i.fragment.uniforms.add(new s("inverseViewMatrix",((i,t)=>{const a=o();return r(a,t.camera.viewMatrix,i.localOrigin),e(a,a)}))),i.fragment.code.add(c`vec4 reconstructLocalPosition(vec2 coord, float linearDepth) {
5
+ import{translate as r,invertOrIdentity as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{zeros as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{CameraSpace as t}from"./CameraSpace.glsl.js";import{NoParameters as a,glsl as c}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as s}from"../../shaderModules/Matrix4PassUniform.js";class m extends a{constructor(){super(...arguments),this.localOrigin=i()}}function n(i){i.include(t),i.fragment.uniforms.add(new s("inverseViewMatrix",((i,t)=>{const a=r(o(),t.camera.viewMatrix,i.localOrigin);return e(a,a)}))).code.add(c`vec4 reconstructLocalPosition(vec2 coord, float linearDepth) {
6
6
  vec4 cameraSpace = vec4(reconstructPosition(coord, linearDepth), 1.0);
7
7
  return inverseViewMatrix * cameraSpace;
8
- }`)}export{n as LocalFromScreenSpace,m as LocalFromScreenSpacePassParameters};
8
+ }`)}export{m as LocalFromScreenSpacePassParameters,n as localFromScreenSpace};
@@ -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/Error.js";import"../../../../../core/has.js";import t from"../../../../../core/Logger.js";import{BindType as r}from"../shaderTechnique/BindType.js";import{assert as n}from"../../lib/Util.js";const s=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class i{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class o extends i{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.constants=new d,this.outputs=new l}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e){const t=this.extensions.generateSource(e),r=this.attributes.generateSource(e),n=this.varyings.generateSource(e),s="vertex"===e?this.vertex:this.fragment,i=s.uniforms.generateSource(),o=s.code.generateSource(),a="vertex"===e?f:g,c=this.constants.generateSource().concat(s.constants.generateSource()),u=this.outputs.generateSource(e);return`#version 300 es\n${t.join("\n")}\n\n${a}\n\n${c.join("\n")}\n\n${i.join("\n")}\n\n${r.join("\n")}\n\n${n.join("\n")}\n\n${u.join("\n")}\n\n${o.join("\n")}`}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let o=0;o<s;++o)n[o](e,t,r,i)}}}class a{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else s().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class c{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class u extends i{constructor(){super(...arguments),this.uniforms=new a(this),this.code=new c(this),this.constants=new d}get builder(){return this}}class h{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class m{constructor(){this._entries=new Map}add(e,t){this._entries.has(e)&&n(this._entries.get(e)===t),this._entries.set(e,t)}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push("vertex"===e?`out ${r} ${n};`:`in ${r} ${n};`))),t}}class _{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?_.ALLOWLIST_VERTEX:_.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}}_.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],_.ALLOWLIST_VERTEX=[];class l{constructor(){this._entries=new Map}add(e,t,r=0){const s=this._entries.get(r);s?n(s.name===e&&s.type===t,`Fragment shader output location ${r} occupied`):this._entries.set(r,{name:e,type:t})}generateSource(e){if("vertex"===e)return[];0===this._entries.size&&this._entries.set(0,{name:l.DEFAULT_NAME,type:l.DEFAULT_TYPE});const t=new Array;return this._entries.forEach(((e,r)=>t.push(`layout(location = ${r}) out ${e.type} ${e.name};`))),t}}l.DEFAULT_TYPE="vec4",l.DEFAULT_NAME="fragColor";class d{constructor(){this._entries=new Set}add(e,t,r){let n="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":n=d._numberToFloatStr(r);break;case"int":n=d._numberToIntStr(r);break;case"bool":n=r.toString();break;case"vec2":n=`vec2(${d._numberToFloatStr(r[0])}, ${d._numberToFloatStr(r[1])})`;break;case"vec3":n=`vec3(${d._numberToFloatStr(r[0])}, ${d._numberToFloatStr(r[1])}, ${d._numberToFloatStr(r[2])})`;break;case"vec4":n=`vec4(${d._numberToFloatStr(r[0])}, ${d._numberToFloatStr(r[1])}, ${d._numberToFloatStr(r[2])}, ${d._numberToFloatStr(r[3])})`;break;case"ivec2":n=`ivec2(${d._numberToIntStr(r[0])}, ${d._numberToIntStr(r[1])})`;break;case"ivec3":n=`ivec3(${d._numberToIntStr(r[0])}, ${d._numberToIntStr(r[1])}, ${d._numberToIntStr(r[2])})`;break;case"ivec4":n=`ivec4(${d._numberToIntStr(r[0])}, ${d._numberToIntStr(r[1])}, ${d._numberToIntStr(r[2])}, ${d._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${t}(${Array.prototype.map.call(r,(e=>d._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${n};`),this}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const g="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif",f="precision highp float;\nprecision highp sampler2D;";export{c as Code,i as Includes,o as ShaderBuilder,u as Stage,a as Uniforms};
5
+ import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import t from"../../../../../core/Logger.js";import{BindType as r}from"../shaderTechnique/BindType.js";import{assert as n}from"../../lib/Util.js";const s=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class i{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class o extends i{constructor(){super(...arguments),this.vertex=new m,this.fragment=new m,this.attributes=new _,this.varyings=new d,this.extensions=new l,this.constants=new f,this.outputs=new g}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e){const t=this.extensions.generateSource(e),r=this.attributes.generateSource(e),n=this.varyings.generateSource(e),s="vertex"===e?this.vertex:this.fragment,i=s.uniforms.generateSource(),o=s.code.generateSource(),a=s.main.generateSource(),u="vertex"===e?p:S,c=this.constants.generateSource().concat(s.constants.generateSource()),h=this.outputs.generateSource(e);return`#version 300 es\n${t.join("\n")}\n\n${u}\n\n${c.join("\n")}\n\n${i.join("\n")}\n\n${r.join("\n")}\n\n${n.join("\n")}\n\n${h.join("\n")}\n\n${o.join("\n")}\n\n${a.join("\n")}`}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let o=0;o<s;++o)n[o](e,i,t,r)}}}class a{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else s().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class u{constructor(e){this.out=e}}class c{constructor(e){this._stage=e,this._entry=null}add(e){return this._entry={header:{out:"void"},body:e},this._stage}addWithHeader(e,t){return this._entry={header:e,body:t},this._stage}generateSource(){return this._entry?[`void main() {\n ${this._entry.body||""} \n}`]:[]}}class h{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class m extends i{constructor(){super(...arguments),this.uniforms=new a(this),this.main=new c(this),this.code=new h(this),this.constants=new f}get builder(){return this}}class _{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class d{constructor(){this._entries=new Map}add(e,t){this._entries.has(e)&&n(this._entries.get(e)===t),this._entries.set(e,t)}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push("vertex"===e?`out ${r} ${n};`:`in ${r} ${n};`))),t}}class l{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?l.ALLOWLIST_VERTEX:l.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}}l.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],l.ALLOWLIST_VERTEX=[];class g{constructor(){this._entries=new Map}add(e,t,r=0){const s=this._entries.get(r);s?n(s.name===e&&s.type===t,`Fragment shader output location ${r} occupied`):this._entries.set(r,{name:e,type:t})}generateSource(e){if("vertex"===e)return[];0===this._entries.size&&this._entries.set(0,{name:g.DEFAULT_NAME,type:g.DEFAULT_TYPE});const t=new Array;return this._entries.forEach(((e,r)=>t.push(`layout(location = ${r}) out ${e.type} ${e.name};`))),t}}g.DEFAULT_TYPE="vec4",g.DEFAULT_NAME="fragColor";class f{constructor(){this._entries=new Set}add(e,t,r){let n="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":n=f._numberToFloatStr(r);break;case"int":n=f._numberToIntStr(r);break;case"bool":n=r.toString();break;case"vec2":n=`vec2(${f._numberToFloatStr(r[0])}, ${f._numberToFloatStr(r[1])})`;break;case"vec3":n=`vec3(${f._numberToFloatStr(r[0])}, ${f._numberToFloatStr(r[1])}, ${f._numberToFloatStr(r[2])})`;break;case"vec4":n=`vec4(${f._numberToFloatStr(r[0])}, ${f._numberToFloatStr(r[1])}, ${f._numberToFloatStr(r[2])}, ${f._numberToFloatStr(r[3])})`;break;case"ivec2":n=`ivec2(${f._numberToIntStr(r[0])}, ${f._numberToIntStr(r[1])})`;break;case"ivec3":n=`ivec3(${f._numberToIntStr(r[0])}, ${f._numberToIntStr(r[1])}, ${f._numberToIntStr(r[2])})`;break;case"ivec4":n=`ivec4(${f._numberToIntStr(r[0])}, ${f._numberToIntStr(r[1])}, ${f._numberToIntStr(r[2])}, ${f._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${t}(${Array.prototype.map.call(r,(e=>f._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${n};`),this}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const S="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif",p="precision highp float;\nprecision highp sampler2D;";export{h as Code,i as Includes,c as Main,u as MainHeader,o as ShaderBuilder,m as Stage,a as Uniforms};