@arcgis/core 4.33.0-next.20250304 → 4.33.0-next.20250305

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 (54) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{e99d7ecb80a9df9ead6d.js → 1e7a70a1871fea29169e.js} +3 -3
  3. package/assets/esri/core/workers/chunks/{618016fc1165bcfc2b0d.js → 42b862550c96cc1be956.js} +7 -9
  4. package/assets/esri/core/workers/chunks/4403b3f08907e88d0d91.js +1 -0
  5. package/assets/esri/core/workers/chunks/{0e2d9cd4e8ee5a62b05c.js → 45eee326f7a649c5a15b.js} +7 -9
  6. package/assets/esri/core/workers/chunks/e3e049311bced533c853.js +1 -0
  7. package/assets/esri/core/workers/chunks/f4111bb5e5a4910b684a.js +1 -0
  8. package/chunks/Clouds.glsl.js +19 -23
  9. package/chunks/ImageMaterial.glsl.js +1 -1
  10. package/core/Accessor.js +1 -1
  11. package/core/accessorSupport/decorators/subclass.js +1 -1
  12. package/core/accessorSupport/interfaces.js +1 -1
  13. package/interfaces.d.ts +8 -4
  14. package/layers/mixins/ArcGISImageService.js +1 -1
  15. package/layers/support/featureLayerUtils.js +1 -1
  16. package/package.json +1 -1
  17. package/request.js +1 -1
  18. package/rest/support/IdentifyParameters.js +1 -1
  19. package/support/revision.js +1 -1
  20. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  21. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  22. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  23. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  24. package/views/3d/environment/Clouds.glsl.js +1 -1
  25. package/views/3d/environment/CloudsParameters.js +1 -1
  26. package/views/3d/environment/CloudsRenderer.js +1 -1
  27. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  28. package/views/3d/layers/MediaLayerView3D.js +1 -1
  29. package/views/3d/layers/support/FeatureTile.js +1 -1
  30. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  31. package/views/3d/support/StreamTextureCollection.js +1 -1
  32. package/views/3d/support/TextureCollection.js +1 -1
  33. package/views/3d/terrain/TerrainRenderer.js +1 -1
  34. package/views/3d/terrain/TerrainSurface.js +1 -1
  35. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +7 -7
  36. package/views/3d/webgl-engine/core/shaderLibrary/util/DoublePrecision.glsl.js +5 -7
  37. package/views/3d/webgl-engine/core/shaderLibrary/util/LookupCloudsFromTextureArray.glsl.js +51 -0
  38. package/views/3d/webgl-engine/lib/GLMaterialParameters.js +5 -0
  39. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  40. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  41. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  42. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  43. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  44. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  45. package/views/animation/pointToPoint/apex/planning.js +1 -1
  46. package/views/webgl/FramebufferObject.js +1 -1
  47. package/views/webgl/TextureDescriptor.js +1 -1
  48. package/widgets/FeatureForm/FieldInput.js +1 -1
  49. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  50. package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
  51. package/assets/esri/core/workers/chunks/04341d50082f864025aa.js +0 -1
  52. package/assets/esri/core/workers/chunks/10118666a5a5b141ece6.js +0 -1
  53. package/assets/esri/core/workers/chunks/64d3e683872791eb6ae9.js +0 -1
  54. package/views/3d/webgl-engine/core/shaderLibrary/util/LookupCubemapFromTextureArray.glsl.js +0 -39
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{lengthDimensionMeasureType as t,LengthDimensionMeasureType as r}from"../../../../analysis/dimensionUtils.js";import{cyclicalDegrees as n}from"../../../../core/Cyclical.js";import{rad2deg as i}from"../../../../core/mathUtils.js";import{watch as o,initial as a}from"../../../../core/reactiveUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{identity as c,scale as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as d,c as u,d as p,e as f,f as g,p as h,l as v,i as y,a as w}from"../../../../chunks/vec32.js";import{create as S,ZEROS as j,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import H from"../../../../geometry/Point.js";import{fromPositionAndNormal as M,create as P,signedDistance as C,getNormal as T}from"../../../../geometry/support/plane.js";import{sv3d as O}from"../../../../geometry/support/vectorStacks.js";import{clonePoint as U}from"../../../../layers/graphics/hydratedFeatures.js";import{isValidComputation as R,computeGeometryFromDimension as z,computationToGeometryDependencies as A,headingFromGeometry as D,computeOffsetForPoint as _,computeSegmentForMeasureType as F,computeOffsetAxis as L,directUp as k,directStartToEnd as E,dimensionStartToEnd as I}from"./lengthDimensionUtils.js";import{getTransparentAccentColor as G,pointRadius as B,lengthFraction as N,markerLineSizeFraction as V,orientationCalloutOffsetPx as W,orientationCalloutWidth as q,orientationDiscScale as J,orientationFocusMultiplier as K,orientationSnapThresholdDegrees as Q,minLengthMeters as X,linePaddingPx as Y,focusedLinePaddingPx as Z}from"./settings.js";import{Manipulator3D as $}from"../../interactive/Manipulator3D.js";import{createManipulatorMaterial as ee,worldScaledManipulatorSettings as te,calculateInputRotationTransform as re,calculateTranslateRotateFromBases as ne,rotateManipulatorDefaults as ie}from"../../interactive/manipulatorUtils.js";import{RenderObject as oe}from"../../interactive/RenderObject.js";import{screenToMap3D as ae,screenToRenderPlane as se,hideManipulatorWhileDragging as ce}from"../../interactive/editingTools/dragEventPipeline3D.js";import{EuclideanSegment as le}from"../../interactive/visualElements/support/Segment.js";import{markerSizePerLineWidth as me}from"../../support/engineContent/marker.js";import{Attribute as de}from"../../webgl-engine/lib/Attribute.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{createSphereGeometry as pe,createPolylineGeometry as fe}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as ge}from"../../webgl-engine/lib/Material.js";import{VertexAttribute as he}from"../../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as ve}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as ye}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createManipulatorDragEventPipeline as we,resetProperties as Se,EventPipeline as je}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as xe,ManipulatorStateFlags as be}from"../../../interactive/interfaces.js";class He{constructor(e){this.start=e.start,this.end=e.end,this.offset=e.offset,this.heading=e.heading,this.rotation=e.rotation,this.direct=e.direct,this.horizontal=e.horizontal,this.vertical=e.vertical}manipulatorName(e){return Object.keys(this).find((t=>this.hasOwnProperty(t)&&e===this[t]))}values(){return[this.start,this.end,this.offset,this.heading,this.rotation,this.direct,this.horizontal,this.vertical]}forEachMeasureTypeManipulator(e){for(const r of t)e(this.manipulatorForMeasureType(r),r)}manipulatorForMeasureType(e){switch(e){case r.Direct:return this.direct;case r.Horizontal:return this.horizontal;case r.Vertical:return this.vertical}}}class Me extends ${constructor(t,r){const n=ee(e.toUnitRGBA(G(t.effectiveTheme))),i=[new oe(pe(n,1,32,32),tt)];super({view:t,renderObjects:i,metadata:r.metadata,available:!1,grabCursor:"crosshair",radius:B,collisionPriority:1}),this._themeHandle=o((()=>({color:e.toUnitRGBA(G(t.effectiveTheme))})),(e=>n.setParameters(e)))}destroy(){this._themeHandle.remove(),super.destroy()}}function Pe(e,t){const r=[x(-.5,0,0),x(.5,0,0)],n=fe(t.unfocusedMaterial,r.map((e=>d(S(),e,N)))),i=n.instantiate({material:t.focusedMaterial});return new $({view:e,renderObjects:[new oe(n,be.Unfocused|be.Selected|tt),new oe(i,be.Focused|tt)],collisionType:{type:"line",paths:[r]},radius:$e(t.lineSizePt)/2,metadata:t.metadata,available:!1,...te})}class Ce extends ${constructor(t,{lineSizePt:r,material:n,metadata:i}){super({view:t,autoScaleRenderObjects:!1,collisionPriority:1,metadata:i}),this._options={calloutColor:b(),lineSizePt:r,material:n},this._themeHandle=o((()=>e.toUnitRGBA(G(t.effectiveTheme))),(e=>{this._options.calloutColor=e,et(this,Te({...this._options,metadata:this.metadata}))}),a)}update({lineSizePt:e,material:t}){this._options.lineSizePt=e,this._options.material=t,et(this,Te({...this._options,metadata:this.metadata}))}destroy(){this._themeHandle.remove(),super.destroy()}}function Te({calloutColor:e,lineSizePt:t,material:r,metadata:n}){return{calloutLength:.25*me*V*s(t)+W,calloutColor:e,calloutWidth:q,customStateMask:tt,discScale:J,focusMultiplier:K,material:r,metadata:n}}function Oe(e,t){const r=[x(-.5,0,0),x(.5,0,0)],n=fe(t.thinOffsetManipulatorMaterial,r),i=fe(t.unfocusedMaterial,r.map((e=>d(S(),e,N)))),o=i.instantiate({material:t.focusedMaterial});return new $({view:e,renderObjects:[new oe(i,be.Unfocused|tt),new oe(o,be.Focused|tt),new oe(n,tt)],collisionType:{type:"line",paths:[r]},radius:$e(t.lineSizePt)/2,available:!1,metadata:t.metadata,...te})}function Ue(e,{isStart:t,createSnappingPipelineStep:r,dimension:n,onUpdate:i,view:o}){const a=t?"startPoint":"endPoint",s=we(e,((e,t,s,c)=>{const l=ce(e),{snappingStep:m,cancelSnapping:d}=r(c);s=s.next(l).next(Se(n,[a,"measureType","orientation"])).next(d),t.next(l).next(ae(o)).next(...m).next((e=>{const t=U(e.mapEnd,new H);i("startPoint"===a?{startPoint:t}:{endPoint:t})}))}));return[s]}function Re(e,{computation:t,view:r}){return[we(e,((e,n,i)=>{if(!R(t)||!e.selected)return;const{geometry:o,dimension:a}=t,s=ce(e);n.next(s).next(ke(r,a,o.dimensionSegment,o.primaryOffsetAxis)),i.next(s).next(Se(a,["offset"]))}))]}function ze(e,{computation:t,view:r}){return[we(e,((e,n,i)=>{_e({cancel:i,computation:t,settingHeading:!0,steps:n,view:r})}))]}function Ae(e,{computation:t,view:r}){return[we(e,((e,n,i)=>{_e({cancel:i,computation:t,settingHeading:!1,steps:n,view:r})})),e.events.on("immediate-click",(e=>{De(e,t,r)}))]}function De(e,t,r){const{dimension:i,geometry:o}=t;if(90===i.orientation||270===i.orientation)return i.orientation=0,void e.stopPropagation();if(null==o)return;const{renderCoordsHelper:a}=r,s=z({...A(t),orientation:90},a),c=z({...A(t),orientation:270},a);if(null==s||null==c)return;const l=D(s,a),m=D(c,a),d=Ee(o,r),u=n.shortestSignedDiff(d,l),p=n.shortestSignedDiff(d,m);i.orientation=Math.abs(u)<Math.abs(p)?90:270,e.stopPropagation()}function _e(e){const{cancel:t,computation:r,settingHeading:n,steps:o,view:a}=e;if(!R(r))return;const{renderCoordsHelper:s}=a,{dimension:c,geometry:l}=r,m=S(),d=Je(S(),l,l.directSegment,s),p=Ke(O.get(),{forHeading:n,geometry:l,renderCoordsHelper:s}),f=M(d,p,P()),g=n?c.orientation??D(l,a.renderCoordsHelper):c.orientation??0;o.next(se(a,f)).next((e=>{"start"===e.action&&u(m,e.renderStart);const t=T(f),r=re(m,e.renderEnd,d,t);let o=g-i(r);n||(o=Fe(o)),c.orientation=o})),t.next(Se(c,["orientation"]))}function Fe(e){const t=n.normalize(e)%90;return t<Q?e-t:90-t<Q?e+(90-t):e}function Le(e,{computation:t,manipulatorMeasureType:n,view:i}){let o=r.Direct,a=0,s=0;return[e.events.on("grab-changed",(r=>{if("start"!==r.action||!R(t))return;const{dimension:c,geometry:l}=t;o=c.measureType,a=c.offset,s=c.orientation;const m=u(O.get(),e.renderLocation);c.measureType=n,c.offset=_(m,n,l,i.renderCoordsHelper),c.orientation=0})),we(e,((e,r,c)=>{if(!R(t))return;const{geometry:l,dimension:m}=t,{renderCoordsHelper:d}=i,u=F(ot,n,t,d),p=L(O.get(),{measureType:n,directSegment:l.directSegment,renderCoordsHelper:d}),f=ce(e);r.next(f).next(ke(i,m,u,p)),c.next(f).next((e=>(m.measureType=o,m.offset=a,m.orientation=s,e)))}))]}function ke(e,t,r,n){const i=p(O.get(),r.endRenderSpace,r.startRenderSpace);f(i,i,n);const o=M(r.startRenderSpace,i,P()),a=M(r.startRenderSpace,n,P()),s=t.offset;let c,l=0;const m=new je;return m.next(se(e,o)).next((r=>{"start"===r.action&&(l=C(a,r.renderStart));const n=(C(a,r.renderEnd)-l)*e.renderCoordsHelper.unitInMeters;t.offset=s+n,c=r})),e=>(m.execute(e),c)}function Ee(e,t){const{directSegment:r}=e,{renderCoordsHelper:n}=t,i=k(O.get(),e,n),o=E(O.get(),e),a=f(O.get(),o,i),{viewForward:s}=t.state.camera;g(a,s)>0&&d(a,a,-1);const c=r.eval(.5,O.get());return n.headingAtPosition(c,a)}function Ie(e,t,r){const{dimensionSegment:n,primaryOffsetAxis:i}=t,o=I(rt,t),a=h(o,j)?c(it):ne(o,i,j,it),s=Math.max(v(o),X/r.unitInMeters);l(a,a,y(rt,s,s,s)),e.modelTransform=a,e.renderLocation=n.eval(.5,rt)}function Ge(e,t,r){Ne(e,t,r,{forHeading:!0})}function Be(e,t,r){Ne(e,t,r,{forHeading:!1})}function Ne(e,t,r,{forHeading:n}){const{dimension:i,geometry:o}=t,{primaryOffsetAxis:a}=o,s=d(Ve,a,i.offset>=0?1:-1),c=Ke(We,{forHeading:n,geometry:o,renderCoordsHelper:r});f(c,c,s);const l=ne(s,c,j,it);e.modelTransform=l,e.renderLocation=Je(rt,o,o.dimensionSegment,r)}const Ve=S(),We=S();function qe(e,t,r,n){const{geometry:i}=t,o=F(ot,r,t,n),a=L(rt,{measureType:r,directSegment:i.directSegment,renderCoordsHelper:n}),s=w(nt,o.endRenderSpace,o.startRenderSpace),c=ne(s,a,j,it),m=v(s);l(c,c,y(nt,m,m,m)),e.modelTransform=c,e.renderLocation=o.eval(.5,nt)}function Je(e,t,r,n){const{startRenderSpace:i,endRenderSpace:o}=r,a=Qe(t,n)?i:o;return u(e,a)}function Ke(e,{forHeading:t,geometry:r,renderCoordsHelper:n}){return t?k(e,r,n):I(e,r,{invert:!0})}function Qe(e,t){const r=E(Xe,e),n=k(Ye,e,t);return g(r,n)>0}const Xe=S(),Ye=S();function Ze(e){return s(e)+Y}function $e(e){return s(e)+Z}function et(e,t){const r=t.material??new ve({writeDepth:!1,textureId:t.texture?.id,renderOccluded:ge.Opaque,isDecoration:!0}),n=t.focusMultiplier??ie.focusMultiplier,i=t.calloutLength??ie.calloutLength,o=ie.discRadius*(t.discScale??1),a=o*n,s=(e,t)=>{const r=[0,1,2,2,3,0];return new ue(t,[[he.POSITION,new de([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],[he.UV0,new de([0,0,1,0,1,1,0,1],r,2,!0)]])},c=t.calloutWidth??ie.calloutWidth,l=new ye({width:c,color:t.calloutColor,renderOccluded:ge.OccludeAndTransparent,isDecoration:!0}),m=fe(l,[[0,0,0],[i-o,0,0]]),d=fe(l,[[0,0,0],[i-a,0,0]]),u=t.customStateMask??xe.None;e.collisionType={type:"disc",direction:[0,0,1],offset:[i,0,0]},e.focusMultiplier=n,e.metadata=t.metadata,e.radius=o,e.renderObjects=[new oe(s(o,r),be.Unfocused|u),new oe(m,be.Unfocused|u),new oe(s(a,r),be.Focused|u),new oe(d,be.Focused|u)]}const tt=xe.Custom1,rt=S(),nt=S(),it=m(),ot=new le;export{tt as DidPointerMoveRecentlyFlag,He as LengthDimensionManipulators,Me as LengthDimensionPointManipulator,Ce as LineOfSightOrientationManipulator,Ee as automaticHeadingFromCamera,Oe as createMeasureTypeManipulator,Pe as createOffsetManipulator,$e as focusedOffsetWidth,ze as headingManipulatorHandles,Le as measureTypeManipulatorHandles,Re as offsetManipulatorHandles,Ue as pointManipulatorHandles,Ae as rotationManipulatorHandles,Fe as snapOrientationToNearestRightAngle,Ze as unfocusedOffsetWidth,Ge as updateHeadingManipulatorTransform,qe as updateMeasureTypeManipulatorTransform,Ie as updateOffsetManipulatorTransform,Be as updateRotationManipulatorTransform};
5
+ import e from"../../../../Color.js";import{lengthDimensionMeasureType as t,LengthDimensionMeasureType as r}from"../../../../analysis/dimensionUtils.js";import{cyclicalDegrees as n}from"../../../../core/Cyclical.js";import{rad2deg as i}from"../../../../core/mathUtils.js";import{watch as o,initial as a}from"../../../../core/reactiveUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{identity as c,scale as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as d,c as u,d as p,e as f,f as g,p as h,l as v,i as y,a as w}from"../../../../chunks/vec32.js";import{create as S,ZEROS as j,fromValues as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import H from"../../../../geometry/Point.js";import{fromPositionAndNormal as M,create as P,signedDistance as C,getNormal as T}from"../../../../geometry/support/plane.js";import{sv3d as O}from"../../../../geometry/support/vectorStacks.js";import{clonePoint as U}from"../../../../layers/graphics/hydratedFeatures.js";import{isValidComputation as R,computeGeometryFromDimension as z,computationToGeometryDependencies as A,headingFromGeometry as _,computeOffsetForPoint as D,computeSegmentForMeasureType as F,computeOffsetAxis as L,directUp as k,directStartToEnd as E,dimensionStartToEnd as G}from"./lengthDimensionUtils.js";import{getTransparentAccentColor as I,pointRadius as B,lengthFraction as N,markerLineSizeFraction as V,orientationCalloutOffsetPx as W,orientationCalloutWidth as q,orientationDiscScale as J,orientationFocusMultiplier as K,orientationSnapThresholdDegrees as Q,minLengthMeters as X,linePaddingPx as Y,focusedLinePaddingPx as Z}from"./settings.js";import{Manipulator3D as $}from"../../interactive/Manipulator3D.js";import{createManipulatorMaterial as ee,worldScaledManipulatorSettings as te,calculateInputRotationTransform as re,calculateTranslateRotateFromBases as ne,rotateManipulatorDefaults as ie}from"../../interactive/manipulatorUtils.js";import{RenderObject as oe}from"../../interactive/RenderObject.js";import{screenToMap3D as ae,screenToRenderPlane as se,hideManipulatorWhileDragging as ce}from"../../interactive/editingTools/dragEventPipeline3D.js";import{EuclideanSegment as le}from"../../interactive/visualElements/support/Segment.js";import{markerSizePerLineWidth as me}from"../../support/engineContent/marker.js";import{Attribute as de}from"../../webgl-engine/lib/Attribute.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{createSphereGeometry as pe,createPolylineGeometry as fe}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as ge}from"../../webgl-engine/lib/Material.js";import{VertexAttribute as he}from"../../webgl-engine/lib/VertexAttribute.js";import{RibbonLineMaterial as ve}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{createManipulatorDragEventPipeline as ye,resetProperties as we,EventPipeline as Se}from"../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as je,ManipulatorStateFlags as be}from"../../../interactive/interfaces.js";class xe{constructor(e){this.start=e.start,this.end=e.end,this.offset=e.offset,this.heading=e.heading,this.rotation=e.rotation,this.direct=e.direct,this.horizontal=e.horizontal,this.vertical=e.vertical}manipulatorName(e){return Object.keys(this).find((t=>this.hasOwnProperty(t)&&e===this[t]))}values(){return[this.start,this.end,this.offset,this.heading,this.rotation,this.direct,this.horizontal,this.vertical]}forEachMeasureTypeManipulator(e){for(const r of t)e(this.manipulatorForMeasureType(r),r)}manipulatorForMeasureType(e){switch(e){case r.Direct:return this.direct;case r.Horizontal:return this.horizontal;case r.Vertical:return this.vertical}}}class He extends ${constructor(t,r){const n=ee(e.toUnitRGBA(I(t.effectiveTheme))),i=[new oe(pe(n,1,32,32),et)];super({view:t,renderObjects:i,metadata:r.metadata,available:!1,grabCursor:"crosshair",radius:B,collisionPriority:1}),this._themeHandle=o((()=>({color:e.toUnitRGBA(I(t.effectiveTheme))})),(e=>n.setParameters(e)))}destroy(){this._themeHandle.remove(),super.destroy()}}function Me(e,t){const r=[b(-.5,0,0),b(.5,0,0)],n=fe(t.unfocusedMaterial,r.map((e=>d(S(),e,N)))),i=n.instantiate({material:t.focusedMaterial});return new $({view:e,renderObjects:[new oe(n,be.Unfocused|be.Selected|et),new oe(i,be.Focused|et)],collisionType:{type:"line",paths:[r]},radius:Ze(t.lineSizePt)/2,metadata:t.metadata,available:!1,...te})}class Pe extends ${constructor(t,{lineSizePt:r,material:n,metadata:i}){super({view:t,autoScaleRenderObjects:!1,collisionPriority:1,metadata:i}),this._options={calloutColor:x(),lineSizePt:r,material:n},this._themeHandle=o((()=>e.toUnitRGBA(I(t.effectiveTheme))),(e=>{this._options.calloutColor=e,$e(this,Ce({...this._options,metadata:this.metadata}))}),a)}update({lineSizePt:e,material:t}){this._options.lineSizePt=e,this._options.material=t,$e(this,Ce({...this._options,metadata:this.metadata}))}destroy(){this._themeHandle.remove(),super.destroy()}}function Ce({calloutColor:e,lineSizePt:t,material:r,metadata:n}){return{calloutLength:.25*me*V*s(t)+W,calloutColor:e,calloutWidth:q,customStateMask:et,discScale:J,focusMultiplier:K,material:r,metadata:n}}function Te(e,t){const r=[b(-.5,0,0),b(.5,0,0)],n=fe(t.thinOffsetManipulatorMaterial,r),i=fe(t.unfocusedMaterial,r.map((e=>d(S(),e,N)))),o=i.instantiate({material:t.focusedMaterial});return new $({view:e,renderObjects:[new oe(i,be.Unfocused|et),new oe(o,be.Focused|et),new oe(n,et)],collisionType:{type:"line",paths:[r]},radius:Ze(t.lineSizePt)/2,available:!1,metadata:t.metadata,...te})}function Oe(e,{isStart:t,createSnappingPipelineStep:r,dimension:n,onUpdate:i,view:o}){const a=t?"startPoint":"endPoint",s=ye(e,((e,t,s,c)=>{const l=ce(e),{snappingStep:m,cancelSnapping:d}=r(c);s=s.next(l).next(we(n,[a,"measureType","orientation"])).next(d),t.next(l).next(ae(o)).next(...m).next((e=>{const t=U(e.mapEnd,new H);i("startPoint"===a?{startPoint:t}:{endPoint:t})}))}));return[s]}function Ue(e,{computation:t,view:r}){return[ye(e,((e,n,i)=>{if(!R(t)||!e.selected)return;const{geometry:o,dimension:a}=t,s=ce(e);n.next(s).next(Le(r,a,o.dimensionSegment,o.primaryOffsetAxis)),i.next(s).next(we(a,["offset"]))}))]}function Re(e,{computation:t,view:r}){return[ye(e,((e,n,i)=>{_e({cancel:i,computation:t,settingHeading:!0,steps:n,view:r})}))]}function ze(e,{computation:t,view:r}){return[ye(e,((e,n,i)=>{_e({cancel:i,computation:t,settingHeading:!1,steps:n,view:r})})),e.events.on("immediate-click",(e=>{Ae(e,t,r)}))]}function Ae(e,t,r){const{dimension:i,geometry:o}=t;if(90===i.orientation||270===i.orientation)return i.orientation=0,void e.stopPropagation();if(null==o)return;const{renderCoordsHelper:a}=r,s=z({...A(t),orientation:90},a),c=z({...A(t),orientation:270},a);if(null==s||null==c)return;const l=_(s,a),m=_(c,a),d=ke(o,r),u=n.shortestSignedDiff(d,l),p=n.shortestSignedDiff(d,m);i.orientation=Math.abs(u)<Math.abs(p)?90:270,e.stopPropagation()}function _e(e){const{cancel:t,computation:r,settingHeading:n,steps:o,view:a}=e;if(!R(r))return;const{renderCoordsHelper:s}=a,{dimension:c,geometry:l}=r,m=S(),d=qe(S(),l,l.directSegment,s),p=Je(O.get(),{forHeading:n,geometry:l,renderCoordsHelper:s}),f=M(d,p,P()),g=n?c.orientation??_(l,a.renderCoordsHelper):c.orientation??0;o.next(se(a,f)).next((e=>{"start"===e.action&&u(m,e.renderStart);const t=T(f),r=re(m,e.renderEnd,d,t);let o=g-i(r);n||(o=De(o)),c.orientation=o})),t.next(we(c,["orientation"]))}function De(e){const t=n.normalize(e)%90;return t<Q?e-t:90-t<Q?e+(90-t):e}function Fe(e,{computation:t,manipulatorMeasureType:n,view:i}){let o=r.Direct,a=0,s=0;return[e.events.on("grab-changed",(r=>{if("start"!==r.action||!R(t))return;const{dimension:c,geometry:l}=t;o=c.measureType,a=c.offset,s=c.orientation;const m=u(O.get(),e.renderLocation);c.measureType=n,c.offset=D(m,n,l,i.renderCoordsHelper),c.orientation=0})),ye(e,((e,r,c)=>{if(!R(t))return;const{geometry:l,dimension:m}=t,{renderCoordsHelper:d}=i,u=F(it,n,t,d),p=L(O.get(),{measureType:n,directSegment:l.directSegment,renderCoordsHelper:d}),f=ce(e);r.next(f).next(Le(i,m,u,p)),c.next(f).next((e=>(m.measureType=o,m.offset=a,m.orientation=s,e)))}))]}function Le(e,t,r,n){const i=p(O.get(),r.endRenderSpace,r.startRenderSpace);f(i,i,n);const o=M(r.startRenderSpace,i,P()),a=M(r.startRenderSpace,n,P()),s=t.offset;let c,l=0;const m=new Se;return m.next(se(e,o)).next((r=>{"start"===r.action&&(l=C(a,r.renderStart));const n=(C(a,r.renderEnd)-l)*e.renderCoordsHelper.unitInMeters;t.offset=s+n,c=r})),e=>(m.execute(e),c)}function ke(e,t){const{directSegment:r}=e,{renderCoordsHelper:n}=t,i=k(O.get(),e,n),o=E(O.get(),e),a=f(O.get(),o,i),{viewForward:s}=t.state.camera;g(a,s)>0&&d(a,a,-1);const c=r.eval(.5,O.get());return n.headingAtPosition(c,a)}function Ee(e,t,r){const{dimensionSegment:n,primaryOffsetAxis:i}=t,o=G(tt,t),a=h(o,j)?c(nt):ne(o,i,j,nt),s=Math.max(v(o),X/r.unitInMeters);l(a,a,y(tt,s,s,s)),e.modelTransform=a,e.renderLocation=n.eval(.5,tt)}function Ge(e,t,r){Be(e,t,r,{forHeading:!0})}function Ie(e,t,r){Be(e,t,r,{forHeading:!1})}function Be(e,t,r,{forHeading:n}){const{dimension:i,geometry:o}=t,{primaryOffsetAxis:a}=o,s=d(Ne,a,i.offset>=0?1:-1),c=Je(Ve,{forHeading:n,geometry:o,renderCoordsHelper:r});f(c,c,s);const l=ne(s,c,j,nt);e.modelTransform=l,e.renderLocation=qe(tt,o,o.dimensionSegment,r)}const Ne=S(),Ve=S();function We(e,t,r,n){const{geometry:i}=t,o=F(it,r,t,n),a=L(tt,{measureType:r,directSegment:i.directSegment,renderCoordsHelper:n}),s=w(rt,o.endRenderSpace,o.startRenderSpace),c=ne(s,a,j,nt),m=v(s);l(c,c,y(rt,m,m,m)),e.modelTransform=c,e.renderLocation=o.eval(.5,rt)}function qe(e,t,r,n){const{startRenderSpace:i,endRenderSpace:o}=r,a=Ke(t,n)?i:o;return u(e,a)}function Je(e,{forHeading:t,geometry:r,renderCoordsHelper:n}){return t?k(e,r,n):G(e,r,{invert:!0})}function Ke(e,t){const r=E(Qe,e),n=k(Xe,e,t);return g(r,n)>0}const Qe=S(),Xe=S();function Ye(e){return s(e)+Y}function Ze(e){return s(e)+Z}function $e(e,t){const r=t.material,n=t.focusMultiplier??ie.focusMultiplier,i=t.calloutLength??ie.calloutLength,o=ie.discRadius*(t.discScale??1),a=o*n,s=(e,t)=>{const r=[0,1,2,2,3,0];return new ue(t,[[he.POSITION,new de([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],[he.UV0,new de([0,0,1,0,1,1,0,1],r,2,!0)]])},c=t.calloutWidth??ie.calloutWidth,l=new ve({width:c,color:t.calloutColor,renderOccluded:ge.OccludeAndTransparent,isDecoration:!0}),m=fe(l,[[0,0,0],[i-o,0,0]]),d=fe(l,[[0,0,0],[i-a,0,0]]),u=t.customStateMask??je.None;e.collisionType={type:"disc",direction:[0,0,1],offset:[i,0,0]},e.focusMultiplier=n,e.metadata=t.metadata,e.radius=o,e.renderObjects=[new oe(s(o,r),be.Unfocused|u),new oe(m,be.Unfocused|u),new oe(s(a,r),be.Focused|u),new oe(d,be.Focused|u)]}const et=je.Custom1,tt=S(),rt=S(),nt=m(),it=new le;export{et as DidPointerMoveRecentlyFlag,xe as LengthDimensionManipulators,He as LengthDimensionPointManipulator,Pe as LineOfSightOrientationManipulator,ke as automaticHeadingFromCamera,Te as createMeasureTypeManipulator,Me as createOffsetManipulator,Ze as focusedOffsetWidth,Re as headingManipulatorHandles,Fe as measureTypeManipulatorHandles,Ue as offsetManipulatorHandles,Oe as pointManipulatorHandles,ze as rotationManipulatorHandles,De as snapOrientationToNearestRightAngle,Ye as unfocusedOffsetWidth,Ge as updateHeadingManipulatorTransform,We as updateMeasureTypeManipulatorTransform,Ee as updateOffsetManipulatorTransform,Ie as updateRotationManipulatorTransform};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{multiplyOpacity as t,getContrast as r}from"../../../../core/colorUtils.js";import{watch as i,initial as o}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as n}from"./sliceToolUtils.js";import{Manipulator3D as s}from"../../interactive/Manipulator3D.js";import{rotateManipulatorDefaults as l}from"../../interactive/manipulatorUtils.js";import{RenderObject as a}from"../../interactive/RenderObject.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as u}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as d}from"../../webgl-engine/lib/Material.js";import{VertexAttribute as p}from"../../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as f}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as b}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{ManipulatorStateFlags as w}from"../../../interactive/interfaces.js";class g extends s{constructor(n,s){const a=new f({writeDepth:!1,renderOccluded:d.Opaque,isDecoration:!0}),c=l.calloutWidth,m=new b({width:c,renderOccluded:d.OccludeAndTransparent,isDecoration:!0});super({view:n,...j({imageMaterial:a,calloutMaterial:m})}),this._currentTexture=null,this._themeHandle=i((()=>n.effectiveTheme.accentColor),(i=>{const o=t(i,.5),n=r(i),l=this._currentTexture,c=s(o,n);a.setParameters({textureId:c.texture.id}),m.setParameters({color:e.toUnitRGBA(i)}),this._currentTexture=c,l?.release()}),o)}destroy(){this._themeHandle.remove(),this._currentTexture?.release(),super.destroy()}}function j({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=l,s=o*r,d=(e,t)=>{const r=[0,1,2,2,3,0];return new m(t,[[p.POSITION,new c([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],[p.UV0,new c([0,0,1,0,1,1,0,1],r,2,!0)]])},f=u(t,[[0,0,0],[i-o,0,0]]),b=u(t,[[0,0,0],[i-s,0,0]]),g=n;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new a(d(o,e),w.Unfocused|g),new a(f,w.Unfocused|g),new a(d(s,e),w.Focused|g),new a(b,w.Focused|g)],state:g}}export{g as RotateManipulator};
5
+ import e from"../../../../Color.js";import{multiplyOpacity as t,getContrast as r}from"../../../../core/colorUtils.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{watch as o,initial as s}from"../../../../core/reactiveUtils.js";import{DidPointerMoveRecentlyFlag as n}from"./sliceToolUtils.js";import{Manipulator3D as l}from"../../interactive/Manipulator3D.js";import{rotateManipulatorDefaults as a}from"../../interactive/manipulatorUtils.js";import{RenderObject as c}from"../../interactive/RenderObject.js";import{Attribute as m}from"../../webgl-engine/lib/Attribute.js";import{Geometry as u}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as d}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as f}from"../../webgl-engine/lib/Material.js";import{VertexAttribute as p}from"../../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as b}from"../../webgl-engine/materials/ImageMaterial.js";import{RibbonLineMaterial as h}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{ManipulatorStateFlags as j}from"../../../interactive/interfaces.js";class w extends l{constructor(i,n){const l=t(i.effectiveTheme.accentColor,.5),c=r(i.effectiveTheme.accentColor),m=n(l,c),u=new b({texture:m.texture,writeDepth:!1,renderOccluded:f.Opaque,isDecoration:!0}),d=a.calloutWidth,p=new h({width:d,renderOccluded:f.OccludeAndTransparent,isDecoration:!0});super({view:i,...g({imageMaterial:u,calloutMaterial:p})}),this._material=u,this._textureHandle=m,this._themeHandle=o((()=>i.effectiveTheme.accentColor),(i=>{const o=t(i,.5),s=r(i),l=this._textureHandle;this._textureHandle=n(o,s),u.setParameters({texture:this._textureHandle.texture}),l?.release(),p.setParameters({color:e.toUnitRGBA(i)})}),s)}destroy(){this._textureHandle=i(this._textureHandle),this._themeHandle.remove(),this._material.dispose(),super.destroy()}}function g({imageMaterial:e,calloutMaterial:t}){const{focusMultiplier:r,calloutLength:i,discRadius:o}=a,s=o*r,l=(e,t)=>{const r=[0,1,2,2,3,0];return new u(t,[[p.POSITION,new m([i-e,-e,0,i+e,-e,0,i+e,e,0,i-e,e,0],r,3,!0)],[p.UV0,new m([0,0,1,0,1,1,0,1],r,2,!0)]])},f=d(t,[[0,0,0],[i-o,0,0]]),b=d(t,[[0,0,0],[i-s,0,0]]),h=n;return{autoScaleRenderObjects:!1,collisionPriority:1,collisionType:{type:"disc",direction:[0,0,1],offset:[i,0,0]},focusMultiplier:r,radius:o,renderObjects:[new c(l(o,e),j.Unfocused|h),new c(f,j.Unfocused|h),new c(l(s,e),j.Focused|h),new c(b,j.Focused|h)],state:h}}export{w as RotateManipulator};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../core/has.js";import"../../../core/mathUtils.js";import"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import"../../../core/libs/gl-matrix-2/math/vec2.js";import"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"./CloudsTechniqueConfiguration.js";import"./NoiseTextureAtlasDimensions.js";import"../webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import"../webgl-engine/core/shaderModules/Float2PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/core/shaderModules/Matrix3PassUniform.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../webgl-engine/shaders/SphereIntersect.glsl.js";import"../../webgl/NoParameters.js";import"../../webgl/ShaderBuilder.js";export{C as CloudsPassParameters,b as build,c as cubeMapSize}from"../../../chunks/Clouds.glsl.js";
5
+ import"../../../core/has.js";import"../../../core/mathUtils.js";import"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import"../../../core/libs/gl-matrix-2/math/vec2.js";import"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"./CloudsTechniqueConfiguration.js";import"./NoiseTextureAtlasDimensions.js";import"../webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import"../webgl-engine/core/shaderModules/BooleanPassUniform.js";import"../webgl-engine/core/shaderModules/Float2PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/core/shaderModules/Matrix3PassUniform.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../webgl-engine/shaders/SphereIntersect.glsl.js";import"../../webgl/NoParameters.js";import"../../webgl/ShaderBuilder.js";export{C as CloudsPassParameters,b as build,c as cubeMapSize}from"../../../chunks/Clouds.glsl.js";
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as a}from"../../../core/compilerUtils.js";import{clamp as t}from"../../../core/mathUtils.js";import{signal as e}from"../../../core/signal.js";import{rotate as s}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{k as h,n as o,h as n,c,l as d,d as l}from"../../../chunks/vec32.js";import{create as _,fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as F,fromPoints as f,axis as p}from"../../../geometry/support/axisAngleDegrees.js";import{earth as S}from"../../../geometry/support/Ellipsoid.js";import{CloudsTextureChannels as m,ensureClouds as E,CubeMapState as D}from"./Clouds.js";import{heightLimit as P}from"./weather.js";class x{constructor(){this.startTime=0,this._data=e(null),this._readChannels=m.RG,this.parallax=new O,this.parallaxNew=new O,this._anchorPoint=_(),this._fadeState=e(A.HIDE),this._fadeFactor=e(1)}get data(){return this._data.value}set data(a){this._data.value=a}get readChannels(){return this._readChannels}get fadeState(){return this._fadeState.value}get fadeFactor(){return this._fadeFactor.value}get opacity(){switch(this.fadeState){case A.HIDE:return 0;case A.FADE_OUT:return 1-this.fadeFactor;case A.FADE_IN:return this.fadeFactor;case A.SHOW:case A.CROSS_FADE:return 1}}fade(a,e,s){this.isFading&&this.fadeFactor<1&&(this._fadeFactor.value=s?t((e-this.startTime)/(H*s),0,1):1,1===this.fadeFactor&&this._endFade()),this._evaluateState(a,e),this._updateParallax(a)}_evaluateState(a,t){const e=a.relativeElevation,s=this._updateAnchorPoint(a);(e>1.7*P||e<-1e4||s>I)&&this.opacity>0?this._startFade(A.HIDE,t):this.isFading||(e>P||e<-.35*P||s>w*I?this.opacity>0&&this._startFade(A.FADE_OUT,t):E(this.data)&&(0===this.opacity?this._startFade(A.FADE_IN,t):this.data.state===D.Ready&&(this.fadeState===A.SHOW?this._startFade(A.CROSS_FADE,t):this._startFade(A.SHOW,t))))}_updateParallax(a){const t=h(a.eye);this.parallax.radiusCurvatureCorrection=.84*Math.sqrt(Math.max(t-S.radius*S.radius,0))/Math.sqrt(t),f(C,this.parallax.anchorPoint,v),s(this.parallax.transform,i,v[3],p(v)),f(C,this.parallaxNew.anchorPoint,v),s(this.parallaxNew.transform,i,v[3],p(v))}_updateAnchorPoint(a){return o(this._anchorPoint,a.eye),n(this._anchorPoint,this._anchorPoint,S.radius),this.fadeState===A.HIDE&&this.data?.state===D.Ready?(c(this.parallax.anchorPoint,this._anchorPoint),0):d(l(g,this.parallax.anchorPoint,this._anchorPoint))}requestFade(){this._fadeFactor.value=0}_startFade(a,t){switch(this._fadeState.value=a,this.startTime=t,a){case A.CROSS_FADE:this.requestFade(),this._switchReadChannels(),c(this.parallaxNew.anchorPoint,this._anchorPoint);break;case A.FADE_IN:this.requestFade(),this._switchReadChannels(),c(this.parallax.anchorPoint,this._anchorPoint),c(this.parallaxNew.anchorPoint,this._anchorPoint);break;case A.FADE_OUT:this.requestFade();break;case A.SHOW:this._switchReadChannels(),c(this.parallax.anchorPoint,this._anchorPoint),c(this.parallaxNew.anchorPoint,this._anchorPoint),this._endFade();break;case A.HIDE:this._endFade()}}_endFade(){switch(this._fadeFactor.value=1,this.data&&this.data.state!==D.Ready&&(this.data.state=D.Idle),this.fadeState){case A.CROSS_FADE:c(this.parallax.anchorPoint,this.parallaxNew.anchorPoint),this._fadeState.value=A.SHOW;break;case A.FADE_IN:this._fadeState.value=A.SHOW;break;case A.FADE_OUT:this._fadeState.value=A.HIDE;break;case A.SHOW:case A.HIDE:break;default:a(this.fadeState)}}_switchReadChannels(){this.data?.state===D.Ready&&(this._readChannels=1-this._readChannels,this.data.state=D.Fading)}get isFading(){return this.fadeState===A.FADE_OUT||this.fadeState===A.FADE_IN||this.fadeState===A.CROSS_FADE}}var A;!function(a){a[a.HIDE=0]="HIDE",a[a.FADE_IN=1]="FADE_IN",a[a.SHOW=2]="SHOW",a[a.CROSS_FADE=3]="CROSS_FADE",a[a.FADE_OUT=4]="FADE_OUT"}(A||(A={}));class O{constructor(){this.anchorPoint=_(),this.radiusCurvatureCorrection=0,this.transform=r()}}const C=u(0,0,1),v=F(),g=_(),H=1.25,w=.5,I=2e5;export{x as CloudsParameters,A as FadeState};
5
+ import{neverReached as a}from"../../../core/compilerUtils.js";import{clamp as t}from"../../../core/mathUtils.js";import{signal as e}from"../../../core/signal.js";import{rotate as s}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as r}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{k as h,n as o,h as n,c,l as d,d as l}from"../../../chunks/vec32.js";import{create as _,fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as F,fromPoints as f,axis as p}from"../../../geometry/support/axisAngleDegrees.js";import{earth as S}from"../../../geometry/support/Ellipsoid.js";import{CloudsTextureChannels as m,ensureClouds as E,CubeMapState as D}from"./Clouds.js";import{heightLimit as P}from"./weather.js";class x{constructor(){this.startTime=0,this._data=e(null),this.coverage=0,this.absorption=0,this._readChannels=m.RG,this.parallax=new O,this.parallaxNew=new O,this._anchorPoint=_(),this._fadeState=e(A.HIDE),this._fadeFactor=e(1)}get data(){return this._data.value}set data(a){this._data.value=a}get readChannels(){return this._readChannels}get fadeState(){return this._fadeState.value}get fadeFactor(){return this._fadeFactor.value}get opacity(){switch(this.fadeState){case A.HIDE:return 0;case A.FADE_OUT:return 1-this.fadeFactor;case A.FADE_IN:return this.fadeFactor;case A.SHOW:case A.CROSS_FADE:return 1}}fade(a,e,s){this.isFading&&this.fadeFactor<1&&(this._fadeFactor.value=s?t((e-this.startTime)/(H*s),0,1):1,1===this.fadeFactor&&this._endFade()),this._evaluateState(a,e),this._updateParallax(a)}_evaluateState(a,t){const e=a.relativeElevation,s=this._updateAnchorPoint(a);(e>1.7*P||e<-1e4||s>I)&&this.opacity>0?this._startFade(A.HIDE,t):this.isFading||(e>P||e<-.35*P||s>w*I?this.opacity>0&&this._startFade(A.FADE_OUT,t):E(this.data)&&(0===this.opacity?this._startFade(A.FADE_IN,t):this.data.state===D.Ready&&(this.fadeState===A.SHOW?this._startFade(A.CROSS_FADE,t):this._startFade(A.SHOW,t))))}_updateParallax(a){const t=h(a.eye);this.parallax.radiusCurvatureCorrection=.84*Math.sqrt(Math.max(t-S.radius*S.radius,0))/Math.sqrt(t),f(v,this.parallax.anchorPoint,C),s(this.parallax.transform,i,C[3],p(C)),f(v,this.parallaxNew.anchorPoint,C),s(this.parallaxNew.transform,i,C[3],p(C))}_updateAnchorPoint(a){return o(this._anchorPoint,a.eye),n(this._anchorPoint,this._anchorPoint,S.radius),this.fadeState===A.HIDE&&this.data?.state===D.Ready?(c(this.parallax.anchorPoint,this._anchorPoint),0):d(l(g,this.parallax.anchorPoint,this._anchorPoint))}requestFade(){this._fadeFactor.value=0}_startFade(a,t){switch(this._fadeState.value=a,this.startTime=t,a){case A.CROSS_FADE:this.requestFade(),this._switchReadChannels(),c(this.parallaxNew.anchorPoint,this._anchorPoint);break;case A.FADE_IN:this.requestFade(),this._switchReadChannels(),c(this.parallax.anchorPoint,this._anchorPoint),c(this.parallaxNew.anchorPoint,this._anchorPoint);break;case A.FADE_OUT:this.requestFade();break;case A.SHOW:this._switchReadChannels(),c(this.parallax.anchorPoint,this._anchorPoint),c(this.parallaxNew.anchorPoint,this._anchorPoint),this._endFade();break;case A.HIDE:this._endFade()}}_endFade(){switch(this._fadeFactor.value=1,this.data&&this.data.state!==D.Ready&&(this.data.state=D.Idle),this.fadeState){case A.CROSS_FADE:c(this.parallax.anchorPoint,this.parallaxNew.anchorPoint),this._fadeState.value=A.SHOW;break;case A.FADE_IN:this._fadeState.value=A.SHOW;break;case A.FADE_OUT:this._fadeState.value=A.HIDE;break;case A.SHOW:case A.HIDE:break;default:a(this.fadeState)}}_switchReadChannels(){this.data?.state===D.Ready&&(this._readChannels=1-this._readChannels,this.data.state=D.Fading)}get isFading(){return this.fadeState===A.FADE_OUT||this.fadeState===A.FADE_IN||this.fadeState===A.CROSS_FADE}}var A;!function(a){a[a.HIDE=0]="HIDE",a[a.FADE_IN=1]="FADE_IN",a[a.SHOW=2]="SHOW",a[a.CROSS_FADE=3]="CROSS_FADE",a[a.FADE_OUT=4]="FADE_OUT"}(A||(A={}));class O{constructor(){this.anchorPoint=_(),this.radiusCurvatureCorrection=0,this.transform=r()}}const v=u(0,0,1),C=F(),g=_(),H=1.25,w=.5,I=2e5;export{x as CloudsParameters,A as FadeState};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{neverReached as s}from"../../../core/compilerUtils.js";import{lerp as i}from"../../../core/mathUtils.js";import{destroyMaybe as r,disposeMaybe as o}from"../../../core/maybe.js";import{watch as a,initial as n}from"../../../core/reactiveUtils.js";import{signal as h}from"../../../core/signal.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as d}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as m,equals as f,copy as _}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as g,ZEROS as x,zeros as y}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{CubeMapState as C,CloudsTextureChannels as w}from"./Clouds.js";import{C as S,c as j}from"../../../chunks/Clouds.glsl.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as z}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as R,RayMarchingSteps as M}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as I}from"./NoiseTextureAtlas.js";import{TaskPriority as H}from"../../support/Scheduler.js";import{Yield as U}from"../../support/Yield.js";import{TextureType as q,TextureWrapMode as A,ColorAttachment as D}from"../../webgl/enums.js";import{FramebufferObject as E}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as F}from"../../webgl/TextureDescriptor.js";let O=class extends e{constructor(t){super(t),this._state=h(C.Idle),this._passParameters=new S,this._weatherTileCount=128,this._faceIndex=0,this._tileIndex=0,this._tilesPerFace=1,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=p(),this._dirty=!0,this.running=!0,this._configuration=new R}initialize(){const t=v(this.view.spatialReference);this._passParameters.cloudRadius=.5*t.radius;const e=()=>this.setDirty();this.addHandles([this.view.resourceController.scheduler.registerTask(H.CLOUDS_GENERATOR,this),a((()=>this.coverage),e,n),a((()=>this.density),e,n),a((()=>this.absorption),e,n),a((()=>this.cloudSize),e,n),a((()=>this.detailSize),e,n),a((()=>this.smoothness),e,n),a((()=>this.cloudHeight),e,n),a((()=>this.raymarchingSteps),e,n)]);const s=g(this._computeWeatherTile());let i=0;this.addHandles(a((()=>{const t=this._computeWeatherTile();return f(s,t)||(++i,_(s,t)),i}),e))}destroy(){this.destroyCubeMap(),this._passParameters.noiseTexture=r(this._passParameters.noiseTexture)}_precompileTechniques(){this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=w.RG,this.context.techniques.precompile(z,this._configuration),this._configuration.writeTextureChannels=w.BA,this.context.techniques.precompile(z,this._configuration)}_acquireTechnique(){switch(this.raymarchingSteps){case M.SIXTEEN:this._tilesPerFace=1;break;case M.HUNDRED:this._tilesPerFace=4;break;case M.COUNT:case M.TWOHUNDRED:this._tilesPerFace=8;break;default:s(this.raymarchingSteps)}return this._configuration.writeTextureChannels=1-this.parameters.readChannels,this._configuration.steps=this.raymarchingSteps,this.context.techniques.get(z,this._configuration)}_computeWeatherTile(){const{camera:t,environment:e}=this.view,{latitude:s,longitude:i}=t.position;if(null==s||null==i)return x;m(L,(s+90)/180,(i+180)/360);const r=Math.floor(this._weatherTileCount*Math.abs(2*L[0]-1));L[0]=Math.floor(2*this._weatherTileCount*L[0]),L[1]=Math.floor(4*(this._weatherTileCount-r)*L[1]);let o=0,a=0;if("virtual"!==e?.lighting?.type&&null!=e?.lighting?.date){const t=new Date(e.lighting.date);t.setUTCHours(e.lighting.date.getUTCHours()+(e.lighting.displayUTCOffset??0)),o=31*t.getUTCMonth()+t.getUTCDate(),a=t.getUTCFullYear()}return L[0]=(L[0]+o)%(2*this._weatherTileCount),L[1]=(L[1]+a%100)%(4*this._weatherTileCount),L}get state(){return this._state.value}set state(t){this._state.value=t}get usedMemory(){return(this._fbo?.usedMemory??0)+(this._passParameters.noiseTexture?.textureAtlas?.usedMemory??0)}_ensureNoiseTexture(){return this._passParameters.noiseTexture??=new I({context:this.context}),this._passParameters.noiseTexture}_ensureFrameBufferCube(t){const e=this.context.renderContext.rctx;if(null==this._fbo){const s=new F(t);s.target=q.TEXTURE_2D_ARRAY,s.depth=5,s.wrapMode=A.CLAMP_TO_EDGE,this._fbo=new E(e,s),this.parameters.data=this}return e.unbindTexture(this._fbo.colorTexture),this._fbo}get cubeMap(){return this._fbo}get parameters(){return this.context.renderContext.bind.clouds}destroyCubeMap(){this._fbo=o(this._fbo),this.parameters.data=null}applyPreset(t,e){const s=t.median,r=t=>{const r=i(t[0],t[1],s);return e<.5?i(t[0],r,2*e):i(r,t[1],2*(e-.5))};this.coverage=r(t.coverage),this.density=r(t.density),this.absorption=r(t.absorption),this.cloudSize=r(t.cloudSize),this.detailSize=r(t.detailSize),this.smoothness=r(t.smoothness),this.cloudHeight=r(t.cloudHeight),this.raymarchingSteps=t.raymarchingSteps,this._precompileTechniques()}setDirty(){this._dirty=this.running=!0}runTask(t){if(this.state===C.Fading)return U;this._dirty&&(this._faceIndex=this._tileIndex=0,this.state=C.Rendering,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._ensureNoiseTexture().updateWeatherMap(this._computeWeatherTile()),this._dirty=!1);const e=this._acquireTechnique();if(!this._ensureNoiseTexture().textureAtlas||!e.compiled)return U;const s=N[this._faceIndex],i=k[this._faceIndex];d(this._viewMatrix,W,s,i),u(this._passParameters.viewMatrix,this._viewMatrix);const r=this.context.renderContext.rctx,o=r.getViewport(),a=j/this._tilesPerFace,n=this._tileIndex*a;r.setViewport(0,n,j,a);const h=this._ensureFrameBufferCube(j);r.bindFramebuffer(h),r.bindTechnique(e,this.context.renderContext.bind,this._passParameters);const c=q.TEXTURE_2D_ARRAY;return h.setColorTextureTarget(c,D.COLOR_ATTACHMENT0,this._faceIndex),r.screen.draw(),r.gl.flush(),r.setViewport(o.x,o.y,o.width,o.height),this.requestRender(),++this._tileIndex,4===this._faceIndex&&this._tileIndex===this._tilesPerFace?(this._faceIndex=this._tileIndex=0,this.state=C.Ready,this.running=!1):this._tileIndex===this._tilesPerFace&&(++this._faceIndex,this._tileIndex=0),t.madeProgress(),U}};t([c({constructOnly:!0})],O.prototype,"context",void 0),t([c({constructOnly:!0})],O.prototype,"view",void 0),t([c({constructOnly:!0})],O.prototype,"requestRender",void 0),t([c()],O.prototype,"coverage",void 0),t([c()],O.prototype,"density",void 0),t([c()],O.prototype,"absorption",void 0),t([c()],O.prototype,"cloudSize",void 0),t([c()],O.prototype,"detailSize",void 0),t([c()],O.prototype,"smoothness",void 0),t([c()],O.prototype,"cloudHeight",void 0),t([c()],O.prototype,"raymarchingSteps",void 0),t([c()],O.prototype,"running",void 0),O=t([l("esri.views.3d.environment.CloudsRenderer")],O);const N=[T(1,0,0),T(-1,0,0),T(0,1,0),T(0,-1,0),T(0,0,1)],k=[T(0,1,0),T(0,1,0),T(0,0,-1),T(0,0,1),T(0,1,0)],W=b(),L=y();export{O as CloudsRenderer};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{neverReached as s}from"../../../core/compilerUtils.js";import{lerp as i}from"../../../core/mathUtils.js";import{destroyMaybe as r,disposeMaybe as o}from"../../../core/maybe.js";import{watch as a,initial as n}from"../../../core/reactiveUtils.js";import{signal as h}from"../../../core/signal.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as d}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as m,equals as _,copy as f}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as g,ZEROS as x,zeros as y}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{CubeMapState as S,CloudsTextureChannels as C}from"./Clouds.js";import{C as w,c as j}from"../../../chunks/Clouds.glsl.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as z}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as R,RayMarchingSteps as I}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as M}from"./NoiseTextureAtlas.js";import{TaskPriority as H}from"../../support/Scheduler.js";import{Yield as U}from"../../support/Yield.js";import{TextureType as q,TextureWrapMode as A,ColorAttachment as D}from"../../webgl/enums.js";import{FramebufferObject as E}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as O}from"../../webgl/TextureDescriptor.js";let N=class extends t{constructor(e){super(e),this._state=h(S.Idle),this._passParameters=new w,this._weatherTileCount=128,this._sliceIndex=0,this._tileIndex=0,this._tilesPerSlice=1,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=p(),this._dirty=!0,this.running=!0,this._configuration=new R}initialize(){const e=v(this.view.spatialReference);this._passParameters.cloudRadius=.5*e.radius;const t=()=>this.setDirty();this.addHandles([this.view.resourceController.scheduler.registerTask(H.CLOUDS_GENERATOR,this),a((()=>this.coverage),t,n),a((()=>this.density),t,n),a((()=>this.absorption),t,n),a((()=>this.cloudSize),t,n),a((()=>this.detailSize),t,n),a((()=>this.smoothness),t,n),a((()=>this.cloudHeight),t,n),a((()=>this.raymarchingSteps),t,n)]);const s=g(this._computeWeatherTile());let i=0;this.addHandles(a((()=>{const e=this._computeWeatherTile();return _(s,e)||(++i,f(s,e)),i}),t))}destroy(){this.destroyCubeMap(),this._passParameters.noiseTexture=r(this._passParameters.noiseTexture)}_precompileTechniques(){this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=C.RG,this.context.techniques.precompile(z,this._configuration),this._configuration.writeTextureChannels=C.BA,this.context.techniques.precompile(z,this._configuration)}_acquireTechnique(){switch(this.raymarchingSteps){case I.SIXTEEN:this._tilesPerSlice=1;break;case I.HUNDRED:this._tilesPerSlice=4;break;case I.COUNT:case I.TWOHUNDRED:this._tilesPerSlice=8;break;default:s(this.raymarchingSteps)}return this._configuration.writeTextureChannels=1-this.parameters.readChannels,this._configuration.steps=this.raymarchingSteps,this.context.techniques.get(z,this._configuration)}_computeWeatherTile(){const{camera:e,environment:t}=this.view,{latitude:s,longitude:i}=e.position;if(null==s||null==i)return x;m(L,(s+90)/180,(i+180)/360);const r=Math.floor(this._weatherTileCount*Math.abs(2*L[0]-1));L[0]=Math.floor(2*this._weatherTileCount*L[0]),L[1]=Math.floor(4*(this._weatherTileCount-r)*L[1]);let o=0,a=0;if("virtual"!==t?.lighting?.type&&null!=t?.lighting?.date){const e=new Date(t.lighting.date);e.setUTCHours(t.lighting.date.getUTCHours()+(t.lighting.displayUTCOffset??0)),o=31*e.getUTCMonth()+e.getUTCDate(),a=e.getUTCFullYear()}return L[0]=(L[0]+o)%(2*this._weatherTileCount),L[1]=(L[1]+a%100)%(4*this._weatherTileCount),L}get state(){return this._state.value}set state(e){this._state.value=e}get usedMemory(){return(this._fbo?.usedMemory??0)+(this._passParameters.noiseTexture?.textureAtlas?.usedMemory??0)}_ensureNoiseTexture(){return this._passParameters.noiseTexture??=new M({context:this.context}),this._passParameters.noiseTexture}_ensureFrameBufferCube(e){const t=this.context.renderContext.rctx;if(null==this._fbo){const s=new O(e,e/2);s.target=q.TEXTURE_2D_ARRAY,s.depth=6,s.wrapMode=A.CLAMP_TO_EDGE,this._fbo=new E(t,s),this.parameters.data=this,this.parameters.absorption=this.absorption,this.parameters.coverage=this.coverage}return t.unbindTexture(this._fbo.colorTexture),this._fbo}get cubeMap(){return this._fbo}get parameters(){return this.context.renderContext.bind.clouds}destroyCubeMap(){this._fbo=o(this._fbo),this.parameters.data=null}applyPreset(e,t){const s=e.median,r=e=>{const r=i(e[0],e[1],s);return t<.5?i(e[0],r,2*t):i(r,e[1],2*(t-.5))};this.coverage=r(e.coverage),this.density=r(e.density),this.absorption=r(e.absorption),this.cloudSize=r(e.cloudSize),this.detailSize=r(e.detailSize),this.smoothness=r(e.smoothness),this.cloudHeight=r(e.cloudHeight),this.raymarchingSteps=e.raymarchingSteps,this._precompileTechniques()}setDirty(){this._dirty=this.running=!0}runTask(e){if(this.state===S.Fading)return U;this._dirty&&(this._sliceIndex=this._tileIndex=0,this.state=S.Rendering,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._ensureNoiseTexture().updateWeatherMap(this._computeWeatherTile()),this._dirty=!1);const t=this._acquireTechnique();if(!this._ensureNoiseTexture().textureAtlas||!t.compiled)return U;const s=k[this._sliceIndex],i=F[this._sliceIndex];d(this._viewMatrix,W,s,i),u(this._passParameters.viewMatrix,this._viewMatrix);const r=this.context.renderContext.rctx,o=r.getViewport(),a=j/this._tilesPerSlice,n=this._tileIndex*a;r.setViewport(0,n,j,a);const h=this._ensureFrameBufferCube(j);r.bindFramebuffer(h),this._passParameters.lastSlice=5===this._sliceIndex,r.bindTechnique(t,this.context.renderContext.bind,this._passParameters);const l=q.TEXTURE_2D_ARRAY;return h.setColorTextureTarget(l,D.COLOR_ATTACHMENT0,this._sliceIndex),r.screen.draw(),r.gl.flush(),r.setViewport(o.x,o.y,o.width,o.height),this.requestRender(),++this._tileIndex,5===this._sliceIndex&&this._tileIndex===this._tilesPerSlice?(this._sliceIndex=this._tileIndex=0,this.state=S.Ready,this.running=!1):this._tileIndex===this._tilesPerSlice&&(++this._sliceIndex,this._tileIndex=0),e.madeProgress(),U}};e([l({constructOnly:!0})],N.prototype,"context",void 0),e([l({constructOnly:!0})],N.prototype,"view",void 0),e([l({constructOnly:!0})],N.prototype,"requestRender",void 0),e([l()],N.prototype,"coverage",void 0),e([l()],N.prototype,"density",void 0),e([l()],N.prototype,"absorption",void 0),e([l()],N.prototype,"cloudSize",void 0),e([l()],N.prototype,"detailSize",void 0),e([l()],N.prototype,"smoothness",void 0),e([l()],N.prototype,"cloudHeight",void 0),e([l()],N.prototype,"raymarchingSteps",void 0),e([l()],N.prototype,"running",void 0),N=e([c("esri.views.3d.environment.CloudsRenderer")],N);const k=[T(1,0,0),T(-1,0,0),T(0,1,0),T(0,-1,0),T(0,0,1),T(0,0,1)],F=[T(0,0,-1),T(0,0,-1),T(0,0,-1),T(0,0,-1),T(0,1,0),T(0,1,0)],W=b(),L=y();export{N as CloudsRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import s from"../../../core/Logger.js";import{abortMaybe as a}from"../../../core/maybe.js";import{debounce as o,isAbortError as n,onAbort as l,isAborted as h,createAbortError as m,throwIfAborted as d}from"../../../core/promiseUtils.js";import{whenOnce as c}from"../../../core/reactiveUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Extent.js";import{equals as f,create as y,width as w,height as _,copy as x,intersection as v}from"../../../geometry/support/aaBoundingRect.js";import{DrapeSourceType as R}from"./interfaces.js";import{LayerView3D as b}from"./LayerView3D.js";import{computeImageExportSize as E,createGeometryForExtent as j,createOuterImageGeometry as S}from"./support/overlayImageUtils.js";import{toViewIfLocal as I}from"./support/projectExtentUtils.js";import{debugFlags as A}from"../support/debugFlags.js";import{OverlayIndex as D}from"../terrain/interfaces.js";import{DirtyOperation as M}from"../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as L}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as C}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{ImageMaterial as P}from"../webgl-engine/materials/ImageMaterial.js";import T from"../../layers/LayerView.js";import O from"../../layers/RefreshableLayerView.js";import{isInEffectiveScaleRange as U}from"../../support/layerViewUtils.js";import{TextureWrapMode as H}from"../../webgl/enums.js";let V=class extends(O(b(T))){constructor(){super(...arguments),this.drapeSourceType=R.RasterImage,this.updatePolicy=G.SYNC,this.fullExtentInLocalViewSpatialReference=null,this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this.updateWhenStationary=!0,this._drapeSourceRenderer=null,this.refreshDebounced=o((async e=>{this.destroyed||await this._doRefresh(e).catch((e=>{n(e)||s.getLogger(this).error(e)}))}),2e3)}get visibleAtCurrentScale(){const e=this.layer,t="effectiveScaleRange"in e?e.effectiveScaleRange:null;return U(t,this.view.scale)}initialize(){this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerGeometryDrapeSource(this),this.addHandles(i((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))),this.addResolvingPromise(I(this).then((e=>this._set("fullExtentInLocalViewSpatialReference",e)))),this._updatingHandles.add((()=>this.suspended),(()=>this._suspendedChangeHandler()))}destroy(){this.clear()}setDrapingExtent(e,t){this._spatialReference=t,e.forEach(((e,t)=>{this._overlays[t]=e,this._updateImageExtent(e,t)}))}_updateImageExtent(e,t){const r=this._clippedExtent(e.extent,z);if(null==r)return;const i=E(e.extent,r,e.resolution);let a=e.pixelRatio*this.view.state.pixelRatio;const{layer:o}=this;if("imageMaxWidth"in o&&null!=o.imageMaxWidth||"imageMaxHeight"in o&&null!=o.imageMaxHeight){const e=o.imageMaxWidth,t=o.imageMaxHeight;if(i.width>e){const t=e/i.width;i.height=Math.floor(i.height*t),i.width=e,a*=t}if(i.height>t){const e=t/i.height;i.width=Math.floor(i.width*e),i.height=t,a*=e}}const l=this._extents[t];l&&f(l.extent,r)&&this._imageSizeEquals(r,l.imageSize,i)||(this._extents[t]={extent:y(r),imageSize:i,pixelRatio:a},this.suspended||this._fetch(t).catch((e=>{n(e)||s.getLogger(this).error(e)})))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(){return this._doRefresh()}async _doRefresh(e){if(this.suspended)return;const t=[];for(let r=0;r<this._extents.length;r++)this._extents[r]&&t.push(this._fetch(r,e));await Promise.allSettled(t)}async processResult(e,t,r){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const r=t.extent;if(new p(r[0],r[1],r[2],r[3],this._spatialReference).contains(e))return t}return null}getFetchOptions(){}async redraw(e,r){await t(this._images,(async(t,i)=>{t&&(await e(t,r),await this._createStageObjects(i,t.image,r))}))}_imageSizeEquals(e,t,r){if(!this.maximumDataResolution)return!1;const i=w(e)/this.maximumDataResolution.x,s=_(e)/this.maximumDataResolution.y,a=i/t.width,o=s/t.height,n=i/r.width,l=s/r.height,h=Math.abs(a-n),m=Math.abs(o-l),d=A.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return h<=d&&m<=d}async _fetch(e,t){if(this.suspended)return;const r=this._extents[e],i=r.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:y(i)});const o=this._images[e];o.loadingAbortController=a(o.loadingAbortController);const c=new p(i[0],i[1],i[2],i[3],this._spatialReference);if(0===c.width||0===c.height)return void this._clearImage(e);const g=new AbortController;o.loadingAbortController=g,l(t,(()=>g.abort()));const u=g.signal,f=this._waitFetchReady(u).then((async()=>{const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.getFetchOptions(),signal:u},{height:i,width:s}=r.imageSize;return"imagery"===this.layer.type?this.layer.internalFetchImage(c,s,i,t):this.layer.fetchImage(c,s,i,t)})).then((e=>{if(h(u))throw s.getLogger(this).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),m();return this.processResult(o,e)})).then((()=>{x(o.renderExtent,i)}));o.loadingPromise=f,await this._updatingHandles.addPromise(f.then((async()=>{d(u),await this._createStageObjects(e,o.image,u)})).catch((e=>{throw e&&!n(e)&&s.getLogger(this).error(e),e})).finally((()=>{f===o.loadingPromise&&(o.loadingPromise=null,o.loadingAbortController=null)})))}_clearImage(e){const t=this._images[e];if(t){null!=t.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],M.UPDATE),t.renderGeometry=null);const e=this.view._stage,r=t.texture;r?.unload(),e.remove(r),t.texture=null,e.remove(t.material),t.material=null,t.loadingAbortController=a(t.loadingAbortController),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,i){const s=this.view._stage,a=this._images[e],o=()=>{a.texture?.unload(),s.remove(a.texture),a.texture=null,a.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([a.renderGeometry],M.UPDATE),a.renderGeometry=null)};if(t){const n=new C(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:H.CLAMP_TO_EDGE,t:H.CLAMP_TO_EDGE}});let l;if(await r(this._images[e===D.INNER?D.OUTER:D.INNER].loadingPromise),d(i),o(),await s.schedule((()=>n.load(s.renderView.renderingContext)),i),s.add(n),a.texture=n,null==a.material?(a.material=new P({textureId:n.id}),s.add(a.material)):a.material.setParameters({textureId:n.id}),e===D.INNER)l=j(a.material,a.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void o();l=S(a.material,e,a.renderExtent)}a.renderGeometry=new L(l),a.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([a.renderGeometry],M.UPDATE)}else o(),s.remove(a.material),a.material=null}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return x(t,e);const r=this.view.basemapTerrain;return r.ready?v(e,r.extent,t):x(t,e)}_suspendedChangeHandler(){this.suspended?this.clear():this.refreshDebounced()}async _waitFetchReady(e){await c((()=>this.view.stationary),e),d(e)}};e([g()],V.prototype,"layer",void 0),e([g()],V.prototype,"suspended",void 0),e([g({readOnly:!0})],V.prototype,"fullExtentInLocalViewSpatialReference",void 0),e([g({readOnly:!0})],V.prototype,"visibleAtCurrentScale",null),e([g()],V.prototype,"updating",void 0),V=e([u("esri.views.3d.layers.DynamicLayerView3D")],V);const N=V,z=y();export{N as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import s from"../../../core/Logger.js";import{abortMaybe as a}from"../../../core/maybe.js";import{debounce as o,isAbortError as n,onAbort as l,isAborted as h,createAbortError as m,throwIfAborted as d}from"../../../core/promiseUtils.js";import{whenOnce as c}from"../../../core/reactiveUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Extent.js";import{equals as f,create as y,width as w,height as _,copy as x,intersection as v}from"../../../geometry/support/aaBoundingRect.js";import{DrapeSourceType as R}from"./interfaces.js";import{LayerView3D as b}from"./LayerView3D.js";import{computeImageExportSize as E,createGeometryForExtent as j,createOuterImageGeometry as S}from"./support/overlayImageUtils.js";import{toViewIfLocal as I}from"./support/projectExtentUtils.js";import{debugFlags as A}from"../support/debugFlags.js";import{OverlayIndex as D}from"../terrain/interfaces.js";import{DirtyOperation as M}from"../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as L}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as C}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{ImageMaterial as P}from"../webgl-engine/materials/ImageMaterial.js";import T from"../../layers/LayerView.js";import O from"../../layers/RefreshableLayerView.js";import{isInEffectiveScaleRange as U}from"../../support/layerViewUtils.js";import{TextureWrapMode as H}from"../../webgl/enums.js";let V=class extends(O(b(T))){constructor(){super(...arguments),this.drapeSourceType=R.RasterImage,this.updatePolicy=G.SYNC,this.fullExtentInLocalViewSpatialReference=null,this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this.updateWhenStationary=!0,this._drapeSourceRenderer=null,this.refreshDebounced=o((async e=>{this.destroyed||await this._doRefresh(e).catch((e=>{n(e)||s.getLogger(this).error(e)}))}),2e3)}get visibleAtCurrentScale(){const e=this.layer,t="effectiveScaleRange"in e?e.effectiveScaleRange:null;return U(t,this.view.scale)}initialize(){this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerGeometryDrapeSource(this),this.addHandles(i((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))),this.addResolvingPromise(I(this).then((e=>this._set("fullExtentInLocalViewSpatialReference",e)))),this._updatingHandles.add((()=>this.suspended),(()=>this._suspendedChangeHandler()))}destroy(){this.clear()}setDrapingExtent(e,t){this._spatialReference=t,e.forEach(((e,t)=>{this._overlays[t]=e,this._updateImageExtent(e,t)}))}_updateImageExtent(e,t){const r=this._clippedExtent(e.extent,z);if(null==r)return;const i=E(e.extent,r,e.resolution);let a=e.pixelRatio*this.view.state.pixelRatio;const{layer:o}=this;if("imageMaxWidth"in o&&null!=o.imageMaxWidth||"imageMaxHeight"in o&&null!=o.imageMaxHeight){const e=o.imageMaxWidth,t=o.imageMaxHeight;if(i.width>e){const t=e/i.width;i.height=Math.floor(i.height*t),i.width=e,a*=t}if(i.height>t){const e=t/i.height;i.width=Math.floor(i.width*e),i.height=t,a*=e}}const l=this._extents[t];l&&f(l.extent,r)&&this._imageSizeEquals(r,l.imageSize,i)||(this._extents[t]={extent:y(r),imageSize:i,pixelRatio:a},this.suspended||this._fetch(t).catch((e=>{n(e)||s.getLogger(this).error(e)})))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(){return this._doRefresh()}async _doRefresh(e){if(this.suspended)return;const t=[];for(let r=0;r<this._extents.length;r++)this._extents[r]&&t.push(this._fetch(r,e));await Promise.allSettled(t)}async processResult(e,t,r){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const r=t.extent;if(new p(r[0],r[1],r[2],r[3],this._spatialReference).contains(e))return t}return null}getFetchOptions(){}async redraw(e,r){await t(this._images,(async(t,i)=>{t&&(await e(t,r),await this._createStageObjects(i,t.image,r))}))}_imageSizeEquals(e,t,r){if(!this.maximumDataResolution)return!1;const i=w(e)/this.maximumDataResolution.x,s=_(e)/this.maximumDataResolution.y,a=i/t.width,o=s/t.height,n=i/r.width,l=s/r.height,h=Math.abs(a-n),m=Math.abs(o-l),d=A.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return h<=d&&m<=d}async _fetch(e,t){if(this.suspended)return;const r=this._extents[e],i=r.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:y(i)});const o=this._images[e];o.loadingAbortController=a(o.loadingAbortController);const c=new p(i[0],i[1],i[2],i[3],this._spatialReference);if(0===c.width||0===c.height)return void this._clearImage(e);const g=new AbortController;o.loadingAbortController=g,l(t,(()=>g.abort()));const u=g.signal,f=this._waitFetchReady(u).then((async()=>{const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.getFetchOptions(),signal:u},{height:i,width:s}=r.imageSize;return"imagery"===this.layer.type?this.layer.internalFetchImage(c,s,i,t):this.layer.fetchImage(c,s,i,t)})).then((e=>{if(h(u))throw s.getLogger(this).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),m();return this.processResult(o,e)})).then((()=>{x(o.renderExtent,i)}));o.loadingPromise=f,await this._updatingHandles.addPromise(f.then((async()=>{d(u),await this._createStageObjects(e,o.image,u)})).catch((e=>{throw e&&!n(e)&&s.getLogger(this).error(e),e})).finally((()=>{f===o.loadingPromise&&(o.loadingPromise=null,o.loadingAbortController=null)})))}_clearImage(e){const t=this._images[e];if(t){null!=t.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],M.UPDATE),t.renderGeometry=null);const e=this.view._stage,r=t.texture;r?.unload(),e.remove(r),t.texture=null,e.remove(t.material),t.material=null,t.loadingAbortController=a(t.loadingAbortController),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,i){const s=this.view._stage,a=this._images[e],o=()=>{a.texture?.unload(),s.remove(a.texture),a.texture=null,a.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([a.renderGeometry],M.UPDATE),a.renderGeometry=null)};if(t){const n=new C(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:H.CLAMP_TO_EDGE,t:H.CLAMP_TO_EDGE}});if(await r(this._images[e===D.INNER?D.OUTER:D.INNER].loadingPromise),d(i),o(),await s.schedule((()=>n.load(s.renderView.renderingContext)),i),!n.loaded)return void o();let l;if(s.add(n),a.texture=n,a.material??=new P({texture:n}),a.material.setParameters({texture:n}),e===D.INNER)l=j(a.material,a.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void o();l=S(a.material,e,a.renderExtent)}a.renderGeometry=new L(l),a.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([a.renderGeometry],M.UPDATE)}else o(),s.remove(a.material),a.material=null}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return x(t,e);const r=this.view.basemapTerrain;return r.ready?v(e,r.extent,t):x(t,e)}_suspendedChangeHandler(){this.suspended?this.clear():this.refreshDebounced()}async _waitFetchReady(e){await c((()=>this.view.stationary),e),d(e)}};e([g()],V.prototype,"layer",void 0),e([g()],V.prototype,"suspended",void 0),e([g({readOnly:!0})],V.prototype,"fullExtentInLocalViewSpatialReference",void 0),e([g({readOnly:!0})],V.prototype,"visibleAtCurrentScale",null),e([g()],V.prototype,"updating",void 0),V=e([u("esri.views.3d.layers.DynamicLayerView3D")],V);const N=V,z=y();export{N as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,on as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{DrapeSourceType as _}from"./interfaces.js";import{LayerView3D as f}from"./LayerView3D.js";import{MediaLayerInteraction as E}from"./support/MediaLayerInteraction.js";import{drapedZ as w}from"../terrain/OverlayRenderer.js";import{Attribute as v}from"../webgl-engine/lib/Attribute.js";import{ContentObjectType as D}from"../webgl-engine/lib/ContentObjectType.js";import{Geometry as b}from"../webgl-engine/lib/Geometry.js";import{DirtyState as R,DirtyOperation as j}from"../webgl-engine/lib/ModelDirtyTypes.js";import{Object3DHighlightStateID as I}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as H}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as G}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as A}from"../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as M}from"../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as T}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import P from"../../layers/MediaLayerView.js";import{defaultHighlightName as S}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";import{TextureWrapMode as O}from"../../webgl/enums.js";let V=class extends(f(P(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce(((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0)),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=_.Features,this.updatePolicy=A.SYNC,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o((async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)}),0);const{view:t,layer:r}=e;this._interaction=new E({view:t,layer:r}),this.addHandles(l((()=>this.interactionOptions),(e=>this._interaction.options=e),h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.basemapTerrain.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r((()=>e.basemapTerrain.overlayManager.unregisterDrapeSource(this))),m((()=>t.effectiveSource),"change",i),m((()=>t.effectiveSource),"refresh",i)]),this._updatingHandles.add((()=>this.suspended),i)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=new I(t?.name??S),n=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(i,n);for(const r of n){const e=this._highlightedElements.get(r);e?e.add(i):this._highlightedElements.set(r,new Set([i]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(i),this._renderer.modifyGeometries([t.renderGeometry],R.HIGHLIGHT))}return r((()=>{const e=this._elementsInHighlightedId.get(i);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(i);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(i),this._renderer.modifyGeometries([r.renderGeometry],R.HIGHLIGHT)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(i)}}))}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch((()=>{})))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map((e=>i.queryElements(u(e.extent,t),{signal:r}))))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach(((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))}))}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new U(i([this._updatingHandles.add((()=>e.opacity),(e=>r.getRenderData()?.material.setParameters({opacity:e}))),this._updatingHandles.add((()=>t.coords),(()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)})),this._updatingHandles.add((()=>e.content),(()=>this._initializeRenderData(t,r))),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch((()=>{}))),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view._stage.renderView.renderingContext),l=()=>{this.view._stage.add(a);const e=new T({textureId:a.id,opacity:i.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(r),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),m=[0,1,2,0,2,3],h=new b(e,[[M.POSITION,new v(o,m,3,!0)],[M.UV0,new v(d,m,2,!0)],[M.PERSPECTIVEDIVIDE,new v(l,m,1,!0)]]),c=new H(h,{layerUid:this.layer.uid,graphicUid:i.uid}),p=this._highlightedElements.get(i);p?.forEach((e=>c.geometry.addHighlight(e))),this._renderer.addGeometries([c],j.ADD),t.data=new C(c,a,e),this.emit("element-render-changed",{element:i})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch((()=>a.dispose()))):l()}_updateGeometry(e,t){const{coords:r,element:i}=e;if(null==r||null==i.content)return void this._destroyRenderData(i,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(r);n.renderGeometry.geometry.setAttributeData(M.POSITION,s);const a=this._getPerspectiveDivideAttributeArray(s,i.contentWidth,i.contentHeight);n.renderGeometry.geometry.setAttributeData(M.PERSPECTIVEDIVIDE,a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],R.GEOMETRY),this.emit("element-render-changed",{element:i})}_getPositionAttributeArray(e){const[t,r,i,n]=e.rings[0];return[t[0],t[1],w,n[0],n[1],w,i[0],i[1],w,r[0],r[1],w]}_getPerspectiveDivideAttributeArray(e,t,r){a(z,[0,0,t,0,t,r,0,r],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const i=z[6]/z[8]*t,n=z[7]/z[8]*r;return[1,1+i,1+i+n,1+n]}_destroyRenderData(e,t){const r=t.data;if(null==r)return;if(t.data=null,r?.type===D.Texture)return void r.dispose();const i=r.texture;i.unload(),this.view._stage.remove(i),this._renderer.removeGeometries([r.renderGeometry],j.REMOVE),this.emit("element-render-changed",{element:e})}_createTexture(e){const r=e instanceof HTMLImageElement?e.naturalWidth:e.width,i=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new G(e,{wrap:{s:O.CLAMP_TO_EDGE,t:O.CLAMP_TO_EDGE},preMultiplyAlpha:!0,width:r,height:i,mipmap:!0,updateCallback:()=>this.view.basemapTerrain.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],V.prototype,"type",void 0),e([c()],V.prototype,"layer",void 0),e([c()],V.prototype,"interactive",null),e([c()],V.prototype,"selectedElement",null),e([c({readOnly:!0})],V.prototype,"visibleAtCurrentScale",null),V=e([p("esri.views.3d.layers.MediaLayerView3D")],V);const z=g();class U{constructor(e){this.handle=e}getRenderData(){return this.data?.type===D.Texture?null:this.data}}class C{constructor(e,t,r){this.renderGeometry=e,this.texture=t,this.material=r,this.type="RenderData"}}const W=V;export{W as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,on as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{DrapeSourceType as _}from"./interfaces.js";import{LayerView3D as f}from"./LayerView3D.js";import{MediaLayerInteraction as E}from"./support/MediaLayerInteraction.js";import{drapedZ as w}from"../terrain/OverlayRenderer.js";import{Attribute as v}from"../webgl-engine/lib/Attribute.js";import{ContentObjectType as D}from"../webgl-engine/lib/ContentObjectType.js";import{Geometry as b}from"../webgl-engine/lib/Geometry.js";import{DirtyState as R,DirtyOperation as j}from"../webgl-engine/lib/ModelDirtyTypes.js";import{Object3DHighlightStateID as H}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as I}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as G}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as A}from"../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as M}from"../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as T}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import P from"../../layers/MediaLayerView.js";import{defaultHighlightName as S}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";import{TextureWrapMode as O}from"../../webgl/enums.js";let V=class extends(f(P(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce(((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0)),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=_.Features,this.updatePolicy=A.SYNC,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o((async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)}),0);const{view:t,layer:r}=e;this._interaction=new E({view:t,layer:r}),this.addHandles(l((()=>this.interactionOptions),(e=>this._interaction.options=e),h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.basemapTerrain.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r((()=>e.basemapTerrain.overlayManager.unregisterDrapeSource(this))),m((()=>t.effectiveSource),"change",i),m((()=>t.effectiveSource),"refresh",i)]),this._updatingHandles.add((()=>this.suspended),i)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=new H(t?.name??S),n=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(i,n);for(const r of n){const e=this._highlightedElements.get(r);e?e.add(i):this._highlightedElements.set(r,new Set([i]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(i),this._renderer.modifyGeometries([t.renderGeometry],R.HIGHLIGHT))}return r((()=>{const e=this._elementsInHighlightedId.get(i);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(i);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(i),this._renderer.modifyGeometries([r.renderGeometry],R.HIGHLIGHT)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(i)}}))}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch((()=>{})))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map((e=>i.queryElements(u(e.extent,t),{signal:r}))))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach(((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))}))}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new U(i([this._updatingHandles.add((()=>e.opacity),(e=>r.getRenderData()?.material.setParameters({opacity:e}))),this._updatingHandles.add((()=>t.coords),(()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)})),this._updatingHandles.add((()=>e.content),(()=>this._initializeRenderData(t,r))),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch((()=>{}))),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view._stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view._stage.add(a);const e=new T({texture:a,opacity:i.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(r),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),m=[0,1,2,0,2,3],h=new b(e,[[M.POSITION,new v(o,m,3,!0)],[M.UV0,new v(d,m,2,!0)],[M.PERSPECTIVEDIVIDE,new v(l,m,1,!0)]]),c=new I(h,{layerUid:this.layer.uid,graphicUid:i.uid}),p=this._highlightedElements.get(i);p?.forEach((e=>c.geometry.addHighlight(e))),this._renderer.addGeometries([c],j.ADD),t.data=new C(c,a,e),this.emit("element-render-changed",{element:i})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch((()=>a.dispose()))):l()}_updateGeometry(e,t){const{coords:r,element:i}=e;if(null==r||null==i.content)return void this._destroyRenderData(i,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(r);n.renderGeometry.geometry.setAttributeData(M.POSITION,s);const a=this._getPerspectiveDivideAttributeArray(s,i.contentWidth,i.contentHeight);n.renderGeometry.geometry.setAttributeData(M.PERSPECTIVEDIVIDE,a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],R.GEOMETRY),this.emit("element-render-changed",{element:i})}_getPositionAttributeArray(e){const[t,r,i,n]=e.rings[0];return[t[0],t[1],w,n[0],n[1],w,i[0],i[1],w,r[0],r[1],w]}_getPerspectiveDivideAttributeArray(e,t,r){a(z,[0,0,t,0,t,r,0,r],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const i=z[6]/z[8]*t,n=z[7]/z[8]*r;return[1,1+i,1+i+n,1+n]}_destroyRenderData(e,t){const r=t.data;if(null==r)return;if(t.data=null,r?.type===D.Texture)return void r.dispose();const i=r.texture;i.unload(),this.view._stage.remove(i),this._renderer.removeGeometries([r.renderGeometry],j.REMOVE),this.emit("element-render-changed",{element:e})}_createTexture(e){const r=e instanceof HTMLImageElement?e.naturalWidth:e.width,i=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new G(e,{wrap:{s:O.CLAMP_TO_EDGE,t:O.CLAMP_TO_EDGE},preMultiplyAlpha:!0,width:r,height:i,mipmap:!0,updateCallback:()=>this.view.basemapTerrain.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],V.prototype,"type",void 0),e([c()],V.prototype,"layer",void 0),e([c()],V.prototype,"interactive",null),e([c()],V.prototype,"selectedElement",null),e([c({readOnly:!0})],V.prototype,"visibleAtCurrentScale",null),V=e([p("esri.views.3d.layers.MediaLayerView3D")],V);const z=g();class U{constructor(e){this.handle=e}getRenderData(){return this.data?.type===D.Texture?null:this.data}}class C{constructor(e,t,r){this.renderGeometry=e,this.texture=t,this.material=r,this.type="RenderData"}}const W=V;export{W as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{shuffle as t}from"../../../../core/arrayUtils.js";import{baseObjectMemory as e}from"../../../../core/memoryEstimations.js";import{signal as s}from"../../../../core/signal.js";import{create as i,diameter as r}from"../../../../geometry/support/aaBoundingBox.js";import{create as u,fromExtent as a,intersects as h,copy as n,positiveInfinity as f,intersection as _}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as l,estimateSize as m,getObjectId as o,computeAABB as c}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as d}from"../graphics/graphicUtils.js";const F=16438;class g{constructor(t){this.descriptor=t,this._numVertices=0,this._featuresMissing=s(!0),this._fetchFailed=s(!1),this._sorted=!1,this._numFeatures=E,this._emptyFeatureRatio=s(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=s(0),this._featureLimit=s(0),this._fetchStatus=p.FETCH_NEEDED,this.fetchingResolution=this.displayingResolution=t.resolution}get featuresMissing(){return this._featuresMissing.value}set featuresMissing(t){this._featuresMissing.value=t}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=this.isFetched&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get hasAllFeatures(){return!(this.featuresMissing||this.fetchFailed||this.hasFeatureLimit)}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s,this._features=t,this._featuresLength.value=t?.length??0,this._sorted=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce(((t,e)=>t+l(e.geometry)),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce(((t,{geometry:e})=>Math.max(t,d(e)??0)),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures:this._features?this._features.length:0}set numFeatures(t){this._numFeatures=t}get hasPreciseFeatureCount(){return this._numFeatures>E}get needsFeatureCount(){return this._numFeatures===E}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateMemoryEstimates(),this._estimatedSize}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateMemoryEstimates(){if(this._estimatedSize<0){if(this._estimatedSize=0,this._estimatedUnusedSize=0,this._features)for(let t=0;t<this._features.length;++t){const e=m(this._features[t]);this._estimatedSize+=e,t>=this.featureLimit&&(this._estimatedUnusedSize+=e)}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=m(this._features[t]);return!0}return!1}get fetchStatus(){return this._fetchStatus}requestFetch(){this._fetchStatus=p.FETCH_NEEDED}requestRefetch(){this._fetchStatus=p.REFETCH_NEEDED}startFetch(){this._fetchStatus=this.needsRefetch?p.REFETCHING:p.FETCHING}fetchDone(t){this._fetchStatus=t?p.FULL:p.DONE}get isFetching(){return this._fetchStatus===p.FETCHING||this._fetchStatus===p.REFETCHING}get isRefetching(){return this._fetchStatus===p.REFETCHING}get needsFetch(){return this._fetchStatus===p.FETCH_NEEDED||this._fetchStatus===p.REFETCH_NEEDED}get needsRefetch(){return this._fetchStatus===p.REFETCH_NEEDED}get isFetched(){return this._fetchStatus===p.DONE||this._fetchStatus===p.FULL}isFullyFetched(t){return!!this.features&&(this.features.length>=t||this.fetchStatus===p.FULL)}resetFetching(){this._fetchStatus=this.isRefetching?p.REFETCH_NEEDED:p.FETCH_NEEDED}get needsDisplayUpdate(){return!!this._features&&!L(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(a(t,R),h(this.descriptor.extent,R))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(a(t,e),_(e,s,e)):n(e,s),e):(n(e,f),e)}_shuffle(e){this._features?.sort(((t,s)=>o(t,e)-o(s,e))),t(this._features,F)}_sortBySize(t){this._features?.sort(((e,s)=>r(c(s.geometry,N))-r(c(e.geometry,N))||o(e,t)-o(s,t)))}reduceFeatures(t,e,s,i){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let r=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&(this.featureLimit=this._features.length,this._fetchStatus===p.DONE&&this._features.length>0&&(this._fetchStatus=p.REFETCH_NEEDED,r=!0)),!this._sorted&&t<1&&(i===D.RANDOM?this._shuffle(s):this._sortBySize(s),this._sorted=!0,this._estimatedUnusedSizeDirty=!0);const u=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>u&&(this._features.length=u,this._featuresLength.value=u,this.featuresMissing=!0,this._fetchStatus===p.FULL&&(this._fetchStatus=p.DONE)),r}get cache(){return new y(this,this._features,this._numFeatures,this._emptyFeatureRatio.value)}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this._fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0}}const E=-1,S=-2;var p,D;!function(t){t[t.FETCH_NEEDED=0]="FETCH_NEEDED",t[t.REFETCH_NEEDED=1]="REFETCH_NEEDED",t[t.FETCHING=2]="FETCHING",t[t.REFETCHING=3]="REFETCHING",t[t.DONE=4]="DONE",t[t.FULL=5]="FULL"}(p||(p={})),function(t){t[t.SIZE=0]="SIZE",t[t.RANDOM=1]="RANDOM"}(D||(D={}));class y{constructor(t,s,i,r){this.features=s,this.numFeatures=i,this.emptyFeatureRatio=r,this.cachedMemory=e+t.estimatedSize,this.resolution=t.displayingResolution,this.availableFields=t.availableFields,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing}}function L(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}const R=u(),N=i();export{g as FeatureTile,y as FeatureTileCacheItem,D as ReduceMode,S as failedFeatureCount};
5
+ import{shuffle as t}from"../../../../core/arrayUtils.js";import{baseObjectMemory as e}from"../../../../core/memoryEstimations.js";import{signal as s}from"../../../../core/signal.js";import{create as i,diameter as r}from"../../../../geometry/support/aaBoundingBox.js";import{create as u,fromExtent as a,intersects as h,copy as n,positiveInfinity as f,intersection as _}from"../../../../geometry/support/aaBoundingRect.js";import{numVertices as l,estimateSize as m,getObjectId as o,computeAABB as c}from"../../../../layers/graphics/dehydratedFeatures.js";import{computeMaxZ as d}from"../graphics/graphicUtils.js";const F=16438;class g{constructor(t){this.descriptor=t,this._numVertices=0,this._featuresMissing=s(!0),this._fetchFailed=s(!1),this._sorted=!1,this._numFeatures=E,this._emptyFeatureRatio=s(0),this._estimatedSize=-1,this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._displayingFeatures=null,this.alive=!0,this.filtered=!1,this._features=null,this._featuresLength=s(0),this._featureLimit=s(0),this._fetchStatus=p.FETCH_NEEDED,this.fetchingResolution=this.displayingResolution=t.resolution}get featuresMissing(){return this._featuresMissing.value}set featuresMissing(t){this._featuresMissing.value=t}get missingAttributes(){return this._missingAttributes}get fetchFailed(){return this._fetchFailed.value}set fetchFailed(t){this._fetchFailed.value=t}get displayingFeatures(){return this._displayingFeatures}set displayingFeatures(t){this._displayingFeatures=t,this.extentIncludingBorrowedFeatures=null}get perTileMaximumNumberOfFeaturesExceeded(){const t=this.isFetched&&this.featuresMissing;return!this.filtered&&(t||this.hasFeatureLimit)}get features(){return this._features}get featureLimit(){return this._featureLimit.value}set featureLimit(t){this._featureLimit.value!==t&&(this._featureLimit.value=t,this._estimatedUnusedSizeDirty=!0)}get hasFeatureLimit(){return this.featureLimit!==this._featuresLength.value}get hasAllFeatures(){return!this.featuresMissing&&!this.fetchFailed&&!this.hasFeatureLimit}get availableFields(){return this._availableFields}setFeatures(t,e,s,i){this._availableFields=s,this._features=t,this._featuresLength.value=t?.length??0,this._sorted=!1,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0,this._missingAttributes=i,t&&t.length>0?(this._emptyFeatureRatio.value=e/(t.length+e),this._numVertices=t.reduce(((t,e)=>t+l(e.geometry)),0)):(this._emptyFeatureRatio.value=0,this._numVertices=0)}computeZQuantizationFactor(){if(this._features&&this._features.length>0){const t=this._features.reduce(((t,{geometry:e})=>Math.max(t,d(e)??0)),0);return Math.floor(t/this.descriptor.planetRadius)+1}return 1}get emptyFeatureRatio(){return this._emptyFeatureRatio.value}get numFeatures(){return this.hasPreciseFeatureCount?this._numFeatures:this._features?this._features.length:0}set numFeatures(t){this._numFeatures=t}get hasPreciseFeatureCount(){return this._numFeatures>E}get needsFeatureCount(){return this._numFeatures===E}get numVertices(){return this._numVertices}get id(){return this.descriptor.id}get estimatedSize(){return this.updateMemoryEstimates(),this._estimatedSize}get estimatedUnusedSize(){return this._estimatedUnusedSize}updateMemoryEstimates(){if(this._estimatedSize<0){if(this._estimatedSize=0,this._estimatedUnusedSize=0,this._features)for(let t=0;t<this._features.length;++t){const e=m(this._features[t]);this._estimatedSize+=e,t>=this.featureLimit&&(this._estimatedUnusedSize+=e)}return!0}if(this._estimatedUnusedSizeDirty){if(this._estimatedUnusedSize=0,this._estimatedUnusedSizeDirty=!1,this._features)for(let t=this.featureLimit;t<this._features.length;++t)this._estimatedUnusedSize+=m(this._features[t]);return!0}return!1}get fetchStatus(){return this._fetchStatus}requestFetch(){this._fetchStatus=p.FETCH_NEEDED}requestRefetch(){this._fetchStatus=p.REFETCH_NEEDED}startFetch(){this._fetchStatus=this.needsRefetch?p.REFETCHING:p.FETCHING}fetchDone(t){this._fetchStatus=t?p.FULL:p.DONE}get isFetching(){return this._fetchStatus===p.FETCHING||this._fetchStatus===p.REFETCHING}get isRefetching(){return this._fetchStatus===p.REFETCHING}get needsFetch(){return this._fetchStatus===p.FETCH_NEEDED||this._fetchStatus===p.REFETCH_NEEDED}get needsRefetch(){return this._fetchStatus===p.REFETCH_NEEDED}get isFetched(){return this._fetchStatus===p.DONE||this._fetchStatus===p.FULL}isFullyFetched(t){return!!this.features&&(this.features.length>=t||this.fetchStatus===p.FULL)}resetFetching(){this._fetchStatus=this.isRefetching?p.REFETCH_NEEDED:p.FETCH_NEEDED}get needsDisplayUpdate(){return!!this._features&&!L(this._features,this.displayingFeatures,this.featureLimit)}intersects(t){return null==t||!this.descriptor.extent||(a(t,R),h(this.descriptor.extent,R))}intersectionIncludingBorrowed(t,e){const s=null!=this.extentIncludingBorrowedFeatures?this.extentIncludingBorrowedFeatures:this.descriptor.extent;return t||s?(null!=t?(a(t,e),_(e,s,e)):n(e,s),e):(n(e,f),e)}_shuffle(e){this._features?.sort(((t,s)=>o(t,e)-o(s,e))),t(this._features,F)}_sortBySize(t){this._features?.sort(((e,s)=>r(c(s.geometry,N))-r(c(e.geometry,N))||o(e,t)-o(s,t)))}reduceFeatures(t,e,s,i){if(t<=0)return!1;if(!this._features)return this.featureLimit=0,!1;let r=!1;this.featureLimit=Math.ceil(this.numFeatures*t),this.featureLimit>this._features.length&&(this.featureLimit=this._features.length,this._fetchStatus===p.DONE&&this._features.length>0&&(this._fetchStatus=p.REFETCH_NEEDED,r=!0)),!this._sorted&&t<1&&(i===D.RANDOM?this._shuffle(s):this._sortBySize(s),this._sorted=!0,this._estimatedUnusedSizeDirty=!0);const u=Math.max(this.featureLimit,Math.ceil(e*this.numFeatures));return this._features.length>u&&(this._features.length=u,this._featuresLength.value=u,this.featuresMissing=!0,this._fetchStatus===p.FULL&&(this._fetchStatus=p.DONE)),r}get cache(){return new y(this,this._features,this._numFeatures,this._emptyFeatureRatio.value)}set cache(t){this.requestController=null,this._availableFields=t.availableFields,this._features=t.features,this._featuresLength.value=t.features?.length??0,this._numFeatures=t.numFeatures,this._emptyFeatureRatio.value=t.emptyFeatureRatio,this._fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing,this._estimatedSize=-1,this._estimatedUnusedSizeDirty=!0}}const E=-1,S=-2;var p,D;!function(t){t[t.FETCH_NEEDED=0]="FETCH_NEEDED",t[t.REFETCH_NEEDED=1]="REFETCH_NEEDED",t[t.FETCHING=2]="FETCHING",t[t.REFETCHING=3]="REFETCHING",t[t.DONE=4]="DONE",t[t.FULL=5]="FULL"}(p||(p={})),function(t){t[t.SIZE=0]="SIZE",t[t.RANDOM=1]="RANDOM"}(D||(D={}));class y{constructor(t,s,i,r){this.features=s,this.numFeatures=i,this.emptyFeatureRatio=r,this.cachedMemory=e+t.estimatedSize,this.resolution=t.displayingResolution,this.availableFields=t.availableFields,this.fetchStatus=t.fetchStatus,this.featuresMissing=t.featuresMissing}}function L(t,e,s){if(null==e||null==t||s!==e.length||s>t.length)return!1;for(let i=0;i<s;++i)if(t[i]!==e[i])return!1;return!0}const R=u(),N=i();export{g as FeatureTile,y as FeatureTileCacheItem,D as ReduceMode,S as failedFeatureCount};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{filterInPlace as s}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import o from"../../../../core/ReactiveMap.js";import{on as u,watch as l}from"../../../../core/reactiveUtils.js";import{schedule as h}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as c}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as _,equals as m,clone as g,expand as F,toExtent as y}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as T,hasVertices as x}from"../../../../layers/graphics/dehydratedFeatures.js";import R from"../../../../rest/support/QuantizationParameters.js";import v from"../../../../rest/support/Query.js";import{ViewingMode as b}from"../../../ViewingMode.js";import{MultiFeatureReference as C,SingleFeatureReference as E}from"./featureReference.js";import{failedFeatureCount as M,FeatureTile as D,ReduceMode as w}from"./FeatureTile.js";import{tilesAreRelated as U}from"../../terrain/tileUtils.js";import{ImmediateTask as j,TaskPriority as O}from"../../../support/Scheduler.js";let A=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this._featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.numFeatures)),e}get hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(P)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void i.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const s=null!=e?e.clone():null;this._set("filterExtent",s),this._reclip(s,t)}_updateTileZQuantization(e){if(this.context.viewingMode===b.Global){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.running=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._frameTask=j,this._featureTiles=new o,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1}initialize(){this.addHandles([u((()=>this.tileDescriptors),"change",(()=>this._setDirty()),{sync:!0,onListenerAdd:()=>this._setDirty()}),l((()=>this._tileZQuantization),(()=>this.refetch()))]),this._objectIdField=this.context.objectIdField,this.FeatureReferenceClass=this.context.capabilities.supportsMultipleResolutions?C:E;const e=this.context.scheduler;null!=e&&(this._frameTask=e.registerTask(O.FEATURE_TILE_FETCHER,this)),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach((t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields?.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(a(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,s=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(s||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(T(e,this._objectIdField))));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())}))}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?T(i,t):null}async _applyEditsAddUpdateFeatures(e,t,s){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const i of e){const e=i.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,s);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(T(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Q(e.availableFields,a.fields),N(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:H})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();const{numFeatures:i,fetchingResolution:r,descriptor:a,isFetched:n}=e;return this._supportsResolution&&i>0&&r!==a.resolution&&n&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let s=!1;for(const i of e){if(!i.needsFetch)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(i.id):null;if(e?.resolution!==i.displayingResolution){if(this._needsNumFeatures(i)){const e=new AbortController,r=this._fetchTileCount(i,e.signal);this._handleRequest(i,r,e,(()=>i.resetFetching()),(()=>i.numFeatures=M)),s=!0,t.madeProgress()}if(t.done)return!0}else i.cache=e,i.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(s)return t.hasProgressed;for(const r of e)if(r.needsFetch){const e=new AbortController,s=this._fetchTile(r,e.signal);if(this._handleRequest(r,s,e,(e=>r.fetchDone(e)),(e=>{r.setFeatures([],0,null,void 0),this._invalidateCounts(),r.featuresMissing=!1,r.fetchFailed=!0,this.context.logFetchError(i.getLogger(this),e)})),t.madeProgress())return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,L),i.intersectionIncludingBorrowed(e,k),m(L,k)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=T(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,this._set("running",this._dirty),e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetch?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=I(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new D(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&U(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=g(e.descriptor.extent),F(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(T(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(!1):e.requestFetch()}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles())}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),z(e),!1;const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,P(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>v.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const a=this._createQuery(e);if(a.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(a,t),d=!u||a.maxRecordCountFactor>=v.MAX_MAX_RECORD_COUNT_FACTOR;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,q(l),N(void 0,h)),this._updateTileZQuantization(e)}),t),n(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,a=0,o=this._maximumFeaturesForTile(e)-a;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),a+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?.concat(p)??p,h=Q(h,_),l=N(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()}),t),n(t),o=this._maximumFeaturesForTile(e)-a,!c||!f||o<=0)return!f}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();t.resultType=this._resultType(e);const s=P(e);return s||(t.geometry=y(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),"tile"!==t.resultType&&this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),!s&&this.context.effectiveDisplayFilter&&(t.where=c(t.where,this.context.effectiveDisplayFilter.where)),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(P(e)||!this._supportsResolution)return null;const t=this.context.viewingMode===b.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new R({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;return s(e,(({geometry:e})=>x(e))),t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!P(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case"tile":if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case"standard":if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||S}_resultType(e){if(this.context.capabilities.supportsResultType)return P(e)?"standard":"tile"}get _reduceMode(){const e=this.context.geometryType;return"polygon"===e||"polyline"===e?w.SIZE:w.RANDOM}_handleRequest(e,t,s,i,r){e.startFetch(),e.requestController=s;let n=!1;t.then((t=>{e.requestController=null,i(t)})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchDone(!1)),a(t)?n=!0:r(t)})).then((()=>{n||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(h((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=T(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=T(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+Z,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetch||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function P(e){return"dummy-tile-full-extent"===e.id}function I(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function z(e){e.setFeatures([],0,null,void 0),e.featuresMissing=!1}function q(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function Q(e,t){if(null==e||null==t)return q(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function N(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:i,attribute:a}of t)r(e,i,s).add(a);return e}e([p({constructOnly:!0})],A.prototype,"features",void 0),e([p()],A.prototype,"tileDescriptors",void 0),e([p({value:1/0})],A.prototype,"maximumNumberOfFeatures",null),e([p({value:1})],A.prototype,"memoryFactor",null),e([p({value:1})],A.prototype,"lodFactor",null),e([p()],A.prototype,"useTileCount",null),e([p({readOnly:!0})],A.prototype,"updating",null),e([p({readOnly:!0})],A.prototype,"dataUpdating",void 0),e([p({readOnly:!0})],A.prototype,"running",void 0),e([p({readOnly:!0})],A.prototype,"updatingTotal",void 0),e([p({readOnly:!0})],A.prototype,"updatingRemaining",void 0),e([p({readOnly:!0})],A.prototype,"expectedFeatureDiff",void 0),e([p({readOnly:!0})],A.prototype,"memoryForUnusedFeatures",null),e([p({readOnly:!0})],A.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([p({readOnly:!0})],A.prototype,"totalVertices",null),e([p({readOnly:!0})],A.prototype,"totalFeatures",null),e([p({readOnly:!0})],A.prototype,"hasAllFeatures",null),e([p({readOnly:!0})],A.prototype,"hasFullGeometries",null),e([p()],A.prototype,"filterExtent",null),e([p({constructOnly:!0})],A.prototype,"context",void 0),e([p()],A.prototype,"_dirty",void 0),e([p()],A.prototype,"_suspended",void 0),e([p()],A.prototype,"_pendingEdits",void 0),e([p()],A.prototype,"_applyEditsTilesUpdated",void 0),e([p()],A.prototype,"_paused",null),e([p()],A.prototype,"_isFetching",void 0),A=e([f("esri.views.3d.layers.support.FeatureTileFetcher3D")],A);const S=2e3,L=_(),k=_(),H=6e5,Z=200;export{A as FeatureTileFetcher3D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{filterInPlace as s}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import i from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{isAbortError as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import o from"../../../../core/ReactiveMap.js";import{on as u,watch as l}from"../../../../core/reactiveUtils.js";import{schedule as h}from"../../../../core/scheduling.js";import{signal as d}from"../../../../core/signal.js";import{sqlAnd as c}from"../../../../core/sql.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as _,equals as m,clone as g,expand as F,toExtent as y}from"../../../../geometry/support/aaBoundingRect.js";import{getObjectId as T,hasVertices as x}from"../../../../layers/graphics/dehydratedFeatures.js";import R from"../../../../rest/support/QuantizationParameters.js";import v from"../../../../rest/support/Query.js";import{ViewingMode as b}from"../../../ViewingMode.js";import{MultiFeatureReference as C,SingleFeatureReference as E}from"./featureReference.js";import{failedFeatureCount as M,FeatureTile as D,ReduceMode as w}from"./FeatureTile.js";import{tilesAreRelated as U}from"../../terrain/tileUtils.js";import{TaskPriority as j,ImmediateTask as O}from"../../../support/Scheduler.js";let A=class extends t{set maximumNumberOfFeatures(e){e=e||1/0;const t=this._get("maximumNumberOfFeatures");e===t||e<1||(this._set("maximumNumberOfFeatures",e),this._maximumFeaturesUpdated(t,e))}set memoryFactor(e){this.memoryFactor!==e&&(this._set("memoryFactor",e),this._setDirty())}set lodFactor(e){this.lodFactor!==e&&(this._set("lodFactor",e),this._supportsResolution&&this.refetch())}get useTileCount(){return this._useTileCount&&null!=this.context.query.queryFeatureCount}set useTileCount(e){this._useTileCount=e,this.notifyChange("useTileCount")}get updating(){return this._dirty||!!this._pendingEdits||this._isFetching||(this.tileDescriptors?.updating??!1)}get running(){return this._dirty}get memoryForUnusedFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.estimatedUnusedSize)),e}get totalVertices(){let e=0;return this._featureTiles.forEach((t=>e+=t.numVertices)),e}get totalFeatures(){let e=0;return this._featureTiles.forEach((t=>e+=t.numFeatures)),e}get hasAllFeatures(){if(this._paused||this.dataUpdating)return!1;for(const e of this._featureTiles.values())if(!this.hasFullGeometries&&0!==e.emptyFeatureRatio||!e.hasAllFeatures)return!1;return!0}get hasFullGeometries(){if(!this._supportsResolution)return!0;return this.tileDescriptors.some(P)||!this.context.capabilities.supportsQuantization&&"polyline"!==this.context.geometryType}set filterExtent(e){if(null!=e&&this.context.tilingScheme&&!e.spatialReference.equals(this.context.tilingScheme.spatialReference))return void i.getLogger(this).error("#filterExtent=","extent needs to be in the same spatial reference as the tiling scheme");const t=this._get("filterExtent");if(t===e||null!=t&&e&&t.equals(e))return;const s=null!=e?e.clone():null;this._set("filterExtent",s),this._reclip(s,t)}_updateTileZQuantization(e){if(this.context.viewingMode===b.Global){const t=e.computeZQuantizationFactor();this._zQuantizationFactor.value<t&&(this._zQuantizationFactor.value=t)}}get _tileZQuantization(){return this.context.isDraped?1:this._zQuantizationFactor.value}constructor(e){super(e),this._useTileCount=!1,this.dataUpdating=!1,this.updatingTotal=0,this.updatingRemaining=0,this.expectedFeatureDiff=0,this.maximumNumberOfFeaturesExceeded=!1,this._fullRatio=1,this._farRatio=1,this._zQuantizationFactor=d(1),this._changes={updates:{adds:new Array,removes:new Array},adds:new Array,removes:new Array},this._featureTiles=new o,this._displayingFeatureReferences=new Map,this._numDisplayingFeatureReferences=0,this._dirty=!1,this._suspended=!0,this._pendingEdits=null,this._applyEditsTilesUpdated=!1,this._isFetching=!1;const t=e.context;this._frameTask=t.scheduler?.registerTask(j.FEATURE_TILE_FETCHER,this)??O,this.FeatureReferenceClass=t.capabilities.supportsMultipleResolutions?C:E,this._objectIdField=t.objectIdField}initialize(){this.addHandles([u((()=>this.tileDescriptors),"change",(()=>this._setDirty())),l((()=>this._tileZQuantization),(()=>this.refetch()))]),this._setDirty()}destroy(){this._frameTask.remove(),this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._removeTile(e)})),this._featureTiles.clear(),this._displayingFeatureReferences.clear(),this._pendingEdits?.controller.abort(),this._pendingEdits=null}get _paused(){return this._suspended||!!this._pendingEdits}restart(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._clearTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}refetch(){this._featureTiles.forEach((e=>{this._cancelFetchTile(e),this._resetFetchTile(e)})),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._setDirty()}suspend(){this._suspended||(this._suspended=!0,this._pause(),this._setDirty())}resume(){this._suspended&&(this._suspended=!1,this._unpause())}getMissingAttributesForFeature(e){for(const t of this._featureTiles.values()){const s=t.missingAttributes?.get(e);if(null!=s)return s}}_pause(){this._paused&&(this._featureTiles.forEach((e=>this._cancelFetchTile(e))),this._updated())}_unpause(){this._paused||this._setDirty()}get availableFields(){let e=null;return this._featureTiles.forEach((t=>{null!=t.displayingFeatures&&0!==t.displayingFeatures.length&&(null==e?e=new Set(t.availableFields):e.forEach((s=>{t.availableFields?.has(s)||e.delete(s)})))})),null!=e?e:new Set}applyEdits(e){this._pendingEdits||(this._pendingEdits={edits:Promise.resolve(),count:0,controller:new AbortController},this._pause());const t=this._pendingEdits;t.count++;const s=t.edits.then((()=>e.result.catch((e=>{if(a(e))throw e;return null})).then((e=>e?(this._applyEditsDeleteFeatures(e.deletedFeatures),this._applyEditsAddUpdateFeatures(e.addedFeatures,e.updatedFeatures,t.controller.signal).then((()=>e))):e)).then((e=>(0==--t.count&&(this._pendingEdits===t&&(this._pendingEdits=null),null!=this.context.memoryCache&&this.context.memoryCache.clear(),this._applyEditsTilesUpdated=!1,this._unpause()),e)))));return t.edits=s,this._updated(),s}_applyEditsDeleteFeatures(e){if(0===e.length)return;const t=this.context.globalIdField,s=t&&this.availableFields.has(t),r=new Set,a=this._objectIdField;e.forEach((({objectId:e,globalId:n})=>{(!e||e<0)&&t&&n&&(s||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(n,a,t)),null!=e&&e>=0&&r.add(e)})),this._featureTiles.forEach((e=>{if(!e.features)return;const t=e.features.filter((e=>!r.has(T(e,this._objectIdField))));t.length!==e.features.length&&(this._applyEditsTileUpdated(),e.setFeatures(t,0,e.availableFields,e.missingAttributes),this._updateTileZQuantization(e),this._invalidateCounts())}))}_objectIdFromGlobalId(e,t,s){if(null==e)return null;const i=this.features.find((t=>t.attributes?.[s]===e));return i?T(i,t):null}async _applyEditsAddUpdateFeatures(e,t,s){const{objectIdField:r,globalIdField:a}=this.context,n=a&&this.availableFields.has(a),o=new Set,u=new Set;for(const i of e){const e=i.objectId;null!=e&&o.add(e)}for(const{objectId:h,globalId:d}of t){let e=h;(null==e||e<0)&&a&&(n||i.getLogger(this).errorOncePerTick(`Editing the specified service requires the layer's globalIdField, ${a} to be included the layer's outFields for updates to be reflected in the view`),e=this._objectIdFromGlobalId(d,r,a)),null!=e&&e>=0&&(o.add(e),u.add(e))}if(0===o.size)return;const l=[];this._featureTiles.forEach((e=>{const t=this._applyEditsAddUpdateTile(e,o,u,s);t&&l.push(t)})),this._updated(),await Promise.allSettled(l)}async _applyEditsAddUpdateTile(e,t,s,i){if(!e.features)return;e.fetchingResolution=e.descriptor.resolution;const r=this._createQuery(e);r.resultType=void 0,r.cacheHint=!1,r.objectIds=Array.from(t);const a=await this._queryFeatures(r,i);let n=null;if(s.size>0){const t=e.features.filter((e=>!s.has(T(e,this._objectIdField))));t.length!==e.features.length&&(n=t)}if(a.features.length>0){n||(n=e.features.slice());for(const e of a.features)n.push(e)}n&&(e.hasPreciseFeatureCount&&(e.numFeatures=Math.max(e.numFeatures,n.length)),this._applyEditsTileUpdated(),e.setFeatures(n,0,Q(e.availableFields,a.fields),N(e.missingAttributes,a.missingAttributes)),this._updateTileZQuantization(e),this._invalidateCounts())}_applyEditsTileUpdated(){this._applyEditsTilesUpdated||(this._applyEditsTilesUpdated=!0,this._updated())}_queryFeatures(e,t){return this.context.query.queryFeaturesDehydrated(e,{signal:t,timeout:H})}_setDirty(){this._dirty=!0,this._updated()}runTask(e){const t=this._frameTask.processQueue(e);if(!this._dirty||!this.initialized)return t;this._dirty=!1;const s=this._getListOfTiles();if(this._markTilesNotAlive(s),!e.run((()=>this._addTiles(s,e)))||!e.run((()=>this._filterExtentTiles(s,e)))||!e.run((()=>this._removeTiles(s,e)))||e.done)return void this._setDirty();const i=this._sortTiles(s);e.run((()=>this._showTiles(i,e)))&&e.run((()=>this._fetchTiles(i,e)))&&e.run((()=>this._updateMemoryEstimates(i,e)))||this._setDirty(),this._updated(),this.updating||this._updateMaximumNumberOfFeaturesExceeded()}_markTilesNotAlive(e){for(const t of e)t.alive=!1}_addTiles(e,t){return!(this._suspended||!this.tileDescriptors)&&(this.tileDescriptors.forEach((s=>{const i=this._featureTiles.get(s.id);i?i.alive=!0:t.done||(e.push(this._addTile(s)),t.madeProgress())})),t.hasProgressed)}_filterExtentTiles(e,t){for(const s of e){if(t.done)break;s.alive&&(s.filtered=!s.intersects(this.filterExtent),s.filtered&&(this._clearTile(s),t.madeProgress()))}return t.hasProgressed}_removeTiles(e,t){for(let s=e.length-1;s>=0&&!t.done;s--){const i=e[s];i.alive||(this._removeTile(i),s!==e.length-1&&(e[s]=e[e.length-1]),e.pop(),t.madeProgress())}return t.hasProgressed}_sortTiles(e){return e.sort(((e,t)=>e.descriptor.loadPriority-t.descriptor.loadPriority)),e}_showTiles(e,t){const s=this._updateRatio(e),i=e=>{const t=this._fullRatio<1?s(e)*this._farRatio:1;e.reduceFeatures(t,this.memoryFactor,this._objectIdField,this._reduceMode)&&this._setDirty();const{numFeatures:i,fetchingResolution:r,descriptor:a,isFetched:n}=e;return this._supportsResolution&&i>0&&r!==a.resolution&&n&&(e.requestRefetch(),this._setDirty()),this._showTile(e)};for(const r of e)if(!t.run((()=>i(r)))){this._setDirty();break}return t.hasProgressed}_fetchTiles(e,t){if(this._paused)return!1;let s=!1;for(const i of e){if(!i.needsFetch)continue;const e=null!=this.context.memoryCache?this.context.memoryCache.pop(i.id):null;if(e?.resolution!==i.displayingResolution){if(this._needsNumFeatures(i)){const e=new AbortController,r=this._fetchTileCount(i,e.signal);this._handleRequest(i,r,e,(()=>i.resetFetching()),(()=>i.numFeatures=M)),s=!0,t.madeProgress()}if(t.done)return!0}else i.cache=e,i.numFeatures&&this._notifyDataUpdating(),this._setDirty(),this._scheduleUpdated(),t.madeProgress()}if(s)return t.hasProgressed;for(const r of e){if(!r.needsFetch)continue;const e=new AbortController,s=this._fetchTile(r,e.signal);if(this._handleRequest(r,s,e,(e=>r.fetchDone(e)),(e=>{r.featuresMissing=!0,r.fetchFailed=!0,this.context.logFetchError(i.getLogger(this),e)})),t.madeProgress(),t.done)return!0}return t.hasProgressed}_updateMemoryEstimates(e,t){return e.some((e=>!t.run((()=>e.updateMemoryEstimates()))&&(this._setDirty(),!0))),t.hasProgressed}_reclip(e,t){if(!this.initialized)return;const s=new Array;this._featureTiles.forEach((i=>{null!=i.displayingFeatures&&0!==i.displayingFeatures.length&&(i.intersectionIncludingBorrowed(t,L),i.intersectionIncludingBorrowed(e,k),m(L,k)||s.push(i))})),this._refreshDisplayingFeatures(s),this._updated()}_refreshDisplayingFeatures(e){const t=new Set,s=this._changes.updates;for(const i of e)if(null!=i.displayingFeatures)for(const e of i.displayingFeatures){const i=T(e,this._objectIdField);if(t.has(i))continue;t.add(i);const r=this._displayingFeatureReferences.get(i).feature;s.removes.push(r),s.adds.push(r)}this._applyChanges()}_updated(){let e=0;if(this._paused||this._featureTiles.forEach((t=>t.isFetching?++e:0)),this._isFetching=e>0,e>0||this._applyEditsTilesUpdated?this._notifyDataUpdating():this._dirty||this._set("dataUpdating",!1),this.updating){let t=0,s=0,i=0,r=0,a=0;const n=this._displayingFeatureReferences.size/this._numDisplayingFeatureReferences;this._featureTiles.forEach((e=>{if(++s,e.isFetching&&e.hasPreciseFeatureCount){const t=this._maximumFeaturesForTile(e)*(1-e.emptyFeatureRatio),s=null!=e.displayingFeatures?e.displayingFeatures.length*n:0;a+=t-s}e.needsFetch?++r:e.numFeatures>0&&(++i,t+=e.numFeatures)})),r+=e;let o=0,u=0;t?(u=t,o=Math.min(r*t/i,t)):(u=s,o=r),a=Math.min(this.maximumNumberOfFeatures-this.features.length,a),this._set("updatingTotal",u),this._set("updatingRemaining",o),this._set("expectedFeatureDiff",a)}else this._set("updatingTotal",0),this._set("updatingRemaining",0),this._set("expectedFeatureDiff",0);this.debugger?.update()}_updateMaximumNumberOfFeaturesExceeded(){for(const{perTileMaximumNumberOfFeaturesExceeded:e}of this._featureTiles.values())if(e)return void this._set("maximumNumberOfFeaturesExceeded",!0);this._set("maximumNumberOfFeaturesExceeded",!1)}_updateRatio(e){const t=I(e),s=e=>1/(1<<Math.max(0,t-e.descriptor.lij[0]));let i=0,r=0;for(const a of e){const e=a.numFeatures;i+=e,r+=e*s(a)}return this._fullRatio=Math.min(1,this.maximumNumberOfFeatures/i),this._farRatio=this.maximumNumberOfFeatures/r,this._scheduleUpdated(),s}_maximumFeaturesUpdated(e,t){e!==t&&(t>e&&this._featureTiles.forEach((e=>{if(!e.featuresMissing)return;const t=this._maximumFeaturesForTile(e);e.isFullyFetched(t)||(this._cancelFetchTile(e),this._resetFetchTile(e))})),this._setDirty())}_addTile(e){const t=new D(e);return this._featureTiles.set(t.id,t),this._resetFetchTile(t),this._referenceDisplayingFeaturesFromRelatedTiles(t),t}_referenceDisplayingFeaturesFromRelatedTiles(e){const t=e.displayingResolution;this._featureTiles.forEach((s=>{if(null!=s.displayingFeatures&&e!==s&&U(e.descriptor.lij,s.descriptor.lij)){null==e.displayingFeatures&&(e.displayingFeatures=[]),e.descriptor.extent&&s.descriptor.extent&&(e.extentIncludingBorrowedFeatures??=g(e.descriptor.extent),F(e.extentIncludingBorrowedFeatures,s.descriptor.extent,e.extentIncludingBorrowedFeatures));for(const i of s.displayingFeatures){e.displayingFeatures.push(i);const s=this._displayingFeatureReferences.get(T(i,this._objectIdField));s.ref(s.feature,t),this._numDisplayingFeatureReferences++}}})),e.featureLimit=null!=e.displayingFeatures?e.displayingFeatures.length:0}_removeTile(e){this._clearTile(e),this._featureTiles.delete(e.id)}_resetFetchTile(e){e.filtered=!e.intersects(this.filterExtent),e.filtered?e.needsFetch&&e.fetchDone(!1):e.requestFetch()}_cancelFetchTile(e){const t=e.requestController;null!=t&&(e.requestController=null,e.resetFetching(),t.abort())}async _fetchTileCount(e,t){e.numFeatures=await this._fetchCount(e,t),this._updateRatio(this._getListOfTiles())}async _fetchTile(e,t){e.fetchFailed=!1;const s=this._maximumFeaturesForTile(e);if(s<=0)return e.hasPreciseFeatureCount&&0===e.numFeatures||(e.fetchFailed=!0),z(e),!1;const i=this._getMaxRecordCount(e),r=Math.ceil(s/i);if(e.fetchingResolution=e.descriptor.resolution,P(e)||!this.context.capabilities.supportsMaxRecordCountFactor||e.numFeatures<=s&&r>v.MAX_MAX_RECORD_COUNT_FACTOR)return this._fetchPagedTile(e,t);const a=this._createQuery(e);if(a.maxRecordCountFactor=r,e.isRefetching&&e.features&&e.features.length>0){const t=Math.ceil(e.features.length/(1-e.emptyFeatureRatio)/i);a.maxRecordCountFactor=Math.max(t+1,a.maxRecordCountFactor)}const{features:o,exceededTransferLimit:u,fields:l,missingAttributes:h}=await this._queryFeatures(a,t),d=!u||a.maxRecordCountFactor>=v.MAX_MAX_RECORD_COUNT_FACTOR;return await this._frameTask.schedule((()=>{e.featuresMissing=e.hasPreciseFeatureCount&&o.length<e.numFeatures||!!u;const t=this._removeEmptyFeatures(o);e.setFeatures(o,t,q(l),N(void 0,h)),this._updateTileZQuantization(e)}),t),n(t),this._invalidateCounts(),d}async _fetchCount(e,t){return this.context.query.queryFeatureCount(this._createFeatureCountQuery(e),{signal:t})}async _fetchPagedTile(e,t){let s,i=0,r=0,a=0,o=this._maximumFeaturesForTile(e)-a;const u=this._getMaxRecordCount(e);let l,h=null;for(;;){const d=this._createQuery(e),c=this._setPagingParameters(d,i,o,u),{features:p,exceededTransferLimit:f,fields:_,missingAttributes:m}=await this._queryFeatures(d,t);if(await this._frameTask.schedule((()=>{c&&(i+=d.num),a+=p.length,r+=this._removeEmptyFeatures(p),e.featuresMissing=c&&e.hasPreciseFeatureCount&&i<e.numFeatures||!!f,s=s?.concat(p)??p,h=Q(h,_),l=N(l,m),e.setFeatures(s,r,h,l),this._updateTileZQuantization(e),this._invalidateCounts(),this._setDirty()}),t),n(t),o=this._maximumFeaturesForTile(e)-a,!c||!f||o<=0)return!f}}_createFeatureCountQuery(e){const t=this._createQuery(e);return this.context.capabilities.supportsCacheHint&&(t.resultType=void 0,t.cacheHint=!0),t}_createQuery(e){const t=this.context.createQuery();t.resultType=this._resultType(e);const s=P(e);return s||(t.geometry=y(e.descriptor.extent,this.context.tilingScheme.spatialReference)),this._setResolutionParams(t,e),"tile"!==t.resultType&&this.context.capabilities.supportsCacheHint&&(t.cacheHint=!0),!s&&this.context.effectiveDisplayFilter&&(t.where=c(t.where,this.context.effectiveDisplayFilter.where)),t}_setPagingParameters(e,t,s,i){return!!this.context.capabilities.supportsPagination&&(e.start=t,s>0&&this.context.capabilities.supportsMaxRecordCountFactor?(e.maxRecordCountFactor=Math.ceil(s/i),e.num=Math.min(e.maxRecordCountFactor*i,s)):e.num=Math.min(i),!0)}_getEffectiveTileResolution(e){if(P(e)||!this._supportsResolution)return null;const t=this.context.viewingMode===b.Global?this.context.tilingScheme.resolutionAtLevel(3):1/0;return Math.min(e.fetchingResolution,t)/this.lodFactor/this._tileZQuantization}get _supportsResolution(){return this.context.capabilities.supportsMultipleResolutions&&"point"!==this.context.geometryType}_setResolutionParams(e,t){const s=this._getEffectiveTileResolution(t);null!=s&&(this.context.capabilities.supportsQuantization?e.quantizationParameters=new R({mode:"view",originPosition:"upper-left",tolerance:s,extent:this.context.fullExtent}):"polyline"===this.context.geometryType&&(e.maxAllowableOffset=s))}_removeEmptyFeatures(e){const t=e.length;return s(e,(({geometry:e})=>x(e))),t-e.length}_needsNumFeatures(e){return this.useTileCount&&e.needsFeatureCount&&!P(e)}_getMaxRecordCount(e){switch(this._resultType(e)){case"tile":if(this.context.tileMaxRecordCount)return this.context.tileMaxRecordCount;break;case"standard":if(this.context.standardMaxRecordCount)return this.context.standardMaxRecordCount}return this.context.maxRecordCount||S}_resultType(e){if(this.context.capabilities.supportsResultType)return P(e)?"standard":"tile"}get _reduceMode(){const e=this.context.geometryType;return"polygon"===e||"polyline"===e?w.SIZE:w.RANDOM}_handleRequest(e,t,s,i,r){e.startFetch(),e.requestController=s;let n=!1;t.then((t=>{e.requestController=null,i(t)})).catch((t=>{e.requestController===s&&(e.requestController=null,e.fetchDone(!1)),a(t)?n=!0:r(t)})).then((()=>{n||this._setDirty(),this._scheduleUpdated()}))}_scheduleUpdated(){this.hasHandles("scheduleUpdated")||this.addHandles(h((()=>{this.removeHandles("scheduleUpdated"),this._updated()})),"scheduleUpdated")}_showTile(e){if(e.displayingFeatures&&!e.needsDisplayUpdate)return!1;const{features:t}=e;if(0===e.featureLimit||!t){const t=null!=e.displayingFeatures&&e.displayingFeatures.length>0;return this._hideTileFeatures(e),e.displayingFeatures=[],t}const s=e.fetchingResolution,{adds:i,updates:r}=this._changes,a=Math.min(e.featureLimit,t.length);e.featureLimit=a;for(let n=0;n<a;++n){const e=t[n],a=T(e,this._objectIdField),o=this._displayingFeatureReferences.get(a);if(o){const{oldVersion:t,newVersion:i}=o.ref(e,s);t!==i&&(t&&r.removes.push(t),i&&r.adds.push(i))}else this._displayingFeatureReferences.set(a,new this.FeatureReferenceClass(e,s)),i.push(e);this._numDisplayingFeatureReferences++}return this._hideTileFeatures(e),e.displayingResolution=e.fetchingResolution,this._applyChanges(),e.displayingFeatures=t.slice(0,a),!0}_hideTile(e){this._cancelFetchTile(e),this._hideTileFeatures(e)}_hideTileFeatures(e){if(null==e.displayingFeatures)return;const{updates:t,removes:s}=this._changes;for(const i of e.displayingFeatures){const r=T(i,this._objectIdField),a=this._displayingFeatureReferences.get(r);if(!a)continue;const{oldVersion:n,newVersion:o}=a.unref(e.displayingResolution);this._numDisplayingFeatureReferences--,n!==o&&(null==o?(this._displayingFeatureReferences.delete(r),n&&s.push(n)):(t.adds.push(o),n&&t.removes.push(n)))}this._applyChanges(),e.displayingFeatures=null}_notifyDataUpdating(){this._get("dataUpdating")||this._set("dataUpdating",!0)}_applyChanges(){const e=this._changes.updates;e.removes.length>0&&(this._notifyDataUpdating(),this.features.removeMany(e.removes),e.removes.length=0),e.adds.length>0&&(this._notifyDataUpdating(),this.features.addMany(e.adds),e.adds.length=0);const t=this._changes.adds,s=this._changes.removes,i=Math.min(t.length,s.length);let r=0;for(;r<i;){const e=Math.min(r+Z,i);this._notifyDataUpdating(),this.features.addMany(t.slice(r,e)),this.features.removeMany(s.slice(r,e)),r=e}t.length>i&&(this._notifyDataUpdating(),this.features.addMany(0===r?t:t.slice(r))),s.length>i&&(this._notifyDataUpdating(),this.features.removeMany(0===r?s:s.slice(r))),t.length=0,s.length=0}_clearTile(e){this._hideTile(e),e.features&&null!=this.context.memoryCache&&this.context.memoryCache.put(e.id,e.cache),e.setFeatures(null,0,null,void 0),this._invalidateCounts()}_invalidateCounts(){this.notifyChange("totalVertices"),this.notifyChange("totalFeatures"),this.notifyChange("memoryForUnusedFeatures")}_getListOfTiles(){return Array.from(this._featureTiles.values())}get storedFeatures(){return this._getListOfTiles().reduce(((e,t)=>e+(t.features?t.features.length:0)),0)}get missingTiles(){return Array.from(this._featureTiles.values()).reduce(((e,t)=>e+(t.needsFetch||t.isFetching?1:0)),0)}_maximumFeaturesForTile(e){const t=e.hasPreciseFeatureCount?e.numFeatures:1/0,s=e.hasPreciseFeatureCount?t:this.maximumNumberOfFeatures,i=this._fullRatio<1?this._farRatio:1;return Math.min(Math.ceil(s*i/(1-e.emptyFeatureRatio)),t)}get test(){}};function P(e){return"dummy-tile-full-extent"===e.id}function I(e){let t=0;for(const s of e)s.features&&s.features.length>0&&s.alive&&(t=Math.max(t,s.descriptor.lij[0]));return t}function z(e){e.setFeatures([],0,null,void 0),e.featuresMissing=!1}function q(e){return null==e?new Set:new Set(e.map((e=>e.name)))}function Q(e,t){if(null==e||null==t)return q(t);const s=new Set;for(const{name:i}of t)e.has(i)&&s.add(i);return s}function N(e,t){if(!t?.length)return e;e??=new Map;const s=()=>new Set;for(const{objectId:i,attribute:a}of t)r(e,i,s).add(a);return e}e([p({constructOnly:!0})],A.prototype,"features",void 0),e([p()],A.prototype,"tileDescriptors",void 0),e([p({value:1/0})],A.prototype,"maximumNumberOfFeatures",null),e([p({value:1})],A.prototype,"memoryFactor",null),e([p({value:1})],A.prototype,"lodFactor",null),e([p()],A.prototype,"useTileCount",null),e([p({readOnly:!0})],A.prototype,"updating",null),e([p({readOnly:!0})],A.prototype,"dataUpdating",void 0),e([p({readOnly:!0})],A.prototype,"updatingTotal",void 0),e([p({readOnly:!0})],A.prototype,"updatingRemaining",void 0),e([p({readOnly:!0})],A.prototype,"expectedFeatureDiff",void 0),e([p({readOnly:!0})],A.prototype,"memoryForUnusedFeatures",null),e([p({readOnly:!0})],A.prototype,"maximumNumberOfFeaturesExceeded",void 0),e([p({readOnly:!0})],A.prototype,"totalVertices",null),e([p({readOnly:!0})],A.prototype,"totalFeatures",null),e([p({readOnly:!0})],A.prototype,"hasAllFeatures",null),e([p({readOnly:!0})],A.prototype,"hasFullGeometries",null),e([p()],A.prototype,"filterExtent",null),e([p({constructOnly:!0})],A.prototype,"context",void 0),e([p()],A.prototype,"_dirty",void 0),e([p()],A.prototype,"_suspended",void 0),e([p()],A.prototype,"_pendingEdits",void 0),e([p()],A.prototype,"_applyEditsTilesUpdated",void 0),e([p()],A.prototype,"_paused",null),e([p()],A.prototype,"_isFetching",void 0),A=e([f("esri.views.3d.layers.support.FeatureTileFetcher3D")],A);const S=2e3,L=_(),k=_(),H=6e5,Z=200;export{A as FeatureTileFetcher3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e,whenOrAbort as t}from"../../../core/promiseUtils.js";import{isSVG as r}from"../../../core/urlUtils.js";import{TextureCollection as s,TextureRequest as i,TextureResult as o}from"./TextureCollection.js";import{Texture as n}from"../webgl-engine/lib/Texture.js";import{TextureWrapMode as l}from"../../webgl/enums.js";class a extends s{constructor(e,t,r){super(t,r),this._streamDataRequester=e}async fromUrl(r,s,n){e(n);const l=n?.signal,a=this.makeUid(r,s);let h=this._textureRequests.get(a);if(!h){const e=new AbortController,t=this._streamDataRequester.request(r,"image",{uid:a,signal:e.signal});h=new i,h.abortController=e;const n=h;this._textureRequests.set(a,h),h.textureAsync=t.then((async e=>{const t=this._createTexture(r,e,s);return n.texture=t,n.abortController=null,await t.load(this._stage.renderView.renderingContext),this._stage.add(t),new o(a,t,(()=>this._release(a)))}),(e=>{throw n.abortController=null,e}))}h.referenceCount++;try{return await t(h.textureAsync,l)}catch(u){throw this._release(a),u}}_createTexture(e,t,s){const i={width:t.width,height:t.height,wrap:{s:l.CLAMP_TO_EDGE,t:l.CLAMP_TO_EDGE},preMultiplyAlpha:!0,reloadable:!0};if(r(e)){if(s||0===t.width&&0===t.height){const e=t.width?t.height/t.width:1;s=s||64,e>1?(t.width=Math.round(s/e),t.height=s):(t.width=s,t.height=Math.round(s*e))}this._stage.renderView?.renderingContext.driverTest.svgPremultipliesAlpha.result&&(i.preMultiplyAlpha=!1)}return new n(t,i)}}export{a as StreamTextureCollection};
5
+ import{throwIfAborted as e,whenOrAbort as t}from"../../../core/promiseUtils.js";import{isSVG as r}from"../../../core/urlUtils.js";import{TextureCollection as s,TextureRequest as i,TextureHandle as o}from"./TextureCollection.js";import{Texture as n}from"../webgl-engine/lib/Texture.js";import{TextureWrapMode as l}from"../../webgl/enums.js";class a extends s{constructor(e,t,r){super(t,r),this._streamDataRequester=e}async fromUrl(r,s,n){e(n);const l=n?.signal,a=this.makeUid(r,s);let h=this._textureRequests.get(a);if(!h){const e=new AbortController,t=this._streamDataRequester.request(r,"image",{uid:a,signal:e.signal});h=new i,h.abortController=e;const n=h;this._textureRequests.set(a,h),h.textureAsync=t.then((async e=>{const t=this._createTexture(r,e,s);return n.texture=t,n.abortController=null,await t.load(this._stage.renderView.renderingContext),this._stage.add(t),new o(a,t,(()=>this._release(a)))}),(e=>{throw n.abortController=null,e}))}h.referenceCount++;try{return await t(h.textureAsync,l)}catch(u){throw this._release(a),u}}_createTexture(e,t,s){const i={width:t.width,height:t.height,wrap:{s:l.CLAMP_TO_EDGE,t:l.CLAMP_TO_EDGE},preMultiplyAlpha:!0,reloadable:!0};if(r(e)){if(s||0===t.width&&0===t.height){const e=t.width?t.height/t.width:1;s=s||64,e>1?(t.width=Math.round(s/e),t.height=s):(t.width=s,t.height=Math.round(s*e))}this._stage.renderView?.renderingContext.driverTest.svgPremultipliesAlpha.result&&(i.preMultiplyAlpha=!1)}return new n(t,i)}}export{a as StreamTextureCollection};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{TaskPriority as o,ImmediateTask as u}from"../../support/Scheduler.js";let i=class extends t{constructor(e,t){super({}),this._stage=e,this._textureRequests=new Map,this._frameTask=t?.registerTask(o.TEXTURE_UNLOAD)??u}normalizeCtorArgs(){return{}}destroy(){super.destroy(),this._frameTask?.remove(),this._textureRequests?.forEach((e=>this._releaseTextureRequest(e))),this._textureRequests?.clear()}get updating(){return this._frameTask.updating}fromData(e,t){const r=this.makeUid(e);let s=this._textureRequests.get(r);if(!s){const e=new a;e.texture=t(),this._stage&&(e.texture.load(this._stage.renderView.renderingContext),this._stage.add(e.texture)),this._textureRequests.set(r,e),s=e}return s.referenceCount++,new n(r,s.texture,(()=>this._release(r)))}_release(e){const t=this._textureRequests.get(e);t?(t.referenceCount<1&&console.warn("TextureCollection: reference count is < 1 for "+e),t.referenceCount--,t.referenceCount<1&&this._frameTask.schedule((()=>this._releaseNow(e)))):console.warn(`TextureCollection: texture doesn't exist: '${e}'`)}get test(){}_releaseNow(e){if(!this._textureRequests)return;const t=this._textureRequests.get(e);!t||t.referenceCount>0||(t.texture?.unload(),this._releaseTextureRequest(t),this._textureRequests.delete(e))}_releaseTextureRequest(e){e.texture?this._stage?.remove(e.texture):e.abortController&&(e.abortController.abort(),e.abortController=null)}makeUid(e,t=null){return null!=t?`${e}.${t}px`:e}};e([r()],i.prototype,"_frameTask",void 0),e([r()],i.prototype,"updating",null),i=e([s("esri.views.3d.support.TextureCollection")],i);class n{constructor(e,t,r){this.uid=e,this.texture=t,this.release=r}}class a{constructor(){this.referenceCount=0}}export{i as TextureCollection,a as TextureRequest,n as TextureResult};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{TaskPriority as o,ImmediateTask as u}from"../../support/Scheduler.js";let i=class extends t{constructor(e,t){super({}),this._stage=e,this._textureRequests=new Map,this._frameTask=t?.registerTask(o.TEXTURE_UNLOAD)??u}normalizeCtorArgs(){return{}}destroy(){super.destroy(),this._frameTask?.remove(),this._textureRequests?.forEach((e=>this._releaseTextureRequest(e))),this._textureRequests?.clear()}get updating(){return this._frameTask.updating}fromData(e,t){const r=this.makeUid(e);let s=this._textureRequests.get(r);if(!s){const e=new a;e.texture=t(),this._stage&&(e.texture.load(this._stage.renderView.renderingContext),this._stage.add(e.texture)),this._textureRequests.set(r,e),s=e}return s.referenceCount++,new n(r,s.texture,(()=>this._release(r)))}_release(e){const t=this._textureRequests.get(e);t?(t.referenceCount<1&&console.warn("TextureCollection: reference count is < 1 for "+e),t.referenceCount--,t.referenceCount<1&&this._frameTask.schedule((()=>this._releaseNow(e)))):console.warn(`TextureCollection: texture doesn't exist: '${e}'`)}get test(){}_releaseNow(e){if(!this._textureRequests)return;const t=this._textureRequests.get(e);!t||t.referenceCount>0||(t.texture?.unload(),this._releaseTextureRequest(t),this._textureRequests.delete(e))}_releaseTextureRequest(e){e.texture?this._stage?.remove(e.texture):e.abortController&&(e.abortController.abort(),e.abortController=null)}makeUid(e,t=null){return null!=t?`${e}.${t}px`:e}};e([r()],i.prototype,"_frameTask",void 0),e([r()],i.prototype,"updating",null),i=e([s("esri.views.3d.support.TextureCollection")],i);class n{constructor(e,t,r){this.uid=e,this.texture=t,this.release=r}}class a{constructor(){this.referenceCount=0}}export{i as TextureCollection,n as TextureHandle,a as TextureRequest};