@arcgis/core 5.2.0-next.62 → 5.2.0-next.63

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 (202) hide show
  1. package/WebDocument2D.d.ts +17 -1
  2. package/WebDocument2D.js +1 -1
  3. package/WebLinkChart.js +1 -1
  4. package/WebMap.js +1 -1
  5. package/WebScene.js +1 -1
  6. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  7. package/arcgisGlobal.d.ts +5 -0
  8. package/assets/esri/core/workers/RemoteClient.js +1 -1
  9. package/assets/esri/core/workers/chunks/02dd79beb13eff6be85e.js +1 -0
  10. package/assets/esri/core/workers/chunks/04ffe788d2efc0a076dd.js +1 -0
  11. package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +29 -0
  12. package/assets/esri/core/workers/chunks/08c2bf9defcece9e049a.js +1 -0
  13. package/assets/esri/core/workers/chunks/0d61c8d348b09179777a.js +1 -0
  14. package/assets/esri/core/workers/chunks/14cd8bb1ad4da8d1d2ca.js +1 -0
  15. package/assets/esri/core/workers/chunks/23a3d8f91caf3136b2aa.js +1 -0
  16. package/assets/esri/core/workers/chunks/{1b68b1b724ad30396723.js → 2426601b8cae7f06af4d.js} +1 -1
  17. package/assets/esri/core/workers/chunks/2a1c6df073e6ca6a6365.js +1 -0
  18. package/assets/esri/core/workers/chunks/{f4891345507df63cff3c.js → 3f775deea48e268411f1.js} +3 -3
  19. package/assets/esri/core/workers/chunks/{e3623e557ab463580fd2.js → 41e821ce229bc56dc1a1.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{17acbf40e7c1cb42d9bd.js → 44b1cdf28269b4fa8a39.js} +1 -1
  21. package/assets/esri/core/workers/chunks/44e8cd4b3dad777ab0c9.js +1 -0
  22. package/assets/esri/core/workers/chunks/456e616f32e7de696d38.js +1 -0
  23. package/assets/esri/core/workers/chunks/54b9667450d066c6f6ce.js +1 -0
  24. package/assets/esri/core/workers/chunks/5dbd8ca7e7b8eb9a0bf7.js +1 -0
  25. package/assets/esri/core/workers/chunks/5e3d5347223f0111f40f.js +1 -0
  26. package/assets/esri/core/workers/chunks/62f3ca0719ac6bc76512.js +1 -0
  27. package/assets/esri/core/workers/chunks/63ede7295938f7010808.js +1 -0
  28. package/assets/esri/core/workers/chunks/687cf21e027f49b44d22.js +1 -0
  29. package/assets/esri/core/workers/chunks/6c98a64d92c9bca78203.js +1 -0
  30. package/assets/esri/core/workers/chunks/{e7402dfd683f82878360.js → 752343d92ed48e674351.js} +1 -1
  31. package/assets/esri/core/workers/chunks/7538a0fe0cec3156769e.js +1 -0
  32. package/assets/esri/core/workers/chunks/{64247e439ef3e1f712e9.js → 7fdd6a5fa062778be55d.js} +1 -1
  33. package/assets/esri/core/workers/chunks/8369edafab7bdc59b95a.js +1 -0
  34. package/assets/esri/core/workers/chunks/{94e9cf8e729ec36de5be.js → 8c535c6a39d2be2ed655.js} +1 -1
  35. package/assets/esri/core/workers/chunks/8e1d4867406753c5483c.js +1 -0
  36. package/assets/esri/core/workers/chunks/92696cce2b980373f9ad.js +1 -0
  37. package/assets/esri/core/workers/chunks/{580451761cadfe308919.js → 9954149def644c371894.js} +1 -1
  38. package/assets/esri/core/workers/chunks/9f65cc6d9f7390bb1d5b.js +1 -0
  39. package/assets/esri/core/workers/chunks/a09ce34fc7c8abe64ed5.js +1 -0
  40. package/assets/esri/core/workers/chunks/{83991475aa54fd5aa008.js → a965d151515b76dd7566.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{128799741dd3c6fc69b9.js → ac4131121230cfc14f21.js} +1 -1
  42. package/assets/esri/core/workers/chunks/afeeb11b39e140303b5a.js +1 -0
  43. package/assets/esri/core/workers/chunks/b13d2da33ec07e9d41ff.js +1 -0
  44. package/assets/esri/core/workers/chunks/{33bd9785bd0b6ccef21b.js → b2cf1d3f0d48eac23a84.js} +1 -1
  45. package/assets/esri/core/workers/chunks/c53b2be005721591e29b.js +1 -0
  46. package/assets/esri/core/workers/chunks/{e287113777a94ded8de6.js → c82ab4f0908290e70ee9.js} +1 -1
  47. package/assets/esri/core/workers/chunks/d456520e4b119a2816b6.js +1 -0
  48. package/assets/esri/core/workers/chunks/d83ea3e4e9ab45334068.js +1 -0
  49. package/assets/esri/core/workers/chunks/{4f59357f535f30a6b5cc.js → d9b83d7dd7d1f7729a91.js} +1 -1
  50. package/assets/esri/core/workers/chunks/dbcec48c4ba104a6d0b5.js +1 -0
  51. package/assets/esri/core/workers/chunks/e02f02040b63d9c2e654.js +1 -0
  52. package/assets/esri/core/workers/chunks/e08c64e4ae5a68eae2be.js +1 -0
  53. package/assets/esri/core/workers/chunks/e2ddfc96ddba92302e0c.js +1 -0
  54. package/assets/esri/core/workers/chunks/{61d3fcb419d6bf7e355e.js → e65ee26feca0564aeb9b.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{35cbf00f0c37a86517af.js → ed1de8b7406269e217b9.js} +1 -1
  56. package/assets/esri/core/workers/chunks/ed4ac5568dc2815b066d.js +1 -0
  57. package/assets/esri/core/workers/chunks/f029c12f1afee0e9b2a1.js +1 -0
  58. package/assets/esri/core/workers/chunks/{461c2de938bf4c9b1442.js → f6715b8765cd36d81ec8.js} +1 -1
  59. package/assets/esri/core/workers/chunks/f9a4f4efd63b8189a4eb.js +1 -0
  60. package/assets/esri/core/workers/chunks/{26a2d4b95cda0a41d980.js → fa1c58e5b582d61a03ab.js} +1 -1
  61. package/assets/esri/core/workers/chunks/fa377112ef3b78f6ed18.js +1 -0
  62. package/chunks/VolumeMask.glsl.js +3 -0
  63. package/chunks/persistableUrlUtils.js +1 -1
  64. package/config.js +1 -1
  65. package/core/Collection.d.ts +42 -6
  66. package/core/Collection.js +1 -1
  67. package/geometry/SpatialReference.d.ts +1 -4
  68. package/kernel.js +1 -1
  69. package/layers/BaseElevationLayer.js +1 -1
  70. package/layers/ElevationLayer.js +1 -1
  71. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  72. package/layers/KnowledgeGraphLayer.js +1 -1
  73. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  74. package/layers/StreamLayer.js +1 -1
  75. package/layers/VoxelWasmPerSceneView.js +1 -1
  76. package/layers/graphics/sources/connections/createConnection.js +1 -1
  77. package/layers/graphics/sources/parquet/ParquetFileStatistics.js +1 -1
  78. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  79. package/layers/graphics/sources/support/QueryTask.js +1 -1
  80. package/layers/mixins/SceneService.js +1 -1
  81. package/layers/raster/datasets/BaseRaster.js +1 -1
  82. package/layers/save/groupLayerUtils.js +1 -1
  83. package/layers/save/mediaLayerUtils.js +1 -1
  84. package/layers/support/ElevationQueryTileCache.js +1 -1
  85. package/layers/video/types.d.ts +17 -1
  86. package/linkChart/LinkChartProperties.js +1 -1
  87. package/package.json +1 -1
  88. package/portal/support/jsonContext.js +1 -1
  89. package/support/persistableUrlUtils.js +1 -1
  90. package/support/revision.js +1 -1
  91. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
  92. package/views/2d/layers/features/sources/strategies/FeatureHybridTileLoadStrategy.js +1 -1
  93. package/views/3d/GroundView3D.js +1 -1
  94. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  95. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  96. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  97. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  98. package/views/3d/layers/support/Tiles3DMeshIntersectionHandler.js +1 -1
  99. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  100. package/views/3d/support/gaussianSplatting/GaussianSplatHeaderTexture.js +1 -1
  101. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  102. package/views/3d/support/hitTest.js +1 -1
  103. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  104. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  105. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  106. package/views/3d/terrain/TerrainRenderer.js +1 -1
  107. package/views/3d/terrain/TerrainSurface.js +1 -1
  108. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/ComponentObjectFixedBVH.js +1 -1
  110. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  111. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +1 -1
  112. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.js +1 -1
  113. package/views/3d/webgl-engine/lib/CutFillVisualization.js +1 -1
  114. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  115. package/views/3d/webgl-engine/lib/IntersectorResult.js +1 -1
  116. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  117. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  118. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  119. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFieldCreation.js +1 -1
  120. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  121. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  122. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  123. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  125. package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +1 -1
  126. package/views/3d/webgl-engine/shaders/ShadowCastMaskTechnique.js +1 -1
  127. package/views/3d/webgl-engine/shaders/{CutFillMask.glsl.js → VolumeMask.glsl.js} +1 -1
  128. package/views/3d/webgl-engine/shaders/VolumeMaskTechnique.js +2 -0
  129. package/webdoc/support/resourceUtils.js +1 -1
  130. package/webdoc/support/types.d.ts +2 -0
  131. package/webdoc/support/utils.js +2 -0
  132. package/webdoc/support/webdocLoadUtils.js +1 -1
  133. package/webdoc/support/webdocSaveUtils.js +1 -1
  134. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  135. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  136. package/widgets/BatchAttributeForm/expressions/ArcadeExecutorProvider.js +1 -1
  137. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  138. package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
  139. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  140. package/widgets/BatchAttributeForm/inputs/BatchFormInputs.js +1 -1
  141. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  142. package/widgets/BatchAttributeForm/inputs/RelationshipElementInput.js +1 -1
  143. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  144. package/widgets/BatchAttributeForm/rendered-content/RelationshipDetails.js +1 -1
  145. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  146. package/widgets/BatchAttributeForm.js +1 -1
  147. package/widgets/Editor/UpdateWorkflow.js +1 -1
  148. package/widgets/Editor.js +1 -1
  149. package/widgets/FeatureForm.js +1 -1
  150. package/widgets/FeatureTable/Grid/Column.d.ts +6 -0
  151. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  152. package/widgets/Sketch/SketchViewModel.js +1 -1
  153. package/widgets/support/SelectionList/FeatureItem.d.ts +116 -0
  154. package/widgets/support/SelectionList/GroupLayerItem.d.ts +94 -0
  155. package/widgets/support/SelectionList/ItemBase.d.ts +70 -0
  156. package/widgets/support/SelectionList/LayerItem.d.ts +140 -0
  157. package/widgets/support/SelectionList/LayerItem.js +1 -1
  158. package/widgets/support/SelectionList/SelectionListViewModel.d.ts +265 -0
  159. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  160. package/widgets/support/SelectionList/types.d.ts +42 -0
  161. package/widgets/support/forms/formUtils.js +1 -1
  162. package/assets/esri/core/workers/chunks/003a87b16f8a4b476e14.js +0 -1
  163. package/assets/esri/core/workers/chunks/0a50efb07eee36237e21.js +0 -1
  164. package/assets/esri/core/workers/chunks/129fdd1636e67997337c.js +0 -1
  165. package/assets/esri/core/workers/chunks/12e0c5b7cc5c3f9e6f0f.js +0 -1
  166. package/assets/esri/core/workers/chunks/147a89553188cc6aabf4.js +0 -1
  167. package/assets/esri/core/workers/chunks/26f1fd3f2be5102aae1d.js +0 -1
  168. package/assets/esri/core/workers/chunks/34fbeeeeef4bd01672c6.js +0 -1
  169. package/assets/esri/core/workers/chunks/36fe6adf6517d8f80125.js +0 -1
  170. package/assets/esri/core/workers/chunks/403f08e0c1a9203f7fba.js +0 -1
  171. package/assets/esri/core/workers/chunks/4f2170609742b51bd7b8.js +0 -1
  172. package/assets/esri/core/workers/chunks/5133083222588799493f.js +0 -1
  173. package/assets/esri/core/workers/chunks/52993a9dc0c56e9bda19.js +0 -1
  174. package/assets/esri/core/workers/chunks/5e35828216020f33e26b.js +0 -1
  175. package/assets/esri/core/workers/chunks/5f0d6c853873a7f32527.js +0 -1
  176. package/assets/esri/core/workers/chunks/6121cd0264b6841a5bac.js +0 -1
  177. package/assets/esri/core/workers/chunks/6823ba1688dfedba0107.js +0 -1
  178. package/assets/esri/core/workers/chunks/705d6b108fd121cea887.js +0 -1
  179. package/assets/esri/core/workers/chunks/73aa1bfa6e1dc271c9d7.js +0 -1
  180. package/assets/esri/core/workers/chunks/825eb845216762a1ed2f.js +0 -1
  181. package/assets/esri/core/workers/chunks/88df19742edb0cdc3e67.js +0 -1
  182. package/assets/esri/core/workers/chunks/8977c85aecc7e08ab13c.js +0 -1
  183. package/assets/esri/core/workers/chunks/8bdca809dd88eab9e5d8.js +0 -29
  184. package/assets/esri/core/workers/chunks/8c5726c7ce40a92901e6.js +0 -1
  185. package/assets/esri/core/workers/chunks/8c5e65982c3f9295e844.js +0 -1
  186. package/assets/esri/core/workers/chunks/8ce649e55fefc8eca55c.js +0 -1
  187. package/assets/esri/core/workers/chunks/90ae80b797642bff0efa.js +0 -1
  188. package/assets/esri/core/workers/chunks/97c758f736f28c5dab84.js +0 -1
  189. package/assets/esri/core/workers/chunks/a494abeb026d536d9fae.js +0 -1
  190. package/assets/esri/core/workers/chunks/a8ade34612e73862de6f.js +0 -1
  191. package/assets/esri/core/workers/chunks/a9d391071803b1e9e8a0.js +0 -1
  192. package/assets/esri/core/workers/chunks/aa3abc07de2921ef6ca1.js +0 -1
  193. package/assets/esri/core/workers/chunks/b03f09ee2224f0cc526a.js +0 -1
  194. package/assets/esri/core/workers/chunks/b3f1a442d6b7826e917f.js +0 -1
  195. package/assets/esri/core/workers/chunks/b819a9187426d0c146df.js +0 -1
  196. package/assets/esri/core/workers/chunks/f0225829f7d941914815.js +0 -1
  197. package/assets/esri/core/workers/chunks/fb34d6d96c8c0d53fcf6.js +0 -1
  198. package/chunks/CutFillMask.glsl.js +0 -3
  199. package/chunks/FocusAreaMask.glsl.js +0 -3
  200. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMask.glsl.js +0 -2
  201. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +0 -2
  202. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as t}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import o from"../../../../core/Logger.js";import{debounce as i,isPromiseLike as n}from"../../../../core/promiseUtils.js";import{createVolume as s}from"../../../../core/quantity.js";import{whenOnce as a,watch as l}from"../../../../core/reactiveUtils.js";import{property as u,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{runUntracked as m}from"../../../../core/accessorSupport/tracking.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{setAxes as h}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{sqrDist as f}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{scaleAndAdd as y,scale as _,set as v,negate as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w,fromValues as j,clone as E}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as x}from"../../../../core/support/UpdatingHandles.js";import R from"../../../../geometry/Multipoint.js";import{projectOrLoad as C}from"../../../../geometry/projectionUtils.js";import{e as T}from"../../../../chunks/containsOperator.js";import{e as O}from"../../../../chunks/convexHullOperator.js";import{e as L}from"../../../../chunks/simplifyOperator.js";import{e as G}from"../../../../chunks/unionOperator.js";import{computeTranslationToOriginAndRotation as V}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as D}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as H,create as M,fromExtent as I,intersects as P}from"../../../../geometry/support/aaBoundingRect.js";import{vectorCoordinates as U}from"../../../../geometry/support/coordinateSystem.js";import{isClockwise as S}from"../../../../geometry/support/coordsUtils.js";import{newDoubleArray as k}from"../../../../geometry/support/DoubleArray.js";import{t as A}from"../../../../chunks/vec3.js";import F from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as W}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as q}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementInsufficientDataError as B,VolumeMeasurementPerimeterTooLargeError as N,VolumeMeasurementUnsupportedCoordinateSystemError as z,VolumeMeasurementUnsupportedLayerTransparencyError as Z}from"./volumeMeasurementErrors.js";import{VolumeMeasurementRawResult as J}from"./VolumeMeasurementRawResult.js";import K from"./VolumeMeasurementResult.js";import{ElevationContext as Q}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as X}from"../../support/ElevationProvider.js";import{Obb as Y}from"../../support/orientedBoundingBox.js";import{polygonToRenderInfoElevationAligned as $}from"../../support/renderInfoUtils/polygon.js";import{IteratorPreorder as ee}from"../../terrain/tileUtils.js";import{CutFillComputation as te,TargetGeometryRenderInfo as re}from"../../webgl-engine/lib/CutFillComputation.js";import{GeometryWorkerHandle as oe}from"../../../support/GeometryWorkerHandle.js";import{isIntegratedMeshLayerView as ie}from"../../../support/layerViewUtils.js";let ne=class extends r{constructor(e){super(e),this._measurementWorkerHandle=new oe,this.depthExtremaPositions=null,this.analysisObb=null,this._updatingHandles=new x,this._rawResult=null,this._sufficientDataCoverage=!0,this._tileIterator=new ee,this._intersectingObbs=[],this._intersectingTiles=[],this._debouncedUpdate=i(async(e,t,r,o)=>{if(!this._computation.done)return;const{renderCoordsHelper:i}=this.view,n=new q({extent:t,localOrigin:r,renderCoordsHelper:i});this._computation.update(n,o),this._determineDataCoverage(n,e);const[s]=await Promise.allSettled([this._measurementWorkerHandle.areaHorizontal(e,{returnLength:!0}),a(()=>this._computation.done).then(()=>{this._updateDepthExtremaPositions(n,this._computation.result)})]);if(this.error)return void(this._rawResult=null);const l=this._computation.result;this._updateResult(n,l,"fulfilled"===s.status?s.value:null)}),this._determineDataCoverage=(e,t)=>{const{frustum:r}=this._computation,{cameraDimensions:o}=e;t.extent&&r&&(this._intersectingObbs.length=0,this._imLayerViewsAffectingMeasurement.forEach(e=>{this._findIntersectingObbs(e,r)}),this._intersectingObbs.length?this._sufficientDataCoverage=this._sufficientIntegratedMeshCoverage(t,o):(this._findIntersectingTerrainTiles(t.extent),this._sufficientDataCoverage=this._sufficientTerrainCoverage(o)))}}initialize(){const e=this.view;this._computation=new te({view:e}),this.addHandles([this._createElevationUpdateHandle(),l(()=>({localOrigin:this._localOrigin,targetGeometryRenderInfo:this._targetGeometryRenderInfo,transparencyError:!!this._unsupportedLayerTransparencyError}),({localOrigin:e,targetGeometryRenderInfo:t,transparencyError:r})=>{const o=this._projectedGeometry,i=o?.extent;if(!o||!i||!e||!t||r)return this._rawResult=null,this.depthExtremaPositions=null,this.analysisObb=null,void(this._sufficientDataCoverage=!0);this._updatingHandles.consumePromise(this._debouncedUpdate(o,i,e,t))})])}destroy(){this._updatingHandles.destroy(),this._computation.destroy(),this._measurementWorkerHandle.destroy()}get _projectedGeometry(){const e=this.analysis.geometry;if(!e||!this.analysis.valid)return null;const t=L(e),r=C(t,this.view.spatialReference);return r.pending?(this._updatingHandles.consumePromise(r.pending),null):(t&&!r.geometry&&W(this.analysis,e.spatialReference,o.getLogger(this)),r.geometry)}get _localOrigin(){const e=this._projectedGeometry?.extent;return e?j(e.center.x,e.center.y,0):null}get elevationAlignedGeometry(){const e=this._projectedGeometry;return e?m(()=>{const t=e.clone();return se(this.view.elevationProvider,t),t}):null}get targetGeometry(){const{elevationAlignedGeometry:e}=this;if(!e)return null;const t=this.analysis.measureType,{effectiveTargetElevation:r}=this.analysisViewData;if("stockpile"===t||null==r)return e;const o=e.clone();return o.rings.forEach(e=>e.forEach(e=>e[2]=r)),o}get _targetGeometryRenderInfo(){const e=this.targetGeometry,t=this._localOrigin;if(!e||!t)return null;const{elevationProvider:r,renderCoordsHelper:o}=this.view,i=$(e,r,o,Q.fromElevationInfo(new F({mode:"absolute-height"})));if(n(i))return this._updatingHandles.consumePromise(i),null;if(null==i)return null;const{positions:s,polygonIndices:a,vertexCount:l}=i,u=k(3*l),p=c(),m=c();return V(e.spatialReference,t,p,o.spatialReference),m[12]=-p[12],m[13]=-p[13],m[14]=-p[14],A(u,s,m),new re(u,a)}get updating(){return this._computation.updating||this._updatingHandles.updating}get result(){const e=this._rawResult,{volume:t,area:r,length:o}=this.analysisViewData.effectiveDisplayUnits;return e?new K({measureType:this.analysis.measureType,rawResult:e,volumeUnit:t,areaUnit:r,lengthUnit:o}):null}get error(){return this._unsupportedCoordinateSystemError??this._unsupportedLayerTransparencyError??this._perimeterTooLargeError??this._insufficientDataError}get _imLayerViewsAffectingMeasurement(){return this.view.allLayerViews.filter(e=>ie(e)).filter(e=>e.visible&&!e.suspended)}get _insufficientDataError(){return this._sufficientDataCoverage?null:new B}get _perimeterTooLargeError(){return this._perimeterTooLargeLocalError??this._perimeterTooLargeGlobalError}get _perimeterTooLargeLocalError(){const{spatialReference:e,state:{isLocal:r}}=this.view;if(!r||!e.isWebMercator)return null;const o=this._perimeterForError,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new N:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeterForError,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new N:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new z:null}get _unsupportedLayerTransparencyError(){return this.view.map.ground&&this.view.map.ground.opacity<1?new Z:null}get _perimeterForError(){const e=this._projectedGeometry;if(null==e)return null;let t=null;for(const r of e.rings){if(!S(r))continue;const e=ue(pe(r));t=e?Math.max(t??0,e):t}return null!=t?t*e.spatialReference.metersPerUnit:null}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(D(e.extent,e.spatialReference,ce,this.view.spatialReference),I(t,he),P(ce,he)&&this.notifyChange("elevationAlignedGeometry"))};return this.view.elevationProvider.on("elevation-change",t=>e(t))}_updateResult(e,t,r){if(!t)return;const{unitInMeters:o}=this.view.renderCoordsHelper,{dimensions:{width:i,height:n},cameraNearFar:{near:a,far:l}}=e,u=i/t.width*(n/t.height),p=ae(t.cut.totalDepth,a,l)*u,m=ae(t.fill.totalDepth,a,l)*u,c=o**3;this._rawResult=new J({cutVolume:s(Math.abs(p*c),"cubic-meters"),fillVolume:s(m*c,"cubic-meters"),area:r?.area,perimeter:r?.length})}_updateDepthExtremaPositions(e,t){if(!t)return;const{dimensions:{width:r,height:o},cameraNearFar:{near:i,far:n},cameraPositionRenderSpace:s,northVector:a,eastVector:l,upVector:u}=e,p=e=>{const{depthExtremum:p,depthExtremumCoords:[m,c],totalDepth:h}=e,d=E(s);return 0!==h&&(y(d,d,l,r*(m/t.width-.5)),y(d,d,a,o*(c/t.height-.5))),y(d,d,u,-ae(p,i,n)),d},m={cut:p(t.cut),fill:p(t.fill)};this.depthExtremaPositions=m,this.analysisObb=le(e,m)}_findIntersectingObbs(e,t){const r=this._intersectingObbs;"integrated-mesh-3d"===e.type&&e.getVisibleNodes().forEach(o=>{e.isNodeLoaded(o.index)&&o.geometryObbInRenderSR?.intersectsFrustum(t)&&r.push(o.geometryObbInRenderSR)}),"integrated-mesh-3dtiles"===e.type&&e.forEachVisibleComponentObject(({obb:e})=>{e.intersectsFrustum(t)&&r.push(e)})}_sufficientIntegratedMeshCoverage(e,t){const{renderCoordsHelper:r,spatialReference:o}=this.view,i=[],n=new R({spatialReference:o});if(this._intersectingObbs.forEach(e=>{if(me(e.radius,t)&&(e.getCorners(we),n.points.length=0,we.forEach(e=>{const t=r.fromRenderCoords(e,je,o);t&&n.addPoint([t[0],t[1]])}),n.points.length)){const e=O(n);"polygon"===e?.type&&i.push(e)}}),!i.length)return!1;const s=G(i);return!!s&&T(s,e)}_findIntersectingTerrainTiles(e){const{basemapTerrain:t}=this.view;this._intersectingTiles.length=0,I(e,de);const r=this._tileIterator;r.reset(t.rootTiles);for(let o=r.next();o;o=r.next())o.intersectsExtent(de)?o.rendered&&this._intersectingTiles.push(o):r.skipSubtree()}_sufficientTerrainCoverage(e){const{basemapTerrain:{tilingScheme:t}}=this.view;if(!this._intersectingTiles.length)return!1;const r=256/t.pixelSize;return this._intersectingTiles.every(t=>me(t.radius*r,e))}};function se(e,t){t.hasZ=!0,t.rings.forEach(t=>t.forEach(t=>t[2]=X(e,t,"ground")??0))}function ae(e,t,r){return e*(r-t)+t}function le(e,t){const{boundingRect:r,eastVector:o,northVector:i,upVector:n}=e;U(t.cut,o,i,n,fe),U(t.fill,o,i,n,ge);const s=.5*(r[0]+r[2]),a=.5*(r[1]+r[3]),l=Math.min(fe[2],ge[2]),u=Math.max(fe[2],ge[2]),p=.5*(l+u);return _(ye,o,s),y(ye,ye,i,a),y(ye,ye,n,p),v(_e,.5*(r[2]-r[0]),.5*(r[3]-r[1]),.5*(u-l)),b(ve,n),new Y(ye,_e,h(be,ve,o,i))}function ue(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1]]),r?o+=f(r,i):r=[0,0],r[0]=i[0],r[1]=i[1];return t&&r&&(o+=f(r,t)),Math.sqrt(o)}function*pe(e){const t=g();for(let r=0;r<e.length;r++)t[0]=e[r][0],t[1]=e[r][1],yield t}e([u()],ne.prototype,"_projectedGeometry",null),e([u()],ne.prototype,"_localOrigin",null),e([u()],ne.prototype,"elevationAlignedGeometry",null),e([u()],ne.prototype,"targetGeometry",null),e([u()],ne.prototype,"_targetGeometryRenderInfo",null),e([u({constructOnly:!0})],ne.prototype,"analysis",void 0),e([u({constructOnly:!0})],ne.prototype,"analysisViewData",void 0),e([u({constructOnly:!0})],ne.prototype,"view",void 0),e([u()],ne.prototype,"updating",null),e([u()],ne.prototype,"result",null),e([u()],ne.prototype,"depthExtremaPositions",void 0),e([u()],ne.prototype,"analysisObb",void 0),e([u()],ne.prototype,"error",null),e([u()],ne.prototype,"_imLayerViewsAffectingMeasurement",null),e([u()],ne.prototype,"_insufficientDataError",null),e([u()],ne.prototype,"_perimeterTooLargeError",null),e([u()],ne.prototype,"_perimeterTooLargeLocalError",null),e([u()],ne.prototype,"_perimeterTooLargeGlobalError",null),e([u()],ne.prototype,"_unsupportedCoordinateSystemError",null),e([u()],ne.prototype,"_unsupportedLayerTransparencyError",null),e([u()],ne.prototype,"_perimeterForError",null),e([u()],ne.prototype,"_computation",void 0),e([u({readOnly:!0})],ne.prototype,"_updatingHandles",void 0),e([u()],ne.prototype,"_rawResult",void 0),e([u()],ne.prototype,"_sufficientDataCoverage",void 0),ne=e([p("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],ne);const me=(e,t)=>e<(t.width+t.height)/2,ce=H(),he=H(),de=M(),fe=w(),ge=w(),ye=w(),_e=w(),ve=w(),be=d(),we=new Array(8).fill(0).map(()=>w()),je=w();export{ne as VolumeMeasurementCutFillController};
2
+ import{__decorate as e}from"tslib";import{volumeMeasurementConfiguration as t}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import r from"../../../../core/Accessor.js";import o from"../../../../core/Logger.js";import{debounce as i,isPromiseLike as n}from"../../../../core/promiseUtils.js";import{createVolume as s}from"../../../../core/quantity.js";import a from"../../../../core/ReactiveMap.js";import{whenOnce as l,watch as u}from"../../../../core/reactiveUtils.js";import{property as p,subclass as m}from"../../../../core/accessorSupport/decorators.js";import{runUntracked as c}from"../../../../core/accessorSupport/tracking.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{setAxes as f}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{sqrDist as g}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{scaleAndAdd as _,scale as v,set as w,negate as b}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,fromValues as E,clone as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as R}from"../../../../core/support/UpdatingHandles.js";import C from"../../../../geometry/Multipoint.js";import{projectOrLoad as L}from"../../../../geometry/projectionUtils.js";import{e as O}from"../../../../chunks/containsOperator.js";import{e as T}from"../../../../chunks/convexHullOperator.js";import{e as V}from"../../../../chunks/simplifyOperator.js";import{e as G}from"../../../../chunks/unionOperator.js";import{computeTranslationToOriginAndRotation as M}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBoundingRect as D}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as H,create as I,fromExtent as P,intersects as U}from"../../../../geometry/support/aaBoundingRect.js";import{vectorCoordinates as k}from"../../../../geometry/support/coordinateSystem.js";import{isClockwise as S}from"../../../../geometry/support/coordsUtils.js";import{newDoubleArray as A}from"../../../../geometry/support/DoubleArray.js";import{t as B}from"../../../../chunks/vec3.js";import F from"../../../../symbols/support/ElevationInfo.js";import{logFailedGeometryProjectionError as W}from"../support/projectionUtils.js";import{VolumeMeasurementCutFillComputation as z}from"./VolumeMeasurementCutFillComputation.js";import{VolumeMeasurementInsufficientDataError as q,VolumeMeasurementPerimeterTooLargeError as N,VolumeMeasurementUnsupportedCoordinateSystemError as Z,VolumeMeasurementUnsupportedLayerTransparencyError as J}from"./volumeMeasurementErrors.js";import{VolumeMeasurementRawResult as K}from"./VolumeMeasurementRawResult.js";import Q from"./VolumeMeasurementResult.js";import{ElevationContext as X}from"../../layers/graphics/ElevationContext.js";import{getElevationAtPoint as Y}from"../../support/ElevationProvider.js";import{Obb as $}from"../../support/orientedBoundingBox.js";import{polygonToRenderInfoElevationAligned as ee}from"../../support/renderInfoUtils/polygon.js";import{IteratorPreorder as te}from"../../terrain/tileUtils.js";import{CutFillComputation as re,TargetGeometryRenderInfo as oe}from"../../webgl-engine/lib/CutFillComputation.js";import{GeometryWorkerHandle as ie}from"../../../support/GeometryWorkerHandle.js";import{isIntegratedMeshLayerView as ne}from"../../../support/layerViewUtils.js";let se=class extends r{constructor(e){super(e),this._measurementWorkerHandle=new ie,this.depthExtremaPositions=null,this.analysisObb=null,this._updatingHandles=new R,this._rawResult=null,this._sufficientDataCoverage=!0,this._tileIterator=new te,this._intersectingObbsByLayerView=new a,this._intersectingTiles=[],this._debouncedUpdate=i(async(e,t,r,o)=>{if(!this._computation.done)return;const{renderCoordsHelper:i}=this.view,n=new z({extent:t,localOrigin:r,renderCoordsHelper:i});this._computation.update(n,o),this._determineDataCoverage(n,e);const[s]=await Promise.allSettled([this._measurementWorkerHandle.areaHorizontal(e,{returnLength:!0}),l(()=>this._computation.done).then(()=>{this._updateDepthExtremaPositions(n,this._computation.result)})]);if(this.error)return void(this._rawResult=null);const a=this._computation.result;this._updateResult(n,a,"fulfilled"===s.status?s.value:null)}),this._determineDataCoverage=(e,t)=>{const{frustum:r}=this._computation,{cameraDimensions:o}=e;t.extent&&r&&(this._intersectingObbsByLayerView.clear(),this._imLayerViewsAffectingMeasurement.forEach(e=>{this._findIntersectingObbs(e,r)}),this._intersectingObbsByLayerView.size>0?this._sufficientDataCoverage=this._sufficientIntegratedMeshCoverage(t,o):(this._findIntersectingTerrainTiles(t.extent),this._sufficientDataCoverage=this._sufficientTerrainCoverage(o)))}}initialize(){const e=this.view;this._computation=new re({view:e}),this.addHandles([this._createElevationUpdateHandle(),u(()=>({localOrigin:this._localOrigin,targetGeometryRenderInfo:this._targetGeometryRenderInfo}),({localOrigin:e,targetGeometryRenderInfo:t})=>{const r=this._projectedGeometry,o=r?.extent;if(!(r&&o&&e&&t))return this._rawResult=null,this.depthExtremaPositions=null,this.analysisObb=null,void(this._sufficientDataCoverage=!0);this._updatingHandles.consumePromise(this._debouncedUpdate(r,o,e,t))})])}destroy(){this._updatingHandles.destroy(),this._computation.destroy(),this._measurementWorkerHandle.destroy()}get _projectedGeometry(){const e=this.analysis.geometry;if(!e||!this.analysis.valid)return null;const t=V(e),r=L(t,this.view.spatialReference);return r.pending?(this._updatingHandles.consumePromise(r.pending),null):(t&&!r.geometry&&W(this.analysis,e.spatialReference,o.getLogger(this)),r.geometry)}get _localOrigin(){const e=this._projectedGeometry?.extent;return e?E(e.center.x,e.center.y,0):null}get elevationAlignedGeometry(){const e=this._projectedGeometry;return e?c(()=>{const t=e.clone();return ae(this.view.elevationProvider,t),t}):null}get targetGeometry(){const{elevationAlignedGeometry:e}=this;if(!e)return null;const t=this.analysis.measureType,{effectiveTargetElevation:r}=this.analysisViewData;if("stockpile"===t||null==r)return e;const o=e.clone();return o.rings.forEach(e=>e.forEach(e=>e[2]=r)),o}get _targetGeometryRenderInfo(){const e=this.targetGeometry,t=this._localOrigin;if(!e||!t)return null;const{elevationProvider:r,renderCoordsHelper:o}=this.view,i=ee(e,r,o,X.fromElevationInfo(new F({mode:"absolute-height"})));if(n(i))return this._updatingHandles.consumePromise(i),null;if(null==i)return null;const{positions:s,polygonIndices:a,vertexCount:l}=i,u=A(3*l),p=h(),m=h();return M(e.spatialReference,t,p,o.spatialReference),m[12]=-p[12],m[13]=-p[13],m[14]=-p[14],B(u,s,m),new oe(u,a)}get updating(){return this._computation.updating||this._updatingHandles.updating}get result(){const e=this._rawResult,{volume:t,area:r,length:o}=this.analysisViewData.effectiveDisplayUnits;return e&&!this.error?new Q({measureType:this.analysis.measureType,rawResult:e,volumeUnit:t,areaUnit:r,lengthUnit:o}):null}get error(){return this._unsupportedCoordinateSystemError??this._unsupportedLayerTransparencyError??this._perimeterTooLargeError??this._insufficientDataError}get _imLayerViewsAffectingMeasurement(){return this.view.allLayerViews.filter(e=>ne(e)).filter(e=>e.visible&&!e.suspended)}get _insufficientDataError(){return this._sufficientDataCoverage?null:new q}get _perimeterTooLargeError(){return this._perimeterTooLargeLocalError??this._perimeterTooLargeGlobalError}get _perimeterTooLargeLocalError(){const{spatialReference:e,state:{isLocal:r}}=this.view;if(!r||!e.isWebMercator)return null;const o=this._perimeterForError,{maxPerimeterLocalWebMercator:i}=t;return null!=o&&o>i?new N:null}get _perimeterTooLargeGlobalError(){if(!this.view.state.isGlobal)return null;const e=this._perimeterForError,{maxPerimeterGlobal:r}=t;return null!=e&&e>r?new N:null}get _unsupportedCoordinateSystemError(){return this.view.state.isLocal&&this.view.spatialReference.isGeographic?new Z:null}get _unsupportedLayerTransparencyError(){const e=this.view.map.ground&&this.view.map.ground.opacity<1,t=this._intersectingObbsByLayerView.size>0;return this._intersectingObbsByLayerView.keys().some(e=>e.fullOpacity<1)||e&&!t?new J:null}get _perimeterForError(){const e=this._projectedGeometry;if(null==e)return null;let t=null;for(const r of e.rings){if(!S(r))continue;const e=pe(me(r));t=e?Math.max(t??0,e):t}return null!=t?t*e.spatialReference.metersPerUnit:null}_createElevationUpdateHandle(){const e=e=>{const t=this._projectedGeometry?.extent;"ground"===e.context&&t&&(D(e.extent,e.spatialReference,he,this.view.spatialReference),P(t,fe),U(he,fe)&&this.notifyChange("elevationAlignedGeometry"))};return this.view.elevationProvider.on("elevation-change",t=>e(t))}_updateResult(e,t,r){if(!t)return;const{unitInMeters:o}=this.view.renderCoordsHelper,{dimensions:{width:i,height:n},cameraNearFar:{near:a,far:l}}=e,u=i/t.width*(n/t.height),p=le(t.cut.totalDepth,a,l)*u,m=le(t.fill.totalDepth,a,l)*u,c=o**3;this._rawResult=new K({cutVolume:s(Math.abs(p*c),"cubic-meters"),fillVolume:s(m*c,"cubic-meters"),area:r?.area,perimeter:r?.length})}_updateDepthExtremaPositions(e,t){if(!t)return;const{dimensions:{width:r,height:o},cameraNearFar:{near:i,far:n},cameraPositionRenderSpace:s,northVector:a,eastVector:l,upVector:u}=e,p=e=>{const{depthExtremum:p,depthExtremumCoords:[m,c],totalDepth:h}=e,f=x(s);return 0!==h&&(_(f,f,l,r*(m/t.width-.5)),_(f,f,a,o*(c/t.height-.5))),_(f,f,u,-le(p,i,n)),f},m={cut:p(t.cut),fill:p(t.fill)};this.depthExtremaPositions=m,this.analysisObb=ue(e,m)}_findIntersectingObbs(e,t){const r=[];"integrated-mesh-3d"===e.type&&e.getVisibleNodes().forEach(o=>{e.isNodeLoaded(o.index)&&o.geometryObbInRenderSR?.intersectsFrustum(t)&&r.push(o.geometryObbInRenderSR)}),"integrated-mesh-3dtiles"===e.type&&e.forEachVisibleComponentObject(({obb:e})=>{e.intersectsFrustum(t)&&r.push(e)}),r.length>0&&this._intersectingObbsByLayerView.set(e,r)}_sufficientIntegratedMeshCoverage(e,t){const{renderCoordsHelper:r,spatialReference:o}=this.view,i=[],n=new C({spatialReference:o});if(this._intersectingObbsByLayerView.forEach(e=>{e.forEach(e=>{if(ce(e.radius,t)&&(e.getCorners(je),n.points.length=0,je.forEach(e=>{const t=r.fromRenderCoords(e,Ee,o);t&&n.addPoint([t[0],t[1]])}),n.points.length)){const e=T(n);"polygon"===e?.type&&i.push(e)}})}),!i.length)return!1;const s=G(i);return!!s&&O(s,e)}_findIntersectingTerrainTiles(e){const{basemapTerrain:t}=this.view;this._intersectingTiles.length=0,P(e,de);const r=this._tileIterator;r.reset(t.rootTiles);for(let o=r.next();o;o=r.next())o.intersectsExtent(de)?o.rendered&&this._intersectingTiles.push(o):r.skipSubtree()}_sufficientTerrainCoverage(e){const{basemapTerrain:{tilingScheme:t}}=this.view;if(!this._intersectingTiles.length)return!1;const r=256/t.pixelSize;return this._intersectingTiles.every(t=>ce(t.radius*r,e))}};function ae(e,t){t.hasZ=!0,t.rings.forEach(t=>t.forEach(t=>t[2]=Y(e,t,"ground")??0))}function le(e,t,r){return e*(r-t)+t}function ue(e,t){const{boundingRect:r,eastVector:o,northVector:i,upVector:n}=e;k(t.cut,o,i,n,ge),k(t.fill,o,i,n,ye);const s=.5*(r[0]+r[2]),a=.5*(r[1]+r[3]),l=Math.min(ge[2],ye[2]),u=Math.max(ge[2],ye[2]),p=.5*(l+u);return v(_e,o,s),_(_e,_e,i,a),_(_e,_e,n,p),w(ve,.5*(r[2]-r[0]),.5*(r[3]-r[1]),.5*(u-l)),b(we,n),new $(_e,ve,f(be,we,o,i))}function pe(e){if(!e)return null;let t=null,r=null,o=0;for(const i of e)t||(t=[i[0],i[1]]),r?o+=g(r,i):r=[0,0],r[0]=i[0],r[1]=i[1];return t&&r&&(o+=g(r,t)),Math.sqrt(o)}function*me(e){const t=y();for(let r=0;r<e.length;r++)t[0]=e[r][0],t[1]=e[r][1],yield t}e([p()],se.prototype,"_projectedGeometry",null),e([p()],se.prototype,"_localOrigin",null),e([p()],se.prototype,"elevationAlignedGeometry",null),e([p()],se.prototype,"targetGeometry",null),e([p()],se.prototype,"_targetGeometryRenderInfo",null),e([p({constructOnly:!0})],se.prototype,"analysis",void 0),e([p({constructOnly:!0})],se.prototype,"analysisViewData",void 0),e([p({constructOnly:!0})],se.prototype,"view",void 0),e([p()],se.prototype,"updating",null),e([p()],se.prototype,"result",null),e([p()],se.prototype,"depthExtremaPositions",void 0),e([p()],se.prototype,"analysisObb",void 0),e([p()],se.prototype,"error",null),e([p()],se.prototype,"_imLayerViewsAffectingMeasurement",null),e([p()],se.prototype,"_insufficientDataError",null),e([p()],se.prototype,"_perimeterTooLargeError",null),e([p()],se.prototype,"_perimeterTooLargeLocalError",null),e([p()],se.prototype,"_perimeterTooLargeGlobalError",null),e([p()],se.prototype,"_unsupportedCoordinateSystemError",null),e([p()],se.prototype,"_unsupportedLayerTransparencyError",null),e([p()],se.prototype,"_perimeterForError",null),e([p()],se.prototype,"_computation",void 0),e([p({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([p()],se.prototype,"_rawResult",void 0),e([p()],se.prototype,"_sufficientDataCoverage",void 0),se=e([m("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillController")],se);const ce=(e,t)=>e<(t.width+t.height)/2,he=H(),fe=H(),de=I(),ge=j(),ye=j(),_e=j(),ve=j(),we=j(),be=d(),je=new Array(8).fill(0).map(()=>j()),Ee=j();export{se as VolumeMeasurementCutFillController};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,destroyMaybe as r,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as o}from"../../../core/promiseUtils.js";import{initial as n,watch as a,when as l}from"../../../core/reactiveUtils.js";import{schedule as c}from"../../../core/scheduling.js";import{unitFromRESTJSON as h,convertUnit as d}from"../../../core/units.js";import{property as u,subclass as m}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as p,invert as f}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as b,IDENTITY as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as y}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as _}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as v,sub as w,dot as C,set as x}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as T,freeze as j,clone as E,ZEROS as R,fromValues as M}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as O,clone as S,ONES as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as U,isMars as H,getReferenceEllipsoid as D,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import P from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as k}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as A}from"../../../geometry/projection/projectVectorToVector.js";import{create as F}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as G}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as z,isWebMercator as B,equals as N,isGeographic as W,isCGCS2000 as q}from"../../../geometry/support/spatialReferenceUtils.js";import X from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4f as $,BufferViewVec4u8 as Z,BufferViewVec4u16 as Y,BufferViewVec3f as J,BufferViewVec3u8 as K,BufferViewVec3u16 as Q,BufferViewVec2f as ee,BufferViewUint32 as te,BufferViewUint16 as ie}from"../../../geometry/support/buffer/BufferView.js";import re from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as se,validateMeshData as oe,makeCacheKey as ne}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as ae}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as le}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as ce}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as he}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as de,removeLayerViewFromWasm as ue,getLyr3DWasm as me}from"./Lyr3DWasm.js";import{toWasmModification as pe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as fe}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as be}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ge,alphaModeConversion as ye,faceCullingConversion as _e,wrapModeConversion as ve}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as we}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as Ce}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as xe}from"../state/Frustum.js";import{ElevationRange as Te}from"../support/ElevationRange.js";import{toBoundingRect as je}from"../support/extentUtils.js";import{Obb as Ee}from"../support/orientedBoundingBox.js";import{glLayout as Re}from"../support/buffer/glUtil.js";import{ComponentGeometryParameters as Me,SourceGeometry as Oe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Se}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ve}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as Ue}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as He}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as De}from"../webgl-engine/materials/pbrUtils.js";import Ie from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Pe,isInEffectiveScaleRange as ke,validateScaleRange as Le}from"../../support/layerViewUtils.js";import{TaskPriority as Ae}from"../../support/Scheduler.js";import{TextureCompressionTracker as Fe}from"../../support/TextureCompressionTracker.js";import{CompressedTextureFormat as Ge,SizedPixelFormat as ze}from"../../webgl/enums.js";import{alphaCutoff as Be}from"../../../webscene/support/AlphaCutoff.js";var Ne;function We(e,t,i){if("image/vnd-ms.dds"===t)switch(i){case"Dxt1":return Ge.COMPRESSED_RGB_S3TC_DXT1_EXT;case"Dxt5":return Ge.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if("image/ktx2"===t)return null;switch(e){case 33319:return ze.RG8;case 6407:return ze.RGB8;case 6408:return ze.RGBA8;case 6403:return ze.R8;default:return null}}let qe=class extends(ce(Ie)){static{Ne=be}constructor(e){super(e),this[Ne]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.drapeTargetType=1,this.fullExtentInLocalViewSpatialReference=null,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Fe,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Ae.TILES3D,this),this._frustum=new xe(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{o(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._workerHandle=new le(we(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),n),!this._canProjectWithoutEngine())throw Pe("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._initializationController=new AbortController;const t=de(this,this._initializationController.signal).then(t=>{o(this._initializationController.signal),this._wasmLayerId=t,this._intersectionHandler=new Ce(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),n),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),n),this._elevationProvider=new fe({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([a(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),l(()=>this.fullOpacity,()=>this._opacityChange()),a(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),n)]),this._initializationController=null});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){if(this._initializationController=i(this._initializationController),this._dbg(2,"Tiles3DLayerView3D destroy() called"),this._workerHandle?.destroyContextAndSelf(this.uid),ue(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider){const e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(const{componentObjects:i}of e)for(const{obb:e}of i)if(!t(e))return}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null}this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=r(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(r=>{const s=r.obb?.intersectsFrustum(e)??!1;s!==r.isVisible&&(r.isVisible=s,s?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,s)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(s,r.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,r){this._intersectionHandler.intersectRay(e,t,i,r,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=pe(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=F();this._layerClippingArea=je(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=c(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ae(e))}get _wasm(){return me(this.view)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||ke(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Le(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new he(this.usedMemory,s,o,Ze(t),Ze(e),Ze(r),Ze(i))}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(z(this.view.renderSpatialReference)||B(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&N(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=se(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!W(t)&&t.wkid&&-1!==t.wkid&&(i=h(X.units[X[t.wkid]])),i&&(e=new P({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===G(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=d(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ae(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new Te(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new Te;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,r=i.isWGS84||i.isWebMercator||q(i)||U(i)||H(i);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);const s=D(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=v(T(),n),c=500,h=Math.max(o[2],c),d=h+s,u=Math.sqrt(d**2-s**2),m=Math.abs(Math.atan2(u,s))*s,p=h>.5*s?.5*Math.PI*s:m,f=T();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:r}=t;if(i<0)return;w(f,r,o);const s=C(f,l);Math.abs(s)<p&&s+i>a&&s-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!oe(t))throw new Error("meshData not valid");const i=new Map;let r;try{r=this._createPrimitiveTextureBundles(t,i)}catch(o){throw i.forEach(e=>this._stage?.removeTexture(e)),o}let s=null;try{if(s=await this._createRenderableMain(t,r),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");const{tileObb:o,componentObjects:n,elevationRange:a}=s;let l=0,c=0,h=0;for(const e of n){const{texture:t,textureMetallicRoughness:i,textureEmissive:r,textureOcclusion:s,textureNormal:o}=e.renderable.drawParameters;l+=(t?.usedMemory??0)+(i?.usedMemory??0)+(r?.usedMemory??0)+(s?.usedMemory??0)+(o?.usedMemory??0),c+=this._collection.getObjectGPUMemoryUsage(e),h+=e.intersectionGeometry.usedMemory}const d=Array.from(i.values()),u=new $e(e.handle,n,d,h,c,l,o,e.stableNodeId,e.nodeDepth,a);return this._lyrHandleToObjects.set(e.handle,u),()=>{this._memCache.put(ne(u.handle),u);const{usedMemory:e}=u;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(o){throw r.forEach(e=>e.cleanup()),s?.componentObjects.forEach(e=>this._collection.destroyObject(e)),i.forEach(e=>this._stage?.removeTexture(e)),o}}_createPrimitiveTextureBundles(e,t){const i=new Array,r=e.desc.prims.length;try{const s=e.desc;for(let o=0;o<r;o++){const r=s.prims[o].materialId,n=s.materials&&null!=r?s.materials[r]:null;let a=Promise.resolve(Je),l=null,c=null,h=null,d=null,u=null;if(n){const i="Pbr"===n.lightingModel;l=this._getTexture(n.baseColorTex,e,t),c=i?this._getTexture(n.metalTex,e,t):null,h=i?this._getTexture(n.emissiveTex,e,t):null,d=i?this._getTexture(n.occlusionTex,e,t):null,u=i?this._getTexture(n.normalTex,e,t):null;const r=[l,c,h,d,u].map(e=>e?.loadPromise??null);a=Promise.all(r)}i.push(new Ke(a,l,c,h,d,u))}}catch(s){throw i.forEach(e=>e.cleanup()),s}return i}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy");const i=new Array,r=e.desc,s=e.data.buffer,o=r.prims.length,n=j(...r.origin),a=this.view.basemapTerrain.spatialReference,l=this.view.state.isGlobal;let c=g;if(l){const e=y();k(I,n,e,a),c=p(b(),e)}if(null==r.obb)throw new Error("meshData.desc.obb undefined");const h=Ye(r.obb),d=l?D(this.view.spatialReference).radius:0,u=new Array;try{for(let i=0;i<o;i++){const e=r.prims[i],o=t[i];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(e));if(null==ge[e.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive."),o.cleanup();continue}const{positionView:n,normalsData:a,colorView:l,texCoord0Data:c,indicesView:h}=this.getBufferViews(e,s);if(null==n||null==h){o.cleanup();continue}const d=n.count,m=(e,t)=>null==e||e===d||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);m(null!=c?c.length/2:void 0,"numTexcoord")&&m(l?.count,"numColors")&&m(a?.length,"normals")?u.push({componentIndex:i,positionView:n,indicesView:h,texCoord0Data:c,colorView:l,normalsData:a}):o.cleanup()}const e=c!==g,m=e?f(b(),c)??g:g,{vertexProcessingOutputs:p,obbHalfSizeAccumulator:y,elevationRange:_}=await this._workerHandle.processTiles3DVertices(u,n,d,l,c,h,this._imVertexNormals&&!this._isUsedAsGroundLayer);if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");const v=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");p.length>0&&h.setHalfSize(y);for(const s of p){const{componentIndex:o,positionView:l,indicesView:c,layout:d,textureCoordinateType:u,interleavedVertexData:p,indices:f}=s,b=r.prims[o],g=t[o],y=h.clone(),_=Re(d),w=new Uint32Array([0,c.typedBuffer.length]),C=new Me(_,this._imShading?2:0,u,e?2:0),x=new Oe({interleavedVertexData:p,vertexCount:p.byteLength/_[0].stride,indexData:f},{positions:l.typedBuffer,indices:c.typedBuffer},w,C),j=this.view.renderSpatialReference,E=T(),R=[1,1,1];L(n,j,R,a)||this._dbg(3,"Unsupported coordinate system for IM overlay"),A(n,j,E,a);const M=v&&null!=b.materialId?v[b.materialId]:null,S=this._createComponentMaterialInitParameters(M,g);S.baseColorTexture||this._dbg(3,"No colour texture 1");const V=this._collection.createObject({toMapSpace:O(E[0],E[1],R[0],R[1]),transform:new Se(n,m),obb:y,geometry:x,elevationAlignable:!1},S);i.push(V)}const{fullExtent:w}=this.layer;return w?.hasZ&&w.zmax&&w.zmin&&(_.minElevation=Math.max(_.minElevation,w.zmin),_.maxElevation=Math.min(_.maxElevation,w.zmax)),{tileObb:h,componentObjects:i,elevationRange:_}}catch(m){throw i.forEach(e=>this._collection.destroyObject(e)),m}}_createComponentMaterialInitParameters(e,t){const i="Pbr"===(null!=e?e.lightingModel:"Unlit");let r=V,s=Be,o=1,n=!1,a=2,l=M(0,0,0);const c=E(De),h=t.baseColorTexture,d=t.metallicRoughnessTexture,u=t.emissionTexture,m=t.occlusionTexture,p=t.normalTexture;return e&&(r=S(e.baseColorFactor),s=e.alphaCutoff??Be,i&&(x(c,e.metallicFactor,e.roughnessFactor,0),e.emissiveFactor&&(l=e.emissiveFactor)),o=ye[e.alphaMode],n=e.isDoubleSided,a=_e[e.faceCulling??"NotSet"]),{isIntegratedMesh:!0,baseColor:r,textureAlphaCutoff:s,mrrFactors:c,baseColorTexture:h,metallicRoughnessTexture:d,normalTexture:p,occlusionTexture:m,emissionTexture:u,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:o,doubleSided:n,cullFace:a,isGround:this.layer.replacesTerrain,emissiveBaseColor:l,usePBR:i,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=ne(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const r=this._frustum,s=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(r)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),s.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(ne(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const r=this._lyrHandleToObjects.get(i);if(r){if(!r.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${r.stableNodeId}`);continue}const e=r.isVisible;this._visibleObjects.delete(r),r.isVisible=!1,r.isLoaded=!1,this._loadedObjects.delete(r),this._intersectionHandler.removeTile(r),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,r.elevationRange)),this._usedMemory-=r.usedMemory,this._cacheMemory+=r.usedMemory,s.push(r.obb),r.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(ne(i),r)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),s.length>0&&this._elevationProvider.notifyObjectsChanged(s),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:r,maxElevation:s}=t;return e?r<i.minElevation||s>i.maxElevation:r===i.minElevation||s===i.maxElevation}_getTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=i.get(r)??this._createTexture(e,t,i);return s?new Ve(this._stage.renderView.textures,s.id):null}_createTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=!!r.mipCount||s>1,n=ve[e.wrapMode??"None"];let a=r.alpha?6408:6407;const l=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let c=null,h=null,d=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(c=l,a=6403,h=""):"Rg8"===r.pixelFormat||"Ga8"===r.pixelFormat?(c=l,a=33319,h=""):"Rgb8"===r.pixelFormat?(c=l,a=6407,h=""):"Rgba8"===r.pixelFormat&&(c=l,a=6408,h="");break;case"Dxt1":c=l,a=6407,h="image/vnd-ms.dds";break;case"Dxt5":c=l,a=6408,h="image/vnd-ms.dds";break;case"Basis":c=l,a=6407,h="image/ktx2";break;case"Png":h="image/png",d=document.createElement("img");break;case"Jpeg":h="image/jpeg",d=document.createElement("img");break;case"Etc2":h="image/ktx",d=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(d&&h){const e=new Blob([l],{type:h});d.src=URL.createObjectURL(e),c=d}if(c&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=We(a,h,r.format),l=new Ue(c,{mipmap:o,maxAnisotropy:s,encoding:h,wrap:n,pixelFormat:a,internalFormat:t??void 0,immutable:null!=t,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(l),i.set(r,l),l}return null}getBufferViews(e,t){let i,r,s,o,n;for(let l=0;l<e.atrbs.length;l++){const n=e.atrbs[l],{view:c}=n,h=void 0,d=c.byteOffset+c.byteCount;try{switch(n.sem){case"Position":3!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+c+")"):i=new J(t,c.byteOffset,h,d);break;case"Normal":if(3!==c.ncomp||"F32"!==c.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+c+")");else{const e=new J(t,c.byteOffset,h,d);o=new Uint32Array(e.count),He(e.typedBuffer,new Int16Array(o.buffer,o.byteOffset,2*o.length))}break;case"TexCoord":2!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+c+")"):void 0===s&&(s=new ee(t,c.byteOffset,h,d).typedBuffer);break;case"Color":4===c.ncomp?("F32"===c.type&&(r=new $(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Z(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new Y(t,c.byteOffset,h,d))):3===c.ncomp&&("F32"===c.type&&(r=new J(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new K(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new Q(t,c.byteOffset,h,d))),null==r&&this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+c+")");break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+n.sem+"). Skipping vertex attribute.")}}catch(a){this._dbg(2,"Error Creating buffer ("+a+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":n=new ie(t,i.byteOffset,r,s);break;case"U32":n=new te(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==n&&null!=i){const e=i.count;n=n=e<65535?new ie(new Uint16Array(e).buffer):new te(new Uint32Array(e).buffer);for(let t=0;t<e;t++)n.set(t,t)}return{positionView:i,colorView:r,texCoord0Data:s,indicesView:n,normalsData:o}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},n),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([u()],qe.prototype,"fullOpacity",null),e([u({readOnly:!0})],qe.prototype,"ready",null),e([u({type:[re]})],qe.prototype,"_modifications",void 0),e([u()],qe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([u()],qe.prototype,"layer",void 0),e([u({readOnly:!0})],qe.prototype,"visibleAtCurrentScale",null),e([u({readOnly:!0})],qe.prototype,"_collection",null),e([u()],qe.prototype,"elevationOffset",null),e([u({readOnly:!0})],qe.prototype,"visibleElevationRange",null),e([u()],qe.prototype,"fullExtentInLocalViewSpatialReference",void 0),qe=e([m("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],qe);const Xe=qe;class $e{constructor(e,t,i,r,s,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const h=T();n?.getCenter(h),this._obbCenterX=h[0],this._obbCenterY=h[1],this._obbCenterZ=h[2];const d=n?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=n?Math.min(n.halfSizeX,n.halfSizeY,n.halfSizeZ):0,this._mbsCenter=n?n.getCenter(T()):R}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:r,_obbCenterZ:s}=this,o=i-e[0],n=r-e[1],a=s-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,r=e.radius,s=t+r,o=this._obbCenterX-i[0];if(o>s)return!1;const n=this._obbCenterY-i[1];if(n>s)return!1;const a=this._obbCenterZ-i[2];if(a>s)return!1;const l=o*o+n*n+a*a;if(l>s*s)return!1;if(l<=(this._obbShortestHalfsize+r)**2)return!0;const c=r-t;return c>0&&l<=c*c||(this.obb?.intersectSphere(e)??!0)}}function Ze(e){return Math.round(e/1048.576)/1e3}function Ye(e){return new Ee(e.center,e.halfSize,_(...e.quaternion))}const Je=new Array;class Ke{constructor(e,t,i,r,s,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=r,this.occlusionTexture=s,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{Xe as default};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,destroyMaybe as r,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as o,createAbortError as n}from"../../../core/promiseUtils.js";import{initial as a,watch as l,when as c}from"../../../core/reactiveUtils.js";import{schedule as h}from"../../../core/scheduling.js";import{unitFromRESTJSON as d,convertUnit as u}from"../../../core/units.js";import{property as m,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as f,invert as b}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as y,IDENTITY as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as _}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as w,sub as C,dot as x,set as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,freeze as E,clone as R,ZEROS as M,fromValues as O}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as S,clone as V,ONES as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as H,isMars as D,getReferenceEllipsoid as P,SphericalECEFSpatialReferenceLike as I}from"../../../geometry/ellipsoidUtils.js";import k from"../../../geometry/HeightModelInfo.js";import{computeTranslationToOriginAndRotation as L}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as A}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as G}from"../../../geometry/support/aaBoundingRect.js";import{isCompatible as z}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as B,isWebMercator as N,equals as W,isGeographic as q,isCGCS2000 as X}from"../../../geometry/support/spatialReferenceUtils.js";import $ from"../../../geometry/support/WKIDUnitConversion.js";import{BufferViewVec4f as Z,BufferViewVec4u8 as Y,BufferViewVec4u16 as J,BufferViewVec3f as K,BufferViewVec3u8 as Q,BufferViewVec3u16 as ee,BufferViewVec2f as te,BufferViewUint32 as ie,BufferViewUint16 as re}from"../../../geometry/support/buffer/BufferView.js";import se from"../../../layers/support/SceneModification.js";import{getHeightModelInfoFromVCS as oe,validateMeshData as ne,makeCacheKey as ae}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as le}from"../../../support/elevationInfoUtils.js";import{IntegratedMesh3DTilesLayerWorkerHandle as ce}from"./IntegratedMesh3DTilesLayerWorkerHandle.js";import{LayerView3D as he}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as de}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ue,removeLayerViewFromWasm as me,getLyr3DWasm as pe}from"./Lyr3DWasm.js";import{toWasmModification as fe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as be}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as ye}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ge,alphaModeConversion as _e,faceCullingConversion as ve,wrapModeConversion as we}from"./support/lyr3dTypeConversions.js";import{makeScheduleFunction as Ce}from"./support/makeScheduleFunction.js";import{Tiles3DMeshIntersectionHandler as xe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as Te}from"../state/Frustum.js";import{ElevationRange as je}from"../support/ElevationRange.js";import{toBoundingRect as Ee}from"../support/extentUtils.js";import{Obb as Re}from"../support/orientedBoundingBox.js";import{glLayout as Me}from"../support/buffer/glUtil.js";import{ComponentGeometryParameters as Oe,SourceGeometry as Se}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Ve}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ue}from"../webgl-engine/core/material/RenderTexture.js";import{ManagedTexture as He}from"../webgl-engine/lib/ManagedTexture.js";import{compressNormals as De}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Pe}from"../webgl-engine/materials/pbrUtils.js";import Ie from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ke,isInEffectiveScaleRange as Le,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TaskPriority as Fe}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ge}from"../../support/TextureCompressionTracker.js";import{CompressedTextureFormat as ze,SizedPixelFormat as Be}from"../../webgl/enums.js";import{alphaCutoff as Ne}from"../../../webscene/support/AlphaCutoff.js";var We;function qe(e,t,i){if("image/vnd-ms.dds"===t)switch(i){case"Dxt1":return ze.COMPRESSED_RGB_S3TC_DXT1_EXT;case"Dxt5":return ze.COMPRESSED_RGBA_S3TC_DXT5_EXT;default:return null}if("image/ktx2"===t)return null;switch(e){case 33319:return Be.RG8;case 6407:return Be.RGB8;case 6408:return Be.RGBA8;case 6403:return Be.R8;default:return null}}let Xe=class extends(he(Ie)){static{We=ye}constructor(e){super(e),this[We]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this._useEsriCrs=!1,this.drapeTargetType=1,this.fullExtentInLocalViewSpatialReference=null,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Ge,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(Fe.TILES3D,this),this._frustum=new Te(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{o(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._workerHandle=new ce(Ce(e.resourceController)),this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),a),!this._canProjectWithoutEngine())throw ke("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._initializationController=new AbortController;const t=ue(this,this._initializationController.signal).then(t=>{o(this._initializationController.signal),this._wasmLayerId=t,this._intersectionHandler=new xe(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),a),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),a),this._elevationProvider=new be({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([l(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),c(()=>this.fullOpacity,()=>this._opacityChange()),l(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),a)]),this._initializationController=null,this.addHandles(c(()=>this._replacesTerrain&&this._wasm?.isTerrainReady,()=>{this.layer.queryElevationCallback=(e,t)=>this._queryElevation(e,t)}))});this.addResolvingPromise(t)}destroy(){if(this._initializationController=i(this._initializationController),this._dbg(2,"Tiles3DLayerView3D destroy() called"),this._workerHandle?.destroyContextAndSelf(this.uid),me(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider){const e=Array.from(this._lyrHandleToObjects.values()),t=e.reduce((e,{componentObjects:t})=>e+t.length,0);this._elevationProvider.notifyObjectsChangedFunctional(t,t=>{for(const{componentObjects:i}of e)for(const{obb:e}of i)if(!t(e))return}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null}this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._frameTask.remove(),this._updatingHandles=r(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(r=>{const s=r.obb?.intersectsFrustum(e)??!1;s!==r.isVisible&&(r.isVisible=s,s?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,s)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(s,r.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,r){this._intersectionHandler.intersectRay(e,t,i,r,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.useEsriCrs?this.layer.supportedSpatialReferences[1]:this.layer.supportedSpatialReferences[0],t=fe(this._layerClippingArea,this._modifications,e,this.view.state.isGlobal);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=G();this._layerClippingArea=Ee(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=h(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,le(e))}get _wasm(){return pe(this.view)}_queryElevation(e,t){return this.destroying||this.destroyed?Promise.reject(n()):this._wasm?.queryElevation(this,e,t)??Promise.reject(n())}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get useEsriCrs(){return this._useEsriCrs}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Le(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new de(this.usedMemory,s,o,Ye(t),Ye(e),Ye(r),Ye(i))}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(B(this.view.renderSpatialReference)||N(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&W(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=oe(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!q(t)&&t.wkid&&-1!==t.wkid&&(i=d($.units[$[t.wkid]])),i&&(e=new k({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===z(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=u(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return le(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new je(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new je;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,r=i.isWGS84||i.isWebMercator||X(i)||H(i)||D(i);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);const s=P(i).radius,{eye:o,viewForward:n,near:a}=t.state.contentCamera,l=w(j(),n),c=500,h=Math.max(o[2],c),d=h+s,u=Math.sqrt(d**2-s**2),m=Math.abs(Math.atan2(u,s))*s,p=h>.5*s?.5*Math.PI*s:m,f=j();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:r}=t;if(i<0)return;C(f,r,o);const s=x(f,l);Math.abs(s)<p&&s+i>a&&s-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun}runTask(e){this._frameTask.processQueue(e)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{meshData:t}=e;if(!ne(t))throw new Error("meshData not valid");const i=new Map;let r;try{r=this._createPrimitiveTextureBundles(t,i)}catch(o){throw i.forEach(e=>this._stage?.removeTexture(e)),o}let s=null;try{if(s=await this._createRenderableMain(t,r),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");const{tileObb:o,componentObjects:n,elevationRange:a}=s;let l=0,c=0,h=0;for(const e of n){const{texture:t,textureMetallicRoughness:i,textureEmissive:r,textureOcclusion:s,textureNormal:o}=e.renderable.drawParameters;l+=(t?.usedMemory??0)+(i?.usedMemory??0)+(r?.usedMemory??0)+(s?.usedMemory??0)+(o?.usedMemory??0),c+=this._collection.getObjectGPUMemoryUsage(e),h+=e.intersectionGeometry.usedMemory}const d=Array.from(i.values()),u=new Ze(e.handle,n,d,h,c,l,o,e.stableNodeId,e.nodeDepth,a);return this._lyrHandleToObjects.set(e.handle,u),()=>{this._memCache.put(ae(u.handle),u);const{usedMemory:e}=u;return this._cacheMemory+=e,{memUsageBytes:e}}}catch(o){throw r.forEach(e=>e.cleanup()),s?.componentObjects.forEach(e=>this._collection.destroyObject(e)),i.forEach(e=>this._stage?.removeTexture(e)),o}}_createPrimitiveTextureBundles(e,t){const i=new Array,r=e.desc.prims.length;try{const s=e.desc;for(let o=0;o<r;o++){const r=s.prims[o].materialId,n=s.materials&&null!=r?s.materials[r]:null;let a=Promise.resolve(Ke),l=null,c=null,h=null,d=null,u=null;if(n){const i="Pbr"===n.lightingModel;l=this._getTexture(n.baseColorTex,e,t),c=i?this._getTexture(n.metalTex,e,t):null,h=i?this._getTexture(n.emissiveTex,e,t):null,d=i?this._getTexture(n.occlusionTex,e,t):null,u=i?this._getTexture(n.normalTex,e,t):null;const r=[l,c,h,d,u].map(e=>e?.loadPromise??null);a=Promise.all(r)}i.push(new Qe(a,l,c,h,d,u))}}catch(s){throw i.forEach(e=>e.cleanup()),s}return i}async _createRenderableMain(e,t){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain called after destroy");const i=new Array,r=e.desc,s=e.data.buffer,o=r.prims.length,n=E(...r.origin),a=this.view.basemapTerrain.spatialReference,l=this.view.state.isGlobal;let c=g;if(l){const e=_();L(I,n,e,a),c=f(y(),e)}if(null==r.obb)throw new Error("meshData.desc.obb undefined");const h=Je(r.obb),d=l?P(this.view.spatialReference).radius:0,u=new Array;try{for(let i=0;i<o;i++){const e=r.prims[i],o=t[i];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(e));if(null==ge[e.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive."),o.cleanup();continue}const{positionView:n,normalsData:a,colorView:l,texCoord0Data:c,indicesView:h}=this.getBufferViews(e,s);if(null==n||null==h){o.cleanup();continue}const d=n.count,m=(e,t)=>null==e||e===d||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);m(null!=c?c.length/2:void 0,"numTexcoord")&&m(l?.count,"numColors")&&m(a?.length,"normals")?u.push({componentIndex:i,positionView:n,indicesView:h,texCoord0Data:c,colorView:l,normalsData:a}):o.cleanup()}const e=c!==g,m=e?b(y(),c)??g:g,{vertexProcessingOutputs:p,obbHalfSizeAccumulator:f,elevationRange:_}=await this._workerHandle.processTiles3DVertices(u,n,d,l,c,h,this._imVertexNormals&&!this._isUsedAsGroundLayer);if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");const v=r.materials;if(await Promise.all(t.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderableMain aborted due to destroyed instance");p.length>0&&h.setHalfSize(f);for(const s of p){const{componentIndex:o,positionView:l,indicesView:c,layout:d,textureCoordinateType:u,interleavedVertexData:p,indices:f}=s,b=r.prims[o],y=t[o],g=h.clone(),_=Me(d),w=new Uint32Array([0,c.typedBuffer.length]),C=new Oe(_,this._imShading?2:0,u,e?2:0),x=new Se({interleavedVertexData:p,vertexCount:p.byteLength/_[0].stride,indexData:f},{positions:l.typedBuffer,indices:c.typedBuffer},w,C),T=this.view.renderSpatialReference,E=j(),R=[1,1,1];A(n,T,R,a)||this._dbg(3,"Unsupported coordinate system for IM overlay"),F(n,T,E,a);const M=v&&null!=b.materialId?v[b.materialId]:null,O=this._createComponentMaterialInitParameters(M,y);O.baseColorTexture||this._dbg(3,"No colour texture 1");const V=this._collection.createObject({toMapSpace:S(E[0],E[1],R[0],R[1]),transform:new Ve(n,m),obb:g,geometry:x,elevationAlignable:!1},O);i.push(V)}const{fullExtent:w}=this.layer;return w?.hasZ&&w.zmax&&w.zmin&&(_.minElevation=Math.max(_.minElevation,w.zmin),_.maxElevation=Math.min(_.maxElevation,w.zmax)),{tileObb:h,componentObjects:i,elevationRange:_}}catch(m){throw i.forEach(e=>this._collection.destroyObject(e)),m}}_createComponentMaterialInitParameters(e,t){const i="Pbr"===(null!=e?e.lightingModel:"Unlit");let r=U,s=Ne,o=1,n=!1,a=2,l=O(0,0,0);const c=R(Pe),h=t.baseColorTexture,d=t.metallicRoughnessTexture,u=t.emissionTexture,m=t.occlusionTexture,p=t.normalTexture;return e&&(r=V(e.baseColorFactor),s=e.alphaCutoff??Ne,i&&(T(c,e.metallicFactor,e.roughnessFactor,0),e.emissiveFactor&&(l=e.emissiveFactor)),o=_e[e.alphaMode],n=e.isDoubleSided,a=ve[e.faceCulling??"NotSet"]),{isIntegratedMesh:!0,baseColor:r,textureAlphaCutoff:s,mrrFactors:c,baseColorTexture:h,metallicRoughnessTexture:d,normalTexture:p,occlusionTexture:m,emissionTexture:u,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:o,doubleSided:n,cullFace:a,isGround:this.layer.replacesTerrain,emissiveBaseColor:l,usePBR:i,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=ae(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const r=this._frustum,s=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(r)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),s.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(ae(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const r=this._lyrHandleToObjects.get(i);if(r){if(!r.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${r.stableNodeId}`);continue}const e=r.isVisible;this._visibleObjects.delete(r),r.isVisible=!1,r.isLoaded=!1,this._loadedObjects.delete(r),this._intersectionHandler.removeTile(r),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,r.elevationRange)),this._usedMemory-=r.usedMemory,this._cacheMemory+=r.usedMemory,s.push(r.obb),r.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(ae(i),r)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),s.length>0&&this._elevationProvider.notifyObjectsChanged(s),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:r,maxElevation:s}=t;return e?r<i.minElevation||s>i.maxElevation:r===i.minElevation||s===i.maxElevation}_getTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=i.get(r)??this._createTexture(e,t,i);return s?new Ue(this._stage.renderView.textures,s.id):null}_createTexture(e,t,i){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const s=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,o=!!r.mipCount||s>1,n=we[e.wrapMode??"None"];let a=r.alpha?6408:6407;const l=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let c=null,h=null,d=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(c=l,a=6403,h=""):"Rg8"===r.pixelFormat||"Ga8"===r.pixelFormat?(c=l,a=33319,h=""):"Rgb8"===r.pixelFormat?(c=l,a=6407,h=""):"Rgba8"===r.pixelFormat&&(c=l,a=6408,h="");break;case"Dxt1":c=l,a=6407,h="image/vnd-ms.dds";break;case"Dxt5":c=l,a=6408,h="image/vnd-ms.dds";break;case"Basis":c=l,a=6407,h="image/ktx2";break;case"Png":h="image/png",d=document.createElement("img");break;case"Jpeg":h="image/jpeg",d=document.createElement("img");break;case"Etc2":h="image/ktx",d=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(d&&h){const e=new Blob([l],{type:h});d.src=URL.createObjectURL(e),c=d}if(c&&null!=h){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=qe(a,h,r.format),l=new He(c,{mipmap:o,maxAnisotropy:s,encoding:h,wrap:n,pixelFormat:a,internalFormat:t??void 0,immutable:null!=t,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(l),i.set(r,l),l}return null}getBufferViews(e,t){let i,r,s,o,n;for(let l=0;l<e.atrbs.length;l++){const n=e.atrbs[l],{view:c}=n,h=void 0,d=c.byteOffset+c.byteCount;try{switch(n.sem){case"Position":3!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+c+")"):i=new K(t,c.byteOffset,h,d);break;case"Normal":if(3!==c.ncomp||"F32"!==c.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+c+")");else{const e=new K(t,c.byteOffset,h,d);o=new Uint32Array(e.count),De(e.typedBuffer,new Int16Array(o.buffer,o.byteOffset,2*o.length))}break;case"TexCoord":2!==c.ncomp||"F32"!==c.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+c+")"):void 0===s&&(s=new te(t,c.byteOffset,h,d).typedBuffer);break;case"Color":4===c.ncomp?("F32"===c.type&&(r=new Z(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Y(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new J(t,c.byteOffset,h,d))):3===c.ncomp&&("F32"===c.type&&(r=new K(t,c.byteOffset,h,d)),"U8"===c.type&&(r=new Q(t,c.byteOffset,h,d)),"U16"===c.type&&(r=new ee(t,c.byteOffset,h,d))),null==r&&this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+c+")");break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+n.sem+"). Skipping vertex attribute.")}}catch(a){this._dbg(2,"Error Creating buffer ("+a+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":n=new re(t,i.byteOffset,r,s);break;case"U32":n=new ie(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==n&&null!=i){const e=i.count;n=n=e<65535?new re(new Uint16Array(e).buffer):new ie(new Uint32Array(e).buffer);for(let t=0;t<e;t++)n.set(t,t)}return{positionView:i,colorView:r,texCoord0Data:s,indicesView:n,normalsData:o}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},a),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([m()],Xe.prototype,"fullOpacity",null),e([m({readOnly:!0})],Xe.prototype,"ready",null),e([m({type:[se]})],Xe.prototype,"_modifications",void 0),e([m()],Xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([m()],Xe.prototype,"layer",void 0),e([m({readOnly:!0})],Xe.prototype,"visibleAtCurrentScale",null),e([m({readOnly:!0})],Xe.prototype,"_collection",null),e([m()],Xe.prototype,"elevationOffset",null),e([m({readOnly:!0})],Xe.prototype,"visibleElevationRange",null),e([m()],Xe.prototype,"fullExtentInLocalViewSpatialReference",void 0),Xe=e([p("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Xe);const $e=Xe;class Ze{constructor(e,t,i,r,s,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const h=j();n?.getCenter(h),this._obbCenterX=h[0],this._obbCenterY=h[1],this._obbCenterZ=h[2];const d=n?.radius??-1;this._obbRadius=d,this._obbRadiusSquared=d*d,this._obbShortestHalfsize=n?Math.min(n.halfSizeX,n.halfSizeY,n.halfSizeZ):0,this._mbsCenter=n?n.getCenter(j()):M}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:r,_obbCenterZ:s}=this,o=i-e[0],n=r-e[1],a=s-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,r=e.radius,s=t+r,o=this._obbCenterX-i[0];if(o>s)return!1;const n=this._obbCenterY-i[1];if(n>s)return!1;const a=this._obbCenterZ-i[2];if(a>s)return!1;const l=o*o+n*n+a*a;if(l>s*s)return!1;if(l<=(this._obbShortestHalfsize+r)**2)return!0;const c=r-t;return c>0&&l<=c*c||(this.obb?.intersectSphere(e)??!0)}}function Ye(e){return Math.round(e/1048.576)/1e3}function Je(e){return new Re(e.center,e.halfSize,v(...e.quaternion))}const Ke=new Array;class Qe{constructor(e,t,i,r,s,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=r,this.occlusionTexture=s,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}export{$e as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{intersectsSphere as e}from"../../../../geometry/support/frustum.js";import{I3sTarget as t}from"./Intersector.js";import{IntersectorResultRay as n}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as r}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as s}from"../../webgl-engine/lib/verticalOffsetUtils.js";class i{constructor(e,t){this.node=e,this.objectHandle=t}}class l{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,t){this._needVerticalOffset=e&&1===t}intersectRay(e,i,l,c,a,d){const u=2===e.options.store,b=e.ray.direction;let h=e=>e,f=e=>e;const y=s(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:R,tolerance:m}=e,p=new r(m,d,e.options.normalRequired),v=e=>{if(0===e.childrenLoaded)return!1;const t=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(t&&!f(t).intersectRay(l,b,m))};for(const{node:r,objectHandle:s}of this._traverseNodeHierarchy(v)){const a=r.serviceObbInRenderSR?.isValid?r.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:d}=r;!s||!a&&d.isValid&&!o(h(d),l,b,m)||null!=r.geometryObbInRenderSR&&!f(r.geometryObbInRenderSR).intersectRay(l,b,m)||this._collection.intersectRay(s,l,c,y,p,(s,o,a,d)=>{if(o<0||null!=i&&!i(l,c,o))return;const b=e=>{const n=new t(this.layerViewUid,this.sublayerId,r.index,s,d);e.set(this.type,n,o,a)};if(this.isGround&&(null==R.ground.distance||o<R.ground.distance)&&b(R.ground),!e.options.isFiltered&&((null==R.min.distance||o<R.min.distance)&&b(R.min),(null==R.max.distance||o>R.max.distance)&&b(R.max),u)){const t=new n(e.ray);b(t),e.results.all.push(t)}})}}*intersectScreenPolygon(n,r){if(null==n.camera)return;const i=s(this._needVerticalOffset?0:null),l=t=>{if(0===t.childrenLoaded)return!1;const n=t.serviceObbInRenderSR?.isValid?t.serviceObbInRenderSR:null;if(null!=n){if(!n.intersectsFrustumConservativeApproximation(r.broadPhaseFrustum))return!1}else{const n=t.serviceMbsInRenderSRElevationAdjusted;if(n.isValid&&!e(r.broadPhaseFrustum,n))return!1}return!0};for(const{node:e,objectHandle:s}of this._traverseNodeHierarchy(l))null!=s&&s.visible&&(null==e.geometryObbInRenderSR||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(r.broadPhaseFrustum))&&(this._collection.intersectScreenPolygon(s,n,r,i,(r,s,i,l)=>{n.polygonResults.add(this.type,new t(this.layerViewUid,this.sublayerId,e.index,r,l),s)}),yield)}}function o(e,t,n,r=0){const s=e.radius+r,i=t[0]-e.center[0],l=t[1]-e.center[1],o=t[2]-e.center[2],[c,a,d]=n,u=c*i+a*l+d*o;return u*u-(c*c+a*a+d*d)*(i*i+l*l+o*o-s*s)>=0}export{l as I3SIntersectionHandler,i as TraversedIntersectionNode};
2
+ import{intersectsSphere as e}from"../../../../geometry/support/frustum.js";import{I3sTarget as r}from"./Intersector.js";import{IntersectorResultRay as t}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as n}from"../../webgl-engine/lib/RayIntersections.js";import{getVerticalOffsetI3S as s}from"../../webgl-engine/lib/verticalOffsetUtils.js";class i{constructor(e,r){this.node=e,this.objectHandle=r}}class l{constructor(e){this.type=2,this._needVerticalOffset=!1,this.layerViewUid=e.layerViewUid,this.sublayerId=e.sublayerId,this._collection=e.collection,this._traverseNodeHierarchy=e.traverseNodeHierarchy,this.slicePlaneEnabled=e.slicePlaneEnabled,this.isGround=e.isGround}updateElevationAlignState(e,r){this._needVerticalOffset=e&&1===r}intersectRay(e,i,l,c,a,d){const u=2===e.options.store,b=e.ray.direction;let h=e=>e,f=e=>e;const y=s(e.verticalOffset??(this._needVerticalOffset?0:null));null!=e.verticalOffset&&null!=y&&(h=e=>y.applyToMbs(e),f=e=>y.applyToObb(e));const{results:R,tolerance:m}=e,p=new n(m,d,e.options.normalRequired),v=e=>{if(0===e.childrenLoaded)return!1;const r=e.serviceObbInRenderSR?.isValid?e.serviceObbInRenderSR:null;return!(r&&!f(r).intersectRay(l,b,m))};for(const{node:n,objectHandle:s}of this._traverseNodeHierarchy(v)){const a=n.serviceObbInRenderSR?.isValid?n.serviceObbInRenderSR:null,{serviceMbsInRenderSRElevationAdjusted:d}=n;!s||!a&&d.isValid&&!o(h(d),l,b,m)||null!=n.geometryObbInRenderSR&&!f(n.geometryObbInRenderSR).intersectRay(l,b,m)||this._collection.intersectRay(s,l,c,y,p,(s,o,a,d,b)=>{if(o<0||null!=i&&!i(l,c,o))return;const h=e=>{const t=new r(this.layerViewUid,this.sublayerId,n.index,b,d);e.set(this.type,t,s,o,a)};if(this.isGround&&(null==R.ground.renderDistance||o<R.ground.renderDistance)&&h(R.ground),!e.options.isFiltered&&((null==R.min.renderDistance||o<R.min.renderDistance)&&h(R.min),(null==R.max.renderDistance||s>R.max.renderDistance)&&h(R.max),u)){const r=new t(e.ray);h(r),e.results.all.push(r)}})}}*intersectScreenPolygon(t,n){if(null==t.camera)return;const i=s(this._needVerticalOffset?0:null),l=r=>{if(0===r.childrenLoaded)return!1;const t=r.serviceObbInRenderSR?.isValid?r.serviceObbInRenderSR:null;if(null!=t){if(!t.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))return!1}else{const t=r.serviceMbsInRenderSRElevationAdjusted;if(t.isValid&&!e(n.broadPhaseFrustum,t))return!1}return!0};for(const{node:e,objectHandle:s}of this._traverseNodeHierarchy(l))null!=s&&s.visible&&(null==e.geometryObbInRenderSR||e.geometryObbInRenderSR.intersectsFrustumConservativeApproximation(n.broadPhaseFrustum))&&(this._collection.intersectScreenPolygon(s,t,n,i,(n,s,i,l)=>{t.polygonResults.add(this.type,new r(this.layerViewUid,this.sublayerId,e.index,n,l),s)}),yield)}}function o(e,r,t,n=0){const s=e.radius+n,i=r[0]-e.center[0],l=r[1]-e.center[1],o=r[2]-e.center[2],[c,a,d]=t,u=c*i+a*l+d*o;return u*u-(c*c+a*a+d*d)*(i*i+l*l+o*o-s*s)>=0}export{l as I3SIntersectionHandler,i as TraversedIntersectionNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{subtract as o,length as a,scale as l,negate as h,dot as c,squaredLength as d,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _,offset as f,contains as P,containsPoint as x,set as b,positiveInfinity as S,equals as w}from"../../../../geometry/support/aaBoundingBox.js";import{create as R}from"../../../../geometry/support/plane.js";import{fromPoints as y}from"../../../../geometry/support/ray.js";import{Sphere as z}from"../../../../geometry/support/sphere.js";import{PclTarget as v}from"./Intersector.js";import{PointCloudHighlights as j}from"./PointCloudHighlights.js";import{isColor as q,isHighlight as F,isDepth as H}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as O}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResultRay as A}from"../../webgl-engine/lib/IntersectorResult.js";import{screenPolygonIntersectsCircle as E}from"../../webgl-engine/lib/screenPolygonOverlapUtils.js";import{VertexArrayObject as I}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as B,g as M}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as V,positionsLayout as N,colorsLayout as T}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as C}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as U}from"../../../webgl/enums.js";import{VertexBuffer as D}from"../../../webgl/VertexBuffer.js";let W=class extends O{constructor(e){super(e),this.type=6,this.isGround=!1,this._passParameters=new B,this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlights:(e,t,i)=>this._addHighlights(e,t,i),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[2,e=>q(e)||F(e)&&!this._highlights.empty],[3,e=>H(e)]]),this.point=g(),this.intersectionRayDir=g(),this.intersectionPlane=R(),this.nodeOriginOffset=g(),this.nodeBoundingBox=_(),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new C,this._nodes=new i,this._highlightsInOrder=null}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersectRay(e,t,i,s){const{point:r,intersectionRayDir:n,nodeOriginOffset:u,intersectionPlane:p,layerViewUid:b,nodeBoundingBox:S}=this,w=y(i,s),R=this._passParameters,j=e.camera.perScreenPixelRatio/2,q=e.camera.near;o(n,s,i);const F=1/a(n);l(n,n,F);const H=g();h(H,n),m(p,n[0],n[1],n[2],-c(n,i));const O=new Y,E=new Y,I=new Array,B=_(R.clipBox);f(B,-i[0],-i[1],-i[2],B);const M=new J;this._nodes.forAll(a=>{const{isLeaf:l,coordinates:h}=a,g=a.splatSize*R.scaleFactor;let{min:m,max:_}=a.obb.signedDistanceRangePlane(p);m-=L(g,m+q,R,j,l),_-=L(g,_+q,R,j,l);const y=_<0,v=null!=O.dist&&null!=E.dist&&O.dist<m*F&&E.dist>_*F;if(y||v)return;const A=G(g,_+q,R,j,l);if(!new z(a.obb.getCenter($),a.obb.radius+A).intersectRay(w))return;if(!a.obb.intersectRay(i,n,A))return;const V=A*A;a.obb.toAaBoundingBox(S),f(S,-i[0],-i[1],-i[2],S);const N=!P(B,S);o(u,a.origin,i);const T=h.length/3;for(let o=0;o<T;o++){const p=3*o;if(r[0]=u[0]+h[p],r[1]=u[1]+h[p+1],r[2]=u[2]+h[p+2],N&&!x(B,r))continue;const m=c(r,n),_=m*m,f=d(r)-_;if(f>V)continue;const{distance:P,radius:S}=K(M,g,m+q,R,j,l),w=P-q;if(w<0)continue;if(f>S*S)continue;const y=w*F,z=e=>(e.point=e.point?Q(a,o,e.point):Q(a,o),e.dist=y,e.normal=H,e.node=a,e.pointId=o,e.layerViewUid=b,e);if((null==O.dist||y<O.dist)&&(null==t||t(i,s,y))&&z(O),0!==e.options.store&&(null==E.dist||y>E.dist)&&(null==t||t(i,s,y))&&z(E),2===e.options.store&&(null==t||t(i,s,y))){const e=new Y;I.push(z(e))}}});const V=e=>{const{layerViewUid:t,node:i,pointId:s}=e;return new v(e.point,t,s,()=>this.createGraphic(i,s,e.point))},N=(e,t)=>{const i=V(t);e.set(this.type,i,t.dist,t.normal)};if(Z(O)){const t=e.results.min;(null==t.distance||O.dist<t.distance)&&N(t,O)}if(Z(E)&&0!==e.options.store){const t=e.results.max;(null==t.distance||E.dist>t.distance)&&N(t,E)}if(2===e.options.store)for(const o of I){const t=new A(w);N(t,o),e.results.all.push(t)}}*intersectScreenPolygon(e,t){const i=e.camera,{screenPolygonPrimitiveProcessor:s}=e,{point:r,layerViewUid:n,_nodes:a}=this,l=this._passParameters,h=i.perScreenPixelRatio/2,{eye:d,near:g,viewForward:_}=i,f=m(ie,_[0],_[1],_[2],-c(_,d)),P=new J,{bounds:x,broadPhaseFrustum:b}=t,{scaleFactor:S}=l;for(let m=0;m<a.length;++m){const w=a.data[m],{isLeaf:R,obb:y}=w,z=w.splatSize*S,j=k(l,R),q=G(z,Math.max(y.signedDistanceRangePlane(f).max,g),l,h,R);if(!y.intersectsFrustumConservativeApproximationWithMargin(b,q))continue;const{coordinates:F}=w,H=F.length/3;for(let a=0;a<H;a++){if(!s.validatePoint(Q(w,a,r)))continue;if(!i.projectToScreen(r,ee))continue;if(!X(x,ee,j))continue;const m=c(o(te,r,d),_),{distance:f,radius:b}=K(P,z,m,l,h,R);if(f<g)continue;const S=b/i.computeScreenPixelSizeAtDist(f);E(t,ee,S)&&e.polygonResults.add(this.type,new v(p(r),n,null,()=>this.createGraphic(w,a,r)),u(d,r))}yield}}acquireTechniques(e){const t=10===e.output;return 0!==this._nodes.length&&(q(e.output)||H(e.output)&&3===e.bind.slot||t)?(this._nodes.forAll(t=>this._initNode(e,t)),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=t&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._configuration.hasEmission=e.bind.hasEmission,this._context.techniques.get(V,this._configuration)):null}render(e,t){const{rctx:i,bind:s,output:r}=e,n=i.bindTechnique(t,s,this._passParameters),o=10===r,a=s.highlight?.name??null;o&&!a||(o&&s.highlights!==this._highlightsInOrder&&this._updateResolvedHighlights(s.highlights),this._nodes.forAll(t=>{const r=o?t.resolvedHighlightRanges.get(a):null;0===t.coordinates.length||null==t.vao||o&&null==r||(n.assertCompatibleVertexAttributeLocations(t.vao),n.bindDraw(s,this._passParameters,t),i.bindVAO(t.vao),o?this._renderHighlightFragments(e,r):i.drawArrays(U.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{rctx:i}=e;for(let s=0;s<t.length;s+=2)i.drawArrays(U.POINTS,t[s],t[s+1])}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){b(this._passParameters.clipBox,e||S)}get _clippingEnabled(){return!w(this._passParameters.clipBox,S,(e,t)=>e===t)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),e.clearHighlights(),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this._nodes.filterInPlace(s=>s.id!==e||(i=s,s.vao=t(s.vao),this._highlights.nodeRemoved(s),!1)),this._requestRender(),i}forEachNode(e){this._nodes.forEach(e)}removeAll(){this._nodes.forAll(e=>e.vao=t(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlights(e,t,i){for(const s of t)e.addHighlight(s,i);this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_initNode(e,t){t.vao??=new I(e.rctx,new Map([["positions",new D(e.rctx,N,t.coordinates)],["colors",new D(e.rctx,T,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}_updateResolvedHighlights(e){this._highlightsInOrder=e,this._nodes.forAll(t=>t.updateResolvedHighlights(e))}};function G(e,t,i,s,r){if(i.drawScreenSpace)return i.fixedSize*t*s;const n=M(r)*t*s;return i.useFixedSizes?Math.min(i.fixedSize/2,n):i.screenMinSize>0?Math.min(Math.max(i.screenMinSize*t*s,e/2),n):Math.min(e/2,n)}function L(e,t,i,s,r){return i.drawScreenSpace?0:G(e,t,i,s,r)}function k(e,t){return e.drawScreenSpace?e.fixedSize/2:M(t)/2}e([r({constructOnly:!0})],W.prototype,"createGraphic",void 0),W=e([n("esri.views.3d.layers.i3s.PointCloudRenderer")],W);class J{constructor(){this.distance=0,this.radius=0}}function K(e,t,i,s,r,n){const o=i-L(t,i,s,r,n);return e.distance=o,e.radius=G(t,o,s,r,n),e}function Q(e,t,i=g()){return i[0]=e.origin[0]+e.coordinates[3*t],i[1]=e.origin[1]+e.coordinates[3*t+1],i[2]=e.origin[2]+e.coordinates[3*t+2],i}function X(e,t,i){return t[0]>=e[0]-i&&t[0]<=e[2]+i&&t[1]>=e[1]-i&&t[1]<=e[3]+i}class Y{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function Z(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}const $=g(),ee=s(),te=g(),ie=R();export{W as PointCloudRenderer};
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../../core/maybe.js";import i from"../../../../core/PooledArray.js";import{createScreenPointArray as s}from"../../../../core/screenUtils.js";import{property as r,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{subtract as o,length as a,scale as l,negate as h,dot as c,squaredLength as d,distance as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _,offset as f,contains as P,containsPoint as x,set as b,positiveInfinity as S,equals as w}from"../../../../geometry/support/aaBoundingBox.js";import{create as R}from"../../../../geometry/support/plane.js";import{fromPoints as y}from"../../../../geometry/support/ray.js";import{Sphere as z}from"../../../../geometry/support/sphere.js";import{PclTarget as v}from"./Intersector.js";import{PointCloudHighlights as j}from"./PointCloudHighlights.js";import{isColor as q,isHighlight as F,isDepth as H}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as O}from"../../webgl-engine/effects/RenderPlugin.js";import{IntersectorResultRay as A}from"../../webgl-engine/lib/IntersectorResult.js";import{screenPolygonIntersectsCircle as E}from"../../webgl-engine/lib/screenPolygonOverlapUtils.js";import{VertexArrayObject as I}from"../../webgl-engine/lib/VertexArrayObject.js";import{P as B,g as M}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as D,positionsLayout as V,colorsLayout as N}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as T}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{PrimitiveType as C}from"../../../webgl/enums.js";import{VertexBuffer as U}from"../../../webgl/VertexBuffer.js";let W=class extends O{constructor(e){super(e),this.type=6,this.isGround=!1,this._passParameters=new B,this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlights:(e,t,i)=>this._addHighlights(e,t,i),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.produces=new Map([[2,e=>q(e)||F(e)&&!this._highlights.empty],[3,e=>H(e)]]),this.point=g(),this.intersectionRayDir=g(),this.intersectionPlane=R(),this.nodeOriginOffset=g(),this.nodeBoundingBox=_(),this.layerViewUid="",this._slicePlaneEnabled=!1,this._configuration=new T,this._nodes=new i,this._highlightsInOrder=null}destroy(){this._nodes.prune()}hasHighlight(e){return this._highlights.has(e)}initializeRenderContext(e){this._context=e,e.requestRender()}uninitializeRenderContext(){}intersectRay(e,t,i,s){const{point:r,intersectionRayDir:n,nodeOriginOffset:u,intersectionPlane:p,layerViewUid:b,nodeBoundingBox:S}=this,w=y(i,s),R=this._passParameters,j=e.camera.perScreenPixelRatio/2,q=e.camera.near;o(n,s,i);const F=1/a(n);l(n,n,F);const H=g();h(H,n),m(p,n[0],n[1],n[2],-c(n,i));const O=new Y,E=new Y,I=new Array,B=_(R.clipBox);f(B,-i[0],-i[1],-i[2],B);const M=new J;this._nodes.forAll(a=>{const{isLeaf:l,coordinates:h}=a,g=a.splatSize*R.scaleFactor;let{min:m,max:_}=a.obb.signedDistanceRangePlane(p);m-=L(g,m+q,R,j,l),_-=L(g,_+q,R,j,l);const y=_<0,v=null!=O.dist&&null!=E.dist&&O.dist<m*F&&E.dist>_*F;if(y||v)return;const A=G(g,_+q,R,j,l);if(!new z(a.obb.getCenter($),a.obb.radius+A).intersectRay(w))return;if(!a.obb.intersectRay(i,n,A))return;const D=A*A;a.obb.toAaBoundingBox(S),f(S,-i[0],-i[1],-i[2],S);const V=!P(B,S);o(u,a.origin,i);const N=h.length/3;for(let o=0;o<N;o++){const p=3*o;if(r[0]=u[0]+h[p],r[1]=u[1]+h[p+1],r[2]=u[2]+h[p+2],V&&!x(B,r))continue;const m=c(r,n),_=m*m,f=d(r)-_;if(f>D)continue;const{distance:P,radius:S}=K(M,g,m+q,R,j,l),w=P-q;if(w<0)continue;if(f>S*S)continue;const y=w*F,z=e=>(e.point=e.point?Q(a,o,e.point):Q(a,o),e.dist=y,e.normal=H,e.node=a,e.pointId=o,e.layerViewUid=b,e);if((null==O.dist||y<O.dist)&&(null==t||t(i,s,y))&&z(O),0!==e.options.store&&(null==E.dist||y>E.dist)&&(null==t||t(i,s,y))&&z(E),2===e.options.store&&(null==t||t(i,s,y))){const e=new Y;I.push(z(e))}}});const D=e=>{const{layerViewUid:t,node:i,pointId:s}=e;return new v(e.point,t,s,()=>this.createGraphic(i,s,e.point))},V=(e,t)=>{const i=D(t);e.set(this.type,i,t.dist,t.dist,t.normal)};if(Z(O)){const t=e.results.min;(null==t.renderDistance||O.dist<t.renderDistance)&&V(t,O)}if(Z(E)&&0!==e.options.store){const t=e.results.max;(null==t.renderDistance||E.dist>t.renderDistance)&&V(t,E)}if(2===e.options.store)for(const o of I){const t=new A(w);V(t,o),e.results.all.push(t)}}*intersectScreenPolygon(e,t){const i=e.camera,{screenPolygonPrimitiveProcessor:s}=e,{point:r,layerViewUid:n,_nodes:a}=this,l=this._passParameters,h=i.perScreenPixelRatio/2,{eye:d,near:g,viewForward:_}=i,f=m(ie,_[0],_[1],_[2],-c(_,d)),P=new J,{bounds:x,broadPhaseFrustum:b}=t,{scaleFactor:S}=l;for(let m=0;m<a.length;++m){const w=a.data[m],{isLeaf:R,obb:y}=w,z=w.splatSize*S,j=k(l,R),q=G(z,Math.max(y.signedDistanceRangePlane(f).max,g),l,h,R);if(!y.intersectsFrustumConservativeApproximationWithMargin(b,q))continue;const{coordinates:F}=w,H=F.length/3;for(let a=0;a<H;a++){if(!s.validatePoint(Q(w,a,r)))continue;if(!i.projectToScreen(r,ee))continue;if(!X(x,ee,j))continue;const m=c(o(te,r,d),_),{distance:f,radius:b}=K(P,z,m,l,h,R);if(f<g)continue;const S=b/i.computeScreenPixelSizeAtDist(f);E(t,ee,S)&&e.polygonResults.add(this.type,new v(p(r),n,null,()=>this.createGraphic(w,a,r)),u(d,r))}yield}}acquireTechniques(e){const t=10===e.output;return 0!==this._nodes.length&&(q(e.output)||H(e.output)&&3===e.bind.slot||t)?(this._nodes.forAll(t=>this._initNode(e,t)),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=t&&null!=e.bind.highlightMixTexture,this._configuration.output=e.output,this._configuration.hasEmission=e.bind.hasEmission,this._context.techniques.get(D,this._configuration)):null}render(e,t){const{rctx:i,bind:s,output:r}=e,n=i.bindTechnique(t,s,this._passParameters),o=10===r,a=s.highlight?.name??null;o&&!a||(o&&s.highlights!==this._highlightsInOrder&&this._updateResolvedHighlights(s.highlights),this._nodes.forAll(t=>{const r=o?t.resolvedHighlightRanges.get(a):null;0===t.coordinates.length||null==t.vao||o&&null==r||(n.assertCompatibleVertexAttributeLocations(t.vao),n.bindDraw(s,this._passParameters,t),i.bindVAO(t.vao),o?this._renderHighlightFragments(e,r):i.drawArrays(C.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const{rctx:i}=e;for(let s=0;s<t.length;s+=2)i.drawArrays(C.POINTS,t[s],t[s+1])}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){b(this._passParameters.clipBox,e||S)}get _clippingEnabled(){return!w(this._passParameters.clipBox,S,(e,t)=>e===t)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),e.clearHighlights(),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this._nodes.filterInPlace(s=>s.id!==e||(i=s,s.vao=t(s.vao),this._highlights.nodeRemoved(s),!1)),this._requestRender(),i}forEachNode(e){this._nodes.forEach(e)}removeAll(){this._nodes.forAll(e=>e.vao=t(e.vao)),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e,t){return this._highlights.add(e,t)}_addHighlights(e,t,i){for(const s of t)e.addHighlight(s,i);this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_removeHighlight(e,t){e.removeHighlight(t),this._highlightsInOrder&&e.updateResolvedHighlights(this._highlightsInOrder),this._requestRender()}_initNode(e,t){t.vao??=new I(e.rctx,new Map([["positions",new U(e.rctx,V,t.coordinates)],["colors",new U(e.rctx,N,t.rgb)]]))}_requestRender(){this._context&&this._context.requestRender()}_updateResolvedHighlights(e){this._highlightsInOrder=e,this._nodes.forAll(t=>t.updateResolvedHighlights(e))}};function G(e,t,i,s,r){if(i.drawScreenSpace)return i.fixedSize*t*s;const n=M(r)*t*s;return i.useFixedSizes?Math.min(i.fixedSize/2,n):i.screenMinSize>0?Math.min(Math.max(i.screenMinSize*t*s,e/2),n):Math.min(e/2,n)}function L(e,t,i,s,r){return i.drawScreenSpace?0:G(e,t,i,s,r)}function k(e,t){return e.drawScreenSpace?e.fixedSize/2:M(t)/2}e([r({constructOnly:!0})],W.prototype,"createGraphic",void 0),W=e([n("esri.views.3d.layers.i3s.PointCloudRenderer")],W);class J{constructor(){this.distance=0,this.radius=0}}function K(e,t,i,s,r,n){const o=i-L(t,i,s,r,n);return e.distance=o,e.radius=G(t,o,s,r,n),e}function Q(e,t,i=g()){return i[0]=e.origin[0]+e.coordinates[3*t],i[1]=e.origin[1]+e.coordinates[3*t+1],i[2]=e.origin[2]+e.coordinates[3*t+2],i}function X(e,t,i){return t[0]>=e[0]-i&&t[0]<=e[2]+i&&t[1]>=e[1]-i&&t[1]<=e[3]+i}class Y{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}function Z(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}const $=g(),ee=s(),te=g(),ie=R();export{W as PointCloudRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{project as t}from"../../../../geometry/projectionUtils.js";import{fromExtent as i}from"../../../../geometry/support/aaBoundingRect.js";import{Tiles3DTarget as n}from"../i3s/Intersector.js";import{createTileBVH as r}from"./Tiles3DBVH.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResultRay as o}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as l,computeInvDir as a,intersectAabbInvDir as c}from"../../webgl-engine/lib/RayIntersections.js";class d{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid;const n=e.view.viewingMode,s=(e.useEsriCrs?e.fullExtentInLocalViewSpatialReference:e.layer.fullExtent?t(e.layer.fullExtent,e.view.renderSpatialReference):void 0)??e.view.extent,o=i(s);this._bvh=r(n,o)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}intersectRay(e,t,i,r,s,d){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:m,tolerance:p}=e,h=2===e.options.store,{componentObjectCollection:f}=this.layerView.view.stage.renderView,g=new l(p,d,e.options.normalRequired),w=a(i,r,u),y=(s,l,a)=>{if(l<0)return;if(null!=t&&!t(i,r,l))return;const c=e=>{const t=new n(this.layerView.uid);e.set(this.type,t,l,a)};if(this.isGround&&(null==m.ground.distance||l<m.ground.distance)&&c(m.ground),!e.options.isFiltered&&((null==m.min.distance||l<m.min.distance)&&c(m.min),(null==m.max.distance||l>m.max.distance)&&c(m.max),h)){const t=new o(e.ray);c(t),e.results.all.push(t)}};this._bvh.forEachTileIntersectingRay(i,r,e=>{const{componentObjects:t}=e;for(const n of t)c(n.aabbInWorldCoordinates,i,w,0)&&f.intersectRay(n,i,r,null,g,y)},d)}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new s(0,0)}}const u=e();export{d as Tiles3DMeshIntersectionHandler};
2
+ import{create as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{project as t}from"../../../../geometry/projectionUtils.js";import{fromExtent as i}from"../../../../geometry/support/aaBoundingRect.js";import{Tiles3DTarget as r}from"../i3s/Intersector.js";import{createTileBVH as n}from"./Tiles3DBVH.js";import{ElevationRange as s}from"../../support/ElevationRange.js";import{IntersectorResultRay as o}from"../../webgl-engine/lib/IntersectorResult.js";import{MeshIntersectionOptions as l,computeInvDir as a,intersectAabbInvDir as c}from"../../webgl-engine/lib/RayIntersections.js";class d{constructor(e){this.layerView=e,this.type=8,this.slicePlaneEnabled=!1,this.isGround=!0,this.layerViewUid=e.uid;const r=e.view.viewingMode,s=(e.useEsriCrs?e.fullExtentInLocalViewSpatialReference:e.layer.fullExtent?t(e.layer.fullExtent,e.view.renderSpatialReference):void 0)??e.view.extent,o=i(s);this._bvh=n(r,o)}destroy(){this._bvh.destroy()}addTile(e){this._bvh.addTile(e)}removeTile(e){this._bvh.removeTile(e)}intersectRay(e,t,i,n,s,d){if(e.options.filteredLayerViewUids.includes(this.layerView.uid))return;const{results:m,tolerance:p}=e,h=2===e.options.store,{componentObjectCollection:f}=this.layerView.view.stage.renderView,g=new l(p,d,e.options.normalRequired),w=a(i,n,u),y=(s,l,a)=>{if(l<0)return;if(null!=t&&!t(i,n,s))return;const c=e=>{const t=new r(this.layerView.uid);e.set(this.type,t,s,l,a)};if(this.isGround&&(null==m.ground.renderDistance||l<m.ground.renderDistance)&&c(m.ground),!e.options.isFiltered&&((null==m.min.renderDistance||l<m.min.renderDistance)&&c(m.min),(null==m.max.renderDistance||l>m.max.renderDistance)&&c(m.max),h)){const t=new o(e.ray);c(t),e.results.all.push(t)}};this._bvh.forEachTileIntersectingRay(i,n,e=>{const{componentObjects:t}=e;for(const r of t)c(r.aabbInWorldCoordinates,i,w,0)&&f.intersectRay(r,i,n,null,g,y)},d)}getElevationRange(e){return this._bvh.getElevationRangeIntersectingSphere(e)??new s(0,0)}}const u=e();export{d as Tiles3DMeshIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as r,createRenderScreenPointArray3 as n,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as a,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as y,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,copy as m,negativeInfinity as g,expandWithNestedArray as f}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as _}from"../../../../geometry/support/normalizeUtils.js";import{create as P}from"../../../../geometry/support/ray.js";import{sv3d as w}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as R}from"../../../../support/elevationInfoUtils.js";import{g as I}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as v}from"../../support/hitTest.js";import{fromRenderAtEye as b,fromScreen as S}from"../../support/geometryUtils/ray.js";import{defaultTolerance as U,Intersector as j,defaultScreenPolygonPrimitiveProcessor as H}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as L,DrapedScreenPolygonIntersectionQuery as F}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as T}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as x,createSliceExtrusionHalfspacePlanes as M,clipPolygonAgainstSlicedAwayHalfspaces as V,sliceFilterPredicate as D}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as E}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as k}from"../../../support/Scheduler.js";class C{constructor(e,r,n){this.viewingMode=e,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new t,this._tolerance=U,this._tmpRay=P(),this._tmpRegion=p(),this._validateHUDIntersector=new j(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(k.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),N(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,N(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(X,r,n),X[0]+=.0466,X[1]-=.0123,b(e,X,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}async intersectIntersectorScreenPolygon(e,t,r){t.polygonResults.init();const n=this._view.state.camera,i=await E(n,e);null!=i&&await this._screenPolygonIntersectionTask.scheduleGenerator(()=>this._intersectIntersectorScreenPolygon(n,t,i,r))}*_intersectIntersectorScreenPolygon(e,t,r,n){const i=new Q(n,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=H,yield*t.intersectScreenPolygon(i.layers,r);const s=this._view.slice.plane,o=s?new x(s):null;t.screenPolygonPrimitiveProcessor=o??H,yield*t.intersectScreenPolygon(i.sliceableLayers,r),t.screenPolygonPrimitiveProcessor=H,yield*this._intersectPolygonHandlersGenerator(t,i,r,null,o),yield*this._intersectDrapedScreenPolygon(t,i,r,n),yield*t.intersectHUDScreenPolygon(i.layers,r),t.screenPolygonPrimitiveProcessor=o??H,yield*t.intersectHUDScreenPolygon(i.sliceableLayers,r),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||T(n)&&7!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=U){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return S(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||c(t,e.origin,a(w.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,t,n=0,i=null){if(null==e)return null;const o=this._view,{renderCoordsHelper:l}=o,c=s(o.spatialReference),d=null!=t?t.mode:"absolute-height",y=R(t)/c,h=("on-the-ground"!==d?y+n:0)*c/l.unitInMeters,{camera:p}=o.state;if("absolute-height"===d){const t=l?.getAltitude(p.eye),r=u(a(B,e.direction),l.worldUpAtPosition(p.eye,Y));if(t<h&&r<0||t>=h&&r>0)return null;if(l.intersectInfiniteManifold(e,h,B)){const e=v(o,B);return e.z??=0,e.z-=y,e}return null}const m=p.projectToRenderScreen(e.origin,r(w.get())),g=new Q(null,this._forEachLayer),f=o.slice.plane,_=f?D(f):null,P=new j(this.viewingMode);P.options.store=0,P.options.verticalOffset=h,P.options.normalRequired=!1;const I=this._createRayIntersectionQuery(e,m,!1);P.reset(I.beginPoint,I.endPoint,p),P.point=m;let b=null;if(i&&"type"in i&&"graphics"===i.type){const e=o.allLayerViews.find(e=>e.layer===i)?.uid;b=e?t=>t.layerViewUid===e:null}else i&&(b=e=>e.graphicUid!==i.uid);switch(d){case"relative-to-scene":{const e=e=>(!b||b(e))&&!!e.lastValidElevationBB;P.intersect(g.layers,I.screenPoint,this._tolerance,null,e),this._intersectRayHandlers(P,g,I,_,!1,e=>2===e.type||7===e.type||8===e.type,!1);break}case"on-the-ground":case"relative-to-ground":this._intersectRayHandlers(P,g,I,_,!1,e=>e.isGround,!1)}if(P.results.min.getIntersectionPoint(B)){const e=v(o,B);return e.z=n,e}return null}computeIntersection(e,t,n,i){if(null==e)return;const s=this._view.state.camera,o=s.projectToRenderScreen(e.origin,r(w.get())),l=new Q(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i);const c=this._createRayIntersectionQuery(e,o,n);t.reset(c.beginPoint,c.endPoint,s),t.intersect(l.layers,c.screenPoint,this._tolerance);const a=this._view.slice.plane,u=a?D(a):null;t.intersect(l.sliceableLayers,c.screenPoint,this._tolerance,u);const d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,l,c,u,!!d);const y=w.get(),h=this._view,p=h.basemapTerrain;if(i&&i.enableDraped&&null!=p.spatialReference&&t.results.ground.getIntersectionPoint(y)){const e=h.overlayManager.renderer,r=h.renderCoordsHelper.spatialReference,n=w.get();h.renderCoordsHelper.fromRenderCoords(y,n,p.spatialReference),n[2]=h.elevationProvider?.getElevation(y[0],y[1],y[2],r,"ground")??0,e.intersectRay(t,n,t.results.ground,e=>l.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;m(this._tmpRegion,g);const r=new Array,n=this._tmpRegion,i=e=>{r.push(new O(e))};e.sortResults(t.all),null!=t.min.distance&&i(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&i(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&i(t.max),!r.length)return;n[0]===n[2]&&(n[2]+=1),n[1]===n[3]&&(n[3]+=1);let s=!0;const o=null==e.results.max.distance;let l=0;for(const c of r)s&&(e.results.min.copy(c.result),s=!1),o&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(l++,0,c.result)}_createRayIntersectionQuery(e,t,r){return new L(e.origin,c(y(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids;for(const{handler:u,filterPredicate:d,isFiltered:y,filteredLayerViewUids:h}of this._getFilteredIntersectionHandlers(t,n,null,s,o))(!y||u.isGround&&i)&&(l.isFiltered=y,l.filteredLayerViewUids=h,u.intersectRay(e,d,e.rayBegin,e.rayEnd,r.screenPoint,r.isVerticalRay));l.isFiltered=c,l.filteredLayerViewUids=a}*_intersectPolygonHandlersGenerator(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids,u=e.screenPolygonPrimitiveProcessor;for(const{handler:d,screenPolygonPrimitiveProcessor:y,isFiltered:h,filteredLayerViewUids:p}of this._getFilteredIntersectionHandlers(t,n,i,s,o))h||null==d.intersectScreenPolygon||(l.isFiltered=h,l.filteredLayerViewUids=p,e.screenPolygonPrimitiveProcessor=y??H,yield*d.intersectScreenPolygon(e,r));l.isFiltered=c,l.filteredLayerViewUids=a,e.screenPolygonPrimitiveProcessor=u}*_intersectDrapedScreenPolygon(e,t,r,n){const{basemapTerrain:i,overlayManager:s}=this._view,o=null!=i.spatialReference&&!s.renderer.isEmpty;if(!e.options.selectionMode||!n?.enableDraped||!o)return;const l=yield*this._createDrapedPolygonIntersectionQueries(r,i.slicePlaneEnabled?this._view.slice.plane:null);null!=l&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,l,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,r){const{state:{camera:{eye:n}},pointsOfInterest:i,basemapTerrain:s}=this._view,c=new Array,a=r?new Array:null,u=I(this._view,i.focus.renderLocation),y=_(s.spatialReference);let p=Number.POSITIVE_INFINITY,m=null;const g=B,f=Y,P=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,f,e))return!1;const t=null!=m&&y?m+y.shortestSignedDiff(m,g[0]):g[0];return m=t,c.push(l(t,g[1])),a&&a.push(h(f)),p=Math.min(p,d(n,f)),!0},{points:w}=t,{length:R}=w;for(let l=0;l<R;l++){const t=w[l],r=w[(l+1)%R];for(let n=0;n<u;n++){const i=n/u;if(!P(0===n?t:o(J,e(t[0],r[0],i),e(t[1],r[1],i))))return null;yield}}if(!Number.isFinite(p))return null;if(null==r||!a)return[z(c,p)];const v=this._clipDrapedScreenPolygonIntersectionQueries(a,r,y,n);return v.length>0?v:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,r,n){const i=new Array,s=M(t);for(const o of V(s,e)){const e=this._createDrapedQueryFromRenderPolygon(o,r,n);null!=e&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,r){const{basemapTerrain:n,renderCoordsHelper:i}=this._view,s=new Array;let o=Number.POSITIVE_INFINITY,c=null;for(const a of e){if(!i.fromRenderCoords(a,K,n.spatialReference))return null;const e=null!=c&&t?c+t.shortestSignedDiff(c,K[0]):K[0];c=e,s.push(l(e,K[1])),o=Math.min(o,d(r,a))}return s.length>=3&&Number.isFinite(o)?z(s,o):null}_intersectDrapedScreenPolygonPoint(e,t,r){const n=this._getPickRay(r,this._tmpRay);if(null==n)return!1;const{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,n,r)||i.intersectManifoldClosestSilhouette(n,0,t);const s=this._view.basemapTerrain;return!!i.fromRenderCoords(t,e,s.spatialReference)}_intersectGroundPoint(e,t,r){const n=this._view.state.camera,i=new Q(null,this._forEachLayer),s=new j(this.viewingMode);W[0]=r[0],W[1]=r[1],W[2]=0;const o=this._createRayIntersectionQuery(t,W,!1);return s.options.selectionMode=!0,s.options.store=0,s.options.normalRequired=!1,s.options.selectOpaqueTerrainOnly=!1,s.reset(o.beginPoint,o.endPoint,n),this._intersectRayHandlers(s,i,o,null,!0,e=>e.isGround,!1),s.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,r,n=()=>!0,i=!0){for(const s of this._externalIntersectionHandlers){if(!n(s))continue;let o=!1;const l=[];if(i){const t=s.layerViewUid,r=s.sublayerId,n=Array.isArray(t),i=n?t:[t];let c=!1;for(const s of i)e.filterLayerViewUid(s,r)?c=!0:n&&l.push(s);o=!c}yield new G(s,s.slicePlaneEnabled?t:null,s.slicePlaneEnabled?r:null,o,l)}}}class O{constructor(e){this.result=e,this.screenPoint=n()}}class G{constructor(e,t,r,n,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=r,this.isFiltered=n,this.filteredLayerViewUids=i}}let A;function N(e){return A&&A.viewingMode===e||(A=new j(e)),A}class Q{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function q(e){return"object"==typeof e&&null!=e&&"intersectRay"in e}function z(e,t){return new F(e,f(p(g),e),t)}const B=y(),Y=y(),W=n(),J=i(),K=y(),X=n();export{C as SceneIntersectionHelper,q as isIntersectionHandler};
2
+ import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as r,createRenderScreenPointArray3 as n,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as a,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as y,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,copy as m,negativeInfinity as g,expandWithNestedArray as f}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as _}from"../../../../geometry/support/normalizeUtils.js";import{create as P}from"../../../../geometry/support/ray.js";import{sv3d as w}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as R}from"../../../../support/elevationInfoUtils.js";import{g as I}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as v}from"../../support/hitTest.js";import{fromRenderAtEye as b,fromScreen as S}from"../../support/geometryUtils/ray.js";import{defaultTolerance as U,Intersector as j,defaultScreenPolygonPrimitiveProcessor as H}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as L,DrapedScreenPolygonIntersectionQuery as F}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as T}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as x,createSliceExtrusionHalfspacePlanes as M,clipPolygonAgainstSlicedAwayHalfspaces as V,sliceFilterPredicate as D}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as E}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as k}from"../../../support/Scheduler.js";class C{constructor(e,r,n){this.viewingMode=e,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new t,this._tolerance=U,this._tmpRay=P(),this._tmpRegion=p(),this._validateHUDIntersector=new j(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(k.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),N(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,N(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(X,r,n),X[0]+=.0466,X[1]-=.0123,b(e,X,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}async intersectIntersectorScreenPolygon(e,t,r){t.polygonResults.init();const n=this._view.state.camera,i=await E(n,e);null!=i&&await this._screenPolygonIntersectionTask.scheduleGenerator(()=>this._intersectIntersectorScreenPolygon(n,t,i,r))}*_intersectIntersectorScreenPolygon(e,t,r,n){const i=new Q(n,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=H,yield*t.intersectScreenPolygon(i.layers,r);const s=this._view.slice.plane,o=s?new x(s):null;t.screenPolygonPrimitiveProcessor=o??H,yield*t.intersectScreenPolygon(i.sliceableLayers,r),t.screenPolygonPrimitiveProcessor=H,yield*this._intersectPolygonHandlersGenerator(t,i,r,null,o),yield*this._intersectDrapedScreenPolygon(t,i,r,n),yield*t.intersectHUDScreenPolygon(i.layers,r),t.screenPolygonPrimitiveProcessor=o??H,yield*t.intersectHUDScreenPolygon(i.sliceableLayers,r),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||T(n)&&7!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=U){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>7===e.type?1:7===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return S(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||c(t,e.origin,a(w.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,t,n=0,i=null){if(null==e)return null;const o=this._view,{renderCoordsHelper:l}=o,c=s(o.spatialReference),d=null!=t?t.mode:"absolute-height",y=R(t)/c,h=("on-the-ground"===d?0:y+n)*c/l.unitInMeters,{camera:p}=o.state;if("absolute-height"===d){const t=l?.getAltitude(p.eye),r=u(a(B,e.direction),l.worldUpAtPosition(p.eye,Y));if(t<h&&r<0||t>=h&&r>0)return null;if(l.intersectInfiniteManifold(e,h,B)){const e=v(o,B);return e.z??=0,e.z-=y,e}return null}const m=p.projectToRenderScreen(e.origin,r(w.get())),g=new Q(null,this._forEachLayer),f=o.slice.plane,_=f?D(f):null,P=new j(this.viewingMode);P.options.store=0,P.options.verticalOffset=h,P.options.normalRequired=!1;const I=this._createRayIntersectionQuery(e,m,!1);P.reset(I.beginPoint,I.endPoint,p),P.point=m;let b=null;if(i&&"type"in i&&"graphics"===i.type){const e=o.allLayerViews.find(e=>e.layer===i)?.uid;b=e?t=>t.layerViewUid===e:null}else i&&(b=e=>e.graphicUid!==i.uid);switch(d){case"relative-to-scene":{const e=e=>(!b||b(e))&&!!e.lastValidElevationBB;P.intersect(g.layers,I.screenPoint,this._tolerance,null,e),this._intersectRayHandlers(P,g,I,_,!1,e=>2===e.type||7===e.type||8===e.type,!1);break}case"on-the-ground":case"relative-to-ground":this._intersectRayHandlers(P,g,I,_,!1,e=>e.isGround,!1)}if(P.results.min.getIntersectionPoint(B)){const e=v(o,B);return e.z=n,e}return null}computeIntersection(e,t,n,i){if(null==e)return;const s=this._view.state.camera,o=s.projectToRenderScreen(e.origin,r(w.get())),l=new Q(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i);const c=this._createRayIntersectionQuery(e,o,n);t.reset(c.beginPoint,c.endPoint,s),t.intersect(l.layers,c.screenPoint,this._tolerance);const a=this._view.slice.plane,u=a?D(a):null;t.intersect(l.sliceableLayers,c.screenPoint,this._tolerance,u);const d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,l,c,u,!!d);const y=w.get(),h=this._view,p=h.basemapTerrain;if(i&&i.enableDraped&&null!=p.spatialReference&&t.results.ground.getIntersectionPoint(y)){const e=h.overlayManager.renderer,r=h.renderCoordsHelper.spatialReference,n=w.get();h.renderCoordsHelper.fromRenderCoords(y,n,p.spatialReference),n[2]=h.elevationProvider?.getElevation(y[0],y[1],y[2],r,"ground")??0,e.intersectRay(t,n,t.results.ground,e=>l.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;m(this._tmpRegion,g);const r=new Array,n=this._tmpRegion,i=e=>{r.push(new O(e))};e.sortResults(t.all),null!=t.min.distance&&i(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&i(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&i(t.max),!r.length)return;n[0]===n[2]&&(n[2]+=1),n[1]===n[3]&&(n[3]+=1);let s=!0;const o=null==e.results.max.distance;let l=0;for(const c of r)s&&(e.results.min.copy(c.result),s=!1),o&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(l++,0,c.result)}_createRayIntersectionQuery(e,t,r){return new L(e.origin,c(y(),e.origin,e.direction),t,r)}_intersectRayHandlers(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids;for(const{handler:u,filterPredicate:d,isFiltered:y,filteredLayerViewUids:h}of this._getFilteredIntersectionHandlers(t,n,null,s,o))(!y||u.isGround&&i)&&(l.isFiltered=y,l.filteredLayerViewUids=h,u.intersectRay(e,d,e.rayBegin,e.rayEnd,r.screenPoint,r.isVerticalRay));l.isFiltered=c,l.filteredLayerViewUids=a}*_intersectPolygonHandlersGenerator(e,t,r,n,i,s=()=>!0,o=!0){const{options:l}=e,c=l.isFiltered,a=l.filteredLayerViewUids,u=e.screenPolygonPrimitiveProcessor;for(const{handler:d,screenPolygonPrimitiveProcessor:y,isFiltered:h,filteredLayerViewUids:p}of this._getFilteredIntersectionHandlers(t,n,i,s,o))h||null==d.intersectScreenPolygon||(l.isFiltered=h,l.filteredLayerViewUids=p,e.screenPolygonPrimitiveProcessor=y??H,yield*d.intersectScreenPolygon(e,r));l.isFiltered=c,l.filteredLayerViewUids=a,e.screenPolygonPrimitiveProcessor=u}*_intersectDrapedScreenPolygon(e,t,r,n){const{basemapTerrain:i,overlayManager:s}=this._view,o=null!=i.spatialReference&&!s.renderer.isEmpty;if(!e.options.selectionMode||!n?.enableDraped||!o)return;const l=yield*this._createDrapedPolygonIntersectionQueries(r,i.slicePlaneEnabled?this._view.slice.plane:null);null!=l&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,l,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,r){const{state:{camera:{eye:n}},pointsOfInterest:i,basemapTerrain:s}=this._view,c=new Array,a=r?new Array:null,u=I(this._view,i.focus.renderLocation),y=_(s.spatialReference);let p=Number.POSITIVE_INFINITY,m=null;const g=B,f=Y,P=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,f,e))return!1;const t=null!=m&&y?m+y.shortestSignedDiff(m,g[0]):g[0];return m=t,c.push(l(t,g[1])),a&&a.push(h(f)),p=Math.min(p,d(n,f)),!0},{points:w}=t,{length:R}=w;for(let l=0;l<R;l++){const t=w[l],r=w[(l+1)%R];for(let n=0;n<u;n++){const i=n/u;if(!P(0===n?t:o(J,e(t[0],r[0],i),e(t[1],r[1],i))))return null;yield}}if(!Number.isFinite(p))return null;if(null==r||!a)return[z(c,p)];const v=this._clipDrapedScreenPolygonIntersectionQueries(a,r,y,n);return v.length>0?v:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,r,n){const i=new Array,s=M(t);for(const o of V(s,e)){const e=this._createDrapedQueryFromRenderPolygon(o,r,n);null!=e&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,r){const{basemapTerrain:n,renderCoordsHelper:i}=this._view,s=new Array;let o=Number.POSITIVE_INFINITY,c=null;for(const a of e){if(!i.fromRenderCoords(a,K,n.spatialReference))return null;const e=null!=c&&t?c+t.shortestSignedDiff(c,K[0]):K[0];c=e,s.push(l(e,K[1])),o=Math.min(o,d(r,a))}return s.length>=3&&Number.isFinite(o)?z(s,o):null}_intersectDrapedScreenPolygonPoint(e,t,r){const n=this._getPickRay(r,this._tmpRay);if(null==n)return!1;const{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,n,r)||i.intersectManifoldClosestSilhouette(n,0,t);const s=this._view.basemapTerrain;return!!i.fromRenderCoords(t,e,s.spatialReference)}_intersectGroundPoint(e,t,r){const n=this._view.state.camera,i=new Q(null,this._forEachLayer),s=new j(this.viewingMode);W[0]=r[0],W[1]=r[1],W[2]=0;const o=this._createRayIntersectionQuery(t,W,!1);return s.options.selectionMode=!0,s.options.store=0,s.options.normalRequired=!1,s.options.selectOpaqueTerrainOnly=!1,s.reset(o.beginPoint,o.endPoint,n),this._intersectRayHandlers(s,i,o,null,!0,e=>e.isGround,!1),s.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,r,n=()=>!0,i=!0){for(const s of this._externalIntersectionHandlers){if(!n(s))continue;let o=!1;const l=[];if(i){const t=s.layerViewUid,r=s.sublayerId,n=Array.isArray(t),i=n?t:[t];let c=!1;for(const s of i)e.filterLayerViewUid(s,r)?c=!0:n&&l.push(s);o=!c}yield new G(s,s.slicePlaneEnabled?t:null,s.slicePlaneEnabled?r:null,o,l)}}}class O{constructor(e){this.result=e,this.screenPoint=n()}}class G{constructor(e,t,r,n,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=r,this.isFiltered=n,this.filteredLayerViewUids=i}}let A;function N(e){return A&&A.viewingMode===e||(A=new j(e)),A}class Q{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function q(e){return"object"==typeof e&&null!=e&&"intersectRay"in e}function z(e,t){return new F(e,f(p(g),e),t)}const B=y(),Y=y(),W=n(),J=i(),K=y(),X=n();export{C as SceneIntersectionHelper,q as isIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{estimateNumberArrayMemory as t}from"../../../../core/memoryEstimations.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import s from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as a}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTexturePages as o,packedGaussianSizeInU32 as h}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class m{constructor(e){this.texture=null,this._headerTextureCapacity=0,this._rctx=e}get usedMemory(){return(this.texture?.usedMemory??0)+t(this._headerBuffer)}ensureCapacity(t){const r=this.texture;if(this._headerTextureCapacity>=t&&r?.hasWebGLTextureObject)return;const m=Math.max(Math.ceil(t*e),o,this._headerTextureCapacity),[c,p]=this._evalTextureSize(m),l=c*p,f=this._headerBuffer,d=new Uint32Array(l*h);f&&d.set(f.subarray(0,Math.min(f.length,d.length))),this._headerBuffer=d,this._headerTextureCapacity=l,this.texture?.dispose();const n=new u;n.width=c,n.height=p,n.pixelFormat=36249,n.dataType=i.UNSIGNED_INT,n.internalFormat=a.RGBA32UI,n.wrapMode=33071,n.samplingMode=9728,n.isImmutable=!0,this.texture=new s(this._rctx,n),this.texture.updateData(0,0,0,c,p,this._headerBuffer)}update(e,t){this.ensureCapacity(e+1);const r=e*h;this._headerBuffer.set(t,r);const s=this.texture,i=s.descriptor.width,a=e%i,o=Math.floor(e/i);s.updateData(0,a,o,1,1,this._headerBuffer.subarray(r,r+4))}clear(){this.texture?.dispose(),this.texture=null}destroy(){this._headerBuffer=void 0,this._headerTextureCapacity=0,this.clear()}_evalTextureSize(e){const t=Math.ceil(Math.sqrt(e)),s=Math.ceil(e/t);return r(t,s)}}export{m as GaussianSplatHeaderTexture};
2
+ import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{estimateNumberArrayMemory as t}from"../../../../core/memoryEstimations.js";import{initialSplatAtlasTexturePages as r,packedGaussianSizeInU32 as u}from"./GaussianSplatAtlasPages.js";import{TextureBackedBufferLayout as s}from"../../webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js";import{TextureBuffer as a}from"../../webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js";const i=new s([{name:"gaussianSplatHeader",type:"vec4u32"}]);class f{constructor(e){this._headerTextureCapacity=0,this._textureBuffer=null,this._rctx=e}get usedMemory(){return(this._textureBuffer?.usedMemory??0)+t(this._headerBuffer)}ensureCapacity(t){const s=this._textureBuffer;if(this._headerTextureCapacity>=t&&s?.texture.hasWebGLTextureObject)return;const f=Math.max(Math.ceil(t*e),r,this._headerTextureCapacity);s?.dispose();const h=new a(this._rctx,i,f);this._textureBuffer=h;const n=this._headerBuffer,o=new Uint32Array(h.itemCount*u);n&&o.set(n.subarray(0,Math.min(n.length,o.length))),this._headerBuffer=o,this._headerTextureCapacity=h.itemCount,h.setSubData(o.buffer)}update(e,t){this.ensureCapacity(e+1);const r=e*u;this._headerBuffer.set(t,r),this._textureBuffer.setSubData(this._headerBuffer.buffer,e,r*Uint32Array.BYTES_PER_ELEMENT,1)}clear(){this._textureBuffer?.dispose(),this._textureBuffer=null}destroy(){this._headerBuffer=void 0,this._headerTextureCapacity=0,this.clear()}get texture(){return this._textureBuffer?.texture??null}}export{f as GaussianSplatHeaderTexture};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{subtract as t,length as i,scale as e,negate as n,dot as s,transformQuatValues as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as l}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{project as a}from"../../../../geometry/projectionUtils.js";import{intersects as c,contains as u}from"../../../../geometry/support/aaBoundingBox.js";import{fromExtent as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as p}from"../../../../geometry/support/plane.js";import{fromPoints as f}from"../../../../geometry/support/ray.js";import{GaussianSplatTarget as h}from"../../layers/i3s/Intersector.js";import{createTileBVH as m}from"../../layers/support/Tiles3DBVH.js";import{ElevationRange as y}from"../ElevationRange.js";import{IntersectorResultRay as g}from"../../webgl-engine/lib/IntersectorResult.js";class w{constructor(t){this.layerView=t,this.type=0,this.slicePlaneEnabled=!1,this.isGround=!1,this._ellipsoidLocalRayOrigin=r(),this._ellipsoidLocalRayDir=r(),this.intersectionNormal=r(),this.intersectionRayDir=r(),this.intersectionPlane=p(),this.layerViewUid=t.uid;const i=t.view.viewingMode,e=(t.useEsriCrs?t.fullExtentInLocalViewSpatialReference:t.layer.fullExtent?a(t.layer.fullExtent,t.view.renderSpatialReference):void 0)??t.view.extent,n=d(e);this._bvh=m(i,n)}destroy(){this._bvh.destroy()}addTile(t){this._bvh.addTile(t)}removeTile(t){this._bvh.removeTile(t)}intersectRay(o,a,d,p,m,y){const{intersectionRayDir:w,intersectionPlane:R,layerViewUid:x,intersectionNormal:_}=this,j=f(d,p);t(w,p,d);const M=1/i(w);e(w,w,M),n(_,w),l(R,w[0],w[1],w[2],-s(w,d));const E=new v,S=new v,D=o.options.store,V=0===D,k=2===D,q=1===D||k,T=k?new Array:null,B=(t,i,e,n,s,o,l,a)=>{const c=t.point??(t.point=r());c[0]=e,c[1]=n,c[2]=s,t.dist=i,t.normal=_;const u=t.outwardDirection??(t.outwardDirection=r()),d=o*o+l*l+a*a;if(d>0){const t=1/Math.sqrt(d);u[0]=o*t,u[1]=l*t,u[2]=a*t}else u[0]=_[0],u[1]=_[1],u[2]=_[2];return t.layerViewUid=x,t},P=d[0],U=d[1],I=d[2],L=w[0],G=w[1],O=w[2],C=this.layerView.clippingBox,A=t=>{const{relativePositions:i,packedRotations:e,packedOpacityScaledScales:n,gaussianCount:s,obb:o,maxSplatMbsRadiusSquared:r}=t,l=o.centerX,c=o.centerY,u=o.centerZ;let f=-1;const h=C[0],m=C[1],y=C[2],g=C[3],w=C[4],b=C[5];for(let R=0,x=0;R<s;R++,x+=3){const t=i[x]+l,s=i[x+1]+c,o=i[x+2]+u;if(t<h||s<m||o<y||t>g||s>w||o>b)continue;const _=t-P,j=s-U,D=o-I,C=_*L+j*G+D*O;if(C<0&&C*C>r)continue;const A=C<0?0:C;if(_*_+j*j+D*D-A*A>r)continue;if(V&&null!=E.dist){f<0&&(f=Math.sqrt(r));if(Math.max(C-f,0)*M>=E.dist)continue}const N=this._intersectGaussianEllipsoid(_,j,D,L,G,O,e[R],n[R]);if(N<0)continue;const X=N*M;if(null!=a&&!a(d,p,X))continue;const Y=null==E.dist||X<E.dist,Z=q&&(null==S.dist||X>S.dist);if(!Y&&!Z&&!k)continue;const F=L*N,H=G*N,Q=O*N,z=P+F,J=U+H,K=I+Q,W=F-_,$=H-j,tt=Q-D;if(Y&&B(E,X,z,J,K,W,$,tt),Z&&B(S,X,z,J,K,W,$,tt),k){const t=new v;T.push(B(t,X,z,J,K,W,$,tt))}}},N=t=>{const{relativePositions:i,packedRotations:e,packedOpacityScaledScales:n,gaussianCount:s,obb:o,maxSplatMbsRadiusSquared:r}=t,l=o.centerX,c=o.centerY,u=o.centerZ;let f=-1;const h=P-l,m=U-c,y=I-u;for(let g=0,w=0;g<s;g++,w+=3){const t=i[w]-h,s=i[w+1]-m,o=i[w+2]-y,l=t*L+s*G+o*O;if(l<0&&l*l>r)continue;const c=l<0?0:l;if(t*t+s*s+o*o-c*c>r)continue;if(V&&null!=E.dist){f<0&&(f=Math.sqrt(r));if(Math.max(l-f,0)*M>=E.dist)continue}const u=this._intersectGaussianEllipsoid(t,s,o,L,G,O,e[g],n[g]);if(u<0)continue;const b=u*M;if(null!=a&&!a(d,p,b))continue;const R=null==E.dist||b<E.dist,x=q&&(null==S.dist||b>S.dist);if(!R&&!x&&!k)continue;const _=L*u,j=G*u,D=O*u,C=P+_,A=U+j,N=I+D,X=_-t,Y=j-s,Z=D-o;if(R&&B(E,b,C,A,N,X,Y,Z),x&&B(S,b,C,A,N,X,Y,Z),k){const t=new v;T.push(B(t,b,C,A,N,X,Y,Z))}}},X=(t,i)=>{const{min:e,max:n}=t.obb.signedDistanceRangePlane(R);if(n<0)return;const s=e*M;if(!(V&&null!=E.dist&&E.dist<s)){if(null!=E.dist&&null!=S.dist){const t=n*M;if(E.dist<s&&S.dist>t)return}i?A(t):N(t)}},Y=t=>{X(t,!1)},Z=t=>{const i=t.boundingBox;c(i,C)&&X(t,!u(C,i))};this._bvh.forEachTileIntersectingRay(d,p,null!=C?Z:Y,y);const F=(t,i)=>{const{layerViewUid:e}=i,n=new h(i.point,i.outwardDirection,e);t.set(0,n,i.dist,i.normal)};if(b(E)){const t=o.results.min;(null==t.distance||E.dist<t.distance)&&F(t,E)}if(b(S)&&q){const t=o.results.max;(null==t.distance||S.dist>t.distance)&&F(t,S)}if(k&&T?.length)for(const t of T){const i=new g(j);F(i,t),o.results.all.push(i)}}_intersectGaussianEllipsoid(t,i,e,n,s,r,l,a){const c=l>>>30,u=1023&l,d=l>>>10&1023,p=l>>>20&1023,f=(u&R)*x*(1-2*(u>>>9&1)),h=(d&R)*x*(1-2*(d>>>9&1)),m=(p&R)*x*(1-2*(p>>>9&1));let y,g,w,b;const v=f*f+h*h+m*m,j=Math.sqrt(Math.max(0,1-v));switch(c){case 0:y=j,g=m,w=h,b=f;break;case 1:y=m,g=j,w=h,b=f;break;case 2:y=m,g=h,w=j,b=f;break;default:y=m,g=h,w=f,b=j}const E=this._ellipsoidLocalRayOrigin;E[0]=-t,E[1]=-i,E[2]=-e,o(E,E,-y,-g,-w,b);const S=this._ellipsoidLocalRayDir;S[0]=n,S[1]=s,S[2]=r,o(S,S,-y,-g,-w,b);const D=M[255&a],V=M[a>>>8&255],k=M[a>>>16],q=E[0]*D,T=E[1]*V,B=E[2]*k,P=q*q+T*T+B*B;if(P<=1)return 0;const U=S[0]*D,I=S[1]*V,L=S[2]*k,G=U*U+I*I+L*L,O=q*U+T*I+B*L;if(O>0)return _;const C=O*O-G*(P-1);return C<0?_:(-O-Math.sqrt(C))/G}getElevationRange(t){return this._bvh.getElevationRangeIntersectingSphere(t)??new y(0,0)}}function b(t){return null!=t.dist&&null!=t.point}class v{constructor(){this.point=null,this.dist=null,this.normal=null,this.outwardDirection=null,this.layerViewUid=""}}const R=511,x=Math.SQRT1_2/R,_=-1,j=3,M=(()=>{const t=new Float64Array(256);for(let i=0;i<t.length;i++)t[i]=Math.exp(10-i/16)/j;return t})();export{w as GaussianSplatIntersectionHandler};
2
+ import{subtract as t,length as i,scale as e,negate as n,dot as s,transformQuatValues as o}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as l}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{project as a}from"../../../../geometry/projectionUtils.js";import{intersects as c,contains as u}from"../../../../geometry/support/aaBoundingBox.js";import{fromExtent as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as p}from"../../../../geometry/support/plane.js";import{fromPoints as f}from"../../../../geometry/support/ray.js";import{GaussianSplatTarget as h}from"../../layers/i3s/Intersector.js";import{createTileBVH as m}from"../../layers/support/Tiles3DBVH.js";import{ElevationRange as y}from"../ElevationRange.js";import{IntersectorResultRay as g}from"../../webgl-engine/lib/IntersectorResult.js";class w{constructor(t){this.layerView=t,this.type=0,this.slicePlaneEnabled=!1,this.isGround=!1,this._ellipsoidLocalRayOrigin=r(),this._ellipsoidLocalRayDir=r(),this.intersectionNormal=r(),this.intersectionRayDir=r(),this.intersectionPlane=p(),this.layerViewUid=t.uid;const i=t.view.viewingMode,e=(t.useEsriCrs?t.fullExtentInLocalViewSpatialReference:t.layer.fullExtent?a(t.layer.fullExtent,t.view.renderSpatialReference):void 0)??t.view.extent,n=d(e);this._bvh=m(i,n)}destroy(){this._bvh.destroy()}addTile(t){this._bvh.addTile(t)}removeTile(t){this._bvh.removeTile(t)}intersectRay(o,a,d,p,m,y){const{intersectionRayDir:w,intersectionPlane:R,layerViewUid:x,intersectionNormal:_}=this,j=f(d,p);t(w,p,d);const M=1/i(w);e(w,w,M),n(_,w),l(R,w[0],w[1],w[2],-s(w,d));const E=new v,S=new v,D=o.options.store,V=0===D,k=2===D,q=1===D||k,T=k?new Array:null,B=(t,i,e,n,s,o,l,a)=>{const c=t.point??(t.point=r());c[0]=e,c[1]=n,c[2]=s,t.dist=i,t.normal=_;const u=t.outwardDirection??(t.outwardDirection=r()),d=o*o+l*l+a*a;if(d>0){const t=1/Math.sqrt(d);u[0]=o*t,u[1]=l*t,u[2]=a*t}else u[0]=_[0],u[1]=_[1],u[2]=_[2];return t.layerViewUid=x,t},P=d[0],U=d[1],I=d[2],L=w[0],G=w[1],O=w[2],C=this.layerView.clippingBox,A=t=>{const{relativePositions:i,packedRotations:e,packedOpacityScaledScales:n,gaussianCount:s,obb:o,maxSplatMbsRadiusSquared:r}=t,l=o.centerX,c=o.centerY,u=o.centerZ;let f=-1;const h=C[0],m=C[1],y=C[2],g=C[3],w=C[4],b=C[5];for(let R=0,x=0;R<s;R++,x+=3){const t=i[x]+l,s=i[x+1]+c,o=i[x+2]+u;if(t<h||s<m||o<y||t>g||s>w||o>b)continue;const _=t-P,j=s-U,D=o-I,C=_*L+j*G+D*O;if(C<0&&C*C>r)continue;const A=C<0?0:C;if(_*_+j*j+D*D-A*A>r)continue;if(V&&null!=E.dist){f<0&&(f=Math.sqrt(r));if(Math.max(C-f,0)*M>=E.dist)continue}const N=this._intersectGaussianEllipsoid(_,j,D,L,G,O,e[R],n[R]);if(N<0)continue;const X=N*M;if(null!=a&&!a(d,p,X))continue;const Y=null==E.dist||X<E.dist,Z=q&&(null==S.dist||X>S.dist);if(!Y&&!Z&&!k)continue;const F=L*N,H=G*N,Q=O*N,z=P+F,J=U+H,K=I+Q,W=F-_,$=H-j,tt=Q-D;if(Y&&B(E,X,z,J,K,W,$,tt),Z&&B(S,X,z,J,K,W,$,tt),k){const t=new v;T.push(B(t,X,z,J,K,W,$,tt))}}},N=t=>{const{relativePositions:i,packedRotations:e,packedOpacityScaledScales:n,gaussianCount:s,obb:o,maxSplatMbsRadiusSquared:r}=t,l=o.centerX,c=o.centerY,u=o.centerZ;let f=-1;const h=P-l,m=U-c,y=I-u;for(let g=0,w=0;g<s;g++,w+=3){const t=i[w]-h,s=i[w+1]-m,o=i[w+2]-y,l=t*L+s*G+o*O;if(l<0&&l*l>r)continue;const c=l<0?0:l;if(t*t+s*s+o*o-c*c>r)continue;if(V&&null!=E.dist){f<0&&(f=Math.sqrt(r));if(Math.max(l-f,0)*M>=E.dist)continue}const u=this._intersectGaussianEllipsoid(t,s,o,L,G,O,e[g],n[g]);if(u<0)continue;const b=u*M;if(null!=a&&!a(d,p,b))continue;const R=null==E.dist||b<E.dist,x=q&&(null==S.dist||b>S.dist);if(!R&&!x&&!k)continue;const _=L*u,j=G*u,D=O*u,C=P+_,A=U+j,N=I+D,X=_-t,Y=j-s,Z=D-o;if(R&&B(E,b,C,A,N,X,Y,Z),x&&B(S,b,C,A,N,X,Y,Z),k){const t=new v;T.push(B(t,b,C,A,N,X,Y,Z))}}},X=(t,i)=>{const{min:e,max:n}=t.obb.signedDistanceRangePlane(R);if(n<0)return;const s=e*M;if(!(V&&null!=E.dist&&E.dist<s)){if(null!=E.dist&&null!=S.dist){const t=n*M;if(E.dist<s&&S.dist>t)return}i?A(t):N(t)}},Y=t=>{X(t,!1)},Z=t=>{const i=t.boundingBox;c(i,C)&&X(t,!u(C,i))};this._bvh.forEachTileIntersectingRay(d,p,null!=C?Z:Y,y);const F=(t,i)=>{const{layerViewUid:e}=i,n=new h(i.point,i.outwardDirection,e);t.set(0,n,i.dist,i.dist,i.normal)};if(b(E)){const t=o.results.min;(null==t.distance||E.dist<t.distance)&&F(t,E)}if(b(S)&&q){const t=o.results.max;(null==t.distance||S.dist>t.distance)&&F(t,S)}if(k&&T?.length)for(const t of T){const i=new g(j);F(i,t),o.results.all.push(i)}}_intersectGaussianEllipsoid(t,i,e,n,s,r,l,a){const c=l>>>30,u=1023&l,d=l>>>10&1023,p=l>>>20&1023,f=(u&R)*x*(1-2*(u>>>9&1)),h=(d&R)*x*(1-2*(d>>>9&1)),m=(p&R)*x*(1-2*(p>>>9&1));let y,g,w,b;const v=f*f+h*h+m*m,j=Math.sqrt(Math.max(0,1-v));switch(c){case 0:y=j,g=m,w=h,b=f;break;case 1:y=m,g=j,w=h,b=f;break;case 2:y=m,g=h,w=j,b=f;break;default:y=m,g=h,w=f,b=j}const E=this._ellipsoidLocalRayOrigin;E[0]=-t,E[1]=-i,E[2]=-e,o(E,E,-y,-g,-w,b);const S=this._ellipsoidLocalRayDir;S[0]=n,S[1]=s,S[2]=r,o(S,S,-y,-g,-w,b);const D=M[255&a],V=M[a>>>8&255],k=M[a>>>16],q=E[0]*D,T=E[1]*V,B=E[2]*k,P=q*q+T*T+B*B;if(P<=1)return 0;const U=S[0]*D,I=S[1]*V,L=S[2]*k,G=U*U+I*I+L*L,O=q*U+T*I+B*L;if(O>0)return _;const C=O*O-G*(P-1);return C<0?_:(-O-Math.sqrt(C))/G}getElevationRange(t){return this._bvh.getElevationRangeIntersectingSphere(t)??new y(0,0)}}function b(t){return null!=t.dist&&null!=t.point}class v{constructor(){this.point=null,this.dist=null,this.normal=null,this.outwardDirection=null,this.layerViewUid=""}}const R=511,x=Math.SQRT1_2/R,_=-1,j=3,M=(()=>{const t=new Float64Array(256);for(let i=0;i<t.length;i++)t[i]=Math.exp(10-i/16)/j;return t})();export{w as GaussianSplatIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{screenPointObjectToArray as t,isScreenPolygon as i,isScreenRect as r,createScreenPointArray as s,createScreenPoint as o}from"../../../core/screenUtils.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../geometry/projection/projectVectorToVector.js";import{Sphere as d,sphereCSO as p}from"../../../geometry/support/sphere.js";import{fallbackObjectIDAttribute as f}from"../../../layers/LayerConstants.js";import{isIntegratedMeshLayer as m}from"../../../layers/support/layerUtils.js";import{debugFlags as g}from"./debugFlags.js";import{getElevationAtPoint as y}from"./ElevationProvider.js";import{getGraphicHitDedupeKey as h,resolveOrderedIntersectionHits as w}from"./intersectionHitUtils.js";import{Intersector as b}from"../webgl-engine/lib/Intersector.js";import{isValidIntersectorResultRay as S}from"../webgl-engine/lib/IntersectorResult.js";import{toHit as x,toOwner as E}from"../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as U}from"../webgl-engine/lib/verticalOffsetUtils.js";async function j(e,n,t,o){const l=t?C(e,t):o;if(i(n))return I(e,n,l,t?.excludeLabels);if(r(n))return I(e,T(n),l,t?.excludeLabels);const a=n,c=s(a.x,a.y);l.requiresGroundFeedback=!0,l.enableDraped=!0;const u=new b(e.state.viewingMode);u.options.selectionMode=!0,u.options.store=2,u.options.excludeLabels=t?.excludeLabels??!1,e.sceneIntersectionHelper.intersectIntersectorScreen(c,u,l);const d=await P(e,u.results.all,l.graphics,{getDistance:e=>e.distanceInRenderSpace,getMapPoint:n=>L(e,n),stopAtSupportSurface:!0}),p=u.results.ground,f=E(p,e),y=null!=f&&"type"in f&&m(f)?f:null,h={screenPoint:a,results:d,ground:{mapPoint:L(e,p),distance:S(p)?p.distanceInRenderSpace:0,layer:y}};return g.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=u),h}async function I(e,n,i,r){i.enableDraped=!0;const s=new b(e.state.viewingMode);s.options.selectionMode=!0,s.options.store=2,s.options.excludeLabels=r??!1,await e.sceneIntersectionHelper.intersectIntersectorScreenPolygon(n.map(e=>t(e)),s,i);const o={screenPoint:null,results:await P(e,R(e,s.polygonResults.all),i.graphics,{getDistance:e=>e.distance,getMapPoint:()=>null}),ground:{mapPoint:null,distance:0,layer:null}};return g.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(o.intersector=s),o}function*R(e,n){const t=V(e);if(null!=t)for(const i of n)i.distance<=t&&(yield i);else yield*n}function V(e){const n=e.basemapTerrain,t=e.state.camera;if(1!==e.state.viewingMode||!t.aboveGround||!n?.opaque)return null;z.radius=n.getLowerBoundRadius();return p.distanceToSilhouette(z,t.eye)*F}function T(e){return[o(e.x,e.y),o(e.x+e.width,e.y),o(e.x+e.width,e.y+e.height),o(e.x,e.y+e.height)]}function M(e,n,i,r){const s=i?C(e,i):r,o=!(!s.graphics?.include&&!s.graphics?.exclude),l=!(!s.mediaElements?.include&&!s.mediaElements?.exclude),a=t(n);s.enableDraped=s.include&&!s.include.has(U)||s.exclude?.has(U);const c=e.sceneIntersectionHelper,u=new b(e.state.viewingMode);if(u.options.selectionMode=!0,u.options.store=o||l?2:0,u.options.excludeLabels=i?.excludeLabels??!1,c.intersectIntersectorScreen(a,u,s),o||l){for(const n of u.results.all){const t=x(n,e);if(null==t)return L(e,n);if(o&&("graphic"!==t.type||D(s.graphics,t.graphic)))return L(e,n);if(l&&("media"!==t.type||G(s.mediaElements,t.element)))return L(e,n)}return null}return L(e,u.results.min)}async function P(e,n,t,i){const r=w(e,i.stopAtSupportSurface?function*(){for(const t of n){yield t;const n=E(t,e);if(null!=n&&(n===e.map.ground||"type"in n&&m(n)))break}}():n,{getDedupeKey:e=>"graphic"===e.type?v(e.graphic):null,filterHit:e=>"graphic"!==e.type||D(t,e.graphic)}),s=new Array;for await(const{input:o,hit:l}of r){const e=i.getMapPoint(o),n=i.getDistance(o);if("media"===l.type){const t=e?l.element.toSource(e):null;s.push({...l,mapPoint:e,distance:n,sourcePoint:t})}else s.push({...l,mapPoint:e,distance:n})}return s}function L(e,n,t){return n.getIntersectionPoint(q)?(t=H(e,q,t),7===n.intersector&&e.basemapTerrain&&(t.z=y(e.basemapTerrain,t)??0),t):null}function v(e){const n=e.getObjectId()??e.attributes?.[f];return e.origin&&null!=n?`o-${e.origin.id}-${n}`:`u-${h(e)}`}function D(e,n){return G(e,v(n))}function G(e,n){return null==e||(null==e.include||e.include.has(n))&&(null==e.exclude||!e.exclude.has(n))}function H(e,n,t){let i=e.spatialReference||c.WGS84;return u(n,e.renderSpatialReference,q,i)?n=q:(i=c.WGS84,u(n,e.renderSpatialReference,q,i)&&(n=q)),t?(t.x=n[0],t.y=n[1],t.z=n[2],t.spatialReference=i):t=new a(n,i),t}function C(e,n){const t=N(e,n.include,0),i=N(e,n.exclude,1);return{include:t.layerViewUids,exclude:i.layerViewUids,graphics:{include:t.graphicUids,exclude:i.graphicUids},mediaElements:{include:t.mediaElements,exclude:i.mediaElements}}}function N(t,i,r,s=new _){if(!i)return s;if(i instanceof e)$(s,v(i)),0===r&&(null!=t.graphicsView&&i.layer===t?W(s,t.graphicsView.uid):i.layer&&O(s,t,i.layer.uid));else if("layer"in i&&"element"in i)k(s,i.element),0===r&&O(s,t,i.layer.uid);else if(n(i))for(const e of i)e===t.graphics&&null!=t.graphicsView?W(s,t.graphicsView.uid):e===t.map.ground?(W(s,U),t.map.ground.integratedMeshGround&&O(s,t,t.map.ground.integratedMeshGround.uid)):N(t,e,r,s);else"layer"in i&&A(s,t,i),"uid"in i&&O(s,t,i.uid);return s}class _{constructor(){this.layerViewUids=null,this.graphicUids=null,this.mediaElements=null}}function O(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t);i&&W(e,i.uid)}function W(e,n){e.layerViewUids??=new Map,e.layerViewUids.set(n,!0)}function A(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t.layer.uid);if(!i)return;e.layerViewUids??=new Map;const r=e.layerViewUids.get(i.uid);!0!==r&&(r?r.add(t.id):e.layerViewUids.set(i.uid,new Set([t.id])))}function $(e,n){e.graphicUids??=new Set,e.graphicUids.add(n)}function k(e,n){e.mediaElements??=new Set,e.mediaElements.add(n)}const q=l(),z=new d,F=1.2;export{H as computeMapPointFromVec3d,C as externalToInternalIntersectOptions,j as hitTest,L as intersectResultToMapPoint,D as testGraphicUidFilter,M as toMap};
2
+ import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{screenPointObjectToArray as t,isScreenPolygon as i,isScreenRect as r,createScreenPointArray as s,createScreenPoint as o}from"../../../core/screenUtils.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import{projectVectorToVector as u}from"../../../geometry/projection/projectVectorToVector.js";import{Sphere as d,sphereCSO as p}from"../../../geometry/support/sphere.js";import{fallbackObjectIDAttribute as f}from"../../../layers/LayerConstants.js";import{isIntegratedMeshLayer as m}from"../../../layers/support/layerUtils.js";import{debugFlags as g}from"./debugFlags.js";import{getElevationAtPoint as y}from"./ElevationProvider.js";import{getGraphicHitDedupeKey as h,resolveOrderedIntersectionHits as w}from"./intersectionHitUtils.js";import{Intersector as b}from"../webgl-engine/lib/Intersector.js";import{isValidIntersectorResultRay as S}from"../webgl-engine/lib/IntersectorResult.js";import{toHit as x,toOwner as E}from"../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as U}from"../webgl-engine/lib/verticalOffsetUtils.js";async function j(e,n,t,o){const l=t?C(e,t):o;if(i(n))return I(e,n,l,t?.excludeLabels);if(r(n))return I(e,T(n),l,t?.excludeLabels);const a=n,c=s(a.x,a.y);l.requiresGroundFeedback=!0,l.enableDraped=!0;const u=new b(e.state.viewingMode);u.options.selectionMode=!0,u.options.store=2,u.options.excludeLabels=t?.excludeLabels??!1,e.sceneIntersectionHelper.intersectIntersectorScreen(c,u,l);const d=await P(e,u.results.all,l.graphics,{getDistance:e=>e.distanceInRenderSpace,getMapPoint:n=>L(e,n),stopAtSupportSurface:!0}),p=u.results.ground,f=E(p,e),y=null!=f&&"type"in f&&m(f)?f:null,h={screenPoint:a,results:d,ground:{mapPoint:L(e,p),distance:S(p)?p.distanceInRenderSpace:0,layer:y}};return g.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=u),h}async function I(e,n,i,r){i.enableDraped=!0;const s=new b(e.state.viewingMode);s.options.selectionMode=!0,s.options.store=2,s.options.excludeLabels=r??!1,await e.sceneIntersectionHelper.intersectIntersectorScreenPolygon(n.map(e=>t(e)),s,i);const o={screenPoint:null,results:await P(e,R(e,s.polygonResults.all),i.graphics,{getDistance:e=>e.distance,getMapPoint:()=>null}),ground:{mapPoint:null,distance:0,layer:null}};return g.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(o.intersector=s),o}function*R(e,n){const t=V(e);if(null!=t)for(const i of n)null!=i.distance&&i.distance<=t&&(yield i);else yield*n}function V(e){const n=e.basemapTerrain,t=e.state.camera;if(1!==e.state.viewingMode||!t.aboveGround||!n?.opaque)return null;z.radius=n.getLowerBoundRadius();return p.distanceToSilhouette(z,t.eye)*F}function T(e){return[o(e.x,e.y),o(e.x+e.width,e.y),o(e.x+e.width,e.y+e.height),o(e.x,e.y+e.height)]}function M(e,n,i,r){const s=i?C(e,i):r,o=!(!s.graphics?.include&&!s.graphics?.exclude),l=!(!s.mediaElements?.include&&!s.mediaElements?.exclude),a=t(n);s.enableDraped=s.include&&!s.include.has(U)||s.exclude?.has(U);const c=e.sceneIntersectionHelper,u=new b(e.state.viewingMode);if(u.options.selectionMode=!0,u.options.store=o||l?2:0,u.options.excludeLabels=i?.excludeLabels??!1,c.intersectIntersectorScreen(a,u,s),o||l){for(const n of u.results.all){const t=x(n,e);if(null==t)return L(e,n);if(o&&("graphic"!==t.type||D(s.graphics,t.graphic)))return L(e,n);if(l&&("media"!==t.type||G(s.mediaElements,t.element)))return L(e,n)}return null}return L(e,u.results.min)}async function P(e,n,t,i){const r=w(e,i.stopAtSupportSurface?function*(){for(const t of n){yield t;const n=E(t,e);if(null!=n&&(n===e.map.ground||"type"in n&&m(n)))break}}():n,{getDedupeKey:e=>"graphic"===e.type?v(e.graphic):null,filterHit:e=>"graphic"!==e.type||D(t,e.graphic)}),s=new Array;for await(const{input:o,hit:l}of r){const e=i.getMapPoint(o),n=i.getDistance(o);if("media"===l.type){const t=e?l.element.toSource(e):null;s.push({...l,mapPoint:e,distance:n,sourcePoint:t})}else s.push({...l,mapPoint:e,distance:n})}return s}function L(e,n,t){return n.getIntersectionPoint(q)?(t=H(e,q,t),7===n.intersector&&e.basemapTerrain&&(t.z=y(e.basemapTerrain,t)??0),t):null}function v(e){const n=e.getObjectId()??e.attributes?.[f];return e.origin&&null!=n?`o-${e.origin.id}-${n}`:`u-${h(e)}`}function D(e,n){return G(e,v(n))}function G(e,n){return null==e||(null==e.include||e.include.has(n))&&(null==e.exclude||!e.exclude.has(n))}function H(e,n,t){let i=e.spatialReference||c.WGS84;return u(n,e.renderSpatialReference,q,i)?n=q:(i=c.WGS84,u(n,e.renderSpatialReference,q,i)&&(n=q)),t?(t.x=n[0],t.y=n[1],t.z=n[2],t.spatialReference=i):t=new a(n,i),t}function C(e,n){const t=N(e,n.include,0),i=N(e,n.exclude,1);return{include:t.layerViewUids,exclude:i.layerViewUids,graphics:{include:t.graphicUids,exclude:i.graphicUids},mediaElements:{include:t.mediaElements,exclude:i.mediaElements}}}function N(t,i,r,s=new _){if(!i)return s;if(i instanceof e)$(s,v(i)),0===r&&(null!=t.graphicsView&&i.layer===t?W(s,t.graphicsView.uid):i.layer&&O(s,t,i.layer.uid));else if("layer"in i&&"element"in i)k(s,i.element),0===r&&O(s,t,i.layer.uid);else if(n(i))for(const e of i)e===t.graphics&&null!=t.graphicsView?W(s,t.graphicsView.uid):e===t.map.ground?(W(s,U),t.map.ground.integratedMeshGround&&O(s,t,t.map.ground.integratedMeshGround.uid)):N(t,e,r,s);else"layer"in i&&A(s,t,i),"uid"in i&&O(s,t,i.uid);return s}class _{constructor(){this.layerViewUids=null,this.graphicUids=null,this.mediaElements=null}}function O(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t);i&&W(e,i.uid)}function W(e,n){e.layerViewUids??=new Map,e.layerViewUids.set(n,!0)}function A(e,n,t){const i=n.allLayerViews.find(e=>e.layer.uid===t.layer.uid);if(!i)return;e.layerViewUids??=new Map;const r=e.layerViewUids.get(i.uid);!0!==r&&(r?r.add(t.id):e.layerViewUids.set(i.uid,new Set([t.id])))}function $(e,n){e.graphicUids??=new Set,e.graphicUids.add(n)}function k(e,n){e.mediaElements??=new Set,e.mediaElements.add(n)}const q=l(),z=new d,F=1.2;export{H as computeMapPointFromVec3d,C as externalToInternalIntersectOptions,j as hitTest,L as intersectResultToMapPoint,D as testGraphicUidFilter,M as toMap};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{destroyMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{on as i}from"../../../../core/reactiveUtils.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{distance as n,exactEquals as a,copy as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import c from"../../../../geometry/Point.js";import{distanceToScale as h}from"../cameraScaleUtils.js";import{PointOfInterest as p}from"./PointOfInterest.js";import{PropertiesPool as u}from"../../../support/PropertiesPool.js";import{Yield as m}from"../../../support/Yield.js";let _=class extends p{constructor(t){super(t),this._dirty=!1,this._propertiesPool=new u({location:()=>new c,renderLocation:()=>d()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryController=null,this.renderLocation=d(),this._tmpPoint=new c}initialize(){if(this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.runTask(),this.map){const t=()=>this._setDirty();this.addHandles(i(()=>this.map?.ground?.layers,"change",t,{onListenerAdd:t,onListenerRemove:t}))}this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=e(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const t=this._propertiesPool.get("location");return t.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,t),t}get scale(){const t=this._camera,e=n(t.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:t}};return h(r,e)}get updating(){return this._dirty||null!=this._elevationQueryController}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0,this.notifyChange("updating"))}_cancelPendingRequest(){const t=this._elevationQueryController;t&&(this._elevationQueryController=null,t.abort(),this.notifyChange("updating"))}get readyToRun(){return!this._elevationQueryController&&this._dirty}runTask(){if(this._cancelPendingRequest(),this._dirty=!1,this.notifyChange("updating"),!this.map?.ground)return this._updateSurfaceAltitude(0),m;const t=this.state.spatialReference;this._tmpPoint.spatialReference=t,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const e=(this._tmpPoint.z??0)>f&&1===this.renderCoordsHelper.viewingMode&&(t.isWGS84||t.isWebMercator);let i=new AbortController;return this.map.ground.queryElevation(this._tmpPoint,{signal:i.signal,cache:this.cache,minDemResolution:e?g:0}).then(t=>this._updateSurfaceAltitude(t.geometry.z??0)).catch(t=>{r(t)||this._updateSurfaceAltitude(0)}).finally(()=>{this._elevationQueryController===i&&(this._elevationQueryController=null,this.notifyChange("updating")),i=null}),this._elevationQueryController=i,this.notifyChange("updating"),m}_updateSurfaceAltitude(t){this._estimatedSurfaceAltitude!==t&&(this._estimatedSurfaceAltitude=t,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(y,this._estimatedSurfaceAltitude,this._camera.eye),a(this._get("renderLocation"),y)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),y)),this.notifyChange("renderLocation"))}};t([o({constructOnly:!0})],_.prototype,"scheduler",void 0),t([o({constructOnly:!0})],_.prototype,"cache",void 0),t([o({constructOnly:!0})],_.prototype,"map",void 0),t([o({constructOnly:!0})],_.prototype,"task",void 0),t([o()],_.prototype,"location",null),t([o()],_.prototype,"renderLocation",void 0),t([o()],_.prototype,"scale",null),t([o()],_.prototype,"updating",null),_=t([s("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],_);const y=d(),f=1e5,g=1e6;export{_ as CameraOnSurface};
2
+ import{__decorate as e}from"tslib";import{createTask as t}from"../../../../core/asyncUtils.js";import{on as r}from"../../../../core/events.js";import{destroyMaybe as i,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as s,isAbortError as n}from"../../../../core/promiseUtils.js";import{property as a,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{distance as d,exactEquals as c,copy as l}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import y from"../../../../geometry/Point.js";import{distanceToScale as _}from"../cameraScaleUtils.js";import{PointOfInterest as m}from"./PointOfInterest.js";import{PropertiesPool as f}from"../../../support/PropertiesPool.js";import{Yield as g}from"../../../support/Yield.js";let Q=class extends m{constructor(e){super(e),this._dirty=!1,this._groundQueryDirty=!0,this._propertiesPool=new f({location:()=>new y,renderLocation:()=>h()},this),this._estimatedSurfaceAltitude=0,this._elevationQueryTask=null,this._lastQueryRenderEye=h(),this.renderLocation=h(),this._tmpPoint=new y}initialize(){this.scheduler&&this.addHandles(this.scheduler.registerTask(this.task,this)),this.surface&&this.addHandles(r(this.surface,"elevation-query-change",()=>this._invalidateElevationQuery())),this.runTask(),this._updateRenderLocation()}destroy(){this._cancelPendingRequest(),this._propertiesPool=i(this._propertiesPool)}get _camera(){return this.state.contentCamera}get location(){const e=this._propertiesPool.get("location");return e.spatialReference=this.state.spatialReference,this.renderCoordsHelper.fromRenderCoords(this.renderLocation,e),e}get scale(){const e=this._camera,t=d(e.eye,this.renderLocation),r={renderCoordsHelper:this.renderCoordsHelper,state:{camera:e}};return _(r,t)}get updating(){return this._dirty||null!=this._elevationQueryTask}updateRenderLocation(){this._setDirty(),this._updateRenderLocation()}_setDirty(){this._dirty||(this._dirty=!0)}_cancelPendingRequest(){this._elevationQueryTask=o(this._elevationQueryTask)}get readyToRun(){return!this._elevationQueryTask&&this._dirty&&this._groundQueryReady}runTask(){this._cancelPendingRequest(),this._dirty=!1;const e=p(this._camera.eye);if(this._hasCurrentGroundQuery(e))return g;const r=this.map?.ground;if(!r)return this._updateSurfaceAltitude(0),this._rememberGroundQuery(e),g;if(!this._groundQueryReady)return this._setDirty(),g;const i=this.state.spatialReference;this._tmpPoint.spatialReference=i,this.renderCoordsHelper.fromRenderCoords(this._camera.eye,this._tmpPoint);const o=(this._tmpPoint.z??0)>R&&1===this.renderCoordsHelper.viewingMode&&(i.isWGS84||i.isWebMercator)?P:0;let a=null;return a=t(async t=>{try{const i=await r.queryElevation(this._tmpPoint,{signal:t,cache:this.cache,minDemResolution:o});if(s(t),this._elevationQueryTask!==a)return;this._updateSurfaceAltitude(i.geometry.z??0),this._rememberGroundQuery(e)}catch(i){if(this._elevationQueryTask!==a||t.aborted||n(i))return;this._updateSurfaceAltitude(0),this._rememberGroundQuery(e)}finally{this._elevationQueryTask===a&&(this._elevationQueryTask=null)}}),this._elevationQueryTask=a,g}get _groundQueryReady(){return this.surface?.elevationQueryReady??!0}_hasCurrentGroundQuery(e){return!this._groundQueryDirty&&c(this._lastQueryRenderEye,e)}_rememberGroundQuery(e){l(this._lastQueryRenderEye,e),this._groundQueryDirty=!1}_invalidateElevationQuery(){this._cancelPendingRequest(),this.cache?.clear(),this._groundQueryDirty=!0,this._setDirty()}_updateSurfaceAltitude(e){this._estimatedSurfaceAltitude!==e&&(this._estimatedSurfaceAltitude=e,this._updateRenderLocation())}_updateRenderLocation(){this.renderCoordsHelper.setAltitude(v,this._estimatedSurfaceAltitude,this._camera.eye),c(this._get("renderLocation"),v)||(this._set("renderLocation",l(this._propertiesPool.get("renderLocation"),v)),this.notifyChange("renderLocation"))}};e([a({constructOnly:!0})],Q.prototype,"scheduler",void 0),e([a({constructOnly:!0})],Q.prototype,"cache",void 0),e([a({constructOnly:!0})],Q.prototype,"map",void 0),e([a({constructOnly:!0})],Q.prototype,"task",void 0),e([a()],Q.prototype,"_dirty",void 0),e([a()],Q.prototype,"_groundQueryDirty",void 0),e([a()],Q.prototype,"_elevationQueryTask",void 0),e([a()],Q.prototype,"location",null),e([a()],Q.prototype,"renderLocation",void 0),e([a()],Q.prototype,"scale",null),e([a()],Q.prototype,"updating",null),e([a()],Q.prototype,"readyToRun",null),e([a()],Q.prototype,"_groundQueryReady",null),Q=e([u("esri.views.3d.support.pointsOfInterest.CameraOnSurface")],Q);const v=h(),R=1e5,P=1e6;export{Q as CameraOnSurface};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{watch as r,sync as n,initial as s,when as i,on as o}from"../../../../core/reactiveUtils.js";import{property as a,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{add as u,exactEquals as d,copy as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as f}from"../../../../core/support/UpdatingHandles.js";import{create as _}from"../../../../geometry/support/ray.js";import{debugFlags as l}from"../debugFlags.js";import{DebugPoint as m}from"../debugUtils.js";import{fromRenderAtEye as C}from"../geometryUtils/ray.js";import{CameraOnSurface as g}from"./CameraOnSurface.js";import{CenterOnSurface as y}from"./CenterOnSurface.js";import{ContentGeometryUpdates as O}from"./ContentGeometryUpdates.js";import{Focus as A}from"./Focus.js";import{StableSurfaceCenter as w}from"./StableSurfaceCenter.js";import{SurfaceGeometryUpdates as S}from"./SurfaceGeometryUpdates.js";import{Intersector as I}from"../../webgl-engine/lib/Intersector.js";import{terrainId as v}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{PropertiesPool as b}from"../../../support/PropertiesPool.js";import{TaskPriority as R}from"../../../support/Scheduler.js";let P=class extends t{constructor(e){super(e),this.renderPointOfView=p(),this._pois=new Array,this._updatingHandles=new f,this._debugCenters=null,this._tmpRay=_(),this._centerRayDirty=!0,this._surfaceAltitudeAtCenter=0,this._surfaceAltitudeAtCenterDirty=!0,this._contentAltitudeAtCenter=0,this._contentAltitudeAtCenterDirty=!0,this._contentChangedSinceLastUpdate=!0,this._propertiesPool=new b({renderPointOfView:()=>p()},this),this._contentIntersector=new I(e.view.state.viewingMode),this._surfaceIntersector=new I(e.view.state.viewingMode),this._surfaceIntersector.options.invisibleTerrain=!1,this._surfaceIntersector.options.store=0}initialize(){const{state:e,groundView:t,renderCoordsHelper:a,map:c}=this.view,u=()=>this._estimateSurfaceAltitudeAtCenter(),d=this.view.resourceController.scheduler,h=t?.elevationQueryCache,p={state:e,scheduler:d,surface:t,renderCoordsHelper:a};this._set("centerOnSurfaceInfrequent",new y({...p,task:R.POINT_OF_INTEREST_INFREQUENT,estimateSurfaceAltitudeAtCenter:u})),this._set("centerOnSurfaceFrequent",new y({...p,task:R.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:u})),this._set("centerOnContent",new y({...p,task:R.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:()=>this._estimateContentAltitudeAtCenter()})),this._set("cameraOnSurface",new g({...p,cache:h,task:R.POINT_OF_INTEREST_INFREQUENT,map:c})),this._set("surfaceGeometryUpdates",new S({...p,centerOnSurfaces:[this.centerOnSurfaceFrequent,this.centerOnContent,this.centerOnSurfaceInfrequent]})),this._set("contentGeometryUpdates",new O(this.view.allLayerViews,()=>this.view.graphicsView)),this._set("surfaceOrigin",new w({cache:h,view:this.view})),this._set("focus",new A({state:e,scheduler:d,surface:t,renderCoordsHelper:a,centerOnSurface:this.centerOnSurfaceFrequent,estimateSurfaceIntersectionAtRenderPoint:(e,t)=>this._estimateSurfaceIntersectionAtRenderPoint(e,this.view.state.contentCamera,t)})),this._pois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.cameraOnSurface,this.focus),this.addHandles([r(()=>e.contentCamera,e=>this._cameraChanged(e),n),this._updatingHandles.add(()=>t.groundExtent,()=>this._updateCenterPointsOfInterest()),this._updatingHandles.add(()=>this.view.map?.ground?.navigationConstraint?.type,e=>{this._surfaceIntersector.options.backfacesTerrain="none"===e},s),i(()=>!t.updating&&this._contentChangedSinceLastUpdate,()=>{this._updateCenterPointsOfInterest(),this._contentChangedSinceLastUpdate=!1},n),o(()=>this.surfaceGeometryUpdates.events,"request-update",()=>this._updateCenterPointsOfInterest()),o(()=>this.contentGeometryUpdates.events,"request-update",()=>{this._contentChangedSinceLastUpdate=!0,this._updateCenterOnContent()}),this._updatingHandles.add(()=>l.SHOW_POI,e=>this._setDebug(e),s)]),this._cameraChanged(this.view.state.contentCamera);for(const r of this._pois)r.runTask()}destroy(){this._setDebug(!1),this._propertiesPool.destroy();for(const e of this._pois)e.destroy();this._pois.length=0,this.surfaceOrigin.destroy(),this._updatingHandles.destroy(),this._set("centerOnSurfaceInfrequent",null),this._set("centerOnSurfaceFrequent",null),this._set("centerOnContent",null),this._set("cameraOnSurface",null),this._set("surfaceGeometryUpdates",null),this._set("contentGeometryUpdates",null),this._set("surfaceOrigin",null),this._set("focus",null)}get updating(){return!(!this.surfaceGeometryUpdates?.updating&&!this._pois.some(e=>e.updating))||this._updatingHandles.updating}get _centerRay(){return this._centerRayDirty&&(this._centerRayCached=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(this.view.state.contentCamera,this._tmpRay),this._centerRayDirty=!1),this._centerRayCached}_estimateContentAltitudeAtCenter(){if(!this._contentAltitudeAtCenterDirty)return this._contentAltitudeAtCenter;this._contentAltitudeAtCenterDirty=!1;const e=this._centerRay;return null==e||(this.view.sceneIntersectionHelper.intersectRay(e,this._contentIntersector,U,H)?this._contentAltitudeAtCenter=this.view.renderCoordsHelper.getAltitude(U):this._contentAltitudeAtCenter=this._estimateSurfaceAltitudeAtCenter()),this._contentAltitudeAtCenter}_estimateSurfaceAltitudeAtCenter(){const{view:e}=this,{groundView:t}=e;if(!t)return 0;if(!this._surfaceAltitudeAtCenterDirty)return this._surfaceAltitudeAtCenter;this._surfaceAltitudeAtCenterDirty=!1;const r=this._centerRay;if(null==r)return this._surfaceAltitudeAtCenter;const n=r.origin,s=u(U,r.origin,r.direction);return this._surfaceIntersector.resetWithRay(r,e.state.contentCamera),t.intersect(this._surfaceIntersector,null,n,s),this._surfaceIntersector.results.min.getIntersectionPoint(U)&&(this._surfaceAltitudeAtCenter=e.renderCoordsHelper.getAltitude(U)),this._surfaceAltitudeAtCenter}_estimateSurfaceIntersectionAtRenderPoint(e,t,r){const n=C(t,e,j);if(null==n)return null;const s=n.origin,i=u(U,n.origin,n.direction);return this._surfaceIntersector.resetWithRay(n,t),this.view.groundView.intersect(this._surfaceIntersector,null,s,i),this._surfaceIntersector.results.min.getIntersectionPoint(r)?r:null}_cameraChanged(e){this._updateCenterPointsOfInterest();const t=e.eye;d(this.renderPointOfView,t)||this._set("renderPointOfView",h(this._propertiesPool.get("renderPointOfView"),t))}_updateCenterPointsOfInterest(){this._centerRayDirty=!0,this._surfaceAltitudeAtCenterDirty=!0,this._contentAltitudeAtCenterDirty=!0;for(const e of this._pois)e.updateRenderLocation()}_updateCenterOnContent(){this._contentAltitudeAtCenterDirty=!0,this.centerOnContent.updateRenderLocation()}_setDebug(e){if(!e)return this._debugCenters?.forEach(e=>e.hide()),void this.removeHandles("debug");if(!this._debugCenters){this._debugCenters=new Map;const e=this.view.graphics;this._debugCenters.set(this.centerOnContent,new m(e,"red","CenterOnContent")),this._debugCenters.set(this.centerOnSurfaceFrequent,new m(e,"red","CenterOnSurface")),this._debugCenters.set(this.centerOnSurfaceInfrequent,new m(e,"red","CenterOnSurface")),this._debugCenters.set(this.cameraOnSurface,new m(e,"blue","CameraOnSurface")),this._debugCenters.set(this.focus,new m(e,"green","Focus"))}for(const t of this._pois)this.addHandles(this._updatingHandles.add(()=>t.renderLocation,e=>this._debugCenters?.get(t)?.show(e,t.renderCoordsHelper.spatialReference),s),"debug")}get test(){}};e([a()],P.prototype,"centerOnContent",void 0),e([a()],P.prototype,"centerOnSurfaceFrequent",void 0),e([a()],P.prototype,"centerOnSurfaceInfrequent",void 0),e([a()],P.prototype,"cameraOnSurface",void 0),e([a()],P.prototype,"focus",void 0),e([a()],P.prototype,"renderPointOfView",void 0),e([a()],P.prototype,"surfaceOrigin",void 0),e([a()],P.prototype,"contentGeometryUpdates",void 0),e([a()],P.prototype,"surfaceGeometryUpdates",void 0),e([a({constructOnly:!0})],P.prototype,"view",void 0),e([a()],P.prototype,"updating",null),P=e([c("esri.views.3d.support.pointsOfInterest.PointsOfInterest")],P);const U=p(),j=_(),H={exclude:new Set([v])};export{P as PointsOfInterest};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{watch as r,sync as n,initial as s,when as i,on as o}from"../../../../core/reactiveUtils.js";import{property as a,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{add as u,exactEquals as d,copy as h}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as p}from"../../../../core/support/UpdatingHandles.js";import{create as _}from"../../../../geometry/support/ray.js";import{debugFlags as l}from"../debugFlags.js";import{DebugPoint as m}from"../debugUtils.js";import{fromRenderAtEye as C}from"../geometryUtils/ray.js";import{CameraOnSurface as g}from"./CameraOnSurface.js";import{CenterOnSurface as y}from"./CenterOnSurface.js";import{ContentGeometryUpdates as O}from"./ContentGeometryUpdates.js";import{Focus as A}from"./Focus.js";import{StableSurfaceCenter as w}from"./StableSurfaceCenter.js";import{SurfaceGeometryUpdates as S}from"./SurfaceGeometryUpdates.js";import{Intersector as v}from"../../webgl-engine/lib/Intersector.js";import{terrainId as I}from"../../webgl-engine/lib/verticalOffsetUtils.js";import{PropertiesPool as P}from"../../../support/PropertiesPool.js";import{TaskPriority as R}from"../../../support/Scheduler.js";let b=class extends t{constructor(e){super(e),this.renderPointOfView=f(),this._pois=new Array,this._updatingHandles=new p,this._debugCenters=null,this._tmpRay=_(),this._centerRayDirty=!0,this._surfaceAltitudeAtCenter=0,this._surfaceAltitudeAtCenterDirty=!0,this._contentAltitudeAtCenter=0,this._contentAltitudeAtCenterDirty=!0,this._contentChangedSinceLastUpdate=!0,this._geometryPois=new Array,this._propertiesPool=new P({renderPointOfView:()=>f()},this),this._contentIntersector=new v(e.view.state.viewingMode),this._surfaceIntersector=new v(e.view.state.viewingMode),this._surfaceIntersector.options.invisibleTerrain=!1,this._surfaceIntersector.options.store=0}initialize(){const{state:e,groundView:t,renderCoordsHelper:a,map:c}=this.view,u=()=>this._estimateSurfaceAltitudeAtCenter(),d=this.view.resourceController.scheduler,h=t?.elevationQueryCache,f={state:e,scheduler:d,surface:t,renderCoordsHelper:a};this._set("centerOnSurfaceInfrequent",new y({...f,task:R.POINT_OF_INTEREST_INFREQUENT,estimateSurfaceAltitudeAtCenter:u})),this._set("centerOnSurfaceFrequent",new y({...f,task:R.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:u})),this._set("centerOnContent",new y({...f,task:R.POINT_OF_INTEREST_FREQUENT,estimateSurfaceAltitudeAtCenter:()=>this._estimateContentAltitudeAtCenter()})),this._set("cameraOnSurface",new g({...f,cache:h,task:R.POINT_OF_INTEREST_INFREQUENT,map:c})),this._set("surfaceGeometryUpdates",new S({...f,centerOnSurfaces:[this.centerOnSurfaceFrequent,this.centerOnContent,this.centerOnSurfaceInfrequent]})),this._set("contentGeometryUpdates",new O(this.view.allLayerViews,()=>this.view.graphicsView)),this._set("surfaceOrigin",new w({cache:h,view:this.view})),this._set("focus",new A({state:e,scheduler:d,surface:t,renderCoordsHelper:a,centerOnSurface:this.centerOnSurfaceFrequent,estimateSurfaceIntersectionAtRenderPoint:(e,t)=>this._estimateSurfaceIntersectionAtRenderPoint(e,this.view.state.contentCamera,t)})),this._pois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.cameraOnSurface,this.focus),this._geometryPois.push(this.centerOnContent,this.centerOnSurfaceFrequent,this.centerOnSurfaceInfrequent,this.focus),this.addHandles([r(()=>e.contentCamera,e=>this._cameraChanged(e),n),this._updatingHandles.add(()=>t.groundExtent,()=>this._updateGeometryPointsOfInterest()),this._updatingHandles.add(()=>this.view.map?.ground?.navigationConstraint?.type,e=>{this._surfaceIntersector.options.backfacesTerrain="none"===e},s),i(()=>!t.updating&&this._contentChangedSinceLastUpdate,()=>{this._updateGeometryPointsOfInterest(),this._contentChangedSinceLastUpdate=!1},n),o(()=>this.surfaceGeometryUpdates.events,"request-update",()=>this._updateGeometryPointsOfInterest()),o(()=>this.contentGeometryUpdates.events,"request-update",()=>{this._contentChangedSinceLastUpdate=!0,this._updateCenterOnContent()}),this._updatingHandles.add(()=>l.SHOW_POI,e=>this._setDebug(e),s)]),this._cameraChanged(this.view.state.contentCamera);for(const r of this._pois)r.runTask()}destroy(){this._setDebug(!1),this._propertiesPool.destroy();for(const e of this._pois)e.destroy();this._pois.length=0,this.surfaceOrigin.destroy(),this._updatingHandles.destroy(),this._set("centerOnSurfaceInfrequent",null),this._set("centerOnSurfaceFrequent",null),this._set("centerOnContent",null),this._set("cameraOnSurface",null),this._set("surfaceGeometryUpdates",null),this._set("contentGeometryUpdates",null),this._set("surfaceOrigin",null),this._set("focus",null)}get updating(){return!(!this.surfaceGeometryUpdates?.updating&&!this._pois.some(e=>e.updating))||this._updatingHandles.updating}get _centerRay(){return this._centerRayDirty&&(this._centerRayCached=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(this.view.state.contentCamera,this._tmpRay),this._centerRayDirty=!1),this._centerRayCached}_estimateContentAltitudeAtCenter(){if(!this._contentAltitudeAtCenterDirty)return this._contentAltitudeAtCenter;this._contentAltitudeAtCenterDirty=!1;const e=this._centerRay;return null==e||(this.view.sceneIntersectionHelper.intersectRay(e,this._contentIntersector,U,E)?this._contentAltitudeAtCenter=this.view.renderCoordsHelper.getAltitude(U):this._contentAltitudeAtCenter=this._estimateSurfaceAltitudeAtCenter()),this._contentAltitudeAtCenter}_estimateSurfaceAltitudeAtCenter(){const{view:e}=this,{groundView:t}=e;if(!t)return 0;if(!this._surfaceAltitudeAtCenterDirty)return this._surfaceAltitudeAtCenter;this._surfaceAltitudeAtCenterDirty=!1;const r=this._centerRay;if(null==r)return this._surfaceAltitudeAtCenter;const n=r.origin,s=u(U,r.origin,r.direction);return this._surfaceIntersector.resetWithRay(r,e.state.contentCamera),t.intersect(this._surfaceIntersector,null,n,s),this._surfaceIntersector.results.min.getIntersectionPoint(U)&&(this._surfaceAltitudeAtCenter=e.renderCoordsHelper.getAltitude(U)),this._surfaceAltitudeAtCenter}_estimateSurfaceIntersectionAtRenderPoint(e,t,r){const n=C(t,e,j);if(null==n)return null;const s=n.origin,i=u(U,n.origin,n.direction);return this._surfaceIntersector.resetWithRay(n,t),this.view.groundView.intersect(this._surfaceIntersector,null,s,i),this._surfaceIntersector.results.min.getIntersectionPoint(r)?r:null}_cameraChanged(e){this._updateAllPointsOfInterest();const t=e.eye;d(this.renderPointOfView,t)||this._set("renderPointOfView",h(this._propertiesPool.get("renderPointOfView"),t))}_updateAllPointsOfInterest(){this._invalidateCenterEstimates();for(const e of this._pois)e.updateRenderLocation()}_updateGeometryPointsOfInterest(){this._invalidateCenterEstimates();for(const e of this._geometryPois)e.updateRenderLocation()}_invalidateCenterEstimates(){this._centerRayDirty=!0,this._surfaceAltitudeAtCenterDirty=!0,this._contentAltitudeAtCenterDirty=!0}_updateCenterOnContent(){this._contentAltitudeAtCenterDirty=!0,this.centerOnContent.updateRenderLocation()}_setDebug(e){if(!e)return this._debugCenters?.forEach(e=>e.hide()),void this.removeHandles("debug");if(!this._debugCenters){this._debugCenters=new Map;const e=this.view.graphics;this._debugCenters.set(this.centerOnContent,new m(e,"red","CenterOnContent")),this._debugCenters.set(this.centerOnSurfaceFrequent,new m(e,"red","CenterOnSurface")),this._debugCenters.set(this.centerOnSurfaceInfrequent,new m(e,"red","CenterOnSurface")),this._debugCenters.set(this.cameraOnSurface,new m(e,"blue","CameraOnSurface")),this._debugCenters.set(this.focus,new m(e,"green","Focus"))}for(const t of this._pois)this.addHandles(this._updatingHandles.add(()=>t.renderLocation,e=>this._debugCenters?.get(t)?.show(e,t.renderCoordsHelper.spatialReference),s),"debug")}get test(){}};e([a()],b.prototype,"centerOnContent",void 0),e([a()],b.prototype,"centerOnSurfaceFrequent",void 0),e([a()],b.prototype,"centerOnSurfaceInfrequent",void 0),e([a()],b.prototype,"cameraOnSurface",void 0),e([a()],b.prototype,"focus",void 0),e([a()],b.prototype,"renderPointOfView",void 0),e([a()],b.prototype,"surfaceOrigin",void 0),e([a()],b.prototype,"contentGeometryUpdates",void 0),e([a()],b.prototype,"surfaceGeometryUpdates",void 0),e([a({constructOnly:!0})],b.prototype,"view",void 0),e([a()],b.prototype,"updating",null),b=e([c("esri.views.3d.support.pointsOfInterest.PointsOfInterest")],b);const U=f(),j=_(),E={exclude:new Set([I])};export{b as PointsOfInterest};