@arcgis/core 5.0.0-next.71 → 5.0.0-next.73

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 (151) hide show
  1. package/Ground.js +1 -1
  2. package/applications/Components/analysisUtils.d.ts +1 -2
  3. package/applications/Components/analysisUtils.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/00631252e8bd4a456253.js +1 -0
  6. package/assets/esri/core/workers/chunks/{322085d63719da6e443c.js → 0c02b084ae30ba138c5d.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0f2f1731543ed21db0a8.js +1 -0
  8. package/assets/esri/core/workers/chunks/1b201d83e9ba7d8615c0.js +1 -0
  9. package/assets/esri/core/workers/chunks/{b4f944ef6c174b20b619.js → 23545a9adc75564ecf6e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/261b5a5db022ef580a1b.js +1 -0
  11. package/assets/esri/core/workers/chunks/2bd59ece927b5c1c9f80.js +1 -0
  12. package/assets/esri/core/workers/chunks/{37e46461da3000949a26.js → 2d8b8880e6bff4414e95.js} +1 -1
  13. package/assets/esri/core/workers/chunks/2fba74bae99ece15706c.js +1 -0
  14. package/assets/esri/core/workers/chunks/2fc64404bc42b7250086.js +1 -0
  15. package/assets/esri/core/workers/chunks/33cbfc34d5e2fc1a1a4f.js +1 -0
  16. package/assets/esri/core/workers/chunks/35887be3e4a218268d99.js +1 -0
  17. package/assets/esri/core/workers/chunks/3596ae4cb2bd2f3f35d9.js +1 -0
  18. package/assets/esri/core/workers/chunks/37814bf052ab59a5fb9e.js +1 -0
  19. package/assets/esri/core/workers/chunks/4e0d299054da075e5103.js +1 -0
  20. package/assets/esri/core/workers/chunks/50186162cd6d7c2ef0f9.js +1 -0
  21. package/assets/esri/core/workers/chunks/543ea1a0e7a6f1d267d1.js +1 -0
  22. package/assets/esri/core/workers/chunks/{dbfb00fb28b8b9f687a1.js → 5bbf20135c87a1cc8a18.js} +1 -1
  23. package/assets/esri/core/workers/chunks/5ed31ec0f53c1d55c4ea.js +1 -0
  24. package/assets/esri/core/workers/chunks/6309e8beedf5e7f2a50f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{1a45b4b4803337f4b99f.js → 64985e9b6e2edb3ceb37.js} +38 -38
  26. package/assets/esri/core/workers/chunks/65475370cc4ebe2aa657.js +1 -0
  27. package/assets/esri/core/workers/chunks/65d9f3bc88472008443a.js +1 -0
  28. package/assets/esri/core/workers/chunks/6ab0f16f5c8806855c47.js +1 -0
  29. package/assets/esri/core/workers/chunks/7e37a3005f2ad2c0a918.js +1 -0
  30. package/assets/esri/core/workers/chunks/7f2496a59379e1a61ee5.js +1 -0
  31. package/assets/esri/core/workers/chunks/88379cd8e8e1c7ae3c7c.js +1 -0
  32. package/assets/esri/core/workers/chunks/{25abbe1663e18e677dc2.js → 935a6dccb88557f98189.js} +2 -2
  33. package/assets/esri/core/workers/chunks/{a808be466812db51813d.js → 9382af94bf6bf1b09c8c.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{8e83c133b201b9b61e70.js → 979bc762ccc0d3fc2467.js} +1 -1
  35. package/assets/esri/core/workers/chunks/9c417f4dfb19e4c4bd71.js +1 -0
  36. package/assets/esri/core/workers/chunks/a554ad74be03b1ed1a72.js +1 -0
  37. package/assets/esri/core/workers/chunks/{e6e837e43b9348050832.js → a67c86f4254807eb6a05.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{1ec1a1997b5577619040.js → b211b53aa7616a093b90.js} +1 -1
  39. package/assets/esri/core/workers/chunks/c31babdb59382b6bc007.js +1 -0
  40. package/assets/esri/core/workers/chunks/c8182c2cbb0ead202af6.js +1 -0
  41. package/assets/esri/core/workers/chunks/ce218c10b209b58e04fd.js +1 -0
  42. package/assets/esri/core/workers/chunks/ceef586d8cc8adc4d249.js +1 -0
  43. package/assets/esri/core/workers/chunks/d13e8ce9270dc0662b87.js +1 -0
  44. package/assets/esri/core/workers/chunks/db28d00171240b4fffac.js +1 -0
  45. package/assets/esri/core/workers/chunks/dbd382546837aa7709e2.js +1 -0
  46. package/assets/esri/core/workers/chunks/ea6f897f21b4f30e8e99.js +1 -0
  47. package/assets/esri/core/workers/chunks/{e8a3ad00936f2ccaf362.js → f0a667d8d33bc51c795d.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{29b09db309ff75fb3e97.js → f65d26588d2d80680a26.js} +1 -1
  49. package/assets/esri/core/workers/chunks/f72e6c903f55ce95a6c5.js +1 -0
  50. package/assets/esri/core/workers/chunks/f893e10d660e819cca45.js +1 -0
  51. package/assets/esri/core/workers/chunks/{878010ca23da0bca9405.js → fb1ed5ef2f95ab093346.js} +1 -1
  52. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  53. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  54. package/chunks/lyr3DMain.js +1 -1
  55. package/config.js +1 -1
  56. package/core/workers/registry.js +1 -1
  57. package/geometry/spatialReferenceEllipsoidUtils.js +1 -1
  58. package/kernel.js +1 -1
  59. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  60. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  61. package/layers/RouteLayer.d.ts +3 -3
  62. package/layers/support/ElevationQuery.js +1 -1
  63. package/layers/support/GeometryDescriptor.js +1 -1
  64. package/layers/support/layerUtils.d.ts +4 -0
  65. package/layers/support/types.d.ts +3 -2
  66. package/package.json +1 -1
  67. package/rest/featureService/FeatureService.d.ts +1 -1
  68. package/rest/featureService/types.d.ts +4 -4
  69. package/rest/geoprocessor/GPOptions.d.ts +5 -5
  70. package/rest/geoprocessor/execute.d.ts +6 -0
  71. package/rest/layerSources/DynamicDataLayer.d.ts +2 -2
  72. package/rest/layerSources/QueryTableDataSource.d.ts +1 -1
  73. package/rest/print.d.ts +1 -1
  74. package/rest/support/ClosestFacilityParameters.d.ts +3 -3
  75. package/rest/support/ClosestFacilitySolveResult.d.ts +2 -2
  76. package/rest/support/Query.d.ts +2 -2
  77. package/rest/support/RouteParameters.d.ts +2 -5
  78. package/rest/support/RouteResult.d.ts +1 -1
  79. package/rest/support/ServiceAreaParameters.d.ts +1 -1
  80. package/rest/support/ServiceAreaSolveResult.d.ts +2 -2
  81. package/rest/support/types.d.ts +1 -1
  82. package/rest/symbolService.d.ts +2 -2
  83. package/support/revision.js +1 -1
  84. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  85. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementController.js +1 -1
  86. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  87. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  88. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  89. package/views/3d/analysis/support/measurementUtils.js +1 -1
  90. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  91. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  92. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  93. package/views/3d/interactive/visualElements/support/Segment.js +1 -1
  94. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  95. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  96. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  97. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  98. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  99. package/views/3d/webgl-engine/lib/Material.js +1 -1
  100. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  101. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  102. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  103. package/views/3d/webgl-engine/materials/VisualVariablePassParameters.js +1 -1
  104. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  105. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  106. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
  107. package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +1 -1
  108. package/views/support/MeasurementWorker.js +5 -0
  109. package/views/support/MeasurementWorkerHandle.js +5 -0
  110. package/views/support/automaticAreaMeasurementUtils.js +1 -1
  111. package/views/support/geodesicAreaMeasurementUtils.js +1 -1
  112. package/views/support/geodesicLengthMeasurementUtils.js +1 -1
  113. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  114. package/widgets/Directions/DirectionsViewModel.d.ts +2 -2
  115. package/widgets/Search/SearchResultRenderer.d.ts +0 -2
  116. package/widgets/Search/SearchSource.d.ts +2 -2
  117. package/widgets/Search/SearchViewModel.d.ts +6 -7
  118. package/widgets/Search/types.d.ts +4 -4
  119. package/assets/esri/core/workers/chunks/0367a8580fede8f804f9.js +0 -1
  120. package/assets/esri/core/workers/chunks/14f4f5b7549cea7b5a6a.js +0 -1
  121. package/assets/esri/core/workers/chunks/1b475593c80d7bccdda5.js +0 -1
  122. package/assets/esri/core/workers/chunks/27ec8688f72130239b98.js +0 -1
  123. package/assets/esri/core/workers/chunks/2dd347aa2a061d536e69.js +0 -1
  124. package/assets/esri/core/workers/chunks/2f6fa33692478e99d24b.js +0 -1
  125. package/assets/esri/core/workers/chunks/3e7ea06b342e33bc48a5.js +0 -1
  126. package/assets/esri/core/workers/chunks/4387aaf9d5e8f6d1833d.js +0 -1
  127. package/assets/esri/core/workers/chunks/668a868fe2dcb6384ac9.js +0 -1
  128. package/assets/esri/core/workers/chunks/6acfa51b81e6f4255118.js +0 -1
  129. package/assets/esri/core/workers/chunks/6f8098f9fe233833245a.js +0 -1
  130. package/assets/esri/core/workers/chunks/76dbaef0d0794913f36f.js +0 -1
  131. package/assets/esri/core/workers/chunks/7c5218eae13d3bd30598.js +0 -1
  132. package/assets/esri/core/workers/chunks/7fc09382f934e9223a9b.js +0 -1
  133. package/assets/esri/core/workers/chunks/822ef6a043c7e147b4b6.js +0 -1
  134. package/assets/esri/core/workers/chunks/980313a6c35e79812d17.js +0 -1
  135. package/assets/esri/core/workers/chunks/9c157c0eeadb824ad01e.js +0 -1
  136. package/assets/esri/core/workers/chunks/a39ac9127a215d14d412.js +0 -1
  137. package/assets/esri/core/workers/chunks/a893f8db2477cf677ac8.js +0 -1
  138. package/assets/esri/core/workers/chunks/a95e28ade258b144cbb5.js +0 -1
  139. package/assets/esri/core/workers/chunks/abcee7cfd53cfe1d91e9.js +0 -1
  140. package/assets/esri/core/workers/chunks/b9f0d313f59fc7c43560.js +0 -1
  141. package/assets/esri/core/workers/chunks/bbe2eaef7edfa33b6eea.js +0 -1
  142. package/assets/esri/core/workers/chunks/bfdf646d4c8f175a4236.js +0 -1
  143. package/assets/esri/core/workers/chunks/d749aa62ad694147aebe.js +0 -1
  144. package/assets/esri/core/workers/chunks/d7d9656b990ce8be2152.js +0 -1
  145. package/assets/esri/core/workers/chunks/d8a7004c399d539aed09.js +0 -1
  146. package/assets/esri/core/workers/chunks/df92239eefff04471a0b.js +0 -1
  147. package/assets/esri/core/workers/chunks/ee2ca25048a920e43743.js +0 -1
  148. package/assets/esri/core/workers/chunks/eeb24a4ab4993f1f4e8e.js +0 -1
  149. package/assets/esri/core/workers/chunks/fe5d2735f057c7789f4b.js +0 -1
  150. package/views/support/GeodesicMeasurementWorker.js +0 -5
  151. package/views/support/GeodesicMeasurementWorkerHandle.js +0 -5
@@ -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{deg2rad as e}from"../../../../../core/mathUtils.js";import{createLength as t,toUnit as s,createArea as i}from"../../../../../core/quantity.js";import{lengthUnitFromSpatialReference as o,areaUnitFromSpatialReference as n}from"../../../../../core/units.js";import{set as r,distance as h}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{B as l,d,f as g,q as c,e as p,g as m,j as u,i as _,n as f}from"../../../../../chunks/vec32.js";import{create as S}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as L}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as M}from"../../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C}from"../../../../../geometry/projectionUtils.js";import{getSphericalPCPF as P}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectDirection as R}from"../../../../../geometry/projection/projectDirection.js";import{projectPointToVector as j}from"../../../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as U}from"../../../../../geometry/projection/projectVectorToVector.js";import{compactIndices as A}from"../../../../../geometry/support/Indices.js";import{segmentIntersects as v}from"../../../../../geometry/support/intersectsBase.js";import{Sphere as I}from"../../../../../geometry/support/sphere.js";import{areaPoints2d as V}from"../../../../../geometry/support/triangle.js";import{bestFitPlane as w,fitHemisphere as W,triangleAreaGeodesic as F,planePointDistance as y,boundingSphere as G}from"../../support/measurementUtils.js";import{getElevationAtPoint as T}from"../../../support/ElevationProvider.js";import{midpoint3d as x,makeOrthonormal as q,tangentFrame as z}from"../../../support/mathUtils.js";import{triangulate as b}from"../../../../support/euclideanAreaMeasurementUtils.js";import{euclideanDistanceBetweenPoints as E}from"../../../../support/euclideanLengthMeasurementUtils.js";import{supportsGeodesicMeasurement as B}from"../../../../support/geodesicMeasurementUtils.js";import{computeEuclideanMeasurementSR as D}from"../../../../support/measurementUtils.js";class H{get numVertices(){return this._length}get hasStagedVertex(){return null!=this._lastCursorPoint}constructor(e,t,s){this._sceneView=e,this._geodesicAreaMeasurementUtils=t,this._geodesicLengthMeasurementUtils=s,this.validMeasurement=!1,this.positionsWorld=[],this.positionsRender=[],this.positionsFittedWorld=[],this.positionsFittedRender=[],this.positionsGeodesic=[],this.positionsSpherical=[],this.positionsStereographic=[],this.pathSegmentLengths=[],this.geodesicPathSegmentLengths=[],this.perimeterSegmentLengths=[],this.intersectingSegments=new Set,this.geodesicIntersectingSegments=new Set,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.areaCentroidWorldCoords=S(),this.areaCentroidRenderCoords=S(),this.geodesicAreaCentroidRenderCoords=S(),this.fittingMode=null,this.area=null,this.geodesicArea=null,this.pathLength=null,this.geodesicPathLength=null,this.perimeterLength=null,this._length=0,this._centroidRenderCoords=S(),this._planeWorldCoords=L(),this._worldUp=S(),this._worldTangent=S(),this._frame=[S(),S(),S()],this._lastPathVersion=-1,this._lastCursorPoint=null,this._mode=null,this._tempU=S(),this._tempV=S(),this._tempVec3=S(),this._tempSphere=new I;const i=D(e.spatialReference);this._measurementSR=i,this._lengthMeasurementUnit=o(i)??"meters",this._areaMeasurementUnit=n(i)??"square-meters"}update(e,t,s,i,o,n){const r=this._lastPathVersion===e.version,h=t?t.equals(this._lastCursorPoint):null==this._lastCursorPoint,a=this._mode===o;return!(r&&!n&&a&&h)&&(this._lastPathVersion=e.version,this._lastCursorPoint=t,this._updateCursorSegmentLength(e,t),this._update(e,t,s,i,o),!0)}_update(e,s,i,o,n){const r=this._sceneView.renderSpatialReference,h=this._measurementSR,a=i.spatialReference;let l=e.numVertices;const d=!(null==s||s.equals(e.lastPoint)||l>2&&s.equals(e.firstPoint)||e.polygonIsClosed);d&&(l+=1);const g=!e.polygonIsClosed&&l>2,c=e.polygonIsClosed||g;this._resize(l);const p=P(a),m=null!=a&&B(a)?a:null,u=null!=m&&C(a,p),{positionsGeodesic:_,positionsWorld:S,positionsRender:L,positionsSpherical:M}=this,R=(e,t)=>{k(i.elevationProvider,e),j(e,S[t],h),j(e,L[t],r),u&&(j(e,_[t],m),j(e,M[t],p),f(M[t],M[t]))};e.forEachVertexPosition((e,t)=>R(e,t)),d&&R(s,l-1);const U=this._updatePathLengths(c);if(this.pathLength=this._length>1?t(U,this._lengthMeasurementUnit):null,u){const e=this._updateGeodesicPathLengths(c,m);this.geodesicPathLength=null!=e&&this._length>1?e:null}else this.geodesicPathLength=null;if(this._updateMode(n),!c)return this.area=null,this.geodesicArea=null,this.perimeterLength=null,this.triangleIndices=null,this.geodesicTriangleIndices=null,this.intersectingSegments.clear(),this.geodesicIntersectingSegments.clear(),void(this.validMeasurement=!1);this._updateAreaAndPerimeterLength(i,r,h,o),u&&this._updateGeodesicArea(i,m),this.validMeasurement=!0}getData(){return{validMeasurement:this.validMeasurement,numVertices:this.numVertices,hasStagedVertex:this.hasStagedVertex,positionsRender:this.positionsRender,positionsFittedWorld:this.positionsFittedWorld,positionsFittedRender:this.positionsFittedRender,intersectingSegments:this.intersectingSegments,geodesicIntersectingSegments:this.geodesicIntersectingSegments,triangleIndices:this.triangleIndices,geodesicTriangleIndices:this.geodesicTriangleIndices,areaCentroidRenderCoords:this.areaCentroidRenderCoords,geodesicAreaCentroidRenderCoords:this.geodesicAreaCentroidRenderCoords,area:this.area,geodesicArea:this.geodesicArea,pathLength:this.pathLength,geodesicPathLength:this.geodesicPathLength,perimeterLength:this.perimeterLength,actualMeasurementMode:this.actualMeasurementMode}}_resize(e){for(e<this._length&&(this.positionsWorld.length=e,this.positionsRender.length=e,this.positionsFittedWorld.length=e,this.positionsFittedRender.length=e,this.positionsGeodesic.length=e,this.positionsSpherical.length=e,this.positionsStereographic.length=e,this.pathSegmentLengths.length=e,this.geodesicPathSegmentLengths.length=e,this.perimeterSegmentLengths.length=e,this._length=e);this._length<e;)this.positionsWorld.push(S()),this.positionsRender.push(S()),this.positionsFittedWorld.push(a()),this.positionsFittedRender.push(S()),this.positionsGeodesic.push(S()),this.positionsSpherical.push(S()),this.positionsStereographic.push(a()),this.pathSegmentLengths.push(0),this.geodesicPathSegmentLengths.push(0),this.perimeterSegmentLengths.push(0),++this._length}_updatePathLengths(e){const t=this.positionsWorld,s=this.pathSegmentLengths;let i=0;const o=this._length;for(let n=0;n<o;++n){const r=s[n]=l(t[n],t[(n+1)%o]);(n<o-1||e)&&(i+=r)}return i}_updateGeodesicPathLengths(e,i){const o=this.positionsGeodesic,n=this.geodesicPathSegmentLengths;let r=0;const h=this._length;for(let t=0;t<h;++t){const a=this._geodesicLengthMeasurementUtils.geodesicDistance(o[t],o[(t+1)%h],i);if(null==a)return null;const l=s(a,"meters").value,d=n[t]=l;(t<h-1||e)&&(r+=d)}return t(r,"meters")}_updateAreaAndPerimeterLength(e,t,s,i){const o=e.renderCoordsHelper,n=this.positionsWorld,h=this.positionsRender,a=this.positionsFittedWorld,l=this.positionsFittedRender,f=this._planeWorldCoords,S=this._centroidRenderCoords;x(h,S),o.worldUpAtPosition(S,this._worldUp),o.worldBasisAtPosition(S,0,this._worldTangent),R(S,this._worldUp,t,this._worldUp,s),R(S,this._worldTangent,t,this._worldTangent,s),n.length>2&&w(n,f),this.fittingMode=this._selectFittingMode(f,n,this._worldUp,i);let L=0;if("horizontal"===this.fittingMode){let e=-1/0;h.forEach((t,s)=>{const i=o.getAltitude(h[s]);i>e&&(e=i,L=s)})}const M=n[L];let C=f,P=this._worldTangent;"horizontal"===this.fittingMode?C=this._worldUp:"vertical"===this.fittingMode&&(C=this._tempVec3,P=this._worldUp,q(f,this._worldUp,C)),d(this._frame[2],C),q(P,C,this._frame[0]),g(this._frame[1],this._frame[0],this._frame[2]),c(this._frame[1],this._frame[1]);const j=this._tempVec3,A=this._tempU,v=this._tempV;for(let d=0;d<this._length;++d){const e=a[d],i=l[d];p(j,n[d],M),r(e,m(this._frame[0],j),m(this._frame[1],j)),u(A,this._frame[0],e[0]),u(v,this._frame[1],e[1]),_(j,A,v),_(j,j,M),U(j,s,i,t)}this.perimeterLength=this._length>0?this._updatePerimeterLengths():null,x(l,this.areaCentroidRenderCoords),U(this.areaCentroidRenderCoords,t,this.areaCentroidWorldCoords,s),this._updateIntersectingSegments(),this.area=0===this.intersectingSegments.size?this._computeArea():null}_updateGeodesicArea(e,t){const{renderCoordsHelper:s,spatialReference:i}=e,{positionsSpherical:o,positionsStereographic:n}=this,h=this._tempVec3,a=W(o,h);if(!a)return void(this.geodesicArea=null);const l=this._tempU,d=this._tempV;z(h,l,d);for(let g=0;g<this._length;++g){const e=m(o[g],l),t=m(o[g],d),s=m(o[g],h);r(n[g],e/s,t/s)}u(h,h,M(i).radius),s.toRenderCoords(h,P(i),this.geodesicAreaCentroidRenderCoords),this._updateGeodesicIntersectingSegments(),this.geodesicArea=a&&0===this.geodesicIntersectingSegments.size?this._computeGeodesicArea(t):null}_updatePerimeterLengths(){const e=this.positionsFittedWorld,s=this.perimeterSegmentLengths;let i=0;for(let t=0;t<this._length;++t){i+=s[t]=h(e[t],e[(t+1)%this._length])}return t(i,this._lengthMeasurementUnit)}_updateIntersectingSegments(){const e=this.positionsFittedWorld,t=this.intersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],n=e[(s+1)%this._length],r=e[i],h=e[(i+1)%this._length];v(o,n,r,h)&&(t.add(s),t.add(i))}}_computeArea(){const e=this.positionsFittedWorld,t=this.triangleIndices=A(b(e));let s=0;for(let i=0;i<t.length;i+=3)s+=V(e[t[i]],e[t[i+1]],e[t[i+2]]);return i(s,this._areaMeasurementUnit)}_updateGeodesicIntersectingSegments(){const e=this.positionsStereographic,t=this.geodesicIntersectingSegments;t.clear();for(let s=0;s<this._length;++s)for(let i=s+2;i<this._length;++i){if((i+1)%this._length===s)continue;const o=e[s],n=e[(s+1)%this._length],r=e[i],h=e[(i+1)%this._length];v(o,n,r,h)&&(t.add(s),t.add(i))}}_computeGeodesicArea(e){const t=this.positionsGeodesic,o=this.positionsStereographic,n=this.geodesicTriangleIndices=A(b(o));let r=0;for(let i=0;i<n.length;i+=3){const o=F(t[n[i]],t[n[i+1]],t[n[i+2]],e,this._geodesicAreaMeasurementUtils);if(null==o)return null;r+=s(o,"square-meters").value}return i(r,"square-meters")}_selectFittingMode(t,s,i,o){const n=s.map(e=>Math.abs(y(t,e))).reduce((e,t)=>Math.max(e,t),0);G(s,this._tempSphere);const r=n/(2*this._tempSphere.radius),h=r<o.maxRelativeErrorCoplanar,a=r<o.maxRelativeErrorAlmostCoplanar;let l="horizontal";if(h)l="oblique";else if(a){l=Math.abs(m(i,t))>Math.cos(e(o.verticalAngleThreshold))?"horizontal":"vertical"}return l}_updateCursorSegmentLength(e,t){const s=e.lastPoint;e.isValidPolygon||null==s||null==t?(this.geodesicStagedSegmentLength=null,this.stagedSegmentLength=null):(this.geodesicStagedSegmentLength=this._geodesicLengthMeasurementUtils.geodesicDistanceBetweenPoints(s,t),this.stagedSegmentLength=E(s,t)?.direct)}_updateMode(e){if(0===e){this.actualMeasurementMode="euclidean";let e=0;null!=this.geodesicPathLength&&(e+=this.geodesicPathLength.value),e>Z&&(this.actualMeasurementMode="geodesic")}else this.actualMeasurementMode=1===e?"euclidean":"geodesic";null==this.geodesicPathLength&&(this.actualMeasurementMode="euclidean"),this._mode=e}}function k(e,t){t.hasZ||(t.z=T(e,t,"ground")??0)}const Z=1e5;export{H as MeasurementDataManager};
5
+ import{__decorate as t}from"tslib";import e from"../../../../../core/Accessor.js";import{deg2rad as r}from"../../../../../core/mathUtils.js";import{abortMaybe as s}from"../../../../../core/maybe.js";import{debounce as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{valueInUnit as n}from"../../../../../core/quantity.js";import{lengthUnitFromSpatialReference as a,areaUnitFromSpatialReference as l}from"../../../../../core/units.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{set as p}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{d as u,h as c,f as _,q as g,e as f,g as j,j as v,i as P}from"../../../../../chunks/vec32.js";import{create as x}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as w}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import C from"../../../../../geometry/Polygon.js";import y from"../../../../../geometry/SpatialReference.js";import{isPCPF as R}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectDirection as M}from"../../../../../geometry/projection/projectDirection.js";import{projectPointToVector as U}from"../../../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as A}from"../../../../../geometry/projection/projectVectorToVector.js";import{compactIndices as W}from"../../../../../geometry/support/Indices.js";import{Sphere as D}from"../../../../../geometry/support/sphere.js";import{bestFitPlane as V,planePointDistance as b,boundingSphere as F}from"../../support/measurementUtils.js";import{getElevationAtPoint as I}from"../../../support/ElevationProvider.js";import{midpoint3d as S,makeOrthonormal as T}from"../../../support/mathUtils.js";import{useGeodesicAreaMeasurement as k}from"../../../../support/automaticAreaMeasurementUtils.js";import{triangulate as q}from"../../../../support/euclideanAreaMeasurementUtils.js";import{computeEuclideanMeasurementSR as z}from"../../../../support/measurementUtils.js";import{MeasurementWorkerHandle as O}from"../../../../support/MeasurementWorkerHandle.js";class E{constructor(t){this.positionsWorld=[],this.positionsRender=[],this.positionsFittedRender=[],this.triangleIndices=null,this.areaPolygon=new C({rings:[[]],spatialReference:t}),this.positionsFittedWorldPlaneProjected=this.areaPolygon.rings[0]}}class H{constructor(t,e=null,r=null,s=null,i=null,o=null,n=null){this.mode=t,this.area=e,this.geodesicArea=r,this.perimeter=s,this.geodesicPerimeter=i,this.areaCentroidRenderCoords=o,this.geodesicAreaCentroidRenderCoords=n}}let L=class extends e{get numVertices(){return this._length}get hasStagedVertex(){return null!=this._lastCursorPoint}get fittingMode(){return this._fittingMode}get measurements(){return this._measurements}get updateId(){return this._updateId}constructor(t){super(t),this._length=0,this._lastCursorPoint=null,this._fittingMode=null,this._measurements=null,this._updateId=0,this._centroidRenderCoords=x(),this._planeWorldCoords=w(),this._worldUp=x(),this._worldTangent=x(),this._frame=[x(),x(),x()],this._worldOrigin=x(),this._updateAxisU=x(),this._updateAxisV=x(),this._updateWorldOrigin=x(),this._lastPathVersion=-1,this._mode=null,this._tempU=x(),this._tempV=x(),this._tempVec3=x(),this._tempSphere=new D,this._measurementWorker=new O,this._updateAbortController=null,this._updateMeasurements=i(async(t,e,r,s,i,n)=>{const a=t.spatialReference,l=k(a);u(this._updateAxisU,this._frame[0]),u(this._updateAxisV,this._frame[1]),u(this._updateWorldOrigin,this._worldOrigin);const h=(e,r)=>(e&&t.renderCoordsHelper.toRenderCoords(e,r)||c(r,0,0,0),r),d=e.areaMeasurement?.geometry,p=l&&1!==r&&d?await this._measurementWorker.geodesicLength(d,{stagedPoint:s?i:null}):null;o(n);const m=this._calculateMode(r,p),_="geodesic"===m,[g,f,j]=await Promise.all([_?null:this._measurementWorker.planarArea(this.vertexData.areaPolygon,{unit:this._areaMeasurementUnit,returnCentroid:!0}),_?null:this._measurementWorker.planarLength(this.vertexData.areaPolygon,{unit:this._lengthMeasurementUnit}),_&&d?await this._measurementWorker.geodesicArea(d,{stagedPoint:s?i:null,returnCentroid:!0}):null]);o(n);const v=_?null:x();v&&g?.centroid&&this._projectPointToFittedRender(v,this._updateWorldOrigin,[g.centroid?.x??0,g.centroid?.y??0],this._updateAxisU,this._updateAxisV,this.view.renderSpatialReference,this._measurementSR);const P=j?.centroid?h(j.centroid,x()):null;this._measurements=new H(m,_?null:g?.area,_?j?.area:null,_?null:f,_?p:null,_?null:v,_?P:null)});const e=z(t.view.spatialReference);this._measurementSR=e,this._lengthMeasurementUnit=a(e)??"meters",this._areaMeasurementUnit=l(e)??"square-meters";const r=R(e)?y.WebMercator:e;this.vertexData=new E(r)}destroy(){this._measurementWorker.destroy()}update(t,e,r,s,i,o,n){const a=this._lastPathVersion===t.version,l=e?e.equals(this._lastCursorPoint):null==this._lastCursorPoint,h=this._mode===i;return!(a&&!o&&h&&l)&&(this._lastPathVersion=t.version,this._lastCursorPoint=e,this._update(t,e,r,s,i,n),!0)}_update(t,e,r,i,o,n){const a=this.view.renderSpatialReference,l=this._measurementSR;let h=t.numVertices;const d=!(null==e||e.equals(t.lastPoint)||h>2&&e.equals(t.firstPoint)||t.polygonIsClosed);d&&(h+=1);const p=!t.polygonIsClosed&&h>2,m=t.polygonIsClosed||p;this._resize(h);const{positionsWorld:u,positionsRender:c}=this.vertexData,_=(t,e)=>{B(r.elevationProvider,t),U(t,u[e],l),U(t,c[e],a)};if(t.forEachVertexPosition((t,e)=>_(t,e)),d&&_(e,h-1),this.vertexData.areaPolygon.clearCache(),!m)return this._measurements=null,this.vertexData.triangleIndices=null,this._updateId++,void(this._updateAbortController=s(this._updateAbortController));this._updateVertexData(r,a,l,i),this._updateId++,this._updateAbortController??=new AbortController,n.addPromise(this._updateMeasurements(r,t,o,d,e,this._updateAbortController.signal))}_resize(t){for(t<this._length&&(this.vertexData.positionsWorld.length=t,this.vertexData.positionsRender.length=t,this.vertexData.positionsFittedWorldPlaneProjected.length=t,this.vertexData.positionsFittedRender.length=t,this._length=t);this._length<t;)this.vertexData.positionsWorld.push(x()),this.vertexData.positionsRender.push(x()),this.vertexData.positionsFittedWorldPlaneProjected.push(m()),this.vertexData.positionsFittedRender.push(x()),++this._length}_updateVertexData(t,e,r,s){const i=t.renderCoordsHelper,{positionsWorld:o,positionsRender:n,positionsFittedWorldPlaneProjected:a,positionsFittedRender:l}=this.vertexData,h=this._planeWorldCoords,d=this._centroidRenderCoords;S(n,d),i.worldUpAtPosition(d,this._worldUp),i.worldBasisAtPosition(d,0,this._worldTangent),M(d,this._worldUp,e,this._worldUp,r),M(d,this._worldTangent,e,this._worldTangent,r),o.length>2&&V(o,h),this._fittingMode=this._selectFittingMode(h,o,this._worldUp,s);let m=0;if("horizontal"===this._fittingMode){let t=-1/0;n.forEach((e,r)=>{const s=i.getAltitude(n[r]);s>t&&(t=s,m=r)})}const{_worldOrigin:c}=this;u(this._worldOrigin,o[m]);let v=h,P=this._worldTangent;"horizontal"===this._fittingMode?v=this._worldUp:"vertical"===this._fittingMode&&(v=this._tempVec3,P=this._worldUp,T(h,this._worldUp,v));const x=this._frame[0],w=this._frame[1];u(this._frame[2],v),T(P,v,x),_(w,x,this._frame[2]),g(w,w);const C=this._tempVec3;for(let u=0;u<this._length;++u){const t=a[u],s=l[u];f(C,o[u],c),p(t,j(x,C),j(w,C)),this._projectPointToFittedRender(s,c,t,x,w,e,r)}this.vertexData.triangleIndices=W(q(a))}_projectPointToFittedRender(t,e,r,s,i,o,n){const a=this._tempU,l=this._tempV;v(a,s,r[0]),v(l,i,r[1]),P(t,a,l),P(t,t,e),A(t,n,t,o)}_selectFittingMode(t,e,s,i){const o=e.map(e=>Math.abs(b(t,e))).reduce((t,e)=>Math.max(t,e),0);F(e,this._tempSphere);const n=o/(2*this._tempSphere.radius),a=n<i.maxRelativeErrorCoplanar,l=n<i.maxRelativeErrorAlmostCoplanar;let h="horizontal";if(a)h="oblique";else if(l){h=Math.abs(j(s,t))>Math.cos(r(i.verticalAngleThreshold))?"horizontal":"vertical"}return h}_calculateMode(t,e){return null!=e&&0===t?n(e,"meters")>Z?"geodesic":"euclidean":null==e||1===t?"euclidean":"geodesic"}};function B(t,e){e.hasZ||(e.z=I(t,e,"ground")??0)}t([h()],L.prototype,"_measurements",void 0),t([h()],L.prototype,"_updateId",void 0),t([h()],L.prototype,"view",void 0),L=t([d("esri.views.3d.analysis.AreaMeasurement.support.MeasurementData")],L);const Z=1e5;export{H as AreaMeasurementQuantities,L as MeasurementData};
@@ -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"../../../core/has.js";import{abortMaybe as t,destroyMaybe as s}from"../../../core/maybe.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import{getDefaultUnitForView as r}from"../../../support/getDefaultUnitForView.js";import o from"./AnalysisView3D.js";import{AreaMeasurementController as n}from"./AreaMeasurement/support/AreaMeasurementController.js";import{AreaMeasurement3DPathHelper as l}from"./AreaMeasurement/support/AreaMeasurementPathHelper.js";import{AreaMeasurementVisualization as u}from"./AreaMeasurement/support/AreaMeasurementVisualization.js";import{toPreferredLengthUnit as p,toPreferredAreaUnit as m}from"./AreaMeasurement/support/utils.js";import y from"../interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js";import{connectAnalysisViewToTool as h,removeAnalysisViewTool as d,startPlaceOperation as g}from"../../analysis/analysisViewUtils.js";import{loadGeodesicAreaMeasurementUtils as c}from"../../support/geodesicAreaMeasurementUtils.js";import{loadGeodesicLengthMeasurementUtils as v}from"../../support/geodesicLengthMeasurementUtils.js";let M=class extends o{constructor(e){super(e),this.type="area-measurement-view-3d",this.analysis=null,this.measurementData=null,this.lastDraggedVertex=null,this.stagedPoint=null,this.mode=0,this.tool=null,this.userOperation=null}initialize(){const{analysis:e,view:t}=this;this.path=new l({view:t,areaMeasurement:e}),this._analysisVisualization=new u({view:t,analysis:e,analysisViewData:this}),this.addResolvingPromise(Promise.all([c(),v()]).then(([s,i])=>{this.destroyed||(this._analysisController=new n({view:t,analysis:e,analysisViewData:this,geodesicAreaMeasurementUtils:s,geodesicLengthMeasurementUtils:i}))})),this.addHandles(h(this,y))}destroy(){d(this),this.userOperation=t(this.userOperation),this._analysisController=s(this._analysisController),this._analysisVisualization=s(this._analysisVisualization),this.path.destroy()}get visible(){return super.visible}set visible(e){super.visible=e}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return!!this._analysisVisualization?.loadingMessages}get result(){const{measurementData:e}=this;if(!e)return null;const{unit:t}=this;if("euclidean"===e.actualMeasurementMode){const{area:s,perimeterLength:i}=e;return{area:s?m(s,t):null,perimeter:i?p(i,t):null,mode:"euclidean"}}const{geodesicArea:s,pathLength:i}=e;return{area:s?m(s,t):null,perimeter:i?p(i,t):null,mode:"geodesic"}}get viewData(){return this._analysisVisualization.viewData}get areaLabel(){return this._analysisVisualization.areaLabel}get perimeterLengthLabel(){return this._analysisVisualization.perimeterLengthLabel}get validMeasurement(){return this.path.isValidPolygon}get unit(){return this.analysis.unit??r(this.view)}get testData(){}place(e){return g(this,{placementOptions:e})}};e([i()],M.prototype,"_analysisVisualization",void 0),e([i()],M.prototype,"_analysisController",void 0),e([i({readOnly:!0})],M.prototype,"type",void 0),e([i({constructOnly:!0,nonNullable:!0})],M.prototype,"analysis",void 0),e([i()],M.prototype,"updating",null),e([i()],M.prototype,"result",null),e([i()],M.prototype,"measurementData",void 0),e([i()],M.prototype,"viewData",null),e([i()],M.prototype,"areaLabel",null),e([i()],M.prototype,"perimeterLengthLabel",null),e([i()],M.prototype,"validMeasurement",null),e([i()],M.prototype,"path",void 0),e([i()],M.prototype,"lastDraggedVertex",void 0),e([i()],M.prototype,"stagedPoint",void 0),e([i()],M.prototype,"mode",void 0),e([i()],M.prototype,"unit",null),e([i()],M.prototype,"tool",void 0),e([i()],M.prototype,"userOperation",void 0),M=e([a("esri.views.3d.analysis.AreaMeasurementAnalysisView3D")],M);const w=M;export{w as default};
5
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import{abortMaybe as t,destroyMaybe as s}from"../../../core/maybe.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import{getDefaultUnitForView as r}from"../../../support/getDefaultUnitForView.js";import o from"./AnalysisView3D.js";import{AreaMeasurementController as n}from"./AreaMeasurement/support/AreaMeasurementController.js";import{AreaMeasurement3DPathHelper as l}from"./AreaMeasurement/support/AreaMeasurementPathHelper.js";import{AreaMeasurementVisualization as p}from"./AreaMeasurement/support/AreaMeasurementVisualization.js";import{toPreferredLengthUnit as u,toPreferredAreaUnit as m}from"./AreaMeasurement/support/utils.js";import y from"../interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js";import{connectAnalysisViewToTool as h,removeAnalysisViewTool as d,startPlaceOperation as v}from"../../analysis/analysisViewUtils.js";let g=class extends o{constructor(e){super(e),this.type="area-measurement-view-3d",this.analysis=null,this.measurementData=null,this.lastDraggedVertex=null,this.stagedPoint=null,this.mode=0,this.tool=null,this.userOperation=null}initialize(){const{analysis:e,view:t}=this;this.path=new l({view:t,areaMeasurement:e}),this._analysisVisualization=new p({view:t,analysis:e,analysisViewData:this}),this._analysisController=new n({view:t,analysis:e,analysisViewData:this}),this.addHandles(h(this,y))}destroy(){d(this),this.userOperation=t(this.userOperation),this._analysisController=s(this._analysisController),this._analysisVisualization=s(this._analysisVisualization),this.path.destroy()}get visible(){return super.visible}set visible(e){super.visible=e}get interactive(){return super.interactive}set interactive(e){super.interactive=e}get updating(){return!!this._analysisVisualization?.loadingMessages||!!this._analysisController?.updating}get result(){const e=this.measurementData?.measurements;if(!e)return null;const{unit:t}=this,{mode:s}=e,i="geodesic"===s,a=i?e.geodesicArea:e.area,r=i?e.geodesicPerimeter:e.perimeter;return{mode:s,area:a?m(a,t):null,perimeter:r?u(r,t):null}}get viewData(){return this._analysisVisualization.viewData}get areaLabel(){return this._analysisVisualization.areaLabel}get perimeterLabel(){return this._analysisVisualization.perimeterLabel}get validMeasurement(){return this.path.isValidPolygon}get unit(){return this.analysis.unit??r(this.view)}get testData(){}place(e){return v(this,{placementOptions:e})}};e([i()],g.prototype,"_analysisVisualization",void 0),e([i()],g.prototype,"_analysisController",void 0),e([i({readOnly:!0})],g.prototype,"type",void 0),e([i({constructOnly:!0,nonNullable:!0})],g.prototype,"analysis",void 0),e([i()],g.prototype,"updating",null),e([i()],g.prototype,"result",null),e([i()],g.prototype,"measurementData",void 0),e([i()],g.prototype,"viewData",null),e([i()],g.prototype,"areaLabel",null),e([i()],g.prototype,"perimeterLabel",null),e([i()],g.prototype,"validMeasurement",null),e([i()],g.prototype,"path",void 0),e([i()],g.prototype,"lastDraggedVertex",void 0),e([i()],g.prototype,"stagedPoint",void 0),e([i()],g.prototype,"mode",void 0),e([i()],g.prototype,"unit",null),e([i()],g.prototype,"tool",void 0),e([i()],g.prototype,"userOperation",void 0),g=e([a("esri.views.3d.analysis.AreaMeasurementAnalysisView3D")],g);const c=g;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{d as e,h as t,i as r,n,f as o,g as s,j as i,s as f}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../../geometry/Polygon.js";import{planeFromPoints as c}from"../../support/mathUtils.js";function u(e,n){t(n.center,0,0,0);for(let t=0;t<e.length;++t)r(n.center,n.center,e[t]);i(n.center,n.center,1/e.length);let o=0;for(let t=0;t<e.length;++t)o=Math.max(o,f(n.center,e[t]));n.radius=Math.sqrt(o)}function g(e,t){if(e.length<3)throw new Error("need at least 3 points to fit a plane");c(e[0],e[1],e[2],t)}function h(e,t){return s(e,t)+e[3]}function m(t,r,n,o,{geodesicArea:s}){const i=d;return e(i.rings[0][0],t),e(i.rings[0][1],r),e(i.rings[0][2],n),e(i.rings[0][3],t),i.spatialReference=o,i.clearCache(),s(i)}function p(i,f=null,l=!0){const a=(e,t)=>{if(0===t[0]&&0===t[1]&&0===t[2])return!1;for(let r=0;r<e.length;++r)if(s(t,e[r])<-1e-6)return!1;return!0};if(0===i.length)return!1;if(1===i.length)return f&&e(f,i[0]),!0;t(w,0,0,0);for(let e=0;e<i.length;++e)r(w,w,i[e]);if(n(w,w),a(i,w))return f&&e(f,w),!0;if(!l)return!1;for(let t=0;t<i.length;++t)for(let r=0;r<i.length;++r)if(t!==r&&(o(w,i[t],i[r]),n(w,w),a(i,w)))return f&&e(f,w),!0;return!1}function j(e){return"mouse"!==e.pointerType||0===e.button}const d=new a({hasM:!1,hasZ:!0,rings:[[l(),l(),l(),l()]],spatialReference:null}),w=l();export{g as bestFitPlane,u as boundingSphere,p as fitHemisphere,j as isPrimaryPointerAction,h as planePointDistance,m as triangleAreaGeodesic};
5
+ import{g as t,h as e,i as n,j as r,s as o}from"../../../../chunks/vec32.js";import{planeFromPoints as s}from"../../support/mathUtils.js";function a(t,s){e(s.center,0,0,0);for(let e=0;e<t.length;++e)n(s.center,s.center,t[e]);r(s.center,s.center,1/t.length);let a=0;for(let e=0;e<t.length;++e)a=Math.max(a,o(s.center,t[e]));s.radius=Math.sqrt(a)}function i(t,e){if(t.length<3)throw new Error("need at least 3 points to fit a plane");s(t[0],t[1],t[2],e)}function c(e,n){return t(e,n)+e[3]}function u(t){return"mouse"!==t.pointerType||0===t.button}export{i as bestFitPlane,a as boundingSphere,u as isPrimaryPointerAction,c as planePointDistance};
@@ -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{multiplyOpacityToUnitRGBA as t,colorEquals as e,getContrast as i}from"../../../../../core/colorUtils.js";import s from"../../../../../core/Handles.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{watch as r,sync as o}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import h from"../../../../../geometry/Point.js";import{Manipulator3D as _}from"../../Manipulator3D.js";import{createManipulatorMaterial as u}from"../../manipulatorUtils.js";import{RenderObject as p}from"../../RenderObject.js";import{PickResult as c}from"../support/PickRequest.js";import{LaserlineVisualElement as d}from"../../visualElements/LaserlineVisualElement.js";import{createSphereGeometry as m}from"../../../webgl-engine/lib/GeometryUtil.js";import{ManipulatorCollection as w}from"../../../../interactive/ManipulatorCollection.js";import{newToolIntersector as v}from"../../../../interactive/ToolIntersector.js";class g{constructor(t){this.vertexManipulators=[],this._destroyed=!1,this._isManipulatorsOwner=!0,this._visible=!0,this._listenerHandles=null,this._tempHandlePosition=l();const{analysisViewData:e,manipulators:i,toolState:s,view:a,visible:r}=t;this._analysisViewData=e,this._toolState=s,null!=i?(this._manipulators=i,this._isManipulatorsOwner=!1):this._manipulators=new w,this._view=a,this._intersector=v(a.state.viewingMode);const o=u(this._handleColor),n=[new p(m(o,1,32,32))],h=new _({view:a,renderObjects:n});h.available=!1,h.radius=b,h.interactive=!1,this._manipulators.add(h),this._cursorManipulator=h,this._cursorManipulatorMaterial=o,this._laserLine=new d({view:a,attached:!0,style:{glowWidth:f,glowFalloff:V,innerWidth:M},isDecoration:!0}),this._updateVisibility(r??!0)}destroy(){this._listenerHandles=a(this._listenerHandles),this._isManipulatorsOwner?this._manipulators=a(this._manipulators):this._manipulators=null,this._laserLine=a(this._laserLine),this._destroyed=!0}get destroyed(){return this._destroyed}get visible(){return this._visible}set visible(t){t?this.show():this.hide()}get testData(){}show(){this._setVisibility(!0)}hide(){this._setVisibility(!1)}_setVisibility(t){this._destroyed||this._visible===t||this._updateVisibility(t)}_updateVisibility(t){this._visible=t,this._laserLine.visible=t,t?(this._initializeListeners(),this._updateAll()):(this._destroyListeners(),this.vertexManipulators.forEach(({manipulator:t})=>this._removeVertexManipulator(t)),this.vertexManipulators=[])}vertexHandleAt(t,e){const i=this._manipulators.intersect(t,e);return i?.metadata}pick(t){const e=this._view.spatialReference,i=n(t.screenPoint);this._view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=l();if(!s.getIntersectionPoint(a))return null;const r=this._view.renderCoordsHelper.fromRenderCoords(a,new h({spatialReference:e}));return null==r?null:new c(a,r)}_updateAll(){this._visible&&(this._updateVertexManipulators(),this._updateLaserLine())}_createVertexManipulator(){const t=u(this._handleColor),e=[new p(m(t,1,32,32))],i=new _({view:this._view,renderObjects:e});return i.radius=b,this._manipulators.add(i),{manipulator:i,material:t}}_removeVertexManipulator(t){this._manipulators.remove(t)}_updateVertexManipulators(){const{viewData:t}=this._analysisViewData,e=this._analysisViewData.path?this._analysisViewData.path.vertices:[],i=this.vertexManipulators;y(i,e.length,()=>this._createVertexManipulator(),({manipulator:t})=>this._removeVertexManipulator(t)),i.forEach(({manipulator:i},s)=>{i.metadata=e[s],i.renderLocation=t.positionsRender[s],i.cursor=0===s&&"drawing"===this._toolState.polygonState?"crosshair":null}),"drawing"===this._toolState.polygonState&&null!=this._analysisViewData.stagedPoint?(this._cursorManipulator.available=!0,this._cursorManipulator.location=this._analysisViewData.stagedPoint):this._cursorManipulator.available=!1}get _handleColor(){return t(this._view.effectiveTheme.accentColor,.5)}_getFocusPoint(){const{lastDraggedVertex:t}=this._analysisViewData;switch(this._toolState.polygonState){case"drawing":return null!=this._analysisViewData.stagedPoint?this._analysisViewData.stagedPoint:null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):this._analysisViewData.path.lastPoint;case"editing":return null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):null;default:return this._analysisViewData.stagedPoint}}_updateLaserLine(){const t="measured"!==this._toolState.polygonState&&this._toolState.active,e=this._getFocusPoint();if(t&&null!=e){const t=this._tempHandlePosition;this._view.renderCoordsHelper.toRenderCoords(e,t),this._laserLine.heightManifoldTarget=t}else this._laserLine.heightManifoldTarget=null}_initializeListeners(){this._listenerHandles=new s,this._listenerHandles.add([r(()=>this._toolState.polygonState,()=>this._updateLaserLine()),r(()=>this._analysisViewData.viewData,()=>this._updateAll(),o),r(()=>({lastDraggedVertex:this._analysisViewData.lastDraggedVertex,cursorPoint:this._analysisViewData.stagedPoint}),()=>this._updateLaserLine()),r(()=>this._toolState.active,()=>this._updateAll()),r(()=>this._view.effectiveTheme.accentColor,e=>{const s=t(e,.5);for(const{material:t}of this.vertexManipulators)t.setParameters({color:s});this._cursorManipulatorMaterial.setParameters({color:s});const a=e.toUnitRGB(),r=i(e).toUnitRGB(),o=.75*e.a,n=this._laserLine,l=n.style;n.style={...l,glowColor:a,innerColor:r,globalAlpha:o}},{initial:!0,equals:e})])}_destroyListeners(){this._listenerHandles=a(this._listenerHandles)}}function y(t,e,i,s){for(;t.length<e;)t.push(i());if(s)for(;t.length>e;){s(t.pop())}else t.length=e}const f=8,V=8,M=1,b=5;export{g as default};
5
+ import{multiplyOpacityToUnitRGBA as t,colorEquals as e,getContrast as i}from"../../../../../core/colorUtils.js";import s from"../../../../../core/Handles.js";import"../../../../../core/has.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{watch as r,sync as o}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import h from"../../../../../geometry/Point.js";import{Manipulator3D as _}from"../../Manipulator3D.js";import{createManipulatorMaterial as u}from"../../manipulatorUtils.js";import{RenderObject as p}from"../../RenderObject.js";import{PickResult as d}from"../support/PickRequest.js";import{LaserlineVisualElement as c}from"../../visualElements/LaserlineVisualElement.js";import{createSphereGeometry as m}from"../../../webgl-engine/lib/GeometryUtil.js";import{ManipulatorCollection as w}from"../../../../interactive/ManipulatorCollection.js";import{newToolIntersector as v}from"../../../../interactive/ToolIntersector.js";class g{constructor(t){this.vertexManipulators=[],this._destroyed=!1,this._isManipulatorsOwner=!0,this._visible=!0,this._listenerHandles=null,this._tempHandlePosition=l();const{analysisViewData:e,manipulators:i,toolState:s,view:a,visible:r}=t;this._analysisViewData=e,this._toolState=s,null!=i?(this._manipulators=i,this._isManipulatorsOwner=!1):this._manipulators=new w,this._view=a,this._intersector=v(a.state.viewingMode);const o=u(this._handleColor);o.setParameters({testsTransparentRenderOrder:4});const n=[new p(m(o,1,32,32))],h=new _({view:a,renderObjects:n});h.available=!1,h.radius=D,h.interactive=!1,this._manipulators.add(h),this._cursorManipulator=h,this._manipulatorMaterial=o,this._laserLine=new c({view:a,attached:!0,style:{glowWidth:f,glowFalloff:V,innerWidth:b},isDecoration:!0}),this._updateVisibility(r??!0)}destroy(){this._listenerHandles=a(this._listenerHandles),this._isManipulatorsOwner?this._manipulators=a(this._manipulators):this._manipulators=null,this._laserLine=a(this._laserLine),this._destroyed=!0}get destroyed(){return this._destroyed}get visible(){return this._visible}set visible(t){t?this.show():this.hide()}get testData(){}show(){this._setVisibility(!0)}hide(){this._setVisibility(!1)}_setVisibility(t){this._destroyed||this._visible===t||this._updateVisibility(t)}_updateVisibility(t){this._visible=t,this._laserLine.visible=t,t?(this._initializeListeners(),this._updateAll()):(this._destroyListeners(),this.vertexManipulators.forEach(t=>this._removeVertexManipulator(t)),this.vertexManipulators=[])}vertexHandleAt(t,e){const i=this._manipulators.intersect(t,e);return i?.metadata}pick(t){const e=this._view.spatialReference,i=n(t.screenPoint);this._view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=l();if(!s.getIntersectionPoint(a))return null;const r=this._view.renderCoordsHelper.fromRenderCoords(a,new h({spatialReference:e}));return null==r?null:new d(a,r)}_updateAll(){this._visible&&(this._updateVertexManipulators(),this._updateLaserLine())}_createVertexManipulator(){const t=[new p(m(this._manipulatorMaterial,1,32,32))],e=new _({view:this._view,renderObjects:t});return e.radius=D,this._manipulators.add(e),e}_removeVertexManipulator(t){this._manipulators.remove(t)}_updateVertexManipulators(){const{viewData:t}=this._analysisViewData,e=this._analysisViewData.path?this._analysisViewData.path.vertices:[],i=this.vertexManipulators;y(i,e.length,()=>this._createVertexManipulator(),t=>this._removeVertexManipulator(t)),i.forEach((i,s)=>{i.metadata=e[s],i.renderLocation=t.vertexData.positionsRender[s],i.cursor=0===s&&"drawing"===this._toolState.polygonState?"crosshair":null}),"drawing"===this._toolState.polygonState&&null!=this._analysisViewData.stagedPoint?(this._cursorManipulator.available=!0,this._cursorManipulator.location=this._analysisViewData.stagedPoint):this._cursorManipulator.available=!1}get _handleColor(){return t(this._view.effectiveTheme.accentColor,.5)}_getFocusPoint(){const{lastDraggedVertex:t}=this._analysisViewData;switch(this._toolState.polygonState){case"drawing":return null!=this._analysisViewData.stagedPoint?this._analysisViewData.stagedPoint:null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):this._analysisViewData.path.lastPoint;case"editing":return null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):null;default:return this._analysisViewData.stagedPoint}}_updateLaserLine(){const t="measured"!==this._toolState.polygonState&&this._toolState.active,e=this._getFocusPoint();if(t&&null!=e){const t=this._tempHandlePosition;this._view.renderCoordsHelper.toRenderCoords(e,t),this._laserLine.heightManifoldTarget=t}else this._laserLine.heightManifoldTarget=null}_initializeListeners(){this._listenerHandles=new s,this._listenerHandles.add([r(()=>this._toolState.polygonState,()=>this._updateLaserLine()),r(()=>this._analysisViewData.viewData,()=>this._updateAll(),o),r(()=>({lastDraggedVertex:this._analysisViewData.lastDraggedVertex,cursorPoint:this._analysisViewData.stagedPoint}),()=>this._updateLaserLine()),r(()=>this._toolState.active,()=>this._updateAll()),r(()=>this._view.effectiveTheme.accentColor,e=>{const s=t(e,.5);this._manipulatorMaterial.setParameters({color:s});const a=e.toUnitRGB(),r=i(e).toUnitRGB(),o=.75*e.a,n=this._laserLine,l=n.style;n.style={...l,glowColor:a,innerColor:r,globalAlpha:o}},{initial:!0,equals:e})])}_destroyListeners(){this._listenerHandles=a(this._listenerHandles)}}function y(t,e,i,s){for(;t.length<e;)t.push(i());if(s)for(;t.length>e;){s(t.pop())}else t.length=e}const f=8,V=8,b=1,D=5;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as r,p as s}from"../../../../chunks/vec32.js";import{create as o,ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as n}from"./Object3DVisualElement.js";import{lineStripsToParameters as l,createGeometry as m}from"../../support/engineContent/line.js";import{isImagePattern as p}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as h}from"../../webgl-engine/materials/RibbonLineMaterial.js";class d extends n{constructor(e,t){super(e),this._hasExternalMaterial=!1,this._hasExternalMaterial=null!=t,this._material=t??new h({width:1,color:a(1,0,1,1),stipplePreferContinuous:!0,isClosed:!1,falloff:0,innerWidth:1,hasPolygonOffset:!1,renderOccluded:4,isDecoration:!!e.isDecoration,writeDepth:!0},e.view.state.isGlobal),this.applyProperties(e)}setGeometryFromPoint(e,t=1e3){const r=o();this.view.renderCoordsHelper.toRenderCoords(e,r)&&this.setGeometryFromRenderSpacePoint(r,t)}setGeometryFromRenderSpacePoint(e,t=1e3){this.geometry=[[[e[0]-t,e[1],e[2]],[e[0]+t,e[1],e[2]]],[[e[0],e[1]-t,e[2]],[e[0],e[1]+t,e[2]]],[[e[0],e[1],e[2]-t],[e[0],e[1],e[2]+t]]]}setGeometryFromExtent(e){const t=this.view.spatialReference,s=o(),i=o(),a=100,n=[];r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,i),n.push([i[0],i[1],i[2]]),r(s,e[2],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,i),n.push([i[0],i[1],i[2]]),r(s,e[2],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,i),n.push([i[0],i[1],i[2]]),r(s,e[0],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,i),n.push([i[0],i[1],i[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,i),n.push([i[0],i[1],i[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,i),n.push([i[0],i[1],i[2]]),this.geometry=[n]}setGeometryFromFrustum(e){const t=[];e.lines.forEach(e=>{t.push([e.origin[0],e.origin[1],e.origin[2]]),t.push([e.endpoint[0],e.endpoint[1],e.endpoint[2]])}),this.geometry=[t]}setGeometryFromBoundedPlane(e){const t=[],r=e.origin,s=e.basis1,i=e.basis2,a=.5,n=o(),l=o(),m=o(),p=o();n[0]=r[0]-s[0]*a-i[0]*a,n[1]=r[1]-s[1]*a-i[1]*a,n[2]=r[2]-s[2]*a-i[2]*a,l[0]=r[0]-s[0]*a+i[0]*a,l[1]=r[1]-s[1]*a+i[1]*a,l[2]=r[2]-s[2]*a+i[2]*a,m[0]=r[0]+s[0]*a+i[0]*a,m[1]=r[1]+s[1]*a+i[1]*a,m[2]=r[2]+s[2]*a+i[2]*a,p[0]=r[0]+s[0]*a-i[0]*a,p[1]=r[1]+s[1]*a-i[1]*a,p[2]=r[2]+s[2]*a-i[2]*a,t.push([n[0],n[1],n[2]]),t.push([l[0],l[1],l[2]]),t.push([m[0],m[1],m[2]]),t.push([p[0],p[1],p[2]]),t.push([n[0],n[1],n[2]]),this.geometry=[t]}setGeometryFromSegment(t){const r=t.endRenderSpace;this.transform=e(f,r);const{points:s}=t.createRenderGeometry(r,this.view.renderCoordsHelper);this.geometry=[s]}setGeometryFromSegments(t,r=i){this.transform=e(f,r),this.geometry=t.map(e=>e.createRenderGeometry(r,this.view.renderCoordsHelper).points)}getTransformedGeometry(){return null==this._geometry?null:this._geometry.map(e=>e.map(e=>s(o(),e,this.transform)))}get renderOccluded(){return this._material.parameters.renderOccluded}set renderOccluded(e){this._material.setParameters({renderOccluded:e})}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get width(){return this._material.parameters.width}set width(e){this._material.setParameters({width:e})}get color(){return this._material.parameters.color}set color(e){const t=1===e[3];this._material.setParameters({color:e,writeDepth:t})}get innerWidth(){return this._material.parameters.innerWidth}set innerWidth(e){this._material.setParameters({innerWidth:e})}get innerColor(){return this._material.parameters.innerColor}set innerColor(e){this._material.setParameters({innerColor:e})}get stipplePattern(){const{stipplePattern:e}=this._material.parameters;return p(e)?null:e}set stipplePattern(e){null!=this._material&&this._material.setParameters({stipplePattern:e})}get stippleOffColor(){return this._material.parameters.stippleOffColor}set stippleOffColor(e){this._material.setParameters({stippleOffColor:e})}get stipplePreferContinuous(){return this._material.parameters.stipplePreferContinuous}set stipplePreferContinuous(e){this._material.setParameters({stipplePreferContinuous:e})}get falloff(){return this._material.parameters.falloff}set falloff(e){this._material.setParameters({falloff:e})}get polygonOffset(){return this._material.parameters.hasPolygonOffset}set polygonOffset(e){this._material.setParameters({hasPolygonOffset:e})}createExternalResources(){}destroyExternalResources(){}createGeometries(e){for(const t of l(this.geometry)){const r=m(this._material,t);e.addGeometry(r)}}forEachMaterial(e){this._hasExternalMaterial||e(this._material)}}const f=t();export{d as LineVisualElement};
5
+ import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as r,p as s}from"../../../../chunks/vec32.js";import{create as i,ZEROS as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as n}from"./Object3DVisualElement.js";import{lineStripsToParameters as l,createGeometry as m}from"../../support/engineContent/line.js";import{isImagePattern as p}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as h}from"../../webgl-engine/materials/RibbonLineMaterial.js";class d extends n{constructor(e,t){super(e),this._hasExternalMaterial=!1,this._hasExternalMaterial=null!=t,this._material=t??new h({width:1,color:a(1,0,1,1),stipplePreferContinuous:!0,isClosed:!1,falloff:0,innerWidth:1,hasPolygonOffset:!1,renderOccluded:4,isDecoration:!!e.isDecoration,writeDepth:!0},e.view.state.isGlobal),this.applyProperties(e)}setGeometryFromPoint(e,t=1e3){const r=i();this.view.renderCoordsHelper.toRenderCoords(e,r)&&this.setGeometryFromRenderSpacePoint(r,t)}setGeometryFromRenderSpacePoint(e,t=1e3){this.geometry=[[[e[0]-t,e[1],e[2]],[e[0]+t,e[1],e[2]]],[[e[0],e[1]-t,e[2]],[e[0],e[1]+t,e[2]]],[[e[0],e[1],e[2]-t],[e[0],e[1],e[2]+t]]]}setGeometryFromExtent(e){const t=this.view.spatialReference,s=i(),o=i(),a=100,n=[];r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[2],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[2],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[3],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),r(s,e[0],e[1],a),this.view.renderCoordsHelper.toRenderCoords(s,t,o),n.push([o[0],o[1],o[2]]),this.geometry=[n]}setGeometryFromFrustum(e){const t=[];e.lines.forEach(e=>{t.push([e.origin[0],e.origin[1],e.origin[2]]),t.push([e.endpoint[0],e.endpoint[1],e.endpoint[2]])}),this.geometry=[t]}setGeometryFromBoundedPlane(e){const t=[],r=e.origin,s=e.basis1,o=e.basis2,a=.5,n=i(),l=i(),m=i(),p=i();n[0]=r[0]-s[0]*a-o[0]*a,n[1]=r[1]-s[1]*a-o[1]*a,n[2]=r[2]-s[2]*a-o[2]*a,l[0]=r[0]-s[0]*a+o[0]*a,l[1]=r[1]-s[1]*a+o[1]*a,l[2]=r[2]-s[2]*a+o[2]*a,m[0]=r[0]+s[0]*a+o[0]*a,m[1]=r[1]+s[1]*a+o[1]*a,m[2]=r[2]+s[2]*a+o[2]*a,p[0]=r[0]+s[0]*a-o[0]*a,p[1]=r[1]+s[1]*a-o[1]*a,p[2]=r[2]+s[2]*a-o[2]*a,t.push([n[0],n[1],n[2]]),t.push([l[0],l[1],l[2]]),t.push([m[0],m[1],m[2]]),t.push([p[0],p[1],p[2]]),t.push([n[0],n[1],n[2]]),this.geometry=[t]}setGeometryFromSegment(t){if(!t.visible)return void(this.geometry=null);const r=t.endRenderSpace;this.transform=e(f,r);const{points:s}=t.createRenderGeometry(r,this.view.renderCoordsHelper);this.geometry=[s]}setGeometryFromSegments(t,r=o){this.transform=e(f,r),this.geometry=t.filter(({visible:e})=>e).map(e=>e.createRenderGeometry(r,this.view.renderCoordsHelper).points)}getTransformedGeometry(){return null==this._geometry?null:this._geometry.map(e=>e.map(e=>s(i(),e,this.transform)))}get renderOccluded(){return this._material.parameters.renderOccluded}set renderOccluded(e){this._material.setParameters({renderOccluded:e})}get tansparentRenderOrder(){return this._material.parameters.testsTransparentRenderOrder}set tansparentRenderOrder(e){this._material.setParameters({testsTransparentRenderOrder:e})}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get width(){return this._material.parameters.width}set width(e){this._material.setParameters({width:e})}get color(){return this._material.parameters.color}set color(e){const t=1===e[3];this._material.setParameters({color:e,writeDepth:t})}get innerWidth(){return this._material.parameters.innerWidth}set innerWidth(e){this._material.setParameters({innerWidth:e})}get innerColor(){return this._material.parameters.innerColor}set innerColor(e){this._material.setParameters({innerColor:e})}get stipplePattern(){const{stipplePattern:e}=this._material.parameters;return p(e)?null:e}set stipplePattern(e){null!=this._material&&this._material.setParameters({stipplePattern:e})}get stippleOffColor(){return this._material.parameters.stippleOffColor}set stippleOffColor(e){this._material.setParameters({stippleOffColor:e})}get stipplePreferContinuous(){return this._material.parameters.stipplePreferContinuous}set stipplePreferContinuous(e){this._material.setParameters({stipplePreferContinuous:e})}get falloff(){return this._material.parameters.falloff}set falloff(e){this._material.setParameters({falloff:e})}get polygonOffset(){return this._material.parameters.hasPolygonOffset}set polygonOffset(e){this._material.setParameters({hasPolygonOffset:e})}createExternalResources(){}destroyExternalResources(){}createGeometries(e){for(const t of l(this.geometry)){const r=m(this._material,t);e.addGeometry(r)}}forEachMaterial(e){this._hasExternalMaterial||e(this._material)}}const f=t();export{d as LineVisualElement};
@@ -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{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{copy as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as o}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as s,f as c}from"../../../../chunks/vec42.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as l}from"./Object3DVisualElement.js";import{Attribute as h}from"../../webgl-engine/lib/Attribute.js";import{Geometry as n}from"../../webgl-engine/lib/Geometry.js";import{CheckerBoardMaterial as d}from"../../webgl-engine/materials/CheckerBoardMaterial.js";class m extends l{constructor(e){super(e),this._checkerBoardMaterial=null,this._renderOccluded=4,this._geometry=null,this._size=t(1,1),this._color1=a(1,.5,0,.5),this._color2=a(1,1,1,.5),this.applyProperties(e)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get size(){return this._size}set size(e){r(this._size,e),this._updateMaterial()}get color1(){return this._color1}set color1(e){s(e,this._color1)||(c(this._color1,e),this._updateMaterial())}get color2(){return this._color2}set color2(e){s(e,this._color2)||(c(this._color2,e),this._updateMaterial())}_updateMaterial(){this._checkerBoardMaterial?.setParameters({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded})}createExternalResources(){this._checkerBoardMaterial=new d({size:this._size,color1:this._color1,color2:this._color2,writeDepth:!1,polygonOffset:!0,renderOccluded:4,isDecoration:this.isDecoration})}destroyExternalResources(){this._checkerBoardMaterial=null}forEachMaterial(e){e(this._checkerBoardMaterial)}createGeometries(r){if(null==this._geometry||null==this._checkerBoardMaterial)return;const t=_;e(t,this.transform);const s=this._geometry,c=[],a=i();s.position.forEach(e=>{o(a,e,t),c.push(a[0],a[1],a[2])});const l=[];s.uv.forEach(e=>{l.push(e[0],e[1])});const d=new n(this._checkerBoardMaterial,[["position",new h(c,s.triangleIndices,3,!0)],["uv0",new h(l,s.triangleIndices,2,!0)]]);r.addGeometry(d)}}const _=i();export{m as MeasurementAreaVisualElement};
5
+ import{getTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{copy as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as s}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as o,f as a}from"../../../../chunks/vec42.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Object3DVisualElement as n}from"./Object3DVisualElement.js";import{Attribute as l}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{CheckerBoardMaterial as h}from"../../webgl-engine/materials/CheckerBoardMaterial.js";class _ extends n{constructor(e){super(e),this._checkerBoardMaterial=null,this._renderOccluded=4,this._transparentRenderOrder=0,this._geometry=null,this._size=t(1,1),this._color1=c(1,.5,0,.5),this._color2=c(1,1,1,.5),this.applyProperties(e)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._updateMaterial())}get testsTransparentRenderOrder(){return this._transparentRenderOrder}set testsTransparentRenderOrder(e){e!==this._transparentRenderOrder&&(this._transparentRenderOrder=e,this._updateMaterial())}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this.recreateGeometry()}get size(){return this._size}set size(e){r(this._size,e),this._updateMaterial()}get color1(){return this._color1}set color1(e){o(e,this._color1)||(a(this._color1,e),this._updateMaterial())}get color2(){return this._color2}set color2(e){o(e,this._color2)||(a(this._color2,e),this._updateMaterial())}_updateMaterial(){this._checkerBoardMaterial?.setParameters({size:this._size,color1:this._color1,color2:this._color2,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder})}createExternalResources(){this._checkerBoardMaterial=new h({size:this._size,color1:this._color1,color2:this._color2,writeDepth:!1,polygonOffset:!0,renderOccluded:this._renderOccluded,testsTransparentRenderOrder:this._transparentRenderOrder,isDecoration:this.isDecoration})}destroyExternalResources(){this._checkerBoardMaterial=null}forEachMaterial(e){e(this._checkerBoardMaterial)}createGeometries(r){if(null==this._geometry||null==this._checkerBoardMaterial)return;const t=m;e(t,this.transform);const o=this._geometry,a=[],c=i();o.position.forEach(e=>{s(c,e,t),a.push(c[0],c[1],c[2])});const n=[];o.uv.forEach(e=>{n.push(e[0],e[1])});const h=new d(this._checkerBoardMaterial,[["position",new l(a,o.triangleIndices,3,!0)],["uv0",new l(n,o.triangleIndices,2,!0)]]);r.addGeometry(h)}}const m=i();export{_ as MeasurementAreaVisualElement};
@@ -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{d as t,i as e,e as s,n as r,l as i,j as o}from"../../../../../chunks/vec32.js";import{create as n,clone as p}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as c}from"../../../../../geometry/projectionUtils.js";import{getSphericalPCPF as a}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectVectorToVector as h}from"../../../../../geometry/projection/projectVectorToVector.js";import{sv3d as d}from"../../../../../geometry/support/vectorStacks.js";import{slerpTangent as l,slerp as f}from"../../../support/mathUtils.js";class m{constructor(t=n(),e=n()){this.startRenderSpace=t,this.endRenderSpace=e,this.type="euclidean"}eval(t,e,o){return i(e,this.startRenderSpace,this.endRenderSpace,t),o&&(s(o,this.endRenderSpace,this.startRenderSpace),r(o,o)),e}createRenderGeometry(t,e){const r=[],i=[],o=(e,o)=>{const n=j;s(n,e,t),r.push([n[0],n[1],n[2]]),i.push([o[0],o[1],o[2]])},n=e.worldUpAtPosition(this.eval(.5,R),d.get());return o(this.startRenderSpace,n),o(this.endRenderSpace,n),{points:r,normals:i}}static fromPositionAndVector(t,s,r=1){return o(R,s,r),e(R,t,R),new m(p(t),p(R))}}class _{_projectIn(e,s){this._project?h(e,this.renderSpatialReference,s,this._pcpf):t(s,e)}constructor(t,e,s){this.startRenderSpace=t,this.endRenderSpace=e,this.renderSpatialReference=s,this.type="geodesic",this._start=n(),this._end=n(),this._pcpf=a(s),this._project=c(s,this._pcpf),this._projectIn(t,this._start),this._projectIn(e,this._end)}eval(t,o,n){if(this._project)if(n){const i=j;l(this._start,this._end,t,o,i),e(S,o,i),h(o,this._pcpf,o,this.renderSpatialReference),h(S,this._pcpf,S,this.renderSpatialReference),s(n,S,o),r(n,n)}else f(this._start,this._end,t,o),h(o,this._pcpf,o,this.renderSpatialReference);else i(o,this._start,this._end,t),n&&(s(n,this._end,this._start),r(n,n));return o}createRenderGeometry(t,e){const r=[],i=[],o=(e,o)=>{const n=S;s(n,e,t),r.push([n[0],n[1],n[2]]),i.push([o[0],o[1],o[2]])},n=128+1&-2;for(let s=0;s<n;++s){const t=s/(n-1),r=R,i=j;this.eval(t,r),e.worldUpAtPosition(r,i),o(r,i)}return{points:r,normals:i}}}const R=n(),j=n(),S=n();export{m as EuclideanSegment,_ as GeodesicSegment};
5
+ import{d as t,i as e,e as s,n as r,l as i,j as o}from"../../../../../chunks/vec32.js";import{create as n,clone as p}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{canProjectWithoutEngine as c}from"../../../../../geometry/projectionUtils.js";import{getSphericalPCPF as a}from"../../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectVectorToVector as h}from"../../../../../geometry/projection/projectVectorToVector.js";import{sv3d as d}from"../../../../../geometry/support/vectorStacks.js";import{slerpTangent as l,slerp as f}from"../../../support/mathUtils.js";class m{constructor(t=n(),e=n(),s=!0){this.startRenderSpace=t,this.endRenderSpace=e,this.visible=s,this.type="euclidean"}eval(t,e,o){return i(e,this.startRenderSpace,this.endRenderSpace,t),o&&(s(o,this.endRenderSpace,this.startRenderSpace),r(o,o)),e}createRenderGeometry(t,e){const r=[],i=[],o=(e,o)=>{const n=j;s(n,e,t),r.push([n[0],n[1],n[2]]),i.push([o[0],o[1],o[2]])},n=e.worldUpAtPosition(this.eval(.5,R),d.get());return o(this.startRenderSpace,n),o(this.endRenderSpace,n),{points:r,normals:i}}static fromPositionAndVector(t,s,r=1){return o(R,s,r),e(R,t,R),new m(p(t),p(R))}}class _{_projectIn(e,s){this._project?h(e,this.renderSpatialReference,s,this._pcpf):t(s,e)}constructor(t,e,s,r=!0){this.startRenderSpace=t,this.endRenderSpace=e,this.renderSpatialReference=s,this.visible=r,this.type="geodesic",this._start=n(),this._end=n(),this._pcpf=a(s),this._project=c(s,this._pcpf),this._projectIn(t,this._start),this._projectIn(e,this._end)}eval(t,o,n){if(this._project)if(n){const i=j;l(this._start,this._end,t,o,i),e(S,o,i),h(o,this._pcpf,o,this.renderSpatialReference),h(S,this._pcpf,S,this.renderSpatialReference),s(n,S,o),r(n,n)}else f(this._start,this._end,t,o),h(o,this._pcpf,o,this.renderSpatialReference);else i(o,this._start,this._end,t),n&&(s(n,this._end,this._start),r(n,n));return o}createRenderGeometry(t,e){const r=[],i=[],o=(e,o)=>{const n=S;s(n,e,t),r.push([n[0],n[1],n[2]]),i.push([o[0],o[1],o[2]])},n=128+1&-2;for(let s=0;s<n;++s){const t=s/(n-1),r=R,i=j;this.eval(t,r),e.worldUpAtPosition(r,i),o(r,i)}return{points:r,normals:i}}}const R=n(),j=n(),S=n();export{m as EuclideanSegment,_ as GeodesicSegment};
@@ -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 s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,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 b}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b as y,t as _,h as v}from"../../../chunks/vec32.js";import{freeze as w,create as j,fromValues as x,clone as C}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as O,clone as M,fromValues as E}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as T,getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as U}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as V}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as H}from"../../../geometry/projection/projectVectorToVector.js";import{create as S}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as A}from"../../../geometry/support/Indices.js";import{BufferViewVec2f as L,BufferViewVec4f as P,BufferViewVec4u8 as k,BufferViewVec4u16 as I,BufferViewVec3f as F,BufferViewVec3u8 as D,BufferViewVec3u16 as B,BufferViewInt16 as G,BufferViewUint32 as N,BufferViewUint16 as z}from"../../../geometry/support/buffer/BufferView.js";import W from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as q}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as J,removeLayerViewFromWasm as X,getLyr3DWasm as Y}from"./Lyr3DWasm.js";import{toWasmModification as K}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as Q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ee,alphaModeConversion as te,faceCullingConversion as ie,wrapModeConversion as se,lyr3DTypeToByteSize as re}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as oe}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as ne}from"../state/Frustum.js";import{ElevationRange as ae}from"../support/ElevationRange.js";import{toBoundingRect as le}from"../support/extentUtils.js";import{compute as de,Obb as ce}from"../support/orientedBoundingBox.js";import{glLayout as he}from"../support/buffer/glUtil.js";import{GeometryParameters as ue,createVertexBufferLayout as me,ComponentGeometryParameters as pe,SourceGeometry as fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as be}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ge}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as ye}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as _e}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ve}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as we}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as je,writeBufferVec2 as xe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ce from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Oe,isInEffectiveScaleRange as Me,validateScaleRange as Ee}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Te}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Re}from"../../../webscene/support/AlphaCutoff.js";class Ue{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=j();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ve(e){return Math.round(e/1048.576)/1e3}let He=class extends(q(Ce)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Te,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,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._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new ne(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Oe("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=J(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new oe(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._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new Q({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)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),X(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=K(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=S();this._layerClippingArea=le(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,$(e))}get _wasm(){return Y(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Me(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ee(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new Z(this.usedMemory,r,o,Ve(t),Ve(e),Ve(s),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 $(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ae(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ae;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange)));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}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)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=w(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r,o;if("global"===this.view.viewingMode){const e=f();U(T,i,e,s),r=h(m(),e),o=u(m(),r)}else r=p,o=p;const n=j(),a=Pe(t.desc.obb);let l=0;const d={textureMemoryUsage:0},c=new Array,b=new Map,S=t.desc.prims.length,A=new Array,P=new ae;try{const e="global"===this.view.viewingMode,h=e?R(this.view.spatialReference).radius:0;for(let u=0;u<S;u++){const m=t.desc.prims[u];this._dbg(2,JSON.stringify(m));if(null==ee[m.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const f=t.desc?.materials&&null!=m.materialId?t.desc.materials[m.materialId]:null,w=null!=f?f.lightingModel:"Unlit",{positionView:T,positionAttr:R,normalsView:U,normalsAttr:S,colorAttr:A,texCoord0Attr:k,indicesView:I}=this.getBufferViews(m,t.data.buffer,r);if(null==R||null==T||null==I)continue;const F=T.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(k,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const B=new ue(null!=A,k?1:0,null!=U,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),G=me(B);for(let t=0;t<T.count;t++){T.getVec(t,n),g(n,n,i);const s=e?y(n)-h:n[2];P.expandElevationRangeValues(s,s)}const N=a?.clone()??Le(R,i);if(r!==p)for(let e=0;e<T.count;e++)T.getVec(e,n),_(n,n,r),T.setVec(e,n);const z=G.createBuffer(F);if(je("position",R,null,null,z,0),null!=k){const e=z.getField("uv0",L);xe(k,e,0)}null!=A&&je("color",A,null,null,z,0),null!=S&&je("normalCompressed",S,null,null,z,0);const W=new Uint32Array([0,I.typedBuffer.length]),$=new pe(he(G),B.shadeNormals,B.applySSAO,B.textureCoordinateType),q=new fe({data:z.buffer,count:z.byteLength/G.stride},{positions:T.typedBuffer,indices:I.typedBuffer},I.typedBuffer,W,$),Z=this.view.renderSpatialReference,J=j(),X=[1,1,1];V(i,Z,X,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),H(i,Z,J,s);let Y=Promise.resolve(Ie),K=O,Q=Re,se=null,re=null,oe=null,ne=null,ae=null,le=1,de=!1,ce=2,ge=!1,ye=x(0,0,0);const _e=C(we),ve="Pbr"===w;if(f){const e=e=>this._getTexture(e,t,b,d);se=e(f.baseColorTex),ae=ve?e(f.metalTex):null,re=ve?e(f.emissiveTex):null,ne=ve?e(f.occlusionTex):null,oe=ve?e(f.normalTex):null;const i=[se,ae,re,ne,oe].map(e=>e?.loadPromise??null);Y=Promise.all(i),K=M(f.baseColorFactor),Q=f.alphaCutoff??Re,ve&&(v(_e,f.metallicFactor,f.roughnessFactor,0),f.emissiveFactor&&(ye=f.emissiveFactor)),le=te[f.alphaMode],de=f.isDoubleSided,ce=ie[f.faceCulling??"NotSet"],ge=this.layer.replacesTerrain}const Ce=Y.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)}se||console.error("No colour texture 1");const e=this._collection.createObject({toMapSpace:E(J[0],J[1],X[0],X[1]),transform:new be(i,o),obb:N,geometry:q,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:K,textureAlphaCutoff:Q,mrrFactors:_e,baseColorTexture:se,metallicRoughnessTexture:ae,normalTexture:oe,occlusionTexture:ne,emissionTexture:re,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:le,doubleSided:de,cullFace:ce,isGround:ge,emissiveBaseColor:ye,usePBR:ve,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1});return d.textureMemoryUsage+=se?.texture?.usedMemory??0,ve&&(d.textureMemoryUsage+=(ae?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(ne?.texture?.usedMemory??0)+(oe?.texture?.usedMemory??0)),l+=this._collection.getObjectGPUMemoryUsage(e),e});c.push(Ce)}if(A.push(...await Promise.all(c)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(N){throw b.forEach(e=>this._stage.removeTexture(e)),N}const k=A.map(e=>e()),I=new Array;b.forEach(e=>I.push(e));const{fullExtent:F}=this.layer;F?.hasZ&&F.zmax&&F.zmin&&(P.minElevation=Math.max(P.minElevation,F.zmin),P.maxElevation=Math.min(P.maxElevation,F.zmax));const D=k.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),B=new Ue(e.handle,k,I,D,l,d.textureMemoryUsage,a,e.stableNodeId,e.nodeDepth,P);this._lyrHandleToObjects.set(e.handle,B),this._memCache.put(ke(B.handle),B);const{usedMemory:G}=B;return this._cacheMemory+=G,{memUsageBytes:G}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=ke(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(ke(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(ke(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new ge(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=se[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new _e(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/re[m.type],g=A(b);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new F(t,m.byteOffset,p,f),r=new ye(s.typedBuffer,g,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new F(t,m.byteOffset,p,f),s=ve(e.typedBuffer,i);a=new G(s.buffer),l=new ye(a.typedBuffer,g,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new ye(new L(t,m.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new P(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new k(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new I(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(c=new F(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new D(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new B(t,m.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new ye(c.typedBuffer,g,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new z(t,i.byteOffset,s,r);break;case"U32":d=new N(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new z(new Uint16Array(e).buffer):new N(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],He.prototype,"fullOpacity",null),e([d({readOnly:!0})],He.prototype,"ready",null),e([d({type:[W]})],He.prototype,"_modifications",void 0),e([d()],He.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],He.prototype,"layer",void 0),e([d({readOnly:!0})],He.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],He.prototype,"_collection",null),e([d()],He.prototype,"elevationOffset",null),e([d({readOnly:!0})],He.prototype,"visibleElevationRange",null),He=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],He);const Se=He,Ae=j();function Le(e,t){const i=de(e);return g(Ae,i.center,t),i.center=Ae,i}function Pe(e){return e?new ce(e.center,e.halfSize,b(...e.quaternion)):null}function ke(e){return`${e}`}const Ie=new Array;export{Se 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 s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,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 b}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b as y,t as _,h as v}from"../../../chunks/vec32.js";import{freeze as w,create as j,fromValues as x,clone as C}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as O,clone as M,fromValues as E}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as T,getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as U}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as V}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as H}from"../../../geometry/projection/projectVectorToVector.js";import{create as S}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as A}from"../../../geometry/support/Indices.js";import{BufferViewVec2f as L,BufferViewVec4f as P,BufferViewVec4u8 as k,BufferViewVec4u16 as I,BufferViewVec3f as F,BufferViewVec3u8 as D,BufferViewVec3u16 as B,BufferViewInt16 as G,BufferViewUint32 as N,BufferViewUint16 as z}from"../../../geometry/support/buffer/BufferView.js";import W from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as q}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as Z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as J,removeLayerViewFromWasm as X,getLyr3DWasm as Y}from"./Lyr3DWasm.js";import{toWasmModification as K}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as Q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ee,alphaModeConversion as te,faceCullingConversion as ie,wrapModeConversion as se,lyr3DTypeToByteSize as re}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as oe}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as ne}from"../state/Frustum.js";import{ElevationRange as ae}from"../support/ElevationRange.js";import{toBoundingRect as le}from"../support/extentUtils.js";import{compute as de,Obb as ce}from"../support/orientedBoundingBox.js";import{glLayout as he}from"../support/buffer/glUtil.js";import{GeometryParameters as ue,createVertexBufferLayout as me,ComponentGeometryParameters as pe,SourceGeometry as fe}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as be}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ge}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as ye}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as _e}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ve}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as we}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as je,writeBufferVec2 as xe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ce from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Oe,isInEffectiveScaleRange as Me,validateScaleRange as Ee}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Te}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Re}from"../../../webscene/support/AlphaCutoff.js";class Ue{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=j();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ve(e){return Math.round(e/1048.576)/1e3}let He=class extends(q(Ce)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Te,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,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._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new ne(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Oe("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=J(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new oe(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._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new Q({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)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),X(this),this.layer.queryElevationCallback=null,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._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=K(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=S();this._layerClippingArea=le(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,$(e))}get _wasm(){return Y(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Me(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ee(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new Z(this.usedMemory,r,o,Ve(t),Ve(e),Ve(s),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 $(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ae(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ae;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange)));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}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)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=w(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r,o;if("global"===this.view.viewingMode){const e=f();U(T,i,e,s),r=h(m(),e),o=u(m(),r)}else r=p,o=p;const n=j(),a=Pe(t.desc.obb);let l=0;const d={textureMemoryUsage:0},c=new Array,b=new Map,S=t.desc.prims.length,A=new Array,P=new ae;try{const e="global"===this.view.viewingMode,h=e?R(this.view.spatialReference).radius:0;for(let u=0;u<S;u++){const m=t.desc.prims[u];this._dbg(2,JSON.stringify(m));if(null==ee[m.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const f=t.desc?.materials&&null!=m.materialId?t.desc.materials[m.materialId]:null,w=null!=f?f.lightingModel:"Unlit",{positionView:T,positionAttr:R,normalsView:U,normalsAttr:S,colorAttr:A,texCoord0Attr:k,indicesView:I}=this.getBufferViews(m,t.data.buffer,r);if(null==R||null==T||null==I)continue;const F=T.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(k,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const B=new ue(null!=A,k?1:0,null!=U,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),G=me(B);for(let t=0;t<T.count;t++){T.getVec(t,n),g(n,n,i);const s=e?y(n)-h:n[2];P.expandElevationRangeValues(s,s)}const N=a?.clone()??Le(R,i);if(r!==p)for(let e=0;e<T.count;e++)T.getVec(e,n),_(n,n,r),T.setVec(e,n);const z=G.createBuffer(F);if(je("position",R,null,null,z,0),null!=k){const e=z.getField("uv0",L);xe(k,e,0)}null!=A&&je("color",A,null,null,z,0),null!=S&&je("normalCompressed",S,null,null,z,0);const W=new Uint32Array([0,I.typedBuffer.length]),$=new pe(he(G),B.shadeNormals,B.applySSAO,B.textureCoordinateType),q=new fe({data:z.buffer,count:z.byteLength/G.stride},{positions:T.typedBuffer,indices:I.typedBuffer},I.typedBuffer,W,$),Z=this.view.renderSpatialReference,J=j(),X=[1,1,1];V(i,Z,X,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),H(i,Z,J,s);let Y=Promise.resolve(Ie),K=O,Q=Re,se=null,re=null,oe=null,ne=null,ae=null,le=1,de=!1,ce=2,ge=!1,ye=x(0,0,0);const _e=C(we),ve="Pbr"===w;if(f){const e=e=>this._getTexture(e,t,b,d);se=e(f.baseColorTex),ae=ve?e(f.metalTex):null,re=ve?e(f.emissiveTex):null,ne=ve?e(f.occlusionTex):null,oe=ve?e(f.normalTex):null;const i=[se,ae,re,ne,oe].map(e=>e?.loadPromise??null);Y=Promise.all(i),K=M(f.baseColorFactor),Q=f.alphaCutoff??Re,ve&&(v(_e,f.metallicFactor,f.roughnessFactor,0),f.emissiveFactor&&(ye=f.emissiveFactor)),le=te[f.alphaMode],de=f.isDoubleSided,ce=ie[f.faceCulling??"NotSet"],ge=this.layer.replacesTerrain}const Ce=Y.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)}se||console.error("No colour texture 1");const e=this._collection.createObject({toMapSpace:E(J[0],J[1],X[0],X[1]),transform:new be(i,o),obb:N,geometry:q,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:K,textureAlphaCutoff:Q,mrrFactors:_e,baseColorTexture:se,metallicRoughnessTexture:ae,normalTexture:oe,occlusionTexture:ne,emissionTexture:re,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:le,doubleSided:de,cullFace:ce,isGround:ge,emissiveBaseColor:ye,usePBR:ve,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1});return d.textureMemoryUsage+=se?.texture?.usedMemory??0,ve&&(d.textureMemoryUsage+=(ae?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(ne?.texture?.usedMemory??0)+(oe?.texture?.usedMemory??0)),l+=this._collection.getObjectGPUMemoryUsage(e),e});c.push(Ce)}if(A.push(...await Promise.all(c)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(N){throw b.forEach(e=>this._stage.removeTexture(e)),N}const k=A.map(e=>e()),I=new Array;b.forEach(e=>I.push(e));const{fullExtent:F}=this.layer;F?.hasZ&&F.zmax&&F.zmin&&(P.minElevation=Math.max(P.minElevation,F.zmin),P.maxElevation=Math.min(P.maxElevation,F.zmax));const D=k.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),B=new Ue(e.handle,k,I,D,l,d.textureMemoryUsage,a,e.stableNodeId,e.nodeDepth,P);this._lyrHandleToObjects.set(e.handle,B),this._memCache.put(ke(B.handle),B);const{usedMemory:G}=B;return this._cacheMemory+=G,{memUsageBytes:G}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=ke(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(ke(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(ke(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new ge(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=se[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new _e(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/re[m.type],g=A(b);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new F(t,m.byteOffset,p,f),r=new ye(s.typedBuffer,g,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new F(t,m.byteOffset,p,f),s=ve(e.typedBuffer,i);a=new G(s.buffer),l=new ye(a.typedBuffer,g,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new ye(new L(t,m.byteOffset,p,f).typedBuffer,g,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new P(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new k(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new I(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(c=new F(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new D(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new B(t,m.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new ye(c.typedBuffer,g,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new z(t,i.byteOffset,s,r);break;case"U32":d=new N(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new z(new Uint16Array(e).buffer):new N(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],He.prototype,"fullOpacity",null),e([d({readOnly:!0})],He.prototype,"ready",null),e([d({type:[W]})],He.prototype,"_modifications",void 0),e([d()],He.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],He.prototype,"layer",void 0),e([d({readOnly:!0})],He.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],He.prototype,"_collection",null),e([d()],He.prototype,"elevationOffset",null),e([d({readOnly:!0})],He.prototype,"visibleElevationRange",null),He=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],He);const Se=He,Ae=j();function Le(e,t){const i=de(e);return g(Ae,i.center,t),i.center=Ae,i}function Pe(e){return e?new ce(e.center,e.halfSize,b(...e.quaternion)):null}function ke(e){return`${e}`}const Ie=new Array;export{Se 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{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import r from"../../../../core/Logger.js";import{property as i,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{fromQuat as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as a,p as l}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as p}from"../../../../geometry/projection/projectBoundingSphere.js";import{empty as m,expand as u}from"../../../../geometry/support/aaBoundingRect.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{ElevationRange as v}from"../../support/ElevationRange.js";import{ElevationUpdateEventImplementation as f}from"../../terrain/ElevationUpdateEvent.js";import{Intersector as d}from"../../webgl-engine/lib/Intersector.js";let E=class extends t{constructor(e){super(e),this._tmpEvent=new f,this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource}initialize(){this._intersector=new d(this.view.state.viewingMode),this._intersector.options.store=0,this._intersector.options.normalRequired=!1,this._tmpEvent.context=this.intersectionHandler.isGround?"ground":"scene"}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,i,n){const o=this._renderCoordsHelper,s=a(x,e,t,i);if(!o.toRenderCoords(s,n,s))return r.getLogger(this).error("could not project point to compute elevation"),null;const{layerElevationSource:l,_intersector:c,intersectionHandler:p}=this,m=l.fullExtent,u=null!=m&&Number.isFinite(m.xmin)&&Number.isFinite(m.xmax)&&Number.isFinite(m.ymin)&&Number.isFinite(m.ymax)&&Number.isFinite(m.zmin)&&Number.isFinite(m.zmax)?new v(m.zmin,m.zmax):l.elevationRange;if(null==u)return null;const h=l.elevationOffset,f=u.minElevation+h,d=u.maxElevation+h,E=o.setAltitude(R,d,s),g=o.setAltitude(y,f,s);return c.reset(E,g,this.view.state.camera),p.intersect(c,null,E,g,null,!0),c.results.min.getIntersectionPoint(s)?o.getAltitude(s):null}getElevations(e,t,r){const{groundSpatialReference:i}=this.view;for(let n=0;n<t;++n){const t=3*n,o=e[t],s=e[t+1];r(n,this.getElevation(o,s,0,i))}}getSphereElevationRange(e,t){return p(e,t,_,this._renderSR),this._layerElevationSource.getElevationRange(_)}getRootElevationRange(){const e=this.layerElevationSource.fullExtent;return e?.hasZ?new v(e.zmin,e.zmax):null}notifyObjectsChanged(e){this.spatialReference&&(this._computeLayerExtent(t=>{for(const r of e)t(r)},this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}notifyObjectsChangedFunctional(e){this.spatialReference&&(this._computeLayerExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}notifyObjectChanged(e){this.spatialReference&&(this._computeObjectExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}_computeObjectExtent(e,t){m(t),this._expandExtent(e,t)}_computeLayerExtent(e,t){m(t),e(e=>{this._expandExtent(e,t)})}_expandExtent(e,t){const r=this.spatialReference;if(null==r)return;if(null==e)return;o(g,e.quaternion),g[12]=e.center[0],g[13]=e.center[1],g[14]=e.center[2];const i=e.halfSize;for(let n=0;n<8;++n)x[0]=1&n?i[0]:-i[0],x[1]=2&n?i[1]:-i[1],x[2]=4&n?i[2]:-i[2],l(x,x,g),this._renderCoordsHelper.fromRenderCoords(x,x,r),u(t,x,t)}};e([i({constructOnly:!0})],E.prototype,"layerElevationSource",void 0),e([i({constructOnly:!0})],E.prototype,"intersectionHandler",void 0),e([i({constructOnly:!0})],E.prototype,"view",void 0),e([i()],E.prototype,"spatialReference",null),E=e([n("esri.views.3d.layers.i3s.LayerElevationProvider")],E);const g=s(),_=new h,x=c(),R=c(),y=c();export{E as LayerElevationProvider};
5
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../../core/Evented.js";import r from"../../../../core/Logger.js";import{property as i,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{fromQuat as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as a,p as l}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as p}from"../../../../geometry/projection/projectBoundingSphere.js";import{empty as m,expand as u}from"../../../../geometry/support/aaBoundingRect.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{ElevationRange as f}from"../../support/ElevationRange.js";import{ElevationUpdateEventImplementation as v}from"../../terrain/ElevationUpdateEvent.js";import{Intersector as d}from"../../webgl-engine/lib/Intersector.js";let E=class extends t{constructor(e){super(e),this._tmpEvent=new v,this._renderCoordsHelper=e.view.renderCoordsHelper,this._renderSR=this._renderCoordsHelper.spatialReference,this._layerElevationSource=e.layerElevationSource}initialize(){this._intersector=new d(this.view.state.viewingMode),this._intersector.options.store=0,this._intersector.options.normalRequired=!1,this._tmpEvent.context=this.intersectionHandler.isGround?"ground":"scene"}get spatialReference(){return this.view?.elevationProvider?.spatialReference}getElevation(e,t,i,n){const o=this._renderCoordsHelper,s=a(x,e,t,i);if(!o.toRenderCoords(s,n,s))return r.getLogger(this).error("could not project point to compute elevation"),null;const{layerElevationSource:l,_intersector:c,intersectionHandler:p}=this,m=l.fullExtent,u=null!=m&&Number.isFinite(m.xmin)&&Number.isFinite(m.xmax)&&Number.isFinite(m.ymin)&&Number.isFinite(m.ymax)&&Number.isFinite(m.zmin)&&Number.isFinite(m.zmax)?new f(m.zmin,m.zmax):l.elevationRange;if(null==u)return null;const h=l.elevationOffset,v=u.minElevation+h,d=u.maxElevation+h,E=o.setAltitude(R,d,s),g=o.setAltitude(y,v,s);return c.reset(E,g,this.view.state.camera),p.intersect(c,null,E,g,null,!0),c.results.min.getIntersectionPoint(s)?o.getAltitude(s):null}getElevations(e,t,r){const{groundSpatialReference:i}=this.view;for(let n=0;n<t;++n){const t=3*n,o=e[t],s=e[t+1];r(n,this.getElevation(o,s,0,i))}}getSphereElevationRange(e,t){return p(e,t,_,this._renderSR),this._layerElevationSource.getElevationRange(_)}getRootElevationRange(){const e=this.layerElevationSource.fullExtent;return e?.hasZ?new f(e.zmin,e.zmax):null}notifyObjectsChanged(e){this.spatialReference&&(this._computeLayerExtent(t=>{for(const r of e)t(r)},this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}notifyObjectsChangedFunctional(e){this.spatialReference&&(this._computeLayerExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}notifyObjectChanged(e){this.spatialReference&&(this._computeObjectExtent(e,this._tmpEvent.extent),this._tmpEvent.spatialReference=this.spatialReference,this.emit("elevation-change",this._tmpEvent))}_computeObjectExtent(e,t){m(t),this._expandExtent(e,t)}_computeLayerExtent(e,t){m(t),e(e=>{this._expandExtent(e,t)})}_expandExtent(e,t){const r=this.spatialReference;if(null==r)return;if(null==e)return;o(g,e.quaternion),g[12]=e.center[0],g[13]=e.center[1],g[14]=e.center[2];const i=e.halfSize;for(let n=0;n<8;++n)x[0]=1&n?i[0]:-i[0],x[1]=2&n?i[1]:-i[1],x[2]=4&n?i[2]:-i[2],l(x,x,g),this._renderCoordsHelper.fromRenderCoords(x,x,r),u(t,x,t);for(let n=0;n<2;++n)x[0]=0,x[1]=0,x[2]=0===n?i[2]:-i[2],l(x,x,g),this._renderCoordsHelper.fromRenderCoords(x,x,r),u(t,x,t)}};e([i({constructOnly:!0})],E.prototype,"layerElevationSource",void 0),e([i({constructOnly:!0})],E.prototype,"intersectionHandler",void 0),e([i({constructOnly:!0})],E.prototype,"view",void 0),e([i()],E.prototype,"spatialReference",null),E=e([n("esri.views.3d.layers.i3s.LayerElevationProvider")],E);const g=s(),_=new h,x=c(),R=c(),y=c();export{E as LayerElevationProvider};
@@ -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 e from"../../../../core/Accessor.js";const r={required:[]},t={required:[1]};class s extends e{precompile(e){return!!this.acquireTechniques(e)}consumes(){return r}get usedMemory(){return 0}get renderOccludedFlags(){return 1}get isDecoration(){return!1}get readyToRun(){return!1}get numGeometries(){return 0}get hasOccludees(){return!1}get hasEmitters(){return!1}forEachGeometry(e){}}class n extends s{}class u extends s{}export{u as AsyncRenderPlugin,t as ConsumesDepth,r as ConsumesNone,n as SyncRenderPlugin};
5
+ import e from"../../../../core/Accessor.js";const r={required:[]},t={required:[1]};class s extends e{precompile(e){return!!this.acquireTechniques(e)}consumes(){return r}get usedMemory(){return 0}get renderOccludedFlags(){return 1}get testsTransparentRenderOrder(){return 0}get isDecoration(){return!1}get readyToRun(){return!1}get numGeometries(){return 0}get hasOccludees(){return!1}get hasEmitters(){return!1}forEachGeometry(e){}}class n extends s{}class u extends s{}export{u as AsyncRenderPlugin,t as ConsumesDepth,r as ConsumesNone,n as SyncRenderPlugin};
@@ -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{removeUnordered as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{isPromiseLike as t,createAbortError as r}from"../../../../core/promiseUtils.js";import{signal as s}from"../../../../core/signal.js";import{DepthRange as n}from"../lib/DepthRange.js";class i{constructor(e){this.context=e,this._renderPlugins=new Array,this._slots=new Array,this._version=s(0);for(let t=0;t<22;++t)this._slots[t]=[]}destroy(){this._renderPlugins.forEach(e=>e.destroy()),this._renderPlugins.length=0}get plugins(){return this._renderPlugins}add(e,s){const n=()=>{if(s?.aborted)throw e.uninitializeRenderContext(),r();this._renderPlugins.push(e),e.produces.forEach((t,r)=>this._slots[r].push(e)),this.context.requestRender(),this._version.value++},i=e.initializeRenderContext(this.context,s);if(t(i))return i.then(n);n()}remove(t){e(this._renderPlugins,t),t.uninitializeRenderContext();for(let e=0;e<this._slots.length;++e)this._slots[e]=this._slots[e].filter(e=>e!==t);this.context.requestRender(),this._version.value++}prepareRender(){this._renderPlugins.forEach(e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)})}updateAnimation(e){let t=!1;return this._renderPlugins.forEach(r=>t=r.updateAnimation?.(e)||t),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender(()=>{});this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(...e){for(const t of e)this.context.renderContext.bind.slot=t,this._forEachRender((e,t)=>e.render(this.context.renderContext,t))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach(s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const i=s.acquireTechniques(this.context.renderContext);i&&e(s,i)})}queryDepthRange(e){return this._renderPlugins.reduce((t,r)=>t.union(r.queryDepthRange?.(e)),new n)}get updating(){return this._version.value>=0&&this._renderPlugins.some(e=>e.readyToRun)}produces(e,...t){return t.some(t=>this._slots[t].some(r=>{const s=r.produces.get(t);return!!s&&s(e)}))}consumes(e){return this._renderPlugins.some(t=>t.consumes().required.includes(e))}hasHighlight(e){return o.some(t=>this._slots[t].some(t=>t.hasHighlight(e)))}get hasDecorations(){return this._renderPlugins.some(e=>e.isDecoration)}get hasOccludees(){return this._renderPlugins.some(e=>e.hasOccludees)}get hasEmitters(){return this._renderPlugins.some(e=>e.hasEmitters)}get renderOccludedFlags(){return this._renderPlugins.reduce((e,t)=>e|(t.renderOccludedFlags??0),0)}get usedMemory(){return this._renderPlugins.reduce((e,t)=>t.material?e:e+(t.usedMemory??0),0)}get test(){}}const o=[2,4,19,14,15];export{i as RenderPluginManager};
5
+ import{removeUnordered as e}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{isPromiseLike as t,createAbortError as r}from"../../../../core/promiseUtils.js";import{signal as s}from"../../../../core/signal.js";import{DepthRange as n}from"../lib/DepthRange.js";class i{constructor(e){this.context=e,this._renderPlugins=new Array,this._slots=new Array,this._version=s(0);for(let t=0;t<22;++t)this._slots[t]=[]}destroy(){this._renderPlugins.forEach(e=>e.destroy()),this._renderPlugins.length=0}get plugins(){return this._renderPlugins}add(e,s){const n=()=>{if(s?.aborted)throw e.uninitializeRenderContext(),r();this._renderPlugins.push(e),e.produces.forEach((t,r)=>this._slots[r].push(e)),this.context.requestRender(),this._version.value++},i=e.initializeRenderContext(this.context,s);if(t(i))return i.then(n);n()}remove(t){e(this._renderPlugins,t),t.uninitializeRenderContext();for(let e=0;e<this._slots.length;++e)this._slots[e]=this._slots[e].filter(e=>e!==t);this.context.requestRender(),this._version.value++}sortTestsTransparentOrderedSlots(e){}prepareRender(){this._renderPlugins.forEach(e=>{e.prepareRender&&e.prepareRender(this.context.renderContext)})}updateAnimation(e){let t=!1;return this._renderPlugins.forEach(r=>t=r.updateAnimation?.(e)||t),t}precompile(...e){++this.context.techniques.precompiling;const t=this.context.renderContext.bind.slot;for(const r of e)this.context.renderContext.bind.slot=r,this._forEachRender(()=>{});this.context.renderContext.bind.slot=t,--this.context.techniques.precompiling}render(...e){for(const t of e)this.context.renderContext.bind.slot=t,this._forEachRender((e,t)=>e.render(this.context.renderContext,t))}_forEachRender(e){const t=this.context.renderContext.bind.slot,r=this.context.renderContext.output;this._slots[t].forEach(s=>{const n=s.produces.get(t);if(!n?.(r)||s.isDecoration&&!this.context.renderContext.bind.decorations)return;const i=s.acquireTechniques(this.context.renderContext);i&&e(s,i)})}queryDepthRange(e){return this._renderPlugins.reduce((t,r)=>t.union(r.queryDepthRange?.(e)),new n)}get updating(){return this._version.value>=0&&this._renderPlugins.some(e=>e.readyToRun)}produces(e,...t){return t.some(t=>this._slots[t].some(r=>{const s=r.produces.get(t);return!!s&&s(e)}))}consumes(e){return this._renderPlugins.some(t=>t.consumes().required.includes(e))}hasHighlight(e){return o.some(t=>this._slots[t].some(t=>t.hasHighlight(e)))}get hasDecorations(){return this._renderPlugins.some(e=>e.isDecoration)}get hasOccludees(){return this._renderPlugins.some(e=>e.hasOccludees)}get hasEmitters(){return this._renderPlugins.some(e=>e.hasEmitters)}get renderOccludedFlags(){return this._renderPlugins.reduce((e,t)=>e|(t.renderOccludedFlags??0),0)}get usedMemory(){return this._renderPlugins.reduce((e,t)=>t.material?e:e+(t.usedMemory??0),0)}get test(){}}const o=[2,4,19,14,15];export{i as RenderPluginManager};
@@ -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"../../../../../core/PooledArray.js";import{property as r,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as o}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as n}from"../../../webgl.js";import i from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends i{constructor(e){super(e),this.consumes={required:[n.OCCLUDED]},this.produces=n.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(t=>{e.precompileSlots(t,10,12),t.material&&e.precompileOccludedSlots(t,h)})}render(e){const t=e.find(({name:e})=>e===this.produces);return this._renderOccludedAndTransparentStencil(t),this._renderOccludedComposite(t),t}_renderOccludedAndTransparentStencil(e){const t=this.view.stage.renderer,r=a;r.clear();for(const s of t.plugins.plugins)8&s.renderOccludedFlags&&r.push(s);0!==r.length&&(t.renderSlots(r,11),this._renderAndComposite(e,e.getAttachment(d),.5,()=>t.renderSlots(r,12),!1,!1),r.clear())}_renderOccludedComposite(e){const t=this.view.stage.renderer,r=a;r.clear();let s=0;for(const i of t.plugins.plugins){const e=i.renderOccludedFlags&u;s|=e,e&&r.push(i)}if(!s)return void r.clear();const o=this._getDepthStencilAttachment(e);let n=o.clearStencil;for(const i of h)s&i&&(this._renderAndComposite(e,o.depth,16===i?1:.5,()=>t.renderOccludedSlots(r,i),!0,n),n=!1);o.release(),r.clear()}_renderAndComposite(e,t,r,s,n,i){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(t),c.bindFramebuffer(a.fbo),c.clearFramebuffer(o,n,i),s(),a.detachDepth(),this._blit.blend(c,a,e,this.bindParameters,r),a.release()}_getDepthStencilAttachment(e){const{width:t,height:r}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(14,t,r,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(t,r,"retained stencil",14);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([r()],l.prototype,"consumes",void 0),e([r()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],l);const a=new t;function p(){a.prune()}const h=[4,2,16],u=h.reduce((e,t)=>e|t,0);export{l as RenderOccludedRenderNode,p as cleanupRenderOccluded};
5
+ import{__decorate as e}from"tslib";import r from"../../../../../core/PooledArray.js";import{property as t,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{Blit as c}from"../blit/Blit.js";import{DepthStencilAttachment as d}from"../../../../webgl/enums.js";let l=class extends o{constructor(e){super(e),this.consumes={required:[i.OCCLUDED]},this.produces=i.OCCLUDED,this._blit=new c(e.view.stage.renderView.techniques,2)}precompile(){const e=this.view.stage.renderer;e.plugins.plugins.forEach(r=>{e.precompileSlots(r,10,12),r.material&&e.precompileOccludedSlots(r,p)})}render(e){const r=e.find(({name:e})=>e===this.produces);return this._renderOccludedAndTransparentStencil(r),this._renderOccludedComposite(r),r}_renderOccludedAndTransparentStencil(e){const r=this.view.stage.renderer,t=a;this._acquirePlugins(t,8),0!==t.length&&(r.renderSlots(t,11),this._renderAndComposite(e,e.getAttachment(d),.5,()=>r.renderSlots(t,12),!1,!1),t.clear())}_renderOccludedComposite(e){const r=this.view.stage.renderer,t=a,s=this._acquirePlugins(t,u);if(0===t.length)return;const n=this._getDepthStencilAttachment(e);let i=n.clearStencil;for(const o of p)s&o&&(this._renderAndComposite(e,n.depth,16===o?1:.5,()=>r.renderOccludedSlots(t,o),!0,i),i=!1);n.release(),t.clear()}_acquirePlugins(e,r){const t=this.view.stage.renderer;e.clear();let s=0,n=!1;for(const i of t.plugins.plugins){const t=i.renderOccludedFlags&r;s|=t,t&&(e.push(i),n||=0!==i.testsTransparentRenderOrder)}return n&&e.sort((e,r)=>e.testsTransparentRenderOrder-r.testsTransparentRenderOrder),s}_renderAndComposite(e,r,t,s,i,o){const c=this.renderingContext,{width:d,height:l}=e.fbo,a=this.fboCache.acquire(d,l,"tmp color");a.attachDepth(r),c.bindFramebuffer(a.fbo),c.clearFramebuffer(n,i,o),s(),a.detachDepth(),this._blit.blend(c,a,e,this.bindParameters,t),a.release()}_getDepthStencilAttachment(e){const{width:r,height:t}=e.fbo;if(!this.view.stage.renderer.occludedRequiresIntegratedMeshStencil){const e=this.fboCache.acquireDepth(14,r,t,"retained stencil");return{depth:e,release:()=>e.release(),clearStencil:!0}}const s=this.fboCache.acquire(r,t,"retained stencil",14);return this.renderingContext.blitFramebuffer(e.fbo,s.fbo,1024),{depth:s.getAttachment(d),release:()=>s.release(),clearStencil:!1}}};e([t()],l.prototype,"consumes",void 0),e([t()],l.prototype,"produces",void 0),l=e([s("esri.views.3d.webgl-engine.effects.geometry.RenderOccludedRenderNode")],l);const a=new r;function h(){a.prune()}const p=[4,2,16],u=p.reduce((e,r)=>e|r,0);export{l as RenderOccludedRenderNode,h as cleanupRenderOccluded};
@@ -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{generateUID as r}from"../../../../core/uid.js";import{isColor as e}from"../core/shaderLibrary/ShaderOutput.js";import{DefaultTechniqueConfiguration as t}from"../materials/DefaultTechniqueConfiguration.js";import{updateParameters as i}from"../materials/internal/MaterialUtil.js";import{NoParameters as s}from"../../../webgl/NoParameters.js";class a{constructor(e,t){this.id=r(),this.supportsEdges=!1,this._renderPriority=0,this._parameters=new t,i(this._parameters,e),this.validateParameters(this._parameters)}get parameters(){return this._parameters}update(r){return!1}setParameters(r,e=!0){i(this._parameters,r)&&(this.validateParameters(this._parameters),e&&this._parametersChanged())}validateParameters(r){}shouldRender(r){return this.visible&&this.isVisibleForOutput(r.output)&&(!this.parameters.isDecoration||r.bind.decorations)&&0!==(this.parameters.renderOccluded&r.renderOccludedMask)}isVisibleForOutput(r){return!0}get renderPriority(){return this._renderPriority}set renderPriority(r){r!==this._renderPriority&&(this._renderPriority=r,this._parametersChanged())}_parametersChanged(){this.repository?.materialChanged(this)}get renderOccludedFlags(){return this.visible?this.parameters.renderOccluded:0}get hasEmissions(){return!1}getConfiguration(r,i,s=new t){return s.output=r,s.hasEmission=i.hasEmission&&e(r),s.hasHighlightMixTexture=8===r&&null!=i.highlightMixTexture,s}}class o extends s{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1}}export{a as Material,o as MaterialParameters};
5
+ import{generateUID as r}from"../../../../core/uid.js";import{isColor as e}from"../core/shaderLibrary/ShaderOutput.js";import{DefaultTechniqueConfiguration as t}from"../materials/DefaultTechniqueConfiguration.js";import{updateParameters as s}from"../materials/internal/MaterialUtil.js";import{NoParameters as i}from"../../../webgl/NoParameters.js";class a{constructor(e,t){this.id=r(),this.supportsEdges=!1,this._renderPriority=0,this._parameters=new t,s(this._parameters,e),this.validateParameters(this._parameters)}get parameters(){return this._parameters}update(r){return!1}setParameters(r,e=!0){s(this._parameters,r)&&(this.validateParameters(this._parameters),e&&this._parametersChanged())}validateParameters(r){}shouldRender(r){return this.visible&&this.isVisibleForOutput(r.output)&&(!this.parameters.isDecoration||r.bind.decorations)&&0!==(this.parameters.renderOccluded&r.renderOccludedMask)}isVisibleForOutput(r){return!0}get renderPriority(){return this._renderPriority}set renderPriority(r){r!==this._renderPriority&&(this._renderPriority=r,this._parametersChanged())}_parametersChanged(){this.repository?.materialChanged(this)}get renderOccludedFlags(){return this.visible?this.parameters.renderOccluded:0}get testsTransparentRenderOrder(){return this.parameters.testsTransparentRenderOrder}get hasEmissions(){return!1}getConfiguration(r,s,i=new t){return i.output=r,i.hasEmission=s.hasEmission&&e(r),i.hasHighlightMixTexture=8===r&&null!=s.highlightMixTexture,i}}class n extends i{constructor(){super(...arguments),this.renderOccluded=1,this.testsTransparentRenderOrder=0,this.isDecoration=!1}}export{a as Material,n as MaterialParameters};