@arcgis/core 5.0.0-next.29 → 5.0.0-next.30

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 (37) hide show
  1. package/WebScene.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{1fc31fab7c4dd18a76e1.js → 11bb437437272d8f3e2c.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{66853ecdebfc2aa68ce7.js → 5f2cf73fb2944f82661d.js} +10 -10
  5. package/assets/esri/core/workers/chunks/8d9e622cec13f5cea726.js +1 -0
  6. package/assets/esri/core/workers/chunks/{a0529423f2039e7d9d08.js → 94dc8b0fa129f1e168c4.js} +1 -1
  7. package/chunks/Terrain.glsl.js +27 -27
  8. package/config.js +1 -1
  9. package/kernel.js +1 -1
  10. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  11. package/layers/graphics/sources/ParquetSource.js +1 -1
  12. package/layers/support/parquetUtils.js +1 -1
  13. package/package.json +1 -1
  14. package/portal/schemas/definitions.js +1 -1
  15. package/rest/networks/support/TraceLocation.js +1 -1
  16. package/support/revision.js +1 -1
  17. package/views/3d/layers/FlowSubView3D.js +1 -1
  18. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  19. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  20. package/views/3d/layers/support/FlowTileTree3DDebugger.js +1 -1
  21. package/views/3d/support/debugFlags.js +1 -1
  22. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  23. package/views/3d/support/flow/FlowWorker.js +1 -1
  24. package/views/3d/support/flow/constants.js +1 -1
  25. package/views/3d/support/flow/loadUtils.js +1 -1
  26. package/views/3d/terrain/SplitLimits.js +1 -1
  27. package/views/3d/terrain/TerrainSurface.js +1 -1
  28. package/views/3d/terrain/Tile.js +1 -1
  29. package/views/3d/terrain/tileUtils.js +1 -1
  30. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  31. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +9 -9
  32. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +6 -6
  33. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  34. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  35. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  36. package/widgets/Legend/support/colorRampUtils.js +1 -1
  37. package/assets/esri/core/workers/chunks/a5305cfc36fabecfd358.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{JSONSupport as e}from"../../../core/JSONSupport.js";import{property as r,subclass as o}from"../../../core/accessorSupport/decorators.js";import{traceLocationTypeKebabDict as i}from"../../../networks/support/typeUtils.js";let p=class extends e{constructor(t){super(t),this.globalId=null,this.isFilterBarrier=!1,this.percentAlong=null,this.terminalId=null,this.type=null,this.firstUnit=null,this.numUnits=null,this.networkSourceId=null}};t([r({type:String,json:{write:!0}})],p.prototype,"globalId",void 0),t([r({type:Boolean,json:{write:!0}})],p.prototype,"isFilterBarrier",void 0),t([r({type:Number,json:{write:!0}})],p.prototype,"percentAlong",void 0),t([r({type:Number,json:{write:!0}})],p.prototype,"terminalId",void 0),t([r({type:i.apiValues,json:{type:i.jsonValues,read:{reader:i.read,source:"traceLocationType"},write:{writer:i.write,target:"traceLocationType"}}})],p.prototype,"type",void 0),t([r({type:Number,json:{write:!0}})],p.prototype,"firstUnit",void 0),t([r({type:Number,json:{write:!0}})],p.prototype,"numUnits",void 0),t([r({type:Number})],p.prototype,"networkSourceId",void 0),p=t([o("esri.rest.networks.support.TraceLocation")],p);const s=p;export{s as default};
5
+ import{__decorate as t}from"tslib";import{ClonableMixin as r}from"../../../core/Clonable.js";import{JSONSupport as e}from"../../../core/JSONSupport.js";import{property as o,subclass as i}from"../../../core/accessorSupport/decorators.js";import{traceLocationTypeKebabDict as p}from"../../../networks/support/typeUtils.js";let s=class extends(r(e)){constructor(t){super(t),this.globalId=null,this.isFilterBarrier=!1,this.percentAlong=null,this.terminalId=null,this.type=null,this.firstUnit=null,this.numUnits=null,this.networkSourceId=null}};t([o({type:String,json:{write:!0}})],s.prototype,"globalId",void 0),t([o({type:Boolean,json:{write:!0}})],s.prototype,"isFilterBarrier",void 0),t([o({type:Number,json:{write:!0}})],s.prototype,"percentAlong",void 0),t([o({type:Number,json:{write:!0}})],s.prototype,"terminalId",void 0),t([o({type:p.apiValues,json:{type:p.jsonValues,read:{reader:p.read,source:"traceLocationType"},write:{writer:p.write,target:"traceLocationType"}}})],s.prototype,"type",void 0),t([o({type:Number,json:{write:!0}})],s.prototype,"firstUnit",void 0),t([o({type:Number,json:{write:!0}})],s.prototype,"numUnits",void 0),t([o({type:Number})],s.prototype,"networkSourceId",void 0),s=t([i("esri.rest.networks.support.TraceLocation")],s);const n=s;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/5.0/esri/copyright.txt for details.
4
4
  */
5
- const e="20251028",f="54a4e0094386f62e32bf34d1f4655c0333ecbafb";export{e as buildDate,f as commitHash};
5
+ const e="20251029",a="e02b839630117e33190511a5c041130aa574ee27";export{e as buildDate,a as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as l,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{getMetersPerVerticalUnitForSR as m}from"../../../core/units.js";import{property as g,subclass as _}from"../../../core/accessorSupport/decorators.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import{projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{fromExtent as v,intersection as w,toExtent as T,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as j}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as A,getPositions as L,getFlowSimulationSettings as M}from"../../2d/engine/flow/utils.js";import U from"./SubView3D.js";import{makeScheduleFunction as P}from"./support/makeScheduleFunction.js";import{tileFilterDistance as E,thresholdForLoadingAllTiles as I,fadeOutTime as q,fadeInTime as F,defaultTransitionDuration as V,transitionDurationFactor as k,seamlessTransitionEnabled as C,averageLoadingTimeSmoothingFactor as B,minimumTracingResolution as D}from"../support/flow/constants.js";import{wrappedWidth as W,isFullExtent as z,FlowQuery3D as G}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as H}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as O,createStreamlineGeometry as N}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Q}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as J}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as K}from"../support/flow/StreamlineResources3DShape.js";import{tilesAreRelated as X}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as Y}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as Z}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as $,hasLayerBasedScaleVisibility as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";let ie=class extends U{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const n=e.at(r);t(n)&&i.add(n),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new H(P(i)),this.frameTask=i.scheduler.registerTask(te.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([l(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&A(e,t)}),l(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),l(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()}),t.enableFeatureTiles(),l(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),l(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=y(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=y(this.layer.fullExtent,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get _ellipsoidRadius(){return f(this.view.spatialReference).radius}get extent(){const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<E&&e.add(t)}),t=e}const s=Q(t,this.spatialReferenceInfo);return null==s?null:(w(s,this._clippingArea,s),T(s,e))}get loadAllTiles(){const{position:e}=this.view.camera,t=e.z;if(null==t)return!1;return t*m(e.spatialReference)/this._ellipsoidRadius>=I}get loadByTileTreesAllowed(){return!this.loadAllTiles||!this.loadRequirementsMet}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=y(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...O(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:F,fadeOutTime:q,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&Y(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?V:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:C}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=W(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,n;i<s?(r=i,n=i/t):(r=s*t,n=s);const o=D,l=this.view.qualitySettings.flow.maxTracingResolution,a=Math.max(1,o/Math.min(r,n)),u=a*Math.min(1,l/Math.max(r*a,n*a));return[Math.round(r*u),Math.round(n*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i}=this;if(null==t||null==i)return 0;const s=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density,r=null==e?null:v(e);if(null==r)return 0;let n=0;for(const a of i)S(r,a.extent)&&(n+=b(a.extent));const o=b(r),l=0===o?0:n/o;return 2*Math.round(s*l)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:s}=this.view;if(null==t)return 0;const r=i.flow.maxTotalNumberOfStreamlines,n=e>=r?r/e:1,o=t.density*n*s;return t.lineSpacing/Math.sqrt(o)<t.lineCollisionWidth?4*t.lineSpacing:o}get elevationInfo(){return this.layer.elevationInfo??se}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:L(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return j(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&this.renderedTiles.size>0}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!ee()||$(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=M(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const s=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const s=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.addPromise(n(s())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=B;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const s=new G(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController,n=await this._loadStreamlines(s,r.signal);if(o(r.signal),this._visible&&null!=n){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=n;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await n.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new J(e,i,r,s,this.layerView):new K(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new Z(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:n,view:o}=this;function*l(l){for(let a=0;a<t.length;++a)s.push(N(o,e,t[a],r,i,n)),l.madeProgress(),l.done&&(l=yield)}return await this.frameTask.scheduleGenerator(l),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(n(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s}=this;if(this.loadAllTiles)return t=>t.leaf&&re(e,t.extent);const r=t=>t.rendered&&t.visible&&re(e,t.extent),{featureTiles:n}=i;if(!n)return r;const o=n.tiles.filter(e=>e.measures.visible);return e=>r(e)&&re(s,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||X(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+q?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ie.prototype,"type",void 0),e([g()],ie.prototype,"renderedTiles",void 0),e([g()],ie.prototype,"_resources",void 0),e([g()],ie.prototype,"_lastResources",void 0),e([g()],ie.prototype,"requireLoad",void 0),e([g()],ie.prototype,"_averageLoadingTime",void 0),e([g()],ie.prototype,"_loadingState",void 0),e([g()],ie.prototype,"emissiveStrength",void 0),e([g()],ie.prototype,"_clippingArea",null),e([g()],ie.prototype,"_dataBounds",null),e([g()],ie.prototype,"_draped",null),e([g()],ie.prototype,"_ellipsoidRadius",null),e([g()],ie.prototype,"extent",null),e([g()],ie.prototype,"loadAllTiles",null),e([g()],ie.prototype,"_featureTilesBounds",null),e([g()],ie.prototype,"_flowRenderer",null),e([g()],ie.prototype,"_materialParameters",null),e([g()],ie.prototype,"_opacity",null),e([g()],ie.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ie.prototype,"_seamlessTransitionEnabled",null),e([g()],ie.prototype,"_tracingResolution",null),e([g()],ie.prototype,"_visible",null),e([g()],ie.prototype,"_estimatedStreamlines",null),e([g()],ie.prototype,"_effectiveDensity",null),e([g()],ie.prototype,"elevationInfo",null),e([g()],ie.prototype,"needsMagnitude",null),e([g()],ie.prototype,"spatialReferenceInfo",null),e([g()],ie.prototype,"layer",null),e([g()],ie.prototype,"loadingState",null),e([g()],ie.prototype,"updating",null),e([g()],ie.prototype,"visibleAtCurrentScale",null),e([g()],ie.prototype,"_overrideMaterialParameters",void 0),e([g()],ie.prototype,"_overrideSimulationSettings",void 0),e([g()],ie.prototype,"_overrideTransitionEnabled",void 0),e([g()],ie.prototype,"_simulationSettings",null),e([g()],ie.prototype,"surface",null),ie=e([_("esri.views.3d.layers.FlowSubView3D")],ie);const se=new x({mode:"on-the-ground"});function re(e,t){return null==e||null==t||R(e,t)}export{ie as default};
5
+ import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as o,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{property as g,subclass as m}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as f}from"../../../geometry/projectionUtils.js";import{fromExtent as _,intersection as y,toExtent as v,create as T,contains as w,area as S,intersects as b}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as R}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as L,getPositions as A,getFlowSimulationSettings as j}from"../../2d/engine/flow/utils.js";import M from"./SubView3D.js";import{getFeatureTileId as E}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as U}from"./support/makeScheduleFunction.js";import{debugFlags as P}from"../support/debugFlags.js";import{tileFilterDistance as I,scaleThresholdForLoadingAllTiles as F,fadeOutTime as D,fadeInTime as C,defaultTransitionDuration as q,transitionDurationFactor as k,seamlessTransitionEnabled as O,densityFactor as V,loadAllTilesDensityFactor as W,averageLoadingTimeSmoothingFactor as G,minimumTracingResolution as B}from"../support/flow/constants.js";import{isFullExtent as H,wrappedWidth as z,FlowQuery3D as N}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as Q}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as J,createStreamlineGeometry as K}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as X}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as Y}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as Z}from"../support/flow/StreamlineResources3DShape.js";import{descendantsAtLevel as $,tilesAreRelated as ee}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as te}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as ie}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as se,hasLayerBasedScaleVisibility as re}from"../../support/layerViewUtils.js";import{TaskPriority as le}from"../../support/Scheduler.js";let ne=class extends M{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const l=e.at(r);t(l)&&i.add(l),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new Q(U(i)),this.frameTask=i.scheduler.registerTask(le.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([o(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&L(e,t)}),o(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),o(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this._triggerTilesUpdate()}),t.enableFeatureTiles(),o(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),o(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=f(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:_(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:_(e)}get _fullExtentSurfaceSpatialReference(){return f(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return this._fullExtentSurfaceSpatialReference;const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<I&&e.add(t)}),t=e}const s=X(t,this.spatialReferenceInfo);return null==s?null:(y(s,this._clippingArea,s),v(s,e))}get loadAllTiles(){return this.view.scale>(P.FLOW_GLOBAL_SCALE_THRESHOLD??F)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&H(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(P.FLOW_GLOBAL_SCALE_THRESHOLD??F)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=T(),s=this.loadAllTilesLevel,r=this.surface.tilingScheme,l=r.rootTilesInExtent(t).flatMap(e=>$(e,s));for(const n of l){const[l,o,a]=n;r.getExtent(s,o,a,i),ae(t,i)&&e.set(E(s,o,a),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=f(e,this.surface.spatialReference).geometry;return null==t?null:_(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...J(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:C,fadeOutTime:D,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&te(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?q:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:O}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=z(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,l;i<s?(r=i,l=i/t):(r=s*t,l=s);const n=B,o=this.view.qualitySettings.flow.maxTracingResolution,a=Math.max(1,n/Math.min(r,l)),u=a*Math.min(1,o/Math.max(r*a,l*a));return[Math.round(r*u),Math.round(l*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i,loadAllTiles:s}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density;if(s)return 2*r;const l=null==e?null:_(e);if(null==l)return 0;let n=0;for(const u of i)w(l,u.extent)&&(n+=S(u.extent));const o=S(l),a=0===o?0:n/o;return 2*Math.round(r*a)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:s}=this.view;if(null==t)return 0;const r=i.flow.maxTotalNumberOfStreamlines,l=e>=r?r/e:1,n=t.density*l*s;return t.lineSpacing/Math.sqrt(n)<t.lineCollisionWidth?(t.lineSpacing/t.lineCollisionWidth)**2:n}get elevationInfo(){return this.layer.elevationInfo??oe}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:A(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return R(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!re()||se(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=j(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.density*=V,this.loadAllTiles&&this.isDataGlobal&&(i.density*=W),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&H(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const s=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const s=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.addPromise(l(s())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=G;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const s=new N(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController,l=await this._loadStreamlines(s,r.signal);if(n(r.signal),this._visible&&null!=l){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=l;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await l.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new Y(e,i,r,s,this.layerView):new Z(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new ie(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:l,view:n}=this;function*o(o){for(let a=0;a<t.length;++a)s.push(K(n,e,t[a],r,i,l)),o.madeProgress(),o.done&&(o=yield)}return await this.frameTask.scheduleGenerator(o),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s,loadAllTiles:r}=this;if(r){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&ae(e,i.extent)}const l=t=>t.rendered&&t.visible&&ae(e,t.extent),{featureTiles:n}=i;if(!n)return l;const o=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&ae(s,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||ee(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+D?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ne.prototype,"type",void 0),e([g()],ne.prototype,"renderedTiles",void 0),e([g()],ne.prototype,"_resources",void 0),e([g()],ne.prototype,"_lastResources",void 0),e([g()],ne.prototype,"requireLoad",void 0),e([g()],ne.prototype,"_averageLoadingTime",void 0),e([g()],ne.prototype,"_loadingState",void 0),e([g()],ne.prototype,"emissiveStrength",void 0),e([g()],ne.prototype,"_clippingArea",null),e([g()],ne.prototype,"_dataBounds",null),e([g()],ne.prototype,"_fullExtentSurfaceSpatialReference",null),e([g()],ne.prototype,"_draped",null),e([g()],ne.prototype,"extent",null),e([g()],ne.prototype,"loadAllTiles",null),e([g()],ne.prototype,"isDataGlobal",null),e([g()],ne.prototype,"loadAllTilesLevel",null),e([g()],ne.prototype,"targetTiles",null),e([g()],ne.prototype,"_featureTilesBounds",null),e([g()],ne.prototype,"_flowRenderer",null),e([g()],ne.prototype,"_materialParameters",null),e([g()],ne.prototype,"_opacity",null),e([g()],ne.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ne.prototype,"_seamlessTransitionEnabled",null),e([g()],ne.prototype,"_tracingResolution",null),e([g()],ne.prototype,"_visible",null),e([g()],ne.prototype,"_estimatedStreamlines",null),e([g()],ne.prototype,"_effectiveDensity",null),e([g()],ne.prototype,"elevationInfo",null),e([g()],ne.prototype,"needsMagnitude",null),e([g()],ne.prototype,"spatialReferenceInfo",null),e([g()],ne.prototype,"layer",null),e([g()],ne.prototype,"loadingState",null),e([g()],ne.prototype,"updating",null),e([g()],ne.prototype,"visibleAtCurrentScale",null),e([g()],ne.prototype,"_overrideMaterialParameters",void 0),e([g()],ne.prototype,"_overrideSimulationSettings",void 0),e([g()],ne.prototype,"_overrideTransitionEnabled",void 0),e([g()],ne.prototype,"_simulationSettings",null),e([g()],ne.prototype,"surface",null),ne=e([m("esri.views.3d.layers.FlowSubView3D")],ne);const oe=new x({mode:"on-the-ground"});function ae(e,t){return null==e||null==t||b(e,t)}export{ne as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{initial as s,watch as o,when as n}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as l,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as d,invert as h}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as g,b,t as y}from"../../../chunks/vec32.js";import{fromArray as _,clone as w,create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as O}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as U}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as P,BufferViewVec4f as H,BufferViewVec4u8 as E,BufferViewVec4u16 as R,BufferViewVec3f as S,BufferViewVec3u8 as V,BufferViewVec3u16 as A,BufferViewInt16 as I,BufferViewUint32 as k,BufferViewUint16 as F}from"../../../geometry/support/buffer/BufferView.js";import D from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as L}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as N}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{Obb as ie,compute as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as be,isInEffectiveScaleRange as ye}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as _e}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class ve{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=v();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}expandElevationRange(e){e.expandElevationRange(this.elevationRange)}}function je(e){return Math.round(e/1048.576)/1e3}let xe=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new _e,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw be("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=z(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(n(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=U();this._layerClippingArea=te(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,L(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return ye(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new N(this.usedMemory,s,o,je(t),je(e),je(r),je(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return L(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=_(i.desc.origin),s=new Array,o=this.view.basemapTerrain.spatialReference;let n,a;if("global"===this.view.viewingMode){const e=p();C(x,r,e,o),n=d(m(),e),a=h(m(),n)}else n=u,a=u;const l=w(r),c=v(),f=Te(i.desc.obb);let U=0,H=0;const E={textureMemoryUsage:0},R=new Map,S=i.desc.prims.length,V=new Array,A=new ee;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let d=0;d<S;d++){const h=i.desc.prims[d];this._dbg(2,JSON.stringify(h));if(null==J[h.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+h.ptype+"). Skipping primitive.");continue}const m=i.desc?.materials&&null!=h.materialId?i.desc.materials[h.materialId]:null,p=null!=m?m.lightingModel:"Unlit",{positionView:_,positionAttr:w,normalsView:x,normalsAttr:M,colorAttr:C,texCoord0Attr:S,indicesView:V}=this.getBufferViews(h,i.data.buffer,n);if(null==w||null==_||null==V)continue;const I=new oe(null!=C,S?1:0,null!=x,this._shadeNormals||this._replacesTerrain,this._applySSAO),k=w.data.length/w.size,F=(e,t)=>!e||e.data.length/e.size===k||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(S,"numTexcoord")||!F(C,"numColors")||!F(M,"normals"))continue;const D=ne(I);for(let i=0;i<_.count;i++){_.getVec(i,c),g(c,c,r);const s=e?b(c)-t:c[2];A.expandElevationRangeValues(s,s)}const L=f?.clone()??Oe(w,r);if(n!==u)for(let e=0;e<_.count;e++)_.getVec(e,c),y(c,c,n),_.setVec(e,c);const B=D.createBuffer(w.data.length);if(pe("position",w,null,null,B,0),null!=S){const e=B.getField("uv0",P);fe(S,e,0)}null!=C&&pe("color",C,null,null,B,0),null!=M&&pe("normalCompressed",M,null,null,B,0);const G=new Uint32Array([0,V.typedBuffer.length]),N=new ae({data:B.buffer,count:B.byteLength/D.stride,layoutParameters:I},{positions:_.typedBuffer,indices:V.typedBuffer},V.typedBuffer,G);U+=_.count+V.count;const z=this.view.renderSpatialReference,W=v(),$=[1,1,1];O(l,z,$,o)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(l,z,W,o);let q=()=>{},X=Promise.resolve(Pe);if(m){const e=e=>this._getTexture(e,i,R,E),t=e(m.baseColorTex),r="Pbr"===p,s=r?e(m.metalTex):null,o=r?e(m.emissiveTex):null,n=r?e(m.occlusionTex):null,a=r?e(m.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);X=Promise.all(l),q=e=>{e.baseColor=m.baseColorFactor,e.usePBR="Pbr"===p,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[m.metallicFactor,m.roughnessFactor,0],e.emissiveBaseColor=m.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[m.alphaMode],e.objectOpacity=this.fullOpacity,E.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(E.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=m.isDoubleSided,e.commonMaterialParameters.cullFace=Q[m.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=m.alphaCutoff??we,e.alphaDiscardMode=K[m.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)}}const Y=X.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new se(j(W[0],W[1],$[0],$[1]),new le(l,a),L,N,!1));return this._collection.updateMaterial(e,q),H+=this._collection.getObjectGPUMemoryUsage(e),e});s.push(Y)}if(V.push(...await Promise.all(s)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(D){throw R.forEach(e=>this._stage.removeTexture(e)),D}const I=V.map(e=>e()),k=new Array;R.forEach(e=>k.push(e));const F=new ve(e.handle,I,k,U,H,E.textureMemoryUsage,f,e.stableNodeId,A);return this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(Ue(F.handle),F),t=F.usedMemory,this._cacheMemory+=t,{memUsageBytes:F.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Ue(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Ue(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Ue(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=X[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new me(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Y[u.type],b=new(He(g))(g);for(let e=0;e<g;++e)b[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new S(t,u.byteOffset,p,f),s=new he(r.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new S(t,u.byteOffset,p,f),r=ue(e.typedBuffer,i);a=new I(r.buffer),l=new he(a.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new P(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new R(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new S(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new F(t,i.byteOffset,r,s);break;case"U32":c=new k(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new F(new Uint16Array(e).buffer):new k(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([l()],xe.prototype,"fullOpacity",null),e([l({type:[D]})],xe.prototype,"_modifications",void 0),e([l()],xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([l()],xe.prototype,"layer",void 0),e([l({readOnly:!0})],xe.prototype,"visibleAtCurrentScale",null),e([l({readOnly:!0})],xe.prototype,"_collection",null),e([l()],xe.prototype,"elevationOffset",null),xe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],xe);const Me=xe,Ce=v();function Oe(e,t){const i=re(e);return g(Ce,i.center,t),i.center=Ce,i}function Te(e){return e?new ie(e.center,e.halfSize,f(...e.quaternion)):null}function Ue(e){return`${e}`}const Pe=new Array;function He(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Me as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as b,b as y,t as _}from"../../../chunks/vec32.js";import{fromArray as w,clone as v,create as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as M,getReferenceEllipsoid as C}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as T}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as U}from"../../../geometry/projection/projectVectorToVector.js";import{create as H}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as P,BufferViewVec4f as R,BufferViewVec4u8 as E,BufferViewVec4u16 as S,BufferViewVec3f as V,BufferViewVec3u8 as A,BufferViewVec3u16 as I,BufferViewInt16 as k,BufferViewUint32 as F,BufferViewUint16 as D}from"../../../geometry/support/buffer/BufferView.js";import L from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as B}from"../../../support/elevationInfoUtils.js";import{toWasmModification as G}from"./I3SMeshWorkerHandle.js";import{LayerView3D as N}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as W,removeLayerViewFromWasm as $,getLyr3DWasm as q}from"./Lyr3DWasm.js";import{LayerElevationProvider as J}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as K,alphaModeConversion as Q,faceCullingConversion as X,wrapModeConversion as Y,lyr3DTypeToByteSize as Z}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ee}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as te}from"../support/ElevationRange.js";import{toBoundingRect as ie}from"../support/extentUtils.js";import{Obb as re,compute as se}from"../support/orientedBoundingBox.js";import{ObjectParameters as oe}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as ne,createVertexBufferLayout as ae,SourceGeometry as le}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as ce}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as de}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as he}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as me}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as ue}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as pe}from"../webgl-engine/lib/Normals.js";import{writeAttribute as fe,writeBufferVec2 as ge}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import be from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as _e}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as we}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as ve}from"../../../webscene/support/AlphaCutoff.js";class je{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=j();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}expandElevationRange(e){e.expandElevationRange(this.elevationRange)}}function xe(e){return Math.round(e/1048.576)/1e3}let Me=class extends(N(be)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new we,this._modificationsUpdatingHandle=null,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}tryRecycleWith(e,t){return e.url!==this.layer.url||"integrated-mesh-3dtiles"!==e.type?null:e.load(t).then(()=>{s(t),this.layer=e,this._modificationsUpdatingHandle&&this._modificationsUpdatingHandle.remove(),this._modificationsUpdatingHandle=this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o)})}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._modificationsUpdatingHandle=this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=W(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ee(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._elevationProvider=new J({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(a(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),$(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=G(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=H();this._layerClippingArea=ie(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.updateMaterial(t,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,B(e))}get _wasm(){return q(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.replacesTerrain||_e(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,s,o,xe(t),xe(e),xe(r),xe(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return B(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new te(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=w(i.desc.origin),s=new Array,o=this.view.basemapTerrain.spatialReference;let n,a;if("global"===this.view.viewingMode){const e=f();O(M,r,e,o),n=h(u(),e),a=m(u(),n)}else n=p,a=p;const l=v(r),c=j(),d=Ue(i.desc.obb);let g=0,H=0;const R={textureMemoryUsage:0},E=new Map,S=i.desc.prims.length,V=new Array,A=new te;try{const e="global"===this.view.viewingMode,t=e?C(this.view.spatialReference).radius:0;for(let h=0;h<S;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==K[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:w,positionAttr:v,normalsView:M,normalsAttr:C,colorAttr:O,texCoord0Attr:S,indicesView:V}=this.getBufferViews(m,i.data.buffer,n);if(null==v||null==w||null==V)continue;const I=new ne(null!=O,S?1:0,null!=M,this._shadeNormals||this._replacesTerrain,this._applySSAO),k=v.data.length/v.size,F=(e,t)=>!e||e.data.length/e.size===k||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!F(S,"numTexcoord")||!F(O,"numColors")||!F(C,"normals"))continue;const D=ae(I);for(let i=0;i<w.count;i++){w.getVec(i,c),b(c,c,r);const s=e?y(c)-t:c[2];A.expandElevationRangeValues(s,s)}const L=d?.clone()??Te(v,r);if(n!==p)for(let e=0;e<w.count;e++)w.getVec(e,c),_(c,c,n),w.setVec(e,c);const B=D.createBuffer(v.data.length);if(fe("position",v,null,null,B,0),null!=S){const e=B.getField("uv0",P);ge(S,e,0)}null!=O&&fe("color",O,null,null,B,0),null!=C&&fe("normalCompressed",C,null,null,B,0);const G=new Uint32Array([0,V.typedBuffer.length]),N=new le({data:B.buffer,count:B.byteLength/D.stride,layoutParameters:I},{positions:w.typedBuffer,indices:V.typedBuffer},V.typedBuffer,G);g+=w.count+V.count;const z=this.view.renderSpatialReference,W=j(),$=[1,1,1];T(l,z,$,o)||this._dbg(3,"Unsupported coordinate system for IM overlay"),U(l,z,W,o);let q=()=>{},J=Promise.resolve(Pe);if(u){const e=e=>this._getTexture(e,i,E,R),t=e(u.baseColorTex),r="Pbr"===f,s=r?e(u.metalTex):null,o=r?e(u.emissiveTex):null,n=r?e(u.occlusionTex):null,a=r?e(u.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);J=Promise.all(l),q=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=Q[u.alphaMode],e.objectOpacity=this.fullOpacity,R.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(R.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=X[u.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??ve,e.alphaDiscardMode=Q[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=he(this.view.spatialReference)}}const Y=J.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new oe(x(W[0],W[1],$[0],$[1]),new ce(l,a),L,N,!1));return this._collection.updateMaterial(e,q),H+=this._collection.getObjectGPUMemoryUsage(e),e});s.push(Y)}if(V.push(...await Promise.all(s)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(D){throw E.forEach(e=>this._stage.removeTexture(e)),D}const I=V.map(e=>e()),k=new Array;E.forEach(e=>k.push(e));const F=new je(e.handle,I,k,g,H,R.textureMemoryUsage,d,e.stableNodeId,A);return this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(He(F.handle),F),t=F.usedMemory,this._cacheMemory+=t,{memUsageBytes:F.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=He(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(He(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(He(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new de(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=Y[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new ue(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Z[u.type],b=new(Re(g))(g);for(let e=0;e<g;++e)b[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new V(t,u.byteOffset,p,f),s=new me(r.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new V(t,u.byteOffset,p,f),r=pe(e.typedBuffer,i);a=new k(r.buffer),l=new me(a.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new me(new P(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new S(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new A(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new I(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new me(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new D(t,i.byteOffset,r,s);break;case"U32":c=new F(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new D(new Uint16Array(e).buffer):new F(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],Me.prototype,"fullOpacity",null),e([c({type:[L]})],Me.prototype,"_modifications",void 0),e([c()],Me.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],Me.prototype,"layer",void 0),e([c({readOnly:!0})],Me.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],Me.prototype,"_collection",null),e([c()],Me.prototype,"elevationOffset",null),Me=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Me);const Ce=Me,Oe=j();function Te(e,t){const i=se(e);return b(Oe,i.center,t),i.center=Oe,i}function Ue(e){return e?new re(e.center,e.halfSize,g(...e.quaternion)):null}function He(e){return`${e}`}const Pe=new Array;function Re(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Ce as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{I3SMeshView3D as o}from"./I3SMeshView3D.js";import{LayerView3D as s}from"./LayerView3D.js";import{updatingProgress as a}from"../support/updatingProperties.js";import l from"../../layers/LayerView.js";import{isInEffectiveScaleRange as n}from"../../support/layerViewUtils.js";const p=.2;let d=class extends(o(s(l))){constructor(){super(...arguments),this.type="integrated-mesh-3d",this._elevationContext=1,this._supportsLabeling=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this.drapeTargetType=1}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.meshLoDFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?p:1}get visibleAtCurrentScale(){return n(this.i3slayer.effectiveScaleRange,this.view.scale)}get fullOpacity(){return 1}get layerPopupEnabledAndHasTemplate(){return!1}initialize(){this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),t),this.view.overlayManager.registerDrapeTarget(this)}destroy(){this.view.overlayManager.unregisterDrapeTarget(this)}get ready(){return this.layer.loaded}_createLayerGraphic(){}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),t),"modifications")}};e([r()],d.prototype,"layer",void 0),e([r()],d.prototype,"i3slayer",null),e([r(a)],d.prototype,"updatingProgress",void 0),e([r()],d.prototype,"updatingProgressValue",null),e([r()],d.prototype,"lodFactor",null),e([r({readOnly:!0})],d.prototype,"progressiveLoadFactor",null),e([r({readOnly:!0})],d.prototype,"visibleAtCurrentScale",null),e([r()],d.prototype,"fullOpacity",null),d=e([i("esri.views.3d.layers.IntegratedMeshLayerView3D")],d);const c=d;export{c as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{I3SMeshView3D as s}from"./I3SMeshView3D.js";import{LayerView3D as o}from"./LayerView3D.js";import{updatingProgress as a}from"../support/updatingProperties.js";import l from"../../layers/LayerView.js";import{isInEffectiveScaleRange as n}from"../../support/layerViewUtils.js";const p=.2;let d=class extends(s(o(l))){constructor(){super(...arguments),this.type="integrated-mesh-3d",this._elevationContext=1,this._supportsLabeling=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this.drapeTargetType=1}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.meshLoDFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?p:1}get visibleAtCurrentScale(){return this.i3slayer.replacesTerrain||n(this.i3slayer.effectiveScaleRange,this.view.scale)}get fullOpacity(){return 1}get layerPopupEnabledAndHasTemplate(){return!1}initialize(){this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),t),this.view.overlayManager.registerDrapeTarget(this)}destroy(){this.view.overlayManager.unregisterDrapeTarget(this)}get ready(){return this.layer.loaded}_createLayerGraphic(){}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),t),"modifications")}};e([r()],d.prototype,"layer",void 0),e([r()],d.prototype,"i3slayer",null),e([r(a)],d.prototype,"updatingProgress",void 0),e([r()],d.prototype,"updatingProgressValue",null),e([r()],d.prototype,"lodFactor",null),e([r({readOnly:!0})],d.prototype,"progressiveLoadFactor",null),e([r({readOnly:!0})],d.prototype,"visibleAtCurrentScale",null),e([r()],d.prototype,"fullOpacity",null),d=e([i("esri.views.3d.layers.IntegratedMeshLayerView3D")],d);const c=d;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import{property as l,subclass as r}from"../../../../core/accessorSupport/decorators.js";import i from"../../../../geometry/Polygon.js";import{toExtent as o}from"../../../../geometry/support/aaBoundingRect.js";import s from"../../../../symbols/SimpleFillSymbol.js";import{tileToKey as a}from"../../support/flow/loadUtils.js";import{TileTreeDebugger as n}from"../../../support/TileTreeDebugger.js";let p=class extends n{get _flowSubView(){const{layerView:e}=this;return"imagery-3d"===e.type?e.test.subView:e.test.flowSubView}constructor(e,t=!0){super(e),this._fullExtentGraphic=null,this.enableLabels=t}clear(){super.clear(),this._fullExtentGraphic&&(this.view.graphics.remove(this._fullExtentGraphic),this._fullExtentGraphic=null)}update(){super.update();const e=this._flowSubView.layer.fullExtent;this._fullExtentGraphic=new t({geometry:e,symbol:new s({color:[0,0,0,0],outline:{color:"black",width:3}})}),this.view.graphics.add(this._fullExtentGraphic)}getTiles(){const e=null!=this.view.basemapTerrain.spatialReference?this.view.basemapTerrain.spatialReference:null,t=this._flowSubView.test.renderedTiles,l=this.view.basemapTerrain.renderedTiles;let r=null;if("imagery-tile"===this._flowSubView.layer.type){const e=this._flowSubView;r=e.test.loadedTiles}return l.map(l=>{const a=this._getColor(l,t,r),n=new s({color:a,outline:{color:"black",width:1}});return{...l,lij:l.lij,level:l.level,geometry:i.fromExtent(o(l.extent,e)),label:l.lij.toString(),polygonSymbol:n}})}_getColor(e,t,l){const r=.1;return null!=t&&t.has(e)?null==l||l.has(a(e))?[0,255,0,r]:[255,165,0,r]:[255,0,0,r]}};e([l()],p.prototype,"layerView",void 0),p=e([r("esri.views.3d.layers.support.FlowTileTree3DDebugger")],p);export{p as FlowTileTree3DDebugger};
5
+ import{__decorate as e}from"tslib";import t from"../../../../Graphic.js";import{property as l,subclass as r}from"../../../../core/accessorSupport/decorators.js";import i from"../../../../geometry/Polygon.js";import{toExtent as o}from"../../../../geometry/support/aaBoundingRect.js";import s from"../../../../symbols/SimpleFillSymbol.js";import{TileTreeDebugger as a}from"../../../support/TileTreeDebugger.js";let n=class extends a{get _flowSubView(){const{layerView:e}=this;return"imagery-3d"===e.type?e.test.subView:e.test.flowSubView}constructor(e,t=!0){super(e),this._fullExtentGraphic=null,this.enableLabels=t}clear(){super.clear(),this._fullExtentGraphic&&(this.view.graphics.remove(this._fullExtentGraphic),this._fullExtentGraphic=null)}update(){super.update();const e=this._flowSubView.layer.fullExtent;this._fullExtentGraphic=new t({geometry:e,symbol:new s({color:[0,0,0,0],outline:{color:"black",width:3}})}),this.view.graphics.add(this._fullExtentGraphic)}getTiles(){const e=null!=this.view.basemapTerrain.spatialReference?this.view.basemapTerrain.spatialReference:null,t=this._flowSubView.test.targetTiles,l=this.view.basemapTerrain.renderedTiles;let r=null;if("imagery-tile"===this._flowSubView.layer.type){const e=this._flowSubView;r=e.test.loadedTiles}return l.map(l=>{const a=this._getColor(l,t,r),n=new s({color:a,outline:{color:"black",width:1}});return{...l,lij:l.lij,level:l.level,geometry:i.fromExtent(o(l.extent,e)),label:l.lij.toString(),polygonSymbol:n}})}_getColor(e,t,l){const r=.1;return null!=t&&t.has(e.key)?null==l||l.has(e.key)?[0,255,0,r]:[255,165,0,r]:[255,0,0,r]}};e([l()],n.prototype,"layerView",void 0),n=e([r("esri.views.3d.layers.support.FlowTileTree3DDebugger")],n);export{n as FlowTileTree3DDebugger};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as E}from"tslib";import _ from"../../../core/Accessor.js";import{property as S,subclass as T}from"../../../core/accessorSupport/decorators.js";let o=class extends _{constructor(){super(...arguments),this.SCENEVIEW_HITTEST_RETURN_INTERSECTOR=!1,this.DECONFLICTOR_SHOW_VISIBLE=!1,this.DECONFLICTOR_SHOW_INVISIBLE=!1,this.DECONFLICTOR_SHOW_GRID=!1,this.LABELS_SHOW_BORDER=!1,this.TEXT_SHOW_BASELINE=!1,this.TEXT_SHOW_BORDER=!1,this.OVERLAY_DRAW_DEBUG_TEXTURE=!1,this.OVERLAY_SHOW_CENTER=!1,this.SHOW_POI=!1,this.TESTS_DISABLE_OPTIMIZATIONS=!1,this.TESTS_DISABLE_FAST_UPDATES=!1,this.DRAW_MESH_GEOMETRY_NORMALS=!1,this.FEATURE_TILE_FETCH_SHOW_TILES=!1,this.FEATURE_TILE_TREE_SHOW_TILES=!1,this.TERRAIN_TILE_TREE_SHOW_TILES=!1,this.I3S_TREE_SHOW_TILES=!1,this.I3S_SHOW_MODIFICATIONS=!1,this.LOD_INSTANCE_RENDERER_DISABLE_UPDATES=!1,this.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL=!1,this.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES=!1,this.LINE_WIREFRAMES=!1}};E([S()],o.prototype,"SCENEVIEW_HITTEST_RETURN_INTERSECTOR",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_VISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_INVISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_GRID",void 0),E([S()],o.prototype,"LABELS_SHOW_BORDER",void 0),E([S()],o.prototype,"TEXT_SHOW_BASELINE",void 0),E([S()],o.prototype,"TEXT_SHOW_BORDER",void 0),E([S()],o.prototype,"OVERLAY_DRAW_DEBUG_TEXTURE",void 0),E([S()],o.prototype,"OVERLAY_SHOW_CENTER",void 0),E([S()],o.prototype,"SHOW_POI",void 0),E([S()],o.prototype,"TESTS_DISABLE_OPTIMIZATIONS",void 0),E([S()],o.prototype,"TESTS_DISABLE_FAST_UPDATES",void 0),E([S()],o.prototype,"DRAW_MESH_GEOMETRY_NORMALS",void 0),E([S()],o.prototype,"FEATURE_TILE_FETCH_SHOW_TILES",void 0),E([S()],o.prototype,"FEATURE_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"TERRAIN_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_SHOW_MODIFICATIONS",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_DISABLE_UPDATES",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL",void 0),E([S()],o.prototype,"EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES",void 0),E([S()],o.prototype,"LINE_WIREFRAMES",void 0),o=E([T("esri.views.3d.support.debugFlags")],o);const t=new o;export{t as debugFlags};
5
+ import{__decorate as E}from"tslib";import _ from"../../../core/Accessor.js";import{property as S,subclass as T}from"../../../core/accessorSupport/decorators.js";let o=class extends _{constructor(){super(...arguments),this.SCENEVIEW_HITTEST_RETURN_INTERSECTOR=!1,this.DECONFLICTOR_SHOW_VISIBLE=!1,this.DECONFLICTOR_SHOW_INVISIBLE=!1,this.DECONFLICTOR_SHOW_GRID=!1,this.LABELS_SHOW_BORDER=!1,this.TEXT_SHOW_BASELINE=!1,this.TEXT_SHOW_BORDER=!1,this.OVERLAY_DRAW_DEBUG_TEXTURE=!1,this.OVERLAY_SHOW_CENTER=!1,this.SHOW_POI=!1,this.TESTS_DISABLE_OPTIMIZATIONS=!1,this.TESTS_DISABLE_FAST_UPDATES=!1,this.DRAW_MESH_GEOMETRY_NORMALS=!1,this.FEATURE_TILE_FETCH_SHOW_TILES=!1,this.FEATURE_TILE_TREE_SHOW_TILES=!1,this.TERRAIN_TILE_TREE_SHOW_TILES=!1,this.I3S_TREE_SHOW_TILES=!1,this.I3S_SHOW_MODIFICATIONS=!1,this.LOD_INSTANCE_RENDERER_DISABLE_UPDATES=!1,this.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL=!1,this.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES=!1,this.LINE_WIREFRAMES=!1,this.FLOW_GLOBAL_SCALE_THRESHOLD=null}};E([S()],o.prototype,"SCENEVIEW_HITTEST_RETURN_INTERSECTOR",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_VISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_INVISIBLE",void 0),E([S()],o.prototype,"DECONFLICTOR_SHOW_GRID",void 0),E([S()],o.prototype,"LABELS_SHOW_BORDER",void 0),E([S()],o.prototype,"TEXT_SHOW_BASELINE",void 0),E([S()],o.prototype,"TEXT_SHOW_BORDER",void 0),E([S()],o.prototype,"OVERLAY_DRAW_DEBUG_TEXTURE",void 0),E([S()],o.prototype,"OVERLAY_SHOW_CENTER",void 0),E([S()],o.prototype,"SHOW_POI",void 0),E([S()],o.prototype,"TESTS_DISABLE_OPTIMIZATIONS",void 0),E([S()],o.prototype,"TESTS_DISABLE_FAST_UPDATES",void 0),E([S()],o.prototype,"DRAW_MESH_GEOMETRY_NORMALS",void 0),E([S()],o.prototype,"FEATURE_TILE_FETCH_SHOW_TILES",void 0),E([S()],o.prototype,"FEATURE_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"TERRAIN_TILE_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_TREE_SHOW_TILES",void 0),E([S()],o.prototype,"I3S_SHOW_MODIFICATIONS",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_DISABLE_UPDATES",void 0),E([S()],o.prototype,"LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL",void 0),E([S()],o.prototype,"EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES",void 0),E([S()],o.prototype,"LINE_WIREFRAMES",void 0),E([S()],o.prototype,"FLOW_GLOBAL_SCALE_THRESHOLD",void 0),o=E([T("esri.views.3d.support.debugFlags")],o);const t=new o;export{t as debugFlags};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{watch as t,sync as s}from"../../../../core/reactiveUtils.js";import{throttle as i}from"../../../../core/throttle.js";import{property as a,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{clone as r}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as o}from"../../../2d/engine/flow/dataUtils.js";import n from"../../layers/FlowSubView3D.js";import{tilesWaitingTime as d}from"./constants.js";import{tileToKey as u,FlowDataTile as h}from"./loadUtils.js";import{isRasterTile as p}from"../../terrain/TerrainData.js";const f={type:"delete"},g={type:"waiting"},c={type:"on-worker",upsampled:!1},_={type:"on-worker",upsampled:!0};let T=class extends n{constructor(e){super(e),this._resetTileData=!0,this._throttledTriggerLoad=null,this._throttling=!1}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{null!=this.renderedTiles&&(this.loadByTileTreesAllowed||this._tileIsUpsampled(e))&&t===this._layerIndex&&1===s&&this._updateFlowDataTile(e)}),t(()=>this.renderedTiles,e=>{const t=this.frameTask.scheduleGenerator(t=>this._updateFlowDataTiles(e,t));this.updatingHandles.addPromise(t)},s),t(()=>this._pixelSize,()=>{this.invalidateTileData(),this._resetTileData=!0},s)]),this._throttledTriggerLoad=i(()=>{super.triggerLoad(),this._throttling=!1},()=>this._throttling=!0,d,this),this.addHandles(this._throttledTriggerLoad)}async*_updateFlowDataTiles(e,t){const s=w();for(const i of e??[]){const e=this._flowDataTiles?.get(u(i)),a=null==e||"delete"===e.type||"waiting"===e.type?this._getLoadedState(i):e;null!=a&&s.set(u(i),a),t.madeProgress(),t.done&&(t=yield)}this._flowDataTiles=s,this._resetTileData=!0,this.triggerLoad()}abort(){super.abort(),this._throttling=!1}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}get loadByTileTreesAllowed(){return super.loadByTileTreesAllowed||!this._allTilesLoaded}get _pixelSize(){return this.surface.tilingScheme.pixelSize}doRefresh(){this.invalidateTileData(),super.doRefresh()}triggerLoad(){const{_throttledTriggerLoad:e}=this;this._allTilesLoaded?(e.hasPendingUpdates()||e(),e.forceUpdate()):e()}async fetchDataAndGenerateStreamlines(e,t){const{_flowDataTiles:s,needsMagnitude:i,workerHandle:a}=this,l=this.getSimulationSettings(e);if(null==l||null==a||null==s)return;const r=this._resetTileData;this._resetTileData=!1;const o=w();s.forEach((e,t)=>{"delete"===e.type?(o.set(t,f),s.delete(t)):(r||"on-worker"!==e.type&&"waiting"!==e.type)&&(o.set(t,e),s.set(t,"waiting"!==e.type&&e.upsampled?_:c))});const n={simulationSettings:l,flowExtentInfo:e.flowExtentInfo,flowDataTiles:o,reset:r,needsMagnitude:i,startPositions:this.startPositions(e)},{streamlines:d}=await a.generateTiledStreamlines(n,t);return d}getUpdating(){return super.getUpdating()||this._throttling}_getLoadedState(e){const{_layerIndex:t}=this,s=null==e.surface;if(null==t||s)return f;const i=e.getLayerInfo(t,1);if(null==i)return f;if(!e.visible&&null==i.requestAbort)return i.requestAbort=new AbortController,this.surface.requestTileData(e,t,1,i.requestAbort),f;const a=this._getRasterTile(i,e,t);return null==a?this._upsampleFlowData(t,i.upsampleInfo,e.lij,e.extent):{type:"loaded",data:this._createFlowDataTile(a,e.lij,e.extent,this._pixelSize),upsampled:!1}}_upsampleFlowData(e,t,s,i){if(null==t)return f;const a=t.tile;if(null==a)return f;const l=a.getLayerInfo(e,1);if(null==l)return f;const r=this._getRasterTile(l,a,e);if(null==r)return f;const{scale:o,offset:n}=t,d=Math.max(Math.floor(this._pixelSize*o),1),u=r.source,h=Math.floor(n[0]*u.width),p=Math.floor((1-n[1]-o)*u.height);return{type:"loaded",data:this._createFlowDataTile(r,s,i,d,h,p),upsampled:!0}}_getRasterTile(e,t,s){const{data:i}=e;return!e.dataMissing&&t.hasLayerData(s,1)&&p(i)?i:null}_createFlowDataTile(e,t,s,i,a,l){const n=o(this.layer.serviceRasterInfo.dataType,e.source,i,i,a,l),d=n.mask.slice();return new h(n.data,d,n.width,n.height,t,r(s))}_updateFlowDataTile(e){const{renderedTiles:t,_layerIndex:s}=this;if(null==t||null==s)return;if(t.has(e)){const t=this._getLoadedState(e);return void(this._setTileData(e,t)&&this.triggerLoad())}let i=this._setTileData(e,f);for(const a of t.values()){const t=a.getLayerInfo(s,1);if(null==t)continue;if(null!=this._getRasterTile(t,a,s))continue;const l=t.upsampleInfo?.tile;if(l!==e)continue;const r=this._getLoadedState(a),o=this._setTileData(a,r);i||=o}i&&this.triggerLoad()}_setTileData(e,t){const{_flowDataTiles:s}=this;if(null==s)return!1;const i=u(e);return(null!=s.get(i)||"delete"!==t.type)&&(s.set(i,t),!0)}get _allTilesLoaded(){let e=0;for(const t of this._flowDataTiles?.values()??[])"delete"!==t.type&&"waiting"!==t.type&&e++;return e===this.renderedTiles?.size}invalidateTileData(){const{_flowDataTiles:e}=this;e?.forEach((t,s)=>{e.set(s,g)})}_tileIsUpsampled(e){const t=this._flowDataTiles?.get(u(e));return null!=t&&("loaded"===t.type||"on-worker"===t.type)&&t.upsampled}get usedMemory(){const e=9*this._pixelSize**2,t=(this._flowDataTiles?.size??0)*e;return super.usedMemory+t}get test(){return{...super.test,loadedTiles:this._flowDataTiles??w()}}};function w(){return new Map}e([a()],T.prototype,"_throttling",void 0),T=e([l("esri.views.3d.support.flow.FlowSubViewTiles3D")],T);export{T as default};
5
+ import{__decorate as e}from"tslib";import{watch as t,when as s,syncAndInitial as i,sync as l}from"../../../../core/reactiveUtils.js";import{throttle as a}from"../../../../core/throttle.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{clone as n,create as d}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as h}from"../../../2d/engine/flow/dataUtils.js";import u from"../../layers/FlowSubView3D.js";import{getFeatureTileId as c}from"../../layers/support/FeatureTileDescriptor.js";import{tilesWaitingTime as p}from"./constants.js";import{FlowDataTile as f}from"./loadUtils.js";import{isRasterTile as T}from"../../terrain/TerrainData.js";import{descendantsAtLevel as g}from"../../terrain/tileUtils.js";const _={type:"delete"},y={type:"invalid"};let m=class extends u{constructor(e){super(e),this._flowDataTiles=D(),this._resetTileData=!0,this._throttledTriggerLoad=null,this._throttling=!1}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{if(t!==this._layerIndex||1!==s)return;const i=this.frameTask.schedule(()=>{this._applyTileDataUpdate(e)&&this.triggerLoad()});this.updatingHandles.addPromise(i)}),t(()=>this.renderedTiles,e=>{const t=this.frameTask.scheduleGenerator(this.loadAllTiles?t=>this._applyTileDataUpdates(e,t):t=>this._syncToTiles(e,t));this.updatingHandles.addPromise(t)},i),s(()=>this.loadAllTiles,()=>{const e=this.frameTask.scheduleGenerator(e=>this._enterAllTilesMode(e));this.updatingHandles.addPromise(e)},i),t(()=>this._pixelSize,()=>{this.invalidateTileData(),this._resetTileData=!0},l),this.layerView.on("data-changed",()=>{this.invalidateTileData(),this._resetTileData=!0})]),this._throttledTriggerLoad=a(()=>{super.triggerLoad(),this._throttling=!1},()=>this._throttling=!0,p,this),this.addHandles(this._throttledTriggerLoad)}*_enterAllTilesMode(e){const{targetTiles:t,_flowDataTiles:s}=this,i=D();for(const[l,a]of s)t.has(l)&&i.set(l,a);this._flowDataTiles=i,this._resetTileData=!0,e.madeProgress(),e.done&&(e=yield),yield*this._applyTileDataUpdates(new Set(this.surface.allTiles),e),this.triggerLoad()}*_syncToTiles(e,t){const s=D();for(const i of e??[]){const e=this._flowDataTiles.get(i.key),l=null==e||"delete"===e.type||"invalid"===e.type?this._getLoadedState(i):e;null!=l&&s.set(i.key,l),t.madeProgress(),t.done&&(t=yield)}this._flowDataTiles=s,this._resetTileData=!0,this.triggerLoad()}*_applyTileDataUpdates(e,t){let s=!1;for(const i of e??[]){const e=this._applyTileDataUpdate(i);s||=e,t.madeProgress(),t.done&&(t=yield)}s&&this.triggerLoad()}abort(){super.abort(),this._throttling=!1}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}get _pixelSize(){return this.surface.tilingScheme.pixelSize}doRefresh(){this.invalidateTileData(),super.doRefresh()}triggerLoad(){const{_throttledTriggerLoad:e}=this;this._allTilesLoaded?(e.hasPendingUpdates()||e(),e.forceUpdate()):e()}async fetchDataAndGenerateStreamlines(e,t){const{_flowDataTiles:s,needsMagnitude:i,workerHandle:l}=this,a=this.getSimulationSettings(e);if(null==a||null==l)return;const r=this._resetTileData;this._resetTileData=!1;const o=D();s.forEach((e,t)=>{"delete"===e.type?(o.set(t,_),s.delete(t)):(r||"on-worker"!==e.type&&"invalid"!==e.type)&&(o.set(t,e),s.set(t,"invalid"===e.type?y:{type:"on-worker",sourceLevel:e.sourceLevel}))});const n={simulationSettings:a,flowExtentInfo:e.flowExtentInfo,flowDataTiles:o,reset:r,needsMagnitude:i,startPositions:this.startPositions(e)},{streamlines:d}=await l.generateTiledStreamlines(n,t);return d}getUpdating(){return super.getUpdating()||this._throttling}_getLoadedState(e){const{_layerIndex:t}=this,s=null==e.surface;if(null==t||s)return null;const i=e.getLayerInfo(t,1);if(null==i)return null;const l=this._getRasterTile(i,e,t);return null==l?this._upsampleFlowData(t,i.upsampleInfo,e.lij,e.extent):{type:"loaded",data:this._createFlowDataTile(l,e.lij,e.extent,this._pixelSize),sourceLevel:e.level}}_upsampleFlowData(e,t,s,i){if(null==t)return null;const l=t.tile;if(null==l)return null;const a=l.getLayerInfo(e,1);if(null==a)return null;const r=this._getRasterTile(a,l,e);if(null==r)return null;const{scale:o,offset:n}=t,d=Math.max(Math.floor(this._pixelSize*o),1),h=r.source,u=Math.floor(n[0]*h.width),c=Math.floor((1-n[1]-o)*h.height);return{type:"loaded",data:this._createFlowDataTile(r,s,i,d,u,c),sourceLevel:l.level}}_getRasterTile(e,t,s){const{data:i}=e;return!e.dataMissing&&t.hasLayerData(s,1)&&T(i)?i:null}_createFlowDataTile(e,t,s,i,l,a){const r=h(this.layer.serviceRasterInfo.dataType,e.source,i,i,l,a),o=r.mask.slice();return new f(r.data,o,r.width,r.height,t,n(s))}_applyTileDataUpdate(e){const{renderedTiles:t,_layerIndex:s,loadAllTiles:i,loadAllTilesLevel:l}=this;if(null==t||null==s||i&&e.level>l)return!1;if(t.has(e))return this._updateRenderedTile(e);const a=e.key;let r=this._setTileData(a,_);const o=this._updateUpsampledTiles(t,e,s);r||=o;const n=i&&this._updateDescendants(e,s);return r||=n,r}_updateRenderedTile(e){const t=e.key,{_flowDataTiles:s}=this;if(w(s.get(t),e))return!1;const i=this._getLoadedState(e);return this._setTileData(t,i)}_updateUpsampledTiles(e,t,s){const{_flowDataTiles:i}=this;let l=!1;for(const a of e.values()){const e=a.key;if(w(i.get(e),t))continue;const r=a.getLayerInfo(s,1);if(null==r)continue;if(null!=this._getRasterTile(r,a,s))continue;const o=r.upsampleInfo?.tile;if(o!==t)continue;const n=this._getLoadedState(a),d=this._setTileData(e,n);l||=d}return l}_updateDescendants(e,t){let s=!1;const{tilingScheme:i,upsampleInfoPool:l}=this.surface,{targetTiles:a,_flowDataTiles:r,loadAllTilesLevel:o}=this,n=e.lij,h=g(n,o).map(e=>[c(e[0],e[1],e[2]),e]).filter(([e])=>a.has(e));if(0===h.length)return s;const u=1<<o-n[0],p=1/u,f=n[1]*u,T=n[2]*u,_=l.acquire();for(const[c,g]of h){if(w(r.get(c),e))continue;const l=d();i.getExtent(g[0],g[1],g[2],l);const a=1-(g[1]-f)*p-p,o=(g[2]-T)*p;_.init(e,o,a,p);const n=this._upsampleFlowData(t,_,g,l),h=this._setTileData(c,n);s||=h}return l.release(_),s}_setTileData(e,t){if(null==t)return!1;const{_flowDataTiles:s}=this;return(null!=s.get(e)||"delete"!==t.type)&&(s.set(e,t),!0)}get _allTilesLoaded(){let e=0;for(const t of this._flowDataTiles.values()??[])"delete"!==t.type&&"invalid"!==t.type&&e++;return this.loadAllTiles?e===this.targetTiles.size:e===this.renderedTiles?.size}invalidateTileData(){const{_flowDataTiles:e}=this;for(const t of e.keys())e.set(t,y)}get usedMemory(){const e=9*this._pixelSize**2,t=(this._flowDataTiles.size??0)*e;return super.usedMemory+t}get test(){return{...super.test,loadedTiles:this._flowDataTiles}}};function D(){return new Map}function w(e,t){return null!=e&&("loaded"===e.type||"on-worker"===e.type)&&e.sourceLevel>=t.level}e([r()],m.prototype,"_throttling",void 0),m=e([o("esri.views.3d.support.flow.FlowSubViewTiles3D")],m);export{m as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{subclass as e}from"../../../../core/accessorSupport/decorators.js";import{createFlowFieldFromData as s,traceFlowPaths as a}from"../../../2d/engine/flow/dataUtils.js";import{createFlowFieldFromDataTiled as i,valuesPerFlowVertex as r}from"./loadUtils.js";let o=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,flowExtentInfo:a,needsMagnitude:i,simulationSettings:r,startPositions:o}=t,n=l(s(r,e),r,a.modelSize,i,o);return{result:{streamlines:n},transferList:n?.map(t=>t.vertices.buffer)}}async generateTiledStreamlines(t){const{flowDataTiles:e,flowExtentInfo:s,needsMagnitude:a,reset:r,simulationSettings:o,startPositions:n}=t;this._updateTileData(e,r);const f=l(i(o,this._tileData,s),o,s.modelSize,a,n);return{result:{streamlines:f},transferList:f?.map(t=>t.vertices.buffer)??[]}}_updateTileData(t,e){e&&this._tileData.forEach((e,s)=>{null==t.get(s)&&this._tileData.delete(s)}),t.forEach((t,e)=>{"delete"===t.type?this._tileData.delete(e):"on-worker"!==t.type&&"waiting"!==t.type&&this._tileData.set(e,t.data)})}};o=t([e("esri.views.3d.support.flow.FlowWorker")],o);const n=o;function l(t,e,s,i,o){if(null==t)return;const n=a(e,t,s[0],s[1],{positions:o}),l=[],f=r(i);for(const{vertices:a,stage:r}of n){const t=new Float32Array(a.length*f);for(let e=0;e<a.length;e++)t[e*f]=a[e].x,t[e*f+1]=a[e].y,t[e*f+2]=a[e].t,i&&(t[e*f+3]=a[e].speed);l.push({vertices:t,stage:r,hasMagnitude:i})}return l}export{n as default};
5
+ import{__decorate as t}from"tslib";import{subclass as e}from"../../../../core/accessorSupport/decorators.js";import{createFlowFieldFromData as s,traceFlowPaths as a}from"../../../2d/engine/flow/dataUtils.js";import{createFlowFieldFromDataTiled as i,valuesPerFlowVertex as r}from"./loadUtils.js";let o=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,flowExtentInfo:a,needsMagnitude:i,simulationSettings:r,startPositions:o}=t,n=l(s(r,e),r,a.modelSize,i,o);return{result:{streamlines:n},transferList:n?.map(t=>t.vertices.buffer)}}async generateTiledStreamlines(t){const{flowDataTiles:e,flowExtentInfo:s,needsMagnitude:a,reset:r,simulationSettings:o,startPositions:n}=t;this._updateTileData(e,r);const f=l(i(o,this._tileData,s),o,s.modelSize,a,n);return{result:{streamlines:f},transferList:f?.map(t=>t.vertices.buffer)??[]}}_updateTileData(t,e){if(e)for(const s of this._tileData.keys())t.has(s)||this._tileData.delete(s);t.forEach((t,e)=>{"delete"===t.type?this._tileData.delete(e):"on-worker"!==t.type&&"invalid"!==t.type&&this._tileData.set(e,t.data)})}};o=t([e("esri.views.3d.support.flow.FlowWorker")],o);const n=o;function l(t,e,s,i,o){if(null==t)return;const n=a(e,t,s[0],s[1],{positions:o}),l=[],f=r(i);for(const{vertices:a,stage:r}of n){const t=new Float32Array(a.length*f);for(let e=0;e<a.length;e++)t[e*f]=a[e].x,t[e*f+1]=a[e].y,t[e*f+2]=a[e].t,i&&(t[e*f+3]=a[e].speed);l.push({vertices:t,stage:r,hasMagnitude:i})}return l}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/5.0/esri/copyright.txt for details.
4
4
  */
5
- const e=.1,o=1,t=1,c=1e3,n=!1,p=3,r=1,s=1.1,x=501,a=256,b=!0,d=3;export{e as averageLoadingTimeSmoothingFactor,r as defaultTransitionDuration,t as fadeInTime,o as fadeOutTime,a as minimumTracingResolution,n as seamlessTransitionEnabled,x as streamlinGeometryBatchSize,s as thresholdForLoadingAllTiles,d as tileFilterDistance,b as tileFilteringByDistanceEnabled,c as tilesWaitingTime,p as transitionDurationFactor};
5
+ const e=.1,o=1,t=1,c=1e3,n=!1,p=3,r=1,s=27e6,x=501,a=256,b=!0,d=3,f=2,g=2;export{e as averageLoadingTimeSmoothingFactor,r as defaultTransitionDuration,f as densityFactor,t as fadeInTime,o as fadeOutTime,g as loadAllTilesDensityFactor,a as minimumTracingResolution,s as scaleThresholdForLoadingAllTiles,n as seamlessTransitionEnabled,x as streamlinGeometryBatchSize,d as tileFilterDistance,b as tileFilteringByDistanceEnabled,c as tilesWaitingTime,p as transitionDurationFactor};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{containsXY as t,width as n,height as e,create as r}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as l}from"../../../2d/engine/flow/dataUtils.js";import{getFeatureTileId as o}from"../../layers/support/FeatureTileDescriptor.js";import{modelToMapSpace as i,insideMapExtent as u,isFullExtent as s}from"./FlowQuery3D.js";function f(t){return t?4:3}function a(t){return t[0].vertices instanceof Float32Array}class c{constructor(t,n,e,r,l,o){this.data=t,this.mask=n,this.width=e,this.height=r,this.lij=l,this.extent=o}}function h(t){return o(t.lij[0],t.lij[1],t.lij[2])}function m(t,n){let[e,l,o,i]=[null,null,null,null];for(const r of t){const t=r.extent;e=p(t[0],e),l=p(t[1],l),o=d(t[2],o),i=d(t[3],i)}if(null==e||null==l||null==o||null==i)return null;if(s(e,o,n)){const n=[...t].toSorted((t,n)=>t.extent[0]-n.extent[0]);let r=n[0].extent[2],l=0,i=0,u=0;for(let t=1;t<n.length;t++){const[e,o,s]=n[t].extent;if(r<e&&(u++,l=r,i=e,u>1))break;r=Math.max(r,s)}1===u&&(e=i,o=l)}return r([e,l,o,i])}function d(t,n){return null==n?t:Math.max(t,n)}function p(t,n){return null==n?t:Math.min(t,n)}function x(r,o,s){const[f,a]=s.modelSize;let c=null;const h=new Map;o.forEach(t=>{h.set(t.lij,l(r,t))});const m=(n,e,r)=>t(n.extent,e,r);return(t,l)=>{const d=Math.round(t),p=Math.round(l);if(!r.wrapAround&&(d<0||d>=f||p<0||p>=a))return[0,0];const[x,j]=i(s,t,l,!0);if(!u(s,x,j))return[0,0];if(null==c||!m(c,x,j)){c=null;for(const[t,n]of o)if(m(n,x,j)){c=n;break}}if(null==c?.data)return[0,0];const g=h.get(c.lij);if(null==g)return[0,0];const{width:w,height:M,extent:y}=c;return g((x-y[0])/n(y)*w,M-(j-y[1])/e(y)*M)}}export{c as FlowDataTile,m as boundingRectOfTiles,x as createFlowFieldFromDataTiled,a as isFlowPathBuffer,h as tileToKey,f as valuesPerFlowVertex};
5
+ import{containsXY as t,width as n,height as e,create as r}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as l}from"../../../2d/engine/flow/dataUtils.js";import{modelToMapSpace as o,insideMapExtent as u,isFullExtent as i}from"./FlowQuery3D.js";function s(t){return t?4:3}function f(t){return t[0].vertices instanceof Float32Array}class a{constructor(t,n,e,r,l,o){this.data=t,this.mask=n,this.width=e,this.height=r,this.lij=l,this.extent=o}}function c(t,n){let[e,l,o,u]=[null,null,null,null];for(const r of t){const t=r.extent;e=d(t[0],e),l=d(t[1],l),o=h(t[2],o),u=h(t[3],u)}if(null==e||null==l||null==o||null==u)return null;if(i(e,o,n)){const n=[...t].toSorted((t,n)=>t.extent[0]-n.extent[0]);let r=n[0].extent[2],l=0,u=0,i=0;for(let t=1;t<n.length;t++){const[e,o,s]=n[t].extent;if(r<e&&(i++,l=r,u=e,i>1))break;r=Math.max(r,s)}1===i&&(e=u,o=l)}return r([e,l,o,u])}function h(t,n){return null==n?t:Math.max(t,n)}function d(t,n){return null==n?t:Math.min(t,n)}function m(r,i,s){const[f,a]=s.modelSize;let c=null;const h=new Map;i.forEach(t=>{h.set(t.lij,l(r,t))});const d=(n,e,r)=>t(n.extent,e,r);return(t,l)=>{const m=Math.round(t),x=Math.round(l);if(!r.wrapAround&&(m<0||m>=f||x<0||x>=a))return[0,0];const[p,g]=o(s,t,l,!0);if(!u(s,p,g))return[0,0];if(null==c||!d(c,p,g)){c=null;for(const[t,n]of i)if(d(n,p,g)){c=n;break}}if(null==c?.data)return[0,0];const j=h.get(c.lij);if(null==j)return[0,0];const{width:w,height:M,extent:k}=c;return j((p-k[0])/n(k)*w,M-(g-k[1])/e(k)*M)}}export{a as FlowDataTile,c as boundingRectOfTiles,m as createFlowFieldFromDataTiled,f as isFlowPathBuffer,s as valuesPerFlowVertex};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import{create as a,copy as n}from"../../../geometry/support/frustum.js";let o=class extends e{constructor(t){super(t)}get fovX(){return Math.tan(.5*this.terrain.view.state.contentCamera.fovX)}get fovY(){return Math.tan(.5*this.terrain.view.state.contentCamera.fovY)}get relativeWidthLimit(){const{pixelRatio:t,width:e}=this.terrain.view.state.camera,r=this.terrain.tilingScheme.pixelSize,i=2**-this.terrain.lodBias*t;return r/e*this.terrain.maxTextureScale*i}get relativeHeightLimit(){const{pixelRatio:t,height:e}=this.terrain.view.state.camera,r=this.terrain.tilingScheme.pixelSize,i=2**-this.terrain.lodBias*t;return r/e*this.terrain.maxTextureScale*i}get maxLod(){return this.terrain.tilingScheme.getMaxLod()}get angledSplitBias(){return this.terrain.view.qualitySettings.tiledSurface.angledSplitBias}get aboveGround(){return this.terrain.view.state.camera.aboveGround}get frustum(){return this.terrain.view.state.fixedContentCamera?(this._frustum??=a(),n(this._frustum,this.terrain.view.state.contentCamera.frustum)):this._frustum=null,this._frustum}};t([r({constructOnly:!0})],o.prototype,"terrain",void 0),t([r({readOnly:!0})],o.prototype,"fovX",null),t([r({readOnly:!0})],o.prototype,"fovY",null),t([r({readOnly:!0})],o.prototype,"relativeWidthLimit",null),t([r({readOnly:!0})],o.prototype,"relativeHeightLimit",null),t([r({readOnly:!0})],o.prototype,"maxLod",null),t([r({readOnly:!0})],o.prototype,"angledSplitBias",null),t([r({readOnly:!0})],o.prototype,"aboveGround",null),t([r({readOnly:!0})],o.prototype,"frustum",null),o=t([i("esri.views.3d.terrain.SplitLimits")],o);export{o as SplitLimits};
5
+ import{__decorate as t}from"tslib";import o from"../../../core/Accessor.js";import{property as i,subclass as e}from"../../../core/accessorSupport/decorators.js";let r=class extends o{constructor(){super(...arguments),this.fovX=0,this.fovY=0,this.relativeWidthLimit=0,this.relativeHeightLimit=0,this.maxLod=0,this.angledSplitBias=0,this.aboveGround=!0}};t([i()],r.prototype,"fovX",void 0),t([i()],r.prototype,"fovY",void 0),t([i()],r.prototype,"relativeWidthLimit",void 0),t([i()],r.prototype,"relativeHeightLimit",void 0),t([i()],r.prototype,"maxLod",void 0),t([i()],r.prototype,"angledSplitBias",void 0),t([i()],r.prototype,"aboveGround",void 0),t([i()],r.prototype,"frustum",void 0),r=t([e("esri.views.3d.terrain.SplitLimits")],r);export{r as SplitLimits};