@arcgis/core 6.0.0-next.1 → 6.0.0-next.2

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 (77) hide show
  1. package/analysis/DimensionSimpleStyle.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/01803f76bc0d9f2cd566.js +1 -0
  4. package/assets/esri/core/workers/chunks/{a7325ebb7edf3273bb34.js → 12b84262dedc6b393136.js} +1 -1
  5. package/assets/esri/core/workers/chunks/261fea092ee7d27608a0.js +1 -0
  6. package/assets/esri/core/workers/chunks/{8af92bcc075e03e3e902.js → 512628db534605a2a93e.js} +22 -22
  7. package/assets/esri/core/workers/chunks/5e4d6c283c2fa28db022.js +1 -0
  8. package/assets/esri/core/workers/chunks/64770e2cf41211b63fd2.js +1 -0
  9. package/assets/esri/core/workers/chunks/{ffb3728e6ac428f62af1.js → 71103472c45928bd730c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/73a87fb270818aa75fc5.js +1 -0
  11. package/assets/esri/core/workers/chunks/7ef182e24cad50815b4e.js +1 -0
  12. package/assets/esri/core/workers/chunks/8313c626596a76c7449d.js +1 -0
  13. package/assets/esri/core/workers/chunks/84e9258a57d8c365f361.js +1 -0
  14. package/assets/esri/core/workers/chunks/{b0cfec11c758eed8095f.js → 87b4e916b2668203a6b0.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{aa1054834738aef48bda.js → a0356702f2d3f787aeac.js} +1 -1
  16. package/assets/esri/core/workers/chunks/ac4cc49104d26c384e98.js +1 -0
  17. package/assets/esri/core/workers/chunks/ec28e18275d36e71b438.js +1 -0
  18. package/assets/esri/core/workers/chunks/{050c4b212f2b5691db34.js → f762f70e7d39634ce797.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{32d08b571bbd996d4e6d.js → fb4ff0ac2bc445fec413.js} +1 -1
  20. package/chunks/RibbonLine.glsl.js +9 -11
  21. package/config.js +1 -1
  22. package/core/screenUtils.js +1 -1
  23. package/kernel.js +1 -1
  24. package/package.json +2 -2
  25. package/smartMapping/renderers/support/spikeUtils.js +3 -3
  26. package/symbols/LineSymbol3DLayer.js +1 -1
  27. package/symbols/callouts/LineCallout3D.js +1 -1
  28. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  29. package/symbols/edges/Edges3D.js +1 -1
  30. package/symbols/support/Symbol3DIconOutline.js +1 -1
  31. package/symbols/support/Symbol3DOutline.js +1 -1
  32. package/symbols/support/Symbol3DTextBorder.js +1 -1
  33. package/symbols/support/defaults3D.js +1 -1
  34. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  35. package/views/2d/analysis/AreaMeasurementAnalysisView2D.d.ts +2 -0
  36. package/views/2d/analysis/AreaMeasurementAnalysisView2D.js +1 -1
  37. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  38. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.d.ts +2 -0
  39. package/views/2d/analysis/DistanceMeasurementAnalysisView2D.js +1 -1
  40. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  41. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  42. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/TexturedLineShader.js +1 -1
  43. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  44. package/views/3d/analysis/LineOfSight/LineOfSightEditTool.js +1 -1
  45. package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
  46. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  47. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  48. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  49. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  50. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  51. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  52. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  53. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  54. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  55. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  56. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  57. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  58. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  59. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  60. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +3 -3
  61. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +23 -9
  62. package/views/draw/support/PluginContext.js +1 -1
  63. package/views/draw/support/managers/TooltipManager.js +1 -1
  64. package/views/interactive/snapping/SnappingVisualizer.js +1 -1
  65. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  66. package/widgets/Editor/workflowUtils.js +1 -1
  67. package/widgets/support/SelectionList/FeatureItem.d.ts +9 -2
  68. package/assets/esri/core/workers/chunks/084222c00d263a534952.js +0 -1
  69. package/assets/esri/core/workers/chunks/37a636f61cfe89c6bfd1.js +0 -1
  70. package/assets/esri/core/workers/chunks/4848f195eb93cc93dd15.js +0 -1
  71. package/assets/esri/core/workers/chunks/750a9f3cdb96b966274a.js +0 -1
  72. package/assets/esri/core/workers/chunks/897fc8e78a0d54a5ff5a.js +0 -1
  73. package/assets/esri/core/workers/chunks/9432feca48ca3e5849bd.js +0 -1
  74. package/assets/esri/core/workers/chunks/956a40f40bde416efe93.js +0 -1
  75. package/assets/esri/core/workers/chunks/985b3f18cee87c3fe022.js +0 -1
  76. package/assets/esri/core/workers/chunks/ca7fb75e2c62e7d37122.js +0 -1
  77. package/assets/esri/core/workers/chunks/e7c60bd85abbd36cdc64.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,removeMaybe as r,destroyMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,whenOnce as s,initial as c}from"../../../core/reactiveUtils.js";import{isUint32Array as l}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as u,convertUnit as d}from"../../../core/units.js";import{property as f,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromValues as m}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as h}from"../../../geometry/ellipsoidUtils.js";import g from"../../../geometry/HeightModelInfo.js";import{create as _}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as v}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as y,isWebMercator as b,equals as x,isGeographic as S}from"../../../geometry/support/spatialReferenceUtils.js";import C from"../../../geometry/support/WKIDUnitConversion.js";import{validateEntity3D as w,makeCacheKey as T,getHeightModelInfoFromVCS as E}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as O}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as k}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as A}from"./LayerView3D.js";import{addLayerViewToWasm as j,getLyr3DWasm as M,removeLayerViewFromWasm as N}from"./Lyr3DWasm.js";import{LayerElevationProvider as P}from"./i3s/LayerElevationProvider.js";import{ElevationRange as F}from"../support/ElevationRange.js";import{projectToBoundingBox as I}from"../support/extentUtils.js";import{Obb as L}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as R,gaussiansPerPage as z,packedGaussianSizeInU32 as B,splatAtlasTextureWidth as V}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as H}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as U}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as W}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as G}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatDepthRenderer as K}from"../webgl-engine/lib/GaussianSplatDepthRenderer.js";import{GaussianSplatRenderer as q}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as J}from"../webgl-engine/lib/GaussianSplatShadows.js";import Y from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as X,isInEffectiveScaleRange as Z}from"../../support/layerViewUtils.js";import{TaskPriority as ee}from"../../support/Scheduler.js";var Q;const te=()=>t.getLogger(`esri.views.3d.layers.GaussianSplatLayerView3D`),ne=(()=>{let e=new Int16Array(256);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/255));return e})();let $=class extends A(Y){static{Q=this}static{this.createRenderableBatchSize=64}static{this.uploadBatchPageCount=16}constructor(e){super(e),this.type=`gaussian-splat-3d`,this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(R*Q.uploadBatchPageCount),this._tmpTilesWithChangedVisibility=[],this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this.skipHeightModelInfoValidation=!0,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(ee.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;let e=_();return I(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){let{view:e}=this;this.addHandles([o(()=>e.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())})]),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await s(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw X(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await j(this,t),a(t),this._renderer=new q({view:e,layerView:this}),this.data=new H(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new J({view:e,layerView:this}),this.fadeHelper=new U(this),this._prepassDepthRenderer=new K({view:e,layerView:this});let n=new W(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new P({view:e,layerElevationSource:this,intersectionHandler:n}),e.elevationProvider.register(2,this._elevationProvider),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),o(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),c)]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),c),this.addHandles([o(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},c),o(()=>this.maximumGaussianCount,e=>this._wasm?.setMaximumGaussianSplatCount(Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians)),c)]),this._initializationController=null}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return M(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return D(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new F(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return Z(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){let e=this._wasm;return this._wasmLayerId<0||e==null?!1:e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!w(t))throw Error(`entity3D not valid`);let n=t.desc.geometry.prims[t.validPrimitiveIndices[0]].atrbs[0],r=t.assets[n.assetId];if(!r)throw Error(`entity3D not valid`);let i=r.count;if(i===0)return te().warnOnce(`encountered tile with zero Gaussians`),()=>({memUsageBytes:0,numGaussians:0});let a=null;if(r.dataType===`U32`&&l(r.data))a=r.data;else throw Error(`unexpected GaussianSplat Entity3D asset.data format`);let o=this.extractHeader(a),s=2.048,c=o.tileOrigin.x*s,u=o.tileOrigin.y*s,d=o.tileOrigin.z*s,f=t.desc,p=f.obb.quaternion,g=new L(f.obb.center,f.obb.halfSize,m(...p)),_=this.view.state.isGlobal,v=_?h(this.view.spatialReference).radius:0,y={handle:e.handle,bufferView:a,totalGaussians:i,packedHeader:o.packedHeader,tileOrigin:{x:c,y:u,z:d},invPosScale:o.invPosScale,obb:g,origin:{x:g.centerX,y:g.centerY,z:g.centerZ},isGlobal:_,ellipsoidRadius:v};this._renderablesBeingCreated.add(e.handle);let b;try{b=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(y,e),this._createRenderableAbortController.signal)}catch(t){throw this._renderablesBeingCreated.delete(e.handle),t}return this._renderablesBeingCreated.delete(e.handle),()=>b}*_createRenderableTask(e,t){let{handle:n,bufferView:r,totalGaussians:i,packedHeader:a,tileOrigin:o,invPosScale:s,obb:c,origin:l,isGlobal:u,ellipsoidRadius:d}=e,f=o.x,p=o.y,m=o.z,h=l.x,g=l.y,_=l.z,v=new Float32Array(i*3),y=new Uint32Array(i),b=new Uint32Array(i),x=[],S=Math.ceil(i/z),C=1/0,w=-1/0,T=1/0,E=-1/0,D=0,O=-1,k=0,A=0;for(let e=0;e<i;e++){let n=e*B,i=r[n],a=r[n+1],o=r[n+2],c=r[n+3],l=a&16383,d=a>>>14&16383,x=a>>>28&15|(o&1023)<<4,S=c>>>24,j=ne[S],M=(o>>>10&255)+j,N=(o>>>18&255)+j,P=(o>>>26&63|(c&3)<<6)+j,F=M>0?M:0,I=N>0?N:0,L=P>0?P:0,R=F|I<<8|L<<16,z=Math.max(F,I,L),V=l*s+f,H=d*s+p,U=x*s+m;if(v[D]=V-h,v[D+1]=H-g,v[D+2]=U-_,u){let e=V*V+H*H+U*U;T=Math.min(T,e),E=Math.max(E,e)}else C=Math.min(C,U),w=Math.max(w,U);y[e]=i,b[e]=R,z>O&&(O=z),S>k&&(k=S),D+=3,A++,A===Q.createRenderableBatchSize&&(A=0,t.madeProgress()&&(t=yield))}A>0&&t.madeProgress()&&(t=yield),u&&(C=Math.sqrt(T)-d,w=Math.sqrt(E)-d);let j=this._extractGaussianSplatMbsRadiusSquared(O),{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(C=Math.max(C,M.zmin),w=Math.min(w,M.zmax));let N=new F(C,w),P=this.data.textureAtlas,I=this.data.headerTexture;try{for(let e=0;e<S;e+=Q.uploadBatchPageCount){let n=Math.min(S,e+Q.uploadBatchPageCount);for(let t=e;t<n;t++){let e=P.allocatePage();if(e===null&&(this._freeInvisibleTiles(),e=P.allocatePage()),e===null)throw Error(`ran out of gaussian splat memory`);x.push(e)}for(let t=e;t<n;){let e=x[t],o=t+1;for(;o<n&&x[o]===x[o-1]+1;)o++;let s=o-t,c=i-t*z,l=Math.min(c,s*z),u=t*R,d=l*B;this._pageBuffer.set(r.subarray(u,u+d));let f=e*z,p=f%V,m=Math.floor(f/V);P.update(p,m,this._pageBuffer,s),I.update(e,a,s),t=o}t.madeProgress()&&(t=yield)}}catch(e){throw P.freePages(x),e}let L=new G(n,c,x,v,y,b,i,j,k/255,N);return this._tileHandles.set(n,L),this._cacheTileMemory+=L.usedMemory,this._memCache.put(`${L.handle}`,L),{memUsageBytes:L.usedMemory,numGaussians:i}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*9}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);let t=this.data?.textureAtlas,n=!1,r=this._tileHandles.get(e);r&&(r.lifecycleState===0?this._cacheTileMemory-=r.usedMemory:(n=!0,this.fadeHelper.onTileDiscarded(r),this._usedTileMemory-=r.usedMemory,this._intersectionHandler.removeTile(r)),t&&r.pageIds.forEach(e=>t.freePage(e)),this.freeObject(r),this._tileHandles.delete(e)),n&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(let{obb:n}of e)if(!t(n))break})}setRenderableVisibility(e,t,n){let r=this._currentLyr3dVisibilityChange+1,i=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(r,i);let a=!1;for(let o=0;o<n;o++){let n=this._tileHandles.get(e[o]);if(!n)continue;let s=t[o]?this._prepareTileFadeIn(n,r,i):this._prepareTileFadeOut(n,r);a||=s}a?(this._currentLyr3dVisibilityChange=r,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(r)}_prepareTileFadeIn(e,t,n){let r=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return e.lifecycleState===2?(this.fadeHelper.fadeTile(e,0,n),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)===t?r:(e.lifecycleState===0&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0)}_prepareTileFadeOut(e,t){let n=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return n&&e.lifecycleState===1&&(this.moveTileToCache(e),e.lifecycleState=0),e.lifecycleState===2?this._tileFadeOutsAwaitingInitialSort.get(e.handle)===t?n:(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):n}_onSortComplete(e,t){let n=this._tmpTilesWithChangedVisibility;n.length=0;let r=this._tmpSortedTileHandles;r.clear();for(let t=0;t<e.length;t++){let n=e[t];r.add(n.handle)}this._triggerFadeIns(t,r,n);let i=this._triggerFadeOuts(t,n);r.clear(),n.length>0&&this.notifyTileObbsChanged(n),i&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,n){for(let[r,i]of this._tileFadeInsAwaitingInitialSort){if(i>e||!t.has(r))continue;let a=this._tileHandles.get(r);if(!a){this._tileFadeInsAwaitingInitialSort.delete(r);continue}let o=this._getFadeDurationForPendingVisibilityChange(i),s=a.lifecycleState===0;a.lifecycleState!==2&&(a.lifecycleState=2,s&&this._popTileFromCache(a),n.push(a)),this.fadeHelper.fadeTile(a,0,o),this._tileFadeInsAwaitingInitialSort.delete(r)}}_triggerFadeOuts(e,t){let n=!1;for(let[r,i]of this._tileFadeOutsAwaitingInitialSort){if(i>e)continue;let a=this._tileHandles.get(r);if(a){let e=a.lifecycleState===2,r=this._getFadeDurationForPendingVisibilityChange(i);this.fadeHelper.fadeTile(a,1,r),e&&a.lifecycleState===0&&(t.push(a),n=!0)}this._tileFadeOutsAwaitingInitialSort.delete(r)}return n}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(this._fadeDurationPerVisibilityChange.size!==0)for(let t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(T(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(T(e.handle),e)}destroy(){this._initializationController=n(this._initializationController),this._createRenderableAbortController.abort(),N(this),this._suspendedHandle&&=r(this._suspendedHandle),this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(let{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=i(this._shadows),this._prepassDepthRenderer=i(this._prepassDepthRenderer),this._renderer=i(this._renderer),this._memCache.destroy(),this.data=i(this.data)}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||y(this.view.renderSpatialReference)||b(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&x(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=E(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=S(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=u(C.units[C[t.wkid]])),r&&(e=new g({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=v(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=d(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(!e?.offset)this._wasm?.setLayerOffset(this,0);else if(!this._useEsriCrs)this._wasm?.setLayerOffset(this,D(e));else{let t=O(e?.unit)/this._metersPerVCSUnit,n=e?.offset??0;this._wasm?.setLayerOffset(this,n*t)}}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){let e=[];for(let t of this._tileHandles.values())t.lifecycleState!==0&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange(`updating`)}get maximumGaussianCount(){return this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*this.view.quality}set maximumGaussianCount(e){this._set(`maximumGaussianCount`,e)}_freeInvisibleTiles(){for(let e of this._tileHandles.values())e.lifecycleState===0&&!this._renderablesBeingCreated.has(e.handle)&&this._deleteTile(e)}extractHeader(e){let t=e.length-4,n=this.reinterpretU32AsFloat(e[t]),r=this.reinterpretU32AsFloat(e[t+1]),i=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(e[t+3]&255));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:n,y:r,z:i},invPosScale:a}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(n=>{n.lifecycleState===0?t++:e++});let n=this.data?.textureAtlasMemory??0,r=this.data?.headerTextureMemory??0,i=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,o=this.data?.sortBufferMemory??0;return new k(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,n,r,i,a,o)}get test(){}};e([f()],$.prototype,`layer`,void 0),e([f({readOnly:!0})],$.prototype,`_clippingBox`,null),e([f()],$.prototype,`elevationOffset`,null),e([f({readOnly:!0})],$.prototype,`visibleAtCurrentScale`,null),e([f()],$.prototype,`fullExtentInLocalViewSpatialReference`,void 0),e([f()],$.prototype,`maximumGaussianCount`,null),$=Q=e([p(`esri.views.3d.layers.GaussianSplatLayerView3D`)],$);const re=$;export{re as default};
2
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as n,removeMaybe as r,destroyMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,whenOnce as s,initial as c}from"../../../core/reactiveUtils.js";import{Milliseconds as l}from"../../../core/time.js";import{isUint32Array as u}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as d,convertUnit as f}from"../../../core/units.js";import{property as p,subclass as m}from"../../../core/accessorSupport/decorators.js";import{fromValues as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import _ from"../../../geometry/HeightModelInfo.js";import{create as v}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as y}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as b,isWebMercator as x,equals as S,isGeographic as C}from"../../../geometry/support/spatialReferenceUtils.js";import w from"../../../geometry/support/WKIDUnitConversion.js";import{validateEntity3D as T,makeCacheKey as E,getHeightModelInfoFromVCS as D}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as O}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as k}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as A}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as j}from"./LayerView3D.js";import{addLayerViewToWasm as M,getLyr3DWasm as N,removeLayerViewFromWasm as P}from"./Lyr3DWasm.js";import{LayerElevationProvider as F}from"./i3s/LayerElevationProvider.js";import{ElevationRange as I}from"../support/ElevationRange.js";import{projectToBoundingBox as L}from"../support/extentUtils.js";import{Obb as R}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as z,gaussiansPerPage as B,packedGaussianSizeInU32 as V,splatAtlasTextureWidth as H}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as U}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as W}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as G}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as K}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatDepthRenderer as q}from"../webgl-engine/lib/GaussianSplatDepthRenderer.js";import{GaussianSplatRenderer as J}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as Y}from"../webgl-engine/lib/GaussianSplatShadows.js";import X from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Z,isInEffectiveScaleRange as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";var Q;const ne=()=>t.getLogger(`esri.views.3d.layers.GaussianSplatLayerView3D`),re=(()=>{let e=new Int16Array(256);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/255));return e})();let $=class extends j(X){static{Q=this}static{this.createRenderableBatchSize=64}static{this.uploadBatchPageCount=16}constructor(e){super(e),this.type=`gaussian-splat-3d`,this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(z*Q.uploadBatchPageCount),this._tmpTilesWithChangedVisibility=[],this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Set,this._pendingTileFadeOuts=new Map,this._pendingFadeDuration=l(0),this._createRenderableAbortController=new AbortController,this.skipHeightModelInfoValidation=!0,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);let t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(te.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;let e=v();return L(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){let{view:e}=this;this.addHandles([o(()=>e.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())})]),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;let{signal:t}=this._initializationController;if(await s(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw Z(`layer`,this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await M(this,t),a(t),this._renderer=new J({view:e,layerView:this}),this.data=new U(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new Y({view:e,layerView:this}),this.fadeHelper=new W(this),this._prepassDepthRenderer=new q({view:e,layerView:this});let n=new G(this);this._intersectionHandler=n,e.sceneIntersectionHelper.addIntersectionHandler(n),this._elevationProvider=new F({view:e,layerElevationSource:this,intersectionHandler:n}),e.elevationProvider.register(2,this._elevationProvider),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),o(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),c)]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),c),this.addHandles([o(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},c),o(()=>this.maximumGaussianCount,e=>this._wasm?.setMaximumGaussianSplatCount(Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians)),c)]),this._initializationController=null}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return N(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return O(this.layer.elevationInfo)}get elevationRange(){let e=this.fullExtent;return e?.zmin&&e?.zmax?new I(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return ee(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){let e=this._wasm;return this._wasmLayerId<0||e==null?!1:e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating}updatingFlagChanged(){this.notifyChange(`updating`)}async createRenderable(e){if(this.destroyed||this.destroying)throw Error(`IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy`);let{entity3d:t}=e;if(!T(t))throw Error(`entity3D not valid`);let n=t.desc.geometry.prims[t.validPrimitiveIndices[0]].atrbs[0],r=t.assets[n.assetId];if(!r)throw Error(`entity3D not valid`);let i=r.count;if(i===0)return ne().warnOnce(`encountered tile with zero Gaussians`),()=>({memUsageBytes:0,numGaussians:0});let a=null;if(r.dataType===`U32`&&u(r.data))a=r.data;else throw Error(`unexpected GaussianSplat Entity3D asset.data format`);let o=this.extractHeader(a),s=2.048,c=o.tileOrigin.x*s,l=o.tileOrigin.y*s,d=o.tileOrigin.z*s,f=t.desc,p=f.obb.quaternion,m=new R(f.obb.center,f.obb.halfSize,h(...p)),_=this.view.state.isGlobal,v=_?g(this.view.spatialReference).radius:0,y={handle:e.handle,bufferView:a,totalGaussians:i,packedHeader:o.packedHeader,tileOrigin:{x:c,y:l,z:d},invPosScale:o.invPosScale,obb:m,origin:{x:m.centerX,y:m.centerY,z:m.centerZ},isGlobal:_,ellipsoidRadius:v};this._renderablesBeingCreated.add(e.handle);let b;try{b=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(y,e),this._createRenderableAbortController.signal)}catch(t){throw this._renderablesBeingCreated.delete(e.handle),t}return this._renderablesBeingCreated.delete(e.handle),()=>b}*_createRenderableTask(e,t){let{handle:n,bufferView:r,totalGaussians:i,packedHeader:a,tileOrigin:o,invPosScale:s,obb:c,origin:l,isGlobal:u,ellipsoidRadius:d}=e,f=o.x,p=o.y,m=o.z,h=l.x,g=l.y,_=l.z,v=new Float32Array(i*3),y=new Uint32Array(i),b=new Uint32Array(i),x=[],S=Math.ceil(i/B),C=1/0,w=-1/0,T=1/0,E=-1/0,D=0,O=-1,k=0,A=0;for(let e=0;e<i;e++){let n=e*V,i=r[n],a=r[n+1],o=r[n+2],c=r[n+3],l=a&16383,d=a>>>14&16383,x=a>>>28&15|(o&1023)<<4,S=c>>>24,j=re[S],M=(o>>>10&255)+j,N=(o>>>18&255)+j,P=(o>>>26&63|(c&3)<<6)+j,F=M>0?M:0,I=N>0?N:0,L=P>0?P:0,R=F|I<<8|L<<16,z=Math.max(F,I,L),B=l*s+f,H=d*s+p,U=x*s+m;if(v[D]=B-h,v[D+1]=H-g,v[D+2]=U-_,u){let e=B*B+H*H+U*U;T=Math.min(T,e),E=Math.max(E,e)}else C=Math.min(C,U),w=Math.max(w,U);y[e]=i,b[e]=R,z>O&&(O=z),S>k&&(k=S),D+=3,A++,A===Q.createRenderableBatchSize&&(A=0,t.madeProgress()&&(t=yield))}A>0&&t.madeProgress()&&(t=yield),u&&(C=Math.sqrt(T)-d,w=Math.sqrt(E)-d);let j=this._extractGaussianSplatMbsRadiusSquared(O),{fullExtent:M}=this.layer;M?.hasZ&&M.zmax&&M.zmin&&(C=Math.max(C,M.zmin),w=Math.min(w,M.zmax));let N=new I(C,w),P=this.data.textureAtlas,F=this.data.headerTexture;try{for(let e=0;e<S;e+=Q.uploadBatchPageCount){let n=Math.min(S,e+Q.uploadBatchPageCount);for(let t=e;t<n;t++){let e=P.allocatePage();if(e===null&&(this._freeInvisibleTiles(),e=P.allocatePage()),e===null)throw Error(`ran out of gaussian splat memory`);x.push(e)}for(let t=e;t<n;){let e=x[t],o=t+1;for(;o<n&&x[o]===x[o-1]+1;)o++;let s=o-t,c=i-t*B,l=Math.min(c,s*B),u=t*z,d=l*V;this._pageBuffer.set(r.subarray(u,u+d));let f=e*B,p=f%H,m=Math.floor(f/H);P.update(p,m,this._pageBuffer,s),F.update(e,a,s),t=o}t.madeProgress()&&(t=yield)}}catch(e){throw P.freePages(x),e}let L=new K(n,c,x,v,y,b,i,j,k/255,N);return this._tileHandles.set(n,L),this._cacheTileMemory+=L.usedMemory,this._memCache.put(`${L.handle}`,L),{memUsageBytes:L.usedMemory,numGaussians:i}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*9}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._pendingTileFadeOuts.delete(e);let t=this.data?.textureAtlas,n=!1,r=this._tileHandles.get(e);if(r){let i=!1;for(let t of this._pendingTileFadeOuts.values())t.incomingTileHandles.has(e)&&(t.visibilityChange=this._currentLyr3dVisibilityChange+1,i=!0);i&&(this._currentLyr3dVisibilityChange++,n=!0),r.lifecycleState===0?this._cacheTileMemory-=r.usedMemory:(n=!0,this.fadeHelper.onTileDiscarded(r),this._usedTileMemory-=r.usedMemory,this._intersectionHandler.removeTile(r)),t&&r.pageIds.forEach(e=>t.freePage(e)),this.freeObject(r),this._tileHandles.delete(e)}n&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(let{obb:n}of e)if(!t(n))break})}setRenderableVisibility(e,t,n){let r=this.fadeHelper.updateFadeDuration(),i=new ie(this._currentLyr3dVisibilityChange+1),a=new Set,o=!1;for(let s=0;s<n;s++){let n=this._tileHandles.get(e[s]);if(!n)continue;let c=t[s]?this._prepareTileFadeIn(n,r):this._prepareTileFadeOut(n,i);t[s]&&i.incomingTileHandles.add(n.handle),c&&a.add(n.handle),o||=c}if(o){if(this._currentLyr3dVisibilityChange++,this._pendingFadeDuration=r,this._updatePendingTileHandoffs(a,i),i.incomingTileHandles.size===0)for(let e of this._tileFadeInsAwaitingInitialSort)i.incomingTileHandles.add(e);this.updateGaussians()}}_updatePendingTileHandoffs(e,t){for(let n of new Set(this._pendingTileFadeOuts.values())){if(n===t)continue;let r=!1;for(let i of e)n.incomingTileHandles.has(i)&&(r=!0,t.incomingTileHandles.size>0&&n.incomingTileHandles.delete(i));if(r){n.visibilityChange=t.visibilityChange;for(let e of t.incomingTileHandles)n.incomingTileHandles.add(e)}}}_prepareTileFadeIn(e,t){let n=this._pendingTileFadeOuts.delete(e.handle);return e.lifecycleState===2?(this.fadeHelper.fadeTile(e,0,t),!1):this._tileFadeInsAwaitingInitialSort.has(e.handle)?n:(e.lifecycleState===0&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.add(e.handle),!0)}_prepareTileFadeOut(e,t){let n=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return n&&e.lifecycleState===1&&(this.moveTileToCache(e),e.lifecycleState=0),e.lifecycleState===2?this._pendingTileFadeOuts.has(e.handle)?n:(this._pendingTileFadeOuts.set(e.handle,t),!0):n}_onSortComplete(e,t){let n=this._tmpTilesWithChangedVisibility;n.length=0,this._triggerFadeIns(e,n);let r=this._triggerFadeOuts(t,n);n.length>0&&this.notifyTileObbsChanged(n),r&&this.updateGaussians()}_triggerFadeIns(e,t){for(let n of e)this._tileHandles.get(n.handle)===n&&this._tileFadeInsAwaitingInitialSort.delete(n.handle)&&(n.lifecycleState=2,t.push(n),this.fadeHelper.fadeTile(n,0,this._pendingFadeDuration))}_triggerFadeOuts(e,t){let n=!1;for(let t of this._pendingTileFadeOuts.values())if(e>=t.visibilityChange){n=!0;break}if(!n)return!1;let r=this._pendingFadeDuration,i=this._pendingFadeDuration;for(let e of this._tileHandles.values()){let{fadeDirection:t,fadeDuration:n,fadeProgress:a}=e;if(t!==0||n==null||a==null)continue;let o=n*(1-a);r=l(Math.max(r,o)),i=l(Math.max(i,n))}let a=!1;for(let[n,o]of this._pendingTileFadeOuts){if(e<o.visibilityChange)continue;this._pendingTileFadeOuts.delete(n);let s=this._tileHandles.get(n);if(s){let e=s.lifecycleState===2,n=s.opacityModifier===1?r:i;this.fadeHelper.fadeTile(s,1,n),e&&s.lifecycleState===0&&(t.push(s),a=!0)}}return a}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(E(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(E(e.handle),e)}destroy(){this._initializationController=n(this._initializationController),this._createRenderableAbortController.abort(),P(this),this._suspendedHandle&&=r(this._suspendedHandle),this._intersectionHandler&&=(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(let{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=i(this._shadows),this._prepassDepthRenderer=i(this._prepassDepthRenderer),this._renderer=i(this._renderer),this._memCache.destroy(),this.data=i(this.data)}_canProjectWithoutEngine(){if(this.view.state.viewingMode===1||b(this.view.renderSpatialReference)||x(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&S(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(this.layer.esriCrsSpatialReference.vcsWkid===115700)return!1;let e=D(this.layer.esriCrsSpatialReference);if(!e){let t=this.layer.esriCrsSpatialReference,n=C(t),r=`meters`;!n&&t.wkid&&t.wkid!==-1&&(r=d(w.units[w[t.wkid]])),r&&(e=new _({heightModel:`gravity-related-height`,heightUnit:r}))}let t=this.view.heightModelInfo;return this._useEsriCrs=y(e,t,!1)===0,this._useEsriCrs&&(e&&(this._metersPerVCSUnit=f(1,e.heightUnit,`meters`)),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(!e?.offset)this._wasm?.setLayerOffset(this,0);else if(!this._useEsriCrs)this._wasm?.setLayerOffset(this,O(e));else{let t=k(e?.unit)/this._metersPerVCSUnit,n=e?.offset??0;this._wasm?.setLayerOffset(this,n*t)}}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){let e=[];for(let t of this._tileHandles.values())t.lifecycleState!==0&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange(`updating`)}get maximumGaussianCount(){return this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*this.view.quality}set maximumGaussianCount(e){this._set(`maximumGaussianCount`,e)}_freeInvisibleTiles(){for(let e of this._tileHandles.values())e.lifecycleState===0&&!this._renderablesBeingCreated.has(e.handle)&&this._deleteTile(e)}extractHeader(e){let t=e.length-4,n=this.reinterpretU32AsFloat(e[t]),r=this.reinterpretU32AsFloat(e[t+1]),i=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(e[t+3]&255));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:n,y:r,z:i},invPosScale:a}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(n=>{n.lifecycleState===0?t++:e++});let n=this.data?.textureAtlasMemory??0,r=this.data?.headerTextureMemory??0,i=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,o=this.data?.sortBufferMemory??0;return new A(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,n,r,i,a,o)}get test(){}};e([p()],$.prototype,`layer`,void 0),e([p({readOnly:!0})],$.prototype,`_clippingBox`,null),e([p()],$.prototype,`elevationOffset`,null),e([p({readOnly:!0})],$.prototype,`visibleAtCurrentScale`,null),e([p()],$.prototype,`fullExtentInLocalViewSpatialReference`,void 0),e([p()],$.prototype,`maximumGaussianCount`,null),$=Q=e([m(`esri.views.3d.layers.GaussianSplatLayerView3D`)],$);class ie{constructor(e){this.visibilityChange=e,this.incomingTileHandles=new Set}}const ae=$;export{ae as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{result as e,createTask as t}from"../../../../core/asyncUtils.js";import n from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{abortMaybe as i,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as o,throwIfAborted as s}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as l}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as d}from"../../../../core/urlUtils.js";import{fromValues as f,fromArray as p,create as m,ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ZEROS as g,fromValues as _,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ee,ZEROS as te}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as y}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as b}from"../../../../geometry/support/aaBoundingBox.js";import x from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as ne}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as S,CIMSymbolInflatedSizeHelper as C}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as re}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as ie}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultIconPrimitive as ae}from"../../../../symbols/support/primitives.js";import oe from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as se}from"../../../../symbols/support/utils.js";import{transparentUnit as ce}from"./constants.js";import{perObjectElevationAligner as le}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as ue,needsElevationUpdates2D as w}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as de}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as fe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as T}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as E}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as D}from"./placementUtils.js";import{placePointOnGeometry as O,updateStageObjectGeometry as k,getLocalOriginForPoint as A,extendPointGraphicElevationContext as j,createStageObject as M}from"./pointUtils.js";import{hasTransparencyModeSymbol as N}from"./transparencyUtils.js";import{initFastSymbolUpdatesState as P,updateFastSymbolUpdatesState as F,evaluateModelTransformScale as I,ConvertOptions as L}from"../support/FastSymbolUpdates.js";import{createTexture as R,requiresHalfTexelOffset as z,defaultBoundingBox as pe,defaultSymbolSizeRatio as B,defaultTexSize as V}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as me}from"../../terrain/DrapedZ.js";import{VerticalOffsetParameters as he}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as H}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as U}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as ge}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as W}from"../../webgl-engine/materials/HUDMaterial.js";var G;const K=_(0,0,1),_e=[V*B,V*B];class q extends T{static{G=N}static{this.PRIMITIVE_SIZE=_e}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=[1,1],this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0},this[G]=!0}async doLoad(e){this._validateOrThrow();let t=this._prepareMaterialParameters(),n=this._getPrimitive();if(n!=null)this._prepareResourcesPrimitive(t,n);else{let n=se(this.symbolLayer),r=Y(n);r==null?await this._prepareResourcesHref(t,n,e):await this._prepareResourcesCIM(t,JSON.parse(r),e)}}_validateOrThrow(){if(this._drivenProperties.size)return;let e=E(this._getIconSize());if(e)throw new n(`graphics3diconsymbollayer:invalid-size`,e)}_getIconSize(){let e=this.symbolLayer,t=Math.round(e.size==null?16:c(e.size));return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){let n=this._overrideHelperClass,i=this._cimData;if((!n||!i||!i.symbol)&&this.logger.error(`Can't create texture, CIM data is undefined`),i.primitiveOverrides){i=r(i);let a=i.primitiveOverrides;n.evaluateOverrides(a,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),n.applyOverrides(i.symbol,a)}let a=u(JSON.stringify(i)),o=this._cimSymbolTextures.get(a);if(o)return o;let s=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&this._context.renderer.type===`dictionary`?this._context.renderer.fieldMap:null;l&&n.applyDictionaryTextOverrides(i.symbol,e,l,null);let d=this._cimScaleFactorOrFunction==null?1:re(this._cimScaleFactorOrFunction,e);d!==1&&i.symbol&&ie(i.symbol,d,!0);let f=S.getEnvelope(i,null,s.resourceManager);if(f?.width&&f.height){let e=f.x+f.width/2,t=f.y+f.height/2,n=i.symbol?.type===`CIMPointSymbol`?C.getPointSymbolHaloPadding(i.symbol,s.resourceManager):0,r=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,a=n>0?Math.ceil((c(n)+1)*r):0,l=s.rasterize({type:`cim`,data:i},f.width,f.height,e,t,1,`esriGeometryPoint`,a,null,r),u=new oe({x:-f.x/f.width-.5,y:(f.height+f.y)/f.height-.5});this._cimMaterialParametersInfo.anchorPosition=X(`relative`,u),o=new U(l,{width:l?.width??1,height:l?.height??1,reloadable:!0})}else o=new U(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(a,o),this._context.stage.addTexture(o),o}_prepareMaterialParameters(){let{symbolLayer:e,symbol:t,_context:n,_drivenProperties:r,view:i}=this,a=this.symbolLayer.occludedVisibility?.mode??`hidden`;return{anchorPosition:X(e.anchor,e.anchorPosition),rotation:e.angle,hasRotation:e.angle!==0||r.rotation,hasVertexRotation:r.rotation,occludedFragmentOpacity:a===`hidden`?void 0:i.state.ensureOccludedFragmentOpacity(!1,a),hasSlicePlane:n.slicePlaneEnabled,verticalOffset:ve(t)?new he(t.verticalOffset):void 0,screenSizePerspective:n.screenSizePerspectiveEnabled?i.screenSizePerspective.parameters:void 0}}_prepareResourcesPrimitive(e,t){let n=this._getOutlineSize();if(J(t)&&n===0)throw Error(`Nothing to render`);if(this._outlineSize=n,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,this._context.sharedResources.textures!=null){let n=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>R(t));this._textureHandle=n,e.textureId=n.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=z(t),e.distanceFieldBoundingBox=pe;let r=this._getIconSize();this._size=[r,r],this._symbolTextureRatio=1/B,e.size=f(r*this._symbolTextureRatio,r*this._symbolTextureRatio),this._createMaterials(e)}async _prepareResourcesHref(t,r,i){this._outlineSize=this._getOutlineSize(),t.color=this._getFillColor(),t.outlineColor=this._getOutlineColor(),t.outlineSize=this._outlineSize,t.textureIsSignedDistanceField=!1;let a=this._getIconSize(),s=a*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(this._context.sharedResources.textures!=null){let c=await e(this._context.sharedResources.textures.fromUrl(r,s,{signal:i}));if(c.ok===!1){o(c.error);let e=`Failed to load (Request for icon resource failed: ${r})`;throw new n(`graphics3diconsymbollayer:request-failed`,e)}this._textureHandle=c.value;let l=c.value.managedTexture;this._size=Z(l,a),t.size=p(this._size),t.textureId=l.id}this._createMaterials(t)}async _prepareResourcesCIM(e,t,n){let{OverrideHelper:r}=await import(`../../../../symbols/cim/OverrideHelper.js`);if(this._overrideHelperClass=r,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){let e=(await import(`../../../../symbols/cim/CIMSymbolRasterizer.js`)).CIMSymbolRasterizer;s(n),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}let i=this._context.sharedResources.cimSymbolRasterizer,a=t,o=a?.symbol,c=[S.normalizeSymbolAndFetchResources(o,i.resourceManager,n)],l=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],u=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:u,fields:l,geometryType:`esriGeometryPoint`},a?.primitiveOverrides&&c.push(r.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),c.length>0&&(await Promise.all(c),s(n)),this._context.renderer&&this._context.renderer.type===`dictionary`&&this._context.renderer.scaleExpression){let e=this._context.renderer;if(e.scaleExpression){let t=e.scaleExpression,n=await ne(t,this._context.layer.spatialReference),{default:r}=await import(`../../../2d/arcade/callExpressionWithFeature.js`),i=new x(l);this._cimScaleFactorOrFunction=(e,t,a)=>{let o=r(n,e,{$view:a},`esriGeometryPoint`,i,t);return o===null?1:o}}}s(n),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return Q(this.symbolLayer)}_getOutlineSize(){let e=0,t=this.symbolLayer;return t.outline?.size==null?(e=J(this._getPrimitive())?1.5:0,Math.max(e,0)):Math.max(c(t.outline.size),0)}_getOutlineColor(){let e=this._getLayerOpacity(),t=this.symbolLayer?.outline?.color;if(t!=null){let n=t.toUnitRGB(),r=t.a*e;return[n[0],n[1],n[2],r]}return[0,0,0,0]}_getFillColor(){if(J(this._getPrimitive()))return ce;let e=this._getPrimitive()==null,t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){let e=this._materialColor;return e==null?this._getPrimitive()==null?ee:te:e.toUnitRGBA()}_getFallbackSize(){let e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(t==null?16:Math.round(c(t)))/e}_createCimMaterials(e){let t=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;if(t)return t;let n=$([],e,this._context.focusAreaStyle,this._context.spherical);return this._cimSymbolMaterials.set(e.textureId??0,n),n}_createMaterials(e){this._fastUpdates=P(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),e.hasVertexColor=this._drivenProperties.color&&!this._fastUpdates?.visualVariables.color||this._drivenProperties.opacity&&!this._fastUpdates?.visualVariables.opacity,e.hasVertexSize=this._drivenProperties.size&&!this._fastUpdates?.visualVariables.size,$(this._materials,e,this._context.focusAreaStyle,this._context.spherical)}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=i(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(e==null)return this._getFallbackSize();let[n,r,i]=e.output;return n===`symbol-value`?1:typeof n==`number`&&isFinite(n)?c(n)/t:typeof i==`number`&&isFinite(i)?c(i)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading?.output??0:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=O(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let r=this._materials,i=this.view.focusAreasView?.containsGeometry(n)??!0;if(this._cimData){if(!this._cimData.symbol)return null;let n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,i=this._generateTextureCIM(t,e),a=f(i.parameters.width/n,i.parameters.height/n);r=this._createCimMaterials({textureId:i.id,size:a,...this._cimMaterialParametersInfo})}let a=r[i?0:2];if(n==null)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;let o=this._getPrimitive()==null,s=e.renderingInfo,c=this._hasDrivenColorOrOpacity?this._getDrivenUInt8Color(s,this._materialColor,o):null,l=this._getDrivenRotation(s),u=null;if(!this._fastUpdates?.visualVariables.size){let e=this._size,t=e[0]>e[1]?e[0]:e[1];u=this._getScaleFactor(s,t)}let d=u==null?null:f(u,u),p=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(p.mode===`on-the-ground`)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(s,n,a,c,l,d,t.uid):this._createAs3DShape(s,n,a,c,l,d,p,t.uid)}terrainTransparencyChanged(){return this.draped}layerOpacityChanged(){let e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(n=>{n.setParameters({color:e}),n.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){let e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateTransparentMode(e,t){let n=e.stageObject.geometries[0]?.material,r=this._cimData?n?.parameters.textureId:null,i=r?this._cimSymbolMaterials.get(r):this._materials,a=(i?.indexOf(n)??-1)<2,o=i?.[t?a?1:3:a?0:2];o&&o!==n&&e.updateMaterial(o)}updateGeometry(e,t){let n=e.geometry;if(this.draped||!n||!this._validateGeometry(n))return!1;let{elevationContext:r,stageObject:i}=t;if(r.mode!==this.getGeometryElevationMode(n))return!1;let a=O(n);if(!a)return!1;r.updateFeatureExpressionFeature(e,this._context.layer);let o=k(i,this._context,a,r);if(o==null)return!1;let s=A(this._context,a);return i.geometries[0].localOrigin===s&&(t.alignedSampledElevation=o,j(t,a,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=ue(q.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=w(r)||r===`absolute-height`;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return this._getPrimitive()!=null}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(F(this._fastUpdates,t,this._fastVisualVariableConvertOptions())){let e=this._fastUpdates;this._materials.forEach(t=>t?.setParameters(e.materialParameters))}else return 0;break;default:return 0}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(r,c){if(!c.resource||c.resource.type!==`partial`)return;let l=c.resource.diff;if(l?.href?.type!==`complete`)return;let u=l.href.newValue,{textures:d}=this._context.sharedResources;if(u==null||d==null||Y(u)!=null)return;let f=this._getIconSize(),p=f*this._context.graphicsCoreOwner.view.state.pixelRatio;r.symbolLayerStatePatches.push(()=>{this._patchTask=i(this._patchTask),this._patchTask=t(t=>this._context.schedule(async(t,r)=>{let i=await e(d.fromUrl(u,p,{signal:r}));s(r);let c=!i.ok;if(c&&o(i.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,c){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});let e=`Failed to load (Request for icon resource failed: ${u})`;this.logger.error(new n(`graphics3diconsymbollayer:request-failed`,e));return}this._textureHandle=i.value;let l=i.value.managedTexture;this._size=Z(l,f),this._forEachMaterial(e=>{e.setParameters({textureId:l.id}),e.visible=!0})},t))}),delete l.href}_preparePatchRotation(e,t){if(!t.angle||t.angle.type!==`complete`)return;let n=t.angle.newValue??0,r=n!==0||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:n,hasRotation:r}))}),delete t.angle}_defaultElevationInfoNoZ(){return be}_createAs3DShape(e,t,n,r,i,a,o,s){let c=this.getFastUpdateAttrValues(e),l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerViewUid:l}),d=H(n,{normal:K,color:r,rotation:i,size:a,centerOffset:g,groundDistance:1,featureAttribute:c,olidColor:u}),f=M(this._context,t,d,o,s);if(f==null)return null;let p=new fe(this,f.object,null,le,o);return p.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),p.hiddenIfDeconflicted=!0,p.alignedSampledElevation=f.sampledElevation,p.needsElevationUpdates=w(o.mode)||o.mode===`absolute-height`,p.getScreenSize=this._createScreenSizeGetter(a,c),p.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(p.getScreenSize(),1,e),j(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,n,r,i,a,o){n.renderPriority=this._renderPriority;let s=v();y(t,s,this._context.overlaySR),s[2]=me;let c=this._context.clippingExtent;if(c!=null&&!b(c,s))return null;let l=this.getFastUpdateAttrValues(e),u=this._context.layerViewUid,d=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:u}),f=H(n,{normal:K,position:s,color:r,rotation:i,size:a,featureAttribute:l,olidColor:d}),p=new ge(f,{layerViewUid:u,graphicUid:o}),m=new de(this,[p],null,this._context.drapeSourceRenderer);return m.getScreenSize=this._createScreenSizeGetter(a,l),m.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(m.getScreenSize(),1,e),m}_createScreenSizeGetter(e,t){e??=h;let n=this._outlineSize+2;if(this._fastUpdates&&t){let r=e[0]*this._size[0],i=e[1]*this._size[1];return(e=m())=>{let[a,o]=I(xe,this._fastUpdates.materialParameters,t);return e[0]=a*r+n,e[1]=o*i+n,e}}let r=e[0]*this._size[0]+n,i=e[1]*this._size[1]+n;return(e=m())=>(e[0]=r,e[1]=i,e)}_fastVisualVariableConvertOptions(){let e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),n=l(1),r=e*n,i=_(r,r,r),a=this._getFallbackSize();return new L({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:i,unitInMeters:n,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(a,a,a)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(t=>t.forEach(e))}test(){return{...super.test(),material:this._materials[0]}}}function ve(e){return e&&e.type===`point-3d`&&e.hasVisibleVerticalOffset()}function J(e){return e==null?!1:e===`cross`||e===`x`}function Y(e){let t=d(e);return t?.mediaType===`application/json`?t.data:void 0}function X(e,t){return e===`relative`?f((t.x||0)+.5,-(t.y||0)+.5):e in D?D[e]:D.center}function Z({parameters:e},t){let n=(e.width??1)/(e.height??1);return n>1?[t,Math.round(t/n)]:[Math.round(t*n),t]}function Q(e){return e.resource?.href?null:e.resource?.primitive??ae}function ye(e){return(e.material?.color?.a??1)===1&&Q(e)!=null}const be={mode:`relative-to-ground`,offset:0},xe=v();function $(e,t,n,r){let i={...t,focusAreaStyle:n};return e[0]=new W(t,r),e[1]=new W(t,r,!0),e[2]=new W(i,r),e[3]=new W(i,r,!0),e}export{q as Graphics3DIconSymbolLayer};
2
+ import{result as e,createTask as t}from"../../../../core/asyncUtils.js";import n from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{abortMaybe as i,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as o,throwIfAborted as s}from"../../../../core/promiseUtils.js";import{pt2px as c,onePixelInPoints as l}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as d}from"../../../../core/urlUtils.js";import{fromValues as f,fromArray as p,create as m,ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ZEROS as g,fromValues as _,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ee,ZEROS as te}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as y}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as b}from"../../../../geometry/support/aaBoundingBox.js";import x from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as ne}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as S,CIMSymbolInflatedSizeHelper as C}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as re}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as ie}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultIconPrimitive as ae}from"../../../../symbols/support/primitives.js";import oe from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as se}from"../../../../symbols/support/utils.js";import{transparentUnit as ce}from"./constants.js";import{perObjectElevationAligner as le}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as ue,needsElevationUpdates2D as w}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as de}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as fe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as T}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as E}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as D}from"./placementUtils.js";import{placePointOnGeometry as O,updateStageObjectGeometry as k,getLocalOriginForPoint as A,extendPointGraphicElevationContext as j,createStageObject as M}from"./pointUtils.js";import{hasTransparencyModeSymbol as N}from"./transparencyUtils.js";import{initFastSymbolUpdatesState as P,updateFastSymbolUpdatesState as F,evaluateModelTransformScale as I,ConvertOptions as L}from"../support/FastSymbolUpdates.js";import{createTexture as R,requiresHalfTexelOffset as z,defaultBoundingBox as pe,defaultSymbolSizeRatio as B,defaultTexSize as V}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as me}from"../../terrain/DrapedZ.js";import{VerticalOffsetParameters as he}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as H}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as U}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as ge}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as W}from"../../webgl-engine/materials/HUDMaterial.js";var G;const K=_(0,0,1),_e=[V*B,V*B];class q extends T{static{G=N}static{this.PRIMITIVE_SIZE=_e}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=[1,1],this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0},this[G]=!0}async doLoad(e){this._validateOrThrow();let t=this._prepareMaterialParameters(),n=this._getPrimitive();if(n!=null)this._prepareResourcesPrimitive(t,n);else{let n=se(this.symbolLayer),r=Y(n);r==null?await this._prepareResourcesHref(t,n,e):await this._prepareResourcesCIM(t,JSON.parse(r),e)}}_validateOrThrow(){if(this._drivenProperties.size)return;let e=E(this._getIconSize());if(e)throw new n(`graphics3diconsymbollayer:invalid-size`,e)}_getIconSize(){let e=this.symbolLayer,t=Math.round(e.size==null?16:c(e.size));return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){let n=this._overrideHelperClass,i=this._cimData;if((!n||!i||!i.symbol)&&this.logger.error(`Can't create texture, CIM data is undefined`),i.primitiveOverrides){i=r(i);let a=i.primitiveOverrides;n.evaluateOverrides(a,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),n.applyOverrides(i.symbol,a)}let a=u(JSON.stringify(i)),o=this._cimSymbolTextures.get(a);if(o)return o;let s=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&this._context.renderer.type===`dictionary`?this._context.renderer.fieldMap:null;l&&n.applyDictionaryTextOverrides(i.symbol,e,l,null);let d=this._cimScaleFactorOrFunction==null?1:re(this._cimScaleFactorOrFunction,e);d!==1&&i.symbol&&ie(i.symbol,d,!0);let f=S.getEnvelope(i,null,s.resourceManager);if(f?.width&&f.height){let e=f.x+f.width/2,t=f.y+f.height/2,n=i.symbol?.type===`CIMPointSymbol`?C.getPointSymbolHaloPadding(i.symbol,s.resourceManager):0,r=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,a=n>0?Math.ceil((c(n)+1)*r):0,l=s.rasterize({type:`cim`,data:i},f.width,f.height,e,t,1,`esriGeometryPoint`,a,null,r),u=new oe({x:-f.x/f.width-.5,y:(f.height+f.y)/f.height-.5});this._cimMaterialParametersInfo.anchorPosition=X(`relative`,u),o=new U(l,{width:l?.width??1,height:l?.height??1,reloadable:!0})}else o=new U(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(a,o),this._context.stage.addTexture(o),o}_prepareMaterialParameters(){let{symbolLayer:e,symbol:t,_context:n,_drivenProperties:r,view:i}=this,a=this.symbolLayer.occludedVisibility?.mode??`hidden`;return{anchorPosition:X(e.anchor,e.anchorPosition),rotation:e.angle,hasRotation:e.angle!==0||r.rotation,hasVertexRotation:r.rotation,occludedFragmentOpacity:a===`hidden`?void 0:i.state.ensureOccludedFragmentOpacity(!1,a),hasSlicePlane:n.slicePlaneEnabled,verticalOffset:ve(t)?new he(t.verticalOffset):void 0,screenSizePerspective:n.screenSizePerspectiveEnabled?i.screenSizePerspective.parameters:void 0}}_prepareResourcesPrimitive(e,t){let n=this._getOutlineSize();if(J(t)&&n===0)throw Error(`Nothing to render`);if(this._outlineSize=n,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,this._context.sharedResources.textures!=null){let n=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>R(t));this._textureHandle=n,e.textureId=n.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=z(t),e.distanceFieldBoundingBox=pe;let r=this._getIconSize();this._size=[r,r],this._symbolTextureRatio=1/B,e.size=f(r*this._symbolTextureRatio,r*this._symbolTextureRatio),this._createMaterials(e)}async _prepareResourcesHref(t,r,i){this._outlineSize=this._getOutlineSize(),t.color=this._getFillColor(),t.outlineColor=this._getOutlineColor(),t.outlineSize=this._outlineSize,t.textureIsSignedDistanceField=!1;let a=this._getIconSize(),s=a*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(this._context.sharedResources.textures!=null){let c=await e(this._context.sharedResources.textures.fromUrl(r,s,{signal:i}));if(c.ok===!1){o(c.error);let e=`Failed to load (Request for icon resource failed: ${r})`;throw new n(`graphics3diconsymbollayer:request-failed`,e)}this._textureHandle=c.value;let l=c.value.managedTexture;this._size=Z(l,a),t.size=p(this._size),t.textureId=l.id}this._createMaterials(t)}async _prepareResourcesCIM(e,t,n){let{OverrideHelper:r}=await import(`../../../../symbols/cim/OverrideHelper.js`);if(this._overrideHelperClass=r,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){let e=(await import(`../../../../symbols/cim/CIMSymbolRasterizer.js`)).CIMSymbolRasterizer;s(n),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}let i=this._context.sharedResources.cimSymbolRasterizer,a=t,o=a?.symbol,c=[S.normalizeSymbolAndFetchResources(o,i.resourceManager,n)],l=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],u=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:u,fields:l,geometryType:`esriGeometryPoint`},a?.primitiveOverrides&&c.push(r.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),c.length>0&&(await Promise.all(c),s(n)),this._context.renderer&&this._context.renderer.type===`dictionary`&&this._context.renderer.scaleExpression){let e=this._context.renderer;if(e.scaleExpression){let t=e.scaleExpression,n=await ne(t,this._context.layer.spatialReference),{default:r}=await import(`../../../2d/arcade/callExpressionWithFeature.js`),i=new x(l);this._cimScaleFactorOrFunction=(e,t,a)=>{let o=r(n,e,{$view:a},`esriGeometryPoint`,i,t);return o===null?1:o}}}s(n),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return Q(this.symbolLayer)}_getOutlineSize(){let e=0,t=this.symbolLayer;return t.outline?.size==null?(e=J(this._getPrimitive())?1.5:0,Math.max(e,0)):Math.max(c(t.outline.size),0)}_getOutlineColor(){let e=this._getLayerOpacity(),t=this.symbolLayer?.outline?.color;if(t!=null){let n=t.toUnitRGB(),r=t.a*e;return[n[0],n[1],n[2],r]}return[0,0,0,0]}_getFillColor(){if(J(this._getPrimitive()))return ce;let e=this._getPrimitive()==null,t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){let e=this._materialColor;return e==null?this._getPrimitive()==null?ee:te:e.toUnitRGBA()}_getFallbackSize(){let e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(t==null?16:Math.round(c(t)))/e}_createCimMaterials(e){let t=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;if(t)return t;let n=$([],e,this._context.focusAreaStyle,this._context.spherical);return this._cimSymbolMaterials.set(e.textureId??0,n),n}_createMaterials(e){this._fastUpdates=P(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),e.hasVertexColor=this._drivenProperties.color&&!this._fastUpdates?.visualVariables.color||this._drivenProperties.opacity&&!this._fastUpdates?.visualVariables.opacity,e.hasVertexSize=this._drivenProperties.size&&!this._fastUpdates?.visualVariables.size,$(this._materials,e,this._context.focusAreaStyle,this._context.spherical)}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=i(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(e==null)return this._getFallbackSize();let[n,r,i]=e.output;return n===`symbol-value`?1:typeof n==`number`&&isFinite(n)?c(n)/t:typeof i==`number`&&isFinite(i)?c(i)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading?.output??0:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=O(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let r=this._materials,i=this.view.focusAreasView?.containsGeometry(n)??!0;if(this._cimData){if(!this._cimData.symbol)return null;let n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,i=this._generateTextureCIM(t,e),a=f(i.parameters.width/n,i.parameters.height/n);r=this._createCimMaterials({textureId:i.id,size:a,...this._cimMaterialParametersInfo})}let a=r[i?0:2];if(n==null)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;let o=this._getPrimitive()==null,s=e.renderingInfo,c=this._hasDrivenColorOrOpacity?this._getDrivenUInt8Color(s,this._materialColor,o):null,l=this._getDrivenRotation(s),u=null;if(!this._fastUpdates?.visualVariables.size){let e=this._size,t=e[0]>e[1]?e[0]:e[1];u=this._getScaleFactor(s,t)}let d=u==null?null:f(u,u),p=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(p.mode===`on-the-ground`)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(s,n,a,c,l,d,t.uid):this._createAs3DShape(s,n,a,c,l,d,p,t.uid)}terrainTransparencyChanged(){return this.draped}layerOpacityChanged(){let e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(n=>{n.setParameters({color:e}),n.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){let e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateTransparentMode(e,t){let n=e.stageObject.geometries[0]?.material,r=this._cimData?n?.parameters.textureId:null,i=r?this._cimSymbolMaterials.get(r):this._materials,a=(i?.indexOf(n)??-1)<2,o=i?.[t?a?1:3:a?0:2];o&&o!==n&&e.updateMaterial(o)}updateGeometry(e,t){let n=e.geometry;if(this.draped||!n||!this._validateGeometry(n))return!1;let{elevationContext:r,stageObject:i}=t;if(r.mode!==this.getGeometryElevationMode(n))return!1;let a=O(n);if(!a)return!1;r.updateFeatureExpressionFeature(e,this._context.layer);let o=k(i,this._context,a,r);if(o==null)return!1;let s=A(this._context,a);return i.geometries[0].localOrigin===s&&(t.alignedSampledElevation=o,j(t,a,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=ue(q.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=w(r)||r===`absolute-height`;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return this._getPrimitive()!=null}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(F(this._fastUpdates,t,this._fastVisualVariableConvertOptions())){let e=this._fastUpdates;this._materials.forEach(t=>t?.setParameters(e.materialParameters))}else return 0;break;default:return 0}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(r,c){if(!c.resource||c.resource.type!==`partial`)return;let l=c.resource.diff;if(l?.href?.type!==`complete`)return;let u=l.href.newValue,{textures:d}=this._context.sharedResources;if(u==null||d==null||Y(u)!=null)return;let f=this._getIconSize(),p=f*this._context.graphicsCoreOwner.view.state.pixelRatio;r.symbolLayerStatePatches.push(()=>{this._patchTask=i(this._patchTask),this._patchTask=t(t=>this._context.schedule(async(t,r)=>{let i=await e(d.fromUrl(u,p,{signal:r}));s(r);let c=!i.ok;if(c&&o(i.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,c){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});let e=`Failed to load (Request for icon resource failed: ${u})`;this.logger.error(new n(`graphics3diconsymbollayer:request-failed`,e));return}this._textureHandle=i.value;let l=i.value.managedTexture;this._size=Z(l,f),this._forEachMaterial(e=>{e.setParameters({textureId:l.id}),e.visible=!0})},t))}),delete l.href}_preparePatchRotation(e,t){if(!t.angle||t.angle.type!==`complete`)return;let n=t.angle.newValue??0,r=n!==0||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:n,hasRotation:r}))}),delete t.angle}_defaultElevationInfoNoZ(){return be}_createAs3DShape(e,t,n,r,i,a,o,s){let c=this.getFastUpdateAttrValues(e),l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerViewUid:l}),d=H(n,{normal:K,color:r,rotation:i,size:a,centerOffset:g,groundDistance:1,featureAttribute:c,olidColor:u}),f=M(this._context,t,d,o,s);if(f==null)return null;let p=new fe(this,f.object,null,le,o);return p.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),p.hiddenIfDeconflicted=!0,p.alignedSampledElevation=f.sampledElevation,p.needsElevationUpdates=w(o.mode)||o.mode===`absolute-height`,p.getScreenSize=this._createScreenSizeGetter(a,c),p.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(p.getScreenSize(),1,e),j(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,n,r,i,a,o){n.renderPriority=this._renderPriority;let s=v();y(t,s,this._context.overlaySR),s[2]=me;let c=this._context.clippingExtent;if(c!=null&&!b(c,s))return null;let l=this.getFastUpdateAttrValues(e),u=this._context.layerViewUid,d=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:u}),f=H(n,{normal:K,position:s,color:r,rotation:i,size:a,featureAttribute:l,olidColor:d}),p=new ge(f,{layerViewUid:u,graphicUid:o}),m=new de(this,[p],null,this._context.drapeSourceRenderer);return m.getScreenSize=this._createScreenSizeGetter(a,l),m.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(m.getScreenSize(),1,e),m}_createScreenSizeGetter(e,t){e??=h;let n=this._outlineSize+2;if(this._fastUpdates&&t){let r=e[0]*this._size[0],i=e[1]*this._size[1];return(e=m())=>{let[a,o]=I(xe,this._fastUpdates.materialParameters,t);return e[0]=a*r+n,e[1]=o*i+n,e}}let r=e[0]*this._size[0]+n,i=e[1]*this._size[1]+n;return(e=m())=>(e[0]=r,e[1]=i,e)}_fastVisualVariableConvertOptions(){let e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),n=l,r=e*n,i=_(r,r,r),a=this._getFallbackSize();return new L({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:i,unitInMeters:n,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(a,a,a)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(t=>t.forEach(e))}test(){return{...super.test(),material:this._materials[0]}}}function ve(e){return e&&e.type===`point-3d`&&e.hasVisibleVerticalOffset()}function J(e){return e==null?!1:e===`cross`||e===`x`}function Y(e){let t=d(e);return t?.mediaType===`application/json`?t.data:void 0}function X(e,t){return e===`relative`?f((t.x||0)+.5,-(t.y||0)+.5):e in D?D[e]:D.center}function Z({parameters:e},t){let n=(e.width??1)/(e.height??1);return n>1?[t,Math.round(t/n)]:[Math.round(t*n),t]}function Q(e){return e.resource?.href?null:e.resource?.primitive??ae}function ye(e){return(e.material?.color?.a??1)===1&&Q(e)!=null}const be={mode:`relative-to-ground`,offset:0},xe=v();function $(e,t,n,r){let i={...t,focusAreaStyle:n};return e[0]=new W(t,r),e[1]=new W(t,r,!0),e[2]=new W(i,r),e[3]=new W(i,r,!0),e}export{q as Graphics3DIconSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{pt2px as t,px2pt as n}from"../../../../core/screenUtils.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as a,clone as o,ones as s}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as c,fromBuffer as l,intersectsClippingArea as u,empty as d,expandWithAABB as f,expandWithBuffer as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{sharedGeometryElevationAligner as g}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as _,needsElevationUpdates2D as v}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as y}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as b}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as x,nanFallbackColor as S}from"./Graphics3DSymbolLayer.js";import{parseCapType as C,computeSymbolLayerIndex as w,parseLineMarkerStyle as T}from"./lineUtils.js";import{initFastSymbolUpdatesState as E,updateFastSymbolUpdatesState as D,getAttributeValue as O,getSizeAttributeValue as k,ConvertOptions as A}from"../support/FastSymbolUpdates.js";import{debugFlags as j}from"../../support/debugFlags.js";import{createGeometry as M}from"../../support/engineContent/line.js";import{geometryToRenderInfo as N,geometryToRenderInfoDraped as P}from"../../support/renderInfoUtils/line.js";import{Object3D as F}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as I}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as L}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as R,patternHidesLine as z}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as B}from"../../webgl-engine/materials/RibbonLineMaterial.js";const V=[`polyline`],H=n(1);class U extends x{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=E(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?H:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:w(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:C(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:R(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new B(this._getMaterialParameters(!1,0),this.view.state.isGlobal),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new B({...this._getMaterialParameters(!1,1),wireframe:!0},this.view.state.isGlobal),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new L({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:T(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let n=s();return this._drivenProperties.color&&(i(n,e?.output??this._getFallbackOpacityAndColor(a)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(n[3]=t?.output??this._getFallbackOpacity()),n}_getDrivenMarkerColor({color:e,opacity:t}){let n=s();return this._drivenProperties.color&&(i(n,e?.output??this._getFallbackMarkerOpacityAndColor(a)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(n[3]=t?.output??this._getFallbackMarkerOpacity()),n}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,V,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(D(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof B&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(D(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof L&&e.setParameters(n.materialParameters);else return 0}break;default:return 0}return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=C(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=_(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=v(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=e.graphic,i=W(r.geometry);if(i==null)return null;let a=[],o=c(),s=N(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,i.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,d=r.mapPositions;if(this._context.clippingExtent!=null&&(l(d,o),!u(o,this._context.clippingExtent)))continue;let f=this._createGeometry(this._lineMaterial,e,c,d,i.type,1,n);if(a.push(f),j.LINE_WIREFRAMES&&a.push(f.instantiate({material:this._wireframeLineMaterial})),this._markerMaterial!=null){let t=f.instantiate({material:this._markerMaterial});t.attributes.has(`color`)&&t.setAttributeData(`color`,this._getDrivenMarkerColor(e.renderingInfo)),a.push(t)}}if(a.length===0)return null;let d=this._context.layerViewUid,f=new F({geometries:a,castShadow:!1,layerViewUid:d,graphicUid:n}),p=new b(this,f,null,g,t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=v(t.mode),p}_createGeometry(e,t,n,r,i,a,o){let s=a===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,c=i===`polygon`,l=this._fastUpdates?.visualVariables.color,u=this._fastUpdates?.visualVariables.size,d=this._fastUpdates?.visualVariables.opacity,f=this._context.layerViewUid,p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:f}),{renderingInfo:m}=t,h={position:n,size:u?null:this._getDrivenSize(m),color:l?null:this._getDrivenColor(m),sizeFeature:u?k(u,m.size):null,colorFeature:l?O(l,m.color):null,opacityFeature:d?O(d,m.opacity):null};return M(e,{overlayInfo:s,removeDuplicateStartEnd:c,mapPositions:r,attributeData:h},p)}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=j.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=c(),s=d(),m=P(n,this._context.overlaySR);this._logGeometryCreationWarnings(m,n.paths,`paths`,`LineSymbol3DLayer`);for(let c of m.lines){if(l(c.position,o),!u(o,this._context.clippingExtent))continue;f(s,o);let d=this._createGeometry(this._lineMaterial,e,c.position,void 0,n.type,0,t.uid),m=e=>{let n=this._context.layerViewUid,r=new I(e,{layerViewUid:n,graphicUid:t.uid});a.push(r)};if(i!=null){let t=d.instantiate({material:i});t.attributes.has(`color`)&&t.setAttributeData(`color`,this._getDrivenMarkerColor(e.renderingInfo)),m(t);let n=this.symbolLayer.marker.placement;(n===`begin`||n===`begin-end`)&&p(o,c.position,0,1),(n===`end`||n===`begin-end`)&&p(o,c.position,c.position.length-3,1)}m(d),j.LINE_WIREFRAMES&&m(d.instantiate({material:r}))}return new y(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return z(this.symbolLayer.pattern)}_computeMaterialWidth(e,n){return n?this._drivenProperties.size?1:e??1:(e??=H,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?t(1):1:t(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let i=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,a=this._getCombinedOpacityAndColor(i);n.useMaterialColor&&G(o(a),this._materials[2],e),this._patternHidesLine&&(a[3]=0),G(a,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:T(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let t=this._getFallbackSize(),{size:n}=this.symbolLayer;return new A({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:r(n,n,n),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(S):this._getFallbackOpacityAndColor(S),fallbackSize:r(t,t,t)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:t(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
2
+ import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{onePixelInPoints as t,pt2px as n,onePointInPixels as r}from"../../../../core/screenUtils.js";import{fromValues as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as a}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as o,clone as s,ones as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p,expandWithBuffer as m}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as h}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as g}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{sharedGeometryElevationAligner as _}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as v,needsElevationUpdates2D as y}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as b}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as x}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as S,nanFallbackColor as C}from"./Graphics3DSymbolLayer.js";import{parseCapType as w,computeSymbolLayerIndex as T,parseLineMarkerStyle as E}from"./lineUtils.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as O,getAttributeValue as k,getSizeAttributeValue as A,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{debugFlags as M}from"../../support/debugFlags.js";import{createGeometry as N}from"../../support/engineContent/line.js";import{geometryToRenderInfo as P,geometryToRenderInfoDraped as F}from"../../support/renderInfoUtils/line.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as R}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as z,patternHidesLine as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as V}from"../../webgl-engine/materials/RibbonLineMaterial.js";const H=[`polyline`];class U extends S{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?t:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:T(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:w(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:z(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new V(this._getMaterialParameters(!1,0),this.view.state.isGlobal),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new V({...this._getMaterialParameters(!1,1),wireframe:!0},this.view.state.isGlobal),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new R({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:E(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=h(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(n[3]=t?.output??this._getFallbackOpacity()),n}_getDrivenMarkerColor({color:e,opacity:t}){let n=c();return this._drivenProperties.color&&(a(n,e?.output??this._getFallbackMarkerOpacityAndColor(o)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(n[3]=t?.output??this._getFallbackMarkerOpacity()),n}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(O(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof V&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(O(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof R&&e.setParameters(n.materialParameters);else return 0}break;default:return 0}return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||g(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=w(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=v(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=y(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=e.graphic,i=W(r.geometry);if(i==null)return null;let a=[],o=l(),s=P(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,i.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometry(this._lineMaterial,e,c,l,i.type,1,n);if(a.push(f),M.LINE_WIREFRAMES&&a.push(f.instantiate({material:this._wireframeLineMaterial})),this._markerMaterial!=null){let t=f.instantiate({material:this._markerMaterial});t.attributes.has(`color`)&&t.setAttributeData(`color`,this._getDrivenMarkerColor(e.renderingInfo)),a.push(t)}}if(a.length===0)return null;let c=this._context.layerViewUid,f=new I({geometries:a,castShadow:!1,layerViewUid:c,graphicUid:n}),p=new x(this,f,null,_,t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=y(t.mode),p}_createGeometry(e,t,n,r,i,a,o){let s=a===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,c=i===`polygon`,l=this._fastUpdates?.visualVariables.color,u=this._fastUpdates?.visualVariables.size,d=this._fastUpdates?.visualVariables.opacity,f=this._context.layerViewUid,p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:f}),{renderingInfo:m}=t,h={position:n,size:u?null:this._getDrivenSize(m),color:l?null:this._getDrivenColor(m),sizeFeature:u?A(u,m.size):null,colorFeature:l?k(l,m.color):null,opacityFeature:d?k(d,m.opacity):null};return N(e,{overlayInfo:s,removeDuplicateStartEnd:c,mapPositions:r,attributeData:h},p)}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=M.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=F(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let l of c.lines){if(u(l.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let c=this._createGeometry(this._lineMaterial,e,l.position,void 0,n.type,0,t.uid),f=e=>{let n=this._context.layerViewUid,r=new L(e,{layerViewUid:n,graphicUid:t.uid});a.push(r)};if(i!=null){let t=c.instantiate({material:i});t.attributes.has(`color`)&&t.setAttributeData(`color`,this._getDrivenMarkerColor(e.renderingInfo)),f(t);let n=this.symbolLayer.marker.placement;(n===`begin`||n===`begin-end`)&&m(o,l.position,0,1),(n===`end`||n===`begin-end`)&&m(o,l.position,l.position.length-3,1)}f(c),M.LINE_WIREFRAMES&&f(c.instantiate({material:r}))}return new b(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return B(this.symbolLayer.pattern)}_computeMaterialWidth(e,i){return i?this._drivenProperties.size?1:e??1:(e??=t,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r:1:n(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let i=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,a=this._getCombinedOpacityAndColor(i);n.useMaterialColor&&G(s(a),this._materials[2],e),this._patternHidesLine&&(a[3]=0),G(a,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:E(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let t=this._getFallbackSize(),{size:n}=this.symbolLayer;return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:i(n,n,n),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(C):this._getFallbackOpacityAndColor(C),fallbackSize:i(t,t,t)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:n(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
@@ -11,11 +11,11 @@ import{EvaluateAmbientLighting as e}from"./EvaluateAmbientLighting.glsl.js";impo
11
11
  `),p.uniforms.add(i).code.add(d`vec3 evaluateAdditionalLighting(float ambientOcclusion, vec3 vPosWorld) {
12
12
  float additionalAmbientScale = additionalDirectedAmbientLight(vPosWorld);
13
13
  return (1.0 - ambientOcclusion) * additionalAmbientScale * ambientBoostFactor * lightingGlobalFactor * mainLightIntensity;
14
- }`);let w=S?`globalIlluminationOcclusion`:`ssao`,T=S?`factorDirect`:`0.0`,E=S?`factorAmbient`:`1.0`;switch(p.constants.add(`mainLightIrradianceScale`,`float`,S?.75:1),p.constants.add(`ambientIrradianceScale`,`float`,S?1.5:1),S&&(p.uniforms.add(new u(`factorDirect`,e=>e.globalIlluminationDirectFactor),new u(`factorAmbient`,e=>e.globalIlluminationAmbientFactor)),p.constants.add(`globalIlluminationEmissionCompressionWeight`,`float`,.75),p.code.add(d`vec3 evaluateGlobalIlluminationOcclusion() {
15
- return min(1.2 * readGlobalIlluminationOcclusion(), 1.0);
14
+ }`);let w=S?`globalIlluminationOcclusion`:`ssao`,T=S?`factorDirect`:`0.0`,E=S?`factorAmbient`:`1.0`;switch(p.constants.add(`mainLightIrradianceScale`,`float`,S?.75:1),p.constants.add(`ambientIrradianceScale`,`float`,S?1.5:1),S&&(p.uniforms.add(new u(`factorDirect`,e=>e.globalIlluminationDirectFactor),new u(`factorAmbient`,e=>e.globalIlluminationAmbientFactor)),p.constants.add(`globalIlluminationOcclusionBoost`,`float`,1.2),p.constants.add(`globalIlluminationEmissionBoost`,`float`,2.25),p.constants.add(`globalIlluminationEmissionCompressionWeight`,`float`,.75),p.code.add(d`vec3 evaluateGlobalIlluminationOcclusion() {
15
+ return min(globalIlluminationOcclusionBoost * readGlobalIlluminationOcclusion(), 1.0);
16
16
  }
17
17
  vec3 evaluateGlobalIlluminationEmission(vec3 albedoLinear) {
18
- vec3 emission = 2.25 * (0.75 * albedoLinear + 0.25) * readGlobalIlluminationEmission().rgb;
18
+ vec3 emission = globalIlluminationEmissionBoost * (0.75 * albedoLinear + 0.25) * readGlobalIlluminationEmission().rgb;
19
19
  vec3 compressedEmission = emission / (emission + 1.0);
20
20
  return mix(emission, compressedEmission, globalIlluminationEmissionCompressionWeight);
21
21
  }`)),y){case 0:case 4:case 3:p.include(a),p.code.add(d`
@@ -4,7 +4,7 @@ void discardByStippleAlpha(float stippleAlpha, float threshold) {}
4
4
  vec4 blendStipple(vec4 color, float stippleAlpha) { return color; }`);return}let p=!(d.draped&&d.stipplePreferContinuous),{vertex:g,fragment:_}=u;d.draped||(n(g,d),g.uniforms.add(new a(`worldToScreenPerDistanceRatio`,({camera:e})=>1/e.screenPixelSizePerDistance)).code.add(s`float computeWorldToScreenRatio(vec3 segmentCenter) {
5
5
  float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
6
6
  return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
7
- }`)),u.varyings.add(`vStippleDistance`,`float`),u.varyings.add(`vStippleDistanceLimits`,`vec2`),u.varyings.add(`vStipplePatternStretch`,`float`),g.code.add(s`
7
+ }`)),u.varyings.add(`vStippleDistance`,`float`),u.varyings.add(`vStippleLimitsAndCaps`,`vec4`),u.varyings.add(`vStipplePatternStretch`,`float`),g.code.add(s`
8
8
  float discretizeStippleDistanceToScreenRatio(float stippleDistanceToScreenRatio) {
9
9
  float step = ${s.float(h)};
10
10
 
@@ -35,9 +35,10 @@ return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
35
35
  }
36
36
  return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
37
37
  }
38
- `),_.uniforms.add(new l(`stipplePatternTexture`,e=>e.stippleTexture),new o(`stipplePatternPixelSizeInv`,e=>1/m(e))),d.stippleOffColorEnabled&&_.uniforms.add(new i(`stippleOffColor`,e=>f(e.stippleOffColor))),u.include(t);let v=d.worldSized&&d.imagePattern,{usePerspectiveCorrectStipple:y}=d,b=!d.worldSized;y&&u.varyings.add(`vStipplePerspective`,`vec4`),v?(u.varyings.add(`vStippleV`,`float`),u.fragment.include(e),_.code.add(s`vec4 getStippleColor(out bool isClamped) {
39
- vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
40
- isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
38
+ `),_.uniforms.add(new l(`stipplePatternTexture`,e=>e.stippleTexture),new o(`stipplePatternPixelSizeInv`,e=>1/m(e))),d.stippleOffColorEnabled&&_.uniforms.add(new i(`stippleOffColor`,e=>f(e.stippleOffColor))),u.include(t);let v=d.worldSized&&d.imagePattern,{usePerspectiveCorrectStipple:y}=d;y&&u.varyings.add(`vStipplePerspective`,`vec4`),v?(u.varyings.add(`vStippleV`,`float`),u.fragment.include(e),_.code.add(s`vec4 getStippleColor(out bool isClamped) {
39
+ vec2 aaCorrectedLimits = vStippleLimitsAndCaps.xy + vec2(1.0, -1.0) / gl_FragCoord.w;
40
+ isClamped = (vStippleLimitsAndCaps.z <= 0.0 && vStippleDistance < aaCorrectedLimits.x) ||
41
+ (vStippleLimitsAndCaps.w <= 0.0 && vStippleDistance > aaCorrectedLimits.y);
41
42
  float u = vStippleDistance * stipplePatternPixelSizeInv;
42
43
  float v = vStippleV == -1.0 ? 0.5 : vStippleV;
43
44
  return texture(stipplePatternTexture, vec2(u, v));
@@ -61,7 +62,21 @@ float opacity = mixExternalOpacity(color.a, 1.0, stippleColor.a, mixMode);
61
62
  return vec4(col, opacity);
62
63
  }`)):_.code.add(s`
63
64
  float getStippleSDF(out bool isClamped) {
64
- float stippleDistance = noPerspectiveRead(${b?`clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y)`:`vStippleDistance`});
65
+ ${c(d.worldSized,s`
66
+ float unclampedStippleDistance = noPerspectiveRead(vStippleDistance);
67
+ float stippleDistancePerPixel = length(vec2(dFdx(unclampedStippleDistance), dFdy(unclampedStippleDistance)));
68
+ `,s`float stippleDistancePerPixel = 1.0;`)}
69
+
70
+ bool clampStart = vStippleLimitsAndCaps.z <= 0.0;
71
+ bool clampEnd = vStippleLimitsAndCaps.w <= 0.0;
72
+ float stippleDistance = vStippleDistance;
73
+ if (clampStart) {
74
+ stippleDistance = max(stippleDistance, vStippleLimitsAndCaps.x);
75
+ }
76
+ if (clampEnd) {
77
+ stippleDistance = min(stippleDistance, vStippleLimitsAndCaps.y);
78
+ }
79
+ stippleDistance = noPerspectiveRead(stippleDistance);
65
80
  float lineSizeInv = noPerspectiveRead(vLineSizeInv);
66
81
 
67
82
  ${c(y,s`
@@ -75,10 +90,9 @@ return vec4(col, opacity);
75
90
  stippleDistance = mix(stipplePerspective.x, stipplePerspective.y, perspectiveFactor);
76
91
  `)}
77
92
 
78
- ${b?s`
79
- vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
80
- isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;
81
- `:s`isClamped = false;`}
93
+ vec2 aaCorrectedLimits = vStippleLimitsAndCaps.xy + vec2(1.0, -1.0) * stippleDistancePerPixel / gl_FragCoord.w;
94
+ isClamped = (clampStart && vStippleDistance < aaCorrectedLimits.x) ||
95
+ (clampEnd && vStippleDistance > aaCorrectedLimits.y);
82
96
 
83
97
  float u = stippleDistance * stipplePatternPixelSizeInv * lineSizeInv;
84
98
  u = fract(u);
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Error.js";import{makeHandle as r}from"../../../core/handleUtils.js";import{createScalar as i,createLength as a,toUnit as o}from"../../../core/quantity.js";import{generateUUID as s}from"../../../core/uuid.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{isWebMercator as u,isGeographic as d}from"../../../geometry/support/spatialReferenceUtils.js";import{createViewAlignedCoordinateSystem as f}from"./surfaceCoordinateSystems.js";import{knownFieldDisplayOrders as p}from"./types.js";import{createGeographicCoordinate as m}from"../../interactive/tooltip/fields/parsingAndFormattingUtils.js";import{elevationFromPoint as h}from"../../support/euclideanLengthMeasurementUtils.js";const g={x:p.Coordinates+10,y:p.Coordinates+11,elevation:p.Coordinates+12};let _=class extends t{constructor(e){super(e)}normalizeCtorArgs(e){let{drawTool:t,plugin:n,...r}=e;return{_drawTool:t,_plugin:n,...r}}get positionOfLastUserInput(){return this._drawTool.positionOfLastUserInput}get elevationConstraint(){return this._drawTool.tooltipManager?.elevationConstraint}getSession(e){return this._drawTool.editSessionManager.getSession(e)}readBooleanSetting(e){let t=this._plugin.configuration?.uniqueId;if(t)return this._drawTool.readPluginSettingValue(t,e)}createInteractiveHandle(e,t){let r=this._drawTool.interactiveHandleManager,a=this._drawTool.tooltipManager,o=this._plugin,c=this.session,l=this._drawTool.coordinateHelper;if(!r||!a)throw new n(`draw-tool:interactive-handle-missing-dependencies`,`Attempted to set up an interactive handle without required dependencies.`);let f=e.name??s(),p=e.defaultCaptureMode??`capture-always`,h=r.registerHandle(o,{...e,name:f,editSession:c,defaultCaptureMode:p,captureMode:p});if(this._drawTool.addPromise(r.setupManipulatorForHandle(h,this._drawTool.lastScreenPosition,this._drawTool.movementCommandContext)),!t?.disableDefaultXYFields){let e=l.spatialReference;u(e)||d(e)?(a.createMeasuredField(o,{id:Symbol(`tooltip-long-${f}`),preset:`longitude`,getMeasurementInput:()=>h.outputMapPosition,measure:async e=>m(e?.longitude),fieldProperties:{displayOrder:g.x},fieldFilters:{appliesToHandlesWithName:f}}),a.createMeasuredField(o,{id:Symbol(`tooltip-lat-${f}`),preset:`latitude`,getMeasurementInput:()=>h.outputMapPosition,measure:async e=>m(e?.latitude),fieldProperties:{displayOrder:g.y},fieldFilters:{appliesToHandlesWithName:f}})):(a.createMeasuredField(o,{id:Symbol(`tooltip-x-${f}`),preset:`x`,getMeasurementInput:()=>h.outputMapPosition,measure:async e=>e?i(e.x):null,fieldProperties:{displayOrder:g.x},fieldFilters:{appliesToHandlesWithName:f}}),a.createMeasuredField(o,{id:Symbol(`tooltip-y-${f}`),preset:`y`,getMeasurementInput:()=>h.outputMapPosition,measure:async e=>e?i(e.y):null,fieldProperties:{displayOrder:g.y},fieldFilters:{appliesToHandlesWithName:f}})),this._drawTool.hasZ&&h.role===`primary`&&a.createMeasuredField(o,{id:Symbol(`tooltip-z-${f}`),preset:`elevation`,getMeasurementInput:()=>h.outputMapPosition,measure:async(e,t)=>this.measureElevation(e,t.inputUnitInfos.verticalLength.unit),fieldProperties:{displayOrder:g.elevation},fieldFilters:{appliesToHandlesWithName:f}})}return h}removeInteractiveHandle(e){let t=e;this._drawTool.interactiveHandleManager?.unregisterHandle(this._plugin,t)}createConstraint(e,t){this._drawTool.interactiveHandleManager?.registerCustomConstraint(this._plugin,e,t)}removeConstraint(e){this._drawTool.interactiveHandleManager?.unregisterCustomConstraint(this._plugin,e)}createCustomField(e){if(!this._drawTool.tooltipManager)throw new n(`draw-tool:tooltip-manager-missing`,`Attempted to create a field without access to a tooltip manager.`);return this._drawTool.tooltipManager.createCustomField(this._plugin,e)}createMeasuredField(e){if(!this._drawTool.tooltipManager)throw new n(`draw-tool:tooltip-manager-missing`,`Attempted to create a field without access to a tooltip manager.`);return this._drawTool.tooltipManager.createMeasuredField(this._plugin,e)}requestComplete(){this._drawTool.complete(this._plugin)}requestCancel(e){this._drawTool.lifecycleManager.cancel(this._plugin)}requestBeginDownstreamPlugin(e,t){this._drawTool.lifecycleManager.begin([e],this._plugin,t?.cancelExisting)}async measureLength(e,t,n,r){let{_drawTool:i,_plugin:a}=this;if(n!==`tooltip`||i.tooltipManager?.effectiveEnabled)return await i.measurementManager.measureLength(a,t,e,r)}async measureArea(e,t,n,r){let{_drawTool:i,_plugin:a}=this;if(n!==`tooltip`||i.tooltipManager?.effectiveEnabled)return await i.measurementManager.measureArea(a,t,e,r)}async measureDistance(e,t,n,r){let{_drawTool:i,_plugin:a}=this;if(n!==`tooltip`||i.tooltipManager?.effectiveEnabled)return await i.measurementManager.measureDistance(a,t,e,r)}measureElevation(e,t){let n=this._drawTool,r=h(e);if(!r){let e=n.surfaceManager?.metersPerVerticalUnit;e&&(r=a(n.defaultZ*e,`meters`))}return t&&r&&r.unit!==t?o(r,t):r}getGlobalState(){return this._drawTool.globalStateManager.getGlobalState()}setGlobalState(e,t){this._drawTool.globalStateManager.setGlobalState(this._plugin,e,t)}addOrUpdateGraphic(e,t){let{_plugin:n,_drawTool:i}=this,a=i.renderer;a?.addOrUpdateGraphic(e,t),n.hasHandles(e)||n.addHandles(r(()=>a?.removeGraphic(e)),e)}addOrUpdateVisual(e,t){let n=this._plugin,i=this._drawTool.renderer;i?.addOrUpdateVisual(e,t),n.hasHandles(e)||n.addHandles(r(()=>i?.removeVisual(e)),e)}removeGraphic(e){this._plugin.removeHandles(e)}removeVisual(e){this._plugin.removeHandles(e)}getViewInformation(){return this._drawTool.view}getViewAlignedSurfaceCoordinateSystem(e){let{view:t,coordinateHelper:n}=this._drawTool;return!t||!n?null:f(t,n.pointToVector(e))}};e([c()],_.prototype,`_plugin`,void 0),e([c()],_.prototype,`_drawTool`,void 0),e([c({nonNullable:!0})],_.prototype,`session`,void 0),e([c()],_.prototype,`positionOfLastUserInput`,null),e([c()],_.prototype,`elevationConstraint`,null),_=e([l(`esri.views.draw.support.PluginContext`)],_);export{_ as PluginContext};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import n from"../../../core/Error.js";import{makeHandle as r}from"../../../core/handleUtils.js";import{createScalar as i,createLength as a,toUnit as o}from"../../../core/quantity.js";import{generateUUID as s}from"../../../core/uuid.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{isWebMercator as u,isGeographic as d}from"../../../geometry/support/spatialReferenceUtils.js";import{getEffectiveElevationMode as f}from"../../../support/elevationInfoUtils.js";import{createViewAlignedCoordinateSystem as p}from"./surfaceCoordinateSystems.js";import{knownFieldDisplayOrders as m}from"./types.js";import{createGeographicCoordinate as h}from"../../interactive/tooltip/fields/parsingAndFormattingUtils.js";import{elevationFromPoint as g}from"../../support/euclideanLengthMeasurementUtils.js";const _={x:m.Coordinates+10,y:m.Coordinates+11,elevation:m.Coordinates+12};let v=class extends t{constructor(e){super(e)}normalizeCtorArgs(e){let{drawTool:t,plugin:n,...r}=e;return{_drawTool:t,_plugin:n,...r}}get positionOfLastUserInput(){return this._drawTool.positionOfLastUserInput}get elevationConstraint(){return this._drawTool.tooltipManager?.elevationConstraint}getSession(e){return this._drawTool.editSessionManager.getSession(e)}readBooleanSetting(e){let t=this._plugin.configuration?.uniqueId;if(t)return this._drawTool.readPluginSettingValue(t,e)}createInteractiveHandle(e,t){let r=this._drawTool.interactiveHandleManager,a=this._drawTool.tooltipManager,o=this._plugin,c=this.session,l=this._drawTool.coordinateHelper;if(!r||!a)throw new n(`draw-tool:interactive-handle-missing-dependencies`,`Attempted to set up an interactive handle without required dependencies.`);let p=e.name??s(),m=e.defaultCaptureMode??`capture-always`,g=r.registerHandle(o,{...e,name:p,editSession:c,defaultCaptureMode:m,captureMode:m});if(this._drawTool.addPromise(r.setupManipulatorForHandle(g,this._drawTool.lastScreenPosition,this._drawTool.movementCommandContext)),!t?.disableDefaultXYFields){let e=l.spatialReference;if(u(e)||d(e)?(a.createMeasuredField(o,{id:Symbol(`tooltip-long-${p}`),preset:`longitude`,getMeasurementInput:()=>g.outputMapPosition,measure:async e=>h(e?.longitude),fieldProperties:{displayOrder:_.x},fieldFilters:{appliesToHandlesWithName:p}}),a.createMeasuredField(o,{id:Symbol(`tooltip-lat-${p}`),preset:`latitude`,getMeasurementInput:()=>g.outputMapPosition,measure:async e=>h(e?.latitude),fieldProperties:{displayOrder:_.y},fieldFilters:{appliesToHandlesWithName:p}})):(a.createMeasuredField(o,{id:Symbol(`tooltip-x-${p}`),preset:`x`,getMeasurementInput:()=>g.outputMapPosition,measure:async e=>e?i(e.x):null,fieldProperties:{displayOrder:_.x},fieldFilters:{appliesToHandlesWithName:p}}),a.createMeasuredField(o,{id:Symbol(`tooltip-y-${p}`),preset:`y`,getMeasurementInput:()=>g.outputMapPosition,measure:async e=>e?i(e.y):null,fieldProperties:{displayOrder:_.y},fieldFilters:{appliesToHandlesWithName:p}})),this._drawTool.hasZ&&g.role===`primary`){let e=a.createMeasuredField(o,{id:Symbol(`tooltip-z-${p}`),preset:`elevation`,getMeasurementInput:()=>g.outputMapPosition,measure:async(e,t)=>this.measureElevation(e,t.inputUnitInfos.verticalLength.unit),fieldProperties:{displayOrder:_.elevation},fieldFilters:{appliesToHandlesWithName:p}}).field,{view:t,hasZ:n,elevationInfo:r}=this._drawTool;t.type===`3d`&&f(n,r)!==`absolute-height`&&!e.locked&&e.lock(this.measureElevation(null))}}return g}removeInteractiveHandle(e){let t=e;this._drawTool.interactiveHandleManager?.unregisterHandle(this._plugin,t)}createConstraint(e,t){this._drawTool.interactiveHandleManager?.registerCustomConstraint(this._plugin,e,t)}removeConstraint(e){this._drawTool.interactiveHandleManager?.unregisterCustomConstraint(this._plugin,e)}createCustomField(e){if(!this._drawTool.tooltipManager)throw new n(`draw-tool:tooltip-manager-missing`,`Attempted to create a field without access to a tooltip manager.`);return this._drawTool.tooltipManager.createCustomField(this._plugin,e)}createMeasuredField(e){if(!this._drawTool.tooltipManager)throw new n(`draw-tool:tooltip-manager-missing`,`Attempted to create a field without access to a tooltip manager.`);return this._drawTool.tooltipManager.createMeasuredField(this._plugin,e)}requestComplete(){this._drawTool.complete(this._plugin)}requestCancel(e){this._drawTool.lifecycleManager.cancel(this._plugin)}requestBeginDownstreamPlugin(e,t){this._drawTool.lifecycleManager.begin([e],this._plugin,t?.cancelExisting)}async measureLength(e,t,n,r){let{_drawTool:i,_plugin:a}=this;if(n!==`tooltip`||i.tooltipManager?.effectiveEnabled)return await i.measurementManager.measureLength(a,t,e,r)}async measureArea(e,t,n,r){let{_drawTool:i,_plugin:a}=this;if(n!==`tooltip`||i.tooltipManager?.effectiveEnabled)return await i.measurementManager.measureArea(a,t,e,r)}async measureDistance(e,t,n,r){let{_drawTool:i,_plugin:a}=this;if(n!==`tooltip`||i.tooltipManager?.effectiveEnabled)return await i.measurementManager.measureDistance(a,t,e,r)}measureElevation(e,t){let n=this._drawTool,r=g(e);if(!r){let e=n.surfaceManager?.metersPerVerticalUnit;e&&(r=a(n.defaultZ*e,`meters`))}return t&&r&&r.unit!==t?o(r,t):r}getGlobalState(){return this._drawTool.globalStateManager.getGlobalState()}setGlobalState(e,t){this._drawTool.globalStateManager.setGlobalState(this._plugin,e,t)}addOrUpdateGraphic(e,t){let{_plugin:n,_drawTool:i}=this,a=i.renderer;a?.addOrUpdateGraphic(e,t),n.hasHandles(e)||n.addHandles(r(()=>a?.removeGraphic(e)),e)}addOrUpdateVisual(e,t){let n=this._plugin,i=this._drawTool.renderer;i?.addOrUpdateVisual(e,t),n.hasHandles(e)||n.addHandles(r(()=>i?.removeVisual(e)),e)}removeGraphic(e){this._plugin.removeHandles(e)}removeVisual(e){this._plugin.removeHandles(e)}getViewInformation(){return this._drawTool.view}getViewAlignedSurfaceCoordinateSystem(e){let{view:t,coordinateHelper:n}=this._drawTool;return!t||!n?null:p(t,n.pointToVector(e))}};e([c()],v.prototype,`_plugin`,void 0),e([c()],v.prototype,`_drawTool`,void 0),e([c({nonNullable:!0})],v.prototype,`session`,void 0),e([c()],v.prototype,`positionOfLastUserInput`,null),e([c()],v.prototype,`elevationConstraint`,null),v=e([l(`esri.views.draw.support.PluginContext`)],v);export{v as PluginContext};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{createTask as n}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import o from"../../../../core/ReactiveMap.js";import{watch as s,syncAndInitial as c,initial as l}from"../../../../core/reactiveUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../core/support/UpdatingHandles.js";import{isLoaded as p,load as m}from"../../../../geometry/coordinateFormatter.js";import{absoluteHeightElevationInfo as h}from"../../../../support/elevationInfoUtils.js";import{ManagedTooltipField as g}from"../ManagedTooltipField.js";import{getConstraintContext as _}from"../../../interactive/sketch/constraintUtils.js";import{makeTooltip as v}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{makeScalarField as y,makeOrientationField as b,makeAreaField as x,makeLengthField as S,makeRadiusField as C,makeTotalLengthField as w,makeSizeField as T,makeScaleField as E,makeYField as D,makeXField as O,makeLongitudeField as k,makeLatitudeField as A,makeElevationField as j,makeDistanceField as M,makeDirectionField as N}from"../../../interactive/tooltip/fields/fields.js";import{TooltipField as P}from"../../../interactive/tooltip/fields/TooltipField.js";import{DynamicTooltipInfo as F,isKnownConstraintField as I}from"../../../interactive/tooltip/infos/DynamicTooltipInfo.js";let L=class extends t{constructor(e){super(e),this._pluginTooltipFieldRegistry=new o,this._updatingHandles=new f,this._coordinateFormatterLoadTask=null,this._constraintSnapshot=null,this.constraintsEnabled=!0,this.keepTooltipAliveEvenWhenTooltipsAreNotEnabled=!1,this.enabled=!0}initialize(){this.addHandles([s(()=>[this.effectiveEnabled,this.context?.view,this.context?.toolOptions],([e,t,n])=>{let{context:r}=this;e&&t&&n?(this._tooltipInfo??=new F({toolOptions:n,getAllFields:()=>this.allFields,getActiveHandle:()=>this.effectiveActiveHandle,getHelpMessageKey:()=>this.context?.getHelpMessageKey(),viewType:t.type}),this._tooltip||this._setupTooltip(r)):(this._tooltip=a(this._tooltip),this._tooltipInfo=a(this._tooltipInfo),this.inputModeHandle=null)},c)])}destroy(){this._tooltip=a(this._tooltip),this._tooltipInfo=a(this._tooltipInfo)}get context(){return this.getDependencies?.()}get focusedHandle(){return this.context?.getActiveHandle?.()}get allHandles(){return this.context?.getAllHandles?.()}get effectiveActiveHandle(){return this._tooltip?.isInInputMode?this.inputModeHandle:this.focusedHandle}get updating(){return this._updatingHandles.updating}get tooltip(){return this._tooltip}get tooltipInfo(){return this._tooltipInfo}get elevationConstraint(){return this.getConstraints(this.focusedHandle)?.elevation}get allFields(){return Array.from(this._pluginTooltipFieldRegistry.values()).flatMap(e=>Array.from(e.values()))}get effectiveEnabled(){return this.enabled&&(this.context?.toolOptions.tooltips.effectiveEnabled||this.keepTooltipAliveEvenWhenTooltipsAreNotEnabled)}getConstraints(e){let{tooltipInfo:t,context:n}=this,{view:r,editGeometryOperations:i,elevationInfo:a,toolOptions:o}=n??{},s=this.getLastScreenPosition?.();if(!s||!r||!t||!i||!o)return null;let{coordinateHelper:c,spatialReference:l}=i.data,u=r.toMap(s);if(!u)return null;let d=_(u,r,l,a??h,c.hasZ(),o.values.effectiveDirectionMode);return{...V(t.getConstraintFieldsForHandle(e)),context:d}}storeConstraintSnapshot(){let e=this.tooltipInfo?.allFields.filter(e=>e.locked&&!e.unlockOnVertexPlacement).filter(I);this._constraintSnapshot=e?.length?V(e):null}unlockOnVertexPlacement(){this.tooltipInfo?.allFields.forEach(e=>{e.unlockOnVertexPlacement&&(e.committed=null)})}unregisterPluginFields(e){let t=this._pluginTooltipFieldRegistry.get(e);t?.forEach(e=>e.destroy()),t?.clear(),this._pluginTooltipFieldRegistry.delete(e)}createMeasuredField(e,{id:t,preset:n,getMeasurementInput:r,measure:i,fieldProperties:a,fieldFilters:o}){let c=this._getOrCreateField(e,t,n,a,o);return c.registerMeasurement(r,i,()=>this.tooltipInfo?.renderContext),c.addHandles(s(()=>this.tooltipInfo?.isEffectiveVisibleField(c.field),e=>c.enabled=!!e,l)),c}createCustomField(e,{id:t,preset:n,fieldProperties:r,fieldFilters:i}){return this._getOrCreateField(e,t,n,r,i)}_setupTooltip(e){let t=this._tooltip=v(()=>({view:e.view,options:e.toolOptions.tooltips,info:this.tooltipInfo}));t.addHandles([s(()=>this.focusedHandle,e=>{(e&&(!t.isInInputMode||this.inputModeHandle==null)||this.inputModeHandle&&!this.allHandles?.includes(this.inputModeHandle))&&(this.inputModeHandle=e)},c),s(()=>this.focusedHandle?.screenPosition,e=>{e?(t.position=e,t.hidden=!1):t.hidden=!0},c),t.on(`commit`,()=>{this.context?.notifyTooltipsChanged()})]),!this._coordinateFormatterLoadTask&&!p()&&(this._coordinateFormatterLoadTask=n(()=>m()),this.addHandles(this._coordinateFormatterLoadTask),this._updatingHandles.addPromise(this._coordinateFormatterLoadTask.promise))}_getOrCreateField(e,t,n,r,a){let s=i(this._pluginTooltipFieldRegistry,e,()=>new o);if(s.has(t))return s.get(t);let c=B(n,r),l=new g({field:c,displayGroup:r?.displayGroup,...a});s.set(t,l);let u=I(c)?this._constraintSnapshot?.[c.name]:void 0;return u&&c.lock(u),l}};e([u()],L.prototype,`_updatingHandles`,void 0),e([u()],L.prototype,`_tooltip`,void 0),e([u()],L.prototype,`_tooltipInfo`,void 0),e([u()],L.prototype,`_coordinateFormatterLoadTask`,void 0),e([u()],L.prototype,`_constraintSnapshot`,void 0),e([u()],L.prototype,`getDependencies`,void 0),e([u()],L.prototype,`getLastScreenPosition`,void 0),e([u()],L.prototype,`context`,null),e([u()],L.prototype,`inputModeHandle`,void 0),e([u()],L.prototype,`focusedHandle`,null),e([u()],L.prototype,`allHandles`,null),e([u()],L.prototype,`effectiveActiveHandle`,null),e([u()],L.prototype,`updating`,null),e([u()],L.prototype,`tooltip`,null),e([u()],L.prototype,`tooltipInfo`,null),e([u()],L.prototype,`constraintsEnabled`,void 0),e([u()],L.prototype,`elevationConstraint`,null),e([u()],L.prototype,`allFields`,null),e([u()],L.prototype,`keepTooltipAliveEvenWhenTooltipsAreNotEnabled`,void 0),e([u()],L.prototype,`enabled`,void 0),e([u()],L.prototype,`effectiveEnabled`,null),L=e([d(`esri.views.draw.support.managers.TooltipManager`)],L);function R(e){return e==null||!(`unit`in e)||!(`rotationType`in e)?null:e}function z(e){return e==null||`rotationType`in e?null:e}function B(e,t){let n=t?{...t}:{};switch(delete n.displayGroup,e){case`area`:return x({...n,name:`area`});case`direction`:return N({...n,name:`direction`});case`distance`:return M({...n,name:`distance`});case`elevation`:{let e=j({...n,name:`elevation`});return e.showAsZ=!0,e}case`latitude`:return A({...n,name:`y`});case`longitude`:return k({...n,name:`x`});case`x`:return O({...n,name:`x`});case`y`:return D({...n,name:`y`});case`orientation`:return b({...n,name:`orientation`});case`scale`:return E({...n,name:`scale`});case`size`:return T({...n,name:`size`});case`totalLength`:return w({...n,name:`totalLength`});case`radius`:return C({...n,name:`radius`});case`generic-length`:return S({...n,name:null});case`generic-area`:return x({...n,name:null});case`generic-angle`:return b({...n,name:null});case`generic-scalar`:return y({...n,name:null});default:if(!n)throw new r(`draw-tool:tooltips:invalid-field-config`,`Attempted to create a tooltip without a preset definition and without tooltip configuration.`);return new P(n)}}function V(e){let t={};for(let n of e)switch(n.name){case`direction`:t[n.name]=n.committed;break;case`distance`:case`elevation`:t[n.name]=n.committed;break;case`x`:t[n.name]=z(n.committed),t.longitude=R(n.committed);break;case`y`:t[n.name]=z(n.committed),t.latitude=R(n.committed)}return t}export{L as TooltipManager};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{createTask as n}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import o from"../../../../core/ReactiveMap.js";import{watch as s,syncAndInitial as c,initial as l}from"../../../../core/reactiveUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as f}from"../../../../core/support/UpdatingHandles.js";import{isLoaded as p,load as m}from"../../../../geometry/coordinateFormatter.js";import{absoluteHeightElevationInfo as h}from"../../../../support/elevationInfoUtils.js";import{ManagedTooltipField as g}from"../ManagedTooltipField.js";import{getConstraintContext as _}from"../../../interactive/sketch/constraintUtils.js";import{makeTooltip as v}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{makeScalarField as y,makeOrientationField as b,makeAreaField as x,makeLengthField as S,makeRadiusField as C,makeTotalLengthField as w,makeSizeField as T,makeScaleField as E,makeYField as D,makeXField as O,makeLongitudeField as k,makeLatitudeField as A,makeElevationField as j,makeDistanceField as M,makeDirectionField as N}from"../../../interactive/tooltip/fields/fields.js";import{TooltipField as P}from"../../../interactive/tooltip/fields/TooltipField.js";import{DynamicTooltipInfo as F,filterFieldsForHandle as I,isKnownConstraintField as L}from"../../../interactive/tooltip/infos/DynamicTooltipInfo.js";let R=class extends t{constructor(e){super(e),this._pluginTooltipFieldRegistry=new o,this._updatingHandles=new f,this._coordinateFormatterLoadTask=null,this._constraintSnapshot=null,this.constraintsEnabled=!0,this.keepTooltipAliveEvenWhenTooltipsAreNotEnabled=!1,this.enabled=!0}initialize(){this.addHandles([s(()=>[this.effectiveEnabled,this.context?.view,this.context?.toolOptions],([e,t,n])=>{let{context:r}=this;e&&t&&n?(this._tooltipInfo??=new F({toolOptions:n,getAllFields:()=>this.allFields,getActiveHandle:()=>this.effectiveActiveHandle,getHelpMessageKey:()=>this.context?.getHelpMessageKey(),viewType:t.type}),this._tooltip||this._setupTooltip(r)):(this._tooltip=a(this._tooltip),this._tooltipInfo=a(this._tooltipInfo),this.inputModeHandle=null)},c)])}destroy(){this._tooltip=a(this._tooltip),this._tooltipInfo=a(this._tooltipInfo)}get context(){return this.getDependencies?.()}get focusedHandle(){return this.context?.getActiveHandle?.()}get allHandles(){return this.context?.getAllHandles?.()}get effectiveActiveHandle(){return this._tooltip?.isInInputMode?this.inputModeHandle:this.focusedHandle}get updating(){return this._updatingHandles.updating}get tooltip(){return this._tooltip}get tooltipInfo(){return this._tooltipInfo}get elevationConstraint(){return I(this.allFields,this.focusedHandle).map(({field:e})=>e).filter(L).find(e=>e.name===`elevation`)?.committed}get allFields(){return Array.from(this._pluginTooltipFieldRegistry.values()).flatMap(e=>Array.from(e.values()))}get effectiveEnabled(){return this.enabled&&(this.context?.toolOptions.tooltips.effectiveEnabled||this.keepTooltipAliveEvenWhenTooltipsAreNotEnabled)}getConstraints(e){let{tooltipInfo:t,context:n}=this,{view:r,editGeometryOperations:i,elevationInfo:a,toolOptions:o}=n??{},s=this.getLastScreenPosition?.();if(!s||!r||!t||!i||!o)return null;let{coordinateHelper:c,spatialReference:l}=i.data,u=r.toMap(s);if(!u)return null;let d=_(u,r,l,a??h,c.hasZ(),o.values.effectiveDirectionMode);return{...H(t.getConstraintFieldsForHandle(e)),context:d}}storeConstraintSnapshot(){let e=I(this.allFields,this.focusedHandle).map(({field:e})=>e).filter(e=>e.locked&&!e.unlockOnVertexPlacement).filter(L);this._constraintSnapshot=e.length?H(e):null}unlockOnVertexPlacement(){this.tooltipInfo?.allFields.forEach(e=>{e.unlockOnVertexPlacement&&(e.committed=null)})}unregisterPluginFields(e){let t=this._pluginTooltipFieldRegistry.get(e);t?.forEach(e=>e.destroy()),t?.clear(),this._pluginTooltipFieldRegistry.delete(e)}createMeasuredField(e,{id:t,preset:n,getMeasurementInput:r,measure:i,fieldProperties:a,fieldFilters:o}){let c=this._getOrCreateField(e,t,n,a,o);return c.registerMeasurement(r,i,()=>this.tooltipInfo?.renderContext),c.addHandles(s(()=>this.tooltipInfo?.isEffectiveVisibleField(c.field),e=>c.enabled=!!e,l)),c}createCustomField(e,{id:t,preset:n,fieldProperties:r,fieldFilters:i}){return this._getOrCreateField(e,t,n,r,i)}_setupTooltip(e){let t=this._tooltip=v(()=>({view:e.view,options:e.toolOptions.tooltips,info:this.tooltipInfo}));t.addHandles([s(()=>this.focusedHandle,e=>{(e&&(!t.isInInputMode||this.inputModeHandle==null)||this.inputModeHandle&&!this.allHandles?.includes(this.inputModeHandle))&&(this.inputModeHandle=e)},c),s(()=>this.focusedHandle?.screenPosition,e=>{e?(t.position=e,t.hidden=!1):t.hidden=!0},c),t.on(`commit`,()=>{this.context?.notifyTooltipsChanged()})]),!this._coordinateFormatterLoadTask&&!p()&&(this._coordinateFormatterLoadTask=n(()=>m()),this.addHandles(this._coordinateFormatterLoadTask),this._updatingHandles.addPromise(this._coordinateFormatterLoadTask.promise))}_getOrCreateField(e,t,n,r,a){let s=i(this._pluginTooltipFieldRegistry,e,()=>new o);if(s.has(t))return s.get(t);let c=V(n,r),l=new g({field:c,displayGroup:r?.displayGroup,...a});s.set(t,l);let u=L(c)?this._constraintSnapshot?.[c.name]:void 0;return u&&c.lock(u),l}};e([u()],R.prototype,`_updatingHandles`,void 0),e([u()],R.prototype,`_tooltip`,void 0),e([u()],R.prototype,`_tooltipInfo`,void 0),e([u()],R.prototype,`_coordinateFormatterLoadTask`,void 0),e([u()],R.prototype,`_constraintSnapshot`,void 0),e([u()],R.prototype,`getDependencies`,void 0),e([u()],R.prototype,`getLastScreenPosition`,void 0),e([u()],R.prototype,`context`,null),e([u()],R.prototype,`inputModeHandle`,void 0),e([u()],R.prototype,`focusedHandle`,null),e([u()],R.prototype,`allHandles`,null),e([u()],R.prototype,`effectiveActiveHandle`,null),e([u()],R.prototype,`updating`,null),e([u()],R.prototype,`tooltip`,null),e([u()],R.prototype,`tooltipInfo`,null),e([u()],R.prototype,`constraintsEnabled`,void 0),e([u()],R.prototype,`elevationConstraint`,null),e([u()],R.prototype,`allFields`,null),e([u()],R.prototype,`keepTooltipAliveEvenWhenTooltipsAreNotEnabled`,void 0),e([u()],R.prototype,`enabled`,void 0),e([u()],R.prototype,`effectiveEnabled`,null),R=e([d(`esri.views.draw.support.managers.TooltipManager`)],R);function z(e){return e==null||!(`unit`in e)||!(`rotationType`in e)?null:e}function B(e){return e==null||`rotationType`in e?null:e}function V(e,t){let n=t?{...t}:{};switch(delete n.displayGroup,e){case`area`:return x({...n,name:`area`});case`direction`:return N({...n,name:`direction`});case`distance`:return M({...n,name:`distance`});case`elevation`:{let e=j({...n,name:`elevation`});return e.showAsZ=!0,e}case`latitude`:return A({...n,name:`y`});case`longitude`:return k({...n,name:`x`});case`x`:return O({...n,name:`x`});case`y`:return D({...n,name:`y`});case`orientation`:return b({...n,name:`orientation`});case`scale`:return E({...n,name:`scale`});case`size`:return T({...n,name:`size`});case`totalLength`:return w({...n,name:`totalLength`});case`radius`:return C({...n,name:`radius`});case`generic-length`:return S({...n,name:null});case`generic-area`:return x({...n,name:null});case`generic-angle`:return b({...n,name:null});case`generic-scalar`:return y({...n,name:null});default:if(!n)throw new r(`draw-tool:tooltips:invalid-field-config`,`Attempted to create a tooltip without a preset definition and without tooltip configuration.`);return new P(n)}}function H(e){let t={};for(let n of e)switch(n.name){case`direction`:t[n.name]=n.committed;break;case`distance`:case`elevation`:t[n.name]=n.committed;break;case`x`:t[n.name]=B(n.committed),t.longitude=z(n.committed);break;case`y`:t[n.name]=B(n.committed),t.latitude=z(n.committed)}return t}export{R as TooltipManager};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{handlesGroup as e}from"../../../core/handleUtils.js";import{CurveSnappingHint as t}from"./hints/CurveSnappingHint.js";import{IntersectionSnappingHint as n}from"./hints/IntersectionSnappingHint.js";import{LineSnappingHint as r}from"./hints/LineSnappingHint.js";import{ParallelSnappingHint as i}from"./hints/ParallelSnappingHint.js";import{PointSnappingHint as a}from"./hints/PointSnappingHint.js";import{RightAngleSnappingHint as o}from"./hints/RightAngleSnappingHint.js";class s{draw(s,l){let u=c(s),d=this.sortUniqueHints(u),f=[];for(let e of d)e instanceof n&&f.push(this.visualizeIntersectionPoint(e,l)),e instanceof r&&f.push(this.visualizeLine(e,l)),e instanceof t&&f.push(this.visualizeCurve(e,l)),e instanceof i&&f.push(this.visualizeParallelSign(e,l)),e instanceof o&&f.push(this.visualizeRightAngleQuad(e,l)),e instanceof a&&f.push(this.visualizePoint(e,l));return e(f)}sortUniqueHints(e){return e}}function c(e){let t=[];for(let n of e){let e=!0;for(let r of t)if(n.equals(r)){e=!1;break}e&&t.push(n)}return t}export{s as SnappingVisualizer};
2
+ import{handlesGroup as e}from"../../../core/handleUtils.js";import{CurveSnappingHint as t}from"./hints/CurveSnappingHint.js";import{IntersectionSnappingHint as n}from"./hints/IntersectionSnappingHint.js";import{LineSnappingHint as r}from"./hints/LineSnappingHint.js";import{ParallelSnappingHint as i}from"./hints/ParallelSnappingHint.js";import{PointSnappingHint as a}from"./hints/PointSnappingHint.js";import{RightAngleSnappingHint as o}from"./hints/RightAngleSnappingHint.js";class s{draw(s,l){let u=c(s),d=this.sortUniqueHints(u),f=[];for(let e=0;e<d.length;++e){let s=d[e];s instanceof n&&f.push(this.visualizeIntersectionPoint(s,l,e)),s instanceof r&&f.push(this.visualizeLine(s,l,e)),s instanceof t&&f.push(this.visualizeCurve(s,l,e)),s instanceof i&&f.push(this.visualizeParallelSign(s,l,e)),s instanceof o&&f.push(this.visualizeRightAngleQuad(s,l,e)),s instanceof a&&f.push(this.visualizePoint(s,l,e))}return e(f)}sortUniqueHints(e){return e}}function c(e){let t=[];for(let n of e){let e=!0;for(let r of t)if(n.equals(r)){e=!1;break}e&&t.push(n)}return t}export{s as SnappingVisualizer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{SketchTooltipInfo as i}from"./SketchTooltipInfo.js";let a=class extends i{constructor(e){super(e),this.type=`dynamic`,this.renderContext=null,this.helpMessage=void 0,this._isVisibleField=e=>{if(!e.visible)return!1;let t=e.name;switch(t){case`x`:case`y`:return this.visibleElements.coordinates;default:return this.visibleElements[t]??!0}}}initialize(){this.addHandles(t(()=>this.getHelpMessageKey?.(),e=>this.helpMessage=e??void 0))}get availableFields(){return this.getAllFields?.()?.map(e=>e.field)??[]}get availableFieldsForCurrentHandle(){let e=this.getAllFields?.(),t=this.getActiveHandle?.();return l(e??[],t)}get allManagedFields(){let{availableFieldsForCurrentHandle:e}=this,t=this.getActiveHandle?.(),n=this._getXyMode(t);return(this._useCoordinateDisplay(t,n)?e.filter(e=>s(e.field)):this._useDirectionDistanceDisplay(t,n)?e.filter(e=>c(e.field)):e).filter(e=>this._isVisibleField(e.field)).sort((e,t)=>o(e.field,t.field))}get fieldsGroupedForDisplay(){let e=this.allManagedFields,t=new Map,n=[];for(let n of e){let e=n.displayGroup;t.has(e)||t.set(e,[]),t.get(e)?.push(n)}for(let[e,r]of t.entries())if(r.length!==2||!e)n.push(...r.map(e=>e.field));else{let e=r.toSorted((e,t)=>o(e.field,t.field));n.push({left:e[0].field,right:e[1].field})}return n}get xyMode(){return this._getXyMode(this.getActiveHandle?.())}get allFields(){return this.allManagedFields.map(e=>e.field)}getConstraintFieldsForHandle(e){let t=this.getAllFields?.(),n=this._getXyMode(e),r=l(t??[],e).map(e=>e.field).filter(u);return(this._useCoordinateDisplay(e,n)?r.filter(s):this._useDirectionDistanceDisplay(e,n)?r.filter(c):r).filter(this._isVisibleField)}getConstraintFieldByName(e,t){return this.getConstraintFieldsForHandle(e).find(e=>e.name===t)}isEffectiveVisibleField(e){let{allFields:t,renderContext:n}=this;return e.visible&&!!n&&t.includes(e)}_getXyMode(e){let t=this.toolOptions.tooltips.xyMode,n=e?.editSession?.endVertex?.leftSegment?.leftVertex&&e?.role===`primary`?`direction-distance`:`coordinates`;return t===`auto`?n:t}_useCoordinateDisplay(e,t){let{availableFields:n}=this;return(t===`coordinates`||e?.role===`secondary`)&&n.some(e=>e.name===`x`)&&n.some(e=>e.name===`y`)}_useDirectionDistanceDisplay(e,t){let{availableFields:n}=this;return t===`direction-distance`&&e?.role===`primary`&&n.some(e=>e.name===`distance`)&&n.some(e=>e.name===`direction`)}};e([n()],a.prototype,`type`,void 0),e([n()],a.prototype,`getAllFields`,void 0),e([n()],a.prototype,`getActiveHandle`,void 0),e([n()],a.prototype,`getHelpMessageKey`,void 0),e([n()],a.prototype,`availableFields`,null),e([n()],a.prototype,`availableFieldsForCurrentHandle`,null),e([n()],a.prototype,`allManagedFields`,null),e([n()],a.prototype,`fieldsGroupedForDisplay`,null),e([n()],a.prototype,`xyMode`,null),e([n()],a.prototype,`allFields`,null),e([n()],a.prototype,`renderContext`,void 0),e([n()],a.prototype,`helpMessage`,void 0),a=e([r(`esri.views.interactive.tooltip.infos.DynamicTooltipInfo`)],a);function o(e,t){return e.displayOrder-t.displayOrder}function s(e){return e.name!==`direction`&&e.name!==`distance`}function c(e){return e.name!==`x`&&e.name!==`y`}function l(e,t){let{name:n,role:r}=t??{};return e?.filter(e=>(e.appliesToHandlesWithName==null||e.appliesToHandlesWithName===n)&&(e.appliesToHandlesWithRole==null||e.appliesToHandlesWithRole===r))??[]}function u(e){switch(e.name){case`direction`:case`distance`:case`elevation`:case`x`:case`y`:return!0;default:return!1}}export{a as DynamicTooltipInfo,u as isKnownConstraintField};
2
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{SketchTooltipInfo as i}from"./SketchTooltipInfo.js";let a=class extends i{constructor(e){super(e),this.type=`dynamic`,this.renderContext=null,this.helpMessage=void 0,this._isVisibleField=e=>{if(!e.visible)return!1;let t=e.name;switch(t){case`x`:case`y`:return this.visibleElements.coordinates;default:return this.visibleElements[t]??!0}}}initialize(){this.addHandles(t(()=>this.getHelpMessageKey?.(),e=>this.helpMessage=e??void 0))}get availableFields(){return this.getAllFields?.()?.map(e=>e.field)??[]}get availableFieldsForCurrentHandle(){let e=this.getAllFields?.(),t=this.getActiveHandle?.();return l(e??[],t)}get allManagedFields(){let{availableFieldsForCurrentHandle:e}=this,t=this.getActiveHandle?.(),n=this._getXyMode(t);return(this._useCoordinateDisplay(t,n)?e.filter(e=>s(e.field)):this._useDirectionDistanceDisplay(t,n)?e.filter(e=>c(e.field)):e).filter(e=>this._isVisibleField(e.field)).sort((e,t)=>o(e.field,t.field))}get fieldsGroupedForDisplay(){let e=this.allManagedFields,t=new Map,n=[];for(let n of e){let e=n.displayGroup;t.has(e)||t.set(e,[]),t.get(e)?.push(n)}for(let[e,r]of t.entries())if(r.length!==2||!e)n.push(...r.map(e=>e.field));else{let e=r.toSorted((e,t)=>o(e.field,t.field));n.push({left:e[0].field,right:e[1].field})}return n}get xyMode(){return this._getXyMode(this.getActiveHandle?.())}get allFields(){return this.allManagedFields.map(e=>e.field)}getConstraintFieldsForHandle(e){let t=this.getAllFields?.(),n=this._getXyMode(e),r=l(t??[],e).map(e=>e.field).filter(u);return(this._useCoordinateDisplay(e,n)?r.filter(s):this._useDirectionDistanceDisplay(e,n)?r.filter(c):r).filter(this._isVisibleField)}getConstraintFieldByName(e,t){return this.getConstraintFieldsForHandle(e).find(e=>e.name===t)}isEffectiveVisibleField(e){let{allFields:t,renderContext:n}=this;return e.visible&&!!n&&t.includes(e)}_getXyMode(e){let t=this.toolOptions.tooltips.xyMode,n=e?.editSession?.endVertex?.leftSegment?.leftVertex&&e?.role===`primary`?`direction-distance`:`coordinates`;return t===`auto`?n:t}_useCoordinateDisplay(e,t){let{availableFields:n}=this;return(t===`coordinates`||e?.role===`secondary`)&&n.some(e=>e.name===`x`)&&n.some(e=>e.name===`y`)}_useDirectionDistanceDisplay(e,t){let{availableFields:n}=this;return t===`direction-distance`&&e?.role===`primary`&&n.some(e=>e.name===`distance`)&&n.some(e=>e.name===`direction`)}};e([n()],a.prototype,`type`,void 0),e([n()],a.prototype,`getAllFields`,void 0),e([n()],a.prototype,`getActiveHandle`,void 0),e([n()],a.prototype,`getHelpMessageKey`,void 0),e([n()],a.prototype,`availableFields`,null),e([n()],a.prototype,`availableFieldsForCurrentHandle`,null),e([n()],a.prototype,`allManagedFields`,null),e([n()],a.prototype,`fieldsGroupedForDisplay`,null),e([n()],a.prototype,`xyMode`,null),e([n()],a.prototype,`allFields`,null),e([n()],a.prototype,`renderContext`,void 0),e([n()],a.prototype,`helpMessage`,void 0),a=e([r(`esri.views.interactive.tooltip.infos.DynamicTooltipInfo`)],a);function o(e,t){return e.displayOrder-t.displayOrder}function s(e){return e.name!==`direction`&&e.name!==`distance`}function c(e){return e.name!==`x`&&e.name!==`y`}function l(e,t){let{name:n,role:r}=t??{};return e?.filter(e=>(e.appliesToHandlesWithName==null||e.appliesToHandlesWithName===n)&&(e.appliesToHandlesWithRole==null||e.appliesToHandlesWithRole===r))??[]}function u(e){switch(e.name){case`direction`:case`distance`:case`elevation`:case`x`:case`y`:return!0;default:return!1}}export{a as DynamicTooltipInfo,l as filterFieldsForHandle,u as isKnownConstraintField};