@arcgis/core 6.0.0-next.55 → 6.0.0-next.56

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 (205) hide show
  1. package/arcgisGlobal.d.ts +1 -0
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/033b9fcd9833db3b6e7d.js +1 -0
  4. package/assets/esri/core/workers/chunks/0978e12dd6a1cbc50b80.js +1 -0
  5. package/assets/esri/core/workers/chunks/{e956845255bce0910944.js → 1507297550c3cd1268e2.js} +1 -1
  6. package/assets/esri/core/workers/chunks/1c0f5c42331fb6fc26cb.js +1 -0
  7. package/assets/esri/core/workers/chunks/2cd2fcf4a37d180d5d5c.js +1 -0
  8. package/assets/esri/core/workers/chunks/2f9adf0b809ce8797ebf.js +1 -0
  9. package/assets/esri/core/workers/chunks/3982409149571a827390.js +1 -0
  10. package/assets/esri/core/workers/chunks/3d851710f7fcc27c5b60.js +2 -0
  11. package/assets/esri/core/workers/chunks/3e8d70039800f2395d66.js +1 -0
  12. package/assets/esri/core/workers/chunks/4d8539674fc2e4fea03c.js +1 -0
  13. package/assets/esri/core/workers/chunks/{e61082f56c08abe54b3a.js → 5954f02c3901b28d8e73.js} +1 -1
  14. package/assets/esri/core/workers/chunks/5ba6007c3c49a8153256.js +1 -0
  15. package/assets/esri/core/workers/chunks/5bdd95eeb8f34dbf26f2.js +2 -0
  16. package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js → 5e47026c681238038955.js} +2 -2
  17. package/assets/esri/core/workers/chunks/{2baf35b1b19482d603b5.js → 5f7505ada0991cfbdd84.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{976303f47c342b9d1cc0.js → 62ddd3a82864e26f009a.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{542a9c414c99d84d52ab.js → 6a202ef9ba9b89e09153.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{0826feebdca8a31eb630.js → 6ba6fece5c11fe2a6ace.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{5eb69e2895e5aec81051.js → 6fd10891506925560443.js} +1 -1
  22. package/assets/esri/core/workers/chunks/7b6fd287e7043ad50f4e.js +1 -0
  23. package/assets/esri/core/workers/chunks/7baa49055bc31618b56e.js +1 -0
  24. package/assets/esri/core/workers/chunks/8570e3df90fb76a8741a.js +1 -0
  25. package/assets/esri/core/workers/chunks/{c3c0f24a9e0047232ae1.js → 8679dfc0c53355b6feb0.js} +1 -1
  26. package/assets/esri/core/workers/chunks/8a636dc51372e14c98f5.js +1 -0
  27. package/assets/esri/core/workers/chunks/{14259910f44c08fd5bbd.js → 9117c9b720c9ba6e7a6e.js} +1 -1
  28. package/assets/esri/core/workers/chunks/a22458e5272332d86cb9.js +1 -0
  29. package/assets/esri/core/workers/chunks/{3ea480cebf8ee56228a5.js → a7dfca326883384d2751.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{723d8316f5d4b6ce2942.js → a9539393e2f1812a973a.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{be0b8bb4f09aae6ff5de.js → ab784764ddf9d7f693a1.js} +1 -1
  32. package/assets/esri/core/workers/chunks/b38b6fe08a367e9de4f5.js +1 -0
  33. package/assets/esri/core/workers/chunks/{4e651869e9a196494694.js → b6e628b5d2643af4c19b.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{b37ab6b1cb4cfc85cd9d.js → b7828d7e2c5b75644057.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{ec465abb0344ad719e9d.js → bd8e329ec74d921d311a.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{56e6e70aa40e51827290.js → c3f94024c6c9eed9f273.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{6d17b45022dfd2548098.js → c5ddf8b347c31fe772a3.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{ee9af58ae202b803bba7.js → c7a0c4ca37ebd1d98cf1.js} +1 -1
  39. package/assets/esri/core/workers/chunks/d7763c42754152510e13.js +2 -0
  40. package/assets/esri/core/workers/chunks/{9e508f930086d2ef5f22.js → dfa1b0308e5e82d1ddfe.js} +40 -41
  41. package/assets/esri/core/workers/chunks/e566102c7ed7a8ebf89e.js +1 -0
  42. package/assets/esri/core/workers/chunks/e74586b074d0fa6abb4b.js +1 -0
  43. package/assets/esri/core/workers/chunks/e7dff025780726d5feae.js +1 -0
  44. package/assets/esri/core/workers/chunks/e96fa029acba59c04e4e.js +2 -0
  45. package/assets/esri/core/workers/chunks/{4401b3f8ebb658abe789.js → efd6ea0966f60ab19520.js} +1 -1
  46. package/assets/esri/core/workers/chunks/fdfbd201be372d3796bf.js +2 -0
  47. package/assets/esri/core/workers/chunks/ff0a0819bba5e8264c47.js +1 -0
  48. package/chunks/BlendLayers.glsl.js +1 -1
  49. package/chunks/ColorMaterial.glsl.js +14 -14
  50. package/chunks/Component.glsl.js +37 -37
  51. package/chunks/DefaultMaterial.glsl.js +15 -15
  52. package/chunks/HUDMaterial.glsl.js +3 -3
  53. package/chunks/Path.glsl.js +15 -15
  54. package/chunks/Pattern.glsl.js +20 -20
  55. package/chunks/RasterColorizer.glsl.js +1 -1
  56. package/chunks/ShadowHighlight.glsl.js +1 -1
  57. package/chunks/Terrain.glsl.js +24 -24
  58. package/chunks/Water.glsl.js +29 -20
  59. package/chunks/pdf.js +57 -0
  60. package/config.js +1 -1
  61. package/core/accessorSupport/write.js +1 -1
  62. package/core/scheduling.js +1 -1
  63. package/kernel.js +1 -1
  64. package/layers/VoxelWasmPerSceneView.js +1 -1
  65. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  66. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -56
  67. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  68. package/layers/geospatialPDF/parserUtils.js +2 -0
  69. package/layers/support/ControlPoint.js +1 -1
  70. package/layers/support/ControlPointsGeoreference.js +1 -1
  71. package/layers/support/commonProperties.js +1 -1
  72. package/layers/support/geospatialPDFUtils.d.ts +63 -0
  73. package/layers/support/geospatialPDFUtils.js +2 -0
  74. package/package.json +5 -5
  75. package/symbols/CIMSymbol.d.ts +9 -9
  76. package/symbols/PathSymbol3DLayer.d.ts +1 -1
  77. package/symbols/WaterSymbol3DLayer.d.ts +13 -1
  78. package/symbols/WaterSymbol3DLayer.js +1 -1
  79. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  80. package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
  81. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  82. package/views/3d/camera/intersectionUtils.js +1 -1
  83. package/views/3d/environment/EnvironmentView.js +1 -1
  84. package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
  85. package/views/3d/interactive/Manipulator3D.js +1 -1
  86. package/views/3d/interactive/Manipulator3DBase.js +1 -1
  87. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  88. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  89. package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
  90. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  91. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  92. package/views/3d/layers/DrapedSubView3D.js +1 -1
  93. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  94. package/views/3d/layers/FeatureLikeLayerViewBase3D.js +1 -1
  95. package/views/3d/layers/FlowSubView3D.js +1 -1
  96. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  97. package/views/3d/layers/I3SMeshView3D.js +1 -1
  98. package/views/3d/layers/RouteLayerView3D.js +1 -1
  99. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  100. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  101. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  102. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  103. package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
  104. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  105. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  108. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  109. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  110. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  111. package/views/3d/layers/support/createTileBVHForLayer.js +1 -1
  112. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  113. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  114. package/views/3d/state/controllers/RotateController.js +1 -1
  115. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  116. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  117. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  118. package/views/3d/state/utils/navigationUtils.js +1 -1
  119. package/views/3d/support/QualityProfile.js +1 -1
  120. package/views/3d/support/QualitySettings.js +1 -1
  121. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  122. package/views/3d/terrain/BlendLayersTechniqueConfiguration.js +1 -1
  123. package/views/3d/terrain/OverlayManager.js +1 -1
  124. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  125. package/views/3d/terrain/RasterColorizerTechniqueConfiguration.js +1 -1
  126. package/views/3d/terrain/TerrainSurface.js +1 -1
  127. package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
  128. package/views/3d/webgl-engine/core/shaderLibrary/clampShadowPosition.glsl.js +2 -0
  129. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +14 -14
  130. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
  131. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -3
  132. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  133. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  134. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  135. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  136. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  137. package/views/3d/webgl-engine/lib/Program.js +1 -1
  138. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  139. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  140. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  141. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  142. package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
  143. package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
  144. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  145. package/views/3d/webgl-engine/parts/Model.js +1 -1
  146. package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
  147. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  148. package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
  149. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  150. package/views/Attribution.js +5 -5
  151. package/views/DOMContainer.d.ts +2 -1
  152. package/views/SceneView.js +1 -1
  153. package/views/draw/DrawGraphicTool.js +1 -1
  154. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  155. package/views/webgl/Program.js +3 -3
  156. package/views/webgl/ShaderBuilder.js +23 -23
  157. package/webscene/Slide.js +1 -1
  158. package/webscene/VirtualLighting.d.ts +2 -4
  159. package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +17 -1
  160. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  161. package/widgets/BatchAttributeForm/inputs/support/inputUtils.d.ts +7 -0
  162. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  163. package/widgets/BatchAttributeForm.js +1 -1
  164. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  165. package/widgets/Sketch/SketchViewModel.js +1 -1
  166. package/widgets/Weather/WeatherViewModel.js +1 -1
  167. package/widgets/support/ContingentValuesManager.js +1 -1
  168. package/widgets/support/forms/types.d.ts +23 -1
  169. package/assets/esri/core/workers/chunks/144f18a3dd2c8cf07cf7.js +0 -1
  170. package/assets/esri/core/workers/chunks/23fc1c1ed483ed3b2298.js +0 -1
  171. package/assets/esri/core/workers/chunks/249a687ce1b6d0815242.js +0 -1
  172. package/assets/esri/core/workers/chunks/2634927d26cb1139c6d0.js +0 -1
  173. package/assets/esri/core/workers/chunks/2d1b8154ee40afc9d40b.js +0 -1
  174. package/assets/esri/core/workers/chunks/4a41bf3d1e2e9bb79771.js +0 -2
  175. package/assets/esri/core/workers/chunks/5f324d88785ffcb73ae0.js +0 -1
  176. package/assets/esri/core/workers/chunks/70695e0fb53018d48e7b.js +0 -2
  177. package/assets/esri/core/workers/chunks/723c9ad4c25be2b82476.js +0 -1
  178. package/assets/esri/core/workers/chunks/766a1357be2ed7f4e125.js +0 -1
  179. package/assets/esri/core/workers/chunks/844c593754b2692257f4.js +0 -1
  180. package/assets/esri/core/workers/chunks/846248697c398468d8e6.js +0 -1
  181. package/assets/esri/core/workers/chunks/89e55895683369b5277a.js +0 -1
  182. package/assets/esri/core/workers/chunks/8c94e987754b3919181e.js +0 -1
  183. package/assets/esri/core/workers/chunks/919115788da38049aea7.js +0 -2
  184. package/assets/esri/core/workers/chunks/a116dd204921e7464944.js +0 -1
  185. package/assets/esri/core/workers/chunks/b33e7e74cf8fa3926617.js +0 -1
  186. package/assets/esri/core/workers/chunks/bb2af16e55cb39163827.js +0 -1
  187. package/assets/esri/core/workers/chunks/d5bb9f9b7b341c671525.js +0 -1
  188. package/assets/esri/core/workers/chunks/d96e63d66f7b1f4ea54a.js +0 -2
  189. package/assets/esri/core/workers/chunks/e3bcd2e356f75afc316a.js +0 -1
  190. package/assets/esri/core/workers/chunks/e80526571f1a34de3278.js +0 -1
  191. package/assets/esri/core/workers/chunks/ea71850ba87ae6038000.js +0 -1
  192. package/assets/esri/core/workers/chunks/f537a5e808dc546813c7.js +0 -1
  193. package/assets/esri/core/workers/chunks/fe811d651d201f698b8f.js +0 -2
  194. package/chunks/NativeLine.glsl.js +0 -8
  195. package/layers/geospatialPDF/geospatialPDFParserUtils.js +0 -2
  196. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +0 -2
  197. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +0 -2
  198. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +0 -2
  199. package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +0 -2
  200. /package/assets/esri/core/workers/chunks/{919115788da38049aea7.js.LICENSE.txt → 3d851710f7fcc27c5b60.js.LICENSE.txt} +0 -0
  201. /package/assets/esri/core/workers/chunks/{fe811d651d201f698b8f.js.LICENSE.txt → 5bdd95eeb8f34dbf26f2.js.LICENSE.txt} +0 -0
  202. /package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js.LICENSE.txt → 5e47026c681238038955.js.LICENSE.txt} +0 -0
  203. /package/assets/esri/core/workers/chunks/{4a41bf3d1e2e9bb79771.js.LICENSE.txt → d7763c42754152510e13.js.LICENSE.txt} +0 -0
  204. /package/assets/esri/core/workers/chunks/{d96e63d66f7b1f4ea54a.js.LICENSE.txt → e96fa029acba59c04e4e.js.LICENSE.txt} +0 -0
  205. /package/assets/esri/core/workers/chunks/{70695e0fb53018d48e7b.js.LICENSE.txt → fdfbd201be372d3796bf.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ZEROS as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as d,copy as f,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{set as m,transformMat4 as h,scale as g}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{lerp as v}from"../../../../core/mathUtils.js";import{destroyMaybe as y}from"../../../../core/maybe.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x}from"../../../../geometry/ellipsoidUtils.js";import{create as S,empty as C,copy as w,offset as T,width as E,height as D,expand as ee}from"../../../../geometry/support/aaBoundingRect.js";import{extrusionContainsPoint as te,create as ne,copy as re}from"../../../../geometry/support/boundedPlane.js";import{create as O}from"../../../../geometry/support/ray.js";import{Sphere as k}from"../../../../geometry/support/sphere.js";import{Yield as A}from"../../../support/Yield.js";import{InternalRenderCategory as j}from"../../webgl.js";import{getVec3AttributeView as M,getScalarAttributeView as N}from"../../webgl-engine/lib/attributeViewUtils.js";import{GPUPointOcclusionQuery as P}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as F}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";import L from"../../webgl/RenderCamera.js";import{DeconflictAABR as R}from"./DeconflictAABR.js";import{prepare as z,drawPoly as B}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as V}from"./transparencyUtils.js";const H=a(),U=a(),ie=a(),W=a(),G=_(),K=_(),q=a(),J=s(),Y=new k,X=O(),ae=a(),oe=S();class se{constructor(e){this.id=e,this.aabr=S(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ce(e,t){let n=e.distanceToOccluder!==0&&e.distance>e.distanceToOccluder,r=t.distanceToOccluder!==0&&t.distance>t.distanceToOccluder;return n===r?e.priority===t.priority?e.distance===t.distance?e.visible===t.visible?e.id-t.id:+t.visible-e.visible:e.distance-t.distance:t.priority-e.priority:+n-r}class Z{constructor(e,t){this.graphics3DGraphic=e,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(e){let t=this.getInfo(e);return t||(t=new se(this.graphics3DGraphic.graphic.uid),this._setInfo(e,t)),t}getInfo(e){return e===16?this._labelInfo:this._info}removeInfo(e){this._setInfo(e,null)}_setInfo(e,t){e===16?this._labelInfo=t:this._info=t}}class Q{constructor(){this.camera=new L,this.slicePlane=ne(),this.slicePlaneEnabled=!1}copyFrom(e){this.camera.equals(e.camera)||this.camera.copyFrom(e.camera),re(e.slicePlane,this.slicePlane),this.slicePlaneEnabled=e.slicePlaneEnabled}}let $=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(e){super(e),this._dirty=!1,this._viewState=new Q,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=[],this._updatingHandles=new b,this._deconflictor=new R((e,t)=>{e.visible=t,this._setGraphicVisibility(this._active.get(e.id),t)},(e,t)=>e.id!==t.id,ce),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange(`_readyToRun`))}setPriority(e,t){let n=this._active.get(e.graphic.uid)?.getInfo(this.visibilityGroup);n&&(n.priority=t)}get _readyToRun(){return this._state!==0||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;let e=this._state/5;return this._dirty?e*.5:e}get readyToRun(){return this.view.ready&&this.view.state!=null&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+(this._occlusionQueryUids?.length??0)*4}runTask(e){switch(this._state){case 0:this._startUpdate(),e.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(e))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??!0)||!(this._opaqueOcclusionQuery?.done??!0))return A;this._readOcclusionQueryResult(),e.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(e))return;case 4:if(this._state=4,this._deconflictor.run(e),!this._deconflictor.done)return;default:this._state=0,this.notifyChange(`_readyToRun`)}}setGraphicsActive(e,t){t?e.forEach(e=>this.addToActiveGraphics(e)):e.forEach(e=>this.removeFromActiveGraphics(e))}isSupportedLayer(e){if(e==null||e.type!==`buffer`||!e.hiddenIfDeconflicted)return!1;let t=e.stageObject;return(t?.geometries.length??0)===1&&t?.geometries[0]?.material instanceof I}_startUpdate(){z(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);let{fullWidth:e,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(e,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery))}addToActiveGraphics(e){e.ensureInfo(this.visibilityGroup),this._active.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromActiveGraphics(e){this._active.get(e.graphics3DGraphic.graphic.uid)===e&&(le(e,this.visibilityGroup),e.removeInfo(this.visibilityGroup),this._active.delete(e.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(e){this._checkOcclusion.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromCheckOcclusion(e){this._checkOcclusion.get(e.graphics3DGraphic.graphic.uid)===e&&this._checkOcclusion.delete(e.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(e){if(this._checkOcclusion.size===0)return!0;let t=this._ensureCheckOcclusionIterator(),n=this._viewState.camera,r=o(J,n.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,s=this.view.viewingMode===`global`&&a&&n.relativeElevation>0?Y:null,c=0;s!=null&&(l(s.center,i,n.viewMatrix),s.radius=x(this.view.spatialReference).radius,c=s.distanceToSilhouette(i));let u=S();for(;;){if(e.done)return!1;e.madeProgress();let i=t.next();if(i.done===!0)break;let a=i.value,o=a.graphics3DGraphic;if(o.destroyed||!o.isVisible(1,8))continue;let d=pe(o,this.visibilityGroup),f=null,p=!0,m=!1;for(let e of d){if(!this.isSupportedLayer(e))continue;if(f=me,!this._projectHudLayer(e,n,f)||this._isCulledBySlice(a,f.positionWorld)||s!=null&&fe(f,s,c)){p=!1;break}C(u);let t=e.stageObject.geometries[0].material;this._expandBoundingRect(u,n,e,t,f),f.altitude=this.view.renderCoordsHelper.getAltitude(f.positionWorld);let i=a.ensureInfo(this.visibilityGroup);if(i.altitude=f.altitude,i.distance=f.distance,i.distanceToOccluder=f.distanceToOccluder,i.culled=!1,w(i.aabr,u),!e.occlusionCheck)break;l(U,f.positionView,r);let d=this._ensureOcclusionQuery(),h=this._ensureOpaqueOcclusionQuery();this._occlusionQueryUids.length===0&&(this._initOcclusionQuery(d),this._initOcclusionQuery(h));let g=d.addPosition(U),_=h.addPosition(U);if(g===this._occlusionQueryUids.length&&_===g){let t=e.adaptiveOcclusion;this._occlusionQueryUids.push(t?-o.graphic.uid:o.graphic.uid),m=!0}break}let h=this._active.has(o.graphic.uid);if(!h&&!m)this._setGraphicVisibility(a,p);else if(h&&(!p||!f)){let e=a.ensureInfo(this.visibilityGroup);e.visible=!f,e.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;let e=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(e.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){let n=this._occlusionQueryUids[e],r=Math.abs(n),i=n<0,a=this._checkOcclusion.get(r);if(!a)continue;let o=this._occlusionQuery.getOcclusion(e)??-1,s=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,c=a.getInfo(this.visibilityGroup);c&&(c.distanceToOccluder=o>0?c.distance-o:0);let l=s===0||s>0&&this._occludedVisibility(c?c.distance-s:0,c?.distance??s,c?.altitude??0,t,i),u=o===0||o>0&&this._occludedVisibility(c?.distanceToOccluder??0,c?.distance??o,c?.altitude??0,t,i),d=l||u;d&&this._setTransparentMode(a,l&&!u),this._active.has(r)?c&&(c.culled=!d,c.visible=d):this._setGraphicVisibility(a,d)}this._occlusionQueryUids.length=0}_collectActiveGraphics(e){let t=this._ensureActiveGraphicsIterator(),n=this.visibilityGroup===16;for(;!e.done;){e.madeProgress();let r=t.next();if(r.done===!0)return this._activeIterator=null,!0;let i=r.value,a=i.getInfo(this.visibilityGroup);if(!a)continue;let o=!n||i.graphics3DGraphic.isVisible();!o||a.culled?(B(a.aabr,!1,!0),this._setGraphicVisibility(i,o&&a.visible)):this._deconflictor.add(a)}return!1}_occludedVisibility(e,t,n,r,i=!0){let a=Math.max(this._minAltitudeDifference,Math.abs(n-r))-this._minAltitudeDifference,o=i?this._baseOccludedVisibility+this._altitudeFactor*a:0;return e===0||t-e<=o}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(e){if(!e)return;let{camera:t}=this._viewState,n=Math.max(2,2+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(H,this._viewState.camera.eye,2**-n),u(H,d(H,H),2**n),e.init(this._checkOcclusion.size,H)}_ensureOcclusionQuery(){return this._occlusionQuery??=new P({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new P({view:this.view,category:j.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(e){return this._checkOcclusion.values().reduce((t,n)=>t+ +!!n.getInfo(e)?.visible,0)}_projectHudLayer(e,t,n){let r=e.stageObject,a=r.geometries[0],o=a.material;f(U,r.boundingVolumeWorldSpace.sphere.center),l(H,U,t.viewMatrix);let s=M(a,`normal`).getVec(0,ie),c=M(a,`centerOffset`)?.getVec(0,W)??i,d=N(a,`groundDistance`).get(0);return o.applyShaderOffsets(U,H,s,r.transformation,c,d,t,n.screenSizePerspectiveEvaluators),m(G,H[0],H[1],H[2],1),h(K,G,t.projectionMatrix),u(n.positionNDC,K,1/K[3]),o.applyShaderOffsetsNDC(n.positionNDC,c,d,t,n.positionNDC,q),!n.isOutsideScreen&&(n.distanceWithoutPolygonOffset=t.depthNDCToWorld(q[2]),n.distance=q[2]===n.positionNDC[2]?n.distanceWithoutPolygonOffset:t.depthNDCToWorld(n.positionNDC[2]),m(K,n.positionNDC[0],n.positionNDC[1],n.positionNDC[2],1),h(G,K,t.inverseProjectionMatrix),g(G,G,1/G[3]),p(n.positionView,G[0],G[1],G[2]),f(n.positionWorld,U),!0)}_isCulledBySlice(e,t){return e.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&te(this._viewState.slicePlane,t)}_expandBoundingRect(e,t,n,r,{positionNDC:i,screenSizePerspectiveEvaluators:a}){let o=n.getScreenSize(ue);a.evaluator.applyVec2(o,o),o[0]*=t.pixelRatio,o[1]*=t.pixelRatio;let s=T(r.calculateRelativeScreenBounds(o,a.alignmentEvaluator.apply(t.pixelRatio),oe),v(0,t.fullWidth,.5+.5*i[0]),v(0,t.fullHeight,.5+.5*i[1])),c=this.marginFactor;if(c!==0){let e=c*Math.min(E(s),D(s));s[0]-=e,s[1]-=e,s[2]+=e,s[3]+=e}ee(e,s,e)}_setGraphicVisibility(e,t){let n=e?.graphics3DGraphic;n&&!n.destroyed&&(n.setVisibilityFlag(this.visibilityGroup,8,t),this.visibilityGroup===16&&this.view.labeler.setLabelGraphicVisibility(n,t))}_setTransparentMode(e,t){let n=e?.graphics3DGraphic;if(n&&!n.destroyed)for(let e of n.layers){if(e?.type!==`object3d`&&e?.type!==`buffer`)continue;let{graphics3DSymbolLayer:n}=e;V(n)&&n.updateTransparentMode(e,t)}}};e([n({constructOnly:!0})],$.prototype,`view`,void 0),e([n({type:Boolean,readOnly:!0})],$.prototype,`_readyToRun`,null),e([n({type:Boolean,readOnly:!0})],$.prototype,`updating`,null),e([n({readOnly:!0})],$.prototype,`_updatingHandles`,void 0),$=e([r(`esri.views.3d.layers.graphics.Deconflictor`)],$);function le(e,t){let n=e.graphics3DGraphic;n.destroyed||n.setVisibilityFlag(t,8,!0)}const ue=c();class de{constructor(){this.positionWorld=a(),this.positionView=a(),this.positionNDC=a(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new F}get isOutsideScreen(){let e=this.positionNDC;return e[0]<-1||e[1]<-1||e[2]<-1||e[0]>=1||e[1]>=1||e[2]>=1}}function fe(e,t,n){return f(X.direction,e.positionView),p(X.origin,0,0,0),t.intersectRay(X,ae)?e.distanceWithoutPolygonOffset>n:!1}function pe(e,t){return t===16?e.labelLayers:e.layers}const me=new de;export{$ as Deconflictor,Z as DeconflictorGraphic,Q as DeconflictorViewState};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ZEROS as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as d,copy as f,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{set as m,transformMat4 as h,scale as g}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{lerp as v}from"../../../../core/mathUtils.js";import{destroyMaybe as y}from"../../../../core/maybe.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x}from"../../../../geometry/ellipsoidUtils.js";import{create as S,empty as C,copy as w,offset as T,width as E,height as D,expand as ee}from"../../../../geometry/support/aaBoundingRect.js";import{extrusionContainsPoint as te,create as ne,copy as re}from"../../../../geometry/support/boundedPlane.js";import{create as O}from"../../../../geometry/support/ray.js";import{Sphere as k}from"../../../../geometry/support/sphere.js";import{Yield as A}from"../../../support/Yield.js";import{InternalRenderCategory as j}from"../../webgl.js";import{getVec3AttributeView as M,getScalarAttributeView as N}from"../../webgl-engine/lib/attributeViewUtils.js";import{GPUPointOcclusionQuery as P}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as F}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";import L from"../../webgl/RenderCamera.js";import{DeconflictAABR as R}from"./DeconflictAABR.js";import{prepare as z,drawPoly as B}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as V}from"./transparencyUtils.js";const H=a(),U=a(),ie=a(),W=a(),G=_(),K=_(),q=a(),J=s(),Y=new k,X=O(),ae=a(),oe=S();class se{constructor(e){this.id=e,this.aabr=S(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ce(e,t){let n=e.distanceToOccluder!==0&&e.distance>e.distanceToOccluder,r=t.distanceToOccluder!==0&&t.distance>t.distanceToOccluder;return n===r?e.priority===t.priority?e.distance===t.distance?e.visible===t.visible?e.id-t.id:+t.visible-e.visible:e.distance-t.distance:t.priority-e.priority:+n-r}class Z{constructor(e,t){this.graphics3DGraphic=e,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(e){let t=this.getInfo(e);return t||(t=new se(this.graphics3DGraphic.graphic.uid),this._setInfo(e,t)),t}getInfo(e){return e===16?this._labelInfo:this._info}removeInfo(e){this._setInfo(e,null)}_setInfo(e,t){e===16?this._labelInfo=t:this._info=t}}class Q{constructor(){this.camera=new L,this.slicePlane=ne(),this.slicePlaneEnabled=!1}copyFrom(e){this.camera.equals(e.camera)||this.camera.copyFrom(e.camera),re(e.slicePlane,this.slicePlane),this.slicePlaneEnabled=e.slicePlaneEnabled}}let $=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(e){super(e),this._dirty=!1,this._viewState=new Q,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=[],this._updatingHandles=new b,this._deconflictor=new R((e,t)=>{e.visible=t,this._setGraphicVisibility(this._active.get(e.id),t)},(e,t)=>e.id!==t.id,ce),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange(`_readyToRun`))}setPriority(e,t){let n=this._active.get(e.graphic.uid)?.getInfo(this.visibilityGroup);n&&(n.priority=t)}get _readyToRun(){return this._state!==0||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;let e=this._state/5;return this._dirty?e*.5:e}get readyToRun(){return this.view.ready&&this.view.state!=null&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+(this._occlusionQueryUids?.length??0)*4}runTask(e){switch(this._state){case 0:this._startUpdate(),e.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(e))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??!0)||!(this._opaqueOcclusionQuery?.done??!0))return A;this._readOcclusionQueryResult(),e.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(e))return;case 4:if(this._state=4,this._deconflictor.run(e),!this._deconflictor.done)return;default:this._state=0,this.notifyChange(`_readyToRun`)}}setGraphicsActive(e,t){t?e.forEach(e=>this.addToActiveGraphics(e)):e.forEach(e=>this.removeFromActiveGraphics(e))}isSupportedLayer(e){if(e==null||e.type!==`buffer`||!e.hiddenIfDeconflicted)return!1;let t=e.stageObject;return(t?.geometries.length??0)===1&&t?.geometries[0]?.material instanceof I}_startUpdate(){z(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);let{fullWidth:e,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(e,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery))}addToActiveGraphics(e){e.ensureInfo(this.visibilityGroup),this._active.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromActiveGraphics(e){this._active.get(e.graphics3DGraphic.graphic.uid)===e&&(le(e,this.visibilityGroup),e.removeInfo(this.visibilityGroup),this._active.delete(e.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(e){this._checkOcclusion.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromCheckOcclusion(e){this._checkOcclusion.get(e.graphics3DGraphic.graphic.uid)===e&&this._checkOcclusion.delete(e.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(e){if(this._checkOcclusion.size===0)return!0;let t=this._ensureCheckOcclusionIterator(),n=this._viewState.camera,r=o(J,n.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,s=this.view.state.isGlobal&&a&&n.relativeElevation>0?Y:null,c=0;s!=null&&(l(s.center,i,n.viewMatrix),s.radius=x(this.view.spatialReference).radius,c=s.distanceToSilhouette(i));let u=S();for(;;){if(e.done)return!1;e.madeProgress();let i=t.next();if(i.done===!0)break;let a=i.value,o=a.graphics3DGraphic;if(o.destroyed||!o.isVisible(1,8))continue;let d=pe(o,this.visibilityGroup),f=null,p=!0,m=!1;for(let e of d){if(!this.isSupportedLayer(e))continue;if(f=me,!this._projectHudLayer(e,n,f)||this._isCulledBySlice(a,f.positionWorld)||s!=null&&fe(f,s,c)){p=!1;break}C(u);let t=e.stageObject.geometries[0].material;this._expandBoundingRect(u,n,e,t,f),f.altitude=this.view.renderCoordsHelper.getAltitude(f.positionWorld);let i=a.ensureInfo(this.visibilityGroup);if(i.altitude=f.altitude,i.distance=f.distance,i.distanceToOccluder=f.distanceToOccluder,i.culled=!1,w(i.aabr,u),!e.occlusionCheck)break;l(U,f.positionView,r);let d=this._ensureOcclusionQuery(),h=this._ensureOpaqueOcclusionQuery();this._occlusionQueryUids.length===0&&(this._initOcclusionQuery(d),this._initOcclusionQuery(h));let g=d.addPosition(U),_=h.addPosition(U);if(g===this._occlusionQueryUids.length&&_===g){let t=e.adaptiveOcclusion;this._occlusionQueryUids.push(t?-o.graphic.uid:o.graphic.uid),m=!0}break}let h=this._active.has(o.graphic.uid);if(!h&&!m)this._setGraphicVisibility(a,p);else if(h&&(!p||!f)){let e=a.ensureInfo(this.visibilityGroup);e.visible=!f,e.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;let e=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(e.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){let n=this._occlusionQueryUids[e],r=Math.abs(n),i=n<0,a=this._checkOcclusion.get(r);if(!a)continue;let o=this._occlusionQuery.getOcclusion(e)??-1,s=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,c=a.getInfo(this.visibilityGroup);c&&(c.distanceToOccluder=o>0?c.distance-o:0);let l=s===0||s>0&&this._occludedVisibility(c?c.distance-s:0,c?.distance??s,c?.altitude??0,t,i),u=o===0||o>0&&this._occludedVisibility(c?.distanceToOccluder??0,c?.distance??o,c?.altitude??0,t,i),d=l||u;d&&this._setTransparentMode(a,l&&!u),this._active.has(r)?c&&(c.culled=!d,c.visible=d):this._setGraphicVisibility(a,d)}this._occlusionQueryUids.length=0}_collectActiveGraphics(e){let t=this._ensureActiveGraphicsIterator(),n=this.visibilityGroup===16;for(;!e.done;){e.madeProgress();let r=t.next();if(r.done===!0)return this._activeIterator=null,!0;let i=r.value,a=i.getInfo(this.visibilityGroup);if(!a)continue;let o=!n||i.graphics3DGraphic.isVisible();!o||a.culled?(B(a.aabr,!1,!0),this._setGraphicVisibility(i,o&&a.visible)):this._deconflictor.add(a)}return!1}_occludedVisibility(e,t,n,r,i=!0){let a=Math.max(this._minAltitudeDifference,Math.abs(n-r))-this._minAltitudeDifference,o=i?this._baseOccludedVisibility+this._altitudeFactor*a:0;return e===0||t-e<=o}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(e){if(!e)return;let{camera:t}=this._viewState,n=Math.max(2,2+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(H,this._viewState.camera.eye,2**-n),u(H,d(H,H),2**n),e.init(this._checkOcclusion.size,H)}_ensureOcclusionQuery(){return this._occlusionQuery??=new P({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new P({view:this.view,category:j.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(e){return this._checkOcclusion.values().reduce((t,n)=>t+ +!!n.getInfo(e)?.visible,0)}_projectHudLayer(e,t,n){let r=e.stageObject,a=r.geometries[0],o=a.material;f(U,r.boundingVolumeWorldSpace.sphere.center),l(H,U,t.viewMatrix);let s=M(a,`normal`).getVec(0,ie),c=M(a,`centerOffset`)?.getVec(0,W)??i,d=N(a,`groundDistance`).get(0);return o.applyShaderOffsets(U,H,s,r.transformation,c,d,t,n.screenSizePerspectiveEvaluators),m(G,H[0],H[1],H[2],1),h(K,G,t.projectionMatrix),u(n.positionNDC,K,1/K[3]),o.applyShaderOffsetsNDC(n.positionNDC,c,d,t,n.positionNDC,q),!n.isOutsideScreen&&(n.distanceWithoutPolygonOffset=t.depthNDCToWorld(q[2]),n.distance=q[2]===n.positionNDC[2]?n.distanceWithoutPolygonOffset:t.depthNDCToWorld(n.positionNDC[2]),m(K,n.positionNDC[0],n.positionNDC[1],n.positionNDC[2],1),h(G,K,t.inverseProjectionMatrix),g(G,G,1/G[3]),p(n.positionView,G[0],G[1],G[2]),f(n.positionWorld,U),!0)}_isCulledBySlice(e,t){return e.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&te(this._viewState.slicePlane,t)}_expandBoundingRect(e,t,n,r,{positionNDC:i,screenSizePerspectiveEvaluators:a}){let o=n.getScreenSize(ue);a.evaluator.applyVec2(o,o),o[0]*=t.pixelRatio,o[1]*=t.pixelRatio;let s=T(r.calculateRelativeScreenBounds(o,a.alignmentEvaluator.apply(t.pixelRatio),oe),v(0,t.fullWidth,.5+.5*i[0]),v(0,t.fullHeight,.5+.5*i[1])),c=this.marginFactor;if(c!==0){let e=c*Math.min(E(s),D(s));s[0]-=e,s[1]-=e,s[2]+=e,s[3]+=e}ee(e,s,e)}_setGraphicVisibility(e,t){let n=e?.graphics3DGraphic;n&&!n.destroyed&&(n.setVisibilityFlag(this.visibilityGroup,8,t),this.visibilityGroup===16&&this.view.labeler.setLabelGraphicVisibility(n,t))}_setTransparentMode(e,t){let n=e?.graphics3DGraphic;if(n&&!n.destroyed)for(let e of n.layers){if(e?.type!==`object3d`&&e?.type!==`buffer`)continue;let{graphics3DSymbolLayer:n}=e;V(n)&&n.updateTransparentMode(e,t)}}};e([n({constructOnly:!0})],$.prototype,`view`,void 0),e([n({type:Boolean,readOnly:!0})],$.prototype,`_readyToRun`,null),e([n({type:Boolean,readOnly:!0})],$.prototype,`updating`,null),e([n({readOnly:!0})],$.prototype,`_updatingHandles`,void 0),$=e([r(`esri.views.3d.layers.graphics.Deconflictor`)],$);function le(e,t){let n=e.graphics3DGraphic;n.destroyed||n.setVisibilityFlag(t,8,!0)}const ue=c();class de{constructor(){this.positionWorld=a(),this.positionView=a(),this.positionNDC=a(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new F}get isOutsideScreen(){let e=this.positionNDC;return e[0]<-1||e[1]<-1||e[2]<-1||e[0]>=1||e[1]>=1||e[2]>=1}}function fe(e,t,n){return f(X.direction,e.positionView),p(X.origin,0,0,0),t.intersectRay(X,ae)?e.distanceWithoutPolygonOffset>n:!1}function pe(e,t){return t===16?e.labelLayers:e.layers}const me=new de;export{$ as Deconflictor,Z as DeconflictorGraphic,Q as DeconflictorViewState};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{watch as i,sync as a,initial as o}from"../../../../core/reactiveUtils.js";import{getReferenceEllipsoid as s}from"../../../../geometry/ellipsoidUtils.js";import{TaskPriority as c}from"../../../support/Scheduler.js";import{Yield as l}from"../../../support/Yield.js";import{FrustumExtentIntersection as u}from"../../support/FrustumExtentIntersection.js";let d=class extends t{constructor(e){super(e),this.suspended=!1,this._extent=null,this._extentIntersectionDirty=!0,this._isVisibleBelowSurfaceInternal=!1,this.graphicsCoreOwner=null,this.updating=!0}initialize(){let{graphicsCoreOwner:e}=this;this._extentIntersection=new u({renderCoordsHelper:e.view.renderCoordsHelper});let{view:t}=e,{groundView:n}=t,{scheduler:r}=t.resourceController;this.addHandles([t.on(`resize`,()=>this._viewChange()),i(()=>t.state.camera,()=>this._viewChange(),a),r.registerTask(c.FRUSTUM_VISIBILITY,this),i(()=>n.visibleElevationRange,()=>this._elevationRangeChange())]),t.viewingMode===`local`?this._isVisibleBelowSurface=!0:this.addHandles([i(()=>[n.baseOpacity,n.wireframe,t.map?.ground?.navigationConstraint?.type],()=>this._updateIsVisibleBelowSurface(),o)])}destroy(){this._set(`graphicsCoreOwner`,null),this._extent=null,this._extentIntersection=null}_setDirty(){this.updating||this._set(`updating`,!0)}setExtent(e){this._extent=e,this._extentIntersectionDirty=!0,this._setDirty()}_viewChange(){this._setDirty()}_elevationRangeChange(){this._setDirty(),this._extentIntersectionDirty=!0}set _isVisibleBelowSurface(e){this._isVisibleBelowSurfaceInternal=e,this._setDirty(),this._extentIntersectionDirty=!0}_updateIsVisibleBelowSurface(){let e=this.graphicsCoreOwner.view,t=e.viewingMode===`local`,n=e.map.ground?.navigationConstraint?.type===`none`;this._isVisibleBelowSurface=t||!e.groundView.opaque||n}_updateExtentIntersection(){if(!this._extentIntersectionDirty)return;this._extentIntersectionDirty=!1;let e=this.graphicsCoreOwner.view,t;if(this._isVisibleBelowSurfaceInternal)t=-.3*s(e.spatialReference).radius;else{let{minElevation:n,maxElevation:r}=e.groundView.visibleElevationRange;t=n-Math.max(1,(r-n)*(1.2-1))}this._extentIntersection.update(this._extent,e.spatialReference,t)}get readyToRun(){return this.updating}runTask(e){if(this._set(`updating`,!1),!this._extent)return this._set(`suspended`,!1),l;this._updateExtentIntersection();let{frustum:t}=this.graphicsCoreOwner.view,n=s(this.graphicsCoreOwner.view.spatialReference).radius;this._set(`suspended`,!this._extentIntersection.isVisibleInFrustum(t,n)),e.madeProgress()}};e([n({readOnly:!0})],d.prototype,`suspended`,void 0),e([n({constructOnly:!0})],d.prototype,`graphicsCoreOwner`,void 0),e([n({readOnly:!0})],d.prototype,`updating`,void 0),d=e([r(`esri.views.3d.layers.graphics.Graphics3DFrustumVisibility`)],d);export{d as Graphics3DFrustumVisibility};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{watch as i,sync as a,initial as o}from"../../../../core/reactiveUtils.js";import{getReferenceEllipsoid as s}from"../../../../geometry/ellipsoidUtils.js";import{TaskPriority as c}from"../../../support/Scheduler.js";import{Yield as l}from"../../../support/Yield.js";import{FrustumExtentIntersection as u}from"../../support/FrustumExtentIntersection.js";let d=class extends t{constructor(e){super(e),this.suspended=!1,this._extent=null,this._extentIntersectionDirty=!0,this._isVisibleBelowSurfaceInternal=!1,this.graphicsCoreOwner=null,this.updating=!0}initialize(){let{graphicsCoreOwner:e}=this;this._extentIntersection=new u({renderCoordsHelper:e.view.renderCoordsHelper});let{view:t}=e,{groundView:n}=t,{scheduler:r}=t.resourceController;this.addHandles([t.on(`resize`,()=>this._viewChange()),i(()=>t.state.camera,()=>this._viewChange(),a),r.registerTask(c.FRUSTUM_VISIBILITY,this),i(()=>n.visibleElevationRange,()=>this._elevationRangeChange())]),t.state.isGlobal?this.addHandles([i(()=>[n.baseOpacity,n.wireframe,t.map?.ground?.navigationConstraint?.type],()=>this._updateIsVisibleBelowSurface(),o)]):this._isVisibleBelowSurface=!0}destroy(){this._set(`graphicsCoreOwner`,null),this._extent=null,this._extentIntersection=null}_setDirty(){this.updating||this._set(`updating`,!0)}setExtent(e){this._extent=e,this._extentIntersectionDirty=!0,this._setDirty()}_viewChange(){this._setDirty()}_elevationRangeChange(){this._setDirty(),this._extentIntersectionDirty=!0}set _isVisibleBelowSurface(e){this._isVisibleBelowSurfaceInternal=e,this._setDirty(),this._extentIntersectionDirty=!0}_updateIsVisibleBelowSurface(){let e=this.graphicsCoreOwner.view,t=e.state.isLocal,n=e.map.ground?.navigationConstraint?.type===`none`;this._isVisibleBelowSurface=t||!e.groundView.opaque||n}_updateExtentIntersection(){if(!this._extentIntersectionDirty)return;this._extentIntersectionDirty=!1;let e=this.graphicsCoreOwner.view,t;if(this._isVisibleBelowSurfaceInternal)t=-.3*s(e.spatialReference).radius;else{let{minElevation:n,maxElevation:r}=e.groundView.visibleElevationRange;t=n-Math.max(1,(r-n)*(1.2-1))}this._extentIntersection.update(this._extent,e.spatialReference,t)}get readyToRun(){return this.updating}runTask(e){if(this._set(`updating`,!1),!this._extent)return this._set(`suspended`,!1),l;this._updateExtentIntersection();let{frustum:t}=this.graphicsCoreOwner.view,n=s(this.graphicsCoreOwner.view.spatialReference).radius;this._set(`suspended`,!this._extentIntersection.isVisibleInFrustum(t,n)),e.madeProgress()}};e([n({readOnly:!0})],d.prototype,`suspended`,void 0),e([n({constructOnly:!0})],d.prototype,`graphicsCoreOwner`,void 0),e([n({readOnly:!0})],d.prototype,`updating`,void 0),d=e([r(`esri.views.3d.layers.graphics.Graphics3DFrustumVisibility`)],d);export{d as Graphics3DFrustumVisibility};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as n}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as r,clone as i,ones as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{onePixelInPoints as o,pt2px as s,onePointInPixels as c}from"../../../../core/screenUtils.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{debugFlags as g}from"../../support/debugFlags.js";import{selectLocalOrigin as _,createBufferGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as y,geometryToRenderInfoDraped as b}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as x}from"../../webgl-engine/lib/BufferObject3D.js";import{createLineMarkerBufferGeometry as S}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";import{LineMarkerMaterial as C}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as w,patternHidesLine as T}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as E}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as O,getAttributeValue as k,getSizeAttributeValue as A,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{perBufferLineElevationAligner as M}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as N,needsElevationUpdates2D as P}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as F}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as I}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as L,nanFallbackColor as R}from"./Graphics3DSymbolLayer.js";import{parseCapType as z,computeSymbolLayerIndex as B,parseLineMarkerStyle as V}from"./lineUtils.js";const H=[`polyline`];class U extends L{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?o:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:B(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:z(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:w(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(o.hasVertexColor=this._hasDrivenColorOrOpacity,o.hasVertexSize=this._drivenProperties.size,o.hasLineDistance=o.stipplePattern!=null,this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new E(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new E({...this._getMaterialParameters(!1,1),wireframe:!0},this.view),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new C({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:V(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(i[3]=t?.output??this._getFallbackOpacity()),i}_getDrivenMarkerColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackMarkerOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(i[3]=t?.output??this._getFallbackMarkerOpacity()),i}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)if(n===`visualVariables`){let e=this._fastUpdates;if(O(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof E&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(O(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof C&&e.setParameters(n.materialParameters);else return 0}else return 0;return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=z(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=N(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=P(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicallyBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=W(e.graphic.geometry);if(r==null)return null;let i=[],a=[],o=l(),s=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,r.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,c,l,1,n);a.push(f),i.push(f.line),f.wireframe!=null&&i.push(f.wireframe),f.marker!=null&&i.push(f.marker)}if(i.length===0)return null;let c=this._context.layerViewUid,f=new x({geometries:i,castShadow:!1,layerViewUid:c,graphicUid:n}),p=new F(this,f,null,(e,t,n,r,i)=>M(e,t,n,r,i,a),t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=P(t.mode),p}_createGeometryParts(e,t,n,r,i){let a=r===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o=this._fastUpdates?.visualVariables.color,s=this._fastUpdates?.visualVariables.size,c=this._fastUpdates?.visualVariables.opacity,l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:l}),{renderingInfo:d}=e,f={position:t,size:s?null:this._getDrivenSize(d),color:o?null:this._getDrivenColor(d),sizeFeature:s?A(s,d.size):null,colorFeature:o?k(o,d.color):null,opacityFeature:c?k(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=_(t,p),h={overlayInfo:a,removeDuplicateStartEnd:!1,mapPositions:n,attributeData:f},y=v(this._lineMaterial,h,m,u),b=g.LINE_WIREFRAMES?v(this._wireframeLineMaterial,h,m,u):null,x=this._markerMaterial,C=null;x!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},C=S(x,h,m));for(let e of[y,C,b])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:y,marker:C,wireframe:b}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=g.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=b(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let n of c.lines){if(u(n.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let r=this._createGeometryParts(e,n.position,void 0,0,t.uid);r.marker!=null&&a.push(r.marker),a.push(r.line),r.wireframe!=null&&a.push(r.wireframe)}return new I(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return T(this.symbolLayer.pattern)}_computeMaterialWidth(e,t){return t?this._drivenProperties.size?1:e??1:(e??=o,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?c:1:s(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let a=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,o=this._getCombinedOpacityAndColor(a);n.useMaterialColor&&G(i(o),this._materials[2],e),this._patternHidesLine&&(o[3]=0),G(o,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:V(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let n=this._getFallbackSize(),{size:r}=this.symbolLayer;return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:t(r,r,r),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(R):this._getFallbackOpacityAndColor(R),fallbackSize:t(n,n,n)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:s(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
2
+ import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as n}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as r,clone as i,ones as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{onePixelInPoints as o,pt2px as s,onePointInPixels as c}from"../../../../core/screenUtils.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{debugFlags as g}from"../../support/debugFlags.js";import{selectLocalOrigin as _,createBufferGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as y,geometryToRenderInfoDraped as b}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as x}from"../../webgl-engine/lib/BufferObject3D.js";import{createLineMarkerBufferGeometry as S}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";import{LineMarkerMaterial as C}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as w,patternHidesLine as T}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as E}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as O,getAttributeValue as k,getSizeAttributeValue as A,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{perBufferLineElevationAligner as M}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as N,needsElevationUpdates2D as P}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as F}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as I}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as L,nanFallbackColor as R}from"./Graphics3DSymbolLayer.js";import{parseCapType as z,computeSymbolLayerIndex as B,parseLineMarkerStyle as V}from"./lineUtils.js";const H=[`polyline`];class U extends L{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?o:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:B(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:z(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:w(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(o.hasVertexColor=this._hasDrivenColorOrOpacity,o.hasVertexSize=this._drivenProperties.size,o.hasLineDistance=o.stipplePattern!=null,this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new E(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new E({...this._getMaterialParameters(!1,1),wireframe:!0},this.view),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new C({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:V(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(i[3]=t?.output??this._getFallbackOpacity()),i}_getDrivenMarkerColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackMarkerOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(i[3]=t?.output??this._getFallbackMarkerOpacity()),i}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)if(n===`visualVariables`){let e=this._fastUpdates;if(O(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof E&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(O(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof C&&e.setParameters(n.materialParameters);else return 0}else return 0;return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=z(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=N(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=P(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicallyBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=W(e.graphic.geometry);if(r==null)return null;let i=[],a=[],o=l(),s=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,r.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,c,l,1,n);a.push(f),i.push(f.line),f.wireframe!=null&&i.push(f.wireframe),f.marker!=null&&i.push(f.marker)}if(i.length===0)return null;let c=this._context.layerViewUid,f=new x({geometries:i,castShadows:!1,layerViewUid:c,graphicUid:n}),p=new F(this,f,null,(e,t,n,r,i)=>M(e,t,n,r,i,a),t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=P(t.mode),p}_createGeometryParts(e,t,n,r,i){let a=r===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o=this._fastUpdates?.visualVariables.color,s=this._fastUpdates?.visualVariables.size,c=this._fastUpdates?.visualVariables.opacity,l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:l}),{renderingInfo:d}=e,f={position:t,size:s?null:this._getDrivenSize(d),color:o?null:this._getDrivenColor(d),sizeFeature:s?A(s,d.size):null,colorFeature:o?k(o,d.color):null,opacityFeature:c?k(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=_(t,p),h={overlayInfo:a,removeDuplicateStartEnd:!1,mapPositions:n,attributeData:f},y=v(this._lineMaterial,h,m,u),b=g.LINE_WIREFRAMES?v(this._wireframeLineMaterial,h,m,u):null,x=this._markerMaterial,C=null;x!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},C=S(x,h,m));for(let e of[y,C,b])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:y,marker:C,wireframe:b}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=g.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=b(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let n of c.lines){if(u(n.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let r=this._createGeometryParts(e,n.position,void 0,0,t.uid);r.marker!=null&&a.push(r.marker),a.push(r.line),r.wireframe!=null&&a.push(r.wireframe)}return new I(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return T(this.symbolLayer.pattern)}_computeMaterialWidth(e,t){return t?this._drivenProperties.size?1:e??1:(e??=o,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?c:1:s(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let a=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,o=this._getCombinedOpacityAndColor(a);n.useMaterialColor&&G(i(o),this._materials[2],e),this._patternHidesLine&&(o[3]=0),G(o,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:V(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let n=this._getFallbackSize(),{size:r}=this.symbolLayer;return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:t(r,r,r),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(R):this._getFallbackOpacityAndColor(R),fallbackSize:t(n,n,n)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:s(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{normalFromMat4 as n,fromMat4 as r}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as o,invert as s,getTranslation as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l,IDENTITY as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as p,add as m,scale as h,transformMat4 as g,transformMat3 as _,normalize as v,scaleAndAdd as y,subtract as b,cross as x,dot as ee}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as te,ZEROS as ne,ONES as re,create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ie}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{releaseMaybe as ae}from"../../../../core/maybe.js";import{isPromiseLike as oe}from"../../../../core/promiseUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as se}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as ce}from"../../../../geometry/projection/projectVectorToVector.js";import{canProjectWithoutEngine as le}from"../../../../geometry/projectionUtils.js";import{fromBuffer as ue,intersectsClippingArea as de,create as fe}from"../../../../geometry/support/aaBoundingBox.js";import{t as w}from"../../../../chunks/vec3.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as E,getContinuousIndexArray as pe}from"../../../../geometry/support/Indices.js";import me from"../../../../geometry/support/MeshComponent.js";import he from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import ge from"../../../../geometry/support/MeshTextureTransform.js";import{transformNormal as D,transformVectorENUPlateCarree as O,transformVectorWMPlateCarree as k,projectNormalToPCPF as _e,transformTangent as A,projectTangentToPCPF as ve}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as ye}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{projectLocalVertexSpaceToPCPF as be}from"../../../../geometry/support/meshUtils/vertexSpaceConversion.js";import{isRelativeVertexSpace as xe,isAbsoluteVertexSpace as Se}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as j,isPlateCarree as M}from"../../../../geometry/support/spatialReferenceUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as Ce}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as we}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as Te}from"../../glTF/internal/resourceUtils.js";import{convertMeshTextureTransformToGLTF as N,getTransformMatrix as P}from"../../glTF/internal/TextureTransformUtils.js";import{debugFlags as F}from"../../support/debugFlags.js";import{Attribute as I}from"../../webgl-engine/lib/Attribute.js";import{Geometry as L}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as Ee}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as De}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Oe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as R}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ke,advancedMRRFactors as Ae,schematicMRRFactors as je}from"../../webgl-engine/materials/pbrUtils.js";import{hasEdges as Me,createMaterial as Ne}from"../support/edgeUtils.js";import{defaultSymbolLayerMemoryComplexity as Pe}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as B,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as Fe}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Ie}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Le}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Re,nanFallbackColor as ze}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as Be,MeshFastUpdateProcessor as Ve}from"./MeshFastUpdateProcessor.js";import{addOlidAttribute as He}from"./olidUtils.js";import{SymbolComplexity as Ue}from"./SymbolComplexity.js";const We=[`mesh`];class Ge extends Re{constructor(e,t,n,r){super(e,t,n,r,Ce(t)),this._materialInfoCache=new Be,this._fastUpdateProcessor=new Ve,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){F.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new R({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new R({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new R({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,We,`fill on mesh-3d`))return null;let n=this.createElevationContextForGraphic(t),r=e.renderingInfo;return this._createAs3DShape(t,r,n,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:n});let t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,B)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicallyBasedRenderingChanged(){let e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateMeshTransform(e,t,n,r,i){if(!e.fastTransformUpdatesAllowed)return!1;let a=e.fastTransformUpdatesEnabled;switch(i){case 0:if(a)return!0;break;case 1:if(!a)return!0}let o=this._context.renderCoordsHelper.spatialReference,s=it,{origin:c,transform:l}=n;if(!C(t.spatialReference,p(J,c.x,c.y,c.z??0),s,o))return!1;switch(i){case void 0:a||this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context,!0);break;case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:if(this._fastUpdateProcessor.disable(e,this._materialInfoCache),t.vertexSpace.type===`local`)return!1}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);let{elevationContext:u}=e;u.centerInElevationSR=this._getCenterInElevationSR(s);let{elevationProvider:d,renderCoordsHelper:f}=this._context;return e.alignedSampledElevation=z(e,u,d.spatialReference,(e,t)=>V(e,d,u,f,t),f,s),e.updateTransform(s,l,this._context.isAsync,r),!0}computeComplexity(){if(!this._textures||this._textures.size===0)return super.computeComplexity();let e=0;for(let t of this._textures.values())e+=t.usedMemory;let t={...Pe(this.symbol,this.symbolLayer),resourceBytes:e},n=Me(this.symbolLayer)?2:0;return new Ue({drawCallsPerFeature:n,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){let n=this._requiresSymbolVertexColors(),r=!!e.vertexAttributes.color,i=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:n,hasVertexColors:r,hasVertexTangents:i,unlit:!1,uid:`vc:${r},vt:${i},vct${t},svc:${n}`}}_materialProperties(e,t,n){let r=this._materialPropertiesDefault(e,n);if(!t.material)return r;let{color:i,colorTexture:a,colorTextureTransform:o,normalTexture:s,normalTextureTransform:c,doubleSided:l,alphaCutoff:u,alphaMode:d}=t.material,f=G(i),p=G(a),m=K(o),h=G(s),g=K(c);if(r.color=i,r.colorTexture=a,r.normalTexture=s,r.uid=`${r.uid},cmuid:${f},ctmuid:${p},cttuid:${m},ntmuid:${h},nttuid:${g},ds:${l},ac:${u},am:${d}`,t.material instanceof he){let{metallic:e,roughness:n,metallicRoughnessTexture:i,metallicRoughnessTextureTransform:a,emissiveColor:s,emissiveStrength:l,emissiveTexture:u,emissiveTextureTransform:d,occlusionTexture:f,occlusionTextureTransform:p,unlit:m}=t.material,h=G(i),g=K(a),_=G(s),v=G(u),y=K(d),b=G(f),x=K(p);r.uid=[r.uid,`mrm:${e}`,`mrr:${n}`,`mrt:${h}`,`mrtt:${g}`,`emuid:${_}`,`ems:${l}`,`etmuid:${v}`,`ett:${y}`,`otmuid:${b}`,`ott:${x}`,`unlit:${m}`].join(`,`),r.metallic=e,r.roughness=n,r.metallicRoughnessTexture=i,r.emissiveColor=m?void 0:s,r.emissiveStrength=l,r.emissiveTexture=m?void 0:u,r.occlusionTexture=f,r.unlit=m,r.colorTextureTransform=N(o),r.normalTextureTransform=N(c),r.emissiveTextureTransform=N(d),r.occlusionTextureTransform=N(p),r.metallicRoughnessTextureTransform=N(a)}return r}_getInternalTexture(e,t=!1,n=1){let r=tt(e);if(!r)return null;let i=`${e.contentHash}/${n}`,a=this._textures.get(i);if(a){let e=this._context.stage.renderView.textures,t=null,n=e.acquire(a.id);return n!=null&&!oe(n)&&(a.events.on(`unloaded`,()=>t=ae(t)),t=n),a}let o=null,s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:Qe(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};return Te(r)?(o=r.data,c.preMultiplyAlpha=!1,c.encoding=r.encoding):(o=r,c.preMultiplyAlpha=n!==1,c.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),a=new Ee(o,c),this._textures.set(i,a),a.events.on(`loaded`,()=>this.updateComplexity()),a.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(a),a.events.on(`unloaded`,()=>{this._textures.delete(i)}),a}_setInternalMaterialTextureParameters(e,n){if(e.colorTexture!=null){let t=n.textureAlphaMode!==1,r=this._getInternalTexture(e.colorTexture,t,n.textureAlphaMode);r?(n.textureId=r.id,n.textureAlphaPremultiplied=!!r.parameters.preMultiplyAlpha):n.textureId=void 0}if(e.normalTexture&&(n.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){let r=e.emissiveColor?.toUnitRGB();n.emissiveBaseColor=te(t(r[0]),t(r[1]),t(r[2]))}e.emissiveStrength&&(n.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(n.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(n.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(n.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,n){e.color!=null&&et(e.color,t,n),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=P(e.colorTextureTransform),t.normalTextureTransformMatrix=P(e.normalTextureTransform);let r=e.normalTextureTransform?.scale==null?f:e.normalTextureTransform?.scale;t.normalScale=[r[0],r[1]],t.occlusionTextureTransformMatrix=P(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=P(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=P(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){let n=this._drivenProperties.color,r=this._drivenProperties.opacity;if(n)e.externalColor=ie;else{let n=t??null;if(n){let t=n.toUnitRGBA();r&&(t[3]=1),e.externalColor=t}else e.externalColor=ze}e.colorMixMode=this.symbolLayer.material?.colorMixMode??`multiply`,e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=we(this.symbolLayer?.material?.emissive?.source??`emissive`)}_getOrCreateMaterial(e,t){let n=t.material?.color,r=t.material?.colorTexture,i=t.material?.alphaMode,a=i===`blend`,o=i!==`opaque`&&($e(e)||n!=null&&n.a<1||r?.transparent||a),s=this._materialProperties(e,t,o),c=this._materialInfoCache.byUid(s.uid);if(c)return this._setInternalMaterialTextureParameters(s,c.material.parameters),c.material;let l={uid:s.uid,material:null,isComponentTransparent:o,alphaMode:t.material?t.material.alphaMode:`opaque`},u=ke({normalTexture:s.normalTexture,metallicRoughnessTexture:s.metallicRoughnessTexture,metallicFactor:s.metallic,roughnessFactor:s.roughness,emissiveTexture:s.unlit?void 0:s.emissiveTexture,emissiveFactor:s.unlit?ne:s.emissiveColor?.toUnitRGB(),occlusionTexture:s.occlusionTexture}),d={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:s.hasVertexColors,hasSymbolColors:s.hasSymbolVertexColors,hasVertexTangents:s.hasVertexTangents,ambient:ne,diffuse:re,opacity:1,doubleSided:!0,doubleSidedType:`winding-order`,cullFace:0,unlit:s.unlit,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||l.isComponentTransparent};d.mrrFactors=u?je:[s.metallic,s.roughness,Ae[2]],t.material&&(d.doubleSided=t.material.doubleSided,d.cullFace=t.material.doubleSided?0:2,d.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTextureAlphaMode(d,l),this._setInternalMaterialParameters(s,d,l);let f=new Oe(d,this._context.spherical);return l.material=f,this._materialInfoCache.set(s.uid,l),f}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue;delete n.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{let t=e.material.parameters;this._setExternalMaterialParameters(t,r),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return Fe(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicallyBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){e.textureAlphaMode=t.alphaMode===`auto`?this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1?3:1:t.alphaMode===`opaque`?1:t.alphaMode===`mask`?2:0}_createFaceDebugNormals(e,t){let r=t.length,a=e.spatialReference.isGeographic?20015077/180:1,o=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),s=[],c=[],l=t[0].transformation,u=n(i(),l);for(let e=0;e<r;e++){let n=t[e].attributes.get(`position`);if(!n)continue;let r=n.data,i=n.indices;for(let e=0;e<i.length;e+=3)U(r,i,e,Z),Ze(r,i,e,J,Y,X),m(J,J,Y),m(J,J,X),h(J,J,1/3),g(J,J,l),s.push(...J),_(Z,Z,u),v(Z,Z),y(J,J,Z,o),s.push(...J),c.push(c.length),c.push(c.length)}return s.length?new L(this._debugFaceNormalMaterial,[[`position`,new I(s,c,3,!0)]],null):null}_createPerVertexDebugVectors(e,t,a,o,s){let c=t.length,l=e.spatialReference.isGeographic?20015077/180:1,u=s*.1*Math.max(e.extent.width*l,e.extent.height*l,e.extent.zmax-e.extent.zmin),d=[],f=[],m=t[0].transformation,h=n(i(),m);a===`tangent`&&r(h,m);for(let e=0;e<c;e++){let n=t[e],r=n.attributes.get(`position`),i=n.attributes.get(a);if(!r||!i)continue;let o=r.data,s=r.indices,c=i.data,l=i.indices;for(let e=0;e<s.length;e++){let t=s[e]*3,n=l[e]*i.stride;p(J,o[t+0],o[t+1],o[t+2]),g(J,J,m),d.push(...J),p(Y,c[n+0],c[n+1],c[n+2]),_(Y,Y,h),v(Y,Y),y(J,J,Y,u),d.push(...J),f.push(f.length),f.push(f.length)}}return d.length?new L(o,[[`position`,new I(d,f,3,!0)]],null):null}_createAs3DShape(e,t,n,r){let i=e.geometry;if(i.type!==`mesh`)return null;let a=this._createGeometryInfo(i,t,r);if(a==null)return null;let{geometries:o,objectTransformation:s}=a;if(F.DRAW_MESH_GEOMETRY_NORMALS){let e=this._createPerVertexDebugVectors(i,o,`normal`,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(i,o,`tangent`,this._debugTangentNormalMaterial,.5),n=this._createFaceDebugNormals(i,o);e&&o.push(e),t&&o.push(t),n&&o.push(n)}let c=this._context.layerViewUid,l=new De({geometries:o,layerViewUid:c,graphicUid:r,isElevationSource:!0});l.transformation=s;let u=Ne(this.symbolLayer,{opacity:this._getLayerOpacity()}),d=u?new Le(o[0].material,u,this._context.slicePlaneEnabled):null,f=new Ie(this,l,null,z,n,d);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=B(n.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(i),n.centerInElevationSR=this._getCenterInElevationSR(l.transformation);let{elevationProvider:p,renderCoordsHelper:m}=this._context;return f.alignedSampledElevation=z(f,n,p.spatialReference,(e,t)=>V(e,p,n,m,t),m),f}_fastTransformUpdatesAllowed(e){let{vertexSpace:t,spatialReference:n}=e;if(!xe(t))return!1;let{type:r}=t,{view:i}=this._context.graphicsCoreOwner,{isGlobal:a,isLocal:o}=i.state,s=i.spatialReference;return a&&r===`local`||o&&j(s,n)&&r===`georeferenced`&&!n.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){let t=S(),n=p(ot,e[12],e[13],e[14]);return ce(n,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return e.reprojection===0&&!!e.objectTransformation}_createPositionBuffer(e,t,n){let r=n.position,i=r,a;if(t.reprojection===0)return{position:i,georeferencedPositionBuffer:a};let o=t.reprojection===1?t.transformBeforeProject:null;o&&(i=w(new Float64Array(i.length),i,o));let{normal:s,tangent:c}=n;!this._passthroughReprojectionInfo(t)&&(s||c)&&(a=i);let l=i===r||i===a?new Float64Array(i.length):i;return se(i,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:a}}_createNormalBuffer(e,t,n,r,i){let a=i.normal;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=D(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,0,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,0,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return _e(o,n,e.spatialReference,t,u,l)}_createTangentBuffer(e,t,n,r,i){let a=i.tangent;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=A(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,1,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,1,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return ve(o,n,e.spatialReference,t,u,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){let n=e.vertexAttributes&&e.vertexAttributes.position;if(!n)return this.logger.warn(`Mesh geometry must contain position vertex attributes`),null;let r=e.vertexAttributes.normal,i=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(r&&r.length!==n.length)return this.logger.warn(`Mesh normal vertex buffer must contain the same number of elements as the position buffer`),null;if(a&&a.length/4!=n.length/3)return this.logger.warn(`Mesh tangent vertex buffer must contain the same number of elements as the position buffer`),null;if(i&&i.length/2!=n.length/3)return this.logger.warn(`Mesh uv vertex buffer must contain the same number of elements as the position buffer`),null;let o=this._computeReprojectionInfo(e),s=o.reprojection===1&&o.convertLocalVertexSpace,c=s&&e.vertexSpace.type===`local`?be(e,e.vertexSpace,this._context.renderCoordsHelper.spatialReference):null;if(s&&!c)return this.logger.warn(`Local mesh vertex space could not be converted for rendering`),null;let{position:l,georeferencedPositionBuffer:u}=c?{position:c.position,georeferencedPositionBuffer:null}:this._createPositionBuffer(e,o,e.vertexAttributes),d=nt(e),f=this._createSymbolColorBuffer(t),p=c?c.normal:this._createNormalBuffer(e,l,u,o,e.vertexAttributes),m=c?c.tangent:this._createTangentBuffer(e,l,u,o,e.vertexAttributes),h=i,{geometryTransformation:g}=o,{transformation:_,position:v,normal:y,tangent:b}=this._passthroughReprojectionInfo(o)?{transformation:o.objectTransformation,position:l,normal:p,tangent:m}:this._expressInOriginLocalSpace(e,l,p,m,g);return{positionBuffer:v,normalBuffer:y,tangentBuffer:b,uvBuffer:h,colorBuffer:d,symbolColorBuffer:f,objectTransformation:_,geometryTransformation:g}}_computeReprojectionInfo(e){let{vertexSpace:t}=e,n=t.type===`georeferenced`,r=t.type===`local`&&this._context.graphicsCoreOwner.view.state.isGlobal,i=n?+!j(this._context.renderCoordsHelper.spatialReference,e.spatialReference):+!!r;if(Se(t))return{reprojection:i,geometryTransformation:l()};let s=t.origin,c=e.transform?.localMatrix??u;if(i===0){let t=l();return C(e.spatialReference,s,t,this._context.renderCoordsHelper.spatialReference),{reprojection:i,objectTransformation:t,geometryTransformation:d(c)}}if(r)return{reprojection:i,convertLocalVertexSpace:!0,geometryTransformation:d(c)};let f=a(l(),s);return o(f,f,c),{reprojection:i,transformBeforeProject:f,geometryTransformation:l()}}_expressInOriginLocalSpace(e,t,n,r,i){let a=this._context.renderCoordsHelper.spatialReference,c=e.origin;q[0]=c.x,q[1]=c.y,q[2]=c.z??0;let u=l();C(e.spatialReference,q,u,a),o(Q,u,i),s(Q,Q);let{position:d,normal:f,tangent:p}=e.vertexAttributes,m=t===d?new Float64Array(t.length):t;w(m,t,Q);let h=n?n===f?new Float32Array(n.length):n:null,g=r?r===p?new Float32Array(r.length):r:null;return n&&h&&D(n,h,Q),r&&g&&A(r,g,Q),{transformation:u,position:m,normal:h,tangent:g}}_validateFaces(e,t){let n=e.vertexAttributes.position.length/3,r=t.faces;if(r&&r.length>0){let e=-1;for(let t=0;t<r.length;t++){let n=r[t];n>e&&(e=n)}if(n<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(n%3!=0)return this.logger.warn(`Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)`),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent||!e.vertexAttributes?.position)return!1;let t=this._context.elevationProvider.spatialReference,n=ye(e,t??e.spatialReference);return n?(ue(n,$),!de($,this._context.clippingExtent)):!1}_createGeometryInfo(e,t,n){if(!le(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn(`Geometry spatial reference is not compatible with the view`),null;if(!this._validateVertexSpace(e)||this._isOutsideClippingArea(e))return null;let r=this._createBuffers(e,t);if(r==null)return null;let{positionBuffer:i,uvBuffer:a,colorBuffer:o,symbolColorBuffer:s,normalBuffer:l,tangentBuffer:u,objectTransformation:d,geometryTransformation:f}=r,p=e.components??at,m=[],h=!1,g=c(J,d),_=this._context.localOriginFactory.getOrigin(g);for(let t of p){if(!this._validateFaces(e,t))return null;let r=Ke(e,t);if(r.length===0)continue;let c=qe(i,l,t,r);c.didFlipNormals&&(h=!0);let d=[[`position`,new I(i,r,3,!0)],[`normal`,new I(c.normals,c.indices,3,!0)]];o&&d.push([`color`,new I(o,r,4,!0)]);let p=null;s&&(p=E(r.length),d.push([`symbolColor`,new I(s,p,4,!0)])),a&&d.push([`uv0`,new I(a,r,2,!0)]),u&&d.push([`tangent`,new I(u,r,4,!0)]);let g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:this._context.layerViewUid});g&&(p??=E(r.length),He(d,g,p));let v=this._getOrCreateMaterial(e,t),y=new L(v,d,null);y.transformation=f,y.localOrigin=_,m.push(y)}return h&&this.logger.warn(`Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals.`),m.length===0?null:{geometries:m,objectTransformation:d}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){return this._context.graphicsCoreOwner.view.state.isLocal&&e.vertexSpace.type===`local`?(this.logger.warn(`Displaying a mesh with a local vertex space in a view in local viewing mode is not supported.`),!1):!0}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class H{constructor(e,t,n){this.normals=e,this.indices=t,this.didFlipNormals=n}}function Ke(e,t){return t.faces??pe(e.vertexAttributes.position.length/3)}function qe(e,t,n,r){switch(n.shading||`flat`){default:case`source`:return Ye(e,t,n,r);case`flat`:return Je(e,r);case`smooth`:return Xe(e,r)}}function Je(e,t){let n=T(t.length),r=Array(t.length*3);for(let i=0;i<t.length;i+=3){let a=U(e,t,i,Z);for(let e=0;e<3;e++)n[i+e]=a[e],r[i+e]=i/3}return new H(n,r,!1)}function Ye(e,t,n,r){if(t==null)return Je(e,r);let i=!1;if(!n.trustSourceNormals)for(let n=0;n<r.length;n+=3){U(e,r,n,Z);for(let e=0;e<3;e++){let a=r[n+e]*3;J[0]=t[a],J[1]=t[a+1],J[2]=t[a+2],ee(Z,J)<0&&(t[a]=-t[a],t[a+1]=-t[a+1],t[a+2]=-t[a+2],i=!0)}}return new H(t,r,i)}function Xe(e,t){let n={};for(let r=0;r<t.length;r+=3){let i=U(e,t,r,Z);for(let e=0;e<3;e++){let a=t[r+e],o=n[a];o||(o={normal:S(),count:0},n[a]=o),m(o.normal,o.normal,i),o.count++}}let r=T(t.length*3),i=Array(t.length*3);for(let e=0;e<t.length;e++){let a=n[t[e]];a.count!==1&&(v(a.normal,a.normal),a.count=1);for(let t=0;t<3;t++)r[e*3+t]=a.normal[t];i[e]=e}return new H(r,i,!1)}function Ze(e,t,n,r,i,a){let o=t[n]*3,s=t[n+1]*3,c=t[n+2]*3;r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],a[0]=e[c],a[1]=e[c+1],a[2]=e[c+2]}function U(e,t,n,r){return Ze(e,t,n,J,Y,X),b(Y,Y,J),b(X,X,J),x(J,Y,X),v(r,J),r}function Qe(e=`repeat`){if(typeof e==`string`){let t=W(e);return{s:t,t}}return{s:W(e.horizontal),t:W(e.vertical)}}function W(e){switch(e){case`clamp`:return 33071;case`mirror`:return 33648;default:return 10497}}function $e(e){let t=e.vertexAttributes.color;if(t==null)return!1;for(let e=3;e<t.length;e+=4)if(t[e]!==255)return!0;return!1}function et(e,t,n){t.diffuse=e.toUnitRGB(),t.opacity=n.alphaMode===`opaque`?1:e.a}function tt(e){return e.data??e.url}function G(t){return t==null?`-`:t instanceof e?t.toHex():t.contentHash}function K(e){let{offset:t,scale:n,rotation:r}=e??rt;return`${t[0]},${t[1]},${r},${n[0]},${n[1]}`}function nt(e){return e.vertexAttributes.color}const rt=new ge,q=S(),J=S(),Y=S(),X=S(),Z=S(),Q=l(),it=l(),$=fe(),at=[new me],ot=S();export{Ge as Graphics3DMeshFillSymbolLayer};
2
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{normalFromMat4 as n,fromMat4 as r}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as o,invert as s,getTranslation as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l,IDENTITY as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as p,add as m,scale as h,transformMat4 as g,transformMat3 as _,normalize as v,scaleAndAdd as y,subtract as b,cross as ee,dot as te}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as ne,ZEROS as x,ONES as re,create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ie}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{releaseMaybe as ae}from"../../../../core/maybe.js";import{isPromiseLike as oe}from"../../../../core/promiseUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as se}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as ce}from"../../../../geometry/projection/projectVectorToVector.js";import{canProjectWithoutEngine as le}from"../../../../geometry/projectionUtils.js";import{fromBuffer as ue,intersectsClippingArea as de,create as fe}from"../../../../geometry/support/aaBoundingBox.js";import{t as w}from"../../../../chunks/vec3.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as E,getContinuousIndexArray as pe}from"../../../../geometry/support/Indices.js";import me from"../../../../geometry/support/MeshComponent.js";import he from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import ge from"../../../../geometry/support/MeshTextureTransform.js";import{transformNormal as D,transformVectorENUPlateCarree as O,transformVectorWMPlateCarree as k,projectNormalToPCPF as _e,transformTangent as A,projectTangentToPCPF as ve}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as ye}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{projectLocalVertexSpaceToPCPF as be}from"../../../../geometry/support/meshUtils/vertexSpaceConversion.js";import{isRelativeVertexSpace as xe,isAbsoluteVertexSpace as Se}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as j,isPlateCarree as M}from"../../../../geometry/support/spatialReferenceUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as Ce}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as we}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as Te}from"../../glTF/internal/resourceUtils.js";import{convertMeshTextureTransformToGLTF as N,getTransformMatrix as P}from"../../glTF/internal/TextureTransformUtils.js";import{debugFlags as F}from"../../support/debugFlags.js";import{Attribute as I}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Ee}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as De}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as Oe}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as ke}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as Ae,advancedMRRFactors as je,schematicMRRFactors as Me}from"../../webgl-engine/materials/pbrUtils.js";import{RibbonLineMaterial as R}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{hasEdges as Ne,createMaterial as Pe}from"../support/edgeUtils.js";import{defaultSymbolLayerMemoryComplexity as Fe}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as B,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as Ie}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Le}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Re}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ze,nanFallbackColor as Be}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as Ve,MeshFastUpdateProcessor as He}from"./MeshFastUpdateProcessor.js";import{addOlidAttribute as Ue}from"./olidUtils.js";import{SymbolComplexity as We}from"./SymbolComplexity.js";const Ge=[`mesh`];class Ke extends ze{constructor(e,t,n,r){super(e,t,n,r,Ce(t)),this._materialInfoCache=new Ve,this._fastUpdateProcessor=new He,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){if(F.DRAW_MESH_GEOMETRY_NORMALS){let e=this._context.stage.view;this._debugVertexNormalMaterial=new R({color:[1,0,1,1],width:1},e),this._debugTangentNormalMaterial=new R({color:[1,.5,0,1],width:1},e),this._debugFaceNormalMaterial=new R({color:[0,1,1,1],width:1},e)}this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,Ge,`fill on mesh-3d`))return null;let n=this.createElevationContextForGraphic(t),r=e.renderingInfo;return this._createAs3DShape(t,r,n,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:n});let t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,B)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicallyBasedRenderingChanged(){let e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateMeshTransform(e,t,n,r,i){if(!e.fastTransformUpdatesAllowed)return!1;let a=e.fastTransformUpdatesEnabled;switch(i){case 0:if(a)return!0;break;case 1:if(!a)return!0}let o=this._context.renderCoordsHelper.spatialReference,s=at,{origin:c,transform:l}=n;if(!C(t.spatialReference,p(J,c.x,c.y,c.z??0),s,o))return!1;switch(i){case void 0:a||this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context,!0);break;case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:if(this._fastUpdateProcessor.disable(e,this._materialInfoCache),t.vertexSpace.type===`local`)return!1}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);let{elevationContext:u}=e;u.centerInElevationSR=this._getCenterInElevationSR(s);let{elevationProvider:d,renderCoordsHelper:f}=this._context;return e.alignedSampledElevation=z(e,u,d.spatialReference,(e,t)=>V(e,d,u,f,t),f,s),e.updateTransform(s,l,this._context.isAsync,r),!0}computeComplexity(){if(!this._textures||this._textures.size===0)return super.computeComplexity();let e=0;for(let t of this._textures.values())e+=t.usedMemory;let t={...Fe(this.symbol,this.symbolLayer),resourceBytes:e},n=Ne(this.symbolLayer)?2:0;return new We({drawCallsPerFeature:n,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){let n=this._requiresSymbolVertexColors(),r=!!e.vertexAttributes.color,i=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:n,hasVertexColors:r,hasVertexTangents:i,unlit:!1,uid:`vc:${r},vt:${i},vct${t},svc:${n}`}}_materialProperties(e,t,n){let r=this._materialPropertiesDefault(e,n);if(!t.material)return r;let{color:i,colorTexture:a,colorTextureTransform:o,normalTexture:s,normalTextureTransform:c,doubleSided:l,alphaCutoff:u,alphaMode:d}=t.material,f=G(i),p=G(a),m=K(o),h=G(s),g=K(c);if(r.color=i,r.colorTexture=a,r.normalTexture=s,r.uid=`${r.uid},cmuid:${f},ctmuid:${p},cttuid:${m},ntmuid:${h},nttuid:${g},ds:${l},ac:${u},am:${d}`,t.material instanceof he){let{metallic:e,roughness:n,metallicRoughnessTexture:i,metallicRoughnessTextureTransform:a,emissiveColor:s,emissiveStrength:l,emissiveTexture:u,emissiveTextureTransform:d,occlusionTexture:f,occlusionTextureTransform:p,unlit:m}=t.material,h=G(i),g=K(a),_=G(s),v=G(u),y=K(d),b=G(f),ee=K(p);r.uid=[r.uid,`mrm:${e}`,`mrr:${n}`,`mrt:${h}`,`mrtt:${g}`,`emuid:${_}`,`ems:${l}`,`etmuid:${v}`,`ett:${y}`,`otmuid:${b}`,`ott:${ee}`,`unlit:${m}`].join(`,`),r.metallic=e,r.roughness=n,r.metallicRoughnessTexture=i,r.emissiveColor=m?void 0:s,r.emissiveStrength=l,r.emissiveTexture=m?void 0:u,r.occlusionTexture=f,r.unlit=m,r.colorTextureTransform=N(o),r.normalTextureTransform=N(c),r.emissiveTextureTransform=N(d),r.occlusionTextureTransform=N(p),r.metallicRoughnessTextureTransform=N(a)}return r}_getInternalTexture(e,t=!1,n=1){let r=nt(e);if(!r)return null;let i=`${e.contentHash}/${n}`,a=this._textures.get(i);if(a){let e=this._context.stage.renderView.textures,t=null,n=e.acquire(a.id);return n!=null&&!oe(n)&&(a.events.on(`unloaded`,()=>t=ae(t)),t=n),a}let o=null,s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:$e(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};return Te(r)?(o=r.data,c.preMultiplyAlpha=!1,c.encoding=r.encoding):(o=r,c.preMultiplyAlpha=n!==1,c.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),a=new De(o,c),this._textures.set(i,a),a.events.on(`loaded`,()=>this.updateComplexity()),a.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(a),a.events.on(`unloaded`,()=>{this._textures.delete(i)}),a}_setInternalMaterialTextureParameters(e,n){if(e.colorTexture!=null){let t=n.textureAlphaMode!==1,r=this._getInternalTexture(e.colorTexture,t,n.textureAlphaMode);r?(n.textureId=r.id,n.textureAlphaPremultiplied=!!r.parameters.preMultiplyAlpha):n.textureId=void 0}if(e.normalTexture&&(n.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){let r=e.emissiveColor?.toUnitRGB();n.emissiveBaseColor=ne(t(r[0]),t(r[1]),t(r[2]))}e.emissiveStrength&&(n.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(n.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(n.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(n.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,n){e.color!=null&&tt(e.color,t,n),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=P(e.colorTextureTransform),t.normalTextureTransformMatrix=P(e.normalTextureTransform);let r=e.normalTextureTransform?.scale==null?f:e.normalTextureTransform?.scale;t.normalScale=[r[0],r[1]],t.occlusionTextureTransformMatrix=P(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=P(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=P(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){let n=this._drivenProperties.color,r=this._drivenProperties.opacity;if(n)e.externalColor=ie;else{let n=t??null;if(n){let t=n.toUnitRGBA();r&&(t[3]=1),e.externalColor=t}else e.externalColor=Be}e.colorMixMode=this.symbolLayer.material?.colorMixMode??`multiply`,e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=we(this.symbolLayer?.material?.emissive?.source??`emissive`)}_getOrCreateMaterial(e,t){let n=t.material?.color,r=t.material?.colorTexture,i=t.material?.alphaMode,a=i===`blend`,o=i!==`opaque`&&(et(e)||n!=null&&n.a<1||r?.transparent||a),s=this._materialProperties(e,t,o),c=this._materialInfoCache.byUid(s.uid);if(c)return this._setInternalMaterialTextureParameters(s,c.material.parameters),c.material;let l={uid:s.uid,material:null,isComponentTransparent:o,alphaMode:t.material?t.material.alphaMode:`opaque`},u=Ae({normalTexture:s.normalTexture,metallicRoughnessTexture:s.metallicRoughnessTexture,metallicFactor:s.metallic,roughnessFactor:s.roughness,emissiveTexture:s.unlit?void 0:s.emissiveTexture,emissiveFactor:s.unlit?x:s.emissiveColor?.toUnitRGB(),occlusionTexture:s.occlusionTexture}),d={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:s.hasVertexColors,hasSymbolColors:s.hasSymbolVertexColors,hasVertexTangents:s.hasVertexTangents,ambient:x,diffuse:re,opacity:1,doubleSided:!0,doubleSidedType:`winding-order`,cullFace:0,unlit:s.unlit,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||l.isComponentTransparent};d.mrrFactors=u?Me:[s.metallic,s.roughness,je[2]],t.material&&(d.doubleSided=t.material.doubleSided,d.cullFace=t.material.doubleSided?0:2,d.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTextureAlphaMode(d,l),this._setInternalMaterialParameters(s,d,l);let f=new ke(d,this._context.spherical);return l.material=f,this._materialInfoCache.set(s.uid,l),f}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue;delete n.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{let t=e.material.parameters;this._setExternalMaterialParameters(t,r),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return Ie(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicallyBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){e.textureAlphaMode=t.alphaMode===`auto`?this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1?3:1:t.alphaMode===`opaque`?1:t.alphaMode===`mask`?2:0}_createFaceDebugNormals(e,t){let r=t.length,a=e.spatialReference.isGeographic?20015077/180:1,o=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),s=[],c=t[0].transformation,l=n(i(),c);for(let e=0;e<r;e++){let n=t[e].attributes.get(`position`);if(!n)continue;let r=n.data,i=n.indices;for(let e=0;e<i.length;e+=3)U(r,i,e,Z),Qe(r,i,e,J,Y,X),m(J,J,Y),m(J,J,X),h(J,J,1/3),g(J,J,c),_(Z,Z,l),v(Z,Z),y(Y,J,Z,o),s.push(L(this._debugFaceNormalMaterial,[J,Y]))}return s}_createPerVertexDebugVectors(e,t,a,o,s){let c=t.length,l=e.spatialReference.isGeographic?20015077/180:1,u=s*.1*Math.max(e.extent.width*l,e.extent.height*l,e.extent.zmax-e.extent.zmin),d=[],f=t[0].transformation,m=n(i(),f);a===`tangent`&&r(m,f);for(let e=0;e<c;e++){let n=t[e],r=n.attributes.get(`position`),i=n.attributes.get(a);if(!r||!i)continue;let s=r.data,c=r.indices,l=i.data,h=i.indices;for(let e=0;e<c.length;e++){let t=c[e]*3,n=h[e]*i.stride;p(J,s[t+0],s[t+1],s[t+2]),g(J,J,f),p(Y,l[n+0],l[n+1],l[n+2]),_(Y,Y,m),v(Y,Y),y(Y,J,Y,u),d.push(L(o,[J,Y]))}}return d}_createAs3DShape(e,t,n,r){let i=e.geometry;if(i.type!==`mesh`)return null;let a=this._createGeometryInfo(i,t,r);if(a==null)return null;let{geometries:o,objectTransformation:s}=a;F.DRAW_MESH_GEOMETRY_NORMALS&&o.push(...this._createPerVertexDebugVectors(i,o,`normal`,this._debugVertexNormalMaterial,1),...this._createPerVertexDebugVectors(i,o,`tangent`,this._debugTangentNormalMaterial,.5),...this._createFaceDebugNormals(i,o));let c=this._context.layerViewUid,l=new Oe({geometries:o,layerViewUid:c,graphicUid:r,isElevationSource:!0});l.transformation=s;let u=Pe(this.symbolLayer,{opacity:this._getLayerOpacity()}),d=u?new Re(o[0].material,u,this._context.slicePlaneEnabled):null,f=new Le(this,l,null,z,n,d);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=B(n.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(i),n.centerInElevationSR=this._getCenterInElevationSR(l.transformation);let{elevationProvider:p,renderCoordsHelper:m}=this._context;return f.alignedSampledElevation=z(f,n,p.spatialReference,(e,t)=>V(e,p,n,m,t),m),f}_fastTransformUpdatesAllowed(e){let{vertexSpace:t,spatialReference:n}=e;if(!xe(t))return!1;let{type:r}=t,{view:i}=this._context.graphicsCoreOwner,{isGlobal:a,isLocal:o}=i.state,s=i.spatialReference;return a&&r===`local`||o&&j(s,n)&&r===`georeferenced`&&!n.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){let t=S(),n=p(st,e[12],e[13],e[14]);return ce(n,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return e.reprojection===0&&!!e.objectTransformation}_createPositionBuffer(e,t,n){let r=n.position,i=r,a;if(t.reprojection===0)return{position:i,georeferencedPositionBuffer:a};let o=t.reprojection===1?t.transformBeforeProject:null;o&&(i=w(new Float64Array(i.length),i,o));let{normal:s,tangent:c}=n;!this._passthroughReprojectionInfo(t)&&(s||c)&&(a=i);let l=i===r||i===a?new Float64Array(i.length):i;return se(i,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:a}}_createNormalBuffer(e,t,n,r,i){let a=i.normal;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;if(s&&(o=D(o,new Float32Array(o.length),s)),r.reprojection===0)return o;if(this._context.graphicsCoreOwner.view.state.isLocal){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,0,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,0,n,e)}return o}if(n==null)return null;let c=o===a?new Float32Array(o.length):o,l=this._context.renderCoordsHelper.spatialReference;return _e(o,n,e.spatialReference,t,l,c)}_createTangentBuffer(e,t,n,r,i){let a=i.tangent;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;if(s&&(o=A(o,new Float32Array(o.length),s)),r.reprojection===0)return o;if(this._context.graphicsCoreOwner.view.state.isLocal){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,1,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,1,n,e)}return o}if(n==null)return null;let c=o===a?new Float32Array(o.length):o,l=this._context.renderCoordsHelper.spatialReference;return ve(o,n,e.spatialReference,t,l,c)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){let n=e.vertexAttributes&&e.vertexAttributes.position;if(!n)return this.logger.warn(`Mesh geometry must contain position vertex attributes`),null;let r=e.vertexAttributes.normal,i=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(r&&r.length!==n.length)return this.logger.warn(`Mesh normal vertex buffer must contain the same number of elements as the position buffer`),null;if(a&&a.length/4!=n.length/3)return this.logger.warn(`Mesh tangent vertex buffer must contain the same number of elements as the position buffer`),null;if(i&&i.length/2!=n.length/3)return this.logger.warn(`Mesh uv vertex buffer must contain the same number of elements as the position buffer`),null;let o=this._computeReprojectionInfo(e),s=o.reprojection===1&&o.convertLocalVertexSpace,c=s&&e.vertexSpace.type===`local`?be(e,e.vertexSpace,this._context.renderCoordsHelper.spatialReference):null;if(s&&!c)return this.logger.warn(`Local mesh vertex space could not be converted for rendering`),null;let{position:l,georeferencedPositionBuffer:u}=c?{position:c.position,georeferencedPositionBuffer:null}:this._createPositionBuffer(e,o,e.vertexAttributes),d=rt(e),f=this._createSymbolColorBuffer(t),p=c?c.normal:this._createNormalBuffer(e,l,u,o,e.vertexAttributes),m=c?c.tangent:this._createTangentBuffer(e,l,u,o,e.vertexAttributes),h=i,{geometryTransformation:g}=o,{transformation:_,position:v,normal:y,tangent:b}=this._passthroughReprojectionInfo(o)?{transformation:o.objectTransformation,position:l,normal:p,tangent:m}:this._expressInOriginLocalSpace(e,l,p,m,g);return{positionBuffer:v,normalBuffer:y,tangentBuffer:b,uvBuffer:h,colorBuffer:d,symbolColorBuffer:f,objectTransformation:_,geometryTransformation:g}}_computeReprojectionInfo(e){let{vertexSpace:t}=e,n=t.type===`georeferenced`,r=t.type===`local`&&this._context.graphicsCoreOwner.view.state.isGlobal,i=n?+!j(this._context.renderCoordsHelper.spatialReference,e.spatialReference):+!!r;if(Se(t))return{reprojection:i,geometryTransformation:l()};let s=t.origin,c=e.transform?.localMatrix??u;if(i===0){let t=l();return C(e.spatialReference,s,t,this._context.renderCoordsHelper.spatialReference),{reprojection:i,objectTransformation:t,geometryTransformation:d(c)}}if(r)return{reprojection:i,convertLocalVertexSpace:!0,geometryTransformation:d(c)};let f=a(l(),s);return o(f,f,c),{reprojection:i,transformBeforeProject:f,geometryTransformation:l()}}_expressInOriginLocalSpace(e,t,n,r,i){let a=this._context.renderCoordsHelper.spatialReference,c=e.origin;q[0]=c.x,q[1]=c.y,q[2]=c.z??0;let u=l();C(e.spatialReference,q,u,a),o(Q,u,i),s(Q,Q);let{position:d,normal:f,tangent:p}=e.vertexAttributes,m=t===d?new Float64Array(t.length):t;w(m,t,Q);let h=n?n===f?new Float32Array(n.length):n:null,g=r?r===p?new Float32Array(r.length):r:null;return n&&h&&D(n,h,Q),r&&g&&A(r,g,Q),{transformation:u,position:m,normal:h,tangent:g}}_validateFaces(e,t){let n=e.vertexAttributes.position.length/3,r=t.faces;if(r&&r.length>0){let e=-1;for(let t=0;t<r.length;t++){let n=r[t];n>e&&(e=n)}if(n<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(n%3!=0)return this.logger.warn(`Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)`),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent||!e.vertexAttributes?.position)return!1;let t=this._context.elevationProvider.spatialReference,n=ye(e,t??e.spatialReference);return n?(ue(n,$),!de($,this._context.clippingExtent)):!1}_createGeometryInfo(e,t,n){if(!le(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn(`Geometry spatial reference is not compatible with the view`),null;if(!this._validateVertexSpace(e)||this._isOutsideClippingArea(e))return null;let r=this._createBuffers(e,t);if(r==null)return null;let{positionBuffer:i,uvBuffer:a,colorBuffer:o,symbolColorBuffer:s,normalBuffer:l,tangentBuffer:u,objectTransformation:d,geometryTransformation:f}=r,p=e.components??ot,m=[],h=!1,g=c(J,d),_=this._context.localOriginFactory.getOrigin(g);for(let t of p){if(!this._validateFaces(e,t))return null;let r=qe(e,t);if(r.length===0)continue;let c=Je(i,l,t,r);c.didFlipNormals&&(h=!0);let d=[[`position`,new I(i,r,3,!0)],[`normal`,new I(c.normals,c.indices,3,!0)]];o&&d.push([`color`,new I(o,r,4,!0)]);let p=null;s&&(p=E(r.length),d.push([`symbolColor`,new I(s,p,4,!0)])),a&&d.push([`uv0`,new I(a,r,2,!0)]),u&&d.push([`tangent`,new I(u,r,4,!0)]);let g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:this._context.layerViewUid});g&&(p??=E(r.length),Ue(d,g,p));let v=this._getOrCreateMaterial(e,t),y=new Ee(v,d,null);y.transformation=f,y.localOrigin=_,m.push(y)}return h&&this.logger.warn(`Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals.`),m.length===0?null:{geometries:m,objectTransformation:d}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){return this._context.graphicsCoreOwner.view.state.isLocal&&e.vertexSpace.type===`local`?(this.logger.warn(`Displaying a mesh with a local vertex space in a view in local viewing mode is not supported.`),!1):!0}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class H{constructor(e,t,n){this.normals=e,this.indices=t,this.didFlipNormals=n}}function qe(e,t){return t.faces??pe(e.vertexAttributes.position.length/3)}function Je(e,t,n,r){switch(n.shading||`flat`){default:case`source`:return Xe(e,t,n,r);case`flat`:return Ye(e,r);case`smooth`:return Ze(e,r)}}function Ye(e,t){let n=T(t.length),r=Array(t.length*3);for(let i=0;i<t.length;i+=3){let a=U(e,t,i,Z);for(let e=0;e<3;e++)n[i+e]=a[e],r[i+e]=i/3}return new H(n,r,!1)}function Xe(e,t,n,r){if(t==null)return Ye(e,r);let i=!1;if(!n.trustSourceNormals)for(let n=0;n<r.length;n+=3){U(e,r,n,Z);for(let e=0;e<3;e++){let a=r[n+e]*3;J[0]=t[a],J[1]=t[a+1],J[2]=t[a+2],te(Z,J)<0&&(t[a]=-t[a],t[a+1]=-t[a+1],t[a+2]=-t[a+2],i=!0)}}return new H(t,r,i)}function Ze(e,t){let n={};for(let r=0;r<t.length;r+=3){let i=U(e,t,r,Z);for(let e=0;e<3;e++){let a=t[r+e],o=n[a];o||(o={normal:S(),count:0},n[a]=o),m(o.normal,o.normal,i),o.count++}}let r=T(t.length*3),i=Array(t.length*3);for(let e=0;e<t.length;e++){let a=n[t[e]];a.count!==1&&(v(a.normal,a.normal),a.count=1);for(let t=0;t<3;t++)r[e*3+t]=a.normal[t];i[e]=e}return new H(r,i,!1)}function Qe(e,t,n,r,i,a){let o=t[n]*3,s=t[n+1]*3,c=t[n+2]*3;r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],a[0]=e[c],a[1]=e[c+1],a[2]=e[c+2]}function U(e,t,n,r){return Qe(e,t,n,J,Y,X),b(Y,Y,J),b(X,X,J),ee(J,Y,X),v(r,J),r}function $e(e=`repeat`){if(typeof e==`string`){let t=W(e);return{s:t,t}}return{s:W(e.horizontal),t:W(e.vertical)}}function W(e){switch(e){case`clamp`:return 33071;case`mirror`:return 33648;default:return 10497}}function et(e){let t=e.vertexAttributes.color;if(t==null)return!1;for(let e=3;e<t.length;e+=4)if(t[e]!==255)return!0;return!1}function tt(e,t,n){t.diffuse=e.toUnitRGB(),t.opacity=n.alphaMode===`opaque`?1:e.a}function nt(e){return e.data??e.url}function G(t){return t==null?`-`:t instanceof e?t.toHex():t.contentHash}function K(e){let{offset:t,scale:n,rotation:r}=e??it;return`${t[0]},${t[1]},${r},${n[0]},${n[1]}`}function rt(e){return e.vertexAttributes.color}const it=new ge,q=S(),J=S(),Y=S(),X=S(),Z=S(),Q=l(),at=l(),$=fe(),ot=[new me],st=S();export{Ke as Graphics3DMeshFillSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{has}from"../../../../applications/Components/baUtils.js";import{ZEROS as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{fromBuffer as n,intersectsClippingArea as r,empty as i,expandWithAABB as a,create as o}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as u}from"../../../../geometry/support/Indices.js";import{isDrivenOpacityFallbackAlwaysOpaque as d}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{createGeometry as f}from"../../support/engineContent/line.js";import{loadTessellationUtils as p,preloadedPolygonToRenderInfoElevationAligned as m,preloadedPolygonToRenderInfoDraped as h}from"../../support/renderInfoUtils/polygon.js";import{Object3D as g}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as _}from"../../webgl-engine/lib/RenderGeometry.js";import{isScreenSizePerspectiveEnabled as v}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{getStipplePatternForLinePattern as y}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as b}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as x}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{initFastSymbolUpdatesState as S,updateFastSymbolUpdatesState as C,getAttributeValue as w,ConvertOptions as T}from"../support/FastSymbolUpdates.js";import{createMaterial as E,uvElevationAligner as D}from"../support/patternUtils.js";import{writeMapSpaceUVCoordsPerConnectedPart as O,writeMapSpaceUVCoordsDraped as k}from"../support/uvUtils.js";import{elevationModeChangeUpdateType as A,needsElevationUpdates2D as j}from"./elevationAlignmentUtils.js";import{PlateLayoutInformation as M,updatePlateNormals as N}from"./extrudePolygon.js";import{Graphics3DDrapedGraphicLayer as P}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as F}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as I}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as L}from"./graphicUtils.js";import{parseCapType as R,computeSymbolLayerIndex as z}from"./lineUtils.js";import{geometryAsPolygon as B,createColorGeometry as V,PolygonCreationDataBase as H}from"./polygonUtils.js";const U=[`polyline`,`polygon`,`extent`];class W extends I{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,d(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=S(this._context.renderer,this._vvConvertOptions),await p()}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _shadingEnabled(){return!this.draped&&!!has(`enable-feature:emissive-on-non-volumetric`)}_createMaterials(){if(this._materials.length>0)return;let{_materialColor:e,draped:n,_shadingEnabled:r}=this,i=this._getCombinedOpacityAndColor(e);this._materials[0]=E(this.symbolLayer,{color:i,forceTransparentMode:this.needsDrivenTransparentPass,hasVertexColors:this._drivenProperties.color||this._drivenProperties.opacity,draped:n,shading:+!!r,castShadows:r&&this.symbolLayer.castShadows,hasSlicePlane:this._context.slicePlaneEnabled,emissiveStrength:this._emissiveStrength,...this._fastUpdates?.materialParameters},this._context),this._needsUV=this._materials[0]instanceof b;let a=this.symbolLayer.outline;if(J(a)){let e=y(a.pattern),n=R(a.pattern?a.patternCap||`butt`:`square`);this._materials[1]=new x({color:this._getOutlineColor(),width:t(a.size),polygonOffset:3,polygonOffsetIndex:z(this._renderPriority,this._renderPriorityStep),shadingEnabled:r,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:e,cap:n,screenSizePerspective:this._outlineScreenSizePerspective},this.view)}}get _outlineScreenSizePerspective(){return!this.draped&&v(this._context.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,U,this.symbolLayer.type))return null;let n=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),r=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(r.mode===`on-the-ground`),this._createMaterials(),this.draped?this._createAsOverlay(e.renderingInfo,t,n):this._createAs3DShape(e.renderingInfo,t,n,r)}applyRendererDiff(e,t){for(let n in e.diff)if(n===`visualVariables`){if(C(this._fastUpdates,t,this._vvConvertOptions))this._materials[0]?.setParameters(this._fastUpdates.materialParameters);else return 0}else return 0;return 2}layerOpacityChanged(){if(this._materials[0]!=null){let e=this._materials[0].parameters.color,t=this._materialColor,n=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],n],forceTransparentMode:this.needsDrivenTransparentPass})}if(this._materials[1]!=null){let e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerScreenSizePerspectiveChanged(){this._materials[1]?.setParameters({screenSizePerspective:this._outlineScreenSizePerspective})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=A(W.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=j(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){let e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicallyBasedRenderingChanged(){return!0}_containsRenderableGeometry(e){return e.polygonIndexCount>0?!0:this._materials[1]==null?!1:e.outline.output===`vertex-data`?e.outline.outlines.length>0:e.outlineIndexCount>0}_createAs3DShape(e,t,n,r){let i=B(t.geometry);if(!i)return null;let a=this._shadingEnabled,o=m(i,this._context.elevationProvider,this._context.renderCoordsHelper,r,{projectIfNearlyVertical:!0,requireNormals:a,outlineOutput:`vertex-data`,owner:this._context.layer});if(o==null)return null;let d=new K(o,n,this._context.layerViewUid,t.uid),f=d.renderInfo.vertexCount;if(this._needsUV){d.uvMapSpace=l(f*4,!0),d.textureElementIndices=Array(f),d.boundingRect=s(9*(d.renderInfo.polygonIndices.length/3));let e=O(d.uvMapSpace,d.boundingRect,d.textureElementIndices,d.renderInfo.positions,d.renderInfo.polygonIndices,this._context.renderCoordsHelper);d.boundingRect=c(d.boundingRect,0,9*e),d.boundingRectIndices=u(e)}if(d.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(d),this._createAs3DShapeFill(e,d),this._materials[1]&&this._createAs3DShapeOutline(d),this._logGeometryCreationWarnings(d.renderInfo,i.rings,`rings`,`FillSymbol3DLayer`),d.outGeometries.length===0)return null;let p=new g({geometries:d.outGeometries,castShadow:this._shadingEnabled,layerViewUid:this._context.layerViewUid,graphicUid:t.uid}),h=d.plateLayout,_=new F(this,p,null,(e,t,n,r,i)=>D(e,t,n,r,i,h),r);return _.alignedSampledElevation=d.renderInfo.sampledElevation,_.needsElevationUpdates=j(r.mode),_}_createAs3DShapeFill(e,t){let{mapPositions:i,positions:a,polygonIndices:o,polygonIndexCount:s,vertexCount:c,compressedNormals:l}=t.renderInfo;if(s===0||this._context.clippingExtent!=null&&(n(i,G),!r(G,this._context.clippingExtent)))return;let u=this._fastUpdates?.visualVariables.color,d=V({material:this._materials[0],indices:o,mapPositions:i,attributeData:{position:a,color:u?null:t.color,compressedNormals:l,colorFeature:u?w(u,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,boundingRect:this._needsUV?t.boundingRect:null,textureElementIndices:this._needsUV?t.textureElementIndices:null,boundingRectIndices:this._needsUV?t.boundingRectIndices:null,olidColor:t.olidColor}});t.plateLayout=new M(c,0,null,0,s/3),N(d,t.plateLayout),t.outGeometries.push(d)}_createAs3DShapeOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;if(i!=null&&i.length!==0)for(let{mapPositions:t,position:a}of i){if(this._context.clippingExtent!=null&&(n(t,G),!r(G,this._context.clippingExtent)))continue;let i=f(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:t,attributeData:{position:a}},e.olidColor);e.outGeometries.push(i)}}_createAsOverlay(e,t,n){let r=B(t.geometry);if(r==null)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,this._materials[1]!=null&&(this._materials[1].renderPriority=this._renderPriority);let a=h(r,{drapedSpatialReference:this._context.overlaySR,outlineOutput:`vertex-data`,owner:this._context.layer});if(a==null)return null;let o=new q(a,n,this._context.layerViewUid,t.uid);return this._needsUV&&(o.uvMapSpace=l(o.renderInfo.vertexCount*4,!0),k(o.uvMapSpace,o.renderInfo.positions,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.isGlobal)),o.outBoundingBox=i(),o.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._materials[1]&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderInfo,r.rings,`rings`,`FillSymbol3DLayer`),new P(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){let{positions:i,polygonIndices:o,polygonIndexCount:s}=t.renderInfo;if(s===0)return;let c=n(i,G);if(!r(c,this._context.clippingExtent))return;a(t.outBoundingBox,c);let l=this._fastUpdates?.visualVariables.color,u=V({material:this._materials[0],indices:o,attributeData:{position:i,color:l?null:t.color,colorFeature:l?w(l,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,olidColor:t.olidColor}});t.outGeometries.push(new _(u,t))}_createAsOverlayOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;for(let{position:t}of i){if(n(t,G),!r(G,this._context.clippingExtent))continue;a(e.outBoundingBox,G);let i=f(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:t}},e.olidColor);e.outGeometries.push(new _(i,e))}}_getOutlineOpacity(){let e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(e==null?0:e.a)}_getOutlineColor(){let e=this.symbolLayer?.outline?.color,t=this._getOutlineOpacity();return L(e?.toUnitRGB(),t)}test(){return{...super.test(),createAsOverlay:(e,t,n)=>this._createAsOverlay(e,t,n),createAs3DShape:(e,t,n,r)=>this._createAs3DShape(e,t,n,r)}}get _vvConvertOptions(){return new T({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:this._materialColor?.toUnitRGBA()??e})}}const G=o();class K extends H{constructor(e,t,n,r){super(e,n,r),this.color=t}}class q extends H{constructor(e,t,n,r){super(e,n,r),this.color=t}}function J(e){return e?.size!=null&&e.size>0&&e.color!=null&&(e.pattern==null||e.pattern.type!==`style`||e.pattern.style!==`none`)}export{W as Graphics3DPolygonFillSymbolLayer};
2
+ import{has}from"../../../../applications/Components/baUtils.js";import{ZEROS as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{fromBuffer as n,intersectsClippingArea as r,empty as i,expandWithAABB as a,create as o}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as s,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as u}from"../../../../geometry/support/Indices.js";import{isDrivenOpacityFallbackAlwaysOpaque as d}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{createGeometry as f}from"../../support/engineContent/line.js";import{loadTessellationUtils as p,preloadedPolygonToRenderInfoElevationAligned as m,preloadedPolygonToRenderInfoDraped as h}from"../../support/renderInfoUtils/polygon.js";import{Object3D as g}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as _}from"../../webgl-engine/lib/RenderGeometry.js";import{isScreenSizePerspectiveEnabled as v}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{getStipplePatternForLinePattern as y}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as b}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as x}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{initFastSymbolUpdatesState as S,updateFastSymbolUpdatesState as C,getAttributeValue as w,ConvertOptions as T}from"../support/FastSymbolUpdates.js";import{createMaterial as E,uvElevationAligner as D}from"../support/patternUtils.js";import{writeMapSpaceUVCoordsPerConnectedPart as O,writeMapSpaceUVCoordsDraped as k}from"../support/uvUtils.js";import{elevationModeChangeUpdateType as A,needsElevationUpdates2D as j}from"./elevationAlignmentUtils.js";import{PlateLayoutInformation as M,updatePlateNormals as N}from"./extrudePolygon.js";import{Graphics3DDrapedGraphicLayer as P}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as F}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as I}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as L}from"./graphicUtils.js";import{parseCapType as R,computeSymbolLayerIndex as z}from"./lineUtils.js";import{geometryAsPolygon as B,createColorGeometry as V,PolygonCreationDataBase as H}from"./polygonUtils.js";const U=[`polyline`,`polygon`,`extent`];class W extends I{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,d(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=S(this._context.renderer,this._vvConvertOptions),await p()}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _shadingEnabled(){return!this.draped&&!!has(`enable-feature:emissive-on-non-volumetric`)}_createMaterials(){if(this._materials.length>0)return;let{_materialColor:e,draped:n,_shadingEnabled:r}=this,i=this._getCombinedOpacityAndColor(e);this._materials[0]=E(this.symbolLayer,{color:i,forceTransparentMode:this.needsDrivenTransparentPass,hasVertexColors:this._drivenProperties.color||this._drivenProperties.opacity,draped:n,shading:+!!r,castShadows:r&&this.symbolLayer.castShadows,hasSlicePlane:this._context.slicePlaneEnabled,emissiveStrength:this._emissiveStrength,...this._fastUpdates?.materialParameters},this._context),this._needsUV=this._materials[0]instanceof b;let a=this.symbolLayer.outline;if(J(a)){let e=y(a.pattern),n=R(a.pattern?a.patternCap||`butt`:`square`);this._materials[1]=new x({color:this._getOutlineColor(),width:t(a.size),polygonOffset:3,polygonOffsetIndex:z(this._renderPriority,this._renderPriorityStep),shadingEnabled:r,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:e,cap:n,screenSizePerspective:this._outlineScreenSizePerspective},this.view)}}get _outlineScreenSizePerspective(){return!this.draped&&v(this._context.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,U,this.symbolLayer.type))return null;let n=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),r=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(r.mode===`on-the-ground`),this._createMaterials(),this.draped?this._createAsOverlay(e.renderingInfo,t,n):this._createAs3DShape(e.renderingInfo,t,n,r)}applyRendererDiff(e,t){for(let n in e.diff)if(n===`visualVariables`){if(C(this._fastUpdates,t,this._vvConvertOptions))this._materials[0]?.setParameters(this._fastUpdates.materialParameters);else return 0}else return 0;return 2}layerOpacityChanged(){if(this._materials[0]!=null){let e=this._materials[0].parameters.color,t=this._materialColor,n=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],n],forceTransparentMode:this.needsDrivenTransparentPass})}if(this._materials[1]!=null){let e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerScreenSizePerspectiveChanged(){this._materials[1]?.setParameters({screenSizePerspective:this._outlineScreenSizePerspective})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=A(W.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=j(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){let e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicallyBasedRenderingChanged(){return!0}_containsRenderableGeometry(e){return e.polygonIndexCount>0?!0:this._materials[1]==null?!1:e.outline.output===`vertex-data`?e.outline.outlines.length>0:e.outlineIndexCount>0}_createAs3DShape(e,t,n,r){let i=B(t.geometry);if(!i)return null;let a=this._shadingEnabled,o=m(i,this._context.elevationProvider,this._context.renderCoordsHelper,r,{projectIfNearlyVertical:!0,requireNormals:a,outlineOutput:`vertex-data`,owner:this._context.layer});if(o==null)return null;let d=new K(o,n,this._context.layerViewUid,t.uid),f=d.renderInfo.vertexCount;if(this._needsUV){d.uvMapSpace=l(f*4,!0),d.textureElementIndices=Array(f),d.boundingRect=s(9*(d.renderInfo.polygonIndices.length/3));let e=O(d.uvMapSpace,d.boundingRect,d.textureElementIndices,d.renderInfo.positions,d.renderInfo.polygonIndices,this._context.renderCoordsHelper);d.boundingRect=c(d.boundingRect,0,9*e),d.boundingRectIndices=u(e)}if(d.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(d),this._createAs3DShapeFill(e,d),this._materials[1]&&this._createAs3DShapeOutline(d),this._logGeometryCreationWarnings(d.renderInfo,i.rings,`rings`,`FillSymbol3DLayer`),d.outGeometries.length===0)return null;let p=new g({geometries:d.outGeometries,castShadows:this._shadingEnabled,layerViewUid:this._context.layerViewUid,graphicUid:t.uid}),h=d.plateLayout,_=new F(this,p,null,(e,t,n,r,i)=>D(e,t,n,r,i,h),r);return _.alignedSampledElevation=d.renderInfo.sampledElevation,_.needsElevationUpdates=j(r.mode),_}_createAs3DShapeFill(e,t){let{mapPositions:i,positions:a,polygonIndices:o,polygonIndexCount:s,vertexCount:c,compressedNormals:l}=t.renderInfo;if(s===0||this._context.clippingExtent!=null&&(n(i,G),!r(G,this._context.clippingExtent)))return;let u=this._fastUpdates?.visualVariables.color,d=V({material:this._materials[0],indices:o,mapPositions:i,attributeData:{position:a,color:u?null:t.color,compressedNormals:l,colorFeature:u?w(u,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,boundingRect:this._needsUV?t.boundingRect:null,textureElementIndices:this._needsUV?t.textureElementIndices:null,boundingRectIndices:this._needsUV?t.boundingRectIndices:null,olidColor:t.olidColor}});t.plateLayout=new M(c,0,null,0,s/3),N(d,t.plateLayout),t.outGeometries.push(d)}_createAs3DShapeOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;if(i!=null&&i.length!==0)for(let{mapPositions:t,position:a}of i){if(this._context.clippingExtent!=null&&(n(t,G),!r(G,this._context.clippingExtent)))continue;let i=f(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:t,attributeData:{position:a}},e.olidColor);e.outGeometries.push(i)}}_createAsOverlay(e,t,n){let r=B(t.geometry);if(r==null)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,this._materials[1]!=null&&(this._materials[1].renderPriority=this._renderPriority);let a=h(r,{drapedSpatialReference:this._context.overlaySR,outlineOutput:`vertex-data`,owner:this._context.layer});if(a==null)return null;let o=new q(a,n,this._context.layerViewUid,t.uid);return this._needsUV&&(o.uvMapSpace=l(o.renderInfo.vertexCount*4,!0),k(o.uvMapSpace,o.renderInfo.positions,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.isGlobal)),o.outBoundingBox=i(),o.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._materials[1]&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderInfo,r.rings,`rings`,`FillSymbol3DLayer`),new P(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){let{positions:i,polygonIndices:o,polygonIndexCount:s}=t.renderInfo;if(s===0)return;let c=n(i,G);if(!r(c,this._context.clippingExtent))return;a(t.outBoundingBox,c);let l=this._fastUpdates?.visualVariables.color,u=V({material:this._materials[0],indices:o,attributeData:{position:i,color:l?null:t.color,colorFeature:l?w(l,e.color):null,uvMapSpace:this._needsUV?t.uvMapSpace:null,olidColor:t.olidColor}});t.outGeometries.push(new _(u,t))}_createAsOverlayOutline(e){if(this._materials[1]==null)return;let{outline:t}=e.renderInfo;if(t.output!==`vertex-data`)return;let{outlines:i}=t;for(let{position:t}of i){if(n(t,G),!r(G,this._context.clippingExtent))continue;a(e.outBoundingBox,G);let i=f(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:t}},e.olidColor);e.outGeometries.push(new _(i,e))}}_getOutlineOpacity(){let e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(e==null?0:e.a)}_getOutlineColor(){let e=this.symbolLayer?.outline?.color,t=this._getOutlineOpacity();return L(e?.toUnitRGB(),t)}test(){return{...super.test(),createAsOverlay:(e,t,n)=>this._createAsOverlay(e,t,n),createAs3DShape:(e,t,n,r)=>this._createAs3DShape(e,t,n,r)}}get _vvConvertOptions(){return new T({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:this._materialColor?.toUnitRGBA()??e})}}const G=o();class K extends H{constructor(e,t,n,r){super(e,n,r),this.color=t}}class q extends H{constructor(e,t,n,r){super(e,n,r),this.color=t}}function J(e){return e?.size!=null&&e.size>0&&e.color!=null&&(e.pattern==null||e.pattern.type!==`style`||e.pattern.style!==`none`)}export{W as Graphics3DPolygonFillSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{toRadian as e}from"../../../../core/libs/gl-matrix-2/math/common.js";import{fromValues as t,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{getMetersPerUnitForSR as a}from"../../../../core/units.js";import{fromBuffer as o,intersectsClippingArea as s,empty as c,expandWithAABB as l,create as u,center as d}from"../../../../geometry/support/aaBoundingBox.js";import{empty as f,expandXYInPlace as p,create as m}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec3f as h,BufferViewVec2f as g,BufferViewVec4u8 as _}from"../../../../geometry/support/buffer/BufferView.js";import{loadTessellationUtils as v,preloadedPolygonToRenderInfoElevationAligned as y,preloadedPolygonToRenderInfoDraped as b}from"../../support/renderInfoUtils/polygon.js";import{BufferGeometry as x}from"../../webgl-engine/lib/BufferGeometry.js";import{BufferObject3D as S}from"../../webgl-engine/lib/BufferObject3D.js";import{Buffers as C}from"../../webgl-engine/lib/Buffers.js";import{wavePresets as w}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";import{Parameters as T,WaterMaterial as E,getWaterLayout as D}from"../../webgl-engine/materials/WaterMaterial.js";import{perBufferVertexElevationAligner as O}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as k,needsElevationUpdates2D as A}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as j}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as M}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as N}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as P,PolygonCreationDataBase as F}from"./polygonUtils.js";const I=[`polyline`,`polygon`,`extent`];class L extends N{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r)}async doLoad(){await v()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(n.mode===`on-the-ground`),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,n,t.uid)}ensureMaterial(){if(this._materials[0])return;let e=new T,n=this.symbolLayer.color.toUnitRGBA();n[3]*=this._getLayerOpacity(),e.color=n,e.transparent=n[3]<1||this.needsDrivenTransparentPass,e.waveDirection=this.symbolLayer.waveDirection==null?t(0,0):R(this.symbolLayer.waveDirection);let r=this.symbolLayer.waveStrength+`-`+this.symbolLayer.waterbodySize,i=w[r];e.waveStrength=i.waveStrength,e.waveTextureRepeat=i.textureRepeat,e.waveVelocity=i.waveVelocity,e.flowStrength=i.perturbationStrength,e.hasSlicePlane=this._context.slicePlaneEnabled,e.draped=this.draped,e.useIndexing=!0,this._materials[0]=new E(e,this._context)}layerOpacityChanged(){if(this._materials[0]==null)return;let e=this._materials[0].parameters.color,t=this.symbolLayer.color.a*this._getLayerOpacity(),n=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:n})}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=k(L.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=A(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicallyBasedRenderingChanged(){return!0}get needsDrivenTransparentPass(){return!1}_createAs3DShape(e,t,n){let r=P(e.geometry);if(r==null)return null;let i=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t,{owner:this._context.layer});if(i==null)return null;let a=new W(i,this._context.layerViewUid,e.uid);if(a.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderInfo,r.rings,`rings`,`WaterSymbol3DLayer`),a.outGeometries.length===0)return null;let o=new S({geometries:a.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:n}),s=new j(this,o,null,O,t);return s.alignedSampledElevation=a.renderInfo.sampledElevation,s.needsElevationUpdates=A(t.mode),s}_create3DShapeGeometries(e){let{mapPositions:t}=e.renderInfo;if(e.renderInfo.polygonIndexCount===0||this._context.clippingExtent!=null&&(o(t,V),!s(V,this._context.clippingExtent)))return;let n=z(e.renderInfo,this._materials[0],this._context.localOriginFactory,this._context.elevationProvider.spatialReference,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}_createAsOverlay(e){let t=P(e.geometry);if(t==null)return null;this._materials[0].renderPriority=this._renderPriority;let n=b(t,{drapedSpatialReference:this._context.overlaySR,owner:this._context.layer});if(n==null)return null;let r=new G(n,this._context.layerViewUid,e.uid);return r.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(r),r.outBoundingBox=c(),this._createAsOverlayWater(r),this._logGeometryCreationWarnings(r.renderInfo,t.rings,`rings`,`WaterSymbol3DLayer`),r.outGeometries.length===0?null:new M(this,r.outGeometries,r.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){let{positions:t}=e.renderInfo;if(o(t,V),!s(V,this._context.clippingExtent)||(l(e.outBoundingBox,V),e.renderInfo.polygonIndexCount===0))return;let n=z(e.renderInfo,this._materials[0],this._context.drapeSourceRenderer.rendererContext.localOriginFactory,this._context.overlaySR,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}function R(t){let r=n(),i=e(t);return r[0]=Math.sin(i),r[1]=Math.cos(i),r}function z(e,t,n,r,s,c,l){let{positions:u,polygonIndices:m,vertexCount:v}=e,y=`mapPositions`in e?e.mapPositions:null,b=y??u;o(u,V),d(V,U);let S=n.getOrigin(U),w=D().createBuffer(v),T=w.getField(`position`,h),E=w.getField(`uv0`,g),O=w.getField(`olidColor`,_),k=a(r);f(H);for(let e=0;e<v;e++)p(H,b[e*3],b[e*3+1]);i(H,H,k);let[A,j]=H,M=A-A%B,N=j-j%B,P=S.vec3;for(let e=0;e<v;e++){let t=e*3;T.setValues(e,u[t]-P[0],u[t+1]-P[1],u[t+2]-P[2]),E.setValues(e,(b[t]*k-M)/B,(b[t+1]*k-N)/B),O!=null&&s!=null&&O.setVec(e,s)}let F=new x(t,new C(w,void 0,m),S,y);return F.layerViewUid=c,F.graphicUid=l,F}const B=100,V=u(),H=m(),U=r();class W extends F{}class G extends F{}export{L as Graphics3DWaterSymbolLayer,z as createWaterGeometry,R as headingVectorFromAngle};
2
+ import{toRadian as e}from"../../../../core/libs/gl-matrix-2/math/common.js";import{fromValues as t,create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{getMetersPerUnitForSR as a}from"../../../../core/units.js";import{fromBuffer as o,intersectsClippingArea as s,empty as c,expandWithAABB as l,create as u,center as d}from"../../../../geometry/support/aaBoundingBox.js";import{empty as f,expandXYInPlace as p,create as m}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec3f as h,BufferViewVec2f as g,BufferViewVec4u8 as _}from"../../../../geometry/support/buffer/BufferView.js";import{loadTessellationUtils as v,preloadedPolygonToRenderInfoElevationAligned as y,preloadedPolygonToRenderInfoDraped as b}from"../../support/renderInfoUtils/polygon.js";import{BufferGeometry as x}from"../../webgl-engine/lib/BufferGeometry.js";import{BufferObject3D as S}from"../../webgl-engine/lib/BufferObject3D.js";import{Buffers as C}from"../../webgl-engine/lib/Buffers.js";import{wavePresets as w}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";import{Parameters as T,WaterMaterial as E,getWaterLayout as D}from"../../webgl-engine/materials/WaterMaterial.js";import{perBufferVertexElevationAligner as O}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as k,needsElevationUpdates2D as A}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as j}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as M}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as N}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as P,PolygonCreationDataBase as F}from"./polygonUtils.js";const I=[`polyline`,`polygon`,`extent`];class L extends N{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r)}async doLoad(){await v()}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;let n=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(n.mode===`on-the-ground`),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,n,t.uid)}ensureMaterial(){if(this._materials[0])return;let e=new T,n=this.symbolLayer.color.toUnitRGBA();n[3]*=this._getLayerOpacity(),e.color=n,e.transparent=n[3]<1||this.needsDrivenTransparentPass,e.waveDirection=this.symbolLayer.waveDirection==null?t(0,0):R(this.symbolLayer.waveDirection);let r=this.symbolLayer.waveStrength+`-`+this.symbolLayer.waterbodySize,i=w[r];e.waveStrength=i.waveStrength,e.waveTextureRepeat=i.textureRepeat,e.waveVelocity=i.waveVelocity,e.flowStrength=i.perturbationStrength,e.hasSlicePlane=this._context.slicePlaneEnabled,e.draped=this.draped,e.castShadows=this.symbolLayer.castShadows,e.useIndexing=!0,this._materials[0]=new E(e,this._context)}layerOpacityChanged(){if(this._materials[0]==null)return;let e=this._materials[0].parameters.color,t=this.symbolLayer.color.a*this._getLayerOpacity(),n=t<1||this.needsDrivenTransparentPass;this._materials[0].setParameters({color:[e[0],e[1],e[2],t],transparent:n})}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=k(L.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=A(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicallyBasedRenderingChanged(){return!0}get needsDrivenTransparentPass(){return!1}_createAs3DShape(e,t,n){let r=P(e.geometry);if(r==null)return null;let i=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t,{owner:this._context.layer});if(i==null)return null;let a=new W(i,this._context.layerViewUid,e.uid);if(a.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderInfo,r.rings,`rings`,`WaterSymbol3DLayer`),a.outGeometries.length===0)return null;let o=new S({geometries:a.outGeometries,castShadows:this.symbolLayer.castShadows,layerViewUid:this._context.layerViewUid,graphicUid:n}),s=new j(this,o,null,O,t);return s.alignedSampledElevation=a.renderInfo.sampledElevation,s.needsElevationUpdates=A(t.mode),s}_create3DShapeGeometries(e){let{mapPositions:t}=e.renderInfo;if(e.renderInfo.polygonIndexCount===0||this._context.clippingExtent!=null&&(o(t,V),!s(V,this._context.clippingExtent)))return;let n=z(e.renderInfo,this._materials[0],this._context.localOriginFactory,this._context.elevationProvider.spatialReference,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}_createAsOverlay(e){let t=P(e.geometry);if(t==null)return null;this._materials[0].renderPriority=this._renderPriority;let n=b(t,{drapedSpatialReference:this._context.overlaySR,owner:this._context.layer});if(n==null)return null;let r=new G(n,this._context.layerViewUid,e.uid);return r.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(r),r.outBoundingBox=c(),this._createAsOverlayWater(r),this._logGeometryCreationWarnings(r.renderInfo,t.rings,`rings`,`WaterSymbol3DLayer`),r.outGeometries.length===0?null:new M(this,r.outGeometries,r.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){let{positions:t}=e.renderInfo;if(o(t,V),!s(V,this._context.clippingExtent)||(l(e.outBoundingBox,V),e.renderInfo.polygonIndexCount===0))return;let n=z(e.renderInfo,this._materials[0],this._context.drapeSourceRenderer.rendererContext.localOriginFactory,this._context.overlaySR,e.olidColor,e.layerViewUid,e.graphicUid);e.outGeometries.push(n)}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}function R(t){let r=n(),i=e(t);return r[0]=Math.sin(i),r[1]=Math.cos(i),r}function z(e,t,n,r,s,c,l){let{positions:u,polygonIndices:m,vertexCount:v}=e,y=`mapPositions`in e?e.mapPositions:null,b=y??u;o(u,V),d(V,U);let S=n.getOrigin(U),w=D().createBuffer(v),T=w.getField(`position`,h),E=w.getField(`uv0`,g),O=w.getField(`olidColor`,_),k=a(r);f(H);for(let e=0;e<v;e++)p(H,b[e*3],b[e*3+1]);i(H,H,k);let[A,j]=H,M=A-A%B,N=j-j%B,P=S.vec3;for(let e=0;e<v;e++){let t=e*3;T.setValues(e,u[t]-P[0],u[t+1]-P[1],u[t+2]-P[2]),E.setValues(e,(b[t]*k-M)/B,(b[t+1]*k-N)/B),O!=null&&s!=null&&O.setVec(e,s)}let F=new x(t,new C(w,void 0,m),S,y);return F.layerViewUid=c,F.graphicUid=l,F}const B=100,V=u(),H=m(),U=r();class W extends F{}class G extends F{}export{L as Graphics3DWaterSymbolLayer,z as createWaterGeometry,R as headingVectorFromAngle};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import t from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{Obb as o}from"../../support/orientedBoundingBox.js";import{NodeBoundingData as s,Node as c,NodeTraversalState as l}from"./I3SNode.js";import{addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as d}from"./ValidatedNode.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class m{get _useNodePages(){return this._pageSize>0}constructor(e,n,r,i,a,o,c,l,u,d,f,m,h,_,y,b){if(this._layer=e,this._groundNavigationCheckDistance=r,this._requester=a,this._clientNodeLoader=o,this._viewportQueries=c,this._logger=l,this.holeFilling=u,this._isLoaded=d,this._isReloading=f,this._shouldLoadNode=m,this._enable=h,this._needsUpdate=_,this._computeVisibilityObb=y,this._computeNodeFiltering=b,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix=``,this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new t({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=e.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=n,e.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,i.type===`page`){let e=i.rootPage;switch(this.urlPrefix=i.urlPrefix,this._pageSize=i.pageSize,i.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(i.rootIndex,i.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[i.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=i.rootIndex;this._addPage(S(i.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(i.type===`node`){this.urlPrefix=i.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:i.rootNode.mbs,obb:i.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:i.rootNode.mbs,obb:i.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new s(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new s(i.rootNode.id),-1);let t=this._validateNode(i.rootNode.id,i.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new s(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let t=this.urlPrefix+e;this._requester.request(t,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(t=>{this._loadingPages.delete(e),n(t)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,t))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),this._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,l=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<l;e++)n.push(t.children[e]);let u=`${t.index}`,d=o.fromJSON(t.obb),p=new i(d.getCenter(N),d.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new c(u,w(a,e,this._pageSize),p,l,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,d);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,l,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let l=new c(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?o.fromJSON(e.obb):null);s.node=l,l.visibilityObbInRenderSR=this._computeVisibilityObb(l);let u=s.nodeBoundingData;return u!=null&&(u.serviceMbsInIndexSR??=e.mbs,l.shareServiceBVsInRenderSRWith(u),u.visibilityObbInRenderSR=l.visibilityObbInRenderSR),l}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new a,o=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);o||=!r}if(n.childCount===0||o){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:s,maxElevation:c}=r;return s===i.minElevation&&c===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=!0,i=new D,a=new O,o=this._imModificationUncategorized;o.clear();let s=new Set,c=0;this.traverseVisible((s,l,u)=>{let d=e=>{this._shouldLoadNode(e)&&e.childCount&&(r=!1)};if(!l){let e=S(s,this._pageSize),t=this._getNodeLoadPriority(s);t===1/0&&(t=this._getNodeLoadPriority(u)),h.set(e,Math.max(t,h.get(e)||0)),!this._loadingPages.has(e)&&!this._failedPages.has(e)&&(this._missingPagesAndNodes.add(e),++c),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let{node:f,childCount:p}=l;if(this._updateNodeFeatureEstimate(f,a),!f){let e=this._getNodeLoadPriority(s);!this._loadingNodes.has(s)&&!this._failedNodes.has(s)&&(this._missingPagesAndNodes.add(s),h.set(s,e)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e);return}let m=this._getPage(s);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<p;e++){let t=m.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(f.failed||f.resources.isEmpty){d(f);return}if(this._isLoaded(s)){if(i.known+=f.memory,++i.knownNodes,d(f),this._shouldLoadNode(f)||(i.unremoved+=f.memory),this._needsUpdate(f)){let e=this._getNodeLoadPriority(s);h.set(s,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(s)}return}if(f.memory&&(i.known+=f.memory,++i.knownNodes),!this._shouldLoadNode(f)){this._isReloading(s)&&this._updates.remove.push(s);return}if(d(f),f.memory?(i.missing+=f.memory,i.known+=f.memory,++i.knownNodes):++i.missingNodes,e.includes(f.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(s)),this._updates.cancel=this._updates.cancel.filter(e=>e!==f.index);return}if(!t.done&&this._enable(f)){t.madeProgress();return}let g=this._getNodeLoadPriority(s);h.set(s,g),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,g),this._updates.add.push(s),this.layerHasModifications&&n&&f!=null&&f.imModificationImpact===4&&o.push(s)},s),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(s,c),this._handleModifications(n,o),this._updateUnloadedMemoryEstimate(i),this._featureEstimate.estimate=this._computeFeatureEstimate(a),this._featureEstimate.leavesReached=r,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new l(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let t=this._getNodeDescriptor(e);if(t.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=t.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(t=>{o(),n(t)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!t||t.id!==e)return this._logger.error(`#validateNode()`,this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error(`#validateNode()`,this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,a=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${a?.[t]?.key??`f_${t}`}/0`))&&this._logger.warn(`#validateNode()`,this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn(`#validateNode()`,this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);let c=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,l=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new s(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?o.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new d(e,new i(t.mbs),c,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{constructor(e){this.missing=e,this.update=new t({deallocator:null}),this.add=new t({deallocator:null}),this.remove=new t({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function _(e){return u(e,-2)}function v(e){return u(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=e(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};
2
+ import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import t from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{projectBoundingSphere as r}from"../../../../geometry/projection/projectBoundingSphere.js";import{Sphere as i}from"../../../../geometry/support/sphere.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{Obb as o}from"../../support/orientedBoundingBox.js";import{NodeBoundingData as s,Node as c,NodeTraversalState as l}from"./I3SNode.js";import{addWraparound as u}from"./I3SUtil.js";import{ValidatedNode as d}from"./ValidatedNode.js";class f{constructor(e,t,n,r,i){this.childOffset=e,this.childCount=t,this.visibilityCache=n,this._boundingData=r,this.node=i,this.parentIndex=-1,this.useAsHole=0,this.filterImpact=2,this.traversalState=null}get nodeBoundingData(){return this._boundingData}destroy(){this._boundingData=null,this.node=null,this.traversalState=null}invalidateBounds(){this.node?.invalidateServiceBVsInRenderSR(),this.nodeBoundingData?.invalidateServiceBVsInRenderSR()}}class p{constructor(e=[],t=[]){this._nodeDescriptors=e,this._children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}destroy(){for(let e of this._nodeDescriptors)e.destroy();this._nodeDescriptors.length=0,this._children.length=0}get nodes(){return this._nodeDescriptors}addNode(e){return this._nodeDescriptors.push(e),this._nodeDescriptors.length-1}setNodes(e,t){this._nodeDescriptors=e,this._children=t}get children(){return this._children}}class m{get _useNodePages(){return this._pageSize>0}constructor(e,n,r,i,a,o,c,l,u,d,f,m,h,_,y,b){if(this._layer=e,this._groundNavigationCheckDistance=r,this._requester=a,this._clientNodeLoader=o,this._viewportQueries=c,this._logger=l,this.holeFilling=u,this._isLoaded=d,this._isReloading=f,this._shouldLoadNode=m,this._enable=h,this._needsUpdate=_,this._computeVisibilityObb=y,this._computeNodeFiltering=b,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=0,this._lodConversion=e=>e,this._isEditable=!1,this.urlPrefix=``,this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=1/0,this._version=v(0),this._visibilityCacheVersion=v(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._progressiveLoadPenaltyWeight=10,this._missingPagesAndNodes=new Set,this._prioritizedMissingNodeAndPageIds=[],this._prefetchNodes=new Set,this._prioritizedPrefetchNodes=[],this._updates=new g(this._missingPagesAndNodes),this._imModificationUncategorized=new t({deallocator:null}),this.ignoreServiceObb=!1,this.isGroundNavigationMode=!1,this._pageQueue=[],this._newPages=[],this._needsNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=e.associatedLayer?.infoFor3D!=null,this.isGroundNavigationMode=n,e.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,i.type===`page`){let e=i.rootPage;switch(this.urlPrefix=i.urlPrefix,this._pageSize=i.pageSize,i.lodMetric){case`maxScreenThreshold`:this._lodMetric=1;break;case`maxScreenThresholdSQ`:this._lodMetric=1,this._lodConversion=k}if(this._isEditable){this._rootIndex=-1;let t=C(i.rootIndex,i.pageSize),n=e.nodes[t],r={nodes:[{index:this._rootIndex,children:[i.rootIndex],mesh:void 0,obb:n.obb,lodThreshold:n.lodThreshold}]};this._addPage(S(this._rootIndex,this._pageSize),r),this.getNode(-1).serviceObbInIndexSR=void 0}else this._rootIndex=i.rootIndex;this._addPage(S(i.rootIndex,this._pageSize),e),this._updateParentsAndLevel()}else if(i.type===`node`){this.urlPrefix=i.urlPrefix;let e=new p;if(this._nodePages.set(0,e),this._isEditable){this._clientNodePage=new p;let e={id:`-1`,version:null,mbs:i.rootNode.mbs,obb:i.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:`root`,href:`../root`,mbs:i.rootNode.mbs,obb:i.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new s(e.id),-1);let t=this._validateNode(e.id,e);t&&this._addNode(t,this._rootIndex)}else this._rootIndex=this._makeRefNode(new s(i.rootNode.id),-1);let t=this._validateNode(i.rootNode.id,i.rootNode);t&&this._addNode(t,0)}}addClientNodeToIndex(e,t){let n=new s(e,t),r=this._makeClientRefNode(n,-1);return this._linkChildToParentNode(-1,r),this.requestUpdate(),r}removeClientNodeFromIndex(e,t,n){this._destroyClientRefNode(e,t,n),this.requestUpdate()}_canRequest(e){return!this._requester.isFull(e)}_loadPage(e){if(this._nodePages.has(e)){this._logger.error(`Requested load page [${e}] already loaded`);return}if(this._loadingPages.has(e)){this._logger.error(`Requested load page [${e}] already loading`);return}this._loadingPages.add(e);let t=this.urlPrefix+e;this._requester.request(t,`json`).then(t=>{this._nodePages.has(e)?this._logger.error(`Queued page [${e}] already loaded`):this._pageQueue.push({pageIndex:e,page:t})}).catch(t=>{this._loadingPages.delete(e),n(t)||(this._failedPages.add(e),this._logger.error(`#loadPage()`,this._layer,`Error when loading page ${e}`,t))})}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){let{pageIndex:t,page:n}=this._pageQueue.shift();this._addPage(t,n),this._loadingPages.delete(t),e.madeProgress(),this._needsNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this._needsNodeElevationRange)for(;this._newPages.length>0&&!e.done;)this._nodePages.get(this._newPages.shift())?.nodes.forEach(e=>{let t=e.parentIndex;for(;t!=null&&t!==this._rootIndex;){let e=this.getNode(t);e?.elevationRangeValid&&(e.invalidateElevationRange(),this.invalidateBoundingVolumeCache(t)),t=this._getParentIndex(t)}})}_addPage(e,t){if(this._nodePages.has(e)){this._logger.error(`Page[${e}] reloaded`);return}let n=[],r=[],a=t.nodes.map((t,a)=>{let s=n.length,l=t.children?t.children.length:0;r.push(this._rootIndex);for(let e=0;e<l;e++)n.push(t.children[e]);let u=`${t.index}`,d=o.fromJSON(t.obb),p=new i(d.getCenter(N),d.radius),m=t.mesh?.attribute,h=t.mesh?.geometry,g=t.mesh?.material,v={hasSharedResource:!1,isEmpty:h==null,attributes:m?.resource==null?void 0:`${m.resource}`,geometry:h?.resource==null?void 0:`${h.resource}`,texture:g?.resource==null?void 0:`${g.resource}`,geometryDefinition:h?h.definition:-1,materialDefinition:g?g.definition:-1},y=new c(u,w(a,e,this._pageSize),p,l,0,v,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),h?.featureCount??null,d);return y.visibilityObbInRenderSR=this._computeVisibilityObb(y),y.vertexCount=h?h.vertexCount:0,new f(s,l,_(this._visibilityCacheVersion),null,y)}),s=new p(a,n);e===-1?this._clientNodePage=s:this._nodePages.set(e,s)}_updateParentsAndLevel(){let e=[],t=(t,n,r)=>{let i=this._getPage(t);if(i!=null){let a=C(t,this._pageSize),o=i.nodes[a];o.parentIndex=n??-1;let s=o.node;s!=null&&(s.level=r,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){let n=e.pop(),r=this.getNode(n);if(r!=null)for(let e=0;e<r.childCount;e++)t(this.getChildIndex(r.index,e),n,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}_getPage(e){let t=S(e,this._pageSize);return this._getPageFromPageIndex(t)}_getPageFromPageIndex(e){return e<0?this._clientNodePage:this._nodePages.get(e)}_getNodeDescriptor(e){let t=this._getPage(e);return t==null?null:(t.lastTraversed=this._frameNumber,t.nodes[C(e,this._pageSize)])}_addNode(e,t){e.children&&this.populateChildren(t,e.children);let n=this.getParent(t),r=n==null?0:n.level+1;this._maxLevel=Math.max(this._maxLevel,e.children?r+1:r);let{lodMetric:i,maxError:a}=E(e.lodSelection),s=this._getNodeDescriptor(t);if(s.node!=null)return this._logger.error(`Loaded node[${t}] already in descriptor`),s.node;let l=new c(e.id,t,e.mbs,s.childCount,r,e.resources,e.version,i,a,e.numFeatures,e.obb?o.fromJSON(e.obb):null);s.node=l,l.visibilityObbInRenderSR=this._computeVisibilityObb(l);let u=s.nodeBoundingData;return u!=null&&(u.serviceMbsInIndexSR??=e.mbs,l.shareServiceBVsInRenderSRWith(u),u.visibilityObbInRenderSR=l.visibilityObbInRenderSR),l}_makeRefNode(e,t){let n=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(n==null)return-1;let r=n.nodes.length,i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_makeClientRefNode(e,t){let n=this._clientNodePage;if(n==null)return-1;if(t>=0)throw Error(`I3SIndex::client side nodes can not be made children of service side nodes.`);let r=-(n.nodes.length+1),i=new f(0,0,_(this._visibilityCacheVersion),e,null);return n.addNode(i),i.parentIndex=t,e.invalidateServiceBVsInRenderSR(),r}_linkChildToParentNode(e,t){let n=this._clientNodePage;if(n==null||e>=0)return;let r=C(e,this._pageSize),i=C(t,this._pageSize),a=n.nodes[r],o=a.childOffset;n.children.splice(a.childOffset+a.childCount,0,t),a.childCount+=1,a.node!=null&&(a.node.childCount+=1);for(let e of n.nodes)e.childOffset>o&&(e.childOffset+=1);let s=n.nodes[i];s.parentIndex=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,n){let r=this._clientNodePage;if(r==null)return;let i=this._getParentIndex(e);if(i==null)return;let a=new Set,o=new Map,s=e=>{let n=C(e,this._pageSize),i=r.nodes[n];if(i.childCount>0)for(let e=i.childOffset;e<i.childOffset+i.childCount;++e)s(r.children[e]);let o=i.node?.id??i.nodeBoundingData?.id;if(o==null)throw Error(`Node has no id`);t(o,e),a.add(i)};s(e);let c=r.nodes,l=r.children,u=r.nodes.map(()=>-1),d=[],f=[];for(let e=0;e<c.length;++e){let t=c[e];if(a.has(t))continue;let r=d.length,i=w(e,-1,this._pageSize),s=w(r,-1,this._pageSize);if(t.node&&(t.node.index=s),u[e]=s,d.push(t),i!==s){let e=t.node?.id??t.nodeBoundingData?.id;if(e==null)throw Error(`Node has no id`);n(e,i,s),o.set(i,s)}}for(let e=0;e<d.length;++e){let t=w(e,-1,this._pageSize),n=d[e],r=f.length;for(let e=n.childOffset;e<n.childOffset+n.childCount;++e){let n=l[e];if(n>=0)f.push(n);else{let e=C(n,this._pageSize),r=c[e];if(a.has(r))continue;let i=u[e];f.push(i),r.parentIndex=t}}n.childOffset=r,n.childCount=f.length-r,n.node&&(n.node.childCount=n.childCount)}r.setNodes(d,f),this._updateParentBoundingInformation(u[C(i,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null,n=this._clientNodeLoader.indexSR,a=this._clientNodeLoader.renderSR,o=this._getNodeDescriptor(t);if(o==null)return;for(let i=0;i<o.childCount;i++){let o=this.getChildIndex(t,i),s=this._getNodeDescriptor(o),c=s==null?null:s.nodeBoundingData||s.node;if(c?.serviceMbsInIndexSR!=null&&c.serviceMbsInIndexSR.radius>0){if(e==null)e=A.copyFrom(c.serviceMbsInIndexSR);else{let t=j;r(c.serviceMbsInIndexSR,n,t,a);let i=M;r(e,n,i,a),r(t.union(i),a,e,n)}}}let s=t=>{t!=null&&(t.serviceObbInIndexSR=null,e==null?t.serviceMbsInIndexSR?.invalidate():(t.serviceMbsInIndexSR??=new i,t.serviceMbsInIndexSR.copyFrom(e)),t.invalidateServiceBVsInRenderSR(),t.geometryObbInRenderSR=null)};s(o.nodeBoundingData),s(o.node),this.invalidateNodeVisibilityCacheInternal(o),t=this._getParentIndex(t)}while(t!=null)}populateChildren(e,t){let n=this._getNodeDescriptor(e),r=this._getPage(e);n.childOffset=r.children.length,n.childCount=t.length;for(let n=0;n<t.length;n++){let i=this._makeRefNode(t[n],e);r.children.push(i)}}getNode(e){let t=this._getNodeDescriptor(e);return t==null?null:t.node}getIndexById(e){let t;return this._forAllNodes((n,r)=>{(n.node!=null&&n.node.id===e||n.nodeBoundingData!=null&&n.nodeBoundingData.id===e)&&(t=r)}),t}getNodeById(e){let t=this.getIndexById(e);return t!=null&&t>=0?this.getNode(t):null}getChildIndex(e,t){let n=this._getPage(e);if(n==null)return-1;let r=n.nodes[C(e,this._pageSize)];return n.children[r.childOffset+t]}_getParentIndex(e){let t=this._getPage(e);return t!=null&&e!==this._rootIndex?t.nodes[C(e,this._pageSize)]?.parentIndex:null}getParent(e){let t=this._getParentIndex(e);return t==null?null:this.getNode(t)}isLeaf(e){let t=this._getNodeDescriptor(e);return t!=null&&t.childCount===0}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes(e=>{e.node!=null&&(e.node.geometryObbInRenderSR=null)})}invalidateVisibilityCache(){this._visibilityCacheVersion=v(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){let t=this._getNodeDescriptor(e);t!=null&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=_(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){let t=this._getNodeDescriptor(e);t!=null&&(t?.invalidateBounds(),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){let t=this._getNodeDescriptor(e);t!=null&&(this._needsNodeElevationRange?(t.node==null?t.nodeBoundingData:t.node)?.invalidateElevationRange():this.invalidateBoundingVolumeCache(e))}invalidateGeometryVisibility(e){let t=this._getNodeDescriptor(e)?.node;t&&(t.geometryObbInRenderSR=null,t.invalidateServiceBVsInRenderSR())}invalidateVisibilityObbs(){this.rootNode!=null&&this.traverse(this.rootNode,e=>(e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.geometryObbInRenderSR=null,!0))}_isElevationRangeValid(e){if(!this._needsNodeElevationRange)return!0;let t=e?.node??e?.nodeBoundingData;return!t||t.elevationRangeValid}_updateElevationRange(e,t){let n=this._getNodeDescriptor(e);if(!n)return!1;let r=n?.node??n?.nodeBoundingData;if(!r)return!1;if(r.elevationRangeValid)return t?.expandElevationRange(r),!0;let i=new a,o=!1;for(let t=0;t<n.childCount;t++){let n=this.getChildIndex(e,t),r=this._updateElevationRange(n,i);o||=!r}if(n.childCount===0||o){let e=!n.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(r,e,i)}(i.minElevation===1/0||i.maxElevation===-1/0)&&i.expandElevationRangeValues(0,0);let{minElevation:s,maxElevation:c}=r;return s===i.minElevation&&c===i.maxElevation?(t?.expandElevationRange(r),!0):(n.node?.setElevationRange(i),n.nodeBoundingData?.setElevationRange(i),this.invalidateBoundingVolumeCache(e),t?.expandElevationRange(r),!0)}isNodeVisible(e){let t=this._getNodeDescriptor(e);if(t==null)return!0;let n=t.nodeBoundingData;if(n!=null&&!n.serviceMbsInIndexSR)return!0;if(this._isElevationRangeValid(t)&&b(t.visibilityCache,this._visibilityCacheVersion))return x(t.visibilityCache);let r=t.node,i=this._viewportQueries;if(r){let e=i.ensureElevationAgnosticBoundingVolume(r),n=i.isElevationAgnosticBoundingVolumeVisible(e,this.isGroundNavigationMode?this._groundNavigationCheckDistance:0),a=n;if(this._needsNodeElevationRange&&n){let t=i.getNodeObbInRenderSRIndependentOfElevationOffset(r);t!=null&&(a=i.isObbVisibleIndependentOfElevation(e,t))}if(!a)return t.visibilityCache=y(!1,this._visibilityCacheVersion),!1}if(this._layerHasFilter&&this._computeNodeFiltering&&(r!=null||n!=null)&&t.filterImpact===2){let e=r==null?n==null?null:n.serviceMbsInIndexSR:r.serviceMbsInIndexSR;t.filterImpact=e==null?0:this._computeNodeFiltering(e)}let a=r!=null&&t.filterImpact===1,o=(r==null||r.imModificationImpact!==2)&&!a;if(o){let t=r&&(!n||r.visibilityObbInRenderSR)?r:n??null;t!=null&&(this._needsNodeElevationRange&&this._updateElevationRange(e),o=i.isNodeVisible(t,this.isGroundNavigationMode))}return t.visibilityCache=y(o,this._visibilityCacheVersion),o}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;let t=this._getNodeDescriptor(e);return t?.node?.geometryObbInRenderSR!=null&&(!this.layerHasModifications||t.node.imModificationImpact!==4)?this._viewportQueries.isGeometryVisible(t.node,this.isGroundNavigationMode):!0}_traverseCoverage(e,t,n,r,i){let a=this._getPage(e);if(a==null||t.childCount===0)return;let o=t.childOffset+t.childCount,s=[];for(let e=t.childOffset;e<o;++e){let t=a.children[e],n=this._getNodeDescriptor(t);n?.node!=null&&this.isGeometryVisible(t)&&s.push(n)}r/=s.length;for(let e of s){let t=e.node.index;this._isLoaded(t)||this._isReloading(t)?(i.delta=Math.max(i.delta,n),i.coverage+=r):this._traverseCoverage(t,e,n+1,r,i)}}useNodeAsHole(e){if(this.holeFilling===`off`)return!1;let t=this._getNodeDescriptor(e);if(t==null)return!1;if(this.holeFilling===`always`)return!0;if(b(t.useAsHole,this._version))return x(t.useAsHole);let n={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,n);let r=n.delta*n.coverage<=.5;return t.useAsHole=y(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.destroy(),this._nodePages.clear(),this._clientNodePage=null,this._layer=null,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._imModificationUncategorized.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=v(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes(({node:e})=>{e!=null&&(e.imModificationImpact=4,e.visibilityObbInRenderSR=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))}),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes(e=>{if(e!=null){e.filterImpact=2;let t=e.node;t!=null&&this.invalidateNodeVisibilityCache(t.index)}}),this.invalidateVisibilityCache()}update(e,t,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this.resetUpdateState(e);let r=new Set(e),i=new Set,a=!0,o=new D,s=new O,c=this._imModificationUncategorized;c.clear();let l=new Set,u=0;this.traverseVisible((e,l,d)=>{let f=e=>{this._shouldLoadNode(e)&&e.childCount&&(a=!1)};if(!l){let t=S(e,this._pageSize),n=this._getNodeLoadPriority(e);n===1/0&&(n=this._getNodeLoadPriority(d)),h.set(t,Math.max(n,h.get(t)||0)),!this._loadingPages.has(t)&&!this._failedPages.has(t)&&(this._missingPagesAndNodes.add(t),++u),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,n);return}let{node:p,childCount:m}=l;if(this._updateNodeFeatureEstimate(p,s),!p){let t=this._getNodeLoadPriority(e);!this._loadingNodes.has(e)&&!this._failedNodes.has(e)&&(this._missingPagesAndNodes.add(e),h.set(e,t)),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t);return}let g=this._getPage(e);if(!this._useNodePages&&this._missingPagesAndNodes.size===0)for(let e=0;e<m;e++){let t=g.children[l.childOffset+e],n=this._getNodeDescriptor(t);n!=null&&!n.node&&!this._loadingNodes.has(t)&&!this._failedNodes.has(t)&&t>=0&&(h.set(t,this._getNodeLoadPriority(t)),this._prefetchNodes.add(t))}if(p.failed||p.resources.isEmpty){f(p);return}if(this._isLoaded(e)){if(o.known+=p.memory,++o.knownNodes,f(p),this._shouldLoadNode(p)||(o.unremoved+=p.memory),this._needsUpdate(p)){let t=this._getNodeLoadPriority(e);h.set(e,t),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,t),this._updates.update.push(e)}return}if(p.memory&&(o.known+=p.memory,++o.knownNodes),!this._shouldLoadNode(p)){this._isReloading(e)&&this._updates.remove.push(e);return}if(f(p),p.memory?(o.missing+=p.memory,o.known+=p.memory,++o.knownNodes):++o.missingNodes,r.has(p.index)){this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._getNodeLoadPriority(e)),i.add(p.index);return}if(!t.done&&this._enable(p)){t.madeProgress();return}let _=this._getNodeLoadPriority(e);h.set(e,_),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,_),this._updates.add.push(e),this.layerHasModifications&&n&&p!=null&&p.imModificationImpact===4&&c.push(e)},l),i.size>0&&(this._updates.cancel=this._updates.cancel.filter(e=>!i.has(e))),this._frameNumber++,this._prioritizeMissingNodesAndPages(),this._removeUnusedNodePages(l,u),this._handleModifications(n,c),this._updateUnloadedMemoryEstimate(o),this._featureEstimate.estimate=this._computeFeatureEstimate(s),this._featureEstimate.leavesReached=a,this._updates.add.filterInPlace(e=>h.get(e)>=this._maxUnloadedPrio).sort((e,t)=>h.get(e)-h.get(t)),this._updates.update.sort((e,t)=>h.get(e)-h.get(t)),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.size,this._dirty=this._indexMissing>0,h.clear()}_updateUnloadedMemoryEstimate(e){this._unloadedMemoryEstimate=e.missing-e.unremoved,e.knownNodes>3&&e.missingNodes>0&&(this._unloadedMemoryEstimate+=e.known/e.knownNodes*e.missingNodes),this._unloadedMemoryEstimate=Math.max(0,this._unloadedMemoryEstimate)*.8}resetUpdateState(e){this._maxUnloadedPrio=-1/0,this._maxProcessingPrio=-1/0,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),h.clear()}_prioritizeMissingNodesAndPages(){let e=this._prioritizedMissingNodeAndPageIds;e.length=0,this._missingPagesAndNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),e.length>0&&(this._maxUnloadedPrio=h.get(e[e.length-1]),this._prefetchNodes.clear())}_handleModifications(e,t){this.layerHasModifications&&this._updates.add.length!==0&&(t.length>0&&e?.(t),this._updates.add.filterInPlace(e=>{let t=this._getNodeDescriptor(e),n=t?.node==null||t.node.imModificationImpact!==2;return n||this.invalidateNodeVisibilityCache(e),n}))}checkFeatureTarget(e,t){let n=this._viewportQueries.updateScreenSpaceErrorBias(t),r=t,i=t,a=n,o=10;for(;o--;){let n=new O;if(this._updateFeatureEstimate(r,n),this._computeFeatureEstimate(n)<=e){if(r>=t||n.missingNodes>0||o===0)break;a=r,r=(r+i)*.5}else i=r,r=(r+a)*.5}return this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(n),Math.min(t,r)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;let n=e.size,r=this._nodePages,i=r.size+this._loadingPages.size+t;if(i>P&&i>n){let t=[];for(let[n,i]of r)i.numNodesWithLoadedChildren===0&&!e.has(n)&&t.push([i.lastTraversed,n]);t.sort((e,t)=>e[0]-t[0]).some(e=>{let t=e[1];return this._deleteNodePage(t),r.size<=P})}}_updateFeatureEstimate(e,t){this._version=v(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible((e,n)=>this._updateNodeFeatureEstimate(n?.node,t))}_updateNodeFeatureEstimate(e,t){e!=null&&!e.failed&&this._shouldLoadNode(e)&&(e.numFeatures==null?++t.missingNodes:(t.numFeatures+=e.numFeatures,++t.knownNodes))}_computeFeatureEstimate(e){let t=e.numFeatures;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.numFeatures/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._prioritizedMissingNodeAndPageIds,this._missingPagesAndNodes)}prefetch(){let e=this._prioritizedPrefetchNodes;return this._prefetchNodes.forEach(t=>e.push(t)),e.sort((e,t)=>h.get(e)-h.get(t)),this._load(e,this._prefetchNodes)}_load(e,t){if(e.length===0||!this._canRequest(this.urlPrefix))return!1;for(;e.length>0&&this._canRequest(this.urlPrefix);){let n=e[e.length-1];e.length--,t.delete(n),this._useNodePages&&n>=0?this._loadPage(n):this._loadNode(n)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.size>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(e==null)return null;let t=e.index,n=this._getNodeDescriptor(t);if(!n)return null;let r=n?.traversalState;if(r&&b(r.version,this._version))return r;let i=this._viewportQueries.getLodLevel(e),a=this._viewportQueries.hasLOD(e),o=!0;if(a){let e=this._getParentIndex(t);if(e!=null){let t=this._getNodeDescriptor(e)?.traversalState;o=!!t&&i>t.lodLevel}else o=i>0}else o=e.childCount===0;return r?(r.lodLevel=i,r.isChosen=o,r.version=y(!0,this._version),r):(r=new l(a,o,i,y(!0,this._version)),n.traversalState=r,r)}_loadNode(e){if(this._loadingNodes.has(e)){this._logger.error(`Node[${e}] already loading`);return}this._loadingNodes.add(e);let t=this._getNodeDescriptor(e);if(t.node){this._logger.error(`Node[${e}] already in descriptor`);return}let r=t.nodeBoundingData;if(r==null){this._failedNodes.add(e);return}let i=r.id,a=this.urlPrefix+i,o=()=>{this._loadingNodes.delete(e),this._missingPagesAndNodes.size===0&&this._loadingNodes.size===0&&this.requestUpdate()};(e>=0?this._requester.request(a,`json`):this._clientNodeLoader.loadNodeJSON(i)).then(t=>{o();let n=this._validateNode(i,t);if(n==null)return;n.obb&&this.invalidateNodeVisibilityCache(e);let r=this._addNode(n,e);this.nodeTraversalState(r)}).catch(t=>{o(),n(t)||(this._logger.error(`#loadNode()`,this._layer,`Error loading node: `+a),this._failedNodes.add(e))})}_validateNode(e,t){if(typeof t!=`object`||!t||t.id!==e)return this._logger.error(`#validateNode()`,this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error(`#validateNode()`,this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&t.sharedResource.href!==`./shared`&&t.sharedResource.href!==`./shared/`&&this._logger.warn(`#validateNode()`,this._layer,`Invalid shared resource href on node "${e}"`);let n=t.geometryData;n!=null&&!(Array.isArray(n)&&n.length===0)&&!(Array.isArray(n)&&n.length===1&&n[0].href===`./geometries/0`)&&this._logger.warn(`#validateNode()`,this._layer,`Invalid geometry data on node "${e}"`);let r=t.attributeData,a=this._layer.attributeStorageInfo;r!=null&&(!Array.isArray(r)||r.some((e,t)=>e.href!==`./attributes/${a?.[t]?.key??`f_${t}`}/0`))&&this._logger.warn(`#validateNode()`,this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn(`#validateNode()`,this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);let c=t.hasOwnProperty(`obb`)&&!this.ignoreServiceObb?t.obb:void 0,l=t.featureData?.length===1&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,u=Array.isArray(t.children)?t.children.map(t=>{if(t==null)return null;let n=t=>this._logger.error(`#validateNode()`,this._layer,`Invalid node reference on node ${e}: ${t}`);if(typeof t.id==`number`)n(`id ${t.id} is a number instead of a string.`);else if(typeof t.id!=`string`||!Array.isArray(t.mbs))return n(`Missing or invalid id.`),null;if(!Array.isArray(t.mbs))return n(`Invalid bounding volume on reference ${t.id}.`),null;let r=new s(`${t.id}`,new i(t.mbs));return r.serviceObbInIndexSR=!this.ignoreServiceObb&&t.hasOwnProperty(`obb`)&&t.obb?o.fromJSON(t.obb):null,r.visibilityObbInRenderSR=this._computeVisibilityObb(r),r}).filter(e=>e!=null):null,f=t.featureData?.length??!1,p=t.isEmpty===!0;return new d(e,new i(t.mbs),c,typeof t.version==`string`?t.version:null,{isEmpty:!f&&p,hasSharedResource:t.sharedResource!=null,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:t.geometryData==null?void 0:e},u,Array.isArray(t.lodSelection)?t.lodSelection:null,l)}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes(e=>{e.node!=null&&(e.node.failed=!1)})}_getNodeLoadPriority(e){let t=this._getNodeDescriptor(e),n=this._getParentIndex(e);if(t==null||n==null&&t.node==null)return n==null?1/0:this._getNodeLoadPriority(n);let r=0;t.node&&n!=null&&(r=this._getNodeDescriptor(n).traversalState?.lodLevel??0);let i=this._getHoleBonus(e);return-(this._viewportQueries.distToCameraPOIRay(t.nodeBoundingData??t.node)*(1+r)+r*this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI())+i}_getHoleBonus(e){return this._hasLoadedAncestor(e)?0:this._progressiveLoadPenaltyWeight*this._viewportQueries.distCameraToPOI()}_hasLoadedAncestor(e){let t=this._getParentIndex(e);for(;t!=null;){if(this._isLoaded(t))return!0;t=this._getParentIndex(t)}return!1}traverseVisible(e,t){let n=this._getNodeDescriptor(this._rootIndex);n==null?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,null,n,e,t)}_traverseVisible(e,t,n,r,i){let a=S(e,this._pageSize);if(i&&i.add(a),n.node&&n.childCount===0){this.isGeometryVisible(e)&&r(e,n,t);return}if(!this.isNodeVisible(e)||(r(e,n,t),n.node==null))return;let o=this.nodeTraversalState(n.node);if(o?.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;let s=this._getPageFromPageIndex(a);for(let t=0;t<n.childCount;t++){let a=s.children[n.childOffset+t],o=this._getNodeDescriptor(a);if(o)this._traverseVisible(a,e,o,r,i);else{if(i){let e=S(a,this._pageSize);i.add(e)}r(a,null,e)}}}traverse(e,t){for(let n of this.traverseValues(e,t));}*traverseValues(e,t){t(e)&&(yield e,yield*this._traverseDescendantValues(e,t))}*_traverseDescendantValues(e,t){let n=e.index,r=this._pageSize,i=S(n,r),a=this._getPageFromPageIndex(i);if(a==null)return;let o=this._frameNumber,s=this._nodePages,c=C(n,r),l=a.nodes[c],u=l.childCount;if(a.lastTraversed=o,u===0)return;let d=[],f=[],p=0;{let{childOffset:e,childCount:t}=l,{children:n}=a;f.length=2**Math.ceil(Math.log2(p+t));for(let r=e;r<e+t;++r){let e=n[r];e>=0?(f[p]=e,++p):d.push(e)}}if(d.length>0){let e=this._clientNodePage;if(e){let n=e.children,r=0;for(;r<d.length;){let i=d[r];++r;let a=-i-1,o=e.nodes[a],s=o.node;if(!s||!t(s))continue;yield s;let{childCount:c}=o;if(c===0)continue;let{childOffset:l}=o,u=l+c;for(let e=l;e<u;++e)d.push(n[e])}}}if(p>0){let e=0;if(r>0){let n=i*r,c=a,l=c.nodes;for(;e<p;){let i=f[e];++e;let a;if(n<=i&&i<n+r)a=c;else{let e=i/r|0,t=s.get(e);if(t===void 0)continue;a=t,a.lastTraversed=o,c=a,l=c.nodes,n=r*e}let u=i-n,d=l[u],m=d?.node;if(m==null||t(m)===!1||(yield m,d.node==null))continue;let{childCount:h}=d;if(h===0)continue;let g=p+h;for(f.length<g&&(f.length=2**Math.ceil(Math.log2(p+h)));f.length<p+h;)f.length+=f.length;let _=a.children,{childOffset:v}=d,y=v+h;for(let e=v;e<y;++e)f[p]=_[e],++p}}else{let n=s.get(0);if(n)for(;e<p;){let r=f[e++],i=n.nodes[r],a=i.node;if(!a||!t(a))continue;yield a;let{childCount:o}=i;if(o===0)continue;f.length=Math.max(f.length,2**Math.ceil(Math.log2(p+o)));let s=n.children,{childOffset:c}=i,l=c+o;for(let e=c;e<l;++e)f[p]=s[e],++p}}}}traverseDescendants(e,t){for(let n of this._traverseDescendantValues(e,t));}updateChildrenLoaded(e,t){let n=this.getNode(e);for(;n!=null;){let e=n.childrenLoaded,r=e+t;n.childrenLoaded=r;let i=e===0?1:r===0?-1:0,a=n.index;if(i!==0){let e=this._getPage(a);e.numNodesWithLoadedChildren+=i}n=this.getParent(a)}}checkChildrenLoadedInvariant(){return!0}updateElevationInfo(e,t){this._needsNodeElevationRange=t&&!!e&&(e.mode===`relative-to-ground`||e.mode===`relative-to-scene`||e.mode===`on-the-ground`),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes(e=>{e?.invalidateBounds(),e.node?.invalidateElevationRange(),e.nodeBoundingData?.invalidateElevationRange()})}_forAllNodes(e){if(this._clientNodePage!=null){let t=this._clientNodePage;for(let n=0;n<t.nodes.length;n++)e(t.nodes[n],-(n+1))}for(let[t,n]of this._nodePages){let r=t*this._pageSize;for(let t=0;t<n.nodes.length;t++)e(n.nodes[t],r+t)}}clearCaches(){if(this._useNodePages){let e=this._nodePages,t=new Set;this.traverseVisible(e=>t.add(S(e,this._pageSize)));for(let[n,r]of e)if(r.numNodesWithLoadedChildren===0&&!t.has(n))this._deleteNodePage(n);else for(let e of r.nodes)e.traversalState=null}}_deleteNodePage(e){if(!this._nodePages.has(e)){this._logger.error(`Destroying non-existent page ${e}`);return}let t=this._nodePages.get(e);this._nodePages.delete(e),t?.destroy()}get test(){}}const h=new Map;class g{constructor(e){this.missing=e,this.update=new t({deallocator:null}),this.add=new t({deallocator:null}),this.remove=new t({deallocator:null}),this.cancel=[]}destroy(){this.update.prune(),this.add.prune(),this.remove.prune(),this.cancel.length=0}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function _(e){return u(e,-2)}function v(e){return u(e,2)}function y(e,t){return t+ +!!e}function b(e,t){return(e&-2)===t}function x(e){return(e&1)==1}function S(e,t){return e<0?-1:t>0?e/t|0:0}function C(e,t){return e<0?-e-1:t===0?e:e%t}function w(e,t,n){return t===-1?-(e+1):n===0?e:t*n+e}const T=[[`maxScreenThreshold`,1],[`screenSpaceRelative`,2],[`removedFeatureDiameter`,3],[`distanceRangeFromDefaultCamera`,4]];function E(e){if(e){for(let t=0;t<e.length;t++)for(let n of T)if(n[0]===e[t].metricType)return{lodMetric:n[1],maxError:e[t].maxError}}return{lodMetric:0,maxError:0}}class D{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}class O{constructor(){this.numFeatures=0,this.knownNodes=0,this.missingNodes=0}}function k(e){return Math.sqrt(4/Math.PI*e)}const A=new i,j=new i,M=new i,N=e(),P=has(`esri-mobile`)?100:300;export{m as I3SIndex,E as selectErrorMetric};