@arcgis/core 5.2.0-next.163 → 5.2.0-next.164

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 (69) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/analysis/LineOfSightAnalysis.d.ts +1 -1
  3. package/analysis/LineOfSightAnalysisObserver.d.ts +5 -4
  4. package/analysis/LineOfSightAnalysisTarget.d.ts +4 -4
  5. package/analysis/Viewshed.d.ts +4 -4
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/{8e19629899a5becf8e19.js → 150e7a7bd5df25693da7.js} +1 -1
  8. package/assets/esri/core/workers/chunks/226f862bbeb33fc7c597.js +1 -0
  9. package/assets/esri/core/workers/chunks/{2e096537a3a5555a4a93.js → 4cb751dc8d00bdaeb04c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{85bba551057366cd00ae.js → 4db829a0238024736fe6.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{8aa80b892fde552577e8.js → 700b1d5bc67b7e1b3ff3.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{f528ac5c648ca6a98582.js → 711cfb84659cb4437679.js} +1 -1
  13. package/assets/esri/core/workers/chunks/ad96132bc89671e595f3.js +1 -0
  14. package/assets/esri/core/workers/chunks/b736046c6b4ede73ea46.js +1 -0
  15. package/assets/esri/core/workers/chunks/c070d2ddf290b4f92916.js +1 -0
  16. package/assets/esri/core/workers/chunks/d77c68e0fc3b259bf4f9.js +1 -0
  17. package/assets/esri/core/workers/chunks/{e0351753f6b4d1adf11e.js → fc0dbb588a4062615cb6.js} +1 -1
  18. package/chunks/GlobalIllumination.glsl.js +2 -17
  19. package/config.js +1 -1
  20. package/geometry/support/clipRay.js +1 -1
  21. package/geometry/support/plane.js +1 -1
  22. package/kernel.js +1 -1
  23. package/layers/GeoJSONLayer.d.ts +2 -107
  24. package/layers/SceneLayer.d.ts +40 -16
  25. package/layers/ViewshedLayer.d.ts +10 -4
  26. package/layers/WMSLayer.d.ts +2 -69
  27. package/layers/mixins/TemporalLayer.d.ts +70 -48
  28. package/layers/mixins/TiledImagery.d.ts +0 -11
  29. package/package.json +2 -2
  30. package/popup/content.d.ts +38 -1
  31. package/popup/content.js +1 -1
  32. package/smartMapping/popup/support/clusterUtils.js +1 -1
  33. package/smartMapping/popup/support/utils.js +2 -2
  34. package/smartMapping/renderers/size.js +1 -1
  35. package/smartMapping/renderers/support/regenerateUtils.js +1 -1
  36. package/support/timeUtils.d.ts +11 -0
  37. package/symbols/cim/CIMCursor.js +1 -1
  38. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  39. package/views/2d/engine/webgl/animations/instructions.js +1 -1
  40. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
  41. package/views/3d/environment/SunLighting.d.ts +0 -1
  42. package/views/3d/environment/SunLighting.js +1 -1
  43. package/views/3d/environment/VirtualLighting.d.ts +0 -1
  44. package/views/3d/environment/VirtualLighting.js +1 -1
  45. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  46. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  47. package/views/3d/webgl-engine/effects/glow/applyEmissiveGlow.glsl.js +9 -4
  48. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  49. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  50. package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +2 -0
  51. package/views/layers/LineOfSightLayerView.d.ts +2 -2
  52. package/views/layers/ViewshedLayerView.d.ts +2 -1
  53. package/views/support/screenshotUtils.js +1 -1
  54. package/webscene/Slide.d.ts +1 -2
  55. package/widgets/DirectionalPad/VisibleElements.d.ts +5 -1
  56. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  57. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  58. package/widgets/Search/SearchViewModel.js +1 -1
  59. package/widgets/Search/support/layerSearchUtils.js +1 -1
  60. package/widgets/Sketch/SketchViewModel.js +1 -1
  61. package/widgets/Sketch/support/PluginManager.js +1 -1
  62. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  63. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +3 -3
  64. package/widgets/UtilityNetworkValidateTopology.d.ts +1 -1
  65. package/assets/esri/core/workers/chunks/0cb50bc2b2125c5fedf2.js +0 -1
  66. package/assets/esri/core/workers/chunks/2f04b8679c9f15390517.js +0 -1
  67. package/assets/esri/core/workers/chunks/42045cf46497828cd3c0.js +0 -1
  68. package/assets/esri/core/workers/chunks/e01fc1c31bc023dd0e33.js +0 -1
  69. package/assets/esri/core/workers/chunks/e077e321a3109c2fbbe2.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../../core/Evented.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../webscene/SunLighting.js";var a;let o=a=class extends t(i){static calculateTimezoneOffset({hours:e,minutes:t,seconds:n}){return Math.round(e+t/60+n/3600)}constructor(e){super(e),this.cameraTrackingEnabled=!0,this.globalIllumination=!1,this.positionTimezoneInfo={hours:0,minutes:0,seconds:0,autoUpdated:!0},this.type=`sun`;let t=new Date().getFullYear(),n=new Date(`March 15, `+t+` 12:00:00 UTC`);this._set(`defaultDate`,n),this._set(`date`,n)}get defaultDate(){return new Date(this._get(`defaultDate`))}static fromWebsceneLighting(e){return new a(e.cloneConstructProperties())}set defaultDate(e){let t=this._get(`date`)===this._get(`defaultDate`);e=new Date(e),this._set(`defaultDate`,e),t&&this._set(`date`,e)}set date(e){e!=null&&(this.positionTimezoneInfo.autoUpdated=!1,this._set(`date`,new Date(e)))}autoUpdate(e,t){let n=a.calculateTimezoneOffset(this.positionTimezoneInfo);this.positionTimezoneInfo.hours=t.hours,this.positionTimezoneInfo.minutes=t.minutes,this.positionTimezoneInfo.seconds=t.seconds;let r=null;e!=null&&(this.positionTimezoneInfo.autoUpdated=!0,isNaN(e.getTime())?(r=this.defaultDate.getTime(),this._set(`date`,this.defaultDate)):(r=this.date&&this.date.getTime(),this._set(`date`,new Date(e))));let i=a.calculateTimezoneOffset(this.positionTimezoneInfo);if(n!==i&&(s.target=this,s.timezoneOffset=i,this.emit(`timezone-will-change`,s),s.target=null),e!=null)return isNaN(e.getTime())||r!==e.getTime()}clone(){let e=this._get(`date`)===this._get(`defaultDate`),t=new a({...this.cloneConstructProperties(),...this.cloneNonPersistentConstructProperties(),defaultDate:this.defaultDate});return e&&t._set(`date`,t._get(`defaultDate`)),t.positionTimezoneInfo.autoUpdated=this.positionTimezoneInfo.autoUpdated,t.positionTimezoneInfo.hours=this.positionTimezoneInfo.hours,t.positionTimezoneInfo.minutes=this.positionTimezoneInfo.minutes,t.positionTimezoneInfo.seconds=this.positionTimezoneInfo.seconds,t}cloneWithWebsceneLighting(e){let t=this.clone();return e.date!=null&&(t.date=e.date),t.directShadowsEnabled=e.directShadowsEnabled,t.glow=e.glow?.clone(),t.displayUTCOffset=e.displayUTCOffset,t}cloneNonPersistentConstructProperties(){return{cameraTrackingEnabled:this.cameraTrackingEnabled,globalIllumination:this.globalIllumination}}};e([n({type:Boolean})],o.prototype,`cameraTrackingEnabled`,void 0),e([n({type:Boolean})],o.prototype,`globalIllumination`,void 0),e([n({type:Date})],o.prototype,`defaultDate`,null),e([n({type:Date})],o.prototype,`date`,null),e([n({readOnly:!0,type:[`sun`],json:{write:!0}})],o.prototype,`type`,void 0),o=a=e([r(`esri.views.3d.environment.SunLighting`)],o);const s={target:null,timezoneOffset:0},c=o;export{c as default};
2
+ import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../../core/Evented.js";import has from"../../../core/has.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../webscene/SunLighting.js";var a;let o=a=class extends t(i){static calculateTimezoneOffset({hours:e,minutes:t,seconds:n}){return Math.round(e+t/60+n/3600)}constructor(e){super(e),this.cameraTrackingEnabled=!0,this.globalIllumination=has(`enable-feature:global-illumination`)??!1,this.positionTimezoneInfo={hours:0,minutes:0,seconds:0,autoUpdated:!0},this.type=`sun`;let t=new Date().getFullYear(),n=new Date(`March 15, `+t+` 12:00:00 UTC`);this._set(`defaultDate`,n),this._set(`date`,n)}get defaultDate(){return new Date(this._get(`defaultDate`))}static fromWebsceneLighting(e){return new a(e.cloneConstructProperties())}set defaultDate(e){let t=this._get(`date`)===this._get(`defaultDate`);e=new Date(e),this._set(`defaultDate`,e),t&&this._set(`date`,e)}set date(e){e!=null&&(this.positionTimezoneInfo.autoUpdated=!1,this._set(`date`,new Date(e)))}autoUpdate(e,t){let n=a.calculateTimezoneOffset(this.positionTimezoneInfo);this.positionTimezoneInfo.hours=t.hours,this.positionTimezoneInfo.minutes=t.minutes,this.positionTimezoneInfo.seconds=t.seconds;let r=null;e!=null&&(this.positionTimezoneInfo.autoUpdated=!0,isNaN(e.getTime())?(r=this.defaultDate.getTime(),this._set(`date`,this.defaultDate)):(r=this.date&&this.date.getTime(),this._set(`date`,new Date(e))));let i=a.calculateTimezoneOffset(this.positionTimezoneInfo);if(n!==i&&(s.target=this,s.timezoneOffset=i,this.emit(`timezone-will-change`,s),s.target=null),e!=null)return isNaN(e.getTime())||r!==e.getTime()}clone(){let e=this._get(`date`)===this._get(`defaultDate`),t=new a({...this.cloneConstructProperties(),...this.cloneNonPersistentConstructProperties(),defaultDate:this.defaultDate});return e&&t._set(`date`,t._get(`defaultDate`)),t.positionTimezoneInfo.autoUpdated=this.positionTimezoneInfo.autoUpdated,t.positionTimezoneInfo.hours=this.positionTimezoneInfo.hours,t.positionTimezoneInfo.minutes=this.positionTimezoneInfo.minutes,t.positionTimezoneInfo.seconds=this.positionTimezoneInfo.seconds,t}cloneWithWebsceneLighting(e){let t=this.clone();return e.date!=null&&(t.date=e.date),t.directShadowsEnabled=e.directShadowsEnabled,t.glow=e.glow?.clone(),t.displayUTCOffset=e.displayUTCOffset,t}cloneNonPersistentConstructProperties(){return{cameraTrackingEnabled:this.cameraTrackingEnabled,globalIllumination:this.globalIllumination}}};e([n({type:Boolean})],o.prototype,`cameraTrackingEnabled`,void 0),e([n({type:Boolean})],o.prototype,`globalIllumination`,void 0),e([n({type:Date})],o.prototype,`defaultDate`,null),e([n({type:Date})],o.prototype,`date`,null),e([n({readOnly:!0,type:[`sun`],json:{write:!0}})],o.prototype,`type`,void 0),o=a=e([r(`esri.views.3d.environment.SunLighting`)],o);const s={target:null,timezoneOffset:0},c=o;export{c as default};
@@ -52,7 +52,6 @@ export default class VirtualLighting extends VirtualLightingSuperclass {
52
52
  * - May produce temporarily noisy lighting after camera or scene changes.
53
53
  * - May reduce rendering performance.
54
54
  *
55
- * @default false
56
55
  * @beta
57
56
  * @since 5.2
58
57
  */
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../../core/Evented.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../webscene/VirtualLighting.js";var a;let o=a=class extends t(i){constructor(e){super(e),this.cameraTrackingEnabled=!0,this.globalIllumination=!1,this.type=`virtual`}clone(){return new a({...this.cloneConstructProperties(),...this.cloneNonPersistentConstructProperties()})}static fromWebsceneLighting(e){return new a(e.cloneConstructProperties())}cloneWithWebsceneLighting(e){let t=this.clone();return t.directShadowsEnabled=e.directShadowsEnabled,t.glow=e.glow?.clone(),t}cloneNonPersistentConstructProperties(){return{cameraTrackingEnabled:this.cameraTrackingEnabled,globalIllumination:this.globalIllumination}}};e([n({type:Boolean})],o.prototype,`cameraTrackingEnabled`,void 0),e([n({type:Boolean})],o.prototype,`globalIllumination`,void 0),e([n({readOnly:!0,type:[`virtual`],json:{write:{isRequired:!0}}})],o.prototype,`type`,void 0),o=a=e([r(`esri.views.3d.environment.VirtualLighting`)],o);const s=o;export{s as default};
2
+ import{__decorate as e}from"tslib";import{EventedMixin as t}from"../../../core/Evented.js";import has from"../../../core/has.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../webscene/VirtualLighting.js";var a;let o=a=class extends t(i){constructor(e){super(e),this.cameraTrackingEnabled=!0,this.globalIllumination=has(`enable-feature:global-illumination`)??!1,this.type=`virtual`}clone(){return new a({...this.cloneConstructProperties(),...this.cloneNonPersistentConstructProperties()})}static fromWebsceneLighting(e){return new a(e.cloneConstructProperties())}cloneWithWebsceneLighting(e){let t=this.clone();return t.directShadowsEnabled=e.directShadowsEnabled,t.glow=e.glow?.clone(),t}cloneNonPersistentConstructProperties(){return{cameraTrackingEnabled:this.cameraTrackingEnabled,globalIllumination:this.globalIllumination}}};e([n({type:Boolean})],o.prototype,`cameraTrackingEnabled`,void 0),e([n({type:Boolean})],o.prototype,`globalIllumination`,void 0),e([n({readOnly:!0,type:[`virtual`],json:{write:{isRequired:!0}}})],o.prototype,`type`,void 0),o=a=e([r(`esri.views.3d.environment.VirtualLighting`)],o);const s=o;export{s as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as n,createRenderScreenPointArray3 as r,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as a}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as l,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,copy as h,negativeInfinity as g,expandWithNestedArray as _}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as v}from"../../../../geometry/support/normalizeUtils.js";import{create as y}from"../../../../geometry/support/ray.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as x}from"../../../../support/elevationInfoUtils.js";import{g as S}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as C}from"../../support/hitTest.js";import{fromRenderAtEye as w,fromScreen as T}from"../../support/geometryUtils/ray.js";import{defaultTolerance as E,Intersector as D,defaultScreenPolygonPrimitiveProcessor as O}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as k,DrapedScreenPolygonIntersectionQuery as A}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as j}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as M,createSliceExtrusionHalfspacePlanes as N,clipPolygonAgainstSlicedAwayHalfspaces as P,sliceFilterPredicate as F}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as I}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as L}from"../../../support/Scheduler.js";class R{constructor(e,n,r){this.viewingMode=e,this._forEachLayer=n,this._view=r,this._externalIntersectionHandlers=new t,this._tolerance=E,this._tmpRay=y(),this._tmpRegion=m(),this._validateHUDIntersector=new D(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(L.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,n){return this.intersectRay(this._getPickRay(e,this._tmpRay),H(this.viewingMode),t,n)}intersectScreenFreePointFallback(e,t,n){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,n)}intersectRayFreePointFallback(e,t,n){return this.intersectRay(e,H(this.viewingMode),t,n)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,n,r){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,r),t.results.min?t.results.min.getIntersectionPoint(n):!1}getCenterRayWithSubpixelOffset(e,t,n=.5,r=.5){return e.getRenderCenter(Z,n,r),Z[0]+=.0466,Z[1]-=.0123,w(e,Z,t)}intersectIntersectorScreen(e,t,n){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,n)}async intersectIntersectorScreenPolygon(e,t,n){t.polygonResults.init();let r=this._view.state.camera,i=await I(r,e);i!=null&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(r,t,i,n,e))}*_intersectIntersectorScreenPolygon(e,t,n,r,i){let a=new U(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=O,yield*t.intersectScreenPolygon(a.layers,n);let o=this._view.slice.plane,s=o?new M(o):null;t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectScreenPolygon(a.sliceableLayers,n),t.screenPolygonPrimitiveProcessor=O,yield*this._intersectPolygonHandlersGenerator(t,a,n,null,s,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,a,n,r),yield*t.intersectHUDScreenPolygon(a.layers,n),t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectHUDScreenPolygon(a.sliceableLayers,n),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,n){let r=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(r,t,n)}intersectToolIntersectorRay(e,t,n){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,n);let r=t.results.min;!this._view.groundView.opaque&&(!j(r)||r.intersector===7)&&(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,n))}setTolerance(e=E){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}removeIntersectionHandler(e){this._externalIntersectionHandlers.removeUnordered(e)!=null&&this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}_getPickRay(e,t){let n=this._view.state.camera;return T(n,e,t)}_intersectRayFreePointLocal(e,t){return this.viewingMode!==2||e==null||c(t,e.origin,l(b.get(),e.direction)),!1}intersectElevationFromScreen(e,t,n=0,r=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,n,r)}_intersectElevation(e,t,r=0,i=null){if(e==null)return null;let o=this._view,{renderCoordsHelper:s}=o,c=a(o.spatialReference),d=t==null?`absolute-height`:t.mode,f=x(t)/c,p=(d===`on-the-ground`?0:f+r)*c/s.unitInMeters,{camera:m}=o.state;if(d===`absolute-height`){let t=s?.getAltitude(m.eye),n=u(l(K,e.direction),s.worldUpAtPosition(m.eye,q));if(t<p&&n<0||t>=p&&n>0)return null;if(s.intersectInfiniteManifold(e,p,K)){let e=C(o,K);return e.z??=0,e.z-=f,e}return null}let h=m.projectToRenderScreen(e.origin,n(b.get())),g=new U(null,this._forEachLayer),_=o.slice.plane,v=_?F(_):null,y=new D(this.viewingMode);y.options.store=0,y.options.verticalOffset=p,y.options.normalRequired=!1;let S=this._createRayIntersectionQuery(e,h,!1);y.reset(S.beginPoint,S.endPoint,m),y.point=h;let w=null;if(i&&`type`in i&&i.type===`graphics`){let e=o.allLayerViews.find(e=>e.layer===i)?.uid;w=e?t=>t.layerViewUid===e:null}else i&&(w=e=>e.graphicUid!==i.uid);switch(d){case`relative-to-scene`:y.intersect(g.layers,S.screenPoint,this._tolerance,null,e=>(!w||w(e))&&!!e.lastValidElevationBB),this._intersectRayHandlers(y,g,S,v,!1,e=>e.type===2||e.type===7||e.type===8,!1);break;case`on-the-ground`:case`relative-to-ground`:this._intersectRayHandlers(y,g,S,v,!1,e=>e.isGround,!1)}if(y.results.min.getIntersectionPoint(K)){let e=C(o,K);return e.z=r,e}return null}computeIntersection(e,t,r,i){if(e==null)return;let a=this._view.state.camera,o=a.projectToRenderScreen(e.origin,n(b.get())),s=new U(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!(`include`in i||`exclude`in i);let c=this._createRayIntersectionQuery(e,o,r);t.reset(c.beginPoint,c.endPoint,a),t.intersect(s.layers,c.screenPoint,this._tolerance,null,s.objectFilter);let l=this._view.slice.plane,u=l?F(l):null;t.intersect(s.sliceableLayers,c.screenPoint,this._tolerance,u,s.objectFilter);let d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,s,c,u,!!d,e=>s.allowedIntersectorTypes==null||s.allowedIntersectorTypes.has(e.type));let f=b.get(),p=this._view,m=p.groundView.spatialReference;if(i&&i.enableDraped&&m!=null&&t.results.ground.getIntersectionPoint(f)){let e=p.overlayManager.renderer,n=p.renderCoordsHelper.spatialReference,r=b.get();p.renderCoordsHelper.fromRenderCoords(f,r,m),r[2]=p.elevationProvider?.getElevation(f[0],f[1],f[2],n,`ground`)??0,e.intersectRay(t,r,t.results.ground,e=>s.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){let t=e.results.hud;h(this._tmpRegion,g);let n=[],r=this._tmpRegion,i=e=>{n.push(new z(e))};e.sortResults(t.all),t.min.distance!=null&&i(t.min);for(let e of t.all)t.min.target.object!==e.target.object&&t.max.target.object!==e.target.object&&i(e);if(t.max.distance!=null&&t.max.target.object!==t.min.target.object&&i(t.max),!n.length)return;r[0]===r[2]&&(r[2]+=1),r[1]===r[3]&&(r[3]+=1);let a=!0,o=e.results.max.distance==null,s=0;for(let t of n)a&&=(e.results.min.copy(t.result),!1),o&&e.results.max.copy(t.result),e.options.store===2&&e.results.all.splice(s++,0,t.result)}_createRayIntersectionQuery(e,t,n){return new k(e.origin,c(f(),e.origin,e.direction),t,n)}_intersectRayHandlers(e,t,n,r,i,a=()=>!0,o=!0){let{options:s}=e,c=s.isFiltered,l=s.filteredLayerViewUids;for(let{handler:c,filterPredicate:l,isFiltered:u,filteredLayerViewUids:d}of this._getFilteredIntersectionHandlers(t,r,null,a,o))(!u||c.isGround&&i)&&(s.isFiltered=u,s.filteredLayerViewUids=d,c.intersectRay(e,l,e.rayBegin,e.rayEnd,n.screenPoint,n.isVerticalRay));s.isFiltered=c,s.filteredLayerViewUids=l}*_intersectPolygonHandlersGenerator(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(let{handler:l,screenPolygonPrimitiveProcessor:u,isFiltered:d,filteredLayerViewUids:f}of this._getFilteredIntersectionHandlers(t,r,i,a,o))d||l.intersectScreenPolygon==null||(c.isFiltered=d,c.filteredLayerViewUids=f,e.screenPolygonPrimitiveProcessor=u??O,yield*l.intersectScreenPolygon(e,n,s));c.isFiltered=l,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,n,r){let{basemapTerrain:i,overlayManager:a}=this._view,o=this._view.groundView.spatialReference!=null&&!a.renderer.isEmpty;if(!e.options.selectionMode||!r?.enableDraped||!o)return;let s=yield*this._createDrapedPolygonIntersectionQueries(n,i.slicePlaneEnabled?this._view.slice.plane:null);s!=null&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,s,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,n){let{state:{camera:{eye:r}},pointsOfInterest:i}=this._view,a=this._view.groundView.spatialReference,c=[],l=n?[]:null,u=S(this._view,i.focus.renderLocation),f=v(a),m=1/0,h=null,g=K,_=q,y=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,_,e))return!1;let t=h!=null&&f?h+f.shortestSignedDiff(h,g[0]):g[0];return h=t,c.push(s(t,g[1])),l&&l.push(p(_)),m=Math.min(m,d(r,_)),!0},{points:b}=t,{length:x}=b;for(let t=0;t<x;t++){let n=b[t],r=b[(t+1)%x];for(let t=0;t<u;t++){let i=t/u;if(!y(t===0?n:o(Y,e(n[0],r[0],i),e(n[1],r[1],i))))return null;yield}}if(!Number.isFinite(m))return null;if(n==null||!l)return[G(c,m)];let C=this._clipDrapedScreenPolygonIntersectionQueries(l,n,f,r);return C.length>0?C:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,n,r){let i=[],a=N(t);for(let t of P(a,e)){let e=this._createDrapedQueryFromRenderPolygon(t,n,r);e!=null&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,n){let{renderCoordsHelper:r}=this._view,i=this._view.groundView.spatialReference,a=[],o=1/0,c=null;for(let l of e){if(!r.fromRenderCoords(l,X,i))return null;let e=c!=null&&t?c+t.shortestSignedDiff(c,X[0]):X[0];c=e,a.push(s(e,X[1])),o=Math.min(o,d(n,l))}return a.length>=3&&Number.isFinite(o)?G(a,o):null}_intersectDrapedScreenPolygonPoint(e,t,n){let r=this._getPickRay(n,this._tmpRay);if(r==null)return!1;let{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,r,n)||i.intersectManifoldClosestSilhouette(r,0,t);let a=this._view.groundView.spatialReference;return!!i.fromRenderCoords(t,e,a)}_intersectGroundPoint(e,t,n){let r=this._view.state.camera,i=new U(null,this._forEachLayer),a=new D(this.viewingMode);J[0]=n[0],J[1]=n[1],J[2]=0;let o=this._createRayIntersectionQuery(t,J,!1);return a.options.selectionMode=!0,a.options.store=0,a.options.normalRequired=!1,a.options.selectOpaqueTerrainOnly=!1,a.reset(o.beginPoint,o.endPoint,r),this._intersectRayHandlers(a,i,o,null,!0,e=>e.isGround,!1),a.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,n,r=()=>!0,i=!0){for(let a of this._externalIntersectionHandlers){if(!r(a))continue;let o=!1,s=[];if(i){let t=a.layerViewUid,n=a.sublayerId,r=Array.isArray(t),i=r?t:[t],c=!1;for(let t of i)e.filterLayerViewUid(t,n)?c=!0:r&&s.push(t);o=!c}yield new B(a,a.slicePlaneEnabled?t:null,a.slicePlaneEnabled?n:null,o,s)}}}class z{constructor(e){this.result=e,this.screenPoint=r()}}class B{constructor(e,t,n,r,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=n,this.isFiltered=r,this.filteredLayerViewUids=i}}let V;function H(e){return(!V||V.viewingMode!==e)&&(V=new D(e)),V}class U{constructor(e,t){this.layers=[],this.sliceableLayers=[],this.include=e?.include,this.exclude=e?.exclude,this.objectFilter=e?.objectFilter,this.allowedIntersectorTypes=e?.allowedIntersectorTypes,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){let{include:n,exclude:r}=this;if(e==null)return n==null&&r==null;let i=n instanceof Map?n.get(e)??!1:n?.has(e),a=r instanceof Map?r.get(e)??!1:r?.has(e);return(i==null||(typeof i==`boolean`?i:t!=null&&i.has(t)))&&(a==null||!(typeof a==`boolean`?a:t!=null&&a.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function W(e){return typeof e==`object`&&!!e&&`intersectRay`in e}function G(e,t){return new A(e,_(m(g),e),t)}const K=f(),q=f(),J=r(),Y=i(),X=f(),Z=r();export{R as SceneIntersectionHelper,W as isIntersectionHandler};
2
+ import{lerp as e}from"../../../../core/mathUtils.js";import t from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as n,createRenderScreenPointArray3 as r,createScreenPointArray as i}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as a}from"../../../../core/units.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{add as c,normalize as l,dot as u,distance as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as m,copy as h,negativeInfinity as g,expandWithNestedArray as _}from"../../../../geometry/support/aaBoundingRect.js";import{createSpatialReferenceCyclical as v}from"../../../../geometry/support/normalizeUtils.js";import{create as y}from"../../../../geometry/support/ray.js";import{sv3d as b}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as x}from"../../../../support/elevationInfoUtils.js";import{g as S}from"../../../../chunks/cameraUtilsSpherical.js";import{computeMapPointFromVec3d as C}from"../../support/hitTest.js";import{fromRenderAtEye as w,fromScreen as T}from"../../support/geometryUtils/ray.js";import{defaultTolerance as E,Intersector as D,defaultScreenPolygonPrimitiveProcessor as O}from"../../webgl-engine/lib/Intersector.js";import{RayIntersectionQuery as k,DrapedScreenPolygonIntersectionQuery as A}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as j}from"../../webgl-engine/lib/IntersectorResult.js";import{SliceScreenPolygonPrimitiveProcessor as M,createSliceExtrusionHalfspacePlanes as N,clipPolygonAgainstSlicedAwayHalfspaces as P,sliceFilterPredicate as F}from"../../webgl-engine/lib/intersectorUtils.js";import{prepareScreenPolygonIntersectionQuery as I}from"../../webgl-engine/lib/screenPolygonIntersectionUtils.js";import{TaskPriority as L}from"../../../support/Scheduler.js";class R{constructor(e,n,r){this.viewingMode=e,this._forEachLayer=n,this._view=r,this._externalIntersectionHandlers=new t,this._tolerance=E,this._tmpRay=y(),this._tmpRegion=m(),this._validateHUDIntersector=new D(this.viewingMode),this._validateHUDIntersector.options.hud=!1,this._screenPolygonIntersectionTask=this._view.resourceController.scheduler.registerTask(L.SCREEN_POLYGON_INTERSECTION)}destroy(){this._screenPolygonIntersectionTask.remove(),this._externalIntersectionHandlers.prune()}get screenPolygonIntersectionTask(){return this._screenPolygonIntersectionTask}intersectScreen(e,t,n){return this.intersectRay(this._getPickRay(e,this._tmpRay),H(this.viewingMode),t,n)}intersectScreenFreePointFallback(e,t,n){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,n)}intersectRayFreePointFallback(e,t,n){return this.intersectRay(e,H(this.viewingMode),t,n)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,n,r){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,r),t.results.min?t.results.min.getIntersectionPoint(n):!1}getCenterRayWithSubpixelOffset(e,t,n=.5,r=.5){return e.getRenderCenter(Z,n,r),Z[0]+=.0466,Z[1]-=.0123,w(e,Z,t)}intersectIntersectorScreen(e,t,n){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,n)}async intersectIntersectorScreenPolygon(e,t,n){t.polygonResults.init();let r=this._view.state.camera,i=await I(r,e);i!=null&&await this._screenPolygonIntersectionTask.scheduleGenerator(e=>this._intersectIntersectorScreenPolygon(r,t,i,n,e))}*_intersectIntersectorScreenPolygon(e,t,n,r,i){let a=new U(r,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!r||!(`include`in r||`exclude`in r),t.camera=e,t.point=null,t.screenPolygonPrimitiveProcessor=O,yield*t.intersectScreenPolygon(a.layers,n);let o=this._view.slice.plane,s=o?new M(o):null;t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectScreenPolygon(a.sliceableLayers,n),t.screenPolygonPrimitiveProcessor=O,yield*this._intersectPolygonHandlersGenerator(t,a,n,null,s,void 0,!0,i),yield*this._intersectDrapedScreenPolygon(t,a,n,r),yield*t.intersectHUDScreenPolygon(a.layers,n),t.screenPolygonPrimitiveProcessor=s??O,yield*t.intersectHUDScreenPolygon(a.sliceableLayers,n),t.polygonResults.sortResults()}intersectToolIntersectorScreen(e,t,n){let r=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(r,t,n)}intersectToolIntersectorRay(e,t,n){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,n);let r=t.results.min;!this._view.groundView.opaque&&(!j(r)||r.intersector===7)&&(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,n))}setTolerance(e=E){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}removeIntersectionHandler(e){this._externalIntersectionHandlers.removeUnordered(e)!=null&&this._externalIntersectionHandlers.sort((e,t)=>e.type===7?1:t.type===7?-1:0)}_getPickRay(e,t){let n=this._view.state.camera;return T(n,e,t)}_intersectRayFreePointLocal(e,t){return this.viewingMode!==2||e==null||c(t,e.origin,l(b.get(),e.direction)),!1}intersectElevationFromScreen(e,t,n=0,r=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,n,r)}_intersectElevation(e,t,r=0,i=null){if(e==null)return null;let o=this._view,{renderCoordsHelper:s}=o,c=a(o.spatialReference),d=t==null?`absolute-height`:t.mode,f=x(t)/c,p=(d===`on-the-ground`?0:f+r)*c/s.unitInMeters,{camera:m}=o.state;if(d===`absolute-height`){let t=s?.getAltitude(m.eye),n=u(l(K,e.direction),s.worldUpAtPosition(m.eye,q));if(t<p&&n<0||t>=p&&n>0)return null;if(s.intersectInfiniteManifold(e,p,K)){let e=C(o,K);return e.z??=0,e.z-=f,e}return null}let h=m.projectToRenderScreen(e.origin,n(b.get())),g=new U(null,this._forEachLayer),_=o.slice.plane,v=_?F(_):null,y=new D(this.viewingMode);y.options.store=0,y.options.verticalOffset=p,y.options.normalRequired=!1;let S=this._createRayIntersectionQuery(e,h,!1);y.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,y.reset(S.beginPoint,S.endPoint,m),y.point=h;let w=null;if(i&&`type`in i&&i.type===`graphics`){let e=o.allLayerViews.find(e=>e.layer===i)?.uid;w=e?t=>t.layerViewUid===e:null}else i&&(w=e=>e.graphicUid!==i.uid);switch(d){case`relative-to-scene`:y.intersect(g.layers,S.screenPoint,this._tolerance,null,e=>(!w||w(e))&&!!e.lastValidElevationBB),this._intersectRayHandlers(y,g,S,v,!1,e=>e.type===2||e.type===7||e.type===8,!1);break;case`on-the-ground`:case`relative-to-ground`:this._intersectRayHandlers(y,g,S,v,!1,e=>e.isGround,!1)}if(y.results.min.getIntersectionPoint(K)){let e=C(o,K);return e.z=r,e}return null}computeIntersection(e,t,r,i){if(e==null)return;let a=this._view.state.camera,o=a.projectToRenderScreen(e.origin,n(b.get())),s=new U(i,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!i||!(`include`in i||`exclude`in i);let c=this._createRayIntersectionQuery(e,o,r);t.metersPerRenderUnit=this._view.renderCoordsHelper.unitInMeters,t.reset(c.beginPoint,c.endPoint,a),t.intersect(s.layers,c.screenPoint,this._tolerance,null,s.objectFilter);let l=this._view.slice.plane,u=l?F(l):null;t.intersect(s.sliceableLayers,c.screenPoint,this._tolerance,u,s.objectFilter);let d=i&&(i.requiresGroundFeedback||i.enableDraped);this._intersectRayHandlers(t,s,c,u,!!d,e=>s.allowedIntersectorTypes==null||s.allowedIntersectorTypes.has(e.type));let f=b.get(),p=this._view,m=p.groundView.spatialReference;if(i&&i.enableDraped&&m!=null&&t.results.ground.getIntersectionPoint(f)){let e=p.overlayManager.renderer,n=p.renderCoordsHelper.spatialReference,r=b.get();p.renderCoordsHelper.fromRenderCoords(f,r,m),r[2]=p.elevationProvider?.getElevation(f[0],f[1],f[2],n,`ground`)??0,e.intersectRay(t,r,t.results.ground,e=>s.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){let t=e.results.hud;h(this._tmpRegion,g);let n=[],r=this._tmpRegion,i=e=>{n.push(new z(e))};e.sortResults(t.all),t.min.distance!=null&&i(t.min);for(let e of t.all)t.min.target.object!==e.target.object&&t.max.target.object!==e.target.object&&i(e);if(t.max.distance!=null&&t.max.target.object!==t.min.target.object&&i(t.max),!n.length)return;r[0]===r[2]&&(r[2]+=1),r[1]===r[3]&&(r[3]+=1);let a=!0,o=e.results.max.distance==null,s=0;for(let t of n)a&&=(e.results.min.copy(t.result),!1),o&&e.results.max.copy(t.result),e.options.store===2&&e.results.all.splice(s++,0,t.result)}_createRayIntersectionQuery(e,t,n){return new k(e.origin,c(f(),e.origin,e.direction),t,n)}_intersectRayHandlers(e,t,n,r,i,a=()=>!0,o=!0){let{options:s}=e,c=s.isFiltered,l=s.filteredLayerViewUids;for(let{handler:c,filterPredicate:l,isFiltered:u,filteredLayerViewUids:d}of this._getFilteredIntersectionHandlers(t,r,null,a,o))(!u||c.isGround&&i)&&(s.isFiltered=u,s.filteredLayerViewUids=d,c.intersectRay(e,l,e.rayBegin,e.rayEnd,n.screenPoint,n.isVerticalRay));s.isFiltered=c,s.filteredLayerViewUids=l}*_intersectPolygonHandlersGenerator(e,t,n,r,i,a=()=>!0,o=!0,s){let{options:c}=e,l=c.isFiltered,u=c.filteredLayerViewUids,d=e.screenPolygonPrimitiveProcessor;for(let{handler:l,screenPolygonPrimitiveProcessor:u,isFiltered:d,filteredLayerViewUids:f}of this._getFilteredIntersectionHandlers(t,r,i,a,o))d||l.intersectScreenPolygon==null||(c.isFiltered=d,c.filteredLayerViewUids=f,e.screenPolygonPrimitiveProcessor=u??O,yield*l.intersectScreenPolygon(e,n,s));c.isFiltered=l,c.filteredLayerViewUids=u,e.screenPolygonPrimitiveProcessor=d}*_intersectDrapedScreenPolygon(e,t,n,r){let{basemapTerrain:i,overlayManager:a}=this._view,o=this._view.groundView.spatialReference!=null&&!a.renderer.isEmpty;if(!e.options.selectionMode||!r?.enableDraped||!o)return;let s=yield*this._createDrapedPolygonIntersectionQueries(n,i.slicePlaneEnabled?this._view.slice.plane:null);s!=null&&(yield*this._view.overlayManager.renderer.intersectScreenPolygon(e,s,e=>t.filterRenderGeometry(e)))}*_createDrapedPolygonIntersectionQueries(t,n){let{state:{camera:{eye:r}},pointsOfInterest:i}=this._view,a=this._view.groundView.spatialReference,c=[],l=n?[]:null,u=S(this._view,i.focus.renderLocation),f=v(a),m=1/0,h=null,g=K,_=q,y=e=>{if(!this._intersectDrapedScreenPolygonPoint(g,_,e))return!1;let t=h!=null&&f?h+f.shortestSignedDiff(h,g[0]):g[0];return h=t,c.push(s(t,g[1])),l&&l.push(p(_)),m=Math.min(m,d(r,_)),!0},{points:b}=t,{length:x}=b;for(let t=0;t<x;t++){let n=b[t],r=b[(t+1)%x];for(let t=0;t<u;t++){let i=t/u;if(!y(t===0?n:o(Y,e(n[0],r[0],i),e(n[1],r[1],i))))return null;yield}}if(!Number.isFinite(m))return null;if(n==null||!l)return[G(c,m)];let C=this._clipDrapedScreenPolygonIntersectionQueries(l,n,f,r);return C.length>0?C:null}_clipDrapedScreenPolygonIntersectionQueries(e,t,n,r){let i=[],a=N(t);for(let t of P(a,e)){let e=this._createDrapedQueryFromRenderPolygon(t,n,r);e!=null&&i.push(e)}return i.sort((e,t)=>e.distance-t.distance),i}_createDrapedQueryFromRenderPolygon(e,t,n){let{renderCoordsHelper:r}=this._view,i=this._view.groundView.spatialReference,a=[],o=1/0,c=null;for(let l of e){if(!r.fromRenderCoords(l,X,i))return null;let e=c!=null&&t?c+t.shortestSignedDiff(c,X[0]):X[0];c=e,a.push(s(e,X[1])),o=Math.min(o,d(n,l))}return a.length>=3&&Number.isFinite(o)?G(a,o):null}_intersectDrapedScreenPolygonPoint(e,t,n){let r=this._getPickRay(n,this._tmpRay);if(r==null)return!1;let{renderCoordsHelper:i}=this._view;this._intersectGroundPoint(t,r,n)||i.intersectManifoldClosestSilhouette(r,0,t);let a=this._view.groundView.spatialReference;return!!i.fromRenderCoords(t,e,a)}_intersectGroundPoint(e,t,n){let r=this._view.state.camera,i=new U(null,this._forEachLayer),a=new D(this.viewingMode);J[0]=n[0],J[1]=n[1],J[2]=0;let o=this._createRayIntersectionQuery(t,J,!1);return a.options.selectionMode=!0,a.options.store=0,a.options.normalRequired=!1,a.options.selectOpaqueTerrainOnly=!1,a.reset(o.beginPoint,o.endPoint,r),this._intersectRayHandlers(a,i,o,null,!0,e=>e.isGround,!1),a.results.ground.getIntersectionPoint(e)}*_getFilteredIntersectionHandlers(e,t,n,r=()=>!0,i=!0){for(let a of this._externalIntersectionHandlers){if(!r(a))continue;let o=!1,s=[];if(i){let t=a.layerViewUid,n=a.sublayerId,r=Array.isArray(t),i=r?t:[t],c=!1;for(let t of i)e.filterLayerViewUid(t,n)?c=!0:r&&s.push(t);o=!c}yield new B(a,a.slicePlaneEnabled?t:null,a.slicePlaneEnabled?n:null,o,s)}}}class z{constructor(e){this.result=e,this.screenPoint=r()}}class B{constructor(e,t,n,r,i){this.handler=e,this.filterPredicate=t,this.screenPolygonPrimitiveProcessor=n,this.isFiltered=r,this.filteredLayerViewUids=i}}let V;function H(e){return(!V||V.viewingMode!==e)&&(V=new D(e)),V}class U{constructor(e,t){this.layers=[],this.sliceableLayers=[],this.include=e?.include,this.exclude=e?.exclude,this.objectFilter=e?.objectFilter,this.allowedIntersectorTypes=e?.allowedIntersectorTypes,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){let{include:n,exclude:r}=this;if(e==null)return n==null&&r==null;let i=n instanceof Map?n.get(e)??!1:n?.has(e),a=r instanceof Map?r.get(e)??!1:r?.has(e);return(i==null||(typeof i==`boolean`?i:t!=null&&i.has(t)))&&(a==null||!(typeof a==`boolean`?a:t!=null&&a.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function W(e){return typeof e==`object`&&!!e&&`intersectRay`in e}function G(e,t){return new A(e,_(m(g),e),t)}const K=f(),q=f(),J=r(),Y=i(),X=f(),Z=r();export{R as SceneIntersectionHelper,W as isIntersectionHandler};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{watch as n,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{waitRender as i}from"../../../../../core/scheduling.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{set as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_W as s,ZEROS as c}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../../webgl.js";import{AmbientIllumination as u}from"../AmbientIllumination.js";import{G as d}from"../../../../../chunks/GlobalIllumination.glsl.js";import{G as f}from"../../../../../chunks/GlobalIlluminationBlur.glsl.js";import{GlobalIlluminationBlurTechnique as p}from"./GlobalIlluminationBlurTechnique.js";import{GlobalIlluminationTechnique as m}from"./GlobalIlluminationTechnique.js";import{GlobalIlluminationTechniqueConfiguration as h}from"./GlobalIlluminationTechniqueConfiguration.js";import{G as g}from"../../../../../chunks/GlobalIlluminationUpscale.glsl.js";import{GlobalIlluminationUpscaleTechnique as _}from"./GlobalIlluminationUpscaleTechnique.js";import{DepthStencilAttachment as v,ColorAttachment1 as y}from"../../../../webgl/enums.js";let b=class extends u{constructor(e){super(e),this._passParameters=new d,this._drawParameters=new f,this._drawParametersUpscale=new g,this._configuration=new h,this._lastOutput=null,this._isGlobalIlluminationUpdate=!1,this._lowQualityResolutionScale=.35,this._maxFrames=256}initialize(){this.addHandles(n(()=>this._mode,e=>{e===0?this._disable():this._enable()},r))}destroy(){this._lastOutput=t(this._lastOutput)}_disable(){super._disable(),this._resetAccumulation(),this._passParameters.temporalSampleFrame=0}get hasHighQuality(){return this._mode===2}resetAccumulation(){!this._isGlobalIlluminationUpdate&&(this._passParameters.accumulatedFrames>100||!this._configuration.hasEmission)&&this._resetAccumulation()}_resetAccumulation(){this._passParameters.accumulatedFrames=0,this._lastOutput=t(this._lastOutput)}get isAccumulating(){return this.enabled&&this._passParameters.accumulatedFrames<this._maxFrames}precompile(){this.techniques.getCompiled(_)}render(e){if(this.bindParameters.frameRendererTarget===3)return null;let t=this.bindParameters.frameRendererTarget!==0;if(this._passParameters.accumulatedFrames>=this._maxFrames&&!t)return this._lastOutput?.retain(),this._lastOutput;let n=e.find(({name:e})=>e===`normals`),r=n?.getTexture(),i=n?.getTexture(v);return!r||!i||this._mode===0?this._emptyOutput:(this._configuration.hasEmission=!!this.bindParameters.reprojection.lastFrameEmission,t?this._renderOffscreen(r,i):this._renderInteractive(r,i))}_renderOffscreen(e,t){let n=this._emptyOutput,r=this._passParameters.accumulatedFrames,i=this._passParameters.temporalSampleFrame;this._passParameters.accumulatedFrames=0,this._passParameters.temporalSampleFrame=0;let a=this.techniques.get(m,this._configuration),o=this.techniques.get(p);for(;this._passParameters.accumulatedFrames<this._maxFrames;){this._passParameters.globalIllumination=n.getTexture(),this._passParameters.globalIlluminationWeights=n.getTexture(y);let r=this._renderAccumulationFrame(e,t,a,o);++this._passParameters.accumulatedFrames,n.release(),n=r}return this._passParameters.globalIllumination=null,this._passParameters.globalIlluminationWeights=null,this._passParameters.accumulatedFrames=r,this._passParameters.temporalSampleFrame=i,n}_renderInteractive(e,t){if(!this._canRender)return this._requestRender(),this._emptyOutput;let n=this._mode===1?this._lowQualityResolutionScale:1,r=this.techniques.getCompiled(m,this._configuration),i=this.techniques.getCompiled(p),a=n<1,o=a?this.techniques.getCompiled(_):null;if(!r||!i||a&&!o)return this._requestRender(),this._emptyOutput;let s=this._renderAccumulationFrame(e,t,r,i,o,n);return++this._passParameters.accumulatedFrames,this._passParameters.accumulatedFrames<this._maxFrames&&this._requestRender(),this._storeOutput(s),s}_renderAccumulationFrame(e,t,n,r,i,a=1){let s=this.bindParameters,c=this.renderingContext,{camera:u}=s;this._passParameters.normalTexture=e,this._passParameters.depthTexture=t,this._passParameters.projScale=1/u.computeScreenPixelSizeAtDistance(1),this._passParameters.resolutionScale=a,this._passParameters.glowBoost=this._glowBoost;let{fullWidth:d,fullHeight:f}=u,p=Math.max(1,Math.floor(d*a)),m=Math.max(1,Math.floor(f*a)),h=this.fboCache.acquire(p,m,`global illumination input`).acquireColor(y,2);c.bindFramebuffer(h.fbo),c.setViewport(0,0,p,m),c.bindTechnique(n,s,this._passParameters,this._drawParameters),c.screen.draw();let g=Math.max(1,Math.round(p)),_=Math.max(1,Math.round(m)),v=this.fboCache.acquire(g,_,`global illumination blur horizontal`);c.bindFramebuffer(v.fbo);let b=h.obtainAttachment(y);this._drawParameters.texture=h.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,0,1/m),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),h.release();let x=this.fboCache.acquire(g,_,i?`global illumination blur vertical`:l.AMBIENT_ILLUMINATION);c.bindFramebuffer(x.fbo),c.setViewport(0,0,g,_),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParameters.texture=v.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,1/g,0),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),v.release(),x.attachColor(b,y),b.release();let S=x;return i&&(S=this.fboCache.acquire(d,f,l.AMBIENT_ILLUMINATION).acquireColor(y,2),c.bindFramebuffer(S.fbo),c.setViewport(0,0,d,f),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParametersUpscale.colorTexture=x.getTexture(),this._drawParametersUpscale.weightTexture=x.getTexture(y),c.bindTechnique(i,s,this._passParameters,this._drawParametersUpscale),c.screen.draw(),x.release()),c.setViewport4fv(u.fullViewport),this._passParameters.temporalSampleFrame=(this._passParameters.temporalSampleFrame+1)%64,S}_requestRender(){this._isGlobalIlluminationUpdate=!0,this.requestRender(1),this._isGlobalIlluminationUpdate=!1}_storeOutput(e){this._lastOutput!==e&&(this._lastOutput=t(this._lastOutput),this._lastOutput=e,this._lastOutput.retain())}get _emptyOutput(){let e=this.renderingContext,{fullWidth:t,fullHeight:n}=this.bindParameters.camera,r=this.fboCache.acquire(t,n,l.AMBIENT_ILLUMINATION).acquireColor(y,2);return e.bindFramebuffer(r.fbo),e.setViewport(0,0,t,n),e.clearBuffer(0,s),e.clearBuffer(1,c),r}get _canRender(){let{reprojection:e,hasEmission:t,globalIllumination:n}=this.bindParameters;return!!e.lastFrameColor&&(!t||!!e.lastFrameEmission)&&!!e.lastFrameDepth&&!!n}get _glowBoost(){let e=this.view.environment.lighting.glow;return e==null?0:2+3*e.intensity}get _mode(){return this._useGlobalIllumination?this.view.stage.renderer.isFeatureEnabled(10)?2:1:0}get test(){let e=this;return{get maxFrames(){return e._maxFrames},set maxFrames(t){e._maxFrames=t},get lowQualityResolutionScale(){return e._lowQualityResolutionScale},set lowQualityResolutionScale(t){e._lowQualityResolutionScale=t},passParameters:this._passParameters,configuration:this._configuration,get mode(){return e._mode},async restartAccumulation(){e.produces!==`disabled`&&(e._disable(),await i(),e._enable())}}}};b=e([a(`esri.views.3d.webgl-engine.effects.globalIllumination.GlobalIllumination`)],b);export{b as GlobalIllumination};
2
+ import{__decorate as e}from"tslib";import{releaseMaybe as t}from"../../../../../core/maybe.js";import{watch as n,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{waitRender as i}from"../../../../../core/scheduling.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{set as o}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_W as s,ZEROS as c}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../../webgl.js";import{AmbientIllumination as u}from"../AmbientIllumination.js";import{G as d}from"../../../../../chunks/GlobalIllumination.glsl.js";import{G as f}from"../../../../../chunks/GlobalIlluminationBlur.glsl.js";import{GlobalIlluminationBlurTechnique as p}from"./GlobalIlluminationBlurTechnique.js";import{GlobalIlluminationTechnique as m}from"./GlobalIlluminationTechnique.js";import{GlobalIlluminationTechniqueConfiguration as h}from"./GlobalIlluminationTechniqueConfiguration.js";import{G as g}from"../../../../../chunks/GlobalIlluminationUpscale.glsl.js";import{GlobalIlluminationUpscaleTechnique as _}from"./GlobalIlluminationUpscaleTechnique.js";import{DepthStencilAttachment as v,ColorAttachment1 as y}from"../../../../webgl/enums.js";let b=class extends u{constructor(e){super(e),this._passParameters=new d,this._drawParameters=new f,this._drawParametersUpscale=new g,this._configuration=new h,this._lastOutput=null,this._isGlobalIlluminationUpdate=!1,this._lowQualityResolutionScale=.35,this._maxFrames=256}initialize(){this.addHandles(n(()=>this._mode,e=>{e===0?this._disable():this._enable()},r))}destroy(){this._lastOutput=t(this._lastOutput)}_disable(){super._disable(),this._resetAccumulation(),this._passParameters.temporalSampleFrame=0}get hasHighQuality(){return this._mode===2}resetAccumulation(){!this._isGlobalIlluminationUpdate&&(this._passParameters.accumulatedFrames>100||!this._configuration.hasEmission)&&this._resetAccumulation()}_resetAccumulation(){this._passParameters.accumulatedFrames=0,this._lastOutput=t(this._lastOutput)}get isAccumulating(){return this.enabled&&this._passParameters.accumulatedFrames<this._maxFrames}precompile(){this.techniques.getCompiled(_)}render(e){if(this.bindParameters.frameRendererTarget===3)return null;let t=this.bindParameters.frameRendererTarget!==0;if(this._passParameters.accumulatedFrames>=this._maxFrames&&!t)return this._lastOutput?.retain(),this._lastOutput;let n=e.find(({name:e})=>e===`normals`),r=n?.getTexture(),i=n?.getTexture(v);return!r||!i||this._mode===0?this._emptyOutput:(this._configuration.hasEmission=!!this.bindParameters.reprojection.lastFrameEmission,t?this._renderOffscreen(r,i):this._renderInteractive(r,i))}_renderOffscreen(e,t){let n=this._emptyOutput,r=this._passParameters.accumulatedFrames,i=this._passParameters.temporalSampleFrame;this._passParameters.accumulatedFrames=0,this._passParameters.temporalSampleFrame=0;let a=this.techniques.get(m,this._configuration),o=this.techniques.get(p);for(;this._passParameters.accumulatedFrames<this._maxFrames;){this._passParameters.globalIllumination=n.getTexture(),this._passParameters.globalIlluminationWeights=n.getTexture(y);let r=this._renderAccumulationFrame(e,t,a,o);++this._passParameters.accumulatedFrames,n.release(),n=r}return this._passParameters.globalIllumination=null,this._passParameters.globalIlluminationWeights=null,this._passParameters.accumulatedFrames=r,this._passParameters.temporalSampleFrame=i,n}_renderInteractive(e,t){if(!this._canRender)return this._requestRender(),this._emptyOutput;let n=this._mode===1?this._lowQualityResolutionScale*this.bindParameters.camera.pixelScale:1,r=n>=.99?1:n,i=this.techniques.getCompiled(m,this._configuration),a=this.techniques.getCompiled(p),o=r<1,s=o?this.techniques.getCompiled(_):null;if(!i||!a||o&&!s)return this._requestRender(),this._emptyOutput;let c=this._renderAccumulationFrame(e,t,i,a,s,r);return++this._passParameters.accumulatedFrames,this._passParameters.accumulatedFrames<this._maxFrames&&this._requestRender(),this._storeOutput(c),c}_renderAccumulationFrame(e,t,n,r,i,a=1){let s=this.bindParameters,c=this.renderingContext,{camera:u}=s;this._passParameters.normalTexture=e,this._passParameters.depthTexture=t,this._passParameters.projScale=1/u.computeScreenPixelSizeAtDistance(1),this._passParameters.resolutionScale=a,this._passParameters.glowBoost=this._glowBoost;let{fullWidth:d,fullHeight:f}=u,p=Math.max(1,Math.floor(d*a)),m=Math.max(1,Math.floor(f*a)),h=this.fboCache.acquire(p,m,`global illumination input`).acquireColor(y,2);c.bindFramebuffer(h.fbo),c.setViewport(0,0,p,m),c.bindTechnique(n,s,this._passParameters,this._drawParameters),c.screen.draw();let g=Math.max(1,Math.round(p)),_=Math.max(1,Math.round(m)),v=this.fboCache.acquire(g,_,`global illumination blur horizontal`);c.bindFramebuffer(v.fbo);let b=h.obtainAttachment(y);this._drawParameters.texture=h.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,0,1/m),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),h.release();let x=this.fboCache.acquire(g,_,i?`global illumination blur vertical`:l.AMBIENT_ILLUMINATION);c.bindFramebuffer(x.fbo),c.setViewport(0,0,g,_),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParameters.texture=v.getTexture(),this._drawParameters.weightTexture=b.attachment,o(this._drawParameters.blurSize,1/g,0),c.bindTechnique(r,s,this._passParameters,this._drawParameters),c.setViewport(0,0,g,_),c.screen.draw(),v.release(),x.attachColor(b,y),b.release();let S=x;return i&&(S=this.fboCache.acquire(d,f,l.AMBIENT_ILLUMINATION).acquireColor(y,2),c.bindFramebuffer(S.fbo),c.setViewport(0,0,d,f),c.setClearColor(1,1,1,0),c.clear(16384),this._drawParametersUpscale.colorTexture=x.getTexture(),this._drawParametersUpscale.weightTexture=x.getTexture(y),c.bindTechnique(i,s,this._passParameters,this._drawParametersUpscale),c.screen.draw(),x.release()),c.setViewport4fv(u.fullViewport),this._passParameters.temporalSampleFrame=(this._passParameters.temporalSampleFrame+1)%64,S}_requestRender(){this._isGlobalIlluminationUpdate=!0,this.requestRender(1),this._isGlobalIlluminationUpdate=!1}_storeOutput(e){this._lastOutput!==e&&(this._lastOutput=t(this._lastOutput),this._lastOutput=e,this._lastOutput.retain())}get _emptyOutput(){let e=this.renderingContext,{fullWidth:t,fullHeight:n}=this.bindParameters.camera,r=this.fboCache.acquire(t,n,l.AMBIENT_ILLUMINATION).acquireColor(y,2);return e.bindFramebuffer(r.fbo),e.setViewport(0,0,t,n),e.clearBuffer(0,s),e.clearBuffer(1,c),r}get _canRender(){let{reprojection:e,hasEmission:t,globalIllumination:n}=this.bindParameters;return!!e.lastFrameColor&&(!t||!!e.lastFrameEmission)&&!!e.lastFrameDepth&&!!n}get _glowBoost(){let e=this.view.environment.lighting.glow;return e==null?0:2+3*e.intensity}get _mode(){return this._useGlobalIllumination?this.view.stage.renderer.isFeatureEnabled(10)?2:1:0}get test(){let e=this;return{get maxFrames(){return e._maxFrames},set maxFrames(t){e._maxFrames=t},get lowQualityResolutionScale(){return e._lowQualityResolutionScale},set lowQualityResolutionScale(t){e._lowQualityResolutionScale=t},passParameters:this._passParameters,configuration:this._configuration,get mode(){return e._mode},async restartAccumulation(){e.produces!==`disabled`&&(e._disable(),await i(),e._enable())}}}};b=e([a(`esri.views.3d.webgl-engine.effects.globalIllumination.GlobalIllumination`)],b);export{b as GlobalIllumination};
@@ -25,13 +25,18 @@ float dispersionPerPixel = getDistanceFalloff(mainDepth, rayDir, scattering * 0.
25
25
  float mainPoint = pow(dispersionPerPixel, 2.0);
26
26
  vec3 emission = vec3(0.0);
27
27
  float weights = 0.0;
28
- float sigmaSq = (0.1 / maxScattering * scattering + 0.003) + 0.03 * (boost - 1.0);
29
- for(float level = floor(mainPoint); level < levels; ++level) {
28
+ float baseSigmaSq = 0.003 + 0.03 * (boost - 1.0);
29
+ float sigmaSq = baseSigmaSq + 0.1 * scattering / maxScattering;
30
+ float minPoint = mainPoint - 0.5;
31
+ float fullPoint = (minPoint + mainPoint) * 0.5;
32
+ for(float level = 0.0; level < levels; ++level) {
30
33
  float point = level / levels;
31
- float dist = abs(point - mainPoint);
32
- float weight = gauss(dist, sigmaSq);
34
+ float dist = point - mainPoint;
35
+ float weight = gauss(dist, sigmaSq) * smoothstep(minPoint, fullPoint, point);
36
+ if(weight > 0.0) {
33
37
  emission += readEmission(point) * weight;
34
38
  weights += weight;
35
39
  }
40
+ }
36
41
  return emission * boost / weights;
37
42
  }`)}export{d as BlurEmissionPassParameters,f as applyEmissiveGlow};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{add as n,transformMat4 as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustumPlanes.js";import{create as s,fromPoints as c,copy as l}from"../../../../geometry/support/ray.js";import u from"../../webgl/RenderCamera.js";import{HUDTarget as d,HUDIntersectorResult as f}from"./HUDIntersectorResult.js";import{IntersectorOptions as p}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as h}from"./IntersectorResult.js";import{ObjectTarget as g}from"./ObjectTarget.js";import{PolygonIntersectionResults as _}from"./PolygonIntersectionResults.js";import{IntersectorTransform as v,getVerticalOffsetObject3D as y}from"./verticalOffsetUtils.js";const b=1e-5,x=t();class S{constructor(e){this.options=new p,this._results=new C,this.polygonResults=new _,this.transform=new v,this.camera=new u,this.screenPolygonPrimitiveProcessor=w,this.tolerance=b,this.verticalOffset=null,this._ray=s(),this._rayEnd=a(),this._rayBeginTransformed=a(),this._rayEndTransformed=a(),this.viewingMode=e??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(e,t,n){this.resetWithRay(c(e,t,this._ray),n)}resetWithRay(e,t){this.camera=t,e!==this._ray&&l(e,this._ray),this.options.verticalOffset===0?this.verticalOffset=null:this.viewingMode===2?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset,n(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(e=null,t,n,r,i){this.point=t,this.filterPredicate=r,this.tolerance=n??b;let a=y(this.verticalOffset);if(e&&e.length>0){let t=i?e=>{i(e)&&this.intersectObject(e)}:e=>{this.intersectObject(e)};for(let n of e){let e=n.getSpatialQueryAccelerator?.();e==null?n.objects.forEach(e=>t(e)):(a==null?e.forEachAlongRay(this._ray.origin,this._ray.direction,t):e.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,t,a),this.options.selectionMode&&this.options.hud&&e.forEachDegenerateObject(t))}}this.sortResults()}*intersectScreenPolygon(e=null,t){if(this.verticalOffset=null,e?.length)for(let n of e){let e=n.getSpatialQueryAccelerator?.();if(e!=null)for(let n of e.intersectingFrustumValues(t.broadPhaseFrustum,e=>e.visible))yield*this._intersectScreenPolygonObject(n,t);else for(let e of n.objects.values())e.visible&&o(t.broadPhaseFrustum,e.boundingVolumeWorldSpace.sphere)&&(yield*this._intersectScreenPolygonObject(e,t))}}*intersectHUDScreenPolygon(e=null,t){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&e?.length)for(let n of e){let e=(n.getSpatialQueryAccelerator?.())?.degenerateObjectValues()??n.objects.values();for(let n of e)yield*this._intersectScreenPolygonObject(n,t)}}*_intersectScreenPolygonObject(e,t){let n=e.geometries;if(!e.visible||!n)return;let r=e.effectiveTransformation;for(let i of n){if(!i.visible)continue;let{material:n,id:a}=i;if(!n.visible||!n.intersectScreenPolygon)continue;this._setGeometryTransform(r,i);let o=n.intersectScreenPolygon(i,this.transform.transform,this,t);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new g(e,a,o.primitiveIndex),o.distance,o.renderDistance,o.point),yield}}intersectObject(e){let t=e.geometries;if(!t)return;let n=e.effectiveTransformation,i=y(this.verticalOffset);for(let a of t){if(!a.visible)continue;let{material:t,id:o}=a;if(!t.visible)continue;this._setGeometryTransform(n,a),r(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),r(this._rayEndTransformed,this.rayEnd,this.transform.inverse);let s=this.transform.transform;i!=null&&(i.objectTransform=this.transform),t.intersectRay(a,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(t,n,r,i,a)=>this.handleObjectIntersection({object:e,geometryId:o,primitiveIndex:i},t,n,r,s,a))}}_setGeometryTransform(t,n){let r=n.type===1?e(x,n.localOrigin.vec3):n.transformation;this.transform.setAndInvalidateLazyTransforms(t,r)}handleObjectIntersection(e,t,n,r,i,a){if(t<0||this.filterPredicate!=null&&!this.filterPredicate(this._ray.origin,this._rayEnd,n))return;let o=a?this._results.hud:this._results;e=a?new d(e,a):e;let s=a?i=>i.set(1,e,t,n,r):a=>a.set(4,e,t,n,r,i);if((o.min.renderDistance==null||n<o.min.renderDistance)&&s(o.min),this.options.store!==0&&(o.max.renderDistance==null||n>o.max.renderDistance)&&s(o.max),this.options.store===2){if(a){let e=new f(this._ray);s(e),this._results.hud.all.push(e)}else{let e=new m(this._ray);s(e),this._results.all.push(e)}}}_handleObjectScreenPolygonIntersection(e,t,n,r,i){n<0||(this.filterPredicate==null||i!=null&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(e,e===1&&i?new d(t,i):t,n,r)}sortResults(e=this._results.all){e.sort(h)}}class C{constructor(){this.min=new m(s()),this.max=new m(s()),this.hud={min:new f(s()),max:new f(s()),all:[]},this.ground=new m(s()),this.all=[]}init(e){this.min.init(e),this.max.init(e),this.ground.init(e),this.all.length=0,this.hud.min.init(e),this.hud.max.init(e),this.hud.all.length=0}}const w={*processTriangle(e){yield e},*processLineSegment(e,t,n){i(e[0],t),i(e[1],n),yield e},validatePoint(){return!0}};export{S as Intersector,w as defaultScreenPolygonPrimitiveProcessor,b as defaultTolerance};
2
+ import{fromTranslation as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{add as n,transformMat4 as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustumPlanes.js";import{create as s,fromPoints as c,copy as l}from"../../../../geometry/support/ray.js";import u from"../../webgl/RenderCamera.js";import{HUDTarget as d,HUDIntersectorResult as f}from"./HUDIntersectorResult.js";import{IntersectorOptions as p}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as h}from"./IntersectorResult.js";import{ObjectTarget as g}from"./ObjectTarget.js";import{PolygonIntersectionResults as _}from"./PolygonIntersectionResults.js";import{IntersectorTransform as v,getVerticalOffsetObject3D as y}from"./verticalOffsetUtils.js";const b=1e-5,x=t();class S{constructor(e){this.options=new p,this._results=new C,this.polygonResults=new _,this.transform=new v,this.camera=new u,this.metersPerRenderUnit=1,this.screenPolygonPrimitiveProcessor=w,this.tolerance=b,this.verticalOffset=null,this._ray=s(),this._rayEnd=a(),this._rayBeginTransformed=a(),this._rayEndTransformed=a(),this.viewingMode=e??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(e,t,n){this.resetWithRay(c(e,t,this._ray),n)}resetWithRay(e,t){this.camera=t,e!==this._ray&&l(e,this._ray),this.options.verticalOffset===0?this.verticalOffset=null:this.viewingMode===2?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset,n(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(e=null,t,n,r,i){this.point=t,this.filterPredicate=r,this.tolerance=n??b;let a=y(this.verticalOffset);if(e&&e.length>0){let t=i?e=>{i(e)&&this.intersectObject(e)}:e=>{this.intersectObject(e)};for(let n of e){let e=n.getSpatialQueryAccelerator?.();e==null?n.objects.forEach(e=>t(e)):(a==null?e.forEachAlongRay(this._ray.origin,this._ray.direction,t):e.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,t,a),this.options.selectionMode&&this.options.hud&&e.forEachDegenerateObject(t))}}this.sortResults()}*intersectScreenPolygon(e=null,t){if(this.verticalOffset=null,e?.length)for(let n of e){let e=n.getSpatialQueryAccelerator?.();if(e!=null)for(let n of e.intersectingFrustumValues(t.broadPhaseFrustum,e=>e.visible))yield*this._intersectScreenPolygonObject(n,t);else for(let e of n.objects.values())e.visible&&o(t.broadPhaseFrustum,e.boundingVolumeWorldSpace.sphere)&&(yield*this._intersectScreenPolygonObject(e,t))}}*intersectHUDScreenPolygon(e=null,t){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&e?.length)for(let n of e){let e=(n.getSpatialQueryAccelerator?.())?.degenerateObjectValues()??n.objects.values();for(let n of e)yield*this._intersectScreenPolygonObject(n,t)}}*_intersectScreenPolygonObject(e,t){let n=e.geometries;if(!e.visible||!n)return;let r=e.effectiveTransformation;for(let i of n){if(!i.visible)continue;let{material:n,id:a}=i;if(!n.visible||!n.intersectScreenPolygon)continue;this._setGeometryTransform(r,i);let o=n.intersectScreenPolygon(i,this.transform.transform,this,t);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new g(e,a,o.primitiveIndex),o.distance,o.renderDistance,o.point),yield}}intersectObject(e){let t=e.geometries;if(!t)return;let n=e.effectiveTransformation,i=y(this.verticalOffset);for(let a of t){if(!a.visible)continue;let{material:t,id:o}=a;if(!t.visible)continue;this._setGeometryTransform(n,a),r(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),r(this._rayEndTransformed,this.rayEnd,this.transform.inverse);let s=this.transform.transform;i!=null&&(i.objectTransform=this.transform),t.intersectRay(a,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(t,n,r,i,a)=>this.handleObjectIntersection({object:e,geometryId:o,primitiveIndex:i},t,n,r,s,a))}}_setGeometryTransform(t,n){let r=n.type===1?e(x,n.localOrigin.vec3):n.transformation;this.transform.setAndInvalidateLazyTransforms(t,r)}handleObjectIntersection(e,t,n,r,i,a){if(t<0||this.filterPredicate!=null&&!this.filterPredicate(this._ray.origin,this._rayEnd,n))return;let o=a?this._results.hud:this._results;e=a?new d(e,a):e;let s=a?i=>i.set(1,e,t,n,r):a=>a.set(4,e,t,n,r,i);if((o.min.renderDistance==null||n<o.min.renderDistance)&&s(o.min),this.options.store!==0&&(o.max.renderDistance==null||n>o.max.renderDistance)&&s(o.max),this.options.store===2){if(a){let e=new f(this._ray);s(e),this._results.hud.all.push(e)}else{let e=new m(this._ray);s(e),this._results.all.push(e)}}}_handleObjectScreenPolygonIntersection(e,t,n,r,i){n<0||(this.filterPredicate==null||i!=null&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(e,e===1&&i?new d(t,i):t,n,r)}sortResults(e=this._results.all){e.sort(h)}}class C{constructor(){this.min=new m(s()),this.max=new m(s()),this.hud={min:new f(s()),max:new f(s()),all:[]},this.ground=new m(s()),this.all=[]}init(e){this.min.init(e),this.max.init(e),this.ground.init(e),this.all.length=0,this.hud.min.init(e),this.hud.max.init(e),this.hud.all.length=0}}const w={*processTriangle(e){yield e},*processLineSegment(e,t,n){i(e[0],t),i(e[1],n),yield e},validatePoint(){return!0}};export{S as Intersector,w as defaultScreenPolygonPrimitiveProcessor,b as defaultTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as n,createScreenPointArray as r}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as i,Seconds as a}from"../../../../core/time.js";import{copy as o,set as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as l,subtract as u,dot as d,scale as f,add as p,copy as m,length as h,distance as g,lerp as _,transformMat4 as v,normalize as y}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromPoints as S,distance2 as C,closestLineSegmentPoint as w,projectPoint as T,projectPointFraction as E,create as D}from"../../../../geometry/support/lineSegment.js";import{fromPoints as O,signedDistance as k,getNormal as ee,create as A}from"../../../../geometry/support/plane.js";import{BufferViewVec3f as j,BufferViewFloat as M,BufferViewVec4Unorm8 as N,BufferViewVec4f16 as te,BufferViewUint32 as ne}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOLID as re,isColor as ie,isDepth as ae,isColorHighlightOLIDOrDepth as oe,is2DGeometryOutput as se}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as ce}from"../effects/geometry/olidUtils.js";import le from"../lib/GLMaterial.js";import{LineMaterial as ue}from"../lib/LineMaterial.js";import{projectWorldLineSegmentToRenderScreen as de,screenPolygonIntersectsBufferedSegment as fe}from"../lib/screenPolygonOverlapUtils.js";import{Hit as pe,DrapedHit as me}from"../lib/screenPolygonTriangleIntersections.js";import{ScreenSizePerspectiveEvaluator as he}from"../lib/screenSizePerspectiveUtils.js";import{isTranslationMatrix as ge,assert as P}from"../lib/Util.js";import{isImagePattern as _e}from"./lineStippleUtils.js";import{VisualVariablePassParameters as ve}from"./VisualVariablePassParameters.js";import{writeColor as ye}from"./internal/bufferWriterUtils.js";import{n as be}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as xe,getTextureBufferLayout as Se}from"../shaders/RibbonLineLayouts.js";import{RibbonLineTechnique as Ce}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as we}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as Te}from"../../../../webscene/support/AlphaCutoff.js";class Ee extends ue{constructor(e,t){super(e,Oe),this.produces=new Map([[2,e=>re(e)||ie(e)&&this.parameters.renderOccluded===8],[3,e=>ae(e)],[10,e=>oe(e)&&this.parameters.renderOccluded===8],[11,e=>oe(e)&&this.parameters.renderOccluded===8],[4,e=>ie(e)&&this.parameters.writeDepth&&this.parameters.renderOccluded!==8],[8,e=>ie(e)&&!this.parameters.writeDepth&&this.parameters.renderOccluded!==8],[18,e=>se(e)]]),this._configuration=new we(t.state.isGlobal),this._isAssumedMetalDriver=t.stage.renderer.renderContext.rctx.isAssumedMetalDriver}updateConfiguration(e){super.updateConfiguration(e),this._configuration.useFlatJoinVarying=!this._isAssumedMetalDriver;let t=this.parameters.stipplePattern!=null&&this.parameters.stippleTexture!=null&&e.output!==10,n=t&&this.parameters.isImagePattern()&&this._configuration.draped,r=this.parameters.usesWorldSizedWidth(n);this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.stippleEnabled=t,this._configuration.stippleOffColorEnabled=t&&this.parameters.stippleOffColor!=null,this._configuration.stipplePreferContinuous=t&&this.parameters.stipplePreferContinuous,this._configuration.numJoinSubdivisions=Ne(this.parameters.join,t),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins=this.parameters.join===`round`,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=this.parameters.markerParameters!=null&&Me(this.parameters.markerParameters),this._configuration.polygonOffsetIndex=this.parameters.polygonOffsetIndex,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&this.parameters.innerColor!=null,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=+!!this.emissions,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective&&!r,this._configuration.worldSized=r,this._configuration.imagePattern=n}get visible(){return this.parameters.color[3]>=Te||this.parameters.stipplePattern!=null&&(this.parameters.stippleOffColor?.[3]??0)>Te}get emissions(){return this.parameters.emissiveStrength>0?this.parameters.renderOccluded===8?1:2:0}setParameters(e,t){e.animation=this.parameters.animation,super.setParameters(e,t)}intersectRayDraped({attributes:e},n,r,i,a,o,s){if(!n.options.selectionMode)return;let c=this._getLineSize(e,!0),l=r[0],u=r[1],d=Ae(c,o,s,this.parameters.usesWorldSizedWidth()),f=Number.MAX_VALUE,p=0;for(let n of je(z,B,this.parameters,e)){let e=l-z[0],r=u-z[1],i=B[0]-z[0],a=B[1]-z[1],o=i*e+a*r,s=i*i+a*a,c=t(o/s,0,1),d=i*c-e,m=a*c-r,h=d*d+m*m;h<f&&(f=h,p=n)}f<d*d&&i(a.distance,a.renderDistance,a.normal,p)}intersectRay(t,n,r,i,a,s){let{options:c,camera:_,rayBegin:v,rayEnd:y}=r;if(!c.selectionMode||!t.visible||!_)return;if(!ge(n)){e.getLogger(`esri.views.3d.webgl-engine.materials.RibbonLineMaterial`).error(`intersection assumes a translation-only matrix`);return}let b=t.attributes,x=b.get(`position`).data,T=this._getLineSize(b),E=Ie;o(E,r.point);let D=T*_.pixelRatio,A=$*_.pixelRatio,j=D/2+A;l(X[0],E[0]-j,E[1]+j,0),l(X[1],E[0]+j,E[1]+j,0),l(X[2],E[0]+j,E[1]-j,0),l(X[3],E[0]-j,E[1]-j,0);for(let e=0;e<4;e++)if(!_.unprojectFromRenderScreen(X[e],Z[e]))return;O(_.eye,Z[0],Z[1],He),O(_.eye,Z[1],Z[2],Ue),O(_.eye,Z[2],Z[3],We),O(_.eye,Z[3],Z[0],Q);let M=Number.MAX_VALUE,N=0;for(let e of this._forEachTransformedLineSegment(L,R,x,n,I(this.parameters,b))){if(k(He,L)<0&&k(He,R)<0||k(Ue,L)<0&&k(Ue,R)<0||k(We,L)<0&&k(We,R)<0||k(Q,L)<0&&k(Q,R)<0)continue;let t=_.projectToRenderScreen(L,G),n=_.projectToRenderScreen(R,K);if(t==null||n==null)continue;if(t[2]<0&&n[2]>0){u(U,L,R);let e=_.frustum,n=-k(e[4],L)/d(U,ee(e[4]));if(f(U,U,n),p(L,L,U),!_.projectToRenderScreen(L,t))continue}else if(t[2]>0&&n[2]<0){u(U,R,L);let e=_.frustum,t=-k(e[4],R)/d(U,ee(e[4]));if(f(U,U,t),p(R,R,U),!_.projectToRenderScreen(R,n))continue}else if(t[2]<0&&n[2]<0)continue;t[2]=0,n[2]=0;let r=S(t,n,q),i=C(r,E);if(!(i>=M)){if(this.parameters.screenSizePerspective){let e=this.computeScreenSizePerspectiveWidth(r,L,R,E,_,T,A);if(i>=e*e)continue}M=i,m(ze,L),m(Be,R),N=e}}if(M<j*j){let e=Number.MAX_VALUE;if(w(S(ze,Be,q),S(v,y,Ve),W)){u(W,W,v);let t=h(W);f(W,W,1/t),e=t/g(v,y)}s(e,e,W,N)}}intersectScreenPolygon(t,n,r,i){let{options:a,camera:o,screenPolygonPrimitiveProcessor:s}=r;if(!a.selectionMode||!t.visible)return null;if(!ge(n))return e.getLogger(`esri.views.3d.webgl-engine.materials.RibbonLineMaterial`).error(`intersection assumes a translation-only matrix`),null;let c=t.attributes,l=c.get(`position`).data,u=this._getLineSize(c),d=$,f=d*o.pixelRatio,p=new pe(4);for(let e of this._forEachTransformedLineSegment(L,R,l,n,I(this.parameters,c)))for(let[t,n]of s.processLineSegment(Ke,L,R)){if(!de(o,t,n,G,K))continue;let r=S(G,K,q),a=u/2+d;this.parameters.screenSizePerspective&&(_(Ie,G,K,.5),a=Math.max(a,this.computeScreenSizePerspectiveWidth(r,t,n,Ie,o,u,f)/o.pixelRatio)),o.renderToScreen(G,Le),o.renderToScreen(K,Re),fe(i,Le,Re,a)&&(T(S(t,n,Ve),o.eye,V),p.updateIfCloserFromValues(g(o.eye,V),e,V,null))}return p}intersectScreenPolygonDraped({attributes:e},t,n,r,i,a){if(!n.options.selectionMode)return null;let o=Ae(this._getLineSize(e,!0),i,a,this.parameters.usesWorldSizedWidth());for(let n of je(z,B,this.parameters,e,t))if(fe(r,z,B,o))return new me(n);return null}createBufferWriter(){return new ke(xe(this.parameters),Se(this.parameters),this.parameters,this._isAssumedMetalDriver)}createGLMaterial(e){return new De(e)}validateParameters(e){e.join!==`miter`&&(e.miterLimit=0),e.markerParameters!=null&&(e.markerScale=e.markerParameters.width/e.width)}update(e){return this.parameters.hasAnimation?(this.setParameters({timeElapsed:i(e.time)},!1),e.dt!==0):!1}computeScreenSizePerspectiveWidth(e,t,n,r,i,a,o){let s=E(e,r);_(V,t,n,s),v(Fe,V,i.viewMatrix);let c=h(Fe),l=this.computeCameraAbsCosAngle(V,i,this._configuration.spherical);return Pe.update(l,c,this.parameters.screenSizePerspective,this.parameters.screenSizePerspectiveMinPixelReferenceSize),Pe.apply(a)*i.pixelRatio/2+o}computeCameraAbsCosAngle(e,t,n){return n?y(W,e):l(W,0,0,1),u(H,e,t.eye),y(H,H),Math.abs(d(W,H))}_getLineSize(e,n=!1){let r=this.parameters.width;if(this.parameters.vvSize){let i=e.get(`sizeFeatureAttribute`).data[0];Number.isNaN(i)?n&&(r*=this.parameters.vvSize.fallback[0]):r*=t(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else e.has(`size`)&&(r*=e.get(`size`).data[0]);return r}*_forEachTransformedLineSegment(e,t,n,r,i){let a=i?n.length-2:n.length-5;for(let i=0;i<a;i+=3){e[0]=n[i]+r[12],e[1]=n[i+1]+r[13],e[2]=n[i+2]+r[14];let a=(i+3)%n.length;t[0]=n[a]+r[12],t[1]=n[a+1]+r[13],t[2]=n[a+2]+r[14],yield i/3}}}class De extends le{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){let{stipplePattern:t}=this._material.parameters;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(Ce,e)}}class Oe extends ve{constructor(){super(...arguments),this._width=0,this.color=x,this.join=`miter`,this.cap=0,this.miterLimit=5,this.shadingEnabled=!1,this.writeDepth=!0,this.polygonOffset=0,this.polygonOffsetIndex=0,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=a(0),this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=a(0),this.endTime=a(1/0),this.worldSized=!1}get width(){return this.isImagePattern()?this.stipplePattern.width:this._width}set width(e){this._width=e}get transparent(){return this.color[3]<1||this.hasAnimation||this.stipplePattern!=null&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return this.animation!==0}usesWorldSizedWidth(e=this.isImagePattern()){return this.worldSized||e}isImagePattern(){return _e(this.stipplePattern)&&this.stippleTexture!=null}}class ke{constructor(e,t,n,r){this.layout=e,this.textureBufferLayout=t,this._parameters=n,this._isAssumedMetalDriver=r,this.numJoinSubdivisions=Ne(this._parameters.join,this._parameters.stipplePattern!=null)}_isClosed(e){return I(this._parameters,e)}allocate(e){return this.layout.createBuffer(e)}elementCountTextureBuffer(e){return e.get(`position`).data.length/3+(this._isClosed(e)?3:2)}elementCount(e){let t=e.get(`position`).indices.length/2+1,n=this._isClosed(e),r=n?2:4,i=+!n,a=n?t:t-1,o=this.numJoinSubdivisions*2+(this._isAssumedMetalDriver?8:4);return r+=(a-i)*o,r+=2,this._parameters.wireframe&&(r=2+(r-2)*4),r}write(e,t,n,r,i,a){a!=null&&this._writeTextureBuffer(e,n,a),r!=null&&this._writeVertexBuffer(e,n,r,i)}_writeTextureBuffer(e,t,n){let r=t.get(`position`),i=r.data.length/3,a=this._isClosed(t),{buffer:o,offset:s}=n,c=o.getField(`position`,j),l=o.getField(`u0`,M),u=o.getField(`sizeFeatureAttribute`,M),d=o.getField(`size`,M),f=o.getField(`colorFeatureAttribute`,M),p=o.getField(`color`,N),h=o.getField(`olidColor`,N),_=o.getField(`timeStamps`,te),v=o.getField(`opacityFeatureAttribute`,M),y=t.get(`sizeFeatureAttribute`)?.data,b=t.get(`size`)?.data,x=t.get(`colorFeatureAttribute`)?.data,S=t.get(`color`)?.data,C=t.get(`opacityFeatureAttribute`)?.data,w=t.get(`distanceToStart`)?.data,T=t.get(`timeStamps`);P(c!==null,`Expected valid position field in texture buffer`),P(l!==null,`Expected valid u0 field in texture buffer`);let E=0;for(let t=0;t<i;++t){this._getTransformedPosition(Y,r.data,t,e),t>0&&(w==null?E+=g(J,Y):E=w[t]??E);let n=s+t+1;if(c.setVec(n,Y),l.set(n,E),m(J,Y),u&&u.set(n,y?.length===1?y[0]:y?.[t]??0),d&&d.set(n,b?.length===1?b[0]:b?.[t]??1),f&&f.set(n,x?.length===1?x[0]:x?.[t]??0),p){if(S!=null){let e=Math.min(t*4,S.length-4);p.setValues(n,S[e],S[e+1],S[e+2],S[e+3])}else p.setValues(n,1,1,1,1)}v&&v.set(n,C?.length===1?C[0]:C?.[t]??0)}if(_!=null&&T!=null){P(T.size===4);let e=T.data;for(let t=0;t<i;++t){let n=t*4,r=s+t+1;_.set(r,0,e[n]),_.set(r,1,e[n+1]),_.set(r,2,e[n+2]),_.set(r,3,e[n+3])}}if(a){let e=s,t=s+1,n=s+2,r=s+i,a=r+1,u=r+2;o.copyItem(r,e),o.copyItem(t,a),o.copyItem(n,u),c.getVec(r,J),c.getVec(t,Y);let d=w?.[i]??E+g(J,Y);l.set(a,d)}else{let e=s,t=s+1,n=s+i,r=n+1;o.copyItem(t,e),o.copyItem(n,r)}let D=t.get(`olidColor`);ce()&&D!=null&&h!=null&&ye(D,4,h,s)}_writeVertexBuffer(e,t,n,r){let{buffer:i,offset:a}=n,{layout:o}=this,s=t.get(`position`),c=s.indices,l=s.data.length/3,u=this._isClosed(t),d=l+(u?3:2);c&&c.length!==2*(l-1)&&console.warn(`RibbonLineMaterial does not support indices`);let f=i.getField(`textureElementIndex`,ne);P(f!=null,`Missing texture buffer index field`),P(r!=null,`Using a texture layout, but the texture range for this instance was not provided`);let p=r.from;P(r.numElements===d,`Expected number of elements in TextureBuffer to equal number of points`);let m=new Float32Array(i.buffer),h=new Float16Array(i.buffer),g=new Uint32Array(i.buffer),_=o.stride/4,v=a*_,y=v,b=m.BYTES_PER_ELEMENT/h.BYTES_PER_ELEMENT,x=(e,t,n,r=!1)=>{let i=n+1;g[v]=p+i,v++;let a=v*b;h[a++]=e,h[a++]=t+(r?Math.sign(t)*8:0),v=Math.ceil(a/b)};v+=_;let S=0,C=0;u?(S=0,C=l):(x(1,-4,0),x(1,4,0),S=1,C=l-1);let w=this._isAssumedMetalDriver;for(let e=S;e<C;e++){x(0,-1,e),x(0,1,e),w&&(x(0,-1,e,!0),x(0,1,e,!0));let t=this.numJoinSubdivisions;for(let n=0;n<t;++n){let r=(n+1)/(t+1);x(r,-1,e,w),x(r,1,e,w)}x(1,-2,e,w),x(1,2,e,w),w&&(x(1,-2,e),x(1,2,e))}u?(x(0,-1,C),x(0,1,C)):(x(0,-5,C),x(0,5,C)),F(m,y+_,m,y,_),v=F(m,v-_,m,v,_),this._parameters.wireframe&&this._addWireframeVertices(i,y,v,_)}_getTransformedPosition(e,t,n,r){let i=n*3;l(e,t[i+0],t[i+1],t[i+2]),r&&v(e,e,r)}_addWireframeVertices(e,t,n,r){let i=new Uint8Array(e.buffer,n*Float32Array.BYTES_PER_ELEMENT),a=new Uint8Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,(n-t)*Float32Array.BYTES_PER_ELEMENT),o=r*Float32Array.BYTES_PER_ELEMENT,s=0,c=e=>s=F(a,e,i,s,o);for(let e=0;e<=a.length-4*o;e+=o*2)c(e),c(e+2*o),c(e+1*o),c(e+2*o),c(e+1*o),c(e+3*o)}}function F(e,t,n,r,i){for(let a=0;a<i;a++)n[r++]=e[t++];return r}function I(e,t){return e.isClosed?t.get(`position`).indices.length>2:!1}function Ae(e,t,n,r){return r?e/(2*n)+$*t:(e/2+$)*t}function*je(e,t,n,r,i){let a=r.get(`position`).data,c=I(n,r)?a.length-2:a.length-5,l=i?.[0]??0,u=i?.[1]??0;s(e,a[0]+l,a[1]+u);for(let n=3;n<c+3;n+=3){let r=n%a.length;s(t,a[r]+l,a[r+1]+u),yield n/3,o(e,t)}}function Me(e){return e.anchor===1&&e.hideOnShortSegments&&e.placement===`begin-end`&&e.worldSpace}function Ne(e,t){let n=+!!t;switch(e){case`miter`:case`bevel`:return n;case`round`:return be+n}}const Pe=new he,L=b(),R=b(),z=c(),B=c(),V=b(),Fe=b(),H=b(),U=b(),W=b(),Ie=b(),G=n(),K=n(),Le=r(),Re=r(),ze=b(),Be=b(),q=D(),Ve=D(),J=b(),Y=b(),X=[n(),n(),n(),n()],Z=[b(),b(),b(),b()],He=A(),Ue=A(),We=A(),Q=A(),$=4,Ge={getDrapedRibbonLineMaxDistance:Ae},Ke=[b(),b()];export{Oe as Parameters,Ee as RibbonLineMaterial,Ge as test};
2
+ import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as n,createScreenPointArray as r}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as i,Seconds as a}from"../../../../core/time.js";import{copy as o,set as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as l,subtract as u,dot as d,scale as f,add as p,copy as m,length as h,distance as g,lerp as _,transformMat4 as v,normalize as y}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromPoints as S,distance2 as C,closestLineSegmentPoint as w,projectPoint as T,projectPointFraction as E,create as D}from"../../../../geometry/support/lineSegment.js";import{fromPoints as O,signedDistance as k,getNormal as ee,create as A}from"../../../../geometry/support/plane.js";import{BufferViewVec3f as te,BufferViewFloat as j,BufferViewVec4Unorm8 as ne,BufferViewVec4f16 as re,BufferViewUint32 as ie}from"../../../../geometry/support/buffer/BufferView.js";import{isHighlightOrOLID as ae,isColor as M,isDepth as oe,isColorHighlightOLIDOrDepth as se,is2DGeometryOutput as ce}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as le}from"../effects/geometry/olidUtils.js";import ue from"../lib/GLMaterial.js";import{LineMaterial as de}from"../lib/LineMaterial.js";import{projectWorldLineSegmentToRenderScreen as fe,screenPolygonIntersectsBufferedSegment as pe}from"../lib/screenPolygonOverlapUtils.js";import{Hit as me,DrapedHit as he}from"../lib/screenPolygonTriangleIntersections.js";import{ScreenSizePerspectiveEvaluator as ge}from"../lib/screenSizePerspectiveUtils.js";import{isTranslationMatrix as _e,assert as N}from"../lib/Util.js";import{isImagePattern as ve}from"./lineStippleUtils.js";import{VisualVariablePassParameters as ye}from"./VisualVariablePassParameters.js";import{writeColor as be}from"./internal/bufferWriterUtils.js";import{intersectRayWithWorldSizedLineSegment as xe}from"./internal/worldSizedRibbonLineIntersectionUtils.js";import{n as Se}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as Ce,getTextureBufferLayout as we}from"../shaders/RibbonLineLayouts.js";import{RibbonLineTechnique as Te}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as Ee}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as De}from"../../../../webscene/support/AlphaCutoff.js";class Oe extends de{constructor(e,t){super(e,Ae),this.produces=new Map([[2,e=>ae(e)||M(e)&&this.parameters.renderOccluded===8],[3,e=>oe(e)],[10,e=>se(e)&&this.parameters.renderOccluded===8],[11,e=>se(e)&&this.parameters.renderOccluded===8],[4,e=>M(e)&&this.parameters.writeDepth&&this.parameters.renderOccluded!==8],[8,e=>M(e)&&!this.parameters.writeDepth&&this.parameters.renderOccluded!==8],[18,e=>ce(e)]]),this._configuration=new Ee(t.state.isGlobal),this._isAssumedMetalDriver=t.stage.renderer.renderContext.rctx.isAssumedMetalDriver}updateConfiguration(e){super.updateConfiguration(e),this._configuration.useFlatJoinVarying=!this._isAssumedMetalDriver;let t=this.parameters.stipplePattern!=null&&this.parameters.stippleTexture!=null&&e.output!==10,n=t&&this.parameters.isImagePattern()&&this._configuration.draped,r=this.parameters.usesWorldSizedWidth(n);this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.stippleEnabled=t,this._configuration.stippleOffColorEnabled=t&&this.parameters.stippleOffColor!=null,this._configuration.stipplePreferContinuous=t&&this.parameters.stipplePreferContinuous,this._configuration.numJoinSubdivisions=Pe(this.parameters.join,t),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins=this.parameters.join===`round`,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=this.parameters.markerParameters!=null&&Ne(this.parameters.markerParameters),this._configuration.polygonOffsetIndex=this.parameters.polygonOffsetIndex,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&this.parameters.innerColor!=null,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=+!!this.emissions,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective&&!r,this._configuration.worldSized=r,this._configuration.imagePattern=n}get visible(){return this.parameters.color[3]>=De||this.parameters.stipplePattern!=null&&(this.parameters.stippleOffColor?.[3]??0)>De}get emissions(){return this.parameters.emissiveStrength>0?this.parameters.renderOccluded===8?1:2:0}setParameters(e,t){e.animation=this.parameters.animation,super.setParameters(e,t)}intersectRayDraped({attributes:e},n,r,i,a,o,s){if(!n.options.selectionMode)return;let c=this._getLineSize(e,!0),l=r[0],u=r[1],d=I(c,o,s,this.parameters.usesWorldSizedWidth()),f=Number.MAX_VALUE,p=0;for(let n of Me(z,B,this.parameters,e)){let e=l-z[0],r=u-z[1],i=B[0]-z[0],a=B[1]-z[1],o=i*e+a*r,s=i*i+a*a,c=t(o/s,0,1),d=i*c-e,m=a*c-r,h=d*d+m*m;h<f&&(f=h,p=n)}f<d*d&&i(a.distance,a.renderDistance,a.normal,p)}intersectRay(t,n,r,i,a,o){let{options:s,camera:c}=r;if(!s.selectionMode||!t.visible||!c)return;if(!_e(n)){e.getLogger(`esri.views.3d.webgl-engine.materials.RibbonLineMaterial`).error(`intersection assumes a translation-only matrix`);return}let l=this._getLineSize(t.attributes);this.parameters.worldSized?this._intersectRayWithWorldSizedLine(t,n,r,l,o):this._intersectRayWithScreenSizedLine(t,n,r,l,o)}_intersectRayWithScreenSizedLine(e,t,n,r,i){let{camera:a}=n,s=e.attributes,c=s.get(`position`).data,_=G;o(_,n.point);let v=r*a.pixelRatio,y=$*a.pixelRatio,b=v/2+y;l(Z[0],_[0]-b,_[1]+b,0),l(Z[1],_[0]+b,_[1]+b,0),l(Z[2],_[0]+b,_[1]-b,0),l(Z[3],_[0]-b,_[1]-b,0);for(let e=0;e<4;e++)if(!a.unprojectFromRenderScreen(Z[e],Q[e]))return;O(a.eye,Q[0],Q[1],Ue),O(a.eye,Q[1],Q[2],We),O(a.eye,Q[2],Q[3],Ge),O(a.eye,Q[3],Q[0],Ke);let x=Number.MAX_VALUE,T=0;for(let e of this._forEachTransformedLineSegment(L,R,c,t,F(this.parameters,s))){if(k(Ue,L)<0&&k(Ue,R)<0||k(We,L)<0&&k(We,R)<0||k(Ge,L)<0&&k(Ge,R)<0||k(Ke,L)<0&&k(Ke,R)<0)continue;let t=a.projectToRenderScreen(L,K),n=a.projectToRenderScreen(R,q);if(t==null||n==null)continue;if(t[2]<0&&n[2]>0){u(U,L,R);let e=a.frustum,n=-k(e[4],L)/d(U,ee(e[4]));if(f(U,U,n),p(L,L,U),!a.projectToRenderScreen(L,t))continue}else if(t[2]>0&&n[2]<0){u(U,R,L);let e=a.frustum,t=-k(e[4],R)/d(U,ee(e[4]));if(f(U,U,t),p(R,R,U),!a.projectToRenderScreen(R,n))continue}else if(t[2]<0&&n[2]<0)continue;t[2]=0,n[2]=0;let i=S(t,n,J),o=C(i,_);if(!(o>=x)){if(this.parameters.screenSizePerspective){let e=this.computeScreenSizePerspectiveWidth(i,L,R,_,a,r,y);if(o>=e*e)continue}x=o,m(ze,L),m(Be,R),T=e}}if(x<b*b){let{rayBegin:e,rayEnd:t}=n,r=Number.MAX_VALUE;if(w(S(ze,Be,J),S(e,t,He),W)){u(W,W,e);let n=h(W);f(W,W,1/n),r=n/g(e,t)}i(r,r,W,T)}}_intersectRayWithWorldSizedLine(e,t,n,r,i){let{camera:a,ray:o,metersPerRenderUnit:s}=n,c=e.attributes,l=c.get(`position`).data,u=r/(2*s),d=1/0,f=0;for(let e of this._forEachTransformedLineSegment(L,R,l,t,F(this.parameters,c))){let t=xe(L,R,u,a,o,Ve);if(t!=null&&t<d&&(d=t,f=e,m(W,Ve),t===0))break}d<1/0&&i(d,d,W,f)}intersectScreenPolygon(t,n,r,i){let{options:a,camera:o,screenPolygonPrimitiveProcessor:s}=r;if(!a.selectionMode||!t.visible)return null;if(!_e(n))return e.getLogger(`esri.views.3d.webgl-engine.materials.RibbonLineMaterial`).error(`intersection assumes a translation-only matrix`),null;let c=t.attributes,l=c.get(`position`).data,u=this._getLineSize(c),d=$,f=d*o.pixelRatio,p=new me(4);for(let e of this._forEachTransformedLineSegment(L,R,l,n,F(this.parameters,c)))for(let[t,n]of s.processLineSegment(Je,L,R)){if(!fe(o,t,n,K,q))continue;let r=S(K,q,J),a=u/2+d;this.parameters.screenSizePerspective&&(_(G,K,q,.5),a=Math.max(a,this.computeScreenSizePerspectiveWidth(r,t,n,G,o,u,f)/o.pixelRatio)),o.renderToScreen(K,Le),o.renderToScreen(q,Re),pe(i,Le,Re,a)&&(T(S(t,n,He),o.eye,V),p.updateIfCloserFromValues(g(o.eye,V),e,V,null))}return p}intersectScreenPolygonDraped({attributes:e},t,n,r,i,a){if(!n.options.selectionMode)return null;let o=I(this._getLineSize(e,!0),i,a,this.parameters.usesWorldSizedWidth());for(let n of Me(z,B,this.parameters,e,t))if(pe(r,z,B,o))return new he(n);return null}createBufferWriter(){return new je(Ce(this.parameters),we(this.parameters),this.parameters,this._isAssumedMetalDriver)}createGLMaterial(e){return new ke(e)}validateParameters(e){e.join!==`miter`&&(e.miterLimit=0),e.markerParameters!=null&&(e.markerScale=e.markerParameters.width/e.width)}update(e){return this.parameters.hasAnimation?(this.setParameters({timeElapsed:i(e.time)},!1),e.dt!==0):!1}computeScreenSizePerspectiveWidth(e,t,n,r,i,a,o){let s=E(e,r);_(V,t,n,s),v(Ie,V,i.viewMatrix);let c=h(Ie),l=this.computeCameraAbsCosAngle(V,i,this._configuration.spherical);return Fe.update(l,c,this.parameters.screenSizePerspective,this.parameters.screenSizePerspectiveMinPixelReferenceSize),Fe.apply(a)*i.pixelRatio/2+o}computeCameraAbsCosAngle(e,t,n){return n?y(W,e):l(W,0,0,1),u(H,e,t.eye),y(H,H),Math.abs(d(W,H))}_getLineSize(e,n=!1){let r=this.parameters.width;if(this.parameters.vvSize){let i=e.get(`sizeFeatureAttribute`).data[0];Number.isNaN(i)?n&&(r*=this.parameters.vvSize.fallback[0]):r*=t(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else e.has(`size`)&&(r*=e.get(`size`).data[0]);return r}*_forEachTransformedLineSegment(e,t,n,r,i){let a=i?n.length-2:n.length-5;for(let i=0;i<a;i+=3){e[0]=n[i]+r[12],e[1]=n[i+1]+r[13],e[2]=n[i+2]+r[14];let a=(i+3)%n.length;t[0]=n[a]+r[12],t[1]=n[a+1]+r[13],t[2]=n[a+2]+r[14],yield i/3}}}class ke extends ue{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(e){let{stipplePattern:t}=this._material.parameters;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.getTechnique(Te,e)}}class Ae extends ye{constructor(){super(...arguments),this._width=0,this.color=x,this.join=`miter`,this.cap=0,this.miterLimit=5,this.shadingEnabled=!1,this.writeDepth=!0,this.polygonOffset=0,this.polygonOffsetIndex=0,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=a(0),this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=a(0),this.endTime=a(1/0),this.worldSized=!1}get width(){return this.isImagePattern()?this.stipplePattern.width:this._width}set width(e){this._width=e}get transparent(){return this.color[3]<1||this.hasAnimation||this.stipplePattern!=null&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return this.animation!==0}usesWorldSizedWidth(e=this.isImagePattern()){return this.worldSized||e}isImagePattern(){return ve(this.stipplePattern)&&this.stippleTexture!=null}}class je{constructor(e,t,n,r){this.layout=e,this.textureBufferLayout=t,this._parameters=n,this._isAssumedMetalDriver=r,this.numJoinSubdivisions=Pe(this._parameters.join,this._parameters.stipplePattern!=null)}_isClosed(e){return F(this._parameters,e)}allocate(e){return this.layout.createBuffer(e)}elementCountTextureBuffer(e){return e.get(`position`).data.length/3+(this._isClosed(e)?3:2)}elementCount(e){let t=e.get(`position`).indices.length/2+1,n=this._isClosed(e),r=n?2:4,i=+!n,a=n?t:t-1,o=this.numJoinSubdivisions*2+(this._isAssumedMetalDriver?8:4);return r+=(a-i)*o,r+=2,this._parameters.wireframe&&(r=2+(r-2)*4),r}write(e,t,n,r,i,a){a!=null&&this._writeTextureBuffer(e,n,a),r!=null&&this._writeVertexBuffer(e,n,r,i)}_writeTextureBuffer(e,t,n){let r=t.get(`position`),i=r.data.length/3,a=this._isClosed(t),{buffer:o,offset:s}=n,c=o.getField(`position`,te),l=o.getField(`u0`,j),u=o.getField(`sizeFeatureAttribute`,j),d=o.getField(`size`,j),f=o.getField(`colorFeatureAttribute`,j),p=o.getField(`color`,ne),h=o.getField(`olidColor`,ne),_=o.getField(`timeStamps`,re),v=o.getField(`opacityFeatureAttribute`,j),y=t.get(`sizeFeatureAttribute`)?.data,b=t.get(`size`)?.data,x=t.get(`colorFeatureAttribute`)?.data,S=t.get(`color`)?.data,C=t.get(`opacityFeatureAttribute`)?.data,w=t.get(`distanceToStart`)?.data,T=t.get(`timeStamps`);N(c!==null,`Expected valid position field in texture buffer`),N(l!==null,`Expected valid u0 field in texture buffer`);let E=0;for(let t=0;t<i;++t){this._getTransformedPosition(X,r.data,t,e),t>0&&(w==null?E+=g(Y,X):E=w[t]??E);let n=s+t+1;if(c.setVec(n,X),l.set(n,E),m(Y,X),u&&u.set(n,y?.length===1?y[0]:y?.[t]??0),d&&d.set(n,b?.length===1?b[0]:b?.[t]??1),f&&f.set(n,x?.length===1?x[0]:x?.[t]??0),p){if(S!=null){let e=Math.min(t*4,S.length-4);p.setValues(n,S[e],S[e+1],S[e+2],S[e+3])}else p.setValues(n,1,1,1,1)}v&&v.set(n,C?.length===1?C[0]:C?.[t]??0)}if(_!=null&&T!=null){N(T.size===4);let e=T.data;for(let t=0;t<i;++t){let n=t*4,r=s+t+1;_.set(r,0,e[n]),_.set(r,1,e[n+1]),_.set(r,2,e[n+2]),_.set(r,3,e[n+3])}}if(a){let e=s,t=s+1,n=s+2,r=s+i,a=r+1,u=r+2;o.copyItem(r,e),o.copyItem(t,a),o.copyItem(n,u),c.getVec(r,Y),c.getVec(t,X);let d=w?.[i]??E+g(Y,X);l.set(a,d)}else{let e=s,t=s+1,n=s+i,r=n+1;o.copyItem(t,e),o.copyItem(n,r)}let D=t.get(`olidColor`);le()&&D!=null&&h!=null&&be(D,4,h,s)}_writeVertexBuffer(e,t,n,r){let{buffer:i,offset:a}=n,{layout:o}=this,s=t.get(`position`),c=s.indices,l=s.data.length/3,u=this._isClosed(t),d=l+(u?3:2);c&&c.length!==2*(l-1)&&console.warn(`RibbonLineMaterial does not support indices`);let f=i.getField(`textureElementIndex`,ie);N(f!=null,`Missing texture buffer index field`),N(r!=null,`Using a texture layout, but the texture range for this instance was not provided`);let p=r.from;N(r.numElements===d,`Expected number of elements in TextureBuffer to equal number of points`);let m=new Float32Array(i.buffer),h=new Float16Array(i.buffer),g=new Uint32Array(i.buffer),_=o.stride/4,v=a*_,y=v,b=m.BYTES_PER_ELEMENT/h.BYTES_PER_ELEMENT,x=(e,t,n,r=!1)=>{let i=n+1;g[v]=p+i,v++;let a=v*b;h[a++]=e,h[a++]=t+(r?Math.sign(t)*8:0),v=Math.ceil(a/b)};v+=_;let S=0,C=0;u?(S=0,C=l):(x(1,-4,0),x(1,4,0),S=1,C=l-1);let w=this._isAssumedMetalDriver;for(let e=S;e<C;e++){x(0,-1,e),x(0,1,e),w&&(x(0,-1,e,!0),x(0,1,e,!0));let t=this.numJoinSubdivisions;for(let n=0;n<t;++n){let r=(n+1)/(t+1);x(r,-1,e,w),x(r,1,e,w)}x(1,-2,e,w),x(1,2,e,w),w&&(x(1,-2,e),x(1,2,e))}u?(x(0,-1,C),x(0,1,C)):(x(0,-5,C),x(0,5,C)),P(m,y+_,m,y,_),v=P(m,v-_,m,v,_),this._parameters.wireframe&&this._addWireframeVertices(i,y,v,_)}_getTransformedPosition(e,t,n,r){let i=n*3;l(e,t[i+0],t[i+1],t[i+2]),r&&v(e,e,r)}_addWireframeVertices(e,t,n,r){let i=new Uint8Array(e.buffer,n*Float32Array.BYTES_PER_ELEMENT),a=new Uint8Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,(n-t)*Float32Array.BYTES_PER_ELEMENT),o=r*Float32Array.BYTES_PER_ELEMENT,s=0,c=e=>s=P(a,e,i,s,o);for(let e=0;e<=a.length-4*o;e+=o*2)c(e),c(e+2*o),c(e+1*o),c(e+2*o),c(e+1*o),c(e+3*o)}}function P(e,t,n,r,i){for(let a=0;a<i;a++)n[r++]=e[t++];return r}function F(e,t){return e.isClosed?t.get(`position`).indices.length>2:!1}function I(e,t,n,r){return r?e/(2*n)+$*t:(e/2+$)*t}function*Me(e,t,n,r,i){let a=r.get(`position`).data,c=F(n,r)?a.length-2:a.length-5,l=i?.[0]??0,u=i?.[1]??0;s(e,a[0]+l,a[1]+u);for(let n=3;n<c+3;n+=3){let r=n%a.length;s(t,a[r]+l,a[r+1]+u),yield n/3,o(e,t)}}function Ne(e){return e.anchor===1&&e.hideOnShortSegments&&e.placement===`begin-end`&&e.worldSpace}function Pe(e,t){let n=+!!t;switch(e){case`miter`:case`bevel`:return n;case`round`:return Se+n}}const Fe=new ge,L=b(),R=b(),z=c(),B=c(),V=b(),Ie=b(),H=b(),U=b(),W=b(),G=b(),K=n(),q=n(),Le=r(),Re=r(),ze=b(),Be=b(),Ve=b(),J=D(),He=D(),Y=b(),X=b(),Z=[n(),n(),n(),n()],Q=[b(),b(),b(),b()],Ue=A(),We=A(),Ge=A(),Ke=A(),$=4,qe={getDrapedRibbonLineMaxDistance:I},Je=[b(),b()];export{Ae as Parameters,Oe as RibbonLineMaterial,qe as test};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{fromMat4 as e,transpose as t}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{subtract as r,dot as i,scaleAndAdd as a,set as o,length as s,scale as c,transformMat4 as l,transformMat3 as u,cross as d,squaredLength as f,normalize as p}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as h,clipSlab as g,create as _,getStart as v}from"../../../../../geometry/support/clipRay.js";import{clipClosedNegativeHalfspace as y}from"../../../../../geometry/support/plane.js";import{wrap as b}from"../../../../../geometry/support/ray.js";import{Sphere as x}from"../../../../../geometry/support/sphere.js";function S(e,t,n,s,c,l){h(c,0,1/0,N);for(let r of[0,1,2])if(!g(r,Math.min(e[r],t[r])-n,Math.max(e[r],t[r])+n,N))return null;if(!y(s.frustum[4],N)||!y(s.frustum[5],N))return null;let u=w(e,t,s,D,O,l);if(u===0)return null;r(k,c.origin,e);let d=i(k,l),f=i(c.direction,l),p=T(c.direction,l);if(Math.abs(f)>p){let e=-d/f;return e<N.c0||e>N.c1?null:(a(k,k,c.direction,e),E(i(k,D),i(k,O),u,n*n)?e:null)}if(Math.abs(d)>T(k,l))return null;let m=i(k,D),_=i(k,O),v=i(c.direction,D),b=i(c.direction,O);return o(N.ray.origin,m,_,0),o(N.ray.direction,v,b,0),!g(0,-n,u+n,N)||!g(1,-n,n,N)?null:C(N,u,n)}function C(e,t,n){let r=v(e,k);if(E(r[0],r[1],t,n*n))return e.c0;o(P.center,r[0]<0?0:t,0,0),P.radius=n;let i=e.ray.direction;if(!P.intersectRay(b(r,i),F))return null;let a=Math.abs(i[0])>Math.abs(i[1])?0:1,s=e.c0+(F[a]-r[a])/i[a];return s<=e.c1?s:null}function w(n,i,a,m,h,g){r(m,i,n);let _=s(m);if(_===0)return 0;c(m,m,1/_);let v=a.viewMatrix;l(A,n,v),e(j,v),u(M,m,j);let y=a.projectionMatrix,b=y[11]*A[2]+y[15],x=y[11]*M[2],S=y[0]*(M[0]*b-A[0]*x),C=y[5]*(M[1]*b-A[1]*x),w=a.fullViewport,T=C*w[3]/(y[0]*w[2]),E=-S*w[2]/(y[5]*w[3]),D=Math.hypot(T,E);if(D===0)return 0;let O=T/D,k=E/D;return o(h,O,k,0),t(j,j),u(h,h,j),d(g,m,h),f(g)===0?0:(p(g,g),d(h,g,m),_)}function T(e,t){return 16*2**-52*(Math.abs(e[0]*t[0])+Math.abs(e[1]*t[1])+Math.abs(e[2]*t[2]))}function E(e,t,n,r){let i=e<0?e:e>n?e-n:0;return i*i+t*t<=r}const D=m(),O=m(),k=m(),A=m(),j=n(),M=m(),N=_(),P=new x,F=m();export{S as intersectRayWithWorldSizedLineSegment};
@@ -11,8 +11,8 @@ export interface LineOfSightLayerViewProperties extends LayerViewProperties, Par
11
11
  * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of a [LineOfSightLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/)
12
12
  * after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
13
13
  *
14
- * The line of sight layer view controls whether the [LineOfSightLayer.analysis](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/#analysis) in its associated
15
- * [LineOfSightLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/) can be created or edited interactively.
14
+ * The line of sight layer view controls whether the [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/) in its associated
15
+ * [LineOfSightLayer.analysis](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/#analysis) can be created or edited interactively.
16
16
  *
17
17
  * It allows to create an observer and/or targets interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/#place) method, query the [results](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/#results),
18
18
  * or make an existing analysis editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/#interactive) property.
@@ -10,7 +10,7 @@ export interface ViewshedLayerViewProperties extends LayerViewProperties, Partia
10
10
  * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of a [ViewshedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/)
11
11
  * after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/).
12
12
  *
13
- * The viewshed layer view controls whether the viewsheds in its associated
13
+ * The viewshed layer view controls whether the [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/) in its associated
14
14
  * [ViewshedLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/#source) can be created or edited interactively.
15
15
  *
16
16
  * It allows to create new viewsheds interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#place) method,
@@ -43,6 +43,7 @@ export interface ViewshedLayerViewProperties extends LayerViewProperties, Partia
43
43
  * @see [Viewshed](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/)
44
44
  * @see [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/)
45
45
  * @see [ViewshedAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/)
46
+ * @see [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/)
46
47
  * @see [Sample - ViewshedLayer in slides](https://developers.arcgis.com/javascript/latest/sample-code/layers-viewshed/)
47
48
  * @see [Async cancellation with AbortController](https://developers.arcgis.com/javascript/latest/async-cancellation-with-abortcontroller/)
48
49
  */
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{clamp as e}from"../../core/mathUtils.js";import{createEmptyImageData as t}from"../../core/imageUtils.js";const n=2048;function r(t,n){let{format:r,quality:i,rotation:a,disableDecorations:o}=t||{},s=b(t,n.padding),c=_(t,{width:n.width-s.left-s.right,height:n.height-s.top-s.bottom}),{width:l,height:u}=g(t,c),d=x(r),f=E[d];return{format:d,quality:e(i??f,0,100),area:c,width:l,height:u,rotation:a,disableDecorations:!!o,ignoreBackground:!!t?.ignoreBackground,ignorePadding:!!t?.ignorePadding}}function i(e,t){let n=r(e,t),i=n.area,a=n.width/i.width,o=b(n,t.padding),s=o.left+o.right,c=o.top+o.bottom,l=t.width-s,u=t.height-c,d=Math.floor(l*a+s),f=Math.floor(u*a+c),p=e?.layers??[],m=n.ignoreBackground,h=n.ignorePadding;return{framebufferWidth:d,framebufferHeight:f,region:{x:Math.floor(i.x*a)+o.left,y:Math.floor(i.y*a)+o.top,width:n.width,height:n.height},format:n.format,quality:n.quality,rotation:n.rotation,pixelRatio:a,layers:p,disableDecorations:n.disableDecorations,ignoreBackground:m,ignorePadding:h,olidColor:!1}}function a(e,t,n){let{ctx:r,canvas:i}=s(e,n),a=r.getImageData(0,0,e.width,e.height),o=d(i,t);return c(i),{dataUrl:o,data:a}}function o(e,t){let{ctx:n,canvas:r}=s(e,t),i=n.getImageData(0,0,e.width,e.height);return c(r),i}function s(e,t){let n=l();t.premultipliedAlpha&&C(e),n.width=e.width,n.height=e.height;let r=n.getContext(`2d`,{willReadFrequently:!0});return r.putImageData(e,0,0),t.flipY&&S(r),{ctx:r,canvas:n}}function c(e){e.width=0,e.height=0}function l(){return u??=document.createElement(`canvas`),u}let u=null;function d(e,t){let n=w[t.format],r=t.quality/100;return e.toDataURL(n,r)}function f(t,n){let r=x(t),i=E[r];return{format:r,quality:e(n??i,0,100)}}function p(e,t){return t/Math.max(e[0],e[1])}function m(e,t,n,r=0,i=0,a=e.width-r,o=e.height-i,s=!1){let{data:c}=e,{width:l,height:u,data:d}=t,f=a/l,p=o/u,m=Math.ceil(f/2),h=Math.ceil(p/2),g=e.width;for(let e=0;e<u;e++)for(let t=0;t<l;t++){let a=(t+(s?u-e-1:e)*l)*4,o=0,_=0,v=0,y=0,b=0,x=0,S=(e+.5)*p;for(let a=Math.floor(e*p);a<(e+1)*p;a++){let e=Math.abs(S-(a+.5))/h,s=(t+.5)*f,l=e*e;for(let e=Math.floor(t*f);e<(t+1)*f;e++){let t=Math.abs(s-(e+.5))/m,u=Math.sqrt(l+t*t);if(u>=1)continue;let d=2*u*u*u-3*u*u+1,f=4*(r+e+(i+a)*g);x+=d*c[f+3],_+=d,!n&&c[f+3]<255&&(d=d*c[f+3]/255),v+=d*c[f],y+=d*c[f+1],b+=d*c[f+2],o+=d}}d[a]=v/o,d[a+1]=y/o,d[a+2]=b/o,d[a+3]=x/_}return t}function h(e,t,r){if(!t)return e;let{framebufferWidth:i,framebufferHeight:a,pixelRatio:o,region:s}=e,c=b(e,r),l=c.left+c.right,u=c.top+c.bottom,d=i-l,f=a-u,p=Math.min(8,Math.min((n-l)/d,(n-u)/f));return p<1.5?e:{...e,framebufferWidth:Math.round(d*p)+l,framebufferHeight:Math.round(f*p)+u,pixelRatio:o*p,resample:{region:{x:Math.round((s.x-c.left)*p)+c.left,y:Math.round((s.y-c.top)*p)+c.top,width:Math.round(s.width*p),height:Math.round(s.height*p)},width:i,height:a}}}function g(e,t){if(!e)return t;let n=e.width,r=e.height;if(n!=null&&r!=null)return{width:Math.floor(n),height:Math.floor(r)};if(n==null&&r==null)return t;let i=t.width/t.height;return r==null?{width:Math.floor(n),height:Math.floor(n/i)}:{width:Math.floor(r*i),height:Math.floor(r)}}function _(e,t){let n={x:0,y:0,width:t.width,height:t.height};if(e?.area){e.area.x!=null&&(n.x=Math.floor(e.area.x)),e.area.y!=null&&(n.y=Math.floor(e.area.y));let r=e.area.width==null?null:Math.floor(e.area.width),i=e.area.height==null?null:Math.floor(e.area.height);if(n.width=t.width-n.x,n.height=t.height-n.y,r!=null&&i!=null)n.width=Math.min(n.width,r),n.height=Math.min(n.height,i);else if(r==null&&i!=null){let e=Math.min(n.width,r);n.height=e/n.width*n.height,n.width=e}else if(r!=null&&i==null){let e=Math.min(n.height,i);n.width=e/n.height*n.width,n.height=e}}return v(y(n,e),t)}function v(e,t){let n=Math.floor(Math.max(e.x,0)),r=Math.floor(Math.max(e.y,0)),i={x:n,y:r,width:Math.floor(Math.min(e.width,t.width-n)),height:Math.floor(Math.min(e.height,t.height-r))},a=i.width/i.height,o=e.width/e.height;if(o===a)return i;if(o>a){let e=Math.floor(i.width/o),t=i.height-e;return{x:i.x,y:Math.floor(i.y+t/2),width:i.width,height:e}}let s=Math.floor(i.height*o),c=i.width-s;return{x:Math.floor(i.x+c/2),y:i.y,width:s,height:i.height}}function y(e,t){if(t?.width==null||t.height==null)return e;let n=t.width/t.height,r=e.width/e.height;if(r===n)return e;if(r<n){let t=Math.floor(e.height*n);return e.x-=(t-e.width)/2,e.width=t,e}let i=Math.floor(e.width/n);return e.y-=(i-e.height)/2,e.height=i,e}function b(e,t){return!t||e?.ignorePadding?D:t}function x(e){switch(e){case`png`:case`jpg`:case`jpeg`:return e;case null:case void 0:return T;default:return T}}function S(e){e.save(),e.globalCompositeOperation=`copy`,e.scale(1,-1),e.translate(0,-e.canvas.height),e.drawImage(e.canvas,0,0),e.restore()}function C(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+3];if(n!==255&&n>0){let r=255/n;t[e]=t[e]*r,t[e+1]=t[e+1]*r,t[e+2]=t[e+2]*r}}}const w={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`},T=`png`,E={png:100,jpg:98,jpeg:98},D={top:0,right:0,bottom:0,left:0};export{r as completeUserSettings,t as createEmptyImageData,a as encode,o as encodeData,f as getFormatAndQuality,p as getMaximumResolutionScale,m as resampleHermite,h as screenshotSuperSampleSettings,d as toDataUrl,i as toRenderSettings};
2
+ import{clamp as e}from"../../core/mathUtils.js";import{createEmptyImageData as t}from"../../core/imageUtils.js";const n=2048;function r(t,n){let{format:r,quality:i,rotation:a,disableDecorations:o}=t||{},s=b(t,n.padding),c=_(t,{width:n.width-s.left-s.right,height:n.height-s.top-s.bottom}),{width:l,height:u}=g(t,c),d=x(r),f=E[d];return{format:d,quality:e(i??f,0,100),area:c,width:l,height:u,rotation:a,disableDecorations:!!o,ignoreBackground:!!t?.ignoreBackground,ignorePadding:!!t?.ignorePadding}}function i(e,t){let n=r(e,t),i=n.area,a=n.width/i.width,o=b(n,t.padding),s=o.left+o.right,c=o.top+o.bottom,l=t.width-s,u=t.height-c,d=Math.floor(l*a+s),f=Math.floor(u*a+c);(d<=0||f<=0)&&(d=i.width,f=i.height);let p=e?.layers??[],m=n.ignoreBackground,h=n.ignorePadding;return{framebufferWidth:d,framebufferHeight:f,region:{x:Math.floor(i.x*a)+o.left,y:Math.floor(i.y*a)+o.top,width:n.width,height:n.height},format:n.format,quality:n.quality,rotation:n.rotation,pixelRatio:a,layers:p,disableDecorations:n.disableDecorations,ignoreBackground:m,ignorePadding:h,olidColor:!1}}function a(e,t,n){let{ctx:r,canvas:i}=s(e,n),a=r.getImageData(0,0,e.width,e.height),o=d(i,t);return c(i),{dataUrl:o,data:a}}function o(e,t){let{ctx:n,canvas:r}=s(e,t),i=n.getImageData(0,0,e.width,e.height);return c(r),i}function s(e,t){let n=l();t.premultipliedAlpha&&C(e),n.width=e.width,n.height=e.height;let r=n.getContext(`2d`,{willReadFrequently:!0});return r.putImageData(e,0,0),t.flipY&&S(r),{ctx:r,canvas:n}}function c(e){e.width=0,e.height=0}function l(){return u??=document.createElement(`canvas`),u}let u=null;function d(e,t){let n=w[t.format],r=t.quality/100;return e.toDataURL(n,r)}function f(t,n){let r=x(t),i=E[r];return{format:r,quality:e(n??i,0,100)}}function p(e,t){return t/Math.max(e[0],e[1])}function m(e,t,n,r=0,i=0,a=e.width-r,o=e.height-i,s=!1){let{data:c}=e,{width:l,height:u,data:d}=t,f=a/l,p=o/u,m=Math.ceil(f/2),h=Math.ceil(p/2),g=e.width;for(let e=0;e<u;e++)for(let t=0;t<l;t++){let a=(t+(s?u-e-1:e)*l)*4,o=0,_=0,v=0,y=0,b=0,x=0,S=(e+.5)*p;for(let a=Math.floor(e*p);a<(e+1)*p;a++){let e=Math.abs(S-(a+.5))/h,s=(t+.5)*f,l=e*e;for(let e=Math.floor(t*f);e<(t+1)*f;e++){let t=Math.abs(s-(e+.5))/m,u=Math.sqrt(l+t*t);if(u>=1)continue;let d=2*u*u*u-3*u*u+1,f=4*(r+e+(i+a)*g);x+=d*c[f+3],_+=d,!n&&c[f+3]<255&&(d=d*c[f+3]/255),v+=d*c[f],y+=d*c[f+1],b+=d*c[f+2],o+=d}}d[a]=v/o,d[a+1]=y/o,d[a+2]=b/o,d[a+3]=x/_}return t}function h(e,t,r){if(!t)return e;let{framebufferWidth:i,framebufferHeight:a,pixelRatio:o,region:s}=e,c=b(e,r),l=c.left+c.right,u=c.top+c.bottom,d=i-l,f=a-u,p=Math.min(8,Math.min((n-l)/d,(n-u)/f));return p<1.5?e:{...e,framebufferWidth:Math.round(d*p)+l,framebufferHeight:Math.round(f*p)+u,pixelRatio:o*p,resample:{region:{x:Math.round((s.x-c.left)*p)+c.left,y:Math.round((s.y-c.top)*p)+c.top,width:Math.round(s.width*p),height:Math.round(s.height*p)},width:i,height:a}}}function g(e,t){if(!e)return t;let n=e.width,r=e.height;if(n!=null&&r!=null)return{width:Math.floor(n),height:Math.floor(r)};if(n==null&&r==null)return t;let i=t.width/t.height;return r==null?{width:Math.floor(n),height:Math.floor(n/i)}:{width:Math.floor(r*i),height:Math.floor(r)}}function _(e,t){let n={x:0,y:0,width:t.width,height:t.height};if(e?.area){e.area.x!=null&&(n.x=Math.floor(e.area.x)),e.area.y!=null&&(n.y=Math.floor(e.area.y));let r=e.area.width==null?null:Math.floor(e.area.width),i=e.area.height==null?null:Math.floor(e.area.height);if(n.width=t.width-n.x,n.height=t.height-n.y,r!=null&&i!=null)n.width=Math.min(n.width,r),n.height=Math.min(n.height,i);else if(r==null&&i!=null){let e=Math.min(n.width,r);n.height=e/n.width*n.height,n.width=e}else if(r!=null&&i==null){let e=Math.min(n.height,i);n.width=e/n.height*n.width,n.height=e}}return v(y(n,e),t)}function v(e,t){let n=Math.floor(Math.max(e.x,0)),r=Math.floor(Math.max(e.y,0)),i={x:n,y:r,width:t.width>0?Math.floor(Math.min(e.width,t.width-n)):e.width,height:t.height>0?Math.floor(Math.min(e.height,t.height-r)):e.height},a=i.width/i.height,o=e.width/e.height;if(o===a)return i;if(o>a){let e=Math.floor(i.width/o),t=i.height-e;return{x:i.x,y:Math.floor(i.y+t/2),width:i.width,height:e}}let s=Math.floor(i.height*o),c=i.width-s;return{x:Math.floor(i.x+c/2),y:i.y,width:s,height:i.height}}function y(e,t){if(t?.width==null||t.height==null)return e;let n=t.width/t.height,r=e.width>0&&e.height>0?e.width/e.height:0;if(r===0)return e.x=0,e.y=0,e.width=Math.floor(t.width),e.height=Math.floor(t.height),e;if(r===n)return e;if(r<n){let t=Math.floor(e.height*n);return e.x-=(t-e.width)/2,e.width=t,e}let i=Math.floor(e.width/n);return e.y-=(i-e.height)/2,e.height=i,e}function b(e,t){return!t||e?.ignorePadding?D:t}function x(e){switch(e){case`png`:case`jpg`:case`jpeg`:return e;case null:case void 0:return T;default:return T}}function S(e){e.save(),e.globalCompositeOperation=`copy`,e.scale(1,-1),e.translate(0,-e.canvas.height),e.drawImage(e.canvas,0,0),e.restore()}function C(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+3];if(n!==255&&n>0){let r=255/n;t[e]=t[e]*r,t[e+1]=t[e+1]*r,t[e+2]=t[e+2]*r}}}const w={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`},T=`png`,E={png:100,jpg:98,jpeg:98},D={top:0,right:0,bottom:0,left:0};export{r as completeUserSettings,t as createEmptyImageData,a as encode,o as encodeData,f as getFormatAndQuality,p as getMaximumResolutionScale,m as resampleHermite,h as screenshotSuperSampleSettings,d as toDataUrl,i as toRenderSettings};
@@ -186,8 +186,7 @@ export default class Slide extends SlideSuperclass {
186
186
  * @param options - Creation options. See properties below for object specifications.
187
187
  * @returns When resolved, returns the created slide.
188
188
  * @example
189
- * // Creates a slide from the view and
190
- * // adds it to the webscene
189
+ * // Creates a slide from the view and adds it to the webscene
191
190
  * Slide.createFrom(view).then(function(slide){
192
191
  * webscene.presentation.slides.add(slide);
193
192
  * });
@@ -1,6 +1,9 @@
1
1
  import type Accessor from "../../core/Accessor.js";
2
2
 
3
- /** @since 5.0 */
3
+ /**
4
+ * @deprecated since 5.2. Use the `hideDirectionalButtons`, `showRotationResetButton`, and `showRotationSlider` properties on the [Directional Pad component](/references/map-components/components/arcgis-directional-pad/) instead.
5
+ * @since 5.0
6
+ */
4
7
  export interface VisibleElementsProperties extends Partial<Pick<VisibleElements, "directionalButtons" | "rotationResetButton" | "rotationSlider">> {}
5
8
 
6
9
  /**
@@ -8,6 +11,7 @@ export interface VisibleElementsProperties extends Partial<Pick<VisibleElements,
8
11
  * This provides the ability to turn individual elements of the widget's display on/off.
9
12
  * Alternatively, developers may also use CSS (e.g. `display: none`) to show/hide elements, such as labels.
10
13
  *
14
+ * @deprecated since 5.2. Use the `hideDirectionalButtons`, `showRotationResetButton`, and `showRotationSlider` properties on the [Directional Pad component](/references/map-components/components/arcgis-directional-pad/) instead.
11
15
  * @since 5.0
12
16
  */
13
17
  export default class VisibleElements extends Accessor {
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{createTask as r}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,initial as s,when as c}from"../../../core/reactiveUtils.js";import{throttle as l}from"../../../core/throttle.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import f from"../../../geometry/Point.js";import{MediaContent as p,TextContent as m,FieldsContent as h}from"../../../popup/content.js";import g from"../../../popup/ElementExpressionInfo.js";import{compileExpression as _}from"../../../popup/support/arcadeFeatureUtils.js";import v from"../FeatureContent/FeatureContentViewModel.js";import y from"../FeatureFields/FeatureFieldsViewModel.js";import b from"../FeatureMedia/FeatureMediaViewModel.js";let x=class extends n{constructor(e){super(e),this._compileTask=null,this._evaluateTask=null,this.expressionInfo=null,this.graphic=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._createVM=()=>{let e=this.contentElement?.type;this.contentElementViewModel?.destroy();let t=e===`fields`?new y:e===`media`?new b:e===`text`?new v:null;this._set(`contentElementViewModel`,t)},this._compileThrottled=l(this._startCompile,()=>this.notifyChange(`state`),1,this),this._evaluateThrottled=l(this._startEvaluate,()=>this.notifyChange(`state`),1,this),this.addHandles([o(()=>[this.expressionInfo,this.graphic],()=>this._compileThrottled(),s),o(()=>[this.contentElement],()=>this._createVM(),s),c(()=>{if(!this._compileTask?.finished)return null;let e=this._compileTask.value,t=e?.dependencies;return[e,this.spatialReference,this.map,this.view,t?.has(`view-scale`)?this.view?.scale:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.start:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.end:null]},([e])=>this._evaluateThrottled(e))])}initialize(){this.addHandles([this._compileThrottled,this._evaluateThrottled])}destroy(){this._compileTask=i(this._compileTask),this._evaluateTask=i(this._evaluateTask),this.contentElementViewModel?.destroy(),this._set(`contentElementViewModel`,null)}get contentElement(){return this._evaluateTask?.value}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){let{contentElement:e,contentElementViewModel:t}=this;return this._compileThrottled.hasPendingUpdates()||this._evaluateThrottled.hasPendingUpdates()||!this._compileTask?.finished||!this._evaluateTask?.finished?`loading`:!e&&!t?`disabled`:`ready`}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}_startCompile(){this._evaluateTask=i(this._evaluateTask),this._compileTask=i(this._compileTask),this._compileTask=r(async e=>{let{expressionInfo:t,graphic:n}=this,r=t?.expression;if(!r||!n)return null;let i=await _({expression:r,graphic:n});return a(e),i})}_startEvaluate(e){this._evaluateTask=i(this._evaluateTask),this._evaluateTask=r(async t=>{let{graphic:n}=this;if(!e||!n)return null;let{interceptor:r,spatialReference:i,map:o,location:s,view:c}=this,l=await e.evaluate({graphic:n,interceptor:r,location:s,map:o,options:{signal:t},spatialReference:i,view:c});a(t);let u=l;if(!u||u.declaredClass!==`esri.arcade.Dictionary`)return null;let d=await u.castAsJsonAsync(t);a(t);let f=d?.type,g=f===`media`?p.fromJSON(d):f===`text`?m.fromJSON(d):f===`fields`?h.fromJSON(d):null;return g.type===`media`&&!g.mediaInfos||g.type===`fields`&&!g.fieldInfos||g.type===`text`&&!g.text?null:g})}};e([u()],x.prototype,`_compileTask`,void 0),e([u()],x.prototype,`_evaluateTask`,void 0),e([u({type:g})],x.prototype,`expressionInfo`,void 0),e([u({type:t})],x.prototype,`graphic`,void 0),e([u({readOnly:!0})],x.prototype,`contentElement`,null),e([u({readOnly:!0})],x.prototype,`contentElementViewModel`,void 0),e([u()],x.prototype,`interceptor`,void 0),e([u({type:f})],x.prototype,`location`,void 0),e([u()],x.prototype,`spatialReference`,null),e([u({readOnly:!0})],x.prototype,`state`,null),e([u()],x.prototype,`map`,null),e([u()],x.prototype,`view`,void 0),x=e([d(`esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel`)],x);export{x as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Accessor.js";import{createTask as r}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as o,initial as s,when as c}from"../../../core/reactiveUtils.js";import{throttle as l}from"../../../core/throttle.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import f from"../../../geometry/Point.js";import p from"../../../popup/ElementExpressionInfo.js";import m from"../../../popup/content/FieldsContent.js";import h from"../../../popup/content/MediaContent.js";import g from"../../../popup/content/TextContent.js";import{compileExpression as _}from"../../../popup/support/arcadeFeatureUtils.js";import v from"../FeatureContent/FeatureContentViewModel.js";import y from"../FeatureFields/FeatureFieldsViewModel.js";import b from"../FeatureMedia/FeatureMediaViewModel.js";let x=class extends n{constructor(e){super(e),this._compileTask=null,this._evaluateTask=null,this.expressionInfo=null,this.graphic=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._createVM=()=>{let e=this.contentElement?.type;this.contentElementViewModel?.destroy();let t=e===`fields`?new y:e===`media`?new b:e===`text`?new v:null;this._set(`contentElementViewModel`,t)},this._compileThrottled=l(this._startCompile,()=>this.notifyChange(`state`),1,this),this._evaluateThrottled=l(this._startEvaluate,()=>this.notifyChange(`state`),1,this),this.addHandles([o(()=>[this.expressionInfo,this.graphic],()=>this._compileThrottled(),s),o(()=>[this.contentElement],()=>this._createVM(),s),c(()=>{if(!this._compileTask?.finished)return null;let e=this._compileTask.value,t=e?.dependencies;return[e,this.spatialReference,this.map,this.view,t?.has(`view-scale`)?this.view?.scale:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.start:null,t?.has(`view-time-extent`)?this.view?.timeExtent?.end:null]},([e])=>this._evaluateThrottled(e))])}initialize(){this.addHandles([this._compileThrottled,this._evaluateThrottled])}destroy(){this._compileTask=i(this._compileTask),this._evaluateTask=i(this._evaluateTask),this.contentElementViewModel?.destroy(),this._set(`contentElementViewModel`,null)}get contentElement(){return this._evaluateTask?.value}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override(`spatialReference`,e)}get state(){let{contentElement:e,contentElementViewModel:t}=this;return this._compileThrottled.hasPendingUpdates()||this._evaluateThrottled.hasPendingUpdates()||!this._compileTask?.finished||!this._evaluateTask?.finished?`loading`:!e&&!t?`disabled`:`ready`}get map(){return this.view?.map??null}set map(e){this._override(`map`,e)}_startCompile(){this._evaluateTask=i(this._evaluateTask),this._compileTask=i(this._compileTask),this._compileTask=r(async e=>{let{expressionInfo:t,graphic:n}=this,r=t?.expression;if(!r||!n)return null;let i=await _({expression:r,graphic:n});return a(e),i})}_startEvaluate(e){this._evaluateTask=i(this._evaluateTask),this._evaluateTask=r(async t=>{let{graphic:n}=this;if(!e||!n)return null;let{interceptor:r,spatialReference:i,map:o,location:s,view:c}=this,l=await e.evaluate({graphic:n,interceptor:r,location:s,map:o,options:{signal:t},spatialReference:i,view:c});a(t);let u=l;if(!u||u.declaredClass!==`esri.arcade.Dictionary`)return null;let d=await u.castAsJsonAsync(t);a(t);let f=d?.type,p=f===`media`?h.fromJSON(d):f===`text`?g.fromJSON(d):f===`fields`?m.fromJSON(d):null;return p.type===`media`&&!p.mediaInfos||p.type===`fields`&&!p.fieldInfos||p.type===`text`&&!p.text?null:p})}};e([u()],x.prototype,`_compileTask`,void 0),e([u()],x.prototype,`_evaluateTask`,void 0),e([u({type:p})],x.prototype,`expressionInfo`,void 0),e([u({type:t})],x.prototype,`graphic`,void 0),e([u({readOnly:!0})],x.prototype,`contentElement`,null),e([u({readOnly:!0})],x.prototype,`contentElementViewModel`,void 0),e([u()],x.prototype,`interceptor`,void 0),e([u({type:f})],x.prototype,`location`,void 0),e([u()],x.prototype,`spatialReference`,null),e([u({readOnly:!0})],x.prototype,`state`,null),e([u()],x.prototype,`map`,null),e([u()],x.prototype,`view`,void 0),x=e([d(`esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel`)],x);export{x as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{watch as s,initial as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{Milliseconds as u}from"../../core/time.js";import{isBlobProtocol as d}from"../../core/urlUtils.js";import{property as f,subclass as p}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Polygon.js";import h from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as _}from"../../webmap/utils.js";import{GoTo as v}from"../support/GoTo.js";function y(e){return e.declaredClass===`esri.WebScene`}let b=class extends v(t){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType=`site`,this.filterMode=`base-floors`,this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([s(()=>this.view?.map,e=>{this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{await this._updateFloorFilterFromMap(e),o(t),this._setInitialViewState(e)}),this._watchMapLayers(e)},c),s(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},l),s(()=>this.mediaLayer,e=>{this._watchLayerVisibility(e)},l),s(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),s(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e}),s(()=>this.facility,()=>void this.getOverlays()),s(()=>this.level,e=>this._updateMediaLayer(e))])}destroy(){if(this._unregisterWidget(this.view),this.mediaLayer&&this.view?.map.remove(this.mediaLayer),this.overlaysByLevel){for(let e of this.overlaysByLevel.values()){let t=e.image.image;d(t)&&URL.revokeObjectURL(t)}this.overlaysByFacility?.clear(),this.overlaysByLevel.clear()}this.view=null,this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride(`enabled`,e)}set facility(e){if(e&&this._isOverridden(`facility`)){let t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride(`facility`,e)}set filterFeatures(e){this._callOverride(`filterFeatures`,e)}set filterLayers(e){this._callOverride(`filterLayers`,e)}get floorVisibilityMode(){return this.view&&y(this.view?.map)?this.view.map.widgets?.floorFilter?.floorVisibilityMode??`belowSelected`:`belowSelected`}get hasFacilities(){return this.filterLayers?.facilityLayer!=null&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return this.filterLayers?.levelLayer!=null&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return this.filterLayers?.siteLayer!=null&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0,t=this._viewWidthBreakpoint;return(this._viewHeightBreakpoint===`xsmall`||t===`xsmall`)&&(e=!1),e}set level(e){if(!e){this._callOverride(`level`,e),this.facility=null,this.site=null,this.setFloors(null);return}let t=null,n=null,r=e?.split(`--`);r?.length>1&&r[0]===`all`?(n=r[1],t={id:e,facilityId:n,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),n=t?.facilityId??null),this.level===e&&!this.isNormalMode&&!this.levelsExpanded?this.getFacilityLevels(n)?.length>1&&(this.levelsExpanded=!0):(t&&this.hasFacilities&&this.hasLevels?(this.facility=n,this.hasMultipleSites&&(this.site=this.getFacility(n)?.siteId||null),this.setFloors(t)):this._isOverridden(`level`)&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType=`site`),this.setFloors(null)),this._callOverride(`level`,e))}set longNames(e){this._callOverride(`longNames`,e)}set minimized(e){this._callOverride(`minimized`,e)}set pinnedLevels(e){this._callOverride(`pinnedLevels`,e)}get selectedVerticalOrder(){return _(this.view?.map)?this.view.map.resourceInfo?.widgets?.floorFilter?.selectedVerticalOrder??null:null}set site(e){this._callOverride(`site`,e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?`ready`:this.view&&!this.filterFeatures?`loading`:`disabled`}get useVerticalOrder(){return this.view?.map==null?!1:_(this.view?.map)||y(this.view.map)?this.view.map.widgets?.floorFilter?.useVerticalOrder??!1:!1}filterFacilities(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site)),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}filterSites(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}getBaseLevel(e){let t=this.filterFeatures?.levels?.levelsInfo,n=null;if(e){let{id:r}=e;if(t&&t.length>0&&(t.forEach(e=>{e.verticalOrder===0&&e.facilityId===r&&(n=e)}),!n)){let e=null;t.forEach(t=>{t.facilityId===r&&(e?(t.verticalOrder??0)>=0?e.verticalOrder!=null&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):e.verticalOrder!=null&&t.verticalOrder!=null&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(n=e)}}return n}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){return!e||!this.filterFeatures?.levels?.levelsInfo?[]:this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{let n=e.verticalOrder??0,r=t.verticalOrder??0;return n>r?-1:n===r?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}async getOverlays(e=!1){let{facility:t,level:n,mediaLayer:i,overlaysByFacility:a,overlaysByLevel:o,view:s}=this;if(_(s?.map)&&i){if((i?.source).elements.removeAll(),t?.length&&(!a?.has(t)||e)){a?.set(t,new r);let e=s.map.floorInfo?.levelLayer?.layerId,n=s.map.findLayerById(e??``);if(!n||s.type!==`2d`)return;let i=await this._getAttachments(n,t),{default:c}=await import(`../../request.js`),l=Object.keys(i).map(async e=>{let r=i[e],s=r.find(e=>e.contentType===`application/json`);if(!s?.url)return;let l=new URL(s.url);n.gdbVersion?.length&&l.searchParams.set(`gdbVersion`,n.gdbVersion);let{data:u}=await c(l.toString(),{responseType:`json`}),d=r.find(e=>e.name===u.name),f=d?.url??``;if(f?.length>0){let e=new URL(f);e.searchParams.delete(`token`),n.gdbVersion?.length&&e.searchParams.set(`gdbVersion`,n.gdbVersion);let{default:r}=await import(`../../layers/support/ControlPointsGeoreference.js`),i=r.fromJSON(u.georeference),c=await this.toImageElement(e.toString(),i,u.opacity,u.clipImage,u.geometry);await c.load();let l={...u,attachments:[s,d],facilityId:t,image:c,source:JSON.stringify(u),url:e.toString()};o?.set(l.levelId,l),a?.get(t)?.push(l)}});await Promise.all(l)}this._updateMediaLayer(n)}}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}async goTo(e){let{view:t}=this;if(!t||!e)return;let{geometry:n}=e;if(n?.extent){let e=e=>{this.callGoTo({target:e,options:{duration:u(1e3),easing:`quad-in-out-coast`}})};if(n.hasZ&&n.spatialReference?.vcsWkid!==t.spatialReference?.vcsWkid){let{projectIsLoaded:r,projectLoad:i,projectExecute:a}=await import(`../../geometry/operators/projectOperator.js`);r()||await i();let o=a(n.extent,t.spatialReference.clone(),{zConversionDisabled:!0});o&&e(o)}else e(n.extent)}}setFloors(e){let{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{e.type===`feature`&&this._computeViewAllModeFloors(e)}),t.floors=new r(this._computeFloors(e)))}async toImageElement(e,t,n,r,i){let{default:o}=await import(`../../layers/support/ImageElement.js`),{facility:s}=this,c=()=>new o({image:e,georeference:t,opacity:n});if(r)try{let r=i?m.fromJSON(i):this.getFacility(s)?.geometry;if(r==null)return c();let{pixelRings:a,width:l,height:u}=await this._polygonToImagePixels(t,r),d=await this._imagePolygonToBlob(e,a,l,u);return new o({image:URL.createObjectURL(d),georeference:t,opacity:n})}catch(e){return a.getLogger(this).warn(`Unable to clip image; using full image instead: ${e.message}`,e),c()}return c()}updateWebDocument(e){if(_(e)||y(e)){let t={enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null,useVerticalOrder:this.useVerticalOrder,selectedVerticalOrder:this.selectedVerticalOrder};y(e)&&(t.floorVisibilityMode=this.floorVisibilityMode);let n=new g(t);e.widgets??=new h,e.widgets.floorFilter=n}}_computeFloors(e){if(this.filterMode===`single-floor`)this._computeSingleFloor(e);else if(this.filterMode===`base-floors`)return this.view?.type===`3d`?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();let t=[];return e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)}):e&&t.push(e.id),t}_computeBaseFloors(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[];e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let r=e?.facilityId,i=e?.verticalOrder,a=(e,t)=>{e===0&&n.push(t)};return t.forEach(e=>{let{id:t,facilityId:o,verticalOrder:s}=e;!r&&!n.includes(t)?a(s,t):o!==r&&!n.includes(t)&&(this.useVerticalOrder?s===i&&n.push(t):a(s,t))}),n}_computeBaseFloors3D(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[],r=e?.id.split(`--`)??[],i=r?.length>1&&r[0]===`all`;i?this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let a=e?.facilityId,o=e?.verticalOrder;return t.forEach(e=>{let{id:t,facilityId:r,verticalOrder:s}=e;if(!a&&!n.includes(t))n.push(t);else if(!n.includes(t)){let{floorVisibilityMode:e,useVerticalOrder:c}=this,l=s<=o;r===a?e===`belowSelected`&&l&&n.push(t):(i||!c||e===`selectedOnly`&&s===o||e===`belowSelected`&&l)&&n.push(t)}}),n}_computeEmptyFloors(){return[]}async _setFilterLayers(){let{view:e}=this;if(e&&!this._isOverridden(`filterLayers`)){if(!_(e.map)&&!y(e.map))throw new i(`floorfilter:unsupported-map`,`Map must be a webmap or webscene`);{let t=e.map,n=t?.allLayers;if(n?.items?.length>0){let e={siteLayer:null,facilityLayer:null,levelLayer:null},r=t.floorInfo?.siteLayer?.layerId,i=t.floorInfo?.facilityLayer?.layerId,a=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!i||!a)return;let s=n.items.filter(e=>e.type===`feature`||e.type===`scene`),c=n.items.filter(e=>e.type===`map-image`);if(c?.length>0&&o){await Promise.all(c.map(e=>e.load()));let n=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,s=t.floorInfo?.levelLayer?.sublayerId;c.forEach(t=>{let c=t.id,l=t?.allSublayers,u=l?.items;(c===r||c===i||c===a)&&u?.length>0&&l.items.forEach(t=>{let i=t.id;c===r&&i===n?e.siteLayer=t:i===o?e.facilityLayer=t:i===s&&(e.levelLayer=t)})})}s?.length>0&&s.forEach(t=>{let n=t.id;n===r?e.siteLayer=t:n===i?e.facilityLayer=t:n===a&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getAttachments(e,t){let{view:n}=this;if(_(n?.map)){let{facilityIdField:r}=n.map.floorInfo?.levelLayer??{};if(e&&n.type===`2d`&&t?.length>0&&e.capabilities.data.supportsAttachment)return e.queryAttachments({returnMetadata:!0,where:`${r} = '${t}'`})}return{}}async _getFilterFeatures(){if(this._isOverridden(`filterFeatures`))return this.filterFeatures;let[e,t,n]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:n}}async _getSites(){let e={sitesInfo:[]},{filterLayers:t,view:n}=this,r=n?.map,{siteLayer:i}=t;if(!i||!r?.floorInfo?.siteLayer)return e;let a=i.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in i&&i.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{siteIdField:o,nameField:s}=r.floorInfo.siteLayer,c=await i.queryFeatures(a);if(c?.features?.length>0){let t=c.features,n=i?.fieldsIndex.get(o)?.name||o,r=i?.fieldsIndex.get(s)?.name||s;n!=null&&r!=null&&t.forEach(t=>{let i=t.attributes,a=t.geometry,o=i[n],s=i[r];o&&s&&e.sitesInfo.push({id:o,name:s,geometry:a})})}return e}async _getFacilities(){let{filterLayers:e,view:t}=this,n=t?.map,{facilityLayer:r}=e,i={facilitiesInfo:[]};if(!r||!n?.floorInfo?.facilityLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in r&&r.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{facilityIdField:o,siteIdField:s,nameField:c}=n.floorInfo.facilityLayer,l=await r.queryFeatures(a);if(l?.features?.length>0){let e=l.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c;t&&n&&a&&e.forEach(e=>{let r=e.attributes,o=e.geometry,s=r[t],c=r[n],l=r[a];s&&l&&i.facilitiesInfo.push({id:s,siteId:c,name:l,geometry:o})})}return i}async _getLevels(){let{filterLayers:e,view:t}=this,n=t?.map,{levelLayer:r}=e,i={levelsInfo:[]};if(!r||!n?.floorInfo?.levelLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0;let{levelIdField:o,facilityIdField:s,longNameField:c,shortNameField:l,levelNumberField:u,verticalOrderField:d}=n.floorInfo.levelLayer,f=await r.queryFeatures(a);if(f?.features?.length>0){let e=f.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c,p=r?.fieldsIndex.get(l)?.name||l,m=r?.fieldsIndex.get(u)?.name||u,h=r?.fieldsIndex.get(d)?.name||d;t&&n&&a&&p&&m&&h&&e.forEach(e=>{let r=e.attributes,o=r[t],s=r[n],c=r[a],l=r[p],u=r[m],d=r[h];o&&s&&c&&l&&typeof u==`number`&&typeof d==`number`&&i.levelsInfo.push({id:o,facilityId:s,longName:c,shortName:l,levelNumber:u,verticalOrder:d})})}return i}async _imagePolygonToBlob(e,t,n,r){let{getImageData:a}=await import(`../../core/imageUtils.js`),o=await a(e),s=new OffscreenCanvas(n,r),c=s.getContext(`2d`);if(!c)throw new i(`floorfilter:floor-plan-overlay`,`Unable to obtain a rendering context from the canvas.`);let l=new Path2D;for(let e of t)if(!(e.length<3)){l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.closePath()}return c.save(),c.clip(l,`evenodd`),c.drawImage(o,0,0,n,r),c.restore(),await s.convertToBlob({type:`image/png`})}async _polygonToImagePixels(e,t){if(e?.type!==`control-points`)throw new i(`floorfilter:floor-plan-overlay`,"Expected a `ControlPointsGeoreference`.");let{default:n}=await import(`../../geometry/Point.js`);return{pixelRings:t.rings.map(r=>r.map(([r,a])=>{let o=new n({x:r,y:a,spatialReference:t.spatialReference}),s=e.toSource(o);if(!s)throw new i(`floorfilter:floor-plan-overlay`,`toSource() returned null; check spatial references and projectOperator.`);return{x:s.x,y:s.y}})),width:e.width,height:e.height}}_registerWidget(e){e?.registerComponent(this)}_unregisterWidget(e){e?.unregisterComponent(this)}_watchLayerVisibility(e){if(this.filterLayers?.levelLayer?.type===`feature`&&e){let t=this.filterLayers?.levelLayer;this.addHandles(s(()=>t.visible,t=>{e.visible=t},l))}}_watchMapLayers(e){this.removeHandles(`layers-handle`),e&&this.addHandles(e.allLayers.on(`after-remove`,t=>{if(t.item){let r=e.floorInfo,i=r?.siteLayer?.layerId??``,a=r?.facilityLayer?.layerId??``,s=r?.levelLayer?.layerId??``;(t.item.id===a||t.item.id===s||t.item.id===i)&&(this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{o(t),this.level=null,this.filterMenuOpen=!1,this._clearOverride(`filterLayers`),this._clearOverride(`filterFeatures`),this._setInitialViewState(e)}))}}),`layers-handle`)}_watchSearchResults(e){e?.on(`select-result-floor`,e=>{let t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();let t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels){a.getLogger(this).error(`Facilities and Levels are required for the Floor Filter widget`);return}if(this.hasMultipleSites||(this.filterMenuType=`facility`),this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||=e?.siteId||void 0,this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||=e?.siteId||void 0,this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||=t?.siteId||void 0,this.setFloors(e)}else if(this.site&&!this.facility&&!this.level)this.filterMenuType=`site`,this.setFloors(null);else{if(!e||!_(e)){this.setFloors(null);return}let t=e?.widgets?.floorFilter;if(!t){this.setFloors(null);return}t.site&&!this.site&&(this.site=t.site,this.filterMenuType=`facility`),this.setFloors(null)}if(this.filterLayers?.levelLayer?.type===`feature`&&this.filterLayers.levelLayer.capabilities.data.supportsAttachment&&this.mediaLayer==null){let{levelLayer:e}=this.filterLayers,{default:t}=await import(`../../layers/MediaLayer.js`);this.mediaLayer=new t({blendMode:`normal`,listMode:`hide`,maxScale:e.maxScale,minScale:e.minScale,spatialReference:this.view.spatialReference.clone(),title:`floor-filter-media-layer`,visible:e.visible}),this.overlaysByFacility=new Map,this.overlaysByLevel=new Map,this.view.map.add(this.mediaLayer),this.getOverlays(!0)}}catch(e){a.getLogger(this).error(`Couldn't retrieve sites, facilities, and levels`,e)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!_(e))return;await this.view?.when();let t=e?.widgets?.floorFilter;t&&(this._isOverridden(`enabled`)||(this.enabled=t.enabled),this._isOverridden(`longNames`)||(this.longNames=t.longNames),this._isOverridden(`minimized`)||(this.minimized=t.minimized),this._isOverridden(`pinnedLevels`)||(this.pinnedLevels=t.pinnedLevels),this._isOverridden(`site`)||(this.site=t.site),this._isOverridden(`facility`)||(this.facility=t.facility),this._isOverridden(`level`)||(this.level=t.level))}_updateMediaLayer(e){let{mediaLayer:t,overlaysByLevel:n}=this;if(t&&n&&e?.length){let r=t.source;r.elements.removeAll(),n.get(e)?.visible===!0&&r.elements.push(n.get(e)?.image)}}_computeViewAllModeFloors(e){let{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&this.filterMode===`base-floors`){let{level:n,facility:i}=this,a=[];t.levels.levelsInfo.forEach(e=>{let{id:t,facilityId:r}=e;i&&r===i?n&&t===n&&a.push(t):a.push(t)}),e.floorInfo.viewAllLevelIds=new r(a)}}};e([f({value:!1})],b.prototype,`enabled`,null),e([f({value:void 0})],b.prototype,`facility`,null),e([f({value:null})],b.prototype,`filterFeatures`,null),e([f({value:null})],b.prototype,`filterLayers`,null),e([f()],b.prototype,`filterMenuOpen`,void 0),e([f()],b.prototype,`filterMenuType`,void 0),e([f()],b.prototype,`filterMode`,void 0),e([f({readOnly:!0,value:`belowSelected`})],b.prototype,`floorVisibilityMode`,null),e([f()],b.prototype,`hasFacilities`,null),e([f()],b.prototype,`hasLevels`,null),e([f()],b.prototype,`hasMultipleSites`,null),e([f({readOnly:!0})],b.prototype,`isNormalMode`,null),e([f({value:void 0})],b.prototype,`level`,null),e([f({value:!1})],b.prototype,`longNames`,null),e([f()],b.prototype,`levelsExpanded`,void 0),e([f()],b.prototype,`mediaLayer`,void 0),e([f({value:!1})],b.prototype,`minimized`,null),e([f()],b.prototype,`overlaysByFacility`,void 0),e([f()],b.prototype,`overlaysByLevel`,void 0),e([f({value:!1})],b.prototype,`pinnedLevels`,null),e([f()],b.prototype,`searchTerm`,void 0),e([f({readOnly:!0})],b.prototype,`selectedVerticalOrder`,null),e([f({value:void 0})],b.prototype,`site`,null),e([f({readOnly:!0})],b.prototype,`state`,null),e([f({readOnly:!0,value:!1})],b.prototype,`useVerticalOrder`,null),e([f()],b.prototype,`view`,void 0),e([f()],b.prototype,`_viewHeightBreakpoint`,void 0),e([f()],b.prototype,`_viewWidthBreakpoint`,void 0),e([f()],b.prototype,`updateWebDocument`,null),b=e([p(`esri.widgets.FloorFilter.FloorFilterViewModel`)],b);const x=b;export{x as default};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{createTask as n}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import i from"../../core/Error.js";import a from"../../core/Logger.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{watch as s,initial as c,syncAndInitial as l}from"../../core/reactiveUtils.js";import{Milliseconds as u}from"../../core/time.js";import{isBlobProtocol as d}from"../../core/urlUtils.js";import{property as f,subclass as p}from"../../core/accessorSupport/decorators.js";import m from"../../geometry/Polygon.js";import h from"../../webdoc/Widgets.js";import g from"../../webdoc/widgets/FloorFilter.js";import{isWebMap as _}from"../../webmap/utils.js";import{GoTo as v}from"../support/GoTo.js";function y(e){return e.declaredClass===`esri.WebScene`}let b=class extends v(t){constructor(e){super(e),this.filterMenuOpen=!1,this.filterMenuType=`site`,this.filterMode=`base-floors`,this.levelsExpanded=!0,this.searchTerm=null,this.view=null,this._updateFloorFilterTask=null,this._viewHeightBreakpoint=null,this._viewWidthBreakpoint=null}initialize(){this.addHandles([s(()=>this.view?.map,e=>{this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{await this._updateFloorFilterFromMap(e),o(t),this._setInitialViewState(e)}),this._watchMapLayers(e)},c),s(()=>this.view,(e,t)=>{this._unregisterWidget(t),this._registerWidget(e),this._watchSearchResults(e)},l),s(()=>this.mediaLayer,e=>{this._watchLayerVisibility(e)},l),s(()=>this.view?.widthBreakpoint??null,e=>{this._viewWidthBreakpoint=e}),s(()=>this.view?.heightBreakpoint??null,e=>{this._viewHeightBreakpoint=e}),s(()=>this.facility,()=>void this.getOverlays()),s(()=>this.level,e=>this._updateMediaLayer(e))])}destroy(){if(this._unregisterWidget(this.view),this.mediaLayer&&this.view?.map.remove(this.mediaLayer),this.overlaysByLevel){for(let e of this.overlaysByLevel.values()){let t=e.image.image;d(t)&&URL.revokeObjectURL(t)}this.overlaysByFacility?.clear(),this.overlaysByLevel.clear()}this.view=null,this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null)}set enabled(e){this._callOverride(`enabled`,e)}set facility(e){if(e&&this._isOverridden(`facility`)){let t=this.getFacility(e);this.hasMultipleSites&&(this.site=t?.siteId||null)}this._callOverride(`facility`,e)}set filterFeatures(e){this._callOverride(`filterFeatures`,e)}set filterLayers(e){this._callOverride(`filterLayers`,e)}get floorVisibilityMode(){return this.view&&y(this.view?.map)?this.view.map.widgets?.floorFilter?.floorVisibilityMode??`belowSelected`:`belowSelected`}get hasFacilities(){return this.filterLayers?.facilityLayer!=null&&this.filterFeatures?.facilities?.facilitiesInfo?.length>0}get hasLevels(){return this.filterLayers?.levelLayer!=null&&this.filterFeatures?.levels?.levelsInfo?.length>0}get hasMultipleSites(){return this.filterLayers?.siteLayer!=null&&this.filterFeatures?.sites?.sitesInfo?.length>1}get isNormalMode(){let e=!0,t=this._viewWidthBreakpoint;return(this._viewHeightBreakpoint===`xsmall`||t===`xsmall`)&&(e=!1),e}set level(e){if(!e){this._callOverride(`level`,e),this.facility=null,this.site=null,this.setFloors(null);return}let t=null,n=null,r=e?.split(`--`);r?.length>1&&r[0]===`all`?(n=r[1],t={id:e,facilityId:n,shortName:null,longName:null,levelNumber:null,verticalOrder:null}):(t=this.getLevel(e),n=t?.facilityId??null),this.level===e&&!this.isNormalMode&&!this.levelsExpanded?this.getFacilityLevels(n)?.length>1&&(this.levelsExpanded=!0):(t&&this.hasFacilities&&this.hasLevels?(this.facility=n,this.hasMultipleSites&&(this.site=this.getFacility(n)?.siteId||null),this.setFloors(t)):this._isOverridden(`level`)&&(this.facility=null,this.site=null,this.hasMultipleSites&&(this.filterMenuType=`site`),this.setFloors(null)),this._callOverride(`level`,e))}set longNames(e){this._callOverride(`longNames`,e)}set minimized(e){this._callOverride(`minimized`,e)}set pinnedLevels(e){this._callOverride(`pinnedLevels`,e)}get selectedVerticalOrder(){return _(this.view?.map)?this.view.map.resourceInfo?.widgets?.floorFilter?.selectedVerticalOrder??null:null}set site(e){this._callOverride(`site`,e)}get state(){return this.view&&this.filterFeatures&&this.hasFacilities&&this.hasLevels?`ready`:this.view&&!this.filterFeatures?`loading`:`disabled`}get useVerticalOrder(){return this.view?.map==null?!1:_(this.view?.map)||y(this.view.map)?this.view.map.widgets?.floorFilter?.useVerticalOrder??!1:!1}filterFacilities(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),this.site&&(t=t.filter(e=>e.siteId===this.site)),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}filterSites(e){let t=e;return this.searchTerm&&(this.searchTerm=this.searchTerm.trim(),t=e.filter(e=>{let{name:t}=e;return t.toLowerCase().includes(this.searchTerm?.toLowerCase())})),t.sort((e,t)=>{let n=e.name,r=t.name;return n.localeCompare(r,void 0,{sensitivity:`base`})})}getBaseLevel(e){let t=this.filterFeatures?.levels?.levelsInfo,n=null;if(e){let{id:r}=e;if(t&&t.length>0&&(t.forEach(e=>{e.verticalOrder===0&&e.facilityId===r&&(n=e)}),!n)){let e=null;t.forEach(t=>{t.facilityId===r&&(e?(t.verticalOrder??0)>=0?e.verticalOrder!=null&&(e.verticalOrder<0||(t.verticalOrder??0)<e.verticalOrder)&&(e=t):e.verticalOrder!=null&&t.verticalOrder!=null&&e.verticalOrder<0&&t.verticalOrder>e.verticalOrder&&(e=t):e=t)}),e&&(n=e)}}return n}getFacility(e){return this.filterFeatures?.facilities?.facilitiesInfo?.find(t=>t.id===e)??null}getFacilityLevels(e){return!e||!this.filterFeatures?.levels?.levelsInfo?[]:this.filterFeatures.levels.levelsInfo.filter(t=>t.facilityId===e).sort((e,t)=>{let n=e.verticalOrder??0,r=t.verticalOrder??0;return n>r?-1:n===r?0:1})}getLevel(e){return this.filterFeatures?.levels?.levelsInfo?.find(t=>t.id===e)??null}async getOverlays(e=!1){let{facility:t,level:n,mediaLayer:i,overlaysByFacility:a,overlaysByLevel:o,view:s}=this;if(_(s?.map)&&i){if((i?.source).elements.removeAll(),t?.length&&(!a?.has(t)||e)){a?.set(t,new r);let e=s.map.floorInfo?.levelLayer?.layerId,n=s.map.findLayerById(e??``);if(!n||s.type!==`2d`)return;let i=await this._getAttachments(n,t),{default:c}=await import(`../../request.js`),l=Object.keys(i).map(async e=>{let r=i[e],s=r.find(e=>e.contentType===`application/json`);if(!s?.url)return;let l=new URL(s.url);n.gdbVersion?.length&&l.searchParams.set(`gdbVersion`,n.gdbVersion);let{data:u}=await c(l.toString(),{responseType:`json`}),d=r.find(e=>e.name===u.name),f=d?.url??``;if(f?.length>0){let e=new URL(f);e.searchParams.delete(`token`),n.gdbVersion?.length&&e.searchParams.set(`gdbVersion`,n.gdbVersion);let{default:r}=await import(`../../layers/support/ControlPointsGeoreference.js`),i=r.fromJSON(u.georeference),c=await this.toImageElement(e.toString(),i,u.opacity,u.clipImage,u.geometry);await c.load();let l={...u,attachments:[s,d],facilityId:t,image:c,source:JSON.stringify(u),url:e.toString()};o?.set(l.levelId,l),a?.get(t)?.push(l)}});await Promise.all(l)}this._updateMediaLayer(n)}}getSite(e){return this.filterFeatures?.sites?.sitesInfo?.find(t=>t.id===e)??null}async goTo(e){let{view:t}=this;if(!t||!e)return;let{geometry:n}=e;if(n?.extent){let e=e=>{this.callGoTo({target:e,options:{duration:u(1e3),easing:`quad-in-out-coast`}})};if(n.hasZ&&n.spatialReference?.vcsWkid!==t.spatialReference?.vcsWkid){let{projectIsLoaded:r,projectLoad:i,projectExecute:a}=await import(`../../geometry/operators/projectOperator.js`);r()||await i();let o=a(n.extent,t.spatialReference.clone(),{zConversionDisabled:!0});o&&e(o)}else e(n.extent)}}setFloors(e){let{view:t}=this;t&&(t?.map?.allLayers?.forEach(e=>{e.type===`feature`&&this._computeViewAllModeFloors(e)}),t.floors=new r(this._computeFloors(e)))}async toImageElement(e,t,n,r,i){let{default:o}=await import(`../../layers/support/ImageElement.js`),{facility:s}=this,c=()=>new o({image:e,georeference:t,opacity:n});if(r)try{let r=i?m.fromJSON(i):this.getFacility(s)?.geometry;if(r==null)return c();let{pixelRings:a,width:l,height:u}=await this._polygonToImagePixels(t,r),d=await this._imagePolygonToBlob(e,a,l,u);return new o({image:URL.createObjectURL(d),georeference:t,opacity:n})}catch(e){return a.getLogger(this).warn(`Unable to clip image; using full image instead: ${e.message}`,e),c()}return c()}updateWebDocument(e){if(_(e)||y(e)){let t={enabled:this.enabled,longNames:this.longNames,minimized:this.minimized,pinnedLevels:this.pinnedLevels,site:this.site??null,facility:this.facility??null,level:this.level??null,useVerticalOrder:this.useVerticalOrder,selectedVerticalOrder:this.selectedVerticalOrder};y(e)&&(t.floorVisibilityMode=this.floorVisibilityMode);let n=new g(t);e.widgets??=new h,e.widgets.floorFilter=n}}_computeFloors(e){if(this.filterMode===`single-floor`)this._computeSingleFloor(e);else if(this.filterMode===`base-floors`)return this.view?.type===`3d`?this._computeBaseFloors3D(e):this._computeBaseFloors(e);return this._computeEmptyFloors()}_computeSingleFloor(e){if(!e)return this._computeEmptyFloors();let t=[];return e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&t.push(e.id)}):e&&t.push(e.id),t}_computeBaseFloors(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[];e?.id===`all`?this.getFacilityLevels(e.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let r=e?.facilityId,i=e?.verticalOrder,a=(e,t)=>{e===0&&n.push(t)};return t.forEach(e=>{let{id:t,facilityId:o,verticalOrder:s}=e;!r&&!n.includes(t)?a(s,t):o!==r&&!n.includes(t)&&(this.useVerticalOrder?s===i&&n.push(t):a(s,t))}),n}_computeBaseFloors3D(e){let t=this.filterFeatures?.levels?.levelsInfo;if(!t?.length)return this._computeEmptyFloors();let n=[],r=e?.id.split(`--`)??[],i=r?.length>1&&r[0]===`all`;i?this.getFacilityLevels(e?.facilityId).forEach(e=>{e.id&&n.push(e.id)}):e&&n.push(e.id);let a=e?.facilityId,o=e?.verticalOrder;return t.forEach(e=>{let{id:t,facilityId:r,verticalOrder:s}=e;if(!a&&!n.includes(t))n.push(t);else if(!n.includes(t)){let{floorVisibilityMode:e,useVerticalOrder:c}=this,l=s<=o;r===a?e===`belowSelected`&&l&&n.push(t):(i||!c||e===`selectedOnly`&&s===o||e===`belowSelected`&&l)&&n.push(t)}}),n}_computeEmptyFloors(){return[]}async _setFilterLayers(){let{view:e}=this;if(e&&!this._isOverridden(`filterLayers`)){if(!_(e.map)&&!y(e.map))throw new i(`floorfilter:unsupported-map`,`Map must be a webmap or webscene`);{let t=e.map,n=t?.allLayers;if(n?.items?.length>0){let e={siteLayer:null,facilityLayer:null,levelLayer:null},r=t.floorInfo?.siteLayer?.layerId,i=t.floorInfo?.facilityLayer?.layerId,a=t.floorInfo?.levelLayer?.layerId,o=t.floorInfo?.siteLayer?.sublayerId||t.floorInfo?.facilityLayer?.sublayerId||t.floorInfo?.levelLayer?.sublayerId;if(!i||!a)return;let s=n.items.filter(e=>e.type===`feature`||e.type===`scene`),c=n.items.filter(e=>e.type===`map-image`);if(c?.length>0&&o){await Promise.all(c.map(e=>e.load()));let n=t.floorInfo?.siteLayer?.sublayerId,o=t.floorInfo?.facilityLayer?.sublayerId,s=t.floorInfo?.levelLayer?.sublayerId;c.forEach(t=>{let c=t.id,l=t?.allSublayers,u=l?.items;(c===r||c===i||c===a)&&u?.length>0&&l.items.forEach(t=>{let i=t.id;c===r&&i===n?e.siteLayer=t:i===o?e.facilityLayer=t:i===s&&(e.levelLayer=t)})})}s?.length>0&&s.forEach(t=>{let n=t.id;n===r?e.siteLayer=t:n===i?e.facilityLayer=t:n===a&&(e.levelLayer=t)}),this.filterLayers=e}}}}async _getAttachments(e,t){let{view:n}=this;if(_(n?.map)){let{facilityIdField:r}=n.map.floorInfo?.levelLayer??{};if(e&&n.type===`2d`&&t?.length>0&&e.capabilities.data.supportsAttachment)return e.queryAttachments({returnMetadata:!0,where:`${r} = '${t}'`})}return{}}async _getFilterFeatures(){if(this._isOverridden(`filterFeatures`))return this.filterFeatures;let[e,t,n]=await Promise.all([this._getSites(),this._getFacilities(),this._getLevels()]);return{sites:e,facilities:t,levels:n}}async _getSites(){let e={sitesInfo:[]},{filterLayers:t,view:n}=this,r=n?.map,{siteLayer:i}=t;if(!i||!r?.floorInfo?.siteLayer)return e;let a=i.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in i&&i.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{siteIdField:o,nameField:s}=r.floorInfo.siteLayer,c=await x(i,a);if(c.features.length>0){let t=c.features,n=i?.fieldsIndex.get(o)?.name||o,r=i?.fieldsIndex.get(s)?.name||s;n!=null&&r!=null&&t.forEach(t=>{let i=t.attributes,a=t.geometry,o=i[n],s=i[r];o&&s&&e.sitesInfo.push({id:o,name:s,geometry:a})})}return e}async _getFacilities(){let{filterLayers:e,view:t}=this,n=t?.map,{facilityLayer:r}=e,i={facilitiesInfo:[]};if(!r||!n?.floorInfo?.facilityLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0,`type`in r&&r.type===`scene`&&(a.multipatchOption=`xyFootprint`);let{facilityIdField:o,siteIdField:s,nameField:c}=n.floorInfo.facilityLayer,l=await x(r,a);if(l.features.length>0){let e=l.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c;t&&n&&a&&e.forEach(e=>{let r=e.attributes,o=e.geometry,s=r[t],c=r[n],l=r[a];s&&l&&i.facilitiesInfo.push({id:s,siteId:c,name:l,geometry:o})})}return i}async _getLevels(){let{filterLayers:e,view:t}=this,n=t?.map,{levelLayer:r}=e,i={levelsInfo:[]};if(!r||!n?.floorInfo?.levelLayer)return i;let a=r.createQuery();a.returnGeometry=!0,a.outFields=[`*`],a.returnZ=!0;let{levelIdField:o,facilityIdField:s,longNameField:c,shortNameField:l,levelNumberField:u,verticalOrderField:d}=n.floorInfo.levelLayer,f=await x(r,a);if(f.features.length>0){let e=f.features,t=r?.fieldsIndex.get(o)?.name||o,n=r?.fieldsIndex.get(s)?.name||s,a=r?.fieldsIndex.get(c)?.name||c,p=r?.fieldsIndex.get(l)?.name||l,m=r?.fieldsIndex.get(u)?.name||u,h=r?.fieldsIndex.get(d)?.name||d;t&&n&&a&&p&&m&&h&&e.forEach(e=>{let r=e.attributes,o=r[t],s=r[n],c=r[a],l=r[p],u=r[m],d=r[h];o&&s&&c&&l&&typeof u==`number`&&typeof d==`number`&&i.levelsInfo.push({id:o,facilityId:s,longName:c,shortName:l,levelNumber:u,verticalOrder:d})})}return i}async _imagePolygonToBlob(e,t,n,r){let{getImageData:a}=await import(`../../core/imageUtils.js`),o=await a(e),s=new OffscreenCanvas(n,r),c=s.getContext(`2d`);if(!c)throw new i(`floorfilter:floor-plan-overlay`,`Unable to obtain a rendering context from the canvas.`);let l=new Path2D;for(let e of t)if(!(e.length<3)){l.moveTo(e[0].x,e[0].y);for(let t=1;t<e.length;t++)l.lineTo(e[t].x,e[t].y);l.closePath()}return c.save(),c.clip(l,`evenodd`),c.drawImage(o,0,0,n,r),c.restore(),await s.convertToBlob({type:`image/png`})}async _polygonToImagePixels(e,t){if(e?.type!==`control-points`)throw new i(`floorfilter:floor-plan-overlay`,"Expected a `ControlPointsGeoreference`.");let{default:n}=await import(`../../geometry/Point.js`);return{pixelRings:t.rings.map(r=>r.map(([r,a])=>{let o=new n({x:r,y:a,spatialReference:t.spatialReference}),s=e.toSource(o);if(!s)throw new i(`floorfilter:floor-plan-overlay`,`toSource() returned null; check spatial references and projectOperator.`);return{x:s.x,y:s.y}})),width:e.width,height:e.height}}_registerWidget(e){e?.registerComponent(this)}_unregisterWidget(e){e?.unregisterComponent(this)}_watchLayerVisibility(e){if(this.filterLayers?.levelLayer?.type===`feature`&&e){let t=this.filterLayers?.levelLayer;this.addHandles(s(()=>t.visible,t=>{e.visible=t},l))}}_watchMapLayers(e){this.removeHandles(`layers-handle`),e&&this.addHandles(e.allLayers.on(`after-remove`,t=>{if(t.item){let r=e.floorInfo,i=r?.siteLayer?.layerId??``,a=r?.facilityLayer?.layerId??``,s=r?.levelLayer?.layerId??``;(t.item.id===a||t.item.id===s||t.item.id===i)&&(this._updateFloorFilterTask!=null&&(this._updateFloorFilterTask.abort(),this._updateFloorFilterTask=null),this._updateFloorFilterTask=n(async t=>{o(t),this.level=null,this.filterMenuOpen=!1,this._clearOverride(`filterLayers`),this._clearOverride(`filterFeatures`),this._setInitialViewState(e)}))}}),`layers-handle`)}_watchSearchResults(e){e?.on(`select-result-floor`,e=>{let t=this.getLevel(e);t&&this.level!==e&&(this.level=e,this.setFloors(t))})}async _setInitialViewState(e){if(this.view)try{await this.view.when(),await this._setFilterLayers();let t=await this._getFilterFeatures();if(!t)return;if(this.filterFeatures=t,!this.hasFacilities||!this.hasLevels){a.getLogger(this).error(`Facilities and Levels are required for the Floor Filter widget`);return}if(this.hasMultipleSites||(this.filterMenuType=`facility`),this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getLevel(this.level);this.site||=e?.siteId||void 0,this.setFloors(t)}else if(this.facility&&!this.level){this.filterMenuType=`facility`;let e=this.getFacility(this.facility),t=this.getBaseLevel(e);this.site||=e?.siteId||void 0,this.level=t?.id||void 0,this.setFloors(t)}else if(!this.facility&&this.level){this.filterMenuType=`facility`;let e=this.getLevel(this.level),t=this.getFacility(e?.facilityId);this.facility=t?.id||void 0,this.site||=t?.siteId||void 0,this.setFloors(e)}else if(this.site&&!this.facility&&!this.level)this.filterMenuType=`site`,this.setFloors(null);else{if(!e||!_(e)){this.setFloors(null);return}let t=e?.widgets?.floorFilter;if(!t){this.setFloors(null);return}t.site&&!this.site&&(this.site=t.site,this.filterMenuType=`facility`),this.setFloors(null)}if(this.filterLayers?.levelLayer?.type===`feature`&&this.filterLayers.levelLayer.capabilities.data.supportsAttachment&&this.mediaLayer==null){let{levelLayer:e}=this.filterLayers,{default:t}=await import(`../../layers/MediaLayer.js`);this.mediaLayer=new t({blendMode:`normal`,listMode:`hide`,maxScale:e.maxScale,minScale:e.minScale,spatialReference:this.view.spatialReference.clone(),title:`floor-filter-media-layer`,visible:e.visible}),this.mediaLayer.persistenceEnabled=!1,this.overlaysByFacility=new Map,this.overlaysByLevel=new Map;let n=e.parent?.type===`group`,r=e.parent,i=(n?r.layers:this.view.map.layers).indexOf(e);n?i>-1?r.add(this.mediaLayer,i+1):r.add(this.mediaLayer):i>-1?this.view.map.add(this.mediaLayer,i+1):this.view.map.add(this.mediaLayer),this.getOverlays(!0)}}catch(e){a.getLogger(this).error(`Couldn't retrieve sites, facilities, and levels`,e)}}_callOverride(e,t){this._override(e,t)}async _updateFloorFilterFromMap(e){if(!e||!_(e))return;await this.view?.when();let t=e?.widgets?.floorFilter;t&&(this._isOverridden(`enabled`)||(this.enabled=t.enabled),this._isOverridden(`longNames`)||(this.longNames=t.longNames),this._isOverridden(`minimized`)||(this.minimized=t.minimized),this._isOverridden(`pinnedLevels`)||(this.pinnedLevels=t.pinnedLevels),this._isOverridden(`site`)||(this.site=t.site),this._isOverridden(`facility`)||(this.facility=t.facility),this._isOverridden(`level`)||(this.level=t.level))}_updateMediaLayer(e){let{mediaLayer:t,overlaysByLevel:n}=this;if(t&&n&&e?.length){let r=t.source;r.elements.removeAll(),n.get(e)?.visible===!0&&r.elements.push(n.get(e)?.image)}}_computeViewAllModeFloors(e){let{filterFeatures:t}=this;if(e.floorInfo?.viewAllMode&&this.hasLevels&&this.hasFacilities&&this.filterMode===`base-floors`){let{level:n,facility:i}=this,a=[];t.levels.levelsInfo.forEach(e=>{let{id:t,facilityId:r}=e;i&&r===i?n&&t===n&&a.push(t):a.push(t)}),e.floorInfo.viewAllLevelIds=new r(a)}}};e([f({value:!1})],b.prototype,`enabled`,null),e([f({value:void 0})],b.prototype,`facility`,null),e([f({value:null})],b.prototype,`filterFeatures`,null),e([f({value:null})],b.prototype,`filterLayers`,null),e([f()],b.prototype,`filterMenuOpen`,void 0),e([f()],b.prototype,`filterMenuType`,void 0),e([f()],b.prototype,`filterMode`,void 0),e([f({readOnly:!0,value:`belowSelected`})],b.prototype,`floorVisibilityMode`,null),e([f()],b.prototype,`hasFacilities`,null),e([f()],b.prototype,`hasLevels`,null),e([f()],b.prototype,`hasMultipleSites`,null),e([f({readOnly:!0})],b.prototype,`isNormalMode`,null),e([f({value:void 0})],b.prototype,`level`,null),e([f({value:!1})],b.prototype,`longNames`,null),e([f()],b.prototype,`levelsExpanded`,void 0),e([f()],b.prototype,`mediaLayer`,void 0),e([f({value:!1})],b.prototype,`minimized`,null),e([f()],b.prototype,`overlaysByFacility`,void 0),e([f()],b.prototype,`overlaysByLevel`,void 0),e([f({value:!1})],b.prototype,`pinnedLevels`,null),e([f()],b.prototype,`searchTerm`,void 0),e([f({readOnly:!0})],b.prototype,`selectedVerticalOrder`,null),e([f({value:void 0})],b.prototype,`site`,null),e([f({readOnly:!0})],b.prototype,`state`,null),e([f({readOnly:!0,value:!1})],b.prototype,`useVerticalOrder`,null),e([f()],b.prototype,`view`,void 0),e([f()],b.prototype,`_viewHeightBreakpoint`,void 0),e([f()],b.prototype,`_viewWidthBreakpoint`,void 0),e([f()],b.prototype,`updateWebDocument`,null),b=e([p(`esri.widgets.FloorFilter.FloorFilterViewModel`)],b);async function x(e,t,n){let r={features:[]};await e.load();let i=(e.type===`sublayer`?e.sourceJSON?.maxRecordCount:e.capabilities.query.maxRecordCount)||2e3,a=async()=>{let n=t.clone();return await e.queryObjectIds(n,void 0)},o=async n=>{let r=t.clone();r.where=null,r.objectIds=n.objectIds,n.features=(await e.queryFeatures(r,void 0))?.features??null},s=await a(),c=i,l=[],u=[];for(let e=0,t=s.length;e<t;e+=c){let t=s.slice(e,e+c);t.length>0&&l.push({objectIds:t,features:null})}for(let e=0,t=l.length;e<t;e+=3){let t=l.slice(e,e+3);t.length>0&&u.push({pages:t})}for await(let e of u){let t=[];for(let n of e.pages)t.push(o(n));t.length>0&&await Promise.all(t)}for(let e of l)e.features?.length&&r.features.push(...e.features);return r}const S=b;export{S as default};