@arcgis/core 5.0.0-next.33 → 5.0.0-next.34

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 (153) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{9252854b512237b6a0ef.js → 0446562aee0639c61485.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{b56c07c0b43cb1999070.js → 1fa55d4c4b092a98bdd7.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{e7f4d135ef9665de1468.js → 33431e8131f6017de2f9.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{096e5f94eaa226814569.js → 4356274cfa477eb6d749.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{866a608d489bf56bc371.js → 486e69261aa2caf9ec3c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{3c1e50c3505e5e7c946a.js → 4d5591c1b4ef37075921.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d21ae4980741be98f948.js → 59889855d23baec1adf9.js} +1 -1
  9. package/assets/esri/core/workers/chunks/5f9e64f00329cb646f0c.js +1 -0
  10. package/assets/esri/core/workers/chunks/{c2596f48b37092dd566c.js → 61cb30e2e8edd18ebbf0.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{d786b17cc9062b1450ac.js → 726a797f5df7eeee0b3d.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{a2cee5ac0d4df0108425.js → 82cc758bddd9f8397b9f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{433d249c35c56bf15806.js → 97650ee3d0eecb69ccbb.js} +3 -3
  14. package/assets/esri/core/workers/chunks/{add17e95f47e6904bf6d.js → a59dab47a58695c639da.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{f441fc74451330384fb0.js → abb05a903440d97a6a74.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{5baef729beef0199c3d9.js → b536fdb655ad293d9024.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{1d4ea8db272655c0608c.js → c7c721de93bc8688e13c.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{446f76356fc116204ec3.js → c8d2cce4a426c72ab173.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{14feb12826e0c8ba7fb8.js → d14bd320f72d8e8a0ad8.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{4b6a44c6265c8959abd8.js → d3db7244fac7398cc700.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{7aa730e5ac7b268e3c98.js → dd34d56caafa38d4b8e4.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{2a17991923abc64c84c6.js → f55328aabf84770c8e6a.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{e32fc0b2c6530d28ce85.js → fa01d1813fa78034526e.js} +1 -1
  24. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  25. package/chunks/ComponentShader.glsl.js +19 -21
  26. package/chunks/Laserlines.glsl.js +1 -1
  27. package/chunks/Terrain.glsl.js +9 -11
  28. package/chunks/boundedPlane.js +1 -1
  29. package/chunks/cameraUtilsSpherical.js +1 -1
  30. package/chunks/lyr3DMain.js +1 -1
  31. package/chunks/vec32.js +1 -1
  32. package/config.js +1 -1
  33. package/core/deprecate.js +1 -1
  34. package/core/has.js +1 -1
  35. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  36. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  37. package/geometry/operators/integrateOperator.js +1 -1
  38. package/geometry/support/lineSegment.js +1 -1
  39. package/geometry/support/meshUtils/merge.js +1 -1
  40. package/geometry/support/sphere.js +1 -1
  41. package/interfaces.d.ts +45 -25
  42. package/intl/locale.js +1 -1
  43. package/kernel.js +1 -1
  44. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  45. package/layers/VoxelWasmPerSceneView.js +1 -1
  46. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  47. package/layers/support/layerOriginUtils.js +1 -1
  48. package/layers/voxel/VoxelVolume.js +1 -1
  49. package/package.json +3 -3
  50. package/request/config.js +1 -1
  51. package/request/process.js +1 -1
  52. package/support/revision.js +1 -1
  53. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  54. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  55. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  56. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  57. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  58. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  59. package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +1 -1
  60. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  61. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  62. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  63. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  64. package/views/3d/camera/constraintUtils/distance.js +1 -1
  65. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  66. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  67. package/views/3d/environment/CloudsParameters.js +1 -1
  68. package/views/3d/environment/EnvironmentManager.js +1 -1
  69. package/views/3d/environment/MarsAtmosphere.js +1 -1
  70. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  71. package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
  72. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  73. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  74. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  75. package/views/3d/layers/I3SMeshView3D.js +1 -1
  76. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  77. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  78. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  79. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  80. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  81. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  82. package/views/3d/state/Frustum.js +1 -1
  83. package/views/3d/state/controllers/FovController.js +1 -1
  84. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  85. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  86. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  87. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  88. package/views/3d/support/cameraUtils.js +1 -1
  89. package/views/3d/support/intersectionUtils.js +1 -1
  90. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  91. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  92. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  93. package/views/3d/support/viewpointUtils.js +1 -1
  94. package/views/3d/terrain/OverlayManager.js +1 -1
  95. package/views/3d/terrain/PatchRenderData.js +1 -1
  96. package/views/3d/terrain/SphericalPatch.js +1 -1
  97. package/views/3d/terrain/Tile.js +1 -1
  98. package/views/3d/webgl/RenderCamera.js +1 -1
  99. package/views/3d/webgl-engine/collections/Component/Material/{shader/ComponentData.glsl.js → ComponentData.glsl.js} +2 -2
  100. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  101. package/views/3d/webgl-engine/collections/Component/Material/ComponentShader.glsl.js +5 -0
  102. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  104. package/views/3d/webgl-engine/collections/Component/Material/{shader/DecodeSymbolColor.glsl.js → DecodeSymbolColor.glsl.js} +1 -1
  105. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  106. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  107. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  108. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  109. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  110. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  111. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  112. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  113. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  114. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  115. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  116. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  117. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  118. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  119. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  120. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  121. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  122. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  123. package/views/SelectionManager.js +1 -1
  124. package/views/interactive/GraphicManipulator.js +1 -1
  125. package/views/interactive/SegmentLabels.js +1 -1
  126. package/views/interactive/coordinateHelper.js +1 -1
  127. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  128. package/views/interactive/sketch/constraints.js +1 -1
  129. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  130. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  131. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  132. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  133. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  134. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  135. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  136. package/views/support/geometry3dUtils.js +1 -1
  137. package/views/support/selectionUtils.js +1 -1
  138. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  139. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  140. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
  141. package/widgets/BuildingExplorer.js +1 -1
  142. package/widgets/Editor/EditorViewModel.js +1 -1
  143. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  144. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  145. package/widgets/ShadowCast/DiscreteOptions.js +1 -1
  146. package/widgets/ShadowCast/DurationOptions.js +1 -1
  147. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  148. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  149. package/widgets/ShadowCast.js +1 -1
  150. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  151. package/assets/esri/core/workers/chunks/f3127bdf28a1d9b8db27.js +0 -1
  152. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +0 -5
  153. /package/views/3d/webgl-engine/collections/Component/Material/{shader/ComponentDataConstants.js → ComponentDataConstants.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{watch as e}from"../../../../core/reactiveUtils.js";import{fromTranslation as t,scale as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{C as s,n as a,e as o,d as n,m as c,i as l}from"../../../../chunks/vec32.js";import{create as u,ZEROS as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d}from"../../../../chunks/vec42.js";import{fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{sv3d as _}from"../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as p}from"../../../../layers/graphics/dehydratedPoint.js";import{EngineVisualElement as f}from"./EngineVisualElement.js";import{drapedZ as g}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{Geometry as b}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as R}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as O}from"../../webgl-engine/lib/RenderGeometry.js";import{ColorMaterial as j}from"../../webgl-engine/materials/ColorMaterial.js";import{RibbonLineMaterial as D}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends f{constructor(e){super(e),this._maxSize=0,this._position=u(),this._up=u(),this._right=u(),this._renderOccluded=4,this._color=m(1,0,0,1),this._outlineColor=m(0,0,0,1),this._outlineSize=0,this._size=32,this._outlineRenderOccluded=16,this.applyProperties(e)}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:()=>{},cameraChanged:()=>this._updateTransformObject3D(),forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:z,forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateQuadMaterial())}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateOutlineMaterial(),this._updateQuadMaterial()}get color(){return this._color}set color(e){d(this._color,e),this._updateQuadMaterial()}get outlineColor(){return this._outlineColor}set outlineColor(e){d(this._outlineColor,e),this._updateOutlineMaterial()}get outlineSize(){return this._outlineSize}set outlineSize(e){const t=0===this._outlineSize!=(0===e);this._outlineSize=e,t?this.recreateGeometry():this._updateOutlineMaterial()}get size(){return this._size}set size(e){e!==this._size&&(this._size=e,this._updateTransform())}get outlineRenderOccluded(){return this._outlineRenderOccluded}set outlineRenderOccluded(e){this._outlineRenderOccluded=e,this._updateOutlineMaterial()}set geometry({previous:e,center:t,next:r}){this._maxSize=Math.min(s(t,e),s(t,r))/3,a(this._up,o(this._up,e,t)),a(this._right,o(this._right,r,t)),n(this._position,t),this.recreateGeometry()}_createObject3DResources(e){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal);return this._createObject3DGeometries(e,t,r),{quadMaterial:t,outlineMaterial:r}}_createObject3DGeometries(e,t,r){if(c(this._up,h)&&c(this._right,h))return;const i=this._createGeometries(t,r);for(const s of i)e.addGeometry(s);this._updateTransformObject3D(e)}_createDrapedResources(){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal),i=this._createGeometries(t,r).map(e=>new O(e));this._setTransformDraped(i);return{quadMaterial:t,outlineMaterial:r,geometries:i,pixelRatioHandle:e(()=>this.view.state.contentPixelRatio,()=>this.drapedResources.recreateGeometry())}}_createGeometries(e,t){const{up:r,right:i,corner:s}=this._getVertices(),a=v(r,i,s,e);if(!t)return[a];return[a,R(t,[r,s,i])]}_getVertices(){let e=this._up,t=this._right;const r=l(_.get(),e,t);return this.isDraped&&(e=n(_.get(),e),t=n(_.get(),t),e[2]=0,t[2]=0,r[2]=0),{up:e,right:t,corner:r}}_updateTransform(){this.isDraped?this.drapedResources.recreateGeometry():this._updateTransformObject3D()}_updateTransformObject3D(e=this.object3dResources.object){if(!e)return;const i=this.view.state.camera,s=this._size*i.computeScreenPixelSizeAt(this._position),a=Math.min(this._maxSize,s);t(y,this._position),r(y,y,[a,a,a]),e.transformation=y}_setTransformDraped(e){if(0===e.length)return;const{view:{overlayManager:i,state:{contentPixelRatio:s}}}=this,{_position:a,_size:o}=this,c=n(_.get(),a);c[2]=g;const l=P;l.spatialReference=i.spatialReference,l.x=c[0],l.y=c[1];const u=o*(this.view.overlayPixelSizeInMapUnits(l)*s),h=Math.min(this._maxSize,u);t(y,c),r(y,y,[h,h,1]);for(const t of e)t.transformation=y}get _quadMaterialParameters(){return{color:this._color,forceTransparentMode:!0,writeDepth:!1,polygonOffset:!0,renderOccluded:this._renderOccluded,isDecoration:this.isDecoration}}_updateQuadMaterial(){this.object3dResources.resources?.quadMaterial.setParameters(this._quadMaterialParameters),this.drapedResources.resources?.quadMaterial.setParameters(this._quadMaterialParameters)}get _outlineMaterialParameters(){return{color:this._outlineColor,width:this._outlineSize,renderOccluded:this._outlineRenderOccluded,isDecoration:this.isDecoration}}_updateOutlineMaterial(){this.object3dResources.resources?.outlineMaterial?.setParameters(this._outlineMaterialParameters),this.drapedResources.resources?.outlineMaterial?.setParameters(this._outlineMaterialParameters)}}function z(e){e.pixelRatioHandle.remove(),e.geometries=[]}function v(e,t,r,i){return new b(i,[["position",new M([0,0,0,...t,...e,...r],[0,1,2,1,2,3],3,!0)]])}const y=i(),P=p(0,0,void 0,null);export{w as RightAngleQuadVisualElement};
5
+ import{watch as e}from"../../../../core/reactiveUtils.js";import{fromTranslation as t,scale as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{D as s,n as a,e as o,d as n,m as c,i as l}from"../../../../chunks/vec32.js";import{create as u,ZEROS as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d}from"../../../../chunks/vec42.js";import{fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{sv3d as _}from"../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as p}from"../../../../layers/graphics/dehydratedPoint.js";import{EngineVisualElement as f}from"./EngineVisualElement.js";import{drapedZ as g}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{Geometry as b}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as R}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as O}from"../../webgl-engine/lib/RenderGeometry.js";import{ColorMaterial as j}from"../../webgl-engine/materials/ColorMaterial.js";import{RibbonLineMaterial as D}from"../../webgl-engine/materials/RibbonLineMaterial.js";class w extends f{constructor(e){super(e),this._maxSize=0,this._position=u(),this._up=u(),this._right=u(),this._renderOccluded=4,this._color=m(1,0,0,1),this._outlineColor=m(0,0,0,1),this._outlineSize=0,this._size=32,this._outlineRenderOccluded=16,this.applyProperties(e)}createObject3DResourceFactory(e){return{view:e,createResources:e=>this._createObject3DResources(e),destroyResources:()=>{},cameraChanged:()=>this._updateTransformObject3D(),forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}createDrapedResourceFactory(e){return{view:e,createResources:()=>this._createDrapedResources(),destroyResources:z,forEachMaterial:(e,t)=>{t(e.outlineMaterial),t(e.quadMaterial)}}}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateQuadMaterial())}get isDecoration(){return this._isDecoration}set isDecoration(e){this._isDecoration=e,this._updateOutlineMaterial(),this._updateQuadMaterial()}get color(){return this._color}set color(e){d(this._color,e),this._updateQuadMaterial()}get outlineColor(){return this._outlineColor}set outlineColor(e){d(this._outlineColor,e),this._updateOutlineMaterial()}get outlineSize(){return this._outlineSize}set outlineSize(e){const t=0===this._outlineSize!=(0===e);this._outlineSize=e,t?this.recreateGeometry():this._updateOutlineMaterial()}get size(){return this._size}set size(e){e!==this._size&&(this._size=e,this._updateTransform())}get outlineRenderOccluded(){return this._outlineRenderOccluded}set outlineRenderOccluded(e){this._outlineRenderOccluded=e,this._updateOutlineMaterial()}set geometry({previous:e,center:t,next:r}){this._maxSize=Math.min(s(t,e),s(t,r))/3,a(this._up,o(this._up,e,t)),a(this._right,o(this._right,r,t)),n(this._position,t),this.recreateGeometry()}_createObject3DResources(e){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal);return this._createObject3DGeometries(e,t,r),{quadMaterial:t,outlineMaterial:r}}_createObject3DGeometries(e,t,r){if(c(this._up,h)&&c(this._right,h))return;const i=this._createGeometries(t,r);for(const s of i)e.addGeometry(s);this._updateTransformObject3D(e)}_createDrapedResources(){const t=new j(this._quadMaterialParameters),r=0===this._outlineSize?void 0:new D(this._outlineMaterialParameters,this.view.state.isGlobal),i=this._createGeometries(t,r).map(e=>new O(e));this._setTransformDraped(i);return{quadMaterial:t,outlineMaterial:r,geometries:i,pixelRatioHandle:e(()=>this.view.state.contentPixelRatio,()=>this.drapedResources.recreateGeometry())}}_createGeometries(e,t){const{up:r,right:i,corner:s}=this._getVertices(),a=v(r,i,s,e);if(!t)return[a];return[a,R(t,[r,s,i])]}_getVertices(){let e=this._up,t=this._right;const r=l(_.get(),e,t);return this.isDraped&&(e=n(_.get(),e),t=n(_.get(),t),e[2]=0,t[2]=0,r[2]=0),{up:e,right:t,corner:r}}_updateTransform(){this.isDraped?this.drapedResources.recreateGeometry():this._updateTransformObject3D()}_updateTransformObject3D(e=this.object3dResources.object){if(!e)return;const i=this.view.state.camera,s=this._size*i.computeScreenPixelSizeAt(this._position),a=Math.min(this._maxSize,s);t(y,this._position),r(y,y,[a,a,a]),e.transformation=y}_setTransformDraped(e){if(0===e.length)return;const{view:{overlayManager:i,state:{contentPixelRatio:s}}}=this,{_position:a,_size:o}=this,c=n(_.get(),a);c[2]=g;const l=P;l.spatialReference=i.spatialReference,l.x=c[0],l.y=c[1];const u=o*(this.view.overlayPixelSizeInMapUnits(l)*s),h=Math.min(this._maxSize,u);t(y,c),r(y,y,[h,h,1]);for(const t of e)t.transformation=y}get _quadMaterialParameters(){return{color:this._color,forceTransparentMode:!0,writeDepth:!1,polygonOffset:!0,renderOccluded:this._renderOccluded,isDecoration:this.isDecoration}}_updateQuadMaterial(){this.object3dResources.resources?.quadMaterial.setParameters(this._quadMaterialParameters),this.drapedResources.resources?.quadMaterial.setParameters(this._quadMaterialParameters)}get _outlineMaterialParameters(){return{color:this._outlineColor,width:this._outlineSize,renderOccluded:this._outlineRenderOccluded,isDecoration:this.isDecoration}}_updateOutlineMaterial(){this.object3dResources.resources?.outlineMaterial?.setParameters(this._outlineMaterialParameters),this.drapedResources.resources?.outlineMaterial?.setParameters(this._outlineMaterialParameters)}}function z(e){e.pixelRatioHandle.remove(),e.geometries=[]}function v(e,t,r,i){return new b(i,[["position",new M([0,0,0,...t,...e,...r],[0,1,2,1,2,3],3,!0)]])}const y=i(),P=p(0,0,void 0,null);export{w as RightAngleQuadVisualElement};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c,createResolver as u}from"../../../core/promiseUtils.js";import{initial as _,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as f}from"../../../core/SetUtils.js";import{isArrayBuffer as p}from"../../../core/typedArrayUtil.js";import{property as y,subclass as b}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as v,invert as I}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 M,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as x,create as S}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as E}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as O,p as R,t as j,a as F,i as V,j as D,e as A,H as T}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as N}from"../../../chunks/vec42.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as U}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as W,create as $,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import _e from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as ge}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as pe,toWasmModification as ye}from"./I3SMeshWorkerHandle.js";import{initialize as be,setModificationsSync as ve,filterObbsForModificationsSync as Ie,interpretObbModificationResults as Ce}from"./SceneLayerWorker.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Se}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Re}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as De,defaultMaterial as Ae,createTexture as Te,configureMaterial as He}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as Le,whenGraphicAttributes as Ge,computeVisibilityObb as Be,filterInPlace as qe,intersectBoundingRectWithMbs as ze,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Ke,getClipRect as Qe}from"./i3s/I3SUtil.js";import{IDBCache as Je}from"./i3s/IDBCache.js";import{IDBMockCache as Ye}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Xe}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as Ze}from"./i3s/SymbologyInfo.js";import{attributeLookup as et}from"./support/attributeUtils.js";import{normalizeHighlightTarget as tt,emptyHighlightHandle as it}from"./support/highlightUtils.js";import{makeScheduleFunction as st}from"./support/makeScheduleFunction.js";import{debugFlags as rt}from"../support/debugFlags.js";import{ElevationRange as ot}from"../support/ElevationRange.js";import{toBoundingRect as nt}from"../support/extentUtils.js";import{Obb as at,ensurePackedObbData as lt}from"../support/orientedBoundingBox.js";import{updatingProgress as dt}from"../support/updatingProperties.js";import{glLayout as ht}from"../support/buffer/glUtil.js";import{ObjectParameters as ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as ut,SourceGeometry as _t,GeometryParameters as gt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as mt}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as ft}from"../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{loadBasisTranscoder as pt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as yt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as bt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as vt}from"../../../webscene/support/AlphaCutoff.js";const It=[1,1,1,1];class Ct extends Re{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,this.cachedSymbologyStride=5}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const Mt=26,wt=104857600,xt=t=>{const p=t;let T=class extends p{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new bt,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._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.i3slayer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>vt}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?63:37:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?he(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new kt(0,0);const t=he(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new kt(0,t);case"relative-to-ground":return new kt(1,t);case"on-the-ground":return new kt(2,0);default:return new kt(0,0)}}get supportedTextureEncodings(){return Ve(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ot;for(const i of e.values()){const e=i?.node.serviceMbsInIndexSR;e&&t.expandElevationRangeValues(e.center[2]-e.radius,e.center[2]+e.radius)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Ye(this.view,e):new Je("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:i}),this._workerHandle=new pe(st(t)),this.addResolvingPromise(this._workerHandle.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(d)),Ue(this.i3slayer),Le(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection;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;const n=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=n;const l=this._controller,h=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=l.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=h.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new Xe({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),_),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),_),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),Gt):t&&this.removeHandles(Gt)},_),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),_),this._updatingHandles.add(()=>this.i3slayer.labelsVisible,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this.i3slayer.labelingInfo,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),_),this.addHandles([g(()=>rt.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&rt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||rt.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},_),g(()=>rt.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),_)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:f}=this,{viewingMode:p,renderCoordsHelper:y}=f;this._planetRadiusInGlobalMode="local"===p?0:y.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(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._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;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 me({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});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=be().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.i3slayer.spatialReference,s=i.isGeographic,r=ye(this._layerClippingArea,this._modifications,i);this._workerHandle.setModifications(t,r,s).catch(e);try{ve({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l:null;this._nodeId2Meta.forEach((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),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),!rt.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={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new _e({...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._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)},i).catch(e=>{h(e)||o.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}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=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,i)=>e.push(i)),this._nodeId2MetaReloading.forEach((t,i)=>e.push(i))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&2&this.supportedTextureEncodings&&this.i3slayer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&pt()}_getVertexBufferLayout(e,t){return ht(ut(this._getGeometryParameters({hasTexture:Vt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||se}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=et(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_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=et(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=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Ge(this.i3slayer,e,this._getObjectIdField(),t,()=>[...this._nodeId2Meta.values()].filter(r))}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${Mt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return qt;if(e===U(e))return zt;return this.i3slayer.spatialReference.equals(e)?Bt:null!=e.wkid?`@${e.wkid}`:null}_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,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=De(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.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=at.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Tt(s.transformedGeometry,s.textureData),s.textureData.every(At)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return Dt(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:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h}=s,c=X(s.globalTrafo),u=O(Ut,r.center.x,r.center.y,r.center.z);R(u,u,c);const _=new at(u,[r.extents.x,r.extents.y,r.extents.z],E(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:Tt(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){const t=null!=g.textureData?g.textureData.map(e=>At(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,i)},i))):Promise.reject()}getElevationRange(e){const t=new ot,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e.radius,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.radius);if(_>=0&&n>=1*_)return null!=r?Kt(t,r,l):null!=d&&d.radius>=0&&Qt(t,d,l),!1;const g=$t;if(g.minElevation=1/0,g.maxElevation=-1/0,(null!=r||null!=d)&&(null!=r?Kt(g,r,l):null!=d&&Qt(g,d,l),g.minElevation>=t.minElevation&&g.maxElevation<=t.maxElevation))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 Kt(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 Be(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=this.i3slayer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Pe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._workerHandle.invoke(m,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(0===this.elevationInfo.mode&&(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),0!==this.elevationInfo.mode&&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: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&&(2===e.encoding||1===e.encoding))&&await pt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=n,{material:E,geometryParameters:O}=this._materialParameters(g,m),R=l||new Uint32Array([0,f?f.length:p.byteLength/m[0].stride]),V=new _t({data:p,count:p.byteLength/m[0].stride,layoutParameters:O},{positions:Z(y.data),indices:ee(y.indices)},f,R),D=g.transformation?x(g.transformation):S(),A=X(t.globalTrafo);M(D,A,D);const T=w(H(),D),N=v(C(),D),k=this.view.renderSpatialReference,U=this.view.basemapTerrain.spatialReference,G=at.fromData(lt(t.geometryObbData)).center,B=[1,1,1];L(G,k,B,U)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const q=H();z(G,k,q,U);const W=C();I(W,N);const $=H();j($,F($,G,T),W);const K=q[0]-$[0]*B[0],Q=q[1]-$[1]*B[1],J=_.createObject(new ct(P(K,Q,B[0],B[1]),new mt(T,N),at.fromData(lt(t.geometryObbData)),V,!this._isIntegratedMesh)),Y=2===O.textureCoordinateType,{textures:te,texturePromise:ie}=this._initMaterialAndTextures(J,E,a,Y,e);e.memory+=this._memEstimateGeometryAdded(J),e.memory+=te.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const se=!!E.hasParametersFromSource,re="blend"!==E.alphaMode&&E.metallicRoughness.baseColorFactor[3]>=1,oe=new Ct(e,h,J,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:se,isOpaque:re},te,c,u);s.meta=oe,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=b,this.notifyChange("hasTexturesOrVertexColors");const ne=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(oe),ie]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(oe.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),this._safeReschedule(()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,oe),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(J,!0),t?.updateObjectVisibility(oe.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),oe.attributeInfo=i.attributeInfo;const s=oe.cachedRendererVersion!==this._rendererVersion,r=ne!==this.slicePlaneEnabled;this._updateElevationOffsets(oe);const o=oe.elevationOffsets;this._updateComponentData(oe);const n=this._applyFiltersToNode(oe);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(oe),null!=this._labeler&&this._addMetaToLabeler(this._labeler,oe),this._visibleGeometryChanged(oe,0),this._highlights?.objectCreated(oe),this._updateMaterial(oe),this._setNewNodeOpacity(oe),null!=this._treeDebugger&&this._treeDebugger.update()},i))).catch(e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){o.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Pt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(null==n||null==o||0===a)return void(e.elevationOffsets=null);const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Ut,h=Lt,c=2===a,u=this.view.renderCoordsHelper,_=e.featureIds.length,g=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*_);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<_;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(O(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),V(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),O(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),j(d,d,l.rotationScale),V(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?g[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(g,_,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Se(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace(e=>null!=this._nodeId2Meta.get(e)),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode)),this._elevationTask}_elevationInfoChanged(e,t){const i=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;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,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ae(),s=t.some(e=>"uvRegion"===e.name),r=t.some(e=>"normalCompressed"===e.name),o=Vt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,n=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},a=i.map(e=>Te(e,t,s,o,this._compressionTracker,n));this._stage.addTextures(a);let l=null;return this._collection.updateMaterial(e,e=>{l=He(e,t,a,i,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)}),{textures:a,texturePromise:l}}_getGeometryParameters(e){return new gt(this._hasVertexColors,e.hasTexture?e.hasRegions?2:1:0,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=u();s=new Nt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return 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=nt(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=nt(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),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=Zt(this._nodeId2Meta.values()),this._filteredIdCounts=Zt(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=Zt(this._nodeId2Meta.values(),2),this.addHandles(g(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Xt(this._featureIdCounts,e.featureIds,t),Xt(this._filteredIdCounts,e.filteredIds,t),Xt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Xt(this._filteredIdCounts,t,-1),Xt(this._filteredIdCounts,e.filteredIds,1),Xt(this._weaklyRemovedIdCounts,i,-1),Xt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=Zt(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=Zt(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=Zt(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}f(e,this._mismatchShow)&&f(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Yt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2))})}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);if(!n)return;const a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&qe(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return G(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),K(St,Et),J(i,Et)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Ot,i,t.objectHandle);qe(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}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){Pt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateObjectVisibility(i,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_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(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=Jt(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!r;const o=Yt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_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=a(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=>this._logEdgeViewError(e,this.i3slayer.title)),this._visibleGeometryChanged(s,1),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights?.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),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.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,e=>e.polygonOffsetEnabled=0===t)}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=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(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 ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&o.getLogger(this).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=i*e.cachedSymbologyStride;N(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[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=$e(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?oe(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=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=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new Ze,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=1,g=Ke,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:jt,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,It,d.color):Me(h,p,null,null,It,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=vt,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=g}else e.cachedEdgeMaterials[f]=Ke;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<<4|+d.pickable<<5;const b=y?.emissive?.strength??ft;b===ft||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(ft)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Pt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Ke),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Ke:(r=r||t!==Ke,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),Pt(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,2)}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}_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._shadeNormals&&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)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_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(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Qe(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_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]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=tt(e);if(0===s.length)return it;const r=yt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return it;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>et(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new ge(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}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)}checkInvariants(){}get test(){}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)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}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;Pt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch(e=>this._logEdgeViewError(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=Ht(e);if(s){const t={context:i,buffer:s.buffer};Ie(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=Ce(i);e.imModificationImpact=s,0!==s&&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.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}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:()=>s(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||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{V(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),V(e,e,D(a,a,t)),A(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)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>wt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([y()],T.prototype,"_hasLoadedPBRTextures",void 0),e([y()],T.prototype,"_asyncModuleLoading",void 0),e([y()],T.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"i3slayer",void 0),e([y()],T.prototype,"_controller",void 0),e([y()],T.prototype,"_labeler",void 0),e([y()],T.prototype,"updating",void 0),e([y()],T.prototype,"suspended",void 0),e([y()],T.prototype,"contentVisible",null),e([y({readOnly:!0})],T.prototype,"legendEnabled",null),e([y(dt)],T.prototype,"updatingProgress",void 0),e([y()],T.prototype,"updatingProgressValue",null),e([y()],T.prototype,"hasTexturesOrVertexColors",null),e([y()],T.prototype,"rendererTextureUsage",null),e([y()],T.prototype,"elevationOffset",null),e([y()],T.prototype,"elevationInfo",null),e([y({type:Boolean})],T.prototype,"slicePlaneEnabled",void 0),e([y()],T.prototype,"supportedTextureEncodings",null),e([y({type:[ne]})],T.prototype,"_modifications",void 0),e([y({readOnly:!0})],T.prototype,"clientGeometry",null),e([y()],T.prototype,"elevationRange",null),e([y()],T.prototype,"fullExtent",null),e([y()],T.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],T.prototype,"_usePBR",null),T=e([b("esri.views.3d.layers.I3SMeshView3D")],T),T},St=$(),Et=Q(),Ot=Q(),Rt=new at,jt=new t([0,0,0,0]),Ft=new te(0,0,0,0);function Vt(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 Dt(e){return"geometryData"in e}function At(e){return null!=e&&p(e.data)}function Tt(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&&p(s.data)&&(i+=s.data.byteLength);return i}function Ht(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=Rt,e.serviceMbsInIndexSR?(t.center=e.serviceMbsInIndexSR.center,t.halfSize=[e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius]):t.invalidate());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}class Nt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Pt(e,t){e.forEach(e=>e.opacity=t)}class kt{constructor(e,t){this.mode=e,this.offset=t}}const Ut=H(),Lt=$(),Gt="elevation-change",Bt="",qt="@null",zt="@ECEF",Wt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],$t=new ot;function Kt(e,t,i){let s=e.minElevation,r=e.maxElevation;const o=i;if(o>0){t.getCorners(Wt);for(const e of Wt){const t=T(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Wt);for(const e of Wt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Qt(e,t,i){const{center:s,radius:r}=t,o=i>0?T(s)-i:s[2];e.expandElevationRangeValues(o-r,o+r)}function Jt(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function Yt(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach((e,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Xt(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}function Zt(e,t=0){const i=new Map;for(const s of e){Xt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}export{xt as I3SMeshView3D};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import i from"../../../Graphic.js";import{removeUnordered as s,isSome as r}from"../../../core/arrayUtils.js";import has from"../../../core/has.js";import o from"../../../core/Logger.js";import{equals as n}from"../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../core/maybe.js";import l from"../../../core/PooledArray.js";import{ignoreAbortErrors as d,isAbortError as h,throwIfAborted as c,createResolver as u}from"../../../core/promiseUtils.js";import{initial as _,watch as g}from"../../../core/reactiveUtils.js";import{schedule as m}from"../../../core/scheduling.js";import{equals as f}from"../../../core/SetUtils.js";import{isArrayBuffer as p}from"../../../core/typedArrayUtil.js";import{property as y,subclass as b}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as v,invert as I}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 M,getTranslation as w}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as x,create as S}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as E}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{h as O,p as R,t as j,a as F,i as V,j as D,e as A,B as T}from"../../../chunks/vec32.js";import{create as H}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as N}from"../../../chunks/vec42.js";import{fromValues as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as k}from"../../../core/support/UpdatingHandles.js";import{getSphericalPCPF as U}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as G}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as z}from"../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as W,create as $,toRect as K}from"../../../geometry/support/aaBoundingBox.js";import{create as Q,intersects as J}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as Y,ensurePackedMat4f64 as X}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{Sphere as te}from"../../../geometry/support/sphere.js";import{newUByteArray as ie}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as se}from"../../../layers/LayerConstants.js";import re from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as oe}from"../../../layers/support/fieldUtils.js";import ne from"../../../layers/support/SceneModification.js";import{getColor as ae,getOpacity as le}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{isBasemapLayerView as de}from"../../../support/basemapUtils.js";import{getElevationOffset as he}from"../../../support/elevationInfoUtils.js";import{loadArcade as ce}from"../../../support/loadArcade.js";import ue from"../../../symbols/MeshSymbol3D.js";import _e from"../../../symbols/SimpleFillSymbol.js";import{ContentGeometryUpdateEvent as ge}from"./ContentGeometryLayerView.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as fe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as pe,toWasmModification as ye}from"./I3SMeshWorkerHandle.js";import{initialize as be,setModificationsSync as ve,filterObbsForModificationsSync as Ie,interpretObbModificationResults as Ce}from"./SceneLayerWorker.js";import{overrideColor as Me}from"./graphics/graphicUtils.js";import{areLabelsVisible as we}from"./graphics/Labeler.js";import xe from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Se}from"./i3s/I3SAsyncElevationUpdater.js";import{getCachedAttributeValue as Ee}from"./i3s/I3SBinaryReader.js";import{I3SCrossfadeHelper as Oe,NodeCrossfadeMetaData as Re}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as je}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Fe}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Ve,selectEncoding as De,defaultMaterial as Ae,createTexture as Te,configureMaterial as He}from"./i3s/I3SMaterialUtil.js";import{I3SOverrides as Ne}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as Pe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as ke,checkSceneLayerValid as Ue,checkSceneLayerCompatibleWithView as Le,whenGraphicAttributes as Ge,computeVisibilityObb as Be,filterInPlace as qe,intersectBoundingRectWithMbs as ze,addWraparound as We,getSymbolInfo as $e,transparentEdgeMaterial as Ke,getClipRect as Qe}from"./i3s/I3SUtil.js";import{IDBCache as Je}from"./i3s/IDBCache.js";import{IDBMockCache as Ye}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as Xe}from"./i3s/LayerElevationProvider.js";import{SymbologyInfo as Ze}from"./i3s/SymbologyInfo.js";import{attributeLookup as et}from"./support/attributeUtils.js";import{normalizeHighlightTarget as tt,emptyHighlightHandle as it}from"./support/highlightUtils.js";import{makeScheduleFunction as st}from"./support/makeScheduleFunction.js";import{debugFlags as rt}from"../support/debugFlags.js";import{ElevationRange as ot}from"../support/ElevationRange.js";import{toBoundingRect as nt}from"../support/extentUtils.js";import{Obb as at,ensurePackedObbData as lt}from"../support/orientedBoundingBox.js";import{updatingProgress as dt}from"../support/updatingProperties.js";import{glLayout as ht}from"../support/buffer/glUtil.js";import{ObjectParameters as ct}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as ut,SourceGeometry as _t,GeometryParameters as gt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as mt}from"../webgl-engine/collections/Component/Transform.js";import{emissiveStrengthDefault as ft}from"../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import{loadBasisTranscoder as pt}from"../webgl-engine/lib/BasisUtil.js";import{getHighlightName as yt}from"../../support/highlightOptionsUtils.js";import{TextureCompressionTracker as bt}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as vt}from"../../../webscene/support/AlphaCutoff.js";const It=[1,1,1,1];class Ct extends Re{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,this.cachedSymbologyStride=5}get usedMemory(){return this.node.memory}get featureExtents(){return this._featureExtents??=new Float64Array(6*this.featureIds.length).fill(Number.POSITIVE_INFINITY),this._featureExtents}}const Mt=26,wt=104857600,xt=t=>{const p=t;let T=class extends p{constructor(){super(...arguments),this._applySSAO=!0,this._shadeNormals=!0,this._updatingHandles=new k,this._highlights=null,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._compressionTracker=new bt,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._needFilterResolve=!1,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new Oe(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerViewUid(){return this.uid}get layerId(){return this.i3slayer.id}get sublayerId(){return null}get _isIntegratedMesh(){return"integrated-mesh"===this.i3slayer.type}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible&&this.fullOpacity>vt}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?63:37:this._usePBR||this._hasLoadedPBRTextures?44:36}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?he(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new kt(0,0);const t=he(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new kt(0,t);case"relative-to-ground":return new kt(1,t);case"on-the-ground":return new kt(2,0);default:return new kt(0,0)}}get supportedTextureEncodings(){return Ve(this.view.stage.renderView.capabilities)}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ot;for(const i of e.values()){const e=i?.node.serviceMbsInIndexSR;e&&t.expandElevationRangeValues(e.center[2]-e.radius,e.center[2]+e.radius)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new Ye(this.view,e):new Je("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Ne({view:this.view,layer:this.i3slayer,memoryController:i}),this._workerHandle=new pe(st(t)),this.addResolvingPromise(this._workerHandle.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._workerHandle.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(d)),Ue(this.i3slayer),Le(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new re({layerView:this,worker:this._workerHandle}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view.stage,this._collection=this._stage.renderView.componentObjectCollection;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;const n=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,e=>this._deleteComponentObject(e));this._memCache=n;const l=this._controller,h=this._nodeId2Meta,c=this._nodeId2MetaReloading,u=e=>{const t=l.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=h.get(i)||c.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Fe({layerViewUid:this.layerViewUid,sublayerId:this.sublayerId,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:u}),this._elevationProvider=new Xe({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add(()=>this.view.clippingArea,()=>this._clippingAreaChanged(),_),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),_),this._updatingHandles.add(()=>!this.suspended&&0!==this.elevationInfo.mode,(e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",({extent:e})=>this._ensureElevationTask().addExtent(e)),Gt):t&&this.removeHandles(Gt)},_),this._updatingHandles.add(()=>this._usePBR,e=>this._updatePBR(e));const m=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add(()=>this.rendererTextureUsage,m),this._updatingHandles.add(()=>this.contentVisible,e=>this._contentVisibleChanged(e),_),this._updatingHandles.add(()=>this.i3slayer.labelsVisible,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this.i3slayer.labelingInfo,()=>this._labelingChanged(),_),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),_),this.addHandles([g(()=>rt.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&rt.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||rt.I3S_TREE_SHOW_TILES||(this._treeDebugger=a(this._treeDebugger))},_),g(()=>rt.I3S_SHOW_MODIFICATIONS,()=>this._showModifications(),_)]),this._cacheKeySuffix=this._getCacheKeySuffix(),this._idbCache.init().catch(e=>o.getLogger(this).warn(`Failed to initialize IndexedDB cache: ${e}`));const{view:f}=this,{viewingMode:p,renderCoordsHelper:y}=f;this._planetRadiusInGlobalMode="local"===p?0:y.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=a(this._elevationTask),this.i3sOverrides=a(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.notifyObjectsChanged(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._workerHandle;e&&(e.destroyContextAndSelf(this.uid),this._workerHandle=null),this._removeAllNodeDataFromStage(),this._memCache=a(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=a(this._labeler),this._treeDebugger=a(this._treeDebugger),this._controller=a(this._controller),this._highlights=a(this._highlights),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=a(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=a(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.usedMemory;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.usedMemory;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 me({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides,layerViewUid:this.uid});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=be().then(()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()}),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=e=>o.getLogger(this).error("set-modifications-error","Error when setting modifications:",e),t=this.uid,i=this.i3slayer.spatialReference,s=i.isGeographic,r=ye(this._layerClippingArea,this._modifications,i);this._workerHandle.setModifications(t,r,s).catch(e);try{ve({context:t,modifications:r,isGeodetic:s})}catch(a){e(a)}this._controller.modificationsChanged();const n=this.hasModifications?new l:null;this._nodeId2Meta.forEach((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._updateFeatureIdCounts(e,-1),this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=n&&n.push(e.node)}),this.notifyChange("elevationRange"),null!=n&&this._nodeId2MetaReloading.forEach(e=>n.push(e.node)),null!=n&&n.length>0&&(this.updateNodeModificationStatus(n),n.forAll(e=>{if(2!==e.imModificationImpact){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._updateFeatureIdCounts(t,-1),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),!rt.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={outline:{color:[255,255,255],width:1}};this._modificationGraphics=[];for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new _e({...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._nodeId2Meta.get(e)===s&&this._attributeValuesChanged(s)},i).catch(e=>{h(e)||o.getLogger(this).warn("Error while updating attribute values. Layer might not display correctly.",e)}))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.appliedFilters=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,(e,t)=>this._createAttributes(e,t)),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear(),this._addTasks.forEach(e=>e.allowMemCache=!1)}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=>t&&e.push(this._collection.getComponentObb(t.objectHandle))),e}getLoadedNodeIndices(e){this._nodeId2Meta.forEach((t,i)=>e.push(i)),this._nodeId2MetaReloading.forEach((t,i)=>e.push(i))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&2&this.supportedTextureEncodings&&this.i3slayer.textureSetDefinitions?.some(e=>e.formats.some(e=>"basis"===e.format||"ktx2"===e.format))&&pt()}_getVertexBufferLayout(e,t){return ht(ut(this._getGeometryParameters({hasTexture:Vt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion})))}_getObjectIdField(){return this.i3slayer.objectIdField||se}_getGlobalIdField(){return this.i3slayer.globalIdField}_findGraphicNodeAndIndex(e){const t=et(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_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=et(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=je(t,this._collection,s,Y(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;return B(r,o,0,r,n,0)?W(r):null}whenGraphicAttributes(e,t){return Ge(this.i3slayer,e,this._getObjectIdField(),t,()=>[...this._nodeId2Meta.values()].filter(r))}getGraphicFromIntersectorTarget(e,t){if(null==e.nodeIndex||null==e.componentIndex)return null;const i=this._nodeId2Meta.get(e.nodeIndex);if(null==i?.featureIds||e.componentIndex>=i.featureIds.length)return null;const s=this._createLayerGraphic(this._createAttributes(e.componentIndex,i));return s?t.defer?(t.defer(async()=>(s.geometry=(await import("./i3s/meshUtils.js")).createMesh({layerView:this,nodeIndex:e.nodeIndex,featureIndex:e.componentIndex}),s)),null):s:null}_getCacheKey(e){return`${this._layerUrl}/v${Mt}/${e}${this._cacheKeySuffix}`}_getCacheKeySuffix(){const e=this.view.renderSpatialReference;if(null==e)return qt;if(e===U(e))return zt;return this.i3slayer.spatialReference.equals(e)?Bt:null!=e.wkid?`@${e.wkid}`:null}_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,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=De(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.globalTrafo=X(s.globalTrafo),s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=at.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then(i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Tt(s.transformedGeometry,s.textureData),s.textureData.every(At)&&this._indexedDbSizeCheck(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch(t=>o.getLogger(this).warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`))),c(t),s))))):Promise.resolve(null)}addNode(e,t,i){return Dt(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:n,featureIds:a,anchorIds:l,anchors:d,transformedGeometry:h}=s,c=X(s.globalTrafo),u=O(Ut,r.center.x,r.center.y,r.center.z);R(u,u,c);const _=new at(u,[r.extents.x,r.extents.y,r.extents.z],E(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));0===this.elevationInfo.mode&&(e.geometryObbInRenderSR=_),t.geometryData.componentOffsets=n,a&&(t.geometryData.featureIds=Array.from(a)),t.geometryData.anchorIds=l,t.geometryData.anchors=d;const g={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:h,globalTrafo:c,geometryObbData:_.data,byteSize:Tt(h,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&this._indexedDbSizeCheck(e,g)){const t=null!=g.textureData?g.textureData.map(e=>At(e)?e:null):null;this._idbCache.put(this._getCacheKey(e.id),{...g,textureData:t}).catch(t=>o.getLogger(this).warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`))}return this._addCachedNodeData(e,g,i)},i))):Promise.reject()}getElevationRange(e){const t=new ot,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e.radius,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.radius);if(_>=0&&n>=1*_)return null!=r?Kt(t,r,l):null!=d&&d.radius>=0&&Qt(t,d,l),!1;const g=$t;if(g.minElevation=1/0,g.maxElevation=-1/0,(null!=r||null!=d)&&(null!=r?Kt(g,r,l):null!=d&&Qt(g,d,l),g.minElevation>=t.minElevation&&g.maxElevation<=t.maxElevation))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 Kt(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 Be(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=this.i3slayer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=Pe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a.toJSON(),obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._workerHandle.invoke(m,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(0===this.elevationInfo.mode&&(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),0!==this.elevationInfo.mode&&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: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&&(2===e.encoding||1===e.encoding))&&await pt(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:f,interleavedVertexData:p,positionData:y,hasColors:b}=n,{material:E,geometryParameters:O}=this._materialParameters(g,m),R=l||new Uint32Array([0,f?f.length:p.byteLength/m[0].stride]),V=new _t({data:p,count:p.byteLength/m[0].stride,layoutParameters:O},{positions:Z(y.data),indices:ee(y.indices)},f,R),D=g.transformation?x(g.transformation):S(),A=X(t.globalTrafo);M(D,A,D);const T=w(H(),D),N=v(C(),D),k=this.view.renderSpatialReference,U=this.view.basemapTerrain.spatialReference,G=at.fromData(lt(t.geometryObbData)).center,B=[1,1,1];L(G,k,B,U)||o.getLogger(this).errorOnce("Unsupported coordinate system for IM overlay");const q=H();z(G,k,q,U);const W=C();I(W,N);const $=H();j($,F($,G,T),W);const K=q[0]-$[0]*B[0],Q=q[1]-$[1]*B[1],J=_.createObject(new ct(P(K,Q,B[0],B[1]),new mt(T,N),at.fromData(lt(t.geometryObbData)),V,!this._isIntegratedMesh)),Y=2===O.textureCoordinateType,{textures:te,texturePromise:ie}=this._initMaterialAndTextures(J,E,a,Y,e);e.memory+=this._memEstimateGeometryAdded(J),e.memory+=te.reduce((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0),0);const se=!!E.hasParametersFromSource,re="blend"!==E.alphaMode&&E.metallicRoughness.baseColorFactor[3]>=1,oe=new Ct(e,h,J,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:se,isOpaque:re},te,c,u);s.meta=oe,this._hasTextures||=t.requiredTextures?.some(({usage:e})=>!!(19&e))||!!e.resources.texture,this._hasData=!0,this._hasColors||=b,this.notifyChange("hasTexturesOrVertexColors");const ne=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(oe),ie]).then(([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(oe.objectHandle,!1).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),this._safeReschedule(()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,oe),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(J,!0),t?.updateObjectVisibility(oe.objectHandle,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),oe.attributeInfo=i.attributeInfo;const s=oe.cachedRendererVersion!==this._rendererVersion,r=ne!==this.slicePlaneEnabled;this._updateElevationOffsets(oe);const o=oe.elevationOffsets;this._updateComponentData(oe);const n=this._applyFiltersToNode(oe);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(oe),null!=this._labeler&&this._addMetaToLabeler(this._labeler,oe),this._visibleGeometryChanged(oe,0),this._highlights?.objectCreated(oe),this._updateMaterial(oe),this._setNewNodeOpacity(oe),null!=this._treeDebugger&&this._treeDebugger.update()},i))).catch(e=>{const{meta:t,allowMemCache:i}=s;throw s.meta=null,t&&i?this._cacheGPUData(t):t&&this._deleteComponentObject(t),e})}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){o.getLogger(this).error("Removing duplicated node");const t=this._nodeId2Meta.get(e);t&&(this._deleteComponentObject(t),this._updateFeatureIdCounts(t,-1))}else this._controller.updateLoadStatus(e,!0);t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&Pt(t.cachedEdgeMaterials,0),this._updateFeatureIdCounts(t,1)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){if(!e.node.serviceMbsInIndexSR)return;const{view:t,elevationInfo:i}=this,s=this._controller.crsIndex,{groundView:r,groundSpatialReference:o,renderSpatialReference:n}=t,a=i.mode;if(null==n||null==o||0===a)return void(e.elevationOffsets=null);const l=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const d=Ut,h=Lt,c=2===a,u=this.view.renderCoordsHelper,_=e.featureIds.length,g=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const t=Y(3*_);e.cachedElevationAnchors=t;const{center:i}=e.node.serviceMbsInIndexSR;for(let r=0;r<_;r++){const a=3*r,c=e.anchorIds?.indexOf(r)??-1;e.anchors&&c>=0?(O(d,e.anchors[3*c],e.anchors[3*c+1],e.anchors[3*c+2]),V(d,d,i),z(d,s,d,o),t[a]=d[0],t[a+1]=d[1],t[a+2]=u.getAltitude(d)):(this._collection.getComponentAabb(e.objectHandle,r,h,!0),O(d,(h[0]+h[3])/2,(h[1]+h[4])/2,h[2]),j(d,d,l.rotationScale),V(d,d,l.position),t[a+2]=u.getAltitude(d),z(d,n,d,o),t[a]=d[0],t[a+1]=d[1])}return t})(),m=i.offset,f=e.elevationOffsets,p=(e,t)=>{const i=c?g[3*e+2]:0;f[e]=m+(t??0)-i};r.getElevations(g,_,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Se(this.view.resourceController.scheduler,e=>this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference)?.filterInPlace(e=>null!=this._nodeId2Meta.get(e)),e=>this._nodeElevationAlignmentChanged(this._nodeId2Meta.get(e)),()=>this.elevationInfo?.mode)),this._elevationTask}_elevationInfoChanged(e,t){const i=0!==e.mode,s=!!t&&t!==e&&0!==t.mode;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,2),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}_safeReschedule(e,t){return c(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:Ae(),s=t.some(e=>"uvRegion"===e.name),r=t.some(e=>"normalCompressed"===e.name),o=Vt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s,r){const o=this._stage.renderView,n=e=>{this._gpuMemoryEstimate-=e,this._texMemoryEstimate-=e,r.memory-=e},a=i.map(e=>Te(e,t,s,o,this._compressionTracker,n));this._stage.addTextures(a);let l=null;return this._collection.updateMaterial(e,e=>{l=He(e,t,a,i,this.view.stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)}),{textures:a,texturePromise:l}}_getGeometryParameters(e){return new gt(this._hasVertexColors,e.hasTexture?e.hasRegions?2:1:0,e.hasNormals,this._shadeNormals,this._applySSAO)}_addData(e,t,i){let s=this._addTasks.get(e.index);if(s)s.attributeInfo=t;else{const r=u();s=new Nt(t,null,r.promise),this._addTasks.set(e.index,s),i().then(r.resolve,r.reject).then(()=>this._addTasks.delete(e.index)).catch(t=>{throw this._addTasks.delete(e.index),t})}return 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=nt(this.view.clippingArea,i,e)?i:null;const s=Q();this._layerClippingArea=nt(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),this._assertFeatureIdNodeCounts(e)}_assertFeatureIdNodeCounts(e){e&&!this._featureIdCounts?(this._featureIdCounts=Zt(this._nodeId2Meta.values()),this._filteredIdCounts=Zt(this._nodeId2Meta.values(),1),this._weaklyRemovedIdCounts=Zt(this._nodeId2Meta.values(),2),this.addHandles(g(()=>this._controller.updating,e=>{!e&&this._needFilterResolve&&(this.multiGeometryFilterResolve(),this._needFilterResolve=!1,this.notifyUpdate())},{sync:!0}),"updateFinished")):!e&&this._featureIdCounts&&(this._featureIdCounts=null,this._filteredIdCounts=null,this._weaklyRemovedIdCounts=null,this._mismatchShow=null,this._mismatchHide=null,this.removeHandles("updateFinished"),this._needFilterResolve=!1,this.notifyUpdate())}_updateFeatureIdCounts(e,t){this._featureIdCounts&&(this._needFilterResolve=!0,Xt(this._featureIdCounts,e.featureIds,t),Xt(this._filteredIdCounts,e.filteredIds,t),Xt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,t))}_updateFilteredIdCounts(e,t,i){this._filteredIdCounts&&(this._needFilterResolve=!0,Xt(this._filteredIdCounts,t,-1),Xt(this._filteredIdCounts,e.filteredIds,1),Xt(this._weaklyRemovedIdCounts,i,-1),Xt(this._weaklyRemovedIdCounts,e.weaklyRemovedIds,1))}_checkFeatureIdNodeCountInvariant(){const e=null!=this._featureIdCounts;if(this.hasGeometryFilter!==e&&o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","LayerView should have feature id node counts if and only if it has a geometry filter",{layerView:this,hasNodeCounts:e}),!this._featureIdCounts||!this._filteredIdCounts)return;const t=Zt(this._nodeId2Meta.values());n(this._featureIdCounts,t)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _featureIdCounts",{layerView:this,counts:this._featureIdCounts,expected:t});const i=Zt(this._nodeId2Meta.values(),1);n(this._filteredIdCounts,i)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _filteredIdCounts",{layerView:this,counts:this._filteredIdCounts,expected:i});const s=Zt(this._nodeId2Meta.values(),2);n(this._weaklyRemovedIdCounts,s)||o.getLogger(this).error("checkFeatureIdNodeCountInvariant()","Incorrect _weaklyRemovedIdCounts",{layerView:this,counts:this._weaklyRemovedIdCounts,expected:i})}multiGeometryFilterResolve(){if(!this._featureIdCounts||!this._filteredIdCounts)return;let e=null,t=null;for(const[i,s]of this._filteredIdCounts){const r=this._featureIdCounts.get(i);if(r!==s){s+(this._weaklyRemovedIdCounts?.get(i)??0)===r?(e??=new Set,e.add(i)):(t??=new Set,t.add(i))}}f(e,this._mismatchShow)&&f(t,this._mismatchHide)||(this._mismatchShow=e,this._mismatchHide=t,this._nodeId2Meta.forEach(e=>{if(!e?.filteredIds)return;const t=Yt(e,this._mismatchShow,this._mismatchHide);this._collection.setAllComponentVisibilities(e.objectHandle,t),this._visibleGeometryChanged(e,2)}))}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach(e=>{e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,2))})}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);if(!n)return;const a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every(e=>e===a||null!=d?.[e])&&qe(e,l,e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Ee(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}})}_boundingRectNodeTest(e,t){return G(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),K(St,Et),J(i,Et)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(3===r)return;if(0===r)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Ot,i,t.objectHandle);qe(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}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){Pt(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateObjectVisibility(i,!0).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch(e=>this._logEdgeViewError(e,this.i3slayer.title)),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){const{filteredIds:t,weaklyRemovedIds:i}=e,s=this._applyFiltersToNodeComponents(e);return this._updateFilteredIdCounts(e,t,i),s&&this._labeler?.applyFilterChange(e),s}_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(null!=e.filteredIds&&e.appliedFilters===this._filters||(e.weaklyRemovedIds=null,e.filteredIds=Jt(e,this._filters),e.appliedFilters=this._filters),s&&e.filteredIds===e.featureIds&&(!this._mismatchHide||e.filteredIds.every(e=>!this._mismatchHide?.has(e))))return!r;const o=Yt(e,this._mismatchShow,this._mismatchHide);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_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=a(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=>this._logEdgeViewError(e,this.i3slayer.title)),this._visibleGeometryChanged(s,1),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights?.objectDeleted(s),i===this._nodeId2Meta?(this._updateFeatureIdCounts(s,-1),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.removeTexture(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,e=>e.polygonOffsetEnabled=0===t)}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=We(this._rendererVersion,1),this._controller?.requestUpdate()}_getInvalidRendererVersion(){return We(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=We(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 ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:o.getLogger(this).warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.symbols)"mesh-3d"!==t.type&&o.getLogger(this).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=i*e.cachedSymbologyStride;N(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255);const o=this._stage.renderView.olidRenderHelper;if(o){const t=e.featureIds[i],r=this.sublayerId?`${this.layerViewUid}_${this.sublayerId}`:this.layerViewUid,n=de(this.view,this.uid);o.setUidToObjectAndLayerId(t,t,this.layerId,r,this.layerPopupEnabledAndHasTemplate&&!n,e.node.resources.attributes,i,this.sublayerId),s.olidColor=o.getObjectAndLayerIdColor({graphicUid:t,layerViewUid:r})}s.externalColorMixMode=15&t[r+4],s.castShadows=!!(16&t[r+4]),s.pickable=!!(32&t[r+4]),s.elevationOffset=e.elevationOffsets?.[i]??0,s.emissiveStrength=e.emissiveStrengths?.[i]??1,s.emissiveSource=e.emissiveSources?.[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=$e(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?oe(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=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=ie(e.featureIds.length*e.cachedSymbologyStride));const d=new Ze,h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=1,g=Ke,m=0;for(let f=0;f<e.featureIds.length;f++){if(null!=o&&(i[o]=e.featureIds[f]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Ee(l[e],f);const r=s?this._getSymbolInfo(s,t):null;let h,p;if(d.pickable=!0,s&&"visualVariables"in s){if(this._colorVariable){const e=ae(this._colorVariable,t,{color:jt,arcade:this._arcade});e&&(h=d.color,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,h[3]=e.a??1,this._opacityVariable||null===e.a||(p=e.a))}this._opacityVariable&&(p=le(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==p?Me(h,p,e.color,e.alpha,It,d.color):Me(h,p,null,null,It,d.color)}h??=N(d.color,1,1,1,1);const y=r?.material;if(d.colorMixMode=y?.colorMixMode??1,d.edgeMaterial=r?.edgeMaterial,this._symbologyOverride?.(t,d),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=3),d.pickable&&=h[3]>=vt,d.castShadows=r?r.castShadows:d.pickable,null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||3===d.colorMixMode)?1:0;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[f]=g}else e.cachedEdgeMaterials[f]=Ke;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<<4|+d.pickable<<5;const b=y?.emissive?.strength??ft;b===ft||e.emissiveStrengths||(e.emissiveStrengths=new Array(e.featureIds.length).fill(ft)),e.emissiveStrengths&&(e.emissiveStrengths[f]=b);const v=y?.emissive?.source||0;0===v||e.emissiveSources||(e.emissiveSources=new Array(e.featureIds.length).fill(0)),e.emissiveSources&&(e.emissiveSources[f]=v)}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||Pt(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some(e=>e!==Ke),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map((t,o)=>e.featureIds[o]!==i[s]?Ke:(r=r||t!==Ke,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),Pt(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,2)}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}_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._shadeNormals&&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)?0:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values())if(!(null==s||t&&s.node.serviceMbsInIndexSR&&1===t(s.node.serviceMbsInIndexSR)))switch(i){case 1:this._forAllFeaturesOfNode(s,e);break;case 0:this._forAllVisibleFeaturesOfNode(s,e);break;case 2:this._forAllQueryableFeaturesOfNode(s,e)}}_forAllFeaturesOfNode(e,t){e.featureIds.forEach((i,s)=>t(i,s,e))}_forAllVisibleFeaturesOfNode(e,t){const i=e.featureIds;this._collection.forEachVisibleComponent(e.objectHandle,s=>0===t(i[s],s,e))}_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(0===s)return;if(3===s)return this._forAllFeaturesOfNode(e,i);const r=e.featureIds,o=e.objectHandle,n=Qe(this._renderClippingArea,this._collection.getObjectTransform(o));for(let a=0;a<r.length;a++)this._boundingRectFeatureTest(e,a,n)&&i(r[a],a,e)}_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]=Ee(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t){const s=tt(e);if(0===s.length)return it;const r=yt(t),o=s[0]instanceof i?this._featureIdsFromGraphics(s):"number"==typeof s[0]?s:null;if(!o)return it;const n=this._ensureHighlights(),{set:a,handle:l}=n.acquireSet(r);return n.setFeatureIds(a,o),l}_featureIdsFromGraphics(e){const t=this.i3slayer.fieldsIndex,i=this._getObjectIdField();return e.map(e=>et(t,e.attributes,i))}_ensureHighlights(){return this._highlights??=new xe({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,1),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)}),this._highlights}resetHighlights(){this._highlights=a(this._highlights)}_visibleGeometryChanged(e,t){this._elevationProvider&&(null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=m(()=>{const{node:t}=e,i=t.visibilityObbInRenderSR??t.geometryObbInRenderSR??t.serviceObbInRenderSR;if(null!=i){const e=$();i.toAaBoundingBox(e),this.emit("visible-geometry-changed",new ge(e))}else this.emit("visible-geometry-changed");this._visibleGeometryChangedSchedulerHandle=null})),this._updateSnappingSources(e,t),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e.objectHandle)))}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)}checkInvariants(){}get test(){}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)}getNodeComponentHandle(e){return this._nodeId2Meta.get(e)?.objectHandle}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;Pt(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch(e=>this._logEdgeViewError(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=Ht(e);if(s){const t={context:i,buffer:s.buffer};Ie(t);const r=new Float64Array(s.buffer);e.forAll((e,t)=>{const i=r[t],s=Ce(i);e.imModificationImpact=s,0!==s&&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.readyToRun||this._needFilterResolve||this._compressionTracker.compressing}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:()=>s(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||0===this.elevationInfo.mode)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=H(),a=H(),l=(e,t)=>{V(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),V(e,e,D(a,a,t)),A(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)1!==t&&2!==t||r.events.remove(i),0!==t&&2!==t||r.events.add(i,s)}_logEdgeViewError(e,t){h(e)||o.getLogger(this).warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}_indexedDbSizeCheck(e,t){return t.byteSize>wt?(o.getLogger(this).warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}get elevationProvider(){return this._elevationProvider}};return e([y()],T.prototype,"_hasLoadedPBRTextures",void 0),e([y()],T.prototype,"_asyncModuleLoading",void 0),e([y()],T.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],T.prototype,"view",void 0),e([y()],T.prototype,"i3slayer",void 0),e([y()],T.prototype,"_controller",void 0),e([y()],T.prototype,"_labeler",void 0),e([y()],T.prototype,"updating",void 0),e([y()],T.prototype,"suspended",void 0),e([y()],T.prototype,"contentVisible",null),e([y({readOnly:!0})],T.prototype,"legendEnabled",null),e([y(dt)],T.prototype,"updatingProgress",void 0),e([y()],T.prototype,"updatingProgressValue",null),e([y()],T.prototype,"hasTexturesOrVertexColors",null),e([y()],T.prototype,"rendererTextureUsage",null),e([y()],T.prototype,"elevationOffset",null),e([y()],T.prototype,"elevationInfo",null),e([y({type:Boolean})],T.prototype,"slicePlaneEnabled",void 0),e([y()],T.prototype,"supportedTextureEncodings",null),e([y({type:[ne]})],T.prototype,"_modifications",void 0),e([y({readOnly:!0})],T.prototype,"clientGeometry",null),e([y()],T.prototype,"elevationRange",null),e([y()],T.prototype,"fullExtent",null),e([y()],T.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],T.prototype,"_usePBR",null),T=e([b("esri.views.3d.layers.I3SMeshView3D")],T),T},St=$(),Et=Q(),Ot=Q(),Rt=new at,jt=new t([0,0,0,0]),Ft=new te(0,0,0,0);function Vt(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 Dt(e){return"geometryData"in e}function At(e){return null!=e&&p(e.data)}function Tt(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&&p(s.data)&&(i+=s.data.byteLength);return i}function Ht(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=Rt,e.serviceMbsInIndexSR?(t.center=e.serviceMbsInIndexSR.center,t.halfSize=[e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius,e.serviceMbsInIndexSR.radius]):t.invalidate());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}class Nt{constructor(e,t,i){this.attributeInfo=e,this.meta=t,this.promise=i,this.allowMemCache=!0}}function Pt(e,t){e.forEach(e=>e.opacity=t)}class kt{constructor(e,t){this.mode=e,this.offset=t}}const Ut=H(),Lt=$(),Gt="elevation-change",Bt="",qt="@null",zt="@ECEF",Wt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],$t=new ot;function Kt(e,t,i){let s=e.minElevation,r=e.maxElevation;const o=i;if(o>0){t.getCorners(Wt);for(const e of Wt){const t=T(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Wt);for(const e of Wt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function Qt(e,t,i){const{center:s,radius:r}=t,o=i>0?T(s)-i:s[2];e.expandElevationRangeValues(o-r,o+r)}function Jt(e,t){const i=e.featureIds.slice();for(const s of t)if(s(i,e),0===i.length)break;return i.length===e.featureIds.length?e.featureIds:i}function Yt(e,t,i){const s=new Array,r=e.filteredIds;if(null==r||t?.size||i?.size){if(null!=r){let o=0;e.featureIds.forEach((e,n)=>{if(r[o]===e)++o;else if(!t?.has(e))return;i?.has(e)||s.push(n)})}}else e.featureIds.forEach((e,t)=>{r[s.length]===e&&s.push(t)});return s}function Xt(e,t,i){if(e&&t)for(const s of t){const t=(e.get(s)??0)+i;t>0?e.set(s,t):e.delete(s)}}function Zt(e,t=0){const i=new Map;for(const s of e){Xt(i,0===t?s?.featureIds:1===t?s?.filteredIds:s?.weaklyRemovedIds,1)}return i}export{xt as I3SMeshView3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as b,b as y,t as _}from"../../../chunks/vec32.js";import{fromArray as w,clone as v,create as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as M,getReferenceEllipsoid as C}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as T}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as U}from"../../../geometry/projection/projectVectorToVector.js";import{create as H}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as P,BufferViewVec4f as R,BufferViewVec4u8 as E,BufferViewVec4u16 as S,BufferViewVec3f as V,BufferViewVec3u8 as A,BufferViewVec3u16 as I,BufferViewInt16 as k,BufferViewUint32 as F,BufferViewUint16 as D}from"../../../geometry/support/buffer/BufferView.js";import L from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as B}from"../../../support/elevationInfoUtils.js";import{toWasmModification as G}from"./I3SMeshWorkerHandle.js";import{LayerView3D as N}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as W,removeLayerViewFromWasm as $,getLyr3DWasm as q}from"./Lyr3DWasm.js";import{LayerElevationProvider as J}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as K,alphaModeConversion as Q,faceCullingConversion as X,wrapModeConversion as Y,lyr3DTypeToByteSize as Z}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ee}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{toBoundingRect as ie}from"../support/extentUtils.js";import{Obb as re,compute as se}from"../support/orientedBoundingBox.js";import{ObjectParameters as oe}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ne,createVertexBufferLayout as ae,SourceGeometry as le}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ce}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as de}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as he}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as me}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as ue}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as pe}from"../webgl-engine/lib/Normals.js";import{writeAttribute as fe,writeBufferVec2 as ge}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import be from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as _e}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as we}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ve}from"../../../webscene/support/AlphaCutoff.js";class je{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=j();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}expandElevationRange(e){e.expandElevationRange(this.elevationRange)}}function xe(e){return Math.round(e/1048.576)/1e3}let Me=class extends(N(be)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new we,this._modificationsUpdatingHandle=null,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}tryRecycleWith(e,t){return e.url!==this.layer.url||"integrated-mesh-3dtiles"!==e.type?null:e.load(t).then(()=>{s(t),this.layer=e,this._modificationsUpdatingHandle&&this._modificationsUpdatingHandle.remove(),this._modificationsUpdatingHandle=this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o)})}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._modificationsUpdatingHandle=this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=W(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ee(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._elevationProvider=new J({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(a(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),$(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=G(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=H();this._layerClippingArea=ie(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,B(e))}get _wasm(){return q(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.replacesTerrain||_e(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,s,o,xe(t),xe(e),xe(r),xe(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return B(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new te(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=w(i.desc.origin),s=new Array,o=this.view.basemapTerrain.spatialReference;let n,a;if("global"===this.view.viewingMode){const e=f();O(M,r,e,o),n=h(u(),e),a=m(u(),n)}else n=p,a=p;const l=v(r),c=j(),d=Ue(i.desc.obb);let g=0,H=0;const R={textureMemoryUsage:0},E=new Map,S=i.desc.prims.length,V=new Array,A=new te;try{const e="global"===this.view.viewingMode,t=e?C(this.view.spatialReference).radius:0;for(let h=0;h<S;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==K[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:w,positionAttr:v,normalsView:M,normalsAttr:C,colorAttr:O,texCoord0Attr:S,indicesView:V}=this.getBufferViews(m,i.data.buffer,n);if(null==v||null==w||null==V)continue;const I=new ne(null!=O,S?1:0,null!=M,this._shadeNormals||this._replacesTerrain,this._applySSAO),k=v.data.length/v.size,F=(e,t)=>!e||e.data.length/e.size===k||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(S,"numTexcoord")||!F(O,"numColors")||!F(C,"normals"))continue;const D=ae(I);for(let i=0;i<w.count;i++){w.getVec(i,c),b(c,c,r);const s=e?y(c)-t:c[2];A.expandElevationRangeValues(s,s)}const L=d?.clone()??Te(v,r);if(n!==p)for(let e=0;e<w.count;e++)w.getVec(e,c),_(c,c,n),w.setVec(e,c);const B=D.createBuffer(v.data.length);if(fe("position",v,null,null,B,0),null!=S){const e=B.getField("uv0",P);ge(S,e,0)}null!=O&&fe("color",O,null,null,B,0),null!=C&&fe("normalCompressed",C,null,null,B,0);const G=new Uint32Array([0,V.typedBuffer.length]),N=new le({data:B.buffer,count:B.byteLength/D.stride,layoutParameters:I},{positions:w.typedBuffer,indices:V.typedBuffer},V.typedBuffer,G);g+=w.count+V.count;const z=this.view.renderSpatialReference,W=j(),$=[1,1,1];T(l,z,$,o)||this._dbg(3,"Unsupported coordinate system for IM overlay"),U(l,z,W,o);let q=()=>{},J=Promise.resolve(Pe);if(u){const e=e=>this._getTexture(e,i,E,R),t=e(u.baseColorTex),r="Pbr"===f,s=r?e(u.metalTex):null,o=r?e(u.emissiveTex):null,n=r?e(u.occlusionTex):null,a=r?e(u.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);J=Promise.all(l),q=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=Q[u.alphaMode],e.objectOpacity=this.fullOpacity,R.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(R.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=X[u.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??ve,e.alphaDiscardMode=Q[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=he(this.view.spatialReference)}}const Y=J.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new oe(x(W[0],W[1],$[0],$[1]),new ce(l,a),L,N,!1));return this._collection.updateMaterial(e,q),H+=this._collection.getObjectGPUMemoryUsage(e),e});s.push(Y)}if(V.push(...await Promise.all(s)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(D){throw E.forEach(e=>this._stage.removeTexture(e)),D}const I=V.map(e=>e()),k=new Array;E.forEach(e=>k.push(e));const F=new je(e.handle,I,k,g,H,R.textureMemoryUsage,d,e.stableNodeId,A);return this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(He(F.handle),F),t=F.usedMemory,this._cacheMemory+=t,{memUsageBytes:F.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=He(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(He(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(He(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new de(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=Y[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new ue(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Z[u.type],b=new(Re(g))(g);for(let e=0;e<g;++e)b[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new V(t,u.byteOffset,p,f),s=new me(r.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new V(t,u.byteOffset,p,f),r=pe(e.typedBuffer,i);a=new k(r.buffer),l=new me(a.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new me(new P(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new S(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new A(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new I(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new me(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new D(t,i.byteOffset,r,s);break;case"U32":c=new F(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new D(new Uint16Array(e).buffer):new F(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],Me.prototype,"fullOpacity",null),e([c({type:[L]})],Me.prototype,"_modifications",void 0),e([c()],Me.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],Me.prototype,"layer",void 0),e([c({readOnly:!0})],Me.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],Me.prototype,"_collection",null),e([c()],Me.prototype,"elevationOffset",null),Me=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Me);const Ce=Me,Oe=j();function Te(e,t){const i=se(e);return b(Oe,i.center,t),i.center=Oe,i}function Ue(e){return e?new re(e.center,e.halfSize,g(...e.quaternion)):null}function He(e){return`${e}`}const Pe=new Array;function Re(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Ce as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as n}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as l,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as d,invert as h}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b,t as y}from"../../../chunks/vec32.js";import{freeze as _,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 j,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as x}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as O}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as C}from"../../../geometry/projection/projectVectorToVector.js";import{create as T}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as U,BufferViewVec4f as H,BufferViewVec4u8 as P,BufferViewVec4u16 as R,BufferViewVec3f as E,BufferViewVec3u8 as S,BufferViewVec3u16 as V,BufferViewInt16 as A,BufferViewUint32 as I,BufferViewUint16 as k}from"../../../geometry/support/buffer/BufferView.js";import F from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{toWasmModification as L}from"./I3SMeshWorkerHandle.js";import{LayerView3D as B}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as G}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as N,removeLayerViewFromWasm as z,getLyr3DWasm as W}from"./Lyr3DWasm.js";import{LayerElevationProvider as $}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as q,alphaModeConversion as J,faceCullingConversion as K,wrapModeConversion as Q,lyr3DTypeToByteSize as X}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Y}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as Z}from"../support/ElevationRange.js";import{toBoundingRect as ee}from"../support/extentUtils.js";import{Obb as te,compute as ie}from"../support/orientedBoundingBox.js";import{ObjectParameters as re}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as se,createVertexBufferLayout as oe,SourceGeometry as ne}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ae}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as le}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as ce}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as de}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as he}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as me}from"../webgl-engine/lib/Normals.js";import{writeAttribute as ue,writeBufferVec2 as pe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import fe from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ge,isInEffectiveScaleRange as be}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as ye}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as _e}from"../../../webscene/support/AlphaCutoff.js";class we{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}expandElevationRange(e){e.expandElevationRange(this.elevationRange)}}function ve(e){return Math.round(e/1048.576)/1e3}let je=class extends(B(fe)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new ye,this._modificationsUpdatingHandle=null,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}tryRecycleWith(e,t){return e.url!==this.layer.url||"integrated-mesh-3dtiles"!==e.type?null:e.load(t).then(()=>{s(t),this.layer=e,this._modificationsUpdatingHandle&&this._modificationsUpdatingHandle.remove(),this._modificationsUpdatingHandle=this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o)})}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._modificationsUpdatingHandle=this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw ge("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=N(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Y(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._elevationProvider=new $({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t)}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return 1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),z(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=L(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=T();this._layerClippingArea=ee(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this._replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,D(e))}get _wasm(){return W(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.replacesTerrain||be(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new G(this.usedMemory,s,o,ve(t),ve(e),ve(r),ve(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return D(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new Z(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=_(...i.desc.origin),s=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=p();x(j,r,e,s),o=d(m(),e),n=h(m(),o)}else o=u,n=u;const a=w(),l=Ce(i.desc.obb);let c=0,f=0;const T={textureMemoryUsage:0},H=new Array,P=new Map,R=i.desc.prims.length,E=new Array,S=new Z;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let d=0;d<R;d++){const h=i.desc.prims[d];this._dbg(2,JSON.stringify(h));if(null==q[h.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+h.ptype+"). Skipping primitive.");continue}const m=i.desc?.materials&&null!=h.materialId?i.desc.materials[h.materialId]:null,p=null!=m?m.lightingModel:"Unlit",{positionView:_,positionAttr:j,normalsView:M,normalsAttr:x,colorAttr:R,texCoord0Attr:E,indicesView:V}=this.getBufferViews(h,i.data.buffer,o);if(null==j||null==_||null==V)continue;const A=new se(null!=R,E?1:0,null!=M,this._shadeNormals||this._replacesTerrain,this._applySSAO),I=j.data.length/j.size,k=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!k(E,"numTexcoord")||!k(R,"numColors")||!k(x,"normals"))continue;const F=oe(A);for(let i=0;i<_.count;i++){_.getVec(i,a),g(a,a,r);const s=e?b(a)-t:a[2];S.expandElevationRangeValues(s,s)}const D=l?.clone()??Oe(j,r);if(o!==u)for(let e=0;e<_.count;e++)_.getVec(e,a),y(a,a,o),_.setVec(e,a);const L=F.createBuffer(j.data.length);if(ue("position",j,null,null,L,0),null!=E){const e=L.getField("uv0",U);pe(E,e,0)}null!=R&&ue("color",R,null,null,L,0),null!=x&&ue("normalCompressed",x,null,null,L,0);const B=new Uint32Array([0,V.typedBuffer.length]),G=new ne({data:L.buffer,count:L.byteLength/F.stride,layoutParameters:A},{positions:_.typedBuffer,indices:V.typedBuffer},V.typedBuffer,B);c+=_.count+V.count;const N=this.view.renderSpatialReference,z=w(),W=[1,1,1];O(r,N,W,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),C(r,N,z,s);let $=()=>{},Q=Promise.resolve(Ue);if(m){const e=e=>this._getTexture(e,i,P,T),t=e(m.baseColorTex),r="Pbr"===p,s=r?e(m.metalTex):null,o=r?e(m.emissiveTex):null,n=r?e(m.occlusionTex):null,a=r?e(m.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);Q=Promise.all(l),$=e=>{e.baseColor=m.baseColorFactor,e.usePBR="Pbr"===p,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveBaseColor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=J[m.alphaMode],e.objectOpacity=this.fullOpacity,T.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(T.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=K[m.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=m.alphaCutoff??_e,e.alphaDiscardMode=J[m.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=ce(this.view.spatialReference)}}const X=Q.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new re(v(z[0],z[1],W[0],W[1]),new ae(r,n),D,G,!1));return this._collection.updateMaterial(e,$),f+=this._collection.getObjectGPUMemoryUsage(e),e});H.push(X)}if(E.push(...await Promise.all(H)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(k){throw P.forEach(e=>this._stage.removeTexture(e)),k}const V=E.map(e=>e()),A=new Array;P.forEach(e=>A.push(e));const I=new we(e.handle,V,A,c,f,T.textureMemoryUsage,l,e.stableNodeId,S);return this._lyrHandleToObjects.set(e.handle,I),this._memCache.put(Te(I.handle),I),t=I.usedMemory,this._cacheMemory+=t,{memUsageBytes:I.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Te(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Te(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Te(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new le(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=Q[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new he(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/X[u.type],b=new(He(g))(g);for(let e=0;e<g;++e)b[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new E(t,u.byteOffset,p,f),s=new de(r.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new E(t,u.byteOffset,p,f),r=me(e.typedBuffer,i);a=new A(r.buffer),l=new de(a.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new de(new U(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new P(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new R(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new S(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new V(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new de(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new k(t,i.byteOffset,r,s);break;case"U32":c=new I(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new k(new Uint16Array(e).buffer):new I(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([l()],je.prototype,"fullOpacity",null),e([l({type:[F]})],je.prototype,"_modifications",void 0),e([l()],je.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([l()],je.prototype,"layer",void 0),e([l({readOnly:!0})],je.prototype,"visibleAtCurrentScale",null),e([l({readOnly:!0})],je.prototype,"_collection",null),e([l()],je.prototype,"elevationOffset",null),je=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],je);const Me=je,xe=w();function Oe(e,t){const i=ie(e);return g(xe,i.center,t),i.center=xe,i}function Ce(e){return e?new te(e.center,e.halfSize,f(...e.quaternion)):null}function Te(e){return`${e}`}const Ue=new Array;function He(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Me as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{colorGamma as e,delinearize as r}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as t}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as o}from"../../../../core/mathUtils.js";import{normalFromMat4 as s,fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as c,e as m,B as f,b as d,n as p,l as g}from"../../../../chunks/vec32.js";import{create as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as T,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as h}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as y,BufferViewVec4f as w,BufferViewVec4u8 as v,BufferViewVec4u16 as B,BufferViewVec3u8 as R,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,b as M,n as F,f as A}from"../../../../chunks/vec3.js";import{t as E,b as C}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as P}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as U}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as O}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as V,processLoadResult as _}from"./wosrLoader.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as W}from"../../webgl-engine/lib/ManagedTexture.js";import{DefaultMaterial as H}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as N,schematicMRRFactors as Q,esriSymbologyMRRFactors as $,advancedMRRFactors as z}from"../../webgl-engine/materials/pbrUtils.js";async function K(e,r){const o=q(t(e));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):V(o.url,r)),{engineResources:t,referenceBoundingBox:s}=_(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L,o.url,r,r.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,re(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:$}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:z},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=J(s,a,u,r,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function q(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=T();return n.lods.forEach((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const s=d?new H({},o):X(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=Y(e,s??new H({},o)),g=l.boundingInfo;null!=g&&0===f&&(b(m,g.bbMin),b(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)}),d||l.push(p)}),{engineResources:l,referenceBoundingBox:m}}function X(e,t,o,s,i,n,l,a,c){const m=e.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=ee(m.alphaMode);if(!n.has(x)){if(T){const r=(r,t=!1,o=!1)=>{if(null!=r&&!l.has(r)){const s=e.textures.get(r);if(s){const e=s.data,i=t&&!U(e)?a.compressionOptions:void 0;l.set(r,new W(U(e)?e.data:e,{...s.parameters,preMultiplyAlpha:!U(e)&&o,encoding:U(e)?e.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;r(m.colorTexture,t,1!==h),r(m.normalTexture),r(m.occlusionTexture,!0),r(m.emissiveTexture),r(m.metallicRoughnessTexture,!0)}const o=r(m.color[0]),f=r(m.color[1]),d=r(m.color[2]),p=null!=m.colorTexture&&T?l.get(m.colorTexture):null,g=N(m),y=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:u;n.set(x,new H({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[o,f,d],ambient:[o,f,d],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=p?p.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=p&&!!p.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[m.emissiveFactor[0],m.emissiveFactor[1],m.emissiveFactor[2]],mrrFactors:g?Q:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:g,colorTextureTransformMatrix:O(m.colorTextureTransform),normalTextureTransformMatrix:O(m.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:O(m.occlusionTextureTransform),emissiveTextureTransformMatrix:O(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:O(m.metallicRoughnessTextureTransform),...i},a))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function Y(e,r){const t=e.attributes.position.count,n=P(e.indices||t,e.primitiveType),l=h(3*t),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;S(l,a,e.transform,3,u);const c=[["position",new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=h(3*t),{typedBuffer:i,typedBufferStride:l}=e.attributes.normal;s(Z,e.transform),M(r,i,Z,3,l),o(Z)&&F(r,r),c.push(["normal",new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=h(4*t),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;i(Z,e.transform),E(r,s,Z,4,l),o(Z)&&F(r,r,4),c.push(["tangent",new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=h(2*t),{typedBuffer:o,typedBufferStride:s}=e.attributes.texCoord0;I(r,o,2,s),c.push(["uv0",new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*t);4===m.elementCount?m instanceof w?C(r,m,1,255):(m instanceof v||m instanceof B)&&C(r,m,1/255,255):(r.fill(255),m instanceof y?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof R||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new D(r,n,4,!0)])}return{geometry:new G(r,c),vertexCount:t}}const Z=n();function ee(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function re(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const n=i.attributes.position,u=n.count,T=x(),b=x(),h=x(),v=new Float32Array(4*u),B=new Float32Array(3*u),R=l(a(),i.transform);let j=0,S=0;for(let l=0;l<u;l++){n.getVec(l,b),s.getVec(l,T),c(b,b,i.transform),m(h,b,t.center),f(h,h,t.radius);const a=h[2],u=d(h),x=Math.min(.45+.55*u*u,1)**e;f(h,h,t.radius),null!==R&&c(h,h,R),p(h,h),o+1!==r.model.lods.length&&r.model.lods.length>1&&g(h,h,T,a>-1?.2:Math.min(-4*a-3.8,1)),B[j]=h[0],B[j+1]=h[1],B[j+2]=h[2],j+=3,v[S]=x,v[S+1]=x,v[S+2]=x,v[S+3]=1,S+=4}i.attributes.normal=new y(B.buffer),i.attributes.color=new w(v.buffer)}}}export{K as fetch,q as parseUrl};
5
+ import{colorGamma as e,delinearize as r}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as t}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as o}from"../../../../core/mathUtils.js";import{normalFromMat4 as s,fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as c,e as m,C as f,b as d,n as p,l as g}from"../../../../chunks/vec32.js";import{create as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as T,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as h}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as y,BufferViewVec4f as w,BufferViewVec4u8 as v,BufferViewVec4u16 as R,BufferViewVec3u8 as B,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,b as M,n as F,f as A}from"../../../../chunks/vec3.js";import{t as E,b as C}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as P}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as U}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as O}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as V,processLoadResult as _}from"./wosrLoader.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as W}from"../../webgl-engine/lib/ManagedTexture.js";import{DefaultMaterial as H}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as N,schematicMRRFactors as Q,esriSymbologyMRRFactors as $,advancedMRRFactors as z}from"../../webgl-engine/materials/pbrUtils.js";async function K(e,r){const o=q(t(e));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):V(o.url,r)),{engineResources:t,referenceBoundingBox:s}=_(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L,o.url,r,r.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,re(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:$}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:z},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=J(s,a,u,r,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function q(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=T();return n.lods.forEach((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const s=d?new H({},o):X(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=Y(e,s??new H({},o)),g=l.boundingInfo;null!=g&&0===f&&(b(m,g.bbMin),b(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)}),d||l.push(p)}),{engineResources:l,referenceBoundingBox:m}}function X(e,t,o,s,i,n,l,a,c){const m=e.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=ee(m.alphaMode);if(!n.has(x)){if(T){const r=(r,t=!1,o=!1)=>{if(null!=r&&!l.has(r)){const s=e.textures.get(r);if(s){const e=s.data,i=t&&!U(e)?a.compressionOptions:void 0;l.set(r,new W(U(e)?e.data:e,{...s.parameters,preMultiplyAlpha:!U(e)&&o,encoding:U(e)?e.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;r(m.colorTexture,t,1!==h),r(m.normalTexture),r(m.occlusionTexture,!0),r(m.emissiveTexture),r(m.metallicRoughnessTexture,!0)}const o=r(m.color[0]),f=r(m.color[1]),d=r(m.color[2]),p=null!=m.colorTexture&&T?l.get(m.colorTexture):null,g=N(m),y=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:u;n.set(x,new H({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[o,f,d],ambient:[o,f,d],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=p?p.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=p&&!!p.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[m.emissiveFactor[0],m.emissiveFactor[1],m.emissiveFactor[2]],mrrFactors:g?Q:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:g,colorTextureTransformMatrix:O(m.colorTextureTransform),normalTextureTransformMatrix:O(m.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:O(m.occlusionTextureTransform),emissiveTextureTransformMatrix:O(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:O(m.metallicRoughnessTextureTransform),...i},a))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function Y(e,r){const t=e.attributes.position.count,n=P(e.indices||t,e.primitiveType),l=h(3*t),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;S(l,a,e.transform,3,u);const c=[["position",new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=h(3*t),{typedBuffer:i,typedBufferStride:l}=e.attributes.normal;s(Z,e.transform),M(r,i,Z,3,l),o(Z)&&F(r,r),c.push(["normal",new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=h(4*t),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;i(Z,e.transform),E(r,s,Z,4,l),o(Z)&&F(r,r,4),c.push(["tangent",new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=h(2*t),{typedBuffer:o,typedBufferStride:s}=e.attributes.texCoord0;I(r,o,2,s),c.push(["uv0",new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*t);4===m.elementCount?m instanceof w?C(r,m,1,255):(m instanceof v||m instanceof R)&&C(r,m,1/255,255):(r.fill(255),m instanceof y?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof B||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new D(r,n,4,!0)])}return{geometry:new G(r,c),vertexCount:t}}const Z=n();function ee(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function re(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const n=i.attributes.position,u=n.count,T=x(),b=x(),h=x(),v=new Float32Array(4*u),R=new Float32Array(3*u),B=l(a(),i.transform);let j=0,S=0;for(let l=0;l<u;l++){n.getVec(l,b),s.getVec(l,T),c(b,b,i.transform),m(h,b,t.center),f(h,h,t.radius);const a=h[2],u=d(h),x=Math.min(.45+.55*u*u,1)**e;f(h,h,t.radius),null!==B&&c(h,h,B),p(h,h),o+1!==r.model.lods.length&&r.model.lods.length>1&&g(h,h,T,a>-1?.2:Math.min(-4*a-3.8,1)),R[j]=h[0],R[j+1]=h[1],R[j+2]=h[2],j+=3,v[S]=x,v[S+1]=x,v[S+2]=x,v[S+3]=1,S+=4}i.attributes.normal=new y(R.buffer),i.attributes.color=new w(v.buffer)}}}export{K as fetch,q as parseUrl};