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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0202eb8c2b2865f99981.js → 00311d1b18d5952a014b.js} +1 -1
  3. package/assets/esri/core/workers/chunks/0b21d0e2e5a91c34a108.js +1 -0
  4. package/assets/esri/core/workers/chunks/{f717005e14a7e9141df7.js → 2050c844b5a29b1df28a.js} +1 -1
  5. package/assets/esri/core/workers/chunks/2c3612379111457c3221.js +1 -0
  6. package/assets/esri/core/workers/chunks/2f9072563194026e320e.js +1 -0
  7. package/assets/esri/core/workers/chunks/{d9a240a3c6bf85124474.js → 342a97974a78007b25e0.js} +1 -1
  8. package/assets/esri/core/workers/chunks/34467f7d84baffd772a3.js +1 -0
  9. package/assets/esri/core/workers/chunks/{4d18b48d4a282a0f341c.js → 427d929dc7f89b0a1ea9.js} +1 -1
  10. package/assets/esri/core/workers/chunks/432728c557be5dfa26b5.js +1 -0
  11. package/assets/esri/core/workers/chunks/46969f379623810b2eca.js +1 -0
  12. package/assets/esri/core/workers/chunks/592b5db1459c02cf6a0c.js +1 -0
  13. package/assets/esri/core/workers/chunks/6a21dc13a465757ba007.js +1 -0
  14. package/assets/esri/core/workers/chunks/{379db67f78161ebd5468.js → 7023651ed6398dcf8efb.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{90360c0bd053d3e3fd77.js → 7027a0e7bfabb3bb7fc2.js} +1 -1
  16. package/assets/esri/core/workers/chunks/78818c2a898444f7e890.js +1 -0
  17. package/assets/esri/core/workers/chunks/{40c2674dae73f0942751.js → 7d497df6e13162156342.js} +1 -1
  18. package/assets/esri/core/workers/chunks/8a3dfe997712dc2ddead.js +1 -0
  19. package/assets/esri/core/workers/chunks/{81bcc495e6eaf2cf7474.js → 8f82a0a6747f673a2a7e.js} +1 -1
  20. package/assets/esri/core/workers/chunks/9826baa3c15ea2062669.js +1 -0
  21. package/assets/esri/core/workers/chunks/{d3369ffed19f4c264dcd.js → 9ab0735e86cf8932bf9d.js} +1 -1
  22. package/assets/esri/core/workers/chunks/ab0ea4042f4e13874aed.js +1 -0
  23. package/assets/esri/core/workers/chunks/ab98ade3257360015d6c.js +1 -0
  24. package/assets/esri/core/workers/chunks/{796c6195b6bf59dcc9bd.js → b25a05c58b0fd0f6ac60.js} +1 -1
  25. package/assets/esri/core/workers/chunks/b90271ce38522bcf813b.js +1 -0
  26. package/assets/esri/core/workers/chunks/ba91df9835cdea7698a9.js +1 -0
  27. package/assets/esri/core/workers/chunks/bfe13ac9fa1aafb190a1.js +1 -0
  28. package/assets/esri/core/workers/chunks/ce0274847ccce6a1ac53.js +1 -0
  29. package/assets/esri/core/workers/chunks/cf2e5f827cea7d7319ce.js +1 -0
  30. package/assets/esri/core/workers/chunks/dae2036faa28dade2119.js +1 -0
  31. package/assets/esri/core/workers/chunks/{e8fb2ba7b7a4f0916325.js → eed4b90494a54f8b337b.js} +1 -1
  32. package/assets/esri/core/workers/chunks/fc77eb7683e708774168.js +1 -0
  33. package/chunks/Clouds.glsl.js +7 -11
  34. package/chunks/RibbonLine.glsl.js +158 -84
  35. package/config.js +1 -1
  36. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  37. package/kernel.js +1 -1
  38. package/layers/BaseElevationLayer.js +1 -1
  39. package/layers/ElevationLayer.js +1 -1
  40. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  41. package/layers/IntegratedMeshLayer.d.ts +2 -0
  42. package/layers/IntegratedMeshLayer.js +1 -1
  43. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  44. package/layers/support/ElevationQuery.js +1 -1
  45. package/layers/video/VideoController.js +3 -3
  46. package/layers/video/types.d.ts +12 -0
  47. package/package.json +3 -3
  48. package/support/timeUtils.js +1 -1
  49. package/views/2d/engine/Bitmap.js +1 -1
  50. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  51. package/views/2d/engine/vectorTiles/SpriteMosaic.js +1 -1
  52. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  53. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  54. package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
  55. package/views/2d/engine/webgl/Overlay.js +1 -1
  56. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  57. package/views/2d/engine/webgl/SpriteMosaic.js +1 -1
  58. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  59. package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
  60. package/views/2d/engine/webgl/collisions/LabelStore.js +1 -1
  61. package/views/2d/engine/webgl/effects/highlight/HighlightGradient.js +1 -1
  62. package/views/2d/engine/webgl/shaderGraph/techniques/TextureStatisticsTechnique.js +1 -1
  63. package/views/2d/engine/webgl/shaderGraph/techniques/blend/BlendTechnique.js +1 -1
  64. package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
  66. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  67. package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapResources.js +1 -1
  68. package/views/2d/engine/webgl/shaderGraph/techniques/magnifier/MagnifierTechnique.js +1 -1
  69. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  70. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  71. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  72. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
  73. package/views/2d/engine/webgl/shaderGraph/techniques/tile/TileDebugInfoTexture.js +1 -1
  74. package/views/2d/engine/webgl/textureUtils.js +1 -1
  75. package/views/2d/layers/LayerView2D.js +1 -1
  76. package/views/2d/webglDeps.js +1 -1
  77. package/views/3d/GroundView3D.js +1 -1
  78. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  79. package/views/3d/analysis/LineOfSight/placementUtils.js +1 -1
  80. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  81. package/views/3d/input/SceneInputManager.js +1 -1
  82. package/views/3d/interactive/Manipulator3D.js +1 -1
  83. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  84. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  85. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  86. package/views/3d/layers/I3SMeshView3D.js +1 -1
  87. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  88. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  89. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  90. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  91. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  92. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  93. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  94. package/views/3d/support/engineContent/line.js +1 -1
  95. package/views/3d/support/engineContent/marker.js +1 -1
  96. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  97. package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
  98. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  99. package/views/3d/support/flow/geometryUtils.js +1 -1
  100. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  101. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  102. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  103. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  104. package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
  105. package/views/3d/support/gaussianSplatting/GaussianTileBuilder.js +2 -0
  106. package/views/3d/support/gaussianSplatting/formatConstants.js +2 -0
  107. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  108. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  109. package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
  110. package/views/3d/terrain/OverlayRenderer.js +1 -1
  111. package/views/3d/terrain/TerrainRenderer.js +1 -1
  112. package/views/3d/terrain/TerrainSurface.js +1 -1
  113. package/views/3d/terrain/TileCompositor.js +1 -1
  114. package/views/3d/terrain/TileRenderer.js +1 -1
  115. package/views/3d/webgl/RenderNode.d.ts +1 -1
  116. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  117. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  118. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  119. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
  120. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +15 -11
  121. package/views/3d/webgl-engine/effects/atmosphere/LocalAtmosphere.js +1 -1
  122. package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
  123. package/views/3d/webgl-engine/effects/clouds/CloudsRenderer.js +1 -1
  124. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  125. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  126. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  127. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  128. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  129. package/views/3d/webgl-engine/lib/AttributeView.js +1 -1
  130. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  131. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  132. package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
  133. package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
  134. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  135. package/views/3d/webgl-engine/lib/GaussianSplatRenderUtils.js +1 -1
  136. package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
  137. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  138. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  139. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js +1 -1
  140. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
  141. package/views/3d/webgl-engine/lib/VerticesView.js +2 -0
  142. package/views/3d/webgl-engine/lib/attributeViewUtils.js +1 -1
  143. package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
  144. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  145. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  146. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  149. package/views/3d/webgl-engine/materials/internal/lineMarkerBufferUtils.js +2 -0
  150. package/views/3d/webgl-engine/materials/internal/ribbonLineBufferUtils.js +2 -0
  151. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  152. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  153. package/views/draw/DrawTool.js +1 -1
  154. package/views/draw/support/ManagedTooltipField.js +1 -1
  155. package/views/support/TextureCompressionHelper.js +1 -1
  156. package/views/support/imageReprojection.js +1 -1
  157. package/views/webgl/FramebufferObject.js +1 -1
  158. package/views/webgl/RenderingContext.js +1 -1
  159. package/views/webgl/Texture.js +1 -1
  160. package/views/webgl/rasterUtils.js +1 -1
  161. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  162. package/views/webgl/textureUtils.js +1 -1
  163. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
  164. package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
  165. package/widgets/OrientedImageryViewer/navigation/utils.js +1 -1
  166. package/widgets/OrientedImageryViewer.js +2 -2
  167. package/widgets/ScaleRangeSlider/types.d.ts +3 -3
  168. package/assets/esri/core/workers/chunks/039d9bc5b5015012f811.js +0 -1
  169. package/assets/esri/core/workers/chunks/08140725277de5d2e41a.js +0 -1
  170. package/assets/esri/core/workers/chunks/16cda273927ab0a39544.js +0 -1
  171. package/assets/esri/core/workers/chunks/29c610ce1c81ebb84a6b.js +0 -1
  172. package/assets/esri/core/workers/chunks/3223f9fbc76ba9ef8d13.js +0 -1
  173. package/assets/esri/core/workers/chunks/3fdcc383bbd9cf0d274c.js +0 -1
  174. package/assets/esri/core/workers/chunks/46c290108a90518ef695.js +0 -1
  175. package/assets/esri/core/workers/chunks/48b8b57f559a53c6c513.js +0 -1
  176. package/assets/esri/core/workers/chunks/4a979fce1c971b614a18.js +0 -1
  177. package/assets/esri/core/workers/chunks/5bd1414220e42cb8ebcf.js +0 -1
  178. package/assets/esri/core/workers/chunks/5d781c2c6204cffffd0d.js +0 -1
  179. package/assets/esri/core/workers/chunks/723df53cfa0189837d01.js +0 -1
  180. package/assets/esri/core/workers/chunks/7400b8c454b47ee4fb3c.js +0 -1
  181. package/assets/esri/core/workers/chunks/7af4edc6e87d27b9d467.js +0 -1
  182. package/assets/esri/core/workers/chunks/990e96139b5a1dccb061.js +0 -1
  183. package/assets/esri/core/workers/chunks/a607541959169741a943.js +0 -1
  184. package/assets/esri/core/workers/chunks/aa779896fd9e5c341349.js +0 -1
  185. package/assets/esri/core/workers/chunks/c131e0dd180a4c10e12e.js +0 -1
  186. package/assets/esri/core/workers/chunks/f3b4159c0722df8ffe13.js +0 -1
  187. package/assets/esri/core/workers/chunks/f75eec2cbc541eec9712.js +0 -1
  188. package/views/3d/webgl-engine/lib/GaussianSplatPrepassDepthRenderer.js +0 -2
@@ -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{onePixelInPoints as t,pt2px as n,onePointInPixels as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as o,clone as s,ones as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p,expandWithBuffer as m}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as h}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as g}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{sharedGeometryElevationAligner as _}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as v,needsElevationUpdates2D as y}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as b}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as x}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as S,nanFallbackColor as C}from"./Graphics3DSymbolLayer.js";import{parseCapType as w,computeSymbolLayerIndex as T,parseLineMarkerStyle as E}from"./lineUtils.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as O,getAttributeValue as k,getSizeAttributeValue as A,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{debugFlags as M}from"../../support/debugFlags.js";import{createGeometry as N}from"../../support/engineContent/line.js";import{geometryToRenderInfo as P,geometryToRenderInfoDraped as F}from"../../support/renderInfoUtils/line.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as R}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as z,patternHidesLine as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as V}from"../../webgl-engine/materials/RibbonLineMaterial.js";const H=[`polyline`];class U extends S{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?t: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:T(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:w(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:z(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 V(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new V({...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 R({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:E(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=h(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(n[3]=t?.output??this._getFallbackOpacity()),n}_getDrivenMarkerColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackMarkerOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(n[3]=t?.output??this._getFallbackMarkerOpacity()),n}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)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(O(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof V&&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 R&&e.setParameters(n.materialParameters);else return 0}break;default: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`||g(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=w(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=v(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=y(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}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=e.graphic,i=W(r.geometry);if(i==null)return null;let a=[],o=l(),s=P(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,i.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._createGeometry(this._lineMaterial,e,c,l,i.type,1,n);if(a.push(f),M.LINE_WIREFRAMES&&a.push(f.instantiate({material:this._wireframeLineMaterial})),this._markerMaterial!=null){let t=f.instantiate({material:this._markerMaterial});t.attributes.has(`color`)&&t.setAttributeData(`color`,this._getDrivenMarkerColor(e.renderingInfo)),a.push(t)}}if(a.length===0)return null;let c=this._context.layerViewUid,f=new I({geometries:a,castShadow:!1,layerViewUid:c,graphicUid:n}),p=new x(this,f,null,_,t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=y(t.mode),p}_createGeometry(e,t,n,r,i,a,o){let s=a===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,c=i===`polygon`,l=this._fastUpdates?.visualVariables.color,u=this._fastUpdates?.visualVariables.size,d=this._fastUpdates?.visualVariables.opacity,f=this._context.layerViewUid,p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:f}),{renderingInfo:m}=t,h={position:n,size:u?null:this._getDrivenSize(m),color:l?null:this._getDrivenColor(m),sizeFeature:u?A(u,m.size):null,colorFeature:l?k(l,m.color):null,opacityFeature:d?k(d,m.opacity):null};return N(e,{overlayInfo:s,removeDuplicateStartEnd:c,mapPositions:r,attributeData:h},p)}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=M.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=F(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let l of c.lines){if(u(l.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let c=this._createGeometry(this._lineMaterial,e,l.position,void 0,n.type,0,t.uid),f=e=>{let n=this._context.layerViewUid,r=new L(e,{layerViewUid:n,graphicUid:t.uid});a.push(r)};if(i!=null){let t=c.instantiate({material:i});t.attributes.has(`color`)&&t.setAttributeData(`color`,this._getDrivenMarkerColor(e.renderingInfo)),f(t);let n=this.symbolLayer.marker.placement;(n===`begin`||n===`begin-end`)&&m(o,l.position,0,1),(n===`end`||n===`begin-end`)&&m(o,l.position,l.position.length-3,1)}f(c),M.LINE_WIREFRAMES&&f(c.instantiate({material:r}))}return new b(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return B(this.symbolLayer.pattern)}_computeMaterialWidth(e,i){return i?this._drivenProperties.size?1:e??1:(e??=t,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r:1:n(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 i=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,a=this._getCombinedOpacityAndColor(i);n.useMaterialColor&&G(s(a),this._materials[2],e),this._patternHidesLine&&(a[3]=0),G(a,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:E(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let t=this._getFallbackSize(),{size:n}=this.symbolLayer;return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:i(n,n,n),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(C):this._getFallbackOpacityAndColor(C),fallbackSize:i(t,t,t)})}_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:n(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{onePixelInPoints as t,pt2px as n,onePointInPixels as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as o,clone as s,ones as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.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{perBufferLineElevationAligner as g}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as _,needsElevationUpdates2D as v}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as y}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as b}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as x,nanFallbackColor as S}from"./Graphics3DSymbolLayer.js";import{parseCapType as C,computeSymbolLayerIndex as w,parseLineMarkerStyle as T}from"./lineUtils.js";import{initFastSymbolUpdatesState as E,updateFastSymbolUpdatesState as D,getAttributeValue as O,getSizeAttributeValue as k,ConvertOptions as A}from"../support/FastSymbolUpdates.js";import{debugFlags as j}from"../../support/debugFlags.js";import{selectLocalOrigin as M,createBufferGeometry as N}from"../../support/engineContent/line.js";import{geometryToRenderInfo as P,geometryToRenderInfoDraped as F}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as I}from"../../webgl-engine/lib/BufferObject3D.js";import{LineMarkerMaterial as L}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as R,patternHidesLine as z}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as B}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createLineMarkerBufferGeometry as V}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";const H=[`polyline`];class U extends x{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=E(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?t: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:w(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:C(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:R(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 B(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new B({...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 L({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:T(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 n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(n[3]=t?.output??this._getFallbackOpacity()),n}_getDrivenMarkerColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackMarkerOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(n[3]=t?.output??this._getFallbackMarkerOpacity()),n}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)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(D(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof B&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(D(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof L&&e.setParameters(n.materialParameters);else return 0}break;default: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=C(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=_(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=v(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}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=e.graphic,i=W(r.geometry);if(i==null)return null;let a=[],o=[],s=l(),c=P(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(c,i.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<c.lines.length;t++){let r=c.lines[t],i=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,s),!d(s,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,i,l,1,n);o.push(f),a.push(f.line),f.wireframe!=null&&a.push(f.wireframe),f.marker!=null&&a.push(f.marker)}if(a.length===0)return null;let f=this._context.layerViewUid,p=new I({geometries:a,castShadow:!1,layerViewUid:f,graphicUid:n}),m=new y(this,p,null,(e,t,n,r,i)=>g(e,t,n,r,i,o),t);return m.alignedSampledElevation=c.sampledElevation,m.needsElevationUpdates=v(t.mode),m}_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?k(s,d.size):null,colorFeature:o?O(o,d.color):null,opacityFeature:c?O(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=M(t,p),h={overlayInfo:a,mapPositions:n,attributeData:f},g=N(this._lineMaterial,h,m,u),_=j.LINE_WIREFRAMES?N(this._wireframeLineMaterial,h,m,u):null,v=this._markerMaterial,y=null;v!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},y=V(v,h,m));for(let e of[g,y,_])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:g,marker:y,wireframe:_}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=j.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=F(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 b(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return z(this.symbolLayer.pattern)}_computeMaterialWidth(e,i){return i?this._drivenProperties.size?1:e??1:(e??=t,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r:1:n(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 i=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,a=this._getCombinedOpacityAndColor(i);n.useMaterialColor&&G(s(a),this._materials[2],e),this._patternHidesLine&&(a[3]=0),G(a,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:T(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let t=this._getFallbackSize(),{size:n}=this.symbolLayer;return new A({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:i(n,n,n),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(S):this._getFallbackOpacityAndColor(S),fallbackSize:i(t,t,t)})}_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:n(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"../../../../core/has.js";import{normalize as e,add as t,scale as n,length as r,set as i,equals as a,subtract as o,dot as s,len as c,sqrDist as l,copy as u,sub as d,scaleAndAdd as f,distance as p,squaredLength as m,squaredDistance as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import v from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as y}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as b}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as ee}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as x}from"../../../../geometry/projection/projectors.js";import{create as S,fromValues as C}from"../../../../geometry/support/aaBoundingRect.js";import{create as te,fromPoints as ne,distance2 as re}from"../../../../geometry/support/lineSegment.js";import{signedDistance as w,getNormal as T}from"../../../../geometry/support/plane.js";import{isPlateCarree as ie,webMercatorValid as E}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as ae}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as D}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as oe}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as O,extractExpressionInfo as se}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as k}from"./I3SUtil.js";import{Frustum as ce}from"../../state/Frustum.js";import{groundNavigationConstants as le}from"../../state/utils/groundNavigationUtils.js";import"../../support/elevationUpdateExtentUtils.js";import{Obb as A,computeOffsetObb as ue}from"../../support/orientedBoundingBox.js";import{SweptSphereCylindricalVolume as de,SphereGlobal as fe,SweptSphereConicalVolume as pe}from"../../support/SweptSphereVolume.js";import{sphereToGeographicExtent as j,intersectsGeographicExtent as M}from"../../support/sphereExtentUtils.js";const N=1e5;class P{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,n,r,i,a,o,s,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=i,this._elevationProvider=a,this._viewingMode=o,this._options=c,this._viewDirection=g(),this._useFrustumCulling=!1,this._poi=g(),this._cameraPOIDirection=g(),this._elevationContext=null,this._checkBelowSegmentEnd=g(),this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new ce(t),this.updateCamera(n,r);let l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=y(l),this._isGlobalMode=this._viewingMode===1,this.elevationIntersectionSpatialReference=this._isGlobalMode?this._indexSR.isWebMercator?this._indexSR:this._elevationProvider.spatialReference:l,this.updateElevationInfo(s),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||ie(l)),this._indexSREllipsoidRadius=_(this._indexSR).radius,this._indexSRSphericalPCPF=y(e),this._projectorIndexSRToIndexSRSphericalPCPF=x(this._indexSR,this._indexSRSphericalPCPF),this._groundNavigationCheckDistance=le.i3sNodeDownwardCheckDistanceInMeters/this._renderCoordsHelper.unitInMeters}updateElevationInfo(e){e==null?this._elevationContext=null:(this._elevationContext=oe.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(O(se(e,!1))))}updateCamera(r,i){this._useFrustumCulling=i,e(this._viewDirection,r.viewForward),i&&this._frustum.update(r),this._halfScreenPixelSizePerDistance=r.screenPixelSizePerDistance/2,this._camPos=r.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0,t(this._checkBelowSegmentEnd,this._camPos,n(this._checkBelowSegmentEnd,this._renderCoordsHelper.worldUpAtPosition(this._camPos,this._checkBelowSegmentEnd),-this._groundNavigationCheckDistance))}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){let t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,n){if(this._elevationContext==null)return;let r=e.serviceMbsInIndexSR;if(!r)return;let i=this._elevationContext.mode===`relative-to-scene`?`scene`:`ground`,a=this._elevationProvider;if(a.getSphereElevationRange){let e=a.getSphereElevationRange(r,this._indexSR,i);if(e){n.expandElevationRange(e);return}}let[o,s,c]=r.center,l=a.getElevation(o,s,c,this._indexSR,i);l&&n.expandElevationRangeValues(l,l);let u=t?null:a.getRootElevationRange?.();u&&n.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){let{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e;if(!n?.isValid)return t;let r=G;return ee(n,this._indexSR,r,this._renderSR),e.updateServiceMbsInRenderSR(r)}intersectsElevationUpdate(e,t){if(this._isGlobalMode&&this._indexSR.isWebMercator){let n=t.serviceMbsInIndexSR;if(!n?.isValid)return!0;let[r,i]=E,a=i-r,o=e[2]-e[0]>=a,s=o?0:Math.round((n.center[0]-(e[0]+e[2])/2)/a)*a;return C(o?-1/0:e[0]+s,e[1],o?1/0:e[2]+s,e[3],K),k(K,n)!==0}let n=this.calculateServiceMbsInRenderSR(t);if(!n.isValid)return!0;if(!this._isGlobalMode)return k(e,n)!==0;let r=t.serviceMbsElevationUpdateExtent;return r[0]>r[2]&&(j(n,r),this.elevationIntersectionSpatialReference.isWebMercator&&Number.isFinite(r[0])&&(r[1]=Math.max(-90,r[1]),r[3]=Math.min(90,r[3]),b(r,v.WGS84,r,this.elevationIntersectionSpatialReference)||C(-1/0,-1/0,1/0,1/0,r))),M(e,r,this.elevationIntersectionSpatialReference)}calculateServiceMbsInRenderSRElevationAdjusted(e){let{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e,r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid||!n?.isValid)return t;let i=G;i.copyFrom(r);let{_elevationContext:a}=this;if(a){let{minElevation:t}=e,{_renderCoordsHelper:r}=this,o=n.center,s=0;if(Number.isFinite(t)){let n=0,c=0,{maxElevation:l}=e,u=o[2];switch(a.mode){case`relative-to-ground`:case`relative-to-scene`:n=a.geometryZWithOffset(u,r)+t-u,c=l-t;break;case`on-the-ground`:n=t-u,c=l-t}s=n+.5*c,i.radius+=.5*c}else i.radius<N&&(s=D(o,this._elevationProvider,a,r)-o[2]);s&&_e(i,s,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(i)}_isGlobalMbsContainingPlanetCenter(e){return this._viewingMode===1&&r(e.center)<=e.radius}calculateMbsConeInRenderSR(e){let{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:n,maxElevation:r}=e;if(!Number.isFinite(n)||!(n<r))return null;let i=this.calculateServiceMbsInRenderSR(e);if(!i.isValid)return null;let a=this._elevationContext;if(a?.mode===`relative-to-ground`||a?.mode===`relative-to-scene`){let t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;let i=t.center[2],o=a.geometryZWithOffset(i,this._renderCoordsHelper);if(this._viewingMode===2)n+=o,r+=o;else{let e=o-i;n+=e,r+=e}}let o=this._renderCoordsHelper.referenceEllipsoid.radius,s=this._viewingMode===2?new de(i,n,r):this._isGlobalMbsContainingPlanetCenter(i)?new fe(i,o+n,o+r):new pe(i,o+n,o+r);return e.updateMbsConeInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{let t=e.visibilityObbInRenderSR;if(t)return t}let t=this._indexSREllipsoidRadius*.01,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(r==null||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(t==null)t=new A,e.serviceObbInRenderSR=t;else if(t.isValid)return t;let a=n.radius,o=0,s=0,c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){let{minElevation:t,maxElevation:n}=e;switch(u.mode){case`relative-to-ground`:case`relative-to-scene`:o=u.geometryZWithOffset(c,l)+t-c,s=n-t;break;case`on-the-ground`:o=t-c,s=n-t}}else if(u&&a<N){let e=i(B,r.centerX,r.centerY,c);o=D(e,this._elevationProvider,u,l)-c}let d=s>0,f=d?z:t;return r.transform(f,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&ue(f,0,s,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{let t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}let t=e.serviceObbInIndexSR;return t?this._viewingMode===2&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>.2*this._indexSREllipsoidRadius?null:(t.transform(z,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),z):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(this._viewingMode===1?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){a(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){let n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume,i=-1,a;if(n){let t=B;n.getCenter(t),e(t,t),a=t,n.getCorners(V);for(let n of V){e(n,n);let a=s(n,t);if(a<=0){r.invalidate();return}let o=Math.sqrt(Math.max(0,1-a*a));i=Math.max(i,o)}}else{let n=t.serviceMbsInRenderSR;if(!n.isValid){r.invalidate();return}let{center:o,radius:s}=n,l=c(o);if(l<s){r.invalidate();return}i=s/l,a=e(W,o)}r.set(a,i+Se)}_updateElevationAgnosticBoundingVolumeLocal(e){let t=e.elevationAgnosticBoundingVolume,n=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(n){let e=n.getCenter(B);e[2]=0;let r=0,i=H;n.getCorners(V);for(let e of V){e[2]=0;let t=l(i,e);r=Math.max(r,t)}t.set(e,Math.sqrt(r))}else{let n=e.serviceMbsInRenderSR;if(n.isValid){let e=u(B,n.center);e[2]=0,t.set(e,n.radius)}}}isNodeVisible(e,t=!1){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling||t&&this.isNodeCloseBelowCamera(e))return!0;let n=this.getAndUpdateVisibilityObbInRenderSR(e);return n?n.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isNodeCloseBelowCamera(e){let t=this.getAndUpdateVisibilityObbInRenderSR(e);if(t?.isValid)return t.intersectSegment(this._camPos,this._checkBelowSegmentEnd);let n=this.calculateServiceMbsInRenderSRElevationAdjusted(e);if(!n.isValid)return!0;let r=ne(this._camPos,this._checkBelowSegmentEnd,me);return re(r,n.center)<=n.radius**2}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||!e.valid?!0:e.intersectsFrustumConservative(this._frustum,this._viewingMode,1+t)?this._viewingMode!==1||this._isConeVisibleInFrustum(e):!1}_isConeVisibleInFrustum(t){let r=t.radius;if(r>be)return!0;let i=this._frustumPlanes,{center:a,radius:o}=this._frustum.boundingSphere,c=t.getAxis(W),l=s(c,a),u=o+1,p=l-u,m=l+u;if(p<=0)return!0;let h=n(I,c,p),g=n(L,c,m),_=r/Math.sqrt(1-r*r);for(let t of i){let r=T(t),i=e(R,r),a=s(i,c);if(Math.abs(1-a)<xe)continue;let o=he;n(o,c,a),d(o,o,i),e(o,o);let l=ge;if(f(l,h,o,p*_),!(w(t,l)<=0)&&(f(l,g,o,m*_),!(w(t,l)<=0)))return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling||!e.valid)return!0;let{center:r,radius:i}=this._frustum.boundingSphere,a=i+1,o=this._frustumPlanes,c=V;if(t.getCorners(c),this._viewingMode===1){let t=e.getAxis(W),i=s(t,r),l=i-a,u=i+a;if(l<=0)return!0;for(let e of o){let r=!0;for(let i of c){let a=s(i,t),o=U;if(n(o,i,l/a),w(e,o)<=0){r=!1;break}let c=U;if(n(c,i,u/a),w(e,c)<=0){r=!1;break}}if(r)return!1}}else{let e=r[2]-a,t=r[2]+a;for(let n of o){let r=!0,i=T(n),a=i[0],o=i[1],s=i[2],l=n[3];for(let n of c){let i=a*n[0]+o*n[1]+l;if(i+s*e<=0||i+s*t<=0){r=!1;break}}if(r)return!1}}return!0}isGeometryVisible(e,t){if(!this._useFrustumCulling)return!0;let n=e.geometryObbInRenderSR;return!n?.isValid||n.intersectsFrustumConservativeApproximation(this._frustumPlanes)||t&&n.intersectSegment(this._camPos,this._checkBelowSegmentEnd)}_isMBSinClippingArea(e){return this._clippingArea==null||k(this._clippingArea,e)!==0}_screenSpaceDiameterMbs(e,t){let n=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return n<0?ve:t/n/this._halfScreenPixelSizePerDistance}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);let n=t.calculateSurfaceDistanceFromPoint(this._camPos),r=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(r),n}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=p(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(n),n}_calculateAngleDependentLoDForSphere(e,t){let n=d(H,e,this._camPos),i=r(e),a=r(n);if(i===0||a===0)return 1;let o=(Math.abs(s(e,n))/i+t)/a;return Math.min(1,o)}calcAngleDependentLoD(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null){let{center:t,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,n)}let{center:i,radius:a}=this.calculateServiceMbsInRenderSR(e);if(this._viewingMode===2)u(q,i),q[2]=t.lowerCenterHeight,u(J,i),J[2]=t.upperCenterHeight;else{let e=r(i);if(e===0)return 1;n(q,i,t.lowerCenterHeight/e),n(J,i,t.upperCenterHeight/e)}let o=this._calculateAngleDependentLoDForSphere(q,a),c=this._calculateAngleDependentLoDForSphere(J,a);if(this._viewingMode===2)u(Y,i),Y[2]=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,this._camPos[2]));else{let e=r(i);if(e===0)return Math.max(o,c);let a=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,s(this._camPos,i)/e));n(Y,i,a/e)}return Math.max(o,c,this._calculateAngleDependentLoDForSphere(Y,a))}hasLOD(e){return e.lodMetric!==0}_getDistanceToSurfaceGlobeMode(e,i){let a=r(i.center),c=r(e)-a;n(q,e,s(e,i.center)/m(e));let l=h(i.center,q),u=i.radius;if(l<=u*u)return Math.abs(c);let d=n(q,i.center,1/a),f=u*u/(2*a),g=n(J,d,a-f),_=o(Y,e,g),v=o(Y,_,n(X,d,s(d,_))),y=t(Y,g,n(Y,v,u/r(v))),b=p(e,y);if(c>=Z){let t=o(J,e,y),n=s(t,d)/r(t);n<Q&&(n=$),b/=n}return b}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):F(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,t){t.calculateClosestCenterToPoint(this._camPos,X);let n=r(X);if(n===0||r(this._camPos)-n<Z)return e;let i=o(Y,this._camPos,X),a=r(i);if(a===0)return e;let c=s(i,X)/(a*n);return e/(c<Q?$:c)}calculateScreenSpaceRelativeSphere(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=this._getDistanceToSurface(this._camPos,t),r=n+t.radius;return this._updateMinMaxDistanceToCenter(r),2*n*this._halfScreenPixelSizePerDistance}calculateScreenSpaceRelativeCone(e){let t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);let n=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(n,e):n)*this._halfScreenPixelSizePerDistance}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(e.lodMetric===0)return 0;if(e.childCount===0)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){let t=this._progressiveLoadFactor*this._screenspaceErrorBias,n=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,n)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let n=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(n*=this.calcAngleDependentLoD(e)),n<e.maxError}case 2:{let n=this.calculateMbsConeInRenderSR(e),r=n?this.calculateScreenSpaceRelativeCone(n):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=r}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<ye;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(e==null)return 0;let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,r=s(n,this._cameraPOIDirection),i=r*r,a=m(n)-i;return Math.sqrt(a)-t.radius}distCameraToPOI(){return p(this._camPos,this._poi)}}function F(e,t){let n=e[0]-t.center[0],r=e[1]-t.center[1],i=e[2]-t.center[2],a=n*n+r*r,o=t.radius;if(a<=o*o)return Math.abs(i);let s=Math.sqrt(a)-o;return Math.sqrt(i*i+s*s)}const I=g(),L=g(),R=g(),z=new A,B=g(),V=[g(),g(),g(),g(),g(),g(),g(),g()],H=g(),me=te(),he=g(),ge=g(),U=g(),W=g(),G=new ae,K=S(),q=g(),J=g(),Y=g(),X=g();function _e(e,t,i){if(i===2)e.center[2]+=t;else{let i=r(e.center);if(i===0){e.radius+=Math.abs(t);return}n(e.center,e.center,1+t/i)}}const ve=.5*Number.MAX_VALUE,ye=10,Z=2e5,Q=.08,$=1e-4,be=.9,xe=.01,Se=.001;export{P as default};
2
+ import"../../../../core/has.js";import{normalize as e,add as t,scale as n,length as r,set as i,equals as a,subtract as o,dot as s,len as c,sqrDist as l,copy as u,sub as d,scaleAndAdd as f,distance as p,squaredLength as m,squaredDistance as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as _}from"../../../../geometry/ellipsoidUtils.js";import v from"../../../../geometry/Point.js";import y from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as b}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingRect as ee}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as te}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as ne}from"../../../../geometry/projection/projectors.js";import{create as re,fromValues as x}from"../../../../geometry/support/aaBoundingRect.js";import{create as ie,fromPoints as S,distance2 as ae}from"../../../../geometry/support/lineSegment.js";import{signedDistance as C,getNormal as w}from"../../../../geometry/support/plane.js";import{isPlateCarree as oe,webMercatorValid as se}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as T}from"../../../../geometry/support/sphere.js";import{evaluateElevationAlignmentAtPoint as E}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as ce}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as le,extractExpressionInfo as ue}from"../graphics/featureExpressionInfoUtils.js";import{intersectBoundingRectWithMbs as D}from"./I3SUtil.js";import{Frustum as de}from"../../state/Frustum.js";import{groundNavigationConstants as fe}from"../../state/utils/groundNavigationUtils.js";import"../../support/elevationUpdateExtentUtils.js";import{Obb as O,computeOffsetObb as pe}from"../../support/orientedBoundingBox.js";import{SweptSphereCylindricalVolume as me,SphereGlobal as he,SweptSphereConicalVolume as k}from"../../support/SweptSphereVolume.js";import{sphereToGeographicExtent as A,intersectsGeographicExtent as j}from"../../support/sphereExtentUtils.js";const M=1e5;class N{get _frustumPlanes(){return this._frustum.planes}constructor(e,t,n,r,i,a,o,s,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=i,this._elevationProvider=a,this._viewingMode=o,this._options=c,this._viewDirection=g(),this._useFrustumCulling=!1,this._poi=g(),this._cameraPOIDirection=g(),this._elevationContext=null,this._checkBelowSegmentEnd=g(),this.minCenterDistance=1/0,this.maxCenterDistance=0,this.maxLodLevel=2,this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this._frustum=new de(t),this.updateCamera(n,r);let l=this._renderCoordsHelper.spatialReference;this._renderSR=l,this._renderSRSphericalPCPF=b(l),this._isGlobalMode=this._viewingMode===1,this.elevationIntersectionSpatialReference=this._isGlobalMode?this._indexSR.isWebMercator?this._indexSR:this._elevationProvider.spatialReference:l,this.updateElevationInfo(s),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(l.isWebMercator||oe(l)),this._indexSREllipsoidRadius=_(this._indexSR).radius,this._indexSRSphericalPCPF=b(e),this._projectorIndexSRToIndexSRSphericalPCPF=ne(this._indexSR,this._indexSRSphericalPCPF),this._groundNavigationCheckDistance=fe.i3sNodeDownwardCheckDistanceInMeters/this._renderCoordsHelper.unitInMeters}updateElevationInfo(e){e==null?this._elevationContext=null:(this._elevationContext=ce.fromElevationInfo(e),this._elevationContext.setFeatureExpressionInfoContext(le(ue(e,!1))))}updateCamera(r,i){this._useFrustumCulling=i,e(this._viewDirection,r.viewForward),i&&this._frustum.update(r),this._halfScreenPixelSizePerDistance=r.screenPixelSizePerDistance/2,this._camPos=r.eye,this._updateCameraPOIDirection(),this.minCenterDistance=1/0,this.maxCenterDistance=0,t(this._checkBelowSegmentEnd,this._camPos,n(this._checkBelowSegmentEnd,this._renderCoordsHelper.worldUpAtPosition(this._camPos,this._checkBelowSegmentEnd),-this._groundNavigationCheckDistance))}setPointOfInterest(e){this._poi=e,this._updateCameraPOIDirection()}updateScreenSpaceErrorBias(e){let t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,n){if(this._elevationContext==null)return;let r=e.serviceMbsInIndexSR;if(!r)return;let i=this._elevationContext.mode===`relative-to-scene`?`scene`:`ground`,a=this._elevationProvider;if(a.getSphereElevationRange){let e=a.getSphereElevationRange(r,this._indexSR,i);if(e){n.expandElevationRange(e);return}}let[o,s,c]=r.center,l=a.getElevation(o,s,c,this._indexSR,i);l&&n.expandElevationRangeValues(l,l);let u=t?null:a.getRootElevationRange?.();u&&n.expandElevationRange(u)}calculateServiceMbsInRenderSR(e){let{serviceMbsInRenderSR:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e;if(!n?.isValid)return t;let r=G;return te(n,this._indexSR,r,this._renderSR),e.updateServiceMbsInRenderSR(r)}intersectsElevationUpdate(e,t){if(this._isGlobalMode&&this._indexSR.isWebMercator){let n=t.serviceMbsInIndexSR;if(!n?.isValid)return!0;let[r,i]=se,a=i-r,o=e[2]-e[0]>=a,s=o?0:Math.round((n.center[0]-(e[0]+e[2])/2)/a)*a;return x(o?-1/0:e[0]+s,e[1],o?1/0:e[2]+s,e[3],K),D(K,n)!==0}let n=this.calculateServiceMbsInRenderSR(t);if(!n.isValid)return!0;if(!this._isGlobalMode)return D(e,n)!==0;let r=t.serviceMbsElevationUpdateExtent;return r[0]>r[2]&&(A(n,r),this.elevationIntersectionSpatialReference.isWebMercator&&Number.isFinite(r[0])&&(r[1]=Math.max(-90,r[1]),r[3]=Math.min(90,r[3]),ee(r,y.WGS84,r,this.elevationIntersectionSpatialReference)||x(-1/0,-1/0,1/0,1/0,r))),j(e,r,this.elevationIntersectionSpatialReference)}_evaluateElevationAlignmentInIndexSR(e,t){return B.x=e[0],B.y=e[1],B.z=e[2],B.spatialReference=this._indexSR,E(B,this._elevationProvider,t,this._renderCoordsHelper)}calculateServiceMbsInRenderSRElevationAdjusted(e){let{serviceMbsInRenderSRElevationAdjusted:t}=e;if(t.isValid)return t;let{serviceMbsInIndexSR:n}=e,r=this.calculateServiceMbsInRenderSR(e);if(!r.isValid||!n?.isValid)return t;let i=G;i.copyFrom(r);let{_elevationContext:a}=this;if(a){let{minElevation:t}=e,{_renderCoordsHelper:r}=this,o=n.center,s=0;if(Number.isFinite(t)){let n=0,c=0,{maxElevation:l}=e,u=o[2];switch(a.mode){case`relative-to-ground`:case`relative-to-scene`:n=a.geometryZWithOffset(u,r)+t-u,c=l-t;break;case`on-the-ground`:n=t-u,c=l-t}s=n+.5*c,i.radius+=.5*c}else i.radius<M&&(s=this._evaluateElevationAlignmentInIndexSR(o,a)-o[2]);s&&ye(i,s,this._viewingMode)}return e.updateServiceMbsInRenderSRElevationAdjusted(i)}_isGlobalMbsContainingPlanetCenter(e){return this._viewingMode===1&&r(e.center)<=e.radius}calculateMbsConeInRenderSR(e){let{mbsConeInRenderSR:t}=e;if(t)return t;if(!e.elevationRangeValid)return null;let{minElevation:n,maxElevation:r}=e;if(!Number.isFinite(n)||!(n<r))return null;let i=this.calculateServiceMbsInRenderSR(e);if(!i.isValid)return null;let a=this._elevationContext;if(a?.mode===`relative-to-ground`||a?.mode===`relative-to-scene`){let t=e.serviceMbsInIndexSR;if(!t?.isValid)return null;let i=t.center[2],o=a.geometryZWithOffset(i,this._renderCoordsHelper);if(this._viewingMode===2)n+=o,r+=o;else{let e=o-i;n+=e,r+=e}}let o=this._renderCoordsHelper.referenceEllipsoid.radius,s=this._viewingMode===2?new me(i,n,r):this._isGlobalMbsContainingPlanetCenter(i)?new he(i,o+n,o+r):new k(i,o+n,o+r);return e.updateMbsConeInRenderSR(s)}getAndUpdateVisibilityObbInRenderSR(e){{let t=e.visibilityObbInRenderSR;if(t)return t}let t=this._indexSREllipsoidRadius*.01,{serviceMbsInIndexSR:n,serviceObbInIndexSR:r}=e;if(r==null||!n||!r.isValid||this._isECEFOBBInLocalMode&&(r.halfSizeX>t||r.halfSizeY>t||r.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(t==null)t=new O,e.serviceObbInRenderSR=t;else if(t.isValid)return t;let a=n.radius,o=0,s=0,c=r.centerZ,l=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){let{minElevation:t,maxElevation:n}=e;switch(u.mode){case`relative-to-ground`:case`relative-to-scene`:o=u.geometryZWithOffset(c,l)+t-c,s=n-t;break;case`on-the-ground`:o=t-c,s=n-t}}else if(u&&a<M){let e=i(z,r.centerX,r.centerY,c);o=this._evaluateElevationAlignmentInIndexSR(e,u)-c}let d=s>0,f=d?R:t;return r.transform(f,this._indexSR,this._renderSR,o,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),d&&pe(f,0,s,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{let t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}let t=e.serviceObbInIndexSR;return t?this._viewingMode===2&&Math.max(t.halfSizeX,t.halfSizeY,t.halfSizeZ)>.2*this._indexSREllipsoidRadius?null:(t.transform(R,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),R):null}ensureElevationAgnosticBoundingVolume(e){return!e.elevationAgnosticBoundingVolume.valid&&e.level>0&&(this._viewingMode===1?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateCameraPOIDirection(){a(this._poi,this._camPos)?this._cameraPOIDirection=this._viewDirection:(o(this._cameraPOIDirection,this._camPos,this._poi),e(this._cameraPOIDirection,this._cameraPOIDirection))}_updateElevationAgnosticBoundingVolumeGlobal(t){let n=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),r=t.elevationAgnosticBoundingVolume,i=-1,a;if(n){let t=z;n.getCenter(t),e(t,t),a=t,n.getCorners(V);for(let n of V){e(n,n);let a=s(n,t);if(a<=0){r.invalidate();return}let o=Math.sqrt(Math.max(0,1-a*a));i=Math.max(i,o)}}else{let n=t.serviceMbsInRenderSR;if(!n.isValid){r.invalidate();return}let{center:o,radius:s}=n,l=c(o);if(l<s){r.invalidate();return}i=s/l,a=e(W,o)}r.set(a,i+we)}_updateElevationAgnosticBoundingVolumeLocal(e){let t=e.elevationAgnosticBoundingVolume,n=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(n){let e=n.getCenter(z);e[2]=0;let r=0,i=H;n.getCorners(V);for(let e of V){e[2]=0;let t=l(i,e);r=Math.max(r,t)}t.set(e,Math.sqrt(r))}else{let n=e.serviceMbsInRenderSR;if(n.isValid){let e=u(z,n.center);e[2]=0,t.set(e,n.radius)}}}isNodeVisible(e,t=!1){if(!this._isMBSinClippingArea(this.calculateServiceMbsInRenderSR(e)))return!1;if(!this._useFrustumCulling||t&&this.isNodeCloseBelowCamera(e))return!0;let n=this.getAndUpdateVisibilityObbInRenderSR(e);return n?n.intersectsFrustumConservativeApproximation(this._frustumPlanes):this._frustum.intersectsSphere(this.calculateServiceMbsInRenderSRElevationAdjusted(e))}isNodeCloseBelowCamera(e){let t=this.getAndUpdateVisibilityObbInRenderSR(e);if(t?.isValid)return t.intersectSegment(this._camPos,this._checkBelowSegmentEnd);let n=this.calculateServiceMbsInRenderSRElevationAdjusted(e);if(!n.isValid)return!0;let r=S(this._camPos,this._checkBelowSegmentEnd,ge);return ae(r,n.center)<=n.radius**2}isElevationAgnosticBoundingVolumeVisible(e,t){return!this._useFrustumCulling||!e.valid?!0:e.intersectsFrustumConservative(this._frustum,this._viewingMode,1+t)?this._viewingMode!==1||this._isConeVisibleInFrustum(e):!1}_isConeVisibleInFrustum(t){let r=t.radius;if(r>Se)return!0;let i=this._frustumPlanes,{center:a,radius:o}=this._frustum.boundingSphere,c=t.getAxis(W),l=s(c,a),u=o+1,p=l-u,m=l+u;if(p<=0)return!0;let h=n(F,c,p),g=n(I,c,m),_=r/Math.sqrt(1-r*r);for(let t of i){let r=w(t),i=e(L,r),a=s(i,c);if(Math.abs(1-a)<Ce)continue;let o=_e;n(o,c,a),d(o,o,i),e(o,o);let l=ve;if(f(l,h,o,p*_),!(C(t,l)<=0)&&(f(l,g,o,m*_),!(C(t,l)<=0)))return!1}return!0}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling||!e.valid)return!0;let{center:r,radius:i}=this._frustum.boundingSphere,a=i+1,o=this._frustumPlanes,c=V;if(t.getCorners(c),this._viewingMode===1){let t=e.getAxis(W),i=s(t,r),l=i-a,u=i+a;if(l<=0)return!0;for(let e of o){let r=!0;for(let i of c){let a=s(i,t),o=U;if(n(o,i,l/a),C(e,o)<=0){r=!1;break}let c=U;if(n(c,i,u/a),C(e,c)<=0){r=!1;break}}if(r)return!1}}else{let e=r[2]-a,t=r[2]+a;for(let n of o){let r=!0,i=w(n),a=i[0],o=i[1],s=i[2],l=n[3];for(let n of c){let i=a*n[0]+o*n[1]+l;if(i+s*e<=0||i+s*t<=0){r=!1;break}}if(r)return!1}}return!0}isGeometryVisible(e,t){if(!this._useFrustumCulling)return!0;let n=e.geometryObbInRenderSR;return!n?.isValid||n.intersectsFrustumConservativeApproximation(this._frustumPlanes)||t&&n.intersectSegment(this._camPos,this._checkBelowSegmentEnd)}_isMBSinClippingArea(e){return this._clippingArea==null||D(this._clippingArea,e)!==0}_screenSpaceDiameterMbs(e,t){let n=this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e);return n<0?be:t/n/this._halfScreenPixelSizePerDistance}calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null)return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e);let n=t.calculateSurfaceDistanceFromPoint(this._camPos),r=t.calculateCenterDistanceFromPoint(this._camPos);return this._updateMinMaxDistanceToCenter(r),n}calcCameraDistanceToSurfaceAndUpdateMinmaxWithSphere(e){return this.calcCameraDistanceToCenterAndUpdateMinmax(e)-this.calculateServiceMbsInRenderSRElevationAdjusted(e).radius}calcCameraDistanceToCenterAndUpdateMinmax(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=p(t.center,this._camPos);return this._updateMinMaxDistanceToCenter(n),n}_calculateAngleDependentLoDForSphere(e,t){let n=d(H,e,this._camPos),i=r(e),a=r(n);if(i===0||a===0)return 1;let o=(Math.abs(s(e,n))/i+t)/a;return Math.min(1,o)}calcAngleDependentLoD(e){let t=this.calculateMbsConeInRenderSR(e);if(t==null){let{center:t,radius:n}=this.calculateServiceMbsInRenderSRElevationAdjusted(e);return this._calculateAngleDependentLoDForSphere(t,n)}let{center:i,radius:a}=this.calculateServiceMbsInRenderSR(e);if(this._viewingMode===2)u(q,i),q[2]=t.lowerCenterHeight,u(J,i),J[2]=t.upperCenterHeight;else{let e=r(i);if(e===0)return 1;n(q,i,t.lowerCenterHeight/e),n(J,i,t.upperCenterHeight/e)}let o=this._calculateAngleDependentLoDForSphere(q,a),c=this._calculateAngleDependentLoDForSphere(J,a);if(this._viewingMode===2)u(Y,i),Y[2]=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,this._camPos[2]));else{let e=r(i);if(e===0)return Math.max(o,c);let a=Math.max(t.lowerCenterHeight,Math.min(t.upperCenterHeight,s(this._camPos,i)/e));n(Y,i,a/e)}return Math.max(o,c,this._calculateAngleDependentLoDForSphere(Y,a))}hasLOD(e){return e.lodMetric!==0}_getDistanceToSurfaceGlobeMode(e,i){let a=r(i.center),c=r(e)-a;n(q,e,s(e,i.center)/m(e));let l=h(i.center,q),u=i.radius;if(l<=u*u)return Math.abs(c);let d=n(q,i.center,1/a),f=u*u/(2*a),g=n(J,d,a-f),_=o(Y,e,g),v=o(Y,_,n(X,d,s(d,_))),y=t(Y,g,n(Y,v,u/r(v))),b=p(e,y);if(c>=Z){let t=o(J,e,y),n=s(t,d)/r(t);n<Q&&(n=$),b/=n}return b}_getDistanceToSurface(e,t){return this._isGlobalMode?this._getDistanceToSurfaceGlobeMode(e,t):P(e,t)}_applyGlobalFlatAngleCorrectionToConeDistance(e,t){t.calculateClosestCenterToPoint(this._camPos,X);let n=r(X);if(n===0||r(this._camPos)-n<Z)return e;let i=o(Y,this._camPos,X),a=r(i);if(a===0)return e;let c=s(i,X)/(a*n);return e/(c<Q?$:c)}calculateScreenSpaceRelativeSphere(e){let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=this._getDistanceToSurface(this._camPos,t),r=n+t.radius;return this._updateMinMaxDistanceToCenter(r),2*n*this._halfScreenPixelSizePerDistance}calculateScreenSpaceRelativeCone(e){let t=e.calculateCenterDistanceFromPoint(this._camPos);this._updateMinMaxDistanceToCenter(t);let n=e.calculateSurfaceDistanceFromPoint(this._camPos);return 2*(this._isGlobalMode?this._applyGlobalFlatAngleCorrectionToConeDistance(n,e):n)*this._halfScreenPixelSizePerDistance}_updateMinMaxDistanceToCenter(e){e>0?(this.minCenterDistance=Math.min(this.minCenterDistance,e),this.maxCenterDistance=Math.max(this.maxCenterDistance,e)):(this.minCenterDistance=0,this.maxCenterDistance=Math.max(this.maxCenterDistance,-e))}getLodLevel(e){if(e.lodMetric===0)return 0;if(e.childCount===0)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){let t=this._progressiveLoadFactor*this._screenspaceErrorBias,n=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,n)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case 1:{let n=this._screenSpaceDiameterMbs(e,(e.serviceMbsInIndexSR?.radius??0)*t);return this._options.angleDependentLoD&&(n*=this.calcAngleDependentLoD(e)),n<e.maxError}case 2:{let n=this.calculateMbsConeInRenderSR(e),r=n?this.calculateScreenSpaceRelativeCone(n):this.calculateScreenSpaceRelativeSphere(e);return e.maxError*t<=r}case 3:return this._screenSpaceDiameterMbs(e,e.maxError)*t<xe;case 4:return this.calcCameraDistanceToSurfaceAndUpdateMinmaxWithCenterDistance(e)>e.maxError*t}return!1}distToCameraPOIRay(e){if(e==null)return 0;let t=this.calculateServiceMbsInRenderSRElevationAdjusted(e),n=t.center,r=s(n,this._cameraPOIDirection),i=r*r,a=m(n)-i;return Math.sqrt(a)-t.radius}distCameraToPOI(){return p(this._camPos,this._poi)}}function P(e,t){let n=e[0]-t.center[0],r=e[1]-t.center[1],i=e[2]-t.center[2],a=n*n+r*r,o=t.radius;if(a<=o*o)return Math.abs(i);let s=Math.sqrt(a)-o;return Math.sqrt(i*i+s*s)}const F=g(),I=g(),L=g(),R=new O,z=g(),B=new v,V=[g(),g(),g(),g(),g(),g(),g(),g()],H=g(),ge=ie(),_e=g(),ve=g(),U=g(),W=g(),G=new T,K=re(),q=g(),J=g(),Y=g(),X=g();function ye(e,t,i){if(i===2)e.center[2]+=t;else{let i=r(e.center);if(i===0){e.radius+=Math.abs(t);return}n(e.center,e.center,1+t/i)}}const be=.5*Number.MAX_VALUE,xe=10,Z=2e5,Q=.08,$=1e-4,Se=.9,Ce=.01,we=.001;export{N as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import n from"../../../../core/Logger.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as o,transformQuatValues as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as l}from"../../../../geometry/projectionUtils.js";import{projectBoundingRect as u}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{create as f,allFinite as p,fromExtent as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as g}from"../../../../geometry/support/sphere.js";import{ElevationRange as _}from"../../support/ElevationRange.js";import{ElevationUpdateEvent as v}from"../../support/ElevationUpdateEvent.js";import{ProjectedElevationUpdateExtent as y,calculateElevationUpdateExtents as b,fullWorldElevationUpdateExtent as x,planetCenterProximityToleranceMeters as S}from"../../support/elevationUpdateExtentUtils.js";import{Intersector as C}from"../../webgl-engine/lib/Intersector.js";let w=class extends t{constructor(e){super(e),this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource,this._projectedExtent=new y(this._renderCoordsHelper)}initialize(){this._intersector=new C(this.view.state.viewingMode),this._intersector.options.store=0,this._intersector.options.normalRequired=!1}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,r,i){let a=this._renderCoordsHelper,s=o(E,e,t,r);if(!a.toRenderCoords(s,i,s))return n.getLogger(this).error(`could not project point to compute elevation`),null;let{layerElevationSource:c,_intersector:l,intersectionHandler:u}=this,d=c.fullExtent,f=d!=null&&Number.isFinite(d.xmin)&&Number.isFinite(d.xmax)&&Number.isFinite(d.ymin)&&Number.isFinite(d.ymax)&&Number.isFinite(d.zmin)&&Number.isFinite(d.zmax)?new _(d.zmin,d.zmax):c.elevationRange;if(f==null)return null;let p=c.elevationOffset,m=f.minElevation+p,h=f.maxElevation+p,g=a.setAltitude(k,h,s),v=a.setAltitude(A,m,s);return l.reset(g,v,this.view.state.camera),u.intersectRay(l,null,g,v,null,!0),l.results.min.getIntersectionPoint(s)?a.getAltitude(s):null}getElevations(e,t,n){let{groundSpatialReference:r}=this.view;for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=this.getElevation(a,o,0,r);n(i,s)}}getSphereElevationRange(e,t){return d(e,t,T,this._renderSR),this._layerElevationSource.getElevationRange(T)}getRootElevationRange(){let e=this.layerElevationSource.fullExtent;return e?.hasZ?new _(e.zmin,e.zmax):null}notifyObjectsChanged(e){this._notifyObjectsChanged(e.length,t=>{for(let n of e)if(!t(n))break})}notifyObjectsChangedFunctional(e,t){this._notifyObjectsChanged(e,t)}notifyObjectChanged(e){this._notifyObjectsChanged(1,t=>{t(e)})}_notifyObjectsChanged(e,t){if(e===0)return;let n=this.spatialReference;if(n==null)return;if(!l(this._renderSR,n)){this._emitFullExtentElevationChange(n);return}let r=new Float64Array(4*e),i=!1,a=0;t(e=>this._computeObjectExtent(e,r,a,n)?(a++,!0):(i=!0,!1)),i?this._emitFullExtentElevationChange(n):this._emitElevationChangeEvents(r,n)}_computeObjectExtent(e,t,n,r){if(this.view.state.viewingMode===1&&P(e))return!1;let i=this._projectedExtent;return E[0]=e.centerX,E[1]=e.centerY,E[2]=e.centerZ,i.reset(E,e.radius,r),!this._expandExtent(e,i,r)||!p(i.extent)?!1:(t.set(i.extent,4*n),!0)}_emitElevationChangeEvents(e,t){for(let n of b(e,t))this._emitElevationChangeEvent(n,t)}_emitFullExtentElevationChange(e){let t=f(),n=this._layerElevationSource.fullExtent;if(n!=null&&u(m(n,M),n.spatialReference,t,e)&&p(t)){this._emitElevationChangeEvent(t,e);return}let r=h(e);r!=null&&this._emitElevationChangeEvent(x(e,r),e)}_emitElevationChangeEvent(e,t){let n=new v(t,e,this.intersectionHandler.isGround?`ground`:`scene`);this.emit(`elevation-change`,n)}_expandExtent(e,t,n){e.getCorners(O);for(let e=0;e<8;++e){let r=O[e];if(t.addRenderPoint(r,n)==null)return!1}for(let e=0;e<D.length;e+=2)if(!t.addRenderEdge(O[D[e]],O[D[e+1]],n))return!1;return!0}};e([r({constructOnly:!0})],w.prototype,`layerElevationSource`,void 0),e([r({constructOnly:!0})],w.prototype,`intersectionHandler`,void 0),e([r({constructOnly:!0})],w.prototype,`view`,void 0),e([r()],w.prototype,`spatialReference`,null),w=e([i(`esri.views.3d.layers.i3s.LayerElevationProvider`)],w);const T=new g,E=c(),D=[0,1,2,3,4,5,6,7,0,2,1,3,4,6,5,7,0,4,1,5,2,6,3,7],O=Array.from({length:8},()=>c()),k=c(),A=c(),j=a(),M=f(),N=c();function P(e){N[0]=-e.centerX,N[1]=-e.centerY,N[2]=-e.centerZ,e.getQuaternion(j),s(N,N,-j[0],-j[1],-j[2],j[3]);let t=Math.max(Math.abs(N[0])-e.halfSizeX,0),n=Math.max(Math.abs(N[1])-e.halfSizeY,0),r=Math.max(Math.abs(N[2])-e.halfSizeZ,0);return t*t+n*n+r*r<=S*S}export{w as LayerElevationProvider};
2
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import n from"../../../../core/Logger.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as o,transformQuatValues as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as l}from"../../../../geometry/projectionUtils.js";import{projectBoundingRect as u}from"../../../../geometry/projection/projectBoundingRect.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{create as f,allFinite as p,fromExtent as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import{Sphere as g}from"../../../../geometry/support/sphere.js";import{ElevationRange as _}from"../../support/ElevationRange.js";import{ElevationUpdateEvent as v}from"../../support/ElevationUpdateEvent.js";import{ProjectedElevationUpdateExtent as y,calculateElevationUpdateExtents as b,fullWorldElevationUpdateExtent as x,planetCenterProximityToleranceMeters as S}from"../../support/elevationUpdateExtentUtils.js";import{Intersector as C}from"../../webgl-engine/lib/Intersector.js";let w=class extends t{constructor(e){super(e),this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource,this._projectedExtent=new y(this._renderCoordsHelper)}initialize(){this._intersector=new C(this.view.state.viewingMode),this._intersector.options.store=0,this._intersector.options.normalRequired=!1}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,r,i){let a=this._renderCoordsHelper,s=o(E,e,t,r);if(!a.toRenderCoords(s,i,s))return n.getLogger(this).error(`could not project point to compute elevation`),null;let{layerElevationSource:c,_intersector:l,intersectionHandler:u}=this,d=c.elevationRange;if(d==null||d.isEmpty)return null;let f=d.minElevation,p=d.maxElevation,m=Math.max(1,(p-f)/2),h=a.setAltitude(k,p+m,s),g=a.setAltitude(A,f-m,s);return l.reset(h,g,this.view.state.camera),u.intersectRay(l,null,h,g,null,!0),l.results.min.getIntersectionPoint(s)?a.getAltitude(s):null}getElevations(e,t,n){let{groundSpatialReference:r}=this.view;for(let i=0;i<t;++i){let t=i*3,a=e[t],o=e[t+1],s=this.getElevation(a,o,0,r);n(i,s)}}getSphereElevationRange(e,t){return d(e,t,T,this._renderSR),this._layerElevationSource.getElevationRange(T)}getRootElevationRange(){let e=this.layerElevationSource.fullExtent;return e?.hasZ?new _(e.zmin,e.zmax):null}notifyObjectsChanged(e){this._notifyObjectsChanged(e.length,t=>{for(let n of e)if(!t(n))break})}notifyObjectsChangedFunctional(e,t){this._notifyObjectsChanged(e,t)}notifyObjectChanged(e){this._notifyObjectsChanged(1,t=>{t(e)})}_notifyObjectsChanged(e,t){if(e===0)return;let n=this.spatialReference;if(n==null)return;if(!l(this._renderSR,n)){this._emitFullExtentElevationChange(n);return}let r=new Float64Array(4*e),i=!1,a=0;t(e=>this._computeObjectExtent(e,r,a,n)?(a++,!0):(i=!0,!1)),i?this._emitFullExtentElevationChange(n):this._emitElevationChangeEvents(r,n)}_computeObjectExtent(e,t,n,r){if(this.view.state.viewingMode===1&&P(e))return!1;let i=this._projectedExtent;return E[0]=e.centerX,E[1]=e.centerY,E[2]=e.centerZ,i.reset(E,e.radius,r),!this._expandExtent(e,i,r)||!p(i.extent)?!1:(t.set(i.extent,4*n),!0)}_emitElevationChangeEvents(e,t){for(let n of b(e,t))this._emitElevationChangeEvent(n,t)}_emitFullExtentElevationChange(e){let t=f(),n=this._layerElevationSource.fullExtent;if(n!=null&&u(m(n,M),n.spatialReference,t,e)&&p(t)){this._emitElevationChangeEvent(t,e);return}let r=h(e);r!=null&&this._emitElevationChangeEvent(x(e,r),e)}_emitElevationChangeEvent(e,t){let n=new v(t,e,this.intersectionHandler.isGround?`ground`:`scene`);this.emit(`elevation-change`,n)}_expandExtent(e,t,n){e.getCorners(O);for(let e=0;e<8;++e){let r=O[e];if(t.addRenderPoint(r,n)==null)return!1}for(let e=0;e<D.length;e+=2)if(!t.addRenderEdge(O[D[e]],O[D[e+1]],n))return!1;return!0}};e([r({constructOnly:!0})],w.prototype,`layerElevationSource`,void 0),e([r({constructOnly:!0})],w.prototype,`intersectionHandler`,void 0),e([r({constructOnly:!0})],w.prototype,`view`,void 0),e([r()],w.prototype,`spatialReference`,null),w=e([i(`esri.views.3d.layers.i3s.LayerElevationProvider`)],w);const T=new g,E=c(),D=[0,1,2,3,4,5,6,7,0,2,1,3,4,6,5,7,0,4,1,5,2,6,3,7],O=Array.from({length:8},()=>c()),k=c(),A=c(),j=a(),M=f(),N=c();function P(e){N[0]=-e.centerX,N[1]=-e.centerY,N[2]=-e.centerZ,e.getQuaternion(j),s(N,N,-j[0],-j[1],-j[2],j[3]);let t=Math.max(Math.abs(N[0])-e.halfSizeX,0),n=Math.max(Math.abs(N[1])-e.halfSizeY,0),r=Math.max(Math.abs(N[2])-e.halfSizeZ,0);return t*t+n*n+r*r<=S*S}export{w as LayerElevationProvider};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{sub as n,normalize as r,len as i,dot as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as c,isEmpty as l,containedBySphere as u,setEmpty as d,intersectsSphere as f,intersectsRay as p,copy as m,exactEquals as h}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as g}from"../../../../geometry/support/aaBoundingRect.js";import{earth as _}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as v}from"../../support/ElevationRange.js";function y(e,t){return e===`local`?new x(t):new S(t)}class b{constructor(e,t){this.viewingMode=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:n}=e,r=[this._ensureRootNode()],i=[],a=t(this._tileMap,e,()=>new Set),o=t=>{if(a.has(t))return;let n=t.addOwnTile(e);T(i,t.parent,n),a.add(t)};for(;r.length>0;){let t=r.pop(),i=this._getSizeStopLength(t);if(t.treeDepth>=U||A(e.obb)>=.5*i){o(t);continue}let{hPlane:a,vPlane:s}=t,c=n.signedDistancePlane(a.normal,a.distance),l=n.signedDistancePlane(s.normal,s.distance);c===0&&l===0?o(t):w(t,c,l,(e,t)=>{r.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(i)}removeTile(t){if(!this._rootNode){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let n=this._tileMap.get(t);if(!n||n.size===0){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let r=[];this._tileMap.delete(t);for(let e of n){e.removeOwnTile(t);let n=e.updateOwnSummaries();T(r,e.parent,n)}this._propagateSummaryUpdates(r)}_propagateSummaryUpdates(e){if(e.length===0)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1,r=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){let i=t.size>0?n:r(),a=t;for(t=new Map;e.length>0&&r()===i;){let{node:t,childrenUpdateKind:n}=e.pop();E(a,t,n)}for(let[e,n]of a){let r=0;for(let t=0;t<4;t++){let n=e.children[t];n&&n.isLeaf&&!n.hasTiles&&(n.clear(),e.children[t]=null,r=3)}r|=e.updateSubtreeSummaries(n|r),E(t,e.parent,r)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,r){r?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(e,t,i){let a=this._rootNode;if(!a)return;n(B,t,e);let o=r(B,B);if(!a.subtreeIntersectsRay(e,o,{tMin:0,tMax:1/0}))return;let s=this._nextIntersectionGeneration(),c=[a],l=H;l.length=0,l.push(0,1/0);let u={tMin:0,tMax:1/0};for(;c.length>0;){let t=c.pop();u.tMax=l.pop(),u.tMin=l.pop(),t.forEachOwnTileIntersectingRay(e,o,u,s,i);let{hPlane:n,vPlane:r}=t;for(let i=0;i<4;i++){let a=t.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(e,o,N(e,o,u,r,!d),n,!f);p&&a.subtreeIntersectsRay(e,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}}_forEachTileIntersectingVerticalRay(e,t,a){let o=this._rootNode;if(!o)return;n(B,t,e);let s=r(B,B),c={tMin:0,tMax:this.viewingMode===`global`?i(e):1/0};if(!o.subtreeIntersectsRay(e,s,c))return;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let t=u.pop();t.forEachOwnTileIntersectingRay(e,s,c,l,a),t.isLeaf||w(t,k(t.hPlane,e),k(t.vPlane,e),(t,n)=>{let r=t.children[n];r&&r.subtreeIntersectsRay(e,s,c)&&u.push(r)},1)}}getElevationRangeIntersectingSphere(e){let t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;let n=this._nextIntersectionGeneration(),r=new v,i=[t];for(;i.length>0;){let t=i.pop();if(!r.contains(t.subtreeElevationRange)){if(t.subtreeContainedBySphere(e))r.expandElevationRange(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(let i of t.ownTiles){if(i.bvhIntersectionGeneration===n||(i.bvhIntersectionGeneration=n,!(i.boundingVolumeIntersectsSphere?.(e)??i.obb.intersectSphere(e))))continue;let t=i.elevationRange;r.contains(t)||r.expandElevationRange(t)}t.isLeaf||w(t,O(e.center,e.radius,t.hPlane),O(e.center,e.radius,t.vPlane),(t,n)=>{let a=t.children[n];if(a&&a.subtreeIntersectsSphere(e)){if(r.contains(a.subtreeElevationRange))return;i.push(a)}})}}}return r.isEmpty?null:r}}class x extends b{constructor(e){super(`local`,e)}_getSizeStopLength(e){return e.sideLength}_ensureRootNode(){if(!this._rootNode){let e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=2**Math.max(1,Math.ceil(Math.log2(t))),r=new C(null,0,g(-n,-n,n,n),new D(o(0,1,0),0),new D(o(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Internal error: attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=t,l=.5*(e[0]+e[2]),u=.5*(e[1]+e[3]),d=n===0||n===1,f=n===2||n===0,p=g(f?e[0]:l,d?e[1]:u,f?l:e[2],d?u:e[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));r=new C(t,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),t.children[n]=r}return r}}class S extends b{constructor(e){super(`global`,e)}_getSizeStopLength(e){return M(e.extent)}_ensureRootNode(){if(!this._rootNode){let e=new C(null,0,g(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new D(o(0,0,1),0),new D(o(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,treeDepth:i}=t,a=.5*(e[0]+e[2]),s=.5*(e[1]+e[3]),c=n===0||n===1,l=n===2||n===0,u=g(l?e[0]:a,c?e[1]:s,l?a:e[2],c?s:e[3]),d=.5*(u[0]+u[2]),f=.5*(u[1]+u[3]),p=Math.cos(d),m=Math.sin(d),h=Math.cos(f),_=Math.sin(f),v=o(-_*p,-_*m,h),y=new D(v,0),b=new D(o(-m,p,0),0),x=j(u);r=new C(t,i+1,u,y,b,x),t.children[n]=r}return r}}class C{constructor(e,t,n,r,i,a,o){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=r,this.vPlane=i,this.sideLength=a,this.bounds=o,this._ownAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new v,this._subtreeElevationRange=new v,this._ownTiles=[],this.children=[null,null,null,null]}get subtreeAABB(){return this._subtreeAABB}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){let t=this._subtreeAABB;return l(t)?!0:u(t,e)}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this._ownTiles.length=0,d(this._ownAABB),d(this._subtreeAABB),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>e==null)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return f(this.subtreeAABB,e)}ownIntersectsSphere(e){return this.hasTiles&&f(this._ownAABB,e)}subtreeIntersectsRay(e,t,n){return p(this._subtreeAABB,e,t,n)}ownIntersectsRay(e,t,n){return this.hasTiles?p(this._ownAABB,e,t,n):null}forEachOwnTileIntersectingRay(e,t,n,r,i){if(this.ownIntersectsRay(e,t,n))for(let n of this.ownTiles)n.bvhIntersectionGeneration!==r&&(n.bvhIntersectionGeneration=r,(n.boundingVolumeIntersectsRay?.(e,t)??n.obb.intersectRay(e,t))&&i(n))}addOwnTile(e){this._ownTiles.push(e);let t=P(this._ownAABB,e,this.bounds)&&F(this._subtreeAABB,this._ownAABB,this.bounds),n=this._ownElevationRange.expandElevationRange(e.elevationRange)&&this._subtreeElevationRange.expandElevationRange(e.elevationRange);return!!t|(n?2:0)}removeOwnTile(t){let n=this._ownTiles,r=n.indexOf(t);if(r===-1){e.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let i=n.length-1;r<i&&(n[r]=n[i]),n.length=i}updateOwnSummaries(){let e=I(this._ownAABB,this.ownTiles,this.bounds),t=L(this._ownElevationRange,this.ownTiles),n=!!e|(t?2:0);return this.updateSubtreeSummaries(n)}updateSubtreeSummaries(e){if(this.isLeaf&&!this.hasTiles)return d(this._subtreeAABB),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(e&1){m(R,this._subtreeAABB),d(this._subtreeAABB),F(this._subtreeAABB,this._ownAABB,this.bounds);for(let e of this.children)e&&F(this._subtreeAABB,e.subtreeAABB,this.bounds);h(this._subtreeAABB,R)||(t|=1)}if(e&2){z.setElevationRange(this._subtreeElevationRange),this._subtreeElevationRange.initializeEmpty(),this._subtreeElevationRange.expandElevationRange(this._ownElevationRange);for(let e of this.children)e&&this._subtreeElevationRange.expandElevationRange(e.subtreeElevationRange);this._subtreeElevationRange.equals(z)||(t|=2)}return t}get ownTiles(){return this._ownTiles}get hasTiles(){return this._ownTiles.length>0}}function w(e,t,n,r,i=1e-12){t<=i&&(n<=i&&r(e,0),n>=-i&&r(e,1)),t>=-i&&(n<=i&&r(e,2),n>=-i&&r(e,3))}function T(e,t,n){t!=null&&n!==0&&e.push({node:t,childrenUpdateKind:n})}function E(e,t,n){if(t==null||n===0)return;let r=e.get(t)??0;e.set(t,r|n)}class D{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function O(e,t,n){let r=a(n.normal,e)+n.distance;return r<0?Math.min(r+t,0):Math.max(r-t,0)}function k(e,t){return a(e.normal,t)+e.distance}function A(e){return 2*Math.max(e.halfSizeX,e.halfSizeY,e.halfSizeZ)}function j(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.max(i,a)}function M(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.min(i,a)}function N(e,t,n,r,i){if(!n)return null;let o=1e-12,s=a(r.normal,t),c=k(r,e)+n.tMin*s;if(Math.abs(s)<o)return(i?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=i===s>0?{tMin:Math.max(n.tMin,l),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,l)};return u.tMin<=u.tMax?u:null}function P(e,t,n){let{obb:r}=t,i=[o(1,0,0),o(0,1,0),o(0,0,1)],a=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let o=r.projectedRadius(i[t]),c=Math.max(n?.[t]??-1/0,a[t]-o),l=Math.min(n?.[t+3]??1/0,a[t]+o);c<e[t]&&(e[t]=c,s=!0),l>e[t+3]&&(e[t+3]=l,s=!0)}return s}function F(e,t,n){if(l(t))return!1;let r=!1;for(let i=0;i<3;i++){let a=Math.max(n?.[i]??-1/0,t[i]),o=Math.min(n?.[i+3]??1/0,t[i+3]);a<e[i]&&(e[i]=a,r=!0),o>e[i+3]&&(e[i+3]=o,r=!0)}return r}function I(e,t,n){m(R,e),d(e);for(let r of t)P(e,r,n);return!h(e,R)}function L(e,t){z.setElevationRange(e),e.initializeEmpty();for(let n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}const R=c(0,0,0,0,0,0),z=new v,B=s(),V=s(),H=[],U=30;export{y as createTileBVH};
2
+ import e from"../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../core/MapUtils.js";import{sub as n,normalize as r,len as i,dot as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as o,create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as c,isEmpty as l,containedBySphere as u,setEmpty as d,intersectsSphere as f,intersectsRay as p,copy as m,exactEquals as h}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as g}from"../../../../geometry/support/aaBoundingRect.js";import{earth as _}from"../../../../geometry/support/Ellipsoid.js";import{ElevationRange as v}from"../../support/ElevationRange.js";function y(e,t){return e===`local`?new x(t):new S(t)}class b{constructor(e,t){this.viewingMode=e,this.layerExtent=t,this._rootNode=null,this._intersectionGeneration=0,this._tileMap=new Map}get elevationRange(){return this._rootNode?.subtreeElevationRange}destroy(){this._rootNode?.clear(),this._tileMap.clear()}_nextIntersectionGeneration(){return this._intersectionGeneration++,this._intersectionGeneration}addTile(e){let{obb:n}=e,r=[this._ensureRootNode()],i=[],a=t(this._tileMap,e,()=>new Set),o=t=>{if(a.has(t))return;let n=t.addOwnTile(e);T(i,t.parent,n),a.add(t)};for(;r.length>0;){let t=r.pop(),i=this._getSizeStopLength(t);if(t.treeDepth>=U||A(e.obb)>=.5*i){o(t);continue}let{hPlane:a,vPlane:s}=t,c=n.signedDistancePlane(a.normal,a.distance),l=n.signedDistancePlane(s.normal,s.distance);c===0&&l===0?o(t):w(t,c,l,(e,t)=>{r.push(this._ensureChild(e,t))})}this._propagateSummaryUpdates(i)}removeTile(t){if(!this._rootNode){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH: Attempted to remove a tile that is not loaded (no root node)`);return}let n=this._tileMap.get(t);if(!n||n.size===0){e.getLogger(`Tiles3DBVH`).error(`Tiles3DBVH internal error: Attempted to remove a tile that is not loaded (not in tile map)`);return}let r=[];this._tileMap.delete(t);for(let e of n){e.removeOwnTile(t);let n=e.updateOwnSummaries();T(r,e.parent,n)}this._propagateSummaryUpdates(r)}_propagateSummaryUpdates(e){if(e.length===0)return;e.sort((e,t)=>e.node.treeDepth-t.node.treeDepth);let t=new Map,n=-1,r=()=>e.length>0?e[e.length-1].node.treeDepth:-1;for(;e.length>0||t.size>0;){let i=t.size>0?n:r(),a=t;for(t=new Map;e.length>0&&r()===i;){let{node:t,childrenUpdateKind:n}=e.pop();E(a,t,n)}for(let[e,n]of a){let r=0;for(let t=0;t<4;t++){let n=e.children[t];n&&n.isLeaf&&!n.hasTiles&&(n.clear(),e.children[t]=null,r=3)}r|=e.updateSubtreeSummaries(n|r),E(t,e.parent,r)}t.size>0&&(n=i-1)}}forEachTileIntersectingRay(e,t,n,r){r?this._forEachTileIntersectingVerticalRay(e,t,n):this._forEachTileIntersectingRayGeneral(e,t,n)}_forEachTileIntersectingRayGeneral(e,t,i){let a=this._rootNode;if(!a)return;n(B,t,e);let o=r(B,B);if(!a.subtreeIntersectsRay(e,o,{tMin:0,tMax:1/0}))return;let s=this._nextIntersectionGeneration(),c=[a],l=H;l.length=0,l.push(0,1/0);let u={tMin:0,tMax:1/0};for(;c.length>0;){let t=c.pop();u.tMax=l.pop(),u.tMin=l.pop(),t.forEachOwnTileIntersectingRay(e,o,u,s,i);let{hPlane:n,vPlane:r}=t;for(let i=0;i<4;i++){let a=t.children[i];if(a==null)continue;let s=i,d=s===0||s===2,f=s===0||s===1,p=N(e,o,N(e,o,u,r,!d),n,!f);p&&a.subtreeIntersectsRay(e,o,p)&&(c.push(a),l.push(p.tMin,p.tMax))}}}_forEachTileIntersectingVerticalRay(e,t,a){let o=this._rootNode;if(!o)return;n(B,t,e);let s=r(B,B),c={tMin:0,tMax:this.viewingMode===`global`?i(e):1/0};if(!o.subtreeIntersectsRay(e,s,c))return;let l=this._nextIntersectionGeneration(),u=[o];for(;u.length>0;){let t=u.pop();t.forEachOwnTileIntersectingRay(e,s,c,l,a),t.isLeaf||w(t,k(t.hPlane,e),k(t.vPlane,e),(t,n)=>{let r=t.children[n];r&&r.subtreeIntersectsRay(e,s,c)&&u.push(r)},1)}}getElevationRangeIntersectingSphere(e){let t=this._rootNode;if(!t||!t.subtreeIntersectsSphere(e))return null;let n=this._nextIntersectionGeneration(),r=new v,i=[t];for(;i.length>0;){let t=i.pop();if(!r.contains(t.subtreeElevationRange)){if(t.subtreeContainedBySphere(e))r.expandElevationRange(t.subtreeElevationRange);else{if(t.ownIntersectsSphere(e))for(let i of t.ownTiles){if(i.bvhIntersectionGeneration===n||(i.bvhIntersectionGeneration=n,!(i.boundingVolumeIntersectsSphere?.(e)??i.obb.intersectSphere(e))))continue;let t=i.elevationRange;r.contains(t)||r.expandElevationRange(t)}t.isLeaf||w(t,O(e.center,e.radius,t.hPlane),O(e.center,e.radius,t.vPlane),(t,n)=>{let a=t.children[n];if(a&&a.subtreeIntersectsSphere(e)){if(r.contains(a.subtreeElevationRange))return;i.push(a)}})}}}return r.isEmpty?null:r}}class x extends b{constructor(e){super(`local`,e)}_getSizeStopLength(e){return e.sideLength}_ensureRootNode(){if(!this._rootNode){let e=this.layerExtent,t=Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])),n=2**Math.max(1,Math.ceil(Math.log2(t))),r=new C(null,0,g(-n,-n,n,n),new D(o(0,1,0),0),new D(o(1,0,0),0),n*2,c(-n,-n,-1/0,n,n,1/0));this._rootNode=r}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Internal error: attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,hPlane:i,vPlane:a,treeDepth:o,sideLength:s}=t,l=.5*(e[0]+e[2]),u=.5*(e[1]+e[3]),d=n===0||n===1,f=n===2||n===0,p=g(f?e[0]:l,d?e[1]:u,f?l:e[2],d?u:e[3]),m=new D(i.normal,-.5*(p[1]+p[3])),h=new D(a.normal,-.5*(p[0]+p[2]));r=new C(t,o+1,p,m,h,s*.5,c(p[0],p[1],-1/0,p[2],p[3],1/0)),t.children[n]=r}return r}}class S extends b{constructor(e){super(`global`,e)}_getSizeStopLength(e){return M(e.extent)}_ensureRootNode(){if(!this._rootNode){let e=new C(null,0,g(-Math.PI,-Math.PI/2,Math.PI,Math.PI/2),new D(o(0,0,1),0),new D(o(0,1,0),0),Math.PI*_.radius);this._rootNode=e}return this._rootNode}_ensureChild(t,n){if(t.treeDepth>=U){let t=`Attempted to create a child node for a node that is already at max depth`;throw e.getLogger(`Tiles3DBVH`).error(t),Error(t)}let r=t.children[n];if(r===null){let{extent:e,treeDepth:i}=t,a=.5*(e[0]+e[2]),s=.5*(e[1]+e[3]),c=n===0||n===1,l=n===2||n===0,u=g(l?e[0]:a,c?e[1]:s,l?a:e[2],c?s:e[3]),d=.5*(u[0]+u[2]),f=.5*(u[1]+u[3]),p=Math.cos(d),m=Math.sin(d),h=Math.cos(f),_=Math.sin(f),v=o(-_*p,-_*m,h),y=new D(v,0),b=new D(o(-m,p,0),0),x=j(u);r=new C(t,i+1,u,y,b,x),t.children[n]=r}return r}}class C{constructor(e,t,n,r,i,a,o){this.parent=e,this._treeDepth=t,this.extent=n,this.hPlane=r,this.vPlane=i,this.sideLength=a,this.bounds=o,this._ownAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._subtreeAABB=c(1/0,1/0,1/0,-1/0,-1/0,-1/0),this._ownElevationRange=new v,this._subtreeElevationRange=new v,this._ownTiles=[],this.children=[null,null,null,null]}get subtreeAABB(){return this._subtreeAABB}get subtreeElevationRange(){return this._subtreeElevationRange}subtreeContainedBySphere(e){let t=this._subtreeAABB;return l(t)?!0:u(t,e)}clear(){for(let e=0;e<4;e++)this.children[e]?.clear(),this.children[e]=null;this._ownTiles.length=0,d(this._ownAABB),d(this._subtreeAABB),this._ownElevationRange.initializeEmpty(),this._subtreeElevationRange.initializeEmpty()}get isLeaf(){return this.children.every(e=>e==null)}get treeDepth(){return this._treeDepth}subtreeIntersectsSphere(e){return f(this.subtreeAABB,e)}ownIntersectsSphere(e){return this.hasTiles&&f(this._ownAABB,e)}subtreeIntersectsRay(e,t,n){return p(this._subtreeAABB,e,t,n)}ownIntersectsRay(e,t,n){return this.hasTiles?p(this._ownAABB,e,t,n):null}forEachOwnTileIntersectingRay(e,t,n,r,i){if(this.ownIntersectsRay(e,t,n))for(let n of this.ownTiles)n.bvhIntersectionGeneration!==r&&(n.bvhIntersectionGeneration=r,(n.boundingVolumeIntersectsRay?.(e,t)??n.obb.intersectRay(e,t))&&i(n))}addOwnTile(e){this._ownTiles.push(e);let t=P(this._ownAABB,e,this.bounds)&&F(this._subtreeAABB,this._ownAABB,this.bounds),n=this._ownElevationRange.expandElevationRange(e.elevationRange)&&this._subtreeElevationRange.expandElevationRange(e.elevationRange);return!!t|(n?2:0)}removeOwnTile(t){let n=this._ownTiles,r=n.indexOf(t);if(r===-1){e.getLogger(`Tiles3DBVH`).error(`BVNode: Attempted to remove a tile that is not in the node`);return}let i=n.length-1;r<i&&(n[r]=n[i]),n.length=i}updateOwnSummaries(){let e=I(this._ownAABB,this.ownTiles,this.bounds),t=L(this._ownElevationRange,this.ownTiles),n=!!e|(t?2:0);return this.updateSubtreeSummaries(n)}updateSubtreeSummaries(e){if(this.isLeaf&&!this.hasTiles)return d(this._subtreeAABB),this._subtreeElevationRange.initializeEmpty(),3;let t=0;if(e&1){m(R,this._subtreeAABB),d(this._subtreeAABB),F(this._subtreeAABB,this._ownAABB,this.bounds);for(let e of this.children)e&&F(this._subtreeAABB,e.subtreeAABB,this.bounds);h(this._subtreeAABB,R)||(t|=1)}if(e&2){z.setElevationRange(this._subtreeElevationRange),this._subtreeElevationRange.initializeEmpty(),this._subtreeElevationRange.expandElevationRange(this._ownElevationRange);for(let e of this.children)e&&this._subtreeElevationRange.expandElevationRange(e.subtreeElevationRange);this._subtreeElevationRange.equals(z)||(t|=2)}return t}get ownTiles(){return this._ownTiles}get hasTiles(){return this._ownTiles.length>0}}function w(e,t,n,r,i=1e-12){t<=i&&(n<=i&&r(e,0),n>=-i&&r(e,1)),t>=-i&&(n<=i&&r(e,2),n>=-i&&r(e,3))}function T(e,t,n){t!=null&&n!==0&&e.push({node:t,childrenUpdateKind:n})}function E(e,t,n){if(t==null||n===0)return;let r=e.get(t)??0;e.set(t,r|n)}class D{constructor(e=[0,0,0],t=0){this.normal=e,this.distance=t}}function O(e,t,n){let r=a(n.normal,e)+n.distance;return r<0?Math.min(r+t,0):Math.max(r-t,0)}function k(e,t){return a(e.normal,t)+e.distance}function A(e){return 2*Math.max(e.halfSizeX,e.halfSizeY,e.halfSizeZ)}function j(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.max(i,a)}function M(e){let t=Math.abs(e[2]-e[0]),n=Math.abs(e[3]-e[1]),r=.5*(e[1]+e[3]),i=_.radius*Math.abs(Math.cos(r))*t,a=_.radius*n;return Math.min(i,a)}function N(e,t,n,r,i){if(!n)return null;let o=1e-12,s=a(r.normal,t),c=k(r,e)+n.tMin*s;if(Math.abs(s)<o)return(i?c>=-1e-12:c<=o)?n:null;let l=n.tMin-c/s,u=i===s>0?{tMin:Math.max(n.tMin,l),tMax:n.tMax}:{tMin:n.tMin,tMax:Math.min(n.tMax,l)};return u.tMin<=u.tMax?u:null}function P(e,t,n){let{obb:r}=t,i=[o(1,0,0),o(0,1,0),o(0,0,1)],a=r.getCenter(V),s=!1;for(let t=0;t<3;t++){let o=r.projectedRadius(i[t]),c=Math.max(n?.[t]??-1/0,a[t]-o),l=Math.min(n?.[t+3]??1/0,a[t]+o);c<e[t]&&(e[t]=c,s=!0),l>e[t+3]&&(e[t+3]=l,s=!0)}return s}function F(e,t,n){if(l(t))return!1;let r=!1;for(let i=0;i<3;i++){let a=Math.max(n?.[i]??-1/0,t[i]),o=Math.min(n?.[i+3]??1/0,t[i+3]);a<e[i]&&(e[i]=a,r=!0),o>e[i+3]&&(e[i+3]=o,r=!0)}return r}function I(e,t,n){m(R,e),d(e);for(let r of t)P(e,r,n);return!h(e,R)}function L(e,t){z.setElevationRange(e),e.initializeEmpty();for(let n of t)e.expandElevationRange(n.elevationRange);return!e.equals(z)}const R=c(0,0,0,0,0,0),z=new v,B=s(),V=s(),H=[],U=30;export{y as createTileBVH};
@@ -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{project as t}from"../../../../geometry/projectionUtils.js";import{fromExtent as n}from"../../../../geometry/support/aaBoundingRect.js";import{Tiles3DTarget as r}from"../i3s/Intersector.js";import{createTileBVH as i}from"./Tiles3DBVH.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{IntersectorResultRay as o}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as s,computeInvDir as c,intersectAabbInvDir as l}from"../../webgl-engine/lib/RayIntersections.js";class u{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.layerViewUid=e.uid;let r=e.view.viewingMode,a=(e.useEsriCrs?e.fullExtentInLocalViewSpatialReference:e.layer.fullExtent?t(e.layer.fullExtent,e.view.renderSpatialReference):void 0)??e.view.extent,o=n(a);this.isGround=!has(`enable-feature:im-as-ground`)||e.layer.isUsedAsGroundLayer,this._bvh=i(r,o)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}intersectRay(e,t,n,i,a,u){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;let{results:f,tolerance:p}=e,m=e.options.store===2,{componentObjectCollection:h}=this.layerView.view.stage.renderView,g=new s(p,u,e.options.normalRequired),_=c(n,i,d),v=(a,s,c)=>{if(s<0||t!=null&&!t(n,i,a))return;let l=e=>{let t=new r(this.layerView.uid);e.set(this.type,t,a,s,c)};if(this.isGround&&(f.ground.renderDistance==null||s<f.ground.renderDistance)&&l(f.ground),!e.options.isFiltered&&((f.min.renderDistance==null||s<f.min.renderDistance)&&l(f.min),(f.max.renderDistance==null||s>f.max.renderDistance)&&l(f.max),m)){let t=new o(e.ray);l(t),e.results.all.push(t)}};this._bvh.forEachTileIntersectingRay(n,i,e=>{let{componentObjects:t}=e;for(let e of t)l(e.aabbInWorldCoordinates,n,_,0)&&h.intersectRay(e,n,i,null,g,v)},u)}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new a(0,0)}}const d=e();export{u as Tiles3DMeshIntersectionHandler};
2
+ import has from"../../../../core/has.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{project as t}from"../../../../geometry/projectionUtils.js";import{fromExtent as n}from"../../../../geometry/support/aaBoundingRect.js";import{Tiles3DTarget as r}from"../i3s/Intersector.js";import{createTileBVH as i}from"./Tiles3DBVH.js";import{ElevationRange as a}from"../../support/ElevationRange.js";import{IntersectorResultRay as o}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as s,computeInvDir as c,intersectAabbInvDir as l}from"../../webgl-engine/lib/RayIntersections.js";class u{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.layerViewUid=e.uid;let r=e.view.viewingMode,a=(e.useEsriCrs?e.fullExtentInLocalViewSpatialReference:e.layer.fullExtent?t(e.layer.fullExtent,e.view.renderSpatialReference):void 0)??e.view.extent,o=n(a);this.isGround=!has(`enable-feature:im-as-ground`)||e.layer.isUsedAsGroundLayer,this._bvh=i(r,o)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}intersectRay(e,t,n,i,a,u){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;let{results:f,tolerance:p}=e,m=e.options.store===2,{componentObjectCollection:h}=this.layerView.view.stage.renderView,g=new s(p,u,e.options.normalRequired),_=c(n,i,d),v=(a,s,c)=>{if(s<0||t!=null&&!t(n,i,a))return;let l=e=>{let t=new r(this.layerView.uid);e.set(this.type,t,a,s,c)};if(this.isGround&&(f.ground.renderDistance==null||s<f.ground.renderDistance)&&l(f.ground),!e.options.isFiltered&&((f.min.renderDistance==null||s<f.min.renderDistance)&&l(f.min),(f.max.renderDistance==null||s>f.max.renderDistance)&&l(f.max),m)){let t=new o(e.ray);l(t),e.results.all.push(t)}};this._bvh.forEachTileIntersectingRay(n,i,e=>{let{componentObjects:t}=e;for(let e of t)l(e.aabbInWorldCoordinates,n,_,0)&&h.intersectRay(e,n,i,null,g,v)},u)}get elevationRange(){let e=this._bvh.elevationRange;return e!=null&&!e.isEmpty?new a(e.minElevation,e.maxElevation):null}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new a(0,0)}}const d=e();export{u as Tiles3DMeshIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{set as e,dist as t}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ONES as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as i}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as a}from"../../../../geometry/projection/projectors.js";import{newDoubleArray as o}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as s}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as c}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as l}from"../../../../geometry/support/Indices.js";import{addOlidAttribute as u}from"../../layers/graphics/olidUtils.js";import{getPlanarDistanceToGroundRatio as d}from"../planarDistanceToGroundRatio.js";import{Attribute as f}from"../../webgl-engine/lib/Attribute.js";import{Geometry as p}from"../../webgl-engine/lib/Geometry.js";import{isImagePattern as m}from"../../webgl-engine/materials/lineStippleUtils.js";function h(e,t,n=null){let r=[],i=t.mapPositions,a=g(t,r),o=a.data,s=a.indices.length,c=l(s);return _(t,r,c),b(t,r,c),v(t,r,c),y(t,r,a.indices,c),x(t,r,a.indices,c),S(t,r),C(t,r,a.indices,c),w(e,t,r,o),n!=null&&u(r,n,c),new p(e,r,i)}function g(e,t){let{attributeData:{position:n},removeDuplicateStartEnd:r}=e,i=n.length/3,a=i>2&&T(n)&&r,o=i-+!!a,s=Array(2*(o-1)),c=a?n.slice(0,-3):n,l=0;for(let e=0;e<o-1;e++)s[l++]=e,s[l++]=e+1;let u=new f(c,s,3,a);return t.push([`position`,u]),u}function _(e,t,n){if(e.attributeData.colorFeature!=null)return;let i=e.attributeData.color;t.push([`color`,new f(i??r,n,4)])}function v(e,t,n){e.attributeData.normal&&t.push([`normal`,new f(e.attributeData.normal,n,3)])}function y(e,t,n,r){let i=e.attributeData.colorFeature;i!=null&&(typeof i==`number`?t.push([`colorFeatureAttribute`,new f([i],r,1,!0)]):t.push([`colorFeatureAttribute`,new f(i,n,1,!0)]))}function b(e,t,n){e.attributeData.sizeFeature??t.push([`size`,new f([e.attributeData.size??1],n,1,!0)])}function x(e,t,n,r){let i=e.attributeData.sizeFeature;i!=null&&(typeof i==`number`?t.push([`sizeFeatureAttribute`,new f([i],r,1,!0)]):t.push([`sizeFeatureAttribute`,new f(i,n,1,!0)]))}function S(e,t){let{attributeData:{position:n,timeStamps:r}}=e;if(!r)return;let i=n.length/3,a=Array(2*(i-1)),o=0;for(let e=0;e<i-1;e++)a[o++]=e,a[o++]=e+1;t.push([`timeStamps`,new f(r,a,k,!0)])}function C(e,t,n,r){let i=e.attributeData.opacityFeature;i!=null&&(typeof i==`number`?t.push([`opacityFeatureAttribute`,new f([i],r,1,!0)]):t.push([`opacityFeatureAttribute`,new f(i,n,1,!0)]))}function w(n,{overlayInfo:r},c,l){let u=n.parameters;if(r==null||!E(u)||u.stipplePattern==null)return;let{renderCoordsHelper:p,spatialReference:h}=r,g=h.isGeographic&&p.viewingMode===1,_=u.worldSized||m(u.stipplePattern);if(!_&&!g)return;let v=l;if(g){let e=o(l.length),t=i(h);for(let n=0;n<e.length;n+=3)a(l,n,e,n,t);v=e}let y=l.length/3,b=s(y+1),x=p.viewingMode===1,S=D,C=O,w=0,T=0,k=0;e(S,v[T++],v[T++]),T++,b[0]=0;for(let n=1;n<y+1;++n){n===y&&(T=0);let r=T;e(C,v[T++],v[T++]),T++;let i=(l[k+1]+l[r+1])/2,a=_?d(h,x,i):1;w+=t(S,C)*a,b[n]=w,[S,C]=[C,S],k=r}c.push([`distanceToStart`,new f(b,c[0][1].indices,1,!0)])}function T(e){let t=e.length;return e[0]===e[t-3]&&e[1]===e[t-2]&&e[2]===e[t-1]}function E(e){return`stipplePattern`in e}const D=n(),O=n(),k=4;function A(e,t,n,r,i){if(e==null||e.length===0)return[];let a=[];return e.forEach((e,s)=>{let c=e.length,l=o(c*3);e.forEach((e,t)=>{l[t*3]=e[0],l[t*3+1]=e[1],l[t*3+2]=e[2]});let u={attributeData:{position:l,normal:t,colorFeature:n?.[s],opacityFeature:r?.[s],sizeFeature:i?.[s]},removeDuplicateStartEnd:!1};a.push(u)}),a}function j(e,t,n,r,i,a){if(e==null||e.length===0)return[];let o=A(e,t,r,i,a);return e.forEach((e,t)=>{let r=n?.[t],i=r==null?void 0:N(r.timeStamps,r.stage);o[t].attributeData.timeStamps=i}),o}function M(e,t=0,n=.01){let r=c(e.length);r[0]=0;for(let t=1;t<e.length;t++){let n=e[t-1],i=e[t],a=Math.sqrt((i[0]-n[0])**2+(i[1]-n[1])**2+(i[2]-n[2])**2);r[t]=r[t-1]+a}let i=r.map(e=>e*n);if(t!==0&&t<i.length){let e=i[t];for(let t=0;t<i.length;t++)i[t]-=e}return i}function N(e,t){let n=c(e.length*4),r=e[0],i=e[e.length-1];for(let a=0;a<e.length;a++)n[a*4]=e[a],n[a*4+1]=r,n[a*4+2]=i,n[a*4+3]=t+.5;return n}export{j as animatedLineStripsToParameters,h as createGeometry,M as getLinearTimeStamps,A as lineStripsToParameters,k as numTimeStampValuesPerVertex,N as timeStampsToAttribute};
2
+ import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,dist as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{negate as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as c}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as l}from"../../../../geometry/projection/projectors.js";import{fromBuffer as u,center as d,create as f}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as p}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as m}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as h}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as g}from"../../../../geometry/support/Indices.js";import{addOlidAttribute as _}from"../../layers/graphics/olidUtils.js";import{getPlanarDistanceToGroundRatio as v}from"../planarDistanceToGroundRatio.js";import{Attribute as y}from"../../webgl-engine/lib/Attribute.js";import{BufferGeometry as b}from"../../webgl-engine/lib/BufferGeometry.js";import{Buffers as x}from"../../webgl-engine/lib/Buffers.js";import{Geometry as S}from"../../webgl-engine/lib/Geometry.js";import{createVerticesView as C}from"../../webgl-engine/lib/VerticesView.js";import{isImagePattern as w}from"../../webgl-engine/materials/lineStippleUtils.js";import{ribbonLineVertexCount as T,writeRibbonLineTextureBuffer as E,writeRibbonLineVertices as D}from"../../webgl-engine/materials/internal/ribbonLineBufferUtils.js";import{getLayout as ee,getTextureBufferLayout as te}from"../../webgl-engine/shaders/RibbonLineLayouts.js";function O(e,t,n=null){let r=[],i=t.mapPositions,a=j(t,r),o=a.data,s=a.indices.length,c=g(s);return M(t,r,c),F(t,r,c),N(t,r,c),P(t,r,a.indices,c),I(t,r,a.indices,c),L(t,r),R(t,r,a.indices,c),z(e,t,r,o),n!=null&&_(r,n,c),new S(e,r,i)}function k(e,t){return u(e,X),d(X,Z),t.getOrigin(Z)}function A(t,n,r,i){let o=n.attributeData,s=C({data:o.position,size:3,stride:3},3),c=!!t.parameters.isClosed&&s.count>2,l=ee(t.parameters).createBuffer(T(s.count,c,t.parameters)),u=te(t.parameters).createBuffer(s.count+(c?3:2)),d=u.layout.fields.has(`u0`)?B(t.parameters,n.overlayInfo,o.position):null;return a(Q,r.vec3),e($,Q),E({...o,position:s,distancesToStart:d,olidColor:i},c,{buffer:u,offset:0},$),D(s.count,c,t.parameters,{buffer:l,offset:0},0),new b(t,new x(l,u),r,n.mapPositions)}function j(e,t){let{attributeData:{position:n},removeDuplicateStartEnd:r}=e,i=n.length/3,a=i>2&&V(n)&&r,o=i-+!!a,s=Array(2*(o-1)),c=a?n.slice(0,-3):n,l=0;for(let e=0;e<o-1;e++)s[l++]=e,s[l++]=e+1;let u=new y(c,s,3,a);return t.push([`position`,u]),u}function M(e,t,n){if(e.attributeData.colorFeature!=null)return;let r=e.attributeData.color;t.push([`color`,new y(r??s,n,4)])}function N(e,t,n){e.attributeData.normal&&t.push([`normal`,new y(e.attributeData.normal,n,3)])}function P(e,t,n,r){let i=e.attributeData.colorFeature;i!=null&&(typeof i==`number`?t.push([`colorFeatureAttribute`,new y([i],r,1,!0)]):t.push([`colorFeatureAttribute`,new y(i,n,1,!0)]))}function F(e,t,n){e.attributeData.sizeFeature??t.push([`size`,new y([e.attributeData.size??1],n,1,!0)])}function I(e,t,n,r){let i=e.attributeData.sizeFeature;i!=null&&(typeof i==`number`?t.push([`sizeFeatureAttribute`,new y([i],r,1,!0)]):t.push([`sizeFeatureAttribute`,new y(i,n,1,!0)]))}function L(e,t){let{attributeData:{position:n,timeStamps:r}}=e;if(!r)return;let i=n.length/3,a=Array(2*(i-1)),o=0;for(let e=0;e<i-1;e++)a[o++]=e,a[o++]=e+1;t.push([`timeStamps`,new y(r,a,G,!0)])}function R(e,t,n,r){let i=e.attributeData.opacityFeature;i!=null&&(typeof i==`number`?t.push([`opacityFeatureAttribute`,new y([i],r,1,!0)]):t.push([`opacityFeatureAttribute`,new y(i,n,1,!0)]))}function z(e,{overlayInfo:t},n,r){let i=B(e.parameters,t,r);i!=null&&n.push([`distanceToStart`,new y(i,n[0][1].indices,1,!0)])}function B(e,t,i){if(t==null||!H(e)||e.stipplePattern==null)return null;let{renderCoordsHelper:a,spatialReference:o}=t,s=o.isGeographic&&a.viewingMode===1,u=e.worldSized||w(e.stipplePattern);if(!u&&!s)return null;let d=i;if(s){let e=p(i.length),t=c(o);for(let n=0;n<e.length;n+=3)l(i,n,e,n,t);d=e}let f=i.length/3,h=m(f+1),g=a.viewingMode===1,_=U,y=W,b=0,x=0,S=0;n(_,d[x++],d[x++]),x++,h[0]=0;for(let e=1;e<f+1;++e){e===f&&(x=0);let t=x;n(y,d[x++],d[x++]),x++;let a=(i[S+1]+i[t+1])/2,s=u?v(o,g,a):1;b+=r(_,y)*s,h[e]=b,[_,y]=[y,_],S=t}return h}function V(e){let t=e.length;return e[0]===e[t-3]&&e[1]===e[t-2]&&e[2]===e[t-1]}function H(e){return`stipplePattern`in e}const U=i(),W=i(),G=4;function K(e,t,n,r,i){if(e==null||e.length===0)return[];let a=[];return e.forEach((e,o)=>{let s=e.length,c=p(s*3);e.forEach((e,t)=>{c[t*3]=e[0],c[t*3+1]=e[1],c[t*3+2]=e[2]});let l={attributeData:{position:c,normal:t,colorFeature:n?.[o],opacityFeature:r?.[o],sizeFeature:i?.[o]},removeDuplicateStartEnd:!1};a.push(l)}),a}function q(e,t,n,r,i,a){if(e==null||e.length===0)return[];let o=K(e,t,r,i,a);return e.forEach((e,t)=>{let r=n?.[t],i=r==null?void 0:Y(r.timeStamps,r.stage);o[t].attributeData.timeStamps=i}),o}function J(e,t=0,n=.01){let r=h(e.length);r[0]=0;for(let t=1;t<e.length;t++){let n=e[t-1],i=e[t],a=Math.sqrt((i[0]-n[0])**2+(i[1]-n[1])**2+(i[2]-n[2])**2);r[t]=r[t-1]+a}let i=r.map(e=>e*n);if(t!==0&&t<i.length){let e=i[t];for(let t=0;t<i.length;t++)i[t]-=e}return i}function Y(e,t){let n=h(e.length*4),r=e[0],i=e[e.length-1];for(let a=0;a<e.length;a++)n[a*4]=e[a],n[a*4+1]=r,n[a*4+2]=i,n[a*4+3]=t+.5;return n}const X=f(),Z=o(),Q=o(),$=t();export{q as animatedLineStripsToParameters,B as computeLineDistances,A as createBufferGeometry,O as createGeometry,J as getLinearTimeStamps,K as lineStripsToParameters,G as numTimeStampValuesPerVertex,k as selectLocalOrigin,Y as timeStampsToAttribute};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{createPrimitive as e}from"./sdfPrimitives.js";import{SizedPixelFormat as t,PixelType as n}from"../../../webgl/enums.js";import r from"../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../webgl/TextureDescriptor.js";const a=64,o=32,s=32/5,c=64/s,l=.25;function u(a,o){let c=e(a,64,32,s),l=new i(64);return l.internalFormat=t.R16F,l.dataType=n.FLOAT,l.pixelFormat=6403,l.wrapMode=33071,new r(o,l,c)}export{u as createMarkerTexture,c as markerSizePerLineWidth,o as markerSymbolSize,a as markerTextureSize,s as markerThickness,l as markerTipThicknessFactor};
2
+ import{createPrimitive as e}from"./sdfPrimitives.js";import{SizedPixelFormat as t,PixelType as n}from"../../../webgl/enums.js";import{Texture as r}from"../../../webgl/Texture.js";import{TextureDescriptor as i}from"../../../webgl/TextureDescriptor.js";const a=64,o=32,s=32/5,c=64/s,l=.25;function u(a,o){let c=e(a,64,32,s),l=new i(64);return l.internalFormat=t.R16F,l.dataType=n.FLOAT,l.pixelFormat=6403,l.wrapMode=33071,new r(o,l,c)}export{u as createMarkerTexture,c as markerSizePerLineWidth,o as markerSymbolSize,a as markerTextureSize,s as markerThickness,l as markerTipThicknessFactor};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import"../../../../core/has.js";import{estimateNestedObjectMemory as e}from"../../../../core/memoryEstimations.js";import{Seconds as t}from"../../../../core/time.js";import{fadeOutTime as n}from"./constants.js";import{FlowQuery3D as r}from"./FlowQuery3D.js";class i{constructor(e,n,r,i,a){this._query=e,this.streamlines=n,this._material=r,this.geometries=i,this._bytesPerFeature=a,this._endTime=t(1/0),this.usedMemory=null,this.computeMemory()}computeMemory(){let t=e(this.streamlines),n=e(this.geometries.map(e=>e.attributes)),r=this.streamlines.length*this._bytesPerFeature;this.usedMemory=t+n+r}get startTime(){return this._query.time}set startTime(e){this._query.time!==e&&(this._query=new r(this._query.extent,this._query.timeExtent,this._query.size,this._query.pixelRatio,t(e))),this.setMaterialParameters({startTime:e})}get endTime(){return this._endTime}set endTime(e){this._endTime!==e&&(this._endTime=e,this.setMaterialParameters({endTime:e}))}get query(){return this._query}hasFadedOut(e){return this.endTime+n<e}setMaterialParameters(e){this._material.setParameters(e)}get test(){return null}}export{i as StreamlineResources3D};
2
+ import"../../../../core/has.js";import{estimateNestedObjectMemory as e}from"../../../../core/memoryEstimations.js";import{Seconds as t}from"../../../../core/time.js";import{fadeOutTime as n}from"./constants.js";import{FlowQuery3D as r}from"./FlowQuery3D.js";import{computeGeometryBufferMemory as i}from"../../webgl-engine/lib/geometryMemoryUtils.js";class a{constructor(e,n,r,i,a){this._query=e,this.streamlines=n,this._material=r,this.geometries=i,this._bytesPerFeature=a,this._endTime=t(1/0),this.usedMemory=null,this.computeMemory()}computeMemory(){let t=e(this.streamlines),n=i(this.geometries),r=this.streamlines.length*this._bytesPerFeature;this.usedMemory=t+n+r}get startTime(){return this._query.time}set startTime(e){this._query.time!==e&&(this._query=new r(this._query.extent,this._query.timeExtent,this._query.size,this._query.pixelRatio,t(e))),this.setMaterialParameters({startTime:e})}get endTime(){return this._endTime}set endTime(e){this._endTime!==e&&(this._endTime=e,this.setMaterialParameters({endTime:e}))}get query(){return this._query}hasFadedOut(e){return this.endTime+n<e}setMaterialParameters(e){this._material.setParameters(e)}get test(){return null}}export{a as StreamlineResources3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{removeMaybe as e,destroyMaybe as t}from"../../../../core/maybe.js";import{memoryEstimators as n}from"../../layers/graphics/defaultSymbolComplexity.js";import{streamlinGeometryBatchSize as r}from"./constants.js";import{StreamlineResources3D as i}from"./StreamlineResources3D.js";import{RenderGeometry as a}from"../../webgl-engine/lib/RenderGeometry.js";import{TaskPriority as o}from"../../../support/Scheduler.js";class s extends i{constructor(e,t,r,i,a){let o=n.LINE_ROUND.draped.bytesPerFeature;super(e,t,r,i,o),this._layerView=a,this._drapeRenderer=null,this.drapeSourceType=2,this.updatePolicy=0,this.renderGroup=0,this._frameTask=null,this._renderGeometries=[]}get _view(){return this._layerView.view}get layer(){return this._layerView.layer}get fullOpacity(){return this._layerView.fullOpacity}get attached(){return this._drapeRenderer!=null}get destroyed(){return this.attached}async attach(){let{geometries:e}=this;e!=null&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(o.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(t=>this._addGeometryToOverlay(e,t)))}async*_addGeometryToOverlay(e,t){this._drapeRenderer=this._view.overlayManager.registerGeometryDrapeSource(this);for(let n=0;n<e.length;n+=r){let i=e.slice(n,n+r).map(e=>new a(e));this._drapeRenderer.addGeometries(i,0),this._renderGeometries.push(...i),this._drapeRenderer.commitChanges(),t.madeProgress(),t.done&&(t=yield)}}detach(){this._frameTask=e(this._frameTask),this._drapeRenderer&&(this._drapeRenderer.removeGeometries(this._renderGeometries,2),this._drapeRenderer.commitChanges(),this._renderGeometries.length=0),this.attached&&this._view.overlayManager.unregisterDrapeSource(this),this._drapeRenderer=t(this._drapeRenderer)}}export{s as StreamlineResources3DOverlay};
2
+ import{removeMaybe as e,destroyMaybe as t}from"../../../../core/maybe.js";import{memoryEstimators as n}from"../../layers/graphics/defaultSymbolComplexity.js";import{streamlinGeometryBatchSize as r}from"./constants.js";import{StreamlineResources3D as i}from"./StreamlineResources3D.js";import{TaskPriority as a}from"../../../support/Scheduler.js";class o extends i{constructor(e,t,r,i,a){let o=n.LINE_ROUND.draped.bytesPerFeature;super(e,t,r,i,o),this._layerView=a,this._drapeRenderer=null,this.drapeSourceType=2,this.updatePolicy=0,this.renderGroup=0,this._frameTask=null}get _view(){return this._layerView.view}get layer(){return this._layerView.layer}get fullOpacity(){return this._layerView.fullOpacity}get attached(){return this._drapeRenderer!=null}get destroyed(){return this.attached}async attach(){let{geometries:e}=this;e!=null&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(a.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(t=>this._addGeometryToOverlay(e,t)))}async*_addGeometryToOverlay(e,t){this._drapeRenderer=this._view.overlayManager.registerGeometryDrapeSource(this);for(let n=0;n<e.length;n+=r)this._drapeRenderer.addGeometries(e.slice(n,n+r),0),this._drapeRenderer.commitChanges(),t.madeProgress(),t.done&&(t=yield)}detach(){this._frameTask=e(this._frameTask),this._drapeRenderer&&(this._drapeRenderer.removeGeometries(this.geometries,2),this._drapeRenderer.commitChanges()),this.attached&&this._view.overlayManager.unregisterDrapeSource(this),this._drapeRenderer=t(this._drapeRenderer)}}export{o as StreamlineResources3DOverlay};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{removeMaybe as e}from"../../../../core/maybe.js";import{memoryEstimators as t}from"../../layers/graphics/defaultSymbolComplexity.js";import{streamlinGeometryBatchSize as n}from"./constants.js";import{StreamlineResources3D as r}from"./StreamlineResources3D.js";import{Object3D as i}from"../../webgl-engine/lib/Object3D.js";import{WebGLLayer as a}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as o}from"../../../support/Scheduler.js";class s extends r{constructor(e,n,r,i,a){let o=t.LINE_ROUND.bytesPerFeature;super(e,n,r,i,o),this._view=a,this._objects3D=[],this._engineLayer=null,this._frameTask=null}get attached(){return this._engineLayer!=null}async attach(){let{geometries:e}=this;e!=null&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(o.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(t=>this._addGeometryToLayer(e,t)))}detach(){this.attached&&(this._engineLayer?.removeMany(this._objects3D),this._objects3D.forEach(e=>e.dispose()),this._engineLayer?.commit(),this._objects3D=[],this._engineLayer=null,this._frameTask=e(this._frameTask))}async*_addGeometryToLayer(e,t){let{stage:r}=this._view,o=new a(r,{pickable:!1,updatePolicy:1});for(let r=0;r<e.length;r+=n){let a=new i({geometries:e.slice(r,r+n),castShadow:!1});o.add(a),this._objects3D.push(a),o.commit(),t.madeProgress(),t.done&&(t=yield)}this._engineLayer=o}}export{s as StreamlineResources3DShape};
2
+ import{removeMaybe as e}from"../../../../core/maybe.js";import{memoryEstimators as t}from"../../layers/graphics/defaultSymbolComplexity.js";import{streamlinGeometryBatchSize as n}from"./constants.js";import{StreamlineResources3D as r}from"./StreamlineResources3D.js";import{BufferObject3D as i}from"../../webgl-engine/lib/BufferObject3D.js";import{WebGLLayer as a}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as o}from"../../../support/Scheduler.js";class s extends r{constructor(e,n,r,i,a){let o=t.LINE_ROUND.bytesPerFeature;super(e,n,r,i,o),this._view=a,this._objects3D=[],this._engineLayer=null,this._frameTask=null}get attached(){return this._engineLayer!=null}async attach(){let{geometries:e}=this;e!=null&&(this.detach(),this._frameTask=this._view.resourceController.scheduler.registerTask(o.FLOW_GENERATOR),await this._frameTask.scheduleGenerator(t=>this._addGeometryToLayer(e,t)))}detach(){this.attached&&(this._engineLayer?.removeMany(this._objects3D),this._objects3D.forEach(e=>e.dispose()),this._engineLayer?.commit(),this._objects3D=[],this._engineLayer=null,this._frameTask=e(this._frameTask))}async*_addGeometryToLayer(e,t){let{stage:r}=this._view,o=new a(r,{pickable:!1,updatePolicy:1});for(let r=0;r<e.length;r+=n){let a=new i({geometries:e.slice(r,r+n),castShadow:!1});o.add(a),this._objects3D.push(a),o.commit(),t.madeProgress(),t.done&&(t=yield)}this._engineLayer=o}}export{s as StreamlineResources3DShape};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as t}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as n}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as r}from"../../../../support/elevationInfoUtils.js";import{convertVisualVariables as i,ConvertOptions as a}from"../../layers/support/FastSymbolUpdates.js";import{animatedLineStripsToParameters as o,createGeometry as s}from"../engineContent/line.js";import{valuesPerFlowVertex as c}from"./loadUtils.js";import{drapedZ as l}from"../../terrain/DrapedZ.js";function u(e,r,{vertices:i,stage:a,hasMagnitude:u},d,p,m){let{spatialReference:h}=r.extent,g=[],_=c(u),v=r.flowExtentInfo.modelSize[0],y=0;for(let t=0;t<i.length;t+=_){if(m&&t>0){let e=i[t]-i[t-_];e>v/2?y-=v:-e>v/2&&(y+=v)}let[n,a]=r.modelToMapSpace(i[t]+y,i[t+1],!1),o=m?[n,a,l]:f(n,a,h,e,d);g.push(o)}let b=Math.floor(i.length/_),x=n(b);for(let e=0;e<b;e++)x[e]=i[e*_+2];let{hasVVColor:S,hasVVOpacity:C,hasVVSize:w}=p.parameters,T=S||C||w,E,D,O;if(u&&T){let e=t(b);for(let t=0;t<b;t++)e[t]=i[t*_+3];S&&(E=[e]),C&&(D=[e]),w&&(O=[e])}let k=o([g],void 0,[{timeStamps:x,stage:a}],E,D,O);return s(p,k[0])}function d(e,t,n){if(e==null)return{};let r=null;if(e.visualVariables){let t=[],n=e.visualVariables,o=new a({supports:{size:!0,color:!0,rotation:!1,opacity:!0}});r=i(n,o,t)}let o=r?.color?[1,1,1,1]:e.color.toUnitRGBA();return o[3]*=t,{color:o,width:e.trailWidth,cap:0,animationSpeed:e.flowSpeed,trailLength:e.trailLength,animation:3,emissiveStrength:n,vvColor:r?.color,vvOpacity:r?.opacity,vvSize:r?.size}}function f(t,n,i,a,o){let{absoluteZ:s}=r(t,n,0,i,a,o),c=e(t,n,s);return a.renderCoordsHelper.toRenderCoords(c,i,c),c}export{u as createStreamlineGeometry,d as materialParametersFromRenderer};
2
+ import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newFloatArray as t}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as n}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as r}from"../../../../support/elevationInfoUtils.js";import{convertVisualVariables as i,ConvertOptions as a}from"../../layers/support/FastSymbolUpdates.js";import{animatedLineStripsToParameters as o,selectLocalOrigin as s,createBufferGeometry as c}from"../engineContent/line.js";import{valuesPerFlowVertex as l}from"./loadUtils.js";import{drapedZ as u}from"../../terrain/DrapedZ.js";function d(e,r,{vertices:i,stage:a,hasMagnitude:d},f,m,h){let{spatialReference:g}=r.extent,_=[],v=l(d),y=r.flowExtentInfo.modelSize[0],b=0;for(let t=0;t<i.length;t+=v){if(h&&t>0){let e=i[t]-i[t-v];e>y/2?b-=y:-e>y/2&&(b+=y)}let[n,a]=r.modelToMapSpace(i[t]+b,i[t+1],!1),o=h?[n,a,u]:p(n,a,g,e,f);_.push(o)}let x=Math.floor(i.length/v),S=n(x);for(let e=0;e<x;e++)S[e]=i[e*v+2];let{hasVVColor:C,hasVVOpacity:w,hasVVSize:T}=m.parameters,E=C||w||T,D,O,k;if(d&&E){let e=t(x);for(let t=0;t<x;t++)e[t]=i[t*v+3];C&&(D=[e]),w&&(O=[e]),T&&(k=[e])}let A=o([_],void 0,[{timeStamps:S,stage:a}],D,O,k),j=h?e.overlayManager.renderer.localOriginFactory:e.stage.localOriginFactory,M=s(A[0].attributeData.position,j);return c(m,A[0],M)}function f(e,t,n){if(e==null)return{};let r=null;if(e.visualVariables){let t=[],n=e.visualVariables,o=new a({supports:{size:!0,color:!0,rotation:!1,opacity:!0}});r=i(n,o,t)}let o=r?.color?[1,1,1,1]:e.color.toUnitRGBA();return o[3]*=t,{color:o,width:e.trailWidth,cap:0,animationSpeed:e.flowSpeed,trailLength:e.trailLength,animation:3,emissiveStrength:n,vvColor:r?.color,vvOpacity:r?.opacity,vvSize:r?.size}}function p(t,n,i,a,o){let{absoluteZ:s}=r(t,n,0,i,a,o),c=e(t,n,s);return a.renderCoordsHelper.toRenderCoords(c,i,c),c}export{d as createStreamlineGeometry,f as materialParametersFromRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{signal as e}from"../../../../core/signal.js";import{Milliseconds as t}from"../../../../core/time.js";import{getGaussianSplatAlphaCutoffValue as n}from"../../webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js";class r{static{this.fadeInEase=e=>e*(2-e)}static{this.fadeOutEase=e=>e*e}static{this.inverseFadeInEase=e=>1-Math.sqrt(1-e)}static{this.inverseFadeOutEase=e=>Math.sqrt(1-e)}static{this.minimumFadeDuration=t(80)}static{this.resetFadeDurationInterval=t(1e3)}constructor(n){this._view=n,this._numFadingTiles=e(0),this._tmpFullyFadedOutTiles=[],this._visibilityUpdatePending=!1,this._previousNumFadingTiles=0,this._lastStoppedFading=t(0),this._currentFadeDuration=this.baseFadeDuration}get numFadingTiles(){return this._numFadingTiles.value}updateForFrame(e){if(e!==this._lastUpdatedFrameStart){if(this._lastUpdatedFrameStart=e,this.numFadingTiles===0)this._previousFrameStart=null;else{let n=t(this._previousFrameStart==null?0:e-this._previousFrameStart);this.updateAllTileFading(n),this._previousFrameStart=e}this._view.updateFadingTexture()}}fadeTile(e,t,n){let r=this._getTargetOpacity(t);if(e.fadeDirection=t,!this.fadingEnabled){this._instantTileFading(e,r);return}let i=e.opacityModifier;if(i!==r){let r=this._getFadeProgressFromOpacity(i,t);this._startTileFading(e,r,n)}else this._stopTileFading(e)}updateAllTileFading(e){let t=this._tmpFullyFadedOutTiles;t.length=0,this._view.tileHandles.forEach(n=>{this._updateTileFading(n,e)&&t.push(n)}),t.length>0&&(this._view.notifyTileObbsChanged(t),this._visibilityUpdatePending=!0),this._numFadingTiles.value===0&&this._visibilityUpdatePending&&(this._visibilityUpdatePending=!1,this._view.updateGaussians()),this._numFadingTiles.value>0&&this._view.view.stage?.renderView.requestRender(2)}onFadeDurationChanged(e){e===0&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(e){return e.fadeProgress!=null&&e.fadeDirection===1}onTileDiscarded(e){e.fadeProgress!=null&&(this._numFadingTiles.value--,this._numFadingTiles.value===0&&(this._lastStoppedFading=t(performance.now())))}updateFadeDuration(){if(this.numFadingTiles&&this.numFadingTiles>=this._previousNumFadingTiles){let e=this._currentFadeDuration*.95;this._currentFadeDuration=t(Math.max(e,r.minimumFadeDuration))}else this.numFadingTiles===0&&performance.now()-this._lastStoppedFading>r.resetFadeDurationInterval&&(this._currentFadeDuration=this.baseFadeDuration);return this._previousNumFadingTiles=this.numFadingTiles,this._currentFadeDuration}get updating(){return this._numFadingTiles.value>0}get baseFadeDuration(){return this._view.view.qualitySettings.fadeDuration}get fadingEnabled(){return this.baseFadeDuration!==0}_startTileFading(e,t,n){e.fadeProgress??this._numFadingTiles.value++,e.fadeDuration=n,e.fadeProgress=t}_stopTileFading(e){e.fadeProgress!=null&&(e.fadeDirection===1&&this._onTileFullyFadedOut(e),this._numFadingTiles.value--,this._numFadingTiles.value===0&&(this._lastStoppedFading=t(performance.now())),e.fadeDuration=null,e.fadeProgress=null)}_updateTileFading(e,t){let{fadeProgress:n,fadeDirection:i}=e;if(n==null)return!1;let a=this._fadeDirectionToSign(i),o=e.fadeDuration,s=this._getTargetOpacity(i),c=t/Math.abs(o||1),l=Math.min(n+c,1),u=s-a*(1-(i===0?r.fadeInEase:r.fadeOutEase)(l)),d=l===1||this._tileReachedFadeOutCutoff(e,u);if(e.opacityModifier=d?s:u,d){let t=i===1;return this._stopTileFading(e),this._updateOpacityModifier(e),t}return e.fadeProgress=l,this._updateOpacityModifier(e),!1}_updateOpacityModifier(e){for(let t=0;t<e.pageIds.length;t++){let n=e.pageIds[t];this._view.data.fadingTexture.updateBuffer(e.opacityModifier,n)}}_tileReachedFadeOutCutoff(e,t){if(e.fadeDirection!==1)return!1;let r=n(this._view.view.qualitySettings.gaussianSplat.minimumOpacity);return t*e.maxGaussianOpacity<=r}_instantTileFading(e,t){e.fadeDuration=null,e.fadeProgress=null,e.opacityModifier=t,this._updateOpacityModifier(e),e.fadeDirection===1&&this._onTileFullyFadedOut(e)}_instantlyFullyFadeAllTiles(){let e=this._tmpFullyFadedOutTiles;e.length=0,this._view.tileHandles.forEach(t=>{if(t.fadeProgress!=null){let n=t.fadeDirection===1;this._instantTileFading(t,this._getTargetOpacity(t.fadeDirection)),n&&e.push(t)}});let t=e.length>0;t&&(this._visibilityUpdatePending=!0),this._numFadingTiles.value=0,this._visibilityUpdatePending&&(this._visibilityUpdatePending=!1,this._view.updateGaussians()),t&&this._view.notifyTileObbsChanged(e)}_onTileFullyFadedOut(e){e.lifecycleState=0,this._view.moveTileToCache(e)}_fadeDirectionToSign(e){return e===0?1:-1}_getTargetOpacity(e){return+(e===0)}_getFadeProgressFromOpacity(e,t){let n=Math.max(0,Math.min(e,1));return t===0?r.inverseFadeInEase(n):r.inverseFadeOutEase(n)}}export{r as GaussianSplatFadeHelper};
2
+ import{signal as e}from"../../../../core/signal.js";import{Milliseconds as t}from"../../../../core/time.js";import{getGaussianSplatAlphaCutoffValue as n}from"../../webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js";class r{static{this.fadeInEase=e=>e*(2-e)}static{this.fadeOutEase=e=>e*e}static{this.inverseFadeInEase=e=>1-Math.sqrt(1-e)}static{this.inverseFadeOutEase=e=>Math.sqrt(1-e)}static{this.minimumFadeDuration=t(80)}static{this.resetFadeDurationInterval=t(1e3)}constructor(n){this._view=n,this._numFadingTiles=e(0),this._tmpFullyFadedOutTiles=[],this._visibilityUpdatePending=!1,this._previousNumFadingTiles=0,this._lastStoppedFading=t(0),this._currentFadeDuration=this.baseFadeDuration}get numFadingTiles(){return this._numFadingTiles.value}updateForFrame(e){if(e!==this._lastUpdatedFrameStart){if(this._lastUpdatedFrameStart=e,this.numFadingTiles===0)this._previousFrameStart=null;else{let n=t(this._previousFrameStart==null?0:e-this._previousFrameStart);this.updateAllTileFading(n),this._previousFrameStart=e}this._view.updateFadingTexture()}}fadeTile(e,t,n){let r=this._getTargetOpacity(t);if(e.fadeDirection=t,!this.fadingEnabled){this._instantTileFading(e,r);return}let i=e.opacityModifier;if(i!==r){let r=this._getFadeProgressFromOpacity(i,t);this._startTileFading(e,r,n)}else this._stopTileFading(e)}updateAllTileFading(e){let t=this._tmpFullyFadedOutTiles;t.length=0,this._view.tileHandles.forEach(n=>{this._updateTileFading(n,e)&&t.push(n)}),t.length>0&&(this._view.notifyTileObbsChanged(t),this._visibilityUpdatePending=!0),this._numFadingTiles.value===0&&this._visibilityUpdatePending&&(this._visibilityUpdatePending=!1,this._view.updateActiveTileVisibility()),this._numFadingTiles.value>0&&this._view.view.stage?.renderView.requestRender(2)}onFadeDurationChanged(e){e===0&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(e){return e.fadeProgress!=null&&e.fadeDirection===1}onTileDiscarded(e){e.fadeProgress!=null&&(this._numFadingTiles.value--,this._numFadingTiles.value===0&&(this._lastStoppedFading=t(performance.now())))}updateFadeDuration(){if(this.numFadingTiles&&this.numFadingTiles>=this._previousNumFadingTiles){let e=this._currentFadeDuration*.95;this._currentFadeDuration=t(Math.max(e,r.minimumFadeDuration))}else this.numFadingTiles===0&&performance.now()-this._lastStoppedFading>r.resetFadeDurationInterval&&(this._currentFadeDuration=this.baseFadeDuration);return this._previousNumFadingTiles=this.numFadingTiles,this._currentFadeDuration}get updating(){return this._numFadingTiles.value>0}get baseFadeDuration(){return this._view.view.qualitySettings.fadeDuration}get fadingEnabled(){return this.baseFadeDuration!==0}_startTileFading(e,t,n){e.fadeProgress??this._numFadingTiles.value++,e.fadeDuration=n,e.fadeProgress=t}_stopTileFading(e){e.fadeProgress!=null&&(e.fadeDirection===1&&this._onTileFullyFadedOut(e),this._numFadingTiles.value--,this._numFadingTiles.value===0&&(this._lastStoppedFading=t(performance.now())),e.fadeDuration=null,e.fadeProgress=null)}_updateTileFading(e,t){let{fadeProgress:n,fadeDirection:i}=e;if(n==null)return!1;let a=this._fadeDirectionToSign(i),o=e.fadeDuration,s=this._getTargetOpacity(i),c=t/Math.abs(o||1),l=Math.min(n+c,1),u=s-a*(1-(i===0?r.fadeInEase:r.fadeOutEase)(l)),d=l===1||this._tileReachedFadeOutCutoff(e,u);if(e.opacityModifier=d?s:u,d){let t=i===1;return this._stopTileFading(e),this._updateOpacityModifier(e),t}return e.fadeProgress=l,this._updateOpacityModifier(e),!1}_updateOpacityModifier(e){for(let t=0;t<e.pageIds.length;t++){let n=e.pageIds[t];this._view.data.fadingTexture.updateBuffer(e.opacityModifier,n)}}_tileReachedFadeOutCutoff(e,t){if(e.fadeDirection!==1)return!1;let r=n(this._view.view.qualitySettings.gaussianSplat.minimumOpacity);return t*e.maxGaussianOpacity<=r}_instantTileFading(e,t){e.fadeDuration=null,e.fadeProgress=null,e.opacityModifier=t,this._updateOpacityModifier(e),e.fadeDirection===1&&this._onTileFullyFadedOut(e)}_instantlyFullyFadeAllTiles(){let e=this._tmpFullyFadedOutTiles;e.length=0,this._view.tileHandles.forEach(t=>{if(t.fadeProgress!=null){let n=t.fadeDirection===1;this._instantTileFading(t,this._getTargetOpacity(t.fadeDirection)),n&&e.push(t)}});let t=e.length>0;t&&(this._visibilityUpdatePending=!0),this._numFadingTiles.value=0,this._visibilityUpdatePending&&(this._visibilityUpdatePending=!1,this._view.updateActiveTileVisibility()),t&&this._view.notifyTileObbsChanged(e)}_onTileFullyFadedOut(e){e.lifecycleState=0,this._view.moveTileToCache(e)}_fadeDirectionToSign(e){return e===0?1:-1}_getTargetOpacity(e){return+(e===0)}_getFadeProgressFromOpacity(e,t){let n=Math.max(0,Math.min(e,1));return t===0?r.inverseFadeInEase(n):r.inverseFadeOutEase(n)}}export{r as GaussianSplatFadeHelper};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{subtract as e,length as t,scale as n,negate as r,dot as i,transformQuatValues as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as s}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{project as c}from"../../../../geometry/projectionUtils.js";import{intersects as l,contains as u}from"../../../../geometry/support/aaBoundingBox.js";import{fromExtent as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as p}from"../../../../geometry/support/ray.js";import{GaussianSplatTarget as m}from"../../layers/i3s/Intersector.js";import{createTileBVH as h}from"../../layers/support/Tiles3DBVH.js";import{ElevationRange as g}from"../ElevationRange.js";import{IntersectorResultRay as _}from"../../webgl-engine/lib/IntersectorResult.js";class v{constructor(e){this.layerView=e,this.type=0,this.slicePlaneEnabled=!1,this.isGround=!1,this._ellipsoidLocalRayOrigin=o(),this._ellipsoidLocalRayDir=o(),this.intersectionNormal=o(),this.intersectionRayDir=o(),this.intersectionPlane=f(),this.layerViewUid=e.uid;let t=e.view.viewingMode,n=(e.useEsriCrs?e.fullExtentInLocalViewSpatialReference:e.layer.fullExtent?c(e.layer.fullExtent,e.view.renderSpatialReference):void 0)??e.view.extent,r=d(n);this._bvh=h(t,r)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}intersectRay(a,c,d,f,h,g){let{intersectionRayDir:v,intersectionPlane:x,layerViewUid:S,intersectionNormal:C}=this,w=p(d,f);e(v,f,d);let T=1/t(v);n(v,v,T),r(C,v),s(x,v[0],v[1],v[2],-i(v,d));let E=new b,D=new b,O=a.options.store,k=O===0,A=O===2,j=O===1||A,M=A?[]:null,N=(e,t,n,r,i,a,s,c)=>{let l=e.point??=o();l[0]=n,l[1]=r,l[2]=i,e.dist=t,e.normal=C;let u=e.outwardDirection??=o(),d=a*a+s*s+c*c;if(d>0){let e=1/Math.sqrt(d);u[0]=a*e,u[1]=s*e,u[2]=c*e}else u[0]=C[0],u[1]=C[1],u[2]=C[2];return e.layerViewUid=S,e},P=d[0],F=d[1],I=d[2],L=v[0],R=v[1],z=v[2],B=this.layerView.clippingBox,V=e=>{let{relativePositions:t,packedRotations:n,packedOpacityScaledScales:r,gaussianCount:i,obb:a,maxSplatMbsRadiusSquared:o}=e,s=a.centerX,l=a.centerY,u=a.centerZ,p=-1,m=B[0],h=B[1],g=B[2],_=B[3],v=B[4],y=B[5];for(let e=0,a=0;e<i;e++,a+=3){let i=t[a]+s,x=t[a+1]+l,S=t[a+2]+u;if(i<m||x<h||S<g||i>_||x>v||S>y)continue;let C=i-P,w=x-F,O=S-I,B=C*L+w*R+O*z;if(B<0&&B*B>o)continue;let V=B<0?0:B;if(C*C+w*w+O*O-V*V>o||k&&E.dist!=null&&(p<0&&(p=Math.sqrt(o)),Math.max(B-p,0)*T>=E.dist))continue;let H=this._intersectGaussianEllipsoid(C,w,O,L,R,z,n[e],r[e]);if(H<0)continue;let U=H*T;if(c!=null&&!c(d,f,U))continue;let W=E.dist==null||U<E.dist,G=j&&(D.dist==null||U>D.dist);if(!W&&!G&&!A)continue;let K=L*H,q=R*H,ee=z*H,J=P+K,Y=F+q,X=I+ee,Z=K-C,Q=q-w,$=ee-O;if(W&&N(E,U,J,Y,X,Z,Q,$),G&&N(D,U,J,Y,X,Z,Q,$),A){let e=new b;M.push(N(e,U,J,Y,X,Z,Q,$))}}},H=e=>{let{relativePositions:t,packedRotations:n,packedOpacityScaledScales:r,gaussianCount:i,obb:a,maxSplatMbsRadiusSquared:o}=e,s=a.centerX,l=a.centerY,u=a.centerZ,p=-1,m=P-s,h=F-l,g=I-u;for(let e=0,a=0;e<i;e++,a+=3){let i=t[a]-m,s=t[a+1]-h,l=t[a+2]-g,u=i*L+s*R+l*z;if(u<0&&u*u>o)continue;let _=u<0?0:u;if(i*i+s*s+l*l-_*_>o||k&&E.dist!=null&&(p<0&&(p=Math.sqrt(o)),Math.max(u-p,0)*T>=E.dist))continue;let v=this._intersectGaussianEllipsoid(i,s,l,L,R,z,n[e],r[e]);if(v<0)continue;let y=v*T;if(c!=null&&!c(d,f,y))continue;let x=E.dist==null||y<E.dist,S=j&&(D.dist==null||y>D.dist);if(!x&&!S&&!A)continue;let C=L*v,w=R*v,O=z*v,B=P+C,V=F+w,H=I+O,U=C-i,W=w-s,G=O-l;if(x&&N(E,y,B,V,H,U,W,G),S&&N(D,y,B,V,H,U,W,G),A){let e=new b;M.push(N(e,y,B,V,H,U,W,G))}}},U=(e,t)=>{let{min:n,max:r}=e.obb.signedDistanceRangePlane(x);if(r<0)return;let i=n*T;if(!(k&&E.dist!=null&&E.dist<i)){if(E.dist!=null&&D.dist!=null){let e=r*T;if(E.dist<i&&D.dist>e)return}t?V(e):H(e)}};this._bvh.forEachTileIntersectingRay(d,f,B==null?e=>{U(e,!1)}:e=>{let t=e.boundingBox;l(t,B)&&U(e,!u(B,t))},g);let W=(e,t)=>{let{layerViewUid:n}=t,r=new m(t.point,t.outwardDirection,n);e.set(0,r,t.dist,t.dist,t.normal)};if(y(E)){let e=a.results.min;(e.distance==null||E.dist<e.distance)&&W(e,E)}if(y(D)&&j){let e=a.results.max;(e.distance==null||D.dist>e.distance)&&W(e,D)}if(A&&M?.length)for(let e of M){let t=new _(w);W(t,e),a.results.all.push(t)}}_intersectGaussianEllipsoid(e,t,n,r,i,o,s,c){let l=s>>>30,u=s&1023,d=s>>>10&1023,f=s>>>20&1023,p=(u&x)*S*(1-(u>>>9&1)*2),m=(d&x)*S*(1-(d>>>9&1)*2),h=(f&x)*S*(1-(f>>>9&1)*2),g,_,v,y,b=p*p+m*m+h*h,T=Math.sqrt(Math.max(0,1-b));switch(l){case 0:g=T,_=h,v=m,y=p;break;case 1:g=h,_=T,v=m,y=p;break;case 2:g=h,_=m,v=T,y=p;break;default:g=h,_=m,v=p,y=T}let E=this._ellipsoidLocalRayOrigin;E[0]=-e,E[1]=-t,E[2]=-n,a(E,E,-g,-_,-v,y);let D=this._ellipsoidLocalRayDir;D[0]=r,D[1]=i,D[2]=o,a(D,D,-g,-_,-v,y);let O=w[c&255],k=w[c>>>8&255],A=w[c>>>16],j=E[0]*O,M=E[1]*k,N=E[2]*A,P=j*j+M*M+N*N;if(P<=1)return 0;let F=D[0]*O,I=D[1]*k,L=D[2]*A,R=F*F+I*I+L*L,z=j*F+M*I+N*L;if(z>0)return C;let B=z*z-R*(P-1);return B<0?C:(-z-Math.sqrt(B))/R}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new g(0,0)}}function y(e){return e.dist!=null&&e.point!=null}class b{constructor(){this.point=null,this.dist=null,this.normal=null,this.outwardDirection=null,this.layerViewUid=``}}const x=511,S=Math.SQRT1_2/511,C=-1,w=(()=>{let e=new Float64Array(256);for(let t=0;t<e.length;t++)e[t]=Math.exp(10-t/16)/3;return e})();export{v as GaussianSplatIntersectionHandler};
2
+ import{subtract as e,length as t,scale as n,negate as r,dot as i,transformQuatValues as a}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as s}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{project as c}from"../../../../geometry/projectionUtils.js";import{intersects as l,contains as u}from"../../../../geometry/support/aaBoundingBox.js";import{fromExtent as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as p}from"../../../../geometry/support/ray.js";import{GaussianSplatTarget as m}from"../../layers/i3s/Intersector.js";import{createTileBVH as h}from"../../layers/support/Tiles3DBVH.js";import{ElevationRange as g}from"../ElevationRange.js";import{gaussianEllipsoidScaleMultiplier as _}from"./formatConstants.js";import{IntersectorResultRay as v}from"../../webgl-engine/lib/IntersectorResult.js";class y{constructor(e){this.layerView=e,this.type=0,this.slicePlaneEnabled=!1,this.isGround=!1,this._ellipsoidLocalRayOrigin=o(),this._ellipsoidLocalRayDir=o(),this.intersectionNormal=o(),this.intersectionRayDir=o(),this.intersectionPlane=f(),this.layerViewUid=e.uid;let t=e.view.viewingMode,n=(e.useEsriCrs?e.fullExtentInLocalViewSpatialReference:e.layer.fullExtent?c(e.layer.fullExtent,e.view.renderSpatialReference):void 0)??e.view.extent,r=d(n);this._bvh=h(t,r)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}get elevationRange(){let e=this._bvh.elevationRange;return e!=null&&!e.isEmpty?new g(e.minElevation,e.maxElevation):null}intersectRay(a,c,d,f,h,g){let{intersectionRayDir:_,intersectionPlane:y,layerViewUid:S,intersectionNormal:C}=this,w=p(d,f);e(_,f,d);let T=1/t(_);n(_,_,T),r(C,_),s(y,_[0],_[1],_[2],-i(_,d));let E=new x,D=new x,O=a.options.store,k=O===0,A=O===2,j=O===1||A,M=A?[]:null,N=(e,t,n,r,i,a,s,c)=>{let l=e.point??=o();l[0]=n,l[1]=r,l[2]=i,e.dist=t,e.normal=C;let u=e.outwardDirection??=o(),d=a*a+s*s+c*c;if(d>0){let e=1/Math.sqrt(d);u[0]=a*e,u[1]=s*e,u[2]=c*e}else u[0]=C[0],u[1]=C[1],u[2]=C[2];return e.layerViewUid=S,e},P=d[0],F=d[1],I=d[2],L=_[0],R=_[1],z=_[2],B=this.layerView.clippingBox,V=e=>{let{relativePositions:t,packedRotations:n,packedOpacityScaledScales:r,gaussianCount:i,obb:a,maxSplatMbsRadiusSquared:o}=e,s=a.centerX,l=a.centerY,u=a.centerZ,p=-1,m=B[0],h=B[1],g=B[2],_=B[3],v=B[4],y=B[5];for(let e=0,a=0;e<i;e++,a+=3){let i=t[a]+s,b=t[a+1]+l,S=t[a+2]+u;if(i<m||b<h||S<g||i>_||b>v||S>y)continue;let C=i-P,w=b-F,O=S-I,B=C*L+w*R+O*z;if(B<0&&B*B>o)continue;let V=B<0?0:B;if(C*C+w*w+O*O-V*V>o||k&&E.dist!=null&&(p<0&&(p=Math.sqrt(o)),Math.max(B-p,0)*T>=E.dist))continue;let H=this._intersectGaussianEllipsoid(C,w,O,L,R,z,n[e],r[e]);if(H<0)continue;let U=H*T;if(c!=null&&!c(d,f,U))continue;let W=E.dist==null||U<E.dist,G=j&&(D.dist==null||U>D.dist);if(!W&&!G&&!A)continue;let K=L*H,q=R*H,ee=z*H,J=P+K,Y=F+q,X=I+ee,Z=K-C,Q=q-w,$=ee-O;if(W&&N(E,U,J,Y,X,Z,Q,$),G&&N(D,U,J,Y,X,Z,Q,$),A){let e=new x;M.push(N(e,U,J,Y,X,Z,Q,$))}}},H=e=>{let{relativePositions:t,packedRotations:n,packedOpacityScaledScales:r,gaussianCount:i,obb:a,maxSplatMbsRadiusSquared:o}=e,s=a.centerX,l=a.centerY,u=a.centerZ,p=-1,m=P-s,h=F-l,g=I-u;for(let e=0,a=0;e<i;e++,a+=3){let i=t[a]-m,s=t[a+1]-h,l=t[a+2]-g,u=i*L+s*R+l*z;if(u<0&&u*u>o)continue;let _=u<0?0:u;if(i*i+s*s+l*l-_*_>o||k&&E.dist!=null&&(p<0&&(p=Math.sqrt(o)),Math.max(u-p,0)*T>=E.dist))continue;let v=this._intersectGaussianEllipsoid(i,s,l,L,R,z,n[e],r[e]);if(v<0)continue;let y=v*T;if(c!=null&&!c(d,f,y))continue;let b=E.dist==null||y<E.dist,S=j&&(D.dist==null||y>D.dist);if(!b&&!S&&!A)continue;let C=L*v,w=R*v,O=z*v,B=P+C,V=F+w,H=I+O,U=C-i,W=w-s,G=O-l;if(b&&N(E,y,B,V,H,U,W,G),S&&N(D,y,B,V,H,U,W,G),A){let e=new x;M.push(N(e,y,B,V,H,U,W,G))}}},U=(e,t)=>{let{min:n,max:r}=e.obb.signedDistanceRangePlane(y);if(r<0)return;let i=n*T;if(!(k&&E.dist!=null&&E.dist<i)){if(E.dist!=null&&D.dist!=null){let e=r*T;if(E.dist<i&&D.dist>e)return}t?V(e):H(e)}};this._bvh.forEachTileIntersectingRay(d,f,B==null?e=>{U(e,!1)}:e=>{let t=e.boundingBox;l(t,B)&&U(e,!u(B,t))},g);let W=(e,t)=>{let{layerViewUid:n}=t,r=new m(t.point,t.outwardDirection,n);e.set(0,r,t.dist,t.dist,t.normal)};if(b(E)){let e=a.results.min;(e.distance==null||E.dist<e.distance)&&W(e,E)}if(b(D)&&j){let e=a.results.max;(e.distance==null||D.dist>e.distance)&&W(e,D)}if(A&&M?.length)for(let e of M){let t=new v(w);W(t,e),a.results.all.push(t)}}_intersectGaussianEllipsoid(e,t,n,r,i,o,s,c){let l=s>>>30,u=s&1023,d=s>>>10&1023,f=s>>>20&1023,p=(u&S)*C*(1-(u>>>9&1)*2),m=(d&S)*C*(1-(d>>>9&1)*2),h=(f&S)*C*(1-(f>>>9&1)*2),g,_,v,y,b=p*p+m*m+h*h,x=Math.sqrt(Math.max(0,1-b));switch(l){case 0:g=x,_=h,v=m,y=p;break;case 1:g=h,_=x,v=m,y=p;break;case 2:g=h,_=m,v=x,y=p;break;default:g=h,_=m,v=p,y=x}let E=this._ellipsoidLocalRayOrigin;E[0]=-e,E[1]=-t,E[2]=-n,a(E,E,-g,-_,-v,y);let D=this._ellipsoidLocalRayDir;D[0]=r,D[1]=i,D[2]=o,a(D,D,-g,-_,-v,y);let O=T[c&255],k=T[c>>>8&255],A=T[c>>>16],j=E[0]*O,M=E[1]*k,N=E[2]*A,P=j*j+M*M+N*N;if(P<=1)return 0;let F=D[0]*O,I=D[1]*k,L=D[2]*A,R=F*F+I*I+L*L,z=j*F+M*I+N*L;if(z>0)return w;let B=z*z-R*(P-1);return B<0?w:(-z-Math.sqrt(B))/R}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new g(0,0)}}function b(e){return e.dist!=null&&e.point!=null}class x{constructor(){this.point=null,this.dist=null,this.normal=null,this.outwardDirection=null,this.layerViewUid=``}}const S=511,C=Math.SQRT1_2/511,w=-1,T=(()=>{let e=new Float64Array(256);for(let t=0;t<e.length;t++)e[t]=Math.exp(10-t/16)/_;return e})();export{y as GaussianSplatIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{minExpectedGaussianCount as t}from"./GaussianSplatAtlasPages.js";import{TextureBackedBufferLayout as n}from"../../webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js";import{TextureBuffer as r}from"../../webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js";const i=new n([{name:`gaussianSplatOrder`,type:`u32`}]);class a{constructor(e){this._textureBuffer=null,this._rctx=e}get usedMemory(){return this._textureBuffer?.usedMemory??0}ensureCapacity(n){if(n<=0)return;let a=this._textureBuffer;if(a!=null&&a.itemCount>=n&&a.texture.hasWebGLTextureObject)return;let o=Math.max(Math.ceil(n*e),t);a?.dispose(),this._textureBuffer=new r(this._rctx,i,o)}setData(e,t){this.ensureCapacity(t),this._textureBuffer.setSubData(e.buffer,0,e.byteOffset,t)}clear(){this._textureBuffer?.dispose(),this._textureBuffer=null}destroy(){this.clear()}get texture(){return this._textureBuffer?.texture??null}}export{a as GaussianSplatOrderTexture};
2
+ import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{minExpectedGaussianCount as t}from"./GaussianSplatAtlasPages.js";import{TextureBackedBufferLayout as n}from"../../webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js";import{TextureBuffer as r}from"../../webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js";const i=new n([{name:`gaussianSplatOrder`,type:`u32`}]);class a{constructor(e){this._textureBuffer=null,this._rctx=e}get usedMemory(){return this._textureBuffer?.usedMemory??0}ensureCapacity(n){if(n<=0)return;let a=this._textureBuffer;if(a!=null&&a.itemCount>=n&&a.texture.hasWebGLTextureObject)return;let o=Math.max(Math.ceil(n*e),t);a?.dispose(),this._textureBuffer=new r(this._rctx,i,o)}setData(e,t){this.ensureCapacity(t);let n=this._textureBuffer,{width:r}=n.texture.descriptor,i=r*Math.max(1,Math.floor(1048576/Uint32Array.BYTES_PER_ELEMENT/r));for(let r=0;r<t;r+=i)n.setSubData(e.buffer,r,e.byteOffset+r*Uint32Array.BYTES_PER_ELEMENT,Math.min(i,t-r))}clear(){this._textureBuffer?.dispose(),this._textureBuffer=null}destroy(){this.clear()}get texture(){return this._textureBuffer?.texture??null}}export{a as GaussianSplatOrderTexture};
@@ -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{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{initialSplatAtlasTextureHeight as t,GaussianSplatAtlasPages as n,splatAtlasTextureWidth as r,maximumSplatAtlasTextureHeightMobile as i,maximumSplatAtlasTextureHeight as a,packedGaussianSizeInU32 as o,gaussiansPerPage as s}from"./GaussianSplatAtlasPages.js";import{PixelType as c,SizedPixelFormat as l}from"../../../webgl/enums.js";import{DisposableFramebufferObject as u}from"../../../webgl/FramebufferObject.js";import d from"../../../webgl/Texture.js";import{TextureDescriptor as f}from"../../../webgl/TextureDescriptor.js";class p{constructor(e,r,i,a){this._splatAtlasTextureHeight=t,this.texture=null,this._rctx=e,this._fboCache=i,this._onCachedTextureEvicted=a,this.pageAllocator=new n,this._cache=r.newCache(`gaussian texture cache`,e=>{e.dispose(),this._onCachedTextureEvicted()})}get usedMemory(){return this.texture?.usedMemory??0}get maximumSupportedVisibleGaussians(){let e=has(`esri-mobile`)?r*i:r*a;return Math.floor(e*.6666666666666666)}ensureTextureAtlas(){if(this.texture?.hasWebGLTextureObject)return;this.texture=null;let e=this._cache.pop(`splatTextureAtlas`);if(e){this.texture=e;return}let t=new f;t.height=this._splatAtlasTextureHeight,t.width=r,t.pixelFormat=36249,t.dataType=c.UNSIGNED_INT,t.internalFormat=l.RGBA32UI,t.samplingMode=9728,t.wrapMode=33071,t.isImmutable=!0,this.texture=new d(this._rctx,t),this._updatePageAllocator()}grow(){if(!this.texture)return this.ensureTextureAtlas(),!1;let t=Math.floor(this._splatAtlasTextureHeight*e);if(t>Math.min(has(`esri-mobile`)?i:a,this._rctx.parameters.maxTextureSize))return!1;let n=new u(this._rctx,this.texture),o=this._fboCache.acquire(r,t,`gaussian splat atlas resize`,12);return this._rctx.blitFramebuffer(n,o.fbo,16384,9728,0,0,r,this._splatAtlasTextureHeight,0,0,r,this._splatAtlasTextureHeight),this.texture=o.fbo?.detachColorTexture(),n.dispose(),o.dispose(),this._splatAtlasTextureHeight=t,this._updatePageAllocator(),!0}allocatePage(){let e=this.pageAllocator.findFirstFreePage();return e===null&&this.grow()&&(e=this.pageAllocator.findFirstFreePage()),e!==null&&this.pageAllocator.allocate(e),e}freePage(e){this.pageAllocator.free(e)}freePages(e){for(let t of e)this.freePage(t)}update(e,t,n,i=1){this.ensureTextureAtlas();let a=i*s,c=0;for(;a>0;){let i=Math.min(r-e,a),s=e===0&&i===r?Math.floor(a/r):1;this.texture.updateData(0,e,t,i,s,n.subarray(c));let l=i*s;c+=l*o,a-=l,e=0,t+=s}}_updatePageAllocator(){let e=r*this._splatAtlasTextureHeight/s;this.pageAllocator.pageCount!==e&&this.pageAllocator.resize(e)}clear(){this.texture&&=(this._cache.put(`splatTextureAtlas`,this.texture),null)}destroy(){this._onCachedTextureEvicted=()=>{},this._cache.destroy(),this.texture?.dispose(),this.texture=null}}export{p as GaussianSplatTextureAtlas};
2
+ import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import{initialSplatAtlasTextureHeight as t,GaussianSplatAtlasPages as n,splatAtlasTextureWidth as r,maximumSplatAtlasTextureHeightMobile as i,maximumSplatAtlasTextureHeight as a,packedGaussianSizeInU32 as o,gaussiansPerPage as s}from"./GaussianSplatAtlasPages.js";import{PixelType as c,SizedPixelFormat as l}from"../../../webgl/enums.js";import{DisposableFramebufferObject as u}from"../../../webgl/FramebufferObject.js";import{Texture as d}from"../../../webgl/Texture.js";import{TextureDescriptor as f}from"../../../webgl/TextureDescriptor.js";class p{constructor(e,r,i,a){this._splatAtlasTextureHeight=t,this.texture=null,this._rctx=e,this._fboCache=i,this._onCachedTextureEvicted=a,this.pageAllocator=new n,this._cache=r.newCache(`gaussian texture cache`,e=>{e.dispose(),this._onCachedTextureEvicted()})}get usedMemory(){return this.texture?.usedMemory??0}get maximumSupportedVisibleGaussians(){let e=has(`esri-mobile`)?r*i:r*a;return Math.floor(e*.6666666666666666)}ensureTextureAtlas(){if(this.texture?.hasWebGLTextureObject)return;this.texture=null;let e=this._cache.pop(`splatTextureAtlas`);if(e){this.texture=e;return}let t=new f;t.height=this._splatAtlasTextureHeight,t.width=r,t.pixelFormat=36249,t.dataType=c.UNSIGNED_INT,t.internalFormat=l.RGBA32UI,t.samplingMode=9728,t.wrapMode=33071,t.isImmutable=!0,this.texture=new d(this._rctx,t),this._updatePageAllocator()}grow(){if(!this.texture)return this.ensureTextureAtlas(),!1;let t=Math.floor(this._splatAtlasTextureHeight*e);if(t>Math.min(has(`esri-mobile`)?i:a,this._rctx.parameters.maxTextureSize))return!1;let n=new u(this._rctx,this.texture),o=this._fboCache.acquire(r,t,`gaussian splat atlas resize`,12);return this._rctx.blitFramebuffer(n,o.fbo,16384,9728,0,0,r,this._splatAtlasTextureHeight,0,0,r,this._splatAtlasTextureHeight),this.texture=o.fbo?.detachColorTexture(),n.dispose(),o.dispose(),this._splatAtlasTextureHeight=t,this._updatePageAllocator(),!0}allocatePage(){let e=this.pageAllocator.findFirstFreePage();return e===null&&this.grow()&&(e=this.pageAllocator.findFirstFreePage()),e!==null&&this.pageAllocator.allocate(e),e}freePage(e){this.pageAllocator.free(e)}freePages(e){for(let t of e)this.freePage(t)}update(e,t,n,i=1){this.ensureTextureAtlas();let a=i*s,c=0;for(;a>0;){let i=Math.min(r-e,a),s=e===0&&i===r?Math.floor(a/r):1;this.texture.updateData(0,e,t,i,s,n.subarray(c));let l=i*s;c+=l*o,a-=l,e=0,t+=s}}_updatePageAllocator(){let e=r*this._splatAtlasTextureHeight/s;this.pageAllocator.pageCount!==e&&this.pageAllocator.resize(e)}clear(){this.texture&&=(this._cache.put(`splatTextureAtlas`,this.texture),null)}destroy(){this._onCachedTextureEvicted=()=>{},this._cache.destroy(),this.texture?.dispose(),this.texture=null}}export{p as GaussianSplatTextureAtlas};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{estimateNumberArrayMemory as e}from"../../../../core/memoryEstimations.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n,diameter as r}from"../../../../geometry/support/aaBoundingBox.js";class i{constructor(i,a,o,s,c,l,u,d,f,p){this.handle=i,this.obb=a,this.pageIds=o,this.relativePositions=s,this.packedRotations=c,this.packedOpacityScaledScales=l,this.gaussianCount=u,this.maxSplatMbsRadiusSquared=d,this.maxGaussianOpacity=f,this.elevationRange=p,this.bvhIntersectionGeneration=0,this.lifecycleState=0,this.cullingRevision=-1,this.cullingVisible=!1,this.fadeDirection=0,this.opacityModifier=0,this.usedMemory=e(this.pageIds,this.relativePositions,this.packedRotations,this.packedOpacityScaledScales);let m=t();a.getCenter(m),this.obbCenterX=m[0],this.obbCenterY=m[1],this.obbCenterZ=m[2];let h=a.radius??-1;this._mbsRadius=h;let g=h<0?-1:h*h;this._mbsRadiusSquared=g,this._obbShortestHalfsize=Math.min(a.halfSizeX,a.halfSizeY,a.halfSizeZ);let _=n();a.toAaBoundingBox(_),this.boundingBox=_;let v=h>=0?h:r(_)*.5;this.paddedMbsRadius=v+Math.sqrt(Math.max(0,d))}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;let{obbCenterX:n,obbCenterY:r,obbCenterZ:i}=this,a=n-e[0],o=r-e[1],s=i-e[2],c=a*t[0]+o*t[1]+s*t[2],l=a*a+o*o+s*s-c*c;return(this._mbsRadiusSquared<0||l<=this._mbsRadiusSquared)&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){let t=this._mbsRadius;if(t<0)return!0;let n=e.center,r=e.radius,i=t+r,a=this.obbCenterX-n[0];if(a>i)return!1;let o=this.obbCenterY-n[1];if(o>i)return!1;let s=this.obbCenterZ-n[2];if(s>i)return!1;let c=a*a+o*o+s*s;return c>i*i?!1:c<=(this._obbShortestHalfsize+r)**2||Math.sqrt(c)+t<=r?!0:this.obb?.intersectSphere(e)??!0}}export{i as GaussianTile};
2
+ import{estimateNumberArrayMemory as e}from"../../../../core/memoryEstimations.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n,diameter as r}from"../../../../geometry/support/aaBoundingBox.js";class i{constructor({handle:i,obb:a,pageIds:o,relativePositions:s,packedRotations:c,packedOpacityScaledScales:l,gaussianCount:u,maxSplatMbsRadiusSquared:d,maxGaussianOpacity:f,elevationRange:p}){this.bvhIntersectionGeneration=0,this.lifecycleState=0,this.cullingRevision=-1,this.cullingVisible=!1,this.fadeDirection=0,this.opacityModifier=0,this.handle=i,this.obb=a,this.pageIds=o,this.relativePositions=s,this.packedRotations=c,this.packedOpacityScaledScales=l,this.gaussianCount=u,this.maxSplatMbsRadiusSquared=d,this.maxGaussianOpacity=f,this.elevationRange=p,this.usedMemory=e(this.pageIds,this.relativePositions,this.packedRotations,this.packedOpacityScaledScales);let m=t();a.getCenter(m),this.obbCenterX=m[0],this.obbCenterY=m[1],this.obbCenterZ=m[2];let h=a.radius??-1;this._mbsRadius=h;let g=h<0?-1:h*h;this._mbsRadiusSquared=g,this._obbShortestHalfsize=Math.min(a.halfSizeX,a.halfSizeY,a.halfSizeZ);let _=n();a.toAaBoundingBox(_),this.boundingBox=_;let v=h>=0?h:r(_)*.5;this.paddedMbsRadius=v+Math.sqrt(Math.max(0,d))}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;let{obbCenterX:n,obbCenterY:r,obbCenterZ:i}=this,a=n-e[0],o=r-e[1],s=i-e[2],c=a*t[0]+o*t[1]+s*t[2],l=a*a+o*o+s*s-c*c;return(this._mbsRadiusSquared<0||l<=this._mbsRadiusSquared)&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){let t=this._mbsRadius;if(t<0)return!0;let n=e.center,r=e.radius,i=t+r,a=this.obbCenterX-n[0];if(a>i)return!1;let o=this.obbCenterY-n[1];if(o>i)return!1;let s=this.obbCenterZ-n[2];if(s>i)return!1;let c=a*a+o*o+s*s;return c>i*i?!1:c<=(this._obbShortestHalfsize+r)**2||Math.sqrt(c)+t<=r?!0:this.obb?.intersectSphere(e)??!0}}export{i as GaussianTile};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ import{isUint32Array as e}from"../../../../core/typedArrayUtil.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{validateEntity3D as n}from"../../../../layers/support/tiles3DUtils.js";import{ElevationRange as r}from"../ElevationRange.js";import{Obb as i}from"../orientedBoundingBox.js";import{gaussianSplatGridCellSize as a,gaussianEllipsoidScaleMultiplier as o}from"./formatConstants.js";import{splatPageSizeInU32 as s,gaussiansPerPage as c,packedGaussianSizeInU32 as l,splatAtlasTextureWidth as u}from"./GaussianSplatAtlasPages.js";import{GaussianTile as d}from"./GaussianTile.js";class f{static{this.createRenderableBatchSize=64}static{this.uploadBatchPageCount=16}constructor(e,t,n){this._textureAtlas=e,this._headerTexture=t,this._freeInvisibleTiles=n,this._pageBuffer=new Uint32Array(s*f.uploadBatchPageCount),this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer)}prepare(r){let{entity3d:o}=r;if(!n(o))throw Error(`entity3D not valid`);let s=o.desc.geometry.prims[o.validPrimitiveIndices[0]];if(s.atrbs.length<1||s.atrbs[0].sem!==`GSplatPacked`)throw Error(`entity3D not valid`);let c=s.atrbs[0],l=o.assets[c.assetId];if(!l)throw Error(`entity3D not valid`);let u=l.count;if(u===0)return null;let d=null;if(l.dataType===`U32`&&e(l.data))d=l.data;else throw Error(`unexpected GaussianSplat Entity3D asset.data format`);let f=this._extractHeader(d),p=f.tileOrigin.x*a,m=f.tileOrigin.y*a,h=f.tileOrigin.z*a,g=o.desc,_=g.obb.quaternion,v=new i(g.obb.center,g.obb.halfSize,t(..._));return{handle:r.handle,bufferView:d,totalGaussians:u,packedHeader:f.packedHeader,tileOrigin:{x:p,y:m,z:h},invPosScale:f.invPosScale,obb:v,origin:{x:v.centerX,y:v.centerY,z:v.centerZ}}}*build(e,t){let{handle:n,bufferView:i,totalGaussians:a,packedHeader:o,tileOrigin:p,invPosScale:g,obb:_,origin:v,isGlobal:y,ellipsoidRadius:b}=e,x=p.x,S=p.y,C=p.z,w=v.x,T=v.y,E=v.z,D=new Float32Array(a*3),O=new Uint32Array(a),k=new Uint32Array(a),A=[],j=Math.ceil(a/c),M=1/0,N=-1/0,P=1/0,F=-1/0,I=0,L=-1,R=0,z=0;for(let e=0;e<a;e++){let n=e*l,r=i[n],a=i[n+1],o=i[n+2],s=i[n+3],c=a&16383,u=a>>>14&16383,d=a>>>28&15|(o&1023)<<4,p=s>>>24,m=h[p],_=(o>>>10&255)+m,v=(o>>>18&255)+m,b=(o>>>26&63|(s&3)<<6)+m,A=_>0?_:0,j=v>0?v:0,B=b>0?b:0,V=A|j<<8|B<<16,H=Math.max(A,j,B),U=c*g+x,W=u*g+S,G=d*g+C;if(D[I]=U-w,D[I+1]=W-T,D[I+2]=G-E,y){let e=U*U+W*W+G*G;P=Math.min(P,e),F=Math.max(F,e)}else M=Math.min(M,G),N=Math.max(N,G);O[e]=r,k[e]=V,H>L&&(L=H),p>R&&(R=p),I+=3,z++,z===f.createRenderableBatchSize&&(z=0,t.madeProgress()&&(t=yield))}z>0&&t.madeProgress()&&(t=yield),y&&(M=Math.sqrt(P)-b,N=Math.sqrt(F)-b);let B=this._extractGaussianSplatMbsRadiusSquared(L),V=new r(M,N),H=this._textureAtlas,U=this._headerTexture;try{for(let e=0;e<j;e+=f.uploadBatchPageCount){let n=Math.min(j,e+f.uploadBatchPageCount);for(let t=e;t<n;t++){let e=H.allocatePage();if(e===null&&(this._freeInvisibleTiles(),e=H.allocatePage()),e===null)throw Error(`ran out of gaussian splat memory`);A.push(e)}for(let t=e;t<n;){let e=A[t],r=t+1;for(;r<n&&A[r]===A[r-1]+1;)r++;let d=r-t,f=a-t*c,p=Math.min(f,d*c),m=t*s,h=p*l;this._pageBuffer.set(i.subarray(m,m+h));let g=e*c,_=g%u,v=Math.floor(g/u);H.update(_,v,this._pageBuffer,d),U.update(e,o,d),t=r}t.madeProgress()&&(t=yield)}}catch(e){throw H.freePages(A),e}return new d({handle:n,obb:_,pageIds:A,relativePositions:D,packedRotations:O,packedOpacityScaledScales:k,gaussianCount:a,maxSplatMbsRadiusSquared:B,maxGaussianOpacity:R/m,elevationRange:V})}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*p}_extractHeader(e){let t=e.length-4,n=this._reinterpretU32AsFloat(e[t]),r=this._reinterpretU32AsFloat(e[t+1]),i=this._reinterpretU32AsFloat(e[t+2]),a=1/(1<<(e[t+3]&255));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:n,y:r,z:i},invPosScale:a}}_reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}}const p=o*o,m=255,h=(()=>{let e=new Int16Array(256);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/255));return e})();export{f as GaussianTileBuilder};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
+ const e=2.048,t=3;export{t as gaussianEllipsoidScaleMultiplier,e as gaussianSplatGridCellSize};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{createTask as t}from"../../../../core/asyncUtils.js";import{on as n}from"../../../../core/events.js";import{destroyMaybe as r,abortMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as a,isAbortError as o}from"../../../../core/promiseUtils.js";import{property as s,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{distance as l,exactEquals as u,copy as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import m from"../../../../geometry/Point.js";import{distanceToScale as h}from"../cameraScaleUtils.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PropertiesPool as _}from"../../../support/PropertiesPool.js";import{Yield as v}from"../../../support/Yield.js";let y=class extends g{constructor(e){super(e),this._dirty=!1,this._groundQueryDirty=!0,this._propertiesPool=new _({location:()=>new m,renderLocation:()=>f()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryTask=null,this._lastQueryRenderEye=f(),this.renderLocation=f(),this._tmpPoint=new m}initialize(){this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.surface&&this.addHandles(n(this.surface,`elevation-query-change`,()=>this._invalidateElevationQuery())),this.runTask(),this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=r(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){let e=this._propertiesPool.get(`location`);return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get scale(){let e=this._camera,t=l(e.eye,this.renderLocation),n={renderCoordsHelper:this.renderCoordsHelper,state:{camera:e}};return h(n,t)}get updating(){return this._dirty||this._elevationQueryTask!=null}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||=!0}_cancelPendingRequest(){this._elevationQueryTask=i(this._elevationQueryTask)}get readyToRun(){return!this._elevationQueryTask&&this._dirty&&this._groundQueryReady}runTask(){this._cancelPendingRequest(),this._dirty=!1;let e=p(this._camera.eye);if(this._hasCurrentGroundQuery(e))return v;let n=this.map?.ground;if(!n)return this._updateSurfaceAltitude(0),this._rememberGroundQuery(e),v;if(!this._groundQueryReady)return this._setDirty(),v;let r=this.state.spatialReference;this._tmpPoint.spatialReference=r,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);let i=(this._tmpPoint.z??0)>x&&this.renderCoordsHelper.viewingMode===1&&(r.isWGS84||r.isWebMercator)?S:0,s=null;return s=t(async t=>{try{let r=await n.queryElevation(this._tmpPoint,{signal:t,cache:this.cache,minDemResolution:i});if(a(t),this._elevationQueryTask!==s)return;this._updateSurfaceAltitude(r.geometry.z??0),this._rememberGroundQuery(e)}catch(n){if(this._elevationQueryTask!==s||t.aborted||o(n))return;this._updateSurfaceAltitude(0),this._rememberGroundQuery(e)}finally{this._elevationQueryTask===s&&(this._elevationQueryTask=null)}}),this._elevationQueryTask=s,v}get _groundQueryReady(){return this.surface?.elevationQueryReady??!0}_hasCurrentGroundQuery(e){return!this._groundQueryDirty&&u(this._lastQueryRenderEye,e)}_rememberGroundQuery(e){d(this._lastQueryRenderEye,e),this._groundQueryDirty=!1}_invalidateElevationQuery(){this._cancelPendingRequest(),this.cache?.clear(),this._groundQueryDirty=!0,this._setDirty()}_updateSurfaceAltitude(e){this._estimatedSurfaceAltitude!==e&&(this._estimatedSurfaceAltitude=e,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(b,this._estimatedSurfaceAltitude,this._camera.eye),u(this._get(`renderLocation`),b)||(this._set(`renderLocation`,d(this._propertiesPool.get(`renderLocation`),b)),this.notifyChange(`renderLocation`))}};e([s({constructOnly:!0})],y.prototype,`scheduler`,void 0),e([s({constructOnly:!0})],y.prototype,`surface`,void 0),e([s({constructOnly:!0})],y.prototype,`cache`,void 0),e([s({constructOnly:!0})],y.prototype,`map`,void 0),e([s({constructOnly:!0})],y.prototype,`task`,void 0),e([s()],y.prototype,`_dirty`,void 0),e([s()],y.prototype,`_groundQueryDirty`,void 0),e([s()],y.prototype,`_elevationQueryTask`,void 0),e([s()],y.prototype,`location`,null),e([s()],y.prototype,`renderLocation`,void 0),e([s()],y.prototype,`scale`,null),e([s()],y.prototype,`updating`,null),e([s()],y.prototype,`readyToRun`,null),e([s()],y.prototype,`_groundQueryReady`,null),y=e([c(`esri.views.3d.support.pointsOfInterest.CameraOnSurface`)],y);const b=f(),x=1e5,S=1e6;export{y as CameraOnSurface};
2
+ import{__decorate as e}from"tslib";import{createTask as t}from"../../../../core/asyncUtils.js";import{on as n}from"../../../../core/events.js";import{destroyMaybe as r,abortMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as a,isAbortError as o}from"../../../../core/promiseUtils.js";import{property as s,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{distance as l,exactEquals as u,copy as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import m from"../../../../geometry/Point.js";import{distanceToScale as h}from"../cameraScaleUtils.js";import{PointOfInterest as g}from"./PointOfInterest.js";import{PropertiesPool as _}from"../../../support/PropertiesPool.js";import{Yield as v}from"../../../support/Yield.js";let y=class extends g{constructor(e){super(e),this._dirty=!1,this._groundQueryDirty=!0,this._propertiesPool=new _({location:()=>new m,renderLocation:()=>f()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryTask=null,this._lastQueryRenderEye=f(),this.renderLocation=f(),this._tmpPoint=new m}initialize(){this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.surface&&this.addHandles(n(this.surface,`elevation-query-change`,()=>this._invalidateElevationQuery())),this.runTask(),this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=r(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){let e=this._propertiesPool.get(`location`);return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get scale(){let e=this._camera,t=l(e.eye,this.renderLocation),n={renderCoordsHelper:this.renderCoordsHelper,state:{camera:e}};return h(n,t)}get updating(){return this._dirty||this._elevationQueryTask!=null}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||=!0}_cancelPendingRequest(){this._elevationQueryTask=i(this._elevationQueryTask)}get readyToRun(){return!this._elevationQueryTask&&this._dirty&&this._groundQueryReady}runTask(){this._cancelPendingRequest(),this._dirty=!1;let e=p(this._camera.eye);if(this._hasCurrentGroundQuery(e))return v;let n=this.map?.ground;if(!n)return this._updateSurfaceAltitude(0),this._rememberGroundQuery(e),v;if(!this._groundQueryReady)return this._setDirty(),v;let r=this.state.spatialReference;this._tmpPoint.spatialReference=r,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);let i=(this._tmpPoint.z??0)>x&&this.renderCoordsHelper.viewingMode===1&&(r.isWGS84||r.isWebMercator)?S:0,s=null;return s=t(async t=>{try{let r=await n.queryElevation(this._tmpPoint,{signal:t,cache:this.cache,minDemResolution:i,view:this.state.view});if(a(t),this._elevationQueryTask!==s)return;this._updateSurfaceAltitude(r.geometry.z??0),this._rememberGroundQuery(e)}catch(n){if(this._elevationQueryTask!==s||t.aborted||o(n))return;this._updateSurfaceAltitude(0),this._rememberGroundQuery(e)}finally{this._elevationQueryTask===s&&(this._elevationQueryTask=null)}}),this._elevationQueryTask=s,v}get _groundQueryReady(){return this.surface?.elevationQueryReady??!0}_hasCurrentGroundQuery(e){return!this._groundQueryDirty&&u(this._lastQueryRenderEye,e)}_rememberGroundQuery(e){d(this._lastQueryRenderEye,e),this._groundQueryDirty=!1}_invalidateElevationQuery(){this._cancelPendingRequest(),this.cache?.clear(),this._groundQueryDirty=!0,this._setDirty()}_updateSurfaceAltitude(e){this._estimatedSurfaceAltitude!==e&&(this._estimatedSurfaceAltitude=e,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(b,this._estimatedSurfaceAltitude,this._camera.eye),u(this._get(`renderLocation`),b)||(this._set(`renderLocation`,d(this._propertiesPool.get(`renderLocation`),b)),this.notifyChange(`renderLocation`))}};e([s({constructOnly:!0})],y.prototype,`scheduler`,void 0),e([s({constructOnly:!0})],y.prototype,`surface`,void 0),e([s({constructOnly:!0})],y.prototype,`cache`,void 0),e([s({constructOnly:!0})],y.prototype,`map`,void 0),e([s({constructOnly:!0})],y.prototype,`task`,void 0),e([s()],y.prototype,`_dirty`,void 0),e([s()],y.prototype,`_groundQueryDirty`,void 0),e([s()],y.prototype,`_elevationQueryTask`,void 0),e([s()],y.prototype,`location`,null),e([s()],y.prototype,`renderLocation`,void 0),e([s()],y.prototype,`scale`,null),e([s()],y.prototype,`updating`,null),e([s()],y.prototype,`readyToRun`,null),e([s()],y.prototype,`_groundQueryReady`,null),y=e([c(`esri.views.3d.support.pointsOfInterest.CameraOnSurface`)],y);const b=f(),x=1e5,S=1e6;export{y as CameraOnSurface};
@@ -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{createTask as n}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,isAbortError as a}from"../../../../core/promiseUtils.js";import{on as o,watch as s}from"../../../../core/reactiveUtils.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../../../../geometry/Point.js";import{center as f}from"../../../../geometry/support/aaBoundingRect.js";import"../../../../core/RandomLCG.js";import"../../../../core/Logger.js";import"../../../../core/units.js";import"../../../../geometry/ellipsoidUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/Geometry.js";import"../../../../geometry/Multipoint.js";import"../../../../geometry/Polygon.js";import"../../../../geometry/Polyline.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/spatialReferenceEllipsoidUtils.js";import"../../../../geometry/operators/support/GeographicTransformation.js";import"../../../../geometry/projection/projectors.js";import"../../../../geometry/support/spatialReferenceUtils.js";import"../../../../layers/support/ElevationTileData.js";import"../../../../layers/support/TileElevationSampler.js";let p=class extends t{constructor(e){super(e),this._updateTask=null,this.location=null}initialize(){this.view.state.isLocal&&(this.addHandles([o(()=>this._groundView,`elevation-query-change`,()=>{this._invalidateGroundQuery()}),s(()=>[this.view.clippingArea,this._groundView?.spatialReference,this._groundView?.groundExtent],()=>this._update())]),this._update())}destroy(){this._cancelPendingUpdate()}get renderLocation(){if(!this.location)return null;let e=u();return this.view.renderCoordsHelper.toRenderCoords(this.location,e),e}get _ground(){return this.view.map?.ground}get _groundView(){return this.view.groundView}_cancelPendingUpdate(){this._updateTask=r(this._updateTask)}_update(){this._cancelPendingUpdate();let e=this._groundView;if(!e?.elevationQueryReady||e.groundExtent==null||e.spatialReference==null){this._set(`location`,null);return}let t=f(e.groundExtent),r=new d({x:t[0],y:t[1],z:0,spatialReference:e.spatialReference}),o=this._ground;if(o&&o.allLayers.length>0){this._set(`location`,null);let e=null;e=n(async e=>{let t=await o.queryElevation(r,{noDataValue:0,signal:e,cache:this.cache});i(e),this._updateTask=null,this._set(`location`,t.geometry)}),this._updateTask=e,e.promise.catch(t=>{this._updateTask===e&&(this._updateTask=null,a(t))})}else this._set(`location`,r)}_invalidateGroundQuery(){this._cancelPendingUpdate(),this.cache?.clear(),this._set(`location`,null),this._update()}};e([c({constructOnly:!0})],p.prototype,`view`,void 0),e([c({constructOnly:!0})],p.prototype,`cache`,void 0),e([c()],p.prototype,`_updateTask`,void 0),e([c({readOnly:!0})],p.prototype,`location`,void 0),e([c({readOnly:!0})],p.prototype,`renderLocation`,null),e([c()],p.prototype,`_ground`,null),e([c()],p.prototype,`_groundView`,null),p=e([l(`esri.views.3d.support.pointsOfInterest.StableSurfaceCenter`)],p);export{p as StableSurfaceCenter};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{createTask as n}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as i,isAbortError as a}from"../../../../core/promiseUtils.js";import{on as o,watch as s}from"../../../../core/reactiveUtils.js";import{property as c,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import d from"../../../../geometry/Point.js";import{center as f}from"../../../../geometry/support/aaBoundingRect.js";import"../../../../core/RandomLCG.js";import"../../../../core/Logger.js";import"../../../../core/units.js";import"../../../../geometry/ellipsoidUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/Geometry.js";import"../../../../geometry/Multipoint.js";import"../../../../geometry/Polygon.js";import"../../../../geometry/Polyline.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/spatialReferenceEllipsoidUtils.js";import"../../../../geometry/operators/support/GeographicTransformation.js";import"../../../../geometry/projection/projectors.js";import"../../../../geometry/support/spatialReferenceUtils.js";import"../../../../layers/support/ElevationTileData.js";import"../../../../layers/support/TileElevationSampler.js";let p=class extends t{constructor(e){super(e),this._updateTask=null,this.location=null}initialize(){this.view.state.isLocal&&(this.addHandles([o(()=>this._groundView,`elevation-query-change`,()=>{this._invalidateGroundQuery()}),s(()=>[this.view.clippingArea,this._groundView?.spatialReference,this._groundView?.groundExtent],()=>this._update())]),this._update())}destroy(){this._cancelPendingUpdate()}get renderLocation(){if(!this.location)return null;let e=u();return this.view.renderCoordsHelper.toRenderCoords(this.location,e),e}get _ground(){return this.view.map?.ground}get _groundView(){return this.view.groundView}_cancelPendingUpdate(){this._updateTask=r(this._updateTask)}_update(){this._cancelPendingUpdate();let e=this._groundView;if(!e?.elevationQueryReady||e.groundExtent==null||e.spatialReference==null){this._set(`location`,null);return}let t=f(e.groundExtent),r=new d({x:t[0],y:t[1],z:0,spatialReference:e.spatialReference}),o=this._ground;if(o&&o.allLayers.length>0){this._set(`location`,null);let e=null;e=n(async e=>{let t=await o.queryElevation(r,{noDataValue:0,signal:e,cache:this.cache,view:this.view});i(e),this._updateTask=null,this._set(`location`,t.geometry)}),this._updateTask=e,e.promise.catch(t=>{this._updateTask===e&&(this._updateTask=null,a(t))})}else this._set(`location`,r)}_invalidateGroundQuery(){this._cancelPendingUpdate(),this.cache?.clear(),this._set(`location`,null),this._update()}};e([c({constructOnly:!0})],p.prototype,`view`,void 0),e([c({constructOnly:!0})],p.prototype,`cache`,void 0),e([c()],p.prototype,`_updateTask`,void 0),e([c({readOnly:!0})],p.prototype,`location`,void 0),e([c({readOnly:!0})],p.prototype,`renderLocation`,null),e([c()],p.prototype,`_ground`,null),e([c()],p.prototype,`_groundView`,null),p=e([l(`esri.views.3d.support.pointsOfInterest.StableSurfaceCenter`)],p);export{p as StableSurfaceCenter};
@@ -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{EventEmitter as n}from"../../../../core/Evented.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as o,expand as s,intersects as c}from"../../../../geometry/support/aaBoundingRect.js";import{TaskPriority as l}from"../../../support/Scheduler.js";import{Yield as u}from"../../../support/Yield.js";let d=class extends t{constructor(e){super(e),this._tileGeometryUpdateExtent=o(),this._tileGeometryUpdateSpatialReference=null,this.events=new n,this.updating=!1}initialize(){this.addHandles([this.surface.on(`elevation-change`,e=>this._tileGeometryChanged(e)),this.scheduler.registerTask(l.SURFACE_GEOMETRY_UPDATES,this)])}get readyToRun(){return this.updating}runTask(){return this.updating&&(this._tileGeometryUpdateSpatialReference&&this._centerIntersectsExtent(this._tileGeometryUpdateExtent,this._tileGeometryUpdateSpatialReference)&&this.events.emit(`request-update`,f),o(this._tileGeometryUpdateExtent),this._set(`updating`,!1)),u}_tileGeometryChanged(e){this._tileGeometryUpdateSpatialReference=e.spatialReference,s(this._tileGeometryUpdateExtent,e.extent,this._tileGeometryUpdateExtent),this._set(`updating`,!0)}_furthestCenterOnSurface(){let e=this.centerOnSurfaces[0];for(let t=1;t<this.centerOnSurfaces.length;t++){let n=this.centerOnSurfaces[t];n.distance>e.distance&&(e=n)}return e}_centerIntersectsExtent(e,t){let n=this.state.contentCamera.eye,r=h,i=this._furthestCenterOnSurface();return this.renderCoordsHelper.fromRenderCoords(n,p,t),this.renderCoordsHelper.fromRenderCoords(i.renderLocation,m,t),p[0]<m[0]?(r[0]=p[0],r[2]=m[0]):(r[0]=m[0],r[2]=p[0]),p[1]<m[1]?(r[1]=p[1],r[3]=m[1]):(r[1]=m[1],r[3]=p[1]),c(r,e)}};e([r({constructOnly:!0})],d.prototype,`state`,void 0),e([r({constructOnly:!0})],d.prototype,`centerOnSurfaces`,void 0),e([r({constructOnly:!0})],d.prototype,`renderCoordsHelper`,void 0),e([r({constructOnly:!0})],d.prototype,`scheduler`,void 0),e([r({constructOnly:!0})],d.prototype,`surface`,void 0),e([r({readOnly:!0})],d.prototype,`updating`,void 0),d=e([i(`esri.views.3d.support.pointsOfInterest.SurfaceGeometryUpdates`)],d);const f={},p=a(),m=a(),h=o();export{d as SurfaceGeometryUpdates};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{EventEmitter as n}from"../../../../core/Evented.js";import{property as r,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as o,expand as s,intersects as c}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as l}from"../../../../geometry/support/spatialReferenceUtils.js";import"../elevationUpdateExtentUtils.js";import{TaskPriority as u}from"../../../support/Scheduler.js";import{Yield as d}from"../../../support/Yield.js";import{intersectsGeographicExtent as f}from"../sphereExtentUtils.js";let p=class extends t{constructor(e){super(e),this._tileGeometryUpdateExtent=o(),this._tileGeometryUpdateSpatialReference=null,this.events=new n,this.updating=!1}initialize(){this.addHandles([this.surface.on(`elevation-change`,e=>this._tileGeometryChanged(e)),this.scheduler.registerTask(u.SURFACE_GEOMETRY_UPDATES,this)])}get readyToRun(){return this.updating}runTask(){return this.updating&&(this._tileGeometryUpdateSpatialReference&&this._centerIntersectsExtent(this._tileGeometryUpdateExtent,this._tileGeometryUpdateSpatialReference)&&this.events.emit(`request-update`,m),o(this._tileGeometryUpdateExtent),this._set(`updating`,!1)),d}_tileGeometryChanged(e){this._tileGeometryUpdateSpatialReference=e.spatialReference,s(this._tileGeometryUpdateExtent,e.extent,this._tileGeometryUpdateExtent),this._set(`updating`,!0)}_furthestCenterOnSurface(){let e=this.centerOnSurfaces[0];for(let t=1;t<this.centerOnSurfaces.length;t++){let n=this.centerOnSurfaces[t];n.distance>e.distance&&(e=n)}return e}_centerIntersectsExtent(e,t){let n=this.state.contentCamera.eye,r=_,i=this._furthestCenterOnSurface();this.renderCoordsHelper.fromRenderCoords(n,h,t),this.renderCoordsHelper.fromRenderCoords(i.renderLocation,g,t);let a=this.renderCoordsHelper.viewingMode===1?l(t)?.valid:null;if(a!=null){let e=a[1]-a[0];g[0]+=Math.round((h[0]-g[0])/e)*e}return h[0]<g[0]?(r[0]=h[0],r[2]=g[0]):(r[0]=g[0],r[2]=h[0]),h[1]<g[1]?(r[1]=h[1],r[3]=g[1]):(r[1]=g[1],r[3]=h[1]),a==null?c(r,e):f(r,e,t)}};e([r({constructOnly:!0})],p.prototype,`state`,void 0),e([r({constructOnly:!0})],p.prototype,`centerOnSurfaces`,void 0),e([r({constructOnly:!0})],p.prototype,`renderCoordsHelper`,void 0),e([r({constructOnly:!0})],p.prototype,`scheduler`,void 0),e([r({constructOnly:!0})],p.prototype,`surface`,void 0),e([r({readOnly:!0})],p.prototype,`updating`,void 0),p=e([i(`esri.views.3d.support.pointsOfInterest.SurfaceGeometryUpdates`)],p);const m={},h=a(),g=a(),_=o();export{p as SurfaceGeometryUpdates};