@arcgis/core 4.34.0-next.32 → 4.34.0-next.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{c6edf028dd04d47d7580.js → 087ae1e3e767f0e678e5.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{341507901f3858559c82.js → 125fdea50620d4db2678.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{971b16677b66c16fb6b9.js → 20aed6e1d9b6bf06a398.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{fb71e533995c54cd806f.js → 319fe6a02ec630a827ea.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{1aa6719be3afbdc7c880.js → 3cd1ab26396052f17832.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{359c282fd67148fda5fa.js → 3d5954478864a975e65e.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{2fdf457786d2d5d7414f.js → 3eb792863a789b97ec58.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{89999baefa341bd3329c.js → 4193691ca076948f4f90.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{057df92b981c9b311d68.js → 43fba9d6be5971ec20a9.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{74f3bc6c6b82de49d6ee.js → 4ac6bf9ff1cfbde87c7b.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{0b3a200b97d790d08248.js → 4b9003ddfe61dc3729f4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{5192f38682f1f9be7da0.js → 549e073fe276363a9896.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{50b0d96e1a5ccffeb803.js → 64fab4e1e28c06c83403.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{d3cb21cdc5b9483dd1f4.js → 69ae235423f0b1bdfcb4.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{3323646096474740fed5.js → 6c72e2c09ed62cb2fd79.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{63cb3dcd359e96733b1b.js → 6ce2f86b9b1d2f2b8675.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{0fc620d6d0c4ac282d72.js → 700c641347853b1034d9.js} +1 -1
  19. package/assets/esri/core/workers/chunks/752eabfbed7b8b65cf3f.js +1 -0
  20. package/assets/esri/core/workers/chunks/{3a0da512562ba492609d.js → 827bebb4bcdde23adc91.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{9152d62c55d3396763bd.js → 8be81e1530b952c97936.js} +1 -1
  22. package/assets/esri/core/workers/chunks/90a0c1c5c851cc9b6d6d.js +1 -0
  23. package/assets/esri/core/workers/chunks/9a54c96b48e94d816881.js +1 -0
  24. package/assets/esri/core/workers/chunks/{c18167a0790241f80bf7.js → a6767d75e718f2e1e714.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{b1ef40ef898a8c7f43a2.js → acb95ae6203f708d71b4.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{22f38cad0213f2112394.js → b1982490762972ae023d.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{bc0f5477b4491ab48b3a.js → b28855db6a30d4d4f348.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{6ccd6171d3c572883034.js → b877142a275188a16e17.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{1c3578d5e956a4587973.js → c30adbead0ba4722acf9.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{0260b33daf48fc207880.js → c9b11c7170c99f9e0e93.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{58393ab52d0b8f718241.js → d3fd11da3a823e148957.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{41d36b87e3dfc01be38d.js → d7b3e81cc313fd0a33b0.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{1e20e43d1dc5273708c7.js → e1472dbf0795d737d6f8.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{300a5257969d3835ceeb.js → f19426eb53d8430ded51.js} +1 -1
  35. package/assets/esri/core/workers/chunks/f3358b19af0f03f16543.js +1 -0
  36. package/assets/esri/core/workers/chunks/{1b5923dfd70d464dfb25.js → f4c38a9c01c29b5a6244.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{c854c3bb4440fd942c12.js → f6c1854f36b029fa6c37.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{039979cbf35a241ed0a4.js → fdc8300b6374ef2b8b3e.js} +1 -1
  39. package/chunks/Distance2DCalculator-CXhBP-8I.js +1 -1
  40. package/chunks/OperatorCrosses.js +1 -1
  41. package/chunks/OperatorGeodesicBuffer.js +1 -1
  42. package/chunks/OperatorIntersects.js +1 -1
  43. package/chunks/OperatorOverlaps.js +1 -1
  44. package/chunks/OperatorProximity.js +1 -1
  45. package/chunks/OperatorShapePreservingLength.js +1 -1
  46. package/chunks/OperatorShapePreservingProject.js +1 -1
  47. package/chunks/OperatorTouches.js +1 -1
  48. package/chunks/OperatorWithin.js +1 -1
  49. package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
  50. package/chunks/UnitFactory.js +1 -1
  51. package/chunks/equalsOperator.js +1 -1
  52. package/config.js +1 -1
  53. package/core/Clonable.js +1 -1
  54. package/geometry/operators/gx/operatorDifference.js +1 -1
  55. package/geometry/operators/gx/operatorIntersection.js +1 -1
  56. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  57. package/kernel.js +1 -1
  58. package/package.json +3 -3
  59. package/support/revision.js +1 -1
  60. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  61. package/views/2d/layers/GraphicsLayerView2D.js +1 -1
  62. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  63. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  64. package/views/2d/layers/TileLayerView2D.js +1 -1
  65. package/views/3d/analysis/Slice/SliceController.js +1 -1
  66. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  67. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  68. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  69. package/views/3d/layers/FlowSubView3D.js +1 -1
  70. package/views/3d/layers/GraphicsLayerView3D.js +1 -1
  71. package/views/3d/layers/GraphicsView3D.js +1 -1
  72. package/views/3d/layers/I3SMeshView3D.js +1 -1
  73. package/views/3d/layers/MediaLayerView3D.js +1 -1
  74. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  75. package/views/3d/layers/RouteLayerView3D.js +1 -1
  76. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  77. package/views/3d/support/flow/geometryUtils.js +1 -1
  78. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  79. package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
  80. package/views/support/Scheduler.js +1 -1
  81. package/views/support/highlightOptionsUtils.js +1 -1
  82. package/views/webgl/FramebufferObject.js +1 -1
  83. package/views/webgl/RenderbufferDescriptor.js +1 -1
  84. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  85. package/assets/esri/core/workers/chunks/0fe32bdf2055bcd1e928.js +0 -1
  86. package/assets/esri/core/workers/chunks/23eae849ee0ca7b3fd81.js +0 -1
  87. package/assets/esri/core/workers/chunks/99e3f7b3ea0bfe9b8d34.js +0 -1
  88. package/assets/esri/core/workers/chunks/c50c2f014e8567870686.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import{result as r,forEach as s}from"../../../core/asyncUtils.js";import"../../../core/has.js";import o from"../../../core/Logger.js";import{destroyMaybe as n,abortMaybe as a}from"../../../core/maybe.js";import{estimateNumberArrayMemory as d,baseObjectMemory as l,estimateNumberMemory as u,estimateFixedArrayMemory as h,baseArrayMemory as p}from"../../../core/memoryEstimations.js";import{isAbortError as c,allSettledValues as _,throwIfAborted as m}from"../../../core/promiseUtils.js";import{initial as g,watch as f,sync as y}from"../../../core/reactiveUtils.js";import{pt2px as b}from"../../../core/screenUtils.js";import{isArrayBuffer as w}from"../../../core/typedArrayUtil.js";import{property as N}from"../../../core/accessorSupport/decorators/property.js";import{subclass as P}from"../../../core/accessorSupport/decorators/subclass.js";import{l as x,f as v,e as C,c as S}from"../../../chunks/vec32.js";import{clone as I}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as A}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import R from"../../../geometry/Extent.js";import j from"../../../geometry/Point.js";import{projectBoundingSphere as k}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as V}from"../../../geometry/projection/projectVectorToVector.js";import{create as Q,fromMinMax as F}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as L,create as D}from"../../../geometry/support/plane.js";import{f as E}from"../../../chunks/sphere.js";import U from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as q}from"../../../layers/graphics/data/QueryEngine.js";import{CodedValue as M}from"../../../layers/support/CodedValue.js";import O from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as W}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as G}from"../../../layers/support/PromiseQueue.js";import z from"../../../rest/support/FeatureSet.js";import H from"../../../rest/support/Query.js";import{getElevationOffset as B}from"../../../support/elevationInfoUtils.js";import{LayerView3D as T}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as $,QueuePerformanceInfo as J}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as K}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as Z}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as Y,checkPointCloudLayerCompatibleWithView as X}from"./i3s/I3SUtil.js";import{nodeDiff as ee,sortFrontToBack as te,splitWorkEntries as ie}from"./i3s/LoDUtil.js";import{PagedNodeIndex as re}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as se}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as oe}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as ne,PointCloudRendererNode as ae}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as de,getFixedSizeAlgorithm as le,getRendererInfo as ue,getFilterInfo as he,rendererUsesFixedSizes as pe,getAttributeInfo as ce}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as _e,readGeometry as me,elevationFromPositions as ge}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as fe,emptyHighlightHandle as ye}from"./support/highlightUtils.js";import{PopupSceneLayerView as be}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as we}from"../support/extentUtils.js";import{computeMapPointFromVec3d as Ne}from"../support/hitTest.js";import{Obb as Pe}from"../support/orientedBoundingBox.js";import{updatingProgress as xe}from"../support/updatingProperties.js";import ve from"../../layers/LayerView.js";import Ce from"../../layers/PointCloudLayerView.js";import{defaultHighlightName as Se}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as Ie}from"../../support/layerViewUtils.js";import{TaskPriority as Ae}from"../../support/Scheduler.js";const Re=8,je=D();let ke=class extends(Ce(be(T(ve)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new G,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=de(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=le(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=le(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=ue(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=he(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of W(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=Q(),t=this.view.renderSpatialReference;return we(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return e&&"absolute-height"===e.mode?B(e,this.layer.spatialReference):0}initialize(){const e=this.view.resourceController,t=De(e);this._worker=new K(t),this.addResolvingPromise(this._worker.promise),Y(this.layer),X(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(2),this._dataRequester=e.createStreamDataRequester(3),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),g),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),g),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),g),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),g),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),g),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([f(()=>this.view.quality,()=>this._setUpdateViewNeeded(),y)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(Ae.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks(()=>this._idleBegin(),()=>this._idleEnd()),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},g)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=n(this._worker),this._destroyRenderer(),this._memCache=n(this._memCache),this._queryFeaturesCache=n(this._queryFeaturesCache),this._queryEngine=n(this._queryEngine),this._codedDomainPopulationAbortController=a(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new oe({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,g),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),g),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,g),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,g),this._updatingHandles.add(()=>this.pointSize,e=>{const t=b(e);this._renderer.size=e,this._renderer.sizePx=t},g),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,g),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),g),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),g),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},g)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:Ne(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new se({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=pe(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ee([...this._renderedNodes],e,this._index),te(this._workQueue,this.view.state.contentCamera.viewForward,this._index),ie(this._workQueue,Re,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach(({abortController:t})=>e.push(t)),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array,i=new Map;this._loadingNodes.forEach((r,s)=>{e.has(s)?i.set(s,r):t.push(r)}),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach(({abortController:e})=>e.abort()),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&e.run(()=>this._processIndexQueue()););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then(t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()}).then(()=>{this._indexPagesLoading.delete(e)},()=>{this._indexPagesLoading.delete(e)}),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map(e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise})).then(t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)}).catch(()=>{}).then(()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",s=this.layer.fieldsIndex.get(i);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await r(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(s.domain=new O({name:"CLASS_CODE",codedValues:n.map(e=>new M({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const r=this._splitGraphicsPerNode(e),o=this.layer.attributeStorageInfo,n=t.map(e=>ce(o,e)).filter(i),a=async(e,t)=>{const i=this._index.getNode(t);await s(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return r.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof se&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?_e({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=me(t,await this._loadGeometry(e,null));return ge(i,i.length/3)}highlight(e,i){const r=fe(e);if(0===r.length)return ye;if(!(r[0]instanceof t))return ye;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),i?.name??Se)}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return Ie(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=z.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i}const s=j.fromJSON(e.geometry);return s.spatialReference=o.spatialReference??n,this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new H(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:R.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new H({outSpatialReference:this.view.spatialReference}).toJSON():H.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new q({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new Z({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{let i=!1;this._renderer.forEachNode(r=>{if(i)return;if(t){const e=r.obb,s=E(e.center[0],e.center[1],e.center[2],x(e.halfSize));k(s,this.view.renderSpatialReference,s,this.view.spatialReference);const o=t(s);if(2===o)return;if(i=0===o,i)return}let s=this._queryFeaturesCache.get(`${r.id}`);s||(s=this._createQueryPointFeatures(r),this._queryFeaturesCache.put(`${r.id}`,s)),s.features.forEach(e)})},getFeatureExtent:({point:e},t)=>F(e,e,t),featureAdapter:{cloneWithGeometry:(e,t)=>new Qe(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=A(t[s+0],t[s+1],t[s+2]);v(o,o,e.origin),V(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Qe(e,r,o);i.push(n)}return new Fe(i)}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new re(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then(e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()})}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then(t=>t.nodes.map((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:Pe.fromJSON(t.obb),obbInRenderSR:new Pe,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=C(s,t.eye),n=L(s,-o,je),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw c(i)||o.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,r){const s=this.layer.outFields;if(!s)return[];const o=W(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const i of o){if(n.has(i))continue;const e=ce(a,i);e&&d.push(t(e))}const l=await _(d);return m(r),l.filter(i)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=ue(this.layer),s=he(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,g,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);m(t);const w={geometryBuffer:_,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",...this.layer.customParameters,token:this.layer.apiKey};return this._indexRequester.request(e,0,{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,1,{query:{...this.layer.customParameters,token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(t.id.toString(),t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(ne(t))return t.splatSize=r,t.obb=s,S(t.origin,t.obb.center),t;const n=Pe.fromData(t.obbData),a=n.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;o.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(n)}`),0===--this._maxLoggedBoxWarnings&&o.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,n)}return new ae(e,r,I(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Le,e+=d(t.coordinates);for(const i of t.attributes){const t=i.values;w(t.buffer)&&(e+=d(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Le)/t)+i*Le}get performanceInfo(){return new $(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new J(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([N()],ke.prototype,"layer",void 0),e([N()],ke.prototype,"baseUrl",null),e([N()],ke.prototype,"pointScale",null),e([N()],ke.prototype,"useRealWorldSymbolSizes",null),e([N()],ke.prototype,"pointSize",null),e([N()],ke.prototype,"inverseDensity",null),e([N()],ke.prototype,"maximumPointCount",void 0),e([N({readOnly:!0})],ke.prototype,"availableFields",null),e([N({readOnly:!0})],ke.prototype,"_clippingBox",null),e([N({readOnly:!0})],ke.prototype,"_elevationOffset",null),e([N({type:Boolean})],ke.prototype,"slicePlaneEnabled",void 0),e([N()],ke.prototype,"updating",void 0),e([N(xe)],ke.prototype,"updatingProgress",void 0),e([N({readOnly:!0})],ke.prototype,"updatingProgressValue",null),e([N({readOnly:!0})],ke.prototype,"visibleAtCurrentScale",null),ke=e([P("esri.views.3d.layers.PointCloudLayerView3D")],ke);const Ve=ke;class Qe{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new U([1],Array.from(this.point))}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return l+l+u+h(this.point,u)}}class Fe{constructor(e){this.features=e}get cachedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,l+p)}}const Le=160;function De(e){return t=>e.immediate.schedule(t)}export{Ve as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import{isSome as i}from"../../../core/arrayUtils.js";import{result as r,forEach as s}from"../../../core/asyncUtils.js";import"../../../core/has.js";import o from"../../../core/Logger.js";import{destroyMaybe as n,abortMaybe as a}from"../../../core/maybe.js";import{estimateNumberArrayMemory as d,baseObjectMemory as l,estimateNumberMemory as u,estimateFixedArrayMemory as h,baseArrayMemory as p}from"../../../core/memoryEstimations.js";import{isAbortError as c,allSettledValues as _,throwIfAborted as m}from"../../../core/promiseUtils.js";import{initial as g,watch as f,sync as y}from"../../../core/reactiveUtils.js";import{pt2px as b}from"../../../core/screenUtils.js";import{isArrayBuffer as w}from"../../../core/typedArrayUtil.js";import{property as N}from"../../../core/accessorSupport/decorators/property.js";import{subclass as P}from"../../../core/accessorSupport/decorators/subclass.js";import{l as x,f as v,e as C,c as S}from"../../../chunks/vec32.js";import{clone as I}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as A}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import R from"../../../geometry/Extent.js";import j from"../../../geometry/Point.js";import{projectBoundingSphere as k}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as V}from"../../../geometry/projection/projectVectorToVector.js";import{create as Q,fromMinMax as F}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as L,create as E}from"../../../geometry/support/plane.js";import{f as D}from"../../../chunks/sphere.js";import U from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as O}from"../../../layers/graphics/data/QueryEngine.js";import{CodedValue as q}from"../../../layers/support/CodedValue.js";import M from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as W}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as G}from"../../../layers/support/PromiseQueue.js";import z from"../../../rest/support/FeatureSet.js";import H from"../../../rest/support/Query.js";import{getElevationOffset as B}from"../../../support/elevationInfoUtils.js";import{LayerView3D as T}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as $,QueuePerformanceInfo as J}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as K}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as Z}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as Y,checkPointCloudLayerCompatibleWithView as X}from"./i3s/I3SUtil.js";import{nodeDiff as ee,sortFrontToBack as te,splitWorkEntries as ie}from"./i3s/LoDUtil.js";import{PagedNodeIndex as re}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as se}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as oe}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as ne,PointCloudRendererNode as ae}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as de,getFixedSizeAlgorithm as le,getRendererInfo as ue,getFilterInfo as he,rendererUsesFixedSizes as pe,getAttributeInfo as ce}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as _e,readGeometry as me,elevationFromPositions as ge}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as fe,emptyHighlightHandle as ye}from"./support/highlightUtils.js";import{PopupSceneLayerView as be}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as we}from"../support/extentUtils.js";import{computeMapPointFromVec3d as Ne}from"../support/hitTest.js";import{Obb as Pe}from"../support/orientedBoundingBox.js";import{updatingProgress as xe}from"../support/updatingProperties.js";import ve from"../../layers/LayerView.js";import Ce from"../../layers/PointCloudLayerView.js";import{getHighlightName as Se}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as Ie}from"../../support/layerViewUtils.js";import{TaskPriority as Ae}from"../../support/Scheduler.js";const Re=8,je=E();let ke=class extends(Ce(be(T(ve)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new G,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=de(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=le(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=le(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=ue(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=he(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of W(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=Q(),t=this.view.renderSpatialReference;return we(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return e&&"absolute-height"===e.mode?B(e,this.layer.spatialReference):0}initialize(){const e=this.view.resourceController,t=Ee(e);this._worker=new K(t),this.addResolvingPromise(this._worker.promise),Y(this.layer),X(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(2),this._dataRequester=e.createStreamDataRequester(3),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),g),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),g),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),g),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),g),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),g),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([f(()=>this.view.quality,()=>this._setUpdateViewNeeded(),y)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(Ae.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks(()=>this._idleBegin(),()=>this._idleEnd()),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},g)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=n(this._worker),this._destroyRenderer(),this._memCache=n(this._memCache),this._queryFeaturesCache=n(this._queryFeaturesCache),this._queryEngine=n(this._queryEngine),this._codedDomainPopulationAbortController=a(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new oe({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,g),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),g),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,g),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,g),this._updatingHandles.add(()=>this.pointSize,e=>{const t=b(e);this._renderer.size=e,this._renderer.sizePx=t},g),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,g),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),g),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),g),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},g)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:Ne(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new se({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=pe(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ee([...this._renderedNodes],e,this._index),te(this._workQueue,this.view.state.contentCamera.viewForward,this._index),ie(this._workQueue,Re,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach(({abortController:t})=>e.push(t)),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array,i=new Map;this._loadingNodes.forEach((r,s)=>{e.has(s)?i.set(s,r):t.push(r)}),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach(({abortController:e})=>e.abort()),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&e.run(()=>this._processIndexQueue()););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then(t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()}).then(()=>{this._indexPagesLoading.delete(e)},()=>{this._indexPagesLoading.delete(e)}),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map(e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise})).then(t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)}).catch(()=>{}).then(()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",s=this.layer.fieldsIndex.get(i);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await r(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(s.domain=new M({name:"CLASS_CODE",codedValues:n.map(e=>new q({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const r=this._splitGraphicsPerNode(e),o=this.layer.attributeStorageInfo,n=t.map(e=>ce(o,e)).filter(i),a=async(e,t)=>{const i=this._index.getNode(t);await s(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return r.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof se&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?_e({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=me(t,await this._loadGeometry(e,null));return ge(i,i.length/3)}highlight(e,i){const r=fe(e);if(0===r.length)return ye;if(!(r[0]instanceof t))return ye;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Se(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return Ie(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=z.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i}const s=j.fromJSON(e.geometry);return s.spatialReference=o.spatialReference??n,this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new H(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:R.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new H({outSpatialReference:this.view.spatialReference}).toJSON():H.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new O({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new Z({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{let i=!1;this._renderer.forEachNode(r=>{if(i)return;if(t){const e=r.obb,s=D(e.center[0],e.center[1],e.center[2],x(e.halfSize));k(s,this.view.renderSpatialReference,s,this.view.spatialReference);const o=t(s);if(2===o)return;if(i=0===o,i)return}let s=this._queryFeaturesCache.get(`${r.id}`);s||(s=this._createQueryPointFeatures(r),this._queryFeaturesCache.put(`${r.id}`,s)),s.features.forEach(e)})},getFeatureExtent:({point:e},t)=>F(e,e,t),featureAdapter:{cloneWithGeometry:(e,t)=>new Qe(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=A(t[s+0],t[s+1],t[s+2]);v(o,o,e.origin),V(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Qe(e,r,o);i.push(n)}return new Fe(i)}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new re(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then(e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()})}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then(t=>t.nodes.map((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:Pe.fromJSON(t.obb),obbInRenderSR:new Pe,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=C(s,t.eye),n=L(s,-o,je),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw c(i)||o.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,r){const s=this.layer.outFields;if(!s)return[];const o=W(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const i of o){if(n.has(i))continue;const e=ce(a,i);e&&d.push(t(e))}const l=await _(d);return m(r),l.filter(i)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=ue(this.layer),s=he(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,g,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);m(t);const w={geometryBuffer:_,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",...this.layer.customParameters,token:this.layer.apiKey};return this._indexRequester.request(e,0,{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,1,{query:{...this.layer.customParameters,token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(t.id.toString(),t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(ne(t))return t.splatSize=r,t.obb=s,S(t.origin,t.obb.center),t;const n=Pe.fromData(t.obbData),a=n.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;o.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(n)}`),0===--this._maxLoggedBoxWarnings&&o.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,n)}return new ae(e,r,I(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Le,e+=d(t.coordinates);for(const i of t.attributes){const t=i.values;w(t.buffer)&&(e+=d(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Le)/t)+i*Le}get performanceInfo(){return new $(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new J(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([N()],ke.prototype,"layer",void 0),e([N()],ke.prototype,"baseUrl",null),e([N()],ke.prototype,"pointScale",null),e([N()],ke.prototype,"useRealWorldSymbolSizes",null),e([N()],ke.prototype,"pointSize",null),e([N()],ke.prototype,"inverseDensity",null),e([N()],ke.prototype,"maximumPointCount",void 0),e([N({readOnly:!0})],ke.prototype,"availableFields",null),e([N({readOnly:!0})],ke.prototype,"_clippingBox",null),e([N({readOnly:!0})],ke.prototype,"_elevationOffset",null),e([N({type:Boolean})],ke.prototype,"slicePlaneEnabled",void 0),e([N()],ke.prototype,"updating",void 0),e([N(xe)],ke.prototype,"updatingProgress",void 0),e([N({readOnly:!0})],ke.prototype,"updatingProgressValue",null),e([N({readOnly:!0})],ke.prototype,"visibleAtCurrentScale",null),ke=e([P("esri.views.3d.layers.PointCloudLayerView3D")],ke);const Ve=ke;class Qe{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new U([1],Array.from(this.point))}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return l+l+u+h(this.point,u)}}class Fe{constructor(e){this.features=e}get cachedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,l+p)}}const Le=160;function Ee(e){return t=>e.immediate.schedule(t)}export{Ve 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 r from"../../../core/Collection.js";import t from"../../../core/CollectionFlattener.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{initial as o,when as i,watch as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../rest/support/DirectionLine.js";import c from"../../../rest/support/DirectionPoint.js";import h from"../../../rest/support/PointBarrier.js";import d from"../../../rest/support/PolygonBarrier.js";import u from"../../../rest/support/PolylineBarrier.js";import m from"../../../rest/support/RouteInfo.js";import y from"../../../rest/support/Stop.js";import{LayerView3D as f}from"./LayerView3D.js";import{GraphicsProcessor as g}from"./graphics/GraphicsProcessor.js";import{LayerViewPerformanceInfo as b}from"./support/LayerViewPerformanceInfo.js";import{EventedSet as j}from"../support/EventedSet.js";import w from"../../layers/LayerView.js";import{defaultHighlightName as v}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as I,hasLayerBasedScaleVisibility as _}from"../../support/layerViewUtils.js";import{projectWithZConversionSilent as S}from"../../support/projectionUtils.js";function V(e){return e instanceof l||e instanceof c||e instanceof h||e instanceof d||e instanceof u||e instanceof m||e instanceof y}let C=class extends(f(w)){constructor(){super(...arguments),this.type="route-3d",this.loadedGraphics=new j,this._byObjectID=new Map,this.slicePlaneEnabled=!1,this.fullExtentInLocalViewSpatialReference=null}initialize(){this._set("processor",new g({owner:this,scaleVisibilityEnabled:!0,frustumVisibilityEnabled:!0})),this.addResolvingPromise(this.processor.initializePromise),this._updatingHandles.addOnCollectionChange(()=>this._routeItems,e=>this._routeItemsChanged(e),o),"local"===this.view.viewingMode&&this.addResolvingPromise((async()=>this.fullExtentInLocalViewSpatialReference=await S(this.layer.fullExtent,this.view.spatialReference))()),this.addHandles(i(()=>this.view?.basemapTerrain?.ready,()=>()=>this.notifyChange("updating"),{once:!0}))}destroy(){this._updatingHandles.removeAll(),this._set("processor",s(this.processor)),this._get("_routeItems")?.destroy()}get _routeItems(){return new t({getCollections:()=>[this.layer.pointBarriers,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.stops,this.layer.directionLines,this.layer.directionPoints,null!=this.layer.routeInfo?new r([this.layer.routeInfo]):null]})}_routeItemsChanged(e){if(e.removed.length){this.loadedGraphics.removeMany(e.removed.map(e=>{const r=this._byObjectID.get(e);return this._byObjectID.delete(e),r}));for(const r of e.removed)this.removeHandles(r)}if(e.added.length){this.loadedGraphics.addMany(e.added.map(e=>{const r=e.toGraphic();return this._byObjectID.set(e,r),r}));for(const r of e.added)this.addHandles([n(()=>r.geometry,(e,t)=>{this._updateGraphic(r,"geometry",e,t)}),n(()=>r.symbol,(e,t)=>{this._updateGraphic(r,"symbol",e,t)})],r)}}get legendEnabled(){return this.canResume()&&!this.processor?.frustumVisibilitySuspended}get visibleAtCurrentScale(){return _()?I(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}getSuspendInfo(){const e=super.getSuspendInfo();return e.outsideOfView=this.processor?.frustumVisibilitySuspended??!1,e}getHit(e){return this.processor.getHit(e)}whenGraphicBounds(e,r){return this.processor.whenGraphicBounds(e,r)}computeAttachmentOrigin(e,r){return this.processor?.computeAttachmentOrigin(e,r)}getSymbolLayerSize(e,r){return this.processor.getSymbolLayerSize(e,r)}async queryGraphics(){return new r(this.loadedGraphics.toArray())}maskOccludee(e){return this.processor.maskOccludee(e)}highlight(e,r){return V(e)&&(e=this._byObjectID.get(e)),this.processor.highlight(e,r?.name??v)}notifyContentGeometryUpdate(){this.emit("visible-geometry-changed")}get updatePolicy(){return this.processor?.graphicsCore.effectiveUpdatePolicy||1}isUpdating(){return!(!this.processor?.updating&&this.view?.basemapTerrain?.ready)}get performanceInfo(){return new b(this.processor?.graphicsCore.usedMemory??0,this.loadedGraphics.length,-1,-1,0,this.processor?.graphicsCore.performanceInfo??null)}_updateGraphic(e,r,t,s){const o=this._byObjectID.get(e);o[r]=t,G.graphic=o,G.property=r,G.oldValue=s,G.newValue=t,this.processor?.graphicsCore.graphicUpdateHandler(G),G.graphic=null}};e([a()],C.prototype,"_routeItems",null),e([a()],C.prototype,"loadedGraphics",void 0),e([a({readOnly:!0})],C.prototype,"legendEnabled",null),e([a({readOnly:!0})],C.prototype,"visibleAtCurrentScale",null),e([a()],C.prototype,"layer",void 0),e([a({readOnly:!0})],C.prototype,"processor",void 0),e([a({type:Boolean})],C.prototype,"slicePlaneEnabled",void 0),C=e([p("esri.views.3d.layers.RouteLayerView3D")],C);const G={graphic:null,property:null,oldValue:null,newValue:null},O=C;export{O as default};
5
+ import{__decorate as e}from"tslib";import r from"../../../core/Collection.js";import t from"../../../core/CollectionFlattener.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{initial as o,when as i,watch as n}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../../../rest/support/DirectionLine.js";import c from"../../../rest/support/DirectionPoint.js";import h from"../../../rest/support/PointBarrier.js";import d from"../../../rest/support/PolygonBarrier.js";import u from"../../../rest/support/PolylineBarrier.js";import m from"../../../rest/support/RouteInfo.js";import y from"../../../rest/support/Stop.js";import{LayerView3D as f}from"./LayerView3D.js";import{GraphicsProcessor as g}from"./graphics/GraphicsProcessor.js";import{LayerViewPerformanceInfo as b}from"./support/LayerViewPerformanceInfo.js";import{EventedSet as j}from"../support/EventedSet.js";import w from"../../layers/LayerView.js";import{getHighlightName as v}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as I,hasLayerBasedScaleVisibility as _}from"../../support/layerViewUtils.js";import{projectWithZConversionSilent as S}from"../../support/projectionUtils.js";function V(e){return e instanceof l||e instanceof c||e instanceof h||e instanceof d||e instanceof u||e instanceof m||e instanceof y}let C=class extends(f(w)){constructor(){super(...arguments),this.type="route-3d",this.loadedGraphics=new j,this._byObjectID=new Map,this.slicePlaneEnabled=!1,this.fullExtentInLocalViewSpatialReference=null}initialize(){this._set("processor",new g({owner:this,scaleVisibilityEnabled:!0,frustumVisibilityEnabled:!0})),this.addResolvingPromise(this.processor.initializePromise),this._updatingHandles.addOnCollectionChange(()=>this._routeItems,e=>this._routeItemsChanged(e),o),"local"===this.view.viewingMode&&this.addResolvingPromise((async()=>this.fullExtentInLocalViewSpatialReference=await S(this.layer.fullExtent,this.view.spatialReference))()),this.addHandles(i(()=>this.view?.basemapTerrain?.ready,()=>()=>this.notifyChange("updating"),{once:!0}))}destroy(){this._updatingHandles.removeAll(),this._set("processor",s(this.processor)),this._get("_routeItems")?.destroy()}get _routeItems(){return new t({getCollections:()=>[this.layer.pointBarriers,this.layer.polygonBarriers,this.layer.polylineBarriers,this.layer.stops,this.layer.directionLines,this.layer.directionPoints,null!=this.layer.routeInfo?new r([this.layer.routeInfo]):null]})}_routeItemsChanged(e){if(e.removed.length){this.loadedGraphics.removeMany(e.removed.map(e=>{const r=this._byObjectID.get(e);return this._byObjectID.delete(e),r}));for(const r of e.removed)this.removeHandles(r)}if(e.added.length){this.loadedGraphics.addMany(e.added.map(e=>{const r=e.toGraphic();return this._byObjectID.set(e,r),r}));for(const r of e.added)this.addHandles([n(()=>r.geometry,(e,t)=>{this._updateGraphic(r,"geometry",e,t)}),n(()=>r.symbol,(e,t)=>{this._updateGraphic(r,"symbol",e,t)})],r)}}get legendEnabled(){return this.canResume()&&!this.processor?.frustumVisibilitySuspended}get visibleAtCurrentScale(){return _()?I(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}getSuspendInfo(){const e=super.getSuspendInfo();return e.outsideOfView=this.processor?.frustumVisibilitySuspended??!1,e}getHit(e){return this.processor.getHit(e)}whenGraphicBounds(e,r){return this.processor.whenGraphicBounds(e,r)}computeAttachmentOrigin(e,r){return this.processor?.computeAttachmentOrigin(e,r)}getSymbolLayerSize(e,r){return this.processor.getSymbolLayerSize(e,r)}async queryGraphics(){return new r(this.loadedGraphics.toArray())}maskOccludee(e){return this.processor.maskOccludee(e)}highlight(e,r){return V(e)&&(e=this._byObjectID.get(e)),this.processor.highlight(e,v(r))}notifyContentGeometryUpdate(){this.emit("visible-geometry-changed")}get updatePolicy(){return this.processor?.graphicsCore.effectiveUpdatePolicy||1}isUpdating(){return!(!this.processor?.updating&&this.view?.basemapTerrain?.ready)}get performanceInfo(){return new b(this.processor?.graphicsCore.usedMemory??0,this.loadedGraphics.length,-1,-1,0,this.processor?.graphicsCore.performanceInfo??null)}_updateGraphic(e,r,t,s){const o=this._byObjectID.get(e);o[r]=t,G.graphic=o,G.property=r,G.oldValue=s,G.newValue=t,this.processor?.graphicsCore.graphicUpdateHandler(G),G.graphic=null}};e([a()],C.prototype,"_routeItems",null),e([a()],C.prototype,"loadedGraphics",void 0),e([a({readOnly:!0})],C.prototype,"legendEnabled",null),e([a({readOnly:!0})],C.prototype,"visibleAtCurrentScale",null),e([a()],C.prototype,"layer",void 0),e([a({readOnly:!0})],C.prototype,"processor",void 0),e([a({type:Boolean})],C.prototype,"slicePlaneEnabled",void 0),C=e([p("esri.views.3d.layers.RouteLayerView3D")],C);const G={graphic:null,property:null,oldValue:null,newValue:null},O=C;export{O 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"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{i as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as m}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as g,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import j from"../../../layers/support/FeatureFilter.js";import N from"../../../rest/support/Query.js";import{isBasemapLayerView as O}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as S}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as F}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as M}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as H}from"./i3s/I3SOverrides.js";import{checkRecyclable as Q,checkSpatialReferences as U,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{defaultHighlightName as ae}from"../../support/HighlightDefaults.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get cachedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(S(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new M((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e)),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),Q(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new H({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new H({view:this.view,layer:this.layer,memoryController:e}),U(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new F({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._worker=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._worker=r(this._worker),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.point.lodFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer),r=this._getObjectIdField();return t?.attributes?.[r]?(t.layer=this.layer,t.sourceLayer=this.layer,{type:"graphic",graphic:t,layer:t.layer}):null}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=t?.name??ae,i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._worker&&(this._worker=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._worker.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!ge(r)&&!me(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=ge(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=ge(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const m=this.view.stage.renderView.olidRenderHelper;if(m){const e=O(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];m.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(m(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?g(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),m=h*o,g=isNaN(t[m+2])?void 0:t[m+2],y=new x(u,t[m],t[m+1],g),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new N(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():N.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:j})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function me(e){return"pointData"in e}function ge(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
5
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{i as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as m}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as g,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import j from"../../../layers/support/FeatureFilter.js";import N from"../../../rest/support/Query.js";import{isBasemapLayerView as O}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as S}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as F}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as M}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as H}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get cachedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(S(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new M((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e)),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new H({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new H({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new F({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._worker=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._worker=r(this._worker),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.point.lodFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer),r=this._getObjectIdField();return t?.attributes?.[r]?(t.layer=this.layer,t.sourceLayer=this.layer,{type:"graphic",graphic:t,layer:t.layer}):null}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._worker&&(this._worker=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._worker.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!ge(r)&&!me(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=ge(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=ge(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const m=this.view.stage.renderView.olidRenderHelper;if(m){const e=O(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];m.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(m(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?g(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),m=h*o,g=isNaN(t[m+2])?void 0:t[m+2],y=new x(u,t[m],t[m+1],g),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new N(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():N.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:j})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function me(e){return"pointData"in e}function ge(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce 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 t from"../../../../Color.js";import o from"../../../../core/RandomLCG.js";import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as r}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as i,createGeometry as l}from"../engineContent/line.js";function a(t,a,s,p,c){const{spatialReference:h}=t,u=s.map(o=>{const r=[];for(let i=0;i<o.length;i+=3){const l=[o[i],o[i+1]],[s,m]=f(l,a),{absoluteZ:c}=n(s,m,0,h,t,p),u=e(s,m,c);t.renderCoordsHelper.toRenderCoords(u,h,u),r.push(u)}return r}),g=new o,d=s.map(t=>{const o=Math.floor(t.length/3),e=r(o);for(let r=0;r<o;r++)e[r]=t[3*r+2];return m(e,Math.floor(g.getIntRange(0,e.length))),e});return i(u,void 0,d).map(t=>l(c,t))}function s(o){return null==o?{}:{color:t.toUnitRGBA(o.color),width:o.trailWidth,cap:2,animationSpeed:o.flowSpeed,trailLength:o.trailLength,animation:3}}function f([t,o],e){const{extent:r,size:[n,i]}=e;return[t/n*r.width+r.xmin,(i-o)/i*r.height+r.ymin]}function m(t,o){if(0===t.length||o<0||o>=t.length)return;const e=t[o];for(let r=0;r<t.length;r++)t[r]-=e}export{a as createFlowGeometry,s as materialParametersFromRenderer};
5
+ import t from"../../../../Color.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as e}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as r,createGeometry as i}from"../engineContent/line.js";function l(t,l,s,c,h,m){const{spatialReference:p}=t,g=[];for(let e=0;e<s.length;e+=3){const r=[s[e],s[e+1]],[i,a]=f(r,l),{absoluteZ:h}=n(i,a,0,p,t,c),m=o(i,a,h);t.renderCoordsHelper.toRenderCoords(m,p,m),g.push(m)}const u=Math.floor(s.length/3),d=e(u);for(let o=0;o<u;o++)d[o]=s[3*o+2];a(d,Math.floor(m.getIntRange(0,d.length)));const j=r([g],void 0,[d]);return i(h,j[0])}function s(o){return null==o?{}:{color:t.toUnitRGBA(o.color),width:o.trailWidth,cap:2,animationSpeed:o.flowSpeed,trailLength:o.trailLength,animation:3}}function f([t,o],e){const{extent:n,size:[r,i]}=e;return[t/r*n.width+n.xmin,(i-o)/i*n.height+n.ymin]}function a(t,o){if(0===t.length||o<0||o>=t.length)return;const e=t[o];for(let n=0;n<t.length;n++)t[n]-=e}export{l as createStreamlineGeometry,s as materialParametersFromRenderer};
@@ -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/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as i}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as a,d as o,e as n,g as l,f as p,c,l as h,j as m,t as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as g}from"../../../../geometry/support/float16.js";import{distance2 as v,fromPoints as b,create as _,closestLineSegmentPoint as S}from"../../../../geometry/support/lineSegment.js";import{fromPoints as y,create as P,signedDistance as j,getNormal as A}from"../../../../geometry/support/plane.js";import{newLayout as w}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as E,isColorOrColorEmission as L,isDepth as z,isColorEmissionHighlightOIDOrDepth as T,is2DGeometryOutput as x}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as C}from"../effects/geometry/olidUtils.js";import O from"../lib/GLMaterial.js";import{Material as M}from"../lib/Material.js";import{isTranslationMatrix as F}from"../lib/Util.js";import{VisualVariablePassParameters as R}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as B}from"./internal/bufferWriterUtils.js";import{r as N}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as k,RibbonLineTechnique as D}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as U}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as V}from"../../../../webscene/support/AlphaCutoff.js";class W extends M{constructor(t){super(t,Y),this._configuration=new U,this.vertexAttributeLocations=k,this.produces=new Map([[2,t=>E(t)||L(t)&&8===this.parameters.renderOccluded],[3,t=>z(t)],[9,t=>T(t)&&8===this.parameters.renderOccluded],[10,t=>T(t)&&8===this.parameters.renderOccluded],[4,t=>L(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[7,t=>L(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[17,t=>x(t)]])}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=17===e.slot;const r=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&I(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&L(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration}get visible(){return this.parameters.color[3]>=V||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>V}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:r},i,s,a,o){if(!i.options.selectionMode)return;const n=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const r=t.get("sizeFeatureAttribute").data[0];Number.isNaN(r)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else n&&(l*=n.data[0]);const p=s[0],c=s[1],h=(l/2+4)*r;let m=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=G(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],r=f[g+1],i=(g+3)%f.length,s=p-t,a=c-r,o=f[i]-t,n=f[i+1]-r,l=e((o*s+n*a)/(o*o+n*n),0,1),h=o*l-s,d=n*l-a,v=h*h+d*d;v<m&&(m=v,u=g/3)}m<h*h&&a(o.distance,o.normal,u)}intersect(r,i,u,f,d,g){const{options:_,camera:P,rayBegin:w,rayEnd:E}=u;if(!_.selectionMode||!r.visible||!P)return;if(!F(i))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const L=r.attributes,z=L.get("position").data;let T=this.parameters.width;if(this.parameters.vvSize){const t=L.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(T*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else L.has("size")&&(T*=L.get("size").data[0]);const x=$;s(x,u.point);const C=T*P.pixelRatio/2+4*P.pixelRatio;a(ct[0],x[0]-C,x[1]+C,0),a(ct[1],x[0]+C,x[1]+C,0),a(ct[2],x[0]+C,x[1]-C,0),a(ct[3],x[0]-C,x[1]-C,0);for(let t=0;t<4;t++)if(!P.unprojectFromRenderScreen(ct[t],ht[t]))return;y(P.eye,ht[0],ht[1],mt),y(P.eye,ht[1],ht[2],ut),y(P.eye,ht[2],ht[3],ft),y(P.eye,ht[3],ht[0],dt);let O=Number.MAX_VALUE,M=0;const R=G(this.parameters,L)?z.length-2:z.length-5;for(let t=0;t<R;t+=3){H[0]=z[t]+i[12],H[1]=z[t+1]+i[13],H[2]=z[t+2]+i[14];const e=(t+3)%z.length;if(K[0]=z[e]+i[12],K[1]=z[e+1]+i[13],K[2]=z[e+2]+i[14],j(mt,H)<0&&j(mt,K)<0||j(ut,H)<0&&j(ut,K)<0||j(ft,H)<0&&j(ft,K)<0||j(dt,H)<0&&j(dt,K)<0)continue;if(P.projectToRenderScreen(H,tt),P.projectToRenderScreen(K,et),tt[2]<0&&et[2]>0){o(Q,H,K);const t=P.frustum,e=-j(t[4],H)/n(Q,A(t[4]));l(Q,Q,e),p(H,H,Q),P.projectToRenderScreen(H,tt)}else if(tt[2]>0&&et[2]<0){o(Q,K,H);const t=P.frustum,e=-j(t[4],K)/n(Q,A(t[4]));l(Q,Q,e),p(K,K,Q),P.projectToRenderScreen(K,et)}else if(tt[2]<0&&et[2]<0)continue;tt[2]=0,et[2]=0;const r=v(b(tt,et,st),x);r<O&&(O=r,c(rt,H),c(it,K),M=t/3)}if(O<C*C){let t=Number.MAX_VALUE;if(S(b(rt,it,st),b(w,E,at),Z)){o(Z,Z,w);const e=h(Z);l(Z,Z,1/e),t=e/m(w,E)}g(t,Z,M)}}get _layout(){const t=w().vec3f("position").vec4f16("previousDelta").vec4f16("nextDelta").f32("u0").vec2f16("lineParameters");return this.parameters.vvColor?t.f32("colorFeatureAttribute"):t.vec4u8("color",{glNormalized:!0}),this.parameters.vvSize?t.f32("sizeFeatureAttribute"):t.f32("size"),this.parameters.vvOpacity&&t.f32("opacityFeatureAttribute"),C()&&t.vec4u8("objectAndLayerIdColor"),this.parameters.hasAnimation&&t.vec3f16("timeStamps"),t}createBufferWriter(){return new q(this._layout,this.parameters)}createGLMaterial(t){return new J(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){const{hasAnimation:e,animationSpeed:r}=this.parameters;return!!e&&(this.setParameters({timeElapsed:i(t.time)*r},!1),t.dt>0)}}class J extends O{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(D,t)}}class Y extends R{constructor(){super(...arguments),this.width=0,this.color=d,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class q{constructor(t,e){this.vertexBufferLayout=t,this._parameters=e;const r=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=N+r}}_isClosed(t){return G(this._parameters,t)}allocate(t){return this.vertexBufferLayout.createBuffer(t)}elementCount(t){const e=2,r=t.get("position").indices.length/2+1,i=this._isClosed(t);let s=i?2:2*e;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,r,i,s,o){const n=r.get("position"),l=n.indices,p=n.data.length/3,h=r.get("distanceToStart")?.data;l&&l.length!==2*(p-1)&&console.warn("RibbonLineMaterial does not support indices");const f=(this.vertexBufferLayout.fields.has("sizeFeatureAttribute")?r.get("sizeFeatureAttribute")?.data[0]:r.get("size")?.data[0])??1;let d=[1,1,1,1],v=0;const b=this.vertexBufferLayout.fields.has("colorFeatureAttribute");b?v=r.get("colorFeatureAttribute").data[0]:r.has("color")&&(d=r.get("color").data);const _=r.get("timeStamps")?.data,S=_&&this.vertexBufferLayout.fields.has("timeStamps"),y=this.vertexBufferLayout.fields.has("opacityFeatureAttribute"),P=y?r.get("opacityFeatureAttribute").data[0]:0,j=new Float32Array(s.buffer),A=g(s.buffer),w=new Uint8Array(s.buffer),E=this.vertexBufferLayout.stride/4;let L=o*E;const z=L;let T=0;const x=h?(t,e,r)=>T=h[r]:(t,e,r)=>T+=m(t,e),O=j.BYTES_PER_ELEMENT/A.BYTES_PER_ELEMENT,M=4/O,F=(t,e,r,s,a,o,n,l)=>{j[L++]=e[0],j[L++]=e[1],j[L++]=e[2],B(t,e,A,L*O),L+=M,B(r,e,A,L*O),L+=M,j[L++]=l;let p=L*O;if(A[p++]=a,A[p++]=o,L=Math.ceil(p/O),b)j[L]=v;else{const t=Math.min(4*n,d.length-4),e=4*L;w[e]=255*d[t],w[e+1]=255*d[t+1],w[e+2]=255*d[t+2],w[e+3]=255*d[t+3]}if(L++,j[L++]=f,y&&(j[L++]=P),C()){let t=4*L;i?(w[t++]=i[0],w[t++]=i[1],w[t++]=i[2],w[t++]=i[3]):(w[t++]=0,w[t++]=0,w[t++]=0,w[t++]=0),L=Math.ceil(.25*t)}S&&(p=L*O,A[p++]=s[0],A[p++]=s[1],A[p++]=s[2],L=Math.ceil(p/O))};L+=E,a(nt,n.data[0],n.data[1],n.data[2]),S&&a(pt,_[0],_[1],_[2]),t&&u(nt,nt,t);const R=this._isClosed(r);if(R){const e=n.data.length-3;a(ot,n.data[e],n.data[e+1],n.data[e+2]),t&&u(ot,ot,t)}else a(lt,n.data[3],n.data[4],n.data[5]),t&&u(lt,lt,t),F(nt,nt,lt,pt,1,-4,0,0),F(nt,nt,lt,pt,1,4,0,0),c(ot,nt),c(nt,lt),S&&a(pt,_[3],_[4],_[5]);const N=R?0:1,k=R?p:p-1;for(let m=N;m<k;m++){const e=(m+1)%p*3;a(lt,n.data[e],n.data[e+1],n.data[e+2]),t&&u(lt,lt,t),x(ot,nt,m),F(ot,nt,lt,pt,0,-1,m,T),F(ot,nt,lt,pt,0,1,m,T);const r=this.numJoinSubdivisions;for(let t=0;t<r;++t){const e=(t+1)/(r+1);F(ot,nt,lt,pt,e,-1,m,T),F(ot,nt,lt,pt,e,1,m,T)}F(ot,nt,lt,pt,1,-2,m,T),F(ot,nt,lt,pt,1,2,m,T),c(ot,nt),c(nt,lt),S&&a(pt,_[e],_[e+1],_[e+2])}R?(a(lt,n.data[3],n.data[4],n.data[5]),t&&u(lt,lt,t),T=x(ot,nt,k),F(ot,nt,lt,pt,0,-1,N,T),F(ot,nt,lt,pt,0,1,N,T)):(T=x(ot,nt,k),F(ot,nt,nt,pt,0,-5,k,T),F(ot,nt,nt,pt,0,5,k,T)),X(j,z+E,j,z,E);return L=X(j,L-E,j,L,E),this._parameters.wireframe&&this._addWireframeVertices(s,z,L,E),null}_addWireframeVertices(t,e,r,i){const s=new Float32Array(t.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,r-e);let o=0;const n=t=>o=X(a,t,s,o,i);for(let l=0;l<a.length-1;l+=2*i)n(l),n(l+2*i),n(l+1*i),n(l+2*i),n(l+1*i),n(l+3*i)}}function X(t,e,r,i,s){for(let a=0;a<s;a++)r[i++]=t[e++];return i}function G(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function I(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const H=f(),K=f(),Q=f(),Z=f(),$=f(),tt=r(),et=r(),rt=f(),it=f(),st=_(),at=_(),ot=f(),nt=f(),lt=f(),pt=f(),ct=[r(),r(),r(),r()],ht=[f(),f(),f(),f()],mt=P(),ut=P(),ft=P(),dt=P();export{Y as Parameters,W as RibbonLineMaterial};
5
+ import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as i}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as a,d as o,e as n,g as l,f as h,c as p,l as c,j as m,t as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as g}from"../../../../geometry/support/float16.js";import{distance2 as v,fromPoints as b,create as _,closestLineSegmentPoint as S}from"../../../../geometry/support/lineSegment.js";import{fromPoints as y,create as P,signedDistance as j,getNormal as A}from"../../../../geometry/support/plane.js";import{newLayout as E}from"../../support/buffer/InterleavedLayout.js";import{isHighlightOrOID as w,isColorOrColorEmission as L,isDepth as z,isColorEmissionHighlightOIDOrDepth as T,is2DGeometryOutput as x}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as C}from"../effects/geometry/olidUtils.js";import O from"../lib/GLMaterial.js";import{Material as M}from"../lib/Material.js";import{isTranslationMatrix as F}from"../lib/Util.js";import{VisualVariablePassParameters as R}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as B}from"./internal/bufferWriterUtils.js";import{r as N}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as k,RibbonLineTechnique as D}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as U}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as V}from"../../../../webscene/support/AlphaCutoff.js";class W extends M{constructor(t){super(t,Y),this._configuration=new U,this.vertexAttributeLocations=k,this.produces=new Map([[2,t=>w(t)||L(t)&&8===this.parameters.renderOccluded],[3,t=>z(t)],[9,t=>T(t)&&8===this.parameters.renderOccluded],[10,t=>T(t)&&8===this.parameters.renderOccluded],[4,t=>L(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[7,t=>L(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[17,t=>x(t)]])}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=17===e.slot;const r=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&I(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&L(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration}get visible(){return this.parameters.color[3]>=V||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>V}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:r},i,s,a,o){if(!i.options.selectionMode)return;const n=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const r=t.get("sizeFeatureAttribute").data[0];Number.isNaN(r)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else n&&(l*=n.data[0]);const h=s[0],p=s[1],c=(l/2+4)*r;let m=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=G(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],r=f[g+1],i=(g+3)%f.length,s=h-t,a=p-r,o=f[i]-t,n=f[i+1]-r,l=e((o*s+n*a)/(o*o+n*n),0,1),c=o*l-s,d=n*l-a,v=c*c+d*d;v<m&&(m=v,u=g/3)}m<c*c&&a(o.distance,o.normal,u)}intersect(r,i,u,f,d,g){const{options:_,camera:P,rayBegin:E,rayEnd:w}=u;if(!_.selectionMode||!r.visible||!P)return;if(!F(i))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const L=r.attributes,z=L.get("position").data;let T=this.parameters.width;if(this.parameters.vvSize){const t=L.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(T*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else L.has("size")&&(T*=L.get("size").data[0]);const x=$;s(x,u.point);const C=T*P.pixelRatio/2+4*P.pixelRatio;a(pt[0],x[0]-C,x[1]+C,0),a(pt[1],x[0]+C,x[1]+C,0),a(pt[2],x[0]+C,x[1]-C,0),a(pt[3],x[0]-C,x[1]-C,0);for(let t=0;t<4;t++)if(!P.unprojectFromRenderScreen(pt[t],ct[t]))return;y(P.eye,ct[0],ct[1],mt),y(P.eye,ct[1],ct[2],ut),y(P.eye,ct[2],ct[3],ft),y(P.eye,ct[3],ct[0],dt);let O=Number.MAX_VALUE,M=0;const R=G(this.parameters,L)?z.length-2:z.length-5;for(let t=0;t<R;t+=3){H[0]=z[t]+i[12],H[1]=z[t+1]+i[13],H[2]=z[t+2]+i[14];const e=(t+3)%z.length;if(K[0]=z[e]+i[12],K[1]=z[e+1]+i[13],K[2]=z[e+2]+i[14],j(mt,H)<0&&j(mt,K)<0||j(ut,H)<0&&j(ut,K)<0||j(ft,H)<0&&j(ft,K)<0||j(dt,H)<0&&j(dt,K)<0)continue;if(P.projectToRenderScreen(H,tt),P.projectToRenderScreen(K,et),tt[2]<0&&et[2]>0){o(Q,H,K);const t=P.frustum,e=-j(t[4],H)/n(Q,A(t[4]));l(Q,Q,e),h(H,H,Q),P.projectToRenderScreen(H,tt)}else if(tt[2]>0&&et[2]<0){o(Q,K,H);const t=P.frustum,e=-j(t[4],K)/n(Q,A(t[4]));l(Q,Q,e),h(K,K,Q),P.projectToRenderScreen(K,et)}else if(tt[2]<0&&et[2]<0)continue;tt[2]=0,et[2]=0;const r=v(b(tt,et,st),x);r<O&&(O=r,p(rt,H),p(it,K),M=t/3)}if(O<C*C){let t=Number.MAX_VALUE;if(S(b(rt,it,st),b(E,w,at),Z)){o(Z,Z,E);const e=c(Z);l(Z,Z,1/e),t=e/m(E,w)}g(t,Z,M)}}get hasEmissions(){return this.parameters.emissiveStrength>0}get _layout(){const t=E().vec3f("position").vec4f16("previousDelta").vec4f16("nextDelta").f32("u0").vec2f16("lineParameters");return this.parameters.vvColor?t.f32("colorFeatureAttribute"):t.vec4u8("color",{glNormalized:!0}),this.parameters.vvSize?t.f32("sizeFeatureAttribute"):t.f32("size"),this.parameters.vvOpacity&&t.f32("opacityFeatureAttribute"),C()&&t.vec4u8("objectAndLayerIdColor"),this.parameters.hasAnimation&&t.vec3f16("timeStamps"),t}createBufferWriter(){return new q(this._layout,this.parameters)}createGLMaterial(t){return new J(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){const{hasAnimation:e,animationSpeed:r}=this.parameters;return!!e&&(this.setParameters({timeElapsed:i(t.time)*r},!1),t.dt>0)}}class J extends O{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(D,t)}}class Y extends R{constructor(){super(...arguments),this.width=0,this.color=d,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class q{constructor(t,e){this.vertexBufferLayout=t,this._parameters=e;const r=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=N+r}}_isClosed(t){return G(this._parameters,t)}allocate(t){return this.vertexBufferLayout.createBuffer(t)}elementCount(t){const e=2,r=t.get("position").indices.length/2+1,i=this._isClosed(t);let s=i?2:2*e;return s+=((i?r:r-1)-(i?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,r,i,s,o){const n=r.get("position"),l=n.indices,h=n.data.length/3,c=r.get("distanceToStart")?.data;l&&l.length!==2*(h-1)&&console.warn("RibbonLineMaterial does not support indices");const f=(this.vertexBufferLayout.fields.has("sizeFeatureAttribute")?r.get("sizeFeatureAttribute")?.data[0]:r.get("size")?.data[0])??1;let d=[1,1,1,1],v=0;const b=this.vertexBufferLayout.fields.has("colorFeatureAttribute");b?v=r.get("colorFeatureAttribute").data[0]:r.has("color")&&(d=r.get("color").data);const _=r.get("timeStamps")?.data,S=_&&this.vertexBufferLayout.fields.has("timeStamps"),y=this.vertexBufferLayout.fields.has("opacityFeatureAttribute"),P=y?r.get("opacityFeatureAttribute").data[0]:0,j=new Float32Array(s.buffer),A=g(s.buffer),E=new Uint8Array(s.buffer),w=this.vertexBufferLayout.stride/4;let L=o*w;const z=L;let T=0;const x=c?(t,e,r)=>T=c[r]:(t,e,r)=>T+=m(t,e),O=j.BYTES_PER_ELEMENT/A.BYTES_PER_ELEMENT,M=4/O,F=(t,e,r,s,a,o,n,l)=>{j[L++]=e[0],j[L++]=e[1],j[L++]=e[2],B(t,e,A,L*O),L+=M,B(r,e,A,L*O),L+=M,j[L++]=l;let h=L*O;if(A[h++]=a,A[h++]=o,L=Math.ceil(h/O),b)j[L]=v;else{const t=Math.min(4*n,d.length-4),e=4*L;E[e]=255*d[t],E[e+1]=255*d[t+1],E[e+2]=255*d[t+2],E[e+3]=255*d[t+3]}if(L++,j[L++]=f,y&&(j[L++]=P),C()){let t=4*L;i?(E[t++]=i[0],E[t++]=i[1],E[t++]=i[2],E[t++]=i[3]):(E[t++]=0,E[t++]=0,E[t++]=0,E[t++]=0),L=Math.ceil(.25*t)}S&&(h=L*O,A[h++]=s[0],A[h++]=s[1],A[h++]=s[2],L=Math.ceil(h/O))};L+=w,a(nt,n.data[0],n.data[1],n.data[2]),S&&a(ht,_[0],_[1],_[2]),t&&u(nt,nt,t);const R=this._isClosed(r);if(R){const e=n.data.length-3;a(ot,n.data[e],n.data[e+1],n.data[e+2]),t&&u(ot,ot,t)}else a(lt,n.data[3],n.data[4],n.data[5]),t&&u(lt,lt,t),F(nt,nt,lt,ht,1,-4,0,0),F(nt,nt,lt,ht,1,4,0,0),p(ot,nt),p(nt,lt),S&&a(ht,_[3],_[4],_[5]);const N=R?0:1,k=R?h:h-1;for(let m=N;m<k;m++){const e=(m+1)%h*3;a(lt,n.data[e],n.data[e+1],n.data[e+2]),t&&u(lt,lt,t),x(ot,nt,m),F(ot,nt,lt,ht,0,-1,m,T),F(ot,nt,lt,ht,0,1,m,T);const r=this.numJoinSubdivisions;for(let t=0;t<r;++t){const e=(t+1)/(r+1);F(ot,nt,lt,ht,e,-1,m,T),F(ot,nt,lt,ht,e,1,m,T)}F(ot,nt,lt,ht,1,-2,m,T),F(ot,nt,lt,ht,1,2,m,T),p(ot,nt),p(nt,lt),S&&a(ht,_[e],_[e+1],_[e+2])}R?(a(lt,n.data[3],n.data[4],n.data[5]),t&&u(lt,lt,t),T=x(ot,nt,k),F(ot,nt,lt,ht,0,-1,N,T),F(ot,nt,lt,ht,0,1,N,T)):(T=x(ot,nt,k),F(ot,nt,nt,ht,0,-5,k,T),F(ot,nt,nt,ht,0,5,k,T)),X(j,z+w,j,z,w);return L=X(j,L-w,j,L,w),this._parameters.wireframe&&this._addWireframeVertices(s,z,L,w),null}_addWireframeVertices(t,e,r,i){const s=new Float32Array(t.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,r-e);let o=0;const n=t=>o=X(a,t,s,o,i);for(let l=0;l<a.length-1;l+=2*i)n(l),n(l+2*i),n(l+1*i),n(l+2*i),n(l+1*i),n(l+3*i)}}function X(t,e,r,i,s){for(let a=0;a<s;a++)r[i++]=t[e++];return i}function G(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function I(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const H=f(),K=f(),Q=f(),Z=f(),$=f(),tt=r(),et=r(),rt=f(),it=f(),st=_(),at=_(),ot=f(),nt=f(),lt=f(),ht=f(),pt=[r(),r(),r(),r()],ct=[f(),f(),f(),f()],mt=P(),ut=P(),ft=P(),dt=P();export{Y as Parameters,W as RibbonLineMaterial};
@@ -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 o}from"tslib";import{parameter as t}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DefaultTechniqueConfiguration as e}from"../materials/DefaultTechniqueConfiguration.js";class i extends e{constructor(){super(...arguments),this.capType=0,this.hasPolygonOffset=!1,this.writeDepth=!1,this.draped=!1,this.stippleEnabled=!1,this.stippleOffColorEnabled=!1,this.stipplePreferContinuous=!0,this.roundJoins=!1,this.applyMarkerOffset=!1,this.vvSize=!1,this.vvColor=!1,this.vvOpacity=!1,this.falloffEnabled=!1,this.innerColorEnabled=!1,this.hasOccludees=!1,this.occluder=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.wireframe=!1,this.discardInvisibleFragments=!1,this.objectAndLayerIdColorInstanced=!1,this.animation=2,this.textureCoordinateType=0,this.emissionSource=0,this.occlusionPass=!1,this.hasVvInstancing=!0,this.hasSliceTranslatedView=!0,this.overlayEnabled=!1,this.snowCover=!1}}o([t({count:3})],i.prototype,"capType",void 0),o([t()],i.prototype,"hasPolygonOffset",void 0),o([t()],i.prototype,"writeDepth",void 0),o([t()],i.prototype,"draped",void 0),o([t()],i.prototype,"stippleEnabled",void 0),o([t()],i.prototype,"stippleOffColorEnabled",void 0),o([t()],i.prototype,"stipplePreferContinuous",void 0),o([t()],i.prototype,"roundJoins",void 0),o([t()],i.prototype,"applyMarkerOffset",void 0),o([t()],i.prototype,"vvSize",void 0),o([t()],i.prototype,"vvColor",void 0),o([t()],i.prototype,"vvOpacity",void 0),o([t()],i.prototype,"falloffEnabled",void 0),o([t()],i.prototype,"innerColorEnabled",void 0),o([t()],i.prototype,"hasOccludees",void 0),o([t()],i.prototype,"occluder",void 0),o([t()],i.prototype,"terrainDepthTest",void 0),o([t()],i.prototype,"cullAboveTerrain",void 0),o([t()],i.prototype,"wireframe",void 0),o([t()],i.prototype,"discardInvisibleFragments",void 0),o([t()],i.prototype,"objectAndLayerIdColorInstanced",void 0),o([t({count:4})],i.prototype,"animation",void 0);export{i as RibbonLineTechniqueConfiguration};
5
+ import{__decorate as o}from"tslib";import{parameter as t}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{DefaultTechniqueConfiguration as e}from"../materials/DefaultTechniqueConfiguration.js";class i extends e{constructor(){super(...arguments),this.capType=0,this.emissionSource=0,this.hasPolygonOffset=!1,this.writeDepth=!1,this.draped=!1,this.stippleEnabled=!1,this.stippleOffColorEnabled=!1,this.stipplePreferContinuous=!0,this.roundJoins=!1,this.applyMarkerOffset=!1,this.vvSize=!1,this.vvColor=!1,this.vvOpacity=!1,this.falloffEnabled=!1,this.innerColorEnabled=!1,this.hasOccludees=!1,this.occluder=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.wireframe=!1,this.discardInvisibleFragments=!1,this.objectAndLayerIdColorInstanced=!1,this.animation=2,this.textureCoordinateType=0,this.occlusionPass=!1,this.hasVvInstancing=!0,this.hasSliceTranslatedView=!0,this.overlayEnabled=!1,this.snowCover=!1}}o([t({count:3})],i.prototype,"capType",void 0),o([t({count:4})],i.prototype,"emissionSource",void 0),o([t()],i.prototype,"hasPolygonOffset",void 0),o([t()],i.prototype,"writeDepth",void 0),o([t()],i.prototype,"draped",void 0),o([t()],i.prototype,"stippleEnabled",void 0),o([t()],i.prototype,"stippleOffColorEnabled",void 0),o([t()],i.prototype,"stipplePreferContinuous",void 0),o([t()],i.prototype,"roundJoins",void 0),o([t()],i.prototype,"applyMarkerOffset",void 0),o([t()],i.prototype,"vvSize",void 0),o([t()],i.prototype,"vvColor",void 0),o([t()],i.prototype,"vvOpacity",void 0),o([t()],i.prototype,"falloffEnabled",void 0),o([t()],i.prototype,"innerColorEnabled",void 0),o([t()],i.prototype,"hasOccludees",void 0),o([t()],i.prototype,"occluder",void 0),o([t()],i.prototype,"terrainDepthTest",void 0),o([t()],i.prototype,"cullAboveTerrain",void 0),o([t()],i.prototype,"wireframe",void 0),o([t()],i.prototype,"discardInvisibleFragments",void 0),o([t()],i.prototype,"objectAndLayerIdColorInstanced",void 0),o([t({count:4})],i.prototype,"animation",void 0);export{i as RibbonLineTechniqueConfiguration};
@@ -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{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as _,when as h}from"../../core/promiseUtils.js";import{watch as u,initial as o,when as d}from"../../core/reactiveUtils.js";import{signal as E}from"../../core/signal.js";import{Milliseconds as l}from"../../core/time.js";import{PromiseQueue as T}from"../../layers/support/PromiseQueue.js";import c from"./debugFlags.js";import{Yield as m}from"./Yield.js";function g(){return new k.Scheduler}var R;!function(e){e.RESOURCE_CONTROLLER_IMMEDIATE="immediate",e.RESOURCE_CONTROLLER="schedule",e.SLIDE="slide",e.STREAM_DATA_LOADER="stream loader",e.ELEVATION_QUERY="elevation query",e.TERRAIN_SURFACE="terrain",e.SURFACE_GEOMETRY_UPDATES="surface geometry updates",e.LOD_RENDERER="LoD renderer",e.GRAPHICS_CORE="Graphics3D",e.I3S_CONTROLLER="I3S",e.POINT_CLOUD_LAYER="point cloud",e.FEATURE_TILE_FETCHER="feature fetcher",e.STREAM_CONTROLLER="stream controller",e.OVERLAY="overlay",e.OVERLAY_RENDERER="overlay renderer",e.STAGE="stage",e.GRAPHICS_DECONFLICTOR="graphics deconflictor",e.FILTER_VISIBILITY="Graphics3D filter visibility",e.SCALE_VISIBILITY="Graphics3D scale visibility",e.FRUSTUM_VISIBILITY="Graphics3D frustum visibility",e.POINT_OF_INTEREST_FREQUENT="POI frequent",e.POINT_OF_INTEREST_INFREQUENT="POI infrequent",e.LABELER="labeler",e.FEATURE_QUERY_ENGINE="feature query",e.FEATURE_TILE_TREE="feature tile tree",e.FEATURE_TILE_TREE_ACTIVE="fast feature tile tree",e.ELEVATION_ALIGNMENT="elevation alignment",e.ELEVATION_ALIGNMENT_SCENE="elevation alignment scene",e.TEXT_TEXTURE_ATLAS="text texture atlas",e.TEXTURE_UNLOAD="texture unload",e.LINE_OF_SIGHT_TOOL="line of sight tool",e.LINE_OF_SIGHT_TOOL_INTERACTIVE="interactive line of sight tool",e.ELEVATION_PROFILE="elevation profile",e.SNAPPING="snapping",e.SHADOW_ACCUMULATOR="shadow accumulator",e.CLOUDS_GENERATOR="clouds generator",e.MAPVIEW_FETCH_QUEUE="mapview fetch queue",e.MAPVIEW_LAYERVIEW_UPDATE="mapview layerview update",e.MAPVIEW_VECTOR_TILE_PARSING_QUEUE="mapview vector tile parsing queue",e[e.NONE=0]="NONE",e[e.TEST_PRIO=1]="TEST_PRIO"}(R||(R={}));const I=0,p=new Map([[R.RESOURCE_CONTROLLER_IMMEDIATE,I],[R.RESOURCE_CONTROLLER,4],[R.SLIDE,I],[R.STREAM_DATA_LOADER,I],[R.ELEVATION_QUERY,I],[R.TERRAIN_SURFACE,1],[R.SURFACE_GEOMETRY_UPDATES,1],[R.LOD_RENDERER,2],[R.GRAPHICS_CORE,2],[R.I3S_CONTROLLER,2],[R.POINT_CLOUD_LAYER,2],[R.FEATURE_TILE_FETCHER,2],[R.STREAM_CONTROLLER,2],[R.CLOUDS_GENERATOR,2],[R.OVERLAY,4],[R.OVERLAY_RENDERER,4],[R.STAGE,4],[R.GRAPHICS_DECONFLICTOR,4],[R.FILTER_VISIBILITY,4],[R.SCALE_VISIBILITY,4],[R.FRUSTUM_VISIBILITY,4],[R.POINT_OF_INTEREST_FREQUENT,6],[R.POINT_OF_INTEREST_INFREQUENT,30],[R.LABELER,8],[R.FEATURE_QUERY_ENGINE,8],[R.FEATURE_TILE_TREE,16],[R.FEATURE_TILE_TREE_ACTIVE,I],[R.ELEVATION_ALIGNMENT,12],[R.ELEVATION_ALIGNMENT_SCENE,14],[R.TEXT_TEXTURE_ATLAS,12],[R.TEXTURE_UNLOAD,12],[R.LINE_OF_SIGHT_TOOL,16],[R.LINE_OF_SIGHT_TOOL_INTERACTIVE,I],[R.SNAPPING,I],[R.SHADOW_ACCUMULATOR,30],[R.MAPVIEW_FETCH_QUEUE,I],[R.MAPVIEW_LAYERVIEW_UPDATE,2],[R.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,I]]);function f(e){return p.has(e)?p.get(e):"number"==typeof e?e:1}const L=l(6.5),A=l(1),O=l(30),S=l(1e3/30),b=l(100),N=.9;var k;!function(n){class _{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=E(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new g,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=u(()=>c.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,o);for(const e of Object.keys(R))this.performanceInfo.tasks.set(R[e],new a(R[e]))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new h(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=L,s=e.frameDuration,r=A;switch(this.state){case 2:t=l(0),s=l(Math.max(b,e.frameDuration)),r=O;break;case 1:s=l(Math.max(S,e.frameDuration))}return s=l(s-e.elapsedFrameTime-t),2!==this.state&&s<A&&!this._forceTask?(this._forceTask=!0,!1):(s=l(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(l(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*N+e*(1-N)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===I&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==I&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===m&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,R.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(R))this._frameTaskTimes.set(R[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}n.Scheduler=_;class h{get task(){return this._task.value}get updating(){return this._queue.running}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new T,this._handles=new s,this._basePriority=f(t),this.schedulePriority=this._basePriority,this._task=E(null!=r?r:this._queue),this._handles.add(d(()=>this.task.running,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(U),this._scheduler.removeTask(this),this.schedule=F.schedule,this.reschedule=F.reschedule,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=f(e);this._basePriority!==I&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.updating||!this.task.destroyed&&this.task.running}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class g{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}n.Budget=g}(k||(k={}));const U=new k.Budget;function C(e){const t=new k.Budget;return t.reset(e),t}U.enabled=!1;class P{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(U))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}}const F=new P;export{F as ImmediateTask,R as TaskPriority,f as getTaskPriority,C as makeBudget,g as newScheduler,U as noBudget,p as taskPriorities};
5
+ import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import a from"../../core/PerformanceSampler.js";import{isAborted as n,createAbortError as _,when as h}from"../../core/promiseUtils.js";import{watch as u,initial as o,when as d}from"../../core/reactiveUtils.js";import{signal as E}from"../../core/signal.js";import{Milliseconds as l}from"../../core/time.js";import{PromiseQueue as T}from"../../layers/support/PromiseQueue.js";import c from"./debugFlags.js";import{Yield as m}from"./Yield.js";function g(){return new k.Scheduler}var R;!function(e){e.RESOURCE_CONTROLLER_IMMEDIATE="immediate",e.RESOURCE_CONTROLLER="schedule",e.SLIDE="slide",e.STREAM_DATA_LOADER="stream loader",e.ELEVATION_QUERY="elevation query",e.TERRAIN_SURFACE="terrain",e.SURFACE_GEOMETRY_UPDATES="surface geometry updates",e.LOD_RENDERER="LoD renderer",e.GRAPHICS_CORE="Graphics3D",e.I3S_CONTROLLER="I3S",e.POINT_CLOUD_LAYER="point cloud",e.FEATURE_TILE_FETCHER="feature fetcher",e.STREAM_CONTROLLER="stream controller",e.OVERLAY="overlay",e.OVERLAY_RENDERER="overlay renderer",e.STAGE="stage",e.GRAPHICS_DECONFLICTOR="graphics deconflictor",e.FILTER_VISIBILITY="Graphics3D filter visibility",e.SCALE_VISIBILITY="Graphics3D scale visibility",e.FRUSTUM_VISIBILITY="Graphics3D frustum visibility",e.POINT_OF_INTEREST_FREQUENT="POI frequent",e.POINT_OF_INTEREST_INFREQUENT="POI infrequent",e.LABELER="labeler",e.FEATURE_QUERY_ENGINE="feature query",e.FEATURE_TILE_TREE="feature tile tree",e.FEATURE_TILE_TREE_ACTIVE="fast feature tile tree",e.ELEVATION_ALIGNMENT="elevation alignment",e.ELEVATION_ALIGNMENT_SCENE="elevation alignment scene",e.TEXT_TEXTURE_ATLAS="text texture atlas",e.TEXTURE_UNLOAD="texture unload",e.LINE_OF_SIGHT_TOOL="line of sight tool",e.LINE_OF_SIGHT_TOOL_INTERACTIVE="interactive line of sight tool",e.ELEVATION_PROFILE="elevation profile",e.SNAPPING="snapping",e.SHADOW_ACCUMULATOR="shadow accumulator",e.CLOUDS_GENERATOR="clouds generator",e.FLOW_GENERATOR="flow generator",e.MAPVIEW_FETCH_QUEUE="mapview fetch queue",e.MAPVIEW_LAYERVIEW_UPDATE="mapview layerview update",e.MAPVIEW_VECTOR_TILE_PARSING_QUEUE="mapview vector tile parsing queue",e[e.NONE=0]="NONE",e[e.TEST_PRIO=1]="TEST_PRIO"}(R||(R={}));const I=0,p=new Map([[R.RESOURCE_CONTROLLER_IMMEDIATE,I],[R.RESOURCE_CONTROLLER,4],[R.SLIDE,I],[R.STREAM_DATA_LOADER,I],[R.ELEVATION_QUERY,I],[R.TERRAIN_SURFACE,1],[R.SURFACE_GEOMETRY_UPDATES,1],[R.LOD_RENDERER,2],[R.GRAPHICS_CORE,2],[R.I3S_CONTROLLER,2],[R.POINT_CLOUD_LAYER,2],[R.FEATURE_TILE_FETCHER,2],[R.STREAM_CONTROLLER,2],[R.CLOUDS_GENERATOR,2],[R.OVERLAY,4],[R.OVERLAY_RENDERER,4],[R.STAGE,4],[R.GRAPHICS_DECONFLICTOR,4],[R.FILTER_VISIBILITY,4],[R.SCALE_VISIBILITY,4],[R.FRUSTUM_VISIBILITY,4],[R.POINT_OF_INTEREST_FREQUENT,6],[R.POINT_OF_INTEREST_INFREQUENT,30],[R.LABELER,8],[R.FEATURE_QUERY_ENGINE,8],[R.FEATURE_TILE_TREE,16],[R.FEATURE_TILE_TREE_ACTIVE,I],[R.ELEVATION_ALIGNMENT,12],[R.ELEVATION_ALIGNMENT_SCENE,14],[R.TEXT_TEXTURE_ATLAS,12],[R.TEXTURE_UNLOAD,12],[R.LINE_OF_SIGHT_TOOL,16],[R.LINE_OF_SIGHT_TOOL_INTERACTIVE,I],[R.SNAPPING,I],[R.SHADOW_ACCUMULATOR,30],[R.FLOW_GENERATOR,12],[R.MAPVIEW_FETCH_QUEUE,I],[R.MAPVIEW_LAYERVIEW_UPDATE,2],[R.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,I]]);function f(e){return p.has(e)?p.get(e):"number"==typeof e?e:1}const L=l(6.5),O=l(1),A=l(30),N=l(1e3/30),S=l(100),b=.9;var k;!function(n){class _{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=E(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new a("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new g,this._state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._idleStateCallbacks=new Array,this._idleUpdatesStartFired=!1,this._forceTask=!1,this._debug=!1,this._debugHandle=u(()=>c.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,o);for(const e of Object.keys(R))this.performanceInfo.tasks.set(R[e],new a(R[e]))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._idleStateCallbacks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new h(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new a(e)),s}registerIdleStateCallbacks(e,t){const s={idleBegin:e,idleEnd:t};this._idleStateCallbacks.push(s),2===this.state&&this._idleUpdatesStartFired&&s.idleBegin();const r=this;return{remove:()=>this._removeIdleStateCallbacks(s),set idleBegin(e){r._idleUpdatesStartFired&&(s.idleEnd(),2===r._state&&e()),s.idleBegin=e},set idleEnd(e){s.idleEnd=e}}}get load(){return this._load}set state(e){this._state!==e&&(this._state=e,2!==this.state&&this._idleUpdatesStartFired&&(this._idleUpdatesStartFired=!1,this._idleStateCallbacks.forEach(e=>e.idleEnd())))}get state(){return this._state}frame(e){this._startFrameTaskTimes();const t=this._updateBudget(e);if(t){const e=this._budget.now();this._runFrame(),this._recordFrameTaskTimes(this._budget.now()-e)}else this._recordFrameTaskTimes(0);return t}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=L,s=e.frameDuration,r=O;switch(this.state){case 2:t=l(0),s=l(Math.max(S,e.frameDuration)),r=A;break;case 1:s=l(Math.max(N,e.frameDuration))}return s=l(s-e.elapsedFrameTime-t),2!==this.state&&s<O&&!this._forceTask?(this._forceTask=!0,!1):(s=l(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._idleUpdatesStartFired||(this._idleUpdatesStartFired=!0,this._idleStateCallbacks.forEach(e=>e.idleBegin())),this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(l(0)),this._budget.madeProgress()}_removeIdleStateCallbacks(t){this._idleUpdatesStartFired&&t.idleEnd(),e(this._idleStateCallbacks,t)}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*b+e*(1-b)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===I&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==I&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===m&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,R.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now()-t;if(s.runtime+=i,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+i),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(R))this._frameTaskTimes.set(R[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}n.Scheduler=_;class h{get task(){return this._task.value}get updating(){return this._queue.running}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new T,this._handles=new s,this._basePriority=f(t),this.schedulePriority=this._basePriority,this._task=E(null!=r?r:this._queue),this._handles.add(d(()=>this.task.running,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(U),this._scheduler.removeTask(this),this.schedule=F.schedule,this.reschedule=F.reschedule,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=f(e);this._basePriority!==I&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.updating||!this.task.destroyed&&this.task.running}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class g{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}n.Budget=g}(k||(k={}));const U=new k.Budget;function C(e){const t=new k.Budget;return t.reset(e),t}U.enabled=!1;class P{remove(){}processQueue(){}schedule(e,t,s){try{if(n(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(U))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}}const F=new P;export{F as ImmediateTask,R as TaskPriority,f as getTaskPriority,C as makeBudget,g as newScheduler,U as noBudget,p as taskPriorities};
@@ -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 o from"../../core/Collection.js";import{defaultHighlightName as r,temporaryHighlightColor as t,temporaryHighlightName as e}from"./HighlightDefaults.js";import i from"./HighlightOptions.js";function n(){return new o([new i({name:r}),new i({name:e,color:t})])}export{n as createInitialHighlightOptions};
5
+ import o from"../../core/Collection.js";import{defaultHighlightName as n,temporaryHighlightColor as r,temporaryHighlightName as t}from"./HighlightDefaults.js";import e from"./HighlightOptions.js";function i(){return new o([new e({name:n}),new e({name:t,color:r})])}function m(o){return o?.name??n}export{i as createInitialHighlightOptions,m as getHighlightName};
@@ -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"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment0 as h,StencilAttachment as n,SizedDepthStencilFormat as o,DepthStencilAttachment as c,SizedDepthFormat as a,DepthAttachment as u}from"./enums.js";import{Renderbuffer as f}from"./Renderbuffer.js";import{Texture as l}from"./Texture.js";const d=()=>t.getLogger("esri.views.webgl.FramebufferObject");class _{constructor(t,e,i){if(this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(s.FramebufferObject,this),null!=e){const i=m(e)?e:new l(t,e);this._colorAttachments.set(h,i),this._validateTextureDescriptor(i.descriptor),this._validateColorAttachmentPoint(h)}if(null!=i)if(T(i))this._depthStencilTexture=m(i)?i:new l(t,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const e=p(i)?i:new f(t,i);this._depthStencilBuffer=e,this._validateRenderbufferDescriptor(e.descriptor)}}dispose(){const{_colorAttachments:t,_glName:e}=this;if(0===t.size&&!this._depthStencilBuffer&&!this._depthStencilTexture&&!e)return;const{_context:i}=this,r=i.getBoundFramebufferObject();t.forEach((t,e)=>this.detachColorTexture(e)?.dispose()),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),i.gl.deleteFramebuffer(e),this._glName=null,i.bindFramebuffer(r===this?null:r),i.instanceCounter.decrement(s.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(h)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(h)??this._depthStencilTexture??this._depthStencilBuffer;return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(h)??this._depthStencilTexture??this._depthStencilBuffer;return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce((t,[e,i])=>t+i.usedMemory,this.depthStencil?.usedMemory??0)}static{this._MAX_COLOR_ATTACHMENTS=-1}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&m(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=h){if(!t)return;this._validateColorAttachmentPoint(e);const{descriptor:i}=t;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=h){const e=this._colorAttachments.get(t);if(e)return this._initialized&&this._context.temporaryBindFramebufferObject(this,()=>{this._framebufferTexture2D(null,t)}),this._colorAttachments.delete(t),e}setColorTextureTarget(t,e=h,i=0){const r=this._colorAttachments.get(e);r&&(35866===t?this._framebufferTextureLayer(r.glName,e,36160,0,i):this._framebufferTexture2D(r.glName,e,t,36160,0))}attachDepthStencil(t){if(t)switch(t.type){case 1:return this._attachDepthStencilTexture(t);case 2:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const{descriptor:e}=t,{pixelFormat:i,dataType:r}=e;34041===i||6402===i?34041!==i||34042===r?6402!==i||5125===r||5123===r?(this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,E(i))),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t):console.error("Depth texture must have data type of UNSIGNED_INT or UNSIGNED_SHORT!"):console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"):console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!")}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&this._context.temporaryBindFramebufferObject(this,()=>{this._framebufferTexture2D(null,E(t.descriptor.pixelFormat))}),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderbufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const{gl:i}=this._context,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(36160,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const{_context:e}=this,i=e.getBoundFramebufferObject();e.bindFramebuffer(this);const{gl:r}=e,s=this._getGLAttachmentPoint(t.descriptor);r.framebufferRenderbuffer(36160,s,r.RENDERBUFFER,null),e.bindFramebuffer(i)}return this._depthStencilBuffer=null,t}invalidateAttachments(t){const{_context:e}=this;e.temporaryBindFramebufferObject(this,()=>e.gl.invalidateFramebuffer(36160,t),!0)}copyToTexture(t,e,i,r,s,h,n){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=n.descriptor;3553!==n.descriptor.target&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||h+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(n,l.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(3553,0,s,h,t,e,i,r),c.bindTexture(a,l.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,r,s,h,n,o){const{gl:c}=this._context,a=i.createPixelPack(this._context,35041,o.byteLength);this._context.bindBuffer(a);const u=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),c.readPixels(t,e,r,s,h,n,0),this._context.unbindBuffer(35051),this._context.bindFramebuffer(u),await a.getSubDataAsync(o),a.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};g(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach(t=>t.resize(i.width,i.height)),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(g(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=36160){const{gl:e}=this._context;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach((e,i)=>{const r=S(e);35866===r?this._framebufferTextureLayer(e.glName,i,t,0,0):this._framebufferTexture2D(e.glName,i,r,t)}),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else if(this._depthStencilTexture){const e=E(this._depthStencilTexture.descriptor.pixelFormat);this._framebufferTexture2D(this._depthStencilTexture.glName,e,S(this._depthStencilTexture),t)}if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=h,i=3553,r=36160,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_framebufferTextureLayer(t,e=h,i=36160,r=0,s=0){this._context.gl.framebufferTextureLayer(i,e,t,r,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(36160,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,E(this._depthStencilTexture.descriptor.pixelFormat))),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){3553!==t.target&&34067!==t.target&&35866!==t.target&&console.error("Texture type must be TEXTURE_2D, TEXTURE_2D_ARRAY or TEXTURE_CUBE_MAP!"),g(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderbufferDescriptor(t){g(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case a.DEPTH_COMPONENT16:case a.DEPTH_COMPONENT24:case a.DEPTH_COMPONENT32F:return u;case o.DEPTH24_STENCIL8:case o.DEPTH32F_STENCIL8:return c;case 36168:return n}}_validateColorAttachmentPoint(e){if(-1===_._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;_._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const i=e-h;i+1>_._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${_._MAX_COLOR_ATTACHMENTS} color attachments`)}}function m(t){return 1===b(t)}function p(t){return 2===b(t)}function T(t){return m(t)||x(t)}function x(t){return 0===b(t)}function b(t){return null!=t&&"type"in t?t.type:null}function g(t,e){const i=Math.max(t.width,t.height);if(i>e){d().warnOnce(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function S(t){return 34067===t.descriptor.target?34069:35866===t.descriptor.target?35866:3553}function E(t){return 6402===t?u:c}export{_ as FramebufferObject,g as ensureAttachmentMaxSize};
5
+ import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as r}from"./BufferObject.js";import{webglDebugEnabled as i}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment0 as n,StencilAttachment as h,SizedDepthStencilFormat as o,DepthStencilAttachment as c,SizedDepthFormat as a,DepthAttachment as u}from"./enums.js";import{Renderbuffer as f}from"./Renderbuffer.js";import{Texture as l}from"./Texture.js";const d=()=>t.getLogger("esri.views.webgl.FramebufferObject");class _{constructor(t,e,r){if(this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(s.FramebufferObject,this),null!=e){const r=S(t,e);null!=r&&(this._colorAttachments.set(n,r),m(r)?this._validateTextureDescriptor(r.descriptor):this._validateRenderbufferDescriptor(r.descriptor)),this._validateColorAttachmentPoint(n)}if(null!=r)if(T(r))this._depthStencilTexture=m(r)?r:new l(t,r),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const e=p(r)?r:new f(t,r);this._depthStencilBuffer=e,this._validateRenderbufferDescriptor(e.descriptor)}}dispose(){const{_colorAttachments:t,_glName:e}=this;if(0===t.size&&!this._depthStencilBuffer&&!this._depthStencilTexture&&!e)return;const{_context:r}=this,i=r.getBoundFramebufferObject();t.forEach((t,e)=>this.detachColorTexture(e)?.dispose()),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),r.gl.deleteFramebuffer(e),this._glName=null,r.bindFramebuffer(i===this?null:i),r.instanceCounter.decrement(s.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){const t=this._colorAttachments.get(n);return m(t)?t:null}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n)??this._depthStencilTexture??this._depthStencilBuffer;return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n)??this._depthStencilTexture??this._depthStencilBuffer;return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce((t,[e,r])=>t+r.usedMemory,this.depthStencil?.usedMemory??0)}static{this._MAX_COLOR_ATTACHMENTS=-1}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&m(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n){if(!t)return;this._validateColorAttachmentPoint(e);const{descriptor:r}=t;this._validateTextureDescriptor(r),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n){const e=this._colorAttachments.get(t);if(!e)return;const r=m(e);return this._initialized&&this._context.temporaryBindFramebufferObject(this,()=>{if(r)this._framebufferTexture2D(null,t);else{const e=this._context.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,t,e.RENDERBUFFER,null)}}),this._colorAttachments.delete(t),r?e:void 0}setColorTextureTarget(t,e=n,r=0){const i=this._colorAttachments.get(e);i&&(35866===t?this._framebufferTextureLayer(i.glName,e,36160,0,r):this._framebufferTexture2D(i.glName,e,t,36160,0))}attachDepthStencil(t){if(t)switch(t.type){case 1:return this._attachDepthStencilTexture(t);case 2:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const{descriptor:e}=t,{pixelFormat:r,dataType:i}=e;34041===r||6402===r?34041!==r||34042===i?6402!==r||5125===i||5123===i?(this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,D(r))),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t):console.error("Depth texture must have data type of UNSIGNED_INT or UNSIGNED_SHORT!"):console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"):console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!")}detachDepthStencilTexture(){const t=this._depthStencilTexture;return t&&this._initialized&&this._context.temporaryBindFramebufferObject(this,()=>{this._framebufferTexture2D(null,D(t.descriptor.pixelFormat))}),this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderbufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const{gl:r}=this._context,i=this._getGLAttachmentPoint(e);r.framebufferRenderbuffer(36160,i,r.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const{_context:e}=this,r=e.getBoundFramebufferObject();e.bindFramebuffer(this);const{gl:i}=e,s=this._getGLAttachmentPoint(t.descriptor);i.framebufferRenderbuffer(36160,s,i.RENDERBUFFER,null),e.bindFramebuffer(r)}return this._depthStencilBuffer=null,t}invalidateAttachments(t){const{_context:e}=this;e.temporaryBindFramebufferObject(this,()=>e.gl.invalidateFramebuffer(36160,t),!0)}copyToTexture(t,e,r,i,s,n,h){(t<0||e<0||s<0||n<0)&&console.error("Offsets cannot be negative!"),(r<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const o=h.descriptor;3553!==h.descriptor.target&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+r>this.width||e+i>this.height||s+r>o.width||n+i>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(h,l.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(3553,0,s,n,t,e,r,i),c.bindTexture(a,l.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,r,i,s,n,h){(r<=0||i<=0)&&console.error("Copy width and height must be greater than zero!"),h||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,r,i,s,n,h)}async readPixelsAsync(t,e,i,s,n,h,o){const{gl:c}=this._context,a=r.createPixelPack(this._context,35041,o.byteLength);this._context.bindBuffer(a);const u=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),c.readPixels(t,e,i,s,n,h,0),this._context.unbindBuffer(35051),this._context.bindFramebuffer(u),await a.getSubDataAsync(o),a.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const r={width:t,height:e};E(r,this._context.parameters.maxTextureSize),this._colorAttachments.forEach(t=>t.resize(r.width,r.height)),this._depthStencilTexture?.resize(r.width,r.height),this._initialized&&(E(r,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(r.width,r.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=36160){const{gl:e}=this._context;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const r=e.createFramebuffer();if(e.bindFramebuffer(t,r),this._colorAttachments.forEach((e,r)=>{if(m(e)){const i=F(e);35866===i?this._framebufferTextureLayer(e.glName,r,t,0,0):this._framebufferTexture2D(e.glName,r,i,t)}else if(p(e)){const i=this._context.gl;i.framebufferRenderbuffer(t,r,i.RENDERBUFFER,e.glName)}}),this._depthStencilBuffer){const r=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,r,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else if(this._depthStencilTexture){const e=D(this._depthStencilTexture.descriptor.pixelFormat);this._framebufferTexture2D(this._depthStencilTexture.glName,e,F(this._depthStencilTexture),t)}if(i()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=r,this._initialized=!0}_framebufferTexture2D(t,e=n,r=3553,i=36160,s=0){this._context.gl.framebufferTexture2D(i,e,r,t,s)}_framebufferTextureLayer(t,e=n,r=36160,i=0,s=0){this._context.gl.framebufferTextureLayer(r,e,t,i,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(36160,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,D(this._depthStencilTexture.descriptor.pixelFormat))),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){3553!==t.target&&34067!==t.target&&35866!==t.target&&console.error("Texture type must be TEXTURE_2D, TEXTURE_2D_ARRAY or TEXTURE_CUBE_MAP!"),E(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderbufferDescriptor(t){E(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case a.DEPTH_COMPONENT16:case a.DEPTH_COMPONENT24:case a.DEPTH_COMPONENT32F:return u;case o.DEPTH24_STENCIL8:case o.DEPTH32F_STENCIL8:return c;case 36168:return h;default:return n}}_validateColorAttachmentPoint(e){if(-1===_._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;_._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const r=e-n;r+1>_._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${r+1}. Implementation supports up to ${_._MAX_COLOR_ATTACHMENTS} color attachments`)}}function m(t){return 1===g(t)}function p(t){return 2===g(t)}function T(t){return m(t)||x(t)}function x(t){return 0===g(t)}function b(t){return 3===g(t)||null!=t&&"samples"in t}function g(t){return null!=t&&"type"in t?t.type:null}function S(t,e){return m(e)||p(e)?e:x(e)?new l(t,e):b(e)?new f(t,e):null}function E(t,e){const r=Math.max(t.width,t.height);if(r>e){d().warnOnce(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const i=e/r;return t.width=Math.round(t.width*i),t.height=Math.round(t.height*i),!1}return!0}function F(t){return 34067===t.descriptor.target?34069:35866===t.descriptor.target?35866:3553}function D(t){return 6402===t?u:c}export{_ as FramebufferObject,E as ensureAttachmentMaxSize};
@@ -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{getBytesPerElementFormat as t}from"./Util.js";class i{constructor(t,i=0,h=i){this.internalFormat=t,this.width=i,this.height=h,this.multisampled=!1,this.samples=1}}function h(i){return i.width<=0||i.height<=0||null==i.internalFormat?0:i.width*i.height*t(i.internalFormat)}export{i as RenderbufferDescriptor,h as estimateMemory};
5
+ import{getBytesPerElementFormat as t}from"./Util.js";class i{constructor(t,i=0,h=i,r=!1,s=1){this.internalFormat=t,this.width=i,this.height=h,this.multisampled=r,this.samples=s}}function h(i){return i.width<=0||i.height<=0||null==i.internalFormat?0:i.width*i.height*t(i.internalFormat)}export{i as RenderbufferDescriptor,h as estimateMemory};