@arcgis/core 4.30.0-next.20240210 → 4.30.0-next.20240213

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 (81) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +1 -0
  3. package/assets/esri/core/workers/chunks/0d54451c740f54a59f49.js +1 -0
  4. package/assets/esri/core/workers/chunks/{2b7513fe57eca6cff7c3.js → 0f30059c4e7a9cb85d1d.js} +1 -1
  5. package/assets/esri/core/workers/chunks/18551a7eb5a9b88aa0dc.js +1 -0
  6. package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +1 -0
  7. package/assets/esri/core/workers/chunks/{3f4d63436c3de04a6ebb.js → 254b4ee3621bbe345bb1.js} +1 -1
  8. package/assets/esri/core/workers/chunks/2d682ee6e5d66f2ea5cd.js +1 -0
  9. package/assets/esri/core/workers/chunks/{d5484d470121de2b403b.js → 36d091be859bbb1a149b.js} +1 -1
  10. package/assets/esri/core/workers/chunks/50b41f91be903a0977f9.js +1 -0
  11. package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +1 -0
  12. package/assets/esri/core/workers/chunks/784b6a8216b97440b180.js +1 -0
  13. package/assets/esri/core/workers/chunks/{7f7a4de2cd4ab71b9aee.js → 8d119dc0a92ad3612daa.js} +1 -1
  14. package/assets/esri/core/workers/chunks/966cc0b54008c7348678.js +1 -0
  15. package/assets/esri/core/workers/chunks/{2853221e88ed7077a447.js → 9850b0e04cce8c1bdddf.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{0014635097a32ad38895.js → a854611d1a86b838c6ad.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{cf6970b490b98aa0a117.js → be562536212360943388.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{50a5abd75fa7dbb571a5.js → ccd53b81c2688dd11584.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{b2b8e6a0b3f70ada2799.js → e4da908079417cc2f495.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{af0314c2b5b7dc4f5bbd.js → e6dbf0a7b7b1cf64f23f.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{eba72ff1726ff6998204.js → f03d62ab7806b68d0b62.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{5fcda75ed02b8aee3a3c.js → f89278782ddfb154aa9f.js} +1 -1
  23. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  24. package/geometry/Mesh.js +1 -1
  25. package/geometry/support/meshVertexSpaceUtils.js +1 -1
  26. package/interfaces.d.ts +174 -16
  27. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  28. package/layers/SceneLayer.js +1 -1
  29. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  30. package/layers/support/PixelBlock.js +1 -1
  31. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  32. package/layers/support/rasterDatasets/MRFRaster.js +1 -1
  33. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  34. package/layers/support/rasterFunctions/surfaceUtils.js +1 -1
  35. package/package.json +2 -2
  36. package/portal/support/resourceUtils.js +1 -1
  37. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  38. package/rest/support/meshFeatureSet.js +1 -1
  39. package/support/revision.js +1 -1
  40. package/symbols/cim/constants.js +1 -1
  41. package/symbols/support/previewSymbol2D.js +1 -1
  42. package/versionManagement/support/versionManagementUtils.js +1 -1
  43. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  44. package/views/2d/engine/webgl/collisions/CollisionGrid.js +1 -1
  45. package/views/2d/engine/webgl/collisions/LabelMetric.js +1 -1
  46. package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
  47. package/views/2d/engine/webgl/shaderGraph/GLSLShaderModule.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  49. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
  52. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  53. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  54. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  55. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  56. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  57. package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
  58. package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
  59. package/views/3d/layers/I3SMeshView3D.js +1 -1
  60. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  61. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  62. package/views/SceneView.js +1 -1
  63. package/views/draw/DrawOperation.js +1 -1
  64. package/views/draw/support/Box.js +1 -1
  65. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  66. package/views/support/automaticLengthMeasurementUtils.js +1 -1
  67. package/views/support/extentUtils.js +5 -0
  68. package/widgets/BasemapLayerList.js +1 -1
  69. package/widgets/Editor/EditorViewModel.js +1 -1
  70. package/widgets/FeatureForm.js +1 -1
  71. package/widgets/LayerList.js +1 -1
  72. package/widgets/TableList.js +1 -1
  73. package/assets/esri/core/workers/chunks/062629a9b4695dea8bf8.js +0 -1
  74. package/assets/esri/core/workers/chunks/3401157faaa8619aaa47.js +0 -1
  75. package/assets/esri/core/workers/chunks/37803888bd9a537481a7.js +0 -1
  76. package/assets/esri/core/workers/chunks/560f677a356c7ebde5d3.js +0 -1
  77. package/assets/esri/core/workers/chunks/5bfc5ffad705aaaafcd4.js +0 -1
  78. package/assets/esri/core/workers/chunks/655f4560fb36a0d9ff0b.js +0 -1
  79. package/assets/esri/core/workers/chunks/b927b655e955abe00d48.js +0 -1
  80. package/assets/esri/core/workers/chunks/d2417d179d015f1193a1.js +0 -1
  81. package/assets/esri/core/workers/chunks/f75ec599f53c66cab194.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.30/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../../geometry.js";import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{assertIsSome as t}from"../../../../../core/maybe.js";import{DateOnly as r}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as s}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as i}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as o}from"../../../../../geometry/support/aaBoundingBox.js";import{getLabelPoint as n}from"../../../../../geometry/support/labelPoint.js";import{convertToGeometry as a,unquantizeOptimizedGeometry as d}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as u}from"../../../../../layers/graphics/OptimizedFeature.js";import l from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as h,unknown as c}from"../../../../../time/timeZoneUtils.js";import{StaticBitSet as m}from"./StaticBitSet.js";import{fromJSON as f}from"../../../../../geometry/support/jsonUtils.js";const y=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],p=y[0],g=y[1],_=y[2],b=y[3],x=has("featurelayer-simplify-payload-size-factors")??[1,2,4],T=x[0],I=x[1],A=x[2],D=has("featurelayer-simplify-mobile-factor")??2,F=has("esri-mobile"),S=4294967295;function B(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class j{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(e,t){let r=1;const s=F?D:1;t>4e6?r=A*s:t>1e6?r=I*s:t>5e5?r=T*s:t>1e5&&(r=s);let i=0;return e>4e3?i=b*r:e>2e3?i=_*r:e>100?i=g:e>15&&(i=p),i}parseTimestampOffset(e){return e}getBounds(e){if(B(this._boundsBuffer,4*this.getIndex()+4,0),this.getBoundsXMin()===S)return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(!t)return this.setBoundsXMin(S),!1;let r=1/0,s=1/0,i=-1/0,n=-1/0;return t.forEachVertex(((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),n=Math.max(n,t)})),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(n),o(e,r,s,i,n),!0}const t=this.getBoundsXMin(),r=this.getBoundsYMin(),s=this.getBoundsXMax(),i=this.getBoundsYMax();return o(e,t,r,s,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}removeIds(e){if(null==this._objectIdToIndex){const e=new Map,r=this.getCursor();for(;r.next();){const s=r.getObjectId();t(s),e.set(s,r.getIndex())}this._objectIdToIndex=e}const r=this._objectIdToIndex;for(const t of e.values())r.has(t)&&this._removeAtIndex(r.get(t))}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace(),s=new u(e,t,r);return s.objectId=this.getObjectId(),s.displayId=this.getDisplayId(),s}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return a(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&d(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&d(r,r,this.hasZ,this.hasM,s),r}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)}geometry(){const e=this.readGeometryWorldSpace(),t=a(e,this.geometryType,this.hasZ,this.hasM),r=f(t);if(r){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.spatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??h):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===c}field(t){let i=this.fields.get(t);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const o of this._joined)if(o.setIndex(this.getIndex()),i=o.fields.get(t),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(o._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(o._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(o._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,o._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((e=>e.name))}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(e){const t=i.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=n(t);return r?(r[1]*=-1,new l([],r)):null}copyInto(e){e._joined=this._joined,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return a(e,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createQuantizedExtrudedGeometry(t,r)}_createQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(e,t):this._createQuantizedExtrudedQuad(e,t)}_createQuantizedExtrudedQuad(e,t){return new l([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(e,t){return new l([2],[e-1,t+1,1,-1])}_removeAtIndex(e){null==this._deleted&&(this._deleted=m.create(this.getSize())),this._deleted.set(e)}}export{j as FeatureSetReader};
5
+ import"../../../../../geometry.js";import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{assertIsSome as t}from"../../../../../core/maybe.js";import{DateOnly as r}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as s}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as i}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as o}from"../../../../../geometry/support/aaBoundingBox.js";import{getLabelPoint as n}from"../../../../../geometry/support/labelPoint.js";import{convertToGeometry as a,unquantizeOptimizedGeometry as d}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as u}from"../../../../../layers/graphics/OptimizedFeature.js";import l from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as h,unknown as c}from"../../../../../time/timeZoneUtils.js";import{StaticBitSet as m}from"./StaticBitSet.js";import{fromJSON as f}from"../../../../../geometry/support/jsonUtils.js";const y=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],p=y[0],g=y[1],_=y[2],b=y[3],x=has("featurelayer-simplify-payload-size-factors")??[1,2,4],T=x[0],I=x[1],A=x[2],D=has("featurelayer-simplify-mobile-factor")??2,F=has("esri-mobile"),S=4294967295;function j(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class B{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(e,t){let r=1;const s=F?D:1;t>4e6?r=A*s:t>1e6?r=I*s:t>5e5?r=T*s:t>1e5&&(r=s);let i=0;return e>4e3?i=b*r:e>2e3?i=_*r:e>100?i=g:e>15&&(i=p),i}parseTimestampOffset(e){return e}getBounds(e){if(j(this._boundsBuffer,4*this.getIndex()+4,0),this.getBoundsXMin()===S)return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(!t)return this.setBoundsXMin(S),!1;let r=1/0,s=1/0,i=-1/0,n=-1/0;return t.forEachVertex(((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),n=Math.max(n,t)})),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(n),o(e,r,s,i,n),!0}const t=this.getBoundsXMin(),r=this.getBoundsYMin(),s=this.getBoundsXMax(),i=this.getBoundsYMax();return o(e,t,r,s,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}removeIds(e){if(null==this._objectIdToIndex){const e=new Map,r=this.getCursor();for(;r.next();){const s=r.getObjectId();t(s),e.set(s,r.getIndex())}this._objectIdToIndex=e}const r=this._objectIdToIndex;for(const t of e.values())r.has(t)&&this._removeAtIndex(r.get(t))}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace(),s=new u(e,t,r);return s.objectId=this.getObjectId(),s.displayId=this.getDisplayId(),s}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return a(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&d(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&d(r,r,this.hasZ,this.hasM,s),r}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some((t=>t.hasField(e)))}geometry(){const e=this.readGeometryWorldSpace(),t=a(e,this.geometryType,this.hasZ,this.hasM),r=f(t);if(r){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.spatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??h):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===c}field(t){let i=this.fields.get(t);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const o of this._joined)if(o.setIndex(this.getIndex()),i=o.fields.get(t),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(o._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(o._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(o._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,o._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((e=>e.name))}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(e){const t=i.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=n(t);return r?(r[1]*=-1,new l([],r)):null}copyInto(e){e._joined=this._joined,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return a(e,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createQuantizedExtrudedGeometry(t,r)}_createQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(e,t):this._createQuantizedExtrudedQuad(e,t)}_createQuantizedExtrudedQuad(e,t){return new l([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(e,t){return new l([2],[e-1,t+1,1,-1])}_removeAtIndex(e){null==this._deleted&&(this._deleted=m.create(this.getSize())),this._deleted.set(e)}}export{B as FeatureSetReader};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{set as t,normalize as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as a,q as i,f as r,l as o,j as n}from"../../../../../chunks/vec32.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as l,c as p}from"../../../../../chunks/boundedPlane.js";import{intersectRay as h}from"../../../../../geometry/support/plane.js";import{sv3d as d}from"../../../../../geometry/support/vectorStacks.js";import{ResizeManipulator as u}from"../../../analysis/Slice/ResizeManipulator.js";import{updateResizeHandle as m,isDiagonalResizeHandle as _,calculateDiagonalResizeHandleScale as S}from"../../../analysis/Slice/sliceToolUtils.js";import{screenToRenderPlane as g}from"../dragEventPipeline3D.js";import{ManipulatorType as f}from"../ManipulatorType.js";import{mapPlaneAutoSize2D as y}from"./extentUtils.js";import{fromScreenNormalized as z}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as x}from"../../../../interactive/dragEventPipeline.js";import{AccumulationBehavior as M}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as v}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{apply as b}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{ExtentScaleTooltipInfo as B}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";class j{get zMax(){if(!this._zMaxDirty)return this._zMax;const t=this._editGeometryOperations.data;if(t.geometry.hasZ){const e=t.coordinateHelper;this._zMax=Number.NEGATIVE_INFINITY;for(const s of t.components)for(const t of s.vertices){const s=e.getZ(t.pos)??0;this._zMax=Math.max(s,this._zMax)}}else this._zMax=0;return this._zMaxDirty=!1,this._zMax}constructor(e,a,i,r,o){this._tool=e,this._graphicState=a,this._editGeometryOperations=i,this._bounds=r,this._preserveAspectRatioStep=o,this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._scaleTooltipInfo=null,this._displayBoundsStart=l(),this._displayBoundsMarginStart=0,this._startScale=s(),this._endScale=s(),this._sizeStart=null,this._zMax=0,this._zMaxDirty=!0;const n=this._tool,c=n.view;this.resizeManipulators=this._resizeHandles.map((t=>{const e=new u(c,t);return n.addHandles([e.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(e,t)]),e})),n.manipulators.addMany(this.resizeManipulators),n.addHandles([n.on("graphic-scale-start",(e=>{t(this._startScale,e.xScale,e.yScale),t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale",(e=>{t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale-stop",(()=>{t(this._startScale,0,0),t(this._endScale,0,0)})),this._graphicState.on("changed",(()=>{"resize"!==n.inputState?.type&&(this._zMaxDirty=!0)}))])}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()}))}forEachManipulator(t){this.resizeManipulators.forEach((e=>t(e,f.SCALE)))}updateManipulators(t,e){this.resizeManipulators.forEach(((s,a)=>{m(s,this._resizeHandles[a],t,e)}))}getUpdatedTooltipInfo(){return this.resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null}_computeScaleTooltipInfo(){const t=this._tool,e=this._scaleTooltipInfo??=new B({sketchOptions:t.sketchOptions}),s=t.graphic.geometry;if(null==s)return null;const a=y(this._bounds.mapBounds,this.zMax,s.spatialReference);return null==a?null:(e.xSize=a[0],e.ySize=a[1],null!=this._sizeStart&&this.resizeManipulators.some((t=>t.dragging))?(e.xScale=a[0].value/this._sizeStart[0].value,e.yScale=a[1].value/this._sizeStart[1].value):(e.xScale=1,e.yScale=1),e)}_onResizeGrab({action:t,screenPoint:e}){const s=this._tool,a=this._bounds;if("start"!==t||!e||!s.graphic.geometry)return;const i=z(s.view.state.camera,e);h(a.displayBounds.plane,i,d.get())&&(a.backupMapBounds(),p(a.displayBounds,this._displayBoundsStart),this._displayBoundsMarginStart=a.displayBoundsMargin,this._sizeStart=y(a.mapBoundsStart,this.zMax,s.graphic.geometry.spatialReference),s.inputState={type:"resize"})}_createResizeDragPipeline(t,e){const s=this._tool,a=s.graphic;return x(t,((t,i,r)=>{null!=s.inputState&&(i.next((t=>("start"===t.action&&s.emit("graphic-scale-start",{graphic:a,xScale:1,yScale:1}),t))).next(g(s.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatioStep()).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:a,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":s.emit("graphic-scale",e);break;case"end":s.inputState=null,s.emit("graphic-scale-stop",e)}return t})),r.next((()=>{null!=s.inputState&&s.emit("graphic-scale-stop",{graphic:a,xScale:1,yScale:1}),s.cancel()})))}))}_resizeDragRenderPlaneToFactors(){const t=this._bounds;return e=>{const s=this._displayBoundsStart,c=e.handle.direction,l=t.displayBoundsMargin,p=this._displayBoundsMarginStart,h=a(d.get(),s.origin);i(h,h,s.basis1,-c[0]),i(h,h,s.basis2,-c[1]);const u=r(d.get(),e.renderEnd,h),m=r(d.get(),e.renderStart,h),g=_(e.handle),f=S(s),y=S(t.displayBounds)/f,z=(t,e)=>{if(0===t)return 1;let s=o(e),a=.5*t*n(e,u)/s;const i=a<0?-1:1;if(g){a+=(s-.5*t*n(e,m)/s)*i*y}const r=s<1.5*p?1:E;return s=Math.max(s-p,E),i>0&&(a-=l),i*Math.max(i*(a/s),r)};return{...e,factor1:z(c[0],s.basis1),factor2:z(c[1],s.basis2)}}}_resizeDragUpdateGeometry(){const r=this._tool,o=this._bounds;return n=>{const l=a(c(),o.mapBoundsStart.origin);i(l,l,o.mapBoundsStart.basis1,-n.handle.direction[0]),i(l,l,o.mapBoundsStart.basis2,-n.handle.direction[1]);const h=t(s(),o.mapBoundsStart.basis1[0],o.mapBoundsStart.basis1[1]);e(h,h);const d=[];for(const t of this._editGeometryOperations.data.components)d.push(...t.vertices);const u="start"===n.action?M.NEW_STEP:M.ACCUMULATE_STEPS,m=this._editGeometryOperations.scaleVertices(d,l,h,n.factor1,n.factor2,u,v.REPLACE);return p(o.mapBoundsStart,o.mapBounds),b(m,o.mapBounds),r.graphic.geometry=this._editGeometryOperations.data.geometry,n}}}const E=1e-6;export{j as ExtentScale,E as scaleEpsilon};
5
+ import{set as t,normalize as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as i,q as a,f as r,l as o,j as n}from"../../../../../chunks/vec32.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as l,c as p}from"../../../../../chunks/boundedPlane.js";import{intersectRay as h}from"../../../../../geometry/support/plane.js";import{sv3d as d}from"../../../../../geometry/support/vectorStacks.js";import{ResizeManipulator as u}from"../../../analysis/Slice/ResizeManipulator.js";import{updateResizeHandle as m,isDiagonalResizeHandle as S,calculateDiagonalResizeHandleScale as _}from"../../../analysis/Slice/sliceToolUtils.js";import{screenToRenderPlane as g}from"../dragEventPipeline3D.js";import{ManipulatorType as y}from"../ManipulatorType.js";import{mapPlaneAutoSize2D as f}from"./extentUtils.js";import{fromScreenNormalized as z}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as x}from"../../../../interactive/dragEventPipeline.js";import{AccumulationBehavior as M}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as v}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{apply as b}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{ExtentScaleTooltipInfo as B}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";class j{get zMax(){if(!this._zMaxDirty)return this._zMax;const t=this._editGeometryOperations.data;if(t.geometry.hasZ){const e=t.coordinateHelper;this._zMax=Number.NEGATIVE_INFINITY;for(const s of t.components)for(const t of s.vertices){const s=e.getZ(t.pos)??0;this._zMax=Math.max(s,this._zMax)}}else this._zMax=0;return this._zMaxDirty=!1,this._zMax}constructor(e,i,a,r,o){this._tool=e,this._graphicState=i,this._editGeometryOperations=a,this._bounds=r,this._preserveAspectRatioStep=o,this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._scaleTooltipInfo=null,this._displayBoundsStart=l(),this._displayBoundsMarginStart=0,this._startScale=s(),this._endScale=s(),this._sizeStart=null,this._zMax=0,this._zMaxDirty=!0;const n=this._tool,c=n.view;this.resizeManipulators=this._resizeHandles.map((t=>{const e=new u(c,t);return n.addHandles([e.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(e,t)]),e})),n.manipulators.addMany(this.resizeManipulators),n.addHandles([n.on("graphic-scale-start",(e=>{t(this._startScale,e.xScale,e.yScale),t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale",(e=>{t(this._endScale,e.xScale,e.yScale)})),n.on("graphic-scale-stop",(()=>{t(this._startScale,0,0),t(this._endScale,0,0)})),this._graphicState.on("changed",(()=>{"resize"!==n.inputState?.type&&(this._zMaxDirty=!0)}))])}destroy(){this.forEachManipulator((t=>{this._tool.manipulators.remove(t),t.destroy()}))}forEachManipulator(t){this.resizeManipulators.forEach((e=>t(e,y.SCALE)))}updateManipulators(t,e){this.resizeManipulators.forEach(((s,i)=>{m(s,this._resizeHandles[i],t,e)}))}getUpdatedTooltipInfo(){return this.resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null}_computeScaleTooltipInfo(){const t=this._tool,e=this._scaleTooltipInfo??=new B({sketchOptions:t.sketchOptions}),s=t.graphic.geometry;if(null==s)return null;const i=f(this._bounds.mapBounds,this.zMax,s.spatialReference);return null==i?null:(e.xSize=i.xSize,e.ySize=i.ySize,null!=this._sizeStart&&this.resizeManipulators.some((t=>t.dragging))?(e.xScale=i.xSize.value/this._sizeStart.xSize.value,e.yScale=i.ySize.value/this._sizeStart.ySize.value):(e.xScale=1,e.yScale=1),e)}_onResizeGrab({action:t,screenPoint:e}){const s=this._tool,i=this._bounds;if("start"!==t||!e||!s.graphic.geometry)return;const a=z(s.view.state.camera,e);h(i.displayBounds.plane,a,d.get())&&(i.backupMapBounds(),p(i.displayBounds,this._displayBoundsStart),this._displayBoundsMarginStart=i.displayBoundsMargin,this._sizeStart=f(i.mapBoundsStart,this.zMax,s.graphic.geometry.spatialReference),s.inputState={type:"resize"})}_createResizeDragPipeline(t,e){const s=this._tool,i=s.graphic;return x(t,((t,a,r)=>{null!=s.inputState&&(a.next((t=>("start"===t.action&&s.emit("graphic-scale-start",{graphic:i,xScale:1,yScale:1}),t))).next(g(s.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatioStep()).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:i,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":s.emit("graphic-scale",e);break;case"end":s.inputState=null,s.emit("graphic-scale-stop",e)}return t})),r.next((()=>{null!=s.inputState&&s.emit("graphic-scale-stop",{graphic:i,xScale:1,yScale:1}),s.cancel()})))}))}_resizeDragRenderPlaneToFactors(){const t=this._bounds;return e=>{const s=this._displayBoundsStart,c=e.handle.direction,l=t.displayBoundsMargin,p=this._displayBoundsMarginStart,h=i(d.get(),s.origin);a(h,h,s.basis1,-c[0]),a(h,h,s.basis2,-c[1]);const u=r(d.get(),e.renderEnd,h),m=r(d.get(),e.renderStart,h),g=S(e.handle),y=_(s),f=_(t.displayBounds)/y,z=(t,e)=>{if(0===t)return 1;let s=o(e),i=.5*t*n(e,u)/s;const a=i<0?-1:1;if(g){i+=(s-.5*t*n(e,m)/s)*a*f}const r=s<1.5*p?1:E;return s=Math.max(s-p,E),a>0&&(i-=l),a*Math.max(a*(i/s),r)};return{...e,factor1:z(c[0],s.basis1),factor2:z(c[1],s.basis2)}}}_resizeDragUpdateGeometry(){const r=this._tool,o=this._bounds;return n=>{const l=i(c(),o.mapBoundsStart.origin);a(l,l,o.mapBoundsStart.basis1,-n.handle.direction[0]),a(l,l,o.mapBoundsStart.basis2,-n.handle.direction[1]);const h=t(s(),o.mapBoundsStart.basis1[0],o.mapBoundsStart.basis1[1]);e(h,h);const d=[];for(const t of this._editGeometryOperations.data.components)d.push(...t.vertices);const u="start"===n.action?M.NEW_STEP:M.ACCUMULATE_STEPS,m=this._editGeometryOperations.scaleVertices(d,l,h,n.factor1,n.factor2,u,v.REPLACE);return p(o.mapBoundsStart,o.mapBounds),b(m,o.mapBounds),r.graphic.geometry=this._editGeometryOperations.data.geometry,n}}}const E=1e-6;export{j as ExtentScale,E as scaleEpsilon};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{max as s}from"../../../../../core/quantityUtils.js";import{getMetersPerCartesianUnitForSR as t,getMetersPerUnitForSR as i}from"../../../../../core/unitUtils.js";import{scale as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{g as e,f as n,k as a,b as r,n as c,i as l,j as p,l as u,q as g}from"../../../../../chunks/vec32.js";import{a as m,c as d,u as b}from"../../../../../chunks/boundedPlane.js";import{sv3d as h}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as f}from"../../../../../support/elevationInfoUtils.js";import{mainAxis as y}from"../geometryUtils.js";import{evaluateElevationAlignmentAtPoint as B}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as j}from"../../../layers/graphics/ElevationContext.js";import{calculateOrientedBounds as v}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{autoDistance2D as C}from"../../../../support/automaticLengthMeasurementUtils.js";class _{constructor(s,t,i){this._tool=s,this._onDisplayBoundsChanged=t,this.mapBounds=m(),this.mapBoundsStart=m(),this.displayBounds=m(),this._calculateMapBounds(i)}get displayBoundsMargin(){const{view:s,graphic:t}=this._tool,i=s.pointsOfInterest?.centerOnSurfaceFrequent.location??t.geometry?.extent?.center;return i?R*s.pixelSizeAt(i):0}backupMapBounds(){d(this.mapBounds,this.mapBoundsStart)}updateDisplayBounds(){this._calculateDisplayBounds(),this._onDisplayBoundsChanged()}_calculateMapBounds(s){const{view:e,attachmentOrigin:n}=this._tool,a=s.geometry,r=y(a);o(r,r,-1);const c=e.spatialReference,l=a.spatialReference,p=n?e.pixelSizeAt(n)*t(c)/i(l):0;v(r,s,U*p,this.mapBounds)}_calculateDisplayBounds(){const{view:s,attachmentOrigin:t,graphic:i}=this._tool;if(!i.geometry)return;const o=t?.z??B(this.mapBounds.origin,s.elevationProvider,j.fromElevationInfo(f(i)),s.renderCoordsHelper),e=d(this.mapBounds);e.origin[2]=o??0,x(e,s.renderCoordsHelper,i.geometry.spatialReference,this.displayBoundsMargin,this.displayBounds)}}const R=10,U=80;function x(s,t,i,o=0,g){g||(g=m()),t.toRenderCoords(s.origin,i,g.origin);const d=h.get();e(d,s.origin,s.basis1),e(d,d,s.basis2),t.toRenderCoords(d,i,d);const f=h.get();e(f,s.origin,s.basis1),n(f,f,s.basis2),t.toRenderCoords(f,i,f);const y=h.get();n(y,s.origin,s.basis1),n(y,y,s.basis2),t.toRenderCoords(y,i,y);const B=h.get();n(B,s.origin,s.basis1),e(B,B,s.basis2),t.toRenderCoords(B,i,B);const j=a(h.get(),d,f,.5);n(j,j,g.origin);const v=a(h.get(),y,B,.5);n(v,g.origin,v),a(g.basis1,j,v,.5);const C=a(h.get(),B,d,.5);n(C,C,g.origin);const _=a(h.get(),f,y,.5);n(_,g.origin,_),a(g.basis2,C,_,.5);const R=r(h.get(),g.basis1,g.basis2),U=r(R,R,g.basis1);return c(U,U),l(g.basis2,U,p(g.basis2,U)),l(g.basis1,g.basis1,1+o/u(g.basis1)),l(g.basis2,g.basis2,1+o/u(g.basis2)),b(g),g}function M(t,i,o){const e=h.get();n(e,n(e,t.origin,t.basis1),t.basis2);const a=h.get();g(a,e,t.basis1,2);const r=h.get();g(r,a,t.basis2,2);const c=h.get();g(c,e,t.basis2,2),e[2]=a[2]=r[2]=c[2]=i;const l=s(C(e,a,o),C(c,r,o)),p=s(C(a,r,o),C(e,c,o));return null==p||null==l?null:[l,p]}export{_ as TransformBounds,M as mapPlaneAutoSize2D};
5
+ import{getMetersPerCartesianUnitForSR as s,getMetersPerUnitForSR as t}from"../../../../../core/unitUtils.js";import{scale as i}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{g as o,f as e,k as a,b as r,n,i as c,j as p,l,q as m}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as g,c as u,u as b}from"../../../../../chunks/boundedPlane.js";import{sv3d as h}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as f}from"../../../../../support/elevationInfoUtils.js";import{mainAxis as B}from"../geometryUtils.js";import{evaluateElevationAlignmentAtPoint as y}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as v}from"../../../layers/graphics/ElevationContext.js";import{calculateOrientedBounds as j}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import{autoSize2D as R}from"../../../../support/extentUtils.js";class C{constructor(s,t,i){this._tool=s,this._onDisplayBoundsChanged=t,this.mapBounds=g(),this.mapBoundsStart=g(),this.displayBounds=g(),this._calculateMapBounds(i)}get displayBoundsMargin(){const{view:s,graphic:t}=this._tool,i=s.pointsOfInterest?.centerOnSurfaceFrequent.location??t.geometry?.extent?.center;return i?_*s.pixelSizeAt(i):0}backupMapBounds(){u(this.mapBounds,this.mapBoundsStart)}updateDisplayBounds(){this._calculateDisplayBounds(),this._onDisplayBoundsChanged()}_calculateMapBounds(o){const{view:e,attachmentOrigin:a}=this._tool,r=o.geometry,n=B(r);i(n,n,-1);const c=e.spatialReference,p=r.spatialReference,l=a?e.pixelSizeAt(a)*s(c)/t(p):0;j(n,o,x*l,this.mapBounds)}_calculateDisplayBounds(){const{view:s,attachmentOrigin:t,graphic:i}=this._tool;if(!i.geometry)return;const o=t?.z??y(this.mapBounds.origin,s.elevationProvider,v.fromElevationInfo(f(i)),s.renderCoordsHelper),e=u(this.mapBounds);e.origin[2]=o??0,S(e,s.renderCoordsHelper,i.geometry.spatialReference,this.displayBoundsMargin,this.displayBounds)}}const _=10,x=80;function S(s,t,i,m=0,d){d||(d=g()),t.toRenderCoords(s.origin,i,d.origin);const u=h.get();o(u,s.origin,s.basis1),o(u,u,s.basis2),t.toRenderCoords(u,i,u);const f=h.get();o(f,s.origin,s.basis1),e(f,f,s.basis2),t.toRenderCoords(f,i,f);const B=h.get();e(B,s.origin,s.basis1),e(B,B,s.basis2),t.toRenderCoords(B,i,B);const y=h.get();e(y,s.origin,s.basis1),o(y,y,s.basis2),t.toRenderCoords(y,i,y);const v=a(h.get(),u,f,.5);e(v,v,d.origin);const j=a(h.get(),B,y,.5);e(j,d.origin,j),a(d.basis1,v,j,.5);const R=a(h.get(),y,u,.5);e(R,R,d.origin);const C=a(h.get(),f,B,.5);e(C,d.origin,C),a(d.basis2,R,C,.5);const _=r(h.get(),d.basis1,d.basis2),x=r(_,_,d.basis1);return n(x,x),c(d.basis2,x,p(d.basis2,x)),c(d.basis1,d.basis1,1+m/l(d.basis1)),c(d.basis2,d.basis2,1+m/l(d.basis2)),b(d),d}function U(s,t,i){return e(O,e(O,s.origin,s.basis1),s.basis2),m(M,O,s.basis1,2),m(D,M,s.basis2,2),m(k,O,s.basis2,2),O[2]=M[2]=D[2]=k[2]=t,R({topLeft:k,topRight:D,bottomRight:M,bottomLeft:O,spatialReference:i})}const k=d(),D=d(),M=d(),O=d();export{C as TransformBounds,U as mapPlaneAutoSize2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import n from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{someMap as d}from"../../../core/MapUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as g}from"../../../core/promiseUtils.js";import{initial as m,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as M}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as x,getTranslation as O}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as E,create as j}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as R,e as S,g as A,t as D,i as T,f as N,C as V}from"../../../chunks/vec32.js";import{create as F}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as P}from"../../../chunks/vec42.js";import{fromValues as H}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as U}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as G}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as L}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as k}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as B}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as q}from"../../../geometry/projection/projectVectorToVector.js";import{create as W,empty as z,expandWithBuffer as K,toRect as $}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as X}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as J}from"../../../geometry/support/FloatArray.js";import{compactIndices as Z}from"../../../geometry/support/Indices.js";import{g as ee,f as te,a as ie}from"../../../chunks/sphere.js";import{newUByteArray as se}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as re}from"../../../layers/LayerConstants.js";import oe from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ne}from"../../../layers/support/fieldUtils.js";import ae from"../../../layers/support/SceneModification.js";import{getColor as le,getOpacity as de}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as he}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as ce}from"../../../support/basemapUtils.js";import ue from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as _e}from"../../../symbols/support/unitConversionUtils.js";import ge from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as me}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as pe,toWasmModification as fe}from"./I3SMeshWorkerHandle.js";import{ElevationMode as be,ForAllFeaturesReturnType as ye,ForAllFeaturesMode as ve}from"./II3SMeshView3D.js";import{initialize as Ie,setModificationsSync as Me,filterObbsForModificationsSync as Ce,interpretObbModificationResults as xe}from"./SceneLayerWorker.js";import{overrideColor as Oe}from"./graphics/graphicUtils.js";import{areLabelsVisible as Ee}from"./graphics/Labeler.js";import{TextureUsage as je,TextureEncoding as we}from"./i3s/enums.js";import Re from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Se}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Ae,NodeCrossfadeMetaData as De}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Te}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ne}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as Fe,defaultMaterial as Pe,createTexture as He,configureMaterial as Ue}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Ge,NodeState as Le}from"./i3s/I3SNode.js";import{I3SOverrides as ke}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Be,getLocalOrigin as qe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as We,checkSceneLayerValid as ze,checkSceneLayerCompatibleWithView as Ke,getCacheKeySuffix as $e,whenGraphicAttributes as Qe,computeVisibilityObb as Xe,filterInPlace as Ye,getCachedAttributeValue as Je,intersectBoundingRectWithMbs as Ze,MbsIntersectResult as et,addWraparound as tt,getSymbolInfo as it,transparentEdgeMaterial as st,getClipRect as rt}from"./i3s/I3SUtil.js";import{IDBCache as ot}from"./i3s/IDBCache.js";import{IDBMockCache as nt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as at}from"./i3s/LayerElevationProvider.js";import{attributeLookup as lt}from"./support/attributeUtils.js";import{ColorMixModeEnum as dt}from"./support/symbolColorUtils.js";import{debugFlags as ht}from"../support/debugFlags.js";import{ElevationRange as ct}from"../support/ElevationRange.js";import{toBoundingRect as ut}from"../support/extentUtils.js";import{Obb as _t}from"../support/orientedBoundingBox.js";import{updatingProgress as gt}from"../support/updatingProperties.js";import{glLayout as mt}from"../support/buffer/glUtil.js";import{createVertexBufferLayout as pt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as ft}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as bt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as yt}from"../webgl-engine/lib/edgeRendering/interfaces.js";const vt="esri.views.3d.layers.I3SMeshView3D",It=()=>l.getLogger(vt),Mt=[1,1,1,1];class Ct extends De{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var xt;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(xt||(xt={}));const Ot=23,Et=100*o.MEGABYTES,jt=t=>{let o=class extends t{constructor(...e){super(e),this._needsNormals=!0,this._updatingHandles=new U,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Ae(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return We(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?je.AllTexturesPBR:je.AllTextures:this._usePBR||this._hasLoadedPBRTextures?je.GeometryTexturesPBR:je.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=y(this.i3slayer.spatialReference),i=_e(e.unit);return(e.offset??0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new qt(be.Absolute,0);const t=y(this.i3slayer.spatialReference),i=_e(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return new qt(be.Absolute,s);case"relative-to-ground":return new qt(be.RelativeToGround,s);case"on-the-ground":return new qt(be.OnTheGround,0);default:return new qt(be.Absolute,0)}}get supportedTextureEncodings(){return Ve(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&we.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ct;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[,s,r]=e;t.expandElevationRangeValues(s-r,s+r)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new nt(this.view,e):new ot("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new ke({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new pe($t(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema),ze(this.i3slayer),Ke(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new oe({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color,this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,a=this._nodeId2Meta,l=this._nodeId2MetaReloading,d=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=a.get(i)||l.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Ne({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:d}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new at({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==be.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Kt):t&&this.removeHandles(Kt)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const c=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),c),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),c),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([p((()=>ht.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ht.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ht.I3S_TREE_SHOW_TILES||(this._treeDebugger=h(this._treeDebugger))}),m),p((()=>ht.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=$e(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>It().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:u}=this,{viewingMode:_,renderCoordsHelper:g}=u;this._planetRadiusInGlobalMode="local"===_?0:g.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=h(this._elevationTask),this.i3sOverrides=h(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=h(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=h(this._labeler),this._treeDebugger=h(this._treeDebugger),this._controller=h(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=h(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=h(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(Ee(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new ge({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=Ie().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=fe(this._layerClippingArea,this._modifications,t);Me({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new c:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Ge.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ht.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||It().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&we.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&bt()}_getVertexBufferLayout(e,t){const i={hasTexture:Pt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return mt(pt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||re}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=lt(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return d(this._nodeId2Meta,(e=>{if(null==e)return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const n of t){const e=lt(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Te(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;if(!k(r,o,0,r,n,0,8))return null;const a=z();return K(a,r,0,8),a}whenGraphicAttributes(e,t){return Qe(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${Ot}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Fe(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===be.Absolute&&(e.geometryObbInRenderSR=_t.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Gt(s.transformedGeometry,s.textureData),s.textureData.every(Ut)&&Lt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>It().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Ht(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:n,anchorIds:a,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=Be(e.serviceMbsInIndexSR,this.elevationOffset,h,c),_=R(Wt,r.center.x,r.center.y,r.center.z);S(_,_,u);const g=new _t(_,[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===be.Absolute&&(e.geometryObbInRenderSR=g),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=a,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObbData:g.data,byteSize:Gt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Lt(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Ut(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>It().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new ct,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e[3],a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&n>=1*_)return null!=r?Yt(t,r,l):null!=d&&d[3]>=0&&Jt(t,d,l),!1;const g=Xt;if(g.elevationRangeMin=1/0,g.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?Yt(g,r,l):null!=d&&Jt(g,d,l),g.elevationRangeMin>=t.elevationRangeMin&&g.elevationRangeMax<=t.elevationRangeMax))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Yt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Xe(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=e.serviceMbsInIndexSR,n=this.elevationOffset,a=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=qe(o,n,a),c=Be(o,n,a,d),u=B(a,l),_=B(l,d);if(null==u||null==_)return Promise.resolve(null);const g=this.i3slayer.normalReferenceFrame,m=t.normalReferenceFrame??g??"none",p={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obbData:e.serviceObbInIndexSR?.data,elevationOffset:n,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:m,indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(p,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===be.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==be.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&a.some((e=>null!=e&&(e.encoding===we.Basis||e.encoding===we.KTX2)))&&await bt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:I}=this._materialParameters(g,m),w=l||new Uint32Array([0,p?p.length:f.byteLength/m[0].stride]),R={vertices:{data:f,count:f.byteLength/m[0].stride,layoutParameters:I},positionData:{positions:J(b.data),indices:Z(b.indices)},indices:p,componentOffsets:w},S=g.transformation?E(g.transformation):j();x(S,n,S);const A=O(F(),S),D=M(C(),S),T=this.view.renderSpatialReference,N=this.view.basemapTerrain.spatialReference,V=F(),P=[1,1,1];G(A,T,P,N)||It().errorOnce("Unsupported coordinate system for IM overlay"),q(A,T,V,N);const U=_.createObject({toMapSpace:H(V[0],V[1],P[0],P[1]),geometry:R,obb:_t.fromData(t.geometryObbData),transform:{position:A,rotationScale:D}}),L=I.textureCoordinates===ft.Atlas,{textures:k,texturePromise:B}=this._initMaterialAndTextures(U,v,a,L);e.memory+=this._memEstimateGeometryAdded(U),e.memory+=k.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const W=!!v.hasParametersFromSource,z="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,K=new Ct(e,h,U,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:W,isOpaque:z},k,c,u);s.meta=K,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&je.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const $=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(K),B]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(K.objectHandle,!1).catch((e=>wt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,K),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(U,!0),null!=t&&t.updateObjectVisibility(K.objectHandle,!0).catch((e=>wt(e,this.i3slayer.title))),K.attributeInfo=i.attributeInfo;const s=K.cachedRendererVersion!==this._rendererVersion,r=$!==this.slicePlaneEnabled;this._updateElevationOffsets(K);const o=K.elevationOffsets;this._updateComponentData(K);const n=this._applyFiltersToNode(K);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(K),null!=this._labeler&&this._addMetaToLabeler(this._labeler,K),this._visibleGeometryChanged(K,Rt.ADD),this._highlights.objectCreated(K),this._updateMaterial(K),this._setNewNodeOpacity(K),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){It().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Bt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,n=s.mode;if(null==t||null==o||n===be.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Wt,d=zt,h=n===be.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Y(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const n=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(R(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),A(l,l,ee(e.node.serviceMbsInIndexSR)),q(l,i,l,o),s[n]=l[0],s[n+1]=l[1],s[n+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),R(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,a.rotationScale),A(l,l,a.position),s[n+2]=c.getAltitude(l),q(l,t,l,o),s[n]=l[0],s[n+1]=l[1])}return s})(),g=s.offset,m=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;m[e]=g+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Se(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==be.Absolute,s=!!t&&t!==e&&t.mode!==be.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Rt.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Pe(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Pt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>He(e,t,s,r)));this._stage.addMany(o);let n=null;return this._collection.updateMaterial(e,(e=>{n=Ue(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:n}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?ft.Atlas:ft.Default:ft.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...g(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Q();this._renderClippingArea=ut(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=ut(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Rt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o),a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===a||null!=d?.[e]))&&Ye(e,l,(e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Je(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return L(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Ft,this.view.renderSpatialReference),Ze(t,Ft)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,St),$(St,At),X(i,At)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===et.INSIDE)return;if(r===et.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Dt,i,t.objectHandle);Ye(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,n)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(null==i)return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:n}=this._getFilteredEdgeMaterials(e),a={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Bt(n,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,n,a,t).catch((e=>wt(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>wt(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>wt(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,n,a).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>wt(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=h(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>wt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Rt.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Le.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=tt(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return tt(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=tt(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await he()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:It().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&It().error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(P(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i],r=ce(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<xt.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<xt.CastShadows),s.pickable=0!=(t[r+4]&1<<xt.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ue))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=it(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?ne(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=se(5*e.featureIds.length));const d={color:Nt,castShadows:!0,pickable:!0,colorMixMode:dt.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=yt.OPAQUE,g=st,m=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Je(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=le(this._colorVariable,t,{color:Vt,arcade:this._arcade});e&&(h=Nt,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=de(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?Oe(h,f,e.color,e.alpha,Mt,Nt):Oe(h,f,null,null,Mt,Nt)}if(null==h&&(h=Nt,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:dt.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=dt.Replace),null!=d.edgeMaterial){const t=h[3]<=0?yt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===dt.Replace)?yt.OPAQUE:yt.TRANSPARENT;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=g}else e.cachedEdgeMaterials[p]=st;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<xt.CastShadows|+d.pickable<<xt.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Bt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==st)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?st:(r=r||t!==st,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Bt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Rt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?ye.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){d(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case ye.EXIT:return!0;case ye.SKIP:return!1}}let r=ye.CONTINUE;switch(i){case ve.ALL:r=this._forAllFeaturesOfNode(s,e);break;case ve.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case ve.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===ye.EXIT}))}_forAllFeaturesOfNode(e,t){let i=ye.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===ye.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=ye.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===ye.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===et.OUTSIDE)return ye.CONTINUE;if(s===et.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=ye.CONTINUE,o=e.featureIds,n=e.objectHandle,a=rt(this._renderClippingArea,this._collection.getObjectTransform(n));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,a))continue;const t=i(o[l],l,e);if(t===ye.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Je(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){if("number"==typeof e||e instanceof i?e=[e]:e instanceof n&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const t=e,i=this.i3slayer.fieldsIndex,s=this._getObjectIdField(),r=t.map((e=>lt(i,e.attributes,s))),{set:o,handle:n}=this._highlights.acquireSet();return this._highlights.setFeatureIds(o,r),n}if("number"==typeof e[0]){const t=e,{set:i,handle:s}=this._highlights.acquireSet();return this._highlights.setFeatureIds(i,t),s}}return a()}resetHighlights(){h(this._highlights),this._highlights=new Re({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,ve.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new me(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}get test(){const e=this,t=e=>{this._nodeColorOverride=e,this._invalidateAllSymbols()};return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),ye.CONTINUE)),null,ve.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))},setNodeColorOverride:t,setNodeColoring:e=>{if("client-nodes"===e)t(((e,t)=>{e.index<0?(t[0]=1,t[1]=0,t[2]=0):(t[0]=1,t[1]=1,t[2]=1)}));else t(null)}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Bt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>wt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=kt(e);if(s){const t={context:i,buffer:s.buffer};Ce(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=xe(i);e.imModificationImpact=s,s!==Ge.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===be.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=F(),a=F(),l=(e,t)=>{A(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),A(e,e,T(a,a,t)),N(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Rt.REMOVE&&t!==Rt.UPDATE||r.events.remove(i),t!==Rt.ADD&&t!==Rt.UPDATE||r.events.add(i,s)}};return e([v()],o.prototype,"_hasLoadedPBRTextures",void 0),e([v()],o.prototype,"_asyncModuleLoading",void 0),e([v()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([v()],o.prototype,"view",void 0),e([v()],o.prototype,"i3slayer",void 0),e([v()],o.prototype,"_controller",void 0),e([v()],o.prototype,"_labeler",void 0),e([v()],o.prototype,"updating",void 0),e([v()],o.prototype,"suspended",void 0),e([v()],o.prototype,"contentVisible",null),e([v({readOnly:!0})],o.prototype,"legendEnabled",null),e([v()],o.prototype,"holeFilling",void 0),e([v(gt)],o.prototype,"updatingProgress",void 0),e([v()],o.prototype,"updatingProgressValue",null),e([v()],o.prototype,"hasTexturesOrVertexColors",null),e([v()],o.prototype,"rendererTextureUsage",null),e([v()],o.prototype,"elevationOffset",null),e([v()],o.prototype,"elevationInfo",null),e([v({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([v()],o.prototype,"supportedTextureEncodings",null),e([v()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([v({type:[ae]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"elevationRange",null),e([v()],o.prototype,"fullExtent",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(vt)],o),o};function wt(e,t){u(e)||It().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Rt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Rt||(Rt={}));const St=W(),At=Q(),Dt=Q(),Tt=new _t,Nt=[0,0,0,0],Vt=new t([0,0,0,0]),Ft=te(0,0,0,0);function Pt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Ht(e){return"geometryData"in e}function Ut(e){return null!=e&&b(e.data)}function Gt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Lt(e,t){return t.byteSize>Et?(It().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function kt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Tt,t.center=ee(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function Bt(e,t){e.forEach((e=>e.opacity=t))}class qt{constructor(e,t){this.mode=e,this.offset=t}}const Wt=F(),zt=W(),Kt="elevation-change";function $t(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}const Qt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Xt=new ct;function Yt(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(Qt);for(const e of Qt){const t=V(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Qt);for(const e of Qt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Jt(e,t,i){const s=ee(t),r=i>0?V(s)-i:s[2],o=ie(t);e.expandElevationRangeValues(r-o,r+o)}export{jt as I3SMeshView3D,$t as makeScheduleFunction};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import n from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{someMap as d}from"../../../core/MapUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import c from"../../../core/PooledArray.js";import{isAbortError as u,throwIfAborted as _,createResolver as g}from"../../../core/promiseUtils.js";import{initial as m,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as I}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as M,invert as C}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as x}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as O,getTranslation as E}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as j,create as w}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as R}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as S,e as A,t as D,y as T,g as N,i as V,f as F,C as P}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as U}from"../../../chunks/vec42.js";import{fromValues as G}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as B}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as q}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as W}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{create as K,empty as $,expandWithBuffer as Q,toRect as X}from"../../../geometry/support/aaBoundingBox.js";import{create as Y,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Z}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as ee}from"../../../geometry/support/FloatArray.js";import{compactIndices as te}from"../../../geometry/support/Indices.js";import{g as ie,f as se,a as re}from"../../../chunks/sphere.js";import{newUByteArray as oe}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as ne}from"../../../layers/LayerConstants.js";import ae from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as le}from"../../../layers/support/fieldUtils.js";import de from"../../../layers/support/SceneModification.js";import{getColor as he,getOpacity as ce}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as ue}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as _e}from"../../../support/basemapUtils.js";import ge from"../../../symbols/Symbol3D.js";import{getMetersPerUnit as me}from"../../../symbols/support/unitConversionUtils.js";import pe from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as be,toWasmModification as ye}from"./I3SMeshWorkerHandle.js";import{ElevationMode as ve,ForAllFeaturesReturnType as Ie,ForAllFeaturesMode as Me}from"./II3SMeshView3D.js";import{initialize as Ce,setModificationsSync as xe,filterObbsForModificationsSync as Oe,interpretObbModificationResults as Ee}from"./SceneLayerWorker.js";import{overrideColor as je}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import{TextureUsage as Re,TextureEncoding as Se}from"./i3s/enums.js";import Ae from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as De}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as Te,NodeCrossfadeMetaData as Ne}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ve}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Pe,selectEncoding as He,defaultMaterial as Ue,createTexture as Ge,configureMaterial as Le}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as ke,NodeState as Be}from"./i3s/I3SNode.js";import{I3SOverrides as qe}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as We,getLocalOrigin as ze}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as Ke,checkSceneLayerValid as $e,checkSceneLayerCompatibleWithView as Qe,getCacheKeySuffix as Xe,whenGraphicAttributes as Ye,computeVisibilityObb as Je,filterInPlace as Ze,getCachedAttributeValue as et,intersectBoundingRectWithMbs as tt,MbsIntersectResult as it,addWraparound as st,getSymbolInfo as rt,transparentEdgeMaterial as ot,getClipRect as nt}from"./i3s/I3SUtil.js";import{IDBCache as at}from"./i3s/IDBCache.js";import{IDBMockCache as lt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as dt}from"./i3s/LayerElevationProvider.js";import{attributeLookup as ht}from"./support/attributeUtils.js";import{ColorMixModeEnum as ct}from"./support/symbolColorUtils.js";import{debugFlags as ut}from"../support/debugFlags.js";import{ElevationRange as _t}from"../support/ElevationRange.js";import{toBoundingRect as gt}from"../support/extentUtils.js";import{Obb as mt}from"../support/orientedBoundingBox.js";import{updatingProgress as pt}from"../support/updatingProperties.js";import{glLayout as ft}from"../support/buffer/glUtil.js";import{createVertexBufferLayout as bt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{TextureCoordinateAttributeType as yt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as vt}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as It}from"../webgl-engine/lib/edgeRendering/interfaces.js";const Mt="esri.views.3d.layers.I3SMeshView3D",Ct=()=>l.getLogger(Mt),xt=[1,1,1,1];class Ot extends Ne{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var Et;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Et||(Et={}));const jt=23,wt=100*o.MEGABYTES,Rt=t=>{let o=class extends t{constructor(...e){super(e),this._needsNormals=!0,this._updatingHandles=new L,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i(null,null,{}),this._crossfadeHelper=new Te(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return Ke(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?Re.AllTexturesPBR:Re.AllTextures:this._usePBR||this._hasLoadedPBRTextures?Re.GeometryTexturesPBR:Re.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null!=e&&"absolute-height"===e.mode){const t=y(this.i3slayer.spatialReference),i=me(e.unit);return(e.offset??0)*i/t}return 0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new zt(ve.Absolute,0);const t=y(this.i3slayer.spatialReference),i=me(e.unit),s=(e.offset??0)*i/t;switch(e.mode){case"absolute-height":return new zt(ve.Absolute,s);case"relative-to-ground":return new zt(ve.RelativeToGround,s);case"on-the-ground":return new zt(ve.OnTheGround,0);default:return new zt(ve.Absolute,0)}}get supportedTextureEncodings(){return Pe(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=0==(this.supportedTextureEncodings&Se.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new _t;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[,s,r]=e;t.expandElevationRangeValues(s-r,s+r)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new lt(this.view,e):new at("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new qe({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new be(Xt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema),$e(this.i3slayer),Qe(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ae({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color,this._isIntegratedMesh||(this._edgeView=this._stage.renderer.ensureEdgeView());const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,a=this._nodeId2Meta,l=this._nodeId2MetaReloading,d=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=a.get(i)||l.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:d}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new dt({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==ve.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Qt):t&&this.removeHandles(Qt)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const c=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),c),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),c),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([p((()=>ut.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ut.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ut.I3S_TREE_SHOW_TILES||(this._treeDebugger=h(this._treeDebugger))}),m),p((()=>ut.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=Xe(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>Ct().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:u}=this,{viewingMode:_,renderCoordsHelper:g}=u;this._planetRadiusInGlobalMode="local"===_?0:g.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=h(this._elevationTask),this.i3sOverrides=h(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=h(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=h(this._labeler),this._treeDebugger=h(this._treeDebugger),this._controller=h(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=h(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=h(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(we(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new pe({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=Ce().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=ye(this._layerClippingArea,this._modifications,t);xe({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new c:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==ke.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ut.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={type:"simple-fill",outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o={...t,color:e[s.type]};this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||Ct().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&0!=(this.supportedTextureEncodings&Se.Basis)&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&vt()}_getVertexBufferLayout(e,t){const i={hasTexture:Ut(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return ft(bt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||ne}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=ht(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());let i=null;return d(this._nodeId2Meta,(e=>{if(null==e)return!1;const s=e.featureIds.indexOf(t);return-1!==s&&(i={node:e.node,index:s},!0)})),i}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const n of t){const e=ht(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ve(t,this._collection,s,Z(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;if(!q(r,o,0,r,n,0,8))return null;const a=$();return Q(a,r,0,8),a}whenGraphicAttributes(e,t){return Ye(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${jt}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(0==(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=He(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=mt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=kt(s.transformedGeometry,s.textureData),s.textureData.every(Lt)&&Bt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>Ct().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Gt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:n,anchorIds:a,anchors:l,transformedGeometry:d}=s,h=this._controller.crsIndex,c=this.view.renderSpatialReference,u=We(e.serviceMbsInIndexSR,this.elevationOffset,h,c),_=S(Kt,r.center.x,r.center.y,r.center.z);A(_,_,u);const g=new mt(_,[r.extents.x,r.extents.y,r.extents.z],R(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=g),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=a,t.geometryData.anchors=l;const m={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:u,geometryObbData:g.data,byteSize:kt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&Bt(e,m)){const t=null!=m.textureData?m.textureData.map((e=>Lt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{...m,textureData:t}).catch((t=>Ct().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,m,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new _t,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e[3],a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&n>=1*_)return null!=r?Zt(t,r,l):null!=d&&d[3]>=0&&ei(t,d,l),!1;const g=Jt;if(g.elevationRangeMin=1/0,g.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?Zt(g,r,l):null!=d&&ei(g,d,l),g.elevationRangeMin>=t.elevationRangeMin&&g.elevationRangeMax<=t.elevationRangeMax))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return Zt(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Je(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let f=0;f<s.length;++f)r[f]=this._getVertexBufferLayout(s[f],t.geometryDescriptor);const o=e.serviceMbsInIndexSR,n=this.elevationOffset,a=this._controller.crsIndex,l=this._controller.crsVertex,d=this.view.renderSpatialReference,h=ze(o,n,a),c=We(o,n,a,d),u=W(a,l),_=W(l,d);if(null==u||null==_)return Promise.resolve(null);const g=this.i3slayer.normalReferenceFrame,m=t.normalReferenceFrame??g??"none",p={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,localOrigin:h,globalTrafo:c,mbs:o,obbData:e.serviceObbInIndexSR?.data,elevationOffset:n,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:m,indexToVertexProjector:u,vertexToRenderProjector:_};return this._worker.invoke(p,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===ve.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==ve.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter((e=>null!=e&&0!=(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&a.some((e=>null!=e&&(e.encoding===Se.Basis||e.encoding===Se.KTX2)))&&await vt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:I}=this._materialParameters(g,m),R=l||new Uint32Array([0,p?p.length:f.byteLength/m[0].stride]),S={vertices:{data:f,count:f.byteLength/m[0].stride,layoutParameters:I},positionData:{positions:ee(b.data),indices:te(b.indices)},indices:p,componentOffsets:R},A=g.transformation?j(g.transformation):w();O(A,n,A);const N=E(H(),A),V=M(x(),A),F=this.view.renderSpatialReference,P=this.view.basemapTerrain.spatialReference,U=mt.fromData(t.geometryObbData).center,L=[1,1,1];k(U,F,L,P)||Ct().errorOnce("Unsupported coordinate system for IM overlay");const B=H();z(U,F,B,P);const q=x();C(q,V);const W=H();D(W,T(W,U,N),q);const K=B[0]-W[0]*L[0],$=B[1]-W[1]*L[1],Q=_.createObject({toMapSpace:G(K,$,L[0],L[1]),geometry:S,obb:mt.fromData(t.geometryObbData),transform:{position:N,rotationScale:V}}),X=I.textureCoordinates===yt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,a,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const Z=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new Ot(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:Z,isOpaque:ie},Y,c,u);s.meta=se,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>0!=(e&Re.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(null!=t&&t.updateObjectVisibility(se.objectHandle,!1).catch((e=>St(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),null!=t&&t.updateObjectVisibility(se.objectHandle,!0).catch((e=>St(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const n=this._applyFiltersToNode(se);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,At.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){Ct().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Wt(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,n=s.mode;if(null==t||null==o||n===ve.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Kt,d=$t,h=n===ve.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=Z(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const n=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(S(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),N(l,l,ie(e.node.serviceMbsInIndexSR)),z(l,i,l,o),s[n]=l[0],s[n+1]=l[1],s[n+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),S(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),D(l,l,a.rotationScale),N(l,l,a.position),s[n+2]=c.getAltitude(l),z(l,t,l,o),s[n]=l[0],s[n+1]=l[1])}return s})(),g=s.offset,m=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;m[e]=g+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new De(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==ve.Absolute,s=!!t&&t!==e&&t.mode!==ve.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,At.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ue(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=Ut(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ge(e,t,s,r)));this._stage.addMany(o);let n=null;return this._collection.updateMaterial(e,(e=>{n=Le(e,t,o,i,this.view._stage.renderView.textureRepository,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:n}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?yt.Atlas:yt.Default:yt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...g(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=Y();this._renderClippingArea=gt(this.view.clippingArea,i,e)?i:null;const s=Y();this._layerClippingArea=gt(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,At.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o),a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===a||null!=d?.[e]))&&Ze(e,l,(e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?et(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return B(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Ht,this.view.renderSpatialReference),tt(t,Ht)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Dt),X(Dt,Tt),J(i,Tt)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===it.INSIDE)return;if(r===it.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Nt,i,t.objectHandle);Ze(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,n)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}_addOrUpdateEdgeRendering(e,t=!0){const i=this._edgeView;if(null==i)return Promise.resolve(null);const s=e.objectHandle,r=i.hasObject(s),{hasEdges:o,perFeatureEdgeMaterials:n}=this._getFilteredEdgeMaterials(e),a={hasSlicePlane:this.slicePlaneEnabled};if(o&&r){if(this.nodeCrossfadingEnabled){Wt(n,this.getNodeOpacity(e))}return i.updateAllComponentMaterials(s,n,a,t).catch((e=>St(e,this.i3slayer.title))),i.updateObjectVisibility(s,!0).catch((e=>St(e,this.i3slayer.title))),i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>St(e,this.i3slayer.title))),Promise.resolve(i)}return o&&!r?this._collection.addEdges(s,i,n,a).then((t=>(e.edgeMemoryUsage=t,e.node.memory+=t,i.updateAllVerticalOffsets(s,e.elevationOffsets).catch((e=>St(e,this.i3slayer.title))),i))):(!o&&r&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,i.removeObject(s)),Promise.resolve(null))}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=h(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>St(e,this.i3slayer.title))),this._visibleGeometryChanged(s,At.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===Be.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=st(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return st(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=st(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ue()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:Ct().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&Ct().error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(U(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i],r=_e(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<Et.CastShadows)-1,s.castShadows=0!=(t[r+4]&1<<Et.CastShadows),s.pickable=0!=(t[r+4]&1<<Et.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=rt(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?le(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=oe(5*e.featureIds.length));const d={color:Ft,castShadows:!0,pickable:!0,colorMixMode:ct.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=It.OPAQUE,g=ot,m=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=et(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=he(this._colorVariable,t,{color:Pt,arcade:this._arcade});e&&(h=Ft,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=ce(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?je(h,f,e.color,e.alpha,xt,Ft):je(h,f,null,null,xt,Ft)}if(null==h&&(h=Ft,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:ct.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=ct.Replace),null!=d.edgeMaterial){const t=h[3]<=0?It.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===ct.Replace)?It.OPAQUE:It.TRANSPARENT;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=g}else e.cachedEdgeMaterials[p]=ot;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<Et.CastShadows|+d.pickable<<Et.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Wt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==ot)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?ot:(r=r||t!==ot,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),Wt(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,At.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?Ie.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){d(this._nodeId2Meta,(s=>{if(null==s)return!1;if(null!=t){switch(t(s)){case Ie.EXIT:return!0;case Ie.SKIP:return!1}}let r=Ie.CONTINUE;switch(i){case Me.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Me.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Me.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}return r===Ie.EXIT}))}_forAllFeaturesOfNode(e,t){let i=Ie.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===Ie.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=Ie.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===Ie.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===it.OUTSIDE)return Ie.CONTINUE;if(s===it.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=Ie.CONTINUE,o=e.featureIds,n=e.objectHandle,a=nt(this._renderClippingArea,this._collection.getObjectTransform(n));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,a))continue;const t=i(o[l],l,e);if(t===Ie.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=et(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e){if("number"==typeof e||e instanceof i?e=[e]:e instanceof n&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const t=e,i=this.i3slayer.fieldsIndex,s=this._getObjectIdField(),r=t.map((e=>ht(i,e.attributes,s))),{set:o,handle:n}=this._highlights.acquireSet();return this._highlights.setFeatureIds(o,r),n}if("number"==typeof e[0]){const t=e,{set:i,handle:s}=this._highlights.acquireSet();return this._highlights.setFeatureIds(i,t),s}}return a()}resetHighlights(){h(this._highlights),this._highlights=new Ae({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Me.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new fe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}get test(){const e=this,t=e=>{this._nodeColorOverride=e,this._invalidateAllSymbols()};return{controller:this._controller,labeler:this._labeler,get visibleObjectIds(){const t=[];return e._forAllFeatures((e=>(t.push(e),Ie.CONTINUE)),null,Me.VISIBLE_ONLY),t.sort(((e,t)=>e-t)),t},get numNodes(){return e._nodeId2Meta.size},get loadedNodes(){return Array.from(e._nodeId2Meta.keys()).sort(((e,t)=>e-t))},setNodeColorOverride:t,setNodeColoring:e=>{if("client-nodes"===e)t(((e,t)=>{e.index<0?(t[0]=1,t[1]=0,t[2]=0):(t[0]=1,t[1]=1,t[2]=1)}));else t(null)}}}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;Wt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>St(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=qt(e);if(s){const t={context:i,buffer:s.buffer};Oe(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ee(i);e.imModificationImpact=s,s!==ke.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===ve.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{N(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),N(e,e,V(a,a,t)),F(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==At.REMOVE&&t!==At.UPDATE||r.events.remove(i),t!==At.ADD&&t!==At.UPDATE||r.events.add(i,s)}};return e([v()],o.prototype,"_hasLoadedPBRTextures",void 0),e([v()],o.prototype,"_asyncModuleLoading",void 0),e([v()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([v()],o.prototype,"view",void 0),e([v()],o.prototype,"i3slayer",void 0),e([v()],o.prototype,"_controller",void 0),e([v()],o.prototype,"_labeler",void 0),e([v()],o.prototype,"updating",void 0),e([v()],o.prototype,"suspended",void 0),e([v()],o.prototype,"contentVisible",null),e([v({readOnly:!0})],o.prototype,"legendEnabled",null),e([v()],o.prototype,"holeFilling",void 0),e([v(pt)],o.prototype,"updatingProgress",void 0),e([v()],o.prototype,"updatingProgressValue",null),e([v()],o.prototype,"hasTexturesOrVertexColors",null),e([v()],o.prototype,"rendererTextureUsage",null),e([v()],o.prototype,"elevationOffset",null),e([v()],o.prototype,"elevationInfo",null),e([v({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([v()],o.prototype,"supportedTextureEncodings",null),e([v()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([v({type:[de]})],o.prototype,"_modifications",void 0),e([v({readOnly:!0})],o.prototype,"clientGeometry",null),e([v()],o.prototype,"elevationRange",null),e([v()],o.prototype,"fullExtent",null),e([v()],o.prototype,"_elevationTask",void 0),e([v({readOnly:!0})],o.prototype,"_usePBR",null),o=e([I(Mt)],o),o};function St(e,t){u(e)||Ct().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var At;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(At||(At={}));const Dt=K(),Tt=Y(),Nt=Y(),Vt=new mt,Ft=[0,0,0,0],Pt=new t([0,0,0,0]),Ht=se(0,0,0,0);function Ut(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Gt(e){return"geometryData"in e}function Lt(e){return null!=e&&b(e.data)}function kt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function Bt(e,t){return t.byteSize>wt?(Ct().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function qt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Vt,t.center=ie(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function Wt(e,t){e.forEach((e=>e.opacity=t))}class zt{constructor(e,t){this.mode=e,this.offset=t}}const Kt=H(),$t=K(),Qt="elevation-change";function Xt(e){return t=>{if(e.immediate)return e.immediate.schedule(t);throw console.error("Error no immediate schudler"),new Error("cant find immediate scheduler")}}const Yt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Jt=new _t;function Zt(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(Yt);for(const e of Yt){const t=P(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Yt);for(const e of Yt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function ei(e,t,i){const s=ie(t),r=i>0?P(s)-i:s[2],o=re(t);e.expandElevationRangeValues(r-o,r+o)}export{Rt as I3SMeshView3D,Xt as makeScheduleFunction};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import r from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as o}from"../../../core/reactiveUtils.js";import{schedule as n}from"../../../core/scheduling.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as h,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{g,t as b}from"../../../chunks/vec32.js";import{fromArray as y,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as _}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as x}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as j}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as C}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as M,BufferViewVec4u8 as T,BufferViewVec4u16 as P,BufferViewVec3f as U,BufferViewVec3u8 as O,BufferViewVec3u16 as E,BufferViewVec2f as I,BufferViewInt16 as V,BufferViewUint32 as H,BufferViewUint16 as R}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as F,wasmFailedToInit as A,Lyr3DPrimitiveType as S,Lyr3DLightingModel as L,Lyr3DUvWrapMode as D,Lyr3DImageFormat as k,Lyr3DPixelFormat as B,Lyr3DVtxAtrbSemantic as N,Lyr3DType as G}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getMetersPerUnit as z}from"../../../symbols/support/unitConversionUtils.js";import{ViewingMode as W}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as $}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as J}from"./interfaces.js";import{LayerView3D as q}from"./LayerView3D.js";import{addLayerViewToWasm as K,removeLayerViewFromWasm as Q,getLyr3DWasm as X}from"./Lyr3DWasm.js";import{LayerElevationProvider as Y}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as ee,faceCullingConversion as te,wrapModeConversion as re,lyr3DTypeToByteSize as ie}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as se}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as oe}from"../support/ElevationRange.js";import{compute as ne}from"../support/orientedBoundingBox.js";import{createVertexBufferLayout as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{ComponentParameterSummary as le}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateAttributeType as me}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as ue}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as he,AlphaDiscardMode as pe,TextureEncodingMimeType as fe}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as ge}from"../webgl-engine/lib/Normals.js";import{Texture as be}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as ye}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as we}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ve from"../../layers/LayerView.js";var _e;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(_e||(_e={}));class xe{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}totalMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function je(e){return Math.round(e/1048.576)/1e3}let Ce=class extends(q(ve)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=J.WithoutRasterImage,this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(_e.Error),this._dbg(_e.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=K(this).then((e=>{this._intersectionHandler=new se(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Y({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this._suspendedHandle=s((()=>this.suspended),(e=>{const t=X(this.view);t&&t.setEnabled(this,!e)}),o),this.addHandles([s((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))])})).catch((e=>{if(Q(this),this._wasmLayerId=-1,e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===A)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(_e.VerboseAPI,"Tiles3DLayerView3D destroy() called"),Q(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=n((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})))}_slicePlaneEnabledChange(e){this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?he.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){const t=e?.offset??0,r=e?.unit?z(e?.unit):1,i=X(this.view);i&&i.setLayerOffset(this,t*r)}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.totalMemory())})),e}get unloadedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.totalMemory())})),e}get performanceInfo(){let e=0,t=0,r=0,i=0,s=0,o=0;return this._lyrHandleToObjects.forEach((n=>{n.isVisible?(e+=n.texMemoryUsage,t+=n.vboMemoryUsage,s++):(r+=n.texMemoryUsage,i+=n.vboMemoryUsage,o++)})),new $(this.usedMemory,s,o,je(t),je(e),je(i),je(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===W.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return(this.layer.elevationInfo?.offset??0)*(this.layer.elevationInfo?.unit?z(this.layer.elevationInfo.unit):1)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new oe(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=X(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=y(t.desc.origin),i=new Array,s=new Map,o=new xe;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const n=this.view.basemapTerrain.spatialReference;let a,l;if("global"===this.view.viewingMode){const e=f();x(_,r,e,n),a=c(u(),e),l=m(u(),a)}else a=d,l=d;const M=f();h(M,M,r);const T=p(w(),M);let P=null;const U=w();for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];if(e.ptype!==S.Lines||null==t.data)continue;const{positionView:i,positionAttr:s,indicesView:o}=this.getBufferViews(e,t.data.buffer,a,!1);null!=s&&null!=i&&null!=o&&(P=ne(s),g(U,P.center,r),P.center=U)}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];if(this._dbg(_e.VerboseAPI,JSON.stringify(e)),e.ptype===S.Lines)continue;if(null==Z[e.ptype]||null==t.data){this._dbg(_e.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,u=null!=m?m.lightingModel:L.Unlit,h=u!==L.Unlit,{positionView:p,positionAttr:f,normalsView:y,normalsAttr:_,colorAttr:x,texCoord0Attr:M,indicesView:O}=this.getBufferViews(e,t.data.buffer,a,h);if(null==f||null==p||null==O)continue;const E={colors:null!=x,textureCoordinates:null!=M?me.Default:me.None,hasNormals:null!=y,needsNormals:h},I=f.data.length/f.size,V=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(_e.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!V(M,"numTexcoord")||!V(x,"numColors")||!V(_,"normals"))continue;const H=ae(E);let R;if(null!=P?R=P.clone():(R=ne(f),g(U,R.center,r),R.center=U),a!==d)for(let t=0;t<p.count;t++)p.getVec(t,U),b(U,U,a),p.setVec(t,U);const F=H.createBuffer(f.data.length),A=new Map([[ye.POSITION,f]]);null!=M&&A.set(ye.UV0,M),null!=x&&A.set(ye.COLOR,x),null!=_&&A.set(ye.NORMALCOMPRESSED,_),A.forEach(((e,t)=>{null!=e&&we(t,e,null,null,F,0)}));const D=new Uint32Array([0,O.typedBuffer.length]),k={vertices:{data:F.buffer,count:F.byteLength/H.stride,layoutParameters:E},positionData:{positions:p.typedBuffer,indices:O.typedBuffer},indices:O.typedBuffer,componentOffsets:D};o.cpuMemoryUsage+=p.count,o.cpuMemoryUsage+=O.count;const B=this.view.renderSpatialReference,N=w(),G=[1,1,1];j(T,B,G,n)||this._dbg(_e.Error,"Unsupported coordinate system for IM overlay"),C(T,B,N,n);const z=this._collection.createObject({toMapSpace:v(N[0],N[1],G[0],G[1]),geometry:k,obb:R,transform:{position:T,rotationScale:l}});m&&this._collection.updateMaterial(z,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=u===L.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,s),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveFactor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,s),e.emissionTexture=this._getTexture(m.emissiveTex,t,s),e.occlusionTexture=this._getTexture(m.occlusionTex,t,s),e.normalTexture=this._getTexture(m.normalTex,t,s)),e.objectOpacity=0,e.alphaDiscardMode=pe.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const n=Promise.all(r);i.push(n),n.then((()=>{e.alphaDiscardMode=ee[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?te[m.faceCulling]:he.Back,this._initialCullFace.set(z,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=le.All,e.textureAlphaCutoff=m.alphaCutoff??.1,e.alphaDiscardMode=ee[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)})),o.components.push(z),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(z)}if(await Promise.all(i),s.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o,o.totalMemory()),{memUsageBytes:o.totalMemory()}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t){const r=this._lyrHandleToObjects.get(e);if(r&&(this._visibleGeometryChanged(),r.isVisible=t,r.components.forEach((e=>{this._collection.setObjectVisibility(e,t),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache))if(t){this._memCache.pop(`${e}`)||console.error(`[js] ${e} was not found in the cache!`)}else this._memCache.put(`${e}`,r,r.totalMemory())}_getTexture(e,t,r){let i=null;if(e&&t.desc?.images&&t.data?.buffer){const s=t.desc.images[e?.imageId];if(i=r.get(s),!i&&s){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=o>1,a=re[e.wrapMode??D.None];let l=s.alpha?4:3;const c=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,d=null,u=null;switch(s.format){case k.Raw:s.pixelFormat===B.R8?(m=c.buffer,l=1,d=""):s.pixelFormat===B.Rgb8?(m=c.buffer,l=3,d=""):s.pixelFormat===B.Rgba8&&(m=c.buffer,l=4,d="");break;case k.Dxt1:m=c.buffer,l=3,d=fe.DDS_ENCODING;break;case k.Dxt5:m=c.buffer,l=4,d=fe.DDS_ENCODING;break;case k.Png:d="image/png",u=document.createElement("img");break;case k.Jpeg:d="image/jpeg",u=document.createElement("img");break;case k.Etc2:d="image/ktx",u=document.createElement("img");break;case k.Astc:this._dbg(_e.Error,"Astc texture not supported");break;case k.Pvrtc:this._dbg(_e.Error,"Pvrtc texture not supported")}if(u&&d){const e=new Blob([c],{type:d});u.src=URL.createObjectURL(e),m=u}m&&null!=d&&(i=new be(m,{mipmap:n,maxAnisotropy:o,encoding:d,wrap:a,components:l,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height}),this._stage.add(i),r.set(s,i))}}return i?new ce(this.view._stage.renderView.textureRepository,i.id):null}getBufferViews(e,t,r,i){let s,o,n,a,l,c,m,d=null;for(let h=0;h<e.atrbs.length;h++){const m=e.atrbs[h],p=m.view,f=void 0,g=p.byteOffset+p.byteCount,b=p.byteCount/ie[p.type],y=[...Array(b).keys()].map((e=>e));try{switch(m.sem){case N.Position:3!==p.ncomp||p.type!==G.F32?this._dbg(_e.Error,"[Unsupported Feature] Unsupported view for Position ("+p+")"):(s=new U(t,p.byteOffset,f,g),o=new ue(s.typedBuffer,y,3));break;case N.Normal:if(3!==p.ncomp||p.type!==G.F32)this._dbg(_e.Error,"[Unsupported Feature] Unsupported view for Normal ("+p+")");else if(i){const e=new U(t,p.byteOffset,f,g),i=ge(e.typedBuffer,r);l=new V(i),c=new ue(l.typedBuffer,y,2)}break;case N.TexCoord:2!==p.ncomp||p.type!==G.F32?this._dbg(_e.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+p+")"):void 0===a&&(a=new ue(new I(t,p.byteOffset,f,g).typedBuffer,y,2));break;case N.Color:4===p.ncomp?(p.type===G.F32&&(d=new M(t,p.byteOffset,f,g)),p.type===G.U8&&(d=new T(t,p.byteOffset,f,g)),p.type===G.U16&&(d=new P(t,p.byteOffset,f,g))):3===p.ncomp&&(p.type===G.F32&&(d=new U(t,p.byteOffset,f,g)),p.type===G.U8&&(d=new O(t,p.byteOffset,f,g)),p.type===G.U16&&(d=new E(t,p.byteOffset,f,g))),null==d?this._dbg(_e.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+p+")"):n=new ue(d.typedBuffer,y,p.ncomp);break;case N.FeatureIndex:break;default:this._dbg(_e.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+m.sem+"). Skipping vertex attribute.")}}catch(u){this._dbg(_e.VerboseAPI,"Error Creating buffer ("+u+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,i=void 0,s=r.byteOffset+r.byteCount;switch(e.index.view.type){case G.U16:m=new R(t,r.byteOffset,i,s);break;case G.U32:m=new H(t,r.byteOffset,i,s);break;case G.U8:default:this._dbg(_e.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==m&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);m=new R(t)}else{const t=new Uint32Array(e);m=new H(t)}for(let t=0;t<e;t++)m.set(t,t)}return{positionView:s,positionAttr:o,colorAttr:n,texCoord0Attr:a,indicesView:m,normalsView:l,normalsAttr:c}}_onRemoveFromCache(e){const t=X(this.view);t&&t.onRenderableEvicted(this,e.handle,e.totalMemory()),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===_e.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],Ce.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([a()],Ce.prototype,"layer",void 0),e([a()],Ce.prototype,"elevationOffset",null),Ce=e([l("esri.views.3d.layers.Tiles3DLayerView3D")],Ce);const Me=Ce;export{Me as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import r from"../../../core/Logger.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as s,initial as o}from"../../../core/reactiveUtils.js";import{schedule as n}from"../../../core/scheduling.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as c,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{IDENTITY as d,create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{translate as u,getTranslation as p}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{g,t as b}from"../../../chunks/vec32.js";import{fromArray as y,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as v}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as _}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as x}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as j}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as C}from"../../../geometry/projection/projectVectorToVector.js";import{BufferViewVec4f as T,BufferViewVec4u8 as M,BufferViewVec4u16 as P,BufferViewVec3f as O,BufferViewVec3u8 as U,BufferViewVec3u16 as E,BufferViewVec2f as V,BufferViewInt16 as I,BufferViewUint32 as H,BufferViewUint16 as R}from"../../../geometry/support/buffer/BufferView.js";import{invalidLayerView as F,wasmFailedToInit as A,Lyr3DPrimitiveType as S,Lyr3DLightingModel as L,Lyr3DUvWrapMode as D,Lyr3DImageFormat as k,Lyr3DPixelFormat as B,Lyr3DVtxAtrbSemantic as G,Lyr3DType as N}from"../../../layers/ILyr3DWasmPerSceneView.js";import{getMetersPerUnit as z}from"../../../symbols/support/unitConversionUtils.js";import{ViewingMode as W}from"../../ViewingMode.js";import{IntegratedMesh3DTilesViewPerformanceInfo as $}from"./IntegratedMesh3DTilesViewPerformanceInfo.js";import{DrapeTargetType as J}from"./interfaces.js";import{LayerView3D as q}from"./LayerView3D.js";import{addLayerViewToWasm as K,removeLayerViewFromWasm as Q,getLyr3DWasm as X}from"./Lyr3DWasm.js";import{LayerElevationProvider as Y}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as Z,alphaModeConversion as ee,faceCullingConversion as te,wrapModeConversion as re,lyr3DTypeToByteSize as ie}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as se}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as oe}from"../support/ElevationRange.js";import{compute as ne}from"../support/orientedBoundingBox.js";import{createVertexBufferLayout as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{ComponentParameterSummary as le}from"../webgl-engine/collections/Component/Material/ComponentMaterial.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{TextureCoordinateAttributeType as me}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as ue,AlphaDiscardMode as pe,TextureEncodingMimeType as fe}from"../webgl-engine/lib/basicInterfaces.js";import{compressAndTransformNormals as ge}from"../webgl-engine/lib/Normals.js";import{Texture as be}from"../webgl-engine/lib/Texture.js";import{VertexAttribute as ye}from"../webgl-engine/lib/VertexAttribute.js";import{writeDefaultAttribute as we}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ve from"../../layers/LayerView.js";var _e;!function(e){e[e.API=1]="API",e[e.VerboseAPI=2]="VerboseAPI",e[e.Error=3]="Error"}(_e||(_e={}));class xe{constructor(){this.handle=0,this.isVisible=!1,this.components=[],this.texMemoryUsage=0,this.vboMemoryUsage=0,this.cpuMemoryUsage=0,this.textures=[]}totalMemory(){return this.texMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}}function je(e){return Math.round(e/1048.576)/1e3}let Ce=class extends(q(ve)){constructor(){super(...arguments),this.type="integrated-mesh-3dtiles",this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this.drapeTargetType=J.WithoutRasterImage,this._lyrHandleToObjects=new Map,this._initialCullFace=new Map,this._suspendedHandle=null,this._dbgFlags=new Set}initialize(){if(this._dbgFlags.add(_e.Error),this._dbg(_e.VerboseAPI,"Tiles3DLayerView3D initialize() called"),!this._canProjectWithoutEngine())throw new t("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});const e=K(this).then((e=>{this._intersectionHandler=new se(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._elevationProvider=new Y({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register("im",this._elevationProvider),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this),this._wasmLayerId=e;const t=this.view.resourceController.memoryController.newCache(`t3d-${this.uid}`,(e=>this._onRemoveFromCache(e)));this._memCache=t,this._suspendedHandle=s((()=>this.suspended),(e=>{const t=X(this.view);t&&t.setEnabled(this,!e)}),o),this.addHandles([s((()=>this.layer.elevationInfo),(e=>this._elevationInfoChanged(e)))])})).catch((e=>{if(Q(this),this._wasmLayerId=-1,e===F)throw new t("tiles3d:addLayer-failure","The 3d tiles layer description was invalid.",{});if(e===A)throw new t("tiles3d:addLayer-failure","The 3d tiles layer web assembly module failed to download.",{})}));this.addResolvingPromise(e)}destroy(){this._dbg(_e.VerboseAPI,"Tiles3DLayerView3D destroy() called"),Q(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.objectsChanged(this._obbs),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach((e=>this.freeObject(e))),this._lyrHandleToObjects.clear(),this._initialCullFace.clear(),this._memCache=i(this._memCache),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null)}_visibleGeometryChanged(){null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=n((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})))}_slicePlaneEnabledChange(e){this.objects.forEach((t=>{const r=this._collection.getMaterial(t);r.commonMaterialParameters.hasSlicePlane=e,r.commonMaterialParameters.cullFace=e?ue.None:this._initialCullFace.get(t)}))}_elevationInfoChanged(e){const t=e?.offset??0,r=e?.unit?z(e?.unit):1,i=X(this.view);i&&i.setLayerOffset(this,t*r)}get _obbs(){return this.objects.map((e=>this._collection.getComponentObb(e)))}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible&&(e+=t.totalMemory())})),e}get unloadedMemory(){let e=0;return this._lyrHandleToObjects.forEach((t=>{t.isVisible||(e+=t.totalMemory())})),e}get performanceInfo(){let e=0,t=0,r=0,i=0,s=0,o=0;return this._lyrHandleToObjects.forEach((n=>{n.isVisible?(e+=n.texMemoryUsage,t+=n.vboMemoryUsage,s++):(r+=n.texMemoryUsage,i+=n.vboMemoryUsage,o++)})),new $(this.usedMemory,s,o,je(t),je(e),je(i),je(r))}_canProjectWithoutEngine(){if(this.view.state.viewingMode===W.Local){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view._stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationOffset(){return(this.layer.elevationInfo?.offset??0)*(this.layer.elevationInfo?.unit?z(this.layer.elevationInfo.unit):1)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new oe(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}get objects(){return Array.from(this._lyrHandleToObjects.values()).reduce(((e,t)=>e.concat(t.components)),new Array)}isUpdating(){const e=X(this.view);return!(this._wasmLayerId<0||null==e)&&e.isUpdating(this._wasmLayerId)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const r=y(t.desc.origin),i=new Array,s=new Map,o=new xe;o.handle=e.handle,this._lyrHandleToObjects.set(e.handle,o);const n=this.view.basemapTerrain.spatialReference;let a,l;if("global"===this.view.viewingMode){const e=f();x(_,r,e,n),a=c(h(),e),l=m(h(),a)}else a=d,l=d;const T=f();u(T,T,r);const M=p(w(),T);let P=null;const O=w();for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];if(e.ptype!==S.Lines||null==t.data)continue;const{positionView:i,positionAttr:s,indicesView:o}=this.getBufferViews(e,t.data.buffer,a,!1);null!=s&&null!=i&&null!=o&&(P=ne(s),g(O,P.center,r),P.center=O)}for(let c=0;c<t.desc.prims.length;c++){const e=t.desc.prims[c];if(this._dbg(_e.VerboseAPI,JSON.stringify(e)),e.ptype===S.Lines)continue;if(null==Z[e.ptype]||null==t.data){this._dbg(_e.VerboseAPI,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const m=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,h=null!=m?m.lightingModel:L.Unlit,u=h!==L.Unlit,{positionView:p,positionAttr:f,normalsView:y,normalsAttr:_,colorAttr:x,texCoord0Attr:T,indicesView:U}=this.getBufferViews(e,t.data.buffer,a,u);if(null==f||null==p||null==U)continue;const E={colors:null!=x,textureCoordinates:null!=T?me.Default:me.None,hasNormals:null!=y,needsNormals:u},V=f.data.length/f.size,I=(e,t)=>!e||e.data.length/e.size===V||(this._dbg(_e.Error,`${t} !== numPos. Skipping primitive.`),!1);if(!I(T,"numTexcoord")||!I(x,"numColors")||!I(_,"normals"))continue;const H=ae(E);let R;if(null!=P?R=P.clone():(R=ne(f),g(O,R.center,r),R.center=O),a!==d)for(let t=0;t<p.count;t++)p.getVec(t,O),b(O,O,a),p.setVec(t,O);const F=H.createBuffer(f.data.length),A=new Map([[ye.POSITION,f]]);null!=T&&A.set(ye.UV0,T),null!=x&&A.set(ye.COLOR,x),null!=_&&A.set(ye.NORMALCOMPRESSED,_),A.forEach(((e,t)=>{null!=e&&we(t,e,null,null,F,0)}));const D=new Uint32Array([0,U.typedBuffer.length]),k={vertices:{data:F.buffer,count:F.byteLength/H.stride,layoutParameters:E},positionData:{positions:p.typedBuffer,indices:U.typedBuffer},indices:U.typedBuffer,componentOffsets:D};o.cpuMemoryUsage+=p.count,o.cpuMemoryUsage+=U.count;const B=this.view.renderSpatialReference,G=w(),N=[1,1,1];j(M,B,N,n)||this._dbg(_e.Error,"Unsupported coordinate system for IM overlay"),C(M,B,G,n);const z=this._collection.createObject({toMapSpace:v(G[0],G[1],N[0],N[1]),geometry:k,obb:R,transform:{position:M,rotationScale:l}});m&&this._collection.updateMaterial(z,(e=>{e.baseColor=m.baseColorFactor,e.usePBR=h===L.Pbr,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(m.baseColorTex,t,s),e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveFactor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(m.metalTex,t,s),e.emissionTexture=this._getTexture(m.emissiveTex,t,s),e.occlusionTexture=this._getTexture(m.occlusionTex,t,s),e.normalTexture=this._getTexture(m.normalTex,t,s)),e.objectOpacity=0,e.alphaDiscardMode=pe.Mask;const r=[];e.baseColorTexture&&r.push(e.baseColorTexture.loadPromise),e.usePBR&&e.metallicRoughnessTexture&&r.push(e.metallicRoughnessTexture.loadPromise),e.usePBR&&e.emissionTexture&&r.push(e.emissionTexture.loadPromise),e.usePBR&&e.occlusionTexture&&r.push(e.occlusionTexture.loadPromise),e.usePBR&&e.normalTexture&&r.push(e.normalTexture.loadPromise);const n=Promise.all(r);i.push(n),n.then((()=>{e.alphaDiscardMode=ee[m.alphaMode],e.objectOpacity=1,o.texMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory||0,e.usePBR&&(o.texMemoryUsage+=e.metallicRoughnessTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.emissionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.occlusionTexture?.glTexture?.usedMemory||0,o.texMemoryUsage+=e.normalTexture?.glTexture?.usedMemory||0)})),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=m.faceCulling?te[m.faceCulling]:ue.Back,this._initialCullFace.set(z,e.commonMaterialParameters.cullFace),e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=le.All,e.textureAlphaCutoff=m.alphaCutoff??.1,e.alphaDiscardMode=ee[m.alphaMode],e.isIntegratedMesh=!0,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)})),o.components.push(z),o.vboMemoryUsage+=this._collection.getObjectGPUMemoryUsage(z)}if(await Promise.all(i),s.forEach((e=>{o.textures.push(e)})),!this._memCache)throw new Error("no memCache");return this._memCache.put(`${o.handle}`,o,o.totalMemory()),{memUsageBytes:o.totalMemory()}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache&&this._memCache.pop(`${e.handle}`),e.components.forEach((t=>{e.textures.forEach((e=>{this._stage.remove(e)})),this._collection.destroyObject(t),this._initialCullFace.delete(t)}))}setRenderableVisibility(e,t,r){if(this._memCache){for(let i=0;i<r;++i){const r=e[i],s=t[i];if(!s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.pop(`${r}`))}for(let i=0;i<r;++i){const r=e[i],s=t[i];if(s)continue;const o=this._lyrHandleToObjects.get(r);o&&(this._visibleGeometryChanged(),o.isVisible=s,o.components.forEach((e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.objectChanged(this._collection.getComponentObb(e))})),this._memCache.put(`${r}`,o,o.totalMemory()))}}}_getTexture(e,t,r){let i=null;if(e&&t.desc?.images&&t.data?.buffer){const s=t.desc.images[e?.imageId];if(i=r.get(s),!i&&s){const o=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,n=o>1,a=re[e.wrapMode??D.None];let l=s.alpha?4:3;const c=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,d=null,h=null;switch(s.format){case k.Raw:s.pixelFormat===B.R8?(m=c.buffer,l=1,d=""):s.pixelFormat===B.Rgb8?(m=c.buffer,l=3,d=""):s.pixelFormat===B.Rgba8&&(m=c.buffer,l=4,d="");break;case k.Dxt1:m=c.buffer,l=3,d=fe.DDS_ENCODING;break;case k.Dxt5:m=c.buffer,l=4,d=fe.DDS_ENCODING;break;case k.Png:d="image/png",h=document.createElement("img");break;case k.Jpeg:d="image/jpeg",h=document.createElement("img");break;case k.Etc2:d="image/ktx",h=document.createElement("img");break;case k.Astc:this._dbg(_e.Error,"Astc texture not supported");break;case k.Pvrtc:this._dbg(_e.Error,"Pvrtc texture not supported")}if(h&&d){const e=new Blob([c],{type:d});h.src=URL.createObjectURL(e),m=h}m&&null!=d&&(i=new be(m,{mipmap:n,maxAnisotropy:o,encoding:d,wrap:a,components:l,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height}),this._stage.add(i),r.set(s,i))}}return i?new ce(this.view._stage.renderView.textureRepository,i.id):null}getBufferViews(e,t,r,i){let s,o,n,a,l,c,m,d=null;for(let u=0;u<e.atrbs.length;u++){const m=e.atrbs[u],p=m.view,f=void 0,g=p.byteOffset+p.byteCount,b=p.byteCount/ie[p.type],y=[...Array(b).keys()].map((e=>e));try{switch(m.sem){case G.Position:3!==p.ncomp||p.type!==N.F32?this._dbg(_e.Error,"[Unsupported Feature] Unsupported view for Position ("+p+")"):(s=new O(t,p.byteOffset,f,g),o=new he(s.typedBuffer,y,3));break;case G.Normal:if(3!==p.ncomp||p.type!==N.F32)this._dbg(_e.Error,"[Unsupported Feature] Unsupported view for Normal ("+p+")");else if(i){const e=new O(t,p.byteOffset,f,g),i=ge(e.typedBuffer,r);l=new I(i),c=new he(l.typedBuffer,y,2)}break;case G.TexCoord:2!==p.ncomp||p.type!==N.F32?this._dbg(_e.Error,"[Unsupported Feature] Unsupported view for Texcoord ("+p+")"):void 0===a&&(a=new he(new V(t,p.byteOffset,f,g).typedBuffer,y,2));break;case G.Color:4===p.ncomp?(p.type===N.F32&&(d=new T(t,p.byteOffset,f,g)),p.type===N.U8&&(d=new M(t,p.byteOffset,f,g)),p.type===N.U16&&(d=new P(t,p.byteOffset,f,g))):3===p.ncomp&&(p.type===N.F32&&(d=new O(t,p.byteOffset,f,g)),p.type===N.U8&&(d=new U(t,p.byteOffset,f,g)),p.type===N.U16&&(d=new E(t,p.byteOffset,f,g))),null==d?this._dbg(_e.VerboseAPI,"[Unsupported Feature] Unsupported view for Color ("+p+")"):n=new he(d.typedBuffer,y,p.ncomp);break;case G.FeatureIndex:break;default:this._dbg(_e.VerboseAPI,"[Unsupported Feature] Unsupported semantic ("+m.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(_e.VerboseAPI,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const r=e.index.view,i=void 0,s=r.byteOffset+r.byteCount;switch(e.index.view.type){case N.U16:m=new R(t,r.byteOffset,i,s);break;case N.U32:m=new H(t,r.byteOffset,i,s);break;case N.U8:default:this._dbg(_e.Error,"[Unsupported Feature] index type not supported ("+r.type+").")}}if(null==m&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);m=new R(t)}else{const t=new Uint32Array(e);m=new H(t)}for(let t=0;t<e;t++)m.set(t,t)}return{positionView:s,positionAttr:o,colorAttr:n,texCoord0Attr:a,indicesView:m,normalsView:l,normalsAttr:c}}_onRemoveFromCache(e){const t=X(this.view);t&&t.onRenderableEvicted(this,e.handle,e.totalMemory()),this.freeRenderable(e.handle)}_dbg(e,t){this._dbgFlags.has(e)&&(e===_e.Error?r.getLogger(this).error(t):r.getLogger(this).warn(t))}};e([a()],Ce.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([a()],Ce.prototype,"layer",void 0),e([a()],Ce.prototype,"elevationOffset",null),Ce=e([l("esri.views.3d.layers.Tiles3DLayerView3D")],Ce);const Te=Ce;export{Te as default};