@arcgis/core 4.34.0-next.40 → 4.34.0-next.42

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 (180) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/016d421114118307d4dd.js +1 -0
  3. package/assets/esri/core/workers/chunks/1a2278b9fe9666342728.js +1 -0
  4. package/assets/esri/core/workers/chunks/250b1629becca0410f2a.js +1 -0
  5. package/assets/esri/core/workers/chunks/3245d20ea4bb779f87ef.js +1 -0
  6. package/assets/esri/core/workers/chunks/6b73926feb5c5d957062.js +1 -0
  7. package/assets/esri/core/workers/chunks/{6269c4bbf0f224a954e9.js → 6f4079b7a2b45f304ee6.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{4e6e5677b90b00622146.js → 7ef7f3925495b9ade88c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/82955562805ad5514ed8.js +346 -0
  10. package/assets/esri/core/workers/chunks/{5fe3c279d57f44416c28.js → a1d3f1c221389eb6090c.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{306a68137e62656b0f05.js → d5d2d4df407cf078bb81.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{94850c094e076d81a016.js → dca2b487152cde45fb65.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{31ad9949b08a5b07218c.js → eea3e0bd17479a767160.js} +2 -2
  14. package/assets/esri/core/workers/chunks/fe6fa1f2c2d54d41645e.js +1 -0
  15. package/config.js +1 -1
  16. package/core/workers/registry.js +1 -1
  17. package/editing/sharedTemplates/executor/support/createFeatureServiceEdit.js +1 -1
  18. package/geometry/support/curves/closestPointOnCurve.js +1 -1
  19. package/geometry/support/curves/curveExtent.js +1 -1
  20. package/geometry/support/curves/curveLength.js +1 -1
  21. package/geometry/support/curves/curveUtils.js +1 -1
  22. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  23. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  24. package/geometry/support/curves/splitCurveAtPoint.js +1 -1
  25. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  26. package/interfaces.d.ts +24 -2
  27. package/kernel.js +1 -1
  28. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  29. package/layers/PointCloudLayer.js +1 -1
  30. package/package.json +1 -1
  31. package/rest/networks/support/CircuitPath.js +1 -1
  32. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  33. package/support/revision.js +1 -1
  34. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  35. package/views/2d/engine/flow/styles/Particles.js +1 -1
  36. package/views/2d/engine/flow/styles/Streamlines.js +1 -1
  37. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  38. package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
  39. package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
  40. package/views/2d/engine/webgl/Mesh2D.js +1 -1
  41. package/views/2d/engine/webgl/VertexStream.js +1 -1
  42. package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
  43. package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
  44. package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
  45. package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
  46. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  47. package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
  48. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  49. package/views/2d/engine/webgl/meshing/SimpleMesh.js +1 -1
  50. package/views/2d/engine/webgl/shaderGraph/techniques/overlay/OverlayTechnique.js +1 -1
  51. package/views/2d/engine/webgl/shaderGraph/techniques/videoScreenRenderer/VideoScreenTechnique.js +1 -1
  52. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  53. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  54. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  55. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  56. package/views/2d/layers/KMLLayerView2D.js +1 -1
  57. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  58. package/views/2d/layers/MediaLayerView2D.js +1 -1
  59. package/views/2d/layers/TileLayerView2D.js +1 -1
  60. package/views/2d/layers/WMSLayerView2D.js +1 -1
  61. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  62. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  63. package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
  64. package/views/2d/layers/support/DebugOverlay.js +1 -1
  65. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  66. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  67. package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
  68. package/views/3d/environment/LocalAtmosphere.js +1 -1
  69. package/views/3d/environment/MarsAtmosphere.js +1 -1
  70. package/views/3d/environment/Precipitation.js +1 -1
  71. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  72. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  73. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  74. package/views/3d/layers/FlowSubView3D.js +1 -1
  75. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  76. package/views/3d/layers/I3SMeshView3D.js +1 -1
  77. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  78. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  79. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  80. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  81. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  82. package/views/3d/layers/support/FlowTileTree3DDebugger.js +1 -1
  83. package/views/3d/support/GaussianSplatSortWorker.js +5 -0
  84. package/views/3d/support/GaussianSplatWorkerHandle.js +5 -0
  85. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  86. package/views/3d/support/flow/geometryUtils.js +1 -1
  87. package/views/3d/support/flow/loadUtils.js +1 -1
  88. package/views/3d/support/intersectionUtils.js +1 -1
  89. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  90. package/views/3d/terrain/PatchRenderData.js +1 -1
  91. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  92. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  93. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  94. package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
  95. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  96. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  97. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  98. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  99. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  100. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  101. package/views/3d/webgl-engine/lib/edgeRendering/edgeBufferWriters.js +1 -1
  102. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  103. package/views/3d/webgl-engine/lib/lodRendering/BackedBufferObject.js +1 -1
  104. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  105. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  106. package/views/3d/webgl-engine/lib/lodRendering/RenderInstanceData.js +1 -1
  107. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +5 -0
  108. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  109. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  110. package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
  111. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +5 -0
  112. package/views/PopupView.js +1 -1
  113. package/views/VideoView.js +1 -1
  114. package/views/draw/DrawAction.js +1 -1
  115. package/views/draw/DrawOperation.js +1 -1
  116. package/views/draw/SegmentDrawAction.js +1 -1
  117. package/views/draw/support/Reshape.js +1 -1
  118. package/views/interactive/SegmentLabels.js +1 -1
  119. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  120. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  121. package/views/interactive/editGeometry/operations/AppendVertex.js +1 -1
  122. package/views/interactive/editGeometry/operations/ClosePart.js +5 -0
  123. package/views/interactive/editGeometry/operations/MoveMesh.js +1 -1
  124. package/views/interactive/editGeometry/operations/MoveVertex.js +1 -1
  125. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  126. package/views/interactive/editGeometry/operations/RemoveVertices.js +1 -1
  127. package/views/interactive/editGeometry/operations/RotateVertex.js +1 -1
  128. package/views/interactive/editGeometry/operations/ScaleVertex.js +1 -1
  129. package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +1 -1
  130. package/views/interactive/editGeometry/operations/SetVertexPosition.js +1 -1
  131. package/views/interactive/editGeometry/operations/SplitSegment.js +5 -0
  132. package/views/interactive/editGeometry/operations/UpdateVertices.js +1 -1
  133. package/views/interactive/editGeometry/operations/curveOperationUtils.js +5 -0
  134. package/views/interactive/editGeometry/operations.js +1 -1
  135. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  136. package/views/interactive/snapping/LineSnapper.js +1 -1
  137. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  138. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  139. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  140. package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
  141. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  142. package/views/support/TileTreeDebugger.js +1 -1
  143. package/views/webgl/BufferObject.js +1 -1
  144. package/views/webgl/Util.js +1 -1
  145. package/views/webgl/VertexArrayObject.js +1 -1
  146. package/views/webgl/VertexBuffer.js +1 -1
  147. package/views/webgl/testFloatBufferBlend.js +1 -1
  148. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  149. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  150. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  151. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  152. package/widgets/Editor/EditorViewModel.js +1 -1
  153. package/widgets/Editor/support/SketchController.js +1 -1
  154. package/widgets/Feature/FeatureMedia.js +1 -1
  155. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  156. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  157. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  158. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  159. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  160. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  161. package/widgets/Features.js +1 -1
  162. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  163. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  164. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  165. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  166. package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +5 -0
  167. package/widgets/PanoramicViewer/support/PanoramicMeshWorker.js +5 -0
  168. package/widgets/Spinner.js +1 -1
  169. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  170. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  171. package/widgets/UtilityNetworkTrace.js +1 -1
  172. package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
  173. package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
  174. package/assets/esri/core/workers/chunks/01bd8f90e55081e65b38.js +0 -1
  175. package/assets/esri/core/workers/chunks/0a27f9b11d03874809ee.js +0 -346
  176. package/assets/esri/core/workers/chunks/34f677e8c1691c10e4e9.js +0 -1
  177. package/assets/esri/core/workers/chunks/e95a8c988ef822723503.js +0 -1
  178. package/assets/esri/core/workers/chunks/fd3009164d5e38fda85f.js +0 -1
  179. package/views/interactive/editGeometry/operations/CloseComponent.js +0 -5
  180. package/views/interactive/editGeometry/operations/SplitEdge.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/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,e as j}from"../../../../../chunks/vec32.js";import{create as w,clone as O}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{a as x,g as v}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as A}from"../LocalOriginManager.js";import{Object3D as k}from"../Object3D.js";import{VertexArrayObject as B}from"../VertexArrayObject.js";import{VertexLayout as L,EdgeInputBufferLayout as U,glVertexLayout as q}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as V,SilhouetteEdgeBufferWriter as H}from"./edgeBufferWriters.js";import{EdgeRenderer as S,lineWidthFractionFactor as I,extensionLengthOffset as N}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as W}from"./EdgeWorkerHandle.js";import{generateStrokesTexture as F}from"./strokes.js";import{determineRendererType as G,determineEdgeTransparency as K,determineObjectTransparency as J,fillComponentBufferIndices as Q}from"./util.js";import{BufferManager as X}from"../TextureBackedBuffer/BufferManager.js";import{BufferObject as Y}from"../../../../webgl/BufferObject.js";import{VertexBuffer as Z}from"../../../../webgl/VertexBuffer.js";const $=128;let ee=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=w(),this._localOrigins=new A(new D(e.renderSR));const t=L.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._verticesBufferObject=Y.createVertex(e.rctx,35044,t.buffer)}initialize(){this._worker=new W(this.schedule),this._componentColorManager=new X(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach(e=>this._discardObjectEntry(e)),this._objectEntries.clear(),this._pendingDeletions.forEach(e=>this._discardObjectEntry(e)),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new se(null,new Promise(e=>a=e),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new se(i,new Promise(e=>o=e),x(a),v(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&re(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof oe))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new oe(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach(e=>this._removeRenderable(e)),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach(e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)}),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce((e,t)=>e+t.statistics.gpuMemoryUsage,0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof k,i=G(t),o=S.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach(e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&le(e.components),this._updateTransparency(e)}),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach(e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;le(e.components)}),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach(e=>e.visible=t),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=w(),n=new T;let i=0,o=0;if(this._renderers.forEach(r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable(t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1),t.silhouette&&r.acquireTechnique(e,!0))},t),--this.techniques.precompiling):this._renderers.delete(r.key)}),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new z(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(_e,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach(t=>{de(t,e,a),he(t,e,a)})}_updateTransparency(e){const t=K(e.components.meta),r=J(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new ne(r,t);return le(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<$&&(n=!0),this._worker.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new ie(new B(this.rctx,new Map([["vertices",new Z(q,this._verticesBufferObject)],["instances",new Z(0===t?V.glLayout:H.glLayout,Y.createVertex(this.rctx,35044,0===t?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer))]])),0===t?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(0):null,a=e.silhouette.lodInfo.lengths.length>0?i(1):null,c=(o?.vao.cachedMemory??0)+(a?.vao.cachedMemory??0);return new ae(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,K(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get("position"),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=U.createBuffer(u);for(let p=0;p<u;p++)m.position.set(p,0,h.data[p*h.size]),m.position.set(p,1,h.data[p*h.size+1]),m.position.set(p,2,h.data[p*h.size+2]);Q(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,o,new oe(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=G(i),d=this._acquireRenderer(l,o||!1,!1),h=U.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Q(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const f=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(f),d.addRenderable(f),this._updateAllVerticalOffsets(t,a),f.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter(e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get("position");return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0});if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach(e=>{const t=e.attributes.get("position"),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]});const g=c||e.geometries[0],f=p(),_=this._computeModelTransformWithLocalOrigin(e,g,f);for(let p=0;p<e.geometries.length;p++)e.geometries[p].localOrigin=_.origin;const b=new pe(new C(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=S.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=F(this.rctx)),n||(n=new S(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:1===this.viewingMode}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){te(e.regular),te(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=w(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach(e=>e.distanceToCamera=o)};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function te(e){e?.vao&&(e.vao.buffer("instances")?.buffer.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function re(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],ee.prototype,"rctx",void 0),e([d({constructOnly:!0})],ee.prototype,"renderSR",void 0),e([d({constructOnly:!0})],ee.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],ee.prototype,"techniques",void 0),e([d({constructOnly:!0})],ee.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],ee.prototype,"schedule",void 0),e([d({readOnly:!0})],ee.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],ee.prototype,"updating",null),ee=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],ee);class se{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,()=>e.abort()):null;this.loaded=t,this.loaded.then(()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()}),this.center=O(r)}}class ne{constructor(e,t){this.buffer=e,this.meta=t}}class ie{constructor(e,t){this.vao=e,this.lod=t}}class oe{constructor(e,t){this.modelMatrix=e,this.origin=t}}class ae{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ce extends ae{}function le(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*I),0,255),c=i(e.extensionLength,-N,255-N)+N,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),R(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function de(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!ue(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=fe(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)},i)}function he(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!ge(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=fe(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)},i)}function ue(e){return null!=e.regular}class me extends ae{}function ge(e){return null!=e.silhouette}function fe(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=f(),be=()=>Promise.reject();export{ee as EdgeView,oe as LegacyTransform,ce as RegularRenderable,ae as Renderable,me as SilhouetteRenderable};
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create 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{i as _,c as b,a as y,e as j}from"../../../../../chunks/vec32.js";import{create as w,clone as O}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{a as x,g as v}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{encodeElevationOffset as R}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as A}from"../LocalOriginManager.js";import{Object3D as k}from"../Object3D.js";import{VertexArrayObject as U}from"../VertexArrayObject.js";import{VertexLayout as q,glVertexLayout as B,EdgeInputBufferLayout as H,RegularEdgeInstancesGLLayout as L,SilhouetteEdgeInstancesGLLayout as V}from"./bufferLayouts.js";import{EdgeRenderer as S,lineWidthFractionFactor as I,extensionLengthOffset as N}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as F}from"./EdgeWorkerHandle.js";import{generateStrokesTexture as G}from"./strokes.js";import{determineRendererType as K,determineEdgeTransparency as W,determineObjectTransparency as J,fillComponentBufferIndices as Q}from"./util.js";import{BufferManager as X}from"../TextureBackedBuffer/BufferManager.js";import{VertexBuffer as Y}from"../../../../webgl/VertexBuffer.js";const Z=128;let $=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=w(),this._localOrigins=new A(new D(e.renderSR));const t=q.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._vertexBuffer=new Y(e.rctx,B,t.buffer)}initialize(){this._workerHandle=new F(this.schedule),this._componentColorManager=new X(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach(e=>this._discardObjectEntry(e)),this._objectEntries.clear(),this._pendingDeletions.forEach(e=>this._discardObjectEntry(e)),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._workerHandle.destroy(),this._vertexBuffer.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",_e))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new re(null,new Promise(e=>a=e),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new re(i,new Promise(e=>o=e),x(a),v(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&te(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof ie))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=f(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new ie(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach(e=>this._removeRenderable(e)),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach(e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)}),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce((e,t)=>e+t.statistics.gpuMemoryUsage,0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof k,i=K(t),o=S.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach(e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&ce(e.components),this._updateTransparency(e)}),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach(e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;ce(e.components)}),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach(e=>e.visible=t),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=w(),n=new T;let i=0,o=0;if(this._renderers.forEach(r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable(t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1),t.silhouette&&r.acquireTechnique(e,!0))},t),--this.techniques.precompiling):this._renderers.delete(r.key)}),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new z(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(fe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,fe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach(t=>{le(t,e,a),de(t,e,a)})}_updateTransparency(e){const t=W(e.components.meta),r=J(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new se(r,t);return ce(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<Z&&(n=!0),this._workerHandle.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new ne(new U(this.rctx,new Map([["vertices",this._vertexBuffer],["instances",0===t?new Y(this.rctx,L,e.regular.instancesData.buffer):new Y(this.rctx,V,e.silhouette.instancesData.buffer)]])),0===t?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(0):null,a=e.silhouette.lodInfo.lengths.length>0?i(1):null,c=(o?.vao.cachedMemory??0)+(a?.vao.cachedMemory??0);return new oe(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,W(t.meta),J(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get("position"),a=f(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=H.createBuffer(u);for(let f=0;f<u;f++)m.position.set(f,0,h.data[f*h.size]),m.position.set(f,1,h.data[f*h.size+1]),m.position.set(f,2,h.data[f*h.size+2]);Q(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,o,new ie(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=K(i),d=this._acquireRenderer(l,o||!1,!1),h=H.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Q(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const p=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(p),d.addRenderable(p),this._updateAllVerticalOffsets(t,a),p.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter(e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get("position");return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0});if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach(e=>{const t=e.attributes.get("position"),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]});const g=c||e.geometries[0],p=f(),_=this._computeModelTransformWithLocalOrigin(e,g,p);for(let f=0;f<e.geometries.length;f++)e.geometries[f].localOrigin=_.origin;const b=new pe(new C(u,h,3),p,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=S.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=G(this.rctx)),n||(n=new S(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:1===this.viewingMode}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ee(e.regular),ee(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=w(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach(e=>e.distanceToCamera=o)};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function ee(e){e?.vao&&(e.vao.buffer("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function te(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],$.prototype,"rctx",void 0),e([d({constructOnly:!0})],$.prototype,"renderSR",void 0),e([d({constructOnly:!0})],$.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],$.prototype,"techniques",void 0),e([d({constructOnly:!0})],$.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],$.prototype,"schedule",void 0),e([d({readOnly:!0})],$.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],$.prototype,"updating",null),$=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],$);class re{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,()=>e.abort()):null;this.loaded=t,this.loaded.then(()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()}),this.center=O(r)}}class se{constructor(e,t){this.buffer=e,this.meta=t}}class ne{constructor(e,t){this.vao=e,this.lod=t}}class ie{constructor(e,t){this.modelMatrix=e,this.origin=t}}class oe{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ae extends oe{}function ce(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*I),0,255),c=i(e.extensionLength,-N,255-N)+N,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),R(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function le(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!he(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)},i)}function de(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable(i=>{if(!me(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=ge(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)},i)}function he(e){return null!=e.regular}class ue extends oe{}function me(e){return null!=e.silhouette}function ge(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const fe=p(),_e=()=>Promise.reject();export{$ as EdgeView,ie as LegacyTransform,ae as RegularRenderable,oe as Renderable,ue as SilhouetteRenderable};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{glLayout as e}from"../../../support/buffer/glUtil.js";import{newLayout as o}from"../../../support/buffer/InterleavedLayout.js";import{fromLayouts as r}from"../../../../webgl/VertexAttributeLocations.js";const t=o().vec3f("position").u16("componentIndex").freeze(),i=o().vec2u8("sideness").freeze(),n=e(i),s=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),a=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").vec2i16("normal2Compressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),f=r([n,e(s)]),m=r([n,e(a)]);export{t as EdgeInputBufferLayout,s as RegularEdgeInstancesLayout,f as RegularEdgeLocations,a as SilhouetteEdgeInstancesLayout,m as SilhouetteEdgeLocations,i as VertexLayout,n as glVertexLayout};
5
+ import{glLayout as e}from"../../../support/buffer/glUtil.js";import{newLayout as o}from"../../../support/buffer/InterleavedLayout.js";import{fromLayouts as r}from"../../../../webgl/VertexAttributeLocations.js";const t=o().vec3f("position").u16("componentIndex").freeze(),i=o().vec2u8("sideness").freeze(),n=e(i),s=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),a=o().vec3f("position0").vec3f("position1").vec2i16("normalCompressed").vec2i16("normal2Compressed").u16("componentIndex").u8("variantOffset",{glNormalized:!0}).u8("variantStroke").u8("variantExtension",{glNormalized:!0}).freeze(),f=e(s,1),m=e(a,1),p=r([n,f]),u=r([n,m]);export{t as EdgeInputBufferLayout,f as RegularEdgeInstancesGLLayout,s as RegularEdgeInstancesLayout,p as RegularEdgeLocations,m as SilhouetteEdgeInstancesGLLayout,a as SilhouetteEdgeInstancesLayout,u as SilhouetteEdgeLocations,i as VertexLayout,n as glVertexLayout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../core/RandomLCG.js";import{f as o,n as e}from"../../../../../chunks/vec32.js";import{create as i}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{glLayout as r}from"../../../support/buffer/glUtil.js";import{compressNormal as s}from"../Normals.js";import{RegularEdgeInstancesLayout as n,SilhouetteEdgeInstancesLayout as a}from"./bufferLayouts.js";const c=.7;class f{updateSettings(t){this.settings=t,this._edgeHashFunction=t.reducedPrecision?d:l}write(t,o,e){B.seed=this._edgeHashFunction(e);const i=B.getIntRange(0,255),r=B.getIntRange(0,this.settings.variants-1),s=B.getFloat(),n=255*(.5*y(-(1-Math.min(s/c,1))+Math.max(0,s-c)/(1-c),1.2)+.5);t.position0.setVec(o,e.position0),t.position1.setVec(o,e.position1),t.componentIndex.set(o,e.componentIndex),t.variantOffset.set(o,i),t.variantStroke.set(o,r),t.variantExtension.set(o,n)}}const m=new Float32Array(6),p=new Uint32Array(m.buffer),u=new Uint32Array(1);function l(t){return m[0]=t.position0[0],m[1]=t.position0[1],m[2]=t.position0[2],m[3]=t.position1[0],m[4]=t.position1[1],m[5]=t.position1[2],u[0]=31*(31*(31*(31*(31*(166811+p[0])+p[1])+p[2])+p[3])+p[4])+p[5],u[0]}function d(t){const o=m;o[0]=g(t.position0[0]),o[1]=g(t.position0[1]),o[2]=g(t.position0[2]),o[3]=g(t.position1[0]),o[4]=g(t.position1[1]),o[5]=g(t.position1[2]),u[0]=5381;for(let e=0;e<p.length;e++)u[0]=31*u[0]+p[e];return u[0]}const h=1e4;function g(t){return Math.round(t*h)/h}function y(t,o){return Math.abs(t)**o*Math.sign(t)}class w{constructor(){this._commonWriter=new f}updateSettings(t){this._commonWriter.updateSettings(t)}allocate(t){return n.createBuffer(t)}write(t,i,r){this._commonWriter.write(t,i,r),o(S,r.faceNormal0,r.faceNormal1),e(S,S);const{typedBuffer:n,typedBufferStride:a}=t.normalCompressed;s(n,i,S[0],S[1],S[2],a)}static{this.Layout=n}static{this.glLayout=r(n,1)}}class N{constructor(){this._commonWriter=new f}updateSettings(t){this._commonWriter.updateSettings(t)}allocate(t){return a.createBuffer(t)}write(t,o,e){this._commonWriter.write(t,o,e);{const{typedBuffer:i,typedBufferStride:r}=t.normalCompressed;s(i,o,e.faceNormal0[0],e.faceNormal0[1],e.faceNormal0[2],r)}{const{typedBuffer:i,typedBufferStride:r}=t.normal2Compressed;s(i,o,e.faceNormal1[0],e.faceNormal1[1],e.faceNormal1[2],r)}}static{this.Layout=a}static{this.glLayout=r(a,1)}}const S=i(),B=new t;export{w as RegularEdgeBufferWriter,N as SilhouetteEdgeBufferWriter};
5
+ import t from"../../../../../core/RandomLCG.js";import{f as e,n as o}from"../../../../../chunks/vec32.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{compressNormal as r}from"../Normals.js";import{RegularEdgeInstancesLayout as i,SilhouetteEdgeInstancesLayout as s}from"./bufferLayouts.js";const a=.7;class c{updateSettings(t){this.settings=t,this._edgeHashFunction=t.reducedPrecision?d:u}write(t,e,o){S.seed=this._edgeHashFunction(o);const n=S.getIntRange(0,255),r=S.getIntRange(0,this.settings.variants-1),i=S.getFloat(),s=255*(.5*g(-(1-Math.min(i/a,1))+Math.max(0,i-a)/(1-a),1.2)+.5);t.position0.setVec(e,o.position0),t.position1.setVec(e,o.position1),t.componentIndex.set(e,o.componentIndex),t.variantOffset.set(e,n),t.variantStroke.set(e,r),t.variantExtension.set(e,s)}}const f=new Float32Array(6),m=new Uint32Array(f.buffer),p=new Uint32Array(1);function u(t){return f[0]=t.position0[0],f[1]=t.position0[1],f[2]=t.position0[2],f[3]=t.position1[0],f[4]=t.position1[1],f[5]=t.position1[2],p[0]=31*(31*(31*(31*(31*(166811+m[0])+m[1])+m[2])+m[3])+m[4])+m[5],p[0]}function d(t){const e=f;e[0]=h(t.position0[0]),e[1]=h(t.position0[1]),e[2]=h(t.position0[2]),e[3]=h(t.position1[0]),e[4]=h(t.position1[1]),e[5]=h(t.position1[2]),p[0]=5381;for(let o=0;o<m.length;o++)p[0]=31*p[0]+m[o];return p[0]}const l=1e4;function h(t){return Math.round(t*l)/l}function g(t,e){return Math.abs(t)**e*Math.sign(t)}class w{constructor(){this._commonWriter=new c}updateSettings(t){this._commonWriter.updateSettings(t)}allocate(t){return i.createBuffer(t)}write(t,n,i){this._commonWriter.write(t,n,i),e(N,i.faceNormal0,i.faceNormal1),o(N,N);const{typedBuffer:s,typedBufferStride:a}=t.normalCompressed;r(s,n,N[0],N[1],N[2],a)}}class y{constructor(){this._commonWriter=new c}updateSettings(t){this._commonWriter.updateSettings(t)}allocate(t){return s.createBuffer(t)}write(t,e,o){this._commonWriter.write(t,e,o);{const{typedBuffer:n,typedBufferStride:i}=t.normalCompressed;r(n,e,o.faceNormal0[0],o.faceNormal0[1],o.faceNormal0[2],i)}{const{typedBuffer:n,typedBufferStride:i}=t.normal2Compressed;r(n,e,o.faceNormal1[0],o.faceNormal1[1],o.faceNormal1[2],i)}}}const N=n(),S=new t;export{w as RegularEdgeBufferWriter,y as SilhouetteEdgeBufferWriter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{hasNativeFloat16Array as r,makeFloat16Array as e}from"../../../../geometry/support/float16.js";import{Pos2TexF16 as t,Pos2TexF32 as o,Pos2 as f}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as n}from"./VertexArrayObject.js";import{BufferObject as m}from"../../../webgl/BufferObject.js";import{Texture as s}from"../../../webgl/Texture.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";import{VertexBuffer as a}from"../../../webgl/VertexBuffer.js";function i(s,u=0,i=-1,p=1){const w=1===u,c=w?r?new Float32Array([i,i,0,p,i,0,i,p,0,p,p,0]):new Float32Array([i,i,0,0,p,i,1,0,i,p,0,1,p,p,1,1]):new Float32Array([i,i,p,i,i,p,p,p]);if(w&&r){const r=e(c.buffer);r[10]=r[17]=r[22]=r[23]=1}return new n(s,new a(w?r?t:o:f,m.createVertex(s,35044,c)))}const p=4;function w(r){const e=new u(p);return e.samplingMode=9728,new s(r,e)}export{w as createEmptyTexture,i as createQuadVAO};
5
+ import{hasNativeFloat16Array as r,makeFloat16Array as e}from"../../../../geometry/support/float16.js";import{Pos2TexF16 as t,Pos2TexF32 as o,Pos2 as n}from"./DefaultVertexBufferLayouts.js";import{VertexArrayObject as f}from"./VertexArrayObject.js";import{Texture as s}from"../../../webgl/Texture.js";import{TextureDescriptor as m}from"../../../webgl/TextureDescriptor.js";import{VertexBuffer as u}from"../../../webgl/VertexBuffer.js";function a(s,m=0,a=-1,i=1){const p=1===m,w=p?r?new Float32Array([a,a,0,i,a,0,a,i,0,i,i,0]):new Float32Array([a,a,0,0,i,a,1,0,a,i,0,1,i,i,1,1]):new Float32Array([a,a,i,a,a,i,i,i]);if(p&&r){const r=e(w.buffer);r[10]=r[17]=r[22]=r[23]=1}return new f(s,new u(s,p?r?t:o:n,w))}const i=4;function p(r){const e=new m(i);return e.samplingMode=9728,new s(r,e)}export{p as createEmptyTexture,a as createQuadVAO};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{BufferObject as e}from"../../../../webgl/BufferObject.js";class t{constructor(t,r,i){this._elementSize=r,this._buffer=e.createVertex(t,35044),this.resize(i)}destroy(){this._buffer.dispose()}get elementSize(){return this._elementSize}get capacity(){return this._capacity}get array(){return this._array}get buffer(){return this._buffer}get usedMemory(){return this._array.byteLength+this._buffer.usedMemory}copyRange(e,t,r,i=0){const s=new Uint8Array(this.array,e*this.elementSize,(t-e)*this.elementSize);new Uint8Array(r.array,i*this.elementSize).set(s)}transferAll(){this._buffer.setData(this._array)}transferRange(e,t){const r=e*this._elementSize,i=t*this._elementSize;this._buffer.setSubData(new Uint8Array(this._array),r,r,i)}resize(e){const t=e*this._elementSize,r=new ArrayBuffer(t);this._array&&(e>=this._capacity?new Uint8Array(r).set(new Uint8Array(this._array)):new Uint8Array(r).set(new Uint8Array(this._array).subarray(0,e*this._elementSize))),this._array=r,this._buffer.setSize(t),this._capacity=e}}export{t as default};
5
+ import{glLayout as e}from"../../../support/buffer/glUtil.js";import{VertexBuffer as t}from"../../../../webgl/VertexBuffer.js";class r{constructor(r,i,s){this.elementSize=i.stride,this._buffer=new t(r,e(i,1)),this.resize(s)}destroy(){this._buffer.dispose()}get capacity(){return this._capacity}get array(){return this._array}get buffer(){return this._buffer}get usedMemory(){return this._array.byteLength+this._buffer.usedMemory}copyRange(e,t,r,i=0){const s=new Uint8Array(this.array,e*this.elementSize,(t-e)*this.elementSize);new Uint8Array(r.array,i*this.elementSize).set(s)}transferAll(){this._buffer.setData(this._array)}transferRange(e,t){const r=e*this.elementSize,i=t*this.elementSize;this._buffer.setSubData(new Uint8Array(this._array),r,r,i)}resize(e){const t=e*this.elementSize,r=new ArrayBuffer(t);this._array&&(e>=this._capacity?new Uint8Array(r).set(new Uint8Array(this._array)):new Uint8Array(r).set(new Uint8Array(this._array).subarray(0,e*this.elementSize))),this._array=r,this._buffer.setSize(t),this._capacity=e}}export{r as BackedBufferObject};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{glLayout as e}from"../../../support/buffer/glUtil.js";import{GLMaterials as t}from"../GLMaterials.js";import{VertexArrayObject as r}from"../VertexArrayObject.js";import{BufferObject as s}from"../../../../webgl/BufferObject.js";import{VertexBuffer as o}from"../../../../webgl/VertexBuffer.js";class i{constructor(i,m){this.geometry=m;const n=i.renderContext.rctx,a=m.renderGeometry,{material:u,layout:l,buffer:g}=a;this._materials=i.materials,u.setParameters({instancedDoublePrecision:!0}),this.glMaterials=new t(u,this._materials),this.vbo=s.createVertex(n,35044,g),this.vao=new r(n,new o(e(l),this.vbo))}destroy(){this.glMaterials.dispose(),this.vbo.dispose(),this.vao.dispose()}get material(){return this.geometry.renderGeometry.material}get layout(){return this.geometry.renderGeometry.layout}get boundingInfo(){return this.geometry.boundingInfo}get numTriangles(){return this.numVertices/3}get numVertices(){return this.geometry.renderGeometry.numVertices}get usedMemory(){return 128+this.vbo.usedMemory+this.vao.usedMemory}intersect(e,t,r,s,o,i,m,n){return this.geometry.intersect(e,t,r,s,o,i,m,n)}}export{i as LodComponentData};
5
+ import{glLayout as e}from"../../../support/buffer/glUtil.js";import{GLMaterials as t}from"../GLMaterials.js";import{VertexArrayObject as r}from"../VertexArrayObject.js";import{VertexBuffer as s}from"../../../../webgl/VertexBuffer.js";class o{constructor(o,i){this.geometry=i;const n=o.renderContext.rctx,m=i.renderGeometry,{material:a,layout:u,buffer:l}=m;this._materials=o.materials,a.setParameters({instancedDoublePrecision:!0}),this.glMaterials=new t(a,this._materials),this.vbo=new s(n,e(u),l),this.vao=new r(n,this.vbo)}destroy(){this.glMaterials.dispose(),this.vbo.dispose(),this.vao.dispose()}get material(){return this.geometry.renderGeometry.material}get layout(){return this.geometry.renderGeometry.layout}get boundingInfo(){return this.geometry.boundingInfo}get numTriangles(){return this.numVertices/3}get numVertices(){return this.geometry.renderGeometry.numVertices}get usedMemory(){return 128+this.vbo.usedMemory+this.vao.usedMemory}intersect(e,t,r,s,o,i,n,m){return this.geometry.intersect(e,t,r,s,o,i,n,m)}}export{o as LodComponentData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import s from"../../../../../core/Error.js";import{someMap as r,getOrCreateMapValue as n}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,e as u,t as m}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,freeze as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import v from"../../../webgl/RenderCamera.js";import{AsyncRenderPlugin as b}from"../../effects/RenderPlugin.js";import{DepthRange as I}from"../DepthRange.js";import{assert as C}from"../Util.js";import{InstanceData as D}from"./InstanceData.js";import{InstanceOctree as R}from"./InstanceOctree.js";import{LevelSelector as E}from"./LevelSelector.js";import{LodLevel as x}from"./LodLevel.js";import{getRenderInstanceDataLayout as S,RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as j}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as U}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as T}from"../../../../support/HighlightDefaults.js";import{TaskPriority as O,noBudget as A}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as M}from"../../../../webgl/Util.js";import{fromLayout as q}from"../../../../webgl/VertexAttributeLocations.js";const B=e=>{const t=e.baseBoundingSphere.radius,s=e.levels.map(e=>e.minScreenSpaceRadius);return new E(t,s)};let F=class extends b{constructor(e,t){super(e),this.type=6,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDatas=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[2,e=>this._produces(e)],[4,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new D({shaderTransformation:e.shaderTransformation},e.symbol.materialParameters),this.addHandles(t.registerTask(O.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=S(this.symbol.materialParameters),this._glInstanceBufferLayout=y(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",()=>this._requestUpdateCycle()),this._instanceData.events.on("instance-transform-changed",({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)}),this._instanceData.events.on("instance-visibility-changed",({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)}),this._instanceData.events.on("instance-highlight-changed",()=>this._requestUpdateCycle(!0))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDatas.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDatas)t[0]!==T&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDatas.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerViewUid(){return this.metadata.layerViewUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some(e=>e.components.some(e=>e.material.hasEmissions))}get usedMemory(){return this._allRenderInstanceData.reduce((e,t)=>t.reduce((e,t)=>e+t.usedMemory,e),this._levels.reduce((e,t)=>e+t.components.reduce((e,t)=>e+t.usedMemory,0),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach((e,s)=>{const r=this._allRenderInstanceData[0][s].size+this._allRenderInstanceData[1][s].size,n=e.triangleCount;t.push({renderedInstances:r,renderedTriangles:r*n,trianglesPerInstance:n})}),{totalInstances:e,renderedInstances:t.reduce((e,t)=>e+t.renderedInstances,0),renderedTriangles:t.reduce((e,t)=>e+t.renderedTriangles,0),levels:t}}_createRenderInstanceDataArray(){const{rctx:e}=this._context.renderContext;return this.symbol.levels.map(t=>new w(e,this._instanceBufferLayout))}async initializeRenderContext(e,s){this._context=e,this._defaultRenderInstanceData=this._createRenderInstanceDataArray();const r=await Promise.allSettled(this.symbol.levels.map(t=>x.create(e,t,s))),n=r.map(e=>"fulfilled"===e.status?e.value:null).filter(t);if(i(s)||n.length!==r.length){n.forEach(e=>e.destroy()),o(s);for(const e of r)if("rejected"===e.status)throw e.reason}this._levels=n,this._levelSelector=B(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach(e=>e.destroy()),this._defaultRenderInstanceData.forEach(e=>e.destroy()),this._highlightRenderInstanceDatas.forEach(e=>e.forEach(e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some(e=>e.components.some(e=>{const t=e.material.produces.get(4);return t?.(0)}))}hasHighlights(){return r(this._highlightRenderInstanceDatas,e=>e.some(e=>e.size>0))}_produces(e){return(8!==e||this.hasHighlights())&&(5!==e||this.hasHighlight(T))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(A),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const s=new Array,r=this.levels;return t.forEach(t=>r.forEach(({components:r},n)=>r.forEach(r=>s.push(this._beginComponent(e,t[n],r))))),s}render(e,t){const s=this._getInstanceDatas(e);if(!s||null==t)return;let r=0;const n=this.levels;s.forEach(s=>n.forEach(({components:n},a)=>n.forEach(n=>this._renderComponent(e,t[r++],s[a],n,a)))),e.rctx.unbindBuffer(34962),e.rctx.bindVAO(null)}_getInstanceDatas(e){const{output:t,bind:s}=e,r=8===t,n=5===t,a=6!==t;if(!r&&!n)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;const{_highlightRenderInstanceDatas:i}=this;if(a){if(r){const e=s.highlight?.name;if(!e)return null;const t=i.get(e);return t?[t]:null}const e=i.get(T);return n?e?[e]:null:Array.from(i.values())}return null}intersect(e,t,s,r){if(!this.baseMaterial.visible||null==this._octree)return;const n=f();d(n,r,s);const a=n=>{this._instanceData.getCombinedModelTransform(n,N),e.transform.set(N),m(W,s,e.transform.inverse),m(k,r,e.transform.inverse);const a=this._instanceData.getState(n),i=this._instanceData.getLodLevel(n),o=this._levels.length;C(!!(18&a),"invalid instance state"),C(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,W,k,n,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(s,n,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new R(e,this.baseBoundingSphere);for(let s=0;s<e.capacity;++s)18&t.get(s)&&this._octreeCached.addInstance(s)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new I;const t=e.viewForward,s=this._octree.findClosest(t,1,e.frustum),r=this._octree.findClosest(t,-1,e.frustum);if(null==s||null==r)return new I;const n=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(s,z),d(z,z,n);const i=u(z,t)-z[3];a.boundingSphere.getVec(r,z),d(z,z,n);const o=u(z,t)+z[3];return new I(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.startUpdateCycle()))}get readyToRun(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.beginUpdate()));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500),{_highlightRenderInstanceDatas:u}=this;for(let m=0;m<l&&!e.done;++m){h===this._cycleStartIndex&&this._startUpdateCycle();const m=o.state.get(h);let f=0;if(!(1&m)){h=h+1===c?0:h+1,l++;continue}const p=o.lodLevel.get(h);if(2&m&&this._defaultRenderInstanceData[p].freeTail(),16&m){const e=i.geHighlightOptionsPrev(h);if(e){const t=u.get(e);if(!t)throw new s("internal:lod-renderer","Internal error in lodRenderer");t[p].freeTail(),t.every(e=>e.isEmpty)&&(t.forEach(e=>e.destroy()),u.delete(e))}}if(32&m)i.freeInstance(h);else if(4&m){let e=0;if(t&&(o.modelOrigin.getVec(h,V),e=a.selectLevel(V,i.getCombinedMedianScaleFactor(h),r)),f=-83&m,e>=0)if(8&m){const t=i.getHighlightName(h);if(t){const r=()=>{const e=this._createRenderInstanceDataArray();return e.forEach(e=>e.beginUpdate()),e},a=n(u,t,r);if(e>=a.length)throw new s("internal:lod-renderer",`LodRenderer internal error - missing lodLevel ${e}`);H(a[e],o,h)}f|=16}else H(this._defaultRenderInstanceData[e],o,h),f|=2;o.state.set(h,f),o.lodLevel.set(h,e)}else f=-83&m,o.state.set(h,f);if(null!=this._octreeCached){const e=!!(18&m),t=!!(18&f);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&64&m&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d===0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.endUpdate())),this._context.requestRender()}_beginComponent(e,t,s){if(0===t.size)return null;const r=s.glMaterials.load(e.rctx,e.bind.slot,e.output);return r?.beginSlot(e.bind)}_renderComponent(e,t,s,r,n){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,r.material.parameters,Y),l=this._glInstanceBufferLayout;o.assertCompatibleVertexAttributeLocations(r.vao,q(l)),i.bindVAO(r.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&0===e.output&&(o.setUniform4fv("externalColor",G[Math.min(n,G.length-1)]),o.setUniform1i("symbolColorMixMode",L.replace));const c=s.capacity,h=s.headIndex,d=s.tailIndex,u=s.firstIndex,m=(e,n)=>{M(i,o.locations,s.buffer,l,e),i.drawArraysInstanced(t.primitiveType,0,r.numVertices,n-e)};r.material.transparent&&null!=u?h>d?(C(u>=d&&u<=h,"invalid firstIndex"),m(u,h),m(d,u)):h<d&&(u<=h?(C(u>=0&&u<=h,"invalid firstIndex"),m(u,h),m(d,c),m(0,u)):(C(u>=d&&u<=c,"invalid firstIndex"),m(u,c),m(0,h),m(d,u))):h>d?m(d,h):h<d&&(m(0,h),m(d,c))}};function H(e,t,s){const r=e.allocateHead();P(t,s,e.view,r)}function P(e,t,s,r){j(e.modelOrigin,t,s.modelOriginHi,s.modelOriginLo,r),s.model.copyFrom(r,e.model,t),s.modelNormal.copyFrom(r,e.modelNormal,t),e.color&&s.color&&s.color.copyFrom(r,e.color,t),e.olidColor&&s.olidColor&&s.olidColor.copyFrom(r,e.olidColor,t),e.featureAttribute&&s.featureAttribute&&s.featureAttribute.copyFrom(r,e.featureAttribute,t)}e([l({constructOnly:!0})],F.prototype,"symbol",void 0),e([l({constructOnly:!0})],F.prototype,"metadata",void 0),e([l({constructOnly:!0})],F.prototype,"shaderTransformation",void 0),e([l()],F.prototype,"_instanceData",void 0),e([l()],F.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],F.prototype,"_enableLevelSelection",null),e([l()],F.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],F.prototype,"readyToRun",null),F=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],F);const V=f(),z=p(),N=h(),W=f(),k=f(),G=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],Y=new U;export{F as LodRenderer};
5
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import s from"../../../../../core/Error.js";import{someMap as r,getOrCreateMapValue as n}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,e as u,t as m}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,freeze as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import v from"../../../webgl/RenderCamera.js";import{AsyncRenderPlugin as b}from"../../effects/RenderPlugin.js";import{DepthRange as I}from"../DepthRange.js";import{assert as C}from"../Util.js";import{InstanceData as D}from"./InstanceData.js";import{InstanceOctree as R}from"./InstanceOctree.js";import{LevelSelector as E}from"./LevelSelector.js";import{LodLevel as x}from"./LodLevel.js";import{getRenderInstanceDataLayout as S,RenderInstanceData as w}from"./RenderInstanceData.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as j}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as U}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as T}from"../../../../support/HighlightDefaults.js";import{TaskPriority as O,noBudget as A}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as M}from"../../../../webgl/Util.js";import{fromLayout as q}from"../../../../webgl/VertexAttributeLocations.js";const B=e=>{const t=e.baseBoundingSphere.radius,s=e.levels.map(e=>e.minScreenSpaceRadius);return new E(t,s)};let F=class extends b{constructor(e,t){super(e),this.type=6,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDatas=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new v,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[2,e=>this._produces(e)],[4,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new D({shaderTransformation:e.shaderTransformation},e.symbol.materialParameters),this.addHandles(t.registerTask(O.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=S(this.symbol.materialParameters),this._glInstanceBufferLayout=y(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",()=>this._requestUpdateCycle()),this._instanceData.events.on("instance-transform-changed",({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)}),this._instanceData.events.on("instance-visibility-changed",({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)}),this._instanceData.events.on("instance-highlight-changed",()=>this._requestUpdateCycle(!0))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDatas.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDatas)t[0]!==T&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDatas.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerViewUid(){return this.metadata.layerViewUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some(e=>e.components.some(e=>e.material.hasEmissions))}get usedMemory(){return this._allRenderInstanceData.reduce((e,t)=>t.reduce((e,t)=>e+t.usedMemory,e),this._levels.reduce((e,t)=>e+t.components.reduce((e,t)=>e+t.usedMemory,0),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach((e,s)=>{const r=this._allRenderInstanceData[0][s].size+this._allRenderInstanceData[1][s].size,n=e.triangleCount;t.push({renderedInstances:r,renderedTriangles:r*n,trianglesPerInstance:n})}),{totalInstances:e,renderedInstances:t.reduce((e,t)=>e+t.renderedInstances,0),renderedTriangles:t.reduce((e,t)=>e+t.renderedTriangles,0),levels:t}}_createRenderInstanceDataArray(){const{rctx:e}=this._context.renderContext;return this.symbol.levels.map(t=>new w(e,this._instanceBufferLayout))}async initializeRenderContext(e,s){this._context=e,this._defaultRenderInstanceData=this._createRenderInstanceDataArray();const r=await Promise.allSettled(this.symbol.levels.map(t=>x.create(e,t,s))),n=r.map(e=>"fulfilled"===e.status?e.value:null).filter(t);if(i(s)||n.length!==r.length){n.forEach(e=>e.destroy()),o(s);for(const e of r)if("rejected"===e.status)throw e.reason}this._levels=n,this._levelSelector=B(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach(e=>e.destroy()),this._defaultRenderInstanceData.forEach(e=>e.destroy()),this._highlightRenderInstanceDatas.forEach(e=>e.forEach(e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some(e=>e.components.some(e=>{const t=e.material.produces.get(4);return t?.(0)}))}hasHighlights(){return r(this._highlightRenderInstanceDatas,e=>e.some(e=>e.size>0))}_produces(e){return(8!==e||this.hasHighlights())&&(5!==e||this.hasHighlight(T))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(A),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const s=new Array,r=this.levels;return t.forEach(t=>r.forEach(({components:r},n)=>r.forEach(r=>s.push(this._beginComponent(e,t[n],r))))),s}render(e,t){const s=this._getInstanceDatas(e);if(!s||null==t)return;let r=0;const n=this.levels;s.forEach(s=>n.forEach(({components:n},a)=>n.forEach(n=>this._renderComponent(e,t[r++],s[a],n,a)))),e.rctx.unbindBuffer(34962),e.rctx.bindVAO(null)}_getInstanceDatas(e){const{output:t,bind:s}=e,r=8===t,n=5===t,a=6!==t;if(!r&&!n)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;const{_highlightRenderInstanceDatas:i}=this;if(a){if(r){const e=s.highlight?.name;if(!e)return null;const t=i.get(e);return t?[t]:null}const e=i.get(T);return n?e?[e]:null:Array.from(i.values())}return null}intersect(e,t,s,r){if(!this.baseMaterial.visible||null==this._octree)return;const n=f();d(n,r,s);const a=n=>{this._instanceData.getCombinedModelTransform(n,N),e.transform.set(N),m(W,s,e.transform.inverse),m(k,r,e.transform.inverse);const a=this._instanceData.getState(n),i=this._instanceData.getLodLevel(n),o=this._levels.length;C(!!(18&a),"invalid instance state"),C(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,W,k,n,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(s,n,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new R(e,this.baseBoundingSphere);for(let s=0;s<e.capacity;++s)18&t.get(s)&&this._octreeCached.addInstance(s)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new I;const t=e.viewForward,s=this._octree.findClosest(t,1,e.frustum),r=this._octree.findClosest(t,-1,e.frustum);if(null==s||null==r)return new I;const n=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(s,z),d(z,z,n);const i=u(z,t)-z[3];a.boundingSphere.getVec(r,z),d(z,z,n);const o=u(z,t)+z[3];return new I(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.startUpdateCycle()))}get readyToRun(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.beginUpdate()));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500),{_highlightRenderInstanceDatas:u}=this;for(let m=0;m<l&&!e.done;++m){h===this._cycleStartIndex&&this._startUpdateCycle();const m=o.state.get(h);let f=0;if(!(1&m)){h=h+1===c?0:h+1,l++;continue}const p=o.lodLevel.get(h);if(2&m&&this._defaultRenderInstanceData[p].freeTail(),16&m){const e=i.geHighlightOptionsPrev(h);if(e){const t=u.get(e);if(!t)throw new s("internal:lod-renderer","Internal error in lodRenderer");t[p].freeTail(),t.every(e=>e.isEmpty)&&(t.forEach(e=>e.destroy()),u.delete(e))}}if(32&m)i.freeInstance(h);else if(4&m){let e=0;if(t&&(o.modelOrigin.getVec(h,V),e=a.selectLevel(V,i.getCombinedMedianScaleFactor(h),r)),f=-83&m,e>=0)if(8&m){const t=i.getHighlightName(h);if(t){const r=()=>{const e=this._createRenderInstanceDataArray();return e.forEach(e=>e.beginUpdate()),e},a=n(u,t,r);if(e>=a.length)throw new s("internal:lod-renderer",`LodRenderer internal error - missing lodLevel ${e}`);H(a[e],o,h)}f|=16}else H(this._defaultRenderInstanceData[e],o,h),f|=2;o.state.set(h,f),o.lodLevel.set(h,e)}else f=-83&m,o.state.set(h,f);if(null!=this._octreeCached){const e=!!(18&m),t=!!(18&f);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&64&m&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d===0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.endUpdate())),this._context.requestRender()}_beginComponent(e,t,s){if(0===t.size)return null;const r=s.glMaterials.load(e.rctx,e.bind.slot,e.output);return r?.beginSlot(e.bind)}_renderComponent(e,t,s,r,n){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,r.material.parameters,Y),l=this._glInstanceBufferLayout;o.assertCompatibleVertexAttributeLocations(r.vao,q(l)),i.bindVAO(r.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&0===e.output&&(o.setUniform4fv("externalColor",G[Math.min(n,G.length-1)]),o.setUniform1i("symbolColorMixMode",L.replace));const c=s.capacity,h=s.headIndex,d=s.tailIndex,u=s.firstIndex,m=(e,n)=>{M(i,o.locations,s.buffer,e),i.drawArraysInstanced(t.primitiveType,0,r.numVertices,n-e)};r.material.transparent&&null!=u?h>d?(C(u>=d&&u<=h,"invalid firstIndex"),m(u,h),m(d,u)):h<d&&(u<=h?(C(u>=0&&u<=h,"invalid firstIndex"),m(u,h),m(d,c),m(0,u)):(C(u>=d&&u<=c,"invalid firstIndex"),m(u,c),m(0,h),m(d,u))):h>d?m(d,h):h<d&&(m(0,h),m(d,c))}};function H(e,t,s){const r=e.allocateHead();P(t,s,e.view,r)}function P(e,t,s,r){j(e.modelOrigin,t,s.modelOriginHi,s.modelOriginLo,r),s.model.copyFrom(r,e.model,t),s.modelNormal.copyFrom(r,e.modelNormal,t),e.color&&s.color&&s.color.copyFrom(r,e.color,t),e.olidColor&&s.olidColor&&s.olidColor.copyFrom(r,e.olidColor,t),e.featureAttribute&&s.featureAttribute&&s.featureAttribute.copyFrom(r,e.featureAttribute,t)}e([l({constructOnly:!0})],F.prototype,"symbol",void 0),e([l({constructOnly:!0})],F.prototype,"metadata",void 0),e([l({constructOnly:!0})],F.prototype,"shaderTransformation",void 0),e([l()],F.prototype,"_instanceData",void 0),e([l()],F.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],F.prototype,"_enableLevelSelection",null),e([l()],F.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],F.prototype,"readyToRun",null),F=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],F);const V=f(),z=p(),N=h(),W=f(),k=f(),G=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],Y=new U;export{F as LodRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{reallocShrinkThreshold as t,reallocGrowthFactor as i,reallocShrinkFactor as e}from"../../../../../core/arrayUtils.js";import{BufferViewVec4f as s,BufferViewVec4u8 as a}from"../../../../../geometry/support/buffer/BufferView.js";import{newLayout as n}from"../../../support/buffer/InterleavedLayout.js";import{assert as r}from"../Util.js";import h from"./BackedBufferObject.js";import{addOptionalLayoutFields as d,initialCapacity as _}from"./InstanceData.js";class c{constructor(t){this.model=t.instanceModel,this.modelNormal=t.instanceModelNormal,this.modelOriginHi=t.instanceModelOriginHi,this.modelOriginLo=t.instanceModelOriginLo,this.featureAttribute=t.getField("instanceFeatureAttribute",s),this.color=t.getField("instanceColor",a),this.olidColor=t.getField("instanceOlidColor",a)}}class o{constructor(t,i){this._rctx=t,this._layout=i,this._headIndex=0,this._tailIndex=0,this._firstIndex=null,this._captureFirstIndex=!0,this._updating=!1,this._prevHeadIndex=0,this._resized=!1,this._capacity=1}destroy(){this._buffer&&this._buffer.destroy()}get buffer(){return this._buffer.buffer}get view(){return this._view}get capacity(){return this._capacity}get size(){const t=this._headIndex,i=this._tailIndex;return t>=i?t-i:t+this._capacity-i}get isEmpty(){return this._headIndex===this._tailIndex}get isFull(){return this._tailIndex===(this._headIndex+1)%this._capacity}get headIndex(){return this._headIndex}get tailIndex(){return this._tailIndex}get firstIndex(){return this._firstIndex}get usedMemory(){return this._buffer?.usedMemory??0}reset(){this._headIndex=0,this._tailIndex=0,this._firstIndex=null}startUpdateCycle(){this._captureFirstIndex=!0}beginUpdate(){r(!this._updating,"already updating"),this._updating=!0,this._prevHeadIndex=this._headIndex}endUpdate(){r(this._updating,"not updating"),this.size<t*this.capacity&&this._shrink(),this._resized?(this._buffer.transferAll(),this._resized=!1):this._transferRange(this._prevHeadIndex,this._headIndex),this._updating=!1}allocateHead(){r(this._updating,"not updating"),this.isFull&&this._grow();const t=this.headIndex;return this._captureFirstIndex&&(this._firstIndex=t,this._captureFirstIndex=!1),this._incrementHead(),r(this._headIndex!==this._tailIndex,"invalid pointers"),t}freeTail(){r(this._updating,"not updating"),r(this.size>0,"invalid size");const t=this._tailIndex===this._firstIndex;this._incrementTail(),t&&(this._firstIndex=this._tailIndex)}_grow(){const t=Math.max(_,Math.floor(this._capacity*i));this._resize(t)}_shrink(){const t=Math.max(_,Math.floor(this._capacity*e));this._resize(t)}_resize(t){if(r(this._updating,"not updating"),t===this._capacity)return;const i=new h(this._rctx,this._layout.stride,t);if(this._buffer){this._firstIndex&&(this._firstIndex=(this._firstIndex+this._capacity-this._tailIndex)%this._capacity);const t=this.size,e=this._compactInstances(i);r(e===t,"invalid compaction"),this._buffer.destroy(),this._tailIndex=0,this._headIndex=e,this._prevHeadIndex=0}this._resized=!0,this._capacity=t,this._buffer=i,this._view=new c(this._layout.createView(this._buffer.array))}_compactInstances(t){const i=this._headIndex,e=this._tailIndex;return e<i?(this._buffer.copyRange(e,i,t),i-e):e>i?(this._buffer.copyRange(e,this._capacity,t),i>0&&this._buffer.copyRange(0,i,t,this._capacity-e),i+(this._capacity-e)):0}_incrementHead(t=1){this._headIndex=(this._headIndex+t)%this._capacity}_incrementTail(t=1){this._tailIndex=(this._tailIndex+t)%this._capacity}_transferRange(t,i){t<i?this._buffer.transferRange(t,i):t>i&&(i>0&&this._buffer.transferRange(0,i),this._buffer.transferRange(t,this._capacity))}}const f=n().vec3f("instanceModelOriginHi").vec3f("instanceModelOriginLo").mat3f("instanceModel").mat3f("instanceModelNormal");function u(t){return d(f.clone(),t)}export{o as RenderInstanceData,c as RenderInstanceDataView,u as getRenderInstanceDataLayout};
5
+ import{reallocShrinkThreshold as t,reallocGrowthFactor as i,reallocShrinkFactor as e}from"../../../../../core/arrayUtils.js";import{BufferViewVec4f as s,BufferViewVec4u8 as a}from"../../../../../geometry/support/buffer/BufferView.js";import{newLayout as n}from"../../../support/buffer/InterleavedLayout.js";import{assert as r}from"../Util.js";import{BackedBufferObject as h}from"./BackedBufferObject.js";import{addOptionalLayoutFields as d,initialCapacity as _}from"./InstanceData.js";class c{constructor(t){this.model=t.instanceModel,this.modelNormal=t.instanceModelNormal,this.modelOriginHi=t.instanceModelOriginHi,this.modelOriginLo=t.instanceModelOriginLo,this.featureAttribute=t.getField("instanceFeatureAttribute",s),this.color=t.getField("instanceColor",a),this.olidColor=t.getField("instanceOlidColor",a)}}class o{constructor(t,i){this._rctx=t,this._layout=i,this._headIndex=0,this._tailIndex=0,this._firstIndex=null,this._captureFirstIndex=!0,this._updating=!1,this._prevHeadIndex=0,this._resized=!1,this._capacity=1}destroy(){this._buffer&&this._buffer.destroy()}get buffer(){return this._buffer.buffer}get view(){return this._view}get capacity(){return this._capacity}get size(){const t=this._headIndex,i=this._tailIndex;return t>=i?t-i:t+this._capacity-i}get isEmpty(){return this._headIndex===this._tailIndex}get isFull(){return this._tailIndex===(this._headIndex+1)%this._capacity}get headIndex(){return this._headIndex}get tailIndex(){return this._tailIndex}get firstIndex(){return this._firstIndex}get usedMemory(){return this._buffer?.usedMemory??0}reset(){this._headIndex=0,this._tailIndex=0,this._firstIndex=null}startUpdateCycle(){this._captureFirstIndex=!0}beginUpdate(){r(!this._updating,"already updating"),this._updating=!0,this._prevHeadIndex=this._headIndex}endUpdate(){r(this._updating,"not updating"),this.size<t*this.capacity&&this._shrink(),this._resized?(this._buffer.transferAll(),this._resized=!1):this._transferRange(this._prevHeadIndex,this._headIndex),this._updating=!1}allocateHead(){r(this._updating,"not updating"),this.isFull&&this._grow();const t=this.headIndex;return this._captureFirstIndex&&(this._firstIndex=t,this._captureFirstIndex=!1),this._incrementHead(),r(this._headIndex!==this._tailIndex,"invalid pointers"),t}freeTail(){r(this._updating,"not updating"),r(this.size>0,"invalid size");const t=this._tailIndex===this._firstIndex;this._incrementTail(),t&&(this._firstIndex=this._tailIndex)}_grow(){const t=Math.max(_,Math.floor(this._capacity*i));this._resize(t)}_shrink(){const t=Math.max(_,Math.floor(this._capacity*e));this._resize(t)}_resize(t){if(r(this._updating,"not updating"),t===this._capacity)return;const i=new h(this._rctx,this._layout,t);if(this._buffer){this._firstIndex&&(this._firstIndex=(this._firstIndex+this._capacity-this._tailIndex)%this._capacity);const t=this.size,e=this._compactInstances(i);r(e===t,"invalid compaction"),this._buffer.destroy(),this._tailIndex=0,this._headIndex=e,this._prevHeadIndex=0}this._resized=!0,this._capacity=t,this._buffer=i,this._view=new c(this._layout.createView(this._buffer.array))}_compactInstances(t){const i=this._headIndex,e=this._tailIndex;return e<i?(this._buffer.copyRange(e,i,t),i-e):e>i?(this._buffer.copyRange(e,this._capacity,t),i>0&&this._buffer.copyRange(0,i,t,this._capacity-e),i+(this._capacity-e)):0}_incrementHead(t=1){this._headIndex=(this._headIndex+t)%this._capacity}_incrementTail(t=1){this._tailIndex=(this._tailIndex+t)%this._capacity}_transferRange(t,i){t<i?this._buffer.transferRange(t,i):t>i&&(i>0&&this._buffer.transferRange(0,i),this._buffer.transferRange(t,this._capacity))}}const f=n().vec3f("instanceModelOriginHi").vec3f("instanceModelOriginLo").mat3f("instanceModel").mat3f("instanceModelNormal");function u(t){return d(f.clone(),t)}export{o as RenderInstanceData,c as RenderInstanceDataView,u as getRenderInstanceDataLayout};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as r,filterInPlace as o}from"../../../../../core/arrayUtils.js";import{nextHighestPowerOfTwo as s}from"../../../../../core/mathUtils.js";import{NestedMap as n}from"../../../../../core/NestedMap.js";import i from"../../../../../core/PooledArray.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,invert as f,transpose as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{assert as m}from"../../lib/Util.js";import{BufferRange as g,mergeAdjacentRanges as p}from"./BufferRange.js";import{Instance as y}from"./Instance.js";import{PerBufferData as b,hasVao as _}from"./PerBufferData.js";import{PerOriginData as v}from"./PerOriginData.js";let w=class extends t{constructor(e){super(e),this._vaoCache=null,this._bufferWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=e.renderContext.rctx.getVaoCache(d(this._bufferWriter.layout))}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._bufferWriter=null,this._vaoCache=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByOrigin.values())if(e.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const r of this.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const s=r.buffers[t];s.holes.length<=1?++t:(s.instances.forEach(({geometry:e})=>o.push(e)),this._vaoCache.deleteVao(s.vao),r.buffers[t]=r.buffers[r.buffers.length-1],--r.buffers.length,e.madeProgress())}if(o.length>0){for(r.buffers.forEach(e=>this._applyAdds(e,o));o.length>0;)r.buffers.push(this._applyAndRebuild(new b,o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e,this.dataByOrigin.forEach(t=>t.buffers.forEach(t=>t.updateHighlights(e)))}_applyUpdates(e,t){const o=this._bufferWriter;if(null==o)return void e.clearUpdates();const s=o.layout.stride/4;for(const n of e.updates){if(t.done)return;const{renderGeometry:i,updateType:a}=n;r(e.pending.updates,n),t.madeProgress();const l=this.dataByOrigin.get(i.localOrigin.id),u=l?.findBuffer(i.id);if(null==u)return;const f=u.instances.get(i.id);if(6&a){const e=k(o.elementCount(f.geometry.geometry.attributes)*s),t=o.layout.createView(e.buffer);this._writeGeometry(i,t,0),u.vao.buffer()?.setSubData(e,f.from*s,0,f.numElements*s)}25&a&&(u.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new n;for(const o of e){const e=o.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new C(e.vec3),r.set(e.id,null,t)),t.changes.push(o)}for(const o of t){const e=o.localOrigin;if(null==e)continue;const t=this.dataByOrigin.get(e.id),s=t?.findBuffer(o.id);if(null==s)continue;let n=r.get(e.id,s);null==n&&(n=new C(e.vec3),r.set(e.id,s,n)),n.changes.push(o)}return r}_applyAddsAndRemoves(e){const{_bufferWriter:t,dataByOrigin:o,_vaoCache:s}=this;if(null==t||null==s)return void e.clearAddsAndRemoves();const n=t.layout.stride/4,i=this._computeDeltas(e.adds,e.removes);i.forEach((e,a)=>{const l=e.get(null),u=l?.changes??[];i.delete(a,null);let f=o.get(a);if(e.forEach((e,l)=>{if(i.delete(a,l),null==l&&m(!1,"No VAO for removed geometries"),l.instances.size===e.changes.length)return s.deleteVao(l.vao),r(f.buffers,l),void(0===f.buffers.length&&0===u.length&&o.delete(a));const c=l.numElements,h=l.vao.getByteLength("geometry")/4,d=u.reduce((e,r)=>e+t.elementCount(r.geometry.attributes),0),g=e.changes.reduce((e,r)=>e+t.elementCount(r.geometry.attributes),0),p=Math.min((c+d-g)*n,R),y=p>h;p>E&&p<h/2?(e.changes.forEach(({id:e})=>l.deleteInstance(e)),l.instances.forEach(({geometry:e})=>u.push(e)),this._vaoCache.deleteVao(l.vao),r(f.buffers,l)):y?this._applyAndRebuild(l,u,e):this._applyRemoves(l,e)}),u.length>0)for(null==f&&(f=new v(l.origin),o.set(a,f)),f.buffers.forEach(e=>this._applyAdds(e,u));u.length>0;)f.buffers.push(this._applyAndRebuild(new b,u,null))}),e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1,this.dataByOrigin.forEach(e=>{e.buffers.forEach(e=>{e.updateIfDrawCommandsDirty(this.highlightOrderMap,this._bufferWriter.layout.stride),this._hasOccludees||=e.hasOccludees})})}_applyAndRebuild(e,t,r){if(r)for(const d of r.changes)e.deleteInstance(d.id);const o=this._bufferWriter,s=o.layout.stride,n=s/4,i=Math.floor(R/n);let a=e.numElements;for(;t.length>0;){const r=t.pop(),s=o.elementCount(r.geometry.attributes);if(a+s>i&&a>0){t.push(r);break}a+=s;const n=new y(r,0,0,this.highlightOrderMap);m(null==e.instances.get(r.id)),e.addInstance(r.id,n)}const l=a*n,u=k(l),f=o.layout.createView(u.buffer);let c=0;e.resetInstanceSummary(),e.instances.forEach((t,r)=>{this._writeGeometry(t.geometry,f,c);const s=c;c+=o.elementCount(t.geometry.geometry.attributes),e.updateInstance(r,s,c),e.updateDrawState(t)}),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.buffer()?.setSubData(u,0,0,c*n),e.holes.clear();const h=e.holes.pushNew();return h.from=c,h.to=Math.floor(e.vao.getByteLength("geometry")/s),e.updateDrawCommands(this.highlightOrderMap,s),e}_applyRemoves(e,t){if(0===t.changes.length||null==this._bufferWriter)return;let r=1/0,o=-1/0;for(const i of t.changes){const t=i.id,s=e.instances.get(t);if(!s)continue;e.deleteInstance(t),this._useMetalWorkaround&&(r=Math.min(r,s.from),o=Math.max(o,s.to));const n=W.back();if(n){if(n.to===s.from){n.to=s.to;continue}if(n.from===s.to){n.from=s.from;continue}}const a=W.pushNew();a.from=s.from,a.to=s.to}p(W);const s=this._bufferWriter.layout.stride/4,n=e.vao.buffer();if(this._useMetalWorkaround){const t=(o-r)*s,i=k(t),a=this._bufferWriter.layout.createView(i.buffer);i.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=r&&e.to<=o))return;const t=e.from-r;this._writeGeometry(e.geometry,a,t)}),n?.setSubData(i,r*s,0,t)}else{const e=W.reduce((e,t)=>Math.max(e,t.numElements),0)*s,t=k(e);t.fill(0,0,e),W.forAll(e=>n?.setSubData(t,e.from*s,0,e.numElements*s))}e.holes.pushArray(W.data,W.length),W.forAll((e,t)=>W.data[t]=null),W.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null==this._bufferWriter)return;if(!_(e))return void this._applyAndRebuild(e,t,null);const r=this._bufferWriter,s=r.layout.stride/4,n=e.numElements,i=t.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),a=Math.min((n+i)*s,R),l=4*a;if(e.vao.getByteLength("geometry")<V(R-E)&&l>e.vao.getByteLength("geometry"))return void this._applyAndRebuild(e,t,null);p(e.holes);const u=new Array;let f=1/0,c=-1/0;for(const o of t){const t=r.elementCount(o.geometry.attributes),s=A(e.holes,t);u.push(s),this._useMetalWorkaround&&null!=s&&(f=Math.min(s,f),c=Math.max(s+t,c))}const h=e.vao.buffer();let d=0,g=0,b=0;const v=this._useMetalWorkaround?k((c-f)*s):k(a),w=r.layout.createView(v.buffer);if(t.forEach((t,o)=>{const n=u[o];if(null==n)return;const i=r.elementCount(t.geometry.attributes);if(!this._useMetalWorkaround){if(!(b===n)){const e=b-g;e>0&&h?.setSubData(v,g*s,0,e*s),g=n,d=0}this._writeGeometry(t,w,d),d+=i,b=n+i}const a=new y(t,n,n+i,this.highlightOrderMap);m(null==e.instances.get(t.id)),e.addInstance(t.id,a),e.drawCommandsDirty=!0}),this._useMetalWorkaround){const t=(c-f)*s;v.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=f&&e.to<=c))return;const t=e.from-f;this._writeGeometry(e.geometry,w,t)}),g=f,b=c}const C=b-g;C>0&&h?.setSubData(v,g*s,0,C*s),o(t,(e,t)=>null==u[t])}_writeGeometry(e,t,r){null!=this._bufferWriter&&(u(M,e.transformation),M[12]-=e.localOrigin.vec3[0],M[13]-=e.localOrigin.vec3[1],M[14]-=e.localOrigin.vec3[2],f(O,M),c(O,O),this._bufferWriter.write(M,O,e.geometry.attributes,e.geometry.olidColor,t,r))}static prune(){x=new Float32Array(E)}};e([a({constructOnly:!0})],w.prototype,"dataByOrigin",void 0),e([a({constructOnly:!0})],w.prototype,"material",void 0),e([a()],w.prototype,"highlightOrderMap",void 0),w=e([l("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],w);class C{constructor(e){this.origin=e,this.changes=new Array}}function A(e,t){const r=e.find(e=>e.numElements>=t);if(null==r)return null;const o=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),o}const M=h(),O=h(),W=new i({allocator:e=>e||new g,deallocator:null}),E=65536,D=4*E,B=1024,j=16777216,R=j/4;let x=new Float32Array(E);function k(e){return x.length<e&&(x=new Float32Array(e)),x}function V(e){const t=4*e;return t<=B?B:t<D?s(t):Math.max(Math.min(Math.ceil(1.5*t/D)*D,j),t)}export{w as MergedBuffer,V as sizeForVao};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as s}from"../../../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../../../core/maybe.js";import{NestedMap as a}from"../../../../../core/NestedMap.js";import o from"../../../../../core/PooledArray.js";import{addMany as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as u,invert as f,transpose as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as m}from"../../../support/buffer/glUtil.js";import{SyncRenderPlugin as g}from"../../effects/RenderPlugin.js";import{GLMaterials as p}from"../../lib/GLMaterials.js";import{assert as y}from"../../lib/Util.js";import{DrawParameters as _}from"../DrawParameters.js";import{BufferRange as b,mergeAdjacentRanges as w}from"./BufferRange.js";import{Instance as v}from"./Instance.js";import{PerBufferData as C,hasVao as O}from"./PerBufferData.js";import{PerOriginData as A}from"./PerOriginData.js";import{defaultHighlightName as E}from"../../../../support/HighlightDefaults.js";let M=class extends g{get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(e){return this._highlightNames.has(e)}constructor(e){super(e),this._dataByOrigin=new Map,this._drawParameters=new _,this._highlightNames=new Set,this.drapedPriority=0,this._produces=new Map,this._hasOccludees=!1}destroy(){this._glMaterials=i(this._glMaterials),this._dataByOrigin.forEach(e=>e.dispose()),this._dataByOrigin.clear(),this._vaoCache=null}initialize(){this._updateProduces()}_updateProduces(){this.material.produces.forEach((e,t)=>{this._produces.set(t,t=>!(0===this._dataByOrigin.size||!(8!==t&&5!==t||this._hasHighlights))&&e(t))})}initializeRenderContext(e){U??=e.renderContext.rctx.isAssumedMetalDriver,this._glMaterials=new p(this.material,e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=e.renderContext.rctx.getVaoCache(m(this._bufferWriter.layout))}uninitializeRenderContext(){}get produces(){return this._produces}get hasOccludees(){return this._hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmissions(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;return this._dataByOrigin.forEach(t=>e+=t.buffers.reduce((e,t)=>e+t.instances.size,0)),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach(t=>e+=t.buffers.reduce((e,t)=>e+t.vao.cachedMemory,0)),e}forEachGeometry(e){this._dataByOrigin.forEach(t=>t.buffers.forEach(t=>t.instances.forEach(({geometry:t})=>e(t))))}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this._dataByOrigin.values())if(e.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const r of this._dataByOrigin.values()){const s=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const i=r.buffers[t];i.holes.length<=1?++t:(i.instances.forEach(({geometry:e})=>s.push(e)),this._vaoCache.deleteVao(i.vao),r.buffers[t]=r.buffers[r.buffers.length-1],--r.buffers.length,e.madeProgress())}if(s.length>0){for(r.buffers.forEach(e=>this._applyAdds(e,s));s.length>0;)r.buffers.push(this._applyAndRebuild(new C,s,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e,this._highlightNames.clear(),this._dataByOrigin.forEach(t=>{t.buffers.forEach(t=>{t.updateHighlights(e),t.highlightNames.forEach(e=>this._highlightNames.add(e))})}),this._updateProduces()}_applyUpdates(e,r){const s=this._bufferWriter;if(null==s)return void e.clearUpdates();const i=s.layout.stride/4;for(const a of e.updates){if(r.done)return;const{renderGeometry:o,updateType:n}=a;t(e.pending.updates,a),r.madeProgress();const l=this._dataByOrigin.get(o.localOrigin.id),h=l?.findBuffer(o.id);if(null==h)return;const u=h.instances.get(o.id);if(6&n){const e=G(s.elementCount(u.geometry.geometry.attributes)*i),t=s.layout.createView(e.buffer);this._writeGeometry(o,t,0),h.vao.buffer()?.buffer.setSubData(e,u.from*i,0,u.numElements*i)}25&n&&(h.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new a;for(const s of e){const e=s.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new D(e.vec3),r.set(e.id,null,t)),t.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),i=t?.findBuffer(s.id);if(null==i)continue;let a=r.get(e.id,i);null==a&&(a=new D(e.vec3),r.set(e.id,i,a)),a.changes.push(s)}return r}_applyAddsAndRemoves(e){const{_bufferWriter:r,_dataByOrigin:s,_vaoCache:i}=this;if(null==r||null==i)return void e.clearAddsAndRemoves();const a=r.layout.stride/4,o=this._computeDeltas(e.adds,e.removes);o.forEach((e,n)=>{const l=e.get(null),h=l?.changes??[];o.delete(n,null);let u=s.get(n);if(e.forEach((e,l)=>{if(o.delete(n,l),null==l&&y(!1,"No VAO for removed geometries"),l.instances.size===e.changes.length)return i.deleteVao(l.vao),t(u.buffers,l),void(0===u.buffers.length&&0===h.length&&s.delete(n));const f=l.numElements,c=l.vao.getByteLength("geometry")/4,d=h.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),m=e.changes.reduce((e,t)=>e+r.elementCount(t.geometry.attributes),0),g=Math.min((f+d-m)*a,W),p=g>c;g>P&&g<c/2?(e.changes.forEach(({id:e})=>l.deleteInstance(e)),l.instances.forEach(({geometry:e})=>h.push(e)),this._vaoCache.deleteVao(l.vao),t(u.buffers,l)):p?this._applyAndRebuild(l,h,e):this._applyRemoves(l,e)}),h.length>0)for(null==u&&(u=new A(l.origin),s.set(n,u)),u.buffers.forEach(e=>this._applyAdds(e,h));h.length>0;)u.buffers.push(this._applyAndRebuild(new C,h,null))}),e.clearAddsAndRemoves()}_updateDrawCommands(){this._highlightNames.clear(),this._hasOccludees=!1,this._dataByOrigin.forEach(e=>{e.buffers.forEach(e=>{e.updateIfDrawCommandsDirty(this.highlightOrderMap,this._bufferWriter.layout.stride),e.hasHighlights&&n(this._highlightNames,e.highlightNames),this._hasOccludees||=e.hasOccludees})})}_applyAndRebuild(e,t,r){if(r)for(const d of r.changes)e.deleteInstance(d.id);const s=this._bufferWriter,i=s.layout.stride,a=i/4,o=Math.floor(W/a);let n=e.numElements;for(;t.length>0;){const r=t.pop(),i=s.elementCount(r.geometry.attributes);if(n+i>o&&n>0){t.push(r);break}n+=i;const a=new v(r,0,0,this.highlightOrderMap);y(null==e.instances.get(r.id)),e.addInstance(r.id,a)}const l=n*a,h=G(l),u=s.layout.createView(h.buffer);let f=0;e.resetInstanceSummary(),e.instances.forEach((t,r)=>{this._writeGeometry(t.geometry,u,f);const i=f;f+=s.elementCount(t.geometry.geometry.attributes),e.updateInstance(r,i,f),e.updateDrawState(t)}),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(z(l)),e.vao.buffer()?.buffer.setSubData(h,0,0,f*a),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.getByteLength("geometry")/i),e.updateDrawCommands(this.highlightOrderMap,i),e}_applyRemoves(e,t){if(0===t.changes.length||null==this._bufferWriter)return;let r=1/0,s=-1/0;for(const o of t.changes){const t=o.id,i=e.instances.get(t);if(!i)continue;e.deleteInstance(t),U&&(r=Math.min(r,i.from),s=Math.max(s,i.to));const a=H.back();if(a){if(a.to===i.from){a.to=i.to;continue}if(a.from===i.to){a.from=i.from;continue}}const n=H.pushNew();n.from=i.from,n.to=i.to}w(H);const i=this._bufferWriter.layout.stride/4,a=e.vao.buffer()?.buffer;if(U){const t=(s-r)*i,o=G(t),n=this._bufferWriter.layout.createView(o.buffer);o.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=r&&e.to<=s))return;const t=e.from-r;this._writeGeometry(e.geometry,n,t)}),a?.setSubData(o,r*i,0,t)}else{const e=H.reduce((e,t)=>Math.max(e,t.numElements),0)*i,t=G(e);t.fill(0,0,e),H.forAll(e=>a?.setSubData(t,e.from*i,0,e.numElements*i))}e.holes.pushArray(H.data,H.length),H.forAll((e,t)=>H.data[t]=null),H.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null==this._bufferWriter)return;if(!O(e))return void this._applyAndRebuild(e,t,null);const s=this._bufferWriter,i=s.layout.stride/4,a=e.numElements,o=t.reduce((e,t)=>e+s.elementCount(t.geometry.attributes),0),n=Math.min((a+o)*i,W),l=4*n;if(e.vao.getByteLength("geometry")<z(W-P)&&l>e.vao.getByteLength("geometry"))return void this._applyAndRebuild(e,t,null);w(e.holes);const h=new Array;let u=1/0,f=-1/0;for(const r of t){const t=s.elementCount(r.geometry.attributes),i=B(e.holes,t);h.push(i),U&&null!=i&&(u=Math.min(i,u),f=Math.max(i+t,f))}const c=e.vao.buffer()?.buffer;let d=0,m=0,g=0;const p=G(U?(f-u)*i:n),_=s.layout.createView(p.buffer);if(t.forEach((t,r)=>{const a=h[r];if(null==a)return;const o=s.elementCount(t.geometry.attributes);if(!U){if(!(g===a)){const e=g-m;e>0&&c?.setSubData(p,m*i,0,e*i),m=a,d=0}this._writeGeometry(t,_,d),d+=o,g=a+o}const n=new v(t,a,a+o,this.highlightOrderMap);y(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}),U){const t=(f-u)*i;p.fill(0,0,t),e.instances.forEach(e=>{if(!(e.from>=u&&e.to<=f))return;const t=e.from-u;this._writeGeometry(e.geometry,_,t)}),m=u,g=f}const b=g-m;b>0&&c?.setSubData(p,m*i,0,b*i),r(t,(e,t)=>null==h[t])}_writeGeometry(e,t,r){null!=this._bufferWriter&&(u(j,e.transformation),j[12]-=e.localOrigin.vec3[0],j[13]-=e.localOrigin.vec3[1],j[14]-=e.localOrigin.vec3[2],f(R,j),c(R,R),this._bufferWriter.write(j,R,e.geometry.attributes,e.geometry.olidColor,t,r))}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){if(!this.material.shouldRender(e))return null;const{output:t,bind:r}=e,s=this.material.produces.get(r.slot);if(!s?.(t))return null;const{highlight:i,slot:a}=r,o=5===t,n=8===t,l=n||o,h=i?.name;if(l&&(0===this._highlightNames.size||n&&h&&!this._highlightNames.has(h)))return null;const u=e=>n&&!!h&&!e.has(h),f=6===t,c=!(l||f);for(const{buffers:d}of this._dataByOrigin.values())for(const s of d){if(u(s.highlightNames))continue;const i=o?s.drawCommandsHighlights.get(E):l?h?s.drawCommandsHighlights.get(h):s.drawCommandsHighlights.size>0:((f&&s.needsMultipleCommands()?s.drawCommandsShadowHighlightRest:s.drawCommandsDefault)||null)?.length??!1,n=c&&s.drawCommandsOccludees||null;if(i||n?.length){const s=this._glMaterials.load(e.rctx,a,t),i=s?.beginSlot(r);if(i)return i}}return null}render(e,t){const{output:r,bind:s}=e,{slot:i,highlight:a}=s,n=8===r,l=a?.name??"";if(n&&!a)return;const h=5===r,u=n||h,f=6===r,c=!(u||f),d=9===i||10===i?i:null,{rctx:m}=e;m.runAppleAmdDriverHelper();const g=m.bindTechnique(t,s,this.material.parameters);for(const p of this._dataByOrigin.values())for(const e of p.buffers){if(n&&(!e.hasHighlights||!e.drawCommandsHighlights.has(l)))continue;if(h&&(!e.hasHighlights||!e.drawCommandsHighlights.has(E)))continue;const r=()=>{const t=[],r=e.drawCommandsHighlights.get(E)??new o;return r&&t.push(r),t},i=u&&!h?e.drawCommandsHighlights.get(l)??null:null,a=h?r():u?i?[i]:I:f&&e.needsMultipleCommands()?[e.drawCommandsShadowHighlightRest]:[e.drawCommandsDefault],y=a.some(e=>e.length>0),_=c&&e.drawCommandsOccludees||null;if(y||_?.length){if(this._drawParameters.origin=p.origin,g.bindDraw(s,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e.vao),m.bindVAO(e.vao),y)for(const e of a)m.setPipelineState(t.getPipeline(!1,d)),e.forAll(e=>m.drawArrays(t.primitiveType,e.first,e.count));_?.length&&(m.setPipelineState(t.getPipeline(!0,d)),_.forAll(e=>m.drawArrays(t.primitiveType,e.first,e.count)))}}}static prune(){V=new Float32Array(P)}get test(){}};e([l({constructOnly:!0})],M.prototype,"material",void 0),e([l({})],M.prototype,"highlightOrderMap",void 0),M=e([h("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],M);class D{constructor(e){this.origin=e,this.changes=new Array}}function B(e,t){const r=e.find(e=>e.numElements>=t);if(null==r)return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}const j=d(),R=d(),H=new o({allocator:e=>e||new b,deallocator:null}),P=65536,S=4*P,x=1024,N=16777216,W=N/4;let V=new Float32Array(P);function G(e){return V.length<e&&(V=new Float32Array(e)),V}function z(e){const t=4*e;return t<=x?x:t<S?s(t):Math.max(Math.min(Math.ceil(1.5*t/S)*S,N),t)}const I=[];let U;export{M as MergedRenderer,z as sizeForVao};
5
+ import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{property as r}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators/subclass.js";import{SyncRenderPlugin as i}from"../../effects/RenderPlugin.js";import{MergedBuffer as s}from"./MergedBuffer.js";import{VaoRenderer as a}from"./VaoRenderer.js";let n=class extends i{constructor(e){super(e),this._dataByOrigin=new Map,this._buffer=null,this._renderer=null,this.drapedPriority=0}initialize(){this._buffer=new s({material:this.material,dataByOrigin:this._dataByOrigin,highlightOrderMap:this.highlightOrderMap}),this._renderer=new a({material:this.material,dataByOrigin:this._dataByOrigin})}destroy(){for(const e of this._dataByOrigin.values())e.dispose();this._dataByOrigin.clear(),this._buffer.destroy(),this._renderer.destroy()}hasHighlight(e){return this._renderer.hasHighlight(e)}initializeRenderContext(e){this._buffer.initializeRenderContext(e),this._renderer.initializeRenderContext(e)}uninitializeRenderContext(){this._buffer.uninitializeRenderContext(),this._renderer.uninitializeRenderContext()}get produces(){return this._renderer.produces}get hasOccludees(){return this._buffer.hasOccludees}get hasOnlyOccluders(){return!!(-2&this.renderOccludedFlags)}get hasEmissions(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}get renderOccludedFlags(){return this.material.renderOccludedFlags}get numGeometries(){let e=0;return this._dataByOrigin.forEach(r=>e+=r.buffers.reduce((e,r)=>e+r.instances.size,0)),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach(r=>e+=r.buffers.reduce((e,r)=>e+r.vao.cachedMemory,0)),e}forEachGeometry(e){this._dataByOrigin.forEach(r=>r.buffers.forEach(r=>r.instances.forEach(({geometry:r})=>e(r))))}modify(e,r){this._buffer.modify(e,r),this._renderer.updateHighlights()}get canCompact(){return this._buffer.canCompact}compact(e){return this._buffer.compact(e)}updateHighlights(e){this.highlightOrderMap=e,this._buffer.updateHighlights(e),this._renderer.updateHighlights()}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){return this._renderer.acquireTechniques(e)}render(e,r){return this._renderer.render(e,r)}static prune(){s.prune()}get test(){}};e([r({constructOnly:!0})],n.prototype,"material",void 0),e([r()],n.prototype,"highlightOrderMap",void 0),n=e([t("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],n);export{n as MergedRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import s from"../../../../../core/PooledArray.js";import{BufferRange as e}from"./BufferRange.js";import{DrawCommand as i}from"./DrawCommand.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";class a{constructor(){this._numElements=0,this._instances=new Map,this.holes=new s({allocator:t=>t||new e,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=r(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=r(),this.drawCommandsShadowHighlightRest=r()}get numElements(){return this._numElements}get instances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(t,s){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const t of this.instances.values())this.updateDrawState(t);this.updateDrawCommands(t,s)}}addInstance(t,s){this.deleteInstance(t),this._instances.set(t,s),this._numElements+=s.numElements}deleteInstance(t){const s=this._instances.get(t);s&&(this._numElements-=s.numElements,this._instances.delete(t))}updateInstance(t,s,e){const i=this._instances.get(t);i&&(this._numElements-=i.numElements,i.from=s,i.to=e,this._numElements+=i.numElements)}updateDrawState(t){if(t.isVisible){const{highlightName:s}=t;s&&this.highlightNames.add(s),t.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(t,s){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:e}=this;if(this._updateHighlightDrawCommands(t,e),!this.needsMultipleCommands()){const t=this.drawCommandsDefault.pushNew(),e=this.holes.front();return this.vao&&1===this.holes.length&&e.to===Math.floor(this.vao.getByteLength("geometry")/s)?(t.first=0,void(t.count=e.from)):(t.first=1/0,t.count=0,this._instances.forEach(s=>{t.first=Math.min(t.first,s.from),t.count=Math.max(t.count,s.to)}),void(t.count-=t.first))}for(const i of e)i.isVisible&&m(i.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,i)}get sortedInstances(){return Array.from(this._instances.values()).sort((t,s)=>t.from===s.from?t.to-s.to:t.from-s.from)}updateHighlights(t){this.highlightNames.clear();const s=this.sortedInstances;for(const e of s)e.updateHighlightOptions(t),e.isVisible&&e.highlightName&&this.highlightNames.add(e.highlightName);this._updateHighlightDrawCommands(t)}_updateHighlightDrawCommands(s,e=this.sortedInstances){const{drawCommandsHighlights:i,drawCommandsShadowHighlightRest:a}=this;i.clear(),a.clear();for(const h of e){if(h.updateHighlightOptions(s),!h.isVisible)continue;const{highlightName:e}=h;if(e){this.highlightNames.add(e);m(t(i,e,r),h)}e&&e===n||m(a,h)}}needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}class h extends a{}function o(t){return null!=t.vao}function r(){return new s({allocator:t=>t||new i,deallocator:t=>t})}function m(t,s){const e=t.back();if(null==e){const e=t.pushNew();return e.first=s.from,void(e.count=s.numElements)}if(l(e,s)){const t=s.from-e.first+s.numElements;e.count=t}else{const e=t.pushNew();e.first=s.from,e.count=s.numElements}}function l(t,s){return t.first+t.count>=s.from}export{a as PerBufferData,h as PerVaoData,o as hasVao};
5
+ import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import s from"../../../../../core/PooledArray.js";import{BufferRange as e}from"./BufferRange.js";import{DrawCommand as i}from"./DrawCommand.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";class a{constructor(){this._numElements=0,this._instances=new Map,this.holes=new s({allocator:t=>t||new e,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=r(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=r(),this.drawCommandsShadowHighlightRest=r()}get numElements(){return this._numElements}get instances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(t,s){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const t of this.instances.values())this.updateDrawState(t);this.updateDrawCommands(t,s)}}addInstance(t,s){this.deleteInstance(t),this._instances.set(t,s),this._numElements+=s.numElements}deleteInstance(t){const s=this._instances.get(t);s&&(this._numElements-=s.numElements,this._instances.delete(t))}updateInstance(t,s,e){const i=this._instances.get(t);i&&(this._numElements-=i.numElements,i.from=s,i.to=e,this._numElements+=i.numElements)}updateDrawState(t){if(t.isVisible){const{highlightName:s}=t;s&&this.highlightNames.add(s),t.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(t,s){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:e}=this;if(this._updateHighlightDrawCommands(t,e),!this.needsMultipleCommands){const t=this.drawCommandsDefault.pushNew(),e=this.holes.front();return this.vao&&1===this.holes.length&&e.to===Math.floor(this.vao.getByteLength("geometry")/s)?(t.first=0,void(t.count=e.from)):(t.first=1/0,t.count=0,this._instances.forEach(s=>{t.first=Math.min(t.first,s.from),t.count=Math.max(t.count,s.to)}),void(t.count-=t.first))}for(const i of e)i.isVisible&&m(i.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,i)}get sortedInstances(){return Array.from(this._instances.values()).sort((t,s)=>t.from===s.from?t.to-s.to:t.from-s.from)}updateHighlights(t){this.highlightNames.clear();const s=this.sortedInstances;for(const e of s)e.updateHighlightOptions(t),e.isVisible&&e.highlightName&&this.highlightNames.add(e.highlightName);this._updateHighlightDrawCommands(t)}_updateHighlightDrawCommands(s,e=this.sortedInstances){const{drawCommandsHighlights:i,drawCommandsShadowHighlightRest:a}=this;i.clear(),a.clear();for(const h of e){if(h.updateHighlightOptions(s),!h.isVisible)continue;const{highlightName:e}=h;if(e){this.highlightNames.add(e);m(t(i,e,r),h)}e&&e===n||m(a,h)}}get needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}class h extends a{}function o(t){return null!=t.vao}function r(){return new s({allocator:t=>t||new i,deallocator:t=>t})}function m(t,s){const e=t.back();if(null==e){const e=t.pushNew();return e.first=s.from,void(e.count=s.numElements)}if(l(e,s)){const t=s.from-e.first+s.numElements;e.count=t}else{const e=t.pushNew();e.first=s.from,e.count=s.numElements}}function l(t,s){return t.first+t.count>=s.from}export{a as PerBufferData,h as PerVaoData,o as hasVao};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{MemCachePool as e}from"../../../../../core/MemCachePool.js";import{VertexArrayObject as t}from"../../lib/VertexArrayObject.js";import{BufferObject as r}from"../../../../webgl/BufferObject.js";import{VertexBuffer as o}from"../../../../webgl/VertexBuffer.js";class c{constructor(t,r){this._rctx=t,this._layout=r,this._cache=new e(t.newCache,"VAOCache")}dispose(){this._cache.destroy()}newVao(e){const c=e.toString();let s=this._cache.pop(c);return s||(s=new t(this._rctx,new o(this._layout,r.createVertex(this._rctx,35044))),s.buffer()?.buffer.setSize(e),s)}deleteVao(e){if(null==e)return;const t=e.getByteLength("geometry").toString();this._cache.put(t,e)}}export{c as VaoCache};
5
+ import{MemCachePool as t}from"../../../../../core/MemCachePool.js";import{VertexArrayObject as e}from"../../lib/VertexArrayObject.js";import{VertexBuffer as r}from"../../../../webgl/VertexBuffer.js";class o{constructor(e,r){this._rctx=e,this._layout=r,this._cache=new t(e.newCache,"VAOCache")}dispose(){this._cache.destroy()}newVao(t){const o=t.toString();let c=this._cache.pop(o);return c||(c=new e(this._rctx,new r(this._rctx,this._layout)),c.buffer()?.setSize(t),c)}deleteVao(t){if(null==t)return;const e=t.getByteLength("geometry").toString();this._cache.put(e,t)}}export{o as VaoCache};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as t}from"tslib";import i from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{GLMaterials as a}from"../../lib/GLMaterials.js";import{DrawParameters as o}from"../DrawParameters.js";import{defaultHighlightName as n}from"../../../../support/HighlightDefaults.js";let h=class extends i{constructor(t){super(t),this._glMaterials=null,this._drawParameters=new o,this._highlightNames=new Set,this._produces=new Map}initialize(){this._updateProduces()}destroy(){this.uninitializeRenderContext()}get _hasHighlights(){return this._highlightNames.size>0}hasHighlight(t){return this._highlightNames.has(t)}get produces(){return this._produces}_updateProduces(){this.material.produces.forEach((t,i)=>{this._produces.set(i,i=>!(0===this.dataByOrigin.size||!(8!==i&&5!==i||this._hasHighlights))&&t(i))})}initializeRenderContext(t){this._glMaterials=new a(this.material,t.materials)}uninitializeRenderContext(){this._glMaterials=e(this._glMaterials)}acquireTechniques(t){if(!this.material.shouldRender(t))return null;const{output:i,bind:e}=t,s=this.material.produces.get(e.slot);if(!s?.(i))return null;const{highlight:r,slot:a}=e,o=5===i,h=8===i,l=h||o,g=r?.name;if(l&&(0===this._highlightNames.size||h&&g&&!this._highlightNames.has(g)))return null;const d=t=>h&&!!g&&!t.has(g),m=6===i,u=!(l||m);for(const{buffers:c}of this.dataByOrigin.values())for(const s of c){if(d(s.highlightNames))continue;const r=o?s.drawCommandsHighlights.get(n):l?g?s.drawCommandsHighlights.get(g):s.drawCommandsHighlights.size>0:((m&&s.needsMultipleCommands?s.drawCommandsShadowHighlightRest:s.drawCommandsDefault)||null)?.length??!1,h=u&&s.drawCommandsOccludees||null;if(r||h?.length){const s=this._glMaterials.load(t.rctx,a,i),r=s?.beginSlot(e);if(r)return r}}return null}render(t,i){const{output:e,bind:s}=t,{slot:r,highlight:a}=s,o=8===e,h=a?.name??"";if(o&&!a)return;const l=5===e,g=o||l,d=6===e,m=!(g||d),u=9===r||10===r?r:null,{rctx:c}=t;c.runAppleAmdDriverHelper();const p=c.bindTechnique(i,s,this.material.parameters);for(const f of this.dataByOrigin.values())for(const t of f.buffers){if(o&&(!t.hasHighlights||!t.drawCommandsHighlights.has(h)))continue;if(l&&(!t.hasHighlights||!t.drawCommandsHighlights.has(n)))continue;const e=g&&!l?t.drawCommandsHighlights.get(h)??null:null,r=l?t.drawCommandsHighlights.get(n):g?e:d&&t.needsMultipleCommands?t.drawCommandsShadowHighlightRest:t.drawCommandsDefault,a=null!=r,w=m&&t.drawCommandsOccludees||null;if(a||w?.length){if(this._drawParameters.origin=f.origin,p.bindDraw(s,this.material.parameters,this._drawParameters),i.ensureAttributeLocations(t.vao),c.bindVAO(t.vao),a)for(const t of r)c.setPipelineState(i.getPipeline(!1,u)),c.drawArrays(i.primitiveType,t.first,t.count);if(w?.length){c.setPipelineState(i.getPipeline(!0,u));for(const t of w)c.drawArrays(i.primitiveType,t.first,t.count)}}}}updateHighlights(){const{_highlightNames:t}=this;t.clear();for(const i of this.dataByOrigin.values())for(const e of i.buffers)for(const i of e.highlightNames)t.add(i);this._updateProduces()}get test(){}};t([s({constructOnly:!0})],h.prototype,"material",void 0),t([s({constructOnly:!0})],h.prototype,"dataByOrigin",void 0),h=t([r("esri.views.3d.webgl-engine.materials.renderers.VaoRenderer")],h);export{h as VaoRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as p}from"tslib";import{createTask as e}from"../core/asyncUtils.js";import t from"../core/Error.js";import has from"../core/has.js";import o from"../core/Logger.js";import{throwIfAborted as i,wrapAbortWithTimeout as s,allSettledValues as r,createResolver as a}from"../core/promiseUtils.js";import{watch as u,syncAndInitial as n,whenOnce as c}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as d}from"./input/InputManager.js";function m(p){return null!=p&&"open"in p&&"declaredClass"in p}function f(p){return null!=p&&"declaredClass"in p&&"dockOptions"in p}const w=a=>{const w=a;let V=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([u(()=>[this.ui,this.popup],([p,e],t)=>{const o="popup",i="manual";if(t){const[p,i]=t;p&&m(i)&&(i.view=null,f(i)&&(p.remove(i,o),i!==e&&e&&i.destroy()))}p&&m(e)&&(e.view=this,f(e)&&p.add(e,{key:o,position:i,internal:!0}))},n),this.on("click",p=>{this.popup&&this.popupEnabled&&("mouse"!==p.pointerType||0===p.button)&&(m(this.popup)?this.popup.viewModel.handleViewClick(p):p.defer(async()=>{await this.setupPopup(),m(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(p)}))},d.WIDGET)]),c(()=>this.ready&&this.popupEnabled&&!this.updating).then(()=>{import("../widgets/Popup.js")})}destroy(){this.destroyed||this.closePopup()}async openPopup(p){if(m(this.popup))return this.popup.open(p);try{if(await this.setupPopup(),!this.popup)return void o.getLogger(this).error(new t("view:null-popup","Popup is null and can't be opened"));this.popup.open(p)}catch{}}closePopup(){this._popupSetupTask?.abort(),m(this.popup)&&this.popup.close()}async fetchPopupFeatures(p,e){return await this.when(),this._popupHitsToFeatures(await this._getPopupHits(p,e),e)}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!m(this.popup))return this._popupSetupTask=e(async p=>{const{default:e}=await import("../widgets/Popup.js");if(i(p),!this.popup||m(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new e(t)}),this._popupSetupTask.promise}async _popupHitsToFeatures({location:p,hits:e},t){const o=[],i=[];let a=!1;const u=s(t,has("popup-view-fetch-timeout")??P),n=p=>{const e=new y(p);return i.push(e),o.push(e.promise),e},c=p=>{const e=i.at(-1);return e&&e.layerView===p&&!a?e:n(p)};for(const s of e)if("graphic"in s){c(s.layerView).graphics.push(s.graphic),a=!1}else o.push(s.layerView.fetchPopupFeaturesAtLocation(s.mapPoint,u)),a=!0;i.map(p=>p.resolve(u));const h=r(o).then(p=>p.filter(p=>!!p).flat());return{pendingFeatures:o,allGraphicsPromise:h,location:p}}async _getPopupHits(p,e){const{hits:t,location:o}=await this.popupHitTest(p);i(e);const s=[];for(const i of t)if("graphic"in i){if(this._isValidPopupGraphic(i.graphic,e)){const p=this._isValidPopupGraphicsLayerView(i.layerView)?i.layerView:void 0;s.push({graphic:i.graphic,layerView:p})}}else this._isValidPopupLocationLayerView(i.layerView)&&s.push({mapPoint:i.mapPoint,layerView:i.layerView});return{hits:s,location:o}}_isValidPopupGraphic(p,e){return p&&!!p.getEffectivePopupTemplate(e?.defaultPopupTemplateEnabled)}_isValidPopupGraphicsLayerView(p){return!p||(!("layer"in p)||!p.suspended)&&"fetchPopupFeaturesFromGraphics"in p}_isValidPopupLocationLayerView(p){return(!("layer"in p)||!p.suspended)&&"fetchPopupFeaturesAtLocation"in p}};return p([h()],V.prototype,"popup",void 0),p([h()],V.prototype,"popupEnabled",void 0),V=p([l("esri.views.PopupView")],V),V};class y{constructor(p){this.layerView=p,this._resolver=a(),this.graphics=[]}get promise(){return this._resolver.promise}resolve(p){const{layerView:e,graphics:t,_resolver:o}=this;if(!e)return o.resolve(t),o.promise;let i;return e.fetchPopupFeaturesFromGraphics(t,p).catch(p=>(i=p,null)).then(p=>{p?o.resolve(p):o.reject(i)}),o.promise}}const P=5e3;export{w as PopupView};
5
+ import{__decorate as p}from"tslib";import{createTask as e}from"../core/asyncUtils.js";import t from"../core/Error.js";import has from"../core/has.js";import o from"../core/Logger.js";import{throwIfAborted as i,wrapAbortWithTimeout as s,allSettledValues as r,createResolver as a}from"../core/promiseUtils.js";import{watch as u,syncAndInitial as n,whenOnce as c}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/RandomLCG.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{ViewEventPriorities as d}from"./input/InputManager.js";function m(p){return null!=p&&"open"in p&&"declaredClass"in p}function f(p){return null!=p&&"declaredClass"in p&&"dockOptions"in p}const w=a=>{const w=a;let V=class extends w{constructor(){super(...arguments),this._popupSetupTask=null,this.popup={},this.popupEnabled=!0}initialize(){this.addHandles([u(()=>[this.ui,this.popup],([p,e],t)=>{const o="popup",i="manual";if(t){const[p,i]=t;p&&m(i)&&(i.view=null,f(i)&&(p.remove(i,o),i!==e&&e&&i.destroy()))}p&&m(e)&&(e.view=this,f(e)&&p.add(e,{key:o,position:i,internal:!0}))},n),this.on("click",p=>{this.popup&&this.popupEnabled&&("mouse"!==p.pointerType||0===p.button)&&(m(this.popup)?this.popup.viewModel.handleViewClick(p):p.defer(async()=>{await this.setupPopup(),m(this.popup)&&!this.destroyed&&this.ready&&this.popupEnabled&&this.popup.viewModel.handleViewClick(p)}))},d.WIDGET)]),c(()=>this.ready&&this.popupEnabled&&!this.updating).then(()=>import("../widgets/Popup.js"))}destroy(){this.destroyed||this.closePopup()}async openPopup(p){if(m(this.popup))return this.popup.open(p);try{if(await this.setupPopup(),!this.popup)return void o.getLogger(this).error(new t("view:null-popup","Popup is null and can't be opened"));this.popup.open(p)}catch{}}closePopup(){this._popupSetupTask?.abort(),m(this.popup)&&this.popup.close()}async fetchPopupFeatures(p,e){return await this.when(),this._popupHitsToFeatures(await this._getPopupHits(p,e),e)}async setupPopup(){if(this._popupSetupTask?.abort(),this.popup&&!m(this.popup))return this._popupSetupTask=e(async p=>{const{default:e}=await import("../widgets/Popup.js");if(i(p),!this.popup||m(this.popup))return;const t=this.popup;delete t.open,delete t.close,this.popup=new e(t)}),this._popupSetupTask.promise}async _popupHitsToFeatures({location:p,hits:e},t){const o=[],i=[];let a=!1;const u=s(t,has("popup-view-fetch-timeout")??P),n=p=>{const e=new y(p);return i.push(e),o.push(e.promise),e},c=p=>{const e=i.at(-1);return e&&e.layerView===p&&!a?e:n(p)};for(const s of e)if("graphic"in s){c(s.layerView).graphics.push(s.graphic),a=!1}else o.push(s.layerView.fetchPopupFeaturesAtLocation(s.mapPoint,u)),a=!0;i.forEach(p=>p.resolve(u));const h=r(o).then(p=>p.filter(p=>!!p).flat());return{pendingFeatures:o,allGraphicsPromise:h,location:p}}async _getPopupHits(p,e){const{hits:t,location:o}=await this.popupHitTest(p);i(e);const s=[];for(const i of t)if("graphic"in i){if(this._isValidPopupGraphic(i.graphic,e)){const p=this._isValidPopupGraphicsLayerView(i.layerView)?i.layerView:void 0;s.push({graphic:i.graphic,layerView:p})}}else this._isValidPopupLocationLayerView(i.layerView)&&s.push({mapPoint:i.mapPoint,layerView:i.layerView});return{hits:s,location:o}}_isValidPopupGraphic(p,e){return p&&!!p.getEffectivePopupTemplate(e?.defaultPopupTemplateEnabled)}_isValidPopupGraphicsLayerView(p){return!p||(!("layer"in p)||!p.suspended)&&"fetchPopupFeaturesFromGraphics"in p}_isValidPopupLocationLayerView(p){return(!("layer"in p)||!p.suspended)&&"fetchPopupFeaturesAtLocation"in p}};return p([h()],V.prototype,"popup",void 0),p([h()],V.prototype,"popupEnabled",void 0),V=p([l("esri.views.PopupView")],V),V};class y{constructor(p){this.layerView=p,this._resolver=a(),this.graphics=[]}get promise(){return this._resolver.promise}resolve(p){const{layerView:e,graphics:t,_resolver:o}=this;if(!e)return o.resolve(t),o.promise;let i;return e.fetchPopupFeaturesFromGraphics(t,p).catch(p=>(i=p,null)).then(p=>{p?o.resolve(p):o.reject(i)}),o.promise}}const P=5e3;export{w as PopupView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import{EventedMixin as r}from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import{EsriPromiseMixin as a}from"../core/Promise.js";import{watch as n,initial as l,whenOnce as p,syncAndInitial as m}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import f from"../geometry/Extent.js";import u from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import{load as j,execute as w}from"../geometry/operators/projectOperator.js";import b from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as v}from"../layers/support/MediaElementView.js";import M from"../layers/support/TileInfo.js";import _ from"../layers/support/VideoElement.js";import{DOMContainer as S}from"./DOMContainer.js";import{Viewport2DBaseMixin as V}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as C}from"./Viewport2DMixin.js";import x from"./2d/AnimationManager.js";import P from"./2d/MapViewConstraints.js";import"../core/Error.js";import"../core/scheduling.js";import"../core/Logger.js";import"../core/mathUtils.js";import"../config.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"../symbols/Font.js";import"../core/ObjectPool.js";import"../geometry/support/spatialReferenceUtils.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectEnclosingPolygon.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectRadial.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectSuppress.js";import"../symbols/cim/effects/EffectTaperedPolygon.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../symbols/cim/constants.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import{Container as E}from"./2d/engine/Container.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./webgl/enums.js";import"./2d/engine/webgl/shaders/BackgroundPrograms.js";import"./webgl/Program.js";import"./webgl/BufferObject.js";import"./webgl/checkWebGLError.js";import"./webgl/VertexAttributeLayouts.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/cpuMapped/MappedMesh.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/shaders/TileInfoPrograms.js";import"./webgl/Texture.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"../request.js";import"../core/urlUtils.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./webgl/FramebufferObject.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./webgl/Renderbuffer.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/shaderGraph/techniques/animated/attributes.js";import"./2d/engine/webgl/mesh/templates/templateUtils.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../core/sql/UnknownTimeZone.js";import"luxon";import"../intl/locale.js";import"../layers/support/fieldUtils.js";import"../time/constants.js";import"./2d/engine/webgl/animations/instructions.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/renderState.js";import"./3d/webgl-engine/core/shaderModules/glsl.js";import"./webgl/testSVGPremultipliedAlpha.js";import{ManagedCanvas as G}from"./2d/engine/ManagedCanvas.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/meshing/definitions.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"../chunks/earcut.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtilsCommon.js";import"../geometry/support/Ellipsoid.js";import"../kernel.js";import"./2d/layers/support/util.js";import D from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/unitUtils.js";import"../geometry/ellipsoidUtils.js";import"../chunks/pe.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import q from"./2d/engine/webgl/Overlay.js";import z from"./2d/engine/webgl/OverlayContainer.js";import O from"./navigation/Navigation.js";import T from"./ui/DefaultUI.js";import W from"./ui/video/DefaultUIVideo.js";const k=new t("#000");let A;async function U(){const[,{ParentStage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);A=e}const F=.01,H=["feature","geojson","csv","stream","ogc-feature","catalog","wfs","parquet","graphics","group"];let L=class extends s{};L=e([c("esri.views.VideoView.Base")],L);let B=class extends(C(V(S(r(a(L)))))){constructor(e){super(e),this._isValid=!1,this._prevZoomEnabled=!1,this._prevRotationEnabled=!1,this.stage=null,this.childStage=null,this._operationalDataView=null,this.operationalDataVisible=!1,this.layer=null,this.map=null,this.navigation=new O,this.ready=!1,this.spatialReference=new y({wkid:0}),this.stateManager=new R({constraints:new P({view:this,minScale:1,maxScale:F})}),this.type="2d",this.ui=new W,this.view2dType="video",this.addHandles([n(()=>this.preconditionsReady,e=>e?this._startup():this._teardown()),n(()=>this.layer,()=>this.addResolvingPromise(p(()=>this.ready)),l),n(()=>this.videoSize,([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}),n(()=>this.size,e=>{this._operationalDataView&&this._operationalDataView.stateManager.resize(e[0],e[1])}),n(()=>[this.layer?.frameEffect,this._effectsContainer],()=>{this._effectsContainer&&(this._effectsContainer.effect=this.layer?.frameEffect??null)},m)])}initialize(){this._prevZoomEnabled="zoom"===this.navigation.actionMap.mouseWheel&&this.ui.components.includes("zoom"),this._prevRotationEnabled="rotate"===this.navigation.actionMap.dragSecondary&&this.ui.components.includes("compass"),this.addHandles([n(()=>[this.operationalDataVisible,this.childStage],()=>{this.childStage&&(this.childStage.videoScreenRenderer.visible=this.operationalDataVisible),this.operationalDataVisible&&(this.scale=1,this.rotation=0),this.navigation&&(this._prevZoomEnabled&&(this.navigation.actionMap.mouseWheel=this.operationalDataVisible?"none":"zoom",this.navigation.actionMap.dragPrimary=this.operationalDataVisible?"none":"pan",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"zoom"!==e):[...new Set([...this.ui.components,"zoom"])])),this._prevRotationEnabled&&(this.navigation.actionMap.dragSecondary=this.operationalDataVisible?"none":"rotate",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"compass"!==e):[...new Set([...this.ui.components,"compass"])])))},m)]),this.addResolvingPromise(U().then(()=>(this._isValid=!0,p(()=>this.ready))))}destroy(){this._teardown(),this.removeAllHandles(),this._set("preconditionsReady",!1),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get preconditionsReady(){return!(!this._isValid||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}async hitTest(e,t){return this._operationalDataView&&this._operationalDataView.ready?this._operationalDataView.hitTest(e,t):{screenPoint:e,results:[]}}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference);const t={renderingOptions:this.renderingOptions,backgroundColor:k,groundControlPoints:()=>this.layer?.groundControlPoints,getSize:()=>this.videoSize},i=new A(this.surface,t,new G(this.surface));this.stage=i,this._prepareStage(this.stage),this.childStage=i.childStage,this._prepareChildStage(this.childStage);const s=new x({view:this});this._set("animationManager",s);const r=new D({view:this,animationManager:s});this._set("mapViewNavigation",r),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.stage.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer.removeAllChildren(),this._overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager.teardown(),this.frameTask.stop(),this.stationaryManager.clear()}_getViewpoint(){return new i({targetGeometry:new u({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([n(()=>this.stationary,t=>e.stationary=t,m),n(()=>this.state.id,()=>e.state=this.state,m),n(()=>this.renderingOptions,t=>e.renderingOptions=t,m)],"video-view"),this._extent=new f({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new v({element:new _({video:this.layer?.videoElement,georeference:new b({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new q(this._videoElementView);this._overlayContainer=new z,this._overlayContainer.addChild(t),this._effectsContainer=new E,this._effectsContainer.addChild(this._overlayContainer),this.stage.addChild(this._effectsContainer);const i=document.createElement("div");i.classList.add("esri-video-poster"),this.container?.classList.add("esri-video-view"),this.container?.appendChild(i)}_prepareChildStage(e){this.addHandles([n(()=>this.map,async t=>{if(!t)return;const{default:i}=await import("./video/VideoOperationalDataView.js");this._operationalDataView=new i({stage:e,layerViewFilter:e=>new Set(H).has(e.type),width:this.size[0],height:this.size[1],map:t}),p(()=>this._operationalDataView?.ready).then(()=>{e.videoScreenRenderer.visible=this.operationalDataVisible})},m),n(()=>this.layer?.groundControlPoints,async()=>{if(!this.layer?.groundControlPoints||!e.state)return;const t=this.layer.groundControlPoints,i=t?.length;if(!i)return;await j();const s=new Array(i),r=e.state.spatialReference;for(let e=0;e<i;e++){const{lat:i,lon:o}=t[e];s[e]=w(new u(o,i),r)}let o=1/0,a=1/0,n=-1/0,l=-1/0;for(const e of s)o=Math.min(o,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),l=Math.max(l,e.y);const p=f.fromJSON({xmin:o,ymin:a,xmax:n,ymax:l,spatialReference:r});await(this._operationalDataView?.goTo(p,{animate:!1}).catch(()=>{}))},m)])}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>F;r/=2)i.push(r);i.push(F);const{lods:s}=M.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}};e([h()],B.prototype,"_overlayContainer",void 0),e([h()],B.prototype,"_isValid",void 0),e([h()],B.prototype,"_effectsContainer",void 0),e([h()],B.prototype,"constraintsInfo",null),e([h()],B.prototype,"operationalDataVisible",void 0),e([h()],B.prototype,"layer",void 0),e([h()],B.prototype,"map",void 0),e([h({type:O,nonNullable:!0})],B.prototype,"navigation",void 0),e([h({readOnly:!0})],B.prototype,"preconditionsReady",null),e([h({readOnly:!0})],B.prototype,"ready",void 0),e([h({readOnly:!0})],B.prototype,"rendering",null),e([h()],B.prototype,"scale",null),e([h()],B.prototype,"spatialReference",void 0),e([h()],B.prototype,"stateManager",void 0),e([h()],B.prototype,"type",void 0),e([h(),d(e=>e instanceof T?e:g(W,e))],B.prototype,"ui",void 0),e([h({readOnly:!0})],B.prototype,"videoSize",null),e([h({readOnly:!0})],B.prototype,"view2dType",void 0),B=e([c("esri.views.VideoView")],B);const I=B;export{I as default};
5
+ import{__decorate as e}from"tslib";import t from"../Color.js";import i from"../Viewpoint.js";import s from"../core/Accessor.js";import{EventedMixin as r}from"../core/Evented.js";import{destroyMaybe as o}from"../core/maybe.js";import{EsriPromiseMixin as a}from"../core/Promise.js";import{watch as n,initial as l,whenOnce as p,syncAndInitial as m}from"../core/reactiveUtils.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import{ensureClass as g}from"../core/accessorSupport/ensureType.js";import f from"../geometry/Extent.js";import u from"../geometry/Point.js";import y from"../geometry/SpatialReference.js";import{load as j,execute as w}from"../geometry/operators/projectOperator.js";import b from"../layers/support/ExtentAndRotationGeoreference.js";import{MediaElementView as v}from"../layers/support/MediaElementView.js";import M from"../layers/support/TileInfo.js";import _ from"../layers/support/VideoElement.js";import{DOMContainer as S}from"./DOMContainer.js";import{Viewport2DBaseMixin as V}from"./Viewport2DBaseMixin.js";import{Viewport2DMixin as C}from"./Viewport2DMixin.js";import x from"./2d/AnimationManager.js";import P from"./2d/MapViewConstraints.js";import"../core/Error.js";import"../core/scheduling.js";import"../core/Logger.js";import"../core/mathUtils.js";import"../config.js";import"../core/floatRGBA.js";import"../geometry/Geometry.js";import"../geometry/Multipoint.js";import"../geometry/Polygon.js";import"../geometry/Polyline.js";import"../symbols/Font.js";import"../core/ObjectPool.js";import"../geometry/support/spatialReferenceUtils.js";import"../symbols/cim/effects/EffectAddControlPoints.js";import"../symbols/cim/effects/EffectArrow.js";import"../symbols/cim/effects/EffectBuffer.js";import"../symbols/cim/effects/EffectControlMeasureLine.js";import"../symbols/cim/effects/EffectCut.js";import"../symbols/cim/effects/EffectDashes.js";import"../symbols/cim/effects/EffectDonut.js";import"../symbols/cim/effects/EffectEnclosingPolygon.js";import"../symbols/cim/effects/EffectJog.js";import"../symbols/cim/effects/EffectMove.js";import"../symbols/cim/effects/EffectOffset.js";import"../symbols/cim/effects/EffectRadial.js";import"../symbols/cim/effects/EffectReverse.js";import"../symbols/cim/effects/EffectRotate.js";import"../symbols/cim/effects/EffectScale.js";import"../symbols/cim/effects/EffectSuppress.js";import"../symbols/cim/effects/EffectTaperedPolygon.js";import"../symbols/cim/effects/EffectWave.js";import"../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../symbols/cim/placements/PlacementAtExtremities.js";import"../symbols/cim/placements/PlacementAtRatioPositions.js";import"../symbols/cim/placements/PlacementInsidePolygon.js";import"../symbols/cim/placements/PlacementOnLine.js";import"../symbols/cim/placements/PlacementOnVertices.js";import"../symbols/cim/placements/PlacementPolygonCenter.js";import"../symbols/cim/constants.js";import"../core/libs/gl-matrix-2/factories/vec2f32.js";import"../symbols/support/defaults.js";import"../symbols/cim/OverrideHelper.js";import{Container as E}from"./2d/engine/Container.js";import"../core/libs/gl-matrix-2/factories/vec4f32.js";import"./webgl/enums.js";import"./2d/engine/webgl/shaders/BackgroundPrograms.js";import"./webgl/Program.js";import"./webgl/checkWebGLError.js";import"./webgl/VertexAttributeLayouts.js";import"./webgl/BufferObject.js";import"./2d/engine/webgl/AFeatureTile.js";import"./2d/engine/webgl/DisplayEntity.js";import"./2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"./2d/engine/webgl/cpuMapped/MappedMesh.js";import"./2d/engine/webgl/number.js";import"./2d/engine/webgl/shaders/TileInfoPrograms.js";import"./webgl/Texture.js";import"./2d/engine/webgl/shaders/BitBlitPrograms.js";import"../request.js";import"../core/urlUtils.js";import"../core/pbf.js";import"./2d/engine/webgl/shaders/StencilPrograms.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"./2d/engine/webgl/shaders/HighlightPrograms.js";import"./webgl/FramebufferObject.js";import"./2d/engine/webgl/meshing/SimpleMesh.js";import"./webgl/Renderbuffer.js";import"./2d/engine/webgl/PooledUint32Array.js";import"./2d/engine/webgl/Profiler.js";import"./2d/engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"./2d/engine/webgl/shaderGraph/techniques/animated/attributes.js";import"./2d/engine/webgl/mesh/templates/templateUtils.js";import"./2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../geometry/support/aaBoundingBox.js";import"./2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"./2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../core/sql/UnknownTimeZone.js";import"luxon";import"../intl/locale.js";import"../layers/support/fieldUtils.js";import"../time/constants.js";import"./2d/engine/webgl/animations/instructions.js";import"./2d/engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"./webgl/renderState.js";import"./3d/webgl-engine/core/shaderModules/glsl.js";import"./webgl/testSVGPremultipliedAlpha.js";import{ManagedCanvas as G}from"./2d/engine/ManagedCanvas.js";import"./2d/engine/transitions/FadeTransition.js";import"./2d/engine/webgl/meshing/definitions.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"./2d/LabelManager.js";import"./2d/layers/graphics/GraphicsView2D.js";import"../chunks/earcut.js";import"../core/libs/gl-matrix-2/factories/vec3f32.js";import"../geometry/support/normalizeUtilsCommon.js";import"../geometry/support/Ellipsoid.js";import"../kernel.js";import"./2d/layers/support/util.js";import D from"./2d/navigation/MapViewNavigation.js";import"../core/asyncUtils.js";import"../core/support/UpdatingHandles.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../core/unitUtils.js";import"../geometry/ellipsoidUtils.js";import"../chunks/pe.js";import"../geometry/projection/projectors.js";import"./2d/engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../geometry/support/geodesicConstants.js";import{ViewStateManager as R}from"./2d/ViewStateManager.js";import q from"./2d/engine/webgl/Overlay.js";import z from"./2d/engine/webgl/OverlayContainer.js";import O from"./navigation/Navigation.js";import T from"./ui/DefaultUI.js";import W from"./ui/video/DefaultUIVideo.js";const k=new t("#000");let A;async function U(){const[,{ParentStage:e}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);A=e}const F=.01,H=["feature","geojson","csv","stream","ogc-feature","catalog","wfs","parquet","graphics","group"];let L=class extends s{};L=e([c("esri.views.VideoView.Base")],L);let B=class extends(C(V(S(r(a(L)))))){constructor(e){super(e),this._isValid=!1,this._prevZoomEnabled=!1,this._prevRotationEnabled=!1,this.stage=null,this.childStage=null,this._operationalDataView=null,this.operationalDataVisible=!1,this.layer=null,this.map=null,this.navigation=new O,this.ready=!1,this.spatialReference=new y({wkid:0}),this.stateManager=new R({constraints:new P({view:this,minScale:1,maxScale:F})}),this.type="2d",this.ui=new W,this.view2dType="video",this.addHandles([n(()=>this.preconditionsReady,e=>e?this._startup():this._teardown()),n(()=>this.layer,()=>this.addResolvingPromise(p(()=>this.ready)),l),n(()=>this.videoSize,([e,t])=>{this._extent&&e&&t&&(this._extent.xmax=e,this._extent.ymax=t)}),n(()=>this.size,e=>{this._operationalDataView&&this._operationalDataView.stateManager.resize(e[0],e[1])}),n(()=>[this.layer?.frameEffect,this._effectsContainer],()=>{this._effectsContainer&&(this._effectsContainer.effect=this.layer?.frameEffect??null)},m)])}initialize(){this._prevZoomEnabled="zoom"===this.navigation.actionMap.mouseWheel&&this.ui.components.includes("zoom"),this._prevRotationEnabled="rotate"===this.navigation.actionMap.dragSecondary&&this.ui.components.includes("compass"),this.addHandles([n(()=>[this.operationalDataVisible,this.childStage],()=>{this.childStage&&(this.childStage.videoScreenRenderer.visible=this.operationalDataVisible),this.operationalDataVisible&&(this.scale=1,this.rotation=0),this.navigation&&(this._prevZoomEnabled&&(this.navigation.actionMap.mouseWheel=this.operationalDataVisible?"none":"zoom",this.navigation.actionMap.dragPrimary=this.operationalDataVisible?"none":"pan",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"zoom"!==e):[...new Set([...this.ui.components,"zoom"])])),this._prevRotationEnabled&&(this.navigation.actionMap.dragSecondary=this.operationalDataVisible?"none":"rotate",this.ui.components&&(this.ui.components=this.operationalDataVisible?this.ui.components.filter(e=>"compass"!==e):[...new Set([...this.ui.components,"compass"])])))},m)]),this.addResolvingPromise(U().then(()=>(this._isValid=!0,p(()=>this.ready))))}destroy(){this._teardown(),this.removeAllHandles(),this._set("preconditionsReady",!1),this.frameTask=o(this.frameTask),this.goToManager.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get constraintsInfo(){return{lods:null,spatialReference:this.spatialReference}}get preconditionsReady(){return!(!this._isValid||0===this.width||0===this.height||0===this.videoSize[0]||0===this.videoSize[1])}get rendering(){return this.stage?.renderRequested??!1}get scale(){return this.stateManager?.scale??0}set scale(e){this.stateManager&&(this.stateManager.scale=e)}get videoSize(){if(!this.layer?.videoWidth||!this.layer?.videoHeight)return[0,0];const[e,t]=this.size,i=(this.layer?.videoWidth||0)/(this.layer?.videoHeight||0),s=t*i,r=e/i;return e/t>=1?i>=1?s<=e?[s,t]:[e,r]:r<=t?[e,r]:[s,t]:i>=1?r<=t?[e,r]:[s,t]:s<=e?[s,t]:[e,r]}async hitTest(e,t){return this._operationalDataView&&this._operationalDataView.ready?this._operationalDataView.hitTest(e,t):{screenPoint:e,results:[]}}_startup(){if(!this.layer)return;const e=this._getViewpoint();this.stateManager.startup(e,this.size,e.targetGeometry.spatialReference);const t={renderingOptions:this.renderingOptions,backgroundColor:k,groundControlPoints:()=>this.layer?.groundControlPoints,getSize:()=>this.videoSize},i=new A(this.surface,t,new G(this.surface));this.stage=i,this._prepareStage(this.stage),this.childStage=i.childStage,this._prepareChildStage(this.childStage);const s=new x({view:this});this._set("animationManager",s);const r=new D({view:this,animationManager:s});this._set("mapViewNavigation",r),this._updateConstraints(),this.frameTask.start(),this._set("ready",!0)}_teardown(){this.stage.destroy(),this.stage=null,this._videoElementView=null,this._overlayContainer.removeAllChildren(),this._overlayContainer=null,this.removeHandles("video-view"),this._set("ready",!1),this.stateManager.teardown(),this.frameTask.stop(),this.stationaryManager.clear()}_getViewpoint(){return new i({targetGeometry:new u({x:this.videoSize[0]/2,y:this.videoSize[1]/2,spatialReference:this.spatialReference}),scale:1})}_prepareStage(e){this.addHandles([n(()=>this.stationary,t=>e.stationary=t,m),n(()=>this.state.id,()=>e.state=this.state,m),n(()=>this.renderingOptions,t=>e.renderingOptions=t,m)],"video-view"),this._extent=new f({xmin:0,ymin:0,xmax:this.videoSize[0],ymax:this.videoSize[1],spatialReference:{wkid:0}}),this._videoElementView=new v({element:new _({video:this.layer?.videoElement,georeference:new b({extent:this._extent}),autoplay:!1}),spatialReference:this.spatialReference});const t=new q(this._videoElementView);this._overlayContainer=new z,this._overlayContainer.addChild(t),this._effectsContainer=new E,this._effectsContainer.addChild(this._overlayContainer),this.stage.addChild(this._effectsContainer);const i=document.createElement("div");i.classList.add("esri-video-poster"),this.container?.classList.add("esri-video-view"),this.container?.appendChild(i)}_prepareChildStage(e){this.addHandles([n(()=>this.map,async t=>{if(!t)return;const{default:i}=await import("./video/VideoOperationalDataView.js");this._operationalDataView=new i({stage:e,layerViewFilter:e=>new Set(H).has(e.type),width:this.size[0],height:this.size[1],map:t}),p(()=>this._operationalDataView?.ready).then(()=>{e.videoScreenRenderer.visible=this.operationalDataVisible})},m),n(()=>this.layer?.groundControlPoints,async()=>{if(!this.layer?.groundControlPoints||!e.state)return;const t=this.layer.groundControlPoints,i=t?.length;if(!i)return;await j();const s=new Array(i),r=e.state.spatialReference;for(let e=0;e<i;e++){const{lat:i,lon:o}=t[e];s[e]=w(new u(o,i),r)}let o=1/0,a=1/0,n=-1/0,l=-1/0;for(const e of s)o=Math.min(o,e.x),a=Math.min(a,e.y),n=Math.max(n,e.x),l=Math.max(l,e.y);const p=f.fromJSON({xmin:o,ymin:a,xmax:n,ymax:l,spatialReference:r});await(this._operationalDataView?.goTo(p,{animate:!1}).catch(()=>{}))},m)])}_updateConstraints(){this._updateZoomConstraints(),this._updatePanConstraints()}_updateZoomConstraints(){const e=this.videoSize,t=Math.max(e[0]/this.size[0],e[1]/this.size[1]),i=[];for(let r=t;r>F;r/=2)i.push(r);i.push(F);const{lods:s}=M.create({scales:i});this.constraints.set({lods:s,minScale:t})}_updatePanConstraints(){const e=e=>{if(!e.targetGeometry)return e;const[t,i]=this.videoSize,s=t*e.scale/2,r=i*e.scale/2,o=e.targetGeometry.clone();return o.x=Math.max(s,Math.min(t-s,o.x)),o.y=Math.max(r,Math.min(i-r,o.y)),e.targetGeometry=o,e};this.constraints.customConstraints.add({constrain:e,applyPanConstraint:e})}};e([h()],B.prototype,"_overlayContainer",void 0),e([h()],B.prototype,"_isValid",void 0),e([h()],B.prototype,"_effectsContainer",void 0),e([h()],B.prototype,"constraintsInfo",null),e([h()],B.prototype,"operationalDataVisible",void 0),e([h()],B.prototype,"layer",void 0),e([h()],B.prototype,"map",void 0),e([h({type:O,nonNullable:!0})],B.prototype,"navigation",void 0),e([h({readOnly:!0})],B.prototype,"preconditionsReady",null),e([h({readOnly:!0})],B.prototype,"ready",void 0),e([h({readOnly:!0})],B.prototype,"rendering",null),e([h()],B.prototype,"scale",null),e([h()],B.prototype,"spatialReference",void 0),e([h()],B.prototype,"stateManager",void 0),e([h()],B.prototype,"type",void 0),e([h(),d(e=>e instanceof T?e:g(W,e))],B.prototype,"ui",void 0),e([h({readOnly:!0})],B.prototype,"videoSize",null),e([h({readOnly:!0})],B.prototype,"view2dType",void 0),B=e([c("esri.views.VideoView")],B);const I=B;export{I as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{createScreenPointArray as o}from"../../core/screenUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/GraphicsLayer.js";import{makeDehydratedPoint as h}from"../../layers/graphics/dehydratedPoint.js";import{SnappingVisualizer2D as l}from"../2d/interactive/SnappingVisualizer2D.js";import{createCoordinateHelper as c}from"../interactive/coordinateHelper.js";import{EditGeometry as m,Component as _}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as u}from"../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as g}from"../interactive/snapping/SnappingContext.js";import{SnappingOperation as y}from"../interactive/snapping/SnappingOperation.js";var v;let f=class extends(n(t)){static{v=this}constructor(e){super(e),this._hasZ=null,this._cursorScreenPoint=null,this._activePointerId=null,this._stagedVertexUnsnapped=null,this._lastVertexUnsnapped=null,this.interactiveUndoDisabled=!1,this.history=[],this.redoHistory=[],this.snapToScene=!1,this.view=null,this.elevationInfo=null,this.defaultZ=0,this._coordinateHelper=c(!!e.hasZ,!1,e.view.spatialReference),this._snappingManager=e.snappingManager,this._editGeometryOperations=new u(new m(e.editGeometryType??"polygon",this._coordinateHelper),2),this._snappingGraphicsLayer=new d({id:v.SNAPPING_GRAPHICS_LAYER_ID,listMode:"hide",internal:!0,title:"Snapping graphics"}),this._snappingContext=new g({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:"mouse",visualizer:new l(this._snappingGraphicsLayer)}),this._activeComponent=new _(e.view.spatialReference,2),this._editGeometryOperations.data.components.push(this._activeComponent)}normalizeCtorArgs(e){const t={...e};return delete t.editGeometryType,delete t.snappingManager,t}initialize(){this._snappingOperation=new y({view:this.view}),"2d"===this.view.type&&this.view.map.layers.add(this._snappingGraphicsLayer)}destroy(){this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy(),null!=this._snappingManager&&this._snappingManager.doneSnapping(),this._snappingOperation=r(this._snappingOperation),this._editGeometryOperations.destroy()}get _committedVertices(){return this._editGeometryOperations.data.components[0].vertices.map(e=>e.pos)}get vertices(){return null!=this._stagedVertex?[...this._committedVertices,this._coordinateHelper.pointToArray(this._stagedVertex)]:this._committedVertices}get hasZ(){return null!=this._hasZ?this._hasZ:"3d"===this.view.type}set hasZ(e){this._hasZ=e,this.notifyChange("hasZ")}get _stagedVertex(){return this._snappingOperation?.stagedPoint}set _stagedVertex(e){this._snappingOperation&&(this._snappingOperation.stagedPoint=i(e))}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this.canUndo&&this._editGeometryOperations.undo()}redo(){this.canRedo&&this._editGeometryOperations.redo()}getCoordsFromScreenPoint(e){const t=e&&this.screenToMap(e);return null==t?null:t.hasZ?[t.x,t.y,t.z]:[t.x,t.y]}getCoordsAndPointFromScreenPoint(e){const t=this.screenToMap(e);return null==t?null:t.hasZ?{vertex:[t.x,t.y,t.z],mapPoint:t}:{vertex:[t.x,t.y],mapPoint:t}}screenToMap(e){let t=null;if("3d"===this.view.type)if(this.hasZ){const i=this.elevationInfo??x;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(o(e.x,e.y),i,this._getGeometryZValue())}else{const i=this.elevationInfo??G;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(o(e.x,e.y),i,0),null!=t&&(t.z=void 0)}else t=this.view.toMap(e),null!=t&&(t.z=this.hasZ?this._getGeometryZValue():void 0);return t}_pushCursorVertex(e,t){const i=h(e[0],e[1],void 0,this.view.spatialReference);this._stagedVertexUnsnapped=i;const r=this._snappingManager;if(null==r)return this._stagedVertex=i,void t();s(this._snappingOperation.snap({point:i},r,this._snappingContext)).then(()=>{t()})}_popCursorVertex(){this._stagedVertexUnsnapped=null,this._stagedVertex=null}_getGeometryZValue(){return this.defaultZ}_abortSnapping(){this._snappingOperation.abort()}_isDuplicateOfLastVertex(e){const t=this._editGeometryOperations.data.components[0].getLastVertex()?.pos;if(t&&e[0]===t[0]&&e[1]===t[1])return!0;const{x:i,y:r}=this._coordinateHelper.vectorToDehydratedPoint(e);return null!=this._lastVertexUnsnapped&&i===this._lastVertexUnsnapped.x&&r===this._lastVertexUnsnapped.y}_shouldHandlePointerEvent(e){return w(e)&&(null==this._activePointerId||this._activePointerId===e.pointerId)}_vertexAddHandler(e){const t=null!=this._stagedVertex?this._coordinateHelper.pointToArray(this._stagedVertex):this.getCoordsFromScreenPoint(this._cursorScreenPoint);null!=t&&this._addVertex(t,e.native)}_drawCompleteHandler(e){this._completeDrawing(e.native)}static{this.SNAPPING_GRAPHICS_LAYER_ID="DrawAction-snapping-graphics-layer"}};e([a({readOnly:!0})],f.prototype,"vertices",null),e([a({type:Boolean,nonNullable:!0})],f.prototype,"interactiveUndoDisabled",void 0),e([a({readOnly:!0})],f.prototype,"history",void 0),e([a({readOnly:!0})],f.prototype,"redoHistory",void 0),e([a()],f.prototype,"snapToScene",void 0),e([a()],f.prototype,"view",void 0),e([a()],f.prototype,"elevationInfo",void 0),e([a({nonNullable:!0})],f.prototype,"defaultZ",void 0),e([a()],f.prototype,"hasZ",null),e([a()],f.prototype,"_snappingOperation",void 0),e([a()],f.prototype,"_stagedVertex",null),f=v=e([p("esri.views.draw.DrawAction")],f);const x={mode:"absolute-height",offset:0},G={mode:"on-the-ground",offset:0};function w(e){return"mouse"!==e.pointerType||0===e.button}const V=f;export{V as default};
5
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../core/Evented.js";import{clone as i}from"../../core/lang.js";import{destroyMaybe as r}from"../../core/maybe.js";import{EsriPromiseMixin as s}from"../../core/Promise.js";import{ignoreAbortErrors as n}from"../../core/promiseUtils.js";import{createScreenPointArray as o}from"../../core/screenUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/GraphicsLayer.js";import{makeDehydratedPoint as h}from"../../layers/graphics/dehydratedPoint.js";import{SnappingVisualizer2D as l}from"../2d/interactive/SnappingVisualizer2D.js";import{createCoordinateHelper as c}from"../interactive/coordinateHelper.js";import{EditGeometry as m,Part as _}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as u}from"../interactive/editGeometry/EditGeometryOperations.js";import{SnappingContext as g}from"../interactive/snapping/SnappingContext.js";import{SnappingOperation as y}from"../interactive/snapping/SnappingOperation.js";var v;let f=class extends(s(t)){static{v=this}constructor(e){super(e),this._hasZ=null,this._cursorScreenPoint=null,this._activePointerId=null,this._stagedVertexUnsnapped=null,this._lastVertexUnsnapped=null,this.interactiveUndoDisabled=!1,this.history=[],this.redoHistory=[],this.snapToScene=!1,this.view=null,this.elevationInfo=null,this.defaultZ=0,this._coordinateHelper=c(!!e.hasZ,!1,e.view.spatialReference),this._snappingManager=e.snappingManager,this._editGeometryOperations=new u(new m(e.editGeometryType??"polygon",this._coordinateHelper),2),this._snappingGraphicsLayer=new d({id:v.SNAPPING_GRAPHICS_LAYER_ID,listMode:"hide",internal:!0,title:"Snapping graphics"}),this._snappingContext=new g({editGeometryOperations:this._editGeometryOperations,elevationInfo:{mode:"on-the-ground",offset:0},pointer:"mouse",visualizer:new l(this._snappingGraphicsLayer)}),this._activeComponent=new _(e.view.spatialReference,2),this._editGeometryOperations.data.parts.push(this._activeComponent)}normalizeCtorArgs(e){const t={...e};return delete t.editGeometryType,delete t.snappingManager,t}initialize(){this._snappingOperation=new y({view:this.view}),"2d"===this.view.type&&this.view.map.layers.add(this._snappingGraphicsLayer)}destroy(){this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy(),null!=this._snappingManager&&this._snappingManager.doneSnapping(),this._snappingOperation=r(this._snappingOperation),this._editGeometryOperations.destroy()}get _committedVertices(){return this._editGeometryOperations.data.parts[0].vertices.map(e=>e.pos)}get vertices(){return null!=this._stagedVertex?[...this._committedVertices,this._coordinateHelper.pointToArray(this._stagedVertex)]:this._committedVertices}get hasZ(){return null!=this._hasZ?this._hasZ:"3d"===this.view.type}set hasZ(e){this._hasZ=e,this.notifyChange("hasZ")}get _stagedVertex(){return this._snappingOperation?.stagedPoint}set _stagedVertex(e){this._snappingOperation&&(this._snappingOperation.stagedPoint=i(e))}canUndo(){return this._editGeometryOperations.canUndo}canRedo(){return this._editGeometryOperations.canRedo}undo(){this.canUndo&&this._editGeometryOperations.undo()}redo(){this.canRedo&&this._editGeometryOperations.redo()}getCoordsFromScreenPoint(e){const t=e&&this.screenToMap(e);return null==t?null:t.hasZ?[t.x,t.y,t.z]:[t.x,t.y]}getCoordsAndPointFromScreenPoint(e){const t=this.screenToMap(e);return null==t?null:t.hasZ?{vertex:[t.x,t.y,t.z],mapPoint:t}:{vertex:[t.x,t.y],mapPoint:t}}screenToMap(e){let t=null;if("3d"===this.view.type)if(this.hasZ){const i=this.elevationInfo??x;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(o(e.x,e.y),i,this._getGeometryZValue())}else{const i=this.elevationInfo??G;t=this.view.sceneIntersectionHelper.intersectElevationFromScreen(o(e.x,e.y),i,0),null!=t&&(t.z=void 0)}else t=this.view.toMap(e),null!=t&&(t.z=this.hasZ?this._getGeometryZValue():void 0);return t}_pushCursorVertex(e,t){const i=h(e[0],e[1],void 0,this.view.spatialReference);this._stagedVertexUnsnapped=i;const r=this._snappingManager;if(null==r)return this._stagedVertex=i,void t();n(this._snappingOperation.snap({point:i},r,this._snappingContext)).then(()=>{t()})}_popCursorVertex(){this._stagedVertexUnsnapped=null,this._stagedVertex=null}_getGeometryZValue(){return this.defaultZ}_abortSnapping(){this._snappingOperation.abort()}_isDuplicateOfLastVertex(e){const t=this._editGeometryOperations.data.parts[0].getLastVertex()?.pos;if(t&&e[0]===t[0]&&e[1]===t[1])return!0;const{x:i,y:r}=this._coordinateHelper.vectorToDehydratedPoint(e);return null!=this._lastVertexUnsnapped&&i===this._lastVertexUnsnapped.x&&r===this._lastVertexUnsnapped.y}_shouldHandlePointerEvent(e){return w(e)&&(null==this._activePointerId||this._activePointerId===e.pointerId)}_vertexAddHandler(e){const t=null!=this._stagedVertex?this._coordinateHelper.pointToArray(this._stagedVertex):this.getCoordsFromScreenPoint(this._cursorScreenPoint);null!=t&&this._addVertex(t,e.native)}_drawCompleteHandler(e){this._completeDrawing(e.native)}static{this.SNAPPING_GRAPHICS_LAYER_ID="DrawAction-snapping-graphics-layer"}};e([a({readOnly:!0})],f.prototype,"vertices",null),e([a({type:Boolean,nonNullable:!0})],f.prototype,"interactiveUndoDisabled",void 0),e([a({readOnly:!0})],f.prototype,"history",void 0),e([a({readOnly:!0})],f.prototype,"redoHistory",void 0),e([a()],f.prototype,"snapToScene",void 0),e([a()],f.prototype,"view",void 0),e([a()],f.prototype,"elevationInfo",void 0),e([a({nonNullable:!0})],f.prototype,"defaultZ",void 0),e([a()],f.prototype,"hasZ",null),e([a()],f.prototype,"_snappingOperation",void 0),e([a()],f.prototype,"_stagedVertex",null),f=v=e([p("esri.views.draw.DrawAction")],f);const x={mode:"absolute-height",offset:0},G={mode:"on-the-ground",offset:0};function w(e){return"mouse"!==e.pointerType||0===e.button}const V=f;export{V as default};