@arcgis/core 5.1.0-next.73 → 5.1.0-next.74

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 (152) hide show
  1. package/Viewpoint.js +1 -1
  2. package/applications/Urban/editingSessionUtils.d.ts +95 -0
  3. package/applications/Urban/editingSessionUtils.js +2 -0
  4. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{d17fcfc502f0e0fa6523.js → 003476e950bd27a2f884.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{8a664451845a47048859.js → 0539b5d015157c1d34a0.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{5a4d7ba6dc1d4b41d80d.js → 07eff82916681fcff069.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{8a14e3db28c403b046cf.js → 0d2bc1be5802681666a4.js} +1 -1
  10. package/assets/esri/core/workers/chunks/0eed2b1b06355ab89013.js +1 -0
  11. package/assets/esri/core/workers/chunks/18f77ee3552d92962f15.js +1 -0
  12. package/assets/esri/core/workers/chunks/1a87e9bbd85ba29b1514.js +1 -0
  13. package/assets/esri/core/workers/chunks/{e1bc9ad767e08dc18bbc.js → 1db1656a033f3992f0d6.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{b54b7cc6b23a70fed700.js → 1f8ccf96069ac3a40c3d.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{cdf6ad970dc1893dac58.js → 24646a1176ce34039155.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{93ceb74ac88ef460fe5f.js → 359d3acb3953e64e5a78.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{80ace1c7203c5059525d.js → 37091cf498a16ccad7ff.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{0839da55707f7c4cf780.js → 3b9100c59a8050f4834e.js} +1 -1
  19. package/assets/esri/core/workers/chunks/452c01cecbbd1e370098.js +1 -0
  20. package/assets/esri/core/workers/chunks/47656ec12401e53f4bd3.js +1 -0
  21. package/assets/esri/core/workers/chunks/{260d4571722cb1ff1366.js → 484d6c1b0fe1633515b7.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{f207b3be0714cc50030a.js → 4bbe684050b3b04681d0.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{29e76256e3e867e80520.js → 4c13869d260a902d3014.js} +1 -1
  24. package/assets/esri/core/workers/chunks/4c97cc922eece3a91b6b.js +1 -0
  25. package/assets/esri/core/workers/chunks/{656d6963e8f837fbf28f.js → 54023458195549f66215.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{a78bc340a794fd332667.js → 5476c2f7b83f4ccd0335.js} +1 -1
  27. package/assets/esri/core/workers/chunks/5511e640e171c294f52a.js +2 -0
  28. package/assets/esri/core/workers/chunks/{faad127dc07e54e7f6d1.js → 5abe34bb0110694f7b42.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{f5c57ff48ca505ed701d.js → 5b324e572737a308500d.js} +1 -1
  30. package/assets/esri/core/workers/chunks/6124141ac642e4ce1454.js +1 -0
  31. package/assets/esri/core/workers/chunks/{b6cadb8a579241adcb86.js → 6b66fc32451433129a88.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{6ea8b0d68881d16a2432.js → 6d25230dd85a4ba54c4f.js} +1 -1
  33. package/assets/esri/core/workers/chunks/6f7aaba26773fe416ac2.js +1 -0
  34. package/assets/esri/core/workers/chunks/{9f4b97204def91567e3c.js → 7595ceba529ed01c7590.js} +1 -1
  35. package/assets/esri/core/workers/chunks/75d5ea0da181f9e7425f.js +1312 -0
  36. package/assets/esri/core/workers/chunks/{af75e91b88e747aa76ac.js → 7601278ebced0c0c31cf.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{1661684357912726a72a.js → 77dd719516138afb1a2a.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{ce2aa75e084ee56f5e29.js → 7f55eef696e9ed717bfc.js} +1 -1
  39. package/assets/esri/core/workers/chunks/85aac8539996372f1ee8.js +1 -0
  40. package/assets/esri/core/workers/chunks/{50d5d6654ada9f28345d.js → 85e65ced3312bf9cf162.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{b9848bdbaf3d9ac93d54.js → 8f4cd30ce23e41c1a42c.js} +1 -1
  42. package/assets/esri/core/workers/chunks/983f6c8727fd9484718e.js +1 -0
  43. package/assets/esri/core/workers/chunks/{5a83ea967ecde01d5622.js → 9be9ccce6369f67202bc.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{422824e407b550170c8c.js → a270960d80d8344dd75f.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{bef27a25fbc4a6e19ec0.js → a36761e3122f70fbb3c9.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{47f2113357b2aa4f4f37.js → a9d2c83bb10b5ade0ca0.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{e25a684eb9f025bdcc01.js → ad064583f8a836005098.js} +1 -1
  48. package/assets/esri/core/workers/chunks/b858adff7043683fe41c.js +1 -0
  49. package/assets/esri/core/workers/chunks/{5c663d5f98bdfa29151b.js → b905e637a67fbb7af4ae.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{03894992558d063d0d5e.js → bab23b905678e42815e5.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{6ef3b8d67b498d655a99.js → bcb021a167580bb1619f.js} +1 -1
  52. package/assets/esri/core/workers/chunks/be0341567bb19e101a4f.js +1 -0
  53. package/assets/esri/core/workers/chunks/bec3ee5ea945e1e07a35.js +1 -0
  54. package/assets/esri/core/workers/chunks/c5f155fe114a2a05aaf2.js +2 -0
  55. package/assets/esri/core/workers/chunks/{84772b023d04e415f17f.js → c61002a117dc2218d6af.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{0dad0bca8d58b2c63d22.js → c804a66ef7615aa8de89.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{cfe246adb5e6cb6f0cfc.js → d00dafad202450e6ee2e.js} +1 -1
  58. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +1 -0
  59. package/assets/esri/core/workers/chunks/{06df187a116709f69952.js → d35c475f004367e333eb.js} +1 -1
  60. package/assets/esri/core/workers/chunks/d82da31dc702b8fd6a07.js +1 -0
  61. package/assets/esri/core/workers/chunks/dd4f431511edd975a53b.js +1 -0
  62. package/assets/esri/core/workers/chunks/{99101789035f1787c630.js → e785f76c1a75cb1d1e1f.js} +1 -1
  63. package/assets/esri/core/workers/chunks/f590b60fca607d66001a.js +1 -0
  64. package/assets/esri/core/workers/chunks/{f6d047358d14328f3622.js → f60292d97bcdbf19165b.js} +1 -1
  65. package/assets/esri/core/workers/chunks/fb5a2205f05afc396119.js +1 -0
  66. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  67. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  68. package/chunks/geometryEngineBase.js +1 -1
  69. package/config.js +1 -1
  70. package/core/has.js +1 -1
  71. package/form/elements/FieldElement.js +1 -1
  72. package/geometry/geometryEngine.js +1 -1
  73. package/geometry/geometryEngineJSON.js +1 -1
  74. package/geometry/operators/projectOperator.d.ts +5 -4
  75. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  76. package/geometry/support/normalizeUtils.js +1 -1
  77. package/geometry/support/normalizeUtilsCommon.js +1 -1
  78. package/identity/IdentityManagerBase.js +1 -1
  79. package/kernel.js +1 -1
  80. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  81. package/layers/IntegratedMeshLayer.js +1 -1
  82. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  83. package/layers/support/SymbolLayerDrawing.d.ts +18 -4
  84. package/package.json +2 -2
  85. package/popup/Features.d.ts +9 -9
  86. package/popup/Features.js +1 -1
  87. package/popup/actionUtils.js +1 -1
  88. package/popup/actions.js +1 -1
  89. package/portal/Portal.js +1 -1
  90. package/portal/PortalQueryParams.js +1 -1
  91. package/rest/print.js +1 -1
  92. package/support/revision.js +1 -1
  93. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  94. package/views/3d/camera/intersectionUtils.js +1 -1
  95. package/views/3d/input/SceneInputManager.js +1 -1
  96. package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
  97. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  98. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  99. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  100. package/views/3d/state/GoToOperation.js +1 -1
  101. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  102. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  103. package/views/3d/support/cameraScaleUtils.js +2 -0
  104. package/views/3d/support/cameraUtils.js +1 -1
  105. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  106. package/views/3d/support/renderInfoUtils/line.js +1 -1
  107. package/views/3d/support/viewpointUtils.js +1 -1
  108. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +13 -12
  110. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  111. package/views/3d/webgl.js +1 -1
  112. package/views/SceneView.d.ts +1 -0
  113. package/views/draw/support/editingSessionUtils.js +2 -0
  114. package/views/interactive/sketch/SketchTooltipOptions.d.ts +9 -1
  115. package/views/support/Scheduler.js +1 -1
  116. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  117. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  118. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  119. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  120. package/widgets/Editor/EditorViewModel.js +1 -1
  121. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  122. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  123. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  124. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  125. package/widgets/Editor/support/SketchController.js +1 -1
  126. package/widgets/Editor/workflowUtils.js +1 -1
  127. package/assets/esri/core/workers/chunks/027c3ea756db68e51f0a.js +0 -1
  128. package/assets/esri/core/workers/chunks/0c00e5e4bd18467bcecd.js +0 -1
  129. package/assets/esri/core/workers/chunks/0ef93722524620023f69.js +0 -1
  130. package/assets/esri/core/workers/chunks/266ba61b72a278d93a26.js +0 -1
  131. package/assets/esri/core/workers/chunks/2abf124e2956e4f76688.js +0 -1
  132. package/assets/esri/core/workers/chunks/30f04dc001eaf838d64c.js +0 -1
  133. package/assets/esri/core/workers/chunks/43678e08a3d9d51c2a6d.js +0 -1
  134. package/assets/esri/core/workers/chunks/5b278b9980752ef495a2.js +0 -1
  135. package/assets/esri/core/workers/chunks/5e59ff96aecdf2adcb3b.js +0 -1
  136. package/assets/esri/core/workers/chunks/74be994d789c57031631.js +0 -1
  137. package/assets/esri/core/workers/chunks/770880ad43f252962017.js +0 -1
  138. package/assets/esri/core/workers/chunks/81750c5177d8d52a3e05.js +0 -1
  139. package/assets/esri/core/workers/chunks/9eb4ae556950e1d0124d.js +0 -2
  140. package/assets/esri/core/workers/chunks/a11f05ddd8314b648f76.js +0 -1
  141. package/assets/esri/core/workers/chunks/af5db0372d526e592fcc.js +0 -1
  142. package/assets/esri/core/workers/chunks/bc53ce9a643f82d516c2.js +0 -1
  143. package/assets/esri/core/workers/chunks/c3381b9a36299210ee47.js +0 -1
  144. package/assets/esri/core/workers/chunks/d65b1234867f7d773d50.js +0 -2
  145. package/assets/esri/core/workers/chunks/d8d7331600d93bbca2b4.js +0 -1
  146. package/assets/esri/core/workers/chunks/e272411e2c9378aa8496.js +0 -1312
  147. package/assets/esri/core/workers/chunks/fa160a2a5dc9f5a7c34b.js +0 -1
  148. package/geometry/support/triangulationUtilsDeprecated.js +0 -2
  149. package/views/3d/layers/graphics/extrudeUtilsDeprecated.js +0 -2
  150. package/views/3d/support/renderInfoUtils/polygonDeprecated.js +0 -2
  151. /package/assets/esri/core/workers/chunks/{9eb4ae556950e1d0124d.js.LICENSE.txt → 5511e640e171c294f52a.js.LICENSE.txt} +0 -0
  152. /package/assets/esri/core/workers/chunks/{d65b1234867f7d773d50.js.LICENSE.txt → c5f155fe114a2a05aaf2.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u,fromQuat as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,set as w,transformMat3 as j,add as x}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,freeze as M,fromValues as T,clone as O,ZEROS as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as E,clone as U,fromValues as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as S,isMars as A,getReferenceEllipsoid as H,SphericalECEFSpatialReferenceLike as L}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as k}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as I}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as P}from"../../../geometry/projection/projectVectorToVector.js";import{create as F}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as D}from"../../../geometry/support/Indices.js";import{isCGCS2000 as B}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4f as G,BufferViewVec4u8 as z,BufferViewVec4u16 as N,BufferViewVec3f as q,BufferViewVec3u8 as W,BufferViewVec3u16 as $,BufferViewVec2f as Q,BufferViewInt16 as Z,BufferViewUint32 as J,BufferViewUint16 as X,BufferViewVec2i16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ee}from"../../../support/elevationInfoUtils.js";import{addNormals as te}from"./IntegratedMeshNormals.js";import{LayerView3D as ie}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as se}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as re,removeLayerViewFromWasm as oe,getLyr3DWasm as ne}from"./Lyr3DWasm.js";import{toWasmModification as ae}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as le}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as de}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ce,alphaModeConversion as he,faceCullingConversion as ue,wrapModeConversion as me,lyr3DTypeToByteSize as pe}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as fe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as be}from"../state/Frustum.js";import{ElevationRange as ye}from"../support/ElevationRange.js";import{toBoundingRect as ge}from"../support/extentUtils.js";import{Obb as _e,compute as ve}from"../support/orientedBoundingBox.js";import{glLayout as we}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as je,createVertexBufferLayout as xe,ComponentGeometryParameters as Ce,SourceGeometry as Me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Te}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Oe}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Re}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Ee}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ue}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Ve}from"../webgl-engine/materials/pbrUtils.js";import Se from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ae,isInEffectiveScaleRange as He,validateScaleRange as Le}from"../../support/layerViewUtils.js";import{PromiseQueue as ke}from"../../support/PromiseQueue.js";import{TaskPriority as Ie}from"../../support/Scheduler.js";import{TextureCompressionTracker as Pe}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Fe}from"../../../webscene/support/AlphaCutoff.js";var De;let Be=class extends(ie(Se)){static{De=de}constructor(e){super(e),this[De]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,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 Pe,this._createRenderableQueue=new ke,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(Ie.TILES3D,this),this._frustum=new be(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(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._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ae("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=re(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new fe(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(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new le({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([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),oe(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),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._createRenderableQueue.destroy(),this.notifyChange("readyToRun"),this._frameTask.remove(),this._updatingHandles=i(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(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ae(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=F();this._layerClippingArea=ge(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{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,ee(e))}get _wasm(){return ne(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||He(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,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new se(this.usedMemory,r,o,Ne(t),Ne(e),Ne(s),Ne(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ee(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ye(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ye;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,s=i.isWGS84||i.isWebMercator||B(i)||S(i)||A(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=H(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(C(),n),d=500,c=Math.max(o[2],d),h=c+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=c>.5*r?.5*Math.PI*r:m,f=C();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-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._createRenderableQueue.readyToRun}runTask(e){this._createRenderableQueue.runTask(e),this.notifyChange("readyToRun")}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const t=this._createRenderableQueue.push(()=>this._createRenderable(e),null);return this.notifyChange("readyToRun"),t}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw this._dbg(3,e),new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=M(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=f;if(this.view.state.isGlobal){const e=b();k(L,i,e,s),r=h(p(),e)}if(null==t.desc.obb)throw new Error("meshData.desc.obb undefined");const o=$e(t.desc.obb);let n=0;const a={textureMemoryUsage:0},l=new Array,d=new Map,c=t.desc.prims.length,m=new Array,y=new ye;try{const e=this.view.state.isGlobal,h=e?H(this.view.spatialReference).radius:0,b=r!==f,g=b?u(p(),r)??f:f,_=t.desc.materials,v=o?C():null;for(let u=0;u<c;u++){const c=t.desc.prims[u];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(c));if(null==ce[c.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+c.ptype+"). Skipping primitive.");continue}const m=_&&null!=c.materialId?_[c.materialId]:null,p=null!=m?m.lightingModel:"Unlit",{positionView:f,positionAttr:j,normalsView:x,normalsAttr:M,colorAttr:R,texCoord0Attr:S,indicesView:A}=this.getBufferViews(c,t.data.buffer,r);if(null==j||null==f||null==A)continue;const H=f.count,L=(e,t)=>!e||e.data.length/e.size===H||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!L(S,"numTexcoord")||!L(R,"numColors")||!L(M,"normals"))continue;const k=new je(null!=R,null!=x,S?1:0),F=xe(k),D=F.createBuffer(H);Je({origin:i,ellipsoidRadius:h,isGlobal:e,ecefRotation:r},{texCoord0Attr:S,colorAttr:R,normalsAttr:M},D,{positionView:f,tileObb:o,obbHalfSizeAccumulator:v,elevationRange:y});const B=o?.clone()??We(j,i),G=new Uint32Array([0,A.typedBuffer.length]),z=we(F),N=this._imVertexNormals,q=te(new Uint8Array(D.buffer),A.typedBuffer,z,N,N?g:void 0),W=new Ce(z,this._imShading?2:0,k.textureCoordinateType,b?1:0,0),$=new Me({interleavedVertexData:q.data,vertexCount:q.data.byteLength/z[0].stride,indexData:q.indices},{positions:f.typedBuffer,indices:A.typedBuffer},G,W),Q=this.view.renderSpatialReference,Z=C(),J=[1,1,1];I(i,Q,J,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),P(i,Q,Z,s);let X=Promise.resolve(Ze),Y=E,K=Fe,ee=null,ie=null,se=null,re=null,oe=null,ne=1,ae=!1,le=2,de=!1,me=T(0,0,0);const pe=O(Ve),fe="Pbr"===p;if(m){const e=e=>this._getTexture(e,t,d,a);ee=e(m.baseColorTex),oe=fe?e(m.metalTex):null,ie=fe?e(m.emissiveTex):null,re=fe?e(m.occlusionTex):null,se=fe?e(m.normalTex):null;const i=[ee,oe,ie,re,se].map(e=>e?.loadPromise??null);X=Promise.all(i),Y=U(m.baseColorFactor),K=m.alphaCutoff??Fe,fe&&(w(pe,m.metallicFactor,m.roughnessFactor,0),m.emissiveFactor&&(me=m.emissiveFactor)),ne=he[m.alphaMode],ae=m.isDoubleSided,le=ue[m.faceCulling??"NotSet"],de=this.layer.replacesTerrain}const be=X.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ee||this._dbg(3,"No colour texture 1");const e=this._collection.createObject({toMapSpace:V(Z[0],Z[1],J[0],J[1]),transform:new Te(i,g),obb:B,geometry:$,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:Y,textureAlphaCutoff:K,mrrFactors:pe,baseColorTexture:ee,metallicRoughnessTexture:oe,normalTexture:se,occlusionTexture:re,emissionTexture:ie,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ne,doubleSided:ae,cullFace:le,isGround:de,emissiveBaseColor:me,usePBR:fe,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO});return a.textureMemoryUsage+=ee?.texture?.usedMemory??0,fe&&(a.textureMemoryUsage+=(oe?.texture?.usedMemory??0)+(ie?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)),n+=this._collection.getObjectGPUMemoryUsage(e),e});l.push(be)}if(m.push(...await Promise.all(l)),this.destroyed){const e="IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call";throw this._dbg(3,e),new Error(e)}}catch(S){throw d.forEach(e=>this._stage.removeTexture(e)),S}const g=m.map(e=>e()),_=new Array;d.forEach(e=>_.push(e));const{fullExtent:v}=this.layer;v?.hasZ&&v.zmax&&v.zmin&&(y.minElevation=Math.max(y.minElevation,v.zmin),y.maxElevation=Math.min(y.maxElevation,v.zmax));const j=g.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),x=new ze(e.handle,g,_,j,n,a.textureMemoryUsage,o,e.stableNodeId,e.nodeDepth,y);this._lyrHandleToObjects.set(e.handle,x),this._memCache.put(Qe(x.handle),x);const{usedMemory:R}=x;return this._cacheMemory+=R,{memUsageBytes:R}}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=Qe(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 s=this._frustum,r=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(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Qe(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 s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=s.isVisible;this._visibleObjects.delete(s),s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),this._intersectionHandler.removeTile(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Qe(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Oe(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=me[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Ee(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/pe[m.type],y=D(b);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new q(t,m.byteOffset,p,f),r=new Re(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new q(t,m.byteOffset,p,f),s=Ue(e.typedBuffer,i);a=new Z(s.buffer),l=new Re(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Re(new Q(t,m.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new G(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new z(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new N(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(c=new q(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new W(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new $(t,m.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Re(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new X(t,i.byteOffset,s,r);break;case"U32":d=new J(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new X(new Uint16Array(e).buffer):new J(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_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.")},o),"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([d()],Be.prototype,"fullOpacity",null),e([d({readOnly:!0})],Be.prototype,"ready",null),e([d({type:[K]})],Be.prototype,"_modifications",void 0),e([d()],Be.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Be.prototype,"layer",void 0),e([d({readOnly:!0})],Be.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Be.prototype,"_collection",null),e([d()],Be.prototype,"elevationOffset",null),e([d({readOnly:!0})],Be.prototype,"visibleElevationRange",null),Be=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Be);const Ge=Be;class ze{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const c=C();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0,this._mbsCenter=n?O(n.center):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:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-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,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ne(e){return Math.round(e/1048.576)/1e3}const qe=C();function We(e,t){const i=ve(e);return x(qe,i.center,t),i.center=qe,i}function $e(e){return new _e(e.center,e.halfSize,y(...e.quaternion))}function Qe(e){return`${e}`}const Ze=new Array;function Je(e,t,i,s){const{origin:r,ellipsoidRadius:o,isGlobal:n,ecefRotation:a}=e,{texCoord0Attr:l,colorAttr:d,normalsAttr:c}=t,{positionView:h,tileObb:u,obbHalfSizeAccumulator:p,elevationRange:b}=s,y=i.getField("position",q),g=y.typedBuffer,_=y.typedBufferStride,v=l?.data,w=null!=l?i.getField("uv0",Q):null,x=w?.typedBuffer,C=w?.typedBufferStride??0,M=d?.data,T=d?.size??0,O=null!=d?i.getField("color",z):null,E=O?.typedBuffer,U=O?.typedBufferStride??0,V=c?.data,S=null!=c?i.getField("normalCompressed",Y):null,A=S?.typedBuffer,H=S?.typedBufferStride??0,L=null!=u?m(Ye,u.quaternionConjugate):f,k=j(Xe,u?.center??R,L),I=L[0],P=L[1],F=L[2],D=L[3],B=L[4],G=L[5],N=L[6],W=L[7],$=L[8],Z=k[0],J=k[1],X=k[2],K=a[0],ee=a[1],te=a[2],ie=a[3],se=a[4],re=a[5],oe=a[6],ne=a[7],ae=a[8],le=a!==f,de=r[0],ce=r[1],he=r[2],ue=h.count,me=h.typedBufferStride,pe=h.typedBuffer,fe=null!=x&&null!=v,be=null!=E&&null!=M&&(3===T||4===T),ye=4===T,ge=null!=A&&null!=V,_e=null!=p;let ve=_e?p[0]:0,we=_e?p[1]:0,je=_e?p[2]:0;for(let m=0;m<ue;++m){const e=m*me,t=pe[e],i=pe[e+1],s=pe[e+2],r=t+de,a=i+ce,l=s+he,d=n?Math.sqrt(r*r+a*a+l*l)-o:l;if(b.expandElevationRangeValues(d,d),_e){const e=Math.abs(r*I+a*D+l*N-Z),t=Math.abs(r*P+a*B+l*W-J),i=Math.abs(r*F+a*G+l*$-X);ve=Math.max(ve,e),we=Math.max(we,t),je=Math.max(je,i)}const c=m*_;if(le){const r=t*K+i*ie+s*oe,o=t*ee+i*se+s*ne,n=t*te+i*re+s*ae;pe[e]=r,pe[e+1]=o,pe[e+2]=n,g[c]=r,g[c+1]=o,g[c+2]=n}else g[c]=t,g[c+1]=i,g[c+2]=s;if(fe){const e=2*m,t=m*C;x[t]=v[e],x[t+1]=v[e+1]}if(be){const e=m*U;if(ye){const t=4*m;E[e]=M[t],E[e+1]=M[t+1],E[e+2]=M[t+2],E[e+3]=M[t+3]}else{const t=3*m;E[e]=M[t],E[e+1]=M[t+1],E[e+2]=M[t+2],E[e+3]=255}}if(ge){const e=2*m,t=m*H;A[t]=V[e],A[t+1]=V[e+1]}}u&&_e&&(p[0]=ve,p[1]=we,p[2]=je,u.setHalfSize(ve,we,je))}const Xe=C(),Ye=p();export{Ge as default};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u,fromQuat as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,set as w,transformMat3 as j,add as C}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as T,freeze as x,fromValues as R,clone as E,ZEROS as O}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as M,clone as V,fromValues as S}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as U,isMars as A,getReferenceEllipsoid as H,SphericalECEFSpatialReferenceLike as L}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as k}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as P}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as I}from"../../../geometry/projection/projectVectorToVector.js";import{create as D}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as F}from"../../../geometry/support/Indices.js";import{isCGCS2000 as B}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4f as G,BufferViewVec4u8 as z,BufferViewVec4u16 as N,BufferViewVec3f as q,BufferViewVec3u8 as W,BufferViewVec3u16 as $,BufferViewVec2f as Q,BufferViewInt16 as J,BufferViewUint32 as Z,BufferViewUint16 as X,BufferViewVec2i16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ee}from"../../../support/elevationInfoUtils.js";import{addNormals as te}from"./IntegratedMeshNormals.js";import{LayerView3D as ie}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as se}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as re,removeLayerViewFromWasm as oe,getLyr3DWasm as ne}from"./Lyr3DWasm.js";import{toWasmModification as ae}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as le}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as de}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ce,alphaModeConversion as he,faceCullingConversion as ue,wrapModeConversion as me,lyr3DTypeToByteSize as pe}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as fe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as be}from"../state/Frustum.js";import{ElevationRange as ye}from"../support/ElevationRange.js";import{toBoundingRect as ge}from"../support/extentUtils.js";import{Obb as _e,compute as ve}from"../support/orientedBoundingBox.js";import{glLayout as we}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as je,createVertexBufferLayout as Ce,ComponentGeometryParameters as Te,SourceGeometry as xe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Re}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ee}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Oe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ve}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Se}from"../webgl-engine/materials/pbrUtils.js";import Ue from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ae,isInEffectiveScaleRange as He,validateScaleRange as Le}from"../../support/layerViewUtils.js";import{PromiseQueue as ke}from"../../support/PromiseQueue.js";import{TaskPriority as Pe}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ie}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as De}from"../../../webscene/support/AlphaCutoff.js";var Fe;let Be=class extends(ie(Ue)){static{Fe=de}constructor(e){super(e),this[Fe]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,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 Ie,this._createRenderableQueue=new ke,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(Pe.TILES3D,this),this._frustum=new be(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(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._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ae("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=re(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new fe(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(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new le({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([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),oe(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),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._createRenderableQueue.destroy(),this.notifyChange("readyToRun"),this._frameTask.remove(),this._updatingHandles=i(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(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ae(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=D();this._layerClippingArea=ge(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{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,ee(e))}get _wasm(){return ne(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||He(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,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new se(this.usedMemory,r,o,Ne(t),Ne(e),Ne(s),Ne(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ee(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ye(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ye;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,s=i.isWGS84||i.isWebMercator||B(i)||U(i)||A(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=H(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(T(),n),d=500,c=Math.max(o[2],d),h=c+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=c>.5*r?.5*Math.PI*r:m,f=T();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-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||this._createRenderableQueue.readyToRun}runTask(e){this._frameTask.processQueue(e),this._createRenderableQueue.runTask(e),this.notifyChange("readyToRun")}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const t=new Map,i=this._getTextureLoadPromises(e,t);if(0===i.length)return this._enqueueCreateRenderable(e,t);const s=()=>{t.forEach(e=>this._stage.removeTexture(e))};return this.notifyChange("readyToRun"),this._frameTask.schedule(()=>Promise.all(i)).then(()=>{if(this.destroyed||this.destroying){const e=new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");throw s(),e}return this._enqueueCreateRenderable(e,t)},e=>{throw s(),e})}_enqueueCreateRenderable(e,t){const i=this._createRenderableQueue.push(()=>this._createRenderable(e,t),null);return this.notifyChange("readyToRun"),i}_getTextureLoadPromises(e,t){const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if("string"==typeof i.desc&&(i.desc=JSON.parse(i.desc)),null==i.desc)throw new Error("meshData.desc undefined");const s=i.desc.materials;if(!s)return[];const r=new Array,o=e=>{const s=this._getTexture(e,i,t);null!=s?.loadPromise&&r.push(s.loadPromise)};for(const n of s){if(!n)continue;const e="Pbr"===n.lightingModel;o(n.baseColorTex),e&&(o(n.metalTex),o(n.emissiveTex),o(n.occlusionTex),o(n.normalTex))}return r}_createRenderable(e,t){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw this._dbg(3,e),new Error(e)}const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if("string"==typeof i.desc&&(i.desc=JSON.parse(i.desc)),null==i.desc)throw new Error("meshData.desc undefined");const s=x(...i.desc.origin),r=this.view.basemapTerrain.spatialReference;let o=f;if(this.view.state.isGlobal){const e=b();k(L,s,e,r),o=h(p(),e)}if(null==i.desc.obb)throw new Error("meshData.desc.obb undefined");const n=$e(i.desc.obb);let a=0;const l=new Array,d=i.desc.prims.length,c=new ye;try{const e=this.view.state.isGlobal,h=e?H(this.view.spatialReference).radius:0,m=o!==f,b=m?u(p(),o)??f:f,y=i.desc.materials,g=n?T():null;for(let u=0;u<d;u++){const d=i.desc.prims[u];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(d));if(null==ce[d.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+d.ptype+"). Skipping primitive.");continue}const p=y&&null!=d.materialId?y[d.materialId]:null,f=null!=p?p.lightingModel:"Unlit",{positionView:_,positionAttr:v,normalsView:j,normalsAttr:C,colorAttr:x,texCoord0Attr:O,indicesView:U}=this.getBufferViews(d,i.data.buffer,o);if(null==v||null==_||null==U)continue;const A=_.count,H=(e,t)=>!e||e.data.length/e.size===A||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!H(O,"numTexcoord")||!H(x,"numColors")||!H(C,"normals"))continue;const L=new je(null!=x,null!=j,O?1:0),k=Ce(L),D=k.createBuffer(A);Je({origin:s,ellipsoidRadius:h,isGlobal:e,ecefRotation:o},{texCoord0Attr:O,colorAttr:x,normalsAttr:C},D,{positionView:_,tileObb:n,obbHalfSizeAccumulator:g,elevationRange:c});const F=n?.clone()??We(v,s),B=new Uint32Array([0,U.typedBuffer.length]),G=we(k),z=this._imVertexNormals,N=te(new Uint8Array(D.buffer),U.typedBuffer,G,z,z?b:void 0),q=new Te(G,this._imShading?2:0,L.textureCoordinateType,m?1:0,0),W=new xe({interleavedVertexData:N.data,vertexCount:N.data.byteLength/G[0].stride,indexData:N.indices},{positions:_.typedBuffer,indices:U.typedBuffer},B,q),$=this.view.renderSpatialReference,Q=T(),J=[1,1,1];P(s,$,J,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),I(s,$,Q,r);let Z=M,X=De,Y=null,K=null,ee=null,ie=null,se=null,re=1,oe=!1,ne=2,ae=!1,le=R(0,0,0);const de=E(Se),me="Pbr"===f;if(p){const e=e=>this._getTexture(e,i,t);Y=e(p.baseColorTex),se=me?e(p.metalTex):null,K=me?e(p.emissiveTex):null,ie=me?e(p.occlusionTex):null,ee=me?e(p.normalTex):null,Z=V(p.baseColorFactor),X=p.alphaCutoff??De,me&&(w(de,p.metallicFactor,p.roughnessFactor,0),p.emissiveFactor&&(le=p.emissiveFactor)),re=he[p.alphaMode],oe=p.isDoubleSided,ne=ue[p.faceCulling??"NotSet"],ae=this.layer.replacesTerrain}if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}Y||this._dbg(3,"No colour texture 1");const pe=this._collection.createObject({toMapSpace:S(Q[0],Q[1],J[0],J[1]),transform:new Re(s,b),obb:F,geometry:W,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:Z,textureAlphaCutoff:X,mrrFactors:de,baseColorTexture:Y,metallicRoughnessTexture:se,normalTexture:ee,occlusionTexture:ie,emissionTexture:K,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:re,doubleSided:oe,cullFace:ne,isGround:ae,emissiveBaseColor:le,usePBR:me,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO});a+=this._collection.getObjectGPUMemoryUsage(pe),l.push(pe)}if(this.destroyed){const e="IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call";throw this._dbg(3,e),new Error(e)}}catch(C){throw l.forEach(e=>this._collection.destroyObject(e)),t.forEach(e=>this._stage.removeTexture(e)),C}const m=new Array;t.forEach(e=>m.push(e));const y=m.reduceRight((e,t)=>e+(t.usedMemory??0),0),{fullExtent:g}=this.layer;g?.hasZ&&g.zmax&&g.zmin&&(c.minElevation=Math.max(c.minElevation,g.zmin),c.maxElevation=Math.min(c.maxElevation,g.zmax));const _=l.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),v=new ze(e.handle,l,m,_,a,y,n,e.stableNodeId,e.nodeDepth,c);this._lyrHandleToObjects.set(e.handle,v),this._memCache.put(Qe(v.handle),v);const{usedMemory:j}=v;return this._cacheMemory+=j,{memUsageBytes:j}}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=Qe(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 s=this._frustum,r=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(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Qe(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 s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=s.isVisible;this._visibleObjects.delete(s),s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),this._intersectionHandler.removeTile(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Qe(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const r=i.get(s)??this._createTexture(e,t,i);return r?new Ee(this._stage.renderView.textures,r.id):null}_createTexture(e,t,i){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const r=this._stage,{renderView:o}=r,n=o.renderingContext.parameters.maxMaxAnisotropy,a=!!s.mipCount||n>1,l=me[e.wrapMode??"None"];let d=s.alpha?6408:6407;const c=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let h=null,u=null,m=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(h=c,d=6403,u=""):"Rgb8"===s.pixelFormat?(h=c,d=6407,u=""):"Rgba8"===s.pixelFormat&&(h=c,d=6408,u="");break;case"Dxt1":h=c,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":h=c,d=6408,u="image/vnd-ms.dds";break;case"Basis":h=c,d=6407,u="image/ktx2";break;case"Png":u="image/png",m=document.createElement("img");break;case"Jpeg":u="image/jpeg",m=document.createElement("img");break;case"Etc2":u="image/ktx",m=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(m&&u){const e=new Blob([c],{type:u});m.src=URL.createObjectURL(e),h=m}if(h&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker}:void 0,t=new Me(h,{mipmap:a,maxAnisotropy:n,encoding:u,wrap:l,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/pe[m.type],y=F(b);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new q(t,m.byteOffset,p,f),r=new Oe(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new q(t,m.byteOffset,p,f),s=Ve(e.typedBuffer,i);a=new J(s.buffer),l=new Oe(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Oe(new Q(t,m.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new G(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new z(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new N(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(c=new q(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new W(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new $(t,m.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Oe(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new X(t,i.byteOffset,s,r);break;case"U32":d=new Z(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new X(new Uint16Array(e).buffer):new Z(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_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.")},o),"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([d()],Be.prototype,"fullOpacity",null),e([d({readOnly:!0})],Be.prototype,"ready",null),e([d({type:[K]})],Be.prototype,"_modifications",void 0),e([d()],Be.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Be.prototype,"layer",void 0),e([d({readOnly:!0})],Be.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Be.prototype,"_collection",null),e([d()],Be.prototype,"elevationOffset",null),e([d({readOnly:!0})],Be.prototype,"visibleElevationRange",null),Be=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Be);const Ge=Be;class ze{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const c=T();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0,this._mbsCenter=n?E(n.center):O}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:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-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,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ne(e){return Math.round(e/1048.576)/1e3}const qe=T();function We(e,t){const i=ve(e);return C(qe,i.center,t),i.center=qe,i}function $e(e){return new _e(e.center,e.halfSize,y(...e.quaternion))}function Qe(e){return`${e}`}function Je(e,t,i,s){const{origin:r,ellipsoidRadius:o,isGlobal:n,ecefRotation:a}=e,{texCoord0Attr:l,colorAttr:d,normalsAttr:c}=t,{positionView:h,tileObb:u,obbHalfSizeAccumulator:p,elevationRange:b}=s,y=i.getField("position",q),g=y.typedBuffer,_=y.typedBufferStride,v=l?.data,w=null!=l?i.getField("uv0",Q):null,C=w?.typedBuffer,T=w?.typedBufferStride??0,x=d?.data,R=d?.size??0,E=null!=d?i.getField("color",z):null,M=E?.typedBuffer,V=E?.typedBufferStride??0,S=c?.data,U=null!=c?i.getField("normalCompressed",Y):null,A=U?.typedBuffer,H=U?.typedBufferStride??0,L=null!=u?m(Xe,u.quaternionConjugate):f,k=j(Ze,u?.center??O,L),P=L[0],I=L[1],D=L[2],F=L[3],B=L[4],G=L[5],N=L[6],W=L[7],$=L[8],J=k[0],Z=k[1],X=k[2],K=a[0],ee=a[1],te=a[2],ie=a[3],se=a[4],re=a[5],oe=a[6],ne=a[7],ae=a[8],le=a!==f,de=r[0],ce=r[1],he=r[2],ue=h.count,me=h.typedBufferStride,pe=h.typedBuffer,fe=null!=C&&null!=v,be=null!=M&&null!=x&&(3===R||4===R),ye=4===R,ge=null!=A&&null!=S,_e=null!=p;let ve=_e?p[0]:0,we=_e?p[1]:0,je=_e?p[2]:0;for(let m=0;m<ue;++m){const e=m*me,t=pe[e],i=pe[e+1],s=pe[e+2],r=t+de,a=i+ce,l=s+he,d=n?Math.sqrt(r*r+a*a+l*l)-o:l;if(b.expandElevationRangeValues(d,d),_e){const e=Math.abs(r*P+a*F+l*N-J),t=Math.abs(r*I+a*B+l*W-Z),i=Math.abs(r*D+a*G+l*$-X);ve=Math.max(ve,e),we=Math.max(we,t),je=Math.max(je,i)}const c=m*_;if(le){const r=t*K+i*ie+s*oe,o=t*ee+i*se+s*ne,n=t*te+i*re+s*ae;pe[e]=r,pe[e+1]=o,pe[e+2]=n,g[c]=r,g[c+1]=o,g[c+2]=n}else g[c]=t,g[c+1]=i,g[c+2]=s;if(fe){const e=2*m,t=m*T;C[t]=v[e],C[t+1]=v[e+1]}if(be){const e=m*V;if(ye){const t=4*m;M[e]=x[t],M[e+1]=x[t+1],M[e+2]=x[t+2],M[e+3]=x[t+3]}else{const t=3*m;M[e]=x[t],M[e+1]=x[t+1],M[e+2]=x[t+2],M[e+3]=255}}if(ge){const e=2*m,t=m*H;A[t]=S[e],A[t+1]=S[e+1]}}u&&_e&&(p[0]=ve,p[1]=we,p[2]=je,u.setHalfSize(ve,we,je))}const Ze=T(),Xe=p();export{Ge as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as i}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{transpose as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as h,copy as d,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as _,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as f,transformMat4 as g,scale as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as O}from"../../../../geometry/ellipsoidUtils.js";import{create as w,empty as Q,copy as D,offset as G,width as I,height as j,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{e as P,d as C,c as S}from"../../../../chunks/boundedPlane.js";import{create as T}from"../../../../geometry/support/ray.js";import{Sphere as x,sphereCSO as M}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as U}from"../../webgl.js";import{DeconflictAABR as V}from"./DeconflictAABR.js";import{prepare as R,drawPoly as A}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as E}from"./transparencyUtils.js";import N from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as q}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as H}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as W}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as z}from"../../../support/Yield.js";const F=y(),B=y(),L=v(),Y=v(),J=y(),K=n(),X=new x,Z=T(),$=y(),ii=w();class ti{constructor(i){this.id=i,this.aabr=w(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ei(i,t){const e=0!==i.distanceToOccluder&&i.distance>i.distanceToOccluder,s=0!==t.distanceToOccluder&&t.distance>t.distanceToOccluder;return e!==s?+e-+s:i.priority!==t.priority?t.priority-i.priority:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id}class si{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(i){let t=this.getInfo(i);return t||(t=new ti(this.graphics3DGraphic.graphic.uid),this._setInfo(i,t)),t}getInfo(i){return 16===i?this._labelInfo:this._info}removeInfo(i){this._setInfo(i,null)}_setInfo(i,t){16===i?this._labelInfo=t:this._info=t}}class ri{constructor(){this.camera=new N,this.slicePlane=C(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.equals(i.camera)||this.camera.copyFrom(i.camera),S(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let oi=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ri,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=new Array,this._updatingHandles=new b,this._deconflictor=new V((i,t)=>{i.visible=t,this._setGraphicVisibility(this._active.get(i.id),t)},(i,t)=>i.id!==t.id,ei),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange("_readyToRun"))}setPriority(i,t){const e=this._active.get(i.graphic.uid)?.getInfo(this.visibilityGroup);e&&(e.priority=t)}get _readyToRun(){return 0!==this._state||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/5;return this._dirty?.5*i:i}get readyToRun(){return this.view.ready&&null!=this.view.state&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+4*(this._occlusionQueryUids?.length??0)}runTask(i){switch(this._state){case 0:this._startUpdate(),i.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(i))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??1)||!(this._opaqueOcclusionQuery?.done??1))return z;this._readOcclusionQueryResult(),i.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(i))return;case 4:if(this._state=4,this._deconflictor.run(i),!this._deconflictor.done)return;default:this._state=0,this.notifyChange("_readyToRun")}}setGraphicsActive(i,t){t?i.forEach(i=>this.addToActiveGraphics(i)):i.forEach(i=>this.removeFromActiveGraphics(i))}isSupportedLayer(i){if(null==i||!("hiddenIfDeconflicted"in i)||!i.hiddenIfDeconflicted)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof W}_startUpdate(){R(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;if(this._deconflictor.reset(i,t),this._resetIterators(),this._occlusionQueryUids.length=0,!this._checkOcclusion.size)return this._occlusionQuery=s(this._occlusionQuery),void(this._opaqueOcclusionQuery=s(this._opaqueOcclusionQuery))}addToActiveGraphics(i){i.ensureInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){ci(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}addToCheckOcclusion(i){this._checkOcclusion.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromCheckOcclusion(i){this._checkOcclusion.delete(i.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(i){if(0===this._checkOcclusion.size)return!0;const t=this._ensureCheckOcclusionIterator(),e=this._viewState.camera,r=c(K,e.viewInverseTransposeMatrix),o=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&o&&e.relativeElevation>0?X:null;let a=0;null!=n&&(l(n.center,_,e.viewMatrix),n.radius=O(this.view.spatialReference).radius,a=M.distanceToSilhouette(n,_));const u=w();for(;;){if(i.done)return!1;i.madeProgress();const s=t.next();if(!0===s.done)break;const o=s.value,c=o.graphics3DGraphic;if(c.destroyed)continue;if(!c.isVisible(1,8))continue;const h=ui(c,this.visibilityGroup);let d=null,p=!0,_=!1;for(const i of h){if(!this.isSupportedLayer(i))continue;d=hi,this._projectHudLayer(i,e,d),Q(u);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(u,e,i,t,d),d.isOutsideScreen){p=!1;break}if(this._isCulledBySlice(o,d.positionWorld)){p=!1;break}if(null!=n&&li(d,n,a)){p=!1;break}d.altitude=this.view.renderCoordsHelper.getAltitude(d.positionWorld);const s=o.ensureInfo(this.visibilityGroup);if(s.altitude=d.altitude,s.distance=d.distance,s.distanceToOccluder=d.distanceToOccluder,s.culled=!1,D(s.aabr,u),!i.occlusionCheck)break;l(B,d.positionView,r);const h=this._ensureOcclusionQuery(),y=this._ensureOpaqueOcclusionQuery();0===this._occlusionQueryUids.length&&(this._initOcclusionQuery(h),this._initOcclusionQuery(y));const f=h.addPosition(B),g=y.addPosition(B);if(f===this._occlusionQueryUids.length&&g===f){const t=i.adaptiveOcclusion;this._occlusionQueryUids.push(t?-c.graphic.uid:c.graphic.uid),_=!0}break}const y=this._active.has(c.graphic.uid);if(y||_){if(y&&(!p||!d)){const i=o.ensureInfo(this.visibilityGroup);i.visible=!d,i.culled=!0}}else this._setGraphicVisibility(o,p)}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=s(this._occlusionQuery),this._opaqueOcclusionQuery=s(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;const i=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(i.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){const i=this._occlusionQueryUids[e],s=Math.abs(i),r=i<0,o=this._checkOcclusion.get(s);if(!o)continue;const c=this._occlusionQuery.getOcclusion(e)??-1,n=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,a=o.getInfo(this.visibilityGroup);a&&(a.distanceToOccluder=c>0?a.distance-c:0);const l=0===n||n>0&&this._occludedVisibility(a?a.distance-n:0,a?.distance??n,a?.altitude??0,t,r),u=0===c||c>0&&this._occludedVisibility(a?.distanceToOccluder??0,a?.distance??c,a?.altitude??0,t,r),h=l||u;h&&this._setTransparentMode(o,l&&!u),this._active.has(s)?a&&(a.culled=!h,a.visible=h):this._setGraphicVisibility(o,h)}this._occlusionQueryUids.length=0}_collectActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=16===this.visibilityGroup;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._activeIterator=null,!0;const r=s.value,o=r.getInfo(this.visibilityGroup);if(!o)continue;const c=!e||r.graphics3DGraphic.isVisible();!c||o.culled?(A(o.aabr,!1,!0),this._setGraphicVisibility(r,c&&o.visible)):this._deconflictor.add(o)}return!1}_occludedVisibility(i,t,e,s,r=!0){const o=Math.max(this._minAltitudeDifference,Math.abs(e-s))-this._minAltitudeDifference,c=r?this._baseOccludedVisibility+this._altitudeFactor*o:0;return 0===i||t-i<=c}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(i){if(!i)return;const{camera:t}=this._viewState,e=2,s=Math.max(e,e+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(F,this._viewState.camera.eye,2**-s),u(F,h(F,F),2**s),i.init(this._checkOcclusion.size,F)}_ensureOcclusionQuery(){return this._occlusionQuery??=new q({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new q({view:this.view,category:U.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(i){return[...this._checkOcclusion.values()].reduce((t,e)=>t+(e.getInfo(i)?.visible?1:0),0)}_projectHudLayer(i,t,e){const s=i.stageObject,r=s.geometries[0],o=r.material;d(B,s.boundingVolumeWorldSpace.bounds.center),l(F,B,t.viewMatrix);const c=r.attributes,n=c.get("normal").data,a=c.get("centerOffset")?.data??_,[h]=c.get("groundDistance").data;o.applyShaderOffsets(B,F,n,s.transformation,a,h,t,e.screenSizePerspectiveEvaluators),f(L,F[0],F[1],F[2],1),g(Y,L,t.projectionMatrix),u(e.positionNDC,Y,1/Y[3]),o.applyShaderOffsetsNDC(e.positionNDC,a,h,t,e.positionNDC,J),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(J[2]),e.distance=J[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),f(Y,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),g(L,Y,t.inverseProjectionMatrix),m(L,L,1/L[3]),p(e.positionView,L[0],L[1],L[2]),d(e.positionWorld,B)}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&P(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:o,screenSizePerspectiveEvaluators:c}){const n=s.getScreenSize(ni);c.evaluator.applyVec2(n,n),n[0]*=t.pixelRatio,n[1]*=t.pixelRatio;const a=G(r.calculateRelativeScreenBounds(n,c.alignmentEvaluator.apply(t.pixelRatio),ii),e(0,t.fullWidth,.5+.5*o[0]),e(0,t.fullHeight,.5+.5*o[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(I(a),j(a));a[0]-=i,a[1]-=i,a[2]+=i,a[3]+=i}k(i,a,i)}_setGraphicVisibility(i,t){const e=i?.graphics3DGraphic;e&&!e.destroyed&&(e.setVisibilityFlag(this.visibilityGroup,8,t),16===this.visibilityGroup&&this.view.labeler.setLabelGraphicVisibility(e,t))}_setTransparentMode(i,t){const e=i?.graphics3DGraphic;if(e&&!e.destroyed)for(const s of e.layers){if("object3d"!==s?.type)continue;const{graphics3DSymbolLayer:i}=s;E(i)&&i.updateTransparentMode(s,t)}}};function ci(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,8,!0)}i([r({constructOnly:!0})],oi.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],oi.prototype,"_readyToRun",null),i([r({type:Boolean,readOnly:!0})],oi.prototype,"updating",null),i([r({readOnly:!0})],oi.prototype,"_updatingHandles",void 0),oi=i([o("esri.views.3d.layers.graphics.Deconflictor")],oi);const ni=a();class ai{constructor(){this.positionWorld=y(),this.positionView=y(),this.positionNDC=y(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new H}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function li(i,t,e){return d(Z.direction,i.positionView),p(Z.origin,0,0,0),!!t.intersectRay(Z,$)&&i.distanceWithoutPolygonOffset>e}function ui(i,t){return 16===t?i.labelLayers:i.layers}const hi=new ai;export{oi as Deconflictor,si as DeconflictorGraphic,ri as DeconflictorViewState};
2
+ import{__decorate as i}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{transpose as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as h,copy as d,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as _,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{set as f,transformMat4 as g,scale as m}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as O}from"../../../../geometry/ellipsoidUtils.js";import{create as w,empty as Q,copy as D,offset as G,width as I,height as j,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{e as P,d as C,c as S}from"../../../../chunks/boundedPlane.js";import{create as T}from"../../../../geometry/support/ray.js";import{Sphere as x,sphereCSO as M}from"../../../../geometry/support/sphere.js";import{InternalRenderCategory as U}from"../../webgl.js";import{DeconflictAABR as V}from"./DeconflictAABR.js";import{prepare as R,drawPoly as A}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as E}from"./transparencyUtils.js";import N from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as q}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as H}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as W}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as z}from"../../../support/Yield.js";const F=y(),B=y(),L=v(),Y=v(),J=y(),K=n(),X=new x,Z=T(),$=y(),ii=w();class ti{constructor(i){this.id=i,this.aabr=w(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ei(i,t){const e=0!==i.distanceToOccluder&&i.distance>i.distanceToOccluder,s=0!==t.distanceToOccluder&&t.distance>t.distanceToOccluder;return e!==s?+e-+s:i.priority!==t.priority?t.priority-i.priority:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id}class si{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(i){let t=this.getInfo(i);return t||(t=new ti(this.graphics3DGraphic.graphic.uid),this._setInfo(i,t)),t}getInfo(i){return 16===i?this._labelInfo:this._info}removeInfo(i){this._setInfo(i,null)}_setInfo(i,t){16===i?this._labelInfo=t:this._info=t}}class ri{constructor(){this.camera=new N,this.slicePlane=C(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.equals(i.camera)||this.camera.copyFrom(i.camera),S(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let oi=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ri,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=new Array,this._updatingHandles=new b,this._deconflictor=new V((i,t)=>{i.visible=t,this._setGraphicVisibility(this._active.get(i.id),t)},(i,t)=>i.id!==t.id,ei),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange("_readyToRun"))}setPriority(i,t){const e=this._active.get(i.graphic.uid)?.getInfo(this.visibilityGroup);e&&(e.priority=t)}get _readyToRun(){return 0!==this._state||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/5;return this._dirty?.5*i:i}get readyToRun(){return this.view.ready&&null!=this.view.state&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+4*(this._occlusionQueryUids?.length??0)}runTask(i){switch(this._state){case 0:this._startUpdate(),i.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(i))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??1)||!(this._opaqueOcclusionQuery?.done??1))return z;this._readOcclusionQueryResult(),i.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(i))return;case 4:if(this._state=4,this._deconflictor.run(i),!this._deconflictor.done)return;default:this._state=0,this.notifyChange("_readyToRun")}}setGraphicsActive(i,t){t?i.forEach(i=>this.addToActiveGraphics(i)):i.forEach(i=>this.removeFromActiveGraphics(i))}isSupportedLayer(i){if(null==i||!("hiddenIfDeconflicted"in i)||!i.hiddenIfDeconflicted)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof W}_startUpdate(){R(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;if(this._deconflictor.reset(i,t),this._resetIterators(),this._occlusionQueryUids.length=0,!this._checkOcclusion.size)return this._occlusionQuery=s(this._occlusionQuery),void(this._opaqueOcclusionQuery=s(this._opaqueOcclusionQuery))}addToActiveGraphics(i){i.ensureInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){this._active.get(i.graphics3DGraphic.graphic.uid)===i&&(ci(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(i){this._checkOcclusion.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromCheckOcclusion(i){this._checkOcclusion.get(i.graphics3DGraphic.graphic.uid)===i&&this._checkOcclusion.delete(i.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(i){if(0===this._checkOcclusion.size)return!0;const t=this._ensureCheckOcclusionIterator(),e=this._viewState.camera,r=c(K,e.viewInverseTransposeMatrix),o=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&o&&e.relativeElevation>0?X:null;let a=0;null!=n&&(l(n.center,_,e.viewMatrix),n.radius=O(this.view.spatialReference).radius,a=M.distanceToSilhouette(n,_));const u=w();for(;;){if(i.done)return!1;i.madeProgress();const s=t.next();if(!0===s.done)break;const o=s.value,c=o.graphics3DGraphic;if(c.destroyed)continue;if(!c.isVisible(1,8))continue;const h=ui(c,this.visibilityGroup);let d=null,p=!0,_=!1;for(const i of h){if(!this.isSupportedLayer(i))continue;d=hi,this._projectHudLayer(i,e,d),Q(u);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(u,e,i,t,d),d.isOutsideScreen){p=!1;break}if(this._isCulledBySlice(o,d.positionWorld)){p=!1;break}if(null!=n&&li(d,n,a)){p=!1;break}d.altitude=this.view.renderCoordsHelper.getAltitude(d.positionWorld);const s=o.ensureInfo(this.visibilityGroup);if(s.altitude=d.altitude,s.distance=d.distance,s.distanceToOccluder=d.distanceToOccluder,s.culled=!1,D(s.aabr,u),!i.occlusionCheck)break;l(B,d.positionView,r);const h=this._ensureOcclusionQuery(),y=this._ensureOpaqueOcclusionQuery();0===this._occlusionQueryUids.length&&(this._initOcclusionQuery(h),this._initOcclusionQuery(y));const f=h.addPosition(B),g=y.addPosition(B);if(f===this._occlusionQueryUids.length&&g===f){const t=i.adaptiveOcclusion;this._occlusionQueryUids.push(t?-c.graphic.uid:c.graphic.uid),_=!0}break}const y=this._active.has(c.graphic.uid);if(y||_){if(y&&(!p||!d)){const i=o.ensureInfo(this.visibilityGroup);i.visible=!d,i.culled=!0}}else this._setGraphicVisibility(o,p)}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=s(this._occlusionQuery),this._opaqueOcclusionQuery=s(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;const i=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(i.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){const i=this._occlusionQueryUids[e],s=Math.abs(i),r=i<0,o=this._checkOcclusion.get(s);if(!o)continue;const c=this._occlusionQuery.getOcclusion(e)??-1,n=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,a=o.getInfo(this.visibilityGroup);a&&(a.distanceToOccluder=c>0?a.distance-c:0);const l=0===n||n>0&&this._occludedVisibility(a?a.distance-n:0,a?.distance??n,a?.altitude??0,t,r),u=0===c||c>0&&this._occludedVisibility(a?.distanceToOccluder??0,a?.distance??c,a?.altitude??0,t,r),h=l||u;h&&this._setTransparentMode(o,l&&!u),this._active.has(s)?a&&(a.culled=!h,a.visible=h):this._setGraphicVisibility(o,h)}this._occlusionQueryUids.length=0}_collectActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=16===this.visibilityGroup;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._activeIterator=null,!0;const r=s.value,o=r.getInfo(this.visibilityGroup);if(!o)continue;const c=!e||r.graphics3DGraphic.isVisible();!c||o.culled?(A(o.aabr,!1,!0),this._setGraphicVisibility(r,c&&o.visible)):this._deconflictor.add(o)}return!1}_occludedVisibility(i,t,e,s,r=!0){const o=Math.max(this._minAltitudeDifference,Math.abs(e-s))-this._minAltitudeDifference,c=r?this._baseOccludedVisibility+this._altitudeFactor*o:0;return 0===i||t-i<=c}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(i){if(!i)return;const{camera:t}=this._viewState,e=2,s=Math.max(e,e+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(F,this._viewState.camera.eye,2**-s),u(F,h(F,F),2**s),i.init(this._checkOcclusion.size,F)}_ensureOcclusionQuery(){return this._occlusionQuery??=new q({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new q({view:this.view,category:U.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(i){return[...this._checkOcclusion.values()].reduce((t,e)=>t+(e.getInfo(i)?.visible?1:0),0)}_projectHudLayer(i,t,e){const s=i.stageObject,r=s.geometries[0],o=r.material;d(B,s.boundingVolumeWorldSpace.bounds.center),l(F,B,t.viewMatrix);const c=r.attributes,n=c.get("normal").data,a=c.get("centerOffset")?.data??_,[h]=c.get("groundDistance").data;o.applyShaderOffsets(B,F,n,s.transformation,a,h,t,e.screenSizePerspectiveEvaluators),f(L,F[0],F[1],F[2],1),g(Y,L,t.projectionMatrix),u(e.positionNDC,Y,1/Y[3]),o.applyShaderOffsetsNDC(e.positionNDC,a,h,t,e.positionNDC,J),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(J[2]),e.distance=J[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),f(Y,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),g(L,Y,t.inverseProjectionMatrix),m(L,L,1/L[3]),p(e.positionView,L[0],L[1],L[2]),d(e.positionWorld,B)}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&P(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:o,screenSizePerspectiveEvaluators:c}){const n=s.getScreenSize(ni);c.evaluator.applyVec2(n,n),n[0]*=t.pixelRatio,n[1]*=t.pixelRatio;const a=G(r.calculateRelativeScreenBounds(n,c.alignmentEvaluator.apply(t.pixelRatio),ii),e(0,t.fullWidth,.5+.5*o[0]),e(0,t.fullHeight,.5+.5*o[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(I(a),j(a));a[0]-=i,a[1]-=i,a[2]+=i,a[3]+=i}k(i,a,i)}_setGraphicVisibility(i,t){const e=i?.graphics3DGraphic;e&&!e.destroyed&&(e.setVisibilityFlag(this.visibilityGroup,8,t),16===this.visibilityGroup&&this.view.labeler.setLabelGraphicVisibility(e,t))}_setTransparentMode(i,t){const e=i?.graphics3DGraphic;if(e&&!e.destroyed)for(const s of e.layers){if("object3d"!==s?.type)continue;const{graphics3DSymbolLayer:i}=s;E(i)&&i.updateTransparentMode(s,t)}}};function ci(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,8,!0)}i([r({constructOnly:!0})],oi.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],oi.prototype,"_readyToRun",null),i([r({type:Boolean,readOnly:!0})],oi.prototype,"updating",null),i([r({readOnly:!0})],oi.prototype,"_updatingHandles",void 0),oi=i([o("esri.views.3d.layers.graphics.Deconflictor")],oi);const ni=a();class ai{constructor(){this.positionWorld=y(),this.positionView=y(),this.positionNDC=y(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new H}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function li(i,t,e){return d(Z.direction,i.positionView),p(Z.origin,0,0,0),!!t.intersectRay(Z,$)&&i.distanceWithoutPolygonOffset>e}function ui(i,t){return 16===t?i.labelLayers:i.layers}const hi=new ai;export{oi as Deconflictor,si as DeconflictorGraphic,ri as DeconflictorViewState};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as r,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as i,ZEROS as n,fromArray as s,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as l}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as p}from"./defaultSymbolComplexity.js";import{ElevationContext as c}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as d}from"./graphicUtils.js";import{Loadable as h}from"./Loadable.js";import{getSizeAttributeValue as y,getAttributeValue as g}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as f}from"../support/symbolColorUtils.js";const v=()=>e.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class m extends h{constructor(e,t,r,o,i=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=i,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=o.renderPriority,this._renderPriorityStep=o.renderPriorityStep,this._elevationContext=new c,this.updateComplexity(),this.ignoreDrivers=o.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,i)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,o){const i=e.projectionSuccess,n="polygons"in e?e.polygons:"polygonIndices"in e?e.polygonIndices:null,s=`${o} geometry failed to be created`;i?!this._logGeometryValidationWarnings(t,r,o)&&0===n?.length&&"rings"===r&&t.length>0&&t[0].length>2&&v().warnOncePerTick(`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):v().warnOncePerTick(`${s} (failed to project geometry to view spatial reference)`)}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const o=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(v().warnOncePerTick(`${o} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(v().warnOncePerTick(`${o} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":l(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){const t=new c;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){const r=t.geometry,o=this.getDefaultElevationInfo(r);e.unit=null!=this._elevationContext.unit?this._elevationContext.unit:o.unit,e.mode=this.getGeometryElevationMode(r,o),e.offsetMeters=this._elevationContext.meterUnitOffset??o.offset??0;const i=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===e.mode;i&&(e.mode="relative-to-ground",e.offsetMeters=0);const n=i?u:this._elevationContext.featureExpressionInfoContext;n?e.updateFeatureExpressionInfoContextForGraphic(n,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=b){const o=this._getCombinedOpacity(e,r);if(this._drivenProperties.color)return d(null,o);const i=e?.toUnitRGB()??t;return d(i,o)}_getDrivenUInt8Color({color:e,opacity:t},r,o){const{color:s,opacity:a}=this._drivenProperties,l=r?.toUnitRGBA()??(o?i:n),p=s?e?.output??l:null,c=e||r||o,u=s?null:l[3];return d(p,a&&c?t?.output??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},i,n){const l=i?s(i.toUnitRGBA()):a(NaN,NaN,NaN,n?NaN:0);return this._drivenProperties.color&&null!=e&&r(l,e.output),this._drivenProperties.opacity&&null!=t&&(l[3]=t.output),o(l,l,255),f(l,l)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return p(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"screenSizePerspectiveEnabled":return this.layerScreenSizePerspectiveChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;case"terrainTransparency":return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let o=1;return e?.forEach(e=>{const i=t(e);if(null!=i){const t=e.graphic;this.updateElevationContextForGraphic(i.elevationContext,t),i.needsElevationUpdates=r(i.elevationContext.mode)}else o=2}),o}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=y(t.size,e.size),o=g(t.color,e.color),i=g(t.opacity,e.opacity);return a(r,o,i,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&v().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const o=e.stops[t].color;o&&o.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=a(NaN,NaN,NaN,NaN);export{m as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};
2
+ import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as r,scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as o,ZEROS as n,fromArray as s,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as l}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as p}from"./defaultSymbolComplexity.js";import{ElevationContext as c}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as d}from"./graphicUtils.js";import{Loadable as h}from"./Loadable.js";import{getSizeAttributeValue as y,getAttributeValue as f}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as g}from"../support/symbolColorUtils.js";const v=()=>e.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class m extends h{constructor(e,t,r,i,o=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=i.renderPriority,this._renderPriorityStep=i.renderPriorityStep,this._elevationContext=new c,this.updateComplexity(),this.ignoreDrivers=i.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,o)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,i){const o=e.projectionSuccess,n="polygonIndices"in e?e.polygonIndices:null,s=`${i} geometry failed to be created`;o?!this._logGeometryValidationWarnings(t,r,i)&&0===n?.length&&"rings"===r&&t.length>0&&t[0].length>2&&v().warnOncePerTick(`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):v().warnOncePerTick(`${s} (failed to project geometry to view spatial reference)`)}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const i=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(v().warnOncePerTick(`${i} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(v().warnOncePerTick(`${i} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":l(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){const t=new c;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){const r=t.geometry,i=this.getDefaultElevationInfo(r);e.unit=null!=this._elevationContext.unit?this._elevationContext.unit:i.unit,e.mode=this.getGeometryElevationMode(r,i),e.offsetMeters=this._elevationContext.meterUnitOffset??i.offset??0;const o=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===e.mode;o&&(e.mode="relative-to-ground",e.offsetMeters=0);const n=o?u:this._elevationContext.featureExpressionInfoContext;n?e.updateFeatureExpressionInfoContextForGraphic(n,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=b){const i=this._getCombinedOpacity(e,r);if(this._drivenProperties.color)return d(null,i);const o=e?.toUnitRGB()??t;return d(o,i)}_getDrivenUInt8Color({color:e,opacity:t},r,i){const{color:s,opacity:a}=this._drivenProperties,l=r?.toUnitRGBA()??(i?o:n),p=s?e?.output??l:null,c=e||r||i,u=s?null:l[3];return d(p,a&&c?t?.output??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},o,n){const l=o?s(o.toUnitRGBA()):a(NaN,NaN,NaN,n?NaN:0);return this._drivenProperties.color&&null!=e&&r(l,e.output),this._drivenProperties.opacity&&null!=t&&(l[3]=t.output),i(l,l,255),g(l,l)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return p(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"screenSizePerspectiveEnabled":return this.layerScreenSizePerspectiveChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;case"terrainTransparency":return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let i=1;return e?.forEach(e=>{const o=t(e);if(null!=o){const t=e.graphic;this.updateElevationContextForGraphic(o.elevationContext,t),o.needsElevationUpdates=r(o.elevationContext.mode)}else i=2}),i}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=y(t.size,e.size),i=f(t.color,e.color),o=f(t.opacity,e.opacity);return a(r,i,o,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&v().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const i=e.stops[t].color;i&&i.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=a(NaN,NaN,NaN,NaN);export{m as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import e from"../../../core/Error.js";import{onAbort as n,createAbortError as a}from"../../../core/promiseUtils.js";import{whenOnce as r}from"../../../core/reactiveUtils.js";import{toRenderCamera as o}from"../webgl.js";import{applyAll as s}from"../camera/constraintUtils.js";import{isPointToPointAnimationController as l,PointToPointAnimationController as h}from"./controllers/PointToPointAnimationController.js";import{SurfaceCollisionCorrectionController as c}from"./controllers/SurfaceCollisionCorrectionController.js";import{create as m}from"../support/viewpointUtils.js";class w{constructor(t,i,e){this._target=t,this._options=i,this.view=e,this.state="pending",this._animationController=null,this.promise=new Promise((t,i)=>{this._resolveCallback=t,this._rejectCallback=i;const e=new AbortController;null!=this._options.signal&&n(this._options.signal,()=>this.abort()),this._abortController=e,this._waitForReady()})}_resolve(t){if("finished"!==this.state)return this.state="finished",this._resolveCallback(t)}_reject(t){if("finished"!==this.state)return this.state="finished",this._rejectCallback(t)}abort(t=!1){if(this._abortController.abort(),"wait-for-animation-finish"===this.state)!t&&null!=this._animationController&&this.view.state.cameraController===this._animationController&&this._animationController.running&&this._animationController.stopController();this._reject(a())}async _waitForReady(){if(this.state="wait-for-ready",!this.view.ready)try{await r(()=>this.view.ready,this._abortController.signal)}catch(t){return this._reject(t)}this._createViewPoint()}async _createViewPoint(){if("finished"!==this.state){this.state="wait-for-viewpoint",this._animationController=this._options.animate?this._getAnimationController():null;try{const t=await m(this.view,this._target,this._abortController.signal);if("finished"===this.state)return;const i=t?this._getCameraFromViewpoint(t):null;if(null==i)return;if(this._options.animate){if(null==this._animationController)return;this._startAnimation(i,this._animationController)}else this.view.stateManager.setStateCamera(i.camera,{applyConstraints:!i.isFullySpecified,positionAndOrientationOnly:!0,doNotCancelGoToOperation:!0}),this._resolve()}catch(t){this._reject(t)}}}_getCameraFromViewpoint(n){const a=!!(this._target instanceof i&&this._target.camera||this._target instanceof t||"position"in this._target&&void 0!==this._target.position?.z||Array.isArray(this._target)&&void 0!==this._target[2]),r=n.camera;if(null==r)return null;if(!this.view.stateManager.isCompatible(r)){const t=r.position,i=t&&t.spatialReference,n=i?i.wkid:"none",a=this.view.spatialReference?.wkid;return this._reject(new e("GotoAnimation:incompatible-spatialreference",`Resulting camera has an incompatible spatial reference (camera: ${n}, view: ${a})`,{camera:r})),null}const s=o(this.view,r);return null==s?(this._reject(new e("GotoAnimation:invalid-camera","Resulting camera is invalid")),null):{viewpoint:n,camera:s,isFullySpecified:a}}_startAnimation(t,i){this.state="wait-for-animation-finish";const n=i.viewAnimation;if(null==n)return void this._reject(new e("GotoAnimation:missing-animation","Unreachable code in view.stateManager"));if(n.update(t.viewpoint,"running"),!i.running||null==i.viewAnimation||i.viewAnimation.target!==t.viewpoint||this.view.state.cameraController!==i)return this.abort();let a;t.isFullySpecified?a=new c({view:this.view,desiredCamera:t.camera}):s(this.view,t.camera),i.begin(t.camera,this._options);const r=()=>{const e=this.view.state.cameraController;a&&(e&&e.running?l(e)&&null!=e.viewAnimation&&e.viewAnimation.target===t.viewpoint&&(this.view.state.cameraController=a):null!=i.viewAnimation&&i.viewAnimation.target===t.viewpoint&&4===i.state&&(this.view.state.cameraController=a))},o=t=>{if(null!=this.view.state)switch(i.state){case 4:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._resolve()}break;case 0:case 1:case 2:case 3:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._reject(t)}}};n.when(r,t=>o(t)),i.asyncResult={resolve:()=>o(),reject:t=>o(t)}}_getAnimationController(){let t=null,i=null;const n=this.view.state.cameraController;return l(n)&&(n.updateStateFromViewAnimation(),n.running&&(t=n,i=t.viewAnimation)),null==t&&(t=new h({view:this.view,mode:"animation"}),i=t.viewAnimation,this.view.state.switchCameraController(t),1===t.state)?(i?.stop(),this._reject(new e("GotoAnimation:goto-cannot-interrupt","Cannot start an animation while interacting")),null):t}}export{w as GoToOperation};
2
+ import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import e from"../../../core/Error.js";import{onAbort as n,createAbortError as a}from"../../../core/promiseUtils.js";import{whenOnce as r}from"../../../core/reactiveUtils.js";import{toRenderCameraWithScale as o}from"../webgl.js";import{applyAll as s}from"../camera/constraintUtils.js";import{isPointToPointAnimationController as l,PointToPointAnimationController as h}from"./controllers/PointToPointAnimationController.js";import{SurfaceCollisionCorrectionController as c}from"./controllers/SurfaceCollisionCorrectionController.js";import{create as m}from"../support/viewpointUtils.js";class w{constructor(t,i,e){this._target=t,this._options=i,this.view=e,this.state="pending",this._animationController=null,this.promise=new Promise((t,i)=>{this._resolveCallback=t,this._rejectCallback=i;const e=new AbortController;null!=this._options.signal&&n(this._options.signal,()=>this.abort()),this._abortController=e,this._waitForReady()})}_resolve(t){if("finished"!==this.state)return this.state="finished",this._resolveCallback(t)}_reject(t){if("finished"!==this.state)return this.state="finished",this._rejectCallback(t)}abort(t=!1){if(this._abortController.abort(),"wait-for-animation-finish"===this.state)!t&&null!=this._animationController&&this.view.state.cameraController===this._animationController&&this._animationController.running&&this._animationController.stopController();this._reject(a())}async _waitForReady(){if(this.state="wait-for-ready",!this.view.ready)try{await r(()=>this.view.ready,this._abortController.signal)}catch(t){return this._reject(t)}this._createViewPoint()}async _createViewPoint(){if("finished"!==this.state){this.state="wait-for-viewpoint",this._animationController=this._options.animate?this._getAnimationController():null;try{const t=await m(this.view,this._target,this._abortController.signal);if("finished"===this.state)return;const i=t?this._getCameraFromViewpoint(t):null;if(null==i)return;if(this._options.animate){if(null==this._animationController)return;this._startAnimation(i,this._animationController)}else this.view.stateManager.setStateCamera(i.camera,{applyConstraints:!i.isFullySpecified,positionAndOrientationOnly:!0,doNotCancelGoToOperation:!0}),this._resolve()}catch(t){this._reject(t)}}}_getCameraFromViewpoint(n){const a=this._target instanceof i,r=this._target instanceof t,s=!!(a&&this._target.camera||r||"position"in this._target&&void 0!==this._target.position?.z||Array.isArray(this._target)&&void 0!==this._target[2]),l=n.camera;if(null==l)return null;if(!this.view.stateManager.isCompatible(l)){const t=l.position,i=t&&t.spatialReference,n=i?i.wkid:"none",a=this.view.spatialReference?.wkid;return this._reject(new e("GotoAnimation:incompatible-spatialreference",`Resulting camera has an incompatible spatial reference (camera: ${n}, view: ${a})`,{camera:l})),null}const h=o(this.view,l,n.scale);return null==h?(this._reject(new e("GotoAnimation:invalid-camera","Resulting camera is invalid")),null):{viewpoint:n,camera:h,isFullySpecified:s}}_startAnimation(t,i){this.state="wait-for-animation-finish";const n=i.viewAnimation;if(null==n)return void this._reject(new e("GotoAnimation:missing-animation","Unreachable code in view.stateManager"));if(n.update(t.viewpoint,"running"),!i.running||null==i.viewAnimation||i.viewAnimation.target!==t.viewpoint||this.view.state.cameraController!==i)return this.abort();let a;t.isFullySpecified?a=new c({view:this.view,desiredCamera:t.camera}):s(this.view,t.camera),i.begin(t.camera,this._options);const r=()=>{const e=this.view.state.cameraController;a&&(e&&e.running?l(e)&&null!=e.viewAnimation&&e.viewAnimation.target===t.viewpoint&&(this.view.state.cameraController=a):null!=i.viewAnimation&&i.viewAnimation.target===t.viewpoint&&4===i.state&&(this.view.state.cameraController=a))},o=t=>{if(null!=this.view.state)switch(i.state){case 4:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._resolve()}break;case 0:case 1:case 2:case 3:switch(this.state){case"pending":case"wait-for-ready":case"wait-for-viewpoint":case"wait-for-animation-finish":this._reject(t)}}};n.when(r,t=>o(t)),i.asyncResult={resolve:()=>o(),reject:t=>o(t)}}_getAnimationController(){let t=null,i=null;const n=this.view.state.cameraController;return l(n)&&(n.updateStateFromViewAnimation(),n.running&&(t=n,i=t.viewAnimation)),null==t&&(t=new h({view:this.view,mode:"animation"}),i=t.viewAnimation,this.view.state.switchCameraController(t),1===t.state)?(i?.stop(),this._reject(new e("GotoAnimation:goto-cannot-interrupt","Cannot start an animation while interacting")),null):t}}export{w as GoToOperation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{cyclicalPI as i}from"../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s}from"../../../../core/screenUtils.js";import{subclass as o}from"../../../../core/accessorSupport/decorators.js";import{copy as a,distance as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as m,negate as h,length as c,subtract as _,normalize as p,add as u,scale as l,dot as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as P}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as v}from"../../../../geometry/support/axisAngle.js";import{create as C,fromPositionAndNormal as w,getNormal as b}from"../../../../geometry/support/plane.js";import{Sphere as M}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as S,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as j}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as E}from"../../input/util.js";import{InteractiveController as y}from"./InteractiveController.js";import{PanPlanarMomentumController as x}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as A}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as O}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as R}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as z}from"./momentum/ZoomSphericalMomentumController.js";import{pickPointAndInitSphere as k,excludeTerrain as F,inferNavigationMode as H,sphereOrPlanePointFromScreenPoint as D,maxPanDistanceModifier as T,minPinchAndPanCameraHeight as U,pivotSearchAreaSize as G,intersectPlaneFromScreenPointAtEye as I,applyZoomOnSphere as Z,shouldPreserveHeading as V,applyPanSphericalPreserveHeading as q,applyPanSphericalDirectRotation as B,normalizeRotationDelta as J,applyRotation as K,applyPanPlanar as L,applyZoomToPoint as N}from"../utils/navigationUtils.js";import Q from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as W}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as X}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as Y}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as $}from"../../../navigation/ZoomMomentumEstimator.js";let tt=class extends y{constructor(){super(...arguments),this._smoothRotation=new E(.05),this._rotationAxis=g(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=C(),this._beginRadius=0,this._smoothScaling=new E(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new $,this._rotationMomentumEstimator=new Y,this._panSphericalMomentumEstimator=new X,this._panPlanarMomentumEstimator=new W,this._adjustedSphere=new M,this._tmp3d=g(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=g(),this._screenPickPoint=n(),this._scenePickPoint=g(),this._navigationMode=1,this._sphere=new M,this._pointerCount=0,this._tmpInteractionDirection=g(),this._beginCamera=new Q,this._constraintOptions=new j(15,0,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._beginAngle=t.angle,this._pointerCount=t.pointers.size,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),a(this._beginScreenPoint,this._screenPickPoint);const n=k(this._intersectionHelper,this.startCamera,this._screenPickPoint,P(this.view.spatialReference).radius,1,this.view.basemapTerrain.invisible?F:{});null!=n.scenePickPoint&&(this._scenePickPoint=n.scenePickPoint,this._sphere=n.sphere,m(this._beginScenePoint,this._scenePickPoint),this._navigationMode=H(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),0===this._navigationMode&&this._preparePlanarPanMode(t,n.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;1===this._navigationMode?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return 1===this._navigationMode?new z({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new R({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new O({view:this.view,momentum:e,center:this._sphere.center,axis:this._rotationAxis});if(1===this._navigationMode){const t=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new A({view:this.view,momentum:t})}else{const t=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=h(this._tmp3d,this.startCamera.viewForward);w(this._scenePickPoint,e,this._panningPlane);const o=n(this._screenPickPoint[0],0),a=g(),r=c(this.startCamera.eye);this._adjustedSphere.radius=r<this._sphere.radius?r-100:this._sphere.radius,D(this._adjustedSphere,this.startCamera,o,a);const P=g(),v=g(),C=g();_(P,this._scenePickPoint,this.currentCamera.eye);const M=c(P);p(P,P);const S=T*Math.max(Math.abs(this.view.camera.position.z),U),f=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,G);let j=null!=f?f:S;i&&(j=Math.min(j,M)),m(C,u(v,this.currentCamera.eye,l(v,P,j))),this._panningPlane[3]=-d(b(this._panningPlane),C),this.startCamera.center=u(v,this.startCamera.eye,l(v,this.startCamera.viewForward,j));const E=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.startCamera,E,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),Z(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);D(this._sphere,this.currentCamera,i,this._tmp3d),V(this._beginScenePoint,d(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(q(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(B(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(r(this._screenPickPoint,i)),f(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){p(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+J(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*e),f(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);I(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(L(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=S(r(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),f(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),N(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=S(t.radius-this._beginRadius),f(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){m(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||h(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=J(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),K(this.currentCamera,this._sphere.center,v(this._rotationAxis,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=S(t.radius*o),f(this.view,this.currentCamera,this._constraintOptions)}};tt=t([o("esri.views.3d.state.controllers.PinchAndPanControllerGlobal")],tt);export{tt as PinchAndPanControllerGlobal};
2
+ import{__decorate as t}from"tslib";import{cyclicalPI as i}from"../../../../core/Cyclical.js";import{deg2rad as e}from"../../../../core/mathUtils.js";import{createScreenPointArray as n,screenPointObjectToArray as s}from"../../../../core/screenUtils.js";import{property as o,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{copy as r,distance as m}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{copy as h,negate as c,length as _,subtract as p,normalize as l,add as u,scale as d,dot as g}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../../geometry/ellipsoidUtils.js";import{wrapAxisAngle as C}from"../../../../geometry/support/axisAngle.js";import{create as w,fromPositionAndNormal as M,getNormal as b}from"../../../../geometry/support/plane.js";import{Sphere as S}from"../../../../geometry/support/sphere.js";import{pixelDistanceToInteractionFactor as f,applyAll as j}from"../../camera/constraintUtils.js";import{ConstraintOptions as E}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as y}from"../../input/util.js";import{InteractiveController as O}from"./InteractiveController.js";import{PanPlanarMomentumController as x}from"./momentum/PanPlanarMomentumController.js";import{PanSphericalMomentumController as A}from"./momentum/PanSphericalMomentumController.js";import{RotationMomentumController as z}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as R}from"./momentum/ZoomPlanarMomentumController.js";import{ZoomSphericalMomentumController as k}from"./momentum/ZoomSphericalMomentumController.js";import{pickPointAndInitSphere as H,excludeTerrain as F,inferNavigationMode as D,sphereOrPlanePointFromScreenPoint as T,maxPanDistanceModifier as U,minPinchAndPanCameraHeight as G,pivotSearchAreaSize as I,intersectPlaneFromScreenPointAtEye as Z,applyZoomOnSphere as V,shouldPreserveHeading as q,applyPanSphericalPreserveHeading as B,applyPanSphericalDirectRotation as J,normalizeRotationDelta as K,applyRotation as L,applyPanPlanar as N,applyZoomToPoint as Q}from"../utils/navigationUtils.js";import W from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as X}from"../../../navigation/PanPlanarMomentumEstimator.js";import{PanSphericalMomentumEstimator as Y}from"../../../navigation/PanSphericalMomentumEstimator.js";import{RotationMomentumEstimator as $}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as tt}from"../../../navigation/ZoomMomentumEstimator.js";let it=class extends O{constructor(t){super(t),this.forceHorizontalPan=!1,this._smoothRotation=new y(.05),this._rotationAxis=P(),this._beginAngle=0,this._beginHeading=0,this._panningPlane=w(),this._beginRadius=0,this._smoothScaling=new y(.05),this._zoomCenterScreen=n(),this._zoomMomentumEstimator=new tt,this._rotationMomentumEstimator=new $,this._panSphericalMomentumEstimator=new Y,this._panPlanarMomentumEstimator=new X,this._adjustedSphere=new S,this._tmp3d=P(),this._tmpScreenPointArray=n(),this._beginScreenPoint=n(),this._beginScenePoint=P(),this._screenPickPoint=n(),this._scenePickPoint=P(),this._navigationMode=1,this._sphere=new S,this._pointerCount=0,this._tmpInteractionDirection=P(),this._beginCamera=new W,this._constraintOptions=new E(15,0,0,this._beginCamera)}get _intersectionHelper(){return this.view.sceneIntersectionHelper}begin(t){if(!this.running)return;this._zoomMomentumEstimator.enabled=this._rotationMomentumEstimator.enabled=this._panPlanarMomentumEstimator.enabled=this._panSphericalMomentumEstimator.enabled=this.view.navigation.momentumEnabled,this._beginHeading=-i.normalize(e(this.view.camera.heading)),this._beginRadius=t.radius,this._beginAngle=t.angle,this._pointerCount=t.pointers.size,this._smoothRotation.reset(),s(t.center,this._screenPickPoint),r(this._beginScreenPoint,this._screenPickPoint);const n=H(this._intersectionHelper,this.startCamera,this._screenPickPoint,v(this.view.spatialReference).radius,1,this.view.basemapTerrain.invisible?F:{});null!=n.scenePickPoint&&(this._scenePickPoint=n.scenePickPoint,this._sphere=n.sphere,h(this._beginScenePoint,this._scenePickPoint),this.forceHorizontalPan?this._navigationMode=1:this._navigationMode=D(this.startCamera,this._screenPickPoint,this.view.renderCoordsHelper,this.view.viewingMode),0===this._navigationMode&&this._preparePlanarPanMode(t,n.hasGeometryIntersection),this._beginCamera.copyFrom(this.startCamera))}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1;1===this._navigationMode?(i&&this._zoomSpherical(t),this._panningSpherical(t),i&&this._rotateSpherical(t)):(i&&this._zoomPlanar(t),this._panningPlanar(t),i&&this._rotatePlanar(t)),this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return 1===this._navigationMode?new k({view:this.view,momentum:i,screenCenter:this._zoomCenterScreen,sceneCenter:this._beginScenePoint,radius:this._sphere.radius}):new R({view:this.view,momentum:i,zoomCenter:this._beginScenePoint});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new z({view:this.view,momentum:e,center:this._sphere.center,axis:this._rotationAxis});if(1===this._navigationMode){const t=this.view.animationsEnabled&&this._panSphericalMomentumEstimator.evaluateMomentum();if(t)return new A({view:this.view,momentum:t})}else{const t=this.view.animationsEnabled&&this._panPlanarMomentumEstimator.evaluateMomentum();if(t)return new x({view:this.view,momentum:t})}return null}_preparePlanarPanMode(t,i){const e=c(this._tmp3d,this.startCamera.viewForward);M(this._scenePickPoint,e,this._panningPlane);const o=n(this._screenPickPoint[0],0),a=P(),r=_(this.startCamera.eye);this._adjustedSphere.radius=r<this._sphere.radius?r-100:this._sphere.radius,T(this._adjustedSphere,this.startCamera,o,a);const m=P(),v=P(),C=P();p(m,this._scenePickPoint,this.currentCamera.eye);const w=_(m);l(m,m);const S=U*Math.max(Math.abs(this.view.camera.position.z),G),f=this.view.stage.renderView.getMinimalDepthForArea(null,this._screenPickPoint[0],this._screenPickPoint[1],this.view.state.camera,I);let j=null!=f?f:S;i&&(j=Math.min(j,w)),h(C,u(v,this.currentCamera.eye,d(v,m,j))),this._panningPlane[3]=-g(b(this._panningPlane),C),this.startCamera.center=u(v,this.startCamera.eye,d(v,this.startCamera.viewForward,j));const E=s(t.center,this._tmpScreenPointArray);Z(this._panningPlane,this.startCamera,E,this._beginScenePoint)}_zoomSpherical(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),V(this._sphere,this.currentCamera,this._smoothScaling.value),s(t.center,this._zoomCenterScreen),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=f(t.radius-this._beginRadius),j(this.view,this.currentCamera,this._constraintOptions)}_panningSpherical(t){const i=s(t.center,this._tmpScreenPointArray);T(this._sphere,this.currentCamera,i,this._tmp3d),q(this._beginScenePoint,g(this.currentCamera.up,this._beginScenePoint),this._sphere.radius,this._beginHeading,this.view.camera.tilt,this.startCamera.aboveGround)?(B(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this._beginHeading,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumPreserveHeading(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere,this._beginHeading,this.view.camera.tilt)):(J(this._sphere,this.currentCamera,this._beginScenePoint,this._tmp3d,this.view.camera.tilt,!1),this._panSphericalMomentumEstimator.addMomentumDirectRotation(i,this._tmp3d,.001*t.timestamp,this.startCamera,this._sphere.radius,this.view.camera.tilt)),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=f(m(this._screenPickPoint,i)),j(this.view,this.currentCamera,this._constraintOptions)}_rotateSpherical(t){l(this._rotationAxis,this._scenePickPoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value,e=i+K(t.angle-i),n=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=n,this._smoothRotation.update(e);const s=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(s,.001*t.timestamp),L(this.currentCamera,this._sphere.center,C(this._rotationAxis,s)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=f(t.radius*e),j(this.view,this.currentCamera,this._constraintOptions)}_panningPlanar(t){const i=s(t.center,this._tmpScreenPointArray);Z(this._panningPlane,this.currentCamera,i,this._tmp3d)&&(N(this.currentCamera,this._beginScenePoint,this._tmp3d),this._panPlanarMomentumEstimator.add(i,this._tmp3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=f(m(this._beginScreenPoint,i)),this._constraintOptions.interactionDirection=this.view.renderCoordsHelper.worldUpAtPosition(this.currentCamera.eye,this._tmpInteractionDirection),j(this.view,this.currentCamera,this._constraintOptions),this._constraintOptions.interactionDirection=null)}_zoomPlanar(t){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._smoothScaling.gain=e,this._smoothScaling.update(i),this._zoomMomentumEstimator.add(this._smoothScaling.value,.001*t.timestamp),Q(this.currentCamera,this._beginScenePoint,this._smoothScaling.value,this.view.state.constraints.minimumPoiDistance),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=f(t.radius-this._beginRadius),j(this.view,this.currentCamera,this._constraintOptions)}_rotatePlanar(t){h(this._rotationAxis,this._beginScenePoint),this.currentCamera.aboveGround||c(this._rotationAxis,this._rotationAxis);const i=this._smoothRotation.value;let e=t.angle-i;e=K(e);const n=i+e,s=.00125*Math.min(Math.max(t.radius,40),120);this._smoothRotation.gain=s,this._smoothRotation.update(n);const o=this._smoothRotation.value-this._beginAngle;this._rotationMomentumEstimator.add(o,.001*t.timestamp),L(this.currentCamera,this._sphere.center,C(this._rotationAxis,o)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=f(t.radius*o),j(this.view,this.currentCamera,this._constraintOptions)}};t([o({constructOnly:!0})],it.prototype,"forceHorizontalPan",void 0),it=t([a("esri.views.3d.state.controllers.PinchAndPanControllerGlobal")],it);export{it as PinchAndPanControllerGlobal};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{subclass as n}from"../../../../core/accessorSupport/decorators.js";import{distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{negate as o,copy as a,dot as r,subtract as m,length as h,normalize as l,scale as c,add as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as _,fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrapAxisAngle as d}from"../../../../geometry/support/axisAngle.js";import{create as g,fromNormalAndOffset as C,setOffsetFromPoint as v,negate as b,getNormal as w}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as M,applyAll as f}from"../../camera/constraintUtils.js";import{ConstraintOptions as P}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as V}from"../../input/util.js";import{getVoxelWasm as z}from"../../layers/VoxelWasm.js";import{InteractiveController as S}from"./InteractiveController.js";import{PanPlanarMomentumController as j}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as E}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as H}from"./momentum/ZoomPlanarMomentumController.js";import{excludeTerrain as x,inferNavigationMode as y,getTiltScaleFactor as O,maxPanDistanceModifier as F,minPinchAndPanCameraHeight as R,pivotSearchAreaSize as A,centroid as T,applyZoomToPoint as U,applyPanPlanar as D,normalizeRotationDelta as I,applyRotation as Z,intersectPlaneFromScreenPointAtEye as k}from"../utils/navigationUtils.js";import G from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as L}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as W}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as q}from"../../../navigation/ZoomMomentumEstimator.js";const B=u(0,0,1);let J=class extends S{constructor(){super(...arguments),this._rotationValueSmooth=new V(.05),this._scalingValueSmooth=new V(.05),this._planeHorizontal=g(),this._planeVertical=g(),this._rotationMomentumEstimator=new W,this._panMomentumEstimator=new L(300,12,.9),this._zoomMomentumEstimator=new q,this._beginRadius=0,this._beginCenter=_(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=i(),this._tmpCentroid3d=_(),this._tmpCentroid2d=i(),this._tmp2d=i(),this._pointerCount=0,this._beginCamera=new G,this._constraintOptions=new P(15,0,0,this._beginCamera)}begin(t){if(!this.running)return;const i=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=i,this._rotationMomentumEstimator.enabled=i,this._panMomentumEstimator.enabled=i,this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),e(t.center,this._beginCenterScreen),C(B,0,this._planeHorizontal);const n=_(),s=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,n,this.view.basemapTerrain.invisible?x:{}),u=_();o(u,this.startCamera.viewForward);const d=_();a(d,B);const g=r(u,d);this._navigationMode=y(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);const M=O(d,this.startCamera.viewForward,F)*Math.max(Math.abs(this.view.camera.position.z),R);v(this._planeHorizontal,this._planeHorizontal,n),this.startCamera.aboveGround||b(this._planeHorizontal,this._planeHorizontal);const f=_(),P=_(),V=_();m(f,n,this.currentCamera.eye);const S=h(f);if(l(f,f),0===this._navigationMode){c(d,d,g),m(w(this._planeVertical),u,d),l(w(this._planeVertical),w(this._planeVertical)),v(this._planeVertical,this._planeVertical,n);const i=this.view.stage.renderView.getMinimalDepthForArea(z(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,A);let e=null!=i?i:M;s&&(e=Math.min(e,S)),a(V,p(P,this.currentCamera.eye,c(P,f,e))),this._planeVertical[3]=-r(w(this._planeVertical),V),this._computePlanePoints(t.pointers,this._planeVertical,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}else{const i=s?S:M;a(V,p(P,this.currentCamera.eye,c(P,f,i))),this._planeHorizontal[3]=-r(w(this._planeHorizontal),V),this._computePlanePoints(t.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),T(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1,n=1===this._navigationMode?this._planeHorizontal:this._planeVertical,o=this._beginCenter;if(i){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._scalingValueSmooth.gain=e,this._scalingValueSmooth.update(i),U(this.currentCamera,o,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=M(Math.abs(t.radius-this._beginRadius)),f(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(t.pointers,n,this.currentCamera,this._tmpPoints),T(this._tmpPoints,this._tmpCentroid3d),e(t.center,this._tmpCentroid2d),D(this.currentCamera,o,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=M(s(this._beginCenterScreen,this._tmpCentroid2d)),f(this.view,this.currentCamera,this._constraintOptions),i){const i=o,e=this._rotationValueSmooth.value,n=e+I(t.angle-e),s=.00125*Math.min(Math.max(t.radius,40),120);this._rotationValueSmooth.gain=s,this._rotationValueSmooth.update(n);const a=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp);const r=w(this._planeHorizontal);Z(this.currentCamera,i,d(r,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=M(Math.abs(t.radius*a)),f(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return new H({view:this.view,momentum:i,zoomCenter:this._beginCenter});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new E({view:this.view,momentum:e,center:this._beginCenter,axis:w(this._planeHorizontal)});const n=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return n?new j({view:this.view,momentum:n}):null}_computePlanePoints(t,i,e,n){n.length=t.size;const s=this._tmp2d;let o=0;return t.forEach(t=>{s[0]=t.x,s[1]=t.y,void 0===n[o]&&(n[o]=_()),k(i,e,s,n[o]),o+=1}),n}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};J=t([n("esri.views.3d.state.controllers.PinchAndPanControllerLocal")],J);export{J as PinchAndPanControllerLocal};
2
+ import{__decorate as t}from"tslib";import{createScreenPointArray as i,screenPointObjectToArray as e}from"../../../../core/screenUtils.js";import{property as n,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{distance as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{negate as a,copy as r,dot as m,subtract as h,length as l,normalize as c,scale as p,add as _}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,fromValues as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{wrapAxisAngle as g}from"../../../../geometry/support/axisAngle.js";import{create as C,fromNormalAndOffset as v,setOffsetFromPoint as b,negate as w,getNormal as M}from"../../../../geometry/support/plane.js";import{pixelDistanceToInteractionFactor as f,applyAll as P}from"../../camera/constraintUtils.js";import{ConstraintOptions as z}from"../../camera/constraintUtils/ConstraintOptions.js";import{ExponentialFalloff as V}from"../../input/util.js";import{getVoxelWasm as S}from"../../layers/VoxelWasm.js";import{InteractiveController as j}from"./InteractiveController.js";import{PanPlanarMomentumController as E}from"./momentum/PanPlanarMomentumController.js";import{RotationMomentumController as H}from"./momentum/RotationMomentumController.js";import{ZoomPlanarMomentumController as y}from"./momentum/ZoomPlanarMomentumController.js";import{excludeTerrain as x,inferNavigationMode as O,getTiltScaleFactor as F,maxPanDistanceModifier as R,minPinchAndPanCameraHeight as A,pivotSearchAreaSize as T,centroid as U,applyZoomToPoint as D,applyPanPlanar as I,normalizeRotationDelta as Z,applyRotation as k,intersectPlaneFromScreenPointAtEye as G}from"../utils/navigationUtils.js";import L from"../../webgl/RenderCamera.js";import{PanPlanarMomentumEstimator as W}from"../../../navigation/PanPlanarMomentumEstimator.js";import{RotationMomentumEstimator as q}from"../../../navigation/RotationMomentumEstimator.js";import{ZoomMomentumEstimator as B}from"../../../navigation/ZoomMomentumEstimator.js";const J=d(0,0,1);let K=class extends j{constructor(t){super(t),this.forceHorizontalPan=!1,this._rotationValueSmooth=new V(.05),this._scalingValueSmooth=new V(.05),this._planeHorizontal=C(),this._planeVertical=C(),this._rotationMomentumEstimator=new q,this._panMomentumEstimator=new W(300,12,.9),this._zoomMomentumEstimator=new B,this._beginRadius=0,this._beginCenter=u(),this._beginAngle=0,this._tmpPoints=[],this._navigationMode=1,this._beginCenterScreen=i(),this._tmpCentroid3d=u(),this._tmpCentroid2d=i(),this._tmp2d=i(),this._pointerCount=0,this._beginCamera=new L,this._constraintOptions=new z(15,0,0,this._beginCamera)}begin(t){if(!this.running)return;const i=this.view.navigation.momentumEnabled;this._zoomMomentumEstimator.enabled=i,this._rotationMomentumEstimator.enabled=i,this._panMomentumEstimator.enabled=i,this._beginRadius=t.radius,this._pointerCount=t.pointers.size,this._beginAngle=t.angle,this._rotationValueSmooth.reset(),this._scalingValueSmooth.reset(),e(t.center,this._beginCenterScreen),v(J,0,this._planeHorizontal);const n=u(),o=this._intersectionHelper.intersectScreenFreePointFallback(this._beginCenterScreen,n,this.view.basemapTerrain.invisible?x:{}),s=u();a(s,this.startCamera.viewForward);const d=u();r(d,J);const g=m(s,d);this.forceHorizontalPan?this._navigationMode=1:this._navigationMode=O(this.startCamera,this._beginCenterScreen,this.view.renderCoordsHelper,this.view.viewingMode);const C=F(d,this.startCamera.viewForward,R)*Math.max(Math.abs(this.view.camera.position.z),A);b(this._planeHorizontal,this._planeHorizontal,n),this.startCamera.aboveGround||w(this._planeHorizontal,this._planeHorizontal);const f=u(),P=u(),z=u();h(f,n,this.currentCamera.eye);const V=l(f);if(c(f,f),0===this._navigationMode){p(d,d,g),h(M(this._planeVertical),s,d),c(M(this._planeVertical),M(this._planeVertical)),b(this._planeVertical,this._planeVertical,n);const i=this.view.stage.renderView.getMinimalDepthForArea(S(this.view),this._beginCenterScreen[0],this._beginCenterScreen[1],this.view.state.camera,T);let e=null!=i?i:C;o&&(e=Math.min(e,V)),r(z,_(P,this.currentCamera.eye,p(P,f,e))),this._planeVertical[3]=-m(M(this._planeVertical),z),this._computePlanePoints(t.pointers,this._planeVertical,this.startCamera,this._tmpPoints),U(this._tmpPoints,this._beginCenter)}else{const i=o?V:C;r(z,_(P,this.currentCamera.eye,p(P,f,i))),this._planeHorizontal[3]=-m(M(this._planeHorizontal),z),this._computePlanePoints(t.pointers,this._planeHorizontal,this.startCamera,this._tmpPoints),U(this._tmpPoints,this._beginCenter)}this._beginCamera.copyFrom(this.startCamera)}update(t){if(!this.running)return;this.currentCamera.copyFrom(this.startCamera);const i=t.pointers.size>1,n=1===this._navigationMode?this._planeHorizontal:this._planeVertical,o=this._beginCenter;if(i){const i=this._beginRadius/t.radius,e=.001875*Math.min(Math.max(t.radius,40),120);this._scalingValueSmooth.gain=e,this._scalingValueSmooth.update(i),D(this.currentCamera,o,this._scalingValueSmooth.value,this.view.state.constraints.minimumPoiDistance),this._zoomMomentumEstimator.add(this._scalingValueSmooth.value,.001*t.timestamp),this._constraintOptions.interactionType=1,this._constraintOptions.interactionFactor=f(Math.abs(t.radius-this._beginRadius)),P(this.view,this.currentCamera,this._constraintOptions)}if(this._computePlanePoints(t.pointers,n,this.currentCamera,this._tmpPoints),U(this._tmpPoints,this._tmpCentroid3d),e(t.center,this._tmpCentroid2d),I(this.currentCamera,o,this._tmpCentroid3d),this._panMomentumEstimator.add(this._tmpCentroid2d,this._tmpCentroid3d,.001*t.timestamp),this._constraintOptions.interactionType=4,this._constraintOptions.interactionFactor=f(s(this._beginCenterScreen,this._tmpCentroid2d)),P(this.view,this.currentCamera,this._constraintOptions),i){const i=o,e=this._rotationValueSmooth.value,n=e+Z(t.angle-e),s=.00125*Math.min(Math.max(t.radius,40),120);this._rotationValueSmooth.gain=s,this._rotationValueSmooth.update(n);const a=this._rotationValueSmooth.value-this._beginAngle;this._rotationMomentumEstimator.add(a,.001*t.timestamp);const r=M(this._planeHorizontal);k(this.currentCamera,i,g(r,a)),this._constraintOptions.interactionType=2,this._constraintOptions.interactionFactor=f(Math.abs(t.radius*a)),P(this.view,this.currentCamera,this._constraintOptions)}this.commitCamera()}end(t){t.pointers.size===this._pointerCount&&this.update(t),this.finishController();const i=this.view.animationsEnabled&&this._zoomMomentumEstimator.evaluateMomentum();if(i)return new y({view:this.view,momentum:i,zoomCenter:this._beginCenter});const e=this.view.animationsEnabled&&this._rotationMomentumEstimator.evaluateMomentum();if(e)return new H({view:this.view,momentum:e,center:this._beginCenter,axis:M(this._planeHorizontal)});const n=this.view.animationsEnabled&&this._panMomentumEstimator.evaluateMomentum();return n?new E({view:this.view,momentum:n}):null}_computePlanePoints(t,i,e,n){n.length=t.size;const o=this._tmp2d;let s=0;return t.forEach(t=>{o[0]=t.x,o[1]=t.y,void 0===n[s]&&(n[s]=u()),G(i,e,o,n[s]),s+=1}),n}get _intersectionHelper(){return this.view.sceneIntersectionHelper}};t([n({constructOnly:!0})],K.prototype,"forceHorizontalPan",void 0),K=t([o("esri.views.3d.state.controllers.PinchAndPanControllerLocal")],K);export{K as PinchAndPanControllerLocal};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ const t=96*39.37;function e(e,n,r){const{unitInMeters:o}=e.renderCoordsHelper;r/=o;return n.width/2/n.pixelRatio/(t/r)/Math.tan(n.fovX/2)}function n(t,n){return e(t,t.state.camera,n)}function r(e,n){const{camera:r}=e.state,{unitInMeters:o}=e.renderCoordsHelper,a=n*Math.tan(r.fovX/2),i=r.width/2/r.pixelRatio;return t/(i/a)*o}export{r as distanceToScale,n as scaleToDistance,e as scaleToDistanceAt};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../Camera.js";import t from"../../../core/Logger.js";import{deg2rad as n,rad2deg as r,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{copy as o,distance as c,dist as s,length as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Point.js";import{projectAsync as d,project as h}from"../../../geometry/projectionUtils.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVectorAsync as y,projectPointToVector as v}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPointAsync as R,projectVectorToPoint as w}from"../../../geometry/projection/projectVectorToPoint.js";import{gcsCyclical as x,webMercatorCyclical as M}from"../../../geometry/support/normalizeUtils.js";import{toRenderCamera as j}from"../webgl.js";import{getGreatCircleSpanAt as T}from"./earthUtils.js";import{getElevationAtPoint as z}from"./ElevationProvider.js";import{viewModeDependentUtil as S,directionToHeadingTilt as C}from"./viewingModeUtils.js";import{isSpatialReferenceSupported as b}from"../../support/spatialReferenceSupport.js";const P=()=>t.getLogger("esri.views.3d.support.cameraUtils"),A=96*39.37,L=1,U=8,H=5,q=1,I=u();function E(e){return e.spatialReference??g.WGS84}function F(e,t,n,r,i){return S(e).headingTiltToDirectionUp(t,n,r,i)}function G(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper;t/=r;return n.width/2/n.pixelRatio/(A/t)/Math.tan(n.fovX/2)}function O(e,t){const{camera:n}=e.state,{unitInMeters:r}=e.renderCoordsHelper,i=t*Math.tan(n.fovX/2),a=n.width/2/n.pixelRatio;return A/(a/i)*r}function X(e,t,n,r){const i=r.levelAtScale(t),a=k(C(e,n.eye,n.viewForward,n.up).tilt),o=Math.max(i-a,0);return r.scaleAtLevel(o)}function D(e,t,n){const r=n.levelAtScale(e),i=k(t);return n.scaleAtLevel(r+i)}function k(e){return 2*((e>90?180-e:e)/90)**2}function V(e,t,n=0){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;const i=m(e.spatialReference).radius,a=2===e.state.viewingMode?t.eye[2]:l(t.eye)-i;return X(e,O(e,Math.abs(a-n)),t,r)}function W(e,t,n=0){const r=j(e,t);return r?V(e,r,n):0}const Y=1,N=100;function Z(e,t,a,o){if(0===t)return 0;const s=e.state.contentCamera,u=c(s.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return P().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),u;let p=u;const d=C(e,s.eye,s.viewForward,s.up),h=d.tilt>90;if(e.state.isLocal){const r=(G(e,D(t,d.tilt,f))-Math.abs(s.eye[2]-o[2]))/Math.cos(n(d.tilt));return p=h?p-r:p+r,p}let g=1/0,y=0,v=te(e,d.heading,d.tilt,a,u,1);if(!v)return p;const R=l(o);for(;g>Y&&y<N;){const o=l(v.eye),u=h?180-v.tilt:v.tilt,w=n(u),x=Math.sin(w)*o,M=Math.cos(w)*o,j=G(e,D(t,v.tilt,f)),T=h?R-j:R+j,z=i(x/T),S=Math.cos(z)*T-M,C=c(v.eye,a);p=h?C-S:C+S,v=te(e,d.heading,d.tilt,a,p,1);const b=Me(e,v,r(s.fov));if(!v||!b)return p;const P=W(e,b,R-m(e.spatialReference).radius);g=Math.abs(t-P),++y}return p}async function B(e,t,n,r,i,a){return K(e,t,G(e,n),r,i,a)}function J(e,t,n,r,i,a){return Me(e,te(e,r.heading,r.tilt,t,n,i),r.fov,a)}async function K(e,t,n,r,i,o){const c=await ne(e,r.heading,r.tilt,t,n,i,o);return a(o),je(e,c,r.fov,o)}function Q(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,I,e.spatialReference)&&e.elevationProvider&&(z(e.elevationProvider,I)??0)>I[2]-q)}async function $(e,t,n){if(Q(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,I,i))return!1;const[c,s,l]=I,u=await r.queryElevation(c,s,l,i,"ground",n)??0;return a(n),u>l-q}async function _(e,t,n){const r=u();if(null==t)return o(r,e.state.camera.center);if(t instanceof p){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,s=t.spatialReference;if(await y(t,r,i,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return o(r,t)}function ee(e,t){const n=u();if(null==t)return o(n,e.state.camera.center);if(t instanceof p){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=z(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return o(n,t)}function te(e,t,n,r,i,a){return re(e,t,n,r instanceof p?r:null,ee(e,r),i,a)}async function ne(e,t,n,r,i,o,c){const s=r instanceof p?r:null,l=await _(e,r,c);return a(c),ie(e,t,n,s,l,i,o,c)}function re(e,t,n,r,i,a,o){if(null==i)return null;if(!r&&(r=new p({spatialReference:E(e)}),!w(i,e.renderSpatialReference,r)))return null;const c=ae(e,t,n,i,a,o);if(oe(e,n,o)&&Q(e,c.eye)){const{tilt:o,mode:c}=ce(e,n,i,a);return re(e,t,o,r,i,a,c)}return se(c,i)}async function ie(e,t,n,r,i,o,c,s){r||(r=new p({spatialReference:E(e)}),await R(i,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=ae(e,t,n,i,o,c);if(oe(e,n,c)&&await $(e,l.eye,s)){a(s);const{tilt:c,mode:l}=ce(e,n,i,o);return ie(e,t,c,r,i,o,l,s)}return se(l,i)}function ae(e,t,n,r,i,a){const o=ge(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),a);return(0,S(e).eyeForCenterWithHeadingTilt)(r,i,o.heading,o.tilt)}function oe(e,t,n){const r=e.map.ground.navigationConstraint;return 1===n&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function ce(e,t,n,r){const i=we(e,n,r,Re(e,r,t,n));return{tilt:i,mode:t-i<1?0:1}}function se(e,t){return{...e,center:f(t)}}function le(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&b(i,1)||n.isLocal&&r.equals(i)}function ue(e,t){let n,r,i;if(e.state.isGlobal){const e=new p(t.xmin,t.ymin,t.spatialReference),a=new p(t.xmax,t.ymax,t.spatialReference),o=t.spatialReference.isGeographic?x:M;n=new p({x:o.center(e.x,a.x),y:(a.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=m(t.spatialReference),s=T(n,e,a);r=s.lon,i=s.lat,o.diff(e.x,a.x)>o.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const a=e.renderSpatialReference??t.spatialReference;a.equals(t.spatialReference)||(t=h(t,a)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const o=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new p({x:t.xmin+.5*r,y:t.ymin+.5*i,z:o,spatialReference:a})}const a=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,o=e.state.camera,c=1/Math.tan(o.fovX/2),s=1/Math.tan(o.fovY/2),l=1/Math.tan(o.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*s,.5*a*l)/L}}async function fe(e,t,n,r,i,o){const c=le(e,t)?t:await d(t,e.spatialReference,{signal:o});a(o);const{center:s,distance:l}=ue(e,c),u=await ne(e,n,r,s,l,i,o);return a(o),je(e,u,e.camera.fov,o)}function me(e,t,n,r,i,a){let o;try{o=le(e,t)?t:h(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=ue(e,o),l=te(e,n,r,c,s,i);return null==l?null:Me(e,l,e.camera.fov,a)}function pe(e,t,n){const r=e.renderSpatialReference,i=new p({spatialReference:E(e)});if(!w(n,r,i))return null;const a=Math.tan(t.fovX/2),o=Math.tan(t.fovY/2),c=s(t.eye,n),l=2*c*a*L,u=2*c*o*L;return S(e).toExtent(e,i,l,u)}function de(e,t){return S(e).toArea(e,t)}function he(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>U)return!0;const i=t,a=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return c(i,a)/(Math.tan(.5*e.state.camera.fov)*r)>H}function ge(e,t,n,r,i,a){let o=0;return 1===a&&he(e,r,i)?(t=0,o=ve(e,i,n,r)):o=xe(e,r,i,n),o=e.state.constraints.clampTilt(i,o),{heading:t,tilt:n=we(e,r,i,o)}}const ye=.7;function ve(e,t,n,r){const i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);a.max=Math.min(a.max,.5*Math.PI);const o=a.min*(1-ye)+a.max*ye;return Math.min(i,o)}function Re(e,t,n,r){let i=xe(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),a.min*(1-ye)+i*ye}function we(e,t,n,r){return S(e).lookAtTiltToEyeTilt(r,t,n)}function xe(e,t,n,r){return S(e).eyeTiltToLookAtTilt(r,t,n)}function Me(t,n,r,i){if(null==n)return null;const a=t.renderSpatialReference,o=new p({spatialReference:E(t)});return w(n.eye,a,o)?(i??=new e,i.position=o,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function je(t,n,r,i){const o=t.renderSpatialReference,c=new p({spatialReference:E(t)});return await R(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function Te(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);P().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function ze(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);P().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{X as applyTiltAdjustToScale,O as distanceToScale,K as fromCenterDistanceAsync,J as fromCenterDistanceSync,B as fromCenterScale,fe as fromExtentAsync,me as fromExtentSync,ne as getObserverForPointAtDistanceAsync,te as getObserverForPointAtDistanceSync,E as getViewSR,F as headingTiltToDirectionUp,D as removeTiltAdjustFromScale,Y as scaleErrorThreshold,G as scaleToDistance,Te as scaleToZoom,de as toArea,pe as toExtent,Z as viewScaleToCameraDistance,ze as zoomToScale};
2
+ import e from"../../../Camera.js";import t from"../../../core/Logger.js";import{deg2rad as n,rad2deg as r,asinClamped as i}from"../../../core/mathUtils.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{copy as o,distance as c,dist as s,length as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as u,clone as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import p from"../../../geometry/Point.js";import{projectAsync as d,project as h}from"../../../geometry/projectionUtils.js";import g from"../../../geometry/SpatialReference.js";import{projectPointToVectorAsync as y,projectPointToVector as v}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPointAsync as R,projectVectorToPoint as w}from"../../../geometry/projection/projectVectorToPoint.js";import{gcsCyclical as x,webMercatorCyclical as M}from"../../../geometry/support/normalizeUtils.js";import{toRenderCamera as j}from"../webgl.js";import{scaleToDistance as T,distanceToScale as S}from"./cameraScaleUtils.js";import{getGreatCircleSpanAt as z}from"./earthUtils.js";import{getElevationAtPoint as b}from"./ElevationProvider.js";import{viewModeDependentUtil as C,directionToHeadingTilt as P}from"./viewingModeUtils.js";import{isSpatialReferenceSupported as A}from"../../support/spatialReferenceSupport.js";const L=()=>t.getLogger("esri.views.3d.support.cameraUtils"),U=1,q=8,E=5,F=1,G=u();function H(e){return e.spatialReference??g.WGS84}function I(e,t,n,r,i){return C(e).headingTiltToDirectionUp(t,n,r,i)}function O(e,t,n,r){const i=r.levelAtScale(t),a=k(P(e,n.eye,n.viewForward,n.up).tilt),o=Math.max(i-a,0);return r.scaleAtLevel(o)}function D(e,t,n){const r=n.levelAtScale(e),i=k(t);return n.scaleAtLevel(r+i)}function k(e){return 2*((e>90?180-e:e)/90)**2}function V(e,t,n=0){const r=e.basemapTerrain?.tilingScheme;if(!r)return 0;const i=m(e.spatialReference).radius,a=2===e.state.viewingMode?t.eye[2]:l(t.eye)-i,o=Math.abs(a-n);return O(e,S(e,o),t,r)}function W(e,t,n=0){const r=j(e,t);return r?V(e,r,n):0}const X=1,Y=100;function N(e,t,a,o){if(0===t)return 0;const s=e.state.contentCamera,u=c(s.eye,a),f=e.basemapTerrain?.tilingScheme;if(!f)return L().error("#scaleToTargetDistance()","Cannot compute distance from scale without a tiling scheme"),u;let p=u;const d=P(e,s.eye,s.viewForward,s.up),h=d.tilt>90;if(e.state.isLocal){const r=D(t,d.tilt,f),i=(T(e,r)-Math.abs(s.eye[2]-o[2]))/Math.cos(n(d.tilt));return p=h?p-i:p+i,p}let g=1/0,y=0,v=ee(e,d.heading,d.tilt,a,u,1);if(!v)return p;const R=l(o);for(;g>X&&y<Y;){const o=l(v.eye),u=h?180-v.tilt:v.tilt,w=n(u),x=Math.sin(w)*o,M=Math.cos(w)*o,j=D(t,v.tilt,f),S=T(e,j),z=h?R-S:R+S,b=i(x/z),C=Math.cos(b)*z-M,P=c(v.eye,a);p=h?P-C:P+C,v=ee(e,d.heading,d.tilt,a,p,1);const A=xe(e,v,r(s.fov));if(!v||!A)return p;const L=W(e,A,R-m(e.spatialReference).radius);g=Math.abs(t-L),++y}return p}async function Z(e,t,n,r,i,a){return J(e,t,T(e,n),r,i,a)}function B(e,t,n,r,i,a){return xe(e,ee(e,r.heading,r.tilt,t,n,i),r.fov,a)}async function J(e,t,n,r,i,o){const c=await te(e,r.heading,r.tilt,t,n,i,o);return a(o),Me(e,c,r.fov,o)}function K(e,t){return!!(e.basemapTerrain&&e.renderCoordsHelper.fromRenderCoords(t,G,e.spatialReference)&&e.elevationProvider&&(b(e.elevationProvider,G)??0)>G[2]-F)}async function Q(e,t,n){if(K(e,t))return!0;const{elevationProvider:r,spatialReference:i,renderCoordsHelper:o}=e;if(null==r||!o.fromRenderCoords(t,G,i))return!1;const[c,s,l]=G,u=await r.queryElevation(c,s,l,i,"ground",n)??0;return a(n),u>l-F}async function $(e,t,n){const r=u();if(null==t)return o(r,e.state.camera.center);if(t instanceof p){const{renderSpatialReference:i,basemapTerrain:o,elevationProvider:c}=e,s=t.spatialReference;if(await y(t,r,i,{signal:n}),a(n),null==t.z&&null!=o&&null!=c){const i=await c.queryElevation(t.x,t.y,t.z??0,s,"ground",n);a(n),null!=i&&e.renderCoordsHelper.setAltitude(r,i)}return r}return o(r,t)}function _(e,t){const n=u();if(null==t)return o(n,e.state.camera.center);if(t instanceof p){if(!v(t,n,e.renderSpatialReference))return null;const{basemapTerrain:r,elevationProvider:i}=e;if(null==t.z&&null!=r&&null!=i){const r=b(i,t);null!=r&&e.renderCoordsHelper.setAltitude(n,r)}return n}return o(n,t)}function ee(e,t,n,r,i,a){return ne(e,t,n,r instanceof p?r:null,_(e,r),i,a)}async function te(e,t,n,r,i,o,c){const s=r instanceof p?r:null,l=await $(e,r,c);return a(c),re(e,t,n,s,l,i,o,c)}function ne(e,t,n,r,i,a,o){if(null==i)return null;if(!r&&(r=new p({spatialReference:H(e)}),!w(i,e.renderSpatialReference,r)))return null;const c=ie(e,t,n,i,a,o);if(ae(e,n,o)&&K(e,c.eye)){const{tilt:o,mode:c}=oe(e,n,i,a);return ne(e,t,o,r,i,a,c)}return ce(c,i)}async function re(e,t,n,r,i,o,c,s){r||(r=new p({spatialReference:H(e)}),await R(i,e.renderSpatialReference,r,{signal:s})||(r=null)),a(s);const l=ie(e,t,n,i,o,c);if(ae(e,n,c)&&await Q(e,l.eye,s)){a(s);const{tilt:c,mode:l}=oe(e,n,i,o);return re(e,t,c,r,i,o,l,s)}return ce(l,i)}function ie(e,t,n,r,i,a){const o=he(e,t,n,r,i=Math.max(i,e.state.constraints.minimumPoiDistance),a);return(0,C(e).eyeForCenterWithHeadingTilt)(r,i,o.heading,o.tilt)}function ae(e,t,n){const r=e.map.ground.navigationConstraint;return 1===n&&e.state.isGlobal&&t>0&&(null==r||"stay-above"===r.type)}function oe(e,t,n,r){const i=Re(e,n,r,ve(e,r,t,n));return{tilt:i,mode:t-i<1?0:1}}function ce(e,t){return{...e,center:f(t)}}function se(e,t){const{state:n,spatialReference:r}=e,i=t.spatialReference;return n.isGlobal&&A(i,1)||n.isLocal&&r.equals(i)}function le(e,t){let n,r,i;if(e.state.isGlobal){const e=new p(t.xmin,t.ymin,t.spatialReference),a=new p(t.xmax,t.ymax,t.spatialReference),o=t.spatialReference.isGeographic?x:M;n=new p({x:o.center(e.x,a.x),y:(a.y+e.y)/2,z:null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0,spatialReference:t.spatialReference});const c=m(t.spatialReference),s=z(n,e,a);r=s.lon,i=s.lat,o.diff(e.x,a.x)>o.range/2&&(r+=c.halfCircumference),r=Math.min(r,c.halfCircumference),i=Math.min(i,c.halfCircumference)}else{const a=e.renderSpatialReference??t.spatialReference;a.equals(t.spatialReference)||(t=h(t,a)),r=t.xmax-t.xmin,i=t.ymax-t.ymin;const o=null!=t.zmax&&null!=t.zmin?(t.zmax+t.zmin)/2:void 0;n=new p({x:t.xmin+.5*r,y:t.ymin+.5*i,z:o,spatialReference:a})}const a=null!=t.zmax&&null!=t.zmin?t.zmax-t.zmin:0,o=e.state.camera,c=1/Math.tan(o.fovX/2),s=1/Math.tan(o.fovY/2),l=1/Math.tan(o.fov/2);return{center:n,distance:Math.max(.5*r*c,.5*i*s,.5*a*l)/U}}async function ue(e,t,n,r,i,o){const c=se(e,t)?t:await d(t,e.spatialReference,{signal:o});a(o);const{center:s,distance:l}=le(e,c),u=await te(e,n,r,s,l,i,o);return a(o),Me(e,u,e.camera.fov,o)}function fe(e,t,n,r,i,a){let o;try{o=se(e,t)?t:h(t,e.spatialReference)}catch(u){return null}const{center:c,distance:s}=le(e,o),l=ee(e,n,r,c,s,i);return null==l?null:xe(e,l,e.camera.fov,a)}function me(e,t,n){const r=e.renderSpatialReference,i=new p({spatialReference:H(e)});if(!w(n,r,i))return null;const a=Math.tan(t.fovX/2),o=Math.tan(t.fovY/2),c=s(t.eye,n),l=2*c*a*U,u=2*c*o*U;return C(e).toExtent(e,i,l,u)}function pe(e,t){return C(e).toArea(e,t)}function de(e,t,n){const r=e.pointsOfInterest.centerOnSurfaceFrequent.distance;if(Math.log(n/r)/Math.LN2>q)return!0;const i=t,a=e.pointsOfInterest.centerOnSurfaceFrequent.renderLocation;return c(i,a)/(Math.tan(.5*e.state.camera.fov)*r)>E}function he(e,t,n,r,i,a){let o=0;return 1===a&&de(e,r,i)?(t=0,o=ye(e,i,n,r)):o=we(e,r,i,n),o=e.state.constraints.clampTilt(i,o),{heading:t,tilt:n=Re(e,r,i,o)}}const ge=.7;function ye(e,t,n,r){const i=we(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);a.max=Math.min(a.max,.5*Math.PI);const o=a.min*(1-ge)+a.max*ge;return Math.min(i,o)}function ve(e,t,n,r){let i=we(e,r,t,n);if(!e.state.constraints.tilt)return i;const a=e.state.constraints.tilt(t);return i=Math.min(i,.5*Math.PI),a.min*(1-ge)+i*ge}function Re(e,t,n,r){return C(e).lookAtTiltToEyeTilt(r,t,n)}function we(e,t,n,r){return C(e).eyeTiltToLookAtTilt(r,t,n)}function xe(t,n,r,i){if(null==n)return null;const a=t.renderSpatialReference,o=new p({spatialReference:H(t)});return w(n.eye,a,o)?(i??=new e,i.position=o,i.heading=n.heading,i.tilt=n.tilt,i.fov=r,i):null}async function Me(t,n,r,i){const o=t.renderSpatialReference,c=new p({spatialReference:H(t)});return await R(n.eye,o,c,{signal:i}),a(i),new e(c,n.heading,n.tilt,r)}function je(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.levelAtScale(t);L().error("#scaleToZoom()","Cannot compute zoom from scale without a tiling scheme")}function Te(e,t){const n=e.basemapTerrain?.tilingScheme;if(n)return n.scaleAtLevel(t);L().error("#zoomToScale()","Cannot compute scale from zoom without a tiling scheme")}export{O as applyTiltAdjustToScale,J as fromCenterDistanceAsync,B as fromCenterDistanceSync,Z as fromCenterScale,ue as fromExtentAsync,fe as fromExtentSync,te as getObserverForPointAtDistanceAsync,ee as getObserverForPointAtDistanceSync,H as getViewSR,I as headingTiltToDirectionUp,D as removeTiltAdjustFromScale,X as scaleErrorThreshold,je as scaleToZoom,pe as toArea,me as toExtent,N as viewScaleToCameraDistance,Te as zoomToScale};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/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"../cameraUtils.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 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};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{projectBuffer as e}from"../../../../geometry/projection/projectBuffer.js";import{newDoubleArray as o,doubleSubArray as t}from"../../../../geometry/support/DoubleArray.js";import{ringsToTriangulationInfo as n}from"../../../../geometry/support/triangulationUtilsDeprecated.js";import{applyPerVertexElevationAlignment as r}from"../../layers/graphics/elevationAlignmentUtils.js";import{drapedZ as i}from"../../terrain/OverlayRenderer.js";function s(e,t,i,s){const p="polygon"===e.type?1:0,a="polygon"===e.type?e.rings:e.paths,{position:c,outlines:u}=n(a,!!e.hasZ,p,e.spatialReference),f=o(c.length),m=r(c,e.spatialReference,0,f,0,c,0,c.length/3,t,i,s),g=null!=m;return{lines:g?l(u,c,f):[],projectionSuccess:g,sampledElevation:m}}function p(o,t){const r="polygon"===o.type?1:0,s="polygon"===o.type?o.rings:o.paths,{position:p,outlines:a}=n(s,!1,r,o.spatialReference),c=e(p,o.spatialReference,0,p,t,0);for(let e=2;e<p.length;e+=3)p[e]=i;return{lines:c?l(a,p):[],projectionSuccess:c}}function l(e,o,n=null){const r=new Array;for(const{index:i,count:s}of e){if(s<=1)continue;const e=3*i,p=3*s;r.push({position:t(o,3*i,3*s),mapPositions:null!=n?t(n,e,p):void 0})}return r}export{s as geometryToRenderInfo,p as geometryToRenderInfoDraped};
2
+ import{projectBuffer as e}from"../../../../geometry/projection/projectBuffer.js";import{newDoubleArray as o,doubleSubArray as n}from"../../../../geometry/support/DoubleArray.js";import{applyPerVertexElevationAlignment as t}from"../../layers/graphics/elevationAlignmentUtils.js";import{ringsToOutlinedTessellationInfo as s}from"../../layers/graphics/tessellationUtils.js";import{drapedZ as r}from"../../terrain/OverlayRenderer.js";function i(e,n,r,i){const l="polygon"===e.type,a="polygon"===e.type?e.rings:e.paths,{positions:c,outlines:f}=s(a,{hasZ:!!e.hasZ,ccwRingsAsHoles:l,spatialReference:e.spatialReference}),u=o(c.length),g=t(c,e.spatialReference,0,u,0,c,0,c.length/3,n,r,i),m=null!=g;return{lines:m?p(f,c,u):[],projectionSuccess:m,sampledElevation:g}}function l(o,n){const t="polygon"===o.type,i="polygon"===o.type?o.rings:o.paths,{positions:l,outlines:a}=s(i,{hasZ:!1,ccwRingsAsHoles:t,spatialReference:o.spatialReference}),c=e(l,o.spatialReference,0,l,n,0);for(let e=2;e<l.length;e+=3)l[e]=r;return{lines:c?p(a,l):[],projectionSuccess:c}}function p(e,o,t=null){const s=new Array;for(const{index:r,count:i}of e){if(i<=1)continue;const e=3*r,l=3*i;s.push({position:n(o,3*r,3*i),mapPositions:null!=t?n(t,e,l):void 0})}return s}export{i as geometryToRenderInfo,l as geometryToRenderInfoDraped};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import{cyclicalDegrees as o}from"../../../core/Cyclical.js";import a from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as u,add as f,distance as p,copy as g,subtract as y,set as h,transformMat3 as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as B}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as M}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as S}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as V,expandWithAABB as O,width as U,height as k,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCamera as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{getViewSR as _,fromExtentAsync as H,scaleToDistance as K,fromCenterDistanceAsync as L,fromExtentSync as Q,distanceToScale as $,fromCenterDistanceSync as tt,fromCenterScale as et,zoomToScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as ot}from"./viewingModeUtils.js";const at=.66;function it(t){return 360-o.normalize(t)}function st(t){return o.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,_(t));const{targetGeometry:o}=e;if(null==o)return null;const{camera:a,mode:i}=ft(t,e.rotation,n);if("point"===o.type)return pt(t,e,o,a,i);const s=o.extent;return null==s?null:Q(t,s,a.heading,a.tilt,i)}async function lt(t,e,n,r){const o=e.camera;if(null!=o)return ut(o,_(t),r);const{targetGeometry:a}=e;if(null==a)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===a.type)return gt(t,e,a,i,s,r);const c=a.extent;if(null==c)throw new Error("Target geometry has no extent!");return H(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position,r=z(n,e);if(!r)return null;const o=t.clone();return o.position=r.clone(),o}async function ut(t,e,n){const r=t.position,o=await R(r,e,{signal:n});i(n);const a=t.clone();return a.position=o.clone(),a}function ft(t,e,n){const r=D(t,t.state.camera);let o=1;return null!=e&&(r.heading=it(e),o=0),null!=n&&(r.tilt=n),{camera:r,mode:o}}function pt(t,e,n,r,o){const a=t.spatialReference,i=z(n.clone(),a);if(!i)return null;const s=null!=e.scale?K(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,o)}async function gt(t,e,n,r,o,a){const s=t.spatialReference,c=await R(n.clone(),s,{signal:a});i(a);const l=null!=e.scale?K(t,e.scale):t.state.camera.distance;return L(t,c,l,r,o,a)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,o){const i=At(e,r);if(!i)throw new a("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Et(await zt(e,i.target,i,o,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,o,c));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Mt(e,i,i.target.center,s,o,c):await Ft(e,i,i.target,s,o,c))}const m=new Ot,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,o),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ut),Jt.x=Ut[0],Jt.y=Ut[1],Jt.z=Ut[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Mt(e,i,Jt,s,o,c));const n=Vt(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,o,c))}return i.position?Et(await St(e,i,s,c,o)):Et(await Zt(e,i,s,o,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?nt(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,r){const o=t.spatialReference||G.WGS84;if(e??=J(t,n),null==e)return r;const a=new b({spatialReference:o});return S(e.center,t.renderSpatialReference,a)?(r.targetGeometry=a,r.scale=$(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const o=()=>new a("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw o();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ut[2]=rt(t.elevationProvider,n)??0):Ut[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ut),0===c.length)throw o();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[a,f,p]of u.points)Ut[0]=a,Ut[1]=f,Ut[2]=p,V(n.boundingBox,Ut);else for(const[a,f]of u.points)Ut[0]=a,Ut[1]=f,V(n.boundingBox,Ut)}async function bt(t,e,n,o,a){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,o,a);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,o,a);const{screenSpaceObjects:l,boundingBox:m}=c.value;O(o.boundingBox,m),l&&l.forEach(t=>{o.screenSpaceObjects.push(t)}),isFinite(m[2])&&(o.hasZ=!0)}async function Rt(t,n,r,o,a){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,o,a)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,o,a))):n instanceof j?await vt(t,n,o,a):n instanceof e&&await bt(t,n,r,o,a)}async function zt(t,e,n,r,o){if(e.camera)return Gt(t,e.camera,r,o);o.scale=e.scale,o.rotation=e.rotation,o.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,o.camera=null,null!=n.heading?o.rotation=st(n.heading):null!=n.rotation&&(o.rotation=n.rotation);const a=dt(t,n);return null!=a&&(o.scale=a),o.camera=await lt(t,o,n.tilt,r),o}async function Gt(t,e,n,r){const o=t.spatialReference,a=await R(e.position,o,{signal:n}),i=e.clone();return i.position=a,jt(t,null,i,r)}async function Bt(t,e,n,r,o,a,i){const s=t.renderSpatialReference;return await M(e,qt,s,{signal:i}),await M(n,Yt,s,{signal:i}),a.targetGeometry=new b(e),o.position=new b(n),y(Wt,qt,Yt),ot(t,Yt,Wt,r.up,o),a.scale=$(t,p(Yt,qt)),a.rotation=st(o.heading),a.camera=o,a}async function Mt(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);if(e.position)return Bt(t,a.targetGeometry,e.position,i,r,a,o);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ut,i.viewForward,-n);i.eye=f(Ut,i.center,r),a.scale=$(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await M(a.targetGeometry,Ut,t.renderSpatialReference,{signal:o});const e=Y(i.frustum,Ut)?p(i.eye,Ut):i.distance;a.camera=await L(t,a.targetGeometry,e,r,s),a.scale=$(t,e)}else a.scale=n,a.camera=await et(t,a.targetGeometry,a.scale,r,s,o)}return a}async function St(t,e,n,r,o){const a=X(t);g(Wt,a.viewForward),ot(t,a.eye,Wt,a.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:o});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r)}async function Zt(t,e,n,r,o){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const a=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return S(a.center,s,c)?Mt(t,e,c,n,r,o):o}return o.scale=t.scale,o.camera=t.camera.clone(),xt(o.camera,e),o}async function Ft(t,e,n,r,o,a){a.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return a.camera=await H(t,n,r.heading,r.tilt,s,o),a}function Tt(t,e,n,r,o){let a=0;null!=n.z?a=n.z:t.basemapTerrain&&t.elevationProvider&&(a=rt(t.elevationProvider,n)),h(Ut,n.x,n.y,a),B(t.spatialReference,Ut,kt,t.renderSpatialReference),s(Nt,kt),c(Nt,Nt),E(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=a),h(Ut,r[e[0]],r[e[1]],n),Z(Ut,t.spatialReference,Ut,t.renderSpatialReference),V(It,d(Ut,Ut,Nt))}const l=U(It),m=k(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/o}async function Pt(t,e,n,r,o,a,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,o);D(t,c,a);const m=xt(a,e)?0:1;return s.camera=await L(t,s.targetGeometry,l,a,m,i),s.scale=$(t,l),s}function At(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Vt(t,e){const n=at;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let o=0;o<e.length;o++){const t=e[o].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Ot{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ut=w(),kt=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let o=0;o<t.rings.length;o++){const a=t.rings[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let o=0;o<t.paths.length;o++){const a=t.paths[o];for(let t=0;t<a.length;t++)n[0]=a[t][0],n[1]=a[t][1],r&&(n[2]=a[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,o=t.hasZ;for(let a=0;a<r.length;a++)n[0]=r[a][0],n[1]=r[a][1],o&&(n[2]=r[a][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};
2
+ import t from"../../../Camera.js";import e from"../../../Graphic.js";import n from"../../../Viewpoint.js";import{result as r}from"../../../core/asyncUtils.js";import{cyclicalDegrees as a}from"../../../core/Cyclical.js";import o from"../../../core/Error.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{fromMat4 as s,transpose as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{scale as u,add as f,distance as p,copy as g,subtract as y,set as h,transformMat3 as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import x from"../../../geometry/Extent.js";import j from"../../../geometry/Geometry.js";import v from"../../../geometry/Multipoint.js";import b from"../../../geometry/Point.js";import{projectAsync as R,tryProject as z}from"../../../geometry/projectionUtils.js";import G from"../../../geometry/SpatialReference.js";import{computeTranslationToOriginAndRotation as S}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVectorAsync as B}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToPoint as M}from"../../../geometry/projection/projectVectorToPoint.js";import{projectVectorToVector as Z}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,center as T,toRect as P,isPoint as A,empty as E,expandWithVec3 as U,expandWithAABB as V,width as O,height as k,depth as N}from"../../../geometry/support/aaBoundingBox.js";import{create as I,isPoint as C}from"../../../geometry/support/aaBoundingRect.js";import{polygonCentroidPoint as W}from"../../../geometry/support/centroid.js";import{intersectsPoint as Y}from"../../../geometry/support/frustum.js";import{getResolutionInMetersForScale as q}from"../../../geometry/support/scaleUtils.js";import{fromRenderCamera as D,toRenderCameraWithScale as J}from"../webgl.js";import{cameraOnContentAlongViewDirection as X}from"../camera/intersectionUtils.js";import{scaleToDistance as _,distanceToScale as H}from"./cameraScaleUtils.js";import{getViewSR as K,fromExtentAsync as L,fromCenterDistanceAsync as Q,fromExtentSync as $,fromCenterDistanceSync as tt,zoomToScale as et,fromCenterScale as nt}from"./cameraUtils.js";import{getElevationAtPoint as rt}from"./ElevationProvider.js";import{directionToHeadingTilt as at}from"./viewingModeUtils.js";const ot=.66;function it(t){return 360-a.normalize(t)}function st(t){return a.normalize(360-t)}function ct(t,e,n){const r=e.camera;if(null!=r)return mt(r,K(t));const{targetGeometry:a}=e;if(null==a)return null;const{camera:o,mode:i}=ft(t,e.rotation,n);if("point"===a.type)return pt(t,e,a,o,i);const s=a.extent;return null==s?null:$(t,s,o.heading,o.tilt,i)}async function lt(t,e,n,r){const a=e.camera;if(null!=a)return ut(a,K(t),r);const{targetGeometry:o}=e;if(null==o)throw new Error("Viewpoint has no targetGeometry!");const{camera:i,mode:s}=ft(t,e.rotation,n);if("point"===o.type)return gt(t,e,o,i,s,r);const c=o.extent;if(null==c)throw new Error("Target geometry has no extent!");return L(t,c,i.heading,i.tilt,s,r)}function mt(t,e){const n=t.position,r=z(n,e);if(!r)return null;const a=t.clone();return a.position=r.clone(),a}async function ut(t,e,n){const r=t.position,a=await R(r,e,{signal:n});i(n);const o=t.clone();return o.position=a.clone(),o}function ft(t,e,n){const r=D(t,t.state.camera);let a=1;return null!=e&&(r.heading=it(e),a=0),null!=n&&(r.tilt=n),{camera:r,mode:a}}function pt(t,e,n,r,a){const o=t.spatialReference,i=z(n.clone(),o);if(!i)return null;const s=null!=e.scale?_(t,e.scale):t.state.camera.distance;return tt(t,i,s,r,a)}async function gt(t,e,n,r,a,o){const s=t.spatialReference,c=await R(n.clone(),s,{signal:o});i(o);const l=null!=e.scale?_(t,e.scale):t.state.camera.distance;return Q(t,c,l,r,a,o)}function yt(t,e,r=null){return null==r&&(r=new n),jt(t,null,e.clone(),r)}async function ht(e,r,a){const i=At(e,r);if(!i)throw new o("viewpointutils-create:no-target","Missing target for creating viewpoint");const s=new t({fov:e.camera.fov}),c=new n({camera:s});if(i.target instanceof n){return Et(await zt(e,i.target,i,a,c))}if(i.target instanceof t)return Et(await Gt(e,i.target,a,c,dt(e,i)));const l=null!=i.scale||null!=i.zoom;if(i.target instanceof x){const t=i.target.xmin===i.target.xmax||i.target.ymin===i.target.ymax;return Et(l||t?await Bt(e,i,i.target.center,s,a,c):await Ft(e,i,i.target,s,a,c))}const m=new Vt,u=l?wt(e,i):void 0;if(await Rt(e,i.target,u,m,a),isFinite(m.boundingBox[0])){let t;if(T(m.boundingBox,Ot),Jt.x=Ot[0],Jt.y=Ot[1],Jt.z=Ot[2],Jt.spatialReference=e.spatialReference,isFinite(Jt.z)&&m.hasZ?t=A(m.boundingBox):(Jt.z=void 0,t=C(P(m.boundingBox,Ct))),l||t)return Et(await Bt(e,i,Jt,s,a,c));const n=Ut(e,m.screenSpaceObjects);return Et(await Pt(e,i,Jt,m.boundingBox,n,s,a,c))}return i.position?Et(await Mt(e,i,s,c,a)):Et(await Zt(e,i,s,a,c))}function dt(t,e){return null==e.scale&&null!=e.zoom?et(t,e.zoom):e.scale}function wt(t,e){const n=dt(t,e);return n?q(n):void 0}function xt(t,e){let n=!1;return null!=e.heading?(t.heading=e.heading,n=!0):null!=e.rotation&&(t.heading=it(e.rotation),n=!0),null!=e.tilt&&(t.tilt=e.tilt,n=!0),null!=e.fov&&(t.fov=e.fov),n}function jt(t,e,n,r,a){const o=t.spatialReference||G.WGS84;if(e??=J(t,n,a),null==e)return r;const i=new b({spatialReference:o});return M(e.center,t.renderSpatialReference,i)?(r.targetGeometry=i,r.scale=a??H(t,e.distance),r.rotation=st(n.heading),r.camera=n,r):r}async function vt(t,e,n,r){const a=()=>new o("viewpointutils:invalid-geometry","The target is missing a valid geometry");if(!e)throw a();"mesh"===e.type&&(e=e.extent);const i=t.basemapTerrain.spatialReference;if(!e.hasZ&&t.basemapTerrain){let n;switch(e.type){case"point":n=e;break;case"multipoint":case"polyline":n=e.extent?.center;break;case"extent":n=e.center;break;case"polygon":{const t=W(e);n=t?b.fromJSON(t):null;break}}null!=n&&i&&t.elevationProvider?(n=await R(n,i,{signal:r}),Ot[2]=rt(t.elevationProvider,n)??0):Ot[2]=0}const s=Xt[e.type],c=new Array;if(s(e,e.hasZ?t=>{c.push([t[0],t[1],t[2]])}:t=>{c.push([t[0],t[1]])},Ot),0===c.length)throw a();const l=e.spatialReference,m=t.spatialReference,u=await R(new v({spatialReference:l,hasZ:e.hasZ,hasM:!1,points:c}),m,{signal:r});if(e.hasZ&&(n.hasZ=!0),e.hasZ)for(const[o,f,p]of u.points)Ot[0]=o,Ot[1]=f,Ot[2]=p,U(n.boundingBox,Ot);else for(const[o,f]of u.points)Ot[0]=o,Ot[1]=f,U(n.boundingBox,Ot)}async function bt(t,e,n,a,o){const i=await r(t.whenViewForGraphic(e));if(!1===i.ok||null==i.value||!("whenGraphicBounds"in i.value))return void await vt(t,e.geometry,a,o);const s=i.value,c=await r(s.whenGraphicBounds(e,{minDemResolution:n}));if(!1===c.ok||!c.value)return void await vt(t,e.geometry,a,o);const{screenSpaceObjects:l,boundingBox:m}=c.value;V(a.boundingBox,m),l&&l.forEach(t=>{a.screenSpaceObjects.push(t)}),isFinite(m[2])&&(a.hasZ=!0)}async function Rt(t,n,r,a,o){if(Array.isArray(n)&&2===n.length){const e=n[0],r=n[1];if("number"==typeof e&&"number"==typeof r)return Jt.x=e,Jt.y=r,Jt.z=void 0,Jt.spatialReference=t.spatialReference?.isGeographic?t.spatialReference:G.WGS84,void await vt(t,Jt,a,o)}n&&"map"in n&&"function"==typeof n.map?await Promise.allSettled(n.map(e=>Rt(t,e,r,a,o))):n instanceof j?await vt(t,n,a,o):n instanceof e&&await bt(t,n,r,a,o)}async function zt(t,e,n,r,a){if(e.camera)return Gt(t,e.camera,r,a,dt(t,n)??e.scale);a.scale=e.scale,a.rotation=e.rotation,a.targetGeometry=null!=e.targetGeometry?e.targetGeometry.clone():null,a.camera=null,null!=n.heading?a.rotation=st(n.heading):null!=n.rotation&&(a.rotation=n.rotation);const o=dt(t,n);return null!=o&&(a.scale=o),a.camera=await lt(t,a,n.tilt,r),a}async function Gt(t,e,n,r,a){const o=t.spatialReference,i=await R(e.position,o,{signal:n}),s=e.clone();return s.position=i,jt(t,null,s,r,a)}async function St(t,e,n,r,a,o,i){const s=t.renderSpatialReference;return await B(e,qt,s,{signal:i}),await B(n,Yt,s,{signal:i}),o.targetGeometry=new b(e),a.position=new b(n),y(Wt,qt,Yt),at(t,Yt,Wt,r.up,a),o.scale=H(t,p(Yt,qt)),o.rotation=st(a.heading),o.camera=a,o}async function Bt(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);if(e.position)return St(t,o.targetGeometry,e.position,i,r,o,a);if(e.zoomFactor){const n=i.distance/e.zoomFactor,r=u(Ot,i.viewForward,-n);i.eye=f(Ot,i.center,r),o.scale=H(t,n)}D(t,i,r);const s=xt(r,e)?0:1;if(!e.zoomFactor){const n=dt(t,e);if(null==n){await B(o.targetGeometry,Ot,t.renderSpatialReference,{signal:a});const e=Y(i.frustum,Ot)?p(i.eye,Ot):i.distance;o.camera=await Q(t,o.targetGeometry,e,r,s),o.scale=H(t,e)}else o.scale=n,o.camera=await nt(t,o.targetGeometry,o.scale,r,s,a)}return o}async function Mt(t,e,n,r,a){const o=X(t);g(Wt,o.viewForward),at(t,o.eye,Wt,o.up,Dt);const i=t.spatialReference,{position:s}=e;if(s){const t=await R(s,i,{signal:a});n.position=t}else n.position=new b;return n.heading=null!=e.heading?e.heading:Dt.heading,n.tilt=null!=e.tilt?e.tilt:Dt.tilt,jt(t,null,n,r,dt(t,e))}async function Zt(t,e,n,r,a){if(null!=e.heading||null!=e.rotation||null!=e.scale||null!=e.tilt||null!=e.zoom||null!=e.zoomFactor){const o=X(t),{spatialReference:i,renderSpatialReference:s}=t,c=new b({spatialReference:i});return M(o.center,s,c)?Bt(t,e,c,n,r,a):a}return a.scale=t.scale,a.camera=t.camera.clone(),xt(a.camera,e),a}async function Ft(t,e,n,r,a,o){o.targetGeometry=n.clone();const i=X(t);D(t,i,r);const s=xt(r,e)?0:1;return o.camera=await L(t,n,r.heading,r.tilt,s,a),o}function Tt(t,e,n,r,a){let o=0;null!=n.z?o=n.z:t.basemapTerrain&&t.elevationProvider&&(o=rt(t.elevationProvider,n)),h(Ot,n.x,n.y,o),S(t.spatialReference,Ot,kt,t.renderSpatialReference),s(Nt,kt),c(Nt,Nt),E(It);const i=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];for(let s=0;s<i.length;s++){const e=i[s];let n=r[e[2]];isFinite(n)||(n=o),h(Ot,r[e[0]],r[e[1]],n),Z(Ot,t.spatialReference,Ot,t.renderSpatialReference),U(It,d(Ot,Ot,Nt))}const l=O(It),m=k(It),u=N(It),f=1/Math.tan(e.fovX/2),p=1/Math.tan(e.fovY/2),g=.5*Math.sqrt(l*l+u*u)*Math.max(p,f)+.5*m,y=.5*m*p+.5*Math.max(l,u);return Math.max(g,y)/a}async function Pt(t,e,n,r,a,o,i,s){s.targetGeometry=n.clone();const c=X(t),l=Tt(t,c,n,r,a);D(t,c,o);const m=xt(o,e)?0:1;return s.camera=await Q(t,s.targetGeometry,l,o,m,i),s.scale=H(t,l),s}function At(t,e){if(!e||!t.spatialReference)return null;const n={target:void 0};return"declaredClass"in e||Array.isArray(e)?n.target=e:(Object.assign(n,e),!n.target&&"center"in e&&e.center&&(n.target=e.center)),n}function Et(t){return null!=t?.camera&&(t.rotation=st(t.camera.heading)),t}function Ut(t,e){const n=ot;if(!e.length)return n;let r=Number.NEGATIVE_INFINITY;for(let a=0;a<e.length;a++){const t=e[a].screenSpaceBoundingRect;r=Math.max(r,Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2]),Math.abs(t[3]))}return n-r/Math.min(t.width,t.height)*2}class Vt{constructor(){this.hasZ=!1,this.boundingBox=E(),this.screenSpaceObjects=new Array}}const Ot=w(),kt=m(),Nt=l(),It=F(),Ct=I(),Wt=w(),Yt=w(),qt=w(),Dt={heading:0,tilt:0},Jt=new b,Xt={point(t,e,n){n[0]=t.x,n[1]=t.y,null!=t.z&&(n[2]=t.z),e(n)},polygon(t,e,n){const r=t.hasZ;for(let a=0;a<t.rings.length;a++){const o=t.rings[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},polyline(t,e,n){const r=t.hasZ;for(let a=0;a<t.paths.length;a++){const o=t.paths[a];for(let t=0;t<o.length;t++)n[0]=o[t][0],n[1]=o[t][1],r&&(n[2]=o[t][2]),e(n)}},multipoint(t,e,n){const r=t.points,a=t.hasZ;for(let o=0;o<r.length;o++)n[0]=r[o][0],n[1]=r[o][1],a&&(n[2]=r[o][2]),e(n)},extent(t,e,n){null!=t.zmin&&null!=t.zmax?(e(h(n,t.xmin,t.ymin,t.zmin)),e(h(n,t.xmax,t.ymin,t.zmin)),e(h(n,t.xmin,t.ymax,t.zmin)),e(h(n,t.xmax,t.ymax,t.zmin)),e(h(n,t.xmin,t.ymin,t.zmax)),e(h(n,t.xmax,t.ymin,t.zmax)),e(h(n,t.xmin,t.ymax,t.zmax)),e(h(n,t.xmax,t.ymax,t.zmax))):(e(h(n,t.xmin,t.ymin,n[2])),e(h(n,t.xmax,t.ymin,n[2])),e(h(n,t.xmin,t.ymax,n[2])),e(h(n,t.xmax,t.ymax,n[2])))}};export{ht as create,yt as fromCamera,lt as toCameraAsync,ct as toCameraSync};