@arcgis/core 4.34.0-next.40 → 4.34.0-next.42

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 (180) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/016d421114118307d4dd.js +1 -0
  3. package/assets/esri/core/workers/chunks/1a2278b9fe9666342728.js +1 -0
  4. package/assets/esri/core/workers/chunks/250b1629becca0410f2a.js +1 -0
  5. package/assets/esri/core/workers/chunks/3245d20ea4bb779f87ef.js +1 -0
  6. package/assets/esri/core/workers/chunks/6b73926feb5c5d957062.js +1 -0
  7. package/assets/esri/core/workers/chunks/{6269c4bbf0f224a954e9.js → 6f4079b7a2b45f304ee6.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{4e6e5677b90b00622146.js → 7ef7f3925495b9ade88c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/82955562805ad5514ed8.js +346 -0
  10. package/assets/esri/core/workers/chunks/{5fe3c279d57f44416c28.js → a1d3f1c221389eb6090c.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{306a68137e62656b0f05.js → d5d2d4df407cf078bb81.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{94850c094e076d81a016.js → dca2b487152cde45fb65.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{31ad9949b08a5b07218c.js → eea3e0bd17479a767160.js} +2 -2
  14. package/assets/esri/core/workers/chunks/fe6fa1f2c2d54d41645e.js +1 -0
  15. package/config.js +1 -1
  16. package/core/workers/registry.js +1 -1
  17. package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
  18. package/geometry/support/curves/closestPointOnCurve.js +1 -1
  19. package/geometry/support/curves/curveExtent.js +1 -1
  20. package/geometry/support/curves/curveLength.js +1 -1
  21. package/geometry/support/curves/curveUtils.js +1 -1
  22. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  23. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  24. package/geometry/support/curves/splitCurveAtPoint.js +1 -1
  25. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  26. package/interfaces.d.ts +24 -2
  27. package/kernel.js +1 -1
  28. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  29. package/layers/PointCloudLayer.js +1 -1
  30. package/package.json +1 -1
  31. package/rest/networks/support/CircuitPath.js +1 -1
  32. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  33. package/support/revision.js +1 -1
  34. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  35. package/views/2d/engine/flow/styles/Particles.js +1 -1
  36. package/views/2d/engine/flow/styles/Streamlines.js +1 -1
  37. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  38. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  39. package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
  40. package/views/2d/engine/webgl/Mesh2D.js +1 -1
  41. package/views/2d/engine/webgl/VertexStream.js +1 -1
  42. package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
  43. package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
  44. package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
  45. package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
  46. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  47. package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
  48. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  49. package/views/2d/engine/webgl/meshing/SimpleMesh.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js +1 -1
  52. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  53. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  54. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  55. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  56. package/views/2d/layers/KMLLayerView2D.js +1 -1
  57. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  58. package/views/2d/layers/MediaLayerView2D.js +1 -1
  59. package/views/2d/layers/TileLayerView2D.js +1 -1
  60. package/views/2d/layers/WMSLayerView2D.js +1 -1
  61. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  62. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  63. package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
  64. package/views/2d/layers/support/DebugOverlay.js +1 -1
  65. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  66. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  67. package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
  68. package/views/3d/environment/LocalAtmosphere.js +1 -1
  69. package/views/3d/environment/MarsAtmosphere.js +1 -1
  70. package/views/3d/environment/Precipitation.js +1 -1
  71. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  72. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  73. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  74. package/views/3d/layers/FlowSubView3D.js +1 -1
  75. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  76. package/views/3d/layers/I3SMeshView3D.js +1 -1
  77. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  78. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  79. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  80. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  81. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  82. package/views/3d/layers/support/FlowTileTree3DDebugger.js +1 -1
  83. package/views/3d/support/GaussianSplatSortWorker.js +5 -0
  84. package/views/3d/support/GaussianSplatWorkerHandle.js +5 -0
  85. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  86. package/views/3d/support/flow/geometryUtils.js +1 -1
  87. package/views/3d/support/flow/loadUtils.js +1 -1
  88. package/views/3d/support/intersectionUtils.js +1 -1
  89. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  90. package/views/3d/terrain/PatchRenderData.js +1 -1
  91. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  92. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  93. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  94. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  95. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  96. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  97. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  98. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  99. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  100. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  101. package/views/3d/webgl-engine/lib/edgeRendering/edgeBufferWriters.js +1 -1
  102. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  103. package/views/3d/webgl-engine/lib/lodRendering/BackedBufferObject.js +1 -1
  104. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  105. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  106. package/views/3d/webgl-engine/lib/lodRendering/RenderInstanceData.js +1 -1
  107. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +5 -0
  108. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  109. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  110. package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
  111. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +5 -0
  112. package/views/PopupView.js +1 -1
  113. package/views/VideoView.js +1 -1
  114. package/views/draw/DrawAction.js +1 -1
  115. package/views/draw/DrawOperation.js +1 -1
  116. package/views/draw/SegmentDrawAction.js +1 -1
  117. package/views/draw/support/Reshape.js +1 -1
  118. package/views/interactive/SegmentLabels.js +1 -1
  119. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  120. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  121. package/views/interactive/editGeometry/operations/AppendVertex.js +1 -1
  122. package/views/interactive/editGeometry/operations/ClosePart.js +5 -0
  123. package/views/interactive/editGeometry/operations/MoveMesh.js +1 -1
  124. package/views/interactive/editGeometry/operations/MoveVertex.js +1 -1
  125. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  126. package/views/interactive/editGeometry/operations/RemoveVertices.js +1 -1
  127. package/views/interactive/editGeometry/operations/RotateVertex.js +1 -1
  128. package/views/interactive/editGeometry/operations/ScaleVertex.js +1 -1
  129. package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +1 -1
  130. package/views/interactive/editGeometry/operations/SetVertexPosition.js +1 -1
  131. package/views/interactive/editGeometry/operations/SplitSegment.js +5 -0
  132. package/views/interactive/editGeometry/operations/UpdateVertices.js +1 -1
  133. package/views/interactive/editGeometry/operations/curveOperationUtils.js +5 -0
  134. package/views/interactive/editGeometry/operations.js +1 -1
  135. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  136. package/views/interactive/snapping/LineSnapper.js +1 -1
  137. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  138. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  139. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  140. package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
  141. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  142. package/views/support/TileTreeDebugger.js +1 -1
  143. package/views/webgl/BufferObject.js +1 -1
  144. package/views/webgl/Util.js +1 -1
  145. package/views/webgl/VertexArrayObject.js +1 -1
  146. package/views/webgl/VertexBuffer.js +1 -1
  147. package/views/webgl/testFloatBufferBlend.js +1 -1
  148. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  149. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  150. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  151. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  152. package/widgets/Editor/EditorViewModel.js +1 -1
  153. package/widgets/Editor/support/SketchController.js +1 -1
  154. package/widgets/Feature/FeatureMedia.js +1 -1
  155. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  156. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  157. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  158. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  159. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  160. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  161. package/widgets/Features.js +1 -1
  162. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  163. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  164. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  165. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  166. package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +5 -0
  167. package/widgets/PanoramicViewer/support/PanoramicMeshWorker.js +5 -0
  168. package/widgets/Spinner.js +1 -1
  169. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  170. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  171. package/widgets/UtilityNetworkTrace.js +1 -1
  172. package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
  173. package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
  174. package/assets/esri/core/workers/chunks/01bd8f90e55081e65b38.js +0 -1
  175. package/assets/esri/core/workers/chunks/0a27f9b11d03874809ee.js +0 -346
  176. package/assets/esri/core/workers/chunks/34f677e8c1691c10e4e9.js +0 -1
  177. package/assets/esri/core/workers/chunks/e95a8c988ef822723503.js +0 -1
  178. package/assets/esri/core/workers/chunks/fd3009164d5e38fda85f.js +0 -1
  179. package/views/interactive/editGeometry/operations/CloseComponent.js +0 -5
  180. package/views/interactive/editGeometry/operations/SplitEdge.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{disposeMaybe as s}from"../../../../core/maybe.js";import t from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as n,l as o,g as a,u as l,e as h,k as c}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as u}from"../../../../chunks/vec42.js";import{create as m,offset as p,contains as g,containsPoint as _,set as f,positiveInfinity as P,equals as x}from"../../../../geometry/support/aaBoundingBox.js";import{create as b}from"../../../../geometry/support/plane.js";import{fromPoints as S}from"../../../../geometry/support/ray.js";import{PclTarget as w}from"./Intersector.js";import{PointCloudHighlights as z}from"./PointCloudHighlights.js";import{isDepth as R,isColorOrColorEmission as y}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as j}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResult as v}from"../../webgl-engine/lib/IntersectorResult.js";import{VertexArrayObject as q}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as A,g as F}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as E,positionsLayout as H,colorsLayout as M}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as I}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as N}from"../../../webgl/BufferObject.js";import{PrimitiveType as V}from"../../../webgl/enums.js";import{VertexBuffer as B}from"../../../webgl/VertexBuffer.js";let L=class extends j{constructor(e){super(e),this.type=5,this.isGround=!1,this._passParameters=new A,this._highlights=new z({forEachNode:e=>this.forEachNode(e),addHighlight:(e,s,t)=>this._addHighlight(e,s,t),removeHighlight:(e,s)=>this._removeHighlight(e,s)}),this.produces=new Map([[2,e=>!(R(e)||8===e&&this._highlights.empty)],[3,e=>R(e)]]),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new I,this._nodes=new t}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersect(e,s,t,i){const r=d(),f=d(),P=d(),x=d(),z=b(),R=e.camera.perScreenPixelRatio/2,y=e.camera.near;n(f,i,t);const j=1/o(f);a(f,f,j),l(P,f),u(z,f[0],f[1],f[2],-h(f,t));const q=new k,A=new k,F=new Array,E=m(),H=m(this._passParameters.clipBox);p(H,-t[0],-t[1],-t[2],H),this._nodes.forAll(o=>{const a=o.splatSize*this._passParameters.scaleFactor;let l=o.obb.minimumDistancePlane(z),d=o.obb.maximumDistancePlane(z);l-=T(a,l+y,this._passParameters,R,o.isLeaf),d-=T(a,d+y,this._passParameters,R,o.isLeaf);const u=d<0,m=null!=q.dist&&null!=A.dist&&q.dist<l*j&&A.dist>d*j;if(u||m)return;const b=O(a,d+y,this._passParameters,R,o.isLeaf);if(!o.obb.intersectRay(t,f,b))return;const S=b*b;o.obb.toAaBoundingBox(E),p(E,-t[0],-t[1],-t[2],E);const w=!g(H,E);n(x,o.origin,t);const v=o.coordinates.length/3;for(let n=0;n<v;n++){if(r[0]=x[0]+o.coordinates[3*n],r[1]=x[1]+o.coordinates[3*n+1],r[2]=x[2]+o.coordinates[3*n+2],w&&!_(H,r))continue;const l=h(r,f),d=c(r)-l*l;if(d>S)continue;let u=l+y;const m=T(a,u,this._passParameters,R,o.isLeaf);if(l-m<0)continue;u-=m;const p=O(a,u,this._passParameters,R,o.isLeaf);if(d>p*p)continue;const g=(l-m)*j,b=e=>(e.point=C(o,n,e.point),e.dist=g,e.normal=P,e.node=o,e.pointId=n,e.layerViewUid=this.layerViewUid,e);if((null==q.dist||g<q.dist)&&(null==s||s(t,i,g))&&b(q),0!==e.options.store&&(null==A.dist||g>A.dist)&&(null==s||s(t,i,g))&&b(A),2===e.options.store&&(null==s||s(t,i,g))){const e=new k;F.push(b(e))}}});const M=e=>{const{layerViewUid:s,node:t,pointId:i}=e;return new w(e.point,s,i,()=>this.createGraphic(t,i,e.point))},I=(e,s)=>{const t=M(s);e.set(this.type,t,s.dist,s.normal)};if(U(q)){const s=e.results.min;(null==s.distance||q.dist<s.distance)&&I(s,q)}if(U(A)&&0!==e.options.store){const s=e.results.max;(null==s.distance||A.dist>s.distance)&&I(s,A)}if(2===e.options.store){const s=S(t,i);for(const t of F){const i=new v(s);I(i,t),e.results.all.push(i)}}}acquireTechniques(e){const s=8===e.output;return 0!==this._nodes.length&&(y(e.output)||R(e.output)&&3===e.bind.slot||s)?(this._nodes.forAll(s=>this._initNode(e,s)),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasHighlightMixTexture=s&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._context.techniques.get(E,this._configuration)):null}render(e,s){const{rctx:t,bind:i,output:r}=e,n=t.bindTechnique(s,i,this._passParameters),o=8===r,a=i.highlight?.name??null;o&&!a||this._nodes.forAll(s=>{0===s.coordinates.length||null==s.vao||o&&!s.highlightMap.has(a)||(n.assertCompatibleVertexAttributeLocations(s.vao),n.bindDraw(i,this._passParameters,s),t.bindVAO(s.vao),o?this._renderHighlightFragments(e,s):t.drawArrays(V.POINTS,0,s.coordinates.length/3))})}_renderHighlightFragments(e,s){const{highlightMap:t}=s,{rctx:i,bind:r}=e,{highlight:n}=r;if(!n)return;const o=n.name,a=t.get(o);if(!a||0===a.length)return;const{highlightOrderMap:l,highlightLevel:h}=r;if(null==h)return;for(const g of t.keys())if(g!==o){const e=l.get(g);if(void 0!==e&&e>h)return}let c=0,d=a[0].componentIndex,u=d+1;const m=()=>{for(;c<a.length&&a[c].id.highlightName!==o;)d=a[c].componentIndex,++c;u=d+1};m();const p=(e,s)=>{const t=s-e;t>0&&i.drawArrays(V.POINTS,e,t)};for(;c<a.length;){const e=a[c];if(e.id.highlightName!==o){p(d,u),++c,m();continue}const s=e.componentIndex;s!==u&&(p(d,u),d=s),u=s+1,++c}p(d,u)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){f(this._passParameters.clipBox,e||P)}get _clippingEnabled(){return!x(this._passParameters.clipBox,P,(e,s)=>e===s)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let t=null;return this._nodes.filterInPlace(i=>i.id!==e||(t=i,i.vao=s(i.vao),this._highlights.nodeRemoved(i),!1)),this._requestRender(),t}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll(e=>e.vao=s(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,s){return this._highlights.add(e,s)}_addHighlight(e,s,t){e.addHighlight(s,t),this._requestRender()}_removeHighlight(e,s){e.removeHighlight(s),this._requestRender()}_initNode(e,s){s.vao??=new q(e.rctx,new Map([["positions",new B(H,N.createVertex(e.rctx,35044,s.coordinates))],["colors",new B(M,N.createVertex(e.rctx,35044,s.rgb))]]))}_requestRender(){this._context&&this._context.requestRender()}};function O(e,s,t,i,r){if(t.drawScreenSpace)return t.fixedSize*s*i;const n=F(r)*s*i;return t.useFixedSizes?Math.min(t.fixedSize/2,n):t.screenMinSize>0?Math.min(Math.max(t.screenMinSize*s*i,e/2),n):Math.min(e/2,n)}function T(e,s,t,i,r){return t.drawScreenSpace?0:O(e,s,t,i,r)}function C(e,s,t){return null==t&&(t=d()),t[0]=e.origin[0]+e.coordinates[3*s],t[1]=e.origin[1]+e.coordinates[3*s+1],t[2]=e.origin[2]+e.coordinates[3*s+2],t}e([i({constructOnly:!0})],L.prototype,"createGraphic",void 0),L=e([r("esri.views.3d.layers.i3s.PointCloudRenderer")],L);class k{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function U(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}export{L as PointCloudRenderer};
5
+ import{__decorate as e}from"tslib";import{disposeMaybe as s}from"../../../../core/maybe.js";import t from"../../../../core/PooledArray.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{d as n,l as o,g as a,u as l,e as h,k as c}from"../../../../chunks/vec32.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as u}from"../../../../chunks/vec42.js";import{create as m,offset as p,contains as g,containsPoint as _,set as f,positiveInfinity as P,equals as x}from"../../../../geometry/support/aaBoundingBox.js";import{create as b}from"../../../../geometry/support/plane.js";import{fromPoints as S}from"../../../../geometry/support/ray.js";import{PclTarget as w}from"./Intersector.js";import{PointCloudHighlights as z}from"./PointCloudHighlights.js";import{isDepth as R,isColorOrColorEmission as y}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as j}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResult as v}from"../../webgl-engine/lib/IntersectorResult.js";import{VertexArrayObject as q}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as A,g as F}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as E,positionsLayout as H,colorsLayout as M}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as I}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as N}from"../../../webgl/enums.js";import{VertexBuffer as L}from"../../../webgl/VertexBuffer.js";let B=class extends j{constructor(e){super(e),this.type=5,this.isGround=!1,this._passParameters=new A,this._highlights=new z({forEachNode:e=>this.forEachNode(e),addHighlight:(e,s,t)=>this._addHighlight(e,s,t),removeHighlight:(e,s)=>this._removeHighlight(e,s)}),this.produces=new Map([[2,e=>!(R(e)||8===e&&this._highlights.empty)],[3,e=>R(e)]]),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new I,this._nodes=new t}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersect(e,s,t,i){const r=d(),f=d(),P=d(),x=d(),z=b(),R=e.camera.perScreenPixelRatio/2,y=e.camera.near;n(f,i,t);const j=1/o(f);a(f,f,j),l(P,f),u(z,f[0],f[1],f[2],-h(f,t));const q=new C,A=new C,F=new Array,E=m(),H=m(this._passParameters.clipBox);p(H,-t[0],-t[1],-t[2],H),this._nodes.forAll(o=>{const a=o.splatSize*this._passParameters.scaleFactor;let l=o.obb.minimumDistancePlane(z),d=o.obb.maximumDistancePlane(z);l-=V(a,l+y,this._passParameters,R,o.isLeaf),d-=V(a,d+y,this._passParameters,R,o.isLeaf);const u=d<0,m=null!=q.dist&&null!=A.dist&&q.dist<l*j&&A.dist>d*j;if(u||m)return;const b=O(a,d+y,this._passParameters,R,o.isLeaf);if(!o.obb.intersectRay(t,f,b))return;const S=b*b;o.obb.toAaBoundingBox(E),p(E,-t[0],-t[1],-t[2],E);const w=!g(H,E);n(x,o.origin,t);const v=o.coordinates.length/3;for(let n=0;n<v;n++){if(r[0]=x[0]+o.coordinates[3*n],r[1]=x[1]+o.coordinates[3*n+1],r[2]=x[2]+o.coordinates[3*n+2],w&&!_(H,r))continue;const l=h(r,f),d=c(r)-l*l;if(d>S)continue;let u=l+y;const m=V(a,u,this._passParameters,R,o.isLeaf);if(l-m<0)continue;u-=m;const p=O(a,u,this._passParameters,R,o.isLeaf);if(d>p*p)continue;const g=(l-m)*j,b=e=>(e.point=T(o,n,e.point),e.dist=g,e.normal=P,e.node=o,e.pointId=n,e.layerViewUid=this.layerViewUid,e);if((null==q.dist||g<q.dist)&&(null==s||s(t,i,g))&&b(q),0!==e.options.store&&(null==A.dist||g>A.dist)&&(null==s||s(t,i,g))&&b(A),2===e.options.store&&(null==s||s(t,i,g))){const e=new C;F.push(b(e))}}});const M=e=>{const{layerViewUid:s,node:t,pointId:i}=e;return new w(e.point,s,i,()=>this.createGraphic(t,i,e.point))},I=(e,s)=>{const t=M(s);e.set(this.type,t,s.dist,s.normal)};if(k(q)){const s=e.results.min;(null==s.distance||q.dist<s.distance)&&I(s,q)}if(k(A)&&0!==e.options.store){const s=e.results.max;(null==s.distance||A.dist>s.distance)&&I(s,A)}if(2===e.options.store){const s=S(t,i);for(const t of F){const i=new v(s);I(i,t),e.results.all.push(i)}}}acquireTechniques(e){const s=8===e.output;return 0!==this._nodes.length&&(y(e.output)||R(e.output)&&3===e.bind.slot||s)?(this._nodes.forAll(s=>this._initNode(e,s)),this._configuration.drawScreenSize=this._passParameters.drawScreenSpace,this._configuration.useFixedSizes=this._passParameters.useFixedSizes,this._configuration.hasSlicePlane=this._slicePlaneEnabled,this._configuration.hasOccludees=e.bind.hasOccludees,this._configuration.clippingEnabled=this._clippingEnabled,this._configuration.hasHighlightMixTexture=s&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._context.techniques.get(E,this._configuration)):null}render(e,s){const{rctx:t,bind:i,output:r}=e,n=t.bindTechnique(s,i,this._passParameters),o=8===r,a=i.highlight?.name??null;o&&!a||this._nodes.forAll(s=>{0===s.coordinates.length||null==s.vao||o&&!s.highlightMap.has(a)||(n.assertCompatibleVertexAttributeLocations(s.vao),n.bindDraw(i,this._passParameters,s),t.bindVAO(s.vao),o?this._renderHighlightFragments(e,s):t.drawArrays(N.POINTS,0,s.coordinates.length/3))})}_renderHighlightFragments(e,s){const{highlightMap:t}=s,{rctx:i,bind:r}=e,{highlight:n}=r;if(!n)return;const o=n.name,a=t.get(o);if(!a||0===a.length)return;const{highlightOrderMap:l,highlightLevel:h}=r;if(null==h)return;for(const g of t.keys())if(g!==o){const e=l.get(g);if(void 0!==e&&e>h)return}let c=0,d=a[0].componentIndex,u=d+1;const m=()=>{for(;c<a.length&&a[c].id.highlightName!==o;)d=a[c].componentIndex,++c;u=d+1};m();const p=(e,s)=>{const t=s-e;t>0&&i.drawArrays(N.POINTS,e,t)};for(;c<a.length;){const e=a[c];if(e.id.highlightName!==o){p(d,u),++c,m();continue}const s=e.componentIndex;s!==u&&(p(d,u),d=s),u=s+1,++c}p(d,u)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){f(this._passParameters.clipBox,e||P)}get _clippingEnabled(){return!x(this._passParameters.clipBox,P,(e,s)=>e===s)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let t=null;return this._nodes.filterInPlace(i=>i.id!==e||(t=i,i.vao=s(i.vao),this._highlights.nodeRemoved(i),!1)),this._requestRender(),t}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll(e=>e.vao=s(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,s){return this._highlights.add(e,s)}_addHighlight(e,s,t){e.addHighlight(s,t),this._requestRender()}_removeHighlight(e,s){e.removeHighlight(s),this._requestRender()}_initNode(e,s){s.vao??=new q(e.rctx,new Map([["positions",new L(e.rctx,H,s.coordinates)],["colors",new L(e.rctx,M,s.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}};function O(e,s,t,i,r){if(t.drawScreenSpace)return t.fixedSize*s*i;const n=F(r)*s*i;return t.useFixedSizes?Math.min(t.fixedSize/2,n):t.screenMinSize>0?Math.min(Math.max(t.screenMinSize*s*i,e/2),n):Math.min(e/2,n)}function V(e,s,t,i,r){return t.drawScreenSpace?0:O(e,s,t,i,r)}function T(e,s,t){return null==t&&(t=d()),t[0]=e.origin[0]+e.coordinates[3*s],t[1]=e.origin[1]+e.coordinates[3*s+1],t[2]=e.origin[2]+e.coordinates[3*s+2],t}e([i({constructOnly:!0})],B.prototype,"createGraphic",void 0),B=e([r("esri.views.3d.layers.i3s.PointCloudRenderer")],B);class C{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function k(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}export{B as PointCloudRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../../../Graphic.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import i from"../../../../geometry/Polygon.js";import{toExtent as s}from"../../../../geometry/support/aaBoundingRect.js";import l from"../../../../symbols/SimpleFillSymbol.js";import{TileTreeDebugger as p}from"../../../support/TileTreeDebugger.js";let a=class extends p{get _flowSubView(){const{layerView:e}=this;return"imagery-3d"===e.type?e.test.subView:e.test.flowSubView}constructor(e){super(e),this._fullExtentGraphic=null}clear(){super.clear(),this._fullExtentGraphic&&(this.view.graphics.remove(this._fullExtentGraphic),this._fullExtentGraphic=null)}update(){super.update();const e=this._flowSubView.layer.fullExtent;this._fullExtentGraphic=new r({geometry:e,symbol:new l({color:[0,0,0,0],outline:{color:"black",width:3}})}),this.view.graphics.add(this._fullExtentGraphic)}getTiles(){const e=null!=this.view.basemapTerrain.spatialReference?this.view.basemapTerrain.spatialReference:null,r=this._flowSubView.test.renderedTiles;return this.view.basemapTerrain.test.getRenderedTiles().map(t=>{const o=r?.has(t)?[0,255,0,.3]:[255,0,0,.3],p=new l({color:o,outline:{color:"black",width:1}});return{...t,lij:t.lij,level:t.level,geometry:i.fromExtent(s(t.extent,e)),label:t.lij.toString(),polygonSymbol:p}})}};e([t()],a.prototype,"layerView",void 0),a=e([o("esri.views.3d.layers.support.FlowTileTree3DDebugger")],a);export{a as FlowTileTree3DDebugger};
5
+ import{__decorate as e}from"tslib";import r from"../../../../Graphic.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import i from"../../../../geometry/Polygon.js";import{toExtent as s}from"../../../../geometry/support/aaBoundingRect.js";import l from"../../../../symbols/SimpleFillSymbol.js";import{TileTreeDebugger as a}from"../../../support/TileTreeDebugger.js";let p=class extends a{get _flowSubView(){const{layerView:e}=this;return"imagery-3d"===e.type?e.test.subView:e.test.flowSubView}constructor(e,r=!0){super(e),this._fullExtentGraphic=null,this.enableLabels=r}clear(){super.clear(),this._fullExtentGraphic&&(this.view.graphics.remove(this._fullExtentGraphic),this._fullExtentGraphic=null)}update(){super.update();const e=this._flowSubView.layer.fullExtent;this._fullExtentGraphic=new r({geometry:e,symbol:new l({color:[0,0,0,0],outline:{color:"black",width:3}})}),this.view.graphics.add(this._fullExtentGraphic)}getTiles(){const e=null!=this.view.basemapTerrain.spatialReference?this.view.basemapTerrain.spatialReference:null,r=this._flowSubView.test.renderedTiles;return this.view.basemapTerrain.test.getRenderedTiles().map(t=>{const o=r?.has(t)?[0,255,0,.3]:[255,0,0,.3],a=new l({color:o,outline:{color:"black",width:1}});return{...t,lij:t.lij,level:t.level,geometry:i.fromExtent(s(t.extent,e)),label:t.lij.toString(),polygonSymbol:a}})}};e([t()],p.prototype,"layerView",void 0),p=e([o("esri.views.3d.layers.support.FlowTileTree3DDebugger")],p);export{p as FlowTileTree3DDebugger};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n}from"../../../geometry/support/aaBoundingBox.js";class e{constructor(t){this.newSortOrder=t}}let a=t(),r=t();const o=n();let s=null,l=null;const i=10,h=20,c=.25;function f(t){let n=!1;for(let e=0;e<t.length;e+=3){const a=t[e],r=t[e+1],s=t[e+2];n?(o[0]=Math.min(o[0],a),o[3]=Math.max(o[3],a),o[1]=Math.min(o[1],r),o[4]=Math.max(o[4],r),o[2]=Math.min(o[2],s),o[5]=Math.max(o[5],s)):(o[0]=o[3]=a,o[1]=o[4]=r,o[2]=o[5]=s,n=!0)}n||(o[0]=o[3]=0,o[1]=o[4]=0,o[2]=o[5]=0)}function m(t,n){s?.length!==t&&(s=new Uint32Array(t)),l&&l.length===1+(1<<n)?l.fill(0):l=new Uint32Array(1+(1<<n))}function u(t,n,e){const a=e[0],r=e[1],f=e[2],u=t.length/3,M=Math.max(i,Math.min(h,Math.round(Math.log2(u/c)))),g=1+(1<<M);m(u,M);let b=0,x=0;for(let s=0;s<8;++s){const t=(1&s?o[0]:o[3])*a+(2&s?o[1]:o[4])*r+(4&s?o[2]:o[5])*f;0===s?b=x=t:(b=Math.min(b,t),x=Math.max(x,t))}const w=x-b;if(w<1e-6)for(let o=0;o<u;++o)s[o]=0,l[0]++;else{const n=(1<<M)/w;for(let e=0,o=0;e<u;++e){const i=(t[o++]*a+t[o++]*r+t[o++]*f-b)*n>>>0;s[e]=i,l[i]++}}for(let o=1;o<g;o++)l[o]+=l[o-1];for(let o=0;o<u;o++){const t=s[o];n[--l[t]]=o}}async function M(t){const{cameraPosition:n,cameraDirection:o,gaussianCenters:s,sortOrder:l}=t;if(0===s.length||0===l.length||l.length!==s.length/3)return{result:new e(l)};const i=.001;return Math.abs(n[0]-a[0])>i||Math.abs(n[1]-a[1])>i||Math.abs(n[2]-a[2])>i||Math.abs(o[0]-r[0])>i||Math.abs(o[1]-r[1])>i||Math.abs(o[2]-r[2])>i?(a=n,r=n,f(s),u(s,l,o),{result:new e(l),transferList:[l.buffer]}):{result:new e(l),transferList:[l.buffer]}}export{e as SplatSortWorkerOutput,M as sortCentersRelativeToCamera};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{WorkerHandle as e}from"../../../core/workers/WorkerHandle.js";class r extends e{constructor(e){super("GaussianSplatSortWorker","sortCentersRelativeToCamera",{sortCentersRelativeToCamera:e=>[e.gaussianCenters.buffer,e.sortOrder.buffer]},e)}sortCentersRelativeToCamera(e,r){return this.invokeMethod("sortCentersRelativeToCamera",e,r)}}export{r as GaussianSplatSortWorkerHandle};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromExtent as s,clone as i}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as a}from"../../../2d/engine/flow/dataUtils.js";import r from"../../layers/FlowSubView3D.js";import{FlowDataTile as l}from"./loadUtils.js";import{isRasterTile as o}from"../../terrain/TerrainData.js";let n=class extends r{constructor(e){super(e),this._flowDataTiles=d(),this._resetTileData=!0}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{const{renderedTiles:i}=this;null!=i&&t===this._layerIndex&&1===s&&this._updateFlowDataTile(e)})]),this.updatingHandles.add(()=>this.renderedTiles,e=>{const t=d();e?.forEach(e=>{const s=this._flowDataTiles.get(h(e))??this._getFlowDataCopy(e);null!=s&&t.set(h(e),s)}),this._flowDataTiles=t,this._resetTileData=!0,this.triggerLoad()})}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}async fetchDataAndGenerateStreamlines(e,t){const{simulationSettings:i,_flowDataTiles:a,workerHandle:r}=this,{size:l}=e;if(null==i||null==r)return;const o=s(e.extent),n=this._resetTileData;this._resetTileData=!1;const h=d();a.forEach((e,t)=>{"delete"===e?(h.set(t,"delete"),a.delete(t)):(n||"on-worker"!==e)&&(h.set(t,e),a.set(t,"on-worker"))});const c={simulationSettings:i,size:l,flowDataTiles:h,reset:n,extent:o,pixelSize:this.surface.tilingScheme.pixelSize},{streamlines:u}=await r.generateTiledStreamlines(c,t);return u}_getFlowDataCopy(e){const{_layerIndex:t}=this;if(null==t)return null;const s=e.getLayerInfo(t,1);if(s.dataMissing||!e.hasLayerData(t,1))return null;const{data:r}=s;if(!o(r))return null;const n=a(this.layer.serviceRasterInfo.dataType,r.source),d=new Uint8Array(n.width*n.height);for(let i=0;i<d.length;i++)d[i]=n.mask[i];return new l(n.data,d,n.width,n.height,e.lij,i(e.extent))}async _updateFlowDataTile(e){if(this.renderedTiles?.has(e)){const t=this._getFlowDataCopy(e)??"delete";this._setTileData(e,t)}else this._setTileData(e,"delete");await this.triggerLoad()}_setTileData(e,t){this._flowDataTiles.set(h(e),t)}};function d(){return new Map}function h(e){return e.lij.join("-")}n=e([t("esri.views.3d.support.flow.FlowSubViewTiles3D")],n);export{n as default};
5
+ import{__decorate as e}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromExtent as s,clone as a}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as i}from"../../../2d/engine/flow/dataUtils.js";import r from"../../layers/FlowSubView3D.js";import{tileToKey as l,FlowDataTile as o}from"./loadUtils.js";import{isRasterTile as n}from"../../terrain/TerrainData.js";let d=class extends r{constructor(e){super(e),this._flowDataTiles=h(),this._resetTileData=!0}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{const{renderedTiles:a}=this;null!=a&&t===this._layerIndex&&1===s&&this._updateFlowDataTile(e)})]),this.updatingHandles.add(()=>this.renderedTiles,e=>{const t=h();e?.forEach(e=>{const s=this._flowDataTiles.get(l(e))??this._getFlowDataCopy(e);null!=s&&t.set(l(e),s)}),this._flowDataTiles=t,this._resetTileData=!0,this.triggerLoad()})}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}async fetchDataAndGenerateStreamlines(e,t){const{simulationSettings:a,_flowDataTiles:i,workerHandle:r}=this,{size:l}=e;if(null==a||null==r)return;const o=s(e.extent),n=this._resetTileData;this._resetTileData=!1;const d=h();i.forEach((e,t)=>{"delete"===e?(d.set(t,"delete"),i.delete(t)):(n||"on-worker"!==e)&&(d.set(t,e),i.set(t,"on-worker"))});const c={simulationSettings:a,size:l,flowDataTiles:d,reset:n,extent:o,pixelSize:this.surface.tilingScheme.pixelSize},{streamlines:u}=await r.generateTiledStreamlines(c,t);return u}_getFlowDataCopy(e){const{_layerIndex:t}=this;if(null==t)return null;const s=e.getLayerInfo(t,1);if(s.dataMissing||!e.hasLayerData(t,1))return null;const{data:r}=s;if(!n(r))return null;const l=i(this.layer.serviceRasterInfo.dataType,r.source),d=new Uint8Array(l.width*l.height);for(let a=0;a<d.length;a++)d[a]=l.mask[a];return new o(l.data,d,l.width,l.height,e.lij,a(e.extent))}async _updateFlowDataTile(e){if(this.renderedTiles?.has(e)){const t=this._getFlowDataCopy(e)??"delete";this._setTileData(e,t)}else this._setTileData(e,"delete");await this.triggerLoad()}_setTileData(e,t){this._flowDataTiles.set(l(e),t)}};function h(){return new Map}d=e([t("esri.views.3d.support.flow.FlowSubViewTiles3D")],d);export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../Color.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as r,createGeometry as i}from"../engineContent/line.js";function l(t,l,s,c,h,m){const{spatialReference:p}=t,g=[];for(let e=0;e<s.length;e+=3){const r=[s[e],s[e+1]],[i,a]=f(r,l),{absoluteZ:h}=n(i,a,0,p,t,c),m=o(i,a,h);t.renderCoordsHelper.toRenderCoords(m,p,m),g.push(m)}const u=Math.floor(s.length/3),d=e(u);for(let o=0;o<u;o++)d[o]=s[3*o+2];a(d,Math.floor(m.getIntRange(0,d.length)));const j=r([g],void 0,[d]);return i(h,j[0])}function s(o,e,n){if(null==o)return{};const r=t.toUnitRGBA(o.color);return r[3]*=e,{color:r,width:o.trailWidth,cap:2,animationSpeed:o.flowSpeed,trailLength:o.trailLength,animation:3,emissiveStrength:n}}function f([t,o],e){const{extent:n,size:[r,i]}=e;return[t/r*n.width+n.xmin,(i-o)/i*n.height+n.ymin]}function a(t,o){if(0===t.length||o<0||o>=t.length)return;const e=t[o];for(let n=0;n<t.length;n++)t[n]-=e}export{l as createStreamlineGeometry,s as materialParametersFromRenderer};
5
+ import t from"../../../../Color.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as r,createGeometry as i}from"../engineContent/line.js";function l(t,l,s,c,h,m){const{spatialReference:p}=l.extent,g=[];for(let e=0;e<s.length;e+=3){const r=[s[e],s[e+1]],[i,a]=f(r,l),{absoluteZ:h}=n(i,a,0,p,t,c),m=o(i,a,h);t.renderCoordsHelper.toRenderCoords(m,p,m),g.push(m)}const u=Math.floor(s.length/3),d=e(u);for(let o=0;o<u;o++)d[o]=s[3*o+2];a(d,Math.floor(m.getIntRange(0,d.length)));const j=r([g],void 0,[d]);return i(h,j[0])}function s(o,e,n){if(null==o)return{};const r=t.toUnitRGBA(o.color);return r[3]*=e,{color:r,width:o.trailWidth,cap:2,animationSpeed:o.flowSpeed,trailLength:o.trailLength,animation:3,emissiveStrength:n}}function f([t,o],e){const{extent:n,size:[r,i]}=e;return[t/r*n.width+n.xmin,(i-o)/i*n.height+n.ymin]}function a(t,o){if(0===t.length||o<0||o>=t.length)return;const e=t[o];for(let n=0;n<t.length;n++)t[n]-=e}export{l as createStreamlineGeometry,s as materialParametersFromRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{width as t,height as n,containsXY as l,intersects as u,create as o}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as r}from"../../../2d/engine/flow/dataUtils.js";class e{constructor(t,n,l,u,o,r){this.data=t,this.mask=n,this.width=l,this.height=u,this.lij=o,this.extent=r}}function i(t,n){let[l,r,e,i]=[null,null,null,null];for(const o of t){const t=o.extent;u(t,n)&&(l=c(t[0],l),r=c(t[1],r),e=s(t[2],e),i=s(t[3],i))}return null==l||null==r||null==e||null==i?null:o([l,r,e,i])}function s(t,n){return null==n?t:Math.max(t,n)}function c(t,n){return null==n?t:Math.min(t,n)}function a(u,o,e,i,s){const[c,a]=e;let f=null;const h=new Map;o.forEach(t=>{h.set(t.lij,r(u,t))});const d=(t,n,u)=>l(t.extent,n,u);return(l,u)=>{const r=Math.round(l),e=Math.round(u);if(r<0||r>=c||e<0||e>=a)return[0,0];const m=l/c*t(i)+i[0],p=(a-u)/a*n(i)+i[1];if(null==f||!d(f,m,p)){f=null;for(const[t,n]of o)if(d(n,m,p)){f=n;break}}if(null==f?.data)return[0,0];const x=h.get(f.lij);if(null==x)return[0,0];const g=f.extent;return x((m-g[0])/t(g)*s,s-(p-g[1])/n(g)*s)}}export{e as FlowDataTile,i as boundingRectOfTiles,a as createFlowFieldFromDataTiled};
5
+ import{width as t,height as n,containsXY as l,create as r}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as o}from"../../../2d/engine/flow/dataUtils.js";import{getFeatureTileId as u}from"../../layers/support/FeatureTileDescriptor.js";class e{constructor(t,n,l,r,o,u){this.data=t,this.mask=n,this.width=l,this.height=r,this.lij=o,this.extent=u}}function i(t){return u(t.lij[0],t.lij[1],t.lij[2])}function s(t){let[n,l,o,u]=[null,null,null,null];for(const r of t){const t=r.extent;n=a(t[0],n),l=a(t[1],l),o=c(t[2],o),u=c(t[3],u)}return null==n||null==l||null==o||null==u?null:r([n,l,o,u])}function c(t,n){return null==n?t:Math.max(t,n)}function a(t,n){return null==n?t:Math.min(t,n)}function f(r,u,e,i,s){const[c,a]=e;let f=null;const h=new Map;u.forEach(t=>{h.set(t.lij,o(r,t))});const m=(t,n,r)=>l(t.extent,n,r);return(l,r)=>{const o=Math.round(l),e=Math.round(r);if(o<0||o>=c||e<0||e>=a)return[0,0];const p=l/c*t(i)+i[0],j=(a-r)/a*n(i)+i[1];if(null==f||!m(f,p,j)){f=null;for(const[t,n]of u)if(m(n,p,j)){f=n;break}}if(null==f?.data)return[0,0];const d=h.get(f.lij);if(null==d)return[0,0];const x=f.extent;return d((p-x[0])/t(x)*s,s-(j-x[1])/n(x)*s)}}export{e as FlowDataTile,s as boundingRectOfTiles,f as createFlowFieldFromDataTiled,i as tileToKey};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as n,d as t,f as i,g as e,j as c,c as o,n as u}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as l,signedDistance as s}from"../../../geometry/support/plane.js";function p(r,n,t){return r[0]*n[0]+r[1]*n[1]+r[2]*n[2]+r[3]<t}function a(r,n,t){const i=n[0],e=n[1],c=n[2];return!(r[0][0]*i+r[0][1]*e+r[0][2]*c+r[0][3]>t)&&(!(r[1][0]*i+r[1][1]*e+r[1][2]*c+r[1][3]>t)&&(!(r[2][0]*i+r[2][1]*e+r[2][2]*c+r[2][3]>t)&&(!(r[3][0]*i+r[3][1]*e+r[3][2]*c+r[3][3]>t)&&(!(r[4][0]*i+r[4][1]*e+r[4][2]*c+r[4][3]>t)&&!(r[5][0]*i+r[5][1]*e+r[5][2]*c+r[5][3]>t)))))}function m(r,n,t,i){return h(r,n,null,v(i,n,t,!1))}function d(r,n){for(let t=0;t<6;t++){if(s(r[t],n)>0)return!1}return!0}function g(r,n,t,i){return h(r,n,t,v(i,n,t,!0))}function j(r,c,o,u){const f=n(o,t(r,u,c));return i(r,c,e(r,o,f))}const b={dir:f(),len:0,clip:r()};function v(r,n,i,f){const l=b;return r?(i&&f&&(l.len=c(n,i)),o(l.dir,r)):f?(l.len=c(n,i),t(l.dir,i,n),e(l.dir,l.dir,1/l.len)):(t(l.dir,i,n),u(l.dir,l.dir)),l}function x(r,t,i){const e=n(l(r),i.dir),c=-s(r,t);if(c<0&&e>=0)return!1;if(e>-1e-6&&e<1e-6)return c>0;if((c<0||e<0)&&!(c<0&&e<0))return!0;const o=c/e;return e>0?o<i.clip[1]&&(i.clip[1]=o):o>i.clip[0]&&(i.clip[0]=o),i.clip[0]<=i.clip[1]}function h(r,n,t,i){i.clip[0]=0,i.clip[1]=t?i.len:Number.MAX_VALUE;for(let e=0;e<r.length;e++)if(!x(r[e],n,i))return!1;return!0}export{j as closestPointOnRay,g as frustumLineSegment,d as frustumPoint,m as frustumRay,a as frustumSphere,p as planeSphere};
5
+ import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as n,c as t,d as i,g as e,e as c,f as o,n as u}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getNormal as l,signedDistance as s}from"../../../geometry/support/plane.js";function p(r,n,t){return r[0]*n[0]+r[1]*n[1]+r[2]*n[2]+r[3]<t}function a(r,n,t){const i=n[0],e=n[1],c=n[2];return!(r[0][0]*i+r[0][1]*e+r[0][2]*c+r[0][3]>t)&&(!(r[1][0]*i+r[1][1]*e+r[1][2]*c+r[1][3]>t)&&(!(r[2][0]*i+r[2][1]*e+r[2][2]*c+r[2][3]>t)&&(!(r[3][0]*i+r[3][1]*e+r[3][2]*c+r[3][3]>t)&&(!(r[4][0]*i+r[4][1]*e+r[4][2]*c+r[4][3]>t)&&!(r[5][0]*i+r[5][1]*e+r[5][2]*c+r[5][3]>t)))))}function m(r,n,t,i){return h(r,n,null,v(i,n,t,!1))}function d(r,n){for(let t=0;t<6;t++){if(s(r[t],n)>0)return!1}return!0}function g(r,n,t,i){return h(r,n,t,v(i,n,t,!0))}function j(r,n,t,u){const f=c(t,i(r,u,n));return o(r,n,e(r,t,f))}const b={dir:f(),len:0,clip:r()};function v(r,c,o,f){const l=b;return r?(o&&f&&(l.len=n(c,o)),t(l.dir,r)):f?(l.len=n(c,o),i(l.dir,o,c),e(l.dir,l.dir,1/l.len)):(i(l.dir,o,c),u(l.dir,l.dir)),l}function x(r,n,t){const i=c(l(r),t.dir),e=-s(r,n);if(e<0&&i>=0)return!1;if(i>-1e-6&&i<1e-6)return e>0;if((e<0||i<0)&&!(e<0&&i<0))return!0;const o=e/i;return i>0?o<t.clip[1]&&(t.clip[1]=o):o>t.clip[0]&&(t.clip[0]=o),t.clip[0]<=t.clip[1]}function h(r,n,t,i){i.clip[0]=0,i.clip[1]=t?i.len:Number.MAX_VALUE;for(let e=0;e<r.length;e++)if(!x(r[e],n,i))return!1;return!0}export{j as closestPointOnRay,g as frustumLineSegment,d as frustumPoint,m as frustumRay,a as frustumSphere,p as planeSphere};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r}from"./ElevationData.js";import{PatchGeometryLUT as i}from"./PatchGeometryLUT.js";import{zeroToFour as a,neighborTileIfLoadedOrSelf as c}from"./PatchRenderData.js";import{internalAssert as l,enableTerrainInternalChecks as u,neighborEdgeIndices as d,almostEquals as f}from"./terrainUtils.js";import{isCornerNeighbor as m}from"./Tile.js";import{compareTilesByLij as g}from"./tileUtils.js";import{compressNormal as h}from"../webgl-engine/lib/Normals.js";const p=65536;function x(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*mt*u,x=ut(r),S=m+p+4*x,v=l.tileGeometryCache.acquire(S);s.numVerticesPerSide=u,s.vertexAttributes=v,s.maxEdgeVertexCount=x;const{boundingBox:V}=s;o(V);const b=P(t);ot.update(f,i,b),y(t),s.poleVerticesStartIndex=m;const B=M(t,g,h);s.edgeVerticesStartIndex=m+p,Q(t),I(t),W(s,B,d),t.intersectionData=null}function M(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],p=r[1],x=r[2],M=c.radius,y=a[1],S=a[3],v=[];let V=f;const I=(t,e)=>{const o=e*u;lt(-g,-p,t*M-x,l),v.push(new et(1===t,o,1===t?0:2,V,mt));const s=C(-1===t?y:S,M),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=M+0,{position:c,uv0:f}=d,{typedBuffer:I,typedBufferStride:b}=d.normalCompressed;for(let u=1;u<=mt;++u){const t=s+r*(u/mt),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ot.sinLonLUT[s],u=ot.cosLonLUT[s]*e,d=r*e,M=o,y=u*a-g,S=d*a-p,v=M*a-x;lt(y,S,v,l),c.setValues(V,y,S,v),f.setValues(V,Math.round(t*n),Math.round(i*n)),h(I,V,u,d,M,b),++V}}};return e&&I(-1,0),o&&I(1,m),v}function y(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:p,typedBufferStride:x}=d.normalCompressed,{extent:M}=e,y=M[0],S=M[2],v=M[1],V=M[3],I=e.ellipsoid.radius,b=i[0],B=i[1],C=i[2],L=m.typedBuffer,A=m.typedBufferStride,P=1/u;let D=0;if(1<=l){const t=P,e=v*(1-t)+V*t,o=ot.sinLatLUT[1],s=ot.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*P,l=y*(1-a)+S*a,u=ot.sinLonLUT[i],d=ot.cosLonLUT[i],m=I+r(l,e,c),h=m*d*s-b,p=m*u*s-B,x=m*o-C;lt(h,p,x,f);const M=(i-1)*A;L[M]=h,L[M+1]=p,L[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let E=1;E<=l;E++){const t=E*P,e=v*(1-t)+V*t,o=ot.sinLatLUT[E],s=ot.cosLatLUT[E],i=E+1,a=i*P,d=v*(1-a)+V*a,m=ot.sinLatLUT[i],M=ot.cosLatLUT[i],T=ot.sinLonLUT[0],O=ot.cosLonLUT[0],R=I+r(y,e,c);let U=O*s*R-b,w=T*s*R-B,N=o*R-C;const j=D*A;let F=L[j],q=L[j+1],W=L[j+2];for(let V=1;V<=l;V++){const t=V*P,i=y*(1-t)+S*t,T=ot.sinLonLUT[V],O=ot.cosLonLUT[V];let R=0,j=0,k=0;if(V<l){const t=(D+1)*A;R=L[t],j=L[t+1],k=L[t+2]}else{const t=ot.sinLonLUT[u],n=ot.cosLonLUT[u],i=I+r(S,e,c);R=n*s*i-b,j=t*s*i-B,k=o*i-C}const z=U,G=w,H=N;U=F,w=q,N=W,F=R,q=j,W=k;const J=R-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(E>1){const t=(D-l)*A;X=L[t],Y=L[t+1],Z=L[t+2]}else{const t=ot.sinLatLUT[0],e=ot.cosLatLUT[0],n=I+r(i,v,c);X=O*e*n-b,Y=T*e*n-B,Z=t*n-C}const $=I+r(i,d,c),_=O*M*$-b,tt=T*M*$-B,et=m*$-C;if(E<l){const e=D+l,o=e*A;L[o]=_,L[o+1]=tt,L[o+2]=et,lt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,st=Y-tt,rt=Z-et;let it=O*s,at=T*s,ct=o;ct*ct<.999&&(it=Q*st-K*rt,at=J*rt-Q*nt,ct=K*nt-J*st);const ut=1/Math.sqrt(it*it+at*at+ct*ct);h(p,D,it*ut,at*ut,ct*ut,x),++D}}}function S(t){t.tile.intersectsClippingArea&&(I(t),_(t),t.intersectionData=null)}function v(t){t.tile.intersectsClippingArea&&(X(t),I(t),_(t),tt(t),t.intersectionData=null)}function V(t){t.tile.intersectsClippingArea&&(B(t),b(t,!0),_(t),t.intersectionData=null)}function I(t){t.tile.intersectsClippingArea&&(B(t),b(t))}function b(t,o=!1){const{geometry:s,geometryState:i,tile:a,localOrigin:m}=t,{level:h,extent:p,extentInRadians:x,ellipsoid:M}=a,y=M.radius,S=x[0],v=x[2],V=x[1],I=x[3],{samplerData:b}=i,B=p[0],C=p[2],L=p[1],A=p[3],D=P(t),{boundingBox:E,vertexAttributes:T}=s,O=m[0],R=m[1],U=m[2],{position:w,uv0:N}=T,j=w.typedBuffer,F=w.typedBufferStride;for(let P=0;P<4;++P){const m=1===P||3===P,x=i.edgeResolutions[P];l(e(x));const M=x+1,T=c(a,i.edgePeerNeighbors[P]);if(it(a,T,P)){Y(t,P,T);continue}const w=null!=T;l(!w||T.level===a.level),l(!w||g(a,T)<=0);const q=T?.renderData,W=q?.geometryState;if(u){const t=a.surface;if(!T&&t&&!t.updatingRootTiles){const e=d[P],n=a.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===a.level);n?n.intersectsClippingArea&&(l(!n.loaded),l(!n.leaf),l(n.level===h)):l(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const k=1===P?p[2]:p[0],z=T?.extent,G=z&&m?1===P?z[0]:z[2]:k,H=0===P?p[3]:p[1],J=1===P?1:0,K=0===P?1:0,Q=1===P?v:S,X=0===P?I:V,Z=Math.sin(Q),$=Math.cos(Q),_=Math.sin(X),tt=Math.cos(X),et=W?.samplerData,nt=w?(t,e,n)=>.5*(r(t,e,b)+r(n,e,et)):(t,e,n)=>r(t,e,b),ot=s.outerEdgesOffsetAndLength[2*P+0],st=o&&M>3?M-3:1,rt=null!=b&&b.some(t=>null!=t),at=null!=et&&et.some(t=>null!=t),ct=rt||at,ut=1/x,dt=ot;l(!z||f(z[2]-z[0],p[2]-p[0]));(()=>{const t=1===P?-1:3===P?1:0,e=0===P?-1:2===P?1:0,o=(p[2]-p[0])*ut,i=t*o,a=e*o,c=m?t*((v-S)*ut):0,l=m?0:e*ut,u=K,d=m?Q+c:Q,f=m?Math.sin(d):Z,g=m?Math.cos(d):$,h=m?Q-c:Q,x=m?Math.sin(h):Z,V=m?Math.cos(h):$,I=m?X:D(u+l),T=m?_:Math.sin(I),q=m?tt:Math.cos(I),W=m?X:D(u-l),z=m?_:Math.sin(W),Y=m?tt:Math.cos(W);let ot=0,rt=0,it=0;{const t=0*ut,e=m?k:B*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);ot=i*l*u,rt=r*l*u,it=c*u}let at=0,ft=0,mt=0;{const t=1*ut,e=m?k:B*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);at=i*l*u,ft=r*l*u,mt=c*u}for(let p=1;p<M-1;p+=st){let t=0,e=0,o=0;{const n=(p+1)*ut,s=m?k:B*(1-n)+C*n,r=m?G:s,i=m?L*(1-n)+A*n:H,a=m?Q:S*(1-n)+v*n,c=m?Z:Math.sin(a),l=m?$:Math.cos(a),u=m?D(n):X,d=m?Math.sin(u):_,f=m?Math.cos(u):tt,g=y+nt(s,i,r);t=l*f*g,e=c*f*g,o=d*g}const c=t,l=e,u=o,d=at,h=ft,M=mt;at=c,ft=l,mt=u;{const t=dt+p,e=t*F,o=d-O,s=h-R,r=M-U;j[e]=o,j[e+1]=s,j[e+2]=r,lt(o,s,r,E);const i=p*ut,a=m?J:i,c=m?i:K;N.setValues(t,Math.round(a*n),Math.round(c*n))}const I=ot,W=rt,st=it;ot=d,rt=h,it=M;const gt=d,ht=h,pt=M,xt=1/Math.sqrt(gt*gt+ht*ht+pt*pt),Mt=pt*xt;let yt=0,St=0,vt=0;if(ct&&Mt*Mt<.999){let t=0,e=0,n=0;{const o=0===P?-1:1;t=o*(c-I),e=o*(l-W),n=o*(u-st)}{const o=p*ut,s=m?k:B*(1-o)+C*o,c=m?G:s,l=m?L*(1-o)+A*o:H,u=m?Q:S*(1-o)+v*o,d=m?Z:Math.sin(u),h=m?$:Math.cos(u),M=m?D(o):X,I=m?Math.sin(M):_,E=m?Math.cos(M):tt;let O=gt,R=ht,U=pt;if(w){const t=y+r(c-i,l-a,et),e=m?E:Y;O=(m?V:h)*e*t,R=(m?x:d)*e*t,U=(m?I:z)*t}{const o=y+r(s+i,l+a,b),c=m?E:q,u=(m?g:h)*c*o,p=(m?f:d)*c*o,x=(m?I:T)*o;w||(O=2*gt-u,R=2*ht-p,U=2*pt-x);const M=3===P?-1:1,S=M*(O-u),v=M*(R-p),V=M*(U-x);yt=n*v-e*V,St=t*V-n*S,vt=e*S-t*v;const B=1/Math.sqrt(yt*yt+St*St+vt*vt);yt*=B,St*=B,vt*=B}}}else yt=gt*xt,St=ht*xt,vt=pt*xt;s.setEdgeNormalFromValues(P,p,yt,St,vt)}})()}}function B(t){Z(t)}function C(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function L(t,e,n,o){return C(t*(1-o)+e*o,n)}function A(t,e,n){return t*(1-n)+e*n}function P(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>L(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>A(n[1],n[3],t)}function D(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=ut(s),v=y+4*S,V=a.renderer.tileGeometryCache.acquire(v),{boundingBox:I}=r;o(I),r.numVerticesPerSide=m,r.vertexAttributes=V,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,E(t),r.edgeVerticesStartIndex=y,Q(t),U(t),W(r,[],c),t.intersectionData=null}function E(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:i,localOrigin:a}=e,{samplerData:c,clippingArea:l,numVerticesPerSide:u}=i,{surface:d,extent:f,ellipsoid:m}=o,{isWebMercatorOnPlateCarree:g}=d,p=null!=l?l:st,x=f[0],M=f[1],y=f[2],S=f[3],v=Math.max(x,p[0]),V=Math.min(y,p[2]),I=Math.max(M,p[1]),b=Math.min(S,p[3]),B=m.radius,C=o.horizontalScale,L=u-1,A=u-2,{minu:P,minv:D,maxu:E,maxv:T,boundingBox:O,vertexAttributes:R}=s,{position:U,uv0:w}=R,{typedBuffer:N,typedBufferStride:j}=R.normalCompressed,F=a[0],q=a[1],W=a[2],k=U.typedBuffer,z=U.typedBufferStride;let G=0;const H=t(M,I,b),J=g?(Math.PI/2-2*Math.atan(Math.exp(-H/B)))*B:H*C,K=1/L,Q=t(M*(1-K)+S*K,I,b);let X=J,Y=g?(Math.PI/2-2*Math.atan(Math.exp(-Q/B)))*B:Q*C;for(let Z=1;Z<=A;Z++){const e=Z/L,o=t(M*(1-e)+S*e,I,b),s=t(e,D,T),i=Y,a=(Z-1)/L,l=t(M*(1-a)+S*a,I,b),u=X,d=(Z+1)/L,f=t(M*(1-d)+S*d,I,b),m=g?(Math.PI/2-2*Math.atan(Math.exp(-f/B)))*B:f*C,p=t(d,D,T);X=Y,Y=m;const R=t(x,v,V);let U=R*C,H=r(R,o,c);const J=1/L,K=t(J,P,E),Q=t(x*(1-K)+y*K,v,V);let $=K,_=Q,tt=Q*C,et=r(Q,o,c);if(1===Z){const e=tt-F,o=X-q,r=et-W,i=0*z;k[i]=e,k[i+1]=o,k[i+2]=r,lt(e,o,r,O);const a=t(J,P,E);w.setValues(G,Math.round(a*n),Math.round(s*n))}for(let g=1;g<=A;g++){const e=tt,a=et,d=(g+1)/L,M=t(d,P,E),S=t(x*(1-d)+y*d,v,V),I=_;_=S;{const t=G+1,e=t*z;if(1===Z||g===A){const a=S*C,l=r(S,o,c);if(1===Z&&g<A){const o=a-F,r=i-q,c=l-W;k[e]=o,k[e+1]=r,k[e+2]=c,lt(o,r,c,O),w.setValues(t,Math.round(M*n),Math.round(s*n))}tt=a,et=l}else tt=k[e]+F,et=k[e+2]+W}const b=tt,B=et,D=U,T=H;U=e,H=a;const R=(G-A)*z,J=1===Z?r(I,l,c):k[R+2]+W,K=r(I,f,c);if(Z<A){const t=G+A,o=t*z,s=e-F,r=m-q,i=K-W;k[o]=s,k[o+1]=r,k[o+2]=i,lt(s,r,i,O);const a=$;$=M,w.setValues(t,Math.round(a*n),Math.round(p*n))}{const t=b-D,e=u-m,n=e*(B-T),o=t*(J-K),s=-e*t,r=n*n+o*o+s*s;if(0===r)h(N,G,0,0,1,j);else{const t=1/Math.sqrt(r);h(N,G,n*t,o*t,s*t,j)}}++G}}}function T(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!0),_(t),t.intersectionData=null)}function O(t,e){t.tile.intersectsClippingArea&&(X(t),U(t),_(t),tt(t),t.intersectionData=null)}function R(t,e){t.tile.intersectsClippingArea&&(U(t),_(t),t.intersectionData=null)}function U(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!1))}function w(n,o){const{geometry:s,geometryState:i,localOrigin:a}=n,f=n.tile,{surface:m,extent:h}=f,{clippingArea:p,samplerData:x}=i,M=null!=p?p:st,y=h[0],S=h[2],v=h[1],V=h[3],I=[V>M[3],S>M[2],v<M[1],y<M[0]],b=f.horizontalScale,B=q(m.isWebMercatorOnPlateCarree,f.ellipsoid.radius,b),{minu:C,minv:L,maxu:A,maxv:P,boundingBox:D}=s,E=Math.max(y,M[0]),T=Math.min(S,M[2]),O=Math.max(v,M[1]),R=Math.min(V,M[3]),U=a[0],w=a[1],N=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,h=i.edgeResolutions[j];l(e(h));const p=h+1,M=I[j],F=c(f,i.edgePeerNeighbors[j]);if(!M&&it(f,F,j)){Y(n,j,F);continue}const q=null!=F&&!M,W=F?.renderData,k=W?.geometryState;if(u&&(l(!q||F.level===f.level),l(!q||g(f,F)<=0),f&&!F&&!m.updatingRootTiles)){const t=d[j],e=f.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===f.level);m.updatingRootTiles||(e?e.intersectsClippingArea&&(l(!e.loaded),l(!e.leaf),l(e.level===f.level)):l(null==m?.rootTiles||!f.shouldHaveNeighbor(t)))}const z=t(1===j?S:y,E,T),G=t(0===j?V:v,O,R),H=k?.samplerData,J=o&&p>3?p-3:1,K=t(1===j?1:0,C,A),Q=t(0===j?1:0,L,P),X=q?(t,e)=>.5*(r(t,e,H)+r(t,e,x)):(t,e)=>r(t,e,x),Z=(S-y)/h,$=a?1===j?Z:-Z:0,_=a?0:0===j?Z:-Z,tt=-$,et=-_;let nt=0,ot=0,st=0;{const e=0/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);nt=n*b,ot=B(o),st=s}let rt=0,at=0,ct=0;{const e=1/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);rt=n*b,at=B(o),ct=s}for(let e=1;e<p-1;e+=J){const n=e/h,o=rt,i=at,c=ct;{const r=a?K:t(n,C,A),l=a?t(n,L,P):Q,u=o-U,d=i-w,f=c-N;lt(o,d,f,D),s.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,r,l)}{const n=(e+1)/h,o=a?z:t(y*(1-n)+S*n,E,T),s=a?t(v*(1-n)+V*n,O,R):G,r=X(o,s);rt=o*b,at=B(s),ct=r}const l=rt,u=ct,d=nt,f=ot,m=st;nt=o,ot=i,st=c;let g=0,p=0,M=0;if(a){const e=at-i,s=u-c,a=f-i,l=m-c,d=t(v*(1-n)+V*n,O,R),h=z+tt,y=h*b-o,S=r(h,d,x)-c,I=3===j?-1:1;if(g=I*(-a+e)*S,p=I*y*(-l+s),M=-I*y*(-a+e),q){const t=z+$,n=t*b-o;g=(-a+e)*(S-(r(t,d,H)-c)),p=(y-n)*(-l+s),M=-(y-n)*(-a+e)}}else{const e=l-o,s=u-c,a=d-o,f=m-c,h=t(y*(1-n)+S*n,E,T),v=G+et,V=r(h,v,x)-c,I=B(v)-i,b=2===j?-1:1;if(g=b*I*(-f+s),p=b*(-a+e)*V,M=-b*I*(-a+e),q){const t=h,n=G+_,o=B(n)-i;g=(-I+o)*(-f+s),p=(-a+e)*(-V+(r(t,n,H)-c)),M=-(-I+o)*(-a+e)}}const I=1/Math.sqrt(g*g+p*p+M*M);s.setEdgeNormalFromValues(j,e,g*I,p*I,M*I)}}}function N(t,e){Z(t)}function j(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function F(t,e){return t*e}function q(t,e,n){return t?t=>j(t,e):t=>F(t,n)}function W(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,c=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=a.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=c>=p?new Uint32Array(g):new Uint16Array(g);for(let a=0;a<g;++a)h[a]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?(H(t),J(t,e),K(t)):(k(t),z(t,e),G(t))}function k(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;dt(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function z(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function G(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function H(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;dt(f,m,g,g-1,i,r)?(ft(e,c,n,s,u),c+=6,ft(e,c,u,d,n)):(ft(e,c,n,s,d),c+=6,ft(e,c,d,u,s)),c+=6}}}function J(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)ft(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(ft(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function K(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function Q(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=ct[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function X(t){Q(t),t.geometryState.wireframe?K(t.geometry):G(t.geometry)}function Y(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:u}=o,d=1===s||3===s,f=i.edgeResolutions[s];l(e(f));const m=f+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),v=t(0===s?1:0,p,M),V=r.renderData,I=V.geometryState,b=V.geometry,B=(s+2)%4,C=b.getEdgeCount(B),L=c.getNeighborEdgeStartVertexIndex(s,r)*f,A=f*2**(c.level-r.level);l(I.edgeResolutions[B]===A),l(C-1===A);const P=V.localOrigin[0]-u[0],D=V.localOrigin[1]-u[1],E=V.localOrigin[2]-u[2],T=a.getEdgeFirstVertexIndex(s),{position:O,uv0:R}=y,U=O.typedBuffer,w=O.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=b.vertexAttributes,W=b.getEdgeFirstVertexIndex(B),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=T+e,s=W+(L+e),r=o*w,i=s*z,a=k[i]+P,c=k[i+1]+D,l=k[i+2]+E;U[r]=a,U[r+1]=c,U[r+2]=l,lt(a,c,l,g);const u=o*F,m=s*H;j[u]=G[m],j[u+1]=G[m+1];const y=e/f,V=d?S:t(y,h,x),I=d?t(y,p,M):v;R.setValues(o,Math.round(V*n),Math.round(I*n))}}function Z(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:p}=o,x=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:v,horizontalScale:V}=x,I="local"===M.view?.viewingMode,b=y.radius;let B=0,C=0,L=0;const A=(t,e,n)=>{const o=v[0===e?1:3],s=v[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=b+n;B=c*r*l,C=a*r*l,L=i*l},D=I?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=q(M.isWebMercatorOnPlateCarree,b,V);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;B=l*V,C=o(u),L=d}})():A;let E=0,T=0,O=0,R=0,U=0,w=0,N=0,j=0,F=0;const W=I&&M.isWebMercatorOnPlateCarree,k=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(I){const t=e*V,s=W?(Math.PI/2-2*Math.atan(Math.exp(-n/b)))*b:n*V;r=t-B,i=s-C,a=o-L}else{const s=P(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=b+o;r=M*h*y-B,i=x*h*y-C,a=p*y-L}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:R-=r,U-=i,w-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:R+=r,U+=i,w+=a}},z=a??st,G=S[0],H=S[2],J=S[1],K=S[3],Q=[K>z[3],H>z[2],J<z[1],G<z[0]],X=Math.max(G,z[0]),Y=Math.min(H,z[2]),Z=Math.max(J,z[1]),_=Math.min(K,z[3]),tt=t=>Math.max(z[0],Math.min(z[2],t)),et=t=>Math.max(z[1],Math.min(z[3],t)),ot=t=>{const e=s.cornerNeighborCornerTiles;E=0,T=0,O=1,R=0,U=0,w=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];rt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=rt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;l(c>1);const u=a/c;for(let s=0;s<4;++s){const t=rt[(s+3)%4],e=rt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=nt[s][0]*u,a=nt[s][1]*u,c=t.extent,l=tt(c[0===n||1===n?2:0]+i),d=et(c[0===n||3===n?3:1]+a),f=e.extent,m=tt(f[0===o||1===o?2:0]+i),g=et(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(l,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);k(h,l,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,l=nt[s],d=tt(c[0===a||1===a?2:0]+l[0]*u),f=et(c[0===a||3===a?3:1]+l[1]*u),m=i.renderData,g=r(d,f,m.geometryState.samplerData);k(m,d,f,g,s)}}if(!I){const t=Math.sqrt(B*B+C*C+L*L);E=B/t,T=C/t,O=L/t}if(I||O*O<.999){const t=Math.sqrt(R*R+U*U+w*w);R/=t,U/=t,w/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,E=w*j-U*F,T=R*F-w*N,O=U*N-R*j;const n=1/Math.sqrt(E*E+T*T+O*O);E*=n,T*=n,O*=n}},it=s.cornerNeighborCornerTiles;for(let P=0;P<4;++P){const e=P,a=(P+1)%4,M=0===P||1===P?1:0,y=0===P||3===P?1:0,S=t(M,u,f),v=t(y,d,m),V=o.getEdgeFirstVertexIndex(e),I=o.getEdgeCount(e),b=0===P||3===P?I-1:0,A=o.getEdgeFirstVertexIndex(a),R=o.getEdgeCount(a),U=0===P||1===P?R-1:0;let w=-1;for(let t=0;t<4;++t){const e=it[4*P+t],n=it[4*P+w];e&&(-1===w||g(n,e)>0)&&(w=t)}const N=w,j=it[4*P+N];if(j!==x){const t=x.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===x.lij[1],0===P&&(1===N||0===N&&j!==it[4*P+3])||1===P&&(0===N||1===N&&j!==it[4*P+2]),o[1]===x.lij[1]+1,2===P&&(3===N||2===N&&j!==it[4*P+1])||3===P&&(2===N||3===N&&j!==it[4*P+0])],a=r.reduce((t,e)=>t+(e?1:0),0);l(1===a||2===a);let c=-1,u=-1;const d=j.renderData;if(1===a){const t=r.findIndex(t=>t);l(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];u=x.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===P||1===t&&0===P||2===t&&1===P||3===t&&3===P?1:0)}else{l(r[1]||r[3]),c=r[1]?3:1;const t=d.geometryState.edgeResolutions[c];u=0===P||3===P?0:t}const f=d.geometry;{const t=V+b,e=A+U,o=f.getEdgeFirstVertexIndex(c)+u,s=f.vertexAttributes,r=d.localOrigin,a=s.position,l=a.typedBuffer,m=o*a.typedBufferStride,g=l[m]+r[0]-i[0],x=l[m+1]+r[1]-i[1],M=l[m+2]+r[2]-i[2];lt(g,x,M,h);const y=p.position,I=y.typedBuffer,B=t*y.typedBufferStride;I[B]=g,I[B+1]=x,I[B+2]=M;const C=e*y.typedBufferStride;I[C]=g,I[C+1]=x,I[C+2]=M;const L=p.uv0;L.setValues(t,Math.round(S*n),Math.round(v*n)),L.setValues(e,Math.round(S*n),Math.round(v*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=p.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(G*(1-M)+H*M,X,Y),n=t(J*(1-y)+K*y,Z,_);l=r(e,n,c)}else l=$(it,P);D(M,y,l),ot(P);const u=B-i[0],d=C-i[1],f=L-i[2];lt(u,d,f,h),o.setEdgeVertexFromValuesRawPositionUVNormal(e,b,u,d,f,S,v,E,T,O),o.setEdgeVertexFromValuesRawPositionUVNormal(a,U,u,d,f,S,v,E,T,O)}}for(let t=0;t<4;++t)rt[t]=null}function $(t,e){const n=4*e,o=a.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);u&&(l(!t[n+0]||!t[n+2]||m(t[n+0],t[n+2],5)),l(!t[n+1]||!t[n+3]||m(t[n+1],t[n+3],7)));let s=0,i=0;for(let a=0;a<4;++a){const e=t[n+a];if(e&&e.level===o){const t=0===a||1===a,n=0===a||3===a,o=e.extent,c=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(c,l,u),s++}}const c=s?i/s:0;return l(null!=c),c}function _(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.buffer.setSubData(r,s,s,r.length)}function tt(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class et{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const nt=[[0,1],[1,0],[0,-1],[-1,0]],ot=new i,st=s(-1/0,-1/0,1/0,1/0),rt=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=g(t,e);return o>0||0===o&&n>=2}class at{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return l(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const ct=[new at,new at,new at,new at];function lt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function ut(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function dt(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],v=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-v)*(m-v)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function ft(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const mt=6;export{D as createPlanarGlobePatch,x as createSphericalGlobePatch,V as updateCornerSpherical,T as updateCornersPlanar,O as updateEdgeElevationsAndResolutionsPlanar,v as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,S as updateEdgesAndCornersSpherical};
5
+ import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r}from"./ElevationData.js";import{PatchGeometryLUT as i}from"./PatchGeometryLUT.js";import{zeroToFour as a,neighborTileIfLoadedOrSelf as c}from"./PatchRenderData.js";import{internalAssert as l,enableTerrainInternalChecks as u,neighborEdgeIndices as d,almostEquals as f}from"./terrainUtils.js";import{isCornerNeighbor as m}from"./Tile.js";import{compareTilesByLij as g}from"./tileUtils.js";import{compressNormal as h}from"../webgl-engine/lib/Normals.js";const p=65536;function x(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*mt*u,x=ut(r),S=m+p+4*x,v=l.tileGeometryCache.acquire(S);s.numVerticesPerSide=u,s.vertexAttributes=v,s.maxEdgeVertexCount=x;const{boundingBox:V}=s;o(V);const B=P(t);ot.update(f,i,B),y(t),s.poleVerticesStartIndex=m;const b=M(t,g,h);s.edgeVerticesStartIndex=m+p,Q(t),I(t),W(s,b,d),t.intersectionData=null}function M(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],p=r[1],x=r[2],M=c.radius,y=a[1],S=a[3],v=[];let V=f;const I=(t,e)=>{const o=e*u;lt(-g,-p,t*M-x,l),v.push(new et(1===t,o,1===t?0:2,V,mt));const s=C(-1===t?y:S,M),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=M+0,{position:c,uv0:f}=d,{typedBuffer:I,typedBufferStride:B}=d.normalCompressed;for(let u=1;u<=mt;++u){const t=s+r*(u/mt),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ot.sinLonLUT[s],u=ot.cosLonLUT[s]*e,d=r*e,M=o,y=u*a-g,S=d*a-p,v=M*a-x;lt(y,S,v,l),c.setValues(V,y,S,v),f.setValues(V,Math.round(t*n),Math.round(i*n)),h(I,V,u,d,M,B),++V}}};return e&&I(-1,0),o&&I(1,m),v}function y(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:p,typedBufferStride:x}=d.normalCompressed,{extent:M}=e,y=M[0],S=M[2],v=M[1],V=M[3],I=e.ellipsoid.radius,B=i[0],b=i[1],C=i[2],L=m.typedBuffer,A=m.typedBufferStride,P=1/u;let D=0;if(1<=l){const t=P,e=v*(1-t)+V*t,o=ot.sinLatLUT[1],s=ot.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*P,l=y*(1-a)+S*a,u=ot.sinLonLUT[i],d=ot.cosLonLUT[i],m=I+r(l,e,c),h=m*d*s-B,p=m*u*s-b,x=m*o-C;lt(h,p,x,f);const M=(i-1)*A;L[M]=h,L[M+1]=p,L[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let E=1;E<=l;E++){const t=E*P,e=v*(1-t)+V*t,o=ot.sinLatLUT[E],s=ot.cosLatLUT[E],i=E+1,a=i*P,d=v*(1-a)+V*a,m=ot.sinLatLUT[i],M=ot.cosLatLUT[i],T=ot.sinLonLUT[0],O=ot.cosLonLUT[0],R=I+r(y,e,c);let U=O*s*R-B,w=T*s*R-b,N=o*R-C;const j=D*A;let F=L[j],q=L[j+1],W=L[j+2];for(let V=1;V<=l;V++){const t=V*P,i=y*(1-t)+S*t,T=ot.sinLonLUT[V],O=ot.cosLonLUT[V];let R=0,j=0,k=0;if(V<l){const t=(D+1)*A;R=L[t],j=L[t+1],k=L[t+2]}else{const t=ot.sinLonLUT[u],n=ot.cosLonLUT[u],i=I+r(S,e,c);R=n*s*i-B,j=t*s*i-b,k=o*i-C}const z=U,G=w,H=N;U=F,w=q,N=W,F=R,q=j,W=k;const J=R-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(E>1){const t=(D-l)*A;X=L[t],Y=L[t+1],Z=L[t+2]}else{const t=ot.sinLatLUT[0],e=ot.cosLatLUT[0],n=I+r(i,v,c);X=O*e*n-B,Y=T*e*n-b,Z=t*n-C}const $=I+r(i,d,c),_=O*M*$-B,tt=T*M*$-b,et=m*$-C;if(E<l){const e=D+l,o=e*A;L[o]=_,L[o+1]=tt,L[o+2]=et,lt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,st=Y-tt,rt=Z-et;let it=O*s,at=T*s,ct=o;ct*ct<.999&&(it=Q*st-K*rt,at=J*rt-Q*nt,ct=K*nt-J*st);const ut=1/Math.sqrt(it*it+at*at+ct*ct);h(p,D,it*ut,at*ut,ct*ut,x),++D}}}function S(t){t.tile.intersectsClippingArea&&(I(t),_(t),t.intersectionData=null)}function v(t){t.tile.intersectsClippingArea&&(X(t),I(t),_(t),tt(t),t.intersectionData=null)}function V(t){t.tile.intersectsClippingArea&&(b(t),B(t,!0),_(t),t.intersectionData=null)}function I(t){t.tile.intersectsClippingArea&&(b(t),B(t))}function B(t,o=!1){const{geometry:s,geometryState:i,tile:a,localOrigin:m}=t,{level:h,extent:p,extentInRadians:x,ellipsoid:M}=a,y=M.radius,S=x[0],v=x[2],V=x[1],I=x[3],{samplerData:B}=i,b=p[0],C=p[2],L=p[1],A=p[3],D=P(t),{boundingBox:E,vertexAttributes:T}=s,O=m[0],R=m[1],U=m[2],{position:w,uv0:N}=T,j=w.typedBuffer,F=w.typedBufferStride;for(let P=0;P<4;++P){const m=1===P||3===P,x=i.edgeResolutions[P];l(e(x));const M=x+1,T=c(a,i.edgePeerNeighbors[P]);if(it(a,T,P)){Y(t,P,T);continue}const w=null!=T;l(!w||T.level===a.level),l(!w||g(a,T)<=0);const q=T?.renderData,W=q?.geometryState;if(u){const t=a.surface;if(!T&&t&&!t.updatingRootTiles){const e=d[P],n=a.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===a.level);n?n.intersectsClippingArea&&(l(!n.loaded),l(!n.leaf),l(n.level===h)):l(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const k=1===P?p[2]:p[0],z=T?.extent,G=z&&m?1===P?z[0]:z[2]:k,H=0===P?p[3]:p[1],J=1===P?1:0,K=0===P?1:0,Q=1===P?v:S,X=0===P?I:V,Z=Math.sin(Q),$=Math.cos(Q),_=Math.sin(X),tt=Math.cos(X),et=W?.samplerData,nt=w?(t,e,n)=>.5*(r(t,e,B)+r(n,e,et)):(t,e,n)=>r(t,e,B),ot=s.outerEdgesOffsetAndLength[2*P+0],st=o&&M>3?M-3:1,rt=null!=B&&B.some(t=>null!=t),at=null!=et&&et.some(t=>null!=t),ct=rt||at,ut=1/x,dt=ot;l(!z||f(z[2]-z[0],p[2]-p[0]));(()=>{const t=1===P?-1:3===P?1:0,e=0===P?-1:2===P?1:0,o=(p[2]-p[0])*ut,i=t*o,a=e*o,c=m?t*((v-S)*ut):0,l=m?0:e*ut,u=K,d=m?Q+c:Q,f=m?Math.sin(d):Z,g=m?Math.cos(d):$,h=m?Q-c:Q,x=m?Math.sin(h):Z,V=m?Math.cos(h):$,I=m?X:D(u+l),T=m?_:Math.sin(I),q=m?tt:Math.cos(I),W=m?X:D(u-l),z=m?_:Math.sin(W),Y=m?tt:Math.cos(W);let ot=0,rt=0,it=0;{const t=0*ut,e=m?k:b*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);ot=i*l*u,rt=r*l*u,it=c*u}let at=0,ft=0,mt=0;{const t=1*ut,e=m?k:b*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);at=i*l*u,ft=r*l*u,mt=c*u}for(let p=1;p<M-1;p+=st){let t=0,e=0,o=0;{const n=(p+1)*ut,s=m?k:b*(1-n)+C*n,r=m?G:s,i=m?L*(1-n)+A*n:H,a=m?Q:S*(1-n)+v*n,c=m?Z:Math.sin(a),l=m?$:Math.cos(a),u=m?D(n):X,d=m?Math.sin(u):_,f=m?Math.cos(u):tt,g=y+nt(s,i,r);t=l*f*g,e=c*f*g,o=d*g}const c=t,l=e,u=o,d=at,h=ft,M=mt;at=c,ft=l,mt=u;{const t=dt+p,e=t*F,o=d-O,s=h-R,r=M-U;j[e]=o,j[e+1]=s,j[e+2]=r,lt(o,s,r,E);const i=p*ut,a=m?J:i,c=m?i:K;N.setValues(t,Math.round(a*n),Math.round(c*n))}const I=ot,W=rt,st=it;ot=d,rt=h,it=M;const gt=d,ht=h,pt=M,xt=1/Math.sqrt(gt*gt+ht*ht+pt*pt),Mt=pt*xt;let yt=0,St=0,vt=0;if(ct&&Mt*Mt<.999){let t=0,e=0,n=0;{const o=0===P?-1:1;t=o*(c-I),e=o*(l-W),n=o*(u-st)}{const o=p*ut,s=m?k:b*(1-o)+C*o,c=m?G:s,l=m?L*(1-o)+A*o:H,u=m?Q:S*(1-o)+v*o,d=m?Z:Math.sin(u),h=m?$:Math.cos(u),M=m?D(o):X,I=m?Math.sin(M):_,E=m?Math.cos(M):tt;let O=gt,R=ht,U=pt;if(w){const t=y+r(c-i,l-a,et),e=m?E:Y;O=(m?V:h)*e*t,R=(m?x:d)*e*t,U=(m?I:z)*t}{const o=y+r(s+i,l+a,B),c=m?E:q,u=(m?g:h)*c*o,p=(m?f:d)*c*o,x=(m?I:T)*o;w||(O=2*gt-u,R=2*ht-p,U=2*pt-x);const M=3===P?-1:1,S=M*(O-u),v=M*(R-p),V=M*(U-x);yt=n*v-e*V,St=t*V-n*S,vt=e*S-t*v;const b=1/Math.sqrt(yt*yt+St*St+vt*vt);yt*=b,St*=b,vt*=b}}}else yt=gt*xt,St=ht*xt,vt=pt*xt;s.setEdgeNormalFromValues(P,p,yt,St,vt)}})()}}function b(t){Z(t)}function C(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function L(t,e,n,o){return C(t*(1-o)+e*o,n)}function A(t,e,n){return t*(1-n)+e*n}function P(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>L(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>A(n[1],n[3],t)}function D(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=ut(s),v=y+4*S,V=a.renderer.tileGeometryCache.acquire(v),{boundingBox:I}=r;o(I),r.numVerticesPerSide=m,r.vertexAttributes=V,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,E(t),r.edgeVerticesStartIndex=y,Q(t),U(t),W(r,[],c),t.intersectionData=null}function E(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:i,localOrigin:a}=e,{samplerData:c,clippingArea:l,numVerticesPerSide:u}=i,{surface:d,extent:f,ellipsoid:m}=o,{isWebMercatorOnPlateCarree:g}=d,p=null!=l?l:st,x=f[0],M=f[1],y=f[2],S=f[3],v=Math.max(x,p[0]),V=Math.min(y,p[2]),I=Math.max(M,p[1]),B=Math.min(S,p[3]),b=m.radius,C=o.horizontalScale,L=u-1,A=u-2,{minu:P,minv:D,maxu:E,maxv:T,boundingBox:O,vertexAttributes:R}=s,{position:U,uv0:w}=R,{typedBuffer:N,typedBufferStride:j}=R.normalCompressed,F=a[0],q=a[1],W=a[2],k=U.typedBuffer,z=U.typedBufferStride;let G=0;const H=t(M,I,B),J=g?(Math.PI/2-2*Math.atan(Math.exp(-H/b)))*b:H*C,K=1/L,Q=t(M*(1-K)+S*K,I,B);let X=J,Y=g?(Math.PI/2-2*Math.atan(Math.exp(-Q/b)))*b:Q*C;for(let Z=1;Z<=A;Z++){const e=Z/L,o=t(M*(1-e)+S*e,I,B),s=t(e,D,T),i=Y,a=(Z-1)/L,l=t(M*(1-a)+S*a,I,B),u=X,d=(Z+1)/L,f=t(M*(1-d)+S*d,I,B),m=g?(Math.PI/2-2*Math.atan(Math.exp(-f/b)))*b:f*C,p=t(d,D,T);X=Y,Y=m;const R=t(x,v,V);let U=R*C,H=r(R,o,c);const J=1/L,K=t(J,P,E),Q=t(x*(1-K)+y*K,v,V);let $=K,_=Q,tt=Q*C,et=r(Q,o,c);if(1===Z){const e=tt-F,o=X-q,r=et-W,i=0*z;k[i]=e,k[i+1]=o,k[i+2]=r,lt(e,o,r,O);const a=t(J,P,E);w.setValues(G,Math.round(a*n),Math.round(s*n))}for(let g=1;g<=A;g++){const e=tt,a=et,d=(g+1)/L,M=t(d,P,E),S=t(x*(1-d)+y*d,v,V),I=_;_=S;{const t=G+1,e=t*z;if(1===Z||g===A){const a=S*C,l=r(S,o,c);if(1===Z&&g<A){const o=a-F,r=i-q,c=l-W;k[e]=o,k[e+1]=r,k[e+2]=c,lt(o,r,c,O),w.setValues(t,Math.round(M*n),Math.round(s*n))}tt=a,et=l}else tt=k[e]+F,et=k[e+2]+W}const B=tt,b=et,D=U,T=H;U=e,H=a;const R=(G-A)*z,J=1===Z?r(I,l,c):k[R+2]+W,K=r(I,f,c);if(Z<A){const t=G+A,o=t*z,s=e-F,r=m-q,i=K-W;k[o]=s,k[o+1]=r,k[o+2]=i,lt(s,r,i,O);const a=$;$=M,w.setValues(t,Math.round(a*n),Math.round(p*n))}{const t=B-D,e=u-m,n=e*(b-T),o=t*(J-K),s=-e*t,r=n*n+o*o+s*s;if(0===r)h(N,G,0,0,1,j);else{const t=1/Math.sqrt(r);h(N,G,n*t,o*t,s*t,j)}}++G}}}function T(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!0),_(t),t.intersectionData=null)}function O(t,e){t.tile.intersectsClippingArea&&(X(t),U(t),_(t),tt(t),t.intersectionData=null)}function R(t,e){t.tile.intersectsClippingArea&&(U(t),_(t),t.intersectionData=null)}function U(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!1))}function w(n,o){const{geometry:s,geometryState:i,localOrigin:a}=n,f=n.tile,{surface:m,extent:h}=f,{clippingArea:p,samplerData:x}=i,M=null!=p?p:st,y=h[0],S=h[2],v=h[1],V=h[3],I=[V>M[3],S>M[2],v<M[1],y<M[0]],B=f.horizontalScale,b=q(m.isWebMercatorOnPlateCarree,f.ellipsoid.radius,B),{minu:C,minv:L,maxu:A,maxv:P,boundingBox:D}=s,E=Math.max(y,M[0]),T=Math.min(S,M[2]),O=Math.max(v,M[1]),R=Math.min(V,M[3]),U=a[0],w=a[1],N=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,h=i.edgeResolutions[j];l(e(h));const p=h+1,M=I[j],F=c(f,i.edgePeerNeighbors[j]);if(!M&&it(f,F,j)){Y(n,j,F);continue}const q=null!=F&&!M,W=F?.renderData,k=W?.geometryState;if(u&&(l(!q||F.level===f.level),l(!q||g(f,F)<=0),f&&!F&&!m.updatingRootTiles)){const t=d[j],e=f.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===f.level);m.updatingRootTiles||(e?e.intersectsClippingArea&&(l(!e.loaded),l(!e.leaf),l(e.level===f.level)):l(null==m?.rootTiles||!f.shouldHaveNeighbor(t)))}const z=t(1===j?S:y,E,T),G=t(0===j?V:v,O,R),H=k?.samplerData,J=o&&p>3?p-3:1,K=t(1===j?1:0,C,A),Q=t(0===j?1:0,L,P),X=q?(t,e)=>.5*(r(t,e,H)+r(t,e,x)):(t,e)=>r(t,e,x),Z=(S-y)/h,$=a?1===j?Z:-Z:0,_=a?0:0===j?Z:-Z,tt=-$,et=-_;let nt=0,ot=0,st=0;{const e=0/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);nt=n*B,ot=b(o),st=s}let rt=0,at=0,ct=0;{const e=1/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);rt=n*B,at=b(o),ct=s}for(let e=1;e<p-1;e+=J){const n=e/h,o=rt,i=at,c=ct;{const r=a?K:t(n,C,A),l=a?t(n,L,P):Q,u=o-U,d=i-w,f=c-N;lt(o,d,f,D),s.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,r,l)}{const n=(e+1)/h,o=a?z:t(y*(1-n)+S*n,E,T),s=a?t(v*(1-n)+V*n,O,R):G,r=X(o,s);rt=o*B,at=b(s),ct=r}const l=rt,u=ct,d=nt,f=ot,m=st;nt=o,ot=i,st=c;let g=0,p=0,M=0;if(a){const e=at-i,s=u-c,a=f-i,l=m-c,d=t(v*(1-n)+V*n,O,R),h=z+tt,y=h*B-o,S=r(h,d,x)-c,I=3===j?-1:1;if(g=I*(-a+e)*S,p=I*y*(-l+s),M=-I*y*(-a+e),q){const t=z+$,n=t*B-o;g=(-a+e)*(S-(r(t,d,H)-c)),p=(y-n)*(-l+s),M=-(y-n)*(-a+e)}}else{const e=l-o,s=u-c,a=d-o,f=m-c,h=t(y*(1-n)+S*n,E,T),v=G+et,V=r(h,v,x)-c,I=b(v)-i,B=2===j?-1:1;if(g=B*I*(-f+s),p=B*(-a+e)*V,M=-B*I*(-a+e),q){const t=h,n=G+_,o=b(n)-i;g=(-I+o)*(-f+s),p=(-a+e)*(-V+(r(t,n,H)-c)),M=-(-I+o)*(-a+e)}}const I=1/Math.sqrt(g*g+p*p+M*M);s.setEdgeNormalFromValues(j,e,g*I,p*I,M*I)}}}function N(t,e){Z(t)}function j(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function F(t,e){return t*e}function q(t,e,n){return t?t=>j(t,e):t=>F(t,n)}function W(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,c=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=a.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=c>=p?new Uint32Array(g):new Uint16Array(g);for(let a=0;a<g;++a)h[a]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?(H(t),J(t,e),K(t)):(k(t),z(t,e),G(t))}function k(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;dt(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function z(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function G(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function H(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;dt(f,m,g,g-1,i,r)?(ft(e,c,n,s,u),c+=6,ft(e,c,u,d,n)):(ft(e,c,n,s,d),c+=6,ft(e,c,d,u,s)),c+=6}}}function J(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)ft(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(ft(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function K(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function Q(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=ct[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function X(t){Q(t),t.geometryState.wireframe?K(t.geometry):G(t.geometry)}function Y(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:u}=o,d=1===s||3===s,f=i.edgeResolutions[s];l(e(f));const m=f+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),v=t(0===s?1:0,p,M),V=r.renderData,I=V.geometryState,B=V.geometry,b=(s+2)%4,C=B.getEdgeCount(b),L=c.getNeighborEdgeStartVertexIndex(s,r)*f,A=f*2**(c.level-r.level);l(I.edgeResolutions[b]===A),l(C-1===A);const P=V.localOrigin[0]-u[0],D=V.localOrigin[1]-u[1],E=V.localOrigin[2]-u[2],T=a.getEdgeFirstVertexIndex(s),{position:O,uv0:R}=y,U=O.typedBuffer,w=O.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=B.vertexAttributes,W=B.getEdgeFirstVertexIndex(b),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=T+e,s=W+(L+e),r=o*w,i=s*z,a=k[i]+P,c=k[i+1]+D,l=k[i+2]+E;U[r]=a,U[r+1]=c,U[r+2]=l,lt(a,c,l,g);const u=o*F,m=s*H;j[u]=G[m],j[u+1]=G[m+1];const y=e/f,V=d?S:t(y,h,x),I=d?t(y,p,M):v;R.setValues(o,Math.round(V*n),Math.round(I*n))}}function Z(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:p}=o,x=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:v,horizontalScale:V}=x,I="local"===M.view?.viewingMode,B=y.radius;let b=0,C=0,L=0;const A=(t,e,n)=>{const o=v[0===e?1:3],s=v[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=B+n;b=c*r*l,C=a*r*l,L=i*l},D=I?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=q(M.isWebMercatorOnPlateCarree,B,V);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;b=l*V,C=o(u),L=d}})():A;let E=0,T=0,O=0,R=0,U=0,w=0,N=0,j=0,F=0;const W=I&&M.isWebMercatorOnPlateCarree,k=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(I){const t=e*V,s=W?(Math.PI/2-2*Math.atan(Math.exp(-n/B)))*B:n*V;r=t-b,i=s-C,a=o-L}else{const s=P(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=B+o;r=M*h*y-b,i=x*h*y-C,a=p*y-L}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:R-=r,U-=i,w-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:R+=r,U+=i,w+=a}},z=a??st,G=S[0],H=S[2],J=S[1],K=S[3],Q=[K>z[3],H>z[2],J<z[1],G<z[0]],X=Math.max(G,z[0]),Y=Math.min(H,z[2]),Z=Math.max(J,z[1]),_=Math.min(K,z[3]),tt=t=>Math.max(z[0],Math.min(z[2],t)),et=t=>Math.max(z[1],Math.min(z[3],t)),ot=t=>{const e=s.cornerNeighborCornerTiles;E=0,T=0,O=1,R=0,U=0,w=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];rt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=rt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;l(c>1);const u=a/c;for(let s=0;s<4;++s){const t=rt[(s+3)%4],e=rt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=nt[s][0]*u,a=nt[s][1]*u,c=t.extent,l=tt(c[0===n||1===n?2:0]+i),d=et(c[0===n||3===n?3:1]+a),f=e.extent,m=tt(f[0===o||1===o?2:0]+i),g=et(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(l,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);k(h,l,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,l=nt[s],d=tt(c[0===a||1===a?2:0]+l[0]*u),f=et(c[0===a||3===a?3:1]+l[1]*u),m=i.renderData,g=r(d,f,m.geometryState.samplerData);k(m,d,f,g,s)}}if(!I){const t=Math.sqrt(b*b+C*C+L*L);E=b/t,T=C/t,O=L/t}if(I||O*O<.999){const t=Math.sqrt(R*R+U*U+w*w);R/=t,U/=t,w/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,E=w*j-U*F,T=R*F-w*N,O=U*N-R*j;const n=1/Math.sqrt(E*E+T*T+O*O);E*=n,T*=n,O*=n}},it=s.cornerNeighborCornerTiles;for(let P=0;P<4;++P){const e=P,a=(P+1)%4,M=0===P||1===P?1:0,y=0===P||3===P?1:0,S=t(M,u,f),v=t(y,d,m),V=o.getEdgeFirstVertexIndex(e),I=o.getEdgeCount(e),B=0===P||3===P?I-1:0,A=o.getEdgeFirstVertexIndex(a),R=o.getEdgeCount(a),U=0===P||1===P?R-1:0;let w=-1;for(let t=0;t<4;++t){const e=it[4*P+t],n=it[4*P+w];e&&(-1===w||g(n,e)>0)&&(w=t)}const N=w,j=it[4*P+N];if(j!==x){const t=x.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===x.lij[1],0===P&&(1===N||0===N&&j!==it[4*P+3])||1===P&&(0===N||1===N&&j!==it[4*P+2]),o[1]===x.lij[1]+1,2===P&&(3===N||2===N&&j!==it[4*P+1])||3===P&&(2===N||3===N&&j!==it[4*P+0])],a=r.reduce((t,e)=>t+(e?1:0),0);l(1===a||2===a);let c=-1,u=-1;const d=j.renderData;if(1===a){const t=r.findIndex(t=>t);l(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];u=x.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===P||1===t&&0===P||2===t&&1===P||3===t&&3===P?1:0)}else{l(r[1]||r[3]),c=r[1]?3:1;const t=d.geometryState.edgeResolutions[c];u=0===P||3===P?0:t}const f=d.geometry;{const t=V+B,e=A+U,o=f.getEdgeFirstVertexIndex(c)+u,s=f.vertexAttributes,r=d.localOrigin,a=s.position,l=a.typedBuffer,m=o*a.typedBufferStride,g=l[m]+r[0]-i[0],x=l[m+1]+r[1]-i[1],M=l[m+2]+r[2]-i[2];lt(g,x,M,h);const y=p.position,I=y.typedBuffer,b=t*y.typedBufferStride;I[b]=g,I[b+1]=x,I[b+2]=M;const C=e*y.typedBufferStride;I[C]=g,I[C+1]=x,I[C+2]=M;const L=p.uv0;L.setValues(t,Math.round(S*n),Math.round(v*n)),L.setValues(e,Math.round(S*n),Math.round(v*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=p.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(G*(1-M)+H*M,X,Y),n=t(J*(1-y)+K*y,Z,_);l=r(e,n,c)}else l=$(it,P);D(M,y,l),ot(P);const u=b-i[0],d=C-i[1],f=L-i[2];lt(u,d,f,h),o.setEdgeVertexFromValuesRawPositionUVNormal(e,B,u,d,f,S,v,E,T,O),o.setEdgeVertexFromValuesRawPositionUVNormal(a,U,u,d,f,S,v,E,T,O)}}for(let t=0;t<4;++t)rt[t]=null}function $(t,e){const n=4*e,o=a.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);u&&(l(!t[n+0]||!t[n+2]||m(t[n+0],t[n+2],5)),l(!t[n+1]||!t[n+3]||m(t[n+1],t[n+3],7)));let s=0,i=0;for(let a=0;a<4;++a){const e=t[n+a];if(e&&e.level===o){const t=0===a||1===a,n=0===a||3===a,o=e.extent,c=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(c,l,u),s++}}const c=s?i/s:0;return l(null!=c),c}function _(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.setSubData(r,s,s,r.length)}function tt(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class et{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const nt=[[0,1],[1,0],[0,-1],[-1,0]],ot=new i,st=s(-1/0,-1/0,1/0,1/0),rt=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=g(t,e);return o>0||0===o&&n>=2}class at{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return l(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const ct=[new at,new at,new at,new at];function lt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function ut(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function dt(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],v=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-v)*(m-v)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function ft(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const mt=6;export{D as createPlanarGlobePatch,x as createSphericalGlobePatch,V as updateCornerSpherical,T as updateCornersPlanar,O as updateEdgeElevationsAndResolutionsPlanar,v as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,S as updateEdgesAndCornersSpherical};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{j as s,F as o,H as a,d as n,n as l,e as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as C,neighborCornerIndices as E,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import T from"./TileOverlayData.js";import{fallsWithinLayerView as V}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class F{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new T,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(C(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(E[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(p(t.layout),A.createVertex(e,i.STATIC_DRAW,t.buffer)),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(V(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=E.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const C=2**_;if(_<0)return void v(!1);const E=e.renderData,S=E.geometry,j=E.localOrigin,R=S.getEdgeCount(y),T=S.numVerticesPerSide-1,V=$.geometry;if(!V)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(E.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=V.getEdgeCount(P),L=R-1,X=F-1;v(L*C===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*C})`);const B=e.extent,H=0===r||4===r,W=F-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=V.numVerticesPerSide-1;v(_>0||q===Math.max(J,T));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<C);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,N,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(N,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,N,j,Y),V.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.extent;if(null==_||c(_,s,p)){const t=o(N,G),r=a(N)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${F}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,E.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${E.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(N),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,N,j,Y),V.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,N,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${N} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=V.getEdgeCount(F);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(N)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),V.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const C=d(k,U),T=1-C<.01||!1||e===x;if(!T){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${F-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${C} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),V.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(T,r())}}Y+=1,Z+=1}})}}const N=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{F as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q as zeroToFour};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r,releaseMaybe as i}from"../../../core/maybe.js";import{j as s,F as o,H as a,d as n,n as l,e as d,a as g,G as h}from"../../../chunks/vec32.js";import{create as u,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as _}from"./TerrainConst.js";import{internalAssert as v,neighborEdgeIndices as $,oppositeEdge as C,neighborCornerIndices as E,enableTerrainInternalChecks as S,v32s as D,lij2s as b}from"./terrainUtils.js";import{TextureFader as j}from"./TextureFader.js";import{TextureReference as R}from"./TextureReference.js";import V from"./TileOverlayData.js";import{fallsWithinLayerView as T}from"./tileUtils.js";import{VertexArrayObject as w}from"../webgl-engine/lib/VertexArrayObject.js";import{BufferObject as A}from"../../webgl/BufferObject.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";class F{constructor(){this.geometry=new x,this.geometryState=null,this._texture=null,this._textureOpacity=1,this._textureRef=new j(()=>this._tile.surface.fadeDuration),this.overlay=new V,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new y,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),S&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)v(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=$[e];if(!t)return v(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.loaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(v(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}v(!t.leaf);let a=i;return t.forAllSubtreeOnSide(C(o),e=>e===r||(e.loaded?(a=Math.max(a,2**(e.level-s)),!0):(v(!e.leaf),!1))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.loaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile($[a],i),l=X(e,n),d=l?.renderData?.geometryState.samplerDataVersion??-1,g=s[a],h=l!==X(e,g),u=o[a]!==d;S&&n&&(v(e.level>=n.level),v(e.level-n.level<=_)),s[a]=n,(h||u)&&(o[a]=d,this._markEdgeDirty(a));const m=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);v(t(c)),v(c>=1),r.edgeResolutions[a]=c,m!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(E[t],i);r.cornerPeerNeighbors[t]=o;const a=X(e,s[t]),n=X(e,s[(t+1)%4]),l=X(e,o);L[t]=l,L[(t+1)%4]=n,L[(t+2)%4]=e,L[(t+3)%4]=a,v(L.some(t=>t?.loaded||t===e));const d=L.reduce((e,t)=>Math.min(e,t?.level??1/0),1/0);L.forEach((e,t)=>{e&&e?.level>d&&(L[t]=null)}),v(L.some(t=>t?.loaded||t===e));const g=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=L[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=g[s]!==r,a=!o&&h[s]!==i;(o||a)&&(g[s]=r,h[s]=i,this._markCornerDirty(t))}S&&v(Q.some(r=>g[4*t+r]?.loaded||g[4*t+r]===e))}S&&v(this.geometryState.edgeResolutions.every(e=>e>0));for(let t=0;t<4;++t)L[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;S&&v(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every(e=>e>0)),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce((e,t)=>e+t+1,0),l=o||a&&n>(i?.maxEdgeVertexCount??0),d=!l&&a,g=!d&&(0!==this.dirtyEdges||a),h=!g&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):d?t.updateEdgeElevationsAndResolutions():g||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r,i){const s=t?6408:6407;return null!=this._texture&&(0===r&&this._tile.surface.fadeDuration>0&&this._isTextureVisible(this._texture)||this._texture.descriptor.width!==e||this._texture.descriptor.pixelFormat!==s)&&this.releaseTexture(),null==this._texture&&(this._texture=i(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){this._texture&&(this._texture=i(this._texture),this.tile.setMemoryDirty())}reuseTexture(e,t){return!(!e||!this._texture)&&(e.setTextureReference(new R(this._texture,0,t,this._textureOpacity,0,1)),!0)}get numVerticesPerSideChanged(){return 0!==(this._modifiedFlags&B)}get samplerDataChanged(){return 0!==(this._modifiedFlags&H)}get clippingAreaChanged(){return 0!==(this._modifiedFlags&W)}get wireframeChanged(){return 0!==(this._modifiedFlags&q)}get dirtyEdges(){return this._modifiedFlags>>z&15}get dirtyCorners(){return this._modifiedFlags>>J&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>K&15}_markCornerDirty(e){const t=1<<e<<J;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<z;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<K;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<J|15<<z|15<<K}updateGeometryState(){const t=this._elevationInfo,r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.minimumVerticesPerSide,s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.withinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const{vertexAttributes:t,indices:r}=this.geometry,i=e.gl;this._vao=new w(e,new P(e,p(t.layout),t.buffer),A.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=0){e?.texture===this._texture?this._textureOpacity=e.opacities[0]:this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_isTextureVisible(e){return this._textureRef.current?.texture===e||this._textureRef.next?.texture===e&&this._textureRef.fadeFactor<1}get _elevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[0],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let d=0;d<r;d++){const r=t[d],n=r.upsampleInfo?.tile;if(n){const t=n.layerInfo[0][d].data,r=t&&t.samplerData;e&&e[s]===r||(a=!0),i[s++]=r,o=Math.max(o,n.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(d,0);if(T(this.tile,t)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){}checkGeometryWaterproofness(){if(!S)return;const e=this.tile;if(!e.loaded||!e.intersectsClippingArea||0===e.level)return void v(e?.loaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const i=$.map((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0),p=e.level;v(0===this.dirtyCorners),v(0===this.dirtyEdges),v(0===this.dirtyEdgeResolutions),v(!this.numVerticesPerSideChanged),v(!this.samplerDataChanged),v(!this.clippingAreaChanged),v(!this.wireframeChanged);const y=E.map(t=>e.findNeighborCornerTileExact(t,t=>!t.intersectsClippingArea||t.loaded||t.level===e.level)??null).map(e=>e?.intersectsClippingArea?e:null),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=y[t];v(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}$.forEach((r,y)=>{if(i[y])return;const x=e.findNeighborTile(r,e=>(e.level===p||e?.loaded)&&e?.intersectsClippingArea);if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void v(!t)}v(x.loaded||x.level===e.level),v(x===this.geometryState.edgePeerNeighbors[y]);const _=p-x.level;if(!x.loaded)return v(!x.leaf),void v(0===_);const $=x.renderData;v(e.isEdgeNeighbor(x,r)),v(_>=0);const C=2**_;if(_<0)return void v(!1);const E=e.renderData,S=E.geometry,j=E.localOrigin,R=S.getEdgeCount(y),V=S.numVerticesPerSide-1,T=$.geometry;if(!T)return void v(!1);const w=$.localOrigin,A=this.geometryState.edgePeerNeighbors[y];if(A?.loaded){const e=A.renderData;v(E.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion),v(this.geometryState.edgePeerNeighborSamplerVersions[y]===e.geometryState.samplerDataVersion)}const P=(y+2)%4,F=T.getEdgeCount(P),L=R-1,X=F-1;v(L*C===X,`Tile[${e.lij}]:e${y},res=${L} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${X} (expected:${L*C})`);const B=e.extent,H=0===r||4===r,W=F-1,q=W>>_,z=R-1;if(q<1)return void v(1===z);v(q===z),v(t(q));const J=T.numVerticesPerSide-1;v(_>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(y,x);v(0<=K&&K<C);const Q=K*q;v(0<=Q&&Q<=W-q);let Y=0,Z=Q;S.getEdgeVertexPosition(y,N,j,0),S.getEdgeVertexPosition(y,G,j,R-1);const ee=s(N,G),te=Math.max(I,1e-4*ee);for(let t=0;t<=q;++t){S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=t/q,s=H?B[0]+i*(B[2]-B[0]):6===r?B[0]:B[2],p=H?4===r?B[1]:B[3]:B[1]+i*(B[3]-B[1]),_=e.surface.extent;if(null==_||c(_,s,p)){const t=o(N,G),r=a(N)-f.radius,i=a(G)-f.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${y}[${Y}/${R}] and [${x.lij}].edge${P}[${Z}/${F}]`),null!=_&&console.warn(" surface extent= ",_," x,y=",s,",",p);const o=u();n(o,E.localOrigin,$.localOrigin),a(o)>0&&console.warn(` localOrigins: ${E.localOrigin} vs ${$.localOrigin} d=${a(o)} [${o}]`);(()=>{const t=m(N),r=m(G);e.updateEdgeElevations(),x.updateEdgeElevations(),S.getEdgeVertexPosition(y,N,j,Y),T.getEdgeVertexPosition(P,G,w,Z);const i=u();g(i,N,t),a(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${N} d=${a(i)} [${i}]`),g(i,G,r),a(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${G} d=${a(i)} [${i}]`)})();const l=S.getEdgeCount(y),d=T.getEdgeCount(F);v(c,`Mismatch in tile [${e.lij}].edge[${y}][${Y}/${l}] vs neighbor [${x.lij}].edge[${P}][${Z}/${d}] ${D(N)} vs ${D(G)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}S.getEdgeNormal(y,O,Y),T.getEdgeNormal(P,M,Z),l(k,O),l(U,M);const C=d(k,U),V=1-C<.01||!1||e===x;if(!V){const t=u();g(t,O,M);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${Y}/${R-1}) edge ${y} vs neighbor ${b(x.lij)} (${Z}/${F-1}) nedge ${P} :${D(O)} vs ${D(M)} dot = ${C} : ${D(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=u(),r=u();S.getEdgeNormal(y,t,Y),T.getEdgeNormal(P,r,Z),h(O,t)||console.warn("Missing update in tile normal: ",D(O)," => ",D(t)),h(M,r)||console.warn("Missing update in neighbor normal: ",D(M)," => ",D(r))}v(V,r())}}Y+=1,Z+=1}})}}const N=u(),G=u(),O=u(),M=u(),k=u(),U=u(),I=1,L=[null,null,null,null];function X(e,t){return t?.loaded||t===e?t:null}const B=1,H=2,W=4,q=8,z=4,J=8,K=12,Q=[0,1,2,3];export{F as PatchRenderData,X as neighborTileIfLoadedOrSelf,Q as zeroToFour};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{encodeSymbolColor as m}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{ComponentData as p}from"./ComponentData.js";import{ComponentObject as g}from"./ComponentObject.js";import{IntersectionGeometry as d}from"./IntersectionGeometry.js";import{Renderable as u}from"./Renderable.js";import{RenderGeometry as b}from"./RenderGeometry.js";import{RenderSubmitSystem as v}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as y}from"./SourceGeometry.js";import{UniformComponentParameters as _}from"./UniformComponentParameters.js";import{ComponentParametersVarying as M,ComponentParametersUniform as C,ComponentMaterial as j}from"./Material/ComponentMaterial.js";import{componentIndexGlLayout as w}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as x}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as O}from"../../effects/geometry/olidUtils.js";import{getVisibility as D,updatePickabilityWithCount as R}from"../../lib/ComponentUtils.js";import{assert as A}from"../../lib/Util.js";import{VertexArrayObject as B}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as E}from"../../lib/verticalOffsetUtils.js";import{BufferManager as H}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as S}from"../../../../webgl/BufferObject.js";import{PrimitiveType as U}from"../../../../webgl/enums.js";import{VertexBuffer as V}from"../../../../webgl/VertexBuffer.js";const P=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class I{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new v(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new H(e.rctx,2+(O()?1:0))}destroy(){A(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy()}createObject(e){const t=e.geometry,i=new p(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new d(this._viewingMode,t.positionData,i),r=new g(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll(e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new _,c=s.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let g=0,d=0,u=0,b=n.verticalOffsets,v=1/0,y=-1/0,j=!1,w=!1,A=0;for(let h=0;h<n.count;h++){t(h,l),g+=+(l.externalColor[3]<1),d+=+(3===l.externalColorMixMode&&1===l.externalColor[3]),u+=+l.castShadows,m(l.externalColor,l.externalColorMixMode,f),f[2]=254&f[2]|+l.castShadows,c.setData(a[h],0,f[0],f[1],f[2],f[3]),j||=h>0&&A!==p[0],A=p[0],w||=0!==l.elevationOffset,w&&null==b&&(b=new Array(h).fill(0)),null!=b&&(b[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),y=Math.max(y,l.elevationOffset),x(l.elevationOffset,f),c.setData(a[h],1,f[0],f[1],f[2],f[3]);const e=l.olidColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==D(n.pickability,h)&&R(n,h,l.pickable)}n.verticalOffsets=w?b:null,i.offsetObb=w?h(i.obb,v,y,this._viewingMode,i.offsetObb??i.obb.clone()):null,j||w||O()?(r.componentParameters=new M,r.componentParameters.castShadows=N(u,n.count),r.componentParameters.transparent=N(g,n.count),r.componentParameters.opaqueOverride=N(d,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new C,r.componentParameters.castShadows=l.castShadows?0:2,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(2===this._viewingMode||0===s)return i[2]+=s,i[5]+=s,i;const a=E(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=2===this._viewingMode,m=l.getComponentAabbs(),h=k;let f=1/0,p=-1/0;for(let g=0;g<s;g++){const e=6*g,r=a?.[g]??0;let s=1/0,l=-1/0;if(c)s=m[e+2]+r+t,l=m[e+5]+r+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==r){const e=E(r);e.localOrigin=n.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+i;o.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),f=Math.min(f,s),p=Math.max(p,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=f,this._elevationRangeCacheMax=p}intersect(e,t,i,o,n,r,s){const a=e,{transform:l,componentData:c,intersectionGeometry:m}=a;return null!=n&&(n.localOrigin=l.position),m.intersect(t,i,o,n,c.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=h.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const p=f.count,g=this._computeVisibilityIndices(s,n,m,p);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange((e,t)=>(r+=i[t]-i[e],!0));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,()=>new Uint32Array(n.count+1));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void P().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void P().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)P().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&P().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=S.createVertex(i,35044,o.vertices.data),s=o.indices?S.createIndex(i,35044,o.indices):null,a=f(y(n)),l=new Uint16Array(o.vertices.count);for(let f=0;f<t.count;f++){const e=t.offsets[f],i=t.offsets[f+1],n=t.materialDataIndices[f];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=S.createVertex(i,35044,l.buffer),m=new j(e.transform,e.toMapSpace),h=new B(i,new Map([["geometry",new V(a,r)],["componentIndices",new V(w,c)]]),s),p=new b(h,U.TRIANGLES,n,null!=s),g={cameraDepthSquared:.5,gpuMemoryEstimate:r.usedMemory+c.usedMemory+(null!=s?s.usedMemory:0)};return new u(m,p,g)}_notifyDirty(){this._renderManager.notifyDirty()}}function N(e,t){return e===t?0:0===e?2:1}const k=s();export{I as ComponentObjectCollection};
5
+ import e from"../../../../../core/Logger.js";import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import i from"../../../../../core/PooledArray.js";import{isTypedArray as o}from"../../../../../core/typedArrayUtil.js";import{s as n}from"../../../../../chunks/vec32.js";import{clone as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as a}from"../../../../../geometry/support/Indices.js";import{c as l}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec33.js";import{encodeSymbolColor as m}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as h}from"../../../support/orientedBoundingBox.js";import{glLayout as f}from"../../../support/buffer/glUtil.js";import{ComponentData as p}from"./ComponentData.js";import{ComponentObject as g}from"./ComponentObject.js";import{IntersectionGeometry as d}from"./IntersectionGeometry.js";import{Renderable as u}from"./Renderable.js";import{RenderGeometry as b}from"./RenderGeometry.js";import{RenderSubmitSystem as v}from"./RenderSubmitSystem.js";import{createVertexBufferLayout as y}from"./SourceGeometry.js";import{UniformComponentParameters as _}from"./UniformComponentParameters.js";import{ComponentParametersVarying as M,ComponentParametersUniform as C,ComponentMaterial as j}from"./Material/ComponentMaterial.js";import{indexGlLayout as w}from"./Material/ComponentTechnique.js";import{encodeElevationOffset as x}from"./Material/shader/ComponentData.glsl.js";import{olidEnabled as O}from"../../effects/geometry/olidUtils.js";import{getVisibility as D,updatePickabilityWithCount as R}from"../../lib/ComponentUtils.js";import{assert as A}from"../../lib/Util.js";import{VertexArrayObject as B}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as E}from"../../lib/verticalOffsetUtils.js";import{BufferManager as H}from"../../lib/TextureBackedBuffer/BufferManager.js";import{BufferObject as S}from"../../../../webgl/BufferObject.js";import{PrimitiveType as U}from"../../../../webgl/enums.js";import{VertexBuffer as P}from"../../../../webgl/VertexBuffer.js";const V=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class I{constructor(e,t){this._renderManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new i,this._hidden=new i,this._renderSubmit=new v(this),this._renderManager.register(this._renderSubmit),this._componentBufferManager=new H(e.rctx,2+(O()?1:0))}destroy(){A(0===this._hidden.length&&0===this._visible.length,"ObjectCollection should be empty upon disposal"),this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy()}createObject(e){const t=e.geometry,i=new p(this._componentBufferManager,a(t.componentOffsets)),o=this._createRenderable(e,i),n=new d(this._viewingMode,t.positionData,i),r=new g(e.transform,e.toMapSpace,e.obb.clone(),i,o,n);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._notifyDirty()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._notifyDirty())}preSubmit(e){const t=e.camera.eye;this.visibleObjects.forAll(e=>e.renderable.meta.cameraDepthSquared=n(t,e.obb.center))}getMaterial(e){return e.renderable.material}updateMaterial(e,t){const i=e.renderable.material;t(i),i.dirty&&this._notifyDirty()}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._notifyDirty()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,i=t.componentData.visibility.componentCount;return{visible:i,invisible:t.componentData.count-i}}setComponentData(e,t){const i=e,{renderable:o,componentData:n}=i,r=o.material,s=n.materialDataBuffer,a=n.materialDataIndices,l=new _,c=s.textureBuffer,f=new Uint8Array(4),p=new Uint32Array(f.buffer);let g=0,d=0,u=0,b=n.verticalOffsets,v=1/0,y=-1/0,j=!1,w=!1,A=0;for(let h=0;h<n.count;h++){t(h,l),g+=+(l.externalColor[3]<1),d+=+(3===l.externalColorMixMode&&1===l.externalColor[3]),u+=+l.castShadows,m(l.externalColor,l.externalColorMixMode,f),f[2]=254&f[2]|+l.castShadows,c.setData(a[h],0,f[0],f[1],f[2],f[3]),j||=h>0&&A!==p[0],A=p[0],w||=0!==l.elevationOffset,w&&null==b&&(b=new Array(h).fill(0)),null!=b&&(b[h]=l.elevationOffset),v=Math.min(v,l.elevationOffset),y=Math.max(y,l.elevationOffset),x(l.elevationOffset,f),c.setData(a[h],1,f[0],f[1],f[2],f[3]);const e=l.olidColor;null!=e&&c.setData(a[h],2,e[0],e[1],e[2],e[3]),l.pickable!==D(n.pickability,h)&&R(n,h,l.pickable)}n.verticalOffsets=w?b:null,i.offsetObb=w?h(i.obb,v,y,this._viewingMode,i.offsetObb??i.obb.clone()):null,j||w||O()?(r.componentParameters=new M,r.componentParameters.castShadows=N(u,n.count),r.componentParameters.transparent=N(g,n.count),r.componentParameters.opaqueOverride=N(d,n.count),r.componentParameters.texture=c,c.updateTexture()):(r.componentParameters=new C,r.componentParameters.castShadows=l.castShadows?0:2,r.componentParameters.externalColor=l.externalColor,r.componentParameters.externalColorMixMode=l.externalColorMixMode),this._elevationRangeCacheVerticalOffset=NaN,this._notifyDirty()}getComponentAabb(e,t,i,o=!1){e.intersectionGeometry.getComponentAabb(t,i);const n=e,r=n.componentData.verticalOffsets;if(o||null==r)return i;const s=r[t];if(2===this._viewingMode||0===s)return i[2]+=s,i[5]+=s,i;const a=E(s);return a.localOrigin=n.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,o){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||o.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const n=e,r=n.componentData,s=r.count,a=r.verticalOffsets,l=n.intersectionGeometry,c=2===this._viewingMode,m=l.getComponentAabbs(),h=k;let f=1/0,p=-1/0;for(let g=0;g<s;g++){const e=6*g,r=a?.[g]??0;let s=1/0,l=-1/0;if(c)s=m[e+2]+r+t,l=m[e+5]+r+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==r){const e=E(r);e.localOrigin=n.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+i;o.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+l*l)-i)}o.expandElevationRangeValues(s,l),f=Math.min(f,s),p=Math.max(p,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=f,this._elevationRangeCacheMax=p}intersect(e,t,i,o,n,r,s){const a=e,{transform:l,componentData:c,intersectionGeometry:m}=a;return null!=n&&(n.localOrigin=l.position),m.intersect(t,i,o,n,c.verticalOffsets,l,r,s)}addEdges(e,t,i,o,n){const r=e,{indices:s,positions:a}=r.intersectionGeometry,l=r.componentData.offsets;return t.addComponentObject(r,a,s,l,i,o,n)}async extractEdgeInformation(e,t,i){const o=e,n=o.componentData.visibility;if(n.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:a}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),f=h.createBuffer(a.length/3);c(f.position.typedBuffer,a,f.position.typedBufferStride,3),l(f.position,f.position,o.transform.rotationScale),this._setComponentIndices(f.componentIndex,s,m);const p=f.count,g=this._computeVisibilityIndices(s,n,m,p);return{origin:r(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:g,indicesLength:g.length,skipDeduplicate:!0,data:f,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let o=0;for(let n=0;n<i.length-1;n++){const r=i[n],s=i[n+1];for(let i=r;i<s;i++){const n=t?t[i]:i;e.set(n,o)}o++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange((e,t)=>(r+=i[t]-i[e],!0));const s=o(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange((t,o)=>{const n=i[t],r=i[o];for(let i=n;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addComponentHighlight(e,i,o){const n=e.componentData,r=t(n.componentHighlights,o,()=>new Uint32Array(n.count+1));{const e=this._activeHighlightOptions.get(o)??0;this._activeHighlightOptions.set(o,e+1)}0===r[i]++&&(n.markHighlightsDirty(),this._notifyDirty()),r[n.count]++}removeComponentHighlight(e,t,i){const{componentData:o}=e,n=o.componentHighlights.get(i);if(void 0===n)return void V().warn("Removing non-existing highlight.");const r=n[t];if(0===r)return void V().warn("Removing non-existing highlight.");this._removeActiveHighlight(i);const s=n[o.count];if(r>1)return n[t]=r-1,void(n[o.count]=s-1);n[t]=0,1===s?o.componentHighlights.delete(i):n[o.count]=s-1,o.markHighlightsDirty(),this._notifyDirty()}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)V().warn("Removing non-existing highlight.");else{const o=i-t;o<0&&V().warn("Removing non-existing highlight."),o<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,o)}}clearHighlights(e){const{componentData:t}=e,{componentHighlights:i}=t;if(i.size>0){for(const e of i)this._removeActiveHighlight(e[0],e[1][t.count]);i.clear(),t.markHighlightsDirty(),this._notifyDirty()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t){const i=this._renderManager.rctx,o=e.geometry,n=o.vertices.layoutParameters,r=f(y(n)),s=new P(i,r,o.vertices.data),a=o.indices?S.createIndex(i,35044,o.indices):null,l=new Uint16Array(o.vertices.count);for(let f=0;f<t.count;f++){const e=t.offsets[f],i=t.offsets[f+1],n=t.materialDataIndices[f];if(null!=o.indices)for(let t=e;t<i;t++){l[o.indices[t]]=n}else for(let t=e;t<i;t++)l[t]=n}const c=new P(i,w,l.buffer),m=new j(e.transform,e.toMapSpace),h=new B(i,new Map([["geometry",s],["componentIndices",c]]),a),p=new b(h,U.TRIANGLES,n,null!=a),g={cameraDepthSquared:.5,gpuMemoryEstimate:s.usedMemory+c.usedMemory+(null!=a?a.usedMemory:0)};return new u(m,p,g)}_notifyDirty(){this._renderManager.notifyDirty()}}function N(e,t){return e===t?0:0===e?2:1}const k=s();export{I as ComponentObjectCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{glLayout as e}from"../../../../support/buffer/glUtil.js";import{newLayout as r}from"../../../../support/buffer/InterleavedLayout.js";import{createVertexBufferLayout as t}from"../SourceGeometry.js";import{C as o}from"../../../../../../chunks/ComponentShader.glsl.js";import{isColorOrColorEmission as n}from"../../../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as s}from"../../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l,depthOnlyOutputBuffersOr as i}from"../../../core/shaderTechnique/ShaderTechnique.js";import{OITPolygonOffset as u,oitDepthTest as d,blending as a,getDrawBuffers as c}from"../../../lib/OrderIndependentTransparency.js";import{replaceBitWhenDepthTestPasses as p,stencilBaseAllZerosParams as m,stencilWriteMaskOn as f}from"../../../lib/StencilUtils.js";import{makePipelineState as h,defaultColorWrite as b,defaultDepthWrite as j,cullingParams as g,premultipliedAlpha as S}from"../../../../../webgl/renderState.js";import{fromLayouts as y}from"../../../../../webgl/VertexAttributeLocations.js";class O extends l{constructor(r,n){super(r,n,new s(o,()=>import("./shader/ComponentShader.glsl.js")),y([e(t(n)),T]))}initializePipeline(e){const{integratedMeshMode:r,output:t,blendingEnabled:o,cullFace:s,hasOccludees:l,hasPolygonOffset:y,oitPass:O,renderOccluded:T}=e,w=0!==r,x=0===O,q=2===O;return h({blending:T?S:n(t)&&o?a(O):null,culling:g(s),depthTest:T?null:{func:d(O)},depthWrite:T||!x&&!q?null:j,drawBuffers:i(t,c(O,t)),colorWrite:b,stencilWrite:!T&&w||l?f:null,stencilTest:w?p(1):l?m:null,polygonOffset:x||q?y?{factor:2,units:2}:null:u})}}const T=e(r().u16("componentIndex"));export{O as ComponentTechnique,T as componentIndexGlLayout};
5
+ import{glLayout as e}from"../../../../support/buffer/glUtil.js";import{newLayout as r}from"../../../../support/buffer/InterleavedLayout.js";import{createVertexBufferLayout as t}from"../SourceGeometry.js";import{C as o}from"../../../../../../chunks/ComponentShader.glsl.js";import{isColorOrColorEmission as n}from"../../../core/shaderLibrary/ShaderOutput.js";import{ReloadableShaderModule as s}from"../../../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l,depthOnlyOutputBuffersOr as i}from"../../../core/shaderTechnique/ShaderTechnique.js";import{OITPolygonOffset as u,oitDepthTest as d,blending as a,getDrawBuffers as c}from"../../../lib/OrderIndependentTransparency.js";import{replaceBitWhenDepthTestPasses as p,stencilBaseAllZerosParams as m,stencilWriteMaskOn as f}from"../../../lib/StencilUtils.js";import{makePipelineState as h,defaultColorWrite as b,defaultDepthWrite as j,cullingParams as g,premultipliedAlpha as S}from"../../../../../webgl/renderState.js";import{fromLayouts as y}from"../../../../../webgl/VertexAttributeLocations.js";class O extends l{constructor(r,n){super(r,n,new s(o,()=>import("./shader/ComponentShader.glsl.js")),y([e(t(n)),T]))}initializePipeline(e){const{integratedMeshMode:r,output:t,blendingEnabled:o,cullFace:s,hasOccludees:l,hasPolygonOffset:y,oitPass:O,renderOccluded:T}=e,w=0!==r,x=0===O,q=2===O;return h({blending:T?S:n(t)&&o?a(O):null,culling:g(s),depthTest:T?null:{func:d(O)},depthWrite:T||!x&&!q?null:j,drawBuffers:i(t,c(O,t)),colorWrite:b,stencilWrite:!T&&w||l?f:null,stencilTest:w?p(1):l?m:null,polygonOffset:x||q?y?{factor:2,units:2}:null:u})}}const T=e(r().u16("componentIndex"));export{O as ComponentTechnique,T as indexGlLayout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Accessor.js";const r={required:[]},s={required:[2]};class t extends e{precompile(e){return!!this.acquireTechniques(e)}consumes(){return r}get usedMemory(){return 0}get renderOccludedFlags(){return 1}get isDecoration(){return!1}get readyToRun(){return!1}modify(e,r){}get numGeometries(){return 0}get hasOccludees(){return!1}get hasEmissions(){return!1}forEachGeometry(e){}}class n extends t{}class u extends t{}export{u as AsyncRenderPlugin,s as ConsumesDepth,r as ConsumesNone,n as SyncRenderPlugin};
5
+ import e from"../../../../core/Accessor.js";const r={required:[]},s={required:[2]};class t extends e{precompile(e){return!!this.acquireTechniques(e)}consumes(){return r}get usedMemory(){return 0}get renderOccludedFlags(){return 1}get isDecoration(){return!1}get readyToRun(){return!1}get numGeometries(){return 0}get hasOccludees(){return!1}get hasEmissions(){return!1}forEachGeometry(e){}}class n extends t{}class u extends t{}export{u as AsyncRenderPlugin,s as ConsumesDepth,r as ConsumesNone,n as SyncRenderPlugin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{Pos2 as t}from"../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as e}from"../lib/VertexArrayObject.js";import{BufferObject as o}from"../../../webgl/BufferObject.js";import{PrimitiveType as s}from"../../../webgl/enums.js";import{VertexBuffer as i}from"../../../webgl/VertexBuffer.js";class a{constructor(r){this._rctx=r,this._vao=m(r)}destroy(){this._vao=r(this._vao)}draw(){null!=this._vao&&(this._rctx.bindVAO(this._vao),this._rctx.drawArrays(s.TRIANGLES,0,3))}get test(){}}function m(r){const s=new Float32Array([-1,-1,3,-1,-1,3]);return new e(r,new i(t,o.createVertex(r,35044,s)))}export{a as ScreenSpaceGeometry};
5
+ import"../../../../core/has.js";import{disposeMaybe as r}from"../../../../core/maybe.js";import{Pos2 as t}from"../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as o}from"../lib/VertexArrayObject.js";import{PrimitiveType as e}from"../../../webgl/enums.js";import{VertexBuffer as s}from"../../../webgl/VertexBuffer.js";class i{constructor(r){this._rctx=r,this._vao=a(r)}destroy(){this._vao=r(this._vao)}draw(){null!=this._vao&&(this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.TRIANGLES,0,3))}get test(){}}function a(r){const e=new Float32Array([-1,-1,3,-1,-1,3]);return new o(r,new s(r,t,e))}export{i as ScreenSpaceGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as s}from"../../../../../core/accessorSupport/decorators/subclass.js";import{RenderCategory as r,InternalRenderCategory as o}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{FocusAreaMaskTechnique as n}from"./FocusAreaMaskTechnique.js";import{Pos3 as a}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{F as h}from"../../../../../chunks/FocusAreaMask.glsl.js";import{BufferObject as p}from"../../../../webgl/BufferObject.js";import{DepthStencilAttachment as l,PrimitiveType as u}from"../../../../webgl/enums.js";import{noParameters as m}from"../../../../webgl/NoParameters.js";import{VertexBuffer as d}from"../../../../webgl/VertexBuffer.js";let f=class extends i{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=o.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new h}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(n)}render(e){const t=this.techniques.get(n),s=this.bindParameters,i=s.camera,a=i.fullViewport[2],c=i.fullViewport[3];if(!t.compiled||!this._vaos)return void this.requestRender();const h=e.find(({name:e})=>e===r.TRANSPARENT),p=this.renderingContext,d=this.fboCache.acquire(a,c,o.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(11),p.blitFramebuffer(h.fbo,d.fbo,256)):d.attachDepth(h.getAttachment(l)),p.bindFramebuffer(d.fbo),p.setClearColor(0,0,0,1),p.clear(17408),p.setViewport(0,0,a,c);const f=p.bindTechnique(t,s);p.setFaceCullingEnabled(!1),p.setStencilTestEnabled(!0),p.setStencilOpSeparate(1028,7680,34055,7680),p.setStencilOpSeparate(1029,7680,34056,7680),p.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(s,m,this._maskParameters),p.bindVAO(e),p.setDepthTestEnabled(!0),p.setStencilWriteMask(255),p.setStencilFunction(519,0,255),p.setColorMask(!1,!1,!1,!1),p.drawArrays(u.TRIANGLES,0,t),p.setDepthTestEnabled(!1),p.setStencilWriteMask(0),p.setStencilFunction(517,0,255),p.setColorMask(!0,!0,!0,!0),p.drawArrays(u.TRIANGLES,0,t)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const t=new Array;let s=0,r=0;e.geometryVolumes.forEach(e=>{const o=e.indicesBottom;s+=o.length;for(let s=0;s<o.length;s++)t.push(e.positions[3*(o[s]-1)]),t.push(e.positions[3*(o[s]-1)+1]),t.push(e.positions[3*(o[s]-1)+2]);const i=e.indicesExtruded;r+=i.length;for(let s=0;s<i.length;s++)t.push(e.positions[3*i[s]]),t.push(e.positions[3*i[s]+1]),t.push(e.positions[3*i[s]+2])});const o=new c(this.renderingContext,new d(a,p.createVertex(this.renderingContext,35044,new Float32Array(t))));this._vaos.push(o),this._counts.push(s+r),this._origins.push(e.origin)}),this.requestRender()}};e([t()],f.prototype,"consumes",void 0),e([t()],f.prototype,"produces",void 0),e([t({constructOnly:!0})],f.prototype,"focusAreasView",void 0),f=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],f);export{f as FocusAreaMaskNode};
5
+ import{__decorate as e}from"tslib";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{RenderCategory as r,InternalRenderCategory as o}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{FocusAreaMaskTechnique as n}from"./FocusAreaMaskTechnique.js";import{Pos3 as a}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{F as h}from"../../../../../chunks/FocusAreaMask.glsl.js";import{DepthStencilAttachment as p,PrimitiveType as l}from"../../../../webgl/enums.js";import{noParameters as u}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends i{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=o.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new h}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(n)}render(e){const s=this.techniques.get(n),t=this.bindParameters,i=t.camera,a=i.fullViewport[2],c=i.fullViewport[3];if(!s.compiled||!this._vaos)return void this.requestRender();const h=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(a,c,o.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(11),m.blitFramebuffer(h.fbo,d.fbo,256)):d.attachDepth(h.getAttachment(p)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,a,c);const f=m.bindTechnique(s,t);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],s=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(t,u,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(l.TRIANGLES,0,s),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(l.TRIANGLES,0,s)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const s=new Array;let t=0,r=0;e.geometryVolumes.forEach(e=>{const o=e.indicesBottom;t+=o.length;for(let t=0;t<o.length;t++)s.push(e.positions[3*(o[t]-1)]),s.push(e.positions[3*(o[t]-1)+1]),s.push(e.positions[3*(o[t]-1)+2]);const i=e.indicesExtruded;r+=i.length;for(let t=0;t<i.length;t++)s.push(e.positions[3*i[t]]),s.push(e.positions[3*i[t]+1]),s.push(e.positions[3*i[t]+2])});const o=new c(this.renderingContext,new m(this.renderingContext,a,new Float32Array(s)));this._vaos.push(o),this._counts.push(t+r),this._origins.push(e.origin)}),this.requestRender()}};e([s()],d.prototype,"consumes",void 0),e([s()],d.prototype,"produces",void 0),e([s({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([t("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as c}from"./HighlightBlurTechnique.js";import{HighlightDownsampleTechnique as u}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as m}from"./HighlightToSingleTechnique.js";import{NoVertex as d}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{H as b}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as w,g as x}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{PrimitiveType as C,DataType as _}from"../../../../webgl/enums.js";import{Texture as v}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let q=class extends a{constructor(){super(...arguments),this.produces=l.HIGHLIGHTS,this.consumes={required:[l.HIGHLIGHTS,"highlights"]},this._downsampleDrawParameters=new w,this._passParameters=new p,this._highlightBlurDrawParameters=new b,this._grid=new P}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new v(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(O(this.view.state.highlights)),this.requestRender(1)}precompile(){this.techniques.precompile(u),this.techniques.precompile(m),this.techniques.precompile(c),this.techniques.precompile(g)}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHTS),{techniques:r,bindParameters:i}=this;if(!i.decorations)return t;if(!r.get(u).compiled)return this.requestRender(1),t;const s=e.find(({name:e})=>"highlights"===e).getTexture();return this._renderHighlightPostprocess(s,t),t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(u),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(C.TRIANGLES,6,_.UNSIGNED_BYTE,0,t)}_renderHighlightPostprocess(e,t){const{fboCache:r,techniques:i,bindParameters:s,_passParameters:o,renderingContext:h}=this,l=i.get(m),a=i.get(c),u=i.get(g);if(!u.compiled||!a.compiled||!l.compiled)return void this.requestRender(1);o.highlightTexture=e;const p=this._prepareAndDownSample(e),{width:d,height:f}=e.descriptor;o.highlightTexture=e;const{camera:b}=s,{fullWidth:w,fullHeight:x,pixelRatio:T,fullViewport:C}=b,_=Math.ceil(w/T),v=Math.ceil(x/T),{_highlightBlurDrawParameters:j}=this,H=this.view.stage.renderView.renderer,{highlights:q}=s;for(let g=0;g<q.length;++g){const{name:e}=q[g];if(!H.hasHighlight(e))continue;o.highlightLevel=g,h.setClearColor(0,0,0,0);const i=r.acquire(d,f,"single highlight",2);h.bindFramebuffer(i.fbo),h.setViewport(0,0,d,f),h.clear(16384),h.bindTechnique(l,s,o),this._renderGrid(p),j.blurInput=i.getTexture(),n(j.blurSize,1/_,0);const c=r.acquire(_,v,"single highlight blur h",2);h.unbindTexture(c.fbo?.colorTexture),h.bindFramebuffer(c.fbo),h.setViewport(0,0,_,v),h.clear(16384),h.bindTechnique(a,s,o,j),this._renderGrid(p),i.release(),n(j.blurSize,0,1/v),o.highlightBlurTexture=c.getTexture(),h.bindFramebuffer(t.fbo),h.setViewport4fv(C),h.bindTechnique(u,s,o,j),this._renderGrid(p),c.release()}o.coverageTexture=o.highlightTexture=null}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/x),t.verticalCellCount=Math.ceil(i/x),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,S);t.vao=new f(s,new H(d,T.createVertex(s,35044)),o)}_gridComputeCoverage(e,t){const r=this.renderingContext,i=this._grid,s=t.descriptor,o=Math.ceil(s.width/x),h=Math.ceil(s.height/x);this._downsampleDrawParameters.input=t;const{highlights:n}=this.bindParameters;i.coverage?.release();const l=this.fboCache.acquire(o,h,"highlight coverage",n.length>I?3:1);return i.coverage=l,r.bindFramebuffer(l.fbo),r.bindTechnique(e,this.bindParameters,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,h),r.screen.draw(),i}get test(){}};e([o()],q.prototype,"produces",void 0),e([o()],q.prototype,"consumes",void 0),q=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],q);class P{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function O(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let y=0;function D(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return y+++(t>=0?0:1)}const S=new Uint8Array([0,1,2,2,1,3]);function G(e,t,r,i,s,o=0){const{highlights:h}=i,l=h.length>1?t.acquire(r.width,r.height,"highlight mix",h.length>I?3:1):null,{gl:a}=e;if(l){const t=e.getBoundFramebufferObject();e.bindFramebuffer(l.fbo),a.clearBufferuiv(a.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const g=l?.getTexture();i.highlightMixTexture=g,n(i.highlightMixOrigin,o,0),h.forEach((t,h)=>{if(h>0){const t=v.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(g,t),e.setActiveTexture(t),a.copyTexSubImage2D(3553,0,0,0,o,0,r.width,r.height),e.bindTexture(null,t)}e.clear(256),i.highlightLevel=h,s()}),i.highlightLevel=null,i.highlightMixTexture=null,l?.release()}const I=4;export{q as Highlight,I as maxHighlightsPerChannel,G as renderHighlightBuffer,D as trackHighlightOptions};
5
+ import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as c}from"./HighlightBlurTechnique.js";import{HighlightDownsampleTechnique as u}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as p}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as m}from"./HighlightToSingleTechnique.js";import{NoVertex as d}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{H as b}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as w,g as x}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{PrimitiveType as C,DataType as _}from"../../../../webgl/enums.js";import{Texture as v}from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let q=class extends a{constructor(){super(...arguments),this.produces=l.HIGHLIGHTS,this.consumes={required:[l.HIGHLIGHTS,"highlights"]},this._downsampleDrawParameters=new w,this._passParameters=new p,this._highlightBlurDrawParameters=new b,this._grid=new P}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new v(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(O(this.view.state.highlights)),this.requestRender(1)}precompile(){this.techniques.precompile(u),this.techniques.precompile(m),this.techniques.precompile(c),this.techniques.precompile(g)}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHTS),{techniques:r,bindParameters:i}=this;if(!i.decorations)return t;if(!r.get(u).compiled)return this.requestRender(1),t;const s=e.find(({name:e})=>"highlights"===e).getTexture();return this._renderHighlightPostprocess(s,t),t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(u),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(C.TRIANGLES,6,_.UNSIGNED_BYTE,0,t)}_renderHighlightPostprocess(e,t){const{fboCache:r,techniques:i,bindParameters:s,_passParameters:o,renderingContext:h}=this,l=i.get(m),a=i.get(c),u=i.get(g);if(!u.compiled||!a.compiled||!l.compiled)return void this.requestRender(1);o.highlightTexture=e;const p=this._prepareAndDownSample(e),{width:d,height:f}=e.descriptor;o.highlightTexture=e;const{camera:b}=s,{fullWidth:w,fullHeight:x,pixelRatio:T,fullViewport:C}=b,_=Math.ceil(w/T),v=Math.ceil(x/T),{_highlightBlurDrawParameters:j}=this,H=this.view.stage.renderView.renderer,{highlights:q}=s;for(let g=0;g<q.length;++g){const{name:e}=q[g];if(!H.hasHighlight(e))continue;o.highlightLevel=g,h.setClearColor(0,0,0,0);const i=r.acquire(d,f,"single highlight",2);h.bindFramebuffer(i.fbo),h.setViewport(0,0,d,f),h.clear(16384),h.bindTechnique(l,s,o),this._renderGrid(p),j.blurInput=i.getTexture(),n(j.blurSize,1/_,0);const c=r.acquire(_,v,"single highlight blur h",2);h.unbindTexture(c.fbo?.colorTexture),h.bindFramebuffer(c.fbo),h.setViewport(0,0,_,v),h.clear(16384),h.bindTechnique(a,s,o,j),this._renderGrid(p),i.release(),n(j.blurSize,0,1/v),o.highlightBlurTexture=c.getTexture(),h.bindFramebuffer(t.fbo),h.setViewport4fv(C),h.bindTechnique(u,s,o,j),this._renderGrid(p),c.release()}o.coverageTexture=o.highlightTexture=null}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/x),t.verticalCellCount=Math.ceil(i/x),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,S);t.vao=new f(s,new H(s,d),o)}_gridComputeCoverage(e,t){const r=this.renderingContext,i=this._grid,s=t.descriptor,o=Math.ceil(s.width/x),h=Math.ceil(s.height/x);this._downsampleDrawParameters.input=t;const{highlights:n}=this.bindParameters;i.coverage?.release();const l=this.fboCache.acquire(o,h,"highlight coverage",n.length>I?3:1);return i.coverage=l,r.bindFramebuffer(l.fbo),r.bindTechnique(e,this.bindParameters,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,h),r.screen.draw(),i}get test(){}};e([o()],q.prototype,"produces",void 0),e([o()],q.prototype,"consumes",void 0),q=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],q);class P{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function O(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let y=0;function D(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return y+++(t>=0?0:1)}const S=new Uint8Array([0,1,2,2,1,3]);function G(e,t,r,i,s,o=0){const{highlights:h}=i,l=h.length>1?t.acquire(r.width,r.height,"highlight mix",h.length>I?3:1):null,{gl:a}=e;if(l){const t=e.getBoundFramebufferObject();e.bindFramebuffer(l.fbo),a.clearBufferuiv(a.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const g=l?.getTexture();i.highlightMixTexture=g,n(i.highlightMixOrigin,o,0),h.forEach((t,h)=>{if(h>0){const t=v.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(g,t),e.setActiveTexture(t),a.copyTexSubImage2D(3553,0,0,0,o,0,r.width,r.height),e.bindTexture(null,t)}e.clear(256),i.highlightLevel=h,s()}),i.highlightLevel=null,i.highlightMixTexture=null,l?.release()}const I=4;export{q as Highlight,I as maxHighlightsPerChannel,G as renderHighlightBuffer,D as trackHighlightOptions};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{i as e,d as t}from"../../../../../chunks/vec32.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{glLayout as o}from"../../../support/buffer/glUtil.js";import{newLayout as i}from"../../../support/buffer/InterleavedLayout.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{BufferObject as n}from"../../../../webgl/BufferObject.js";import{PrimitiveType as u}from"../../../../webgl/enums.js";import{VertexBuffer as a}from"../../../../webgl/VertexBuffer.js";class c{constructor(e){this._renderCoordsHelper=e,this._origin=r(),this._dirty=!1,this._count=0}set vertices(e){const t=s(3*e.length);let r=0;for(const s of e)t[r++]=s[0],t[r++]=s[1],t[r++]=s[2];this.buffers=[t]}set buffers(t){if(this._buffers=t,this._buffers.length>0){const t=this._buffers[0],r=3*Math.floor(t.length/3/2);e(this._origin,t[r],t[r+1],t[r+2])}else e(this._origin,0,0,0);this._dirty=!0}get origin(){return this._origin}draw(e){const t=this._ensureVAO(e);null!=t&&(e.bindVAO(t),e.drawArrays(u.TRIANGLES,0,this._count))}dispose(){null!=this._vao&&this._vao.dispose()}get _layout(){return 1===this._renderCoordsHelper.viewingMode?d:p}_ensureVAO(e){return null==this._buffers?null:(this._vao??=this._createVAO(e,this._buffers),this._ensureVertexData(this._vao,this._buffers),this._vao)}_createVAO(e,t){const r=this._createDataBuffer(t);return this._dirty=!1,new f(e,new a(o(this._layout),n.createVertex(e,35044,r)))}_ensureVertexData(e,t){if(!this._dirty)return;const r=this._createDataBuffer(t);e.buffer()?.buffer.setData(r),this._dirty=!1}_createDataBuffer(r){const s=r.reduce((e,t)=>e+l(t),0);this._count=s;const o=this._layout.createBuffer(s),i=this._origin;let f=0,n=0;const u="startUp"in o?this._setUpVectors.bind(this,o):void 0;for(const a of r){for(let r=0;r<a.length;r+=3){const s=e(_,a[r],a[r+1],a[r+2]);0===r?n=this._renderCoordsHelper.getAltitude(s):this._renderCoordsHelper.setAltitude(s,n);const c=f+2*r;u?.(r,c,a,s);const l=t(_,s,i);if(r<a.length-3){for(let e=0;e<6;e++)o.start.setVec(c+e,l);o.extrude.setValues(c,0,-1),o.extrude.setValues(c+1,1,-1),o.extrude.setValues(c+2,1,1),o.extrude.setValues(c+3,0,-1),o.extrude.setValues(c+4,1,1),o.extrude.setValues(c+5,0,1)}if(r>0)for(let e=-6;e<0;e++)o.end.setVec(c+e,l)}f+=l(a)}return o.buffer}_setUpVectors(e,t,r,s,o){const i=this._renderCoordsHelper.worldUpAtPosition(o,h);if(t<s.length-3)for(let f=0;f<6;f++)e.startUp.setVec(r+f,i);if(t>0)for(let f=-6;f<0;f++)e.endUp.setVec(r+f,i)}}function l(e){return 3*(2*(e.length/3-1))}const h=r(),_=r(),d=i().vec3f("start").vec3f("end").vec2f("extrude").vec3f("startUp").vec3f("endUp"),p=i().vec3f("start").vec3f("end").vec2f("extrude");export{c as LaserlinePathData};
5
+ import{i as e,d as t}from"../../../../../chunks/vec32.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as s}from"../../../../../geometry/support/DoubleArray.js";import{glLayout as i}from"../../../support/buffer/glUtil.js";import{newLayout as o}from"../../../support/buffer/InterleavedLayout.js";import{VertexArrayObject as f}from"../../lib/VertexArrayObject.js";import{PrimitiveType as n}from"../../../../webgl/enums.js";import{VertexBuffer as u}from"../../../../webgl/VertexBuffer.js";class a{constructor(e){this._renderCoordsHelper=e,this._origin=r(),this._dirty=!1,this._count=0}set vertices(e){const t=s(3*e.length);let r=0;for(const s of e)t[r++]=s[0],t[r++]=s[1],t[r++]=s[2];this.buffers=[t]}set buffers(t){if(this._buffers=t,this._buffers.length>0){const t=this._buffers[0],r=3*Math.floor(t.length/3/2);e(this._origin,t[r],t[r+1],t[r+2])}else e(this._origin,0,0,0);this._dirty=!0}get origin(){return this._origin}draw(e){const t=this._ensureVAO(e);null!=t&&(e.bindVAO(t),e.drawArrays(n.TRIANGLES,0,this._count))}dispose(){null!=this._vao&&this._vao.dispose()}get _layout(){return 1===this._renderCoordsHelper.viewingMode?_:d}_ensureVAO(e){return null==this._buffers?null:(this._vao??=this._createVAO(e,this._buffers),this._ensureVertexData(this._vao,this._buffers),this._vao)}_createVAO(e,t){const r=this._createDataBuffer(t);return this._dirty=!1,new f(e,new u(e,i(this._layout),r))}_ensureVertexData(e,t){if(!this._dirty)return;const r=this._createDataBuffer(t);e.buffer()?.setData(r),this._dirty=!1}_createDataBuffer(r){const s=r.reduce((e,t)=>e+l(t),0);this._count=s;const i=this._layout.createBuffer(s),o=this._origin;let f=0,n=0;const u="startUp"in i?this._setUpVectors.bind(this,i):void 0;for(const a of r){for(let r=0;r<a.length;r+=3){const s=e(h,a[r],a[r+1],a[r+2]);0===r?n=this._renderCoordsHelper.getAltitude(s):this._renderCoordsHelper.setAltitude(s,n);const l=f+2*r;u?.(r,l,a,s);const c=t(h,s,o);if(r<a.length-3){for(let e=0;e<6;e++)i.start.setVec(l+e,c);i.extrude.setValues(l,0,-1),i.extrude.setValues(l+1,1,-1),i.extrude.setValues(l+2,1,1),i.extrude.setValues(l+3,0,-1),i.extrude.setValues(l+4,1,1),i.extrude.setValues(l+5,0,1)}if(r>0)for(let e=-6;e<0;e++)i.end.setVec(l+e,c)}f+=l(a)}return i.buffer}_setUpVectors(e,t,r,s,i){const o=this._renderCoordsHelper.worldUpAtPosition(i,c);if(t<s.length-3)for(let f=0;f<6;f++)e.startUp.setVec(r+f,o);if(t>0)for(let f=-6;f<0;f++)e.endUp.setVec(r+f,o)}}function l(e){return 3*(2*(e.length/3-1))}const c=r(),h=r(),_=o().vec3f("start").vec3f("end").vec2f("extrude").vec3f("startUp").vec3f("endUp"),d=o().vec3f("start").vec3f("end").vec2f("extrude");export{a as LaserlinePathData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{fetchAsset as e}from"../../../../../assets.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Error.js";import i from"../../../../../core/Logger.js";import{abortMaybe as a,disposeMaybe as o}from"../../../../../core/maybe.js";import{isAbortError as n}from"../../../../../core/promiseUtils.js";import{watch as f,initial as c,syncAndInitial as m}from"../../../../../core/reactiveUtils.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,rotateZ as l,multiply as d}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{fromValues as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as b}from"../../../webgl.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{OpaqueEnvironment as g}from"../OpaqueEnvironment.js";import{StarPassParameters as w,StarsTechnique as j,layout as v}from"./StarsTechnique.js";import{VertexArrayObject as P}from"../../lib/VertexArrayObject.js";import{BufferObject as y}from"../../../../webgl/BufferObject.js";import{PrimitiveType as D}from"../../../../webgl/enums.js";import{VertexBuffer as T}from"../../../../webgl/VertexBuffer.js";let M=class extends g{constructor(){super(...arguments),this._numPoints=0,this._passParameters=new w}initialize(){this.addHandles([f(()=>this.view.environment.starsEnabled,t=>t?this._enable():this._disable(),c),f(()=>"virtual"===this.view.environment.lighting.type?null:this.view.environment.lighting.date,t=>this._update(t),m)])}_enable(){super._enable(),this._loadDataTask=this._createLoadDataTask()}get loading(){return!!this._loadDataTask&&!this._loadDataTask.finished}destroy(){this._loadDataTask=a(this._loadDataTask),this._numPoints=0,this._vao=o(this._vao),this._starData=null}precompile(){this.techniques.precompile(j)}render(t){const e=t.find(({name:t})=>t===b.OPAQUE_ENVIRONMENT),s=this.renderingContext;if(this.loading)return this.requestRender(1),e;if(!this._starData)return e;this._vao??=this._ensureResources(this._starData,s);const r=this.techniques.get(j);return r.compiled?(s.bindTechnique(r,this.bindParameters,this._passParameters),s.bindVAO(this._vao),s.drawArrays(D.POINTS,0,this._numPoints),e):(this.requestRender(1),e)}_ensureResources(t,e){this._numPoints=t.byteLength/E;return q(e,new Float32Array(t,0,2*this._numPoints),new Uint8Array(t,2*this._numPoints*4,this._numPoints),this._numPoints)}_update(t){if(!t)return;const e=(t.getHours()/12+t.getMinutes()/60*(2/24)+t.getSeconds()/60*(2/1440)-.9972222)%2,s=2*x(t),r=u(this._passParameters.modelMatrix,A);l(r,r,-s*Math.PI),d(r,O,r),l(r,r,-e*Math.PI),this.requestRender(1)}_createLoadDataTask(){if(this._starData)return null;const t=s(async t=>{const{data:s}=await e("esri/views/3d/environment/resources/stars.wsv",{responseType:"array-buffer",signal:t});R(s),this._starData=s});return t.promise.catch(t=>{n(t)||i.getLogger(this).error(t)}).then(()=>{this.destroyed||this.requestRender(1)}),t}};function q(t,e,s,r){const i=v.createBuffer(r),a=i.position,o=i.color,n=i.size;for(let f=0;f<r;f++){const t=e[2*f],r=e[2*f+1];a.set(f,0,-Math.cos(t)*Math.sin(r)),a.set(f,1,-Math.sin(t)*Math.sin(r)),a.set(f,2,-Math.cos(r));const i=I(s[f]),c=k(L[i[1]]);o.set(f,0,255*c[0]),o.set(f,1,255*c[1]),o.set(f,2,255*c[2]),o.set(f,3,255),n.set(f,i[0])}return new P(t,new T(_(v),y.createVertex(t,35044,i.buffer)))}function x(t){const e=t,s=new Date(t.getFullYear(),0,1,11,58,56);return(+e-+s)/(+new Date(t.getFullYear()+1,0,1,11,58,55)-+s)}function R(t){if(!t)throw new r("stars:no-data-received","Failed to create stars because star catalogue is missing");const e=t.byteLength/E;if(e%1!=0||e>5e4||e<5e3)throw new r("stars:invalid-data","Failed to create stars because star catalogue data is invalid")}function k(t){return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function I(t){return t>=192?[2.9,t-192]:t>=160?[2.5,t-160]:t>=128?[2,t-128]:t>=96?[1.5,t-96]:t>=64?[1,t-64]:t>=32?[.7,t-32]:[.4,t]}M=t([h("esri.views.3d.webgl-engine.effects.stars.Stars")],M);const L=["9bb2ff","9eb5ff","aabfff","bbccff","ccd8ff ","dae2ff","e4e9ff","eeefff","f8f6ff","fff9fb","fff5ef","fff1e5","ffeddb","ffe9d2","ffe6ca","ffe3c3","ffe0bb","ffddb4","ffdaad","ffd6a5","ffd29c","ffcc8f","ffc178","ffa94b","ff7b00"],O=p(1,0,0,0,0,.9174771405229186,.39778850739794974,0,0,-.39778850739794974,.9174771405229186,0,0,0,0,1),A=p(1,0,0,0,0,.9174771405229186,-.39778850739794974,0,0,.39778850739794974,.9174771405229186,0,0,0,0,1),E=9;export{M as Stars};
5
+ import{__decorate as t}from"tslib";import{fetchAsset as e}from"../../../../../assets.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Error.js";import i from"../../../../../core/Logger.js";import{abortMaybe as a,disposeMaybe as o}from"../../../../../core/maybe.js";import{isAbortError as n}from"../../../../../core/promiseUtils.js";import{watch as f,initial as c,syncAndInitial as m}from"../../../../../core/reactiveUtils.js";import"../../../../../core/has.js";import"../../../../../core/RandomLCG.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,rotateZ as l,multiply as d}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{fromValues as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as b}from"../../../webgl.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{OpaqueEnvironment as g}from"../OpaqueEnvironment.js";import{StarPassParameters as w,StarsTechnique as j,layout as v}from"./StarsTechnique.js";import{VertexArrayObject as P}from"../../lib/VertexArrayObject.js";import{PrimitiveType as y}from"../../../../webgl/enums.js";import{VertexBuffer as D}from"../../../../webgl/VertexBuffer.js";let T=class extends g{constructor(){super(...arguments),this._numPoints=0,this._passParameters=new w}initialize(){this.addHandles([f(()=>this.view.environment.starsEnabled,t=>t?this._enable():this._disable(),c),f(()=>"virtual"===this.view.environment.lighting.type?null:this.view.environment.lighting.date,t=>this._update(t),m)])}_enable(){super._enable(),this._loadDataTask=this._createLoadDataTask()}get loading(){return!!this._loadDataTask&&!this._loadDataTask.finished}destroy(){this._loadDataTask=a(this._loadDataTask),this._numPoints=0,this._vao=o(this._vao),this._starData=null}precompile(){this.techniques.precompile(j)}render(t){const e=t.find(({name:t})=>t===b.OPAQUE_ENVIRONMENT),s=this.renderingContext;if(this.loading)return this.requestRender(1),e;if(!this._starData)return e;this._vao??=this._ensureResources(this._starData,s);const r=this.techniques.get(j);return r.compiled?(s.bindTechnique(r,this.bindParameters,this._passParameters),s.bindVAO(this._vao),s.drawArrays(y.POINTS,0,this._numPoints),e):(this.requestRender(1),e)}_ensureResources(t,e){this._numPoints=t.byteLength/E;return M(e,new Float32Array(t,0,2*this._numPoints),new Uint8Array(t,2*this._numPoints*4,this._numPoints),this._numPoints)}_update(t){if(!t)return;const e=(t.getHours()/12+t.getMinutes()/60*(2/24)+t.getSeconds()/60*(2/1440)-.9972222)%2,s=2*q(t),r=u(this._passParameters.modelMatrix,A);l(r,r,-s*Math.PI),d(r,L,r),l(r,r,-e*Math.PI),this.requestRender(1)}_createLoadDataTask(){if(this._starData)return null;const t=s(async t=>{const{data:s}=await e("esri/views/3d/environment/resources/stars.wsv",{responseType:"array-buffer",signal:t});x(s),this._starData=s});return t.promise.catch(t=>{n(t)||i.getLogger(this).error(t)}).then(()=>{this.destroyed||this.requestRender(1)}),t}};function M(t,e,s,r){const i=v.createBuffer(r),a=i.position,o=i.color,n=i.size;for(let f=0;f<r;f++){const t=e[2*f],r=e[2*f+1];a.set(f,0,-Math.cos(t)*Math.sin(r)),a.set(f,1,-Math.sin(t)*Math.sin(r)),a.set(f,2,-Math.cos(r));const i=k(s[f]),c=R(I[i[1]]);o.set(f,0,255*c[0]),o.set(f,1,255*c[1]),o.set(f,2,255*c[2]),o.set(f,3,255),n.set(f,i[0])}return new P(t,new D(t,_(v),i.buffer))}function q(t){const e=t,s=new Date(t.getFullYear(),0,1,11,58,56);return(+e-+s)/(+new Date(t.getFullYear()+1,0,1,11,58,55)-+s)}function x(t){if(!t)throw new r("stars:no-data-received","Failed to create stars because star catalogue is missing");const e=t.byteLength/E;if(e%1!=0||e>5e4||e<5e3)throw new r("stars:invalid-data","Failed to create stars because star catalogue data is invalid")}function R(t){return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function k(t){return t>=192?[2.9,t-192]:t>=160?[2.5,t-160]:t>=128?[2,t-128]:t>=96?[1.5,t-96]:t>=64?[1,t-64]:t>=32?[.7,t-32]:[.4,t]}T=t([h("esri.views.3d.webgl-engine.effects.stars.Stars")],T);const I=["9bb2ff","9eb5ff","aabfff","bbccff","ccd8ff ","dae2ff","e4e9ff","eeefff","f8f6ff","fff9fb","fff5ef","fff1e5","ffeddb","ffe9d2","ffe6ca","ffe3c3","ffe0bb","ffddb4","ffdaad","ffd6a5","ffd29c","ffcc8f","ffc178","ffa94b","ff7b00"],L=p(1,0,0,0,0,.9174771405229186,.39778850739794974,0,0,-.39778850739794974,.9174771405229186,0,0,0,0,1),A=p(1,0,0,0,0,.9174771405229186,-.39778850739794974,0,0,.39778850739794974,.9174771405229186,0,0,0,0,1),E=9;export{T as Stars};