@arcgis/core 4.25.0-next.20220721 → 4.25.0-next.20220722

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 (101) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{791220164501a791b2cd.js → 0896986aa60516f716f1.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{59e18862b803fdc41786.js → 0c145b87c24bf6c7d572.js} +1 -1
  4. package/assets/esri/core/workers/chunks/2504c43fac77ecd9ec2a.js +1 -0
  5. package/assets/esri/core/workers/chunks/{39de883f236e2a8d9024.js → 30d7796ee6f7e4a6a3e1.js} +2 -2
  6. package/assets/esri/core/workers/chunks/{39de883f236e2a8d9024.js.LICENSE.txt → 30d7796ee6f7e4a6a3e1.js.LICENSE.txt} +0 -0
  7. package/assets/esri/core/workers/chunks/3281656a9bd3627e41ff.js +1 -0
  8. package/assets/esri/core/workers/chunks/374ee2b2cad26f7ad572.js +1 -0
  9. package/assets/esri/core/workers/chunks/4d14be8c7e8adaa91876.js +1011 -0
  10. package/assets/esri/core/workers/chunks/{c22d7622294fe4aefe0b.js → 4f2d2cc71f5ff5ac2a60.js} +1 -1
  11. package/assets/esri/core/workers/chunks/8b1d5b7e9de73bc9da3a.js +1 -0
  12. package/assets/esri/core/workers/chunks/9dc4db35c387e11e9beb.js +1 -0
  13. package/assets/esri/core/workers/chunks/{42987dcfda665c860151.js → a23376df9696ebe5b5cd.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e4ad2cf5d6bded02e392.js → ed763fc352d0b55e5867.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a05f6afcf56245824853.js → f1fdb335c5f9ec8b27cb.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{9493a8e5d6001b6bf275.js → f59f82a43437a51c934c.js} +1 -1
  17. package/assets/esri/widgets/support/t9n/DatePicker.json +1 -1
  18. package/assets/esri/widgets/support/t9n/DatePicker_en.json +1 -1
  19. package/assets/esri/widgets/support/t9n/TimePicker.json +1 -1
  20. package/assets/esri/widgets/support/t9n/TimePicker_en.json +1 -1
  21. package/chunks/DefaultMaterial.glsl.js +42 -37
  22. package/chunks/RealisticTree.glsl.js +25 -25
  23. package/geometry/support/MeshMaterial.js +1 -1
  24. package/geometry/support/MeshMaterialMetallicRoughness.js +1 -1
  25. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  26. package/layers/mixins/ArcGISImageService.js +1 -1
  27. package/package.json +2 -2
  28. package/support/revision.js +1 -1
  29. package/views/2d/engine/webgl/util/Matcher.js +1 -1
  30. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  31. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  32. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  33. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  34. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  35. package/views/3d/environment/resources/MarsAtmosphereTexture.js +1 -1
  36. package/views/3d/environment/resources/SimpleAtmosphereTexture.js +1 -1
  37. package/views/3d/glTF/LoaderResult.js +1 -1
  38. package/views/3d/glTF/internal/Resource.js +1 -1
  39. package/views/3d/glTF/internal/TextureTransformUtils.js +5 -0
  40. package/views/3d/glTF/loader.js +1 -1
  41. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  42. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  43. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  44. package/views/3d/layers/I3SMeshView3D.js +1 -1
  45. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  46. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  47. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  48. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  49. package/views/3d/layers/SceneLayerView3D.js +1 -1
  50. package/views/3d/layers/TileLayerView3D.js +1 -1
  51. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  52. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  53. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  54. package/views/3d/layers/i3s/I3SElevationProvider.js +1 -1
  55. package/views/3d/layers/i3s/I3SQueryEngine.js +1 -1
  56. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  57. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  58. package/views/3d/support/CombinedElevationProvider.js +1 -1
  59. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  60. package/views/3d/terrain/OverlayManager.js +1 -1
  61. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  62. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  63. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +22 -22
  64. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +19 -10
  65. package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +15 -0
  66. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  67. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  68. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  69. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  70. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  71. package/views/input/recognizers/DoubleTapDrag.js +1 -1
  72. package/views/input/recognizers/Drag.js +1 -1
  73. package/views/input/recognizers/ImmediateDoubleClick.js +1 -1
  74. package/views/input/recognizers/PointerClickHoldAndDrag.js +1 -1
  75. package/views/input/recognizers/SingleAndDoubleClick.js +1 -1
  76. package/views/input/recognizers/VerticalTwoFingerDrag.js +1 -1
  77. package/views/input/recognizers/support.js +1 -1
  78. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  79. package/views/overlay/ViewOverlay.js +1 -1
  80. package/widgets/AreaMeasurement3D.js +1 -1
  81. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  82. package/widgets/BuildingExplorer.js +1 -1
  83. package/widgets/CoordinateConversion/support/Format.js +1 -1
  84. package/widgets/Daylight.js +1 -1
  85. package/widgets/DirectLineMeasurement3D.js +1 -1
  86. package/widgets/ElevationProfile.js +1 -1
  87. package/widgets/LineOfSight.js +1 -1
  88. package/widgets/ShadowCast.js +1 -1
  89. package/widgets/Slice.js +1 -1
  90. package/widgets/Slider.js +1 -1
  91. package/widgets/TimeSlider.js +1 -1
  92. package/widgets/Weather.js +1 -1
  93. package/widgets/Zoom.js +1 -1
  94. package/widgets/support/DatePicker.js +1 -1
  95. package/widgets/support/TimePicker.js +1 -1
  96. package/assets/esri/core/workers/chunks/0b269862733afe740a63.js +0 -1
  97. package/assets/esri/core/workers/chunks/290cd411d0d18b1d0efd.js +0 -1
  98. package/assets/esri/core/workers/chunks/85a2cf095f002b2c486f.js +0 -1
  99. package/assets/esri/core/workers/chunks/b312dd3027492007d75e.js +0 -1
  100. package/assets/esri/core/workers/chunks/bf348f6f52701fa6016e.js +0 -987
  101. package/assets/esri/core/workers/chunks/c79d4cb3332550fb0df5.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.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Logger.js";import{isNone as i,isSome as s,applySome as o,destroyMaybe as l}from"../../../core/maybe.js";import{initial as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as d}from"../../../core/sql/WhereClause.js";import h from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as p}from"../../../layers/support/floorFilterUtils.js";import c from"../../../rest/support/Query.js";import{I3SMeshView3D as y}from"./I3SMeshView3D.js";import{ForAllFeaturesReturnType as f,ForAllFeaturesVisibilityMode as g}from"./II3SMeshView3D.js";import{LayerView3D as m}from"./LayerView3D.js";import{createInteractiveEditSession as _,processAttributeEdits as F}from"./i3s/attributeEditing.js";import{createGetFeatureExtent as I}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as S}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as j}from"./i3s/I3SNode.js";import{I3SQueryEngine as v}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as w}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{getIndexCrs as b,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as q}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as A}from"./support/SceneLayerViewRequiredFields.js";import{updatingProgress as L}from"../support/updatingProperties.js";import D from"../../layers/SceneLayerView.js";import{TaskPriority as O}from"../../support/Scheduler.js";const R=Q();let U=class extends(y(C(q(m(D))))){constructor(){super(...arguments),this.type="scene-layer-3d",this.lodFactor=1,this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._interactiveEditingSessions=new Map,this._queryEngine=null}get filter(){return this._get("filter")}set filter(e){this._set("filter",S.checkSupport(e)?e:null)}get viewFilter(){const e=this.filter;if(i(e)&&i(this.layerFilter))return null;const t=this._get("viewFilter");return i(t)?new S({layerFilter:this.layerFilter,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),applyFilters:()=>this._applyFilters(!0),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError)}):(t.viewFilter=this.filter,t.layerFilter=this.layerFilter,this.notifyChange("viewFilter"),t)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=p(this);return s(e)?d.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds;return e.length?e.toArray().sort(((e,t)=>e-t)):null}get lodCrossfadeinDuration(){return this.view?.qualitySettings.sceneService.object.lodCrossfadeinDuration??0}get lodCrossfadeoutDuration(){return this.view?.qualitySettings.sceneService.object.lodCrossfadeoutDuration??0}get lodCrossfadeUncoveredDuration(){return this.view?.qualitySettings.sceneService.object.lodCrossfadeUncoveredDuration??0}initialize(){this._fieldsHelper=new A({layerView:this}),this.updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),n),this.updatingHandles.add((()=>this.layer.renderer),(e=>this.updatingHandles.addPromise(this._rendererChange(e))),n),this.updatingHandles.add((()=>[this.parsedDefinitionExpression,this.filter,this.layer.filter,this._floorFilterClause,this._excludeObjectIdsSorted,o(this.viewFilter,(e=>[e.parsedWhereClause,e.parsedGeometry,e.sortedObjectIds]))]),(()=>this._filterChange())),this.updatingHandles.add((()=>[this.filter,o(this.viewFilter,(e=>e.parsedGeometry))]),(()=>this._geometryFilterChange())),this.handles.add(this.layer.on("apply-edits",(e=>this.updatingHandles.addPromise(e.result)))),this.handles.add(this.layer.on("edits",(e=>this._handleEdits(e))))}destroy(){this._fieldsHelper=l(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&r.getLogger(this.declaredClass).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return s(this.filter)?this.filter.createQuery(e):new c(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const r of e.features)r.layer=t,r.sourceLayer=t;return e}))}queryObjectIds(e,t){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=I(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new v({layerView:this,priority:O.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new w({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo,getFeatureExtent:e}),toArray:()=>{const e=new Array;return this._forAllFeatures(((t,r,i)=>(e.push({id:t,index:r,meta:i}),f.CONTINUE)),null,g.ALL_IN_CLIPPING_AREA),e},forAllFeatures:(e,t)=>this._forAllFeatures(((t,r,i)=>e({id:t,index:r,meta:i})),t,g.ALL_IN_CLIPPING_AREA),getFeatureExtent:e,sourceSpatialReference:b(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof c){const{set:r,handle:i}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(r,e))),i}return super.highlight(e)}createInteractiveEditSession(e){return _(this._attributeEditingContext,e)}_createLayerGraphic(e){const r=new t(null,null,e);return r.layer=this.layer,r.sourceLayer=this.layer,r}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}getFilters(){const e=super.getFilters(),t=this._excludeObjectIdsSorted;return s(t)&&e.push((e=>x(t,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),s(this.viewFilter)&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}isUpdating(){return super.isUpdating()||this.layerFilterUpdating}_ensureQuery(e){return this._addDefinitionExpressionToQuery(i(e)?this.createQuery():c.from(e))}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),forEachNode:e=>this._forAllNodes((t=>s(t)?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo,attributeOverrides:this.attributeOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}_handleEdits(e){F(this._attributeEditingContext,e)}get hasGeometryFilter(){const e=this.viewFilter;return s(e)&&s(e.parsedGeometry)}computeNodeFiltering(e){const t=this.viewFilter;return i(t)||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?j.Unmodified:j.Culled}};e([a({aliasOf:"layer"})],U.prototype,"i3slayer",void 0),e([a(L)],U.prototype,"updatingProgress",void 0),e([a({type:h})],U.prototype,"filter",null),e([a({readOnly:!0})],U.prototype,"viewFilter",null),e([a(R.requiredFields)],U.prototype,"requiredFields",null),e([a(R.availableFields)],U.prototype,"availableFields",void 0),e([a()],U.prototype,"_fieldsHelper",void 0),e([a()],U.prototype,"_floorFilterClause",null),e([a()],U.prototype,"_excludeObjectIdsSorted",null),e([a({readOnly:!0,aliasOf:"view.qualitySettings.sceneService.object.lodFactor"})],U.prototype,"lodFactor",void 0),e([a({readOnly:!0,aliasOf:"_controller.updatingProgress"})],U.prototype,"updatingProgressValue",void 0),U=e([u("esri.views.3d.layers.SceneLayerView3D")],U);const V=U;export{V as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Logger.js";import{isNone as i,isSome as s,applySome as o,destroyMaybe as l}from"../../../core/maybe.js";import{initial as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as d}from"../../../core/sql/WhereClause.js";import h from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as p}from"../../../layers/support/floorFilterUtils.js";import c from"../../../rest/support/Query.js";import{I3SMeshView3D as y}from"./I3SMeshView3D.js";import{ForAllFeaturesReturnType as f,ForAllFeaturesVisibilityMode as g}from"./II3SMeshView3D.js";import{LayerView3D as m}from"./LayerView3D.js";import{createInteractiveEditSession as _,processAttributeEdits as F}from"./i3s/attributeEditing.js";import{createGetFeatureExtent as j}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as I}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as S}from"./i3s/I3SNode.js";import{I3SQueryEngine as b}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as w}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{getIndexCrs as v,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as A}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as q}from"./support/SceneLayerViewRequiredFields.js";import{updatingProgress as L}from"../support/updatingProperties.js";import D from"../../layers/SceneLayerView.js";import{TaskPriority as R}from"../../support/Scheduler.js";const U=Q();let V=class extends(y(C(A(m(D))))){constructor(){super(...arguments),this.type="scene-layer-3d",this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}get filter(){return this._get("filter")}set filter(e){this._set("filter",I.checkSupport(e)?e:null)}get viewFilter(){const e=this.filter;if(i(e)&&i(this.layerFilter))return null;const t=this._get("viewFilter");return i(t)?new I({layerFilter:this.layerFilter,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),applyFilters:()=>this._applyFilters(!0),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError)}):(t.viewFilter=this.filter,t.layerFilter=this.layerFilter,this.notifyChange("viewFilter"),t)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=p(this);return s(e)?d.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds;return e.length?e.toArray().sort(((e,t)=>e-t)):null}get _objectQualitySettings(){return this.view?.qualitySettings?.sceneService?.object}get lodFactor(){return this._objectQualitySettings?.lodFactor??1}get lodCrossfadeinDuration(){return this._objectQualitySettings.lodCrossfadeinDuration??0}get lodCrossfadeoutDuration(){return this._objectQualitySettings.lodCrossfadeoutDuration??0}get lodCrossfadeUncoveredDuration(){return this._objectQualitySettings.lodCrossfadeUncoveredDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}initialize(){this._fieldsHelper=new q({layerView:this}),this.updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),n),this.updatingHandles.add((()=>this.layer.renderer),(e=>this.updatingHandles.addPromise(this._rendererChange(e))),n),this.updatingHandles.add((()=>[this.parsedDefinitionExpression,this.filter,this.layer.filter,this._floorFilterClause,this._excludeObjectIdsSorted,o(this.viewFilter,(e=>[e.parsedWhereClause,e.parsedGeometry,e.sortedObjectIds]))]),(()=>this._filterChange())),this.updatingHandles.add((()=>[this.filter,o(this.viewFilter,(e=>e.parsedGeometry))]),(()=>this._geometryFilterChange())),this.handles.add(this.layer.on("apply-edits",(e=>this.updatingHandles.addPromise(e.result)))),this.handles.add(this.layer.on("edits",(e=>this._handleEdits(e))))}destroy(){this._fieldsHelper=l(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&r.getLogger(this.declaredClass).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return s(this.filter)?this.filter.createQuery(e):new c(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const r of e.features)r.layer=t,r.sourceLayer=t;return e}))}queryObjectIds(e,t){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=j(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new b({layerView:this,priority:R.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new w({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo,getFeatureExtent:e}),toArray:()=>{const e=new Array;return this._forAllFeatures(((t,r,i)=>(e.push({id:t,index:r,meta:i}),f.CONTINUE)),null,g.ALL_IN_CLIPPING_AREA),e},forAllFeatures:(e,t)=>this._forAllFeatures(((t,r,i)=>e({id:t,index:r,meta:i})),t,g.ALL_IN_CLIPPING_AREA),getFeatureExtent:e,sourceSpatialReference:v(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof c){const{set:r,handle:i}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(r,e))),i}return super.highlight(e)}createInteractiveEditSession(e){return _(this._attributeEditingContext,e)}_createLayerGraphic(e){const r=new t(null,null,e);return r.layer=this.layer,r.sourceLayer=this.layer,r}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}getFilters(){const e=super.getFilters(),t=this._excludeObjectIdsSorted;return s(t)&&e.push((e=>x(t,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),s(this.viewFilter)&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}isUpdating(){return super.isUpdating()||this.layerFilterUpdating}_ensureQuery(e){return this._addDefinitionExpressionToQuery(i(e)?this.createQuery():c.from(e))}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),forEachNode:e=>this._forAllNodes((t=>s(t)?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo,attributeOverrides:this.attributeOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}_handleEdits(e){F(this._attributeEditingContext,e)}get hasGeometryFilter(){const e=this.viewFilter;return s(e)&&s(e.parsedGeometry)}computeNodeFiltering(e){const t=this.viewFilter;return i(t)||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?S.Unmodified:S.Culled}};e([a()],V.prototype,"i3slayer",null),e([a(L)],V.prototype,"updatingProgress",void 0),e([a({type:h})],V.prototype,"filter",null),e([a({readOnly:!0})],V.prototype,"viewFilter",null),e([a(U.requiredFields)],V.prototype,"requiredFields",null),e([a(U.availableFields)],V.prototype,"availableFields",void 0),e([a()],V.prototype,"_fieldsHelper",void 0),e([a()],V.prototype,"_floorFilterClause",null),e([a()],V.prototype,"_excludeObjectIdsSorted",null),e([a()],V.prototype,"_objectQualitySettings",null),e([a()],V.prototype,"lodFactor",null),e([a()],V.prototype,"updatingProgressValue",null),V=e([u("esri.views.3d.layers.SceneLayerView3D")],V);const N=V;export{N 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.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Error.js";import{isNone as t}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as s}from"../../../geometry/projection.js";import{LayerView3D as a}from"./LayerView3D.js";import{TiledLayerView3D as l}from"./TiledLayerView3D.js";import n from"../../layers/LayerView.js";import p from"../../layers/RefreshableLayerView.js";import m from"../../layers/TileLayerView.js";import{createQueryGeometry as c}from"../../support/drapedUtils.js";let f=class extends(p(l(m(a(n))))){constructor(){super(...arguments),this.type="tile-3d"}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get dataLevelRange(){if(this.tileInfo){const e=this.tileInfo.lods,r=e[0].scale,t=e[e.length-1].scale;return this.levelRangeFromScaleRange(r,t)}return{minLevel:0,maxLevel:0}}initialize(){if("web-tile"===this.layer.type){const e=this.layer.get("fullExtent.spatialReference"),i=this.layer.get("tileInfo.spatialReference");if(t(e)||t(i)||!s(e,i)){const e="defaults"===this.layer.originOf("fullExtent")||t(this.layer.fullExtent)?"SceneView requires fullExtent to be specified by the user on WebTileLayer":"SceneView requires fullExtent to be specified in the same spatial reference as tileInfo on WebTileLayer";this.addResolvingPromise(Promise.reject(new r("layerview:incompatible-fullextent",e)))}}this._addTilingSchemeMatchPromise()}createFetchPopupFeaturesQueryGeometry(e,r){return c(e,r,this.view)}async doRefresh(){this.suspended||this.emit("data-changed")}};e([i({readOnly:!0})],f.prototype,"imageFormatIsOpaque",null),e([i({readOnly:!0})],f.prototype,"hasMixedImageFormats",null),e([i()],f.prototype,"layer",void 0),e([i({readOnly:!0,aliasOf:"layer.tileInfo"})],f.prototype,"tileInfo",void 0),e([i({readOnly:!0})],f.prototype,"dataLevelRange",null),f=e([o("esri.views.3d.layers.TileLayerView3D")],f);const y=f;export{y as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{isNone as r}from"../../../core/maybe.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as s}from"../../../geometry/projection.js";import{LayerView3D as a}from"./LayerView3D.js";import{TiledLayerView3D as l}from"./TiledLayerView3D.js";import n from"../../layers/LayerView.js";import p from"../../layers/RefreshableLayerView.js";import m from"../../layers/TileLayerView.js";import{createQueryGeometry as c}from"../../support/drapedUtils.js";let f=class extends(p(l(m(a(n))))){constructor(){super(...arguments),this.type="tile-3d"}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get tileInfo(){return this.layer?.tileInfo}get dataLevelRange(){if(this.tileInfo){const e=this.tileInfo.lods,t=e[0].scale,r=e[e.length-1].scale;return this.levelRangeFromScaleRange(t,r)}return{minLevel:0,maxLevel:0}}initialize(){if("web-tile"===this.layer.type){const e=this.layer.get("fullExtent.spatialReference"),i=this.layer.get("tileInfo.spatialReference");if(r(e)||r(i)||!s(e,i)){const e="defaults"===this.layer.originOf("fullExtent")||r(this.layer.fullExtent)?"SceneView requires fullExtent to be specified by the user on WebTileLayer":"SceneView requires fullExtent to be specified in the same spatial reference as tileInfo on WebTileLayer";this.addResolvingPromise(Promise.reject(new t("layerview:incompatible-fullextent",e)))}}this._addTilingSchemeMatchPromise()}createFetchPopupFeaturesQueryGeometry(e,t){return c(e,t,this.view)}async doRefresh(){this.suspended||this.emit("data-changed")}};e([i()],f.prototype,"imageFormatIsOpaque",null),e([i()],f.prototype,"hasMixedImageFormats",null),e([i()],f.prototype,"layer",void 0),e([i()],f.prototype,"tileInfo",null),e([i()],f.prototype,"dataLevelRange",null),f=e([o("esri.views.3d.layers.TileLayerView3D")],f);const y=f;export{y 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.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../core/Error.js";import t from"../../../core/Handles.js";import r from"../../../core/Logger.js";import{isSome as i,destroyMaybe as a,isNone as o}from"../../../core/maybe.js";import{watch as l,initial as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{equals as m}from"../../../geometry/support/spatialReferenceUtils.js";import{LayerView3D as c}from"./LayerView3D.js";import u from"../../layers/LayerView.js";import{ContextType as p}from"../../webgl/context-util.js";var y;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(y||(y={}));let g=class extends(c(u)){constructor(){super(...arguments),this._usedMemory=0,this._futureMemory=0,this.type="voxel-3d",this._wasmLayerId=-1,this._handles=new t,this._dbgFlags=new Set}get wasmLayerId(){return this._wasmLayerId}initialize(){if("local"!==this.view.viewingMode)throw new s("voxel:unsupported-viewingMode","Voxel layers support local viewingMode only.",{});if(this.view._stage.renderView.renderingContext.type!==p.WEBGL2)throw new s("voxel:unsupported-context","Voxel layers are supported in WebGL2 rendering contexts only.",{});if(!!!this.view._stage.renderView.renderingContext.capabilities.colorBufferFloat?.textureFloat)throw new s("voxel:missing-color-buffer-float","Voxel layers require the WebGL2 extension EXT_color_buffer_float",{});const e=this.layer.spatialReference;if(!m(e,this.view.spatialReference))throw new s("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const t=this.layer.currentVariableId,r=this.layer.getVolume(t),a=this.layer.getVariable(t);if(i(r)&&i(a)){const e=r.dimensions[0],s=r.dimensions[1],t=r.getZDimension();if(t>1){const i=r.dimensions[t],o=e.size*s.size*i.size;let l=1;switch(a.renderingFormat.type){case"Int16":case"UInt16":l=2;break;case"Int32":case"UInt32":case"Float32":l=4}this._futureMemory=l*o}}const o=this.view.addVoxelLayerViewToWasm(this).then((e=>{this._wasmLayerId=e,this._suspendedHandle=l((()=>this.suspended),(e=>{const s=this.view.voxelWasm;i(s)&&s.setEnabled(this,!e)}),n),this._handles.add([l((()=>this.layer.renderMode),(e=>this._pushRenderModeToWasm(e))),l((()=>this.layer.currentVariableId),(e=>this._pushCurrentVariableIdToWasm(e))),l((()=>this.layer.getDynamicSections()),(e=>this._pushDynamicSectionsToWasm(e))),l((()=>this.layer.getSlices()),(e=>this._pushSlicesToWasm(e))),l((()=>this.layer.getSections()),(e=>this._pushSectionsToWasm(e))),l((()=>this.layer.getVerticalExaggeration()),(e=>this._pushVerticalExaggerationToWasm(e))),l((()=>this.layer.getVerticalOffset()),(e=>this._pushVerticalOffsetToWasm(e)))])})).catch((e=>{if(this.view.removeVoxelLayerViewFromWasm(this),this._wasmLayerId=-1,-1===e)throw new s("voxel:addLayer-failure","The voxel layer description was invalid.",{});if(-2===e)throw new s("voxel:addLayer-failure","The voxel layer web assembly module failed to download.",{})}));this.addResolvingPromise(o)}destroy(){this.view.removeVoxelLayerViewFromWasm(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._handles=a(this._handles)}isUpdating(){const e=this.view.voxelWasm;return!(this._wasmLayerId<0||!i(e))&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}getUsedMemory(){return this._usedMemory}getUnloadedMemory(){return this._futureMemory}ignoresMemoryFactor(){return!0}get performanceInfo(){return{nodes:0,displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null}}setUsedMemory(e){this._usedMemory=e,this._futureMemory=0}captureFrustum(){const e=this.view.voxelWasm;i(e)&&e.captureFrustum()}toggleFullVolumeExtentDraw(){const e=this.view.voxelWasm;i(e)&&e.toggleFullVolumeExtentDraw(this)}_pushRenderModeToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushRenderModeToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setRenderMode(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushRenderModeToWasm() failed!")}_pushSlicesToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushSlicesToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setSlices(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushSlicesToWasm() failed!")}_pushSectionsToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushSectionsToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setStaticSections(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushSectionsToWasm() failed!")}_pushDynamicSectionsToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushDynamicSectionsToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setDynamicSections(this,e)||this._dbg(y.Error,"VoxelLayer._updateDynamicSections() failed!")}_pushCurrentVariableIdToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushCurrentVariableIdToWasm() called!, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setCurrentVariable(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushCurrentVariableIdToWasm() failed!")}_pushVerticalExaggerationToWasm(e){const s=this.layer.getVolumeStyle(null),t=this.view.voxelWasm;if(this._dbg(y.VerboseAPI,`VoxelLayerView3D._pushVerticalExaggerationToWasm() called, ${i(t)?"have WASM":"don't have WASM!!!"}, ${i(s)?"have style":"don't have style!!!"}`),o(s))return;!!i(t)&&t.setVerticalExaggerationAndOffset(this,s.volumeId,e,s.verticalOffset)||this._dbg(y.Error,"VoxelLayerView3D._pushVerticalExaggerationToWasm() failed!")}_pushVerticalOffsetToWasm(e){const s=this.layer.getVolumeStyle(null),t=this.view.voxelWasm;if(this._dbg(y.VerboseAPI,`VoxelLayerView3D._pushVerticalOffsetToWasm() called, ${i(t)?"have WASM":"don't have WASM!!!"}, ${i(s)?"have style":"don't have style!!!"}`),o(s))return;!!i(t)&&t.setVerticalExaggerationAndOffset(this,s.volumeId,s.verticalExaggeration,e)||this._dbg(y.Error,"VoxelLayerView3D._pushVerticalOffsetToWasm() failed!")}_dbg(e,s){this._dbgFlags.has(e)&&(e===y.Error?r.getLogger(this.declaredClass).error(s):r.getLogger(this.declaredClass).warn(s))}};e([h()],g.prototype,"layer",void 0),e([h({readOnly:!0,aliasOf:"layer.parsedUrl.path"})],g.prototype,"baseUrl",void 0),g=e([d("esri.views.3d.layers.VoxelLayerView3D")],g);const f=g;export{f as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import s from"../../../core/Error.js";import t from"../../../core/Handles.js";import r from"../../../core/Logger.js";import{isSome as i,destroyMaybe as a,isNone as o}from"../../../core/maybe.js";import{watch as l,initial as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{equals as m}from"../../../geometry/support/spatialReferenceUtils.js";import{LayerView3D as c}from"./LayerView3D.js";import u from"../../layers/LayerView.js";import{ContextType as p}from"../../webgl/context-util.js";var y;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(y||(y={}));let g=class extends(c(u)){constructor(){super(...arguments),this._usedMemory=0,this._futureMemory=0,this.type="voxel-3d",this._wasmLayerId=-1,this._handles=new t,this._dbgFlags=new Set}get baseUrl(){return this.layer.parsedUrl?.path??""}get wasmLayerId(){return this._wasmLayerId}initialize(){if("local"!==this.view.viewingMode)throw new s("voxel:unsupported-viewingMode","Voxel layers support local viewingMode only.",{});if(this.view._stage.renderView.renderingContext.type!==p.WEBGL2)throw new s("voxel:unsupported-context","Voxel layers are supported in WebGL2 rendering contexts only.",{});if(!!!this.view._stage.renderView.renderingContext.capabilities.colorBufferFloat?.textureFloat)throw new s("voxel:missing-color-buffer-float","Voxel layers require the WebGL2 extension EXT_color_buffer_float",{});const e=this.layer.spatialReference;if(!m(e,this.view.spatialReference))throw new s("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const t=this.layer.currentVariableId,r=this.layer.getVolume(t),a=this.layer.getVariable(t);if(i(r)&&i(a)){const e=r.dimensions[0],s=r.dimensions[1],t=r.getZDimension();if(t>1){const i=r.dimensions[t],o=e.size*s.size*i.size;let l=1;switch(a.renderingFormat.type){case"Int16":case"UInt16":l=2;break;case"Int32":case"UInt32":case"Float32":l=4}this._futureMemory=l*o}}const o=this.view.addVoxelLayerViewToWasm(this).then((e=>{this._wasmLayerId=e,this._suspendedHandle=l((()=>this.suspended),(e=>{const s=this.view.voxelWasm;i(s)&&s.setEnabled(this,!e)}),n),this._handles.add([l((()=>this.layer.renderMode),(e=>this._pushRenderModeToWasm(e))),l((()=>this.layer.currentVariableId),(e=>this._pushCurrentVariableIdToWasm(e))),l((()=>this.layer.getDynamicSections()),(e=>this._pushDynamicSectionsToWasm(e))),l((()=>this.layer.getSlices()),(e=>this._pushSlicesToWasm(e))),l((()=>this.layer.getSections()),(e=>this._pushSectionsToWasm(e))),l((()=>this.layer.getVerticalExaggeration()),(e=>this._pushVerticalExaggerationToWasm(e))),l((()=>this.layer.getVerticalOffset()),(e=>this._pushVerticalOffsetToWasm(e)))])})).catch((e=>{if(this.view.removeVoxelLayerViewFromWasm(this),this._wasmLayerId=-1,-1===e)throw new s("voxel:addLayer-failure","The voxel layer description was invalid.",{});if(-2===e)throw new s("voxel:addLayer-failure","The voxel layer web assembly module failed to download.",{})}));this.addResolvingPromise(o)}destroy(){this.view.removeVoxelLayerViewFromWasm(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._handles=a(this._handles)}isUpdating(){const e=this.view.voxelWasm;return!(this._wasmLayerId<0||!i(e))&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}getUsedMemory(){return this._usedMemory}getUnloadedMemory(){return this._futureMemory}ignoresMemoryFactor(){return!0}get performanceInfo(){return{nodes:0,displayedNumberOfFeatures:0,maximumNumberOfFeatures:0,totalNumberOfFeatures:0,core:null}}setUsedMemory(e){this._usedMemory=e,this._futureMemory=0}captureFrustum(){const e=this.view.voxelWasm;i(e)&&e.captureFrustum()}toggleFullVolumeExtentDraw(){const e=this.view.voxelWasm;i(e)&&e.toggleFullVolumeExtentDraw(this)}_pushRenderModeToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushRenderModeToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setRenderMode(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushRenderModeToWasm() failed!")}_pushSlicesToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushSlicesToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setSlices(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushSlicesToWasm() failed!")}_pushSectionsToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushSectionsToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setStaticSections(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushSectionsToWasm() failed!")}_pushDynamicSectionsToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushDynamicSectionsToWasm() called, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setDynamicSections(this,e)||this._dbg(y.Error,"VoxelLayer._updateDynamicSections() failed!")}_pushCurrentVariableIdToWasm(e){const s=this.view.voxelWasm;this._dbg(y.VerboseAPI,"VoxelLayerView3D._pushCurrentVariableIdToWasm() called!, "+(i(s)?"have WASM":"don't have WASM!!!"));!!i(s)&&s.setCurrentVariable(this,e)||this._dbg(y.Error,"VoxelLayerView3D._pushCurrentVariableIdToWasm() failed!")}_pushVerticalExaggerationToWasm(e){const s=this.layer.getVolumeStyle(null),t=this.view.voxelWasm;if(this._dbg(y.VerboseAPI,`VoxelLayerView3D._pushVerticalExaggerationToWasm() called, ${i(t)?"have WASM":"don't have WASM!!!"}, ${i(s)?"have style":"don't have style!!!"}`),o(s))return;!!i(t)&&t.setVerticalExaggerationAndOffset(this,s.volumeId,e,s.verticalOffset)||this._dbg(y.Error,"VoxelLayerView3D._pushVerticalExaggerationToWasm() failed!")}_pushVerticalOffsetToWasm(e){const s=this.layer.getVolumeStyle(null),t=this.view.voxelWasm;if(this._dbg(y.VerboseAPI,`VoxelLayerView3D._pushVerticalOffsetToWasm() called, ${i(t)?"have WASM":"don't have WASM!!!"}, ${i(s)?"have style":"don't have style!!!"}`),o(s))return;!!i(t)&&t.setVerticalExaggerationAndOffset(this,s.volumeId,s.verticalExaggeration,e)||this._dbg(y.Error,"VoxelLayerView3D._pushVerticalOffsetToWasm() failed!")}_dbg(e,s){this._dbgFlags.has(e)&&(e===y.Error?r.getLogger(this.declaredClass).error(s):r.getLogger(this.declaredClass).warn(s))}};e([h()],g.prototype,"layer",void 0),e([h()],g.prototype,"baseUrl",null),g=e([d("esri.views.3d.layers.VoxelLayerView3D")],g);const f=g;export{f 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.25/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,unwrapOr as a,get as o}from"../../../../core/maybe.js";import{f as s,t as n}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{f as l,m as c,a as u}from"../../../../chunks/mat4.js";import{b as m,c as h}from"../../../../chunks/mat4f64.js";import{a as p,g as f,e as d,n as g,b as x,f as _}from"../../../../chunks/vec3.js";import{Z as y,O as b,c as v}from"../../../../chunks/vec3f64.js";import{O as T}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as C,projectBuffer as O,computeTranslationToOriginAndRotation as A,canProjectWithoutEngine as M}from"../../../../geometry/projection.js";import{create as w,empty as E,expandWithBuffer as N,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import R from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as I,BufferViewVec3f as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,a as F}from"../../../../chunks/vec32.js";import{transformPosition as L,transformNormal as U,projectNormalToPCPF as V,transformTangent as G,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as k}from"../../../ViewingMode.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as q}from"./elevationAlignmentUtils.js";import{ElevationContext as H}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as W}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Y}from"./Graphics3DSymbolLayer.js";import{createMaterial as Z}from"../support/edgeUtils.js";import{parseColorMixMode as J,encodeSymbolColor as K}from"../support/symbolColorUtils.js";import Q from"../../support/debugFlags.js";import{AlphaDiscardMode as X,CullFaceOptions as ee,PrimitiveType as te}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as re}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as ae}from"../../webgl-engine/lib/geometryDataUtils.js";import{Object3D as oe}from"../../webgl-engine/lib/Object3D.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as ne}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as ie}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as le}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ce}from"../../../webgl/enums.js";const ue=["mesh"];class me extends Y{constructor(e,t,r,a){super(e,t,r,a),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){Q.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new le({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new le({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ue,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new H),a=e.renderingInfo;return this._createAs3DShape(t,a,r,t.uid)}layerOpacityChanged(e,r){const a=this._getLayerOpacity();return this._materials.forEach((e=>{e.material.setParameters({layerOpacity:a});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=r(e);t(o)&&o.layerOpacityChanged(a,this._context.isAsync)})),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,q)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const a=r(e);t(a)&&a.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),a=!!e.vertexAttributes.color,o=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:a,hasVertexTangents:o,uid:`vc:${a},vt:${o},vct${t},svc:${r}`}}_materialProperties(e,t,r){const a=this._materialPropertiesDefault(e,r);if(!t.material)return a;const{color:o,colorTexture:s,normalTexture:n,doubleSided:i,alphaCutoff:l,alphaMode:c}=t.material,u=this._colorOrTextureUid(o),m=this._colorOrTextureUid(s),h=this._colorOrTextureUid(n);if(a.color=o,a.colorTexture=s,a.normalTexture=n,a.uid=`${a.uid},cmuid:${u},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${c}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:o,emissiveColor:s,emissiveTexture:n,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(o),c=this._colorOrTextureUid(s),u=this._colorOrTextureUid(n),m=this._colorOrTextureUid(i);a.metallic=e,a.roughness=r,a.metallicRoughnessTexture=o,a.emissiveColor=s,a.emissiveTexture=n,a.occlusionTexture=i,a.uid=`${a.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${c},etmuid:${u},otmuid:${m}`}return a}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,X.Opaque);return t(r)?r.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const a=`${e.contentHash}/${t}`;let o=this._textures.get(a);return o||(o=new se(r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:t!==X.Opaque}),this._textures.set(a,o),this._context.stage.add(o),this._context.stage.loadImmediate(o)),o}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ce.CLAMP_TO_EDGE;case"mirror":return ce.MIRRORED_REPEAT;default:return ce.REPEAT}}_setInternalMaterialParameters(r,a){if(t(r.color)&&this._setInternalColorValueParameters(r.color,a),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,a.textureAlphaMode);t(e)?(a.textureId=e.id,a.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):a.textureId=void 0}t(r.normalTexture)&&(a.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(a.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(a.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(a.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(a.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture))}_setExternalMaterialParameters(r){const a=this._drivenProperties.color;let o=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(a)r.externalColor=T;else{const a=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(a)?r.externalColor=e.toUnitRGBA(a):(o=null,r.externalColor=T)}o&&(r.colorMixMode=o),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){const a=r.material?.color,o=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(e)||t(a)&&a.a<1||t(o)&&o.transparent||n),l=this._materialProperties(e,r,i),c=this._materials.get(l.uid);if(c)return c.material;const u={material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=null==l.metallicRoughnessTexture&&null==l.metallic&&null==l.roughness,h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:y,diffuse:b,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ee.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[null!=l.metallic?l.metallic:1,null!=l.roughness?l.roughness:1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ee.None:ee.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const p=new ie(h);return u.material=p,this._materials.set(l.uid,u),this._context.stage.add(p),p}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?X.MaskBlend:X.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?X.Opaque:"mask"===t.alphaMode?X.Mask:X.Blend}_addDebugNormals(e,t,r,a){const o=t.length,s=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*s,e.extent.height*s,e.extent.zmax-e.extent.zmin),i=[],l=[],c=[],u=[];for(let m=0;m<o;m++){const e=t[m],r=e.vertexAttributes.get(ne.POSITION),a=e.vertexAttributes.get(ne.NORMAL),o=e.indices.get(ne.POSITION),s=e.indices.get(ne.NORMAL),h=r.data,d=a.data;for(let t=0;t<o.length;t++){const e=3*o[t],r=3*s[t];for(let t=0;t<3;t++)i.push(h[e+t]);for(let t=0;t<3;t++)i.push(h[e+t]+d[r+t]*n);if(l.push(l.length),l.push(l.length),t%3==0){this._calculateFaceNormal(h,o,t,ge),this._getFaceVertices(h,o,t,pe,fe,de),p(pe,pe,fe),p(pe,pe,de),f(pe,pe,1/3);for(let e=0;e<3;e++)c.push(pe[e]);for(let e=0;e<3;e++)c.push(pe[e]+ge[e]*n);u.push(u.length),u.push(u.length)}}}const h=new re([[ne.POSITION,{data:i,size:3,exclusive:!0}]],[[ne.POSITION,new Uint32Array(l)]],te.Line);t.push(h),r.push(this._debugVertexNormalMaterial),a.push(m(a[0]));const d=new re([[ne.POSITION,{data:c,size:3,exclusive:!0}]],[[ne.POSITION,new Uint32Array(u)]],te.Line);t.push(d),r.push(this._debugFaceNormalMaterial),a.push(m(a[0]))}_createAs3DShape(e,r,a,o){const s=e.geometry;if("mesh"!==s.type)return null;const n=this._createGeometryInfo(s,r,o);if(!n)return null;const{geometries:i,materials:l,transformations:c,objectTransformation:u}=n;Q.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,i,l,c);const m=new oe({geometries:i,materials:l,transformations:c,metadata:{layerUid:this._context.layer.uid,graphicUid:o}});m.transformation=u;const h=this._createEdgeMaterial(),p=t(h)?{baseMaterial:l[0],edgeMaterials:[h],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,f=new W(this,m,i,null,null,z,a,p);return f.needsElevationUpdates=q(a.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.elevationContext.centerPointInElevationSR=this._getCenterPointInElevationSR(m),f.alignedSampledElevation=z(f,f.elevationContext,this._context.elevationProvider,this._context.renderCoordsHelper),f}_getCenterPointInElevationSR(e){const r=D(0,0,0,t(this._context.elevationProvider.spatialReference)?this._context.elevationProvider.spatialReference:null);return C([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,r),r}_createComponentNormals(e,t,r,a){switch(r.shading||"flat"){case"source":return this._createComponentNormalsSource(e,t,r,a);case"flat":return this._createComponentNormalsFlat(e,a);case"smooth":return this._createComponentNormalsSmooth(e,a);default:return}}_createComponentNormalsSource(e,t,a,o){if(r(t))return this._createComponentNormalsFlat(e,o);let s=!1;if(!a.trustSourceNormals)for(let r=0;r<o.length;r+=3){this._calculateFaceNormal(e,o,r,ge);for(let e=0;e<3;e++){const a=3*o[r+e];pe[0]=t[a+0],pe[1]=t[a+1],pe[2]=t[a+2],d(ge,pe)<0&&(t[a+0]=-t[a+0],t[a+1]=-t[a+1],t[a+2]=-t[a+2],s=!0)}}return{normals:t,indices:o,didFlipNormals:s}}_createComponentNormalsFlat(e,t){const r=new Float32Array(t.length),a=new Uint32Array(3*t.length);for(let o=0;o<t.length;o+=3){const s=this._calculateFaceNormal(e,t,o,ge);for(let e=0;e<3;e++)r[o+e]=s[e],a[o+e]=o/3}return{normals:r,indices:a,didFlipNormals:!1}}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const a=this._calculateFaceNormal(e,t,s,ge);for(let e=0;e<3;e++){const o=t[s+e];let n=r[o];n||(n={normal:v(),count:0},r[o]=n),p(n.normal,n.normal,a),n.count++}}const a=new Float32Array(3*t.length),o=new Uint32Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(g(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)a[3*s+t]=e.normal[t];o[s]=s}return{normals:a,indices:o,didFlipNormals:!1}}_getFaceVertices(e,t,r,a,o,s){const n=3*t[r+0],i=3*t[r+1],l=3*t[r+2];a[0]=e[n+0],a[1]=e[n+1],a[2]=e[n+2],o[0]=e[i+0],o[1]=e[i+1],o[2]=e[i+2],s[0]=e[l+0],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,a){return this._getFaceVertices(e,t,r,pe,fe,de),x(fe,fe,pe),x(de,de,pe),_(pe,fe,de),g(a,pe),a}_getOrCreateComponents(e){return a(e.components,be)}_createPositionBuffer(e,r){let a=e.vertexAttributes.position;const o=r.reprojection===ve.ECEF?r.transformBeforeProject:null;if(t(o)&&(a=L(a,new Float64Array(a.length),o)),r.reprojection===ve.NONE)return r.needsBufferCopy?new Float64Array(a):a;const s=t(o)?a:new Float64Array(a.length);return O(a,e.spatialReference,0,s,this._context.renderCoordsHelper.spatialReference,0,a.length/3),s}_createNormalBuffer(e,a,o){let s=e.vertexAttributes.normal;if(r(s))return null;const n=o.reprojection===ve.ECEF?o.transformBeforeProject:null;t(n)&&(s=U(s,new Float32Array(s.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||o.reprojection===ve.NONE)return o.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return V(s,i,a,e.spatialReference,l)}_createTangentBuffer(e,a,o){let s=e.vertexAttributes.tangent;if(r(s))return null;const n=o.reprojection===ve.ECEF?o.transformBeforeProject:null;t(n)&&(s=G(s,new Float32Array(s.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||o.reprojection===ve.NONE)return o.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return $(s,i,a,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=J(o(this.symbolLayer,"material","colorMixMode")),a=new Uint8Array(4);return K(t,r,a),a}return null}_createBuffers(e,r){const a=e.vertexAttributes&&e.vertexAttributes.position;if(!a)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,s=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(t(o)&&o.length!==a.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/4!=a.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/2!=a.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(r),m=this._createNormalBuffer(e,l,i),p=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:m,tangentBuffer:p,uvBuffer:s,colorBuffer:c,symbolColorBuffer:u,objectTransformation:i.reprojection===ve.NONE&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,m,p),geometryTransformation:i.reprojection===ve.NONE&&t(i.geometryTransformation)?i.geometryTransformation:h()}}_computeReprojectionInfo(e){const r=t(e.transform),a=r&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===k.Local?ve.NONE:ve.ECEF;if(r){if(a===ve.NONE){const t=h();A(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:a,objectTransformation:t,geometryTransformation:m(e.transform.localMatrix),needsBufferCopy:!1}}const t=l(h(),e.transform.origin);return c(t,t,e.transform.localMatrix),{reprojection:a,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:a,needsBufferCopy:!0}}_transformOriginLocal(e,r,a,o){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;he[0]=l.x,he[1]=l.y,he[2]=l.z;const c=h();A(e.spatialReference,he,c,i);const m=I.fromTypedArray(r);if(u(xe,c),S(m,m,xe),t(a)||t(o)){if(s(_e,c),n(_e,_e),t(a)){const e=B.fromTypedArray(a);F(e,e,_e)}if(t(o)){const e=B.fromTypedArray(o,4*o.BYTES_PER_ELEMENT);F(e,e,_e)}}return c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,a=t.faces;if(a){let e=-1;for(let t=0;t<a.length;t++){const r=a[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces?t.faces:ae(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return!1;const a=this._context.elevationProvider.spatialReference;let o;const s=r.length/3;return t(a)&&!e.spatialReference.equals(a)?(o=new Float64Array(r.length),O(e.vertexAttributes.position,e.spatialReference,0,o,a,0,s)):o=r,E(ye),N(ye,o,0,s),!j(ye,this._context.clippingExtent)}_createGeometryInfo(e,a,o){if(!M(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const s=this._createBuffers(e,a);if(r(s))return null;const{positionBuffer:n,uvBuffer:i,colorBuffer:l,symbolColorBuffer:c,normalBuffer:u,tangentBuffer:m,objectTransformation:h,geometryTransformation:p}=s,f=this._getOrCreateComponents(e),d=[],g=[],x=[];let _=!1;for(const r of f){if(!this._validateFaces(e,r))return null;const a=this._getOrCreateFaces(e,r);if(0===a.length)continue;const s=this._createComponentNormals(n,u,r,a);s.didFlipNormals&&(_=!0);const h=[[ne.POSITION,{size:3,data:n,exclusive:!0}],[ne.NORMAL,{size:3,data:s.normals,exclusive:!0}]],f=[[ne.POSITION,a],[ne.NORMAL,s.indices]];t(l)&&(h.push([ne.COLOR,{size:4,data:l,exclusive:!0}]),f.push([ne.COLOR,a])),t(c)&&(h.push([ne.SYMBOLCOLOR,{size:4,data:c,exclusive:!0}]),f.push([ne.SYMBOLCOLOR,new Uint16Array(a.length)])),t(i)&&(h.push([ne.UV0,{size:2,data:i,exclusive:!0}]),f.push([ne.UV0,a])),t(m)&&(h.push([ne.TANGENT,{size:4,data:m,exclusive:!0}]),f.push([ne.TANGENT,a]));const y=this._context.stage.renderView._getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),b=new re(h,f,te.Triangle,y);d.push(b),g.push(p),x.push(this._getOrCreateMaterial(e,r))}return _&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:d,transformations:g,materials:x,objectTransformation:h}}_createEdgeMaterial(){const e={opacity:this._getLayerOpacity()};return Z(this.symbolLayer,e)}}const he=v(),pe=v(),fe=v(),de=v(),ge=v(),xe=h(),_e=i(),ye=w(),be=[new R];var ve;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(ve||(ve={}));export{me as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,unwrapOr as a,get as o}from"../../../../core/maybe.js";import{f as s,t as n}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{f as l,m as u,a as c}from"../../../../chunks/mat4.js";import{b as m,c as h}from"../../../../chunks/mat4f64.js";import{a as f,g as p,e as d,n as g,b as x,f as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as C,projectBuffer as O,computeTranslationToOriginAndRotation as A,canProjectWithoutEngine as M}from"../../../../geometry/projection.js";import{create as w,empty as E,expandWithBuffer as N,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import R from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as I,BufferViewVec3f as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,a as F}from"../../../../chunks/vec32.js";import{transformPosition as L,transformNormal as U,projectNormalToPCPF as V,transformTangent as G,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as k}from"../../../ViewingMode.js";import{getTransformMatrix as z}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as q}from"./ElevationAligners.js";import{needsElevationUpdates3D as H}from"./elevationAlignmentUtils.js";import{ElevationContext as W}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as Y}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Z}from"./Graphics3DSymbolLayer.js";import{createMaterial as J}from"../support/edgeUtils.js";import{parseColorMixMode as K,encodeSymbolColor as Q}from"../support/symbolColorUtils.js";import X from"../../support/debugFlags.js";import{AlphaDiscardMode as ee,CullFaceOptions as te,PrimitiveType as re}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as ae}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as oe}from"../../webgl-engine/lib/geometryDataUtils.js";import{Object3D as se}from"../../webgl-engine/lib/Object3D.js";import{Texture as ne}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as le}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as ue}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ce}from"../../../webgl/enums.js";const me=["mesh"];class he extends Z{constructor(e,t,r,a){super(e,t,r,a),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){X.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new ue({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new ue({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,me,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new W),a=e.renderingInfo;return this._createAs3DShape(t,a,r,t.uid)}layerOpacityChanged(e,r){const a=this._getLayerOpacity();return this._materials.forEach((e=>{e.material.setParameters({layerOpacity:a});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=r(e);t(o)&&o.layerOpacityChanged(a,this._context.isAsync)})),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,H)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const a=r(e);t(a)&&a.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),a=!!e.vertexAttributes.color,o=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:a,hasVertexTangents:o,uid:`vc:${a},vt:${o},vct${t},svc:${r}`}}_materialProperties(e,t,r){const a=this._materialPropertiesDefault(e,r);if(!t.material)return a;const{color:o,colorTexture:s,normalTexture:n,doubleSided:i,alphaCutoff:l,alphaMode:u}=t.material,c=this._colorOrTextureUid(o),m=this._colorOrTextureUid(s),h=this._colorOrTextureUid(n);if(a.color=o,a.colorTexture=s,a.normalTexture=n,a.uid=`${a.uid},cmuid:${c},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${u}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:o,emissiveColor:s,emissiveTexture:n,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(o),u=this._colorOrTextureUid(s),c=this._colorOrTextureUid(n),m=this._colorOrTextureUid(i);a.metallic=e,a.roughness=r,a.metallicRoughnessTexture=o,a.emissiveColor=s,a.emissiveTexture=n,a.occlusionTexture=i,a.colorTextureTransform=t.material.colorTextureTransform,a.normalTextureTransform=t.material.normalTextureTransform,a.emissiveTextureTransform=t.material.emissiveTextureTransform,a.occlusionTextureTransform=t.material.occlusionTextureTransform,a.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,a.uid=`${a.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${u},etmuid:${c},otmuid:${m}`}return a}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,ee.Opaque);return t(r)?r.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const a=`${e.contentHash}/${t}`;let o=this._textures.get(a);return o||(o=new ne(r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:t!==ee.Opaque}),this._textures.set(a,o),this._context.stage.add(o),this._context.stage.loadImmediate(o)),o}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ce.CLAMP_TO_EDGE;case"mirror":return ce.MIRRORED_REPEAT;default:return ce.REPEAT}}_setInternalMaterialParameters(r,a){if(t(r.color)&&this._setInternalColorValueParameters(r.color,a),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,a.textureAlphaMode);t(e)?(a.textureId=e.id,a.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):a.textureId=void 0}t(r.normalTexture)&&(a.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(a.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(a.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(a.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(a.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture)),a.colorTextureTransformMatrix=z(r.colorTextureTransform),a.normalTextureTransformMatrix=z(r.normalTextureTransform),a.occlusionTextureTransformMatrix=z(r.occlusionTextureTransform),a.emissiveTextureTransformMatrix=z(r.emissiveTextureTransform),a.metallicRoughnessTextureTransformMatrix=z(r.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(r){const a=this._drivenProperties.color;let o=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(a)r.externalColor=v;else{const a=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(a)?r.externalColor=e.toUnitRGBA(a):(o=null,r.externalColor=v)}o&&(r.colorMixMode=o),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){const a=r.material?.color,o=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(e)||t(a)&&a.a<1||t(o)&&o.transparent||n),l=this._materialProperties(e,r,i),u=this._materials.get(l.uid);if(u)return u.material;const c={material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=null==l.metallicRoughnessTexture&&null==l.metallic&&null==l.roughness,h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:te.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[null!=l.metallic?l.metallic:1,null!=l.roughness?l.roughness:1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?te.None:te.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,c),this._setInternalMaterialParameters(l,h);const f=new le(h);return c.material=f,this._materials.set(l.uid,c),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ee.MaskBlend:ee.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ee.Opaque:"mask"===t.alphaMode?ee.Mask:ee.Blend}_addDebugNormals(e,t,r,a){const o=t.length,s=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*s,e.extent.height*s,e.extent.zmax-e.extent.zmin),i=[],l=[],u=[],c=[];for(let m=0;m<o;m++){const e=t[m],r=e.vertexAttributes.get(ie.POSITION),a=e.vertexAttributes.get(ie.NORMAL),o=e.indices.get(ie.POSITION),s=e.indices.get(ie.NORMAL),h=r.data,d=a.data;for(let t=0;t<o.length;t++){const e=3*o[t],r=3*s[t];for(let t=0;t<3;t++)i.push(h[e+t]);for(let t=0;t<3;t++)i.push(h[e+t]+d[r+t]*n);if(l.push(l.length),l.push(l.length),t%3==0){this._calculateFaceNormal(h,o,t,xe),this._getFaceVertices(h,o,t,pe,de,ge),f(pe,pe,de),f(pe,pe,ge),p(pe,pe,1/3);for(let e=0;e<3;e++)u.push(pe[e]);for(let e=0;e<3;e++)u.push(pe[e]+xe[e]*n);c.push(c.length),c.push(c.length)}}}const h=new ae([[ie.POSITION,{data:i,size:3,exclusive:!0}]],[[ie.POSITION,new Uint32Array(l)]],re.Line);t.push(h),r.push(this._debugVertexNormalMaterial),a.push(m(a[0]));const d=new ae([[ie.POSITION,{data:u,size:3,exclusive:!0}]],[[ie.POSITION,new Uint32Array(c)]],re.Line);t.push(d),r.push(this._debugFaceNormalMaterial),a.push(m(a[0]))}_createAs3DShape(e,r,a,o){const s=e.geometry;if("mesh"!==s.type)return null;const n=this._createGeometryInfo(s,r,o);if(!n)return null;const{geometries:i,materials:l,transformations:u,objectTransformation:c}=n;X.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,i,l,u);const m=new se({geometries:i,materials:l,transformations:u,metadata:{layerUid:this._context.layer.uid,graphicUid:o}});m.transformation=c;const h=this._createEdgeMaterial(),f=t(h)?{baseMaterial:l[0],edgeMaterials:[h],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,p=new Y(this,m,i,null,null,q,a,f);return p.needsElevationUpdates=H(a.mode),p.useObjectOriginAsAttachmentOrigin=!0,p.elevationContext.centerPointInElevationSR=this._getCenterPointInElevationSR(m),p.alignedSampledElevation=q(p,p.elevationContext,this._context.elevationProvider,this._context.renderCoordsHelper),p}_getCenterPointInElevationSR(e){const r=D(0,0,0,t(this._context.elevationProvider.spatialReference)?this._context.elevationProvider.spatialReference:null);return C([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,r),r}_createComponentNormals(e,t,r,a){switch(r.shading||"flat"){case"source":return this._createComponentNormalsSource(e,t,r,a);case"flat":return this._createComponentNormalsFlat(e,a);case"smooth":return this._createComponentNormalsSmooth(e,a);default:return}}_createComponentNormalsSource(e,t,a,o){if(r(t))return this._createComponentNormalsFlat(e,o);let s=!1;if(!a.trustSourceNormals)for(let r=0;r<o.length;r+=3){this._calculateFaceNormal(e,o,r,xe);for(let e=0;e<3;e++){const a=3*o[r+e];pe[0]=t[a+0],pe[1]=t[a+1],pe[2]=t[a+2],d(xe,pe)<0&&(t[a+0]=-t[a+0],t[a+1]=-t[a+1],t[a+2]=-t[a+2],s=!0)}}return{normals:t,indices:o,didFlipNormals:s}}_createComponentNormalsFlat(e,t){const r=new Float32Array(t.length),a=new Uint32Array(3*t.length);for(let o=0;o<t.length;o+=3){const s=this._calculateFaceNormal(e,t,o,xe);for(let e=0;e<3;e++)r[o+e]=s[e],a[o+e]=o/3}return{normals:r,indices:a,didFlipNormals:!1}}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const a=this._calculateFaceNormal(e,t,s,xe);for(let e=0;e<3;e++){const o=t[s+e];let n=r[o];n||(n={normal:b(),count:0},r[o]=n),f(n.normal,n.normal,a),n.count++}}const a=new Float32Array(3*t.length),o=new Uint32Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(g(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)a[3*s+t]=e.normal[t];o[s]=s}return{normals:a,indices:o,didFlipNormals:!1}}_getFaceVertices(e,t,r,a,o,s){const n=3*t[r+0],i=3*t[r+1],l=3*t[r+2];a[0]=e[n+0],a[1]=e[n+1],a[2]=e[n+2],o[0]=e[i+0],o[1]=e[i+1],o[2]=e[i+2],s[0]=e[l+0],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,a){return this._getFaceVertices(e,t,r,pe,de,ge),x(de,de,pe),x(ge,ge,pe),_(pe,de,ge),g(a,pe),a}_getOrCreateComponents(e){return a(e.components,be)}_createPositionBuffer(e,r){let a=e.vertexAttributes.position;const o=r.reprojection===ve.ECEF?r.transformBeforeProject:null;if(t(o)&&(a=L(a,new Float64Array(a.length),o)),r.reprojection===ve.NONE)return r.needsBufferCopy?new Float64Array(a):a;const s=t(o)?a:new Float64Array(a.length);return O(a,e.spatialReference,0,s,this._context.renderCoordsHelper.spatialReference,0,a.length/3),s}_createNormalBuffer(e,a,o){let s=e.vertexAttributes.normal;if(r(s))return null;const n=o.reprojection===ve.ECEF?o.transformBeforeProject:null;t(n)&&(s=U(s,new Float32Array(s.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||o.reprojection===ve.NONE)return o.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return V(s,i,a,e.spatialReference,l)}_createTangentBuffer(e,a,o){let s=e.vertexAttributes.tangent;if(r(s))return null;const n=o.reprojection===ve.ECEF?o.transformBeforeProject:null;t(n)&&(s=G(s,new Float32Array(s.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||o.reprojection===ve.NONE)return o.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return $(s,i,a,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=K(o(this.symbolLayer,"material","colorMixMode")),a=new Uint8Array(4);return Q(t,r,a),a}return null}_createBuffers(e,r){const a=e.vertexAttributes&&e.vertexAttributes.position;if(!a)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,s=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(t(o)&&o.length!==a.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/4!=a.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/2!=a.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(r),m=this._createNormalBuffer(e,l,i),f=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:m,tangentBuffer:f,uvBuffer:s,colorBuffer:u,symbolColorBuffer:c,objectTransformation:i.reprojection===ve.NONE&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,m,f),geometryTransformation:i.reprojection===ve.NONE&&t(i.geometryTransformation)?i.geometryTransformation:h()}}_computeReprojectionInfo(e){const r=t(e.transform),a=r&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===k.Local?ve.NONE:ve.ECEF;if(r){if(a===ve.NONE){const t=h();A(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:a,objectTransformation:t,geometryTransformation:m(e.transform.localMatrix),needsBufferCopy:!1}}const t=l(h(),e.transform.origin);return u(t,t,e.transform.localMatrix),{reprojection:a,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:a,needsBufferCopy:!0}}_transformOriginLocal(e,r,a,o){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;fe[0]=l.x,fe[1]=l.y,fe[2]=l.z;const u=h();A(e.spatialReference,fe,u,i);const m=I.fromTypedArray(r);if(c(_e,u),S(m,m,_e),t(a)||t(o)){if(s(Te,u),n(Te,Te),t(a)){const e=B.fromTypedArray(a);F(e,e,Te)}if(t(o)){const e=B.fromTypedArray(o,4*o.BYTES_PER_ELEMENT);F(e,e,Te)}}return u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,a=t.faces;if(a){let e=-1;for(let t=0;t<a.length;t++){const r=a[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces?t.faces:oe(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return!1;const a=this._context.elevationProvider.spatialReference;let o;const s=r.length/3;return t(a)&&!e.spatialReference.equals(a)?(o=new Float64Array(r.length),O(e.vertexAttributes.position,e.spatialReference,0,o,a,0,s)):o=r,E(ye),N(ye,o,0,s),!j(ye,this._context.clippingExtent)}_createGeometryInfo(e,a,o){if(!M(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const s=this._createBuffers(e,a);if(r(s))return null;const{positionBuffer:n,uvBuffer:i,colorBuffer:l,symbolColorBuffer:u,normalBuffer:c,tangentBuffer:m,objectTransformation:h,geometryTransformation:f}=s,p=this._getOrCreateComponents(e),d=[],g=[],x=[];let _=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const a=this._getOrCreateFaces(e,r);if(0===a.length)continue;const s=this._createComponentNormals(n,c,r,a);s.didFlipNormals&&(_=!0);const h=[[ie.POSITION,{size:3,data:n,exclusive:!0}],[ie.NORMAL,{size:3,data:s.normals,exclusive:!0}]],p=[[ie.POSITION,a],[ie.NORMAL,s.indices]];t(l)&&(h.push([ie.COLOR,{size:4,data:l,exclusive:!0}]),p.push([ie.COLOR,a])),t(u)&&(h.push([ie.SYMBOLCOLOR,{size:4,data:u,exclusive:!0}]),p.push([ie.SYMBOLCOLOR,new Uint16Array(a.length)])),t(i)&&(h.push([ie.UV0,{size:2,data:i,exclusive:!0}]),p.push([ie.UV0,a])),t(m)&&(h.push([ie.TANGENT,{size:4,data:m,exclusive:!0}]),p.push([ie.TANGENT,a]));const T=this._context.stage.renderView._getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),y=new ae(h,p,re.Triangle,T);d.push(y),g.push(f),x.push(this._getOrCreateMaterial(e,r))}return _&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:d,transformations:g,materials:x,objectTransformation:h}}_createEdgeMaterial(){const e={opacity:this._getLayerOpacity()};return J(this.symbolLayer,e)}}const fe=b(),pe=b(),de=b(),ge=b(),xe=b(),_e=h(),Te=i(),ye=w(),be=[new R];var ve;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(ve||(ve={}));export{he as Graphics3DMeshFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{get as t,isSome as r,isNone as s}from"../../../../core/maybe.js";import{b as o}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a}from"../../../../chunks/mat4.js";import{c as u}from"../../../../chunks/mat4f64.js";import{m as n,b as l,H as c,l as m,n as d,h as f}from"../../../../chunks/vec3.js";import{c as p}from"../../../../chunks/vec3f64.js";import{empty as x,expandWithVec3 as g}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as h,BufferViewVec4f as b,BufferViewVec2f as R,BufferViewVec4u8 as v,BufferViewVec4u16 as B,BufferViewVec3u8 as M,BufferViewVec3u16 as T}from"../../../../geometry/support/buffer/BufferView.js";import{t as w,a as y,s as j}from"../../../../chunks/vec32.js";import{t as O,s as E}from"../../../../chunks/vec42.js";import{createBuffer as C}from"../../../../geometry/support/buffer/utils.js";import{DefaultLoadingContext as S}from"../../glTF/DefaultLoadingContext.js";import{load as A}from"../../glTF/loader.js";import{triangleFanToTriangles as N,triangleStripToTriangles as I,trianglesToTriangles as L}from"../../glTF/internal/indexUtils.js";import{load as F,processLoadResult as k}from"./wosrLoader.js";import{AlphaDiscardMode as P,DepthTestFunction as V,CullFaceOptions as _}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{Texture as D}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as z}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as U}from"../../webgl-engine/materials/DefaultMaterial.js";import{COLOR_GAMMA as q}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{PrimitiveType as W}from"../../../webgl/enums.js";import{n as $}from"../../../../chunks/vec22.js";import{c as H,f as K}from"../../../../chunks/vec43.js";import{c as Q}from"../../../../chunks/vec33.js";async function J(s,o){const i=X(e(s));if("wosr"===i.fileType){const e=await(o.cache?o.cache.loadWOSR(i.url,o):F(i.url,o)),t=k(e,o);return{lods:[t],referenceBoundingBox:t.boundingBox,isEsriSymbolResource:!1,isWosr:!0,remove:e.remove}}const a=await(o.cache?o.cache.loadGLTF(i.url,o,o.usePBR):A(new S(o.streamDataRequester),i.url,o,o.usePBR)),u=t(a.model.meta,"ESRI_proxyEllipsoid");a.meta.isEsriSymbolResource&&r(u)&&a.meta.uri.includes("/RealisticTrees/")&&te(a,u);const n=a.meta.isEsriSymbolResource?{usePBR:o.usePBR,isSchematic:!1,treeRendering:!!a.customMeta.esriTreeRendering,mrrFactors:[0,1,.2]}:{usePBR:o.usePBR,isSchematic:!1,treeRendering:!1,mrrFactors:[0,1,.5]},l={...o.materialParamsMixin,treeRendering:!!a.customMeta.esriTreeRendering};if(null!=i.specifiedLodIndex){const e=Y(a,n,l,i.specifiedLodIndex);let t=e[0].boundingBox;if(0!==i.specifiedLodIndex){t=Y(a,n,l,0)[0].boundingBox}return{lods:e,referenceBoundingBox:t,isEsriSymbolResource:a.meta.isEsriSymbolResource,isWosr:!1,remove:a.remove}}const c=Y(a,n,l);return{lods:c,referenceBoundingBox:c[0].boundingBox,isEsriSymbolResource:a.meta.isEsriSymbolResource,isWosr:!1,remove:a.remove}}function X(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function Y(e,t,s,a){const u=e.model,n=i(),l=new Array,c=new Map,m=new Map;return u.lods.forEach(((e,i)=>{if(void 0!==a&&i!==a)return;const d={name:e.name,stageResources:{textures:new Array,materials:new Array,geometries:new Array},lodThreshold:r(e.lodThreshold)?e.lodThreshold:null,pivotOffset:[0,0,0],numberOfVertices:0,boundingBox:x()};l.push(d),e.parts.forEach((e=>{const i=e.material+(e.attributes.normal?"_normal":"")+(e.attributes.color?"_color":"")+(e.attributes.texCoord0?"_texCoord0":"")+(e.attributes.tangent?"_tangent":""),a=u.materials.get(e.material),l=r(e.attributes.texCoord0),f=r(e.attributes.normal),p=Z(a.alphaMode);if(!c.has(i)){if(l){if(r(a.textureColor)&&!m.has(a.textureColor)){const e=u.textures.get(a.textureColor),t={...e.parameters,preMultiplyAlpha:p!==P.Opaque};m.set(a.textureColor,new D(e.data,t))}if(r(a.textureNormal)&&!m.has(a.textureNormal)){const e=u.textures.get(a.textureNormal);m.set(a.textureNormal,new D(e.data,e.parameters))}if(r(a.textureOcclusion)&&!m.has(a.textureOcclusion)){const e=u.textures.get(a.textureOcclusion);m.set(a.textureOcclusion,new D(e.data,e.parameters))}if(r(a.textureEmissive)&&!m.has(a.textureEmissive)){const e=u.textures.get(a.textureEmissive);m.set(a.textureEmissive,new D(e.data,e.parameters))}if(r(a.textureMetallicRoughness)&&!m.has(a.textureMetallicRoughness)){const e=u.textures.get(a.textureMetallicRoughness);m.set(a.textureMetallicRoughness,new D(e.data,e.parameters))}}const o=a.color[0]**(1/q),n=a.color[1]**(1/q),d=a.color[2]**(1/q),x=a.emissiveFactor[0]**(1/q),g=a.emissiveFactor[1]**(1/q),h=a.emissiveFactor[2]**(1/q),b=r(a.textureColor)&&l?m.get(a.textureColor):null;c.set(i,new U({...t,transparent:p===P.Blend,customDepthTest:V.Lequal,textureAlphaMode:p,textureAlphaCutoff:a.alphaCutoff,diffuse:[o,n,d],ambient:[o,n,d],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?_.None:_.Back,hasVertexColors:!!e.attributes.color,hasVertexTangents:!!e.attributes.tangent,normals:f?"default":"screenDerivative",castShadows:!0,receiveSSAO:!0,textureId:r(b)?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:r(a.textureNormal)&&l?m.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:r(b)&&!!b.params.preMultiplyAlpha,occlusionTextureId:r(a.textureOcclusion)&&l?m.get(a.textureOcclusion).id:void 0,emissiveTextureId:r(a.textureEmissive)&&l?m.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:r(a.textureMetallicRoughness)&&l?m.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[x,g,h],mrrFactors:[a.metallicFactor,a.roughnessFactor,t.mrrFactors[2]],isSchematic:!1,...s}))}const x=ee(e.indices||e.attributes.position.count,e.primitiveType),S=e.attributes.position.count,A=C(h,S);w(A,e.attributes.position,e.transform);const N=[[z.POSITION,{data:A.typedBuffer,size:A.elementCount,exclusive:!0}]],I=[[z.POSITION,x]];if(r(e.attributes.normal)){const t=C(h,S);o(n,e.transform),y(t,e.attributes.normal,n),N.push([z.NORMAL,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([z.NORMAL,x])}if(r(e.attributes.tangent)){const t=C(b,S);o(n,e.transform),O(t,e.attributes.tangent,n),N.push([z.TANGENT,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([z.TANGENT,x])}if(r(e.attributes.texCoord0)){const t=C(R,S);$(t,e.attributes.texCoord0),N.push([z.UV0,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([z.UV0,x])}if(r(e.attributes.color)){const t=C(v,S);if(4===e.attributes.color.elementCount)e.attributes.color instanceof b?E(t,e.attributes.color,255):e.attributes.color instanceof v?H(t,e.attributes.color):e.attributes.color instanceof B&&E(t,e.attributes.color,1/256);else{K(t,255,255,255,255);const r=new M(t.buffer,0,4);e.attributes.color instanceof h?j(r,e.attributes.color,255):e.attributes.color instanceof M?Q(r,e.attributes.color):e.attributes.color instanceof T&&j(r,e.attributes.color,1/256)}N.push([z.COLOR,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([z.COLOR,x])}const L=new G(N,I);d.stageResources.geometries.push(L),d.stageResources.materials.push(c.get(i)),l&&(r(a.textureColor)&&d.stageResources.textures.push(m.get(a.textureColor)),r(a.textureNormal)&&d.stageResources.textures.push(m.get(a.textureNormal)),r(a.textureOcclusion)&&d.stageResources.textures.push(m.get(a.textureOcclusion)),r(a.textureEmissive)&&d.stageResources.textures.push(m.get(a.textureEmissive)),r(a.textureMetallicRoughness)&&d.stageResources.textures.push(m.get(a.textureMetallicRoughness))),d.numberOfVertices+=S;const F=L.boundingInfo;r(F)&&(g(d.boundingBox,F.getBBMin()),g(d.boundingBox,F.getBBMax()))}))})),l}function Z(e){switch(e){case"BLEND":return P.Blend;case"MASK":return P.Mask;case"OPAQUE":case null:case void 0:return P.Opaque}}function ee(e,t){switch(t){case W.TRIANGLES:return L(e);case W.TRIANGLE_STRIP:return I(e);case W.TRIANGLE_FAN:return N(e)}}function te(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];e.customMeta.esriTreeRendering=!0;for(const i of o.parts){const o=i.attributes.normal;if(s(o))return;const x=i.attributes.position,g=x.count,b=p(),R=p(),B=p(),M=C(v,g),T=C(h,g),w=a(u(),i.transform);for(let s=0;s<g;s++){x.getVec(s,R),o.getVec(s,b),n(R,R,i.transform),l(B,R,t.center),c(B,B,t.radius);const a=B[2],u=m(B),p=Math.min(.45+.55*u*u,1);c(B,B,t.radius),n(B,B,w),d(B,B),r+1!==e.model.lods.length&&e.model.lods.length>1&&f(B,B,b,a>-1?.2:Math.min(-4*a-3.8,1)),T.setVec(s,B),M.set(s,0,255*p),M.set(s,1,255*p),M.set(s,2,255*p),M.set(s,3,255)}i.attributes.normal=T,i.attributes.color=M}}}export{J as fetch,Y as gltfToEngineResources,X as parseUrl};
5
+ import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{get as t,isSome as r,isNone as s}from"../../../../core/maybe.js";import{b as o}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a}from"../../../../chunks/mat4.js";import{c as n}from"../../../../chunks/mat4f64.js";import{m as u,b as l,H as c,l as m,n as f,h as d}from"../../../../chunks/vec3.js";import{c as x}from"../../../../chunks/vec3f64.js";import{empty as p,expandWithVec3 as g}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as h,BufferViewVec4f as b,BufferViewVec2f as T,BufferViewVec4u8 as R,BufferViewVec4u16 as v,BufferViewVec3u8 as M,BufferViewVec3u16 as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as w,a as y,s as j}from"../../../../chunks/vec32.js";import{t as O,s as E}from"../../../../chunks/vec42.js";import{createBuffer as C}from"../../../../geometry/support/buffer/utils.js";import{DefaultLoadingContext as S}from"../../glTF/DefaultLoadingContext.js";import{load as A}from"../../glTF/loader.js";import{triangleFanToTriangles as N,triangleStripToTriangles as I,trianglesToTriangles as L}from"../../glTF/internal/indexUtils.js";import{getTransformMatrix as F}from"../../glTF/internal/TextureTransformUtils.js";import{load as k,processLoadResult as P}from"./wosrLoader.js";import{AlphaDiscardMode as V,DepthTestFunction as _,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as D}from"../../webgl-engine/lib/Geometry.js";import{Texture as z}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as U}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as q}from"../../webgl-engine/materials/DefaultMaterial.js";import{COLOR_GAMMA as W}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{PrimitiveType as $}from"../../../webgl/enums.js";import{n as H}from"../../../../chunks/vec22.js";import{c as K,f as Q}from"../../../../chunks/vec43.js";import{c as J}from"../../../../chunks/vec33.js";async function X(s,o){const i=Y(e(s));if("wosr"===i.fileType){const e=await(o.cache?o.cache.loadWOSR(i.url,o):k(i.url,o)),t=P(e,o);return{lods:[t],referenceBoundingBox:t.boundingBox,isEsriSymbolResource:!1,isWosr:!0,remove:e.remove}}const a=await(o.cache?o.cache.loadGLTF(i.url,o,o.usePBR):A(new S(o.streamDataRequester),i.url,o,o.usePBR)),n=t(a.model.meta,"ESRI_proxyEllipsoid");a.meta.isEsriSymbolResource&&r(n)&&a.meta.uri.includes("/RealisticTrees/")&&re(a,n);const u=a.meta.isEsriSymbolResource?{usePBR:o.usePBR,isSchematic:!1,treeRendering:!!a.customMeta.esriTreeRendering,mrrFactors:[0,1,.2]}:{usePBR:o.usePBR,isSchematic:!1,treeRendering:!1,mrrFactors:[0,1,.5]},l={...o.materialParamsMixin,treeRendering:!!a.customMeta.esriTreeRendering};if(null!=i.specifiedLodIndex){const e=Z(a,u,l,i.specifiedLodIndex);let t=e[0].boundingBox;if(0!==i.specifiedLodIndex){t=Z(a,u,l,0)[0].boundingBox}return{lods:e,referenceBoundingBox:t,isEsriSymbolResource:a.meta.isEsriSymbolResource,isWosr:!1,remove:a.remove}}const c=Z(a,u,l);return{lods:c,referenceBoundingBox:c[0].boundingBox,isEsriSymbolResource:a.meta.isEsriSymbolResource,isWosr:!1,remove:a.remove}}function Y(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function Z(e,t,s,a){const n=e.model,u=i(),l=new Array,c=new Map,m=new Map;return n.lods.forEach(((e,i)=>{if(void 0!==a&&i!==a)return;const f={name:e.name,stageResources:{textures:new Array,materials:new Array,geometries:new Array},lodThreshold:r(e.lodThreshold)?e.lodThreshold:null,pivotOffset:[0,0,0],numberOfVertices:0,boundingBox:p()};l.push(f),e.parts.forEach((e=>{const i=e.material+(e.attributes.normal?"_normal":"")+(e.attributes.color?"_color":"")+(e.attributes.texCoord0?"_texCoord0":"")+(e.attributes.tangent?"_tangent":""),a=n.materials.get(e.material),l=r(e.attributes.texCoord0),d=r(e.attributes.normal),x=ee(a.alphaMode);if(!c.has(i)){if(l){if(r(a.textureColor)&&!m.has(a.textureColor)){const e=n.textures.get(a.textureColor),t={...e.parameters,preMultiplyAlpha:x!==V.Opaque};m.set(a.textureColor,new z(e.data,t))}if(r(a.textureNormal)&&!m.has(a.textureNormal)){const e=n.textures.get(a.textureNormal);m.set(a.textureNormal,new z(e.data,e.parameters))}if(r(a.textureOcclusion)&&!m.has(a.textureOcclusion)){const e=n.textures.get(a.textureOcclusion);m.set(a.textureOcclusion,new z(e.data,e.parameters))}if(r(a.textureEmissive)&&!m.has(a.textureEmissive)){const e=n.textures.get(a.textureEmissive);m.set(a.textureEmissive,new z(e.data,e.parameters))}if(r(a.textureMetallicRoughness)&&!m.has(a.textureMetallicRoughness)){const e=n.textures.get(a.textureMetallicRoughness);m.set(a.textureMetallicRoughness,new z(e.data,e.parameters))}}const o=a.color[0]**(1/W),u=a.color[1]**(1/W),f=a.color[2]**(1/W),p=a.emissiveFactor[0]**(1/W),g=a.emissiveFactor[1]**(1/W),h=a.emissiveFactor[2]**(1/W),b=r(a.textureColor)&&l?m.get(a.textureColor):null;c.set(i,new q({...t,transparent:x===V.Blend,customDepthTest:_.Lequal,textureAlphaMode:x,textureAlphaCutoff:a.alphaCutoff,diffuse:[o,u,f],ambient:[o,u,f],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?G.None:G.Back,hasVertexColors:!!e.attributes.color,hasVertexTangents:!!e.attributes.tangent,normals:d?"default":"screenDerivative",castShadows:!0,receiveSSAO:!0,textureId:r(b)?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:r(a.textureNormal)&&l?m.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:r(b)&&!!b.params.preMultiplyAlpha,occlusionTextureId:r(a.textureOcclusion)&&l?m.get(a.textureOcclusion).id:void 0,emissiveTextureId:r(a.textureEmissive)&&l?m.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:r(a.textureMetallicRoughness)&&l?m.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,h],mrrFactors:[a.metallicFactor,a.roughnessFactor,t.mrrFactors[2]],isSchematic:!1,colorTextureTransformMatrix:F(a.colorTextureTransform),normalTextureTransformMatrix:F(a.normalTextureTransform),occlusionTextureTransformMatrix:F(a.occlusionTextureTransform),emissiveTextureTransformMatrix:F(a.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:F(a.metallicRoughnessTextureTransform),...s}))}const p=te(e.indices||e.attributes.position.count,e.primitiveType),S=e.attributes.position.count,A=C(h,S);w(A,e.attributes.position,e.transform);const N=[[U.POSITION,{data:A.typedBuffer,size:A.elementCount,exclusive:!0}]],I=[[U.POSITION,p]];if(r(e.attributes.normal)){const t=C(h,S);o(u,e.transform),y(t,e.attributes.normal,u),N.push([U.NORMAL,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([U.NORMAL,p])}if(r(e.attributes.tangent)){const t=C(b,S);o(u,e.transform),O(t,e.attributes.tangent,u),N.push([U.TANGENT,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([U.TANGENT,p])}if(r(e.attributes.texCoord0)){const t=C(T,S);H(t,e.attributes.texCoord0),N.push([U.UV0,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([U.UV0,p])}if(r(e.attributes.color)){const t=C(R,S);if(4===e.attributes.color.elementCount)e.attributes.color instanceof b?E(t,e.attributes.color,255):e.attributes.color instanceof R?K(t,e.attributes.color):e.attributes.color instanceof v&&E(t,e.attributes.color,1/256);else{Q(t,255,255,255,255);const r=new M(t.buffer,0,4);e.attributes.color instanceof h?j(r,e.attributes.color,255):e.attributes.color instanceof M?J(r,e.attributes.color):e.attributes.color instanceof B&&j(r,e.attributes.color,1/256)}N.push([U.COLOR,{data:t.typedBuffer,size:t.elementCount,exclusive:!0}]),I.push([U.COLOR,p])}const L=new D(N,I);f.stageResources.geometries.push(L),f.stageResources.materials.push(c.get(i)),l&&(r(a.textureColor)&&f.stageResources.textures.push(m.get(a.textureColor)),r(a.textureNormal)&&f.stageResources.textures.push(m.get(a.textureNormal)),r(a.textureOcclusion)&&f.stageResources.textures.push(m.get(a.textureOcclusion)),r(a.textureEmissive)&&f.stageResources.textures.push(m.get(a.textureEmissive)),r(a.textureMetallicRoughness)&&f.stageResources.textures.push(m.get(a.textureMetallicRoughness))),f.numberOfVertices+=S;const k=L.boundingInfo;r(k)&&(g(f.boundingBox,k.getBBMin()),g(f.boundingBox,k.getBBMax()))}))})),l}function ee(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function te(e,t){switch(t){case $.TRIANGLES:return L(e);case $.TRIANGLE_STRIP:return I(e);case $.TRIANGLE_FAN:return N(e)}}function re(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];e.customMeta.esriTreeRendering=!0;for(const i of o.parts){const o=i.attributes.normal;if(s(o))return;const p=i.attributes.position,g=p.count,b=x(),T=x(),v=x(),M=C(R,g),B=C(h,g),w=a(n(),i.transform);for(let s=0;s<g;s++){p.getVec(s,T),o.getVec(s,b),u(T,T,i.transform),l(v,T,t.center),c(v,v,t.radius);const a=v[2],n=m(v),x=Math.min(.45+.55*n*n,1);c(v,v,t.radius),u(v,v,w),f(v,v),r+1!==e.model.lods.length&&e.model.lods.length>1&&d(v,v,b,a>-1?.2:Math.min(-4*a-3.8,1)),B.setVec(s,v),M.set(s,0,255*x),M.set(s,1,255*x),M.set(s,2,255*x),M.set(s,3,255)}i.attributes.normal=B,i.attributes.color=M}}}export{X as fetch,Z as gltfToEngineResources,Y as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import s from"../../../../core/Logger.js";import{isNone as i,isSome as o}from"../../../../core/maybe.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{C as c}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{m as p,c as h}from"../../../../chunks/vec3.js";import{c as d}from"../../../../chunks/vec3f64.js";import{empty as m,expand as f}from"../../../../geometry/support/aaBoundingRect.js";import{a as u,g as v}from"../../../../chunks/sphere.js";import{newIntersector as _}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as g}from"../../webgl-engine/lib/IntersectorInterfaces.js";const x=m(),y=l(),j=d(),E=d(),b=d();let R=class extends(r.EventedMixin(t)){constructor(e){super(e),this._tmpEvent={spatialReference:null,extent:x,context:"scene"}}initialize(){this.view=this.layerView.view,this._renderCoordsHelper=this.view.renderCoordsHelper,this._intersector=_(this.view.state.viewingMode),this._intersector.options.store=g.MIN;const e=this.layerView.i3slayer.fullExtent;i(e)?s.getLogger(this.declaredClass).error("I3SElevationProvider expected fullExtent on I3SLayer."):(this._zmin=e.zmin,this._zmax=e.zmax),this._tmpEvent.context=this.intersectionHandler.isGround?"ground":"scene"}getElevation(e,t,r,i){if(j[0]=e,j[1]=t,j[2]=r,!this._renderCoordsHelper.toRenderCoords(j,i,j))return s.getLogger(this.declaredClass).error("could not project point to compute elevation"),null;const o=this.layerView.elevationOffset,n=this._zmin+o,a=this._zmax+o;return this._renderCoordsHelper.setAltitude(E,a,j),this._renderCoordsHelper.setAltitude(b,n,j),this._intersector.reset(E,b,null),this.intersectionHandler.intersect(this._intersector,null,E,b),this._intersector.results.min.getIntersectionPoint(j)?this._renderCoordsHelper.getAltitude(j):null}layerChanged(){this.spatialReference&&(this._tmpEvent.extent=this._computeLayerExtent(),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}objectChanged(e){this.spatialReference&&(this._tmpEvent.extent=this._computeObjectExtent(e),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}_computeObjectExtent(e){return m(x),this._expandExtent(e,x),x}_computeLayerExtent(){m(x);for(const e of this.layerView.getVisibleNodes())this._expandExtent(e,x);return x}_expandExtent(e,t){const r=e.visibilityObb||e.serviceObbInRenderSR;if(o(r)){c(y,r.quaternion),y[12]=r.center[0],y[13]=r.center[1],y[14]=r.center[2];for(let e=0;e<8;++e)j[0]=1&e?r.halfSize[0]:-r.halfSize[0],j[1]=2&e?r.halfSize[1]:-r.halfSize[1],j[2]=4&e?r.halfSize[2]:-r.halfSize[2],p(j,j,y),this._renderCoordsHelper.fromRenderCoords(j,j,this.spatialReference),f(t,j,t)}else{const r=u(e.renderMbs),s=h(E,v(e.renderMbs));s[0]-=r,s[1]-=r,s[2]-=r;const i=h(b,v(e.renderMbs));i[0]+=r,i[1]+=r,i[2]+=r;for(let e=0;e<8;++e)j[0]=1&e?s[0]:i[0],j[1]=2&e?s[1]:i[1],j[2]=4&e?s[2]:i[2],this._renderCoordsHelper.fromRenderCoords(j,j,this.spatialReference),f(t,j,t)}}};e([n({constructOnly:!0})],R.prototype,"layerView",void 0),e([n({constructOnly:!0})],R.prototype,"intersectionHandler",void 0),e([n()],R.prototype,"view",void 0),e([n({readOnly:!0,aliasOf:"view.elevationProvider.spatialReference"})],R.prototype,"spatialReference",void 0),R=e([a("esri.views.3d.layers.i3s.I3SElevationProvider")],R);const C=R;export{C as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import s from"../../../../core/Logger.js";import{isNone as i,isSome as o}from"../../../../core/maybe.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{C as a}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{m as p,c as h}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{empty as d,expand as f}from"../../../../geometry/support/aaBoundingRect.js";import{a as u,g as v}from"../../../../chunks/sphere.js";import{newIntersector as _}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as g}from"../../webgl-engine/lib/IntersectorInterfaces.js";const x=d(),y=l(),j=m(),E=m(),b=m();let R=class extends(r.EventedMixin(t)){constructor(e){super(e),this._tmpEvent={spatialReference:null,extent:x,context:"scene"}}get spatialReference(){return this.view?.elevationProvider?.spatialReference}initialize(){this.view=this.layerView.view,this._renderCoordsHelper=this.view.renderCoordsHelper,this._intersector=_(this.view.state.viewingMode),this._intersector.options.store=g.MIN;const e=this.layerView.i3slayer.fullExtent;i(e)?s.getLogger(this.declaredClass).error("I3SElevationProvider expected fullExtent on I3SLayer."):(this._zmin=e.zmin,this._zmax=e.zmax),this._tmpEvent.context=this.intersectionHandler.isGround?"ground":"scene"}getElevation(e,t,r,i){if(j[0]=e,j[1]=t,j[2]=r,!this._renderCoordsHelper.toRenderCoords(j,i,j))return s.getLogger(this.declaredClass).error("could not project point to compute elevation"),null;const o=this.layerView.elevationOffset,n=this._zmin+o,c=this._zmax+o;return this._renderCoordsHelper.setAltitude(E,c,j),this._renderCoordsHelper.setAltitude(b,n,j),this._intersector.reset(E,b,null),this.intersectionHandler.intersect(this._intersector,null,E,b),this._intersector.results.min.getIntersectionPoint(j)?this._renderCoordsHelper.getAltitude(j):null}layerChanged(){this.spatialReference&&(this._tmpEvent.extent=this._computeLayerExtent(),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}objectChanged(e){this.spatialReference&&(this._tmpEvent.extent=this._computeObjectExtent(e),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}_computeObjectExtent(e){return d(x),this._expandExtent(e,x),x}_computeLayerExtent(){d(x);for(const e of this.layerView.getVisibleNodes())this._expandExtent(e,x);return x}_expandExtent(e,t){const r=this.spatialReference;if(i(r))return;const s=e.visibilityObb||e.serviceObbInRenderSR;if(o(s)){a(y,s.quaternion),y[12]=s.center[0],y[13]=s.center[1],y[14]=s.center[2];for(let e=0;e<8;++e)j[0]=1&e?s.halfSize[0]:-s.halfSize[0],j[1]=2&e?s.halfSize[1]:-s.halfSize[1],j[2]=4&e?s.halfSize[2]:-s.halfSize[2],p(j,j,y),this._renderCoordsHelper.fromRenderCoords(j,j,r),f(t,j,t)}else{const s=u(e.renderMbs),i=h(E,v(e.renderMbs));i[0]-=s,i[1]-=s,i[2]-=s;const o=h(b,v(e.renderMbs));o[0]+=s,o[1]+=s,o[2]+=s;for(let e=0;e<8;++e)j[0]=1&e?i[0]:o[0],j[1]=2&e?i[1]:o[1],j[2]=4&e?i[2]:o[2],this._renderCoordsHelper.fromRenderCoords(j,j,r),f(t,j,t)}}};e([n({constructOnly:!0})],R.prototype,"layerView",void 0),e([n({constructOnly:!0})],R.prototype,"intersectionHandler",void 0),e([n()],R.prototype,"view",void 0),e([n()],R.prototype,"spatialReference",null),R=e([c("esri.views.3d.layers.i3s.I3SElevationProvider")],R);const C=R;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.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{isNone as n}from"../../../../core/maybe.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import a from"../../../../geometry/Extent.js";import{QueryEngine as u}from"../../../../layers/graphics/data/QueryEngine.js";import y from"../../../../rest/support/FeatureSet.js";import c from"../../../../rest/support/Query.js";const l=u;let p=class extends r{constructor(e){super(e),this._dataQueryEngineInstance=null,this._handles=new s}get defaultQueryJSON(){return new c({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}initialize(){this._handles.add(this.layerView.on("visible-geometry-changed",(()=>this.spatialIndex.events.emit("changed"))))}destroy(){this._dataQueryEngineInstance&&(this._dataQueryEngineInstance.destroy(),this._dataQueryEngineInstance=null),this._handles&&(this._handles.destroy(),this._handles=null),this._set("layerView",null)}async executeQueryForCount(e,r){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),r)}async executeQueryForExtent(e,r){const{count:t,extent:s}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),r);return{count:t,extent:a.fromJSON(s)}}async executeQueryForIds(e,r){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),r)}async executeQuery(e,r){const s=this._ensureQueryJSON(e);if(s.returnGeometry)throw new t("feature-store:unsupported-query","returnGeometry is not yet supported for mesh scene layer queries");if(s.returnCentroid)throw new t("feature-store:unsupported-query","returnCentroid is not yet supported for mesh scene layer queries");const n=await this._dataQueryEngine.executeQuery(s,r),o=y.fromJSON(n);return o.features.forEach((e=>{e.geometry=null})),o}_ensureQueryJSON(e){return n(e)?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const e=this.layer.objectIdField||"OBJECTID",r="esriGeometryPolygon",t=this.layer.fields.map((e=>e.toJSON())),s=this.layerView.view.resourceController.scheduler,n=this.spatialReference.toJSON(),o=this.priority,i=this.spatialIndex;return this._dataQueryEngineInstance=new l({hasZ:!0,hasM:!1,geometryType:r,fields:t,timeInfo:null,spatialReference:n,objectIdField:e,featureStore:i,scheduler:s,priority:o}),this._dataQueryEngineInstance}};e([o({constructOnly:!0})],p.prototype,"layerView",void 0),e([o({constructOnly:!0})],p.prototype,"priority",void 0),e([o({constructOnly:!0})],p.prototype,"spatialIndex",void 0),e([o({readOnly:!0,aliasOf:"layerView.view.spatialReference"})],p.prototype,"spatialReference",void 0),e([o({readOnly:!0,aliasOf:"layerView.i3slayer"})],p.prototype,"layer",void 0),e([o({readOnly:!0})],p.prototype,"defaultQueryJSON",null),p=e([i("esri.views.3d.layers.i3s.I3SQueryEngine")],p);export{p as I3SQueryEngine};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{isNone as n}from"../../../../core/maybe.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import a from"../../../../geometry/Extent.js";import{QueryEngine as u}from"../../../../layers/graphics/data/QueryEngine.js";import y from"../../../../rest/support/FeatureSet.js";import c from"../../../../rest/support/Query.js";const l=u;let p=class extends r{constructor(e){super(e),this._dataQueryEngineInstance=null,this._handles=new s}get spatialReference(){return this.layerView.view.spatialReference}get layer(){return this.layerView.i3slayer}get defaultQueryJSON(){return new c({outSpatialReference:this.spatialReference}).toJSON()}get _dataQueryEngine(){return this._ensureDataQueryEngine()}initialize(){this._handles.add(this.layerView.on("visible-geometry-changed",(()=>this.spatialIndex.events.emit("changed"))))}destroy(){this._dataQueryEngineInstance&&(this._dataQueryEngineInstance.destroy(),this._dataQueryEngineInstance=null),this._handles&&(this._handles.destroy(),this._handles=null),this._set("layerView",null)}async executeQueryForCount(e,r){return this._dataQueryEngine.executeQueryForCount(this._ensureQueryJSON(e),r)}async executeQueryForExtent(e,r){const{count:t,extent:s}=await this._dataQueryEngine.executeQueryForExtent(this._ensureQueryJSON(e),r);return{count:t,extent:a.fromJSON(s)}}async executeQueryForIds(e,r){return this._dataQueryEngine.executeQueryForIds(this._ensureQueryJSON(e),r)}async executeQuery(e,r){const s=this._ensureQueryJSON(e);if(s.returnGeometry)throw new t("feature-store:unsupported-query","returnGeometry is not yet supported for mesh scene layer queries");if(s.returnCentroid)throw new t("feature-store:unsupported-query","returnCentroid is not yet supported for mesh scene layer queries");const n=await this._dataQueryEngine.executeQuery(s,r),o=y.fromJSON(n);return o.features.forEach((e=>{e.geometry=null})),o}_ensureQueryJSON(e){return n(e)?this.defaultQueryJSON:e.toJSON()}_ensureDataQueryEngine(){if(this._dataQueryEngineInstance)return this._dataQueryEngineInstance;const e=this.layer.objectIdField||"OBJECTID",r="esriGeometryPolygon",t=this.layer.fields.map((e=>e.toJSON())),s=this.layerView.view.resourceController.scheduler,n=this.spatialReference.toJSON(),o=this.priority,i=this.spatialIndex;return this._dataQueryEngineInstance=new l({hasZ:!0,hasM:!1,geometryType:r,fields:t,timeInfo:null,spatialReference:n,objectIdField:e,featureStore:i,scheduler:s,priority:o}),this._dataQueryEngineInstance}};e([o({constructOnly:!0})],p.prototype,"layerView",void 0),e([o({constructOnly:!0})],p.prototype,"priority",void 0),e([o({constructOnly:!0})],p.prototype,"spatialIndex",void 0),e([o()],p.prototype,"spatialReference",null),e([o()],p.prototype,"layer",null),e([o()],p.prototype,"defaultQueryJSON",null),p=e([i("esri.views.3d.layers.i3s.I3SQueryEngine")],p);export{p as I3SQueryEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import e from"../../../../core/Handles.js";import{initial as r}from"../../../../core/reactiveUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as i}from"../../../../core/support/WatchUpdatingTracking.js";import{TileTreeDebugger as a}from"../../../support/TileTreeDebugger.js";import p from"../../../../geometry/Polygon.js";let n=class extends a{constructor(t){super(t),this._watchUpdatingTracking=new i,this._handles=new e}initialize(){const{featureTiles:t}=this.view;this._handles.add(t.addClient()),this._watchUpdatingTracking.addOnCollectionChange((()=>t?.tiles),(()=>this.update()),r)}destroy(){this._handles&&(this._handles.destroy(),this._handles=null),this._watchUpdatingTracking.destroy()}getTiles(){const t=t=>{const[e,r,o]=t.lij;return p.fromExtent(this.view.featureTiles.tilingScheme.getExtentGeometry(e,r,o))};return this.view.featureTiles.tiles.toArray().sort(((t,e)=>t.loadPriority-e.loadPriority)).map((e=>({...e,geometry:t(e)})))}};t([o({readOnly:!0})],n.prototype,"_watchUpdatingTracking",void 0),t([o({readOnly:!0,aliasOf:"watchUpdatingTracking.updating"})],n.prototype,"updating",void 0),t([o()],n.prototype,"view",void 0),n=t([s("esri.views.3d.layers.support.FeatureTileTree3DDebugger")],n);export{n as FeatureTileTree3DDebugger};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import e from"../../../../core/Handles.js";import{initial as r}from"../../../../core/reactiveUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as i}from"../../../../core/support/WatchUpdatingTracking.js";import{TileTreeDebugger as a}from"../../../support/TileTreeDebugger.js";import p from"../../../../geometry/Polygon.js";let n=class extends a{constructor(t){super(t),this._watchUpdatingTracking=new i,this._handles=new e}get updating(){return this._watchUpdatingTracking?.updating??!1}initialize(){const{featureTiles:t}=this.view;this._handles.add(t.addClient()),this._watchUpdatingTracking.addOnCollectionChange((()=>t?.tiles),(()=>this.update()),r)}destroy(){this._handles&&(this._handles.destroy(),this._handles=null),this._watchUpdatingTracking.destroy()}getTiles(){const t=t=>{const[e,r,o]=t.lij;return p.fromExtent(this.view.featureTiles.tilingScheme.getExtentGeometry(e,r,o))};return this.view.featureTiles.tiles.toArray().sort(((t,e)=>t.loadPriority-e.loadPriority)).map((e=>({...e,geometry:t(e)})))}};t([o()],n.prototype,"_watchUpdatingTracking",void 0),t([o()],n.prototype,"updating",null),t([o()],n.prototype,"view",void 0),n=t([s("esri.views.3d.layers.support.FeatureTileTree3DDebugger")],n);export{n as FeatureTileTree3DDebugger};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import o from"../../../../core/Evented.js";import r from"../../../../core/Handles.js";import s from"../../../../core/Logger.js";import{unwrapOr as i}from"../../../../core/maybe.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec3.js";import{c as d}from"../../../../chunks/vec3f64.js";import{empty as m,toRect as p,expandWithVec3 as h}from"../../../../geometry/support/aaBoundingBox.js";import{empty as u}from"../../../../geometry/support/aaBoundingRect.js";import{getMetersPerUnit as f}from"../../../../symbols/support/unitConversionUtils.js";import{newIntersector as _}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as y}from"../../webgl-engine/lib/IntersectorInterfaces.js";const j=1;let g=class extends(o.EventedMixin(t)){constructor(e){super(e),this._elevationOffset=0,this._layerHandes=new r}initialize(){this._renderCoordsHelper=this.view.renderCoordsHelper,this._intersectLayers=[this.stageLayer],this._intersector=_(this.view.state.viewingMode),this._intersector.options.store=y.MIN;const e=this._computeLayerExtent(this.stageLayer);this._zmin=e[2],this._zmax=e[5];const t=this.stageLayer.events;this._layerHandes.add([t.on("layerObjectAdded",(e=>this._objectChanged(e.object))),t.on("layerObjectRemoved",(e=>this._objectChanged(e.object))),t.on("objectGeometryAdded",(e=>this._objectChanged(e.object))),t.on("objectGeometryRemoved",(e=>this._objectChanged(e.object))),t.on("vertexAttrsUpdated",(e=>this._objectChanged(e.object))),t.on("objectTransformation",(e=>this._objectChanged(e)))])}dispose(){this._layerHandes.destroy()}elevationInfoChanged(){const e=null!=this.layer?this.layer.elevationInfo:null;if(null!=e&&"on-the-ground"!==e.mode){const t=n(this.layer.spatialReference),o=f(e.unit);this._elevationOffset=i(e.offset,0)*o/t}else this._elevationOffset=0}getElevation(e,t,o,r){if(C[0]=e,C[1]=t,C[2]=o,!this._renderCoordsHelper.toRenderCoords(C,r,C))return s.getLogger(this.declaredClass).error("could not project point for elevation alignment"),null;const i=this._elevationOffset,n=this._zmin+i,a=this._zmax+i;this._renderCoordsHelper.setAltitude(E,a,C),this._renderCoordsHelper.setAltitude(B,n,C);const l=e=>e.metadata&&e.metadata.isElevationSource;return this._intersector.reset(E,B,null),this._intersector.intersect(this._intersectLayers,null,j,null,l),this._intersector.results.min.getIntersectionPoint(C)?this._renderCoordsHelper.getAltitude(C):null}_objectChanged(e){if(!e.metadata?.isElevationSource||!this.spatialReference)return;m(v),e.metadata.lastValidElevationBB.isEmpty()||this._expandExtent(e.metadata.lastValidElevationBB.min,e.metadata.lastValidElevationBB.max,v);const t=e.boundingVolumeWorldSpace.min,o=e.boundingVolumeWorldSpace.max;this._expandExtent(t,o,v),p(v,b),this._zmin=Math.min(this._zmin,v[2]),this._zmax=Math.max(this._zmax,v[5]),x.extent=b,x.spatialReference=this.spatialReference,this.emit("elevation-change",x),c(e.metadata.lastValidElevationBB.min,t),c(e.metadata.lastValidElevationBB.max,o)}_computeLayerExtent(e){return m(v),e.objects.forAll((e=>this._expandExtent(e.boundingVolumeWorldSpace.min,e.boundingVolumeWorldSpace.max,v))),v}_expandExtent(e,t,o){for(let r=0;r<8;++r)C[0]=1&r?e[0]:t[0],C[1]=2&r?e[1]:t[1],C[2]=4&r?e[2]:t[2],this._renderCoordsHelper.fromRenderCoords(C,C,this.spatialReference),h(o,C);return o}};e([a({constructOnly:!0})],g.prototype,"layer",void 0),e([a({constructOnly:!0})],g.prototype,"stageLayer",void 0),e([a({constructOnly:!0})],g.prototype,"view",void 0),e([a({readOnly:!0,aliasOf:"view.spatialReference"})],g.prototype,"spatialReference",void 0),g=e([l("esri.views.3d.layers.support.StageLayerElevationProvider")],g);const v=m(),b=u(),x={spatialReference:null,extent:b,context:"scene"},C=d(),E=d(),B=d();export{g as StageLayerElevationProvider};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import o from"../../../../core/Evented.js";import r from"../../../../core/Handles.js";import s from"../../../../core/Logger.js";import{unwrapOr as n,isNone as i,isSome as a}from"../../../../core/maybe.js";import{getMetersPerVerticalUnitForSR as c}from"../../../../core/unitUtils.js";import{property as l}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as m}from"../../../../chunks/vec3.js";import{c as p}from"../../../../chunks/vec3f64.js";import{empty as h,toRect as u,expandWithVec3 as f}from"../../../../geometry/support/aaBoundingBox.js";import{empty as _}from"../../../../geometry/support/aaBoundingRect.js";import{getMetersPerUnit as j}from"../../../../symbols/support/unitConversionUtils.js";import{newIntersector as y}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as g}from"../../webgl-engine/lib/IntersectorInterfaces.js";const v=1;let b=class extends(o.EventedMixin(t)){constructor(e){super(e),this._elevationOffset=0,this._layerHandes=new r}get spatialReference(){return this.view?.spatialReference}initialize(){this._renderCoordsHelper=this.view.renderCoordsHelper,this._intersectLayers=[this.stageLayer],this._intersector=y(this.view.state.viewingMode),this._intersector.options.store=g.MIN;const e=this._computeLayerExtent(this.spatialReference,this.stageLayer);this._zmin=e[2],this._zmax=e[5];const t=this.stageLayer.events;this._layerHandes.add([t.on("layerObjectAdded",(e=>this._objectChanged(e.object))),t.on("layerObjectRemoved",(e=>this._objectChanged(e.object))),t.on("objectGeometryAdded",(e=>this._objectChanged(e.object))),t.on("objectGeometryRemoved",(e=>this._objectChanged(e.object))),t.on("vertexAttrsUpdated",(e=>this._objectChanged(e.object))),t.on("objectTransformation",(e=>this._objectChanged(e)))])}dispose(){this._layerHandes.destroy()}elevationInfoChanged(){const e=null!=this.layer?this.layer.elevationInfo:null;if(null!=e&&"on-the-ground"!==e.mode){const t=c(this.layer.spatialReference),o=j(e.unit);this._elevationOffset=n(e.offset,0)*o/t}else this._elevationOffset=0}getElevation(e,t,o,r){if(R[0]=e,R[1]=t,R[2]=o,!this._renderCoordsHelper.toRenderCoords(R,r,R))return s.getLogger(this.declaredClass).error("could not project point for elevation alignment"),null;const n=this._elevationOffset,i=this._zmin+n,a=this._zmax+n;this._renderCoordsHelper.setAltitude(H,a,R),this._renderCoordsHelper.setAltitude(L,i,R);const c=e=>e.metadata&&e.metadata.isElevationSource;return this._intersector.reset(H,L,null),this._intersector.intersect(this._intersectLayers,null,v,null,c),this._intersector.results.min.getIntersectionPoint(R)?this._renderCoordsHelper.getAltitude(R):null}_objectChanged(e){const t=this.spatialReference;if(!e.metadata?.isElevationSource||i(t))return;h(x);const{lastValidElevationBB:o}=e.metadata;o.isEmpty()||this._expandExtent(t,o.min,o.max,x);const{min:r,max:s}=e.boundingVolumeWorldSpace;this._expandExtent(t,r,s,x),u(x,C),this._zmin=Math.min(this._zmin,x[2]),this._zmax=Math.max(this._zmax,x[5]),E.extent=C,E.spatialReference=t,this.emit("elevation-change",E),m(o.min,r),m(o.max,s)}_computeLayerExtent(e,t){return h(x),a(e)&&t.objects.forAll((t=>this._expandExtent(e,t.boundingVolumeWorldSpace.min,t.boundingVolumeWorldSpace.max,x))),x}_expandExtent(e,t,o,r){for(let s=0;s<8;++s)R[0]=1&s?t[0]:o[0],R[1]=2&s?t[1]:o[1],R[2]=4&s?t[2]:o[2],this._renderCoordsHelper.fromRenderCoords(R,R,e),f(r,R);return r}};e([l({constructOnly:!0})],b.prototype,"layer",void 0),e([l({constructOnly:!0})],b.prototype,"stageLayer",void 0),e([l({constructOnly:!0})],b.prototype,"view",void 0),e([l()],b.prototype,"spatialReference",null),b=e([d("esri.views.3d.layers.support.StageLayerElevationProvider")],b);const x=h(),C=_(),E={spatialReference:null,extent:C,context:"scene"},R=p(),H=p(),L=p();export{b as StageLayerElevationProvider};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{destroyMaybe as s,isNone as i,isSome as o}from"../../../core/maybe.js";import{createResolver as n,isAbortError as a}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{equals as h}from"../../../geometry/support/spatialReferenceUtils.js";import{ElevationQuery as u}from"../layers/graphics/ElevationQuery.js";let p=class extends(r.EventedMixin(t)){constructor(e){super(e),this._im=new Array,this._ground=new Array,this._scene=new Array,this._handles=new Map,this.lastElevationQuery=null,this.elevationCacheEnabled=!1}destroy(){this._elevationQueryCached=s(this._elevationQueryCached)}get _elevationQuery(){return i(this._elevationQueryCached)&&(this._elevationQueryCached=new u(this.view.resourceController.scheduler,this.view.spatialReference,(()=>this.view.map&&this.view.map.ground),{maximumAutoTileRequests:4})),this._elevationQueryCached}enableElevationCache(e){e||(this.lastElevationQuery=null),this.elevationCacheEnabled=e}getElevation(e,t,r,s,o){if(this.elevationCacheEnabled&&null!=this.lastElevationQuery){const i=this.lastElevationQuery;if(e===i.x&&t===i.y&&r===i.z&&h(s,i.spatialReference)&&o===i.queryContext)return i.result}let n=null;return n=v(n,this._im,e,t,r,s,o),i(n)&&(n=v(n,this._ground,e,t,r,s,o)),"scene"===o&&(n=v(n,this._scene,e,t,r,s,o)),this.elevationCacheEnabled&&(this.lastElevationQuery={x:e,y:t,z:r,spatialReference:s,queryContext:o,result:n}),n}queryElevation(e,t,r,s,i,o=null,l=0){const c=n();return this._elevationQuery.queryElevation(e,t,o,l).then((o=>{"scene"===i&&(o=v(o,this._scene,e,t,r,s,i)),c.resolve(o)})).catch((o=>{a(o)?c.reject(o):c.resolve(this.getElevation(e,t,r,s,i))})),c.promise}register(e,t){this._handles.set(t,t.on("elevation-change",(e=>this.emit("elevation-change",e)))),this._providersFromContext(e).push(t)}unregister(e){this._handles.has(e)&&(this._handles.get(e).remove(),this._handles.delete(e));for(const t of[this._im,this._ground,this._scene]){const r=t.indexOf(e);r>-1&&t.splice(r,1)}}_providersFromContext(e){switch(e){case"ground":return this._ground;case"im":return this._im;case"scene":return this._scene}}};function v(e,t,r,s,i,n,a){for(const l of t){const t=l.getElevation(r,s,i,n,a);o(t)&&(e=o(e)?Math.max(t,e):t)}return e}e([l({constructOnly:!0})],p.prototype,"view",void 0),e([l({readOnly:!0,aliasOf:"view.basemapTerrain.spatialReference"})],p.prototype,"spatialReference",void 0),p=e([c("esri.views.3d.support.CombinedElevationProvider")],p);export{p as CombinedElevationProvider};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{destroyMaybe as s,isNone as i,isSome as o}from"../../../core/maybe.js";import{createResolver as n,isAbortError as a}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{equals as h}from"../../../geometry/support/spatialReferenceUtils.js";import{ElevationQuery as u}from"../layers/graphics/ElevationQuery.js";let p=class extends(r.EventedMixin(t)){constructor(e){super(e),this._im=new Array,this._ground=new Array,this._scene=new Array,this._handles=new Map,this.lastElevationQuery=null,this.elevationCacheEnabled=!1}get spatialReference(){return this.view?.basemapTerrain?.spatialReference}destroy(){this._elevationQueryCached=s(this._elevationQueryCached)}get _elevationQuery(){return i(this._elevationQueryCached)&&(this._elevationQueryCached=new u(this.view.resourceController.scheduler,this.view.spatialReference,(()=>this.view.map&&this.view.map.ground),{maximumAutoTileRequests:4})),this._elevationQueryCached}enableElevationCache(e){e||(this.lastElevationQuery=null),this.elevationCacheEnabled=e}getElevation(e,t,r,s,o){if(this.elevationCacheEnabled&&null!=this.lastElevationQuery){const i=this.lastElevationQuery;if(e===i.x&&t===i.y&&r===i.z&&h(s,i.spatialReference)&&o===i.queryContext)return i.result}let n=null;return n=m(n,this._im,e,t,r,s,o),i(n)&&(n=m(n,this._ground,e,t,r,s,o)),"scene"===o&&(n=m(n,this._scene,e,t,r,s,o)),this.elevationCacheEnabled&&(this.lastElevationQuery={x:e,y:t,z:r,spatialReference:s,queryContext:o,result:n}),n}queryElevation(e,t,r,s,i,o=null,l=0){const c=n();return this._elevationQuery.queryElevation(e,t,o,l).then((o=>{"scene"===i&&(o=m(o,this._scene,e,t,r,s,i)),c.resolve(o)})).catch((o=>{a(o)?c.reject(o):c.resolve(this.getElevation(e,t,r,s,i))})),c.promise}register(e,t){this._handles.set(t,t.on("elevation-change",(e=>this.emit("elevation-change",e)))),this._providersFromContext(e).push(t)}unregister(e){this._handles.has(e)&&(this._handles.get(e).remove(),this._handles.delete(e));for(const t of[this._im,this._ground,this._scene]){const r=t.indexOf(e);r>-1&&t.splice(r,1)}}_providersFromContext(e){switch(e){case"ground":return this._ground;case"im":return this._im;case"scene":return this._scene}}};function m(e,t,r,s,i,n,a){for(const l of t){const t=l.getElevation(r,s,i,n,a);o(t)&&(e=o(e)?Math.max(t,e):t)}return e}e([l({constructOnly:!0})],p.prototype,"view",void 0),e([l()],p.prototype,"spatialReference",null),p=e([c("esri.views.3d.support.CombinedElevationProvider")],p);export{p as CombinedElevationProvider};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Handles.js";import{isNone as o}from"../../../../core/maybe.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{watch as i,on as a}from"../../../../core/reactiveUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec3f64.js";import p from"../../../../geometry/Point.js";import{center as u}from"../../../../geometry/support/aaBoundingRect.js";let h=class extends t{constructor(e){super(e),this.location=null,this._updateController=null,this._handles=new r}get renderLocation(){if(!this.location)return null;const e=c();return this.view.renderCoordsHelper.toRenderCoords(this.location,e),e}initialize(){this.view.state.isLocal&&(this._handles.add([i((()=>[this.surfaceView?.spatialReference,this.surfaceView?.extent]),(()=>this._update())),a((()=>this.surface?.layers),"change",(()=>this._update()))]),this._update())}destroy(){this._handles.destroy()}_update(){if(this._updateController&&(this._updateController.abort(),this._updateController=null),!this.surfaceView||o(this.surfaceView.extent)||o(this.surfaceView.spatialReference))return void this._set("location",null);const e=u(this.surfaceView.extent),t=new p({x:e[0],y:e[1],z:0,spatialReference:this.surfaceView.spatialReference});this.surface&&this.surface.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this.surface.queryElevation(t,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then((e=>{this._updateController=null,this._set("location",e.geometry)})).catch((e=>{s(e)||e&&"elevation-query:invalid-layer"===e.name||console.error("StableSurfaceCenter failed to update: ",e)}))):this._set("location",t)}};e([n({constructOnly:!0})],h.prototype,"view",void 0),e([n({constructOnly:!0})],h.prototype,"cache",void 0),e([n({readOnly:!0,aliasOf:"view.map.ground"})],h.prototype,"surface",void 0),e([n({readOnly:!0,aliasOf:"view.basemapTerrain"})],h.prototype,"surfaceView",void 0),e([n({readOnly:!0})],h.prototype,"location",void 0),e([n({readOnly:!0})],h.prototype,"renderLocation",null),h=e([l("esri.views.3d.terrain.StableSurfaceCenter")],h);export{h as StableSurfaceCenter};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Handles.js";import{isNone as o}from"../../../../core/maybe.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{watch as i,on as a}from"../../../../core/reactiveUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec3f64.js";import u from"../../../../geometry/Point.js";import{center as p}from"../../../../geometry/support/aaBoundingRect.js";let h=class extends t{constructor(e){super(e),this.location=null,this._updateController=null,this._handles=new r}get surface(){return this.view.map?.ground}get surfaceView(){return this.view.basemapTerrain}get renderLocation(){if(!this.location)return null;const e=c();return this.view.renderCoordsHelper.toRenderCoords(this.location,e),e}initialize(){this.view.state.isLocal&&(this._handles.add([i((()=>[this.surfaceView?.spatialReference,this.surfaceView?.extent]),(()=>this._update())),a((()=>this.surface?.layers),"change",(()=>this._update()))]),this._update())}destroy(){this._handles.destroy()}_update(){if(this._updateController&&(this._updateController.abort(),this._updateController=null),!this.surfaceView||o(this.surfaceView.extent)||o(this.surfaceView.spatialReference))return void this._set("location",null);const e=p(this.surfaceView.extent),t=new u({x:e[0],y:e[1],z:0,spatialReference:this.surfaceView.spatialReference});this.surface&&this.surface.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this.surface.queryElevation(t,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then((e=>{this._updateController=null,this._set("location",e.geometry)})).catch((e=>{s(e)||e&&"elevation-query:invalid-layer"===e.name||console.error("StableSurfaceCenter failed to update: ",e)}))):this._set("location",t)}};e([n({constructOnly:!0})],h.prototype,"view",void 0),e([n({constructOnly:!0})],h.prototype,"cache",void 0),e([n()],h.prototype,"surface",null),e([n()],h.prototype,"surfaceView",null),e([n({readOnly:!0})],h.prototype,"location",void 0),e([n({readOnly:!0})],h.prototype,"renderLocation",null),h=e([l("esri.views.3d.terrain.StableSurfaceCenter")],h);export{h as StableSurfaceCenter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.25/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import i from"../../../core/Handles.js";import has from"../../../core/has.js";import{clamp as a,deg2rad as n}from"../../../core/mathUtils.js";import{isSome as o,isNone as l,unwrap as h}from"../../../core/maybe.js";import{watch as c,sync as d}from"../../../core/reactiveUtils.js";import{addFrameTask as u}from"../../../core/scheduling.js";import{Milliseconds as p}from"../../../core/time.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{a as y}from"../../../chunks/vec2.js";import{a as g,b as f,y as v,c as R,i as T}from"../../../chunks/vec3.js";import{c as O}from"../../../chunks/vec3f64.js";import{t as w,b as D,a as x}from"../../../chunks/vec4.js";import{c as S,f as E}from"../../../chunks/vec4f64.js";import{projectVectorToVector as P}from"../../../geometry/projection.js";import{getReferenceEllipsoid as U}from"../../../geometry/projectionEllipsoid.js";import{create as M,width as C,copy as j,center as I,intersection as N,height as b,contains as A,intersects as G,offset as H}from"../../../geometry/support/aaBoundingRect.js";import{create as L,wrap as V}from"../../../geometry/support/ray.js";import{b as k,e as B,t as F}from"../../../chunks/sphere.js";import{angleAroundAxis as q}from"../../../geometry/support/vector.js";import{y2lat as W}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as z}from"../state/utils/viewUtils.js";import Y from"../support/debugFlags.js";import{PointGraphics as X}from"../support/debugUtils.js";import{OverlayIndex as K}from"./interfaces.js";import{computeOverlayResolution as Z}from"./Overlay.js";import{OverlayRenderer as J}from"./OverlayRenderer.js";import{RenderRequestType as Q,ValidationState as $}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as ee}from"../webgl-engine/lib/Intersector.js";import{fromValues as te}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as re}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{removeLoadedShaderModules as se}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ie}from"../../support/Scheduler.js";const ae=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let ne,oe=class extends t{constructor(e){super(e),this._handles=new i,this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._hasUnusedRenderTargets=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096,this._animationTimeLast=0}get running(){return this._placementDirty&&(this._drapeSources.size>0||this._view.graphics.length>0||Y.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this._view.state.isGlobal}get _worldToPCSRatio(){return o(this._spatialReference)&&this._spatialReference.isGeographic&&!this._view.state.isLocal?U(this._spatialReference).metersPerDegree:1}get _view(){return this.surface.view}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get hasHighlights(){return this.renderer.hasHighlights}get rendersOccluded(){return this.renderer.rendersOccluded}initialize(){const e=this._view;this.renderer=new J({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),this._groundIntersector=ee(this._view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this._handles.add([this.renderer.events.on("has-highlights",(()=>{this.setDrawTexturesDirty(),this.notifyChange("hasHighlights")})),this.renderer.events.on("has-water",(t=>e._stage?.renderView.setRenderParameters({hasOverlayWater:t}))),this.renderer.events.on("renders-occluded",(()=>{this.setDrawTexturesDirty(),this.notifyChange("rendersOccluded")})),this.renderer.events.on("content-changed",(()=>this.setDrawTexturesDirty())),this.renderer.events.on("textures-disposed",(()=>this.updateOverlayResult())),c((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),c((()=>e.state?.pixelRatio),(()=>this.setPlacementDirty()),d),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),u({preRender:e=>{this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays&&(this._dispatchAnimationUpdate(e),this._drawOverlayTextures(this.renderer.overlays,Q.UPDATE)),this._hasUnusedRenderTargets&&this._collectUnusedRenderTargetMemory()}}),e.resourceController.scheduler.registerTask(ie.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(e,Q.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlayTextures(this.renderer.overlays,Q.BACKGROUND,e)}))])}destroy(){this.renderer.dispose(),this._handles&&(this._handles.destroy(),this._handles=null),o(ne)&&(ne.hide(),ne=null)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this._view.renderSpatialReference;o(e)&&o(t)?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}get gpuMemoryUsage(){return this.renderer.gpuMemoryUsage}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,re)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&o(e.setDrapingExtent)&&o(this._spatialReference)&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}updateOverlayResult(){this._view._stage?.renderView.setRenderParameters({overlays:this.renderer.overlays})}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(){this._updateOverlays(this._view.state.camera,Q.UPDATE)}_updateOverlays(e,t){if(!this._spatialReference)return;const r=Z(e.fullWidth,e.fullHeight,this._maxResolution);this._computeOverlayExtents(e,r,de);const s=C(de.inner)/C(de.outer);this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const i=this._updateOverlay(K.INNER,de.inner,r,1*de.pixelRatioAdjustment,de.mapUnitsPerPixel),a=this._updateOverlay(K.OUTER,de.outer,r,s*de.pixelRatioAdjustment,de.mapUnitsPerPixel);i!==me.EXTENT&&a!==me.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(t)),i===me.NONE&&a===me.NONE||this.setDrawTexturesDirty(),this._placementDirty=!1}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return me.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,le(t,a.extent)&&r===a.resolution)return n===i?me.NONE:me.RERENDER_ONLY;j(a.extent,t),a.resolution=r;const o=I(a.extent);return a.renderLocalOrigin=te(o[0],o[1],0,"OV_"+this._latestOriginId++),me.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[K.INNER],s=this.renderer.overlays[K.OUTER],i=N(e.extent,this.surface.extent,ue);this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,K.INNER,t),this._setTileOverlayData(i,K.OUTER,t)):(this._clearTileOverlayData(K.INNER,t),this._clearTileOverlayData(K.OUTER,t))}else this._clearTileOverlayData(K.INNER,t),this._clearTileOverlayData(K.OUTER,t)}overlayPixelSizeInMapUnits(e){if(0===this.renderer.overlays.length)return 0;const t=this.renderer.overlays[K.INNER],r=this.renderer.overlays[K.OUTER],s=this._pointIsInExtent(e,t.extent)?t:r;return(s.extent[2]-s.extent[0])/s.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=C(s),a=b(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,C(e)/i,b(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){se(),await this.renderer.reloadShaders(),this.setDrawTexturesDirty(),this.runTask()}_dispatchAnimationUpdate(e){const t=p(e.time-this._animationTimeLast);(t>=this.surface.view._stage.renderView.animationTimestep||o(this.forcedAnimationTime)||this._drawTexturesDirty||this._drawTexturesAnimateDirty)&&(this.renderer.updateAnimation({dt:t,forcedTime:this.forcedAnimationTime,camera:this._view.state.camera})&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e.time)}setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this._view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,_e,t,r);if(l(i))return!1;const a=i.origin,n=g(ce,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([],null),this._view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const i=.55,n=this._view.renderCoordsHelper.getAltitude(e.eye),o=this._view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=a(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:n+l,e.aboveGround?n-l:1/0),c=e.aboveGround;if("global"===this._view.viewingMode){const t=ce;k(B(F,U(this._view.spatialReference).radius+h),V(e.eye,e.viewForward),t),f(t,t,e.eye);const a=s.normalize(q(e.viewForward,t,e.viewRight))/e.fovY+.5,n=a<=0||a>=1?.5:i;r=c?n*a:a+n*(1-a)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),n=E(0,s,1,0),o=w(n,n,e.projectionMatrix)[1],l=a(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*i:1-(1-l)*i}return!!this._intersectGroundFromView(e,.5,r,t)&&v(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this._view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=O();this._findHorizonBasedPointOfInterest(e,i)||R(i,s);const a=Math.max(.1,T(e.eye,i)),c=z(this._view.renderCoordsHelper,s,e.eye),d=Math.PI/2-Math.abs(c-Math.PI/2);Y.OVERLAY_SHOW_CENTER?(l(ne)&&(ne=new X(this._view.graphics,"red")),ne.show(i,this._renderSR)):o(ne)&&ne.hide(),this._overlaySREqualsRenderSR||P(i,this._renderSR,i,this._spatialReference);const u=this.surface.extent,p=!this._isSpherical&&o(this._spatialReference)&&this._spatialReference.isGeographic,_=p&&o(this._spatialReference)?1/U(this._spatialReference).metersPerDegree:1,m=e.perRenderPixelRatio*a*_;r.mapUnitsPerPixel=m/this._worldToPCSRatio;let g=t*m/2,f=!1,v=p?90:1/0;this._isSpherical&&o(u)&&o(this._spatialReference)&&(this._spatialReference.isWebMercator?(g/=Math.cos(W(i[1])),v=u[3]):(f=!0,g/=U(this._spatialReference).metersPerDegree,v=90),g>=v&&(g=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let w=1;f&&(w=1/Math.max(.2,Math.cos(Math.abs(n(i[1])))),g*w>180&&(w=180/g),r.mapUnitsPerPixel*=w);const S=Math.log(2)/12;g=Math.exp(Math.round(Math.log(g)/S)*S);const E=g*w,M=32,I=.5*t/(M*E),b=.5*t/(M*g);i[0]=Math.round(i[0]*I)/I,i[1]=Math.round(i[1]*b)/b;const G=r.inner;G[0]=i[0]-E,G[1]=i[1]-g,G[2]=i[0]+E,G[3]=i[1]+g,this._isSpherical&&this._shiftExtentToFitBounds(G,1/0,v);const H=r.outer;if(6*E>C(u))j(H,h(u));else if(d<=.25*Math.PI)H[0]=G[0]-E,H[1]=G[1]-g,H[2]=G[2]+E,H[3]=G[3]+g;else{P(e.eye,this._renderSR,ce,this._spatialReference),y(he,i,ce);let t=-Math.atan2(he[1],he[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));D(he,ae[r],2*g),he[0]*=w,he[2]*=w,x(H,G,he)}if(this._isSpherical)H[0]=this._longitudeCyclical.clamp(H[0]),H[2]=this._longitudeCyclical.clamp(H[2]),H[1]=Math.max(H[1],-v),H[3]=Math.min(H[3],v);else{const e=N(G,u,ue),t=N(H,u,pe);A(e,t)&&(H[2]=H[0],H[3]=H[1])}const L=Math.abs(G[2]-G[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,L),r.pixelRatioAdjustment=r.mapUnitsPerPixel/L}_drawOverlayTextures(e,t,r=this._view.state.camera){if(0===e.length||!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return;const s=this._drawTexturesDirty;this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1;const i=this._drawOverlay(e[K.INNER],r),a=this._drawOverlay(e[K.OUTER],r);i!==$.CHANGED&&a!==$.CHANGED||this.surface.updateTileOverlayParams(Q.UPDATE),this._collectUnusedRenderTargetMemory(),this.updateOverlayResult(),s?(this.surface.requestRender(t),t===Q.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(Q.BACKGROUND)}_drawOverlay(e,t){return this._longitudeCyclical?e.setupGeometryViewsCyclical(this._longitudeCyclical):e.setupGeometryViewsDirect(),e.draw(this.renderer,t.pixelRatio)}_collectUnusedRenderTargetMemory(){if(this._hasUnusedRenderTargets=!1,this.renderer.hasOverlays){const e=performance.now();this._hasUnusedRenderTargets=this.renderer.collectUnusedRenderTargetMemory(e)}}_rectanglesOverlap(e,t){return!l(e)&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):G(e,t))}_rectInsideRect(e,t){return!l(t)&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:A(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),H(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask()}}};function le(e,t){const r=1e-5,s=Y.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([_()],oe.prototype,"_spatialReference",void 0),e([_({readOnly:!0})],oe.prototype,"running",null),e([_()],oe.prototype,"_placementDirty",void 0),e([_()],oe.prototype,"_contentUpdated",void 0),e([_()],oe.prototype,"_isSpherical",null),e([_()],oe.prototype,"_worldToPCSRatio",null),e([_()],oe.prototype,"renderer",void 0),e([_({constructOnly:!0})],oe.prototype,"surface",void 0),e([_({readOnly:!0,aliasOf:"surface.suspended"})],oe.prototype,"suspended",void 0),e([_({readOnly:!0})],oe.prototype,"updating",null),e([_({type:Boolean})],oe.prototype,"hasHighlights",null),e([_({type:Boolean})],oe.prototype,"rendersOccluded",null),oe=e([m("esri.views.3d.terrain.OverlayManager")],oe);const he=S(),ce=O(),de={inner:M(),outer:M(),mapUnitsPerPixel:0,pixelRatioAdjustment:1},ue=M(),pe=M(),_e=L();var me;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(me||(me={}));export{oe as OverlayManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import i from"../../../core/Handles.js";import has from"../../../core/has.js";import{clamp as a,deg2rad as n}from"../../../core/mathUtils.js";import{isSome as o,isNone as l,unwrap as h}from"../../../core/maybe.js";import{watch as c,sync as d}from"../../../core/reactiveUtils.js";import{addFrameTask as u}from"../../../core/scheduling.js";import{Milliseconds as p}from"../../../core/time.js";import{property as _}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{a as y}from"../../../chunks/vec2.js";import{a as g,b as f,y as v,c as R,i as T}from"../../../chunks/vec3.js";import{c as O}from"../../../chunks/vec3f64.js";import{t as w,b as D,a as x}from"../../../chunks/vec4.js";import{c as S,f as E}from"../../../chunks/vec4f64.js";import{projectVectorToVector as P}from"../../../geometry/projection.js";import{getReferenceEllipsoid as U}from"../../../geometry/projectionEllipsoid.js";import{create as M,width as C,copy as j,center as I,intersection as N,height as b,contains as A,intersects as G,offset as H}from"../../../geometry/support/aaBoundingRect.js";import{create as L,wrap as V}from"../../../geometry/support/ray.js";import{b as k,e as B,t as F}from"../../../chunks/sphere.js";import{angleAroundAxis as q}from"../../../geometry/support/vector.js";import{y2lat as W}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as z}from"../state/utils/viewUtils.js";import Y from"../support/debugFlags.js";import{PointGraphics as X}from"../support/debugUtils.js";import{OverlayIndex as K}from"./interfaces.js";import{computeOverlayResolution as Z}from"./Overlay.js";import{OverlayRenderer as J}from"./OverlayRenderer.js";import{RenderRequestType as Q,ValidationState as $}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as ee}from"../webgl-engine/lib/Intersector.js";import{fromValues as te}from"../webgl-engine/lib/LocalOriginFactory.js";import{SortedRenderGeometryRenderer as re}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{removeLoadedShaderModules as se}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ie}from"../../support/Scheduler.js";const ae=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let ne,oe=class extends t{constructor(e){super(e),this._handles=new i,this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._hasUnusedRenderTargets=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096,this._animationTimeLast=0}get running(){return this._placementDirty&&(this._drapeSources.size>0||this._view.graphics.length>0||Y.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this._view.state.isGlobal}get _worldToPCSRatio(){return o(this._spatialReference)&&this._spatialReference.isGeographic&&!this._view.state.isLocal?U(this._spatialReference).metersPerDegree:1}get _view(){return this.surface.view}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get hasHighlights(){return this.renderer.hasHighlights}get rendersOccluded(){return this.renderer.rendersOccluded}initialize(){const e=this._view;this.renderer=new J({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),this._groundIntersector=ee(this._view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this._handles.add([this.renderer.events.on("has-highlights",(()=>{this.setDrawTexturesDirty(),this.notifyChange("hasHighlights")})),this.renderer.events.on("has-water",(t=>e._stage?.renderView.setRenderParameters({hasOverlayWater:t}))),this.renderer.events.on("renders-occluded",(()=>{this.setDrawTexturesDirty(),this.notifyChange("rendersOccluded")})),this.renderer.events.on("content-changed",(()=>this.setDrawTexturesDirty())),this.renderer.events.on("textures-disposed",(()=>this.updateOverlayResult())),c((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),c((()=>e.state?.pixelRatio),(()=>this.setPlacementDirty()),d),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),u({preRender:e=>{this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays&&(this._dispatchAnimationUpdate(e),this._drawOverlayTextures(this.renderer.overlays,Q.UPDATE)),this._hasUnusedRenderTargets&&this._collectUnusedRenderTargetMemory()}}),e.resourceController.scheduler.registerTask(ie.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(e,Q.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlayTextures(this.renderer.overlays,Q.BACKGROUND,e)}))])}destroy(){this.renderer.dispose(),this._handles&&(this._handles.destroy(),this._handles=null),o(ne)&&(ne.hide(),ne=null)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this._view.renderSpatialReference;o(e)&&o(t)?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}get gpuMemoryUsage(){return this.renderer.gpuMemoryUsage}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,re)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&o(e.setDrapingExtent)&&o(this._spatialReference)&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}updateOverlayResult(){this._view._stage?.renderView.setRenderParameters({overlays:this.renderer.overlays})}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(){this._updateOverlays(this._view.state.camera,Q.UPDATE)}_updateOverlays(e,t){if(!this._spatialReference)return;const r=Z(e.fullWidth,e.fullHeight,this._maxResolution);this._computeOverlayExtents(e,r,de);const s=C(de.inner)/C(de.outer);this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const i=this._updateOverlay(K.INNER,de.inner,r,1*de.pixelRatioAdjustment,de.mapUnitsPerPixel),a=this._updateOverlay(K.OUTER,de.outer,r,s*de.pixelRatioAdjustment,de.mapUnitsPerPixel);i!==me.EXTENT&&a!==me.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(t)),i===me.NONE&&a===me.NONE||this.setDrawTexturesDirty(),this._placementDirty=!1}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return me.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,le(t,a.extent)&&r===a.resolution)return n===i?me.NONE:me.RERENDER_ONLY;j(a.extent,t),a.resolution=r;const o=I(a.extent);return a.renderLocalOrigin=te(o[0],o[1],0,"OV_"+this._latestOriginId++),me.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[K.INNER],s=this.renderer.overlays[K.OUTER],i=N(e.extent,this.surface.extent,ue);this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,K.INNER,t),this._setTileOverlayData(i,K.OUTER,t)):(this._clearTileOverlayData(K.INNER,t),this._clearTileOverlayData(K.OUTER,t))}else this._clearTileOverlayData(K.INNER,t),this._clearTileOverlayData(K.OUTER,t)}overlayPixelSizeInMapUnits(e){if(0===this.renderer.overlays.length)return 0;const t=this.renderer.overlays[K.INNER],r=this.renderer.overlays[K.OUTER],s=this._pointIsInExtent(e,t.extent)?t:r;return(s.extent[2]-s.extent[0])/s.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=C(s),a=b(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,C(e)/i,b(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){se(),await this.renderer.reloadShaders(),this.setDrawTexturesDirty(),this.runTask()}_dispatchAnimationUpdate(e){const t=p(e.time-this._animationTimeLast);(t>=this.surface.view._stage.renderView.animationTimestep||o(this.forcedAnimationTime)||this._drawTexturesDirty||this._drawTexturesAnimateDirty)&&(this.renderer.updateAnimation({dt:t,forcedTime:this.forcedAnimationTime,camera:this._view.state.camera})&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e.time)}setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this._view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,_e,t,r);if(l(i))return!1;const a=i.origin,n=g(ce,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([],null),this._view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const i=.55,n=this._view.renderCoordsHelper.getAltitude(e.eye),o=this._view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=a(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:n+l,e.aboveGround?n-l:1/0),c=e.aboveGround;if("global"===this._view.viewingMode){const t=ce;k(B(F,U(this._view.spatialReference).radius+h),V(e.eye,e.viewForward),t),f(t,t,e.eye);const a=s.normalize(q(e.viewForward,t,e.viewRight))/e.fovY+.5,n=a<=0||a>=1?.5:i;r=c?n*a:a+n*(1-a)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),n=E(0,s,1,0),o=w(n,n,e.projectionMatrix)[1],l=a(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*i:1-(1-l)*i}return!!this._intersectGroundFromView(e,.5,r,t)&&v(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this._view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=O();this._findHorizonBasedPointOfInterest(e,i)||R(i,s);const a=Math.max(.1,T(e.eye,i)),c=z(this._view.renderCoordsHelper,s,e.eye),d=Math.PI/2-Math.abs(c-Math.PI/2);Y.OVERLAY_SHOW_CENTER?(l(ne)&&(ne=new X(this._view.graphics,"red")),ne.show(i,this._renderSR)):o(ne)&&ne.hide(),this._overlaySREqualsRenderSR||P(i,this._renderSR,i,this._spatialReference);const u=this.surface.extent,p=!this._isSpherical&&o(this._spatialReference)&&this._spatialReference.isGeographic,_=p&&o(this._spatialReference)?1/U(this._spatialReference).metersPerDegree:1,m=e.perRenderPixelRatio*a*_;r.mapUnitsPerPixel=m/this._worldToPCSRatio;let g=t*m/2,f=!1,v=p?90:1/0;this._isSpherical&&o(u)&&o(this._spatialReference)&&(this._spatialReference.isWebMercator?(g/=Math.cos(W(i[1])),v=u[3]):(f=!0,g/=U(this._spatialReference).metersPerDegree,v=90),g>=v&&(g=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let w=1;f&&(w=1/Math.max(.2,Math.cos(Math.abs(n(i[1])))),g*w>180&&(w=180/g),r.mapUnitsPerPixel*=w);const S=Math.log(2)/12;g=Math.exp(Math.round(Math.log(g)/S)*S);const E=g*w,M=32,I=.5*t/(M*E),b=.5*t/(M*g);i[0]=Math.round(i[0]*I)/I,i[1]=Math.round(i[1]*b)/b;const G=r.inner;G[0]=i[0]-E,G[1]=i[1]-g,G[2]=i[0]+E,G[3]=i[1]+g,this._isSpherical&&this._shiftExtentToFitBounds(G,1/0,v);const H=r.outer;if(6*E>C(u))j(H,h(u));else if(d<=.25*Math.PI)H[0]=G[0]-E,H[1]=G[1]-g,H[2]=G[2]+E,H[3]=G[3]+g;else{P(e.eye,this._renderSR,ce,this._spatialReference),y(he,i,ce);let t=-Math.atan2(he[1],he[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));D(he,ae[r],2*g),he[0]*=w,he[2]*=w,x(H,G,he)}if(this._isSpherical)H[0]=this._longitudeCyclical.clamp(H[0]),H[2]=this._longitudeCyclical.clamp(H[2]),H[1]=Math.max(H[1],-v),H[3]=Math.min(H[3],v);else{const e=N(G,u,ue),t=N(H,u,pe);A(e,t)&&(H[2]=H[0],H[3]=H[1])}const L=Math.abs(G[2]-G[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,L),r.pixelRatioAdjustment=r.mapUnitsPerPixel/L}_drawOverlayTextures(e,t,r=this._view.state.camera){if(0===e.length||!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return;const s=this._drawTexturesDirty;this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1;const i=this._drawOverlay(e[K.INNER],r),a=this._drawOverlay(e[K.OUTER],r);i!==$.CHANGED&&a!==$.CHANGED||this.surface.updateTileOverlayParams(Q.UPDATE),this._collectUnusedRenderTargetMemory(),this.updateOverlayResult(),s?(this.surface.requestRender(t),t===Q.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(Q.BACKGROUND)}_drawOverlay(e,t){return this._longitudeCyclical?e.setupGeometryViewsCyclical(this._longitudeCyclical):e.setupGeometryViewsDirect(),e.draw(this.renderer,t.pixelRatio)}_collectUnusedRenderTargetMemory(){if(this._hasUnusedRenderTargets=!1,this.renderer.hasOverlays){const e=performance.now();this._hasUnusedRenderTargets=this.renderer.collectUnusedRenderTargetMemory(e)}}_rectanglesOverlap(e,t){return!l(e)&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):G(e,t))}_rectInsideRect(e,t){return!l(t)&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:A(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),H(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask()}}};function le(e,t){const r=1e-5,s=Y.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([_()],oe.prototype,"_spatialReference",void 0),e([_({readOnly:!0})],oe.prototype,"running",null),e([_()],oe.prototype,"_placementDirty",void 0),e([_()],oe.prototype,"_contentUpdated",void 0),e([_()],oe.prototype,"_isSpherical",null),e([_()],oe.prototype,"_worldToPCSRatio",null),e([_()],oe.prototype,"renderer",void 0),e([_({constructOnly:!0})],oe.prototype,"surface",void 0),e([_()],oe.prototype,"suspended",null),e([_()],oe.prototype,"updating",null),e([_({type:Boolean})],oe.prototype,"hasHighlights",null),e([_({type:Boolean})],oe.prototype,"rendersOccluded",null),oe=e([m("esri.views.3d.terrain.OverlayManager")],oe);const he=S(),ce=O(),de={inner:M(),outer:M(),mapUnitsPerPixel:0,pixelRatioAdjustment:1},ue=M(),pe=M(),_e=L();var me;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(me||(me={}));export{oe as OverlayManager};