@arcgis/core 4.33.0-next.20250424 → 4.33.0-next.20250425

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 (115) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/analysis/support/AnalysisOriginWebScene.d.ts +1 -1
  3. package/analysis/support/AnalysisOriginWebScene.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/070839cb71c8e764b8d7.js +1 -0
  6. package/assets/esri/core/workers/chunks/19084a293694c5a00cae.js +1 -0
  7. package/assets/esri/core/workers/chunks/{5958af341014e13475d2.js → 2bed8a5ed9ae3760fa2f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{7ffa68d69c138db1295d.js → 2e3019ce49e972a815ca.js} +1 -1
  9. package/assets/esri/core/workers/chunks/38f5e6a202ce292edd9f.js +1 -0
  10. package/assets/esri/core/workers/chunks/415903f481392c72870f.js +1 -0
  11. package/assets/esri/core/workers/chunks/4351b3e54b309935faed.js +1 -0
  12. package/assets/esri/core/workers/chunks/4da99f058cca83937e9b.js +1 -0
  13. package/assets/esri/core/workers/chunks/5acdd49c5f1a49fdc6e7.js +1 -0
  14. package/assets/esri/core/workers/chunks/968f2f841c011095a6d2.js +1 -0
  15. package/assets/esri/core/workers/chunks/a2676f3f135ad5fdf872.js +1 -0
  16. package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +1 -0
  17. package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +319 -0
  18. package/assets/esri/core/workers/chunks/bf543bdec3da0fe278fb.js +1 -0
  19. package/assets/esri/core/workers/chunks/f52e597dca4b32a81881.js +1 -0
  20. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  21. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  22. package/chunks/ShadowCastAccumulate.glsl.js +13 -9
  23. package/chunks/ShadowCastVisualize.glsl.js +24 -9
  24. package/chunks/lyr3DMain.js +1 -1
  25. package/chunks/lyr3DWorker.js +1 -1
  26. package/interfaces.d.ts +200 -5
  27. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  28. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  29. package/layers/ParquetLayer.js +1 -1
  30. package/layers/mixins/ImageryTileMixin.js +1 -1
  31. package/layers/support/ParquetEncodingLocation.d.ts +4 -0
  32. package/layers/support/ParquetEncodingLocation.js +1 -1
  33. package/layers/support/ParquetEncodingWkb.d.ts +4 -0
  34. package/layers/support/ParquetEncodingWkb.js +1 -1
  35. package/layers/support/RasterStorageInfo.js +1 -1
  36. package/layers/support/layerUtils.js +1 -1
  37. package/layers/support/parquetUtils.d.ts +3 -0
  38. package/layers/support/parquetUtils.js +1 -1
  39. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  40. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  41. package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
  42. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  43. package/package.json +2 -2
  44. package/portal/schemas/definitions.js +1 -1
  45. package/portal/schemas/integratedMesh3DTilesLayerItem.js +1 -1
  46. package/support/revision.js +1 -1
  47. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  48. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  49. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  50. package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
  51. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  52. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  53. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  54. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  55. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  56. package/views/3d/layers/Lyr3DWorker.js +1 -1
  57. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  58. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  59. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  60. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
  61. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
  62. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  63. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  64. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  65. package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +5 -0
  66. package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +5 -0
  67. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  68. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  69. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  70. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  71. package/views/3d/webgl/ManagedFBO.js +1 -1
  72. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  73. package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +7 -13
  74. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendColorsPremultiplied.glsl.js +5 -0
  75. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  76. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  77. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  78. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  79. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +5 -0
  80. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  81. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  82. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
  83. package/views/PopupView.js +1 -1
  84. package/views/SelectionManager.js +1 -1
  85. package/views/analysis/analysisViewUtils.js +1 -1
  86. package/views/input/InputManager.js +1 -1
  87. package/views/input/ViewEvents.js +1 -1
  88. package/views/support/selectionUtils.js +1 -1
  89. package/webscene/support/analysisUtils.js +1 -1
  90. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  91. package/widgets/Editor/UpdateWorkflow.js +1 -1
  92. package/widgets/Editor/workflowUtils.js +1 -1
  93. package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
  94. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  95. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  96. package/widgets/FeatureTable.js +1 -1
  97. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  98. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  99. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  100. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  101. package/widgets/Sketch/SketchViewModel.js +1 -1
  102. package/widgets/VideoPlayer.js +1 -1
  103. package/widgets/support/AnalysisViewModel.js +1 -1
  104. package/assets/esri/core/workers/chunks/0a48b9734ab4c64a6f4f.js +0 -1
  105. package/assets/esri/core/workers/chunks/1427e7953c3d8c87c5e8.js +0 -1
  106. package/assets/esri/core/workers/chunks/146b3699a9e8b1f2dcc2.js +0 -1
  107. package/assets/esri/core/workers/chunks/22f604726529ee6f8c25.js +0 -1
  108. package/assets/esri/core/workers/chunks/8dd26b12c625d20196ed.js +0 -319
  109. package/assets/esri/core/workers/chunks/91f8547a13f0461045ef.js +0 -1
  110. package/assets/esri/core/workers/chunks/931275cfa2c55eb0f504.js +0 -1
  111. package/assets/esri/core/workers/chunks/9f416cc5673665f8c37c.js +0 -1
  112. package/assets/esri/core/workers/chunks/b42ecc7c3eb2fd8d1308.js +0 -1
  113. package/assets/esri/core/workers/chunks/d04efa51da9b4eb3a8a7.js +0 -1
  114. package/assets/esri/core/workers/chunks/d8474dca270b25705699.js +0 -1
  115. package/assets/esri/core/workers/chunks/ed3d1d0465f4a4d8df4a.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{schema_definitions as e}from"./definitions.js";const i={title:"Integrated Mesh 3D Tiles Layer config on layer item",type:"object",properties:{layers:{type:"array",items:{properties:{customParameters:{$ref:"#/definitions/customParameters_schema.json"},id:{type:"integer",description:"ID of the service layer."},layerDefinition:{type:"object",description:"A layerDefinition object defining the attribute schema and drawing information for the layer.",allOf:[{$ref:"#/definitions/layerDefinition_schema.json"},{properties:{elevationInfo:{},maxScale:{},minScale:{}},additionalProperties:!1}]},listMode:{type:"string",description:"To show or hide layers in the layer list",enum:["hide","show"],default:"show"},opacity:{type:"number",description:"The degree of transparency applied to the layer on the client side, where 0 is full transparency and 1 is no transparency.",minimum:0,maximum:1,default:1},visibility:{type:"boolean",description:"Boolean property determining whether the layer is initially visible in the web scene.",default:!0},visibilityTimeExtent:{description:"Represents time extent that will control when a layer should be visible based on webscene's current time. Visibility time extent only affects the layer visibility and will not filter the data.",$ref:"#/definitions/timeExtent_schema.json"}},additionalProperties:!1}}},additionalProperties:!1,$schema:"http://json-schema.org/draft-07/schema",definitions:e};export{i as json};
5
+ import{schema_definitions as e}from"./definitions.js";const i={title:"Integrated Mesh 3D Tiles Layer config on layer item",type:"object",properties:{layers:{type:"array",items:{properties:{customParameters:{$ref:"#/definitions/customParameters_schema.json"},id:{type:"integer",description:"ID of the service layer."},layerDefinition:{type:"object",description:"A layerDefinition object defining the attribute schema and drawing information for the layer.",allOf:[{$ref:"#/definitions/layerDefinition_schema.json"},{properties:{elevationInfo:{},maxScale:{},minScale:{}},additionalProperties:!1}]},listMode:{type:"string",description:"To show or hide layers in the layer list",enum:["hide","show"],default:"show"},modifications:{type:"string",description:"URL to modifications json file, typically stored in `ITEM/resources`. Content of the file follows the $ref:[Modifications schema](modifications_schema.json)."},opacity:{type:"number",description:"The degree of transparency applied to the layer on the client side, where 0 is full transparency and 1 is no transparency.",minimum:0,maximum:1,default:1},visibility:{type:"boolean",description:"Boolean property determining whether the layer is initially visible in the web scene.",default:!0},visibilityTimeExtent:{description:"Represents time extent that will control when a layer should be visible based on webscene's current time. Visibility time extent only affects the layer visibility and will not filter the data.",$ref:"#/definitions/timeExtent_schema.json"}},additionalProperties:!1}}},additionalProperties:!1,$schema:"http://json-schema.org/draft-07/schema",definitions:e};export{i as json};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- const b="20250424",a="0381b1480547c57a17136852873b53ba0e4b21d2";export{b as buildDate,a as commitHash};
5
+ const d="20250425",f="fddfc7eddfd0c7b50fd58414fc86e2da403f090e";export{d as buildDate,f as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../core/Logger.js";import{isAbortError as i}from"../../../core/promiseUtils.js";import{watch as t,sync as r,initial as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{hasExcludedVariableOrDimension as u}from"../../../layers/support/rasterDatasets/multidimensionalUtils.js";import h from"../engine/flow/FlowView2D.js";import{LayerView2DMixin as l}from"./LayerView2D.js";import d from"./imagery/ImageryTileView2D.js";import c from"./imagery/VectorFieldTileView2D.js";import{canUseMajorityInterpolationOnDataSource as p}from"./support/util.js";import m from"../../layers/ImageryTileLayerView.js";import v from"../../layers/LayerView.js";import w from"../../layers/RefreshableLayerView.js";let b=class extends(m(w(l(v)))){constructor(){super(...arguments),this._useWebGLForProcessing=!0,this._useProgressiveUpdate=!0,this.subview=null}get useWebGLForProcessing(){return this._useWebGLForProcessing}set useWebGLForProcessing(e){this._useWebGLForProcessing=e,this.subview&&"useWebGLForProcessing"in this.subview&&(this.subview.useWebGLForProcessing=e)}get useProgressiveUpdate(){return this._useWebGLForProcessing}set useProgressiveUpdate(e){this._useProgressiveUpdate=e,this.subview&&"useProgressiveUpdate"in this.subview&&(this.subview.useProgressiveUpdate=e)}get displayParameters(){const{layer:e}=this,s=this._get("displayParameters");return e.renderer&&e.visible?{bandIds:e.bandIds,renderer:e.renderer,interpolation:e.interpolation,multidimensionalDefinition:e.multidimensionalDefinition,rasterFunction:"imagery-tile"===e.type?e.rasterFunction:null}:s}update(e){this.subview?.update(e),this.notifyChange("updating")}isUpdating(){return!this.subview||this.subview.updating}attach(){this.layer.increaseRasterJobHandlerUsage(),this._updateSubview(),this.addAttachHandles([t((()=>this.displayParameters),((e,t)=>{const r=e.interpolation!==t?.interpolation&&("majority"===e.interpolation||"majority"===t?.interpolation)&&p(this.layer),o=e.renderer!==t?.renderer&&this._getSubviewType(t?.renderer)!==this._getSubviewType(e.renderer);o&&this._updateSubview();const a=e.multidimensionalDefinition!==t?.multidimensionalDefinition,n=e.rasterFunction!==t?.rasterFunction,u=n&&!this._useWebGLForProcessing,h=a||r||o||u;this.subview.redrawOrRefetch({refetch:h,reprocess:n}).catch((e=>{i(e)||s.getLogger(this).error(e)})),this.notifyChange("updating")})),t((()=>this.layer.multidimensionalSubset??null),((e,t)=>{const{multidimensionalDefinition:r}=this.layer;null!=r&&u(r,e)!==u(r,t)&&(this.subview.redrawOrRefetch({refetch:!0}).catch((e=>{i(e)||s.getLogger(this).error(e)})),this.notifyChange("updating"))}),r),t((()=>this.timeExtent),(()=>{this.subview.timeExtent=this.timeExtent,this.subview.redrawOrRefetch({refetch:!0}).catch((e=>{i(e)||s.getLogger(this).error(e)}))}),o)])}detach(){this.layer.decreaseRasterJobHandlerUsage(),this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null}viewChange(){this.requestUpdate()}moveEnd(){this.subview.moveEnd()}doRefresh(){return this.subview?this.subview.doRefresh():Promise.resolve()}_updateSubview(){const{renderer:e}=this.layer;if(!e)return;const s=this._getSubviewType(e);if(this.subview){if(this.subview.type===s)return void this._attachSubview(this.subview);this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null}const{layer:i}=this;let t;if(t="rasterVF"===s?new c({layer:i,layerView:this,scheduler:this.scheduler}):"flow"===s?new h({layer:i,layerView:this,scheduler:this.scheduler}):new d({layer:i,layerView:this,scheduler:this.scheduler}),"useWebGLForProcessing"in t&&(t.useWebGLForProcessing=this._useWebGLForProcessing),"useProgressiveUpdate"in t&&(t.useProgressiveUpdate=this._useProgressiveUpdate),"previousLOD"in t){const{subview:e}=this;t.previousLOD=e&&"previousLOD"in e?e.previousLOD:null}this._attachSubview(t),this.subview=t,this.requestUpdate()}_attachSubview(e){e&&!e.attached&&(e.attach(),e.attached=!0,this.container.addChildAt(e.container,0))}_detachSubview(e){e?.attached&&(this.container.removeChild(e.container),e.detach(),e.attached=!1)}_getSubviewType(e){const s=e?.type;return"vector-field"===s?"rasterVF":"flow"===s?"flow":"raster"}};e([a()],b.prototype,"subview",void 0),e([a()],b.prototype,"useWebGLForProcessing",null),e([a()],b.prototype,"useProgressiveUpdate",null),e([a({readOnly:!0})],b.prototype,"displayParameters",null),b=e([n("esri.views.2d.layers.ImageryTileLayerView2D")],b);const g=b;export{g as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../core/Logger.js";import{isAbortError as i}from"../../../core/promiseUtils.js";import{watch as t,sync as r,initial as o}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{hasExcludedVariableOrDimension as u}from"../../../layers/support/rasterDatasets/multidimensionalUtils.js";import h from"../engine/flow/FlowView2D.js";import{LayerView2DMixin as l}from"./LayerView2D.js";import d from"./imagery/ImageryTileView2D.js";import c from"./imagery/VectorFieldTileView2D.js";import{canUseMajorityInterpolationOnDataSource as p}from"./support/util.js";import v from"../../layers/ImageryTileLayerView.js";import m from"../../layers/LayerView.js";import b from"../../layers/RefreshableLayerView.js";let w=class extends(v(b(l(m)))){constructor(){super(...arguments),this._useWebGLForProcessing=!0,this._useProgressiveUpdate=!0,this.subview=null}get useWebGLForProcessing(){return this._useWebGLForProcessing}set useWebGLForProcessing(e){this._useWebGLForProcessing=e,this.subview&&"useWebGLForProcessing"in this.subview&&(this.subview.useWebGLForProcessing=e)}get useProgressiveUpdate(){return this._useWebGLForProcessing}set useProgressiveUpdate(e){this._useProgressiveUpdate=e,this.subview&&"useProgressiveUpdate"in this.subview&&(this.subview.useProgressiveUpdate=e)}get displayParameters(){const{layer:e}=this,s=this._get("displayParameters");return e.renderer&&e.visible?{bandIds:e.bandIds,renderer:e.renderer,interpolation:e.interpolation,multidimensionalDefinition:e.multidimensionalDefinition,rasterFunction:"imagery-tile"===e.type?e.rasterFunction:null}:s}update(e){this.subview?.update(e),this.notifyChange("updating")}isUpdating(){return!this.subview||this.subview.updating}attach(){this.layer.increaseRasterJobHandlerUsage(),this._updateSubview(),this.addAttachHandles([t((()=>this.displayParameters),((e,t)=>{const r=e.interpolation!==t?.interpolation&&("majority"===e.interpolation||"majority"===t?.interpolation)&&p(this.layer),o=!!this.layer.serviceRasterInfo?.storageInfo?.isBsqTile&&e.bandIds?.join()!==t?.bandIds?.join(),a=e.renderer!==t?.renderer&&this._getSubviewType(t?.renderer)!==this._getSubviewType(e.renderer);a&&this._updateSubview();const n=e.multidimensionalDefinition!==t?.multidimensionalDefinition,u=e.rasterFunction!==t?.rasterFunction,h=u&&!this._useWebGLForProcessing,l=n||r||a||h||o;this.subview.redrawOrRefetch({refetch:l,reprocess:u}).catch((e=>{i(e)||s.getLogger(this).error(e)})),this.notifyChange("updating")})),t((()=>this.layer.multidimensionalSubset??null),((e,t)=>{const{multidimensionalDefinition:r}=this.layer;null!=r&&u(r,e)!==u(r,t)&&(this.subview.redrawOrRefetch({refetch:!0}).catch((e=>{i(e)||s.getLogger(this).error(e)})),this.notifyChange("updating"))}),r),t((()=>this.timeExtent),(()=>{this.subview.timeExtent=this.timeExtent,this.subview.redrawOrRefetch({refetch:!0}).catch((e=>{i(e)||s.getLogger(this).error(e)}))}),o)])}detach(){this.layer.decreaseRasterJobHandlerUsage(),this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null}viewChange(){this.requestUpdate()}moveEnd(){this.subview.moveEnd()}doRefresh(){return this.subview?this.subview.doRefresh():Promise.resolve()}_updateSubview(){const{renderer:e}=this.layer;if(!e)return;const s=this._getSubviewType(e);if(this.subview){if(this.subview.type===s)return void this._attachSubview(this.subview);this._detachSubview(this.subview),this.subview?.destroy(),this.subview=null}const{layer:i}=this;let t;if(t="rasterVF"===s?new c({layer:i,layerView:this,scheduler:this.scheduler}):"flow"===s?new h({layer:i,layerView:this,scheduler:this.scheduler}):new d({layer:i,layerView:this,scheduler:this.scheduler}),"useWebGLForProcessing"in t&&(t.useWebGLForProcessing=this._useWebGLForProcessing),"useProgressiveUpdate"in t&&(t.useProgressiveUpdate=this._useProgressiveUpdate),"previousLOD"in t){const{subview:e}=this;t.previousLOD=e&&"previousLOD"in e?e.previousLOD:null}this._attachSubview(t),this.subview=t,this.requestUpdate()}_attachSubview(e){e&&!e.attached&&(e.attach(),e.attached=!0,this.container.addChildAt(e.container,0))}_detachSubview(e){e?.attached&&(this.container.removeChild(e.container),e.detach(),e.attached=!1)}_getSubviewType(e){const s=e?.type;return"vector-field"===s?"rasterVF":"flow"===s?"flow":"raster"}};e([a()],w.prototype,"subview",void 0),e([a()],w.prototype,"useWebGLForProcessing",null),e([a()],w.prototype,"useProgressiveUpdate",null),e([a({readOnly:!0})],w.prototype,"displayParameters",null),w=e([n("esri.views.2d.layers.ImageryTileLayerView2D")],w);const g=w;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{assertIsSome as s}from"../../../../core/maybe.js";import{debounce as r,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as n}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Extent.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import p from"../../../../layers/support/TileInfo.js";import{update as d,unregister as y,getRasterId as g,register as m}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as _,computeProjectedScales as f}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import w from"../../tiling/TileQueue.js";import P from"../../tiling/TileStrategy.js";import{tileSize as I}from"../../engine/webgl/definitions.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{getWebGLCapabilities as C}from"../../../webgl/capabilities.js";const S=[0,0];let U=class extends t{constructor(){super(...arguments),this._updatingHandles=new n,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=r((async(e={})=>{const t=this._rasterFunctionState,i=e.reprocess||"gpu"===t&&!this.canUseWebGLForProcessing||"cpu"===t&&this.canUseWebGLForProcessing;if(i&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const s=this._rasterFunctionState,{type:r}=this;return e.refetch||"raster"!==r&&!!i||"cpu"===s||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))}))}destroy(){this._updatingHandles.destroy()}get canUseWebGLForProcessing(){return!1}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s="toJSON"in t?t:h.fromJSON(t);d(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._globalUpdateRequested||this._updatingHandles?.updating}attach(){const e=C();this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new w({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile(e,t),priority:R.MAPVIEW_FETCH_QUEUE,scheduler:this.scheduler});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._updatingHandles.addPromise(this._enqueueTileFetch(t)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new u({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):"rasterFunction"in t?i:e}updateRasterFunctionParameters(){}_fetchTile(e,t){const i=this._getFetchOptions(e.level,t.signal);return this.fetchTile(e,i)}_getFetchOptions(e,t){const{canUseWebGLForProcessing:i}=this,{layerView:s}=this,{tileInfo:r}=s,a=!r.isWrappable&&null!=_(s.view.spatialReference),o=i&&this.layer.raster.hasUniqueSourceStorageInfo;return{allowPartialFill:!0,datumTransformation:s.datumTransformation,interpolation:i?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:o,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:t,srcResolution:this._srcResolutions[e],timeExtent:s.timeExtent,tileInfo:r,disableWrapAround:a}}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=p.create({spatialReference:t,size:I,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const{scales:i,srcResolutions:r,isCustomTilingScheme:a}=f(this.layer.serviceRasterInfo,t,{tileSize:I,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),o=p.create({spatialReference:t,size:I,scales:i}),l=0===o.origin.x;s(e.fullExtent);const{xmin:n,ymax:h}=e.fullExtent;(l||a&&o.origin.x>n)&&(o.origin=new c({x:n,y:h,spatialReference:t})),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.serviceRasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),r=this._getBandIds();let o=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){o=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){a(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(S,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:o,bandIds:r,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){a(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await Promise.allSettled(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t=this._getFetchOptions(this.previousLOD.level,e),i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,{...t,interpolation:"nearest",requestRawData:!1,skipRasterFunction:!1});if(!i?.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.minOutput=Math.round(255*a.minOutput),a.maxOutput=Math.round(255*a.maxOutput)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{raster:s}=t,{multidimensionalDefinition:r}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),a=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(r):null,o=g(s.rasterId,a);if(o!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=m(o,s.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),r=this._srcResolutions[t.level];d(o,this._blockCacheRegistryId,e.extent,e.resolution,r,s.ioConfig.sampling)}this._blockCacheRegistryUrl=o}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh((t=>e.push(this._enqueueTileFetch(t)))),await this._updatingHandles.addPromise(Promise.allSettled(e))}};e([o()],U.prototype,"_globalUpdateRequested",void 0),e([o()],U.prototype,"attached",void 0),e([o()],U.prototype,"container",void 0),e([o()],U.prototype,"layer",void 0),e([o()],U.prototype,"layerView",void 0),e([o()],U.prototype,"scheduler",void 0),e([o()],U.prototype,"type",void 0),e([o()],U.prototype,"useWebGLForProcessing",null),e([o()],U.prototype,"useProgressiveUpdate",null),e([o()],U.prototype,"timeExtent",void 0),e([o()],U.prototype,"updating",null),U=e([l("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],U);export{U as BaseImageryTileSubView2D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{assertIsSome as s}from"../../../../core/maybe.js";import{debounce as r,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as n}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Extent.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import d from"../../../../layers/support/TileInfo.js";import{update as p,unregister as y,getRasterId as g,register as m}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as _,computeProjectedScales as f}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import w from"../../tiling/TileQueue.js";import I from"../../tiling/TileStrategy.js";import{tileSize as P}from"../../engine/webgl/definitions.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{getWebGLCapabilities as C}from"../../../webgl/capabilities.js";const S=[0,0];let v=class extends t{constructor(){super(...arguments),this._updatingHandles=new n,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=r((async(e={})=>{const t=this._rasterFunctionState,i=e.reprocess||"gpu"===t&&!this.canUseWebGLForProcessing||"cpu"===t&&this.canUseWebGLForProcessing;if(i&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const s=this._rasterFunctionState,{type:r}=this;return e.refetch||"raster"!==r&&!!i||"cpu"===s||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))}))}destroy(){this._updatingHandles.destroy()}get canUseWebGLForProcessing(){return!1}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s="toJSON"in t?t:h.fromJSON(t);p(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._globalUpdateRequested||this._updatingHandles?.updating}attach(){const e=C();this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new w({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile(e,t),priority:R.MAPVIEW_FETCH_QUEUE,scheduler:this.scheduler});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._updatingHandles.addPromise(this._enqueueTileFetch(t)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new u({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):"rasterFunction"in t?i:e}updateRasterFunctionParameters(){}_fetchTile(e,t){const i=this._getFetchOptions(e.level,t.signal);return this.fetchTile(e,i)}_getFetchOptions(e,t){const{canUseWebGLForProcessing:i}=this,{layerView:s}=this,{tileInfo:r}=s,a=!r.isWrappable&&null!=_(s.view.spatialReference),o=i&&this.layer.raster.hasUniqueSourceStorageInfo,{layer:l}=this.layerView,n=l.serviceRasterInfo?.storageInfo.isBsqTile?l.bandIds:void 0;return{allowPartialFill:!0,datumTransformation:s.datumTransformation,interpolation:i?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:o,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:t,srcResolution:this._srcResolutions[e],timeExtent:s.timeExtent,tileInfo:r,bandIds:n,disableWrapAround:a}}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=d.create({spatialReference:t,size:P,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const{scales:i,srcResolutions:r,isCustomTilingScheme:a}=f(this.layer.serviceRasterInfo,t,{tileSize:P,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),o=d.create({spatialReference:t,size:P,scales:i}),l=0===o.origin.x;s(e.fullExtent);const{xmin:n,ymax:h}=e.fullExtent;(l||a&&o.origin.x>n)&&(o.origin=new c({x:n,y:h,spatialReference:t})),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.serviceRasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),r=this._getBandIds();let o=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){o=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){a(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(S,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:o,bandIds:r,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){a(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await Promise.allSettled(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t=this._getFetchOptions(this.previousLOD.level,e),i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,{...t,interpolation:"nearest",requestRawData:!1,skipRasterFunction:!1});if(!i?.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.minOutput=Math.round(255*a.minOutput),a.maxOutput=Math.round(255*a.maxOutput)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{raster:s}=t,{multidimensionalDefinition:r}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),a=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(r):null,o=s.rasterInfo.storageInfo.isBsqTile&&t.bandIds?.length?t.bandIds:null,l=g(s.rasterId,a,o);if(l!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=m(l,s.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),r=this._srcResolutions[t.level];p(l,this._blockCacheRegistryId,e.extent,e.resolution,r,s.ioConfig.sampling)}this._blockCacheRegistryUrl=l}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh((t=>e.push(this._enqueueTileFetch(t)))),await this._updatingHandles.addPromise(Promise.allSettled(e))}};e([o()],v.prototype,"_globalUpdateRequested",void 0),e([o()],v.prototype,"attached",void 0),e([o()],v.prototype,"container",void 0),e([o()],v.prototype,"layer",void 0),e([o()],v.prototype,"layerView",void 0),e([o()],v.prototype,"scheduler",void 0),e([o()],v.prototype,"type",void 0),e([o()],v.prototype,"useWebGLForProcessing",null),e([o()],v.prototype,"useProgressiveUpdate",null),e([o()],v.prototype,"timeExtent",void 0),e([o()],v.prototype,"updating",null),v=e([l("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],v);export{v as BaseImageryTileSubView2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{isFunctionRaster as s}from"../../../../layers/support/rasterDatasets/datasetUtils.js";import{RasterTileContainer as i}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as o}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as n}from"../support/util.js";import a from"../../../layers/support/Geometry.js";let l=class extends o{constructor(){super(...arguments),this.type="raster"}get canUseWebGLForProcessing(){const{loaded:e,symbolizer:t}=this.layer;if(!e||!t)return!1;const r=t.lookup.colormapLut?.indexedColormap,s=r&&r.length>this._maxIndexedColormapSize;return this.useWebGLForProcessing&&t.canRenderInWebGL&&!s&&!("majority"===this.layer.interpolation&&n(this.layer))}attach(){super.attach(),this.container=new i(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}fetchTile(e,t){return this.layer.fetchTile(e.level,e.row,e.col,t)}updateRasterFunctionParameters(){const{clips:e,view:t}=this.layerView;null!=this._geometry&&e.remove(this._geometry);const{raster:r,type:i}=this.layer;if(s(r)){const s=r.getClippingGeometry(t.spatialReference);if(s){const t=new a({geometry:s});e.add(t),this._geometry=t}}const{container:o}=this;if("Function"!==r.datasetFormat||"wcs"===i)return o.rasterFunctionChain=null,o.children.forEach((e=>{const{bitmap:t}=e;t&&(t.suspended=!0,t.processed=!1,t.projected&&(t.invalidateTexture(),t.rasterTexture=null))})),void(this._rasterFunctionState="na");const n=this._rasterFunctionState,{rasterFunction:l,primaryRasters:c}=r,u=l.supportsGPU&&(!c||c.rasters.length<=1),p=u?l.flatWebGLFunctionChain:null,{renderer:d}=this.layer,h=!u||!p?.functions.length||"raster-stretch"===d?.type&&d.dynamicRangeAdjustment||!this.canUseWebGLForProcessing;o.rasterFunctionChain=h?null:this._addProjection(p);const m=null==l?"na":o.rasterFunctionChain?"gpu":"cpu",y=n===m||"na"===n&&"cpu"===m&&0===p?.functions?.length;o.children.forEach((e=>{const{bitmap:t}=e;t&&(t.suspended=!y,t.processed=!1,t.processedTexture=null)})),this._rasterFunctionState=m}async updateTileSource(e,t){const r=this._getBandIds(),s=this._getLayerInterpolation(),{canUseWebGLForProcessing:i}=this,{source:o,globalSymbolizerParams:n,suspended:a,coords:l,resolution:c}=t,u=this.layerView.hasTilingEffects?n:t.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,null!=o?.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock,srcPixelSize:o.srcTilePixelSize};if(p.rawPixelData=e,i)p.source=o.pixelBlock,p.isRendereredSource=!1;else{const t=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);p.source=t,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,p.transformGrid=i?o.transformGrid:null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?r:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:r,global:s}=t,i=this._getBandIds(),o=this._getLayerInterpolation(),{canUseWebGLForProcessing:n}=this,{bitmap:a}=e,{rawPixelData:l}=a;n||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=n?this.layerView.hasTilingEffects?s:r:null,a.bandIds=n?i:null,a.interpolation=o,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:t}=this.layer;if(!t)return e;const r=t.type;return"raster-colormap"===r||"unique-value"===r?"nearest":"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}_addProjection(e){return e?.functions?.length&&!e.hasFocalFunction&&e.functions.unshift({name:"Reproject",parameters:{targetImageSize:this._tileInfoView.tileInfo.size,requireNNEdge:e.isSourceSingleBand},pixelType:"f32",id:0,isNoopProcess:!1}),e}};e([t()],l.prototype,"container",void 0),e([t()],l.prototype,"layer",void 0),e([t()],l.prototype,"type",void 0),l=e([r("esri.views.2d.layers.imagery.ImageryTileView2D")],l);const c=l;export{c as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import has from"../../../../core/has.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{isFunctionRaster as s}from"../../../../layers/support/rasterDatasets/datasetUtils.js";import{getBytesPerPixel as i}from"../../../../layers/support/rasterFormats/pixelRangeUtils.js";import{RasterTileContainer as o}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as n}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as a}from"../support/util.js";import l from"../../../layers/support/Geometry.js";let c=class extends n{constructor(){super(...arguments),this.type="raster"}get canUseWebGLForProcessing(){const{loaded:e,symbolizer:t}=this.layer;if(!e||!t)return!1;const r=t.lookup.colormapLut?.indexedColormap,s=r&&r.length>this._maxIndexedColormapSize,o=i(this.layer.serviceRasterInfo);return!(has("ios")&&o>4)&&this.useWebGLForProcessing&&t.canRenderInWebGL&&!s&&!("majority"===this.layer.interpolation&&a(this.layer))}attach(){super.attach(),this.container=new o(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}fetchTile(e,t){return this.layer.fetchTile(e.level,e.row,e.col,t)}updateRasterFunctionParameters(){const{clips:e,view:t}=this.layerView;null!=this._geometry&&e.remove(this._geometry);const{raster:r,type:i}=this.layer;if(s(r)){const s=r.getClippingGeometry(t.spatialReference);if(s){const t=new l({geometry:s});e.add(t),this._geometry=t}}const{container:o}=this;if("Function"!==r.datasetFormat||"wcs"===i)return o.rasterFunctionChain=null,o.children.forEach((e=>{const{bitmap:t}=e;t&&(t.suspended=!0,t.processed=!1,t.projected&&(t.invalidateTexture(),t.rasterTexture=null))})),void(this._rasterFunctionState="na");const n=this._rasterFunctionState,{rasterFunction:a,primaryRasters:c}=r,u=a.supportsGPU&&(!c||c.rasters.length<=1),p=u?a.flatWebGLFunctionChain:null,{renderer:d}=this.layer,h=!u||!p?.functions.length||"raster-stretch"===d?.type&&d.dynamicRangeAdjustment||!this.canUseWebGLForProcessing;o.rasterFunctionChain=h?null:this._addProjection(p);const m=null==a?"na":o.rasterFunctionChain?"gpu":"cpu",y=n===m||"na"===n&&"cpu"===m&&0===p?.functions?.length;o.children.forEach((e=>{const{bitmap:t}=e;t&&(t.suspended=!y,t.processed=!1,t.processedTexture=null)})),this._rasterFunctionState=m}async updateTileSource(e,t){const r=this._getBandIds(),s=this._getLayerInterpolation(),{canUseWebGLForProcessing:i}=this,{source:o,globalSymbolizerParams:n,suspended:a,coords:l,resolution:c}=t,u=this.layerView.hasTilingEffects?n:t.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,null!=o?.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock,srcPixelSize:o.srcTilePixelSize};if(p.rawPixelData=e,i)p.source=o.pixelBlock,p.isRendereredSource=!1;else{const t=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);p.source=t,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,p.transformGrid=i?o.transformGrid:null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?r:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:r,global:s}=t,i=this._getBandIds(),o=this._getLayerInterpolation(),{canUseWebGLForProcessing:n}=this,{bitmap:a}=e,{rawPixelData:l}=a;n||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=n?this.layerView.hasTilingEffects?s:r:null,a.bandIds=n?i:null,a.interpolation=o,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:t}=this.layer;if(!t)return e;const r=t.type;return"raster-colormap"===r||"unique-value"===r?"nearest":"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}_addProjection(e){return e?.functions?.length&&!e.hasFocalFunction&&e.functions.unshift({name:"Reproject",parameters:{targetImageSize:this._tileInfoView.tileInfo.size,requireNNEdge:e.isSourceSingleBand},pixelType:"f32",id:0,isNoopProcess:!1}),e}};e([t()],c.prototype,"container",void 0),e([t()],c.prototype,"layer",void 0),e([t()],c.prototype,"type",void 0),c=e([r("esri.views.2d.layers.imagery.ImageryTileView2D")],c);const u=c;export{u as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{destroyHandle as o,makeHandle as s,abortHandle as i}from"../../../../core/handleUtils.js";import{debounce as n}from"../../../../core/promiseUtils.js";import{initial as r}from"../../../../core/reactiveUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{ViewEventPriorities as c}from"../../../input/InputManager.js";const h={redo:"r",undo:"z"},p=Symbol(),m=Symbol(),u=Symbol();let _=class extends t{constructor(e){super(e),this._tool=null,this._updatingHandles=new d,this.enabled=!1,this._onPointerMove=n((async e=>{const t=await this._updatingHandles.addPromise(this._findElementAtScreenPoint(e));this.destroyed||(this.removeHandles(m),t&&t!==this.selectedElement&&(this.view.cursor="pointer",this.addHandles(s((()=>this.view.cursor=null)),m)))}))}initialize(){this.addHandles(o(this._updatingHandles)),this._updatingHandles.add((()=>this.enabled),(e=>this._setEnabled(e)),r),this._updatingHandles.add((()=>this._preferredInteractionTool),(()=>this._preferredInteractionToolChanged()))}get _validatedSelectedElement(){const e=this.selectedElement;if(!e)return null;const{layer:{source:t}}=this;return t?"hasElement"in t?t.hasElement(e)?e:null:t===e?e:null:null}get _preferredInteractionTool(){return this.options?.tool??"transform"}get updating(){return this._updatingHandles.updating}_setEnabled(e){if(this.removeHandles(p),!e)return;const{view:t}=this;this.addHandles([t.on("immediate-click",(e=>this._onClick(e)),c.TOOL),t.on("pointer-move",(e=>this._onPointerMove(e).catch((()=>{}))),c.TOOL),t.on("key-down",(e=>{e.key===h.undo&&this._tool?.canUndo()&&(this._tool.undo(),e.stopPropagation()),e.key===h.redo&&this._tool?.canRedo()&&(this._tool.redo(),e.stopPropagation())})),this._updatingHandles.add((()=>this._validatedSelectedElement),(e=>this._selectedElementChanged(e)),r),s((()=>{t.cursor=null,this._removeTool()}))],p)}async _findElementAtScreenPoint(e){const t=(await this.view.hitTest(e,{include:[this.layer]})).results[0];return"media"===t?.type?t.element:null}async _onClick(e){await this._updatingHandles.addPromise(e.async((async()=>{const t=await this._findElementAtScreenPoint(e);this.destroyed||(t&&e.stopPropagation(),this.selectedElement=t,this.selectedElement&&(this.view.cursor=null))})))}_preferredInteractionToolChanged(){const{_tool:e}=this;e&&(this._preferredInteractionTool===e.type||this._updatingHandles.addPromise(this._recreateTool()))}async _recreateTool(){this.removeHandles(u),this._removeTool();const e=this._validatedSelectedElement;if(!e)return;const t=new AbortController;this.addHandles(i(t),u);const{TransformTool:o,ControlPointsTransformTool:n}=await import("../../interactive/editingTools.js");if(t.signal.aborted)return;const{view:r}=this;switch(this._preferredInteractionTool){case"transform":this._tool=new o({target:e,view:r});break;case"reshape":this._tool=new n({mediaElement:e,view:r})}this.addHandles(s((()=>{this._tool&&(r.tools.remove(this._tool),this._tool=null)})),this._tool),r.addAndActivateTool(this._tool)}_removeTool(){this._tool&&this.removeHandles(this._tool)}async _selectedElementChanged(e){e?.georeference?await this._updatingHandles.addPromise(this._recreateTool()):this._removeTool()}};e([l()],_.prototype,"_validatedSelectedElement",null),e([l()],_.prototype,"_preferredInteractionTool",null),e([l({constructOnly:!0})],_.prototype,"view",void 0),e([l({constructOnly:!0})],_.prototype,"layer",void 0),e([l()],_.prototype,"selectedElement",void 0),e([l()],_.prototype,"enabled",void 0),e([l()],_.prototype,"options",void 0),e([l()],_.prototype,"updating",null),_=e([a("esri.views.2d.layers.support.MediaLayerInteraction")],_);export{_ as MediaLayerInteraction};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{destroyHandle as o,makeHandle as s,abortHandle as i}from"../../../../core/handleUtils.js";import{debounce as n}from"../../../../core/promiseUtils.js";import{initial as r}from"../../../../core/reactiveUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{ViewEventPriorities as c}from"../../../input/InputManager.js";const h={redo:"r",undo:"z"},p=Symbol(),m=Symbol(),u=Symbol();let _=class extends t{constructor(e){super(e),this._tool=null,this._updatingHandles=new d,this.enabled=!1,this._onPointerMove=n((async e=>{const t=await this._updatingHandles.addPromise(this._findElementAtScreenPoint(e));this.destroyed||(this.removeHandles(m),t&&t!==this.selectedElement&&(this.view.cursor="pointer",this.addHandles(s((()=>this.view.cursor=null)),m)))}))}initialize(){this.addHandles(o(this._updatingHandles)),this._updatingHandles.add((()=>this.enabled),(e=>this._setEnabled(e)),r),this._updatingHandles.add((()=>this._preferredInteractionTool),(()=>this._preferredInteractionToolChanged()))}get _validatedSelectedElement(){const e=this.selectedElement;if(!e)return null;const{layer:{source:t}}=this;return t?"hasElement"in t?t.hasElement(e)?e:null:t===e?e:null:null}get _preferredInteractionTool(){return this.options?.tool??"transform"}get updating(){return this._updatingHandles.updating}_setEnabled(e){if(this.removeHandles(p),!e)return;const{view:t}=this;this.addHandles([t.on("immediate-click",(e=>this._onClick(e)),c.TOOL),t.on("pointer-move",(e=>this._onPointerMove(e).catch((()=>{}))),c.TOOL),t.on("key-down",(e=>{e.key===h.undo&&this._tool?.canUndo()&&(this._tool.undo(),e.stopPropagation()),e.key===h.redo&&this._tool?.canRedo()&&(this._tool.redo(),e.stopPropagation())})),this._updatingHandles.add((()=>this._validatedSelectedElement),(e=>this._selectedElementChanged(e)),r),s((()=>{t.cursor=null,this._removeTool()}))],p)}async _findElementAtScreenPoint(e){const t=(await this.view.hitTest(e,{include:[this.layer]})).results[0];return"media"===t?.type?t.element:null}async _onClick(e){await this._updatingHandles.addPromise(e.defer((async()=>{const t=await this._findElementAtScreenPoint(e);this.destroyed||(t&&e.stopPropagation(),this.selectedElement=t,this.selectedElement&&(this.view.cursor=null))})))}_preferredInteractionToolChanged(){const{_tool:e}=this;e&&(this._preferredInteractionTool===e.type||this._updatingHandles.addPromise(this._recreateTool()))}async _recreateTool(){this.removeHandles(u),this._removeTool();const e=this._validatedSelectedElement;if(!e)return;const t=new AbortController;this.addHandles(i(t),u);const{TransformTool:o,ControlPointsTransformTool:n}=await import("../../interactive/editingTools.js");if(t.signal.aborted)return;const{view:r}=this;switch(this._preferredInteractionTool){case"transform":this._tool=new o({target:e,view:r});break;case"reshape":this._tool=new n({mediaElement:e,view:r})}this.addHandles(s((()=>{this._tool&&(r.tools.remove(this._tool),this._tool=null)})),this._tool),r.addAndActivateTool(this._tool)}_removeTool(){this._tool&&this.removeHandles(this._tool)}async _selectedElementChanged(e){e?.georeference?await this._updatingHandles.addPromise(this._recreateTool()):this._removeTool()}};e([l()],_.prototype,"_validatedSelectedElement",null),e([l()],_.prototype,"_preferredInteractionTool",null),e([l({constructOnly:!0})],_.prototype,"view",void 0),e([l({constructOnly:!0})],_.prototype,"layer",void 0),e([l()],_.prototype,"selectedElement",void 0),e([l()],_.prototype,"enabled",void 0),e([l()],_.prototype,"options",void 0),e([l()],_.prototype,"updating",null),_=e([a("esri.views.2d.layers.support.MediaLayerInteraction")],_);export{_ as MediaLayerInteraction};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import"../../../core/has.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as l}from"../../../properties/defaultUnit.js";import{AnalysisView3D as n}from"./AnalysisView3D.js";import{MeasurementMode as o}from"./interfaces.js";import{DirectLineMeasurementController as r}from"./DirectLineMeasurement/DirectLineMeasurementController.js";import{DirectLineMeasurementVisualization as u}from"./DirectLineMeasurement/DirectLineMeasurementVisualization.js";let p=class extends(n(e)){constructor(t){super(t),this.type="direct-line-measurement-view-3d",this.analysis=null,this.result=null,this.measurementMode=o.Auto,this.elevationAlignedStartPoint=null,this.elevationAlignedEndPoint=null}initialize(){const t=this.view,e=this.analysis;this._analysisVisualization=new u({view:t,analysis:e,analysisView:this}),this._analysisController=new r({view:t,analysis:e,viewData:this})}destroy(){this._analysisController=i(this._analysisController),this._analysisVisualization=i(this._analysisVisualization)}get updating(){return!!this._analysisVisualization?.loadingMessages}get viewMode(){return this._analysisVisualization.viewMode}get actualVisualizedMeasurement(){return this._analysisVisualization.actualVisualizedMeasurement}get visualElementOrientation(){return this._analysisVisualization.visualElementOrientation}set visualElementOrientation(t){this._analysisVisualization.visualElementOrientation=t}get allowVisualElementsOrientationChange(){return this._analysisVisualization.allowVisualElementsOrientationChange}set allowVisualElementsOrientationChange(t){this._analysisVisualization.allowVisualElementsOrientationChange=t}get triangleCollapseRatioThreshold(){return this._analysisVisualization.triangleCollapseRatioThreshold}set triangleCollapseRatioThreshold(t){this._analysisVisualization.triangleCollapseRatioThreshold=t}get directLabelText(){return this._analysisVisualization.labels.direct?.text??""}get horizontalLabelText(){return this._analysisVisualization.labels.horizontal?.text??""}get verticalLabelText(){return this._analysisVisualization.labels.vertical?.text??""}get unit(){return this.analysis.unit??this._defaultUnit}get testData(){}};t([a()],p.prototype,"updating",null),t([a({readOnly:!0})],p.prototype,"type",void 0),t([a({constructOnly:!0,nonNullable:!0})],p.prototype,"analysis",void 0),t([a()],p.prototype,"result",void 0),t([a()],p.prototype,"measurementMode",void 0),t([a()],p.prototype,"elevationAlignedStartPoint",void 0),t([a()],p.prototype,"elevationAlignedEndPoint",void 0),t([a({readOnly:!0})],p.prototype,"viewMode",null),t([a({readOnly:!0})],p.prototype,"actualVisualizedMeasurement",null),t([a()],p.prototype,"visualElementOrientation",null),t([a()],p.prototype,"allowVisualElementsOrientationChange",null),t([a()],p.prototype,"triangleCollapseRatioThreshold",null),t([a({readOnly:!0})],p.prototype,"directLabelText",null),t([a({readOnly:!0})],p.prototype,"horizontalLabelText",null),t([a({readOnly:!0})],p.prototype,"verticalLabelText",null),t([a()],p.prototype,"_analysisVisualization",void 0),t([a()],p.prototype,"_analysisController",void 0),t([a()],p.prototype,"unit",null),t([a(l)],p.prototype,"_defaultUnit",void 0),p=t([s("esri.views.3d.analysis.DirectLineMeasurementAnalysisView3D")],p);const y=p;export{y as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import i from"../../../core/Error.js";import"../../../core/has.js";import{destroyMaybe as a}from"../../../core/maybe.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{defaultUnitPropertyMetadata as n}from"../../../properties/defaultUnit.js";import{AnalysisView3D as o}from"./AnalysisView3D.js";import{MeasurementMode as r}from"./interfaces.js";import{DirectLineMeasurementController as u}from"./DirectLineMeasurement/DirectLineMeasurementController.js";import{DirectLineMeasurementVisualization as p}from"./DirectLineMeasurement/DirectLineMeasurementVisualization.js";import y from"../interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js";import{connectAnalysisViewToTool as d,startExclusiveInteractiveOperation as m}from"../../analysis/analysisViewUtils.js";let h=class extends(o(e)){constructor(t){super(t),this.type="direct-line-measurement-view-3d",this.analysis=null,this.tool=null,this.result=null,this.measurementMode=r.Auto,this.elevationAlignedStartPoint=null,this.elevationAlignedEndPoint=null,this.userOperation=null}initialize(){const t=this.view,e=this.analysis;this._analysisVisualization=new p({view:t,analysis:e,analysisView:this}),this._analysisController=new u({view:t,analysis:e,viewData:this}),this.addHandles(d(this,y))}destroy(){this._analysisController=a(this._analysisController),this._analysisVisualization=a(this._analysisVisualization)}get updating(){return!!this._analysisVisualization?.loadingMessages}get viewMode(){return this._analysisVisualization.viewMode}get actualVisualizedMeasurement(){return this._analysisVisualization.actualVisualizedMeasurement}get visualElementOrientation(){return this._analysisVisualization.visualElementOrientation}set visualElementOrientation(t){this._analysisVisualization.visualElementOrientation=t}get allowVisualElementsOrientationChange(){return this._analysisVisualization.allowVisualElementsOrientationChange}set allowVisualElementsOrientationChange(t){this._analysisVisualization.allowVisualElementsOrientationChange=t}get triangleCollapseRatioThreshold(){return this._analysisVisualization.triangleCollapseRatioThreshold}set triangleCollapseRatioThreshold(t){this._analysisVisualization.triangleCollapseRatioThreshold=t}get directLabelText(){return this._analysisVisualization.labels.direct?.text??""}get horizontalLabelText(){return this._analysisVisualization.labels.horizontal?.text??""}get verticalLabelText(){return this._analysisVisualization.labels.vertical?.text??""}get unit(){return this.analysis.unit??this._defaultUnit}get testData(){}place(t){if(this.analysis.valid)throw new i("DirectLineMeasurementAnalysisView3D:place","Cannot place a direct line measurement when the analysis already has a start and end point.");return this.userOperation=m(this,t),this.userOperation.promise}};t([s()],h.prototype,"_analysisVisualization",void 0),t([s()],h.prototype,"_analysisController",void 0),t([s(n)],h.prototype,"_defaultUnit",void 0),t([s()],h.prototype,"updating",null),t([s({readOnly:!0})],h.prototype,"type",void 0),t([s({constructOnly:!0,nonNullable:!0})],h.prototype,"analysis",void 0),t([s()],h.prototype,"tool",void 0),t([s()],h.prototype,"result",void 0),t([s()],h.prototype,"measurementMode",void 0),t([s()],h.prototype,"elevationAlignedStartPoint",void 0),t([s()],h.prototype,"elevationAlignedEndPoint",void 0),t([s({readOnly:!0})],h.prototype,"viewMode",null),t([s({readOnly:!0})],h.prototype,"actualVisualizedMeasurement",null),t([s()],h.prototype,"visualElementOrientation",null),t([s()],h.prototype,"allowVisualElementsOrientationChange",null),t([s()],h.prototype,"triangleCollapseRatioThreshold",null),t([s({readOnly:!0})],h.prototype,"directLabelText",null),t([s({readOnly:!0})],h.prototype,"horizontalLabelText",null),t([s({readOnly:!0})],h.prototype,"verticalLabelText",null),t([s()],h.prototype,"unit",null),t([s()],h.prototype,"userOperation",void 0),h=t([l("esri.views.3d.analysis.DirectLineMeasurementAnalysisView3D")],h);const c=h;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Color.js";import i from"../../../../analysis/LineOfSightAnalysisObserver.js";import a from"../../../../analysis/LineOfSightAnalysisTarget.js";import n from"../../../../core/Handles.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{watch as o,syncAndInitial as l,initial as u}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{create as p,fromPoints as g}from"../../../../geometry/support/lineSegment.js";import{getGraphicEffectiveElevationInfo as _,getConvertedElevation as m}from"../../../../support/elevationInfoUtils.js";import v from"../../../../symbols/support/ElevationInfo.js";import{getLaserLineColors as b,laserLineConfiguration as y}from"./LineOfSightConfiguration.js";import{LineOfSightTargetManipulator as f,LineOfSightObserverManipulator as T}from"./LineOfSightManipulators.js";import{LineOfSightRayIntersector as L}from"./LineOfSightRayIntersector.js";import{LaserlineVisualElement as w}from"../../interactive/visualElements/LaserlineVisualElement.js";import{IntersectorType as M}from"../../webgl-engine/lib/IntersectorInterfaces.js";import"../../../input/ViewEvents.js";import{AnalysisToolBase as C}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as k}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as V}from"../../../interactive/interfaces.js";import{createScreenPointFromEvent as H}from"../../../support/screenUtils.js";import{MouseButton as I}from"../../../input/IViewEvents.js";var O;!function(e){e.Ready="ready",e.Creating="creating",e.Created="created"}(O||(O={}));let P=class extends C{constructor(e){super(e),this._creationMode=!1,this.removeIncompleteOnCancel=!1,this.analysisViewData=null,this._latestPointerMovePointerType=null,this._laserlineVisualElement=null,this._grabbedManipulator=null,this._analysisHandles=new n,this._updatingHandles=new d,this._manipulatorHandles=new n,this._targetTrackerManipulator=null}initialize(){this._intersector=new L({view:this.view}),this.addHandles(o((()=>this.state),(e=>{e===O.Created&&this.finishToolCreation()}),l)),this._observerManipulator=this._createObserverManipulator(),this._createLaserLine(),this.addHandles([this._updatingHandles.add((()=>this.analysisViewData?.elevationAlignedObserver),(e=>this._onObserverLocationChange(e)),u),this._updatingHandles.add((()=>b(this.view.effectiveTheme)),(({glowColor:e,innerColor:t,globalAlpha:i})=>this._updateLaserLineStyle(e,t,i)),u),this._updatingHandles.add((()=>this._laserLineRendererDependencies()),(e=>this._updateLaserLineRenderer(e))),this._connectComputations(),this._updatingHandles.addWhen((()=>!this._shouldRenderTracker),(()=>this._clearCursorTracker()),u),this._updatingHandles.add((()=>({active:this.active,hasGrabbedManipulators:this.hasGrabbedManipulators})),(({active:e,hasGrabbedManipulators:t})=>{this._creationMode=!!e&&(this._creationMode||!t)}),u)])}destroy(){this._updatingHandles=s(this._updatingHandles),this._manipulatorHandles=s(this._manipulatorHandles),this._analysisHandles=s(this._analysisHandles),this._observerManipulator=null,this._clearCursorTracker(),this._removeLaserLine(),this._intersector=null,this._set("analysis",null)}get state(){return this.active?!this.hasGrabbedManipulators||this._creationMode?O.Creating:O.Created:null!=this.analysis.observer?.position?O.Created:O.Ready}get cursor(){return this.active&&this._showTracker?"crosshair":null}get updating(){return null!=this.analysisViewData&&this.analysisViewData.updating||this._updatingHandles.updating}get _showTracker(){return this.active&&"mouse"===this._latestPointerMovePointerType}get _shouldRenderTracker(){return this._showTracker&&null!=this.analysis.observer?.position&&!this.hasGrabbedManipulators}continue(){this.view.activeTool=this}stop(){this.view.activeTool=null}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickHandler(e)}onShow(){}onHide(){}onDeactivate(){this._clearCursorTracker()}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this.analysisViewData.computations),(e=>this._onComputationsCollectionChange(e)),{initial:!0,final:!0})}_onComputationsCollectionChange({added:e,removed:t}){for(const i of t)this._disconnectComputation(i);for(const i of e)this._connectComputation(i)}_connectComputation(e){if(this.destroyed)return void r.getLogger(this).warn("Attempting to connect an analysis to a destroyed LineOfSight tool. Ignoring.");const t=this._analysisHandles;if(t.has(e))return;const i=this._createTargetManipulator(e.target);null==this._targetTrackerManipulator&&i.metadata.target===this.analysisViewData.cursorTarget&&(this._targetTrackerManipulator=i,this._targetTrackerManipulator.available=!1,this._targetTrackerManipulator.interactive=!1,this._updateLaserLineRenderer()),t.add([this._updatingHandles.add((()=>j(e)),(()=>D(i,e)),u),this._updatingHandles.add((()=>e.elevationAlignedTargetLocation),(e=>this._onTargetLocationChange(e,i)),u)],e)}_disconnectComputation(e){if(this.destroyed)return void r.getLogger(this).warn("Attempting to disconnect an analysis from a destroyed LineOfSight tool. Ignoring.");this._analysisHandles.remove(e);const t=this._getTargetManipulator(e.target);null!=t&&(this.manipulators.remove(t),this._manipulatorHandles.remove(t),null!=this._targetTrackerManipulator&&this._targetTrackerManipulator===t&&(this._targetTrackerManipulator=null))}_clearCursorTracker(){this.analysisViewData.cursorTarget=s(this.analysisViewData.cursorTarget)}_createTargetManipulator(e){const t={target:e,type:"target"},i=new f(this.view,t);return this._manipulatorHandles.add([this._createTargetManipulatorDragPipeline(i),i.events.on("grab-changed",(e=>this._manipulatorGrabChanged(i,e))),i.events.on("immediate-click",(e=>this._manipulatorClick(i,e)))],i),this.manipulators.add(i),null!=e.position?i.elevationAlignedLocation=e.position:i.available=!1,i}_getTargetManipulator(e){let t=null;return this.manipulators.forEach((i=>{const a=i.manipulator;null==t&&"target"===a.metadata.type&&a.metadata.target===e&&(t=a)})),t}_createObserverManipulator(){const e=new T(this.view,{type:"observer",intersection:null});return this._manipulatorHandles.add([this._createObserverManipulatorDragPipeline(e),e.events.on("grab-changed",(t=>this._manipulatorGrabChanged(e,t))),e.events.on("immediate-click",(t=>this._manipulatorClick(e,t)))],e),this.manipulators.add(e),e}_screenToIntersection(){return e=>{const t=this._intersector.getScreenPointIntersection(e.screenEnd);return null==t?null:{...e,intersection:t}}}_createTargetManipulatorDragPipeline(e){return k(e,((t,i,a)=>{i.next(this._screenToIntersection()).next(this._updateTargetDragStep(e)).next((()=>this._updateLaserLineRenderer())),a.next(R(e.metadata.target)).next((()=>this._updateLaserLineRenderer()))}))}_createObserverManipulatorDragPipeline(e){return k(e,((e,t,i)=>{t.next(this._screenToIntersection()).next(this._updateObserverDragStep()).next((()=>this._updateLaserLineRenderer())),i.next(this._cancelObserverDragStep()).next((()=>this._updateLaserLineRenderer()))}))}_updateObserverDragStep(){return e=>(null!=e.intersection.mapPoint?(null==this.analysis.observer&&(this.analysis.observer=new i),this._updateFromIntersection(this.analysis.observer,e.intersection)):this.analysis.observer=null,e)}_cancelObserverDragStep(){const e=null!=this.analysis.observer?.position?this.analysis.observer.clone():null;return t=>(this.analysis.observer=e,t)}_updateTargetDragStep(e){return t=>{this._updateFromIntersection(e.metadata.target,t.intersection);const i=t.intersection.mapPoint;return null!=i&&(e.elevationAlignedLocation=i),t}}_manipulatorGrabChanged(e,t){switch(t.action){case"start":this._grabbedManipulator=e;break;case"end":this._grabbedManipulator===e&&(this._grabbedManipulator=null)}}_laserLineRendererDependencies(){return{laserlineVisualElement:this._laserlineVisualElement,grabbedManipulator:this._grabbedManipulator,shouldRenderTracker:this._shouldRenderTracker,observerPosition:null!=this.analysis.observer?this.analysis.observer.position:null,visible:this.visible}}_updateLaserLineRenderer(e=this._laserLineRendererDependencies()){const{laserlineVisualElement:t,grabbedManipulator:i,shouldRenderTracker:a,observerPosition:n,visible:r}=e;if(null==t)return;const s=null!=i?i:a&&null!=n?this._targetTrackerManipulator:null;null!=s&&r?(t.visible=!0,t.heightManifoldTarget=s.renderLocation,s!==this._observerManipulator?t.lineVerticalPlaneSegment=g(this._observerManipulator.renderLocation,s.renderLocation,S):t.lineVerticalPlaneSegment=null):(t.visible=!1,t.heightManifoldTarget=null,t.lineVerticalPlaneSegment=null)}_createLaserLine(){this._removeLaserLine();const{glowWidth:e,innerWidth:t}=y;this._laserlineVisualElement=new w({view:this.view,attached:!0,visible:this.visible,style:{glowWidth:e,innerWidth:t},isDecoration:!0})}_removeLaserLine(){null!=this._laserlineVisualElement&&(this._laserlineVisualElement.destroy(),this._laserlineVisualElement=null)}_updateLaserLineStyle(e,i,a){const n=this._laserlineVisualElement;if(null==n)return;const r=n.style;n.style={...r,glowColor:t.toUnitRGB(e),innerColor:t.toUnitRGB(i),globalAlpha:a}}_onObserverLocationChange(e){null!=e?(this._observerManipulator.metadata.intersection=null,this._observerManipulator.available=!0,this._observerManipulator.elevationAlignedLocation=e):this._observerManipulator.available=!1}_onTargetLocationChange(e,t){null!=e?(t.elevationAlignedLocation=e,t!==this._targetTrackerManipulator&&(t.available=!0)):t.available=!1}_addPointFromClickEvent(e){const t=this._intersector.getScreenPointIntersection(e);if(null!=t?.mapPoint)if(null!=this.analysis.observer?.position){this._clearCursorTracker();const e=new a;this._updateFromIntersection(e,t),this.analysis.targets.add(e)}else{const e=new i;this._updateFromIntersection(e,t),this.analysis.observer=e}}_clickHandler(e){this.active&&e.button!==I.Right&&(this._addPointFromClickEvent(H(e)),e.stopPropagation())}_doubleClickHandler(e){this.active&&e.button!==I.Right&&(this.stop(),e.stopPropagation())}_pointerMoveHandler(e){if(this.hasGrabbedManipulators)return;if(this._latestPointerMovePointerType=e.pointerType,this._updateLaserLineRenderer(),!this._showTracker||null==this.analysis.observer?.position)return;const t=H(e),i=this._intersector.getScreenPointIntersection(t);null!=i?.mapPoint&&(null==this.analysisViewData.cursorTarget&&(this.analysisViewData.cursorTarget=new a),this._updateFromIntersection(this.analysisViewData.cursorTarget,i),this._updateLaserLineRenderer())}_updateFromIntersection(e,t){if(null==t.mapPoint)return e.position=null,e.elevationInfo=null,void(e.feature=null);switch(t.type){case M.OBJECT:if(null!=t.graphic){const i=t.graphic,a=_(i);"on-the-ground"===a.mode&&(a.mode="relative-to-ground",a.offset=0),e.elevationInfo=new v(a),e.feature=i}else e.elevationInfo=null,e.feature=null;break;case M.TERRAIN:e.elevationInfo=new v({mode:"on-the-ground"}),e.feature=null;break;default:e.elevationInfo=null,e.feature=null}const i=t.mapPoint.clone();i.z=m(this.view,i,{mode:"absolute-height",offset:0},e.elevationInfo),e.position=i}_manipulatorClick(e,t){if("observer"===e.metadata.type||e.grabbing||e.dragging||t.button!==I.Right||this.analysis.targets.length<=1)return;const{target:i}=e.metadata;this.analysis.targets.remove(i),t.stopPropagation()}get testInfo(){}};function R(e){const t=e.position?.clone();return i=>(e.position=t,i)}function D(e,t){const{isValid:i,isTargetVisible:a}=t.computationResult;e.state=i?a?V.Custom1:V.Custom2:V.Custom3}function j(e){const{isValid:t,isTargetVisible:i}=e.computationResult;return{isValid:t,isTargetVisible:i}}e([c({constructOnly:!0})],P.prototype,"view",void 0),e([c({constructOnly:!0})],P.prototype,"analysis",void 0),e([c()],P.prototype,"_creationMode",void 0),e([c({readOnly:!0})],P.prototype,"state",null),e([c({readOnly:!0})],P.prototype,"cursor",null),e([c()],P.prototype,"removeIncompleteOnCancel",void 0),e([c({readOnly:!0})],P.prototype,"updating",null),e([c({constructOnly:!0})],P.prototype,"analysisViewData",void 0),e([c({readOnly:!0})],P.prototype,"_showTracker",null),e([c()],P.prototype,"_latestPointerMovePointerType",void 0),e([c()],P.prototype,"_shouldRenderTracker",null),e([c()],P.prototype,"_laserlineVisualElement",void 0),e([c()],P.prototype,"_grabbedManipulator",void 0),P=e([h("esri.views.3d.analysis.LineOfSight.LineOfSightTool")],P);const S=p();export{P as LineOfSightTool};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../Color.js";import i from"../../../../analysis/LineOfSightAnalysisObserver.js";import a from"../../../../analysis/LineOfSightAnalysisTarget.js";import n from"../../../../core/Handles.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{when as o,syncAndInitial as l,initial as u}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import{create as p,fromPoints as g}from"../../../../geometry/support/lineSegment.js";import{getGraphicEffectiveElevationInfo as _,getConvertedElevation as m}from"../../../../support/elevationInfoUtils.js";import v from"../../../../symbols/support/ElevationInfo.js";import{getLaserLineColors as b,laserLineConfiguration as y}from"./LineOfSightConfiguration.js";import{LineOfSightTargetManipulator as f,LineOfSightObserverManipulator as T}from"./LineOfSightManipulators.js";import{LineOfSightRayIntersector as L}from"./LineOfSightRayIntersector.js";import{LaserlineVisualElement as w}from"../../interactive/visualElements/LaserlineVisualElement.js";import{IntersectorType as M}from"../../webgl-engine/lib/IntersectorInterfaces.js";import"../../../input/ViewEvents.js";import{AnalysisToolBase as C}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as k}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as V}from"../../../interactive/interfaces.js";import{createScreenPointFromEvent as H}from"../../../support/screenUtils.js";import{MouseButton as I}from"../../../input/IViewEvents.js";var O;!function(e){e.Ready="ready",e.Creating="creating",e.Created="created"}(O||(O={}));let P=class extends C{constructor(e){super(e),this._creationMode=!1,this.removeIncompleteOnCancel=!1,this.analysisViewData=null,this._latestPointerMovePointerType=null,this._laserlineVisualElement=null,this._grabbedManipulator=null,this._analysisHandles=new n,this._updatingHandles=new d,this._manipulatorHandles=new n,this._targetTrackerManipulator=null}initialize(){this._intersector=new L({view:this.view}),this.addHandles(o((()=>this.state===O.Created),(()=>this.finishToolCreation()),l)),this._observerManipulator=this._createObserverManipulator(),this._createLaserLine(),this.addHandles([this._updatingHandles.add((()=>this.analysisViewData?.elevationAlignedObserver),(e=>this._onObserverLocationChange(e)),u),this._updatingHandles.add((()=>b(this.view.effectiveTheme)),(({glowColor:e,innerColor:t,globalAlpha:i})=>this._updateLaserLineStyle(e,t,i)),u),this._updatingHandles.add((()=>this._laserLineRendererDependencies()),(e=>this._updateLaserLineRenderer(e))),this._connectComputations(),this._updatingHandles.addWhen((()=>!this._shouldRenderTracker),(()=>this._clearCursorTracker()),u),this._updatingHandles.add((()=>({active:this.active,hasGrabbedManipulators:this.hasGrabbedManipulators})),(({active:e,hasGrabbedManipulators:t})=>{this._creationMode=!!e&&(this._creationMode||!t)}),u)])}destroy(){this._updatingHandles=s(this._updatingHandles),this._manipulatorHandles=s(this._manipulatorHandles),this._analysisHandles=s(this._analysisHandles),this._observerManipulator=null,this._clearCursorTracker(),this._removeLaserLine(),this._intersector=null,this._set("analysis",null)}get state(){return this.active?!this.hasGrabbedManipulators||this._creationMode?O.Creating:O.Created:null!=this.analysis.observer?.position?O.Created:O.Ready}get cursor(){return this.active&&this._showTracker?"crosshair":null}get updating(){return null!=this.analysisViewData&&this.analysisViewData.updating||this._updatingHandles.updating}get _showTracker(){return this.active&&"mouse"===this._latestPointerMovePointerType}get _shouldRenderTracker(){return this._showTracker&&null!=this.analysis.observer?.position&&!this.hasGrabbedManipulators}continue(){this.view.activeTool=this}stop(){this.view.activeTool=null}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickHandler(e)}onShow(){}onHide(){}onDeactivate(){this._clearCursorTracker()}_connectComputations(){return this._updatingHandles.addOnCollectionChange((()=>this.analysisViewData.computations),(e=>this._onComputationsCollectionChange(e)),{initial:!0,final:!0})}_onComputationsCollectionChange({added:e,removed:t}){for(const i of t)this._disconnectComputation(i);for(const i of e)this._connectComputation(i)}_connectComputation(e){if(this.destroyed)return void r.getLogger(this).warn("Attempting to connect an analysis to a destroyed LineOfSight tool. Ignoring.");const t=this._analysisHandles;if(t.has(e))return;const i=this._createTargetManipulator(e.target);null==this._targetTrackerManipulator&&i.metadata.target===this.analysisViewData.cursorTarget&&(this._targetTrackerManipulator=i,this._targetTrackerManipulator.available=!1,this._targetTrackerManipulator.interactive=!1,this._updateLaserLineRenderer()),t.add([this._updatingHandles.add((()=>j(e)),(()=>D(i,e)),u),this._updatingHandles.add((()=>e.elevationAlignedTargetLocation),(e=>this._onTargetLocationChange(e,i)),u)],e)}_disconnectComputation(e){if(this.destroyed)return void r.getLogger(this).warn("Attempting to disconnect an analysis from a destroyed LineOfSight tool. Ignoring.");this._analysisHandles.remove(e);const t=this._getTargetManipulator(e.target);null!=t&&(this.manipulators.remove(t),this._manipulatorHandles.remove(t),null!=this._targetTrackerManipulator&&this._targetTrackerManipulator===t&&(this._targetTrackerManipulator=null))}_clearCursorTracker(){this.analysisViewData.cursorTarget=s(this.analysisViewData.cursorTarget)}_createTargetManipulator(e){const t={target:e,type:"target"},i=new f(this.view,t);return this._manipulatorHandles.add([this._createTargetManipulatorDragPipeline(i),i.events.on("grab-changed",(e=>this._manipulatorGrabChanged(i,e))),i.events.on("immediate-click",(e=>this._manipulatorClick(i,e)))],i),this.manipulators.add(i),null!=e.position?i.elevationAlignedLocation=e.position:i.available=!1,i}_getTargetManipulator(e){let t=null;return this.manipulators.forEach((i=>{const a=i.manipulator;null==t&&"target"===a.metadata.type&&a.metadata.target===e&&(t=a)})),t}_createObserverManipulator(){const e=new T(this.view,{type:"observer",intersection:null});return this._manipulatorHandles.add([this._createObserverManipulatorDragPipeline(e),e.events.on("grab-changed",(t=>this._manipulatorGrabChanged(e,t))),e.events.on("immediate-click",(t=>this._manipulatorClick(e,t)))],e),this.manipulators.add(e),e}_screenToIntersection(){return e=>{const t=this._intersector.getScreenPointIntersection(e.screenEnd);return null==t?null:{...e,intersection:t}}}_createTargetManipulatorDragPipeline(e){return k(e,((t,i,a)=>{i.next(this._screenToIntersection()).next(this._updateTargetDragStep(e)).next((()=>this._updateLaserLineRenderer())),a.next(R(e.metadata.target)).next((()=>this._updateLaserLineRenderer()))}))}_createObserverManipulatorDragPipeline(e){return k(e,((e,t,i)=>{t.next(this._screenToIntersection()).next(this._updateObserverDragStep()).next((()=>this._updateLaserLineRenderer())),i.next(this._cancelObserverDragStep()).next((()=>this._updateLaserLineRenderer()))}))}_updateObserverDragStep(){return e=>(null!=e.intersection.mapPoint?(null==this.analysis.observer&&(this.analysis.observer=new i),this._updateFromIntersection(this.analysis.observer,e.intersection)):this.analysis.observer=null,e)}_cancelObserverDragStep(){const e=null!=this.analysis.observer?.position?this.analysis.observer.clone():null;return t=>(this.analysis.observer=e,t)}_updateTargetDragStep(e){return t=>{this._updateFromIntersection(e.metadata.target,t.intersection);const i=t.intersection.mapPoint;return null!=i&&(e.elevationAlignedLocation=i),t}}_manipulatorGrabChanged(e,t){switch(t.action){case"start":this._grabbedManipulator=e;break;case"end":this._grabbedManipulator===e&&(this._grabbedManipulator=null)}}_laserLineRendererDependencies(){return{laserlineVisualElement:this._laserlineVisualElement,grabbedManipulator:this._grabbedManipulator,shouldRenderTracker:this._shouldRenderTracker,observerPosition:null!=this.analysis.observer?this.analysis.observer.position:null,visible:this.visible}}_updateLaserLineRenderer(e=this._laserLineRendererDependencies()){const{laserlineVisualElement:t,grabbedManipulator:i,shouldRenderTracker:a,observerPosition:n,visible:r}=e;if(null==t)return;const s=null!=i?i:a&&null!=n?this._targetTrackerManipulator:null;null!=s&&r?(t.visible=!0,t.heightManifoldTarget=s.renderLocation,s!==this._observerManipulator?t.lineVerticalPlaneSegment=g(this._observerManipulator.renderLocation,s.renderLocation,S):t.lineVerticalPlaneSegment=null):(t.visible=!1,t.heightManifoldTarget=null,t.lineVerticalPlaneSegment=null)}_createLaserLine(){this._removeLaserLine();const{glowWidth:e,innerWidth:t}=y;this._laserlineVisualElement=new w({view:this.view,attached:!0,visible:this.visible,style:{glowWidth:e,innerWidth:t},isDecoration:!0})}_removeLaserLine(){null!=this._laserlineVisualElement&&(this._laserlineVisualElement.destroy(),this._laserlineVisualElement=null)}_updateLaserLineStyle(e,i,a){const n=this._laserlineVisualElement;if(null==n)return;const r=n.style;n.style={...r,glowColor:t.toUnitRGB(e),innerColor:t.toUnitRGB(i),globalAlpha:a}}_onObserverLocationChange(e){null!=e?(this._observerManipulator.metadata.intersection=null,this._observerManipulator.available=!0,this._observerManipulator.elevationAlignedLocation=e):this._observerManipulator.available=!1}_onTargetLocationChange(e,t){null!=e?(t.elevationAlignedLocation=e,t!==this._targetTrackerManipulator&&(t.available=!0)):t.available=!1}_addPointFromClickEvent(e){const t=this._intersector.getScreenPointIntersection(e);if(null!=t?.mapPoint)if(null!=this.analysis.observer?.position){this._clearCursorTracker();const e=new a;this._updateFromIntersection(e,t),this.analysis.targets.add(e)}else{const e=new i;this._updateFromIntersection(e,t),this.analysis.observer=e}}_clickHandler(e){this.active&&e.button!==I.Right&&(this._addPointFromClickEvent(H(e)),e.stopPropagation())}_doubleClickHandler(e){this.active&&e.button!==I.Right&&(this.stop(),e.stopPropagation())}_pointerMoveHandler(e){if(this.hasGrabbedManipulators)return;if(this._latestPointerMovePointerType=e.pointerType,this._updateLaserLineRenderer(),!this._showTracker||null==this.analysis.observer?.position)return;const t=H(e),i=this._intersector.getScreenPointIntersection(t);null!=i?.mapPoint&&(null==this.analysisViewData.cursorTarget&&(this.analysisViewData.cursorTarget=new a),this._updateFromIntersection(this.analysisViewData.cursorTarget,i),this._updateLaserLineRenderer())}_updateFromIntersection(e,t){if(null==t.mapPoint)return e.position=null,e.elevationInfo=null,void(e.feature=null);switch(t.type){case M.OBJECT:if(null!=t.graphic){const i=t.graphic,a=_(i);"on-the-ground"===a.mode&&(a.mode="relative-to-ground",a.offset=0),e.elevationInfo=new v(a),e.feature=i}else e.elevationInfo=null,e.feature=null;break;case M.TERRAIN:e.elevationInfo=new v({mode:"on-the-ground"}),e.feature=null;break;default:e.elevationInfo=null,e.feature=null}const i=t.mapPoint.clone();i.z=m(this.view,i,{mode:"absolute-height",offset:0},e.elevationInfo),e.position=i}_manipulatorClick(e,t){if("observer"===e.metadata.type||e.grabbing||e.dragging||t.button!==I.Right||this.analysis.targets.length<=1)return;const{target:i}=e.metadata;this.analysis.targets.remove(i),t.stopPropagation()}get testInfo(){}};function R(e){const t=e.position?.clone();return i=>(e.position=t,i)}function D(e,t){const{isValid:i,isTargetVisible:a}=t.computationResult;e.state=i?a?V.Custom1:V.Custom2:V.Custom3}function j(e){const{isValid:t,isTargetVisible:i}=e.computationResult;return{isValid:t,isTargetVisible:i}}e([c({constructOnly:!0})],P.prototype,"view",void 0),e([c({constructOnly:!0})],P.prototype,"analysis",void 0),e([c()],P.prototype,"_creationMode",void 0),e([c({readOnly:!0})],P.prototype,"state",null),e([c({readOnly:!0})],P.prototype,"cursor",null),e([c()],P.prototype,"removeIncompleteOnCancel",void 0),e([c({readOnly:!0})],P.prototype,"updating",null),e([c({constructOnly:!0})],P.prototype,"analysisViewData",void 0),e([c({readOnly:!0})],P.prototype,"_showTracker",null),e([c()],P.prototype,"_latestPointerMovePointerType",void 0),e([c()],P.prototype,"_shouldRenderTracker",null),e([c()],P.prototype,"_laserlineVisualElement",void 0),e([c()],P.prototype,"_grabbedManipulator",void 0),P=e([h("esri.views.3d.analysis.LineOfSight.LineOfSightTool")],P);const S=p();export{P as LineOfSightTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,syncAndInitial as l}from"../../../../core/reactiveUtils.js";import{addFrameTask as o}from"../../../../core/scheduling.js";import{createScreenPoint as h,screenPointObjectToArray as p}from"../../../../core/screenUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as d,fromScaling as _,multiply as v}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as P,l as y,c as m,h as w,g,t as f,n as M,i as D}from"../../../../chunks/vec32.js";import{clone as V,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as T,ZEROS as E}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{d as k,a as S,n as x,f as j}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as C,intersectRay as R,getNormal as O}from"../../../../geometry/support/plane.js";import{create as I}from"../../../../geometry/support/ray.js";import{sv3d as z,sm4d as G,sv2d as L}from"../../../../geometry/support/vectorStacks.js";import{getRotateHeadingTexture as U,getTiltRotateTexture as A}from"../images/Factory.js";import{ResizeManipulator as K}from"./ResizeManipulator.js";import{RotateManipulator as B}from"./RotateManipulator.js";import{getOutlineColor as F,planeColor as N}from"./settings.js";import{ShiftManipulator as q,OffsetMode as Z}from"./ShiftManipulator.js";import{pointerMoveTimerMs as W,planePreviewOutlineWidth as J,forceVerticalModifier as Q,forceHorizontalModifier as X,previewFadeDotThreshold as Y,previewFadeDurationSeconds as $,initialDepthOffsetFrac as tt}from"./sliceToolConfig.js";import{createGridVisualElement as et,createOutlineVisualElement as it,planeToShape as at,createRotatePlane as st,RotationAxis as nt,resizePlane as rt,calculatePlaneHalfSize as lt,SliceOrientation as ot,createPlane as ht,DidPointerMoveRecentlyFlag as pt,calculateBoundedPlaneTranslateRotate as ut,updateShiftRestartHandle as ct,updateRotateHeadingHandle as dt,updateRotateTiltHandle as _t,updateResizeHandle as vt,createShiftPlane as Pt}from"./sliceToolUtils.js";import{calculateInputRotationTransform as yt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as mt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreenNormalized as wt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as gt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as ft}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as Mt}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Dt}from"../../../support/screenUtils.js";var Vt;let bt=class extends gt{static{Vt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this._layersMode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=W,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=k(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=h(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=Mt(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&S(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new q(this.view,Z.CENTER_ON_ARROW);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",(i=>{this._onShiftGrab(i),t(e)}))]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new B(this.view,((t,e)=>U(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i})));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",(e=>{this._onRotateHeadingGrab(e),t(a)}))]);const s=new B(this.view,((t,e)=>A(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i})));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",(e=>{this._onRotateTiltGrab(e),t(s)}))]),this.resizeManipulators=this._resizeHandles.map(((e,i)=>{const a=new K(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",(e=>{this._onResizeGrab(e,i),t(a)}))]),a})),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=et(this.view),this._previewPlaneOutlineVisualElement=it(this.view),this._previewPlaneOutlineVisualElement.width=J,this.addHandles(n((()=>[this.analysisViewData.plane,this.analysis.tiltEnabled]),(()=>this._updateManipulators()),r));const o=n((()=>this.state),(t=>{"sliced"===t&&(this.finishToolCreation(),this.stop())}),l);this.addHandles([o,n((()=>this.view.state.camera),(()=>this._onCameraChange()))])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this._isPlacingSlicePlane||"exclude"===this.layersMode?"crosshair":null!=this._creatingPointerId?"grabbing":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get layersMode(){return this._layersMode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _isPlacingSlicePlane(){return!this.inputState&&!this.analysisViewData.plane&&this.active}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}stop(){this.active&&(this.view.activeTool=null)}enterExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._layersMode="exclude",this.active||(this.view.activeTool=this))}exitExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._layersMode="none",this.stop())}onDeactivate(){this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!kt(t))return;this._isPlacingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!kt(t))return;this._onClickPlacePlane(t)&&t.stopPropagation();break;case"click":if(!kt(t))return;this._onClickExcludeLayer(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Dt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Dt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Dt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),S(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if("exclude"===this.layersMode)return!1;if(this._isPlacingSlicePlane){const i=Dt(t),a=k();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if("pointer-drag"===t.type){const e=wt(this.view.state.camera,i,xt);this.inputState=Et(e,t.pointerId,a.origin,a)}return S(a,this._startPlane),this.analysis.shape=at(a,this.view,this.view.spatialReference,new e),!0}}return!1}_onClickExcludeLayer(t){return!("exclude"!==this.layersMode||!this.created)&&(this.view.hitTest(Dt(t)).then((t=>{if(t.results.length){const e=t.results[0],i="graphic"===e?.type&&e.graphic;if(i){const t=i.sourceLayer||i.layer;t&&this.analysis.excludedLayers.push(t)}}else t.ground.layer?this.analysis.excludedLayers.push(t.ground.layer):this.analysis.excludeGroundSurface=!0})),this.exitExcludeLayerMode(),!0)}_onKeyDown(t){return(t.key===Q||t.key===X)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Q&&t.key!==X||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=wt(this.view.state.camera,t.screenPoint,xt);S(this.analysisViewData.plane,this._startPlane),this.inputState=Et(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return ft(t,((t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,k()):null;e.next(mt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(P(x(this.analysisViewData.plane),e.ray.direction)/y(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=m(z.get(),this._startPlane.origin),i=m(z.get(),x(this._startPlane));w(i,i,-t.depth),g(i,i,e);const a=j(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,k());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=st(this.analysisViewData.plane,this.view.renderCoordsHelper,nt.HEADING,C()),i=wt(this.view.state.camera,t.screenPoint,xt),a=b();R(e,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return ft(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,k()):null;e.next(mt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=st(this.analysisViewData.plane,this.view.renderCoordsHelper,nt.TILT,C()),i=wt(this.view.state.camera,t.screenPoint,xt),a=b();R(e,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return ft(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?S(this.analysisViewData.plane,k()):null;e.next(mt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=O(t.rotatePlane),a=yt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=d(G.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=f(z.get(),this._startPlane.basis1,e),a=f(z.get(),this._startPlane.basis2,e),s=j(this.analysisViewData.plane.origin,i,a,k());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=wt(this.view.state.camera,t.screenPoint,xt),a=z.get();R(this.analysisViewData.plane.plane,i,a)&&(S(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:V(a)})}_createResizeDragPipeline(t){return ft(t,((t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=S(this.analysisViewData.plane,k());e.next(mt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next((()=>{this._updateBoundedPlane(s)}))}))}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,S(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(!this.analysisViewData.plane&&this.active){const a=null!=i?i:k();if(i=null!=i?S(i,St):null,this._pickPlane(t,!0,e,a)){const t=Y;let e=!1;null!=i&&(e=P(O(i.plane),O(a.plane))<t||P(M(z.get(),i.basis1),M(z.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=o({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*$),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=p(t,L.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=z.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(z.get()),l=this.view.state.camera;P(r,l.viewForward)>0&&w(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*tt,p=w(z.get(),r,h);g(p,p,n);const u=this.analysis.tiltEnabled?ot.TILTED:ot.HORIZONTAL_OR_VERTICAL,c=i[Q]?ot.VERTICAL:i[X]?ot.HORIZONTAL:u;return ht(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=pt,this.rotateHeadingManipulator.state|=pt,this.rotateTiltManipulator.state|=pt,this._prevPointerMoveTimeout=this._clock.setTimeout((()=>{this.shiftManipulator.state&=~pt,this.rotateHeadingManipulator.state&=~pt,this.rotateTiltManipulator.state&=~pt}),this._pointerMoveTimerMs)}_updateManipulators(){if(Vt.disableEngineLayers)return;let t,e=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=!1;else{if(null==this._previewPlane)return this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!1,void(this._previewPlaneGridVisualElement.visible=!1);t=this._previewPlane,e=!0}const i=ut(t,G.get());e?(this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.attached=!0,this._previewPlaneGridVisualElement.attached=!0,this._previewPlaneOutlineVisualElement.visible=!0,this._previewPlaneGridVisualElement.visible=!0):(this.shiftManipulator.available=!0,this.rotateHeadingManipulator.available=!0,this.rotateTiltManipulator.available=this.analysis.tiltEnabled,this.resizeManipulators.forEach((t=>t.available=!0)),ct(this.shiftManipulator,i,t,this.view.state.camera),dt(this.rotateHeadingManipulator,i,t,this.view.renderCoordsHelper),_t(this.rotateTiltManipulator,i,t),this.resizeManipulators.forEach(((e,a)=>vt(e,this._resizeHandles[a],i,t))),this._previewPlaneOutlineVisualElement.visible=!1,this._previewPlaneGridVisualElement.visible=!1);const a=D(z.get(),y(t.basis1),y(t.basis2),1),s=_(G.get(),a),n=v(s,i,s);this._previewPlaneOutlineVisualElement.transform=n,this._previewPlaneGridVisualElement.transform=n,this._updateMaterials()}_updateMaterials(){const t=F(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=T(N);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=E}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach((t=>{t.interactive=!0}));this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach((e=>{e.interactive=e===t}))}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};t([u()],bt.prototype,"_clock",void 0),t([u({constructOnly:!0})],bt.prototype,"view",void 0),t([u()],bt.prototype,"analysisViewData",void 0),t([u({readOnly:!0})],bt.prototype,"state",null),t([u({readOnly:!0})],bt.prototype,"cursor",null),t([u()],bt.prototype,"analysis",null),t([u()],bt.prototype,"removeIncompleteOnCancel",void 0),t([u()],bt.prototype,"_layersMode",void 0),t([u()],bt.prototype,"layersMode",null),t([u({value:null})],bt.prototype,"inputState",null),t([u()],bt.prototype,"_isPlacingSlicePlane",null),t([u()],bt.prototype,"_creatingPointerId",null),bt=Vt=t([c("esri.views.3d.analysis.Slice.SliceTool")],bt);const Tt=bt;function Et(t,e,i,a){const s=Pt(i,x(a),t.direction,C()),n=b();return R(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function kt(t){return"mouse"!==t.pointerType||0===t.button}const St=k(),xt=I();export{Tt as default};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,when as r,sync as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as _,fromScaling as v,multiply as P}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as y,l as m,c as w,h as g,g as f,t as M,n as D,i as V}from"../../../../chunks/vec32.js";import{clone as b,create as T}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as E,ZEROS as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{d as S,a as x,n as j,f as H}from"../../../../chunks/boundedPlane.js";import{signedDistance as C,create as R,intersectRay as O,getNormal as I}from"../../../../geometry/support/plane.js";import{create as z}from"../../../../geometry/support/ray.js";import{sv3d as G,sm4d as L,sv2d as U}from"../../../../geometry/support/vectorStacks.js";import{getRotateHeadingTexture as A,getTiltRotateTexture as K}from"../images/Factory.js";import{ResizeManipulator as B}from"./ResizeManipulator.js";import{RotateManipulator as F}from"./RotateManipulator.js";import{getOutlineColor as N,planeColor as q}from"./settings.js";import{ShiftManipulator as Z,OffsetMode as W}from"./ShiftManipulator.js";import{pointerMoveTimerMs as J,planePreviewOutlineWidth as Q,forceVerticalModifier as X,forceHorizontalModifier as Y,previewFadeDotThreshold as $,previewFadeDurationSeconds as tt,initialDepthOffsetFrac as et}from"./sliceToolConfig.js";import{createGridVisualElement as it,createOutlineVisualElement as at,planeToShape as st,createRotatePlane as nt,RotationAxis as rt,resizePlane as lt,calculatePlaneHalfSize as ot,SliceOrientation as ht,createPlane as pt,DidPointerMoveRecentlyFlag as ut,calculateBoundedPlaneTranslateRotate as ct,updateShiftRestartHandle as dt,updateRotateHeadingHandle as _t,updateRotateTiltHandle as vt,updateResizeHandle as Pt,createShiftPlane as yt}from"./sliceToolUtils.js";import{calculateInputRotationTransform as mt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as wt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreenNormalized as gt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as ft}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as Mt}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as Dt}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Vt}from"../../../support/screenUtils.js";var bt;let Tt=class extends ft{static{bt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this._layersMode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=J,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=S(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=Dt(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&x(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new Z(this.view,W.CENTER_ON_ARROW);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",(i=>{this._onShiftGrab(i),t(e)}))]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new F(this.view,((t,e)=>A(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i})));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",(e=>{this._onRotateHeadingGrab(e),t(a)}))]);const s=new F(this.view,((t,e)=>K(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i})));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",(e=>{this._onRotateTiltGrab(e),t(s)}))]),this.resizeManipulators=this._resizeHandles.map(((e,i)=>{const a=new B(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",(e=>{this._onResizeGrab(e,i),t(a)}))]),a})),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=it(this.view),this._previewPlaneOutlineVisualElement=at(this.view),this._previewPlaneOutlineVisualElement.width=Q,this.addHandles(n((()=>[this.analysisViewData.plane,this.analysis.tiltEnabled]),(()=>this._updateManipulators()),l)),this.addHandles([r((()=>"sliced"===this.state),(()=>{this.finishToolCreation(),this.stop()}),o),n((()=>this.view.state.camera),(()=>this._onCameraChange()))])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this._isPlacingSlicePlane||"exclude"===this.layersMode?"crosshair":null!=this._creatingPointerId?"grabbing":null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get layersMode(){return this._layersMode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _isPlacingSlicePlane(){return!this.inputState&&!this.analysisViewData.plane&&this.active}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}stop(){this.active&&(this.view.activeTool=null)}enterExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._layersMode="exclude",this.active||(this.view.activeTool=this))}exitExcludeLayerMode(){null!=this.analysisViewData.plane&&(this._layersMode="none",this.stop())}onDeactivate(){this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!St(t))return;this._isPlacingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!St(t))return;this._onClickPlacePlane(t)&&t.stopPropagation();break;case"click":if(!St(t))return;this._onClickExcludeLayer(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Vt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Vt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Vt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),x(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if("exclude"===this.layersMode)return!1;if(this._isPlacingSlicePlane){const i=Vt(t),a=S();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if("pointer-drag"===t.type){const e=gt(this.view.state.camera,i,jt);this.inputState=kt(e,t.pointerId,a.origin,a)}return x(a,this._startPlane),this.analysis.shape=st(a,this.view,this.view.spatialReference,new e),!0}}return!1}_onClickExcludeLayer(t){return!("exclude"!==this.layersMode||!this.created)&&(this.view.hitTest(Vt(t)).then((t=>{if(t.results.length){const e=t.results[0],i="graphic"===e?.type&&e.graphic;if(i){const t=i.sourceLayer||i.layer;t&&this.analysis.excludedLayers.push(t)}}else t.ground.layer?this.analysis.excludedLayers.push(t.ground.layer):this.analysis.excludeGroundSurface=!0})),this.exitExcludeLayerMode(),!0)}_onKeyDown(t){return(t.key===X||t.key===Y)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==X&&t.key!==Y||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=gt(this.view.state.camera,t.screenPoint,jt);x(this.analysisViewData.plane,this._startPlane),this.inputState=kt(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return Mt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?x(this.analysisViewData.plane,S()):null;e.next(wt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(y(j(this.analysisViewData.plane),e.ray.direction)/m(e.ray.direction)))/i,1),s=-C(this._startPlane.plane,e.renderEnd),n=-C(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(G.get(),this._startPlane.origin),i=w(G.get(),j(this._startPlane));g(i,i,-t.depth),f(i,i,e);const a=H(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,S());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,rt.HEADING,R()),i=gt(this.view.state.camera,t.screenPoint,jt),a=T();O(e,i,a)&&(x(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return Mt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?x(this.analysisViewData.plane,S()):null;e.next(wt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,rt.TILT,R()),i=gt(this.view.state.camera,t.screenPoint,jt),a=T();O(e,i,a)&&(x(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return Mt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?x(this.analysisViewData.plane,S()):null;e.next(wt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next((()=>{null!=s&&this._updateBoundedPlane(s)}))}))}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=I(t.rotatePlane),a=mt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(L.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(G.get(),this._startPlane.basis1,e),a=M(G.get(),this._startPlane.basis2,e),s=H(this.analysisViewData.plane.origin,i,a,S());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=gt(this.view.state.camera,t.screenPoint,jt),a=G.get();O(this.analysisViewData.plane.plane,i,a)&&(x(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:b(a)})}_createResizeDragPipeline(t){return Mt(t,((t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=x(this.analysisViewData.plane,S());e.next(wt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next((()=>{this._updateBoundedPlane(s)}))}))}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=lt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,x(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(!this.analysisViewData.plane&&this.active){const a=null!=i?i:S();if(i=null!=i?x(i,xt):null,this._pickPlane(t,!0,e,a)){const t=$;let e=!1;null!=i&&(e=y(I(i.plane),I(a.plane))<t||y(D(G.get(),i.basis1),D(G.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*tt),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,U.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=G.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(G.get()),l=this.view.state.camera;y(r,l.viewForward)>0&&g(r,r,-1);const o=ot(n,l),h=(e?1:-1)*o*et,p=g(G.get(),r,h);f(p,p,n);const u=this.analysis.tiltEnabled?ht.TILTED:ht.HORIZONTAL_OR_VERTICAL,c=i[X]?ht.VERTICAL:i[Y]?ht.HORIZONTAL:u;return pt(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ut,this.rotateHeadingManipulator.state|=ut,this.rotateTiltManipulator.state|=ut,this._prevPointerMoveTimeout=this._clock.setTimeout((()=>{this.shiftManipulator.state&=~ut,this.rotateHeadingManipulator.state&=~ut,this.rotateTiltManipulator.state&=~ut}),this._pointerMoveTimerMs)}_updateManipulators(){if(bt.disableEngineLayers)return;let t,e=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=!1;else{if(null==this._previewPlane)return this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.visible=!1,void(this._previewPlaneGridVisualElement.visible=!1);t=this._previewPlane,e=!0}const i=ct(t,L.get());e?(this.shiftManipulator.available=!1,this.rotateHeadingManipulator.available=!1,this.rotateTiltManipulator.available=!1,this.resizeManipulators.forEach((t=>t.available=!1)),this._previewPlaneOutlineVisualElement.attached=!0,this._previewPlaneGridVisualElement.attached=!0,this._previewPlaneOutlineVisualElement.visible=!0,this._previewPlaneGridVisualElement.visible=!0):(this.shiftManipulator.available=!0,this.rotateHeadingManipulator.available=!0,this.rotateTiltManipulator.available=this.analysis.tiltEnabled,this.resizeManipulators.forEach((t=>t.available=!0)),dt(this.shiftManipulator,i,t,this.view.state.camera),_t(this.rotateHeadingManipulator,i,t,this.view.renderCoordsHelper),vt(this.rotateTiltManipulator,i,t),this.resizeManipulators.forEach(((e,a)=>Pt(e,this._resizeHandles[a],i,t))),this._previewPlaneOutlineVisualElement.visible=!1,this._previewPlaneGridVisualElement.visible=!1);const a=V(G.get(),m(t.basis1),m(t.basis2),1),s=v(L.get(),a),n=P(s,i,s);this._previewPlaneOutlineVisualElement.transform=n,this._previewPlaneGridVisualElement.transform=n,this._updateMaterials()}_updateMaterials(){const t=N(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=E(q);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=k}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach((t=>{t.interactive=!0}));this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach((e=>{e.interactive=e===t}))}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};t([c()],Tt.prototype,"_clock",void 0),t([c({constructOnly:!0})],Tt.prototype,"view",void 0),t([c()],Tt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],Tt.prototype,"state",null),t([c({readOnly:!0})],Tt.prototype,"cursor",null),t([c()],Tt.prototype,"analysis",null),t([c()],Tt.prototype,"removeIncompleteOnCancel",void 0),t([c()],Tt.prototype,"_layersMode",void 0),t([c()],Tt.prototype,"layersMode",null),t([c({value:null})],Tt.prototype,"inputState",null),t([c()],Tt.prototype,"_isPlacingSlicePlane",null),t([c()],Tt.prototype,"_creatingPointerId",null),Tt=bt=t([d("esri.views.3d.analysis.Slice.SliceTool")],Tt);const Et=Tt;function kt(t,e,i,a){const s=yt(i,j(a),t.direction,R()),n=T();return O(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function St(t){return"mouse"!==t.pointerType||0===t.button}const xt=S(),jt=z();export{Et as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{memoize as i}from"../../../../../core/memoize.js";import{watch as n,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as o}from"../../../../../core/support/UpdatingHandles.js";import l from"../../../../../geometry/Point.js";import{clonePoint as u}from"../../../../../layers/graphics/hydratedFeatures.js";import{isPrimaryPointerAction as p}from"../../../analysis/support/measurementUtils.js";import{SnappingVisualizer3D as c}from"../../SnappingVisualizer3D.js";import{SurfaceType as d,screenToMap3D as h,hideManipulatorWhileDragging as m}from"../../editingTools/dragEventPipeline3D.js";import{DirectLineMeasurement3DView as g}from"./DirectLineMeasurement3DView.js";import{getElevationAtPoint as v}from"../../../support/ElevationProvider.js";import{AnalysisToolBase as y}from"../../../../interactive/AnalysisToolBase.js";import{createCoordinateHelper as P}from"../../../../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as f,resetProperties as w}from"../../../../interactive/dragEventPipeline.js";import{EditGeometry as _}from"../../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as S}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as M}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as j}from"../../../../interactive/snapping/SnappingManagerPool.js";import{setupSnappingToggleHandles as b}from"../../../../interactive/snapping/snappingUtils.js";import{createScreenPointFromEvent as L}from"../../../../support/screenUtils.js";let x=class extends y{constructor(t){super(t),this._updatingHandles=new o,this._emulatedDrag=null,this.lineState="initial",this.startPointSurfaceLocation=null,this.endPointSurfaceLocation=null,this.cursorPointSurfaceLocation=null,this.startManipulator=null,this.endManipulator=null,this.cursorManipulator=null,this._getSnappingContext=i((t=>new M({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new S(new _("point",P(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new c})))}initialize(){const{view:t,analysis:e,analysisViewData:i,visible:s}=this;this.measurementView=new g({toolState:this,view:t,analysis:e,analysisViewData:i,visible:s});const r=j(t);this._snappingManagerResult=r,this.addHandles(r);const{start:o,end:p,cursor:c}=this.measurementView.createManipulators(),d=(t,e,i)=>f(t,((t,n,a,s)=>{const r=m(t),o=this._snappingManager,p=this._getSnappingContext(s),c=this._updatingHandles,{lineState:d}=this;a=a.next(r).next(w(this,[i,e])).next((i=>{if("cursorPoint"!==e){const i=this.analysis[e];null!=i&&(t.location=i)}return i}));const g=h(this.view),v=t=>{const n=g(t);return n||"drawing"!==this.lineState&&"initial"!==this.lineState||(this[e]=null,this[i]=null),n};let y=n.next(r).next(v);if("touch"!==s||"editing"===d){const{snappingStep:t,cancelSnapping:e}=D({snappingManager:o,snappingContext:p,updatingHandles:c});a=a.next(e),y=y.next(...t)}y.next((t=>"start"!==t.action?t:null)).next((n=>{const a=u(n.mapEnd,new l);this[e]=a,t.location=a,this[i]=this._surfaceLocation(a,n.surfaceType)}))})),v=t=>t.events.on("grab-changed",(()=>{const t=o.grabbing||p.grabbing;this.lineState=t?"editing":"measured"}));this.addHandles([d(o,"startPoint","startPointSurfaceLocation"),d(p,"endPoint","endPointSurfaceLocation"),d(c,"cursorPoint","cursorPointSurfaceLocation"),v(o),v(p)]),this.manipulators.add(o),this.manipulators.add(p),this.manipulators.add(c),this.startManipulator=o,this.endManipulator=p,this.cursorManipulator=c,this.addHandles(n((()=>this.state),(t=>{"measured"===t&&this.finishToolCreation()}),a)),b(this)}destroy(){this._updatingHandles=e(this._updatingHandles),this.measurementView=e(this.measurementView)}get _snappingManager(){return this._snappingManagerResult.snappingManager}get state(){const{analysis:t}=this;if(null==t.startPoint&&null==t.endPoint)return"ready";const{lineState:e}=this;return this.validMeasurement&&"editing"!==e&&"drawing"!==e?"measured":"measuring"}get cursor(){return"ready"===this.state||"drawing"===this.lineState?"crosshair":null}get startPoint(){return this.analysis.startPoint}set startPoint(t){this.analysis.startPoint=t}get endPoint(){return this.analysis.endPoint}set endPoint(t){this.analysis.endPoint=t}get cursorPoint(){return this.measurementView.cursorPoint}set cursorPoint(t){this.measurementView.cursorPoint=t}get snappingOptions(){return this._snappingManager.options}get validMeasurement(){return null!=this.analysis.startPoint&&null!=this.analysis.endPoint}get updating(){return this._updatingHandles.updating||this._snappingManager.updating}onShow(){this.measurementView.show(),this._updateManipulatorAvailability()}onHide(){this.measurementView.hide()}onDeactivate(){this._emulatedDrag?.cancel(),this._emulatedDrag=null}onInputEvent(t){switch(t.type){case"immediate-click":this._handleImmediateClick(t);break;case"pointer-move":this._handlePointerMove(t)}this._updateManipulatorAvailability()}_handlePointerMove(t){if(!this.active||this.view.navigating)return;const{pointerType:e}=t;if("mouse"!==e)return;const i=L(t),{lineState:n,cursorManipulator:a,endManipulator:s}=this;let r=!1;null==this.cursorPoint&&(this._emulatedDrag?.cancel(),this._emulatedDrag=V(a,e,i),r=!0),"initial"===n&&(this._emulatedDrag?.update(i),r=!0),"drawing"===n&&(s.events.emit("drag",{action:"update",start:i,screenPoint:i}),r=!0),r&&t.stopPropagation()}_handleImmediateClick(t){if(!this.active)return;if(!p(t))return;const e=L(t),{pointerType:i}=t,{cursorManipulator:n,startManipulator:a,endManipulator:s,lineState:r}=this;let o=!1;switch(null==this.cursorPoint&&(this._emulatedDrag?.cancel(),this._emulatedDrag=V(n,i,e)),r){case"initial":if(this._emulatedDrag?.update(e),null!=this.cursorPoint){this._emulatedDrag?.end(e),this._emulatedDrag=null;const{cursorPoint:t}=this;this.startPoint=t,this.startPointSurfaceLocation=this.cursorPointSurfaceLocation,a.location=t,a.interactive=!1,s.interactive=!1,this.lineState="drawing",this._emulatedDrag=V(s,i,e),o=!0}break;case"drawing":this._emulatedDrag?.update(e),null!=this.endPoint&&(this._emulatedDrag?.end(e),this._emulatedDrag=null,a.interactive=!0,s.interactive=!0,this.lineState="measured",o=!0)}o&&t.stopPropagation()}_surfaceLocation(t,e){return e===d.GROUND?"on-the-surface":(t.z??0)>=this._getElevation(t)?"above-the-surface":"below-the-surface"}_updateManipulatorAvailability(){this.startManipulator.available=null!=this.analysis.startPoint,this.endManipulator.available=null!=this.analysis.endPoint}_getElevation(t){return this.view.basemapTerrain.ready?v(this.view.elevationProvider,t)??0:0}get test(){}};function V(t,e,i){return t.events.emit("drag",{action:"start",pointerType:e,start:i,screenPoint:i}),{update:e=>t.events.emit("drag",{action:"update",start:e,screenPoint:e}),end:e=>t.events.emit("drag",{action:"end",start:e,screenPoint:e}),cancel:()=>t.events.emit("drag",{action:"cancel"})}}t([s({readOnly:!0})],x.prototype,"state",null),t([s()],x.prototype,"lineState",void 0),t([s({readOnly:!0})],x.prototype,"cursor",null),t([s()],x.prototype,"startPoint",null),t([s()],x.prototype,"endPoint",null),t([s()],x.prototype,"cursorPoint",null),t([s({constructOnly:!0})],x.prototype,"analysis",void 0),t([s({constructOnly:!0})],x.prototype,"analysisViewData",void 0),t([s()],x.prototype,"measurementView",void 0),t([s({constructOnly:!0})],x.prototype,"view",void 0),t([s({readOnly:!0})],x.prototype,"validMeasurement",null),t([s({value:null})],x.prototype,"startPointSurfaceLocation",void 0),t([s({value:null})],x.prototype,"endPointSurfaceLocation",void 0),t([s({value:null})],x.prototype,"cursorPointSurfaceLocation",void 0),t([s()],x.prototype,"updating",null),x=t([r("esri.views.3d.interactive.measurementTools.directLineMeasurement3D.DirectLineMeasurement3DTool")],x);const H=x;export{H as default};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import{destroyMaybe as e}from"../../../../../core/maybe.js";import{memoize as i}from"../../../../../core/memoize.js";import{when as n,syncAndInitial as a,watch as s}from"../../../../../core/reactiveUtils.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as l}from"../../../../../core/support/UpdatingHandles.js";import u from"../../../../../geometry/Point.js";import{clonePoint as p}from"../../../../../layers/graphics/hydratedFeatures.js";import{isPrimaryPointerAction as c}from"../../../analysis/support/measurementUtils.js";import{SnappingVisualizer3D as d}from"../../SnappingVisualizer3D.js";import{SurfaceType as m,screenToMap3D as h,hideManipulatorWhileDragging as g}from"../../editingTools/dragEventPipeline3D.js";import{DirectLineMeasurement3DView as v}from"./DirectLineMeasurement3DView.js";import{getElevationAtPoint as P}from"../../../support/ElevationProvider.js";import{AnalysisToolBase as y}from"../../../../interactive/AnalysisToolBase.js";import{createCoordinateHelper as f}from"../../../../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as w,resetProperties as S}from"../../../../interactive/dragEventPipeline.js";import{EditGeometry as _}from"../../../../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as M}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as D}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as j}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{acquire as b}from"../../../../interactive/snapping/SnappingManagerPool.js";import{setupSnappingToggleHandles as L}from"../../../../interactive/snapping/snappingUtils.js";import{createScreenPointFromEvent as x}from"../../../../support/screenUtils.js";let V=class extends y{constructor(t){super(t),this._updatingHandles=new l,this._emulatedDrag=null,this.lineState="initial",this.removeIncompleteOnCancel=!1,this.startPointSurfaceLocation=null,this.endPointSurfaceLocation=null,this.cursorPointSurfaceLocation=null,this.startManipulator=null,this.endManipulator=null,this.cursorManipulator=null,this._getSnappingContext=i((t=>new D({elevationInfo:{mode:"absolute-height",offset:0},pointer:t,editGeometryOperations:new M(new _("point",f(!0,!1,this.view.spatialReference)),this.view.state.viewingMode),visualizer:new d})))}initialize(){const{view:t,analysis:e,analysisViewData:i,visible:r}=this;this.measurementView=new v({toolState:this,view:t,analysis:e,analysisViewData:i,visible:r});const o=b(t);this._snappingManagerResult=o,this.addHandles(o);const{start:l,end:c,cursor:d}=this.measurementView.createManipulators(),m=(t,e,i)=>w(t,((t,n,a,s)=>{const r=g(t),o=this._snappingManager,l=this._getSnappingContext(s),c=this._updatingHandles,{lineState:d}=this;a=a.next(r).next(S(this,[i,e])).next((i=>{if("cursorPoint"!==e){const i=this.analysis[e];null!=i&&(t.location=i)}return i}));const m=h(this.view),v=t=>{const n=m(t);return n||"drawing"!==this.lineState&&"initial"!==this.lineState||(this[e]=null,this[i]=null),n};let P=n.next(r).next(v);if("touch"!==s||"editing"===d){const{snappingStep:t,cancelSnapping:e}=j({snappingManager:o,snappingContext:l,updatingHandles:c});a=a.next(e),P=P.next(...t)}P.next((t=>"start"!==t.action?t:null)).next((n=>{const a=p(n.mapEnd,new u);this[e]=a,t.location=a,this[i]=this._surfaceLocation(a,n.surfaceType)}))})),P=t=>t.events.on("grab-changed",(()=>{const t=l.grabbing||c.grabbing;this.lineState=t?"editing":"measured"}));this.addHandles([m(l,"startPoint","startPointSurfaceLocation"),m(c,"endPoint","endPointSurfaceLocation"),m(d,"cursorPoint","cursorPointSurfaceLocation"),P(l),P(c)]),this.manipulators.add(l),this.manipulators.add(c),this.manipulators.add(d),this.startManipulator=l,this.endManipulator=c,this.cursorManipulator=d,this.addHandles([n((()=>"measured"===this.state),(()=>{this.finishToolCreation(),this.active&&(this.view.activeTool=null)}),a),s((()=>({startPointAvailable:null!=this.startPoint,endPointAvailable:null!=this.endPoint})),(({startPointAvailable:t,endPointAvailable:e})=>{this.startManipulator.available=t,this.endManipulator.available=e}),a)]),L(this)}destroy(){this._updatingHandles=e(this._updatingHandles),this.measurementView=e(this.measurementView)}get _snappingManager(){return this._snappingManagerResult.snappingManager}get state(){const{analysis:t}=this;if(null==t.startPoint&&null==t.endPoint)return"ready";const{lineState:e}=this;return this.validMeasurement&&"editing"!==e&&"drawing"!==e?"measured":"measuring"}get cursor(){return this.active&&("ready"===this.state||"drawing"===this.lineState)?"crosshair":null}get startPoint(){return this.analysis.startPoint}set startPoint(t){this.analysis.startPoint=t}get endPoint(){return this.analysis.endPoint}set endPoint(t){this.analysis.endPoint=t}get cursorPoint(){return this.measurementView.cursorPoint}set cursorPoint(t){this.measurementView.cursorPoint=t}get snappingOptions(){return this._snappingManager.options}get validMeasurement(){return null!=this.analysis.startPoint&&null!=this.analysis.endPoint}get updating(){return this._updatingHandles.updating||this._snappingManager.updating}resetCreated(){super.resetCreated(),this.lineState="initial",this.measurementView.cursorPoint=null}onShow(){this.measurementView.show()}onHide(){this.measurementView.hide()}onDeactivate(){this._emulatedDrag?.cancel(),this._emulatedDrag=null}onInputEvent(t){switch(t.type){case"immediate-click":this._handleImmediateClick(t);break;case"pointer-move":this._handlePointerMove(t)}}_handlePointerMove(t){if(!this.active||this.view.navigating)return;const{pointerType:e}=t;if("mouse"!==e)return;const i=x(t),{lineState:n,cursorManipulator:a,endManipulator:s}=this;let r=!1;null==this.cursorPoint&&(this._emulatedDrag?.cancel(),this._emulatedDrag=C(a,e,i),r=!0),"initial"===n&&(this._emulatedDrag?.update(i),r=!0),"drawing"===n&&(s.events.emit("drag",{action:"update",start:i,screenPoint:i}),r=!0),r&&t.stopPropagation()}_handleImmediateClick(t){if(!this.active)return;if(!c(t))return;const e=x(t),{pointerType:i}=t,{cursorManipulator:n,startManipulator:a,endManipulator:s,lineState:r}=this;let o=!1;switch(null==this.cursorPoint&&(this._emulatedDrag?.cancel(),this._emulatedDrag=C(n,i,e)),r){case"initial":if(this._emulatedDrag?.update(e),null!=this.cursorPoint){this._emulatedDrag?.end(e),this._emulatedDrag=null;const{cursorPoint:t}=this;this.startPoint=t,this.startPointSurfaceLocation=this.cursorPointSurfaceLocation,a.location=t,a.interactive=!1,s.interactive=!1,this.lineState="drawing",this._emulatedDrag=C(s,i,e),o=!0}break;case"drawing":this._emulatedDrag?.update(e),null!=this.endPoint&&(this._emulatedDrag?.end(e),this._emulatedDrag=null,a.interactive=!0,s.interactive=!0,this.lineState="measured",o=!0)}o&&t.stopPropagation()}_surfaceLocation(t,e){return e===m.GROUND?"on-the-surface":(t.z??0)>=this._getElevation(t)?"above-the-surface":"below-the-surface"}_getElevation(t){return this.view.basemapTerrain.ready?P(this.view.elevationProvider,t)??0:0}get test(){}};function C(t,e,i){return t.events.emit("drag",{action:"start",pointerType:e,start:i,screenPoint:i}),{update:e=>t.events.emit("drag",{action:"update",start:e,screenPoint:e}),end:e=>t.events.emit("drag",{action:"end",start:e,screenPoint:e}),cancel:()=>t.events.emit("drag",{action:"cancel"})}}t([r({readOnly:!0})],V.prototype,"state",null),t([r()],V.prototype,"lineState",void 0),t([r({readOnly:!0})],V.prototype,"cursor",null),t([r()],V.prototype,"startPoint",null),t([r()],V.prototype,"endPoint",null),t([r()],V.prototype,"cursorPoint",null),t([r({constructOnly:!0})],V.prototype,"analysis",void 0),t([r({constructOnly:!0})],V.prototype,"analysisViewData",void 0),t([r()],V.prototype,"measurementView",void 0),t([r()],V.prototype,"removeIncompleteOnCancel",void 0),t([r({constructOnly:!0})],V.prototype,"view",void 0),t([r({readOnly:!0})],V.prototype,"validMeasurement",null),t([r({value:null})],V.prototype,"startPointSurfaceLocation",void 0),t([r({value:null})],V.prototype,"endPointSurfaceLocation",void 0),t([r({value:null})],V.prototype,"cursorPointSurfaceLocation",void 0),t([r()],V.prototype,"updating",null),V=t([o("esri.views.3d.interactive.measurementTools.directLineMeasurement3D.DirectLineMeasurement3DTool")],V);const H=V;export{H as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import{schedule as n}from"../../../core/scheduling.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{g as b,q as y}from"../../../chunks/vec32.js";import{fromArray as w,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec2f as M,BufferViewVec4f as P,BufferViewVec4u8 as O,BufferViewVec4u16 as U,BufferViewVec3f as E,BufferViewVec3u8 as I,BufferViewVec3u16 as V,BufferViewInt16 as A,BufferViewUint32 as H,BufferViewUint16 as S}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as R,wasmFailedToInit as F,Lyr3DLightingModel as D,Lyr3DUvWrapMode as L,Lyr3DImageFormat as k,Lyr3DPixelFormat as B,Lyr3DVtxAtrbSemantic as N,Lyr3DType as G}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getElevationOffsetInMeters as z}from"../../../support/elevationInfoUtils.js";import{ViewingMode as W}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as $}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as q}from"./interfaces.js";import{LayerView3D as J}from"./LayerView3D.js";import{addLayerViewToWasm as K,removeLayerViewFromWasm as X,getLyr3DWasm as Q}from"./Lyr3DWasm.js";import{LayerElevationProvider as Y}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as ee,faceCullingConversion as te,wrapModeConversion as re,lyr3DTypeToByteSize as se}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ie}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as oe}from"../support/ElevationRange.js";import{Obb as ne,compute as ae}from"../support/orientedBoundingBox.js";import{ObjectParameters as le}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ce,createVertexBufferLayout as me}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as de}from"../webgl-engine/collections/Component/Transform.js";import{ComponentParameterSummary as he}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ue}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateType as pe}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as fe}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ge}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as be,AlphaDiscardMode as ye,TextureEncodingMimeType as we}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as _e}from"../webgl-engine/lib/Normals.js";import{Texture as ve}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as je,writeBufferVec2 as Ce}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Te from"../../layers/LayerView.js";import{isInEffectiveScaleRange as Me}from"../../support/layerViewUtils.js";import{alphaCutoff as Pe}from"../../../webscene/support/AlphaCutoff.js";var Oe;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(Oe||(Oe={}));class Ue{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}get usedMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get cachedMemory(){return this.usedMemory}}function Ee(e){return Math.round(e/1048.576)/1e3}let Ie=class extends(J(Te)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=q.WithoutRasterImage,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(Oe.Error),this._dbg(Oe.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=K(this).then((e=>{this._intersectionHandler=new ie(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Y({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this.addHandles([i((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))]),this._suspendedHandle=i((()=>this.suspended),(e=>this._wasm?.setEnabled(this,!e)),o)})).catch((e=>{if(X(this),this._wasmLayerId=-1,e===R)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(Oe.VerboseAPI,"Tiles3DLayerView3D destroy() called"),X(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=s(this._memCache),this._updatingHandles=s(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=n((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?be.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,z(e))}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get _wasm(){return Q(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.usedMemory)})),e}get unloadedMemory(){return 0}get cachedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.usedMemory)})),e}get visibleAtCurrentScale(){return Me(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,r=0,s=0,i=0,o=0;return this._lyrHandleToObjects.forEach((n=>{n.isVisible?(e+=n.texMemoryUsage,t+=n.vboMemoryUsage,i++):(r+=n.texMemoryUsage,s+=n.vboMemoryUsage,o++)})),new $(this.usedMemory,i,o,Ee(t),Ee(e),Ee(s),Ee(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===W.Local){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 elevationOffset(){return z(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new oe(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;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 r=w(t.desc.origin),s=new Array,i=new Map,o=new Ue;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const n=this.view.basemapTerrain.spatialReference;let a,l;if("global"===this.view.viewingMode){const e=f();j(x,r,e,n),a=c(h(),e),l=m(h(),a)}else a=d,l=d;const P=f();u(P,P,r);const O=p(_(),P);let U=null;const E=_();if(t.desc.obb){const e=t.desc.obb.quaternion;U=new ne(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(Oe.VerboseAPI,JSON.stringify(e));if(null==Z[e.ptype]||null==t.data){this._dbg(Oe.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:D.Unlit,{positionView:u,positionAttr:p,normalsView:f,normalsAttr:g,colorAttr:w,texCoord0Attr:x,indicesView:j}=this.getBufferViews(e,t.data.buffer,a);if(null==p||null==u||null==j)continue;const P=new ce(null!=w,x?pe.Default:pe.None,null!=f,this._shadeNormals,this._applySSAO),I=p.data.length/p.size,V=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(Oe.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!V(x,"numTexcoord")||!V(w,"numColors")||!V(g,"normals"))continue;const A=me(P);if(null!=U?U=U.clone():(U=ae(p),b(E,U.center,r),U.center=E),a!==d)for(let t=0;t<u.count;t++)u.getVec(t,E),y(E,E,a),u.setVec(t,E);const H=A.createBuffer(p.data.length);if(je(xe.POSITION,p,null,null,H,0),null!=x){const e=H.getField(xe.UV0,M);Ce(x,e,0)}null!=w&&je(xe.COLOR,p,null,null,H,0),null!=g&&je(xe.NORMALCOMPRESSED,g,null,null,H,0);const S=new Uint32Array([0,j.typedBuffer.length]),R={vertices:{data:H.buffer,count:H.byteLength/A.stride,layoutParameters:P},positionData:{positions:u.typedBuffer,indices:j.typedBuffer},indices:j.typedBuffer,componentOffsets:S};o.cpuMemoryUsage+=u.count,o.cpuMemoryUsage+=j.count;const F=this.view.renderSpatialReference,L=_(),k=[1,1,1];C(O,F,k,n)||this._dbg(Oe.Error,"Unsupported coordinate system for IM overlay"),T(O,F,L,n);const B=this._collection.createObject(new le(v(L[0],L[1],k[0],k[1]),new de(O,l),U,R));m&&this._collection.updateMaterial(B,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===D.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,i),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveBaseColor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,i),e.emissionTexture=this._getTexture(m.emissiveTex,t,i),e.occlusionTexture=this._getTexture(m.occlusionTex,t,i),e.normalTexture=this._getTexture(m.normalTex,t,i)),e.objectOpacity=0,e.alphaDiscardMode=ye.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const n=Promise.all(r);s.push(n),n.then((()=>{e.alphaDiscardMode=ee[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?te[m.faceCulling]:be.Back,this._initialCullFace.set(B,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=he.All,e.textureAlphaCutoff=m.alphaCutoff??Pe,e.alphaDiscardMode=ee[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=fe(this.view.spatialReference)})),o.components.push(B),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(B)}if(await Promise.all(s),i.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o),{memUsageBytes:o.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let s=0;s<r;++s){const r=e[s],i=t[s];if(!i)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=i,o.components.forEach((e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let s=0;s<r;++s){const r=e[s],i=t[s];if(i)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=i,o.components.forEach((e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o))}}}_getTexture(e,t,r){let s=null;if(e&&t.desc?.images&&t.data?.buffer){const i=t.desc.images[e?.imageId];if(s=r.get(i),!s&&i){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=!!i.mipCount||o>1,a=re[e.wrapMode??L.None];let l=i.alpha?4:3;const c=new Uint8Array(t.data.buffer,i.data.byteOffset,i.data.byteCount);let m=null,d=null,h=null;switch(i.format){case k.Raw:i.pixelFormat===B.R8?(m=c,l=1,d=""):i.pixelFormat===B.Rgb8?(m=c,l=3,d=""):i.pixelFormat===B.Rgba8&&(m=c,l=4,d="");break;case k.Dxt1:m=c,l=3,d=we.DDS_ENCODING;break;case k.Dxt5:m=c,l=4,d=we.DDS_ENCODING;break;case k.Basis:m=c,l=3,d=we.KTX2_ENCODING;break;case k.Png:d="image/png",h=document.createElement("img");break;case k.Jpeg:d="image/jpeg",h=document.createElement("img");break;case k.Etc2:d="image/ktx",h=document.createElement("img");break;case k.Astc:this._dbg(Oe.Error,"Astc texture not supported");break;case k.Pvrtc:this._dbg(Oe.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(s=new ve(m,{mipmap:n,maxAnisotropy:o,encoding:d,wrap:a,components:l,noUnpackFlip:!0,width:i.mip0Width,height:i.mip0Height}),this._stage.add(s),r.set(i,s))}}return s?new ue(this.view.stage.renderView.textures,s.id):null}getBufferViews(e,t,r){let s,i,o,n,a,l,c,m=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/se[u.type],b=[...Array(g).keys()].map((e=>e));try{switch(c.sem){case N.Position:3!==u.ncomp||u.type!==G.F32?this._dbg(Oe.Error,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new E(t,u.byteOffset,p,f),i=new ge(s.typedBuffer,b,3));break;case N.Normal:if(3!==u.ncomp||u.type!==G.F32)this._dbg(Oe.Error,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new E(t,u.byteOffset,p,f),s=_e(e.typedBuffer,r);a=new A(s),l=new ge(a.typedBuffer,b,2)}break;case N.TexCoord:2!==u.ncomp||u.type!==G.F32?this._dbg(Oe.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new ge(new M(t,u.byteOffset,p,f).typedBuffer,b,2));break;case N.Color:4===u.ncomp?(u.type===G.F32&&(m=new P(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new O(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new U(t,u.byteOffset,p,f))):3===u.ncomp&&(u.type===G.F32&&(m=new E(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new I(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new V(t,u.byteOffset,p,f))),null==m?this._dbg(Oe.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ge(m.typedBuffer,b,u.ncomp);break;case N.FeatureIndex:break;default:this._dbg(Oe.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(d){this._dbg(Oe.VerboseAPI,"Error Creating buffer ("+d+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,s=void 0,i=r.byteOffset+r.byteCount;switch(e.index.view.type){case G.U16:c=new S(t,r.byteOffset,s,i);break;case G.U32:c=new H(t,r.byteOffset,s,i);break;case G.U8:default:this._dbg(Oe.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new S(t)}else{const t=new Uint32Array(e);c=new H(t)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:i,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_onRemoveFromCache(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===Oe.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],Ie.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([a()],Ie.prototype,"layer",void 0),e([a({readOnly:!0})],Ie.prototype,"visibleAtCurrentScale",null),e([a()],Ie.prototype,"elevationOffset",null),Ie=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ie);const Ve=Ie;export{Ve as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import has from"../../../core/has.js";import r from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{initial as s,watch as o}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{g as b,q as y}from"../../../chunks/vec32.js";import{fromArray as w,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as j}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec2f as T,BufferViewVec4f as P,BufferViewVec4u8 as O,BufferViewVec4u16 as U,BufferViewVec3f as E,BufferViewVec3u8 as H,BufferViewVec3u16 as I,BufferViewInt16 as V,BufferViewUint32 as A,BufferViewUint16 as S}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as R,wasmFailedToInit as F,Lyr3DLightingModel as D,Lyr3DUvWrapMode as L,Lyr3DImageFormat as k,Lyr3DPixelFormat as B,Lyr3DVtxAtrbSemantic as N,Lyr3DType as G}from"../../../layers/ILyr3DWasmPerSceneView.js";import z from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as W}from"../../../support/elevationInfoUtils.js";import{ViewingMode as $}from"../../ViewingMode.js";import{toWasmModification as q}from"./I3SMeshWorkerHandle.js";import{IntegratedMesh3DTilesViewPerformanceInfo as J}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as K}from"./interfaces.js";import{LayerView3D as X}from"./LayerView3D.js";import{addLayerViewToWasm as Q,removeLayerViewFromWasm as Y,getLyr3DWasm as Z}from"./Lyr3DWasm.js";import{LayerElevationProvider as ee}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as te,alphaModeConversion as re,faceCullingConversion as ie,wrapModeConversion as se,lyr3DTypeToByteSize as oe}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ae}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ne}from"../support/ElevationRange.js";import{Obb as le,compute as ce}from"../support/orientedBoundingBox.js";import{ObjectParameters as me}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as de,createVertexBufferLayout as he}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ue}from"../webgl-engine/collections/Component/Transform.js";import{ComponentParameterSummary as pe}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as fe}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateType as ge}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as be}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ye}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as we,AlphaDiscardMode as _e,TextureEncodingMimeType as ve}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as xe}from"../webgl-engine/lib/Normals.js";import{Texture as je}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as Ce}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as Me,writeBufferVec2 as Te}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Pe from"../../layers/LayerView.js";import{isInEffectiveScaleRange as Oe}from"../../support/layerViewUtils.js";import{alphaCutoff as Ue}from"../../../webscene/support/AlphaCutoff.js";var Ee;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(Ee||(Ee={}));class He{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}get usedMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get cachedMemory(){return this.usedMemory}}function Ie(e){return Math.round(e/1048.576)/1e3}let Ve=class extends(X(Pe)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=K.WithoutRasterImage,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}get hasModifications(){return this._modifications&&this._modifications.length>0}initialize(){if(this._dbgFlags.add(Ee.Error),this._dbg(Ee.VerboseAPI,"Tiles3DLayerView3D initialize() called"),this._updatingHandles.add((()=>this.layer.modifications),(()=>this._loadModifications()),s),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=Q(this).then((e=>{this._intersectionHandler=new ae(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),s),this._elevationProvider=new ee({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this.addHandles([o((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))]),this._suspendedHandle=o((()=>this.suspended),(e=>this._wasm?.setEnabled(this,!e)),s)})).catch((e=>{if(Y(this),this._wasmLayerId=-1,e===R)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(Ee.VerboseAPI,"Tiles3DLayerView3D destroy() called"),Y(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_modificationsChanged(){const e=this.layer.spatialReference,t=q(null,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?we.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,W(e))}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get _wasm(){return Z(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.usedMemory)})),e}get unloadedMemory(){return 0}get cachedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.usedMemory)})),e}get visibleAtCurrentScale(){return Oe(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,r=0,i=0,s=0,o=0;return this._lyrHandleToObjects.forEach((a=>{a.isVisible?(e+=a.texMemoryUsage,t+=a.vboMemoryUsage,s++):(r+=a.texMemoryUsage,i+=a.vboMemoryUsage,o++)})),new J(this.usedMemory,s,o,Ie(t),Ie(e),Ie(i),Ie(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===$.Local){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 elevationOffset(){return W(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ne(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;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 r=w(t.desc.origin),i=new Array,s=new Map,o=new He;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const a=this.view.basemapTerrain.spatialReference;let n,l;if("global"===this.view.viewingMode){const e=f();j(x,r,e,a),n=c(h(),e),l=m(h(),n)}else n=d,l=d;const P=f();u(P,P,r);const O=p(_(),P);let U=null;const E=_();if(t.desc.obb){const e=t.desc.obb.quaternion;U=new le(t.desc.obb.center,t.desc.obb.halfSize,g(e[0],e[1],e[2],e[3]))}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];this._dbg(Ee.VerboseAPI,JSON.stringify(e));if(null==te[e.ptype]||null==t.data){this._dbg(Ee.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:D.Unlit,{positionView:u,positionAttr:p,normalsView:f,normalsAttr:g,colorAttr:w,texCoord0Attr:x,indicesView:j}=this.getBufferViews(e,t.data.buffer,n);if(null==p||null==u||null==j)continue;const P=new de(null!=w,x?ge.Default:ge.None,null!=f,this._shadeNormals,this._applySSAO),H=p.data.length/p.size,I=(e,t)=>!e||e.data.length/e.size===H||(this._dbg(Ee.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!I(x,"numTexcoord")||!I(w,"numColors")||!I(g,"normals"))continue;const V=he(P);if(null!=U?U=U.clone():(U=ce(p),b(E,U.center,r),U.center=E),n!==d)for(let t=0;t<u.count;t++)u.getVec(t,E),y(E,E,n),u.setVec(t,E);const A=V.createBuffer(p.data.length);if(Me(Ce.POSITION,p,null,null,A,0),null!=x){const e=A.getField(Ce.UV0,T);Te(x,e,0)}null!=w&&Me(Ce.COLOR,p,null,null,A,0),null!=g&&Me(Ce.NORMALCOMPRESSED,g,null,null,A,0);const S=new Uint32Array([0,j.typedBuffer.length]),R={vertices:{data:A.buffer,count:A.byteLength/V.stride,layoutParameters:P},positionData:{positions:u.typedBuffer,indices:j.typedBuffer},indices:j.typedBuffer,componentOffsets:S};o.cpuMemoryUsage+=u.count,o.cpuMemoryUsage+=j.count;const F=this.view.renderSpatialReference,L=_(),k=[1,1,1];C(O,F,k,a)||this._dbg(Ee.Error,"Unsupported coordinate system for IM overlay"),M(O,F,L,a);const B=this._collection.createObject(new me(v(L[0],L[1],k[0],k[1]),new ue(O,l),U,R));m&&this._collection.updateMaterial(B,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===D.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,s),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveBaseColor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,s),e.emissionTexture=this._getTexture(m.emissiveTex,t,s),e.occlusionTexture=this._getTexture(m.occlusionTex,t,s),e.normalTexture=this._getTexture(m.normalTex,t,s)),e.objectOpacity=0,e.alphaDiscardMode=_e.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const a=Promise.all(r);i.push(a),a.then((()=>{e.alphaDiscardMode=re[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?ie[m.faceCulling]:we.Back,this._initialCullFace.set(B,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=pe.All,e.textureAlphaCutoff=m.alphaCutoff??Ue,e.alphaDiscardMode=re[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=be(this.view.spatialReference)})),o.components.push(B),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(B)}if(await Promise.all(i),s.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o),{memUsageBytes:o.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let i=0;i<r;++i){const r=e[i],s=t[i];if(!s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let i=0;i<r;++i){const r=e[i],s=t[i];if(s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o))}}}_getTexture(e,t,r){let i=null;if(e&&t.desc?.images&&t.data?.buffer){const s=t.desc.images[e?.imageId];if(i=r.get(s),!i&&s){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=!!s.mipCount||o>1,n=se[e.wrapMode??L.None];let l=s.alpha?4:3;const c=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,d=null,h=null;switch(s.format){case k.Raw:s.pixelFormat===B.R8?(m=c,l=1,d=""):s.pixelFormat===B.Rgb8?(m=c,l=3,d=""):s.pixelFormat===B.Rgba8&&(m=c,l=4,d="");break;case k.Dxt1:m=c,l=3,d=ve.DDS_ENCODING;break;case k.Dxt5:m=c,l=4,d=ve.DDS_ENCODING;break;case k.Basis:m=c,l=3,d=ve.KTX2_ENCODING;break;case k.Png:d="image/png",h=document.createElement("img");break;case k.Jpeg:d="image/jpeg",h=document.createElement("img");break;case k.Etc2:d="image/ktx",h=document.createElement("img");break;case k.Astc:this._dbg(Ee.Error,"Astc texture not supported");break;case k.Pvrtc:this._dbg(Ee.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(i=new je(m,{mipmap:a,maxAnisotropy:o,encoding:d,wrap:n,components:l,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height}),this._stage.add(i),r.set(s,i))}}return i?new fe(this.view.stage.renderView.textures,i.id):null}getBufferViews(e,t,r){let i,s,o,a,n,l,c,m=null;for(let h=0;h<e.atrbs.length;h++){const c=e.atrbs[h],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/oe[u.type],b=[...Array(g).keys()].map((e=>e));try{switch(c.sem){case N.Position:3!==u.ncomp||u.type!==G.F32?this._dbg(Ee.Error,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(i=new E(t,u.byteOffset,p,f),s=new ye(i.typedBuffer,b,3));break;case N.Normal:if(3!==u.ncomp||u.type!==G.F32)this._dbg(Ee.Error,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new E(t,u.byteOffset,p,f),i=xe(e.typedBuffer,r);n=new V(i),l=new ye(n.typedBuffer,b,2)}break;case N.TexCoord:2!==u.ncomp||u.type!==G.F32?this._dbg(Ee.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===a&&(a=new ye(new T(t,u.byteOffset,p,f).typedBuffer,b,2));break;case N.Color:4===u.ncomp?(u.type===G.F32&&(m=new P(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new O(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new U(t,u.byteOffset,p,f))):3===u.ncomp&&(u.type===G.F32&&(m=new E(t,u.byteOffset,p,f)),u.type===G.U8&&(m=new H(t,u.byteOffset,p,f)),u.type===G.U16&&(m=new I(t,u.byteOffset,p,f))),null==m?this._dbg(Ee.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new ye(m.typedBuffer,b,u.ncomp);break;case N.FeatureIndex:break;default:this._dbg(Ee.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(d){this._dbg(Ee.VerboseAPI,"Error Creating buffer ("+d+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,i=void 0,s=r.byteOffset+r.byteCount;switch(e.index.view.type){case G.U16:c=new S(t,r.byteOffset,i,s);break;case G.U32:c=new A(t,r.byteOffset,i,s);break;case G.U8:default:this._dbg(Ee.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==c&&null!=i){const e=i.count;if(e<65535){const t=new Uint16Array(e);c=new S(t)}else{const t=new Uint32Array(e);c=new A(t)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:i,positionAttr:s,colorAttr:o,texCoord0Attr:a,indicesView:c,normalsView:n,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.toArray()),s),"modifications")}_onRemoveFromCache(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===Ee.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([n({type:[z]})],Ve.prototype,"_modifications",void 0),e([n()],Ve.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([n()],Ve.prototype,"layer",void 0),e([n({readOnly:!0})],Ve.prototype,"visibleAtCurrentScale",null),e([n()],Ve.prototype,"elevationOffset",null),Ve=e([l("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Ve);const Ae=Ve;export{Ae as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{Lyr3DWasmWorkerOutputStatus as s}from"../../../layers/ILyr3DWasmPerSceneView.js";import{loadLyr3DWorkerWASM as t}from"../../../libs/lyr3d/Lyr3DModule.js";let e,n;async function r(t){if(await o(),t.inputs.length<1)return{result:{status:s.Failed,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[]},transferList:[]};const e={ptrs:[],sizes:[]};for(const s of t.inputs){const t=n._malloc(s.byteLength);new Uint8Array(n.HEAPU8.buffer,t,s.byteLength).set(new Uint8Array(s)),e.ptrs.push(t),e.sizes.push(s.byteLength)}const r=n.process(t.jobDescJson,e,t.isMissingResourceCase),i=r.status===s.Succeeded&&r.data,a=r.status===s.MissingInputs&&r.missingInputUrls.length>0;if(i){const s=r.data.slice();r.data=s}else a&&(r.jobDescJson=r.jobDescJson.slice(),r.originalInputs=t.inputs.slice());for(let s=0;s<e.ptrs.length;++s)n._free(e.ptrs[s]);const l=[];if(i)l.push(r.data.buffer);else if(a)for(const s of t.inputs)l.push(s);return{result:r,transferList:l}}function i(){n&&(n.uninitialize_lyr3d_worker_wasm(),n=null)}function o(){return n?Promise.resolve():(e||(e=t().then((s=>{n=s,n.initialize_lyr3d_worker_wasm(),e=null}))),e)}export{i as destroyWasm,o as initialize,r as process};
5
+ import{Lyr3DWasmWorkerOutputStatus as s}from"../../../layers/ILyr3DWasmPerSceneView.js";import{loadLyr3DWorkerWASM as t}from"../../../libs/lyr3d/Lyr3DModule.js";let e,r;async function n(t){await o();const e={status:s.Failed,error:"",jobDescJson:"",data:new Uint8Array(0),missingInputUrls:[]};if(t.inputs.length<1)return{result:e,transferList:[]};const n={ptrs:[],sizes:[]};for(const s of t.inputs){const t=r._malloc(s.byteLength);new Uint8Array(r.HEAPU8.buffer,t,s.byteLength).set(new Uint8Array(s)),n.ptrs.push(t),n.sizes.push(s.byteLength)}const i=r.process(t.jobDescJson,t.id,n,t.isMissingResourceCase);e.status=i.status,e.missingInputUrls=i.missingInputUrls.slice();const u=i.status===s.Succeeded&&i.data,l=e.status===s.MissingInputs&&e.missingInputUrls.length>0;e.jobDescJson=i.jobDescJson.slice(),e.error=i.error.slice(),u?e.data=i.data.slice():l&&(e.originalInputs=t.inputs.slice());for(let s=0;s<n.ptrs.length;++s)r._free(n.ptrs[s]);const a=[];if(u)a.push(e.data.buffer);else if(l)for(const s of t.inputs)a.push(s);return{result:e,transferList:a}}function i(){r&&(r.uninitialize_lyr3d_worker_wasm(),r=null)}function o(){return r?Promise.resolve():(e||(e=t().then((s=>{r=s,r.initialize_lyr3d_worker_wasm(),e=null}))),e)}export{i as destroyWasm,o as initialize,n as process};