@arcgis/core 5.1.0-next.35 → 5.1.0-next.37

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 (206) hide show
  1. package/applications/Components/analysisUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{e09722903e63f6cc2540.js → 03894992558d063d0d5e.js} +1 -1
  4. package/assets/esri/core/workers/chunks/13838b6c045425e73cf8.js +1 -0
  5. package/assets/esri/core/workers/chunks/1d54b71c43d9d6a5f713.js +1 -0
  6. package/assets/esri/core/workers/chunks/29ff5325e604dd0adc37.js +1 -0
  7. package/assets/esri/core/workers/chunks/34f79355145c8e4c59dd.js +1 -0
  8. package/assets/esri/core/workers/chunks/3be111488365768fd917.js +1 -0
  9. package/assets/esri/core/workers/chunks/448620052233e51b496c.js +1 -0
  10. package/assets/esri/core/workers/chunks/{973e3743cb7fdaa27f80.js → 4e07827ab870c65377d3.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{2d49a611ad3441d7e759.js → 64450e280d602c5b0863.js} +5 -5
  12. package/assets/esri/core/workers/chunks/{eb811adbc5243d293ef5.js → 653d61aaaacb169b9418.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{64e1273e4e79c73ed579.js → 8346c342b822487a5477.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{a7a9716582b256d76e5b.js → 873c1b705ac3d4e6c384.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{527547fa10d52cb3a7b1.js → 888f6387e795d45a7ad3.js} +2 -2
  16. package/assets/esri/core/workers/chunks/{7c16493ea34c49a6291e.js → 8ed7ff651241f8adc4bf.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{bd902ae413887082b453.js → 9360a24ba765742f4e81.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{2128a66f522d15493ce2.js → 98a84dc2988297bd6ab1.js} +1 -1
  19. package/assets/esri/core/workers/chunks/b396b5186d618fad1cee.js +1 -0
  20. package/assets/esri/core/workers/chunks/{a35d1be700ebd3109397.js → b5403c8b5099179dc16d.js} +2 -2
  21. package/assets/esri/core/workers/chunks/{f5144e570952ca62a1b0.js → b98c24229463029504e8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{19955d064c17ba2fd9ad.js → ba4e018492bd3327cd95.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{0e78678281bcb888964d.js → c2e4cf3a277a6f40c7c2.js} +1 -1
  24. package/assets/esri/core/workers/chunks/d42d670edfae902c677b.js +2 -0
  25. package/assets/esri/core/workers/chunks/d6c2c9fedde498ad1a8c.js +2 -0
  26. package/assets/esri/core/workers/chunks/{e8ae71e482b8d5f54a72.js → dec51409372764e7093d.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{6f1c590abd0e3adeb8fc.js → e011318fb8f8e59bc1f1.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{b859d98fa1c39f8e4099.js → e0a63b5861e8c975097e.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{04094d576bfa11d90f73.js → ebcfc20c1d92d90bf661.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{2f20a21db44bd8448e9e.js → ecddd8c7593d3483ed09.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{eaeb95be8d4032513247.js → fbada7f029b293d934ac.js} +2 -2
  32. package/assets/esri/core/workers/chunks/{67de5225b2c66c9c7bc9.js → ffc87a038712a4c9d2cb.js} +1 -1
  33. package/chunks/ChapmanAtmosphere.glsl.js +4 -4
  34. package/chunks/Clouds.glsl.js +14 -14
  35. package/chunks/ComponentShader.glsl.js +1 -1
  36. package/chunks/DefaultMaterial.glsl.js +1 -1
  37. package/chunks/GaussianSplat.glsl.js +2 -2
  38. package/chunks/GeodeticDistanceCalculator-Ce-woMPw.js +1 -1
  39. package/chunks/GeodeticUtils.js +1 -1
  40. package/chunks/Haze.glsl.js +4 -4
  41. package/chunks/MultiPathImpl.js +1 -1
  42. package/chunks/NoiseTextureAtlas.glsl.js +34 -34
  43. package/chunks/OperatorGeodesicBuffer.js +1 -1
  44. package/chunks/OperatorGeodeticArea.js +1 -1
  45. package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
  46. package/chunks/OperatorGeodeticLength.js +1 -1
  47. package/chunks/OperatorProximityGeodesic.js +1 -1
  48. package/chunks/OperatorShapePreservingLength.js +1 -1
  49. package/chunks/OperatorShapePreservingProject.js +1 -1
  50. package/chunks/Path.glsl.js +2 -2
  51. package/chunks/Point2D.js +1 -1
  52. package/chunks/RealisticTree.glsl.js +1 -1
  53. package/chunks/SlicePlaneMaterial.glsl.js +6 -5
  54. package/chunks/SpatialReference.js +1 -1
  55. package/config.js +1 -1
  56. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  57. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  58. package/intl.js +1 -1
  59. package/kernel.js +1 -1
  60. package/layers/graphics/dehydratedPoint.js +1 -1
  61. package/layers/video/VideoController.js +1 -1
  62. package/package.json +4 -4
  63. package/support/revision.js +1 -1
  64. package/views/2d/layers/MediaLayerView2D.js +1 -1
  65. package/views/2d/layers/TileLayerView2D.js +1 -1
  66. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  67. package/views/3d/analysis/Dimension/DimensionController.js +1 -1
  68. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  69. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  70. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  71. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  72. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  73. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  74. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  75. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  76. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  77. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  78. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  79. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  80. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  81. package/views/3d/state/NearFarHeuristic.js +1 -1
  82. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  83. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  84. package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
  85. package/views/3d/webgl-engine/collections/Component/Material/ComponentShader.glsl.js +1 -1
  86. package/views/3d/{environment → webgl-engine/effects/atmosphere}/ChapmanApproximation.glsl.js +3 -3
  87. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.glsl.js +2 -0
  88. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +2 -0
  89. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphereTechnique.js +2 -0
  90. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphereTechniqueConfiguration.js +2 -0
  91. package/views/3d/{environment → webgl-engine/effects/atmosphere}/ChapmanRaymarching.glsl.js +5 -5
  92. package/views/3d/webgl-engine/effects/atmosphere/LocalAtmosphere.js +2 -0
  93. package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +2 -0
  94. package/views/3d/webgl-engine/effects/atmosphere/SimpleAtmosphere.glsl.js +2 -0
  95. package/views/3d/webgl-engine/effects/atmosphere/SimpleAtmosphereTechnique.js +2 -0
  96. package/views/3d/webgl-engine/effects/atmosphere/SimpleAtmosphereTechniqueConfiguration.js +2 -0
  97. package/views/3d/webgl-engine/effects/atmosphere/atmosphereUtils.js +2 -0
  98. package/views/3d/webgl-engine/effects/clouds/Clouds.glsl.js +2 -0
  99. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.glsl.js +2 -0
  100. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.js +2 -0
  101. package/views/3d/webgl-engine/effects/clouds/CloudsCompositionTechnique.js +2 -0
  102. package/views/3d/webgl-engine/effects/clouds/CloudsParameters.js +2 -0
  103. package/views/3d/webgl-engine/effects/clouds/CloudsRenderer.js +2 -0
  104. package/views/3d/webgl-engine/effects/clouds/CloudsTechnique.js +2 -0
  105. package/views/3d/webgl-engine/effects/clouds/CloudsTechniqueConfiguration.js +2 -0
  106. package/views/3d/webgl-engine/effects/clouds/NoiseTextureAtlas.glsl.js +2 -0
  107. package/views/3d/webgl-engine/effects/clouds/NoiseTextureAtlas.js +2 -0
  108. package/views/3d/webgl-engine/effects/clouds/NoiseTextureAtlasConfiguration.js +2 -0
  109. package/views/3d/webgl-engine/effects/clouds/NoiseTextureAtlasDimensions.js +2 -0
  110. package/views/3d/webgl-engine/effects/clouds/NoiseTextureAtlasTechnique.js +2 -0
  111. package/views/3d/webgl-engine/effects/fog/Fog.glsl.js +2 -0
  112. package/views/3d/webgl-engine/effects/fog/Fog.js +2 -0
  113. package/views/3d/webgl-engine/effects/fog/FogTechnique.js +2 -0
  114. package/views/3d/webgl-engine/effects/fog/FogTechniqueConfiguration.js +2 -0
  115. package/views/3d/webgl-engine/effects/haze/Haze.glsl.js +1 -1
  116. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  117. package/views/3d/webgl-engine/effects/precipitation/Precipitation.glsl.js +2 -0
  118. package/views/3d/webgl-engine/effects/precipitation/Precipitation.js +2 -0
  119. package/views/3d/webgl-engine/effects/precipitation/PrecipitationTechnique.js +2 -0
  120. package/views/3d/webgl-engine/effects/precipitation/PrecipitationTechniqueConfiguration.js +2 -0
  121. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  122. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  123. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  124. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  125. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  126. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  127. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  128. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  129. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  130. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  131. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  132. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  133. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  134. package/views/3d/webgl-engine/shaders/SlicePlaneMaterial.glsl.js +1 -1
  135. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechniqueConfiguration.js +2 -0
  136. package/views/VideoView.js +1 -1
  137. package/views/interactive/sketch/normalizedPoint.js +1 -1
  138. package/views/interactive/snapping/LineSnapper.js +1 -1
  139. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  140. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  141. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  142. package/views/interactive/snapping/SelfSnappingEngine.js +1 -1
  143. package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
  144. package/views/interactive/snapping/SnappingManager.js +1 -1
  145. package/views/interactive/snapping/candidates/dehydrated/DehydratedVertexSnappingCandidate.js +1 -1
  146. package/views/interactive/tooltip/infos/TooltipInfoWithCoordinates.js +1 -1
  147. package/views/support/MeasurementWorker.js +1 -1
  148. package/views/support/MeasurementWorkerHandle.js +1 -1
  149. package/views/support/measurementWorkerUtils.js +1 -1
  150. package/views/webgl/WebGLDriverTest.js +1 -1
  151. package/widgets/OrientedImageryViewer.js +1 -1
  152. package/assets/esri/core/workers/chunks/144acac9bb1aa78f1170.js +0 -1
  153. package/assets/esri/core/workers/chunks/4490f8eeeb2ee04daa9d.js +0 -2
  154. package/assets/esri/core/workers/chunks/63722607fbf8d411188d.js +0 -1
  155. package/assets/esri/core/workers/chunks/6ac84e6d33104e74398d.js +0 -1
  156. package/assets/esri/core/workers/chunks/a53979c45ee429e21b99.js +0 -2
  157. package/assets/esri/core/workers/chunks/b1ddc837a6805a09d0da.js +0 -1
  158. package/assets/esri/core/workers/chunks/ce3e192fbb53a9c6eb3b.js +0 -1
  159. package/assets/esri/core/workers/chunks/de5719ef663224860af5.js +0 -1
  160. package/assets/esri/core/workers/chunks/f7506c9d57b2ae0c5fd3.js +0 -1
  161. package/views/3d/environment/ChapmanAtmosphere.glsl.js +0 -2
  162. package/views/3d/environment/ChapmanAtmosphere.js +0 -2
  163. package/views/3d/environment/ChapmanAtmosphereTechnique.js +0 -2
  164. package/views/3d/environment/ChapmanAtmosphereTechniqueConfiguration.js +0 -2
  165. package/views/3d/environment/Clouds.glsl.js +0 -2
  166. package/views/3d/environment/CloudsComposition.glsl.js +0 -2
  167. package/views/3d/environment/CloudsComposition.js +0 -2
  168. package/views/3d/environment/CloudsCompositionTechnique.js +0 -2
  169. package/views/3d/environment/CloudsParameters.js +0 -2
  170. package/views/3d/environment/CloudsRenderer.js +0 -2
  171. package/views/3d/environment/CloudsTechnique.js +0 -2
  172. package/views/3d/environment/CloudsTechniqueConfiguration.js +0 -2
  173. package/views/3d/environment/Fog.glsl.js +0 -2
  174. package/views/3d/environment/Fog.js +0 -2
  175. package/views/3d/environment/FogTechnique.js +0 -2
  176. package/views/3d/environment/FogTechniqueConfiguration.js +0 -2
  177. package/views/3d/environment/LocalAtmosphere.js +0 -2
  178. package/views/3d/environment/MarsAtmosphere.js +0 -2
  179. package/views/3d/environment/NoiseTextureAtlas.glsl.js +0 -2
  180. package/views/3d/environment/NoiseTextureAtlas.js +0 -2
  181. package/views/3d/environment/NoiseTextureAtlasConfiguration.js +0 -2
  182. package/views/3d/environment/NoiseTextureAtlasDimensions.js +0 -2
  183. package/views/3d/environment/NoiseTextureAtlasTechnique.js +0 -2
  184. package/views/3d/environment/Precipitation.glsl.js +0 -2
  185. package/views/3d/environment/Precipitation.js +0 -2
  186. package/views/3d/environment/PrecipitationTechnique.js +0 -2
  187. package/views/3d/environment/PrecipitationTechniqueConfiguration.js +0 -2
  188. package/views/3d/environment/SimpleAtmosphere.glsl.js +0 -2
  189. package/views/3d/environment/SimpleAtmosphereTechnique.js +0 -2
  190. package/views/3d/environment/SimpleAtmosphereTechniqueConfiguration.js +0 -2
  191. package/views/3d/environment/atmosphereUtils.js +0 -2
  192. package/views/support/geodesicAreaMeasurementUtils.js +0 -2
  193. package/views/support/geodesicLengthMeasurementUtils.js +0 -2
  194. package/views/support/geodesicMeasurementUtils.js +0 -2
  195. package/views/webgl/AppleAmdDriverHelper.js +0 -2
  196. package/views/webgl/testAppleAmdDrawArrays.js +0 -2
  197. /package/assets/esri/core/workers/chunks/{4490f8eeeb2ee04daa9d.js.LICENSE.txt → 888f6387e795d45a7ad3.js.LICENSE.txt} +0 -0
  198. /package/assets/esri/core/workers/chunks/{a35d1be700ebd3109397.js.LICENSE.txt → b5403c8b5099179dc16d.js.LICENSE.txt} +0 -0
  199. /package/assets/esri/core/workers/chunks/{a53979c45ee429e21b99.js.LICENSE.txt → d42d670edfae902c677b.js.LICENSE.txt} +0 -0
  200. /package/assets/esri/core/workers/chunks/{527547fa10d52cb3a7b1.js.LICENSE.txt → d6c2c9fedde498ad1a8c.js.LICENSE.txt} +0 -0
  201. /package/assets/esri/core/workers/chunks/{eaeb95be8d4032513247.js.LICENSE.txt → fbada7f029b293d934ac.js.LICENSE.txt} +0 -0
  202. /package/views/3d/{environment/resources → webgl-engine/effects/atmosphere}/MarsAtmosphereTexture.js +0 -0
  203. /package/views/3d/{environment/resources → webgl-engine/effects/atmosphere}/SimpleAtmosphereTexture.js +0 -0
  204. /package/views/3d/{environment → webgl-engine/effects/clouds}/Clouds.js +0 -0
  205. /package/views/3d/{environment → webgl-engine/effects/clouds}/CloudsPresets.js +0 -0
  206. /package/views/3d/webgl-engine/effects/{weather → snowcover}/SnowCover.glsl.js +0 -0
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import"../../core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/PiUtils.glsl.js";import"../../core/shaderLibrary/util/CloudsParallaxShading.glsl.js";import"../../core/shaderLibrary/util/ColorConversion.glsl.js";import"../../core/shaderModules/Float3BindUniform.js";import"../../core/shaderModules/FloatBindUniform.js";import"../../core/shaderModules/glsl.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/CloudsComposition.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{OpaqueEnvironment as o}from"../OpaqueEnvironment.js";import{CloudsCompositionTechnique as n}from"./CloudsCompositionTechnique.js";import{createQuadVAO as a}from"../../lib/glUtil3D.js";import{ColorAttachment0 as m,PrimitiveType as d}from"../../../../webgl/enums.js";let h=class extends o{initialize(){this.addHandles([i(()=>null!=this.view.environment.weather&&this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),s)])}destroy(){this._vao=t(this._vao)}precompile(){this.bindParameters.clouds.data&&this.techniques.precompile(n)}render(e){const t=e.find(({name:e})=>e===this.produces),i=this.bindParameters.clouds;if(!i.data)return t;const s=this.techniques.getCompiled(n);if(!s)return this.requestRender(1),t;const r=this.renderingContext;this._vao??=a(r);const o=r.bindTechnique(s,this.bindParameters);return r.setDrawBuffers([m]),r.bindVAO(this._vao),o.assertCompatibleVertexAttributeLocations(this._vao),r.drawArrays(d.TRIANGLE_STRIP,0,4),i.isFading&&this.requestRender(2),t}};h=e([r("esri.views.3d.webgl-engine.effects.clouds.CloudsComposition")],h);export{h as CloudsComposition};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as r}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{C as i}from"../../../../../chunks/CloudsComposition.glsl.js";import{PrimitiveType as t}from"../../../../webgl/enums.js";import{makePipelineState as n,defaultColorWrite as l,separateBlendingParams as m}from"../../../../webgl/renderState.js";let p=class extends s{constructor(){super(...arguments),this.primitiveType=t.TRIANGLE_STRIP,this.shader=new r(i,()=>import("./CloudsComposition.glsl.js"))}initializePipeline(){return n({blending:m(1,0,770,1),depthTest:{func:515},colorWrite:l})}};p=e([o("esri.views.3d.webgl-engine.effects.clouds.CloudsCompositionTechnique")],p);export{p as CloudsCompositionTechnique};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{clamp as t}from"../../../../../core/mathUtils.js";import{signal as a}from"../../../../../core/signal.js";import{rotate as e}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as i}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{squaredLength as r,normalize as h,scale as o,copy as n,length as c,subtract as d}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,fromPoints as f,axis as p}from"../../../../../geometry/support/axisAngleDegrees.js";import{earth as m}from"../../../../../geometry/support/Ellipsoid.js";import{heightLimit as F}from"../../../environment/weather.js";import{ensureClouds as P}from"./Clouds.js";class x{constructor(){this.startTime=0,this._data=a(null),this.coverage=0,this.absorption=0,this._readChannels=0,this.parallax=new v,this.parallaxNew=new v,this._anchorPoint=l(),this._fadeState=a(0),this._fadeFactor=a(1)}get data(){return this._data.value}set data(t){this._data.value=t}get readChannels(){return this._readChannels}get fadeState(){return this._fadeState.value}get fadeFactor(){return this._fadeFactor.value}get opacity(){switch(this.fadeState){case 0:return 0;case 4:return 1-this.fadeFactor;case 1:return this.fadeFactor;case 2:case 3:return 1}}fade(a,e,s){this.isFading&&this.fadeFactor<1&&(this._fadeFactor.value=s?t((e-this.startTime)/(b*s),0,1):1,1===this.fadeFactor&&this._endFade()),this._evaluateState(a,e),this._updateParallax(a)}_evaluateState(t,a){const e=t.relativeElevation,s=this._updateAnchorPoint(t);(Math.abs(e)>1.7*F||s>j)&&this.opacity>0?this._startFade(0,a):this.isFading||(Math.abs(e)>F||s>C*j?this.opacity>0&&this._startFade(4,a):P(this.data)&&(0===this.opacity?this._startFade(1,a):2===this.data.state&&(2===this.fadeState?this._startFade(3,a):this._startFade(2,a))))}_updateParallax(t){const a=r(t.eye);this.parallax.radiusCurvatureCorrection=.84*Math.sqrt(Math.max(a-m.radius*m.radius,0))/Math.sqrt(a),f(g,this.parallax.anchorPoint,w),e(this.parallax.transform,s,w[3],p(w)),f(g,this.parallaxNew.anchorPoint,w),e(this.parallaxNew.transform,s,w[3],p(w))}_updateAnchorPoint(t){return h(this._anchorPoint,t.eye),o(this._anchorPoint,this._anchorPoint,m.radius),0===this.fadeState&&2===this.data?.state?(n(this.parallax.anchorPoint,this._anchorPoint),0):c(d(S,this.parallax.anchorPoint,this._anchorPoint))}requestFade(){this._fadeFactor.value=0}_startFade(t,a){switch(this._fadeState.value=t,this.startTime=a,t){case 3:this.requestFade(),this._switchReadChannels(),n(this.parallaxNew.anchorPoint,this._anchorPoint);break;case 1:this.requestFade(),this._switchReadChannels(),n(this.parallax.anchorPoint,this._anchorPoint),n(this.parallaxNew.anchorPoint,this._anchorPoint);break;case 4:this.requestFade();break;case 2:this._switchReadChannels(),n(this.parallax.anchorPoint,this._anchorPoint),n(this.parallaxNew.anchorPoint,this._anchorPoint),this._endFade();break;case 0:this._endFade()}}_endFade(){switch(this._fadeFactor.value=1,this.data&&2!==this.data.state&&(this.data.state=0),this.fadeState){case 3:n(this.parallax.anchorPoint,this.parallaxNew.anchorPoint),this._fadeState.value=2;break;case 1:this._fadeState.value=2;break;case 4:this._fadeState.value=0;break;case 2:case 0:break;default:this.fadeState}}_switchReadChannels(){2===this.data?.state&&(this._readChannels=1-this._readChannels,this.data.state=3)}get isFading(){return 4===this.fadeState||1===this.fadeState||3===this.fadeState}}class v{constructor(){this.anchorPoint=l(),this.radiusCurvatureCorrection=0,this.transform=i()}}const g=_(0,0,1),w=u(),S=l(),b=1.25,C=.5,j=2e5;export{x as CloudsParameters};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{lerp as s}from"../../../../../core/mathUtils.js";import{destroyMaybe as i,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as o,initial as a}from"../../../../../core/reactiveUtils.js";import{signal as h}from"../../../../../core/signal.js";import{property as n,subclass as l}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as c}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as u}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{equals as p,copy as m,set as f}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as _,ZEROS as g,zeros as x}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as y}from"../../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../../../geometry/ellipsoidUtils.js";import{C as v,c as S}from"../../../../../chunks/Clouds.glsl.js";import{cloudPresets as C}from"./CloudsPresets.js";import{CloudsTechnique as w}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as P}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as j}from"./NoiseTextureAtlas.js";import{TaskPriority as z}from"../../../../support/Scheduler.js";import{Yield as I}from"../../../../support/Yield.js";import{ColorAttachment0 as M}from"../../../../webgl/enums.js";import{FramebufferObject as H}from"../../../../webgl/FramebufferObject.js";import{TextureDescriptor as q}from"../../../../webgl/TextureDescriptor.js";let R=class extends t{constructor(e){super(e),this._state=h(0),this._passParameters=new v,this._weatherTileCount=128,this._sliceIndex=0,this._tileIndex=0,this._tilesPerSlice=1,this.coverage=s(C.default.coverage[0],C.default.coverage[1],.5),this.density=s(C.default.density[0],C.default.density[1],.5),this.absorption=s(C.default.absorption[0],C.default.absorption[1],.5),this.cloudSize=s(C.default.cloudSize[0],C.default.cloudSize[1],.5),this.detailSize=s(C.default.detailSize[0],C.default.detailSize[1],.5),this.smoothness=s(C.default.smoothness[0],C.default.smoothness[1],.5),this.cloudHeight=s(C.default.cloudHeight[0],C.default.cloudHeight[1],.5),this.raymarchingSteps=C.default.raymarchingSteps,this._viewMatrix=d(),this._dirty=!0,this.readyToRun=!0,this._configuration=new P}initialize(){const e=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*e.radius;const t=()=>this.setDirty();this.addHandles([this.view.resourceController.scheduler.registerTask(z.CLOUDS_GENERATOR,this),o(()=>this.coverage,t,a),o(()=>this.density,t,a),o(()=>this.absorption,t,a),o(()=>this.cloudSize,t,a),o(()=>this.detailSize,t,a),o(()=>this.smoothness,t,a),o(()=>this.cloudHeight,t,a),o(()=>this.raymarchingSteps,t,a)]);const s=_(this._computeWeatherTile());let i=0;this.addHandles(o(()=>{const e=this._computeWeatherTile();return p(s,e)||(++i,m(s,e)),i},t))}destroy(){this.destroyCubeMap(),this._passParameters.noiseTexture=i(this._passParameters.noiseTexture)}_precompile(){this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=1-this.parameters.readChannels,this.context.techniques.precompile(w,this._configuration)}_acquireTechnique(){switch(this.raymarchingSteps){case 0:this._tilesPerSlice=1;break;case 1:this._tilesPerSlice=4;break;case 3:case 2:this._tilesPerSlice=8;break;default:this.raymarchingSteps}return this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=1-this.parameters.readChannels,this.context.techniques.getCompiled(w,this._configuration)}_computeWeatherTile(){const{camera:e,environment:t}=this.view,{latitude:s,longitude:i}=e.position;if(null==s||null==i)return g;f(D,(s+90)/180,(i+180)/360);const r=Math.floor(this._weatherTileCount*Math.abs(2*D[0]-1));D[0]=Math.floor(2*this._weatherTileCount*D[0]),D[1]=Math.floor(4*(this._weatherTileCount-r)*D[1]);let o=0,a=0;if("virtual"!==t?.lighting?.type&&null!=t?.lighting?.date){const e=new Date(t.lighting.date);e.setUTCHours(t.lighting.date.getUTCHours()+(t.lighting.displayUTCOffset??0)),o=31*e.getUTCMonth()+e.getUTCDate(),a=e.getUTCFullYear()}return D[0]=(D[0]+o)%(2*this._weatherTileCount),D[1]=(D[1]+a%100)%(4*this._weatherTileCount),D}get state(){return this._state.value}set state(e){this._state.value=e}get usedMemory(){return(this._fbo?.usedMemory??0)+(this._passParameters.noiseTexture?.textureAtlas?.usedMemory??0)}_ensureNoiseTexture(){return this._passParameters.noiseTexture??=new j({context:this.context}),this._passParameters.noiseTexture}_ensureFrameBufferCube(e){const t=this.context.renderContext.rctx;if(null==this._fbo){const s=new q(e,e/2);s.target=35866,s.depth=6,s.wrapMode=33071,this._fbo=new H(t,s),this.parameters.data=this,this.parameters.absorption=this.absorption,this.parameters.coverage=this.coverage}return t.unbindTexture(this._fbo.colorTexture),this._fbo}get cubeMap(){return this._fbo}get parameters(){return this.context.renderContext.bind.clouds}destroyCubeMap(){this._fbo=r(this._fbo),this.parameters.data=null}applyPreset(e,t){const i=e.median,r=e=>{const r=s(e[0],e[1],i);return t<.5?s(e[0],r,2*t):s(r,e[1],2*(t-.5))};this.coverage=r(e.coverage),this.density=r(e.density),this.absorption=r(e.absorption),this.cloudSize=r(e.cloudSize),this.detailSize=r(e.detailSize),this.smoothness=r(e.smoothness),this.cloudHeight=r(e.cloudHeight),this.raymarchingSteps=e.raymarchingSteps}setDirty(){this._dirty=this.readyToRun=!0,this._precompile()}runTask(e){if(3===this.state)return I;this._dirty&&(this._sliceIndex=this._tileIndex=0,this.state=1,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._ensureNoiseTexture().updateWeatherMap(this._computeWeatherTile()),this._dirty=!1);const t=this._acquireTechnique();if(!this._ensureNoiseTexture().textureAtlas||!t)return I;const s=U[this._sliceIndex],i=O[this._sliceIndex];u(this._viewMatrix,k,s,i),c(this._passParameters.viewMatrix,this._viewMatrix);const r=this.context.renderContext.rctx,o=r.getViewport(),a=S/this._tilesPerSlice,h=this._tileIndex*a;r.setViewport(0,h,S,a);const n=this._ensureFrameBufferCube(S);r.bindFramebuffer(n),this._passParameters.lastSlice=5===this._sliceIndex,r.bindTechnique(t,this.context.renderContext.bind,this._passParameters);const l=35866;return n.setColorTextureTarget(l,M,this._sliceIndex),r.screen.draw(),r.gl.flush(),r.setViewport(o.x,o.y,o.width,o.height),this.requestRender(),++this._tileIndex,5===this._sliceIndex&&this._tileIndex===this._tilesPerSlice?(this._sliceIndex=this._tileIndex=0,this.state=2,this.readyToRun=!1):this._tileIndex===this._tilesPerSlice&&(++this._sliceIndex,this._tileIndex=0),e.madeProgress(),I}};e([n({constructOnly:!0})],R.prototype,"context",void 0),e([n({constructOnly:!0})],R.prototype,"view",void 0),e([n({constructOnly:!0})],R.prototype,"requestRender",void 0),e([n()],R.prototype,"coverage",void 0),e([n()],R.prototype,"density",void 0),e([n()],R.prototype,"absorption",void 0),e([n()],R.prototype,"cloudSize",void 0),e([n()],R.prototype,"detailSize",void 0),e([n()],R.prototype,"smoothness",void 0),e([n()],R.prototype,"cloudHeight",void 0),e([n()],R.prototype,"raymarchingSteps",void 0),e([n()],R.prototype,"readyToRun",void 0),R=e([l("esri.views.3d.webgl-engine.effects.clouds.CloudsRenderer")],R);const U=[y(1,0,0),y(-1,0,0),y(0,1,0),y(0,-1,0),y(0,0,1),y(0,0,1)],O=[y(0,0,-1),y(0,0,-1),y(0,0,-1),y(0,0,-1),y(0,1,0),y(0,1,0)],k=b(),D=x();export{R as CloudsRenderer};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as o}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as i}from"../../../../../chunks/Clouds.glsl.js";import{makePipelineState as t,defaultColorWrite as n,simpleBlendingParams as l}from"../../../../webgl/renderState.js";let c=class extends o{constructor(){super(...arguments),this.shader=new s(i,()=>import("./Clouds.glsl.js")),this.ignoreUnused=!0}initializePipeline(e){return t({blending:l(32769,32770,32774,0===e.writeTextureChannels?[1,1,0,0]:[0,0,1,1]),depthTest:{func:515},colorWrite:n})}};c=e([r("esri.views.3d.webgl-engine.effects.clouds.CloudsTechnique")],c);export{c as CloudsTechnique};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{parameter as t,ShaderTechniqueConfiguration as o}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";class r extends o{constructor(){super(...arguments),this.steps=0,this.writeTextureChannels=0}}e([t({count:3})],r.prototype,"steps",void 0),e([t({count:2})],r.prototype,"writeTextureChannels",void 0);export{r as CloudsTechniqueConfiguration};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderModules/Float2PassUniform.js";import"../../core/shaderModules/glsl.js";import"./NoiseTextureAtlasDimensions.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{N as NoiseTextureAtlasPassParameters,b as build}from"../../../../../chunks/NoiseTextureAtlas.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import{equals as i,copy as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{N as c}from"../../../../../chunks/NoiseTextureAtlas.glsl.js";import{NoiseTextureAtlasTechniqueConfiguration as a}from"./NoiseTextureAtlasConfiguration.js";import{atlasSize as u}from"./NoiseTextureAtlasDimensions.js";import{NoiseTextureAtlasTechnique as h}from"./NoiseTextureAtlasTechnique.js";import{FramebufferObject as m}from"../../../../webgl/FramebufferObject.js";import{TextureDescriptor as p}from"../../../../webgl/TextureDescriptor.js";let f=class extends t{constructor(e){super(e),this._passParameters=new c,this._configuration=new a,this._fbo=new m(e.context.renderContext.rctx,new p(u)),e.context.techniques.precompile(h,this._configuration)}get textureAtlas(){if(this._texture)return this._texture;const e=this.context.techniques.getCompiled(h,this._configuration);return e&&(this._texture=this._render(e)),this._texture}updateWeatherMap(e){i(this._passParameters.weatherTile,e)||(n(this._passParameters.weatherTile,e),this._configuration.mode=this._texture?1:0,this._texture=null,this.context.techniques.precompile(h,this._configuration))}destroy(){this._fbo=r(this._fbo)}_render(e){if(!this._fbo)return null;const t=this.context.renderContext.rctx,r=t.getViewport();return t.setViewport(0,0,u,u),t.bindFramebuffer(this._fbo),t.bindTechnique(e,this.context.renderContext.bind,this._passParameters),t.screen.draw(),t.setViewport(r.x,r.y,r.width,r.height),this._fbo.colorTexture}};e([o({constructOnly:!0})],f.prototype,"context",void 0),f=e([s("esri.views.3d.webgl-engine.effects.clouds.NoiseTextureAtlas")],f);export{f as NoiseTextureAtlas};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as o}from"tslib";import{parameter as e,ShaderTechniqueConfiguration as r}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";class t extends r{constructor(){super(...arguments),this.mode=0}}o([e({count:2})],t.prototype,"mode",void 0);export{t as NoiseTextureAtlasTechniqueConfiguration};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import has from"../../../../../core/has.js";const e=has("esri-mobile")?64:128,o=e/128,r=Math.ceil(Math.sqrt(e)),t=(e+2)*r,s=1e5,i=128,a=t/1560;export{t as atlasSize,o as textureScale,r as tileRows,e as tileSize,a as weatherMapScale,s as weatherMapSize,i as weatherTileSize};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as o}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as t}from"../../../../../chunks/NoiseTextureAtlas.glsl.js";import{makePipelineState as i,defaultColorWrite as l,copySource as c,separateBlendingParams as a}from"../../../../webgl/renderState.js";let n=class extends o{constructor(){super(...arguments),this.shader=new s(t,()=>import("./NoiseTextureAtlas.glsl.js"))}initializePipeline(e){return i({blending:0===e.mode?c:a(0,1,1,0),depthTest:{func:519},colorWrite:l})}};n=e([r("esri.views.3d.webgl-engine.effects.clouds.NoiseTextureAtlasTechnique")],n);export{n as NoiseTextureAtlasTechnique};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../../core/shaderLibrary/output/ReadDepth.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderModules/Float3PassUniform.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"../raymarching/RayDistanceFalloff.glsl.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{F as FogPassParameters,b as build}from"../../../../../chunks/Fog.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{lerp as t,smoothstep as s}from"../../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{watch as a,syncAndInitial as i}from"../../../../../core/reactiveUtils.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{copy as n,normalize as h,dot as m,scale as p,lerp as c,length as l}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as u}from"../../../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as f}from"../../../webgl.js";import{heightLimit as g}from"../../../environment/weather.js";import{TransparentEnvironment as P}from"../TransparentEnvironment.js";import{Blit as w}from"../blit/Blit.js";import{F as b}from"../../../../../chunks/Fog.glsl.js";import{FogTechnique as y}from"./FogTechnique.js";import{FogTechniqueConfiguration as v}from"./FogTechniqueConfiguration.js";import{ColorAttachment1 as j,DepthStencilAttachment as F,ColorAttachment0 as E}from"../../../../webgl/enums.js";const R=.95,q=1;let x=class extends P{constructor(e){super(e),this._configuration=new v,this._newParameters=new T,this._oldParameters=new T,this._fadedParameters=new T,this._parameters=this._newParameters,this._passParameters=new b,this._blit=null;const t=u(e.view.spatialReference);this._planetRadius=t.radius,this._atmosphereRadius=t.radius+t.atmosphereHeight}initialize(){this.addHandles([a(()=>this.view.environment.atmosphereEnabled,()=>this._updateEnabled(),i),a(()=>this.view.environment.weather,()=>this._updateEnabled(),i),a(()=>this._updateFogParameters(),()=>{},i)]),this.addHandles(a(()=>this._fadeFactor,e=>this._fade(e),i))}_updateEnabled(){this.view.environment.atmosphereEnabled&&this.view.environment.weather?this._enable():this._disable()}get _fadeFactor(){return this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1}_fade(e){const{_newParameters:t,_oldParameters:s}=this;e>=1?(this._parameters=t,this._oldParameters.copyFrom(this._newParameters)):e<=0?this._parameters=s:(this._fadedParameters.lerp(s,t,e),this._parameters=this._fadedParameters)}_updateFogParameters(){const e=this.view.environment.weather,s="foggy"===e.type||"snowy"===e.type||"rainy"===e.type;this._newParameters.strength="foggy"===e.type?t(3e-5,.005,e.fogStrength**3):"snowy"===e.type||"rainy"===e.type?t(4e-6,2e-4,(e.precipitation??0)**3):0,this._newParameters.amount=s?1:0,"foggy"!==e.type&&"snowy"!==e.type||n(this._newParameters.color,H),"rainy"===e.type&&n(this._newParameters.color,A),this._fadeFactor>=1&&this._oldParameters.copyFrom(this._newParameters),this.requestRender(2)}precompile(){this._parameters.amount>0&&(this._configuration.hasEmissive=this.bindParameters.hasEmission,this.techniques.precompile(y,this._configuration))}render(e){const t=e.find(({name:e})=>e===f.TRANSPARENT_ENVIRONMENT);if(0===this._parameters.amount)return t;if(this._update(),this._passParameters.amount<=0)return t;const s=t.getAttachment(j);this._configuration.hasEmissive=null!=s;const a=this.techniques.getCompiled(y,this._configuration);if(!a)return this.requestRender(1),t;const i=t.getAttachment(F),o=this.renderingContext,{fullWidth:n,fullHeight:h}=this.bindParameters.camera,m=n,p=h;return s&&(this._passParameters.emission=this.fboCache.acquire(m,p,"glow horizontal",8),this._blit??=new w(this.techniques),this._blit.blitTexture(o,s?.attachment,this.bindParameters,this._passParameters.emission)),t.attachDepth(null),o.bindFramebuffer(t.fbo),o.bindTechnique(a,this.bindParameters,this._passParameters),o.setDrawBuffers([E]),o.screen.draw(),t.attachDepth(i),this._passParameters.emission=r(this._passParameters.emission),t}_update(){const e=this.bindParameters.camera;h(C,e.eye);const t=Math.max(0,m(C,this.bindParameters.lighting.mainLight.direction)),r=this._parameters.color;p(N,r,.1),c(this._passParameters.color,N,r,t);const a=l(e.eye);this._passParameters.atmosphereC=a**2-this._atmosphereRadius**2,this._passParameters.amount=(1-s(R*g,q*g,Math.abs(a-this._planetRadius)))*this._parameters.amount,this._passParameters.strength=this._parameters.strength}get test(){return{parameters:this._passParameters}}};x=e([o("esri.views.3d.webgl-engine.effects.fog.Fog")],x);class T{constructor(){this.color=d(),this.strength=0,this.amount=0}copyFrom(e){this.amount=e.amount,this.strength=e.strength,n(this.color,e.color)}lerp(e,s,r){this.amount=t(e.amount,s.amount,r),this.strength=t(e.strength,s.strength,r),c(this.color,e.color,s.color,r)}}const C=d(),N=d(),A=_(.5,.5,.5),H=_(1.5,1.5,1.5);export{x as Fog,T as FogParameters};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as o}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as i}from"../../../../../chunks/Fog.glsl.js";import{makePipelineState as t,defaultColorWrite as c,separateBlendingParams as n}from"../../../../webgl/renderState.js";let l=class extends s{constructor(){super(...arguments),this.shader=new o(i,()=>import("./Fog.glsl.js"))}initializePipeline(){return t({blending:n(770,0,771,1),colorWrite:c})}};l=e([r("esri.views.3d.webgl-engine.effects.fog.FogTechnique")],l);export{l as FogTechnique};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as s}from"tslib";import{parameter as e,ShaderTechniqueConfiguration as i}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";class o extends i{constructor(){super(...arguments),this.hasEmissive=!1}}s([e()],o.prototype,"hasEmissive",void 0);export{o as FogTechniqueConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../../../environment/ChapmanApproximation.glsl.js";import"../../../environment/ChapmanRaymarching.glsl.js";import"../../core/shaderLibrary/output/ReadDepth.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../shaders/SphereIntersect.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/Haze.glsl.js";
2
+ import"../../core/shaderLibrary/output/ReadDepth.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../atmosphere/ChapmanApproximation.glsl.js";import"../atmosphere/ChapmanRaymarching.glsl.js";import"../../shaders/ScreenSpacePassAtmosphere.glsl.js";import"../../shaders/SphereIntersect.glsl.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/Haze.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ChapmanApproximationPassParameters as t}from"../../../environment/ChapmanApproximation.glsl.js";import{ReloadableShader as o}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{H as i}from"../../../../../chunks/Haze.glsl.js";import{Pos2TexF16 as n}from"../../lib/DefaultVertexBufferLayouts.js";import{PrimitiveType as a}from"../../../../webgl/enums.js";import{makePipelineState as m,defaultColorWrite as l,copySource as c,separateBlendingParams as p}from"../../../../webgl/renderState.js";class h extends t{constructor(){super(...arguments),this.hazeStrength=1}}let u=class extends s{constructor(e,r){super(e,r,n),this.shader=new o(i,()=>import("./Haze.glsl.js")),this.primitiveType=a.TRIANGLE_STRIP}initializePipeline(e){return e.reduced?m({blending:c,depthTest:{func:519},colorWrite:l}):m({blending:p(1,0,769,1),colorWrite:l})}};u=e([r("esri.views.3d.webgl-engine.effects.haze.HazeTechnique")],u);export{h as HazePassParameters,u as HazeTechnique};
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as t}from"../../core/shaderTechnique/ShaderTechnique.js";import{ChapmanApproximationPassParameters as o}from"../atmosphere/ChapmanApproximation.glsl.js";import{H as i}from"../../../../../chunks/Haze.glsl.js";import{Pos2TexF16 as a}from"../../lib/DefaultVertexBufferLayouts.js";import{PrimitiveType as n}from"../../../../webgl/enums.js";import{makePipelineState as m,defaultColorWrite as l,copySource as p,separateBlendingParams as c}from"../../../../webgl/renderState.js";class h extends o{constructor(){super(...arguments),this.hazeStrength=1}}let u=class extends t{constructor(e,r){super(e,r,a),this.shader=new s(i,()=>import("./Haze.glsl.js")),this.primitiveType=n.TRIANGLE_STRIP}initializePipeline(e){return e.reduced?m({blending:p,depthTest:{func:519},colorWrite:l}):m({blending:c(1,0,769,1),colorWrite:l})}};u=e([r("esri.views.3d.webgl-engine.effects.haze.HazeTechnique")],u);export{h as HazePassParameters,u as HazeTechnique};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import"../../../../../core/libs/gl-matrix-2/math/vec3.js";import"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../../core/shaderModules/Float3BindUniform.js";import"../../core/shaderModules/Float3PassUniform.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Matrix4BindUniform.js";import"../../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../../chunks/Precipitation.glsl.js";
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{lerp as t}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{watch as i,syncAndInitial as r,sync as n}from"../../../../../core/reactiveUtils.js";import{secondsFromMilliseconds as o}from"../../../../../core/time.js";import{property as a,subclass as d}from"../../../../../core/accessorSupport/decorators.js";import{getReferenceEllipsoid as p}from"../../../../../geometry/ellipsoidUtils.js";import{getContinuousIndexArray as c}from"../../../../../geometry/support/Indices.js";import{InternalRenderCategory as m}from"../../../webgl.js";import{glLayout as h}from"../../../support/buffer/glUtil.js";import{newLayout as f}from"../../../support/buffer/InterleavedLayout.js";import{TransparentEnvironment as u}from"../TransparentEnvironment.js";import{PrecipitationPassParameters as l,PrecipitationTechnique as _}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as b}from"./PrecipitationTechniqueConfiguration.js";import{VertexArrayObject as y}from"../../lib/VertexArrayObject.js";import{ColorAttachment0 as w,PrimitiveType as v}from"../../../../webgl/enums.js";import{bindVertexBufferLayout as g}from"../../../../webgl/Util.js";import{fromLayout as P}from"../../../../webgl/VertexAttributeLocations.js";import{VertexBuffer as j}from"../../../../webgl/VertexBuffer.js";let I=class extends u{constructor(e){super(e),this._hasSnowCover=!1,this._rainSpeed=.1,this._snowSpeed=.01,this._numParticles=0,this._passParameters=new l,this._configuration=new b;const{view:t,type:s}=e;this._configuration.type="rainy"===s?0:1,this._passParameters.time=0,this._passParameters.radius=p(t.spatialReference).radius,this.addHandles([i(()=>t.environment.weather,e=>{e.type===s&&this.addHandles([i(()=>e.precipitation,e=>this._adjustParticles(e),r),i(()=>"snowy"===e.type&&"enabled"===e.snowCover,e=>this._hasSnowCover=e,r)])},r)]),this.addHandles(i(()=>t.stage?.renderer.renderContext.bind.clouds.fadeFactor??1,e=>{this._passParameters.opacity=e,1===e&&(this.removeHandles("opacity"),this.addHandles(i(()=>t.stage?.renderer.renderContext.bind.clouds.opacity??1,e=>this._passParameters.opacity=e,r),"opacity"))},n),"opacity")}initialize(){this.addHandles([i(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),r)])}_adjustParticles(e){const s=.35,i=e<.5?t(0,s,2*e):t(s,1,2*(e-.5));this._numParticles=C*i}destroy(){this._numParticles=0,this._vao=s(this._vao),this._instanceIdBuffer=s(this._instanceIdBuffer)}fadeOut(e){this.removeAllHandles(),this.addHandles(i(()=>this.renderContext?.bind.clouds.fadeFactor??1,t=>{this._passParameters.opacity=1-t,1===t&&(this.removeAllHandles(),e())}),"opacity")}get snowCover(){return this._hasSnowCover?this._passParameters.opacity:null}updateAnimation(e){const t=("rainy"===this.type?this._rainSpeed:this._snowSpeed)*o(e.time)%1e5;return this._passParameters.time!==t&&(this._passParameters.time=t,!0)}precompile(){this.view.stage.renderView.techniques.precompile(_,this._configuration)}render(e){const t=e.find(({name:e})=>e===m.TRANSPARENT_ENVIRONMENT),s=this.techniques.getCompiled(_,this._configuration);if(!s)return this.requestRender(1),t;const i=Math.round(this._numParticles*this._passParameters.opacity);if(i<1)return t;const r=this.renderingContext,n=r.bindTechnique(s,this.bindParameters,this._passParameters);return r.setDrawBuffers([w]),this._vao??=A(r),r.bindVAO(this._vao),this._bindInstanceIdBuffer(n.locations),n.assertCompatibleVertexAttributeLocations(this._vao,P(x)),r.drawArraysInstanced(v.TRIANGLES,0,3,i),r.unbindBuffer(34962),t}_bindInstanceIdBuffer(e){const t=this.renderingContext;if(this._instanceIdBuffer)return void t.bindBuffer(this._instanceIdBuffer);const s=c(C);this._instanceIdBuffer=new j(t,x,new Float32Array(s)),g(t,e,this._instanceIdBuffer,0)}};function A(e){const t=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new y(e,new j(e,h(B),t))}e([a({constructOnly:!0})],I.prototype,"type",void 0),I=e([d("esri.views.3d.webgl-engine.effects.precipitation.Precipitation")],I);const C=25e4,B=f().vec3f("position").freeze(),x=h(f().f32("instanceFeatureAttribute"),1);export{I as Precipitation};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as t}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../../core/shaderTechnique/ShaderTechnique.js";import{P as s}from"../../../../../chunks/Precipitation.glsl.js";import{DataType as o}from"../../../../webgl/enums.js";import{NoParameters as n}from"../../../../webgl/NoParameters.js";import{makePipelineState as c,defaultColorWrite as p,premultipliedAlpha as a}from"../../../../webgl/renderState.js";import{VertexElementDescriptor as m}from"../../../../webgl/VertexElementDescriptor.js";class l extends n{constructor(){super(...arguments),this.time=0,this.radius=1,this.width=500,this.opacity=0}}let h=class extends i{constructor(e,r){super(e,r,[new m("position",2,o.FLOAT,0,16),new m("instanceFeatureAttribute",2,o.FLOAT,8,16)]),this.shader=new t(s,()=>import("./Precipitation.glsl.js"))}initializePipeline(){return c({blending:a,depthTest:{func:515},colorWrite:p})}};h=e([r("esri.views.3d.webgl-engine.effects.precipitation.PrecipitationTechnique")],h);export{l as PrecipitationPassParameters,h as PrecipitationTechnique};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{__decorate as e}from"tslib";import{parameter as o,ShaderTechniqueConfiguration as t}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";class r extends t{constructor(){super(...arguments),this.type=0}}e([o({count:2})],r.prototype,"type",void 0);export{r as PrecipitationTechniqueConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{CloudsParameters as e}from"../../environment/CloudsParameters.js";import h from"../../webgl/RenderCamera.js";import{OITPolygonOffsetLimit as s}from"./OrderIndependentTransparency.js";import{SceneLighting as n}from"../lighting/SceneLighting.js";class r{constructor(i,t){this.width=i,this.height=t}}class l{constructor(i,s){this.emptyTexture=i,this.shadowMap=s,this.slot=2,this.slicePlane=null,this.hasOccludees=!1,this.hasEmission=!1,this.enableFillLights=!0,this.oitPass=0,this.alignPixelEnabled=!1,this.decorations=!0,this.overlayStretch=1,this.viewshedEnabled=!1,this.cutFillEnabled=!1,this._camera=new h,this._inverseViewport=t(),this._oldLighting=new n,this._newLighting=new n,this._fadedLighting=new n,this._lighting=this._newLighting,this.ssr=new g,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.highlights=new Array,this.highlightOrderMap=new Map,this.highlightMixOrigin=t(),this.highlightMixTexture=null,this.hudRenderStyle=0,this.snowCover=0,this.clouds=new e,this.shadowHighlightsVisible=!1}destroy(){this._camera=null,this.contentCamera=null,this.depth=null,this.geometryDepth=null,this.mainDepth=null,this.overlay=null,this.ssao=null,this.terrainDepth=null}get camera(){return this._camera}set camera(i){this._camera=i,this._inverseViewport[0]=1/i.fullViewport[2],this._inverseViewport[1]=1/i.fullViewport[3]}get enableOffset(){return 1===this.oitPass&&this.camera.relativeElevation<s}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}fadeLighting(){switch(this.clouds.fadeFactor){case 0:this._lighting=this._oldLighting;break;default:this._fadedLighting.lerpLighting(this._oldLighting,this._newLighting,this.clouds.fadeFactor),this._lighting=this._fadedLighting;break;case 1:this._lighting=this._newLighting,this._oldLighting.copyFrom(this._newLighting)}}updateLighting(i,t,e,h){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=t,this._newLighting.globalFactor=e,this._newLighting.set(i),this._oldLighting.updateLegacy(),1===h&&this.clouds.requestFade(),this.fadeLighting()}get highlight(){return null==this.highlightLevel?null:this.highlights[this.highlightLevel]}get occluder(){return 11===this.slot||12===this.slot?this.slot:null}}class g{constructor(){this.fadeFactor=1,this.reprojectionMatrix=i()}}export{l as BindParameters,r as ViewportSize};
2
+ import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import e from"../../webgl/RenderCamera.js";import{CloudsParameters as h}from"../effects/clouds/CloudsParameters.js";import{OITPolygonOffsetLimit as s}from"./OrderIndependentTransparency.js";import{SceneLighting as r}from"../lighting/SceneLighting.js";class n{constructor(i,t){this.width=i,this.height=t}}class l{constructor(i,s){this.emptyTexture=i,this.shadowMap=s,this.slot=2,this.slicePlane=null,this.hasOccludees=!1,this.hasEmission=!1,this.enableFillLights=!0,this.oitPass=0,this.alignPixelEnabled=!1,this.decorations=!0,this.overlayStretch=1,this.viewshedEnabled=!1,this.cutFillEnabled=!1,this._camera=new e,this._inverseViewport=t(),this._oldLighting=new r,this._newLighting=new r,this._fadedLighting=new r,this._lighting=this._newLighting,this.ssr=new g,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.highlights=new Array,this.highlightOrderMap=new Map,this.highlightMixOrigin=t(),this.highlightMixTexture=null,this.hudRenderStyle=0,this.snowCover=0,this.clouds=new h,this.shadowHighlightsVisible=!1}destroy(){this._camera=null,this.contentCamera=null,this.depth=null,this.geometryDepth=null,this.mainDepth=null,this.overlay=null,this.ssao=null,this.terrainDepth=null}get camera(){return this._camera}set camera(i){this._camera=i,this._inverseViewport[0]=1/i.fullViewport[2],this._inverseViewport[1]=1/i.fullViewport[3]}get enableOffset(){return 1===this.oitPass&&this.camera.relativeElevation<s}get inverseViewport(){return this._inverseViewport}get lighting(){return this._lighting}fadeLighting(){switch(this.clouds.fadeFactor){case 0:this._lighting=this._oldLighting;break;default:this._fadedLighting.lerpLighting(this._oldLighting,this._newLighting,this.clouds.fadeFactor),this._lighting=this._fadedLighting;break;case 1:this._lighting=this._newLighting,this._oldLighting.copyFrom(this._newLighting)}}updateLighting(i,t,e,h){this._oldLighting.copyFrom(this.lighting),this._newLighting.noonFactor=t,this._newLighting.globalFactor=e,this._newLighting.set(i),this._oldLighting.updateLegacy(),1===h&&this.clouds.requestFade(),this.fadeLighting()}get highlight(){return null==this.highlightLevel?null:this.highlights[this.highlightLevel]}get occluder(){return 11===this.slot||12===this.slot?this.slot:null}}class g{constructor(){this.fadeFactor=1,this.reprojectionMatrix=i()}}export{l as BindParameters,n as ViewportSize};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,scale as o,floor as n,subtract as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{InternalRenderCategory as l}from"../../webgl.js";import m from"../../webgl/RenderNode.js";import{G as u}from"../../../../chunks/GaussianSplat.glsl.js";import{G as c}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as d}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as _}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as g}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as f}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as P}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as C,ColorAttachment1 as b,PrimitiveType as v}from"../../../webgl/enums.js";var q;let S=class extends m{static{q=this}constructor(e){super(e),this.produces=l.PRE_TRANSPARENT,this.consumes={required:[l.PRE_TRANSPARENT]},this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new u,this._compositionPassParameters=new c,this._depthCompositionPassParameters=new _,this._previousCameraDirection=p(),this._previousSortRequestCameraDirection=p(),this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new P(e.view.state.isGlobal)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){this._configuration.alphaCutoff=this.view.qualitySettings.gaussianSplat.minimumOpacity,this._configuration.terrainDepthTest=this.bindParameters.terrainDepthTest,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this.techniques.precompile(f,this._configuration),this.techniques.precompile(d),this.techniques.precompile(g)}render(e){const t=e.find(({name:e})=>e===this.produces);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=this.techniques.getCompiled(f,this._configuration),i=this.techniques.getCompiled(d),a=this.techniques.getCompiled(g);if(!s||!a||!i)return this.requestRender(1),t;const{fullWidth:r,fullHeight:o}=this.bindParameters.camera;this._prepareParameters(o,r);const n=this.renderingContext,h=this.fboCache,p=h.acquire(r,o,"gaussian color output"),l=t.getAttachment(C);p.attachDepth(l),this._renderGaussianColorAndDepth(p,s);const m=h.acquire(r,o,this.produces);return this._depthCompositionPassParameters.splatDepth=p.getTexture(b),m.attachDepth(t.getAttachment(C)),n.bindFramebuffer(m.fbo),n.bindTechnique(a,this.bindParameters,this._depthCompositionPassParameters),n.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),n.bindFramebuffer(m.fbo),n.bindTechnique(i,this.bindParameters,this._compositionPassParameters),n.screen.draw(),p.release(),m}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}destroy(){super.destroy()}_onCameraChange(){const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_renderGaussianColorAndDepth(e,t){const s=this.renderingContext;e.acquireColor(b,5,"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(v.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/q.tileSize),n(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,q.tileSize),h(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([s()],S.prototype,"produces",void 0),e([s()],S.prototype,"consumes",void 0),e([s({constructOnly:!0})],S.prototype,"layerView",void 0),S=q=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],S);export{S as GaussianSplatRenderNode};
2
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as r,set as o,scale as n,floor as h,subtract as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,set as u,positiveInfinity as c,equals as d}from"../../../../geometry/support/aaBoundingBox.js";import{InternalRenderCategory as _}from"../../webgl.js";import g from"../../webgl/RenderNode.js";import{G as f}from"../../../../chunks/GaussianSplat.glsl.js";import{G as C}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as P}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as b}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as x}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as v}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as q}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as S,ColorAttachment1 as R,PrimitiveType as D}from"../../../webgl/enums.js";var E;let T=class extends g{static{E=this}constructor(e){super(e),this.produces=_.PRE_TRANSPARENT,this.consumes={required:[_.PRE_TRANSPARENT]},this._slicePlaneEnabled=!1,this.layerView=null,this._passParameters=new f,this._compositionPassParameters=new C,this._depthCompositionPassParameters=new b,this._clipBox=m(),this._previousCameraDirection=l(),this._previousSortRequestCameraDirection=l(),this._sortRequestDirectionEpsilon=.01,this._directionChangeEpsilon=.001,this._configuration=new q(e.view.state.isGlobal),u(this._clipBox,c)}async initialize(){this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){this._configuration.alphaCutoff=this.view.qualitySettings.gaussianSplat.minimumOpacity,this._configuration.terrainDepthTest=this.bindParameters.terrainDepthTest,this._configuration.fadingEnabled=this._fadeHelper.fadingEnabled,this._configuration.clippingEnabled=this._clippingEnabled,this.techniques.precompile(v,this._configuration),this.techniques.precompile(P),this.techniques.precompile(x)}render(e){const t=e.find(({name:e})=>e===this.produces);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const i=this.techniques.getCompiled(v,this._configuration),s=this.techniques.getCompiled(P),a=this.techniques.getCompiled(x);if(!i||!a||!s)return this.requestRender(1),t;const{fullWidth:r,fullHeight:o}=this.bindParameters.camera;this._prepareParameters(o,r);const n=this.renderingContext,h=this.fboCache,p=h.acquire(r,o,"gaussian color output"),l=t.getAttachment(S);p.attachDepth(l),this._renderGaussianColorAndDepth(p,i);const m=h.acquire(r,o,this.produces);return this._depthCompositionPassParameters.splatDepth=p.getTexture(R),m.attachDepth(t.getAttachment(S)),n.bindFramebuffer(m.fbo),n.bindTechnique(a,this.bindParameters,this._depthCompositionPassParameters),n.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),n.bindFramebuffer(m.fbo),n.bindTechnique(s,this.bindParameters,this._compositionPassParameters),n.screen.draw(),p.release(),m}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}set clippingBox(e){const t=e||c;this._hasSameClipBox(t)||(u(this._clipBox,t),this._data.requestSort(),this.requestRender(1))}get clippingBox(){return this._clippingEnabled?this._clipBox:null}get _clippingEnabled(){return!d(this._clipBox,c,(e,t)=>e===t)}get _data(){return this.layerView.data}get _fadeHelper(){return this.layerView.fadeHelper}destroy(){super.destroy()}_onCameraChange(){const e=this.view.state.camera.ray.direction;if(!this._directionChanged(e))return;if(r(this._previousCameraDirection,e),!this._shouldRequestSort(e))return;this._data.requestSort()&&r(this._previousSortRequestCameraDirection,e)}_directionChanged(e){return Math.abs(e[0]-this._previousCameraDirection[0])>this._directionChangeEpsilon||Math.abs(e[1]-this._previousCameraDirection[1])>this._directionChangeEpsilon||Math.abs(e[2]-this._previousCameraDirection[2])>this._directionChangeEpsilon}_shouldRequestSort(e){return Math.abs(e[0]-this._previousSortRequestCameraDirection[0])>this._sortRequestDirectionEpsilon||Math.abs(e[1]-this._previousSortRequestCameraDirection[1])>this._sortRequestDirectionEpsilon||Math.abs(e[2]-this._previousSortRequestCameraDirection[2])>this._sortRequestDirectionEpsilon}_prepareParameters(e,t){this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const i=Math.tan(.5*this.camera.fovY),s=i/e*t;a(this._passParameters.tanFov,s,i),this._passParameters.focalLength=e/(2*i);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition(),this._updateClipUniforms()}_updateClipUniforms(){if(this._clippingEnabled){const[e,t,i,s,a,r]=this._clipBox,[n,h,p]=this.camera.eye;o(this._passParameters.clipMinCameraRelative,e-n,t-h,i-p),o(this._passParameters.clipMaxCameraRelative,s-n,a-h,r-p)}}_hasSameClipBox(e){return d(this._clipBox,e,(e,t)=>e===t)}_renderGaussianColorAndDepth(e,t){const i=this.renderingContext;e.acquireColor(R,5,"gaussian depth output"),i.bindFramebuffer(e.fbo),i.setClearColor(0,0,0,0),i.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(D.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_prepareHighPrecisionCameraPosition(){n(this._passParameters.tileCameraPosition,this.camera.eye,1/E.tileSize),h(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),n(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,E.tileSize),p(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this._fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this._fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};e([i()],T.prototype,"produces",void 0),e([i()],T.prototype,"consumes",void 0),e([i({constructOnly:!0})],T.prototype,"layerView",void 0),T=E=e([s("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],T);export{T as GaussianSplatRenderNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as r,abortMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as m,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as E}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as T,ZEROS as w}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as C}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as R}from"../../webgl.js";import{innerAtmosphereFadeStart as D}from"../../environment/atmosphereUtils.js";import{minNearDistanceInMeters as O}from"../../state/NearFarHeuristic.js";import{debugFlags as I}from"../../support/debugFlags.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as y}from"../core/renderPasses/RenderPassManager.js";import{isColor as v}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as F}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as N}from"../effects/RenderNodes.js";import{RenderPluginManager as M}from"../effects/RenderPluginManager.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as V}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as Z}from"./RenderFeature.js";import{RenderPluginInput as $}from"./RenderPluginInput.js";import{ShadowAccumulator as X}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,r,i){super({stage:e}),this._techniques=s,this._rctx=r,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new y,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=T(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new V,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new $,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of Te)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new H(r),this._compositor=new k(r,s),this._renderStateFeatures=u(Z(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(s),this._shadowAccumulator=new X(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,r)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,r,!0,i),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new N(this._renderContext),this._plugins=new M({renderContext:this._renderContext,techniques:s,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>I.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():w;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=F,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=r(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),se.prune(),C()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=Z(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(r=>r.set(t,e,s)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=n(this._bindParameters.depth)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&m(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_bindParameters:t}=this;if(void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const s="virtual"!==e.environment.lighting.type;t.enableFillLights!==s&&(t.enableFillLights=s,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?r(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,s,r=!1){try{return this._isRendering=!0,this._render(e,t,s,r)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,r){const i=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._rctx.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!r,this._bindParameters.mainDepth=null;const d=!r||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(a,n),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!r;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._rctx.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(A.ANTIALIASING,e));const m=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(m,e)),_.update(e=>this._renderNodes(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new re(f,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._rctx.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,A.OPAQUE_ENVIRONMENT,A.PRE_TRANSPARENT);const s=this._bindParameters;s.terrainDepthTest=s.cullAboveTerrain=this._needsTerrainDepth,this._rctx.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._rctx.output=0,this._plugins.precompile(...pe),e&&this.oitEnabled&&this._oitBlend.precompile(t,this._pluginsHas.occludedHudElements,0),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(s.cullAboveTerrain=!1,this._precompileTransparentGeometry(),s.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,A.FOCUSAREA);const r=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,r,t),this._oitCallouts||this._plugins.precompile(17),s.terrainDepthTest=s.cullAboveTerrain=!1,this._nodes.precompile(t,A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING),s.highlightMixTexture=s.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(0),s.hasEmission=!1,this._precompileHUD(0),this._precompileHUD(1),s.hasEmission=this._hasEmission,this._hasHighlights&&(s.highlights.forEach((e,t)=>{s.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),s.highlightLevel=null,this._nodes.precompile(t,A.HIGHLIGHT_COLOR)),s.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ae.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._rctx.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let r=this.fboCache.acquire(t,s,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._rctx.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let r=0;t?r=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,r);this._animationTimestep.frame(i,s)}}readMainDepth(e,t){const{mainDepth:s,camera:r}=this._bindParameters;if(!s)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),r.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(w),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),i.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ne.UNSIGNED_BYTE,t),i.release()}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquire(s,r,"edges"),a=this._bindParameters.geometryDepth,n=()=>t.render(this._bindParameters,e);this._renderToTargets(n,i,a??this._framebuffer.depth,w),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ae.OPAQUE_EDGES:ae.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ae.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),r.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ae.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){const s=this._rctx.output;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e);t.finish(e),this._rctx.output=s}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ae.DEPTH)):(e.detachDepth(),this._bindParameters.depth=n(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=n(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ae.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._rctx.output;this._rctx.output=1;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=r.obtainDepthTexture(),r.release(),this._rctx.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._rctx.output,{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._rctx.output=e,this._bindParameters.geometryDepth=r.obtainDepthTexture(),r.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<D)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=O,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...S,A.VIEWSHED,A.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(w,!0,!0),this._rctx.output=2,this._plugins.render(...ce);const i=this._nodes.optional("normals",...S,A.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(ae.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ae.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._rctx.output;this._rctx.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._rctx.output=t}renderAllGeometry(e){this._rctx.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Ee[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._rctx.output;this._rctx.output=e,this._plugins.precompile(0,1,...pe),this._rctx.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.output=r}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._rctx.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._rctx.output=r}_renderOpaqueAndTransparentGeometry(e){this._rctx.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._rctx.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"transparent terrain"),r=()=>this._plugins.render(6);return this._renderToTargets(r,s,this._framebuffer.depth,w),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._rctx.output;this._rctx.output=8,this._precompileHUDOutput(e),this._rctx.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&v(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0,this._oitBlend.precompile(this._bindParameters.hasEmission,!1,1)):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const r=!!t.getTexture(he);this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),r),s.release()}else if(this._rctx.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,s,r,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ae.HUD_OCCLUDED:ae.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:r,height:i}=this._framebuffer.size,{highlights:a}=s,n=a.length>G?3:1,h=e.acquire(r,i,"highlights",n);h.acquireDepth(13);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._rctx.output=8,t.bindFramebuffer(h.fbo),L(t,e,r,i,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ae.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...R)+this._nodes.optional("highlights",...R)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:s,camera:r,contentCamera:i}=this._bindParameters;this._rctx.output=0,this._shadowAccumulator.accumulating&&s&&this._shadowAccumulator.renderAccumulation(s,r,i,t)&&this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&v(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const s=1===e,{width:r,height:i}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._rctx.output;this._rctx.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(r,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,w),a(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(r,i,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(w,s),a(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!s;let m;return this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),h.oitPass=0,s?(m=this.fboCache.acquire(r,i,"oit hud composite"),this._rctx.bindFramebuffer(m.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(c&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,w)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._rctx.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,...le);e&&(this._plugins.render(0,1),this._framebuffer.update(e=>this._renderNodes(A.CUTFILL_COLOR,e)),this._framebuffer.bind(),this._plugins.render(2,3));const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),t.update(e=>this._renderNodes(A.PRE_TRANSPARENT,e)),this.fboCache.debugCallback?.(A.PRE_TRANSPARENT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const s=this._renderPhotoshopTerrain(),r=s?.getTexture();r&&this._renderHUD(0,t.color),this._bindParameters.cullAboveTerrain=!1,r&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ae.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=n(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ae.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){const r=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(r,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(f(Ce,this._bindParameters.camera.viewMatrix),f(we,this._bindParameters.camera.projectionMatrix),g(xe,Ce,we),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,r){this._bindParameters.updateLighting(e,t,s,r),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,r,i=!1,a=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(r,i,a),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([c("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],ce=[0,1,2,4,...pe],me=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Pe=[4,9,5,12],Ee={0:[15],1:[14],2:[15,14],3:[15,14]},Te=["normals","highlights"],we=P(),Ce=P(),xe=P();function Ae(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
2
+ import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{removeMaybe as r,abortMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import{throwIfAborted as h}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as d,initial as _,sync as l}from"../../../../core/reactiveUtils.js";import{signal as u}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as m,invert as f,multiply as g}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as E}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as T,ZEROS as w}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as C}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as x,InternalRenderCategory as A,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as R}from"../../webgl.js";import{minNearDistanceInMeters as D}from"../../state/NearFarHeuristic.js";import{debugFlags as O}from"../../support/debugFlags.js";import{FBOCache as I}from"../core/FBOCache.js";import{RenderPassManager as H}from"../core/renderPasses/RenderPassManager.js";import{isColor as y}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as v}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as F}from"../effects/RenderNodes.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{innerAtmosphereFadeStart as M}from"../effects/atmosphere/atmosphereUtils.js";import{Blit as q}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as G,renderHighlightBuffer as L}from"../effects/highlight/Highlight.js";import{OITBlend as U}from"../effects/transparency/OITBlend.js";import{AnimationTimer as j}from"./AnimationTimer.js";import{AnimationTimeStep as V}from"./AnimationTimeStep.js";import{BoundingInfo as B}from"./BoundingInfo.js";import{Compositor as k}from"./Compositor.js";import{DepthRange as z}from"./DepthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{MainFramebuffer as Q}from"./MainFramebuffer.js";import{RenderContext as Y,defaultRenderOccludedMask as J}from"./RenderContext.js";import{RendererBase as K}from"./RendererBase.js";import{setupFeatureDefaults as Z}from"./RenderFeature.js";import{RenderPluginInput as $}from"./RenderPluginInput.js";import{ShadowAccumulator as X}from"./ShadowAccumulator.js";import{ShadowMap as ee}from"./ShadowMap.js";import te from"./SliceHelper.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as re}from"../parts/renderUtils.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{PixelType as ne,ColorAttachment1 as he,ColorAttachment2 as oe,ColorAttachment0 as de}from"../../../webgl/enums.js";let _e=class extends K{constructor(e,t,s,r,i){super({stage:e}),this._techniques=s,this._rctx=r,this._requestRender=i,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new H,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=T(0,0,0,1),this._sliceHelper=new te,this.sceneDepthRange=u(z.Infinite),this._state=u(2),this._hasAnimations=!1,this._animationTimestep=new V,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=u(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new $,this._oitCallouts=!1,this._releaseNodeInputs=e=>{for(const t of Te)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._debugNeedsDepth=!1,this._fboCache=new I(r),this._compositor=new k(r,s),this._renderStateFeatures=u(Z(e.view.qualityProfile)),this._framebuffer=new Q(this.fboCache),this._performanceInfo=new ie(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._blit=new q(s),this._shadowAccumulator=new X(this.fboCache,s,e,e=>{const t=this.shadowsEnabled;this._shadowMap.enabled=!0,this._ensureBindParametersCamera(e.camera,e.contentCamera),this._plugins.prepareRender(),this._shadowMap.enabled=t},(t,s,r)=>{const i=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,r,!0,i),this._renderShadowCascades(3,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},i),this._renderContext=new Y(this._rctx,this._shadowMap,s),this._nodes=new F(this._renderContext),this._plugins=new N({renderContext:this._renderContext,techniques:s,materials:t,requestRender:i,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this._plugins.add(this.renderPassManager),this.addHandles([o(()=>e.view.state.camera,()=>i(),d),o(()=>O.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},i()},_),o(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():w;E(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),i()},d),o(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=v,d),o(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},l),o(()=>this._bindParameters.clouds.data?.state,()=>i(),l),o(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,i()},_)])}destroy(){this._gpuTimerHandle=r(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowMap.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=i(this._loadEdgeViewTask),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this._fboCache.destroy(),this._fboCache=null,this._plugins.destroy(),this._plugins=null,this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._shadowMap=null,this._renderContext=null,this._performanceInfo=null,B.prune(),se.prune(),C()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new U(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=Z(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(r=>r.set(t,e,s)),this._requestRender()}get _highQualityTransparency(){return this.isFeatureEnabled(1)}get hasReflections(){return this._pluginsHas.water&&this.isFeatureEnabled(6)}get _hasHighlights(){return this._plugins.produces(8,2,4,20,14,15,16)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(8,14,15,16)}get hasSSAO(){return this.isFeatureEnabled(5)&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _hasEmission(){return this._plugins.hasEmitters&&this._hasFloatBufferBlendSupport}get highResolutionAtmosphere(){return this.isFeatureEnabled(4)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion)}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOutputs(),this._bindParameters.depth=n(this._bindParameters.depth)}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._shadowAccumulator.readyToRun||this._plugins.updating||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");h(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:Ae(this.stage.view.resourceController)});return this.addHandles(o(()=>s.updating,()=>this._requestRender(),l)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&m(this._bindParameters.ssr.reprojectionMatrix,b)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this._reprojectionMatrixVersion.value++}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_bindParameters:t}=this;if(void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),e.environment){void 0!==e.environment.weather&&(this._bindParameters.weather=e.environment.weather);const s="virtual"!==e.environment.lighting.type;t.enableFillLights!==s&&(t.enableFillLights=s,this._requestRender())}e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}get _hasFloatBufferBlendSupport(){return this._rctx.driverTest.floatBufferBlend.result}get oitEnabled(){return this.isFeatureEnabled(2)&&this._hasFloatBufferBlendSupport}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}rendererAdded(e){this._plugins.add(e)}rendererRemoved(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this.occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,10)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,15),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...ge),has.water=this._plugins.produces(2,21),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new j(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?r(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,s,r=!1){try{return this._isRendering=!0,this._render(e,t,s,r)}catch(i){console.error(`Exception during rendering: ${i}`)}finally{this._isRendering=!1}return new re(this._pluginInput.get(x.FINAL),null)}_render(e,t,s,r){const i=0===s;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:a,contentCamera:n,mode:h,alignPixelEnabled:o}=e;this._state.value=h,this._renderContext.time=t,this._rctx.output=0,this._bindParameters.hasEmission=this._hasEmission,this._bindParameters.oitPass=0,this._bindParameters.alignPixelEnabled=o,this._bindParameters.decorations=!r,this._bindParameters.mainDepth=null;const d=!r||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=d?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(A.VIEWSHED),this._bindParameters.cutFillEnabled=this._nodes.produces(A.CUTFILL_DEPTH),this._renderOverlay(),a.setGLViewport(this._rctx);const _=this._framebuffer,l=_.initialize(a.fullWidth,a.fullHeight,this._backgroundColor,this._bindParameters.hasEmission);this.hasReflections?(l?.setName("last frame color"),this._bindParameters.ssr.lastFrameColor=l):l?.release(),this._ensureBindParametersCamera(a,n),this._plugins.sortTestsTransparentOrderedSlots(Pe),this._plugins.prepareRender(),this._bindParameters.shadowHighlightsVisible=this._needsShadowHighlight&&!r;const u=this._plugins.produces(0,...ue);this._precompilePrepasses(),this.performanceInfo.advance(ae.PREPARE);const p=this._computeShadowDepthRange(a);this._renderShadowMap(a,this._bindParameters.lighting.mainLight.direction,p),this._pluginInput.set("normals",this._renderNormals()),this._renderRemainingGeometryDepth(),this._renderShadowAccumulation(p,!i),this._oitCallouts=u&&this.oitEnabled,this._ensureBindParametersSSR(t),this._precompileShaders(u),this._rctx.output=0,_.bind(),this._bindParameters.mainDepth=_.depth.attachment,this._renderOpaque(),this._renderTransparent(u),this._shadowMap.disposeOutput(3),this._pluginInput.set(A.FOCUSAREA,this._renderFocusAreaGeometry()),this._pluginInput.set(A.CUTFILL_DEPTH,this._renderCutFillDepth()),_.update(e=>this._renderNodes(A.TRANSPARENT_ENVIRONMENT,e)),_.update(e=>this._renderNodes(A.VIEWSHED,e)),_.update(e=>this._renderNodes(A.LASERLINES,e)),_.update(e=>this._renderNodes(A.FOCUSAREA_COLOR,e)),this._pluginInput.release(A.FOCUSAREA),this._pluginInput.release(A.CUTFILL_DEPTH),_.update(e=>this._renderNodes(A.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===s?this._renderObjectAndLayerIdColor():null;_.update(e=>this._renderNodes(x.COMPOSITE,e)),this._shadowMap.disposeOutputs(),_.update(e=>this._renderNodes(A.ANTIALIASING,e));const m=this._hasPhotoshopTerrain||!u?1:2;let f;return this._bindParameters.hasEmission=!1,this._hasHUDHighlights&&_.update(e=>this._renderHUD(m,e)),_.update(e=>this._renderNodes(A.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||_.update(e=>this._renderHUD(m,e)),this._bindParameters.hasEmission=this._hasEmission,_.update(e=>this._renderNodes(A.MAGNIFIER,e)),_.update(e=>this._renderNodes(x.FINAL,e)),i&&this._blit.toFramebuffer(this._rctx,_.color,this._bindParameters),this.onPostRender?.(),this._releaseFBOs(),_.releaseDepth(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(f=_.color,f.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new re(f,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling,this._rctx.output=0;const t=this._bindParameters.hasEmission;this._precompileOpaqueGeometry(),this._nodes.precompile(t,A.OPAQUE_ENVIRONMENT,A.PRE_TRANSPARENT);const s=this._bindParameters;s.terrainDepthTest=s.cullAboveTerrain=this._needsTerrainDepth,this._rctx.output=1,this._plugins.precompile(...pe),this._needsTerrainDepth&&(this._precompileOpaqueGeometry(),this._precompileTransparentGeometry()),this._rctx.output=0,this._plugins.precompile(...pe),e&&this.oitEnabled&&this._oitBlend.precompile(t,this._pluginsHas.occludedHudElements,0),e&&(this._precompileTransparentGeometry(),this._hasPhotoshopTerrain&&(s.cullAboveTerrain=!1,this._precompileTransparentGeometry(),s.cullAboveTerrain=this._needsTerrainDepth)),this._nodes.precompile(t,A.FOCUSAREA);const r=this._hasPhotoshopTerrain&&!this._needsTerrainDepth;this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,r,t),this._oitCallouts||this._plugins.precompile(17),s.terrainDepthTest=s.cullAboveTerrain=!1,this._nodes.precompile(t,A.TRANSPARENT_ENVIRONMENT,A.VIEWSHED,A.CUTFILL_DEPTH,A.CUTFILL_COLOR,A.LASERLINES,A.FOCUSAREA_COLOR,A.OCCLUDED,A.ANTIALIASING),s.highlightMixTexture=s.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(0),s.hasEmission=!1,this._precompileHUD(0),this._precompileHUD(1),s.hasEmission=this._hasEmission,this._hasHighlights&&(s.highlights.forEach((e,t)=>{s.highlightLevel=t,this._precompileAllGeometry(8),this._hasHUDHighlights&&this._plugins.precompile(15,14)}),s.highlightLevel=null,this._nodes.precompile(t,A.HIGHLIGHT_COLOR)),s.highlightMixTexture=null,this._nodes.precompile(t,x.COMPOSITE,A.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(9),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(A.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(ae.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces("olid"))return null;const e=this._rctx.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let r=this.fboCache.acquire(t,s,"olid");return r.acquireDepth(13),r=this._nodes.render(r,this._pluginInput),--this._techniques.precompiling,this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._rctx.output=e,r}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let r=0;t?r=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const i=Math.max(e,r);this._animationTimestep.frame(i,s)}}readMainDepth(e,t){const{mainDepth:s,camera:r}=this._bindParameters;if(!s)return;const i=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(i.fbo),r.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(w),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),i.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,ne.UNSIGNED_BYTE,t),i.release()}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquire(s,r,"edges"),a=this._bindParameters.geometryDepth,n=()=>t.render(this._bindParameters,e);this._renderToTargets(n,i,a??this._framebuffer.depth,w),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,i.getTexture()),i.release(),this.performanceInfo.advance(1===e?ae.OPAQUE_EDGES:ae.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(ae.OVERLAY)}_renderShadowMap(e,t,s){if(!this.shadowsEnabled)return;const r=this._shadowMap;r.start(e,t,s,this.isFeatureEnabled(7),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight?(this._renderShadowCascades(5,this._shadowMap),r.clear(),this._renderShadowCascades(4,this._shadowMap)):this._renderShadowCascades(3),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this.performanceInfo.advance(ae.SHADOW_MAP)}_renderCutFillDepth(){return this._nodes.produce(A.CUTFILL_DEPTH,this._pluginInput)}_precompileShadowCascades(e){0!==this._shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._shadowMap){const s=this._rctx.output;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e);t.finish(e),this._rctx.output=s}get _needsDepth(){return this._plugins.consumes(1)||this._nodes.requireGeometryDepth()||this.hasReflections||this._needsShadowHighlight||this._shadowAccumulator.active||this._debugNeedsDepth}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements&&this.oitEnabled||this._hasPhotoshopTerrain}_renderRemainingGeometryDepth(){const e=this._pluginInput.get("normals");e?(this._pluginInput.set(A.SSAO,this._renderSSAO()),this._needsDepth?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(1),this._bindParameters.depth?.release(),this._bindParameters.depth=e.obtainDepthTexture(),this.performanceInfo.advance(ae.DEPTH)):(e.detachDepth(),this._bindParameters.depth=n(this._bindParameters.depth)),this.hasSSAO&&this._pluginInput.release("normals")):this._renderAllGeometryDepth()}_renderAllGeometryDepth(){if(this._bindParameters.depth=n(this._bindParameters.depth),!this._needsDepth)return;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"geometry depth",13);this._rctx.bindFramebuffer(s.fbo),this._rctx.clear(1280),this.renderAllGeometry(1),this._bindParameters.depth=s.obtainDepthTexture(),s.release(),this.performanceInfo.advance(ae.DEPTH)}_renderTerrainDepth(){if(this._bindParameters.terrainDepth=n(this._bindParameters.terrainDepth),this._bindParameters.terrainDepthTest=this._bindParameters.cullAboveTerrain=this._needsTerrainDepth,!this._needsTerrainDepth)return;const e=this._rctx.output;this._rctx.output=1;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"terrain depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderTransparentGround(),this._bindParameters.terrainDepth=r.obtainDepthTexture(),r.release(),this._rctx.output=e}_renderGeometryDepth(){if(this._bindParameters.geometryDepth=n(this._bindParameters.geometryDepth),!this._needsTerrainDepth)return;const e=this._rctx.output,{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"geometry depth",13);this._rctx.bindFramebuffer(r.fbo),this._rctx.clear(1280),this._renderOpaqueAndTransparentGeometry(1),this._rctx.output=e,this._bindParameters.geometryDepth=r.obtainDepthTexture(),r.release()}get _needsShadowDepthRange(){return this._shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return z.Zero;const t=W(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=z.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<M)return void(this.sceneDepthRange.value=z.Infinite);const t=e.clone();t.near=D,t.far=1e10;const s=W(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){const e=this._nodes.require("normals",...S,A.VIEWSHED,A.LASERLINES);return(this.hasSSAO?1:0)+e}_precompilePrepasses(){this._normalsRequired&&this._precompileAllGeometry(2),this._needsDepth&&this._precompileAllGeometry(1),this.shadowsEnabled&&(this._needsShadowHighlight?(this._precompileShadowCascades(4),this._precompileShadowCascades(5)):this._precompileShadowCascades(3)),this._shadowAccumulator.active&&this._precompileAllGeometry(3),this.hasSSAO&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,A.SSAO)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquire(t,s,"normals",5);r.acquireDepth(13),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(w,!0,!0),this._rctx.output=2,this._plugins.render(...ce);const i=this._nodes.optional("normals",...S,A.VIEWSHED);return r.retain(e+i-1),this.performanceInfo.advance(ae.NORMALS),r}_renderSSAO(){const e=this._pluginInput.get("normals");if(this.hasSSAO&&e)return this._bindParameters.ssao=this._nodes.produce(A.SSAO,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(ae.SSAO),this._bindParameters.ssao}_precompileAllGeometry(e){const t=this._rctx.output;this._rctx.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...pe),this._rctx.output=t}renderAllGeometry(e){this._rctx.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...fe);this._renderContext.renderOccludedMask=J}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(10),this.renderSlots(e,...fe),this._renderContext.renderOccludedMask=J}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Ee[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(18),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(16)}precompileViewshedShadowMap(){this._precompileAllGeometry(6)}precompileCutFill(){const e=7,t=this._rctx.output;this._rctx.output=e,this._plugins.precompile(0,1,...pe),this._rctx.output=t}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(6),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.output=r}renderCutFillReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,r=this._rctx.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._rctx.output=7,this._plugins.render(0,1,...pe),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._rctx.output=r}_renderOpaqueAndTransparentGeometry(e){this._rctx.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._rctx.output=e,this._plugins.render(...me)}_precompileOpaqueGeometry(){this._plugins.precompile(...le),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color")}_renderOpaqueGeometry(){this._plugins.render(...le)}_renderTransparentGeometry(){this._plugins.render(...ue),this._oitCallouts&&this._plugins.render(17)}get _hasPhotoshopTerrain(){return this._plugins.produces(0,6)}get _needsTerrainDepth(){return this._highQualityTransparency&&this._hasPhotoshopTerrain}_renderPhotoshopTerrain(){if(!this._hasPhotoshopTerrain)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,"transparent terrain"),r=()=>this._plugins.render(6);return this._renderToTargets(r,s,this._framebuffer.depth,w),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),s}_renderTransparentGround(){this._plugins.render(...pe)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,0===e){const e=()=>this._plugins.render(17),{width:t,height:s}=this._framebuffer.size,r=this.fboCache.acquireDepth(12,t,s,"line callouts");this._renderToTargets(e,this._framebuffer.color,r,void 0,!0,!0),r.release()}else this._plugins.render(17)}_precompileHUD(e){if(this._pluginsHas.hudElements&&(this._precompileHUDOutput(e),this._hasHighlights)){const t=this._rctx.output;this._rctx.output=8,this._precompileHUDOutput(e),this._rctx.output=t}}_precompileHUDOutput(e){const t=this._bindParameters.hudRenderStyle;this._bindParameters.hudRenderStyle=e,this.oitEnabled&&y(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ge),this._bindParameters.oitPass=2,this._plugins.precompile(...ge),this._bindParameters.oitPass=0,this._oitBlend.precompile(this._bindParameters.hasEmission,!1,1)):this._plugins.precompile(...ge),this._bindParameters.hudRenderStyle=t}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;if(this.oitEnabled){const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const r=!!t.getTexture(he);this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),r),s.release()}else if(this._rctx.output=0,0===e){const t=()=>this._renderHUDElements(e),{width:s,height:r}=this._framebuffer.size,i=this.fboCache.acquireDepth(12,s,r,"hud");this._renderToTargets(t,this._framebuffer.color,i,void 0,!0,!0),i.release()}else t.acquireDepth(12),this._rctx.bindFramebuffer(t.fbo),this._rctx.clear(256),this._renderHUDElements(e),t.detachDepth();return this.performanceInfo.advance(0===e?ae.HUD_OCCLUDED:ae.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(4,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:r,height:i}=this._framebuffer.size,{highlights:a}=s,n=a.length>G?3:1,h=e.acquire(r,i,"highlights",n);h.acquireDepth(13);const o=this._plugins.produces(8,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._rctx.output=8,t.bindFramebuffer(h.fbo),L(t,e,r,i,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(ae.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...R)+this._nodes.optional("highlights",...R)-1),h}_renderHighlightGeometries(){this._plugins.render(...be),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e,t){this._shadowAccumulator.updateDepthRange(e);const{depth:s,camera:r,contentCamera:i}=this._bindParameters;this._rctx.output=0,this._shadowAccumulator.accumulating&&s&&this._shadowAccumulator.renderAccumulation(s,r,i,t)&&this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS)}_precompileTransparentGeometry(){this.oitEnabled&&y(this._rctx.output)?(this._bindParameters.oitPass=1,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=2,this._plugins.precompile(...ue),this._oitCallouts&&this._plugins.precompile(17),this._bindParameters.oitPass=0):this._plugins.precompile(...ue)}_renderOIT(e,t=2){const s=1===e,{width:r,height:i}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=this._rctx.output;this._rctx.output=0,h.oitPass=1;const d=s?"oit hud":"oit",_=this.fboCache.acquire(r,i,d,8),l=this._bindParameters.hasEmission&&(0===e||1!==t);l&&_.acquireColor(he,8,"oit emissive");const u=l?oe:he;_.acquireColor(u,7,"oit alpha"),s||_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer([0,0,0,1]),l&&this._rctx.clearBuffer(1,w),a(),_.detachDepth(),h.oitPass=2;const p=this.fboCache.acquire(r,i,s?"oit hud front":"oit front");l&&p.acquireColor(he,8,"oit emissive front"),s?p.acquireDepth(12):p.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(p.fbo),this._rctx.clearFramebuffer(w,s),a(),p.detachDepth();const c=this._pluginsHas.occludedHudElements&&!s;let m;return this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),h.oitPass=0,s?(m=this.fboCache.acquire(r,i,"oit hud composite"),this._rctx.bindFramebuffer(m.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(c&&(this._framebuffer.color.acquireColor(u,0,"hud occlusion"),this._rctx.clearBuffer(u-de,w)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,_,p,h,l,c,e),m?.detachDepth(),s||(this._rctx.bindFramebuffer(p.fbo),this._framebuffer.bind(),c&&(this._bindParameters.hudOcclusion=this._framebuffer.color.obtainAttachment(u))),p.release(),_.release(),this._rctx.output=o,m}_renderOpaque(){const e=this.plugins.produces(0,...le);e&&(this._plugins.render(0,1),this._framebuffer.update(e=>this._renderNodes(A.CUTFILL_COLOR,e)),this._framebuffer.bind(),this._plugins.render(2,3));const t=this._framebuffer;this._renderTerrainDepth(),t.update(t=>this._renderNodes(x.OPAQUE,t,e)),this.fboCache.debugCallback?.(x.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(A.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(A.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderTransparent(e){const t=this._framebuffer;t.bind(),t.update(e=>this._renderNodes(A.PRE_TRANSPARENT,e)),this.fboCache.debugCallback?.(A.PRE_TRANSPARENT,t.color.fbo),this._renderHiddenTransparentEdges(),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry()),t.update(t=>this._renderNodes(x.TRANSPARENT,t,e)),this.fboCache.debugCallback?.(x.TRANSPARENT,t.color.fbo),this._renderGeometryDepth(),this._needsTerrainDepth||this._oitCallouts||this._plugins.render(17),this._renderEdges(0);const s=this._renderPhotoshopTerrain(),r=s?.getTexture();r&&this._renderHUD(0,t.color),this._bindParameters.cullAboveTerrain=!1,r&&(t.bind(),this._compositor.compositePreMultipliedAlpha(this._bindParameters,r),s?.release(),this._needsTerrainDepth&&(this._renderEdges(1),e&&(this.oitEnabled?this._renderOIT(0):this._renderTransparentGeometry(),this.performanceInfo.advance(ae.TRANSPARENT)),this._renderEdges(0))),this._bindParameters.ssao=n(this._bindParameters.ssao),this._needsTerrainDepth&&this._renderLineCallouts(1),this._bindParameters.terrainDepthTest=!1,this._renderTransparentEnvironment()}_renderTransparentEnvironment(){this._shadowAccumulator.render(this._bindParameters),this.performanceInfo.advance(ae.APPLY_ACCUMULATED_SHADOWS),this._framebuffer.bind(),this._plugins.render(9),this.performanceInfo.advance(ae.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){const r=t.name;if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;this._fboCache.debugCallback?.(r,t.fbo);const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),i}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=b:(f(Ce,this._bindParameters.camera.viewMatrix),f(we,this._bindParameters.camera.projectionMatrix),g(xe,Ce,we),g(xe,this._renderContext.lastFrameCamera.viewMatrix,xe),g(xe,this._renderContext.lastFrameCamera.projectionMatrix,xe),this._reprojectionMatrix=xe);const t=this.stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=t>0?Math.min(t,e-this._ssrEnableTime)/t:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=b,this._ssrEnableTime=null}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,r){this._bindParameters.updateLighting(e,t,s,r),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0}}_renderToTargets(e,t,s,r,i=!1,a=!1){t.attachDepth(s),this._rctx.bindFramebuffer(t.fbo),this._rctx.clearFramebuffer(r,i,a),e(),t.detachDepth()}get test(){}};e([p({readOnly:!0})],_e.prototype,"highResolutionAtmosphere",null),e([p()],_e.prototype,"_edgeView",void 0),e([p()],_e.prototype,"updating",null),_e=e([c("esri.views.3d.webgl-engine.lib.Renderer")],_e);const le=[0,1,2,3],ue=[7,8,4,5],pe=[6,7,8],ce=[0,1,2,4,...pe],me=[3,5],fe=[2,4,9],ge=[18,14,16,15],be=[4,5,2,3,0,1,...pe],Pe=[4,9,5,12],Ee={0:[15],1:[14],2:[15,14],3:[15,14]},Te=["normals","highlights"],we=P(),Ce=P(),xe=P();function Ae(e){return t=>e.immediate.schedule(t)}export{_e as Renderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{isDepthOrShadowLike as s}from"../core/shaderLibrary/ShaderOutput.js";import{ScreenSpaceGeometry as r}from"../effects/ScreenSpaceGeometry.js";import{createEmptyTexture as t}from"./glUtil3D.js";import{IndexBufferCache as i}from"../materials/renderers/IndexBufferCache.js";import{TextureBufferCache as h}from"../materials/renderers/TextureBufferCache.js";import{VaoCache as a}from"../materials/renderers/VaoCache.js";import{VboCache as o}from"../materials/renderers/VboCache.js";import{AppleAmdDriverHelper as u}from"../../../webgl/AppleAmdDriverHelper.js";import{DrawBufferNone as n}from"../../../webgl/enums.js";import{RenderingContext as c,getFramebufferDrawBuffers as f}from"../../../webgl/RenderingContext.js";class p extends c{constructor(e,s){super(e,s),this.emptyTexture=t(this),this._vaoCaches=new Map,this._vboCaches=new Map,this._indexBufferCache=null,this._textureBufferCaches=new Map,this._output=0,this.debugBoundTechnique="",this._appleAmdDriverHelper=null,this._refCount=1,this._newCache=s.newCache,this._screen=new r(this)}configure(e){super.configure(e),this._newCache=e.newCache}destroy(){this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache=e(this._indexBufferCache),this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}get refCount(){return this._refCount}dispose(){this.emptyTexture.dispose(),this._screen.destroy(),this._screen=null,super.dispose(),this._appleAmdDriverHelper?.dispose(),this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache?.dispose(),this._indexBufferCache=null,this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear()}get newCache(){return this._newCache}get screen(){return this._screen}getVaoCache(e){const s=JSON.stringify(e),r=this._vaoCaches.get(s);if(r)return r;const t=new a(this,e);return this._vaoCaches.set(s,t),t}getVboCache(e){const s=JSON.stringify(e),r=this._vboCaches.get(s);if(r)return r;const t=new o(this,e);return this._vboCaches.set(s,t),t}get indexBufferCache(){return this._indexBufferCache??=new i(this),this._indexBufferCache}getTextureBufferCache(e){const s=JSON.stringify(e),r=this._textureBufferCaches.get(s);if(r)return r;const t=new h(this,e);return this._textureBufferCaches.set(s,t),t}get output(){return this._output}set output(e){this._output!==e&&(this._output=e,this.setDrawBuffers(f(this._state.drawFramebuffer)))}setDrawBuffers(e){return s(this.output)?super.setDrawBuffers([n]):super.setDrawBuffers(e)}bindTechnique(e,s,r,t){return this.debugBoundTechnique=e.declaredClass,this.useProgram(e.program),this.setPipelineState(e.getPipeline(s)),e.program.bind(s),r&&(e.program.bindPass(r,s),t&&e.program.bindDraw(s,r,t)),e.program}runAppleAmdDriverHelper(){this.driverTest.drawArraysRequiresIndicesTypeReset.result&&(this._appleAmdDriverHelper??=new u(this),this._appleAmdDriverHelper.run())}get isAssumedMetalDriver(){if(null==this._isAssumedMetalDriver&&(this._isAssumedMetalDriver=!!has("ios")||!!has("safari"),!this._isAssumedMetalDriver&&has("mac")&&has("chrome"))){const e=this.capabilities.rendererInfo?.getUnmaskedRenderer().toLowerCase(),s=e?.includes("apple")&&e?.includes("angle")&&e?.includes("metal");this._isAssumedMetalDriver=s??!0}return this._isAssumedMetalDriver}get test(){}}export{p as RenderingContext};
2
+ import has from"../../../../core/has.js";import{disposeMaybe as e}from"../../../../core/maybe.js";import{isDepthOrShadowLike as s}from"../core/shaderLibrary/ShaderOutput.js";import{ScreenSpaceGeometry as t}from"../effects/ScreenSpaceGeometry.js";import{createEmptyTexture as r}from"./glUtil3D.js";import{IndexBufferCache as i}from"../materials/renderers/IndexBufferCache.js";import{TextureBufferCache as h}from"../materials/renderers/TextureBufferCache.js";import{VaoCache as a}from"../materials/renderers/VaoCache.js";import{VboCache as o}from"../materials/renderers/VboCache.js";import{DrawBufferNone as u}from"../../../webgl/enums.js";import{RenderingContext as n,getFramebufferDrawBuffers as c}from"../../../webgl/RenderingContext.js";class f extends n{constructor(e,s){super(e,s),this.emptyTexture=r(this),this._vaoCaches=new Map,this._vboCaches=new Map,this._indexBufferCache=null,this._textureBufferCaches=new Map,this._output=0,this.debugBoundTechnique="",this._refCount=1,this._newCache=s.newCache,this._screen=new t(this)}configure(e){super.configure(e),this._newCache=e.newCache}destroy(){this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache=e(this._indexBufferCache),this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear(),--this._refCount>0||this.dispose()}ref(){++this._refCount}get refCount(){return this._refCount}dispose(){this.emptyTexture.dispose(),this._screen.destroy(),this._screen=null,super.dispose(),this._vaoCaches.forEach(e=>e.dispose()),this._vaoCaches.clear(),this._vboCaches.forEach(e=>e.dispose()),this._vboCaches.clear(),this._indexBufferCache?.dispose(),this._indexBufferCache=null,this._textureBufferCaches.forEach(e=>e.dispose()),this._textureBufferCaches.clear()}get newCache(){return this._newCache}get screen(){return this._screen}getVaoCache(e){const s=JSON.stringify(e),t=this._vaoCaches.get(s);if(t)return t;const r=new a(this,e);return this._vaoCaches.set(s,r),r}getVboCache(e){const s=JSON.stringify(e),t=this._vboCaches.get(s);if(t)return t;const r=new o(this,e);return this._vboCaches.set(s,r),r}get indexBufferCache(){return this._indexBufferCache??=new i(this),this._indexBufferCache}getTextureBufferCache(e){const s=JSON.stringify(e),t=this._textureBufferCaches.get(s);if(t)return t;const r=new h(this,e);return this._textureBufferCaches.set(s,r),r}get output(){return this._output}set output(e){this._output!==e&&(this._output=e,this.setDrawBuffers(c(this._state.drawFramebuffer)))}setDrawBuffers(e){return s(this.output)?super.setDrawBuffers([u]):super.setDrawBuffers(e)}bindTechnique(e,s,t,r){return this.debugBoundTechnique=e.declaredClass,this.useProgram(e.program),this.setPipelineState(e.getPipeline(s)),e.program.bind(s),t&&(e.program.bindPass(t,s),r&&e.program.bindDraw(s,t,r)),e.program}get isAssumedMetalDriver(){if(null==this._isAssumedMetalDriver&&(this._isAssumedMetalDriver=!!has("ios")||!!has("safari"),!this._isAssumedMetalDriver&&has("mac")&&has("chrome"))){const e=this.capabilities.rendererInfo?.getUnmaskedRenderer().toLowerCase(),s=e?.includes("apple")&&e?.includes("angle")&&e?.includes("metal");this._isAssumedMetalDriver=s??!0}return this._isAssumedMetalDriver}get test(){}}export{f as RenderingContext};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import r from"../../../../../core/Error.js";import{someMap as n,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l,subclass as c}from"../../../../../core/accessorSupport/decorators.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{subtract as d,dot as u,transformMat4 as m}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _,freeze as p}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import v from"../../../webgl/RenderCamera.js";import{AsyncRenderPlugin as b}from"../../effects/RenderPlugin.js";import{DepthRange as I}from"../DepthRange.js";import{assert as C}from"../Util.js";import{InstanceData as D}from"./InstanceData.js";import{InstanceOctree as R}from"./InstanceOctree.js";import{LevelSelector as E}from"./LevelSelector.js";import{LodLevel as x}from"./LodLevel.js";import{getRenderInstanceDataLayout as S,RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as j}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as U}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as T}from"../../../../support/HighlightDefaults.js";import{TaskPriority as O,noBudget as A}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as M}from"../../../../webgl/Util.js";import{fromLayout as q}from"../../../../webgl/VertexAttributeLocations.js";const B=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map(e=>e.minScreenSpaceRadius);return new E(t,r)};let F=class extends b{constructor(e,t){super(e),this.type=3,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDatas=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[2,e=>this._produces(e)],[4,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new D({shaderTransformation:e.shaderTransformation},e.symbol.materialParameters),this.addHandles(t.registerTask(O.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=S(this.symbol.materialParameters),this._glInstanceBufferLayout=y(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",()=>this._requestUpdateCycle()),this._instanceData.events.on("instance-transform-changed",({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)}),this._instanceData.events.on("instance-visibility-changed",({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)}),this._instanceData.events.on("instance-highlight-changed",()=>this._requestUpdateCycle(!0))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDatas.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDatas)t[0]!==T&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDatas.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerViewUid(){return this.metadata.layerViewUid}get instanceData(){return this._instanceData}get hasEmitters(){return this._levels.some(e=>e.components.some(e=>e.material.hasEmissions))}get usedMemory(){return this._allRenderInstanceData.reduce((e,t)=>t.reduce((e,t)=>e+t.usedMemory,e),this._levels.reduce((e,t)=>e+t.components.reduce((e,t)=>e+t.usedMemory,0),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach((e,r)=>{const n=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:n,renderedTriangles:n*s,trianglesPerInstance:s})}),{totalInstances:e,renderedInstances:t.reduce((e,t)=>e+t.renderedInstances,0),renderedTriangles:t.reduce((e,t)=>e+t.renderedTriangles,0),levels:t}}_createRenderInstanceDataArray(){const{rctx:e}=this._context.renderContext;return this.symbol.levels.map(t=>new w(e,this._instanceBufferLayout))}async initializeRenderContext(e,r){this._context=e,this._defaultRenderInstanceData=this._createRenderInstanceDataArray();const n=await Promise.allSettled(this.symbol.levels.map(t=>x.create(e,t,r))),s=n.map(e=>"fulfilled"===e.status?e.value:null).filter(t);if(i(r)||s.length!==n.length){s.forEach(e=>e.destroy()),o(r);for(const e of n)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=B(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach(e=>e.destroy()),this._defaultRenderInstanceData.forEach(e=>e.destroy()),this._highlightRenderInstanceDatas.forEach(e=>e.forEach(e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some(e=>e.components.some(e=>{const t=e.material.produces.get(4);return t?.(0)}))}hasHighlights(){return n(this._highlightRenderInstanceDatas,e=>e.some(e=>e.size>0))}_produces(e){return(8!==e||this.hasHighlights())&&(4!==e||this.hasHighlight(T))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(A),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const r=new Array,n=this.levels;return t.forEach(t=>n.forEach(({components:n},s)=>n.forEach(n=>r.push(this._beginComponent(e,t[s],n))))),r}render(e,t){const r=this._getInstanceDatas(e);if(!r||null==t)return;let n=0;const s=this.levels;r.forEach(r=>s.forEach(({components:s},a)=>s.forEach(s=>this._renderComponent(e,t[n++],r[a],s,a)))),e.rctx.unbindBuffer(34962),e.rctx.bindVAO(null)}_getInstanceDatas(e){const{output:t,bind:r}=e,n=8===t,s=4===t,a=5!==t;if(!n&&!s)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;const{_highlightRenderInstanceDatas:i}=this;if(a){if(n){const e=r.highlight?.name;if(!e)return null;const t=i.get(e);return t?[t]:null}const e=i.get(T);return s?e?[e]:null:Array.from(i.values())}return null}intersect(e,t,r,n){if(!this.baseMaterial.visible||null==this._octree)return;const s=f();d(s,n,r);const a=s=>{this._instanceData.getCombinedModelTransform(s,N),e.transform.set(N),m(G,r,e.transform.inverse),m(W,n,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;4&a&&(C(!!(18&a),"invalid instance state"),C(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,G,W,s,this.metadata,o))};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(r,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new R(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)18&t.get(r)&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new I;const t=e.viewForward,r=this._octree.findClosest(t,1,e.frustum),n=this._octree.findClosest(t,-1,e.frustum);if(null==r||null==n)return new I;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(r,z),d(z,z,s);const i=u(z,t)-z[3];a.boundingSphere.getVec(n,z),d(z,z,s);const o=u(z,t)+z[3];return new I(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.startUpdateCycle()))}get readyToRun(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:n,_levelSelector:a}=this;this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.beginUpdate()));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500),{_highlightRenderInstanceDatas:u}=this;for(let m=0;m<l&&!e.done;++m){h===this._cycleStartIndex&&this._startUpdateCycle();const m=o.state.get(h);let f=0;if(!(1&m)){h=h+1===c?0:h+1,l++;continue}const _=o.lodLevel.get(h);if(2&m&&this._defaultRenderInstanceData[_].freeTail(),16&m){const e=i.geHighlightOptionsPrev(h);if(e){const t=u.get(e);if(!t)throw new r("internal:lod-renderer","Internal error in lodRenderer");t[_].freeTail(),t.every(e=>e.isEmpty)&&(t.forEach(e=>e.destroy()),u.delete(e))}}if(32&m)i.freeInstance(h);else if(4&m){let e=0;if(t&&(o.modelOrigin.getVec(h,P),e=a.selectLevel(P,i.getCombinedMedianScaleFactor(h),n)),f=-83&m,e>=0)if(8&m){const t=i.getHighlightName(h);if(t){const n=()=>{const e=this._createRenderInstanceDataArray();return e.forEach(e=>e.beginUpdate()),e},a=s(u,t,n);if(e>=a.length)throw new r("internal:lod-renderer",`LodRenderer internal error - missing lodLevel ${e}`);H(a[e],o,h)}f|=16}else H(this._defaultRenderInstanceData[e],o,h),f|=2;o.state.set(h,f),o.lodLevel.set(h,e)}else f=-83&m,o.state.set(h,f);const p=!!(18&m),g=!!(18&f);null!=this._octreeCached&&(!p&&g?this._octreeCached.addInstance(h):p&&!g?this._octreeCached.removeInstance(h):p&&g&&64&m&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))),h=h+1===c?0:h+1,h%d===0&&e.madeProgress(),p!==g&&this.metadata.notifyGraphicVisibilityChanged(h),g&&64&m&&this.metadata.notifyGraphicGeometryChanged(h)}this._instanceIndex=h,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.endUpdate())),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const n=r.glMaterials.load(e.rctx,e.bind.slot,e.output);return n?.beginSlot(e.bind)}_renderComponent(e,t,r,n,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,n.material.parameters,Y),l=this._glInstanceBufferLayout;o.assertCompatibleVertexAttributeLocations(n.vao,q(l)),i.bindVAO(n.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&0===e.output&&(o.setUniform4fv("externalColor",k[Math.min(s,k.length-1)]),o.setUniform1i("symbolColorMixMode",L.replace));const c=r.capacity,h=r.headIndex,d=r.tailIndex,u=r.firstIndex,m=(e,s)=>{M(i,o.locations,r.buffer,e),i.drawArraysInstanced(t.primitiveType,0,n.numVertices,s-e)};n.material.transparent&&null!=u?h>d?(C(u>=d&&u<=h,"invalid firstIndex"),m(u,h),m(d,u)):h<d&&(u<=h?(C(u>=0&&u<=h,"invalid firstIndex"),m(u,h),m(d,c),m(0,u)):(C(u>=d&&u<=c,"invalid firstIndex"),m(u,c),m(0,h),m(d,u))):h>d?m(d,h):h<d&&(m(0,h),m(d,c))}};function H(e,t,r){const n=e.allocateHead();V(t,r,e.view,n)}function V(e,t,r,n){j(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,n),r.model.copyFrom(n,e.model,t),r.modelNormal.copyFrom(n,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(n,e.color,t),e.olidColor&&r.olidColor&&r.olidColor.copyFrom(n,e.olidColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(n,e.featureAttribute,t)}e([l({constructOnly:!0})],F.prototype,"symbol",void 0),e([l({constructOnly:!0})],F.prototype,"metadata",void 0),e([l({constructOnly:!0})],F.prototype,"shaderTransformation",void 0),e([l()],F.prototype,"_instanceData",void 0),e([l()],F.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],F.prototype,"_enableLevelSelection",null),e([l()],F.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],F.prototype,"readyToRun",null),F=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],F);const P=f(),z=_(),N=h(),G=f(),W=f(),k=[p(1,0,1,1),p(0,0,1,1),p(0,1,0,1),p(1,1,0,1),p(1,0,0,1)],Y=new U;export{F as LodRenderer};
2
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Error.js";import{someMap as s,getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l,subclass as c}from"../../../../../core/accessorSupport/decorators.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{subtract as d,dot as u,transformMat4 as m}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as _,freeze as p}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import v from"../../../webgl/RenderCamera.js";import{AsyncRenderPlugin as b}from"../../effects/RenderPlugin.js";import{DepthRange as I}from"../DepthRange.js";import{assert as C}from"../Util.js";import{InstanceData as D}from"./InstanceData.js";import{InstanceOctree as R}from"./InstanceOctree.js";import{LevelSelector as E}from"./LevelSelector.js";import{LodLevel as x}from"./LodLevel.js";import{getRenderInstanceDataLayout as S,RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as j}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as U}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as T}from"../../../../support/HighlightDefaults.js";import{TaskPriority as O,noBudget as A}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as M}from"../../../../webgl/Util.js";import{fromLayout as q}from"../../../../webgl/VertexAttributeLocations.js";const B=e=>{const t=e.baseBoundingSphere.radius,n=e.levels.map(e=>e.minScreenSpaceRadius);return new E(t,n)};let F=class extends b{constructor(e,t){super(e),this.type=3,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDatas=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[2,e=>this._produces(e)],[4,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new D({shaderTransformation:e.shaderTransformation},e.symbol.materialParameters),this.addHandles(t.registerTask(O.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=S(this.symbol.materialParameters),this._glInstanceBufferLayout=y(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",()=>this._requestUpdateCycle()),this._instanceData.events.on("instance-transform-changed",({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)}),this._instanceData.events.on("instance-visibility-changed",({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)}),this._instanceData.events.on("instance-highlight-changed",()=>this._requestUpdateCycle(!0))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDatas.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDatas)t[0]!==T&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDatas.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerViewUid(){return this.metadata.layerViewUid}get instanceData(){return this._instanceData}get hasEmitters(){return this._levels.some(e=>e.components.some(e=>e.material.hasEmissions))}get usedMemory(){return this._allRenderInstanceData.reduce((e,t)=>t.reduce((e,t)=>e+t.usedMemory,e),this._levels.reduce((e,t)=>e+t.components.reduce((e,t)=>e+t.usedMemory,0),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach((e,n)=>{const s=this._allRenderInstanceData[0][n].size+this._allRenderInstanceData[1][n].size,r=e.triangleCount;t.push({renderedInstances:s,renderedTriangles:s*r,trianglesPerInstance:r})}),{totalInstances:e,renderedInstances:t.reduce((e,t)=>e+t.renderedInstances,0),renderedTriangles:t.reduce((e,t)=>e+t.renderedTriangles,0),levels:t}}_createRenderInstanceDataArray(){const{rctx:e}=this._context.renderContext;return this.symbol.levels.map(t=>new w(e,this._instanceBufferLayout))}async initializeRenderContext(e,n){this._context=e,this._defaultRenderInstanceData=this._createRenderInstanceDataArray();const s=await Promise.allSettled(this.symbol.levels.map(t=>x.create(e,t,n))),r=s.map(e=>"fulfilled"===e.status?e.value:null).filter(t);if(i(n)||r.length!==s.length){r.forEach(e=>e.destroy()),o(n);for(const e of s)if("rejected"===e.status)throw e.reason}this._levels=r,this._levelSelector=B(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach(e=>e.destroy()),this._defaultRenderInstanceData.forEach(e=>e.destroy()),this._highlightRenderInstanceDatas.forEach(e=>e.forEach(e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some(e=>e.components.some(e=>{const t=e.material.produces.get(4);return t?.(0)}))}hasHighlights(){return s(this._highlightRenderInstanceDatas,e=>e.some(e=>e.size>0))}_produces(e){return(8!==e||this.hasHighlights())&&(4!==e||this.hasHighlight(T))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(A),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const n=new Array,s=this.levels;return t.forEach(t=>s.forEach(({components:s},r)=>s.forEach(s=>n.push(this._beginComponent(e,t[r],s))))),n}render(e,t){const n=this._getInstanceDatas(e);if(!n||null==t)return;let s=0;const r=this.levels;n.forEach(n=>r.forEach(({components:r},a)=>r.forEach(r=>this._renderComponent(e,t[s++],n[a],r,a)))),e.rctx.unbindBuffer(34962),e.rctx.bindVAO(null)}_getInstanceDatas(e){const{output:t,bind:n}=e,s=8===t,r=4===t,a=5!==t;if(!s&&!r)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;const{_highlightRenderInstanceDatas:i}=this;if(a){if(s){const e=n.highlight?.name;if(!e)return null;const t=i.get(e);return t?[t]:null}const e=i.get(T);return r?e?[e]:null:Array.from(i.values())}return null}intersect(e,t,n,s){if(!this.baseMaterial.visible||null==this._octree)return;const r=f();d(r,s,n);const a=r=>{this._instanceData.getCombinedModelTransform(r,N),e.transform.set(N),m(G,n,e.transform.inverse),m(W,s,e.transform.inverse);const a=this._instanceData.getState(r),i=this._instanceData.getLodLevel(r),o=this._levels.length;4&a&&(C(!!(18&a),"invalid instance state"),C(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,G,W,r,this.metadata,o))};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(n,r,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new R(e,this.baseBoundingSphere);for(let n=0;n<e.capacity;++n)18&t.get(n)&&this._octreeCached.addInstance(n)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new I;const t=e.viewForward,n=this._octree.findClosest(t,1,e.frustum),s=this._octree.findClosest(t,-1,e.frustum);if(null==n||null==s)return new I;const r=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(n,z),d(z,z,r);const i=u(z,t)-z[3];a.boundingSphere.getVec(s,z),d(z,z,r);const o=u(z,t)+z[3];return new I(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.startUpdateCycle()))}get readyToRun(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:s,_levelSelector:a}=this;this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.beginUpdate()));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500),{_highlightRenderInstanceDatas:u}=this;for(let m=0;m<l&&!e.done;++m){h===this._cycleStartIndex&&this._startUpdateCycle();const m=o.state.get(h);let f=0;if(!(1&m)){h=h+1===c?0:h+1,l++;continue}const _=o.lodLevel.get(h);if(2&m&&this._defaultRenderInstanceData[_].freeTail(),16&m){const e=i.geHighlightOptionsPrev(h);if(e){const t=u.get(e);if(!t)throw new n("internal:lod-renderer","Internal error in lodRenderer");t[_].freeTail(),t.every(e=>e.isEmpty)&&(t.forEach(e=>e.destroy()),u.delete(e))}}if(32&m)i.freeInstance(h);else if(4&m){let e=0;if(t&&(o.modelOrigin.getVec(h,P),e=a.selectLevel(P,i.getCombinedMedianScaleFactor(h),s)),f=-83&m,e>=0)if(8&m){const t=i.getHighlightName(h);if(t){const s=()=>{const e=this._createRenderInstanceDataArray();return e.forEach(e=>e.beginUpdate()),e},a=r(u,t,s);if(e>=a.length)throw new n("internal:lod-renderer",`LodRenderer internal error - missing lodLevel ${e}`);V(a[e],o,h)}f|=16}else V(this._defaultRenderInstanceData[e],o,h),f|=2;o.state.set(h,f),o.lodLevel.set(h,e)}else f=-83&m,o.state.set(h,f);const p=!!(18&m),g=!!(18&f);null!=this._octreeCached&&(!p&&g?this._octreeCached.addInstance(h):p&&!g?this._octreeCached.removeInstance(h):p&&g&&64&m&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))),h=h+1===c?0:h+1,h%d===0&&e.madeProgress(),p!==g&&this.metadata.notifyGraphicVisibilityChanged(h),g&&64&m&&this.metadata.notifyGraphicGeometryChanged(h)}this._instanceIndex=h,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.endUpdate())),this._context.requestRender()}_beginComponent(e,t,n){if(0===t.size)return null;const s=n.glMaterials.load(e.rctx,e.bind.slot,e.output);return s?.beginSlot(e.bind)}_renderComponent(e,t,n,s,r){if(!t)return;const{bind:a,rctx:i}=e,o=i.bindTechnique(t,a,s.material.parameters,Y),l=this._glInstanceBufferLayout;o.assertCompatibleVertexAttributeLocations(s.vao,q(l)),i.bindVAO(s.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&0===e.output&&(o.setUniform4fv("externalColor",k[Math.min(r,k.length-1)]),o.setUniform1i("symbolColorMixMode",L.replace));const c=n.capacity,h=n.headIndex,d=n.tailIndex,u=n.firstIndex,m=(e,r)=>{M(i,o.locations,n.buffer,e),i.drawArraysInstanced(t.primitiveType,0,s.numVertices,r-e)};s.material.transparent&&null!=u?h>d?(C(u>=d&&u<=h,"invalid firstIndex"),m(u,h),m(d,u)):h<d&&(u<=h?(C(u>=0&&u<=h,"invalid firstIndex"),m(u,h),m(d,c),m(0,u)):(C(u>=d&&u<=c,"invalid firstIndex"),m(u,c),m(0,h),m(d,u))):h>d?m(d,h):h<d&&(m(0,h),m(d,c))}};function V(e,t,n){const s=e.allocateHead();H(t,n,e.view,s)}function H(e,t,n,s){j(e.modelOrigin,t,n.modelOriginHi,n.modelOriginLo,s),n.model.copyFrom(s,e.model,t),n.modelNormal.copyFrom(s,e.modelNormal,t),e.color&&n.color&&n.color.copyFrom(s,e.color,t),e.olidColor&&n.olidColor&&n.olidColor.copyFrom(s,e.olidColor,t),e.featureAttribute&&n.featureAttribute&&n.featureAttribute.copyFrom(s,e.featureAttribute,t)}e([l({constructOnly:!0})],F.prototype,"symbol",void 0),e([l({constructOnly:!0})],F.prototype,"metadata",void 0),e([l({constructOnly:!0})],F.prototype,"shaderTransformation",void 0),e([l()],F.prototype,"_instanceData",void 0),e([l()],F.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],F.prototype,"_enableLevelSelection",null),e([l()],F.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],F.prototype,"readyToRun",null),F=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],F);const P=f(),z=_(),N=h(),G=f(),W=f(),k=[p(1,0,1,1),p(0,0,1,1),p(0,1,0,1),p(1,1,0,1),p(1,0,0,1)],Y=new U;export{F as LodRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../core/shaderLibrary/ForwardLinearDepthToWriteShadowMap.glsl.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/attributes/PathVertexPosition.glsl.js";import"../core/shaderLibrary/output/OutputDepth.glsl.js";import"../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import"../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../core/shaderLibrary/shading/MainLighting.glsl.js";import"../core/shaderLibrary/shading/Normals.glsl.js";import"../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float3PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../effects/weather/SnowCover.glsl.js";import"../shaders/OutputColorHighlightOLID.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/Path.glsl.js";
2
+ import"../core/shaderLibrary/ForwardLinearDepthToWriteShadowMap.glsl.js";import"../core/shaderLibrary/ShaderOutput.js";import"../core/shaderLibrary/Slice.glsl.js";import"../core/shaderLibrary/Transform.glsl.js";import"../core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js";import"../core/shaderLibrary/attributes/PathVertexPosition.glsl.js";import"../core/shaderLibrary/output/OutputDepth.glsl.js";import"../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js";import"../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../core/shaderLibrary/shading/MainLighting.glsl.js";import"../core/shaderLibrary/shading/Normals.glsl.js";import"../core/shaderLibrary/shading/NormalUtils.glsl.js";import"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../core/shaderLibrary/util/ColorConversion.glsl.js";import"../core/shaderLibrary/util/View.glsl.js";import"../core/shaderModules/Float3PassUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/glsl.js";import"../effects/snowcover/SnowCover.glsl.js";import"../shaders/OutputColorHighlightOLID.glsl.js";import"../../../webgl/ShaderBuilder.js";export{b as build}from"../../../../chunks/Path.glsl.js";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{isColor as r}from"../core/shaderLibrary/ShaderOutput.js";import{InstancedDoubleConfiguration as e}from"../core/shaderLibrary/attributes/InstancedDoubleConfiguration.js";import t from"../lib/GLMaterial.js";import{DefaultBufferWriter as s}from"./DefaultBufferWriter.js";import{PositionUvLayout as i}from"./DefaultLayouts.js";import{TriangleMaterial as o}from"./TriangleMaterial.js";import{SlicePlaneMaterialPassParameters as a,SlicePlaneMaterialTechnique as n}from"../shaders/SlicePlaneMaterialTechnique.js";class u extends o{constructor(t){super(t,f),this.visible=!0,this.produces=new Map([[9,e=>r(e)]]),this._configuration=new e}createGLMaterial(r){return new c(r)}createBufferWriter(){return new s(i)}getConfiguration(){return this._configuration}}class c extends t{constructor(r){super(r)}beginSlot(r){return this.getTechnique(n,r)}}class f extends a{constructor(){super(...arguments),this.renderOccluded=1,this.testsTransparentRenderOrder=0,this.isDecoration=!1}}export{f as Parameters,u as SlicePlaneMaterial};
2
+ import{isColor as r}from"../core/shaderLibrary/ShaderOutput.js";import e from"../lib/GLMaterial.js";import{DefaultBufferWriter as t}from"./DefaultBufferWriter.js";import{PositionUvLayout as i}from"./DefaultLayouts.js";import{TriangleMaterial as s}from"./TriangleMaterial.js";import{SlicePlaneMaterialPassParameters as o,SlicePlaneMaterialTechnique as n}from"../shaders/SlicePlaneMaterialTechnique.js";import{SlicePlaneMaterialTechniqueConfiguration as a}from"../shaders/SlicePlaneMaterialTechniqueConfiguration.js";class u extends s{constructor(e){super(e,f),this.visible=!0,this.produces=new Map([[9,e=>r(e)]]),this._configuration=new a}createGLMaterial(r){return new c(r)}createBufferWriter(){return new t(i)}getConfiguration(r,e){return super.getConfiguration(r,e,this._configuration),this._configuration}}class c extends e{constructor(r){super(r)}beginSlot(r){return this.getTechnique(n,r)}}class f extends o{constructor(){super(...arguments),this.renderOccluded=1,this.testsTransparentRenderOrder=0,this.isDecoration=!1}}export{f as Parameters,u as SlicePlaneMaterial};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{property as s,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{GLMaterials as n}from"../../lib/GLMaterials.js";import{assert as a}from"../../lib/Util.js";import{DrawParameters as o}from"../DrawParameters.js";import{getStrideForDataType as l}from"./IndexLayout.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";let d=class extends e{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new o,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,e)=>{this._produces.set(e,e=>!(0===this.dataByBaseInstance.size||!(8!==e&&4!==e||this._hasHighlights))&&t(e))})}initializeRenderContext(t){this._glMaterials=new n(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=i(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:e,bind:i}=t,s=this.material.produces.get(i.slot);if(!s?.(e))return null;const{highlight:r,slot:n}=i,a=4===e,o=8===e,l=o||a,d=r?.name;if(l&&(0===this._highlightNames.size||o&&d&&!this._highlightNames.has(d)))return null;const u=t=>o&&!!d&&!t.has(d),c=5===e,m=!(l||c);for(const g of this.dataByBaseInstance.values())for(const s of g.dataByOrigin.values())for(const r of s.buffers){if(u(r.highlightNames))continue;const s=a?r.drawCommandsHighlights.get(h):l?d?r.drawCommandsHighlights.get(d):r.drawCommandsHighlights.size>0:((c&&r.needsMultipleCommands?r.drawCommandsShadowHighlightRest:r.drawCommandsDefault)||null)?.length??!1,o=m&&r.drawCommandsOccludees||null;if(s||o?.length){const s=this._glMaterials.load(t.rctx,n,e),r=s?.beginSlot(i);if(r)return r}}return null}render(t,e){const{output:i,bind:s}=t,{highlight:r}=s,n=8===i,o=r?.name??"";if(n&&!r)return;const l=4===i,d=n||l,p=5===i,w=!(d||p),{rctx:_}=t;_.runAppleAmdDriverHelper();const C=_.bindTechnique(e,s,this.material.parameters),x=this.material.useIndexing;for(const B of this.dataByBaseInstance.values()){const{baseInstanceData:t}=B,i=null!=t;a(!(i&&x),"Instanced indexed rendering is not supported");const r=i?f:x?g:m,H=i?c:u;for(const a of B.dataByOrigin.values()){this._drawParameters.origin=a.origin;for(const i of a.buffers){if(n&&(!i.hasHighlights||!i.drawCommandsHighlights.has(o)))continue;if(l&&(!i.hasHighlights||!i.drawCommandsHighlights.has(h)))continue;this._drawParameters.textureBuffer=i.textureBuffer?.texture;const a=H(i),u=y(a,i.needsMultipleCommands,o,l,d,p),c=b(a,w);(u?.length||c?.length)&&(C.bindDraw(s,this.material.parameters,this._drawParameters),r(_,i,t,e,u,c,s)),this._drawParameters.textureBuffer=null}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const e of this.dataByBaseInstance.values())for(const i of e.dataByOrigin.values())for(const e of i.buffers)for(const i of e.highlightNames)t.add(i);this._updateProduces()}get test(){}};t([s({constructOnly:!0})],d.prototype,"material",void 0),t([s({constructOnly:!0})],d.prototype,"dataByBaseInstance",void 0),d=t([r("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],d);const u=t=>t,c=t=>t.instancedCommandVAOs,m=(t,{vao:e},i,s,r,n,a)=>{s.ensureAttributeLocations(e),t.bindVAO(e),p(t,s,r,a,!1),p(t,s,n,a,!0)},g=(t,{vao:e},i,s,r,n,o)=>{s.ensureAttributeLocations(e),t.bindVAO(e);const l=e.indexBuffer?.indexType;a(null!=l,"Missing index array"),w(t,s,r,o,!1,l),w(t,s,n,o,!0,l)},f=(t,e,{baseCommand:i},s,r,n,a)=>{_(t,s,i,r,a,!1),_(t,s,i,n,a,!0)};function p(t,e,i,s,r){if(i?.length){t.setPipelineState(e.getPipeline(s,r));for(const s of i)t.drawArrays(e.primitiveType,s.first,s.count)}}function w(t,e,i,s,r,n){if(!i?.length)return;const a=l(n);t.setPipelineState(e.getPipeline(s,r));for(const o of i)t.drawElements(e.primitiveType,o.count,n,o.first*a)}function _(t,e,{first:i,count:s},r,n,a){if(r?.length){t.setPipelineState(e.getPipeline(n,a));for(const{vao:n,instanceCount:a}of r)e.ensureAttributeLocations(n),t.bindVAO(n),t.drawArraysInstanced(e.primitiveType,i,s,a)}}function y(t,e,i,s,r,n){const a=r&&!s?t.drawCommandsHighlights.get(i)??null:null;return s?t.drawCommandsHighlights.get(h):r?a:n&&e?t.drawCommandsShadowHighlightRest:t.drawCommandsDefault}function b(t,e){return e&&t.drawCommandsOccludees||null}export{d as VaoRenderer};
2
+ import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{property as s,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{GLMaterials as a}from"../../lib/GLMaterials.js";import{assert as n}from"../../lib/Util.js";import{DrawParameters as o}from"../DrawParameters.js";import{getStrideForDataType as l}from"./IndexLayout.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";let d=class extends e{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new o,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,e)=>{this._produces.set(e,e=>!(0===this.dataByBaseInstance.size||!(8!==e&&4!==e||this._hasHighlights))&&t(e))})}initializeRenderContext(t){this._glMaterials=new a(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=i(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:e,bind:i}=t,s=this.material.produces.get(i.slot);if(!s?.(e))return null;const{highlight:r,slot:a}=i,n=4===e,o=8===e,l=o||n,d=r?.name;if(l&&(0===this._highlightNames.size||o&&d&&!this._highlightNames.has(d)))return null;const u=t=>o&&!!d&&!t.has(d),c=5===e,g=!(l||c);for(const m of this.dataByBaseInstance.values())for(const s of m.dataByOrigin.values())for(const r of s.buffers){if(u(r.highlightNames))continue;const s=n?r.drawCommandsHighlights.get(h):l?d?r.drawCommandsHighlights.get(d):r.drawCommandsHighlights.size>0:((c&&r.needsMultipleCommands?r.drawCommandsShadowHighlightRest:r.drawCommandsDefault)||null)?.length??!1,o=g&&r.drawCommandsOccludees||null;if(s||o?.length){const s=this._glMaterials.load(t.rctx,a,e),r=s?.beginSlot(i);if(r)return r}}return null}render(t,e){const{output:i,bind:s}=t,{highlight:r}=s,a=8===i,o=r?.name??"";if(a&&!r)return;const l=4===i,d=a||l,p=5===i,w=!(d||p),{rctx:_}=t,C=_.bindTechnique(e,s,this.material.parameters),x=this.material.useIndexing;for(const B of this.dataByBaseInstance.values()){const{baseInstanceData:t}=B,i=null!=t;n(!(i&&x),"Instanced indexed rendering is not supported");const r=i?f:x?m:g,H=i?c:u;for(const n of B.dataByOrigin.values()){this._drawParameters.origin=n.origin;for(const i of n.buffers){if(a&&(!i.hasHighlights||!i.drawCommandsHighlights.has(o)))continue;if(l&&(!i.hasHighlights||!i.drawCommandsHighlights.has(h)))continue;this._drawParameters.textureBuffer=i.textureBuffer?.texture;const n=H(i),u=y(n,i.needsMultipleCommands,o,l,d,p),c=b(n,w);(u?.length||c?.length)&&(C.bindDraw(s,this.material.parameters,this._drawParameters),r(_,i,t,e,u,c,s)),this._drawParameters.textureBuffer=null}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const e of this.dataByBaseInstance.values())for(const i of e.dataByOrigin.values())for(const e of i.buffers)for(const i of e.highlightNames)t.add(i);this._updateProduces()}get test(){}};t([s({constructOnly:!0})],d.prototype,"material",void 0),t([s({constructOnly:!0})],d.prototype,"dataByBaseInstance",void 0),d=t([r("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],d);const u=t=>t,c=t=>t.instancedCommandVAOs,g=(t,{vao:e},i,s,r,a,n)=>{s.ensureAttributeLocations(e),t.bindVAO(e),p(t,s,r,n,!1),p(t,s,a,n,!0)},m=(t,{vao:e},i,s,r,a,o)=>{s.ensureAttributeLocations(e),t.bindVAO(e);const l=e.indexBuffer?.indexType;n(null!=l,"Missing index array"),w(t,s,r,o,!1,l),w(t,s,a,o,!0,l)},f=(t,e,{baseCommand:i},s,r,a,n)=>{_(t,s,i,r,n,!1),_(t,s,i,a,n,!0)};function p(t,e,i,s,r){if(i?.length){t.setPipelineState(e.getPipeline(s,r));for(const s of i)t.drawArrays(e.primitiveType,s.first,s.count)}}function w(t,e,i,s,r,a){if(!i?.length)return;const n=l(a);t.setPipelineState(e.getPipeline(s,r));for(const o of i)t.drawElements(e.primitiveType,o.count,a,o.first*n)}function _(t,e,{first:i,count:s},r,a,n){if(r?.length){t.setPipelineState(e.getPipeline(a,n));for(const{vao:a,instanceCount:n}of r)e.ensureAttributeLocations(a),t.bindVAO(a),t.drawArraysInstanced(e.primitiveType,i,s,n)}}function y(t,e,i,s,r,a){const n=r&&!s?t.drawCommandsHighlights.get(i)??null:null;return s?t.drawCommandsHighlights.get(h):r?n:a&&e?t.drawCommandsShadowHighlightRest:t.drawCommandsDefault}function b(t,e){return e&&t.drawCommandsOccludees||null}export{d as VaoRenderer};