@arcgis/core 5.2.0-next.42 → 5.2.0-next.44

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 (182) hide show
  1. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/0115681a3de6df0aebdf.js +1 -0
  4. package/assets/esri/core/workers/chunks/025caafc70ac26f0a4ed.js +1 -0
  5. package/assets/esri/core/workers/chunks/{d66d58ed5d66520ab1bf.js → 04a167c110fb7811169d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{72fe7fb03c156f26a589.js → 08e18fb12533fc76e49c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{2e79fb1b8445b2091cdb.js → 0a0732ba8271d7dc985c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{e6b5c015205d38abe037.js → 127b111ee53e4b9184f8.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{2d7cfc68a38dabd8898a.js → 176c5eaaa23a479c88e0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1d1f5578c7d8619f7a46.js +1 -0
  11. package/assets/esri/core/workers/chunks/268637fd6c50264acfc3.js +1 -0
  12. package/assets/esri/core/workers/chunks/296fa9fb80e521c30cb1.js +1 -0
  13. package/assets/esri/core/workers/chunks/{c50e4e8c6188e64e7d45.js → 2974cddb0b0f67df7d2d.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e9511627418c6864148a.js → 305ee2dd597c48a38e64.js} +1 -1
  15. package/assets/esri/core/workers/chunks/3252da57b800356116af.js +1 -0
  16. package/assets/esri/core/workers/chunks/{fd47ee8598e37fea03fe.js → 384b619854ef8a3f6e94.js} +1 -1
  17. package/assets/esri/core/workers/chunks/3af923abeb6e65c4468f.js +1 -0
  18. package/assets/esri/core/workers/chunks/3f4f1595c8a77d072b04.js +1 -0
  19. package/assets/esri/core/workers/chunks/4f09f208ece2ec1db727.js +1 -0
  20. package/assets/esri/core/workers/chunks/{67468c50ecb1fbedda87.js → 549295a5db9bf1536491.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{284e88805184334396fe.js → 57374213084bef59b776.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{2a8d791aef3123e6a3c4.js → 57970d43cdcc5cf57a30.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{dedf678490572c500a19.js → 5b937c405788fd14be8b.js} +2 -2
  24. package/assets/esri/core/workers/chunks/5f9c4dad6952c4c58ebf.js +1 -0
  25. package/assets/esri/core/workers/chunks/706230b70a36d2e038f7.js +1 -0
  26. package/assets/esri/core/workers/chunks/76713b700e053f8bad29.js +1 -0
  27. package/assets/esri/core/workers/chunks/{90ace5f9b4af1beea6bf.js → 7b6b8d0673976c6c26de.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{321dbc60f44819c2b4de.js → 81d55594cee124040565.js} +1 -1
  29. package/assets/esri/core/workers/chunks/8a01fe8d78ca85ea4784.js +1 -0
  30. package/assets/esri/core/workers/chunks/9114a575b78a7ea18d0f.js +1 -0
  31. package/assets/esri/core/workers/chunks/93e705c1147cc8ceca02.js +1 -0
  32. package/assets/esri/core/workers/chunks/{d082de5dd83bd73d209b.js → 94cebc34e49da1e295ed.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{34fcb776e4de1d870bbd.js → a38a7e3a5aa9294ab918.js} +2 -2
  34. package/assets/esri/core/workers/chunks/a8033e606b2db1ee332d.js +1 -0
  35. package/assets/esri/core/workers/chunks/{6f408397e2c8a2ea9805.js → aea247138617e12b699b.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{26e7884d8639df4d994b.js → b03dcf3d55266745f3d1.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{f1d3cf674b6bea89e122.js → b3cefc1895bfd62fc440.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{ec1a2e68957fae48e60b.js → b75db3b1becf8265ec59.js} +3 -3
  39. package/assets/esri/core/workers/chunks/{82f4aa0533db009b11d8.js → bac4d4a9f3a9b7f6864d.js} +2 -2
  40. package/assets/esri/core/workers/chunks/{2f29f08cddd5add9388e.js → c01a121ebe571a848452.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{c1845682cc9a5aac8703.js → c316234837b7ca406b1c.js} +3 -3
  42. package/assets/esri/core/workers/chunks/c3cd38ca8690286d40d7.js +1 -0
  43. package/assets/esri/core/workers/chunks/c6042825f61cd70d54d8.js +1 -0
  44. package/assets/esri/core/workers/chunks/{0646524250bb9fe82935.js → d8b67ca02cdc1e8191e3.js} +1 -1
  45. package/assets/esri/core/workers/chunks/db416ba3132034e20642.js +1 -0
  46. package/assets/esri/core/workers/chunks/{590e977f8eeb379b86c8.js → e5c19e9b6fa53abdca8c.js} +21 -27
  47. package/assets/esri/core/workers/chunks/f9b2727b41943d83d4ca.js +1 -0
  48. package/assets/esri/core/workers/chunks/{934044f2ef6ce199b399.js → fc880b275f5eaf42171e.js} +1 -1
  49. package/assets/esri/libs/basisu/basis_encoder.wasm +0 -0
  50. package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
  51. package/chunks/Component.glsl.js +2 -2
  52. package/chunks/CutFillTargetDepth.glsl.js +1 -2
  53. package/chunks/Fog.glsl.js +3 -3
  54. package/chunks/GlobalIllumination.glsl.js +21 -21
  55. package/chunks/GlobalIlluminationBlur.glsl.js +1 -1
  56. package/chunks/GlowComposition.glsl.js +3 -3
  57. package/chunks/OITAddEmission.glsl.js +1 -1
  58. package/chunks/Path.glsl.js +4 -4
  59. package/chunks/Terrain.glsl.js +2 -2
  60. package/chunks/basis_encoder.js +1 -1
  61. package/chunks/dxt_encoder.js +1 -1
  62. package/config.js +1 -1
  63. package/geometry/support/aaBoundingBox.js +1 -1
  64. package/geometry/support/frustum.js +1 -1
  65. package/kernel.js +1 -1
  66. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  67. package/package.json +2 -2
  68. package/support/revision.js +1 -1
  69. package/third-party-notices.txt +156 -0
  70. package/views/2d/engine/webgl/Painter.js +1 -1
  71. package/views/2d/engine/webgl/RenderingDevice.js +1 -1
  72. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedShader.js +1 -1
  73. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  74. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  75. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimationUniformInfo.js +1 -1
  76. package/views/2d/engine/webgl/shaderGraph/techniques/blend/BlendTechnique.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/bloom/BloomTechnique.js +1 -1
  78. package/views/2d/engine/webgl/shaderGraph/techniques/blur/BlurTechnique.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  80. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BaseRasterProcessorTechnique.js +1 -1
  82. package/views/2d/engine/webgl/shaderGraph/techniques/utility/BitBlitTechnique.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/utility/HighlightTechnique.js +1 -1
  84. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  85. package/views/2d/layers/features/sources/strategies/FeatureDrillDownTileLoadStrategy.js +1 -1
  86. package/views/2d/layers/features/sources/strategies/FeatureHybridTileLoadStrategy.js +1 -1
  87. package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +1 -1
  88. package/views/2d/webglDeps.js +1 -1
  89. package/views/3d/analysis/LineOfSight/LineOfSightAggregateManipulatedObject3D.js +1 -1
  90. package/views/3d/analysis/LineOfSight/LineOfSightConfiguration.js +1 -1
  91. package/views/3d/analysis/LineOfSight/LineOfSightDrawToolRenderer.js +1 -1
  92. package/views/3d/analysis/LineOfSight/LineOfSightManipulators.js +1 -1
  93. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  94. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  95. package/views/3d/input/SceneInputManager.js +1 -1
  96. package/views/3d/layers/I3SMeshView3D.js +1 -1
  97. package/views/3d/layers/i3s/I3SGeometryUtil.js +1 -1
  98. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  99. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  100. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  101. package/views/3d/terrain/GeometryState.js +1 -1
  102. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  103. package/views/3d/terrain/PatchRenderData.js +1 -1
  104. package/views/3d/terrain/TerrainSurface.js +1 -1
  105. package/views/3d/terrain/Tile.js +1 -1
  106. package/views/3d/terrain/TileAgent.js +1 -1
  107. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  108. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  110. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
  111. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  112. package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
  113. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  114. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +1 -1
  115. package/views/3d/webgl-engine/collections/Component/Transform.js +1 -1
  116. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
  117. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +4 -4
  118. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +4 -10
  119. package/views/3d/webgl-engine/effects/WeatherFader.js +1 -1
  120. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  121. package/views/3d/webgl-engine/effects/fog/Fog.glsl.js +1 -1
  122. package/views/3d/webgl-engine/effects/fog/FogTechniqueConfiguration.js +1 -1
  123. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.glsl.js +1 -1
  124. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  125. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlur.glsl.js +1 -1
  126. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechniqueConfiguration.js +1 -1
  127. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  128. package/views/3d/webgl-engine/effects/glow/GlowBlurTechniqueConfiguration.js +1 -1
  129. package/views/3d/webgl-engine/effects/glow/GlowComposition.glsl.js +1 -1
  130. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechniqueConfiguration.js +1 -1
  131. package/views/3d/webgl-engine/effects/transparency/OITAddEmission.glsl.js +1 -1
  132. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  133. package/views/3d/webgl-engine/effects/transparency/OITBlendFragmentTechniqueConfiguration.js +1 -1
  134. package/views/3d/webgl-engine/effects/transparency/oitBlendFragment.glsl.js +1 -1
  135. package/views/3d/webgl-engine/lib/CutFillComputation.js +1 -1
  136. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  137. package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +1 -1
  138. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  139. package/views/3d/webgl-engine/shaders/CutFillTargetDepth.glsl.js +1 -1
  140. package/views/3d/webgl-engine/shaders/GaussianSplatCompositionTechniqueConfiguration.js +1 -1
  141. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +2 -2
  142. package/views/3d/webgl-engine/shaders/{oitResolution.glsl.js → floatBlendScale.glsl.js} +1 -1
  143. package/views/GroundView.js +1 -1
  144. package/views/input/BrowserEventSource.js +1 -1
  145. package/views/input/InputManager.js +1 -1
  146. package/views/support/LayerViewManager.js +1 -1
  147. package/views/support/TextureCompressionWorker.js +1 -1
  148. package/views/support/imageReprojection.js +1 -1
  149. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  150. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  151. package/widgets/BatchAttributeForm.js +1 -1
  152. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  153. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  154. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  155. package/widgets/Sketch/SketchViewModel.js +1 -1
  156. package/widgets/support/dateUtils.js +1 -1
  157. package/assets/esri/core/workers/chunks/0d6afba80d2f8dcb5cf7.js +0 -1
  158. package/assets/esri/core/workers/chunks/1276df03201c1b855fee.js +0 -1
  159. package/assets/esri/core/workers/chunks/18d874739ee9ffad7480.js +0 -1
  160. package/assets/esri/core/workers/chunks/23570397304969f724b3.js +0 -1
  161. package/assets/esri/core/workers/chunks/474ea8c97d101e41b3f5.js +0 -1
  162. package/assets/esri/core/workers/chunks/551d0c5432f7a08dea77.js +0 -1
  163. package/assets/esri/core/workers/chunks/5923ebadd4f75be2c9cc.js +0 -1
  164. package/assets/esri/core/workers/chunks/7cb0681cc6a5e956cb15.js +0 -1
  165. package/assets/esri/core/workers/chunks/8b73694d5a97638a3a61.js +0 -1
  166. package/assets/esri/core/workers/chunks/8dee03779b569f233daf.js +0 -1
  167. package/assets/esri/core/workers/chunks/9ebc98746b1f085b82b7.js +0 -1
  168. package/assets/esri/core/workers/chunks/9ee3741eef73f3edb18b.js +0 -1
  169. package/assets/esri/core/workers/chunks/af97e19516dbbcfb5286.js +0 -1
  170. package/assets/esri/core/workers/chunks/b4047333265a2665aef9.js +0 -1
  171. package/assets/esri/core/workers/chunks/c3fae4f4522604a9c17e.js +0 -1
  172. package/assets/esri/core/workers/chunks/cce83896093279c70449.js +0 -1
  173. package/assets/esri/core/workers/chunks/d5561dff043789494845.js +0 -1
  174. package/assets/esri/core/workers/chunks/e2c9393bec747f7876bb.js +0 -1
  175. package/assets/esri/core/workers/chunks/e94f2d6037fba042dc6e.js +0 -1
  176. package/assets/esri/core/workers/chunks/f5d7f69047e1b1116202.js +0 -1
  177. package/views/2d/engine/webgl/MaterialManager.js +0 -2
  178. package/views/2d/engine/webgl/shaders/MaterialPrograms.js +0 -2
  179. package/views/2d/engine/webgl/shaders/sources/resolver.js +0 -2
  180. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +0 -2
  181. package/views/webgl/ShaderCompiler.js +0 -2
  182. /package/assets/esri/core/workers/chunks/{82f4aa0533db009b11d8.js.LICENSE.txt → bac4d4a9f3a9b7f6864d.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{toConst as e}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{clamp as t}from"../../../core/mathUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{subtract as n,squaredLength as r,dot as a,scale as l,add as o,length as h,copy as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,unitZ as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f,rectangleContainsRectangleCyclicalAware as _,rectanglesIntersectCyclicalAware as m,width as y,height as v}from"../../../geometry/support/aaBoundingRect.js";import{Sphere as M}from"../../../geometry/support/sphere.js";import{isGroupLayer as A}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as x}from"../support/flowUtils.js";import{ElevationBounds as D}from"./ElevationBounds.js";import{ElevationTileAgent as b,isElevationTileAgent as L}from"./ElevationTileAgent.js";import{LayerClasses as j}from"./LayerClass.js";import{MapDataCacheItem as I}from"./MapDataCacheItem.js";import{MapTileAgent as T,isMapTileAgent as C}from"./MapTileAgent.js";import{maxPatchTesselation as B}from"./TerrainConst.js";import{isVectorTile as U,isTileTexture as S,isRasterTile as w,isCreateBitmapResult as P}from"./TerrainData.js";import{weakAssert as E,isBlendableLayerView as O,oppositeCorner as R,internalAssert as q,enableTerrainInternalChecks as V,neighborEdgeIndices as N,oppositeEdge as G,neighborCornerIndices as F,almostEquals as k,enableWaterproofTests as z,isNorth as W,isSouth as J,isWest as H,isEast as X,isWestCorner as Y,isNorthCorner as $}from"./terrainUtils.js";import{tileAgentDone as Q}from"./TileAgent.js";import{TilePerLayerInfo as K}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),new M,u()],this.up=c(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get isDisposed(){return null==this._surface}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}_setPendingUpdateForDescendants(){const e=this._children;if(e[0])for(const t of e)t.renderData&&(t.setPendingUpdate(16),t.setMemoryDirty()),t._setPendingUpdateForDescendants()}static prune(){ne.prune(0),re.prune(0),K.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1].radius}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??1;this._frustumVisibility=0===t?0:2===t&&this._elevationBoundsMin>=e._elevationBoundsMin&&this._elevationBoundsMax<=e._elevationBoundsMax?2:this._calculateFrustumVisibility(this.surface.frustum);const i=2!==this._frustumVisibility&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1].radius=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of j){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=K.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,B)}dispose(){E(!this.renderData,"tile.renderData was not unloaded"),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,new I(e(this)))}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this.mapDataMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this.mapDataMemory:0}get mapDataMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(U(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[1])U(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(const e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?1===e?this._cached?0:this.getTerrainDataMemory(i.data):0===e?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return S(e)?e.texture.usedMemory:w(e)?e.memoryUsage:U(e)?e.usedMemoryPerReference:P(e)?this._cpuImageMemorySize:0}updateScreenDepth(e){const[t,i,s]=this._center[1].center,n=e,r=n[2]*t+n[6]*i+n[10]*s+n[14];this.screenDepth=r<0?0:r/(n[3]*t+n[7]*i+n[11]*s+n[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const s=this.level;n(ce,this._center[1].center,t);let d=r(ce),u=ce,c=this._center[1].center;n(ge,this._center[0],t);const g=r(ge);g<d&&(d=g,u=ge,c=this._center[0]),n(pe,this._center[2],t);const p=r(pe);if(p<d&&(d=p,u=pe,c=this._center[2]),this._edgeLen2>d&&s<e.maxLod)return 1;const f=Math.sqrt(d),_=e.fovX*f*2,m=this._edgeLen/_,y=()=>{if(s<e.maxLod)return this.elevationLevel=s,0;const t=s+Math.ceil(-Math.log2(e.relativeWidthLimit/m));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},v=null!=i?i-s:1/0;if(v<=.5)return y();const M=a(this.up,ce),A=this._elevationBoundsMax-this._elevationBoundsMin,x=A/this.edgeLen;if(e.aboveGround&&M>0&&x<.001){if(M/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-x>0)return 0}const D=null!=i?3-Math.min(v,2):1;if(m*D<e.relativeWidthLimit||s>=e.maxLod)return y();if(s<7)return 1;l(fe,this.up,M),n(fe,fe,u);const b=r(fe);if(b<=this.radius*this.radius)return 1;l(fe,fe,this.radius/Math.sqrt(b)),o(fe,fe,c),n(fe,t,fe);const L=Math.min(1,(Math.abs(a(fe,this.up))+.5*A+this._curvatureHeight)/h(fe)),j=ee/e.angledSplitBias,I=e.fovY*f*2;return L*(this._edgeLen/I*D)<j*e.relativeHeightLimit?0:1}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of j)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of j){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==Q&&(se(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){const e=this.layerInfo[1];for(const t of e)t.loadingAgent&&t.loadingAgent!==Q&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData?.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty(!1)}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of j){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Q&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(1)||0!==e&&!this._loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,1===e||4===e?this._surface.setTileTreeDirty(!0):this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),t,e);const i=U(n.data);return s.dataArrived(this,i),!0}if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,{signal:n.requestAbort.signal});if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return r(n(fe,this._center[1].center,e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);E(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=U(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll(e=>e.dataArrived(this,s)),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll(e=>e.dataMissing()),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor(i=>i.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(0===e?16:32),this.setPendingUpdate(0===e?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(const e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData()}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[0];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.minElevation),s=Math.max(s,a.elevationBounds.maxElevation),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty(!1))}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;l(fe,this.up,i),o(s[1].center,this.centerAtSeaLevel,fe),l(fe,this.up,e),o(s[0],this.centerAtSeaLevel,fe),l(fe,this.up,t),o(s[2],this.centerAtSeaLevel,fe)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[0][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,0);if(!Z(this,a))return;const l=ae;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.minElevation=e.samplerData.data.minValue,l.maxElevation=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[0][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.minElevation!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new D),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Q&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:K.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Q&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of j){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Q&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Q&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Q&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=Q,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||A(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(O(e)&&"normal"!==e?.layer?.blendMode||A(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);let n=!1;for(let r=e;r<i.length;++r){const a=i[r],l=this._surface.layerViewByIndex(r,t);let o=!1;n&&!x(l)||(a.loadingAgent?Z(this,l)?(a.loadingAgent!==Q&&a.loadingAgent.setSuspension(s),a.loadingAgent!==Q&&(o=a.loadingAgent.update())):a.dispose():Z(this,l)&&(a.loadingAgent=ie(this,r,t,s),o=a.loadingAgent.startLoading(),o?a.loadingAgent===Q&&this.setPendingUpdate(8):(se(a.loadingAgent),a.loadingAgent=Q)),a.loadingAgent===Q&&this.updateRenderData(t,0),!l.destroyed&&!this._hasBlendModes(e,i.length,t)&&o&&l.isOpaque&&(n||=!0))}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(e){const i=this.elevationLevel-this.level,s=Math.max(this.level-e,this.elevationLevelDelta-i),n=t(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const{rootTiles:i}=this.surface;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?oe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=1===e?1:7===e?0:5===e?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(R(e),t)||null}forAllSubtreeOnSide(e,t){const i=0===e?[0,1]:1===e?[1]:2===e?[1,3]:3===e?[3]:4===e?[2,3]:5===e?[2]:6===e?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach(e=>s(n[e]))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(q(!V||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return V&&(q(a<=l&&l<a+s),q(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;N.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(G(t),i=>!!i.loaded&&(e(i,t),!0))}),F.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(R(t),e=>e.loaded);q(!s||he(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=W(t)?-1:J(t)?1:0,s=H(t)?-1:X(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&2===t)return!0;if(this._westEnd&&e._eastEnd&&6===t)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case 0:return k(this.extent[3],e.extent[1],i);case 4:return k(this.extent[1],e.extent[3],i);case 2:return k(this.extent[2],e.extent[0],i)||k(this.extent[2],-e.extent[0],i);case 6:return k(this.extent[0],e.extent[2],i)||k(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){z&&(q(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,{rootTilesExtent:i}=this._surface,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(J(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&H(e)&&t[0]-s<=i[0])&&!(!n&&X(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;d(this._lastPOI,e);const i=this._center[1].center,s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}updateOverlayParameters(e){const{renderData:t}=this;if(!t)return;const{overlays:i,longitudeCyclical:s}=e,n=t.overlay;if(0===i.length)this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n);else{const[e,t]=i,r=this.extent;_(e.extent,r,s)||m(r,e.extent,s)||m(r,t.extent,s)?(this._setOverlayData(i,s,r,0,n),this._setOverlayData(i,s,r,1,n)):(this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n))}}_setOverlayData(e,t,i,s,n){const r=e[s].extent,a=y(r),l=v(r);let o=i[0];if(t){o=t.minimalMonotonic(r[0],o);const e=t.minimalMonotonic(r[0],i[2]);o>e&&(o=e-(i[2]-i[0]))}if(0===a||0===l)return void n.setOffsetAndScale(s,0,0,1,1);const h=y(i)/a,d=v(i)/l,u=(o-r[0])/a,c=(i[1]-r[1])/l;n.setOffsetAndScale(s,u,c,h,d)}_clearTileOverlayData(e,t){t.setOffsetAndScale(e,-1,-1,-1,-1)}}function ie(e,t,i,s){const n=0===i?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),L(e)?re.release(e):C(e)&&ne.release(e)}const ne=new s(()=>new T),re=new s(()=>new b),ae=new D;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function oe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function he(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?de(e,t,i):de(t,e,R(i)))}function de(e,t,i){q(e.level>=t.level);const s=Y(i),n=$(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),d=k(l[0],o[0],h)||e.surface.isGlobal&&k(l[0],-o[0],h),u=k(l[1],o[1],h);if(d&&u)return!0;if(e.level===t.level)return q(!1),!1;if(!d&&!u)return q(!1),!1;const c=d?ue(a[1],a[3],r[1],r[3],h):ue(a[0],a[2],r[0],r[2],h);return q(c),c}function ue(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ce=u(),ge=u(),pe=u(),fe=u();export{te as Tile,he as isCornerNeighbor,oe as lijEquals};
2
+ import{toConst as e}from"../../../core/compilerUtils.js";import"../../../core/has.js";import{clamp as t}from"../../../core/mathUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{subtract as n,squaredLength as r,dot as a,scale as l,add as o,length as h,copy as u}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,unitZ as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f,rectangleContainsRectangleCyclicalAware as _,rectanglesIntersectCyclicalAware as m,width as y,height as v}from"../../../geometry/support/aaBoundingRect.js";import{Sphere as M}from"../../../geometry/support/sphere.js";import{isGroupLayer as A}from"../../../layers/support/layerUtils.js";import{isLayerViewWithFlowRenderer as x}from"../support/flowUtils.js";import{ElevationBounds as D}from"./ElevationBounds.js";import{ElevationTileAgent as L,isElevationTileAgent as S}from"./ElevationTileAgent.js";import{LayerClasses as b}from"./LayerClass.js";import{MapDataCacheItem as j}from"./MapDataCacheItem.js";import{MapTileAgent as I,isMapTileAgent as U}from"./MapTileAgent.js";import{maxPatchTesselation as T}from"./TerrainConst.js";import{isVectorTile as C,isTileTexture as B,isRasterTile as E,isCreateBitmapResult as w}from"./TerrainData.js";import{weakAssert as P,isBlendableLayerView as R,oppositeCorner as q,internalAssert as O,enableTerrainInternalChecks as V,neighborEdgeIndices as N,oppositeEdge as G,neighborCornerIndices as k,almostEquals as F,enableWaterproofTests as z,isNorth as W,isSouth as J,isWest as H,isEast as $,isWestCorner as X,isNorthCorner as Y}from"./terrainUtils.js";import{tileAgentDone as Q}from"./TileAgent.js";import{TilePerLayerInfo as K}from"./TilePerLayerInfo.js";import{fallsWithinLayerView as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this._dirty=!0,this._previouslyRendered=!1,this._lastElevationSourceUpdateRequestSignature=null,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=d(),this._center=[d(),new M,d()],this.up=c(),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=0,this._rasterTileMemory=0,this._vectorTileMemory=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.onCompressionFinished=()=>{this.setPendingUpdate(16),this.setMemoryDirty()},this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=d(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}get spatialReference(){return this._surface.spatialReference??this._surface.tilingScheme.spatialReference}get isDisposed(){return null==this._surface}get elevationLevelDelta(){return this._surface.getElevationLevelDelta(this.level)}_setPendingUpdateForDescendants(){const e=this._children;if(e[0])for(const t of e)t.renderData&&(t.setPendingUpdate(16),t.setMemoryDirty()),t._setPendingUpdateForDescendants()}static prune(){ne.prune(0),re.prune(0),K.prune()}get _cached(){return!this.leaf&&this._mapDataRefCount<=0}get withinClippingArea(){return this._withinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[1].radius}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??1;this._frustumVisibility=0===t?0:2===t&&this._elevationBoundsMin>=e._elevationBoundsMin&&this._elevationBoundsMax<=e._elevationBoundsMax?2:this._calculateFrustumVisibility(this.surface.frustum);const i=2!==this._frustumVisibility&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get _loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._withinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[1].radius=0,this.elevationLevel=e,this._lastElevationSourceUpdateRequestSignature=null,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.clearChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of b){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=K.acquire(this._surface.upsampleInfoPool),0===r&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,T)}dispose(){P(!this.renderData,"tile.renderData was not unloaded"),this._surface?.upsampleMapCache.pop(this.key),this.layerInfo.forEach(e=>{e.forEach(e=>e.release()),e.length=0}),this._surface=this._parent=null,this.clearChildren(),this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._cached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){--this._mapDataRefCount,this._cached&&this.cachedMemory>0&&this._surface.upsampleMapCache.put(this.key,new j(e(this)))}setMemoryDirty(){this._usedMemory=0}get usedMemory(){return this._ensureUsedMemory()+(this._cached?0:this.mapDataMemory)}get cachedMemory(){return this._ensureUsedMemory(),null==this._surface?this.usedMemory:this._cached?this.mapDataMemory:0}get mapDataMemory(){return this._rasterTileMemory+this._vectorTileMemory}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(this._usedMemory>0)return this._vectorTileMemory=this.layerInfo[1].reduce((e,{data:t})=>e+(C(t)?t.usedMemoryPerReference:0),0),this._usedMemory;this._usedMemory=this._baseUsedMemory,this._rasterTileMemory=0,this._vectorTileMemory=0;for(const{data:e}of this.layerInfo[1])C(e)?this._vectorTileMemory+=e.usedMemoryPerReference:this._rasterTileMemory+=this.getTerrainDataMemory(e);for(const e of this.layerInfo[0])this._usedMemory+=e.data?this._cpuImageMemorySize:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._rasterTileMemory+=this.renderData.texture?.usedMemory??0),this._cached&&this._surface.upsampleMapCache.updateSize(this.key),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?1===e?this._cached?0:this.getTerrainDataMemory(i.data):0===e?this._cpuImageMemorySize:0:0}getTerrainDataMemory(e){return B(e)?e.texture.usedMemory:E(e)?e.memoryUsage:C(e)?e.usedMemoryPerReference:w(e)?this._cpuImageMemorySize:0}updateScreenDepth(e){const[t,i,s]=this._center[1].center,n=e,r=n[2]*t+n[6]*i+n[10]*s+n[14];this.screenDepth=r<0?0:r/(n[3]*t+n[7]*i+n[11]*s+n[15])}shouldSplit(e,t,i){if(!this.visible)return 0;if(e.frustum&&(!this._intersectsClippingArea||2===this._calculateFrustumVisibility(e.frustum)))return 0;const s=this.level;n(ce,this._center[1].center,t);let u=r(ce),d=ce,c=this._center[1].center;n(ge,this._center[0],t);const g=r(ge);g<u&&(u=g,d=ge,c=this._center[0]),n(pe,this._center[2],t);const p=r(pe);if(p<u&&(u=p,d=pe,c=this._center[2]),this._edgeLen2>u&&s<e.maxLod)return 1;const f=Math.sqrt(u),_=e.fovX*f*2,m=this._edgeLen/_,y=()=>{if(s<e.maxLod)return this.elevationLevel=s,0;const t=s+Math.ceil(-Math.log2(e.relativeWidthLimit/m));return t!==this.elevationLevel?(this.elevationLevel=t,2):0},v=null!=i?i-s:1/0;if(v<=.5)return y();const M=a(this.up,ce),A=this._elevationBoundsMax-this._elevationBoundsMin,x=A/this.edgeLen;if(e.aboveGround&&M>0&&x<.001){if(M/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-x>0)return y()}const D=null!=i?3-Math.min(v,2):1;if(m*D<e.relativeWidthLimit||s>=e.maxLod)return y();if(s<7)return 1;l(fe,this.up,M),n(fe,fe,d);const L=r(fe);if(L<=this.radius*this.radius)return 1;l(fe,fe,this.radius/Math.sqrt(L)),o(fe,fe,c),n(fe,t,fe);const S=Math.min(1,(Math.abs(a(fe,this.up))+.5*A+this._curvatureHeight)/h(fe)),b=ee/e.angledSplitBias,j=e.fovY*f*2;return S*(this._edgeLen/j*D)<b*e.relativeHeightLimit?y():1}needsElevationSourceUpdate(){const e=this.renderData?.geometryState.samplerDataSourceLevels;if(null==e)return!1;const t=Math.max(this.elevationLevel-this.elevationLevelDelta,0);return e.some(e=>e>t)&&this._lastElevationSourceUpdateRequestSignature!==this._elevationSourceUpdateRequestSignature(e)}markElevationSourceUpdateRequested(){const e=this.renderData?.geometryState.samplerDataSourceLevels;this._lastElevationSourceUpdateRequestSignature=null!=e?this._elevationSourceUpdateRequestSignature(e):null}_elevationSourceUpdateRequestSignature(e){return`${Math.max(this.elevationLevel-this.elevationLevelDelta,0)}:${e.join(",")}`}createChildren(){const e=this._children,t=this.lij[0]+1,i=2*this.lij[1],s=2*this.lij[2];return e[0]=this.surface.createTile(t,i,s,this),e[1]=this.surface.createTile(t,i,s+1,this),e[2]=this.surface.createTile(t,i+1,s,this),e[3]=this.surface.createTile(t,i+1,s+1,this),e}clearChildren(){this._children[0]=this._children[1]=this._children[2]=this._children[3]=null}get loaded(){return this.renderData?.hasGeometry??!1}get hasGeometryState(){return null!=this.renderData?.geometryState}load(){this.refMapData();for(const e of b)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(){this.renderData&&this.unrefMapData(),this.surface.renderer.unloadTile(this);for(const e of b){const t=this.layerInfo[e];for(const e of t)e.loadingAgent&&e.loadingAgent!==Q&&(se(e.loadingAgent),e.loadingAgent=null),e.pendingUpdates=0}this.resetPendingUpdate(8),this.resetPendingUpdate(16),this.resetPendingUpdate(32)}unloadMapData(){const e=this.layerInfo[1];for(const t of e)t.loadingAgent&&t.loadingAgent!==Q&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0,t.invalidateSourceData();this.renderData?.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._withinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._withinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._withinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._withinClippingArea,n=!(i||t||this._withinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(8),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty(!1)}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of b){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==Q&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(1)||0!==e&&!this._loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,1===e||4===e?this._surface.setTileTreeDirty(!0):this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,t,s){const n=this.layerInfo[t][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),t,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),t,e);const i=C(n.data);return s.dataArrived(this,i),!0}if(n.requestPromise)return!0;i(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,t,{signal:n.requestAbort.signal});if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get leaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return r(n(fe,this._center[1].center,e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);P(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=C(i),n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll(e=>e.dataArrived(this,s)),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t){const i=this.layerInfo[t][e];i.dataMissing=!0,i.waitingAgents.forAll(e=>e.dataMissing()),i.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor(i=>i.updateRenderData(e,t)),e){case 1:return this._updateTexture(t);case 0:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(0===e?16:32),this.setPendingUpdate(0===e?32:16))}_updateGeometry(){this.setPendingUpdate(8);for(const e of this.layerInfo[0])e.pendingUpdates|=8}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData()}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[0];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.minElevation),s=Math.max(s,a.elevationBounds.maxElevation),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty(!1))}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;l(fe,this.up,i),o(s[1].center,this.centerAtSeaLevel,fe),l(fe,this.up,e),o(s[0],this.centerAtSeaLevel,fe),l(fe,this.up,t),o(s[2],this.centerAtSeaLevel,fe)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[0][e],s=this.elevationLevelDelta,n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,0);if(!Z(this,a))return;const l=ae;let o=!1;const h=i.data;if(h&&h.level<=n){const e=i.data;l.minElevation=e.samplerData.data.minValue,l.maxElevation=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,o=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[0][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.minElevation!==1/0&&(l.level=i.level,o=!0))}o&&(null==i.elevationBounds&&(i.elevationBounds=new D),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==Q&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:K.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,0))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===Q&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of b){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==Q&&(i.loadingAgent.setSuspension(t),i.loadingAgent===Q&&this.updateRenderData(e,0))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==Q&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=Q,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||A(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(R(e)&&"normal"!==e?.layer?.blendMode||A(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);let n=!1;for(let r=e;r<i.length;++r){const a=i[r],l=this._surface.layerViewByIndex(r,t);let o=!1;n&&!x(l)||(a.loadingAgent?Z(this,l)?(a.loadingAgent!==Q&&a.loadingAgent.setSuspension(s),a.loadingAgent!==Q&&(o=a.loadingAgent.update())):a.dispose():Z(this,l)&&(a.loadingAgent=ie(this,r,t,s),o=a.loadingAgent.startLoading(),o?a.loadingAgent===Q&&this.setPendingUpdate(8):(se(a.loadingAgent),a.loadingAgent=Q)),a.loadingAgent===Q&&this.updateRenderData(t,0),!l.destroyed&&!this._hasBlendModes(e,i.length,t)&&o&&l.isOpaque&&(n||=!0))}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(e){const i=this.elevationLevel-this.level,s=Math.max(this.level-e,this.elevationLevelDelta-i),n=t(1+(this._maxTesselation>>s),2,this._maxTesselation+1),r=this.minimumVerticesPerSide;return Math.max(n,r)}_findLIJ(e,t){if(!e)return null;const{rootTiles:i}=this.surface;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.leaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this._getNeighborLIJ(i,e);return s?oe(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=1===e?1:7===e?0:5===e?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,e=>t(e)||e.level===this.level)?.findCorner(q(e),t)||null}forAllSubtreeOnSide(e,t){const i=0===e?[0,1]:1===e?[1]:2===e?[1,3]:3===e?[3]:4===e?[2,3]:5===e?[2]:6===e?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach(e=>s(n[e]))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(O(!V||i>=0),0===i)return 0;const s=2**i,n=!(1&~e),r=n?0:1,a=t.lij[r+1]*s,l=this._lij[r+1],o=l-a,h=n?s-1-o:o;return V&&(O(a<=l&&l<a+s),O(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.loaded;N.forEach(t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(G(t),i=>!!i.loaded&&(e(i,t),!0))}),k.forEach(t=>{const s=this.findNeighborTile(t,i)?.findCorner(q(t),e=>e.loaded);O(!s||he(this,s,t)),s?.loaded&&e(s,t)})}_getNeighborLIJ(e,t){const i=W(t)?-1:J(t)?1:0,s=H(t)?-1:$(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this._wrapLIJ(n):n[2]<0?null:n}_wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}isEdgeNeighbor(e,t){if(null==e)return!1;if(0===this.level&&0===e.level){if(this._eastEnd&&e._westEnd&&2===t)return!0;if(this._westEnd&&e._eastEnd&&6===t)return!0}const i=Math.max(1e-6*(this.extent[2]-this.extent[0]),1);switch(t){case 0:return F(this.extent[3],e.extent[1],i);case 4:return F(this.extent[1],e.extent[3],i);case 2:return F(this.extent[2],e.extent[0],i)||F(this.extent[2],-e.extent[0],i);case 6:return F(this.extent[0],e.extent[2],i)||F(this.extent[0],-e.extent[2],i)}}get _eastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get _westEnd(){return 0===this._lij[2]}checkGeometryWaterproofness(){z&&(O(this.loaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,{rootTilesExtent:i}=this._surface,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(J(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&H(e)&&t[0]-s<=i[0])&&!(!n&&$(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;u(this._lastPOI,e);const i=this._center[1].center,s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}updateOverlayParameters(e){const{renderData:t}=this;if(!t)return;const{overlays:i,longitudeCyclical:s}=e,n=t.overlay;if(0===i.length)this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n);else{const[e,t]=i,r=this.extent;_(e.extent,r,s)||m(r,e.extent,s)||m(r,t.extent,s)?(this._setOverlayData(i,s,r,0,n),this._setOverlayData(i,s,r,1,n)):(this._clearTileOverlayData(0,n),this._clearTileOverlayData(1,n))}}_setOverlayData(e,t,i,s,n){const r=e[s].extent,a=y(r),l=v(r);let o=i[0];if(t){o=t.minimalMonotonic(r[0],o);const e=t.minimalMonotonic(r[0],i[2]);o>e&&(o=e-(i[2]-i[0]))}if(0===a||0===l)return void n.setOffsetAndScale(s,0,0,1,1);const h=y(i)/a,u=v(i)/l,d=(o-r[0])/a,c=(i[1]-r[1])/l;n.setOffsetAndScale(s,d,c,h,u)}_clearTileOverlayData(e,t){t.setOffsetAndScale(e,-1,-1,-1,-1)}}function ie(e,t,i,s){const n=0===i?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),S(e)?re.release(e):U(e)&&ne.release(e)}const ne=new s(()=>new I),re=new s(()=>new L),ae=new D;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function oe(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function he(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ue(e,t,i):ue(t,e,q(i)))}function ue(e,t,i){O(e.level>=t.level);const s=X(i),n=Y(i),r=e.extent,a=t.extent,l=[s?r[0]:r[2],n?r[3]:r[1]],o=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=F(l[0],o[0],h)||e.surface.isGlobal&&F(l[0],-o[0],h),d=F(l[1],o[1],h);if(u&&d)return!0;if(e.level===t.level)return O(!1),!1;if(!u&&!d)return O(!1),!1;const c=u?de(a[1],a[3],r[1],r[3],h):de(a[0],a[2],r[0],r[2],h);return O(c),c}function de(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}const ce=d(),ge=d(),pe=d(),fe=d();export{te as Tile,he as isCornerNeighbor,oe as lijEquals};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../../../core/has.js";import{progressiveLoadingModulo as e}from"./TerrainConst.js";import{fallsWithinLayerView as t,getTileMapCache as s}from"./tileUtils.js";class i{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(e,t){this._setUpsampleTile(e,t),this._tileRequested=null,e===this.tile?this.tile.updateRenderData(this._layerClass,0,t):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const i=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(i,l),{minLevel:n,maxLevel:r}=a.dataLevelRange,h=this._desiredMinLevelDelta,d=this._progressiveLevelModulo+h;let u=this.tile;const _=u.level;let o;if(this._scaleRangeEnabled&&!t(u,a))return null;const p=this._tileLayerInfo.upsampleInfo,y=p?.tile?.level??-1,f=null!=p&&y-_>=h,v=s(a),c="vector-tile-3d"===a.type?a.schemaHelper:null;for(;u&&u.level>=n;){const t=u.level,s=_-t,a=u.layerInfo[l][i];if(a.data&&s>=h){(!f||t>y)&&this._setUpsampleTile(u),a.dataInvalidated&&(o=u);break}const p=c?.getLevelRowColumn(u.lij)??u.lij;if("unavailable"!==v?.getAvailability(p[0],p[1],p[2])&&t<=r&&!a.data&&!a.dataMissing&&((!o||u.level===n||t%e===0||_-o.level<h)&&(o=u),s>=d))break;u=u.parent}if(null!=o&&_-o.level<h)if(p)o=null;else{const e=this._findAncestorWithData();if(null!=e){this._setUpsampleTile(e);o=e.layerInfo[l][i].dataInvalidated?e:null}}return o}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(e,t){this._tileLayerInfo.setUpsampleInfo(this.tile,e),this.tile.updateRenderData(this._layerClass,0,t)}get test(){}}class l extends i{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw a}get _progressiveLevelModulo(){throw a}dispose(){}}const a=new Error("Abstract method called on TileAgent"),n=new l;export{i as TileAgent,n as tileAgentDone};
2
+ import"../../../core/has.js";import{progressiveLoadingModulo as e}from"./TerrainConst.js";import{fallsWithinLayerView as t,getTileMapCache as s}from"./tileUtils.js";class i{get updating(){return!!this._tileRequested}init(e,t,s,i){this.tile=e,this._layerIdx=t,this._layerClass=s,this._suspended=i,this._tileLayerInfo=e.getLayerInfo(t,s),this._tileRequested=null;const l=this._findAncestorWithData();this._setUpsampleTile(l)}startLoading(){return this._requestNext()}dispose(){this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null),this.tile=null,this._tileLayerInfo=null}setSuspension(e){e!==this._suspended&&(this._suspended=e,e?this._tileRequested&&(this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null):this._tileLayerInfo.data||this.update())}update(){const e=this._findAncestorWithData();return this._setUpsampleTile(e),this._requestNext()}dataArrived(e,t){this._setUpsampleTile(e,t),this._tileRequested=null,e===this.tile?this.tile.updateRenderData(this._layerClass,0,t):this._requestNext()}dataMissing(){this._tileRequested=null,this._tileLayerInfo.data=null,this._requestNext()}_agentDone(){this.tile.agentDone(this._layerIdx,this._layerClass),this.dispose()}_requestNext(){if(this._suspended)return!0;const e=this._findNextDownload();if(this._tileRequested){if(e===this._tileRequested)return!0;this._tileRequested.unrequestLayerData(this._layerIdx,this._layerClass,this),this._tileRequested=null}return null!=e?e.requestLayerData(this._layerIdx,this._layerClass,this)&&(this._tileRequested=e):this._agentDone(),!!this._tileRequested}_findNextDownload(){const i=this._layerIdx,l=this._layerClass,a=this.tile.surface.layerViewByIndex(i,l),{minLevel:n,maxLevel:r}=a.dataLevelRange,h=this._desiredMinLevelDelta,d=this._progressiveLevelModulo+h;let u=this.tile;const _=u.level;let o;if(this._scaleRangeEnabled&&!t(u,a))return null;const p=this._tileLayerInfo.upsampleInfo,y=p?.tile?.level??-1,f=null!=p&&_-y>=h,v=s(a),c="vector-tile-3d"===a.type?a.schemaHelper:null;for(;u&&u.level>=n;){const t=u.level,s=_-t,a=u.layerInfo[l][i];if(a.data&&s>=h){(!f||t>y)&&this._setUpsampleTile(u),a.dataInvalidated&&(o=u);break}const p=c?.getLevelRowColumn(u.lij)??u.lij;if("unavailable"!==v?.getAvailability(p[0],p[1],p[2])&&t<=r&&!a.data&&!a.dataMissing&&((!o||u.level===n||t%e===0||_-o.level<h)&&(o=u),s>=d))break;u=u.parent}if(null!=o&&_-o.level<h)if(p)o=null;else{const e=this._findAncestorWithData();if(null!=e){this._setUpsampleTile(e);o=e.layerInfo[l][i].dataInvalidated?e:null}}return o}_findAncestorWithData(){const e=this.tile.elevationLevel,t=this._desiredMinLevelDelta;let s;for(let i=this.tile;i;i=i.parent)if(i.hasLayerData(this._layerIdx,this._layerClass)){if(e-i.level>=t)return i;s=i}return s}_setUpsampleTile(e,t){this._tileLayerInfo.setUpsampleInfo(this.tile,e),this.tile.updateRenderData(this._layerClass,0,t)}get test(){}}class l extends i{constructor(){super(...arguments),this.type="none"}get _desiredMinLevelDelta(){throw a}get _progressiveLevelModulo(){throw a}dispose(){}}const a=new Error("Abstract method called on TileAgent"),n=new l;export{i as TileAgent,n as tileAgentDone};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t,transformMat3 as a,add as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as i}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as s}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as n}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as l,ComponentParametersVarying as m}from"./ComponentDrawParameters.js";import{UniformComponentParameters as h}from"./UniformComponentParameters.js";import{olidEnabled as c}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as d}from"../../../../support/HighlightDefaults.js";class p{constructor(e,t,a,r,o,i){this._collection=e,this.transform=t,this.obb=a,this._componentData=r,this._renderable=o,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}get emissions(){return this.renderable.material.emissions}updateMaterial(e,t){const{_renderable:a}=this,r=a.material,{opacity:o,useFloatBlend:i,...s}=e,n=o??a.opacity,l=this._collection.materials.acquire({...r.parameters,...s,isObjectTransparent:n<1},a.geometry.parameters,t??a.drawParameters.componentParameters);this._collection.materials.release(r),l!==r&&a.updateMaterial(l)}get opacity(){return this.renderable.opacity}updateOpacity(e){this.opacity!==e&&(this._renderable.updateOpacity(e),this.updateMaterial({opacity:e}))}updateCameraDerivedParameters(e){const{eye:t}=e,{centerX:a,centerY:r,centerZ:o}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-a)**2+(t[1]-r)**2+(t[2]-o)**2}setComponentData(e,t){const a=this._componentData,{materialDataBuffer:r,materialDataIndices:o}=a,i=new h,d=r.textureBuffer,p=d.getVec4Field("colorAndCastShadows"),f=d.getScalarField("elevationOffset"),b=d.getScalarField("emissiveStrength"),g=d.getScalarField("emissiveSourceMode"),y=d.getVec4Field("olidColor"),_=new Uint8Array(4),v=new Uint32Array(_.buffer);let M,w=0,C=0,S=0,x=0,D=0,O=a.verticalOffsets,P=1/0,j=-1/0,A=!1,I=!1,k=!1,B=0;for(let n=0;n<a.count;n++){e(n,i),w+=+(i.externalColor[3]<1),C+=+(3===i.externalColorMixMode&&1===i.externalColor[3]),x+=+(i.emissiveStrength>0),D+=+(1===i.emissiveSource),I||=1!==i.emissiveStrength,S+=+i.castShadows,s(i.externalColor,i.externalColorMixMode,_),_[2]=254&_[2]|+i.castShadows,p.setArray(o[n],_),A||=n>0&&B!==v[0],B=v[0],k||=0!==i.elevationOffset,k&&null==O&&(O=new Array(n).fill(0)),null!=O&&(O[n]=i.elevationOffset),P=Math.min(P,i.elevationOffset),j=Math.max(j,i.elevationOffset),f.set(o[n],i.elevationOffset),b.set(o[n],i.emissiveStrength),g.set(o[n],0===i.emissiveSource?0:255);const t=i.olidColor;null!=t&&y.setArray(o[n],t),i.pickable!==a.isPickable(n)&&a.updatePickabilityWithCount(n,i.pickable)}if(a.verticalOffsets=k?O:null,this.offsetObb=k?n(this.obb,P,j,t,this.offsetObb??this.obb.clone()):null,A||k||c()||(I||D>0)&&x>0){const{count:e}=a;M=new m(u(w,e),u(C,e),u(x,e),u(D,e),u(S,e)),d.updateTexture(),this._renderable.updateComponentParametersVarying(M,d)}else M=new l(i.externalColor,i.externalColorMixMode,i.emissiveStrength,i.emissiveSource,i.castShadows?0:2),this._renderable.updateComponentParametersUniform(M);this.updateMaterial({},M)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=i(),{positions:o}=this._intersectionGeometry;if(Math.floor(o.length/3)>0){const{rotationScale:i,position:s}=this.transform;let n=1/0,l=1/0,m=1/0,h=-1/0,c=-1/0,d=-1/0;const p=g;for(let e=0;e<o.length;e+=3)t(p,o[e+0],o[e+1],o[e+2]),a(p,p,i),r(p,p,s),n=Math.min(n,p[0]),l=Math.min(l,p[1]),m=Math.min(m,p[2]),h=Math.max(h,p[0]),c=Math.max(c,p[1]),d=Math.max(d,p[2]);e[0]=n,e[1]=l,e[2]=m,e[3]=h,e[4]=c,e[5]=d}return e}submit(e,t){const{componentData:a,renderable:r}=this;if(r.drawParameters.opacity<=0)return;const{geometry:o,drawParameters:i,material:s}=r,n=r.meta.cameraDepthSquared,{geometryRanges:l,highlightRangesMap:m,shadowmapRanges:h}=a,c=e=>e.submitDraw(s,i,o,l,n);switch(s.materialPass){case 0:c(e.opaque);break;case 1:c(e.transparent);break;case 2:c(e.opaque),c(e.transparent);break;case 3:c(e.integratedMesh),f(t)&&c(e.occludedGround),b(t)&&c(e.highlightIntegratedMesh);break;case 4:c(e.transparentIntegratedMesh)}if(i.castAnyShadows){if(null!=m)for(const t of m)t[0]===d&&e.highlightShadowMap.submitDraw(s,i,o,t[1],n,t[0]);null!=h&&e.defaultShadowMap.submitDraw(s,i,o,h,n),c(e.shadowMap)}if(null!=m)for(const d of m)e.highlight.submitDraw(s,i,o,d[1],n,d[0]);t.viewshedEnabled&&c(e.viewshedShadowMap)}}function u(e,t){return e===t?0:0===e?2:1}function f(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}function b(e){return null!=e.overlay?.getTexture(2)}const g=o();export{p as ComponentObject};
2
+ import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as r}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as o}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as i}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as s,ComponentParametersVarying as n}from"./ComponentDrawParameters.js";import{UniformComponentParameters as l}from"./UniformComponentParameters.js";import{olidEnabled as m}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as h}from"../../../../support/HighlightDefaults.js";class c{constructor(e,t,a,r,o,i){this._collection=e,this.transform=t,this.obb=a,this._componentData=r,this._renderable=o,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}get emissions(){return this.renderable.material.emissions}updateMaterial(e,t){const{_renderable:a}=this,r=a.material,{opacity:o,useFloatBlend:i,...s}=e,n=o??a.opacity,l=this._collection.materials.acquire({...r.parameters,...s,isObjectTransparent:n<1},a.geometry.parameters,t??a.drawParameters.componentParameters);this._collection.materials.release(r),l!==r&&a.updateMaterial(l)}get opacity(){return this.renderable.opacity}updateOpacity(e){this.opacity!==e&&(this._renderable.updateOpacity(e),this.updateMaterial({opacity:e}))}updateCameraDerivedParameters(e){const{eye:t}=e,{centerX:a,centerY:r,centerZ:o}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-a)**2+(t[1]-r)**2+(t[2]-o)**2}setComponentData(e,t){const a=this._componentData,{materialDataBuffer:r,materialDataIndices:h}=a,c=new l,p=r.textureBuffer,u=p.getVec4Field("colorAndCastShadows"),f=p.getScalarField("elevationOffset"),b=p.getScalarField("emissiveStrength"),g=p.getScalarField("emissiveSourceMode"),y=p.getVec4Field("olidColor"),_=new Uint8Array(4),v=new Uint32Array(_.buffer);let M,w=0,C=0,x=0,S=0,D=0,O=a.verticalOffsets,P=1/0,j=-1/0,A=!1,I=!1,k=!1,B=0;for(let i=0;i<a.count;i++){e(i,c),w+=+(c.externalColor[3]<1),C+=+(3===c.externalColorMixMode&&1===c.externalColor[3]),S+=+(c.emissiveStrength>0),D+=+(1===c.emissiveSource),I||=1!==c.emissiveStrength,x+=+c.castShadows,o(c.externalColor,c.externalColorMixMode,_),_[2]=254&_[2]|+c.castShadows,u.setArray(h[i],_),A||=i>0&&B!==v[0],B=v[0],k||=0!==c.elevationOffset,k&&null==O&&(O=new Array(i).fill(0)),null!=O&&(O[i]=c.elevationOffset),P=Math.min(P,c.elevationOffset),j=Math.max(j,c.elevationOffset),f.set(h[i],c.elevationOffset),b.set(h[i],c.emissiveStrength),g.set(h[i],0===c.emissiveSource?0:255);const t=c.olidColor;null!=t&&y.setArray(h[i],t),c.pickable!==a.isPickable(i)&&a.updatePickabilityWithCount(i,c.pickable)}if(a.verticalOffsets=k?O:null,this.offsetObb=k?i(this.obb,P,j,t,this.offsetObb??this.obb.clone()):null,A||k||m()||(I||D>0)&&S>0){const{count:e}=a;M=new n(d(w,e),d(C,e),d(S,e),d(D,e),d(x,e)),p.updateTexture(),this._renderable.updateComponentParametersVarying(M,p)}else M=new s(c.externalColor,c.externalColorMixMode,c.emissiveStrength,c.emissiveSource,c.castShadows?0:2),this._renderable.updateComponentParametersUniform(M);this.updateMaterial({},M)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=r(),{positions:a}=this._intersectionGeometry;if(Math.floor(a.length/3)>0){const{transform:r}=this;let o=1/0,i=1/0,s=1/0,n=-1/0,l=-1/0,m=-1/0;const h=f;for(let e=0;e<a.length;e+=3)t(h,a[e+0],a[e+1],a[e+2]),r.applyVec3(h,h),o=Math.min(o,h[0]),i=Math.min(i,h[1]),s=Math.min(s,h[2]),n=Math.max(n,h[0]),l=Math.max(l,h[1]),m=Math.max(m,h[2]);e[0]=o,e[1]=i,e[2]=s,e[3]=n,e[4]=l,e[5]=m}return e}submit(e,t){const{componentData:a,renderable:r}=this;if(r.drawParameters.opacity<=0)return;const{geometry:o,drawParameters:i,material:s}=r,n=r.meta.cameraDepthSquared,{geometryRanges:l,highlightRangesMap:m,shadowmapRanges:c}=a,d=e=>e.submitDraw(s,i,o,l,n);switch(s.materialPass){case 0:d(e.opaque);break;case 1:d(e.transparent);break;case 2:d(e.opaque),d(e.transparent);break;case 3:d(e.integratedMesh),p(t)&&d(e.occludedGround),u(t)&&d(e.highlightIntegratedMesh);break;case 4:d(e.transparentIntegratedMesh)}if(i.castAnyShadows){if(null!=m)for(const t of m)t[0]===h&&e.highlightShadowMap.submitDraw(s,i,o,t[1],n,t[0]);null!=c&&e.defaultShadowMap.submitDraw(s,i,o,c,n),d(e.shadowMap)}if(null!=m)for(const h of m)e.highlight.submitDraw(s,i,o,h[1],n,h[0]);t.viewshedEnabled&&d(e.viewshedShadowMap)}}function d(e,t){return e===t?0:0===e?2:1}function p(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}function u(e){return null!=e.overlay?.getTexture(2)}const f=a();export{c as ComponentObject};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import i from"../../../../../core/Logger.js";import n from"../../../../../core/PooledArray.js";import{watch as s,sync as o}from"../../../../../core/reactiveUtils.js";import{isTypedArray as r}from"../../../../../core/typedArrayUtil.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as h}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as c}from"../../../../../geometry/support/Indices.js";import{d as m}from"../../../../../chunks/vec3.js";import{c as g}from"../../../../../chunks/vec32.js";import{ComponentData as p}from"./ComponentData.js";import{defaultComponentParameters as d,ComponentDrawParametersImplementation as f}from"./ComponentDrawParameters.js";import{ComponentObject as u}from"./ComponentObject.js";import{IntersectionGeometry as b}from"./IntersectionGeometry.js";import{RenderableMeta as _,Renderable as v}from"./Renderable.js";import{RenderGeometry as y}from"./RenderGeometry.js";import{RenderSubmitSystem as O}from"./RenderSubmitSystem.js";import{ComponentMaterialParameters as j}from"./Material/ComponentMaterialInitParameters.js";import{ComponentMaterialRepository as C}from"./Material/ComponentMaterialRepository.js";import{SamplerRepository as M}from"../../lib/SamplerRepository.js";import{VertexArrayObject as w}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as R}from"../../lib/verticalOffsetUtils.js";import{BufferManager as x}from"../../lib/TextureBackedBuffer/BufferManager.js";import{getComponentDataLayout as H,IndexGlLayout as D}from"../../materials/DefaultLayouts.js";import{BufferObject as A}from"../../../../webgl/BufferObject.js";import{PrimitiveType as I}from"../../../../webgl/enums.js";import{VertexBuffer as E}from"../../../../webgl/VertexBuffer.js";const B=()=>i.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");let V=class extends t{constructor(e,t,i){super({}),this._renderPassManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._highlightsInOrder=[],this._highlights=null,this._activeHighlightOptions=new Map,this._visible=new n,this._hidden=new n,this._renderSubmit=new O(this),this._renderPassManager.register(this._renderSubmit);const{rctx:r,bind:a}=e;this._componentBufferManager=new x(r,H());const l=2===this._viewingMode?0:i?1:2;this.materials=new C(a,l),this.samplers=new M(r.gl),this.addHandles(s(()=>a.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},o))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){const{geometry:i}=e,n=new p(this._componentBufferManager,c(i.componentOffsets)),s=this._createRenderable(e,t,n),o=new b(this._viewingMode,i.positions,n,e.elevationAlignable),r=new u(this,e.transform,e.obb.clone(),n,s,o);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._requestRender())}preSubmit(e){const{camera:t,highlights:i}=e;this._updateHighlightsInOrder(i),this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t){const i=e;i.opacity!==t&&(i.updateOpacity(t),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,{componentData:i}=t,n=i.visibility.componentCount;return{visible:n,invisible:i.count-n}}setComponentData(e,t){e.setComponentData(t,this._viewingMode),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,i,n=!1){e.intersectionGeometry.getComponentAabb(t,i);const s=e,o=s.componentData.verticalOffsets;if(n||null==o)return i;const r=o[t];if(2===this._viewingMode||0===r)return i[2]+=r,i[5]+=r,i;const a=R(r);return a.localOrigin=s.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}_updateHighlightsInOrder(e){if(this._highlights===e)return;const{_highlightsInOrder:t}=this,i=Math.min(e.length,8);let n=t.length!==i;for(let s=0;s<i;++s)if(t[s]!==e[s].name){n=!0;break}if(this._highlights=e,n){t.length=i;for(let n=0;n<i;++n)t[n]=e[n].name;this._syncHighlightedObjectHighlightOrder()}}_syncHighlightedObjectHighlightOrder(){const e=this._highlightsInOrder,t=t=>{t.componentData.componentHighlights.size>0&&t.componentData.setHighlightsInOrder(e)};this._visible.forAll(t),this._hidden.forAll(t)}expandRangeWithComponentObjectElevationRange(e,t,i,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const s=e,{componentData:o}=s,r=o.count,{verticalOffsets:a}=o,{intersectionGeometry:l}=s,h=2===this._viewingMode,c=l.getComponentAabbs(),m=P;let g=1/0,p=-1/0;for(let d=0;d<r;d++){const e=6*d,o=a?.[d]??0;let r=1/0,l=-1/0;if(h)r=c[e+2]+o+t,l=c[e+5]+o+t;else{if(m[0]=c[e],m[1]=c[e+1],m[2]=c[e+2],m[3]=c[e+3],m[4]=c[e+4],m[5]=c[e+5],0!==o){const e=R(o);e.localOrigin=s.transform.position,e.applyToAabb(m)}const r=Math.max(Math.abs(m[3]),Math.abs(m[0])),a=Math.max(Math.abs(m[4]),Math.abs(m[1])),l=t+m[5]+i;n.expandElevationRangeValues(t+m[2],Math.sqrt(r*r+a*a+l*l)-i)}n.expandElevationRangeValues(r,l),g=Math.min(g,r),p=Math.max(p,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=g,this._elevationRangeCacheMax=p}intersectRay(e,t,i,n,s,o){const r=e,{transform:a,componentData:l,intersectionGeometry:h}=r;return null!=n&&(n.localOrigin=a.position),h.intersect(t,i,n,l.verticalOffsets,a,s,o)}addEdges(e,t,i,n,s){const o=e,{indices:r,positions:a}=o.intersectionGeometry,l=o.componentData.offsets;return t.addComponentObject(o,a,r,l,i,n,s)}async extractEdgeInformation(e,t,i){const n=e,s=n.componentData.visibility;if(s.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:o,positions:r}=n.intersectionGeometry,a=n.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),c=h.createBuffer(r.length/3);g(c.position.typedBuffer,r,c.position.typedBufferStride,3),m(c.position,c.position,n.transform.rotationScale),this._setComponentIndices(c.componentIndex,o,a);const p=c.count,d=this._computeVisibilityIndices(o,s,a,p);return{origin:l(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:d,indicesLength:d.length,skipDeduplicate:!0,data:c,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let n=0;for(let s=0;s<i.length-1;s++){const o=i[s],r=i[s+1];for(let i=o;i<r;i++){const s=t?t[i]:i;e.set(s,n)}n++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let s=0;t.forEachComponentRange((e,t)=>(s+=i[t]-i[e],!0));const o=r(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(s):new Uint32Array(s):new Array(s);let a=0;return t.forEachComponentRange((t,n)=>{const s=i[t],r=i[n];for(let i=s;i<r;i++)o[a++]=e?e[i]:i;return!0}),o}addHighlight(e,t,i){const n=e,s=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,s+1),n.componentData.setHighlightsInOrder(this._highlightsInOrder);n.addHighlight(t,i)&&this._requestRender()}removeHighlight(e,t,i){const n=e.removeHighlight(t,i);"notfound"!==n&&(this._removeActiveHighlight(i),n&&this._requestRender())}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)B().warn(`Removing non-existing highlight "${e}".`);else{const n=i-t;n<0&&B().warn(`Removing non-existing highlight "${e}".`),n<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,n)}}clearHighlights(e){const t=e,{componentData:i}=t,{componentHighlights:n}=t.componentData;if(n.size>0){for(const e of n)this._removeActiveHighlight(e[0],e[1][i.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,i){const n=this._renderPassManager.rctx,s=e.geometry,o=s.parameters.layout,{interleavedVertexData:r,indexData:a,vertexCount:l}=s.renderGeometryData,h=new E(n,o,r),c=a?A.createIndex(n,35044,a):null;let m=0;const g=[["geometry",h]];if(!t.isIntegratedMesh){const e=new Uint16Array(l);for(let n=0;n<i.count;n++){const t=i.offsets[n],s=i.offsets[n+1],o=i.materialDataIndices[n];if(null!=a)for(let i=t;i<s;i++){e[a[i]]=o}else for(let i=t;i<s;i++)e[i]=o}const t=new E(n,D,e.buffer);m+=t.usedMemory,g.push(["componentIndices",t])}const p=new w(n,new Map(g),c),u=a?.length??l,b=new y(p,I.TRIANGLES,s.parameters,null!=c,u),O=new j(t),C=this.materials.acquire(O,b.parameters,d),M=new _(h.usedMemory+m+(c?.usedMemory??0)),R=this.samplers.addFromTexture(t.baseColorTexture?.texture),x=new f(e,t,R);return new v(C,x,b,M)}_requestRender(){this._renderPassManager.requestRender()}};V=e([a("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection")],V);const P=h();export{V as ComponentObjectCollection};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import i from"../../../../../core/Logger.js";import n from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as r}from"../../../../../core/typedArrayUtil.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as h}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as c}from"../../../../../geometry/support/Indices.js";import{d as m}from"../../../../../chunks/vec3.js";import{c as g}from"../../../../../chunks/vec32.js";import{ComponentData as p}from"./ComponentData.js";import{defaultComponentParameters as d,ComponentDrawParametersImplementation as f}from"./ComponentDrawParameters.js";import{ComponentObject as u}from"./ComponentObject.js";import{IntersectionGeometry as b}from"./IntersectionGeometry.js";import{RenderableMeta as _,Renderable as v}from"./Renderable.js";import{RenderGeometry as y}from"./RenderGeometry.js";import{RenderSubmitSystem as O}from"./RenderSubmitSystem.js";import{ComponentMaterialParameters as j}from"./Material/ComponentMaterialInitParameters.js";import{ComponentMaterialRepository as C}from"./Material/ComponentMaterialRepository.js";import{SamplerRepository as M}from"../../lib/SamplerRepository.js";import{VertexArrayObject as w}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as R}from"../../lib/verticalOffsetUtils.js";import{BufferManager as x}from"../../lib/TextureBackedBuffer/BufferManager.js";import{getComponentDataLayout as D,IndexGlLayout as H}from"../../materials/DefaultLayouts.js";import{BufferObject as A}from"../../../../webgl/BufferObject.js";import{PrimitiveType as I}from"../../../../webgl/enums.js";import{VertexBuffer as E}from"../../../../webgl/VertexBuffer.js";const B=()=>i.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");let P=class extends t{constructor(e,t,i){super({}),this._renderPassManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._highlightsInOrder=[],this._highlights=null,this._activeHighlightOptions=new Map,this._visible=new n,this._hidden=new n,this._renderSubmit=new O(this),this._renderPassManager.register(this._renderSubmit);const{rctx:r,bind:a}=e;this._componentBufferManager=new x(r,D());const l=2===this._viewingMode?0:i?1:2;this.materials=new C(a,l),this.samplers=new M(r.gl),this.addHandles(o(()=>a.useFloatBlend.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){const{geometry:i}=e,n=new p(this._componentBufferManager,c(i.componentOffsets)),o=this._createRenderable(e,t,n),s=new b(this._viewingMode,i.positions,n,e.elevationAlignable),r=new u(this,e.transform,e.obb.clone(),n,o,s);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._requestRender())}preSubmit(e){const{camera:t,highlights:i}=e;this._updateHighlightsInOrder(i),this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t){const i=e;i.opacity!==t&&(i.updateOpacity(t),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,{componentData:i}=t,n=i.visibility.componentCount;return{visible:n,invisible:i.count-n}}setComponentData(e,t){e.setComponentData(t,this._viewingMode),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,i,n=!1){e.intersectionGeometry.getComponentAabb(t,i);const o=e,s=o.componentData.verticalOffsets;if(n||null==s)return i;const r=s[t];if(2===this._viewingMode||0===r)return i[2]+=r,i[5]+=r,i;const a=R(r);return a.localOrigin=o.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}_updateHighlightsInOrder(e){if(this._highlights===e)return;const{_highlightsInOrder:t}=this,i=Math.min(e.length,8);let n=t.length!==i;for(let o=0;o<i;++o)if(t[o]!==e[o].name){n=!0;break}if(this._highlights=e,n){t.length=i;for(let n=0;n<i;++n)t[n]=e[n].name;this._syncHighlightedObjectHighlightOrder()}}_syncHighlightedObjectHighlightOrder(){const e=this._highlightsInOrder,t=t=>{t.componentData.componentHighlights.size>0&&t.componentData.setHighlightsInOrder(e)};this._visible.forAll(t),this._hidden.forAll(t)}expandRangeWithComponentObjectElevationRange(e,t,i,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const o=e,{componentData:s}=o,r=s.count,{verticalOffsets:a}=s,{intersectionGeometry:l}=o,h=2===this._viewingMode,c=l.getComponentAabbs(),m=V;let g=1/0,p=-1/0;for(let d=0;d<r;d++){const e=6*d,s=a?.[d]??0;let r=1/0,l=-1/0;if(h)r=c[e+2]+s+t,l=c[e+5]+s+t;else{if(m[0]=c[e],m[1]=c[e+1],m[2]=c[e+2],m[3]=c[e+3],m[4]=c[e+4],m[5]=c[e+5],0!==s){const e=R(s);e.localOrigin=o.transform.position,e.applyToAabb(m)}const r=Math.max(Math.abs(m[3]),Math.abs(m[0])),a=Math.max(Math.abs(m[4]),Math.abs(m[1])),l=t+m[5]+i;n.expandElevationRangeValues(t+m[2],Math.sqrt(r*r+a*a+l*l)-i)}n.expandElevationRangeValues(r,l),g=Math.min(g,r),p=Math.max(p,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=g,this._elevationRangeCacheMax=p}intersectRay(e,t,i,n,o,s){const r=e,{transform:a,componentData:l,intersectionGeometry:h}=r;null!=n&&(n.localOrigin=a.position),h.intersectRay(t,i,n,l.verticalOffsets,a,o,s)}intersectScreenPolygon(e,t,i,n,o){const s=e,{transform:r,componentData:a,intersectionGeometry:l}=s;null!=n&&(n.localOrigin=r.position),l.intersectScreenPolygon(t,i,n,a.verticalOffsets,r,o)}addEdges(e,t,i,n,o){const s=e,{indices:r,positions:a}=s.intersectionGeometry,l=s.componentData.offsets;return t.addComponentObject(s,a,r,l,i,n,o)}async extractEdgeInformation(e,t,i){const n=e,o=n.componentData.visibility;if(o.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:r}=n.intersectionGeometry,a=n.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),c=h.createBuffer(r.length/3);g(c.position.typedBuffer,r,c.position.typedBufferStride,3),m(c.position,c.position,n.transform.rotationScale),this._setComponentIndices(c.componentIndex,s,a);const p=c.count,d=this._computeVisibilityIndices(s,o,a,p);return{origin:l(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:d,indicesLength:d.length,skipDeduplicate:!0,data:c,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let n=0;for(let o=0;o<i.length-1;o++){const s=i[o],r=i[o+1];for(let i=s;i<r;i++){const o=t?t[i]:i;e.set(o,n)}n++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let o=0;t.forEachComponentRange((e,t)=>(o+=i[t]-i[e],!0));const s=r(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(o):new Uint32Array(o):new Array(o);let a=0;return t.forEachComponentRange((t,n)=>{const o=i[t],r=i[n];for(let i=o;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addHighlight(e,t,i){const n=e,o=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,o+1),n.componentData.setHighlightsInOrder(this._highlightsInOrder);n.addHighlight(t,i)&&this._requestRender()}removeHighlight(e,t,i){const n=e.removeHighlight(t,i);"notfound"!==n&&(this._removeActiveHighlight(i),n&&this._requestRender())}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)B().warn(`Removing non-existing highlight "${e}".`);else{const n=i-t;n<0&&B().warn(`Removing non-existing highlight "${e}".`),n<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,n)}}clearHighlights(e){const t=e,{componentData:i}=t,{componentHighlights:n}=t.componentData;if(n.size>0){for(const e of n)this._removeActiveHighlight(e[0],e[1][i.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,i){const n=this._renderPassManager.rctx,o=e.geometry,s=o.parameters.layout,{interleavedVertexData:r,indexData:a,vertexCount:l}=o.renderGeometryData,h=new E(n,s,r),c=a?A.createIndex(n,35044,a):null;let m=0;const g=[["geometry",h]];if(!t.isIntegratedMesh){const e=new Uint16Array(l);for(let n=0;n<i.count;n++){const t=i.offsets[n],o=i.offsets[n+1],s=i.materialDataIndices[n];if(null!=a)for(let i=t;i<o;i++){e[a[i]]=s}else for(let i=t;i<o;i++)e[i]=s}const t=new E(n,H,e.buffer);m+=t.usedMemory,g.push(["componentIndices",t])}const p=new w(n,new Map(g),c),u=a?.length??l,b=new y(p,I.TRIANGLES,o.parameters,null!=c,u),O=new j(t),C=this.materials.acquire(O,b.parameters,d),M=new _(h.usedMemory+m+(c?.usedMemory??0)),R=this.samplers.addFromTexture(t.baseColorTexture?.texture),x=new f(e,t,R);return new v(C,x,b,M)}_requestRender(){this._renderPassManager.requestRender()}};P=e([a("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection")],P);const V=h();export{P as ComponentObjectCollection};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{copy as t,sub as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o}from"../../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{ComponentObjectElevationAgnosticComponentGeometryBVH as i,intersectTriangleRangeForComponent as a}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as r}from"./ElevationAgnosticBVH.js";import{MeshIntersectionOptions as c,computeInvDir as l,intersectAabbInvDir as m}from"../../lib/RayIntersections.js";import{elevationAlignVertexGlobal as h}from"../../lib/triangleIntersectionUtils.js";class p{constructor(t,e,o,s,i,a,c,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._componentData=s,this._componentAabbs3D=i,this.geometryMinZ=a,this.planetCenterZ=c,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=u,this._ray1=D,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=y,this._callback=g,this.rayDirectionC=n(),this._componentIndexMap=null,this._bvh=new r(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._componentData.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=s(4*t),i=this._componentAabbs3D;for(let s=0;s<t;++s){const t=6*s,a=i[t+0],r=i[t+1],c=i[t+2],l=i[t+3],m=i[t+4],h=n/(c-e),p=n/(i[t+5]-e),b=Math.min(a*h,a*p),_=Math.min(r*h,r*p),f=Math.max(l*h,l*p),u=Math.max(m*h,m*p),D=4*s;o[D+0]=b,o[D+1]=_,o[D+2]=f,o[D+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=s(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],a=n[t+3],r=n[t+4],c=4*o;e[c+0]=s,e[c+1]=i,e[c+2]=a,e[c+3]=r}return e}intersectRay(t,e,n,o,s,i){const{isVerticalRay:a}=n;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=s??null,this._verticalOffset=i??null,this._tolerance=n.tolerance,this._intersectionOptions=n,this._componentIndexMap=this._bvh.elementIndexMap,l(t,e,this._invDir),this._callback=o,this._bvh.intersectRay(t,e,a),this._callback=g}intersectRange(t,e){const n=this._componentIndexMap,o=this._componentData;for(let s=t;s<e;++s){const t=n?n[s]:s;o.isPickable(t)&&o.isVisible(t)&&this._intersectComponent(t)}}getComponentTriangleCount(t){const e=this._componentData.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponent(n){const o=this.getComponentAabb3D(n,b);let s=!1;const{localMode:r,_componentVerticalOffsets:c,_verticalOffset:l,_ray0:p,_ray1:u,_invDir:D,planetCenterZ:g,_tolerance:y,rayDirectionC:v,componentIntersectionData:x}=this,{isVerticalRay:A}=this._intersectionOptions,d=this._componentData.offsets,M=t(_,p),O=t(f,u),j=c?.[n]??0,V=j+(l?.offset??0);if(0!==V&&(r?(M[2]=p[2]-V,O[2]=u[2]-V,s=!0):(null!=l&&(l.componentOffset=j),A&&(h(M,-V,g,p),h(O,-V,g,u),s=!0))),null==l||s||0===V||l.applyToAabb(o),!m(o,M,D,y))return;e(v,O,M);const Z=d[n]/3,I=d[n+1]/3,R=I-Z,B=(t,e,o)=>this._callback(t,o,n,e),{vertexData:k,vertexStride:G,indexData:w,_intersectionOptions:E}=this,{normalRequired:H}=E;if(R>C){let t=x[n];null==t&&(t=new i(n,k,G,w,Z,I,this.geometryMinZ,g,r),x[n]=t),t.intersectRay(M,O,A,s?0:V,B,H)}else{a(M,v,Z,I,w,k,G,s?0:V,g,H,B)}}}const b=o(),_=n(),f=n(),u=n(),D=n(),g=()=>{},y=new c,C=40;export{p as ComponentObjectElevationAgnosticComponentBVH};
2
+ import{copy as t,sub as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o,copy as s,expandWithAABB as i}from"../../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as r}from"../../../../../geometry/support/DoubleArray.js";import{intersectsTransformedAabb as a}from"../../../../../geometry/support/frustum.js";import{intersectTriangleRangeForComponent as l,intersectTriangleRangeScreenPolygonForComponent as c,ComponentObjectElevationAgnosticComponentGeometryBVH as h}from"./ComponentObjectElevationAgnosticComponentGeometryBVH.js";import{ElevationAgnosticBVH as m}from"./ElevationAgnosticBVH.js";import{MeshIntersectionOptions as p,computeInvDir as _,intersectAabbInvDir as f}from"../../lib/RayIntersections.js";import{elevationAlignVertexGlobal as b}from"../../lib/triangleIntersectionUtils.js";class u{constructor(t,e,o,s,i,r,a,l){this.vertexData=t,this.vertexStride=e,this.indexData=o,this._componentData=s,this._componentAabbs3D=i,this.geometryMinZ=r,this.planetCenterZ=a,this.localMode=l,this.maxBspNodeDepth=6,this.minElementCountForBVH=10,this.minBspNodeElementCount=3,this._ray0=P,this._ray1=v,this._invDir=n(),this._componentVerticalOffsets=null,this._verticalOffset=null,this._tolerance=0,this._intersectionOptions=I,this._callback=A,this._screenPolygonCallback=O,this._screenPolygonIntersector=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this._localModeOffsetDisplacement=new S,this._nodeAabbs3D=null,this.rayDirectionC=n(),this._intersectComponent=A,this._componentIndexMap=null,this._bvh=new m(s.count,this),this.componentIntersectionData=new Array(s.count)}get numComponents(){return this._componentData.count}get minZGlobal(){return this.geometryMinZ-this.planetCenterZ}getAabbs2D(){return this.localMode?this.getAabbs2DLocal():this.getAabbs2DGlobal()}getAabbs2DGlobal(){const{numComponents:t,planetCenterZ:e,minZGlobal:n}=this,o=r(4*t),s=this._componentAabbs3D;for(let i=0;i<t;++i){const t=6*i,r=s[t+0],a=s[t+1],l=s[t+2],c=s[t+3],h=s[t+4],m=n/(l-e),p=n/(s[t+5]-e),_=Math.min(r*m,r*p),f=Math.min(a*m,a*p),b=Math.max(c*m,c*p),u=Math.max(h*m,h*p),y=4*i;o[y+0]=_,o[y+1]=f,o[y+2]=b,o[y+3]=u}return o}getAabbs2DLocal(){const{numComponents:t}=this,e=r(4*t),n=this._componentAabbs3D;for(let o=0;o<t;++o){const t=6*o,s=n[t+0],i=n[t+1],r=n[t+3],a=n[t+4],l=4*o;e[l+0]=s,e[l+1]=i,e[l+2]=r,e[l+3]=a}return e}intersectRay(t,e,n,o,s,i){const{isVerticalRay:r}=n;this._ray0=t,this._ray1=e,this._componentVerticalOffsets=s??null,this._verticalOffset=i??null,this._tolerance=n.tolerance,this._intersectionOptions=n,this._intersectComponent=this._intersectComponentRay,this._componentIndexMap=this._bvh.elementIndexMap,_(t,e,this._invDir),this._callback=o,this._bvh.intersectRay(t,e,r),this._callback=A,this._intersectComponent=A}intersectScreenPolygon(t,e,n,o,s,i){this._componentVerticalOffsets=s??null,this._verticalOffset=i??null,this._screenPolygonIntersector=t,this._screenPolygonQuery=e,this._screenPolygonTransformation=n,this._screenPolygonCallback=o,this._componentIndexMap=this._bvh.elementIndexMap,this._intersectComponent=this._intersectComponentScreenPolygon,this._bvh.intersectNodes((t,e)=>this._intersectScreenPolygonNode(t,e)),this._componentIndexMap=null,this._componentVerticalOffsets=null,this._verticalOffset=null,this._screenPolygonCallback=O,this._screenPolygonTransformation=null,this._screenPolygonQuery=null,this._screenPolygonIntersector=null,this._intersectComponent=A}intersectRange(t,e){this._forEachIntersectableComponent(t,e,t=>{this._intersectComponent(t)})}getComponentTriangleCount(t){const e=this._componentData.offsets,n=e[t]/3;return e[t+1]/3-n}getComponentAabb3D(t,e){const n=this._componentAabbs3D,o=6*t;return e[0]=n[o],e[1]=n[o+1],e[2]=n[o+2],e[3]=n[o+3],e[4]=n[o+4],e[5]=n[o+5],e}_intersectComponentRay(n){const o=this.getComponentAabb3D(n,y);let s=!1;const{localMode:i,_componentVerticalOffsets:r,_verticalOffset:a,_ray0:c,_ray1:h,_invDir:m,planetCenterZ:p,_tolerance:_,rayDirectionC:u}=this,{isVerticalRay:g}=this._intersectionOptions,D=this._componentData.offsets,d=t(C,c),P=t(x,h),v=r?.[n]??0,A=v+(a?.offset??0);if(0!==A&&(i?(d[2]=c[2]-A,P[2]=h[2]-A,s=!0):(null!=a&&(a.componentOffset=v),g&&(b(d,-A,p,c),b(P,-A,p,h),s=!0))),null==a||s||0===A||a.applyToAabb(o),!f(o,d,m,_))return;e(u,P,d);const O=D[n]/3,I=D[n+1]/3,S=I-O,T=(t,e,o)=>this._callback(t,o,n,e),{vertexData:V,vertexStride:R,indexData:N,_intersectionOptions:j}=this,{normalRequired:B}=j;if(S>M){this._getOrCreateComponentGeometryBvh(n,O,I).intersectRay(d,P,g,s?0:A,T,B)}else{l(d,u,O,I,N,V,R,s?0:A,p,B,T)}}_intersectComponentScreenPolygon(t){const e=this._screenPolygonIntersector,n=this._screenPolygonQuery;if(null==e||null==n)return;const o=this.getComponentAabb3D(t,y),{_screenPolygonTransformation:i,_screenPolygonCallback:r,vertexData:l,vertexStride:h,indexData:m}=this,p=this._getScreenPolygonElevationDisplacement(t),_=null!=p?p.applyToAabb(s(g,o)):o;if(!a(n.broadPhaseFrustum,_,i))return;const f=this._componentData.offsets,b=f[t]/3,u=f[t+1]/3;if(u-b>M){return void this._getOrCreateComponentGeometryBvh(t,b,u).intersectScreenPolygon(e,i,n,p,(e,n,o)=>{r(e,n,t,o)})}const D=c(e,i,n,b,u,m,l,h,p);null!=D&&r(D.distance,D.primitiveIndex,t,D.point)}_intersectScreenPolygonNode(t,e){const n=this._screenPolygonQuery;if(null==n)return!1;const o=this._getScreenPolygonNodeAabb(t,e,g),{_screenPolygonTransformation:s}=this;return a(n.broadPhaseFrustum,o,s)}_forEachIntersectableComponent(t,e,n){const o=this._componentIndexMap,s=this._componentData;for(let i=t;i<e;++i){const t=o?o[i]:i;s.isPickable(t)&&s.isVisible(t)&&n(t)}}_getOrCreateComponentGeometryBvh(t,e,n){let o=this.componentIntersectionData[t];return null==o&&(o=new h(t,this.vertexData,this.vertexStride,this.indexData,e,n,this._componentAabbs3D[6*t+2],this._componentAabbs3D[6*t+5],this.geometryMinZ,this.planetCenterZ,this.localMode),this.componentIntersectionData[t]=o),o}_getScreenPolygonElevationDisplacement(t){const e=this._componentVerticalOffsets?.[t]??0;return this._getScreenPolygonDisplacementForOffset(e)}_getScreenPolygonDisplacementForOffset(t){const e=this._verticalOffset;return null!=e?0===t&&0===e.offset?null:(e.componentOffset=t,e):this.localMode&&0!==t?(this._localModeOffsetDisplacement.offset=t,this._localModeOffsetDisplacement):null}_getScreenPolygonNodeAabb(t,e,n){const o=this._getNodeAabb3D(t,e,n),[r,a]=this._getNodeComponentOffsetRange(t);if(r===a)return this._applyScreenPolygonDisplacementToAabb(o,r);const l=this._applyScreenPolygonDisplacementToAabb(s(D,o),r),c=this._applyScreenPolygonDisplacementToAabb(s(d,o),a);return i(l,c,n),n}_applyScreenPolygonDisplacementToAabb(t,e){const n=this._getScreenPolygonDisplacementForOffset(e);return null!=n?n.applyToAabb(t):t}_getNodeAabb3D(t,e,n){const r=this._nodeAabbs3D??=[],a=r[e];if(null!=a)return s(n,a);const l=this._componentIndexMap;let c=!1;for(let o=t.minIndexIndex;o<t.maxIndexIndex;++o){const t=l?l[o]:o,e=this.getComponentAabb3D(t,D);c?i(n,e):(s(n,e),c=!0)}const h=o();return s(h,n),r[e]=h,n}_getNodeComponentOffsetRange(t){const e=this._componentVerticalOffsets;if(null==e)return[0,0];const n=this._componentIndexMap;let o=0,s=0,i=!1;for(let r=t.minIndexIndex;r<t.maxIndexIndex;++r){const t=e[n?n[r]:r]??0;i?(o=Math.min(o,t),s=Math.max(s,t)):(o=t,s=t,i=!0)}return i?[o,s]:[0,0]}}const y=o(),g=o(),D=o(),d=o(),C=n(),x=n(),P=n(),v=n(),A=()=>{},O=()=>{},I=new p,M=40;class S{constructor(){this.offset=0}applyToVertex(t,e,n,o){return t[0]=e,t[1]=n,t[2]=o+this.offset,t}applyToAabb(t){return t[2]+=this.offset,t[5]+=this.offset,t}}export{u as ComponentObjectElevationAgnosticComponentBVH};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{copy as t,sub as e}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ElevationAgnosticBVH as r}from"./ElevationAgnosticBVH.js";import{intersectRayTrianglesWithVerticalOffsetENUGlobal as s,intersectRayTriangles as a}from"../../lib/RayIntersections.js";import{generateTriangleAabbsLocal as n,generateTriangleAabbsGlobal as h}from"../../lib/triangleIntersectionUtils.js";class l{constructor(t,e,s,a,n,h,l,o,c){this.componentIndex=t,this.vertexData=e,this.vertexStride=s,this.indexData=a,this.startTriangleNumber=n,this.endTriangleNumber=h,this.geometryMinZ=l,this.planetCenterZ=o,this.localMode=c,this.maxBspNodeDepth=8,this.minElementCountForBVH=20,this.minBspNodeElementCount=10,this.rayDirection=i(),this.ray0=i(),this.isVerticalRay=!1,this._triangleHitCallback=m,this.totalElevationOffset=0,this.normalRequired=!1,this._bvh=new r(h-n,this)}getAabbs2D(){return this.localMode?n(this.startTriangleNumber,this.endTriangleNumber,this.indexData,this.vertexData,this.vertexStride):h(this.startTriangleNumber,this.endTriangleNumber,this.indexData,this.vertexData,this.vertexStride,this.geometryMinZ,this.planetCenterZ)}get numTriangles(){return this.endTriangleNumber-this.startTriangleNumber}intersectRay(i,r,s,a,n,h){t(this.ray0,i),e(this.rayDirection,r,i),this.isVerticalRay=s,this.totalElevationOffset=a,this.normalRequired=h,this._triangleHitCallback=n,this._bvh.intersectRay(i,r,s),this._triangleHitCallback=m}intersectRange(t,e){const i=this._bvh.elementIndexMap;o(this.ray0,this.rayDirection,t,e,this.indexData,this.vertexData,this.vertexStride,this.totalElevationOffset,this.planetCenterZ,this.normalRequired,this._triangleHitCallback,i,this.startTriangleNumber)}getTriangleElevationOffset(t){return this.totalElevationOffset}}function o(t,e,i,r,n,h,l,o,m,c,g,b=null,u=0){0!==o?s(t,e,i,r,n,h,l,o,m,c,g,b,u):a(t,e,i,r,n,h,l,c,g,b,u)}function m(){}export{l as ComponentObjectElevationAgnosticComponentGeometryBVH,o as intersectTriangleRangeForComponent};
2
+ import{copy as e,sub as t}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s,fromValues as i}from"../../../../../geometry/support/aaBoundingBox.js";import{intersectsTransformedAabb as r}from"../../../../../geometry/support/frustum.js";import{ElevationAgnosticBVH as o}from"./ElevationAgnosticBVH.js";import{intersectRayTrianglesWithVerticalOffsetENUGlobal as a,intersectRayTriangles as l}from"../../lib/RayIntersections.js";import{forEachTriangleRangeScreenPolygonHit as h,Hit as c}from"../../lib/screenPolygonTriangleIntersections.js";import{generateTriangleAabbsLocal as m,generateTriangleAabbsGlobal as g}from"../../lib/triangleIntersectionUtils.js";const y=()=>{};class u{constructor(e,t,s,i,r,a,l,h,c,m,g){this.componentIndex=e,this.vertexData=t,this.vertexStride=s,this.indexData=i,this.startTriangleNumber=r,this.endTriangleNumber=a,this.componentMinZ=l,this.componentMaxZ=h,this.geometryMinZ=c,this.planetCenterZ=m,this.localMode=g,this.maxBspNodeDepth=8,this.minElementCountForBVH=20,this.minBspNodeElementCount=10,this.rayDirection=n(),this.ray0=n(),this.isVerticalRay=!1,this._triangleHitCallback=p,this.totalElevationOffset=0,this.normalRequired=!1,this._screenPolygonDisplacement=null,this._screenPolygonIntersector=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this._screenPolygonBestDistance=Number.POSITIVE_INFINITY,this._screenPolygonBestTriangleNumber=-1,this._screenPolygonHasNormal=!1,this._screenPolygonBestNormal=n(),this._screenPolygonBestPoint=n(),this.intersectRange=y,this._bvh=new o(a-r,this)}getAabbs2D(){return this.localMode?m(this.startTriangleNumber,this.endTriangleNumber,this.indexData,this.vertexData,this.vertexStride):g(this.startTriangleNumber,this.endTriangleNumber,this.indexData,this.vertexData,this.vertexStride,this.geometryMinZ,this.planetCenterZ)}get numTriangles(){return this.endTriangleNumber-this.startTriangleNumber}intersectRay(n,s,i,r,o,a){e(this.ray0,n),t(this.rayDirection,s,n),this.isVerticalRay=i,this.totalElevationOffset=r,this.normalRequired=a,this.intersectRange=this._intersectRangeRay,this._triangleHitCallback=o,this._bvh.intersectRay(n,s,i),this._triangleHitCallback=p,this.intersectRange=y}intersectScreenPolygon(e,t,n,s,i){this._screenPolygonIntersector=e,this._screenPolygonTransformation=t,this._screenPolygonQuery=n,this._screenPolygonDisplacement=s,this._screenPolygonBestDistance=Number.POSITIVE_INFINITY,this.intersectRange=this._intersectRangeScreenPolygon,this._bvh.intersectNodes(e=>this._couldIntersectScreenPolygonNode(e)),this._screenPolygonBestDistance<Number.POSITIVE_INFINITY&&i(this._screenPolygonBestDistance,this._screenPolygonBestTriangleNumber,this._screenPolygonBestPoint,this._screenPolygonHasNormal?this._screenPolygonBestNormal:null),this._screenPolygonDisplacement=null,this._screenPolygonQuery=null,this._screenPolygonTransformation=null,this._screenPolygonIntersector=null,this.intersectRange=y}_intersectRangeRay(e,t){const n=this._bvh.elementIndexMap;_(this.ray0,this.rayDirection,e,t,this.indexData,this.vertexData,this.vertexStride,this.totalElevationOffset,this.planetCenterZ,this.normalRequired,this._triangleHitCallback,n,this.startTriangleNumber)}_intersectRangeScreenPolygon(t,n){const{_screenPolygonQuery:s,_screenPolygonIntersector:i}=this;if(!s||!i)return;const r=this._bvh.elementIndexMap,o=P(i,this._screenPolygonTransformation,s,t,n,this.indexData,this.vertexData,this.vertexStride,this._screenPolygonDisplacement,r,this.startTriangleNumber);null!=o&&o.distance<this._screenPolygonBestDistance&&(this._screenPolygonBestDistance=o.distance,this._screenPolygonBestTriangleNumber=o.primitiveIndex,this._screenPolygonHasNormal=o.hasNormal,e(this._screenPolygonBestPoint,o.point),o.hasNormal&&e(this._screenPolygonBestNormal,o.normal))}getTriangleElevationOffset(e){return this.totalElevationOffset}_couldIntersectScreenPolygonNode(e){const t=this._screenPolygonQuery;if(null==t)return!1;const n=this._getNodeAabb3D(e,f);return this._screenPolygonDisplacement?.applyToAabb(n),r(t.broadPhaseFrustum,n,this._screenPolygonTransformation)}_getNodeAabb3D(e,t){const[n,s,r,o]=e.aabb2D;if(this.localMode)return i(n,s,this.componentMinZ,r,o,this.componentMaxZ,t);const a=this.geometryMinZ-this.planetCenterZ,l=(this.componentMinZ-this.planetCenterZ)/a,h=(this.componentMaxZ-this.planetCenterZ)/a,c=n*l,m=n*h,g=r*l,y=r*h,u=s*l,_=s*h,P=o*l,p=o*h;return i(Math.min(c,m,g,y),Math.min(u,_,P,p),this.componentMinZ,Math.max(c,m,g,y),Math.max(u,_,P,p),this.componentMaxZ,t)}}function _(e,t,n,s,i,r,o,h,c,m,g,y=null,u=0){0!==h?a(e,t,n,s,i,r,o,h,c,m,g,y,u):l(e,t,n,s,i,r,o,m,g,y,u)}function P(t,n,s,i,r,o,a,l,c,m=null,g=0){let y=Number.POSITIVE_INFINITY,u=-1,_=!1,P=!1;for(const p of h(t,n,s,i,r,o,a,l,c,m,g))p.distance>=y||(y=p.distance,u=p.primitiveIndex,_=!0,P=p.hasNormal,e(b,p.point),p.hasNormal&&e(N,p.normal));return _?(d.update(y,u,b,P?N:null),d):null}function p(){}const b=n(),N=n(),d=new c(4),f=s();export{u as ComponentObjectElevationAgnosticComponentGeometryBVH,_ as intersectTriangleRangeForComponent,P as intersectTriangleRangeScreenPolygonForComponent};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{Vertices as t}from"../../lib/Attribute.js";import{TriangleIntersectionData as n}from"../../lib/TriangleIntersectionData.js";class e{constructor(e,r,s,o,i){this._componentOffsets=i,this._intersectionData=new n(s,o,new t(e,3,r))}intersectRay(t,n,e,s){const o=(t,n,e)=>{const o=r(this._componentOffsets,e);s(t,e,o,n)};this._intersectionData.intersectRay(t,n,e,o)}}function r(t,n){const{length:e}=t;if(0===e||n<t[0])return-1;if(n>t[e-1])return e;let r=0,s=e-1;for(;s-r>1;){const e=Math.round(.5*(r+s));n<=t[e]?s=e:r=e}return r}export{e as ComponentObjectFixedBVH};
2
+ import{Vertices as t}from"../../lib/Attribute.js";import{TriangleIntersectionData as n}from"../../lib/TriangleIntersectionData.js";class e{constructor(e,o,s,i,r){this._componentOffsets=r,this._intersectionData=new n(s,i,new t(e,3,o))}intersectRay(t,n,e,s){const i=(t,n,e)=>{const i=o(this._componentOffsets,e);s(t,e,i,n)};this._intersectionData.intersectRay(t,n,e,i)}intersectScreenPolygon(t,n,e,s){this._intersectionData.forEachScreenPolygonHit(t,e,n,null,(t,n,e)=>{const i=o(this._componentOffsets,n);i<0||i>=this._componentOffsets.length-1||s(t,n,i,e)})}}function o(t,n){const{length:e}=t;if(0===e||n<t[0])return-1;if(n>t[e-1])return e;let o=0,s=e-1;for(;s-o>1;){const e=Math.round(.5*(o+s));n<=t[e]?s=e:o=e}return o}export{e as ComponentObjectFixedBVH};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{clamp as t}from"../../../../../core/mathUtils.js";import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../../../geometry/support/aaBoundingRect.js";import{createUintArray as i}from"../../lib/triangleIntersectionUtils.js";class s{constructor(t,n){this.elementCount=t,this.model=n,this._elementIndexMap=null,this._bspNodes=[],this._generatedBVH=!1,this.localMode=n.localMode,this.planetCenterZ=n.planetCenterZ,this.geometryMinZ=n.geometryMinZ,this.planetCenter=e(0,0,this.planetCenterZ),this.maxBspNodeDepth=n.maxBspNodeDepth??8,this.minElementCountForBVH=n.minElementCountForBVH??15,this.minBspNodeElementCount=n.minBspNodeElementCount??5}get elementIndexMap(){return this._ensureBVH(),this._elementIndexMap}get _skipBVH(){return this.elementCount<this.minElementCountForBVH||this.geometryMinZ<.5*this.planetCenterZ}_ensureBVH(){this._generatedBVH||this._skipBVH||0===this._bspNodes.length&&this._generateBsp()}intersectRay(t,e,n){this.elementCount<1||(this._skipBVH?this._intersectRayWithoutBVH(n):this._intersectRayWithBVH(t,e,n))}_intersectRayWithoutBVH(t){this._intersectRange(0,this.elementCount)}_intersectRange(t,e){this.model.intersectRange(t,e)}_intersectRayWithBVH(t,e,n){this._ensureBVH(),n?this._intersectGeometryWithBVHVerticalRay(t):this._intersectGeometryWithBVHGeneralRay(t,e)}_intersectGeometryWithBVHVerticalRay(t){let e=t[0],n=t[1];if(!this.localMode){const{geometryMinZ:i,planetCenterZ:s}=this,h=(i-s)/(t[2]-s);e=t[0]*h,n=t[1]*h}const{_bspNodes:i}=this;let s=0;for(;s>=0;){const t=i[s],{d:h,dim:a,minIndexIndex:o,minMidIndexIndex:r,maxMidIndexIndex:c,maxIndexIndex:m,aabb2D:d}=t;if(e<d[0]||e>d[2]||n<d[1]||n>d[3])break;if(-1===a||-1===t.child0&&-1===t.child1){this._intersectRange(o,m);break}{this._intersectRange(r,c);const i=(0===a?e:n)-h;if(i<0){if(-1===t.child0){this._intersectRange(o,r);break}s=t.child0}else{if(!(i>0))break;if(-1===t.child1){this._intersectRange(c,m);break}s=t.child1}}}}_intersectGeometryWithBVHGeneralRay(e,n){let i=e[0],s=e[1],h=n[0],a=n[1];const{geometryMinZ:o}=this;if(!this.localMode){let t=0,r=1;const c=Math.min(.5*this.planetCenterZ,o),m=e[2],d=n[2];if(m<c&&d<c)return;if(m<c&&(t=(c-m)/(d-m)),d<c&&(r=(c-m)/(d-m)),t>r)return;const l=(1-t)*e[0]+t*n[0],M=(1-t)*e[1]+t*n[1],u=(1-t)*e[2]+t*n[2],x=(1-r)*e[0]+r*n[0],p=(1-r)*e[1]+r*n[1],f=(1-r)*e[2]+r*n[2],{planetCenterZ:g}=this,_=o-g,B=_/(u-g);i=l*B,s=M*B;const I=_/(f-g);h=x*I,a=p*I}const r=h-i,c=a-s,m=this._bspNodes;let d=1;{const{aabb2D:t}=m[0],e=(t,e,n,i)=>{if(Math.abs(e)<1e-5*Math.max(i-n,1))return!1;const s=e>0,h=s?i:n,a=t+d*e;return(s?a<h:a>h)&&(d=Math.max((h-t)/e,d),!0)},n=()=>e(i,r,t[0],t[2]),h=()=>e(s,c,t[1],t[3]);Math.abs(r)>=Math.abs(c)?n()||h():h()||n()}const l=[0,0,d];let M=0;for(;M<l.length;){const e=l[M];let n=l[M+1],h=l[M+2];if(M+=3,n>h)continue;const a=m[e],{minIndexIndex:o,maxIndexIndex:u}=a,{child0:x,child1:p,minMidIndexIndex:f,maxMidIndexIndex:g,aabb2D:_,d:B,dim:I}=a;{const t=i+n*r,e=i+h*r,s=Math.min(t,e),a=Math.max(t,e),o=_[0],c=_[2];if(a<o||c<s)continue;if(s<o){const t=(o-i)/r;r>0?n=Math.max(n,t):h=Math.min(h,t)}if(c<a){const t=(c-i)/r;r>0?h=Math.min(h,t):n=Math.max(n,t)}}{const t=s+n*c,e=s+h*c,i=Math.min(t,e),a=Math.max(t,e),o=_[1],r=_[3];if(a<o||r<i)continue;if(i<o){const t=(o-s)/c;c>0?n=Math.max(n,t):h=Math.min(h,t)}if(r<a){const t=(r-s)/c;c>0?h=Math.min(h,t):n=Math.max(n,t)}}if(-1===x&&-1===p)this._intersectRange(o,u);else{const e=0===I?i:s,a=0===I?r:c,m=e+n*a,M=e+h*a,_=Math.min(m,M),b=Math.max(m,M),V=t((B-e)/a,0,d);o<f&&_<=B&&(-1!==x?(l.push(x),l.push(a>=0?n:Math.max(n,V)),l.push(a>=0?Math.min(h,V):h)):this._intersectRange(o,f)),this._intersectRange(f,g),g<u&&B<=b&&(-1!==p?(l.push(p),l.push(a>=0?Math.max(n,V):n),l.push(a>=0?h:Math.min(h,V))):this._intersectRange(g,u))}}}_generateBsp(){const{elementCount:t}=this;if(t<1)return;const e=i(t,t);this._elementIndexMap=e;for(let n=0;n<t;++n)e[n]=n;const s=this.model.getAabbs2D();let r=0;const d=this._bspNodes;d.length=0;const{localMode:l}=this;let M=!1;if(!l){const{planetCenterZ:t,geometryMinZ:e}=this;M=t>=0||e<.5*t}const u=[],x=(t,e,n,i,s)=>{u.push(t),u.push(e),u.push(n),u.push(i<0?-1:(s?0:1)+2*i)},{maxBspNodeDepth:p,minBspNodeElementCount:f}=this,g=(t,i,r,u,g)=>{const _=d.length;if(_>0&&(M||r>=p||i-t<f))return;const B=n();c(B,t,i,e,s);const{d:I,dim:b}=l?h(B):a(B),{rangeMidStart:V,rangeMidEnd:R}=o(t,i,b,I,e,s),y=r===p-1,C=!y&&V>=t+f,H=!y&&i>=R+f;if(C||H||0===_){const e=new m(t,V,R,i,b,I,B);if(C&&x(t,V,r+1,_,!0),H&&x(R,i,r+1,_,!1),d.push(e),-1!==u){const t=d[u];g?t.child0=_:t.child1=_}}};for(x(0,t,0,-1,!1);r<u.length;){const t=u[r],e=u[r+1],n=u[r+2],i=u[r+3];r+=4;const s=i>>1;g(t,e,n,s,i-(s<<1)==0)}this._generatedBVH=!0}}function h(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,a;return i-e>=s-n?(a=.5*(e+i),h=0):(a=.5*(n+s),h=1),{d:a,dim:h}}function a(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,a;return i-e>=s-n?(h=0,a=.5*(e+i)):(h=1,a=.5*(n+s)),{dim:h,d:a}}function o(t,e,n,i,s,h){let a=t;{let t=e;for(;a<t;){const e=s[a];r(e,n,i,h)<0?++a:(--t,s[a]=s[t],s[t]=e)}}const o=a;let c=a,m=e;for(;c<m;){const t=s[m-1];r(t,n,i,h)>0?--m:(s[m-1]=s[c],s[c]=t,++c)}return{rangeMidStart:o,rangeMidEnd:m}}function r(t,e,n,i){const s=4*t,h=i[s+0+e];return i[s+2+e]<n?-1:h>n?1:0}function c(t,e,n,i,s){let h=1/0,a=1/0,o=-1/0,r=-1/0;for(let c=e;c<n;++c){const t=4*i[c];h=Math.min(h,s[t+0]),a=Math.min(a,s[t+1]),o=Math.max(o,s[t+2]),r=Math.max(r,s[t+3])}t[0]=h,t[1]=a,t[2]=o,t[3]=r}class m{constructor(t,e,n,i,s,h,a){this.minIndexIndex=t,this.minMidIndexIndex=e,this.maxMidIndexIndex=n,this.maxIndexIndex=i,this.dim=s,this.d=h,this.aabb2D=a,this.child0=-1,this.child1=-1}}export{s as ElevationAgnosticBVH};
2
+ import{clamp as t}from"../../../../../core/mathUtils.js";import{fromValues as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../../../geometry/support/aaBoundingRect.js";import{createUintArray as i}from"../../lib/triangleIntersectionUtils.js";class s{constructor(t,n){this.elementCount=t,this.model=n,this._elementIndexMap=null,this._bspNodes=[],this._generatedBVH=!1,this.localMode=n.localMode,this.planetCenterZ=n.planetCenterZ,this.geometryMinZ=n.geometryMinZ,this.planetCenter=e(0,0,this.planetCenterZ),this.maxBspNodeDepth=n.maxBspNodeDepth??8,this.minElementCountForBVH=n.minElementCountForBVH??15,this.minBspNodeElementCount=n.minBspNodeElementCount??5}get elementIndexMap(){return this._ensureBVH(),this._elementIndexMap}get _skipBVH(){return this.elementCount<this.minElementCountForBVH||this.geometryMinZ<.5*this.planetCenterZ}_ensureBVH(){this._generatedBVH||this._skipBVH||0===this._bspNodes.length&&this._generateBsp()}intersectRay(t,e,n){this.elementCount<1||(this._skipBVH?this._intersectRayWithoutBVH(n):this._intersectRayWithBVH(t,e,n))}intersectNodes(t){if(this.elementCount<1)return;if(this._skipBVH)return void this._intersectRange(0,this.elementCount);this._ensureBVH();const e=[0];for(;e.length>0;){const n=e.pop(),i=this._bspNodes[n];if(!t(i,n))continue;const{child0:s,child1:h,minIndexIndex:o,minMidIndexIndex:a,maxMidIndexIndex:r,maxIndexIndex:c}=i;-1!==s||-1!==h?(-1!==s?e.push(s):this._intersectRange(o,a),this._intersectRange(a,r),-1!==h?e.push(h):this._intersectRange(r,c)):this._intersectRange(o,c)}}_intersectRayWithoutBVH(t){this._intersectRange(0,this.elementCount)}_intersectRange(t,e){this.model.intersectRange(t,e)}_intersectRayWithBVH(t,e,n){this._ensureBVH(),n?this._intersectGeometryWithBVHVerticalRay(t):this._intersectGeometryWithBVHGeneralRay(t,e)}_intersectGeometryWithBVHVerticalRay(t){let e=t[0],n=t[1];if(!this.localMode){const{geometryMinZ:i,planetCenterZ:s}=this,h=(i-s)/(t[2]-s);e=t[0]*h,n=t[1]*h}const{_bspNodes:i}=this;let s=0;for(;s>=0;){const t=i[s],{d:h,dim:o,minIndexIndex:a,minMidIndexIndex:r,maxMidIndexIndex:c,maxIndexIndex:d,aabb2D:m}=t;if(e<m[0]||e>m[2]||n<m[1]||n>m[3])break;if(-1===o||-1===t.child0&&-1===t.child1){this._intersectRange(a,d);break}{this._intersectRange(r,c);const i=(0===o?e:n)-h;if(i<0){if(-1===t.child0){this._intersectRange(a,r);break}s=t.child0}else{if(!(i>0))break;if(-1===t.child1){this._intersectRange(c,d);break}s=t.child1}}}}_intersectGeometryWithBVHGeneralRay(e,n){let i=e[0],s=e[1],h=n[0],o=n[1];const{geometryMinZ:a}=this;if(!this.localMode){let t=0,r=1;const c=Math.min(.5*this.planetCenterZ,a),d=e[2],m=n[2];if(d<c&&m<c)return;if(d<c&&(t=(c-d)/(m-d)),m<c&&(r=(c-d)/(m-d)),t>r)return;const l=(1-t)*e[0]+t*n[0],x=(1-t)*e[1]+t*n[1],u=(1-t)*e[2]+t*n[2],p=(1-r)*e[0]+r*n[0],M=(1-r)*e[1]+r*n[1],f=(1-r)*e[2]+r*n[2],{planetCenterZ:_}=this,g=a-_,I=g/(u-_);i=l*I,s=x*I;const B=g/(f-_);h=p*B,o=M*B}const r=h-i,c=o-s,d=this._bspNodes;let m=1;{const{aabb2D:t}=d[0],e=(t,e,n,i)=>{if(Math.abs(e)<1e-5*Math.max(i-n,1))return!1;const s=e>0,h=s?i:n,o=t+m*e;return(s?o<h:o>h)&&(m=Math.max((h-t)/e,m),!0)},n=()=>e(i,r,t[0],t[2]),h=()=>e(s,c,t[1],t[3]);Math.abs(r)>=Math.abs(c)?n()||h():h()||n()}const l=[0,0,m];let x=0;for(;x<l.length;){const e=l[x];let n=l[x+1],h=l[x+2];if(x+=3,n>h)continue;const o=d[e],{minIndexIndex:a,maxIndexIndex:u}=o,{child0:p,child1:M,minMidIndexIndex:f,maxMidIndexIndex:_,aabb2D:g,d:I,dim:B}=o;{const t=i+n*r,e=i+h*r,s=Math.min(t,e),o=Math.max(t,e),a=g[0],c=g[2];if(o<a||c<s)continue;if(s<a){const t=(a-i)/r;r>0?n=Math.max(n,t):h=Math.min(h,t)}if(c<o){const t=(c-i)/r;r>0?h=Math.min(h,t):n=Math.max(n,t)}}{const t=s+n*c,e=s+h*c,i=Math.min(t,e),o=Math.max(t,e),a=g[1],r=g[3];if(o<a||r<i)continue;if(i<a){const t=(a-s)/c;c>0?n=Math.max(n,t):h=Math.min(h,t)}if(r<o){const t=(r-s)/c;c>0?h=Math.min(h,t):n=Math.max(n,t)}}if(-1===p&&-1===M)this._intersectRange(a,u);else{const e=0===B?i:s,o=0===B?r:c,d=e+n*o,x=e+h*o,g=Math.min(d,x),b=Math.max(d,x),R=t((I-e)/o,0,m);a<f&&g<=I&&(-1!==p?(l.push(p),l.push(o>=0?n:Math.max(n,R)),l.push(o>=0?Math.min(h,R):h)):this._intersectRange(a,f)),this._intersectRange(f,_),_<u&&I<=b&&(-1!==M?(l.push(M),l.push(o>=0?Math.max(n,R):n),l.push(o>=0?h:Math.min(h,R))):this._intersectRange(_,u))}}}_generateBsp(){const{elementCount:t}=this;if(t<1)return;const e=i(t,t);this._elementIndexMap=e;for(let n=0;n<t;++n)e[n]=n;const s=this.model.getAabbs2D();let r=0;const m=this._bspNodes;m.length=0;const{localMode:l}=this;let x=!1;if(!l){const{planetCenterZ:t,geometryMinZ:e}=this;x=t>=0||e<.5*t}const u=[],p=(t,e,n,i,s)=>{u.push(t),u.push(e),u.push(n),u.push(i<0?-1:(s?0:1)+2*i)},{maxBspNodeDepth:M,minBspNodeElementCount:f}=this,_=(t,i,r,u,_)=>{const g=m.length;if(g>0&&(x||r>=M||i-t<f))return;const I=n();c(I,t,i,e,s);const{d:B,dim:b}=l?h(I):o(I),{rangeMidStart:R,rangeMidEnd:V}=a(t,i,b,B,e,s),C=r===M-1,H=!C&&R>=t+f,y=!C&&i>=V+f;if(H||y||0===g){const e=new d(t,R,V,i,b,B,I);if(H&&p(t,R,r+1,g,!0),y&&p(V,i,r+1,g,!1),m.push(e),-1!==u){const t=m[u];_?t.child0=g:t.child1=g}}};for(p(0,t,0,-1,!1);r<u.length;){const t=u[r],e=u[r+1],n=u[r+2],i=u[r+3];r+=4;const s=i>>1;_(t,e,n,s,i-(s<<1)==0)}this._generatedBVH=!0}}function h(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,o;return i-e>=s-n?(o=.5*(e+i),h=0):(o=.5*(n+s),h=1),{d:o,dim:h}}function o(t){const e=t[0],n=t[1],i=t[2],s=t[3];let h,o;return i-e>=s-n?(h=0,o=.5*(e+i)):(h=1,o=.5*(n+s)),{dim:h,d:o}}function a(t,e,n,i,s,h){let o=t;{let t=e;for(;o<t;){const e=s[o];r(e,n,i,h)<0?++o:(--t,s[o]=s[t],s[t]=e)}}const a=o;let c=o,d=e;for(;c<d;){const t=s[d-1];r(t,n,i,h)>0?--d:(s[d-1]=s[c],s[c]=t,++c)}return{rangeMidStart:a,rangeMidEnd:d}}function r(t,e,n,i){const s=4*t,h=i[s+0+e];return i[s+2+e]<n?-1:h>n?1:0}function c(t,e,n,i,s){let h=1/0,o=1/0,a=-1/0,r=-1/0;for(let c=e;c<n;++c){const t=4*i[c];h=Math.min(h,s[t+0]),o=Math.min(o,s[t+1]),a=Math.max(a,s[t+2]),r=Math.max(r,s[t+3])}t[0]=h,t[1]=o,t[2]=a,t[3]=r}class d{constructor(t,e,n,i,s,h,o){this.minIndexIndex=t,this.minMidIndexIndex=e,this.maxMidIndexIndex=n,this.maxIndexIndex=i,this.dim=s,this.d=h,this.aabb2D=o,this.child0=-1,this.child1=-1}}export{s as ElevationAgnosticBVH};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{invert as t,transpose as s}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as e}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{sub as n,transformMat3 as i,negate as o}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a}from"../../../../../geometry/support/aaBoundingBox.js";import{floatArrayFrom as h,floatArrayByteSize as m,newFloatArray as p}from"../../../../../geometry/support/FloatArray.js";import{indexArrayFrom as c,getContinuousIndexArray as l,indexArrayByteSize as _}from"../../../../../geometry/support/Indices.js";import{ComponentObjectElevationAgnosticComponentBVH as b}from"./ComponentObjectElevationAgnosticBVH.js";import{ComponentObjectFixedBVH as u}from"./ComponentObjectFixedBVH.js";class f{constructor(t,s,e,n){this.viewingMode=t,this._components=e,this._needsElevationAlignment=n,this.verticalOffset=null,this.componentVerticalOffsets=null,this._planetCenter=r(),this._componentBvh=null,this._aabb=a();const{indices:i,positions:o}=s,m=o.length/3;this._indices=i?c(i,m):l(m),this._positions=h(o)}get usedMemory(){return m(this._positions)+_(this._indices)}destroy(){this._positions=null,this._indices=null,this._perComponentAabbs=null,this._componentBvh=null}getComponentAabb(t,s){const e=this._ensureComponentAabbs(),n=6*t;return s[0]=e[n],s[1]=e[n+1],s[2]=e[n+2],s[3]=e[n+3],s[4]=e[n+4],s[5]=e[n+5],s}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs()),this._perComponentAabbs}getComponentPositions(t,s){s.indices=this._indices,s.data=this._positions,s.stride=3,s.startIndex=this._components.offsets[t],s.endIndex=this._components.offsets[t+1]}intersect(e,r,a,h,m,p,c){this.verticalOffset=a,this.componentVerticalOffsets=h;const{position:l}=m,_=n(d,e,l),b=n(g,r,l),u=t(C,m.rotationScale);i(_,_,u),i(b,b,u);const f=s(A,u);if(1===this.viewingMode){const t=this._planetCenter;o(t,l),i(t,t,u)}const v=(t,s,e,n)=>{c(e,t,n?i(M,n,f):null,s)};this._intersectComponents(_,b,h,a,v,p)}_computePerComponentAabbs(){const t=this._aabb,s=.5*(t[0]+t[3]),e=.5*(t[1]+t[4]),n=.5*(t[2]+t[5]),i=this._components.count,o=p(6*i),r=this._indices,a=this._positions,h=this._components.offsets;let m=0,c=1/0,l=1/0,_=1/0,b=-1/0,u=-1/0,f=-1/0;for(let p=0;p<i;p++){const t=h[p],i=h[p+1];let d=1/0,g=1/0,C=1/0,M=-1/0,A=-1/0,v=-1/0;if(t<i)for(let s=t;s<i;s++){const t=3*r[s],e=a[t],n=a[t+1],i=a[t+2];d=Math.min(d,e),g=Math.min(g,n),C=Math.min(C,i),M=Math.max(M,e),A=Math.max(A,n),v=Math.max(v,i)}else d=s,g=e,C=n,M=s,A=e,v=n;o[m++]=d,o[m++]=g,o[m++]=C,o[m++]=M,o[m++]=A,o[m++]=v,c=Math.min(c,d),l=Math.min(l,g),_=Math.min(_,C),b=Math.max(b,M),u=Math.max(u,A),f=Math.max(f,v)}return this._aabb[0]=c,this._aabb[1]=l,this._aabb[2]=_,this._aabb[3]=b,this._aabb[4]=u,this._aabb[5]=f,o}_intersectComponents(t,s,e,n,i,o){let r=this._componentBvh;null==r&&(r=this._needsElevationAlignment?new b(this._positions,v,this._indices,this._components,this._ensureComponentAabbs(),this.geometryMinZ,this.planetCenterZ,this.localMode):new u(this._positions,v,this._indices,this.numTriangles,this._components.offsets),this._componentBvh=r),r.intersectRay(t,s,o,i,e??void 0,n??void 0)}get geometryMinZ(){return this._aabb[2]}get planetCenterZ(){return this._planetCenter[2]}get numTriangles(){return this._indices.length/3}get localMode(){return 2===this.viewingMode}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}const d=r(),g=r(),C=e(),M=r(),A=e(),v=3;export{f as IntersectionGeometry};
2
+ import{transpose as t,invert as e}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{sub as i,transformMat3 as o,negate as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as h}from"../../../../../geometry/support/aaBoundingBox.js";import{floatArrayFrom as m,floatArrayByteSize as p,newFloatArray as c}from"../../../../../geometry/support/FloatArray.js";import{indexArrayFrom as _,getContinuousIndexArray as l,indexArrayByteSize as b}from"../../../../../geometry/support/Indices.js";import{ComponentObjectElevationAgnosticComponentBVH as u}from"./ComponentObjectElevationAgnosticBVH.js";import{ComponentObjectFixedBVH as f}from"./ComponentObjectFixedBVH.js";class g{constructor(t,e,s,n){this.viewingMode=t,this._components=s,this._needsElevationAlignment=n,this.verticalOffset=null,this.componentVerticalOffsets=null,this._planetCenter=a(),this._componentBvh=null,this._aabb=h();const{indices:i,positions:o}=e,r=o.length/3;this._indices=i?_(i,r):l(r),this._positions=m(o)}get usedMemory(){return p(this._positions)+b(this._indices)}destroy(){this._positions=null,this._indices=null,this._perComponentAabbs=null,this._componentBvh=null}getComponentAabb(t,e){const s=this._ensureComponentAabbs(),n=6*t;return e[0]=s[n],e[1]=s[n+1],e[2]=s[n+2],e[3]=s[n+3],e[4]=s[n+4],e[5]=s[n+5],e}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs()),this._perComponentAabbs}getComponentPositions(t,e){e.indices=this._indices,e.data=this._positions,e.stride=3,e.startIndex=this._components.offsets[t],e.endIndex=this._components.offsets[t+1]}intersectRay(e,s,n,r,a,h,m){const p=v;this._setupIntersect(n,r,a,p);const{position:c}=a,_=i(d,e,c),l=i(C,s,c);o(_,_,p),o(l,l,p);const b=t(x,p),u=(t,e,s,n)=>{m(s,t,n?o(A,n,b):null,e)};this._intersectComponents(_,l,r,n,u,h)}intersectScreenPolygon(t,e,s,n,i,o){this._setupIntersect(s,n,i);this._ensureComponentBvh().intersectScreenPolygon(t,e,i.toMat4(M),(t,e,s,n)=>o(s,t,n,e),n??void 0,s??void 0)}_setupIntersect(t,s,n,i=v){if(this.verticalOffset=t,this.componentVerticalOffsets=s,e(i,n.rotationScale),1===this.viewingMode){const t=this._planetCenter;r(t,n.position),o(t,t,i)}}_computePerComponentAabbs(){const t=this._aabb,e=.5*(t[0]+t[3]),s=.5*(t[1]+t[4]),n=.5*(t[2]+t[5]),i=this._components.count,o=c(6*i),r=this._indices,a=this._positions,h=this._components.offsets;let m=0,p=1/0,_=1/0,l=1/0,b=-1/0,u=-1/0,f=-1/0;for(let c=0;c<i;c++){const t=h[c],i=h[c+1];let g=1/0,d=1/0,C=1/0,v=-1/0,M=-1/0,A=-1/0;if(t<i)for(let e=t;e<i;e++){const t=3*r[e],s=a[t],n=a[t+1],i=a[t+2];g=Math.min(g,s),d=Math.min(d,n),C=Math.min(C,i),v=Math.max(v,s),M=Math.max(M,n),A=Math.max(A,i)}else g=e,d=s,C=n,v=e,M=s,A=n;o[m++]=g,o[m++]=d,o[m++]=C,o[m++]=v,o[m++]=M,o[m++]=A,p=Math.min(p,g),_=Math.min(_,d),l=Math.min(l,C),b=Math.max(b,v),u=Math.max(u,M),f=Math.max(f,A)}return this._aabb[0]=p,this._aabb[1]=_,this._aabb[2]=l,this._aabb[3]=b,this._aabb[4]=u,this._aabb[5]=f,o}_intersectComponents(t,e,s,n,i,o){this._ensureComponentBvh().intersectRay(t,e,o,i,s??void 0,n??void 0)}_ensureComponentBvh(){let t=this._componentBvh;return null==t&&(t=this._needsElevationAlignment?new u(this._positions,j,this._indices,this._components,this._ensureComponentAabbs(),this.geometryMinZ,this.planetCenterZ,this.localMode):new f(this._positions,j,this._indices,this.numTriangles,this._components.offsets),this._componentBvh=t),t}get geometryMinZ(){return this._aabb[2]}get planetCenterZ(){return this._planetCenter[2]}get numTriangles(){return this._indices.length/3}get localMode(){return 2===this.viewingMode}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}const d=a(),C=a(),v=s(),M=n(),A=a(),x=s(),j=3;export{g as IntersectionGeometry};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{DecodeSymbolColor as o}from"./DecodeSymbolColor.glsl.js";import{TextureBackedBufferModule as e}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{Float4DrawUniform as r}from"../../../core/shaderModules/Float4DrawUniform.js";import{FloatDrawUniform as t}from"../../../core/shaderModules/FloatDrawUniform.js";import{glsl as n,If as d}from"../../../core/shaderModules/glsl.js";import{IntegerDrawUniform as a}from"../../../core/shaderModules/IntegerDrawUniform.js";import{Texture2DUintDrawUniform as l}from"../../../core/shaderModules/Texture2DUintDrawUniform.js";import{olidEnabled as i}from"../../../effects/geometry/olidUtils.js";import{componentDataLayout as s,componentDataOlidLayout as c}from"../../../materials/DefaultLayouts.js";import{oitResolution as u}from"../../../shaders/oitResolution.glsl.js";function m(o,e){switch(e.componentDataType){case 1:return p(o,e);case 0:return M(o,e);case 2:return;default:e.componentDataType}}const f=new l("componentTextureBuffer",o=>o.textureBackedBuffer?.texture),v=new e({layout:s,itemIndexExpression:"componentIndex",bufferUniform:f}),x=new e({layout:c,itemIndexExpression:"componentIndex",bufferUniform:f});function C(){return i()?x:v}function p(e,r){const{vertex:t,fragment:a}=e,{output:l,hasEmission:i}=r,s=11===l,c=C().createBuilder(e,r);e.attributes.add("componentIndex","uint"),e.varyings.add("vExternalColorMixMode","mediump float"),e.varyings.add("vExternalColor","vec4"),s&&e.varyings.add("vObjectAndLayerIdColor","vec4"),i&&(e.varyings.add("emissiveStrength","float"),e.varyings.add("emissiveSource","int")),e.include(o),t.include(u,r),t.code.add(n`
2
+ import{DecodeSymbolColor as o}from"./DecodeSymbolColor.glsl.js";import{TextureBackedBufferModule as e}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{Float4DrawUniform as r}from"../../../core/shaderModules/Float4DrawUniform.js";import{FloatDrawUniform as t}from"../../../core/shaderModules/FloatDrawUniform.js";import{glsl as n,If as d}from"../../../core/shaderModules/glsl.js";import{IntegerDrawUniform as a}from"../../../core/shaderModules/IntegerDrawUniform.js";import{Texture2DUintDrawUniform as l}from"../../../core/shaderModules/Texture2DUintDrawUniform.js";import{olidEnabled as i}from"../../../effects/geometry/olidUtils.js";import{componentDataLayout as s,componentDataOlidLayout as c}from"../../../materials/DefaultLayouts.js";import{floatBlendScale as u}from"../../../shaders/floatBlendScale.glsl.js";function m(o,e){switch(e.componentDataType){case 1:return p(o,e);case 0:return M(o,e);case 2:return;default:e.componentDataType}}const f=new l("componentTextureBuffer",o=>o.textureBackedBuffer?.texture),v=new e({layout:s,itemIndexExpression:"componentIndex",bufferUniform:f}),x=new e({layout:c,itemIndexExpression:"componentIndex",bufferUniform:f});function C(){return i()?x:v}function p(e,r){const{vertex:t,fragment:a}=e,{output:l,hasEmission:i}=r,s=11===l,c=C().createBuilder(e,r);e.attributes.add("componentIndex","uint"),e.varyings.add("vExternalColorMixMode","mediump float"),e.varyings.add("vExternalColor","vec4"),s&&e.varyings.add("vObjectAndLayerIdColor","vec4"),i&&(e.varyings.add("emissiveStrength","float"),e.varyings.add("emissiveSource","int")),e.include(o),t.include(u,r),t.code.add(n`
3
3
  float readElevationOffset() {
4
4
  return ${c.getTextureAttribute("elevationOffset")};
5
5
  }
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- class t{constructor(t,o){this.position=t,this.rotationScale=o}}export{t as Transform};
2
+ import{transformMat3 as t,add as o}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";class i{constructor(t,o){this.position=t,this.rotationScale=o}applyVec3(i,r){return t(i,r,this.rotationScale),o(i,i,this.position),i}toMat4(t){const{position:o,rotationScale:i}=this;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=0,t[4]=i[3],t[5]=i[4],t[6]=i[5],t[7]=0,t[8]=i[6],t[9]=i[7],t[10]=i[8],t[11]=0,t[12]=o[0],t[13]=o[1],t[14]=o[2],t[15]=1,t}}export{i as Transform};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{addNearFar as o}from"../ForwardLinearDepthToWriteShadowMap.glsl.js";import{SliceDraw as r}from"../Slice.glsl.js";import{Transform as e}from"../Transform.glsl.js";import{NormalAttribute as t}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as s}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as l}from"../output/OutputDepth.glsl.js";import{OutputHighlight as d}from"../output/OutputHighlight.glsl.js";import{VisualVariables as n}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as c}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as u}from"../util/View.glsl.js";import{glsl as p,If as v}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as m}from"../../shaderModules/Texture2DPassUniform.js";function f(f,g){const{vertex:x,fragment:O,varyings:j}=f,{hasColorTexture:h,alphaDiscardMode:w}=g,V=h&&1!==w,{output:C,normalType:b,hasColorTextureTransform:A}=g;switch(C){case 3:u(x,g),f.include(e),O.include(r,g),f.include(a,g),V&&O.uniforms.add(new m("tex",o=>o.texture)),x.main.add(p`vpos = getVertexInLocalOriginSpace();
2
+ import{addNearFar as o}from"../ForwardLinearDepthToWriteShadowMap.glsl.js";import{SliceDraw as r}from"../Slice.glsl.js";import{Transform as e}from"../Transform.glsl.js";import{NormalAttribute as t}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as s}from"../attributes/VertexNormal.glsl.js";import{outputDepth as l}from"../output/OutputDepth.glsl.js";import{OutputHighlight as d}from"../output/OutputHighlight.glsl.js";import{VisualVariables as n}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as c}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as u}from"../util/View.glsl.js";import{glsl as p,If as v}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as m}from"../../shaderModules/Texture2DPassUniform.js";function f(f,g){const{vertex:x,fragment:O,varyings:j}=f,{hasColorTexture:h,alphaDiscardMode:w}=g,V=h&&1!==w,{output:C,normalType:b,hasColorTextureTransform:A}=g;switch(C){case 3:u(x,g),f.include(e),O.include(r,g),f.include(a,g),V&&O.uniforms.add(new m("tex",o=>o.texture)),x.main.add(p`vpos = getVertexInLocalOriginSpace();
3
3
  vpos = subtractOrigin(vpos);
4
4
  vpos = addVerticalOffset(vpos, localOrigin);
5
5
  gl_Position = transformPosition(proj, view, vpos);
@@ -1,9 +1,9 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{clamp as e}from"../../../../../../core/mathUtils.js";import{isColor as s}from"../ShaderOutput.js";import{VertexTextureCoordinates as i}from"../attributes/VertexTextureCoordinates.glsl.js";import{Gamma as o}from"../shading/Gamma.glsl.js";import{Float3DrawUniform as r}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as m}from"../../shaderModules/Float3PassUniform.js";import{FloatDrawUniform as t}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as n}from"../../shaderModules/FloatPassUniform.js";import{If as a,glsl as v}from"../../shaderModules/glsl.js";import{Texture2DDrawUniform as l}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as u}from"../../shaderModules/Texture2DPassUniform.js";import{floatBlendReductionFactor as f}from"../../../shaders/oitResolution.glsl.js";const c=1,d=1;function g(c,g){if(!s(g.output))return;c.fragment.include(o);const{emissionSource:x,hasEmissiveTextureTransform:p,bindType:h}=g,j=3===x||4===x||5===x;j&&(c.include(i,g),c.fragment.uniforms.add(1===h?new u("texEmission",e=>e.textureEmissive):new l("texEmission",e=>e.textureEmissive)));const T=2===x||j;T&&c.fragment.uniforms.add(1===h?new m("emissiveBaseColor",e=>e.emissiveBaseColor):new r("emissiveBaseColor",e=>e.emissiveBaseColor));const C=0!==x;if(C&&!(7===x||6===x||4===x||5===x)){const s=s=>e(s??0,0,f);c.fragment.uniforms.add(1===h?new n("emissiveStrength",e=>s(e.emissiveStrength)):new t("emissiveStrength",e=>s(e.emissiveStrength)))}const b=7===x,F=5===x,S=1===x||6===x||b;c.fragment.code.add(v`
2
+ import{clamp as e}from"../../../../../../core/mathUtils.js";import{isColor as s}from"../ShaderOutput.js";import{VertexTextureCoordinates as i}from"../attributes/VertexTextureCoordinates.glsl.js";import{Gamma as o}from"../shading/Gamma.glsl.js";import{Float3DrawUniform as r}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as m}from"../../shaderModules/Float3PassUniform.js";import{FloatDrawUniform as t}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as n}from"../../shaderModules/FloatPassUniform.js";import{If as a,glsl as l}from"../../shaderModules/glsl.js";import{Texture2DDrawUniform as v}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as u}from"../../shaderModules/Texture2DPassUniform.js";import{floatBlendReductionFactor as f}from"../../../shaders/floatBlendScale.glsl.js";const c=1,d=1;function g(c,g){if(!s(g.output))return;c.fragment.include(o);const{emissionSource:x,hasEmissiveTextureTransform:p,bindType:h}=g,j=3===x||4===x||5===x;j&&(c.include(i,g),c.fragment.uniforms.add(1===h?new u("texEmission",e=>e.textureEmissive):new v("texEmission",e=>e.textureEmissive)));const T=2===x||j;T&&c.fragment.uniforms.add(1===h?new m("emissiveBaseColor",e=>e.emissiveBaseColor):new r("emissiveBaseColor",e=>e.emissiveBaseColor));const C=0!==x;if(C&&!(7===x||6===x||4===x||5===x)){const s=s=>e(s??0,0,f);c.fragment.uniforms.add(1===h?new n("emissiveStrength",e=>s(e.emissiveStrength)):new t("emissiveStrength",e=>s(e.emissiveStrength)))}const S=7===x,b=5===x,F=1===x||6===x||S;c.fragment.code.add(l`
3
3
  vec4 getEmissions(vec3 symbolColor) {
4
- vec4 emissions = ${T?F?"emissiveSource == 0 ? vec4(emissiveBaseColor, 1.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(emissiveBaseColor, 1.0)":S?b?"emissiveSource == 0 ? vec4(0.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(linearizeGamma(symbolColor), 1.0)":"vec4(0.0)"};
5
- ${a(j,`${a(F,`if(emissiveSource == 0) {\n vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);\n }`,`vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);`)}\n emissions.a = emissions.rgb == vec3(0.0) ? 0.0: emissions.a;`)}
6
- ${a(C,`emissions.rgb *= emissiveStrength * ${v.float(d)};`)}
4
+ vec4 emissions = ${T?b?"emissiveSource == 0 ? vec4(emissiveBaseColor, 1.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(emissiveBaseColor, 1.0)":F?S?"emissiveSource == 0 ? vec4(0.0): vec4(linearizeGamma(symbolColor), 1.0)":"vec4(linearizeGamma(symbolColor), 1.0)":"vec4(0.0)"};
5
+ ${a(j,`${a(b,`if(emissiveSource == 0) {\n vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);\n }`,`vec4 emissiveFromTex = textureLookup(texEmission, ${p?"emissiveUV":"vuv0"});\n emissions *= vec4(linearizeGamma(emissiveFromTex.rgb), emissiveFromTex.a);`)}\n emissions.a = emissions.rgb == vec3(0.0) ? 0.0: emissions.a;`)}
6
+ ${a(C,`emissions.rgb *= emissiveStrength * ${l.float(d)};`)}
7
7
  return emissions;
8
8
  }
9
9
  `)}export{g as Emissions,d as emissiveStrengthBoost,c as emissiveStrengthDefault};
@@ -1,13 +1,7 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{glsl as t}from"../../shaderModules/glsl.js";function a(a,e){switch(e.output){case 5:case 6:case 7:case 8:a.fragment.code.add(t`float _calculateFragDepth(const in float depth) {
2
+ import{glsl as a}from"../../shaderModules/glsl.js";function e(e,t){switch(t.output){case 5:case 6:case 7:case 8:e.fragment.code.add(a`void outputDepth(float _linearDepth){
3
3
  const float slope_scale = 2.0;
4
4
  const float bias = 20.0 * .000015259;
5
- float m = max(abs(dFdx(depth)), abs(dFdy(depth)));
6
- return depth + slope_scale * m + bias;
7
- }
8
- void outputDepth(float _linearDepth){
9
- float fragDepth = _calculateFragDepth(_linearDepth);
10
- gl_FragDepth = fragDepth;
11
- }`);break;case 9:a.fragment.code.add(t`void outputDepth(float _linearDepth){
12
- gl_FragDepth = _linearDepth;
13
- }`)}}export{a as OutputDepth};
5
+ float m = max(abs(dFdx(_linearDepth)), abs(dFdy(_linearDepth)));
6
+ gl_FragDepth = _linearDepth + slope_scale * m + bias;
7
+ }`)}}export{e as outputDepth};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as s,sync as o}from"../../../../core/reactiveUtils.js";import{signal as r}from"../../../../core/signal.js";import{property as n,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{cloudPresets as c}from"./clouds/CloudsPresets.js";import{CloudsRenderer as u}from"./clouds/CloudsRenderer.js";import{Precipitation as p}from"./precipitation/Precipitation.js";let h=class extends e{constructor(t){super(t),this._clouds=r(null),this._incarnation=0,this._precipitation=null}initialize(){const t=()=>this._requestRender();this.addHandles([s(()=>this._precipitation,t,o),s(()=>this._clouds.value?.state,t,o),s(()=>this.view.state.mode,t,o),s(()=>this.view.state.stationary&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera),e=>{e&&t()},o),s(()=>this._updateClouds(),t,o),s(()=>this._updatePrecipitation(),t,o),s(()=>this.weather,t=>this._initWeather(t))])}destroy(){this.removeHandles(),this._clouds.value=i(this._clouds.value),this._precipitation=null,this._precipitationOutgoing=null}get readyToRun(){return!!this._clouds.value?.readyToRun||this.view.state.stationary&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera)}get usedMemory(){return this._clouds.value?.usedMemory??0}_fadeOutPrecipitation(){this._precipitation&&(this._precipitationOutgoing?.destroy(),this._precipitationOutgoing=this._precipitation,this._precipitationOutgoing.fadeOut(()=>this._precipitationOutgoing=i(this._precipitationOutgoing)),this._precipitation=null,++this._incarnation)}get snowCover(){return this._precipitationOutgoing?.snowCover??this._precipitation?.snowCover??0}get weather(){return this.view?.environmentManager?.weatherEnabled?this.view.environment.weather:null}cleanupCubemap(){const t=this._clouds.value;0!==t?.state||0!==t.coverage||t.readyToRun||t.destroyCubeMap()}_requestRender(){this.view.stage.renderView.requestRender()}_initWeather(t){t&&this.context?this._clouds.value||(this._clouds.value=new u({context:this.context,view:this.view,requestRender:()=>this._requestRender()})):this._clouds.value=i(this._clouds.value)}_updateClouds(){const t=this.view.environment.weather;return null==t||null==this._clouds.value||this._clouds.value.applyPreset(c[t.type],l(t)),++this._incarnation}_updatePrecipitation(){const t=this.view.environment.weather;if(t.type===this._precipitation?.type)return this._incarnation;this._fadeOutPrecipitation();return("rainy"===t.type||"snowy"===t.type)&&(this._precipitation=new p({view:this.view,type:t.type}),++this._incarnation),this._incarnation}get test(){}};function l(t){switch(t.type){case"rainy":case"snowy":case"cloudy":case"sunny":return t.cloudCover;case"foggy":return t.fogStrength}}t([n({constructOnly:!0})],h.prototype,"view",void 0),t([n({constructOnly:!0})],h.prototype,"context",void 0),h=t([a("esri.views.3d.webgl-engine.effects.WeatherFader")],h);export{h as WeatherFader};
2
+ import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{destroyMaybe as i}from"../../../../core/maybe.js";import{watch as s,sync as o}from"../../../../core/reactiveUtils.js";import{signal as r}from"../../../../core/signal.js";import{property as n,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{cloudPresets as c}from"./clouds/CloudsPresets.js";import{CloudsRenderer as u}from"./clouds/CloudsRenderer.js";import{Precipitation as h}from"./precipitation/Precipitation.js";let p=class extends e{constructor(t){super(t),this._clouds=r(null),this._incarnation=0,this._precipitation=null}initialize(){const t=()=>this._requestRender();this.addHandles([s(()=>this._precipitation,t,o),s(()=>this._clouds.value?.state,t,o),s(()=>this.view.state.mode,t,o),s(()=>this.view.state.stationary&&!!this.context.bind.clouds.data&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera),e=>{e&&t()},o),s(()=>this._updateClouds(),t,o),s(()=>this._updatePrecipitation(),t,o),s(()=>this.weather,t=>this._initWeather(t))])}destroy(){this.removeHandles(),this._clouds.value=i(this._clouds.value),this._precipitation=null,this._precipitationOutgoing=null}get readyToRun(){return!!this._clouds.value?.readyToRun||this.view.state.stationary&&!!this.context.bind.clouds.data&&this.context.bind.clouds.needsStationaryAnchorUpdate(this.view.state.camera)}get usedMemory(){return this._clouds.value?.usedMemory??0}_fadeOutPrecipitation(){this._precipitation&&(this._precipitationOutgoing?.destroy(),this._precipitationOutgoing=this._precipitation,this._precipitationOutgoing.fadeOut(()=>this._precipitationOutgoing=i(this._precipitationOutgoing)),this._precipitation=null,++this._incarnation)}get snowCover(){return this._precipitationOutgoing?.snowCover??this._precipitation?.snowCover??0}get weather(){return this.view?.environmentManager?.weatherEnabled?this.view.environment.weather:null}cleanupCubemap(){const t=this._clouds.value;0!==t?.state||0!==t.coverage||t.readyToRun||t.destroyCubeMap()}_requestRender(){this.view.stage.renderView.requestRender()}_initWeather(t){t&&this.context?this._clouds.value||(this._clouds.value=new u({context:this.context,view:this.view,requestRender:()=>this._requestRender()})):this._clouds.value=i(this._clouds.value)}_updateClouds(){const t=this.view.environment.weather;return null==t||null==this._clouds.value||this._clouds.value.applyPreset(c[t.type],d(t)),++this._incarnation}_updatePrecipitation(){const t=this.view.environment.weather;if(t.type===this._precipitation?.type)return this._incarnation;this._fadeOutPrecipitation();return("rainy"===t.type||"snowy"===t.type)&&(this._precipitation=new h({view:this.view,type:t.type}),++this._incarnation),this._incarnation}get test(){}};function d(t){switch(t.type){case"rainy":case"snowy":case"cloudy":case"sunny":return t.cloudCover;case"foggy":return t.fogStrength}}t([n({constructOnly:!0})],p.prototype,"view",void 0),t([n({constructOnly:!0})],p.prototype,"context",void 0),p=t([a("esri.views.3d.webgl-engine.effects.WeatherFader")],p);export{p as WeatherFader};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{property as t,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import s from"../../../webgl/RenderNode.js";import{If as a,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as u}from"../../lib/DefaultVertexBufferLayouts.js";import{floatBlendReductionFactor as l}from"../../shaders/oitResolution.glsl.js";import{checkWebGLError as h}from"../../../../webgl/checkWebGLError.js";import{ColorAttachment0 as p,SizedPixelFormat as d,DataType as f}from"../../../../webgl/enums.js";let m=class extends s{constructor(e){super(e),this.destroyedCB=null,this.consumes={required:[i.FINAL]},this.produces=i.FINAL,this.clearColor=n,this._focusedFBOType=7,this._programs=new Map}destroy(){this._programs.clear(),this.destroyedCB()}render(){const e=this.input;if(!this._focusedTexture)return e;const r=this.renderingContext,t=r.boundFramebuffer;r.bindFramebuffer(e.fbo),r.setClearColor(0,0,0,0),r.clear(16384);const o=this._focusedTexture.attachment,n=[g(o)],i=this._ensureProgram(r,!1,n);return r.useProgram(i),r.bindTexture(o,0),i.setUniform1i("colorTex0",0),i.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&i.setUniform2fv("nearFar",this.camera.nearFar),r.setDrawBuffers([p]),r.screen.draw(),r.bindFramebuffer(t),e}getDownscaledFBO(e,r,t,o,n,i){if(n?.startsWith(`${r}\n`)??!1){const r=1/2**e.level;t=e.width*r,o=e.height*r}else i=null;const s="linear depth"===r||r.includes("shadow"),a="overlay highlight"===r||"highlights"===r||"highlight mix"===r,c="highlight coverage"===r,u=e.colorTexture?.descriptor,l=u?.internalFormat,f=[],m=new Array,v=new Array;e.colorAttachments.forEach((r,t)=>{const o=e.getColorTexture(r);if(o){const e=g(o);f.push(e);const{descriptor:r}=o;"float"!==e||r.hasMipmap||r.isImmutable||(o.generateMipmap(),m[t]=!0)}if(t>0){const e=o?.descriptor.internalFormat;return void(e===d.RGBA8&&(o?.debugName?.indexOf("emissive")??-1)>=0?v.push(8):v.push(T(e)))}v.push(s?0:a?1:c?2:i??T(l))});const x=this.renderingContext,{depthStencilTexture:$}=e,b=this._ensureProgram(x,null!=$,f,e.level),C=this.fboCache.acquire(t,o,"fbo visualizer");x.useProgram(b);const R=x.boundFramebuffer;x.bindFramebuffer(C.fbo);const y=new Array;e.colorAttachments.forEach((r,t)=>{const o=`colorTex${t.toFixed()}`;x.bindTexture(e.getColorTexture(r),t),b.setUniform1i(o,t),t>0&&C.acquireColor(p+t,5,"fbo visualizer"),y.push(r)});const w=$?.descriptor.linearFilterDepth??!1;if($){const r=e.colorAttachments.length;$.setShadowFiltering(!1),x.bindTexture($,r),b.setUniform1i("depthTex",r);const t=p+r;t>p&&C.acquireColor(t,5,"fbo visualizer"),y.push(t)}x.gl.drawBuffers(y),h(x.gl);const B=x.getViewport();return x.setViewport(0,0,t,o),x.setClearColor(0,0,0,0),x.clear(16384),x.setBlendingEnabled(!0),x.setBlendFunction(1,771),b.setUniform1iv("inputTypes",v.length>0?v:[7]),b.setUniform2fv("nearFar",this.camera.nearFar),x.screen.draw(),h(x.gl),x.bindFramebuffer(R),x.setViewport(B.x,B.y,B.width,B.height),e.colorAttachments.forEach((t,o)=>{const i=e.getColorTexture(t);m[o]&&i?.clearMipmap(),n===F(r,e,t,!1)&&(this._focusedTexture?.release(),this._focusedTexture=C.getAttachment(t),this._focusedTexture?.retain(),this._focusedFBOType=9===v[o]?T(i?.descriptor.internalFormat):v[o])}),$&&$.setShadowFiltering(w),C}clearFocusedFBO(){this._focusedTexture=r(this._focusedTexture)}getPreviewContent(e,r,t,o){const n=this.renderingContext,i=o.includes("\ndepth"),s=this.fboCache.acquire(e,r,"fbo visualizer"),a=n.boundFramebuffer;n.bindFramebuffer(s?.fbo);const c=n.getViewport();n.setViewport(0,0,e,r),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(16384),n.setBlendingEnabled(!0),n.setBlendFunction(1,771);const u=t.attachment,l=this._ensureProgram(n,!1,[g(u)]);n.useProgram(l),n.bindTexture(u,0),l.setUniform1i("colorTex0",0),l.setUniform1iv("inputTypes",[i||u.descriptor.internalFormat!==d.RGBA16F?7:5]),n.screen.draw();const p=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,6408,f.UNSIGNED_BYTE,new Uint8Array(p.data.buffer)),h(n.gl),n.bindFramebuffer(a),n.setViewport(c.x,c.y,c.width,c.height),s?.release(),p}_ensureProgram(e,r,t,o=0){const n=x({hasDepthAttachment:r,colorSamplerTypes:t,level:o}),i=this._programs.get(n);if(i)return i;const s="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",h=e=>{let r="";for(let t=0;t<e.length;++t){const o=e[t];r+=`layout(location = ${c.int(t)}) out vec4 fragColor${c.int(t)};\n uniform ${v(o)} colorTex${c.int(t)};`}return r},p=e=>e.reduce((e,r,t)=>e+`{\n int inputType = inputTypes[${t}];\n if (inputType == ${3..toFixed()}) {\n fragColor${t} = vec4(vec3(readTexture(colorTex${t}, uv, ${o}).r), 1.0);\n } else if (inputType == ${4..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}).rg, 0.0, 1.0);\n } else if (inputType == ${(0).toFixed()}) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex${t}, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n fragColor${t} = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if (inputType == ${5..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}).rgb, 1.0);\n } else if (inputType == ${1..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o})) * 255.0;\n fragColor${t} = vec4(fragColor${t}.rgb / fragColor${t}.a, fragColor${t}.a);\n } else if(inputType == ${2..toFixed()}) {\n vec2 texDim = vec2(textureSize(colorTex${t}, 0));\n ivec2 iuv = ivec2(uv * texDim);\n uvec2 hh = uvec2(texelFetch(colorTex${t}, iuv, 0).rg);\n fragColor${t} = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else if(inputType == ${8..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}));\n fragColor${t}.rgb *= ${l.toFixed(1)};\n } else if (inputType == ${9..toFixed()}) {\n fragColor${t} = vec4(vec3(readTexture(colorTex${t}, uv, ${o}).a), 1.0);\n } else {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}));\n }\n }`,""),d=t.length,f=`#version 300 es\n precision highp float;\n precision highp usampler2D;\n\n in vec2 uv;\n ${h(t)}\n ${a(r,`layout(location = ${c.int(d)}) out vec4 fragDepth;\n uniform sampler2D depthTex;`)}\n\n uniform int inputTypes[${t.length||1}];\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaToFloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaToFloat(depth));\n }\n\n vec4 readTexture(sampler2D tex, vec2 uv, int lod) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(tex, lod)));\n return texelFetch(tex, iuv, lod);\n }\n\n ${"float"===t[0]?"float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }":"float linearDepthFromTexture(usampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(vec4(texelFetch(depthTex, iuv, 0)) * 255.0);\n }"}\n\n void main() {\n ${p(t)}\n ${a(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n }`,m=e.programCache.get(s,f,u);return this._programs.set(n,m),m}};function v(e){switch(e){case"float":return"sampler2D";case"uint":return"usampler2D";case"int":return"isampler2D"}}function g(e){if(!e)return"float";const{internalFormat:r}=e.descriptor;switch(r){case d.R8I:case d.R16I:case d.R32I:case d.RG8I:case d.RG16I:case d.RG32I:case d.RGB8I:case d.RGB16I:case d.RGB32I:case d.RGBA8I:case d.RGBA16I:case d.RGBA32I:return"int";case d.R8UI:case d.R16UI:case d.R32UI:case d.RG8UI:case d.RG16UI:case d.RG32UI:case d.RGB8UI:case d.RGB16UI:case d.RGB32UI:case d.RGBA8UI:case d.RGBA16UI:case d.RGBA32UI:return"uint";default:return"float"}}function x(e){const{hasDepthAttachment:r,colorSamplerTypes:t,level:o}=e;return`${r?"Depth":""}${t.reduceRight((e,r)=>e+`|C${r}`,"")} ${o}`}function T(e){switch(e){case d.R16F:case d.R32F:case d.R8:return 3;case d.RG8:return 4;case d.RGBA16F:return 5;case d.RG8UI:return 6;default:return 7}}function F(e,r,t,o){return o?`${e}\ndepth`:`${e}\n${$(r,t)}`}function $(e,r){return`${e.getColorTexture(r)?.debugName??"color"+(r-p)}`}e([t()],m.prototype,"destroyedCB",void 0),e([t()],m.prototype,"consumes",void 0),e([t()],m.prototype,"produces",void 0),e([t()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m);export{m as RenderNodeVisualizerNode,F as getAttachmentName};
2
+ import{__decorate as e}from"tslib";import{releaseMaybe as r}from"../../../../../core/maybe.js";import{property as t,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderNodeOutput as i}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{If as s,glsl as c}from"../../core/shaderModules/glsl.js";import{Pos2Locations as u}from"../../lib/DefaultVertexBufferLayouts.js";import{floatBlendReductionFactor as l}from"../../shaders/floatBlendScale.glsl.js";import{checkWebGLError as h}from"../../../../webgl/checkWebGLError.js";import{ColorAttachment0 as p,SizedPixelFormat as d,DataType as f}from"../../../../webgl/enums.js";let m=class extends a{constructor(e){super(e),this.destroyedCB=null,this.consumes={required:[i.FINAL]},this.produces=i.FINAL,this.clearColor=n,this._focusedFBOType=7,this._programs=new Map}destroy(){this._programs.clear(),this.destroyedCB()}render(){const e=this.input;if(!this._focusedTexture)return e;const r=this.renderingContext,t=r.boundFramebuffer;r.bindFramebuffer(e.fbo),r.setClearColor(0,0,0,0),r.clear(16384);const o=this._focusedTexture.attachment,n=[g(o)],i=this._ensureProgram(r,!1,n);return r.useProgram(i),r.bindTexture(o,0),i.setUniform1i("colorTex0",0),i.setUniform1i("inputType",this._focusedFBOType),3===this._focusedFBOType&&i.setUniform2fv("nearFar",this.camera.nearFar),r.setDrawBuffers([p]),r.screen.draw(),r.bindFramebuffer(t),e}getDownscaledFBO(e,r,t,o,n,i){if(n?.startsWith(`${r}\n`)??!1){const r=1/2**e.level;t=e.width*r,o=e.height*r}else i=null;const a="linear depth"===r||r.includes("shadow"),s="overlay highlight"===r||"highlights"===r||"highlight mix"===r,c="highlight coverage"===r,u=e.colorTexture?.descriptor,l=u?.internalFormat,f=[],m=new Array,v=new Array;e.colorAttachments.forEach((r,t)=>{const o=e.getColorTexture(r);if(o){const e=g(o);f.push(e);const{descriptor:r}=o;"float"!==e||r.hasMipmap||r.isImmutable||(o.generateMipmap(),m[t]=!0)}if(t>0){const e=o?.descriptor.internalFormat;return void(e===d.RGBA8&&(o?.debugName?.indexOf("emissive")??-1)>=0?v.push(8):v.push(T(e)))}v.push(a?0:s?1:c?2:i??T(l))});const x=this.renderingContext,{depthStencilTexture:$}=e,b=this._ensureProgram(x,null!=$,f,e.level),C=this.fboCache.acquire(t,o,"fbo visualizer");x.useProgram(b);const R=x.boundFramebuffer;x.bindFramebuffer(C.fbo);const y=new Array;e.colorAttachments.forEach((r,t)=>{const o=`colorTex${t.toFixed()}`;x.bindTexture(e.getColorTexture(r),t),b.setUniform1i(o,t),t>0&&C.acquireColor(p+t,5,"fbo visualizer"),y.push(r)});const w=$?.descriptor.linearFilterDepth??!1;if($){const r=e.colorAttachments.length;$.setShadowFiltering(!1),x.bindTexture($,r),b.setUniform1i("depthTex",r);const t=p+r;t>p&&C.acquireColor(t,5,"fbo visualizer"),y.push(t)}x.gl.drawBuffers(y),h(x.gl);const B=x.getViewport();return x.setViewport(0,0,t,o),x.setClearColor(0,0,0,0),x.clear(16384),x.setBlendingEnabled(!0),x.setBlendFunction(1,771),b.setUniform1iv("inputTypes",v.length>0?v:[7]),b.setUniform2fv("nearFar",this.camera.nearFar),x.screen.draw(),h(x.gl),x.bindFramebuffer(R),x.setViewport(B.x,B.y,B.width,B.height),e.colorAttachments.forEach((t,o)=>{const i=e.getColorTexture(t);m[o]&&i?.clearMipmap(),n===F(r,e,t,!1)&&(this._focusedTexture?.release(),this._focusedTexture=C.getAttachment(t),this._focusedTexture?.retain(),this._focusedFBOType=9===v[o]?T(i?.descriptor.internalFormat):v[o])}),$&&$.setShadowFiltering(w),C}clearFocusedFBO(){this._focusedTexture=r(this._focusedTexture)}getPreviewContent(e,r,t,o){const n=this.renderingContext,i=o.includes("\ndepth"),a=this.fboCache.acquire(e,r,"fbo visualizer"),s=n.boundFramebuffer;n.bindFramebuffer(a?.fbo);const c=n.getViewport();n.setViewport(0,0,e,r),n.setClearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]),n.clear(16384),n.setBlendingEnabled(!0),n.setBlendFunction(1,771);const u=t.attachment,l=this._ensureProgram(n,!1,[g(u)]);n.useProgram(l),n.bindTexture(u,0),l.setUniform1i("colorTex0",0),l.setUniform1iv("inputTypes",[i||u.descriptor.internalFormat!==d.RGBA16F?7:5]),n.screen.draw();const p=new ImageData(new Uint8ClampedArray(e*r*4),e,r);return n.gl.readPixels(0,0,e,r,6408,f.UNSIGNED_BYTE,new Uint8Array(p.data.buffer)),h(n.gl),n.bindFramebuffer(s),n.setViewport(c.x,c.y,c.width,c.height),a?.release(),p}_ensureProgram(e,r,t,o=0){const n=x({hasDepthAttachment:r,colorSamplerTypes:t,level:o}),i=this._programs.get(n);if(i)return i;const a="#version 300 es\n in vec2 position;\n out vec2 uv;\n\n void main() {\n gl_Position = vec4(position, 0.0, 1.0);\n uv = position * 0.5 + vec2(0.5);\n }",h=e=>{let r="";for(let t=0;t<e.length;++t){const o=e[t];r+=`layout(location = ${c.int(t)}) out vec4 fragColor${c.int(t)};\n uniform ${v(o)} colorTex${c.int(t)};`}return r},p=e=>e.reduce((e,r,t)=>e+`{\n int inputType = inputTypes[${t}];\n if (inputType == ${3..toFixed()}) {\n fragColor${t} = vec4(vec3(readTexture(colorTex${t}, uv, ${o}).r), 1.0);\n } else if (inputType == ${4..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}).rg, 0.0, 1.0);\n } else if (inputType == ${(0).toFixed()}) {\n float depth = 1.0 - ((-linearDepthFromTexture(colorTex${t}, uv) - nearFar[0]) / (nearFar[1] - nearFar[0]));\n fragColor${t} = vec4(vec3(depth), depth >= 0.999 ? 0.0 : 1.0);\n } else if (inputType == ${5..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}).rgb, 1.0);\n } else if (inputType == ${1..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o})) * 255.0;\n fragColor${t} = vec4(fragColor${t}.rgb / fragColor${t}.a, fragColor${t}.a);\n } else if(inputType == ${2..toFixed()}) {\n vec2 texDim = vec2(textureSize(colorTex${t}, 0));\n ivec2 iuv = ivec2(uv * texDim);\n uvec2 hh = uvec2(texelFetch(colorTex${t}, iuv, 0).rg);\n fragColor${t} = vec4(\n ((hh & uvec2(0x55u)) != uvec2(0u)) ? 1.0 : 0.0,\n ((hh & uvec2(0xaau)) != uvec2(0u)) ? 1.0 : 0.0,\n 0.0,\n 1.0);\n } else if(inputType == ${8..toFixed()}) {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}));\n fragColor${t}.rgb *= ${l.toFixed(1)};\n } else if (inputType == ${9..toFixed()}) {\n fragColor${t} = vec4(vec3(readTexture(colorTex${t}, uv, ${o}).a), 1.0);\n } else {\n fragColor${t} = vec4(readTexture(colorTex${t}, uv, ${o}));\n }\n }`,""),d=t.length,f=`#version 300 es\n precision highp float;\n precision highp usampler2D;\n\n in vec2 uv;\n ${h(t)}\n ${s(r,`layout(location = ${c.int(d)}) out vec4 fragDepth;\n uniform sampler2D depthTex;`)}\n\n uniform int inputTypes[${t.length||1}];\n uniform vec2 nearFar;\n\n // Factors to convert rgba back to float\n const vec4 RGBA_2_FLOAT_FACTORS = vec4(\n 255.0 / (256.0),\n 255.0 / (256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0),\n 255.0 / (256.0 * 256.0 * 256.0 * 256.0)\n );\n\n\n float rgbaToFloat(vec4 rgba) {\n // Convert components from 0->1 back to 0->255 and then add the components together with their corresponding\n // fixed point factors, i.e. (256^1, 256^2, 256^3, 256^4)\n return dot(rgba, RGBA_2_FLOAT_FACTORS);\n }\n\n float linearDepthFromFloat(float depth) {\n depth = pow(depth, 0.2);\n return -(depth * (nearFar[1] - nearFar[0]) + nearFar[0]);\n }\n\n float linearDepthFromRGBA(vec4 depth) {\n return linearDepthFromFloat(rgbaToFloat(depth));\n }\n\n vec4 readTexture(sampler2D tex, vec2 uv, int lod) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(tex, lod)));\n return texelFetch(tex, iuv, lod);\n }\n\n ${"float"===t[0]?"float linearDepthFromTexture(sampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(texelFetch(depthTex, iuv, 0));\n }":"float linearDepthFromTexture(usampler2D depthTex, vec2 uv) {\n ivec2 iuv = ivec2(uv * vec2(textureSize(depthTex, 0)));\n return linearDepthFromRGBA(vec4(texelFetch(depthTex, iuv, 0)) * 255.0);\n }"}\n\n void main() {\n ${p(t)}\n ${s(r,"float depth = 1.0 - pow(texture(depthTex, uv).r, 10.0);\n fragDepth = vec4(vec3(depth), depth < 0.000001 ? 0.0 : 1.0);")}\n }`,m=e.programCache.get(a,f,u);return this._programs.set(n,m),m}};function v(e){switch(e){case"float":return"sampler2D";case"uint":return"usampler2D";case"int":return"isampler2D"}}function g(e){if(!e)return"float";const{internalFormat:r}=e.descriptor;switch(r){case d.R8I:case d.R16I:case d.R32I:case d.RG8I:case d.RG16I:case d.RG32I:case d.RGB8I:case d.RGB16I:case d.RGB32I:case d.RGBA8I:case d.RGBA16I:case d.RGBA32I:return"int";case d.R8UI:case d.R16UI:case d.R32UI:case d.RG8UI:case d.RG16UI:case d.RG32UI:case d.RGB8UI:case d.RGB16UI:case d.RGB32UI:case d.RGBA8UI:case d.RGBA16UI:case d.RGBA32UI:return"uint";default:return"float"}}function x(e){const{hasDepthAttachment:r,colorSamplerTypes:t,level:o}=e;return`${r?"Depth":""}${t.reduceRight((e,r)=>e+`|C${r}`,"")} ${o}`}function T(e){switch(e){case d.R16F:case d.R32F:case d.R8:return 3;case d.RG8:return 4;case d.RGBA16F:return 5;case d.RG8UI:return 6;default:return 7}}function F(e,r,t,o){return o?`${e}\ndepth`:`${e}\n${$(r,t)}`}function $(e,r){return`${e.getColorTexture(r)?.debugName??"color"+(r-p)}`}e([t()],m.prototype,"destroyedCB",void 0),e([t()],m.prototype,"consumes",void 0),e([t()],m.prototype,"produces",void 0),e([t()],m.prototype,"clearColor",void 0),m=e([o("esri.views.3d.webgl-engine.effects.debug.RenderNodeVisualizerNode")],m);export{m as RenderNodeVisualizerNode,F as getAttachmentName};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/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/DistanceFalloff.glsl.js";import"../../shaders/oitResolution.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";
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/DistanceFalloff.glsl.js";import"../../shaders/floatBlendScale.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";
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as s}from"tslib";import{parameter as o}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{OITResolutionConfiguration as e}from"../../shaders/oitResolution.glsl.js";class i extends e{constructor(){super(...arguments),this.hasEmissive=!1}}s([o()],i.prototype,"hasEmissive",void 0);export{i as FogTechniqueConfiguration};
2
+ import{__decorate as s}from"tslib";import{parameter as e}from"../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{FloatBlendScaleConfiguration as o}from"../../shaders/floatBlendScale.glsl.js";class r extends o{constructor(){super(...arguments),this.hasEmissive=!1}}s([e()],r.prototype,"hasEmissive",void 0);export{r as FogTechniqueConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/output/ReadDepthLastFrame.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js";import"../../core/shaderLibrary/util/CameraSpace.glsl.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Matrix4BindUniform.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"./GlobalIlluminationColorQuantization.glsl.js";import"../../../../webgl/enums.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{G as GlobalIlluminationPassParameters,c as build,e as defaultColorBleedWeight,d as defaultRayMarchMaxReach,f as defaultRayMarchMaxReachEmissionWeight,b as defaultRayMarchMaxSteps,g as defaultRayMarchMinReach,h as defaultRayMarchMinReachEmissionWeight,i as defaultRayMarchWorldReach}from"../../../../../chunks/GlobalIllumination.glsl.js";
2
+ import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/output/ReadDepthLastFrame.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js";import"../../core/shaderLibrary/util/CameraSpace.glsl.js";import"../../core/shaderModules/FloatPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/Matrix4BindUniform.js";import"../../core/shaderModules/Texture2DBindUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"./GlobalIlluminationColorQuantization.glsl.js";import"../../shaders/floatBlendScale.glsl.js";import"../../../../webgl/enums.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{G as GlobalIlluminationPassParameters,c as build,e as defaultColorBleedWeight,d as defaultRayMarchMaxReach,f as defaultRayMarchMaxReachEmissionWeight,b as defaultRayMarchMaxSteps,g as defaultRayMarchMinReach,h as defaultRayMarchMinReachEmissionWeight,i as defaultRayMarchWorldReach}from"../../../../../chunks/GlobalIllumination.glsl.js";